1import{T as e,z as t,q as a,h as r,u as n}from"./2c1ab0fe.Bywc2Brn.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 h,j as b,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 I,aA as j,av as w,at as x,aw as q,ax as C,L,af as P,cn as B,aL as T,bA as S,ab as z}from"./164ad2e3.Bn4mVc0u.js";import{C as A}from"./d6972375.CtWp7aWB.js";import{P as O,a as Q,b as $,d as H,c as M}from"./0a30a815.YsqvP3Rs.js";import{T as E}from"./7e8cd205.CAfOJ21-.js";import{c as N,b9 as D,aC as F,I as K,bb as R}from"./9dba8418.nSn06qNc.js";import{U as V}from"./5c5c2e96.D7SHoIgf.js";import{u as W}from"./9f047e05.yxRbfGZc.js";import{u as X,S as G}from"./71ae3d5c.BAoM4Tq1.js";import{u as J,N as Y}from"./f5a7bb50.CXNQeucx.js";import"./d0bb51ec.up41EQh6.js";import"./app.B7Ohb9rB.js";import"./f67abd2c.BiDTv4D9.js";import"./60a453ce.BI5dm7PK.js";import"./e12db40c.xtsrYBcz.js";import"./f36e5f3f.k6-O7u1m.js";import"./5fda1420.renPlTOa.js";function Z(){const{i18n:S,observability:z,shop:Z,url:ae,source:re,router:ne,embed:le,checkout:{negotiator:se}}=N(),{value:ie}=se.current.fields.allViolations,{value:ce}=se.current.fields.merchandiseLines,oe=D("merchandiseLines").value,{progress:ue}=l(),{previousPage:de}=s(),pe=se.parts.merchandiseLines,he=i(),be=J(),me=be.type,{value:fe}=F();W("stock_problems");const _e=e(()=>ce?.lines??[],[ce]),[ge]=t(pe.peek()),ye=e(()=>B(ge,ie),[ge,ie]),ke=c(ge,_e,ie),ve="draftOrder"===re.type,Ue=K(le?.embedder),{hasStorefront:Ie}=Z,{isAppLayout:je}=o(),we=be.cartEmpty,xe=we||!ge?0:ge.length,qe=Ie||xe>1,Ce=e(()=>_e.reduce((e,t)=>({...e,[t.stableId]:t}),{}),[_e]),Le=a(({removeUnavailableMerchandise:e=!1}={})=>{const t=pe.value,a=t.flatMap(t=>{const a=Ce[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)},[Ce,pe,ye]),Pe=a(()=>{R(le,V)},[le]),Be=a(()=>{Le({removeUnavailableMerchandise:!0}),ue("stock-problems-submit")},[ue,Le]),Te=u(),Se=a(async()=>{await Te(be.lineItems),window.location.replace(ae.cart())},[Te,be.lineItems,ae]);r(()=>{he.notify({checkout_in_progress:!1})},[he]),X({stage:oe?G.Loading:G.Complete,id:"StockProblems"}),r(()=>{let e=ne.currentUrl.value;return ne.currentUrl.subscribe(t=>{e!==t&&(e=t,Le())})},[ne,Le]);const ze=e(()=>me===I.Unfulfillable?T([...ye],fe):null,[fe,me,ye]),Ae=()=>{if(!be.showLineItems)return be.title;switch(me){case I.Unavailable:return S.translate("contextual_availability.title",{count:ke.length});case I.UnpurchasableB2B:return S.translate("stock.unpurchasable_product.title");case I.Unpurchasable:return S.translate("stock.unpurchasable_product_generic.title");case I.QuantityChange:return S.translate("stock.quantity_update.title");case I.Unshippable:return S.translate("stock.unshippable_product.title");case I.Unfulfillable:return S.translate("stock.unfulfillable_product.title");default:return S.translate("stock.title")}},Oe=Ie&&(!je||!we)||Ue?n(O,{children:n(d,{variant:"primary",size:"large",inlineSize:"fill",onClick:we&&Ue?Pe:Be,loading:oe,children:ve||we&&!Ue?S.translate("stock.return_to_store_label"):S.translate("general.continue_button_label")})}):null,Qe=!Ie||!de.route||je||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(h,{type:"chevron-left",size:"small"}),n(b,{children:S.translate("general.back_to_cart")})]})})}),$e=()=>{if(!be.showLineItems)return be.subtitle;switch(me){case I.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 I.UnpurchasableB2B:return S.translate("stock.unpurchasable_product.message");case I.Unpurchasable:return S.translate("stock.unpurchasable_product_generic.message");case I.QuantityChange:return S.translate("stock.quantity_update.description");case I.Unshippable:return S.translate("stock.unshippable_product.message",{count:ke.length});case I.Unfulfillable:return ze?S.translate("stock.unfulfillable_product.message",{delivery_method:ze,count:ke.length}):(z.error(new Y),S.translate("stock.unfulfillable_product.default_message",{count:ke.length}));default:return S.translate("stock.items_unavailable_notice")}};return n(P,{section:"stock-problems",children:[n(E,{children:Ae()}),n(m,{message:$e(),errorType:f.InventoryError,children:n(p,{gap:"large-500",children:[n(A,{status:"warning",children:[n(_,{children:(()=>
1{if(!be.showLineItems)return be.title;switch(me){case I.UnpurchasableB2B:return S.translate("stock.unpurchasable_product.header");case I.Unpurchasable:return S.translate("stock.unpurchasable_product_generic.header");case I.Unshippable:return S.translate("stock.unshippable_product.header",{count:ke.length});case I.Unfulfillable:return S.translate("stock.unfulfillable_product.title");default:return Ae()}})()}),n(g,{color:"subdued",children:$e()})]}),n($,{children:[ke.length>0&&be.showLineItems?n(H,{children:n(y,{children:n(k,{titleHidden:!0,border:"outer",spacing:"none",title:me===I.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(b,{type:"strong",children:S.translate("order_summary.description_label")})}),n(U,{hidden:me!==I.OutOfStock,children:n(b,{type:"strong",children:me===I.OutOfStock?S.translate("order_summary.quantity_label"):S.translate("order_summary.description_label")})})]}),n(j,{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(C,{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(L,{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(M,{children:[Oe,Qe]}):null]})]})})]})}function ee({merchandiseIssueType:e}){const{i18n:t}=N();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(h,{type:"disabled",tone:"critical",size:"small"}),n(S,{children:(()=>{switch(e){case I.Unfulfillable:case I.Unavailable:return t.translate("contextual_availability.unavailable_label");case I.UnpurchasableB2B:return t.translate("stock.unpurchasable_product.status_column_header");case I.Unpurchasable:return t.translate("stock.unpurchasable_product_generic.status_column_header");case I.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(b,{color:"subdued",children:t}),n(b,{color:"subdued",children:"â"}),n(b,{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.