1import{T as e,z as t,q as a,h as r,u as n}from"./2c1ab0fe.DlNazk3M.js";import{v as l,x as s,bL as i,cm as c,bK as o,bN as u,B as d,S as p,a1 as b,j as h,bO as m,aa as f,H as _,f as g,i as y,aB as k,ay as v,az as U,as as j,aA as I,av as w,at as x,aw as q,ax as P,L as B,af as C,cn as L,aL as T,bA as S,ab as z}from"./164ad2e3.CR6m0m--.js";import{C as A}from"./d6972375.pQ8OlggP.js";import{P as O,a as Q,b as M,d as $,c as D}from"./0a30a815.39p9N5f_.js";import{T as H}from"./7e8cd205.8iAG-o1l.js";import{c as E,b9 as N,aD as F,I as K,bb as R}from"./4b4bc88f.DJ4vpQqJ.js";import{U as V}from"./5c5c2e96.BzutapeJ.js";import{u as W}from"./9f047e05.lZ3NAtFn.js";import{u as Y,S as G}from"./71ae3d5c.0c8Rx8xO.js";import{u as J,N as X}from"./f5a7bb50.D3PnmI6I.js";import"./d0bb51ec.CruejZky.js";import"./app.DKKjpp8o.js";import"./f67abd2c.Dckgq3F6.js";import"./60a453ce.CV8OqWZ9.js";import"./e12db40c.C6hBKds9.js";import"./9dba8418.C1GTC4hZ.js";import"./f36e5f3f.BRLxGa0d.js";import"./5fda1420.C9a0YiCo.js";function Z(){const{i18n:S,observability:z,shop:Z,url:ae,source:re,router:ne,embed:le,checkout:{negotiator:se}}=E(),{value:ie}=se.current.fields.allViolations,{value:ce}=se.current.fields.merchandiseLines,oe=N("merchandiseLines").value,{progress:ue}=l(),{previousPage:de}=s(),pe=se.parts.merchandiseLines,be=i(),he=J(),me=he.type,{value:fe}=F();W("stock_problems");const _e=e(()=>ce?.lines??[],[ce]),[ge]=t(pe.peek()),ye=e(()=>L(ge,ie),[ge,ie]),ke=c(ge,_e,ie),ve="draftOrder"===re.type,Ue=K(le?.embedder),{hasStorefront:je}=Z,{isAppLayout:Ie}=o(),we=he.cartEmpty,xe=we||!ge?0:ge.length,qe=je||xe>1,Pe=e(()=>_e.reduce((e,t)=>({...e,[t.stableId]:t}),{}),[_e]),Be=a(({removeUnavailableMerchandise:e=!1}={})=>{const t=pe.value,a=t.flatMap(t=>{const a=Pe[t.stableId];return!e||a&&0!==a.quantity&&!ye.has(t.stableId)?!a||0===a.quantity||ye.has(t.stableId)||t.quantity===a.quantity&&t.totalPrice===a.totalPrice?[t]:[{...t,quantity:a.quantity,totalPrice:a.totalPrice}]:[]});a.length===t.length&&a.every((e,a)=>e===t[a])||(pe.value=a)},[Pe,pe,ye]),Ce=a(()=>{R(le,V)},[le]),Le=a(()=>{Be({removeUnavailableMerchandise:!0}),ue("stock-problems-submit")},[ue,Be]),Te=u(),Se=a(async()=>{await Te(he.lineItems),window.location.replace(ae.cart())},[Te,he.lineItems,ae]);r(()=>{be.notify({checkout_in_progress:!1})},[be]),Y({stage:oe?G.Loading:G.Complete,id:"StockProblems"}),r(()=>{let e=ne.currentUrl.value;return ne.currentUrl.subscribe(t=>{e!==t&&(e=t,Be())})},[ne,Be]);const ze=e(()=>me===j.Unfulfillable?T([...ye],fe):null,[fe,me,ye]),Ae=()=>{if(!he.showLineItems)return he.title;switch(me){case j.Unavailable:return S.translate("contextual_availability.title",{count:ke.length});case j.UnpurchasableB2B:return S.translate("stock.unpurchasable_product.title");case j.Unpurchasable:return S.translate("stock.unpurchasable_product_generic.title");case j.QuantityChange:return S.translate("stock.quantity_update.title");case j.Unshippable:return S.translate("stock.unshippable_product.title");case j.Unfulfillable:return S.translate("stock.unfulfillable_product.title");default:return S.translate("stock.title")}},Oe=je&&(!Ie||!we)||Ue?n(O,{children:n(d,{variant:"primary",size:"large",inlineSize:"fill",onClick:we&&Ue?Ce:Le,loading:oe,children:ve||we&&!Ue?S.translate("stock.return_to_store_label"):S.translate("general.continue_button_label")})}):null,Qe=!je||!de.route||Ie||we||Ue?null:n(Q,{children:n(d,{onClick:async()=>{await Se()},variant:"plain",inlineSize:"fill",textDecoration:"none",children:n(p,{direction:"inline",gap:"small-200",alignItems:"center",children:[n(b,{type:"chevron-left",size:"small"}),n(h,{children:S.translate("general.back_to_cart")})]})})}),Me=()=>{if(!he.showLineItems)return he.subtitle;switch(me){case j.Unavailable:return we?S.translate("contextual_availability.all_products_in_cart_unavailable",{count:ke.length}):S.translate("contextual_availability.products_not_available",{count:ke.length});case j.UnpurchasableB2B:return S.translate("stock.unpurchasable_product.message");case j.Unpurchasable:return S.translate("stock.unpurchasable_product_generic.message");case j.QuantityChange:return S.translate("stock.quantity_update.description");case j.Unshippable:return S.translate("stock.unshippable_product.message",{count:ke.length});case j.Unfulfillable:return ze?S.translate("stock.unfulfillable_product.message",{delivery_method:ze,count:ke.length}):(z.error(new X),S.translate("stock.unfulfillable_product.default_message",{count:ke.length}));default:return S.translate("stock.items_unavailable_notice")}};return n(C,{section:"stock-problems",children:[n(H,{children:Ae()}),n(m,{message:Me(),errorType:f.InventoryError,children:n(p,{gap:"large-500",children:[n(A,{status:"warning",children:[n(_,{children:(()=>
1{if(!he.showLineItems)return he.title;switch(me){case j.UnpurchasableB2B:return S.translate("stock.unpurchasable_product.header");case j.Unpurchasable:return S.translate("stock.unpurchasable_product_generic.header");case j.Unshippable:return S.translate("stock.unshippable_product.header",{count:ke.length});case j.Unfulfillable:return S.translate("stock.unfulfillable_product.title");default:return Ae()}})()}),n(g,{color:"subdued",children:Me()})]}),n(M,{children:[ke.length>0&&he.showLineItems?n($,{children:n(y,{children:n(k,{titleHidden:!0,border:"outer",spacing:"none",title:me===j.QuantityChange?S.translate("stock.quantity_update.page_title"):Ae(),children:[n(v,{blockPadding:"base",children:[n(U,{hidden:!0,children:S.translate("order_summary.product_image_label")}),n(U,{primary:!0,children:n(h,{type:"strong",children:S.translate("order_summary.description_label")})}),n(U,{hidden:me!==j.OutOfStock,children:n(h,{type:"strong",children:me===j.OutOfStock?S.translate("order_summary.quantity_label"):S.translate("order_summary.description_label")})})]}),n(I,{children:ke.map(({proposed:e,negotiated:t})=>{const a=t??e,r=e?.quantity,l=t?.quantity,{stableId:s,image:i,title:c}=a;return n(w,{spacing:"base",blockPadding:"base",children:[n(x,{children:n(q,{src:i?.one,srcSet:i?`${i.one} 1x, ${i.two} 2x, ${i.four} 4x`:void 0,alt:i?.altText})}),n(x,{primary:!0,children:n(P,{id:null,deferredAmount:a.deferredAmount,options:a.options,properties:a.properties,recurringTotal:a.recurringTotal,sellingPlan:a.sellingPlan,subtitle:a.subtitle,title:c,totalPrice:a.totalPrice})}),n(x,{noWrap:!0,children:null!=l&&l>0&&!ye.has(s)?n(p,{alignItems:"end",gap:"small-400",children:[n(te,{quantity:l,previousQuantity:r??0}),qe?n(B,{id:`remove-${s}`,onClick:()=>(e=>{const t=pe.peek();pe.value=t.filter(({stableId:t,quantity:a})=>t!==e&&a>0),ue("stock-problems-remove-item")})(s),children:S.translate("stock.remove")}):null]}):n(ee,{merchandiseIssueType:me})})]},s)})})]})})}):null,Oe||Qe?n(D,{children:[Oe,Qe]}):null]})]})})]})}function ee({merchandiseIssueType:e}){const{i18n:t}=E();return n(z,{gridAutoFlow:"column",gridAutoColumns:"minmax(auto, max-content)",gridTemplateColumns:"minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",gap:"small-400",alignItems:"center",alignContent:"center",children:[n(b,{type:"disabled",tone:"critical",size:"small"}),n(S,{children:(()=>{switch(e){case j.Unfulfillable:case j.Unavailable:return t.translate("contextual_availability.unavailable_label");case j.UnpurchasableB2B:return t.translate("stock.unpurchasable_product.status_column_header");case j.Unpurchasable:return t.translate("stock.unpurchasable_product_generic.status_column_header");case j.Unshippable:return t.translate("stock.unshippable_product.status_column_header");default:return t.translate("stock.sold_out_label")}})()})]})}function te({quantity:e,previousQuantity:t}){return n(p,{direction:"inline",gap:"small-200",children:[n(h,{color:"subdued",children:t}),n(h,{color:"subdued",children:"â"}),n(h,{type:"strong",children:e})]})}export{Z as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.