1import{T as e,z as a,q as t,h as r,u as n}from"./2c1ab0fe.XVnTovwp.js";import{r as l,w as s,bK as i,ck as c,cl as o,bJ as u,bM as d,B as p,S as h,a0 as m,i as b,bN as f,a9 as _,H as g,f as y,h as k,aA as v,ax as U,ay as w,ar as I,az as j,au as x,as as q,av as P,aw as C,L as B,ae as L,aH as z,bz as S,aa as T}from"./164ad2e3.hrg71Gqs.js";import{C as A}from"./d6972375.B1OM7QZm.js";import{P as M,a as O,b as Q,d as H,c as $}from"./0a30a815.pKEqyakH.js";import{T as E}from"./7e8cd205.QvHjn0uW.js";import{a as N,b3 as D,aC as F,z as G,b5 as J}from"./f67abd2c.DYpmk7mw.js";import{U as K}from"./5c5c2e96.C1Y8KUBP.js";import{u as R}from"./9f047e05.B-A87NBT.js";import{u as V,S as W}from"./71ae3d5c.DAFuGUTz.js";import{u as X,N as Y}from"./f5a7bb50.BU9L2Qp8.js";import"./d0bb51ec.Bel_y502.js";import"./app.Bke-0Cv3.js";import"./60a453ce.Al5ISuVm.js";import"./e12db40c.D-IRYT_x.js";import"./9dba8418.C8BcPjk_.js";import"./f36e5f3f.BdiV7Rs6.js";import"./5fda1420.DrrBq7aV.js";function Z(){const{i18n:S,observability:T,shop:Z,url:te,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(),me=X(),be=me.type,{value:fe}=F();R("stock_problems");const _e=e(()=>ce?.lines??[],[ce]),[ge]=a(pe.peek()),ye=c(ge,ie),ke=o(ge,_e,ie),ve="draftOrder"===re.type,Ue=G(le?.embedder),{hasStorefront:we}=Z,{isAppLayout:Ie}=u(),je=me.cartEmpty,xe=je||!ge?0:ge.length,qe=we||xe>1,Pe=e(()=>_e.reduce((e,a)=>({...e,[a.stableId]:a}),{}),[_e]),Ce=t(({removeUnavailableMerchandise:e=!1}={})=>{const a=pe.value,t=a.flatMap(a=>{const t=Pe[a.stableId];return!e||t&&0!==t.quantity&&!ye.has(a.stableId)?!t||0===t.quantity||ye.has(a.stableId)||a.quantity===t.quantity&&a.totalPrice===t.totalPrice?[a]:[{...a,quantity:t.quantity,totalPrice:t.totalPrice}]:[]});t.length===a.length&&t.every((e,t)=>e===a[t])||(pe.value=t)},[Pe,pe,ye]),Be=t(()=>{J(le,K)},[le]),Le=t(()=>{Ce({removeUnavailableMerchandise:!0}),ue("stock-problems-submit")},[ue,Ce]),ze=d(),Se=t(async()=>{await ze(me.lineItems),window.location.replace(te.cart())},[ze,me.lineItems,te]);r(()=>{he.notify({checkout_in_progress:!1})},[he]),V({stage:oe?W.Loading:W.Complete,id:"StockProblems"}),r(()=>{let e=ne.currentUrl.value;return ne.currentUrl.subscribe(a=>{e!==a&&(e=a,Ce())})},[ne,Ce]);const Te=e(()=>be===I.Unfulfillable?z([...ye],fe):null,[fe,be,ye]),Ae=()=>
1{if(!me.showLineItems)return me.title;switch(be){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")}},Me=we&&(!Ie||!je)||Ue?n(M,{children:n(p,{variant:"primary",size:"large",inlineSize:"fill",onClick:je&&Ue?Be:Le,loading:oe,children:ve||je&&!Ue?S.translate("stock.return_to_store_label"):S.translate("general.continue_button_label")})}):null,Oe=!we||!de.route||Ie||je||Ue?null:n(O,{children:n(p,{onClick:async()=>{await Se()},variant:"plain",inlineSize:"fill",textDecoration:"none",children:n(h,{direction:"inline",gap:"small-200",alignItems:"center",children:[n(m,{type:"chevron-left",size:"small"}),n(b,{children:S.translate("general.back_to_cart")})]})})}),Qe=()=>
1{if(!me.showLineItems)return me.subtitle;switch(be){case I.Unavailable:return je?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 Te?S.translate("stock.unfulfillable_product.message",{delivery_method:Te,count:ke.length}):(T.error(new Y),S.translate("stock.unfulfillable_product.default_message",{count:ke.length}));default:return S.translate("stock.items_unavailable_notice")}};return n(L,{section:"stock-problems",children:[n(E,{children:Ae()}),n(f,{message:Qe(),errorType:_.InventoryError,children:n(h,{gap:"large-500",children:[n(A,{status:"warning",children:[n(g,{children:(()=>
1{if(!me.showLineItems)return me.title;switch(be){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(y,{color:"subdued",children:Qe()})]}),n(Q,{children:[ke.length>0&&me.showLineItems?n(H,{children:n(k,{children:n(v,{titleHidden:!0,border:"outer",spacing:"none",title:be===I.QuantityChange?S.translate("stock.quantity_update.page_title"):Ae(),children:[n(U,{blockPadding:"base",children:[n(w,{hidden:!0,children:S.translate("order_summary.product_image_label")}),n(w,{primary:!0,children:n(b,{type:"strong",children:S.translate("order_summary.description_label")})}),n(w,{hidden:be!==I.OutOfStock,children:n(b,{type:"strong",children:be===I.OutOfStock?S.translate("order_summary.quantity_label"):S.translate("order_summary.description_label")})})]}),n(j,{children:ke.map(({proposed:e,negotiated:a})=>{const t=a??e,r=e?.quantity,l=a?.quantity,{stableId:s,image:i,title:c}=t;return n(x,{spacing:"base",blockPadding:"base",children:[n(q,{children:n(P,{src:i?.one,srcSet:i?`${i.one} 1x, ${i.two} 2x, ${i.four} 4x`:void 0,alt:i?.altText})}),n(q,{primary:!0,children:n(C,{id:null,deferredAmount:t.deferredAmount,options:t.options,properties:t.properties,recurringTotal:t.recurringTotal,sellingPlan:t.sellingPlan,subtitle:t.subtitle,title:c,totalPrice:t.totalPrice})}),n(q,{noWrap:!0,children:null!=l&&l>0&&!ye.has(s)?n(h,{alignItems:"end",gap:"small-400",children:[n(ae,{quantity:l,previousQuantity:r??0}),qe?n(B,{id:`remove-${s}`,onClick:()=>(e=>{const a=pe.peek();pe.value=a.filter(({stableId:a,quantity:t})=>a!==e&&t>0),ue("stock-problems-remove-item")})(s),children:S.translate("stock.remove")}):null]}):n(ee,{merchandiseIssueType:be})})]},s)})})]})})}):null,Me||Oe?n($,{children:[Me,Oe]}):null]})]})})]})}function ee({merchandiseIssueType:e}){const{i18n:a}=N();return n(T,{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(m,{type:"disabled",tone:"critical",size:"small"}),n(S,{children:(()=>{switch(e){case I.Unfulfillable:case I.Unavailable:return a.translate("contextual_availability.unavailable_label");case I.UnpurchasableB2B:return a.translate("stock.unpurchasable_product.status_column_header");case I.Unpurchasable:return a.translate("stock.unpurchasable_product_generic.status_column_header");case I.Unshippable:return a.translate("stock.unshippable_product.status_column_header");default:return a.translate("stock.sold_out_label")}})()})]})}function ae({quantity:e,previousQuantity:a}){return n(h,{direction:"inline",gap:"small-200",children:[n(b,{color:"subdued",children:a}),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.