1import{T as e,x as a,s as t,m as r,u as n}from"./2c1ab0fe.GMbxnz74.js";import{i as l,R as s,bv as i,cc as c,cd as o,bu as u,bx as d,l as p,m as h,c as m,I as b,o as _,p as g,q as f,by as y,F as k,H as v,P as U,r as I,Y as w,a3 as x,ap as q,am as j,an as P,af as C,ao as L,aj as S,ag as T,ak as B,al as Q,L as z,s as A,V as O,at as $,c0 as E,J as F}from"./164ad2e3.BbIvMjRY.js";import{C as M}from"./611e718a.BXIcslXp.js";import{S as H,T as R,bh as V,W,a_ as D,bE as J,bF as N}from"./4c290a1e.C6TDJ9Fn.js";import{U as Y}from"./5c5c2e96.CVCPr6-x.js";import{u as G}from"./9f047e05.CCJUgz_L.js";import{u as K,S as X}from"./ca5e9c49.BT49yYQL.js";import{u as Z,N as ee}from"./f5a7bb50.W2ESKrfp.js";import"./app.CepNJbvh.js";import"./0a7dffce.DfUtZWCu.js";import"./5fda1420.KYpufQ--.js";import"./60a453ce.CkhHeRBc.js";import"./21cc90a2.DAzJmttM.js";import"./bb728e1c.iawBHR84.js";function ae(){const{i18n:E,observability:F,shop:ae,url:ne,source:le,router:se,embed:ie}=H(),{value:ce}=R().allViolations,{value:oe}=R().merchandiseLines,ue=V("merchandiseLines").value,{progress:de}=l(),{previousPage:pe}=s(),he=W().merchandiseLines,me=i(),be=Z(),_e=be.type,{value:ge}=D();G("stock_problems");const fe=e(()=>oe?.lines??[],[oe]),[ye]=a(he.peek()),ke=c(ye,ce),ve=o(ye,fe,ce),Ue="draftOrder"===le.type,Ie=J(ie?.embedder),{hasStorefront:we}=ae,{isAppLayout:xe}=u(),qe=be.cartEmpty,je=qe||!ye?0:ye.length,Pe=we||je>1,Ce=e(()=>fe.reduce((e,a)=>({...e,[a.stableId]:a}),{}),[fe]),Le=t(({removeUnavailableMerchandise:e=!1}={})=>{const a=he.value,t=a.flatMap(a=>{const t=Ce[a.stableId];return!e||t&&0!==t.quantity&&!ke.has(a.stableId)?!t||0===t.quantity||ke.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])||(he.value=t)},[Ce,he,ke]),Se=t(()=>{N(ie,Y)},[ie]),Te=t(()=>{Le({removeUnavailableMerchandise:!0}),de("stock-problems-submit")},[de,Le]),Be=d(),Qe=t(async()=>{await Be(be.lineItems),window.location.replace(ne.cart())},[Be,be.lineItems,ne]);r(()=>{me.notify({checkout_in_progress:!1})},[me]),K({stage:ue?X.Loading:X.Complete,id:"StockProblems"}),r(()=>{let e=se.currentUrl.value;return se.currentUrl.subscribe(a=>{e!==a&&(e=a,Le())})},[se,Le]);const ze=e(()=>_e===C.Unfulfillable?$([...ke],ge):null,[ge,_e,ke]),Ae=()=>{if(!be.showLineItems)return be.title;switch(_e){case C.Unavailable:return E.translate("contextual_availability.title",{count:ve.length});case C.UnpurchasableB2B:return E.translate("stock.unpurchasable_product.title");case C.Unpurchasable:return E.translate("stock.unpurchasable_product_generic.title");case C.QuantityChange:return E.translate("stock.quantity_update.title");case C.Unshippable:return E.translate("stock.unshippable_product.title");case C.Unfulfillable:return E.translate("stock.unfulfillable_product.title");default:return E.translate("stock.title")}},Oe=we&&(!xe||!qe)||Ie?n(h,{children:n(p,{variant:"primary",size:"large",inlineSize:"fill",onClick:qe&&Ie?Se:Te,loading:ue,children:Ue||qe&&!Ie?E.translate("stock.return_to_store_label"):E.translate("general.continue_button_label")})}):null,$e=!we||!pe.route||xe||qe||Ie?null:n(g,{children:n(p,{onClick:async()=>{await Qe()},variant:"plain",inlineSize:"fill",textDecoration:"none",children:n(m,{direction:"inline",gap:"small-200",alignItems:"center",children:[n(b,{type:"chevron-left",size:"small"}),n(_,{children:E.translate("general.back_to_cart")})]})})}),Ee=()=>{if(!be.showLineItems)return be.subtitle;switch(_e){case C.Unavailable:return qe?E.translate("contextual_availability.all_products_in_cart_unavailable",{count:ve.length}):E.translate("contextual_availability.products_not_available",{count:ve.length});case C.UnpurchasableB2B:return E.translate("stock.unpurchasable_product.message");case C.Unpurchasable:return E.translate("stock.unpurchasable_product_generic.message");case C.QuantityChange:return E.translate("stock.quantity_update.description");case C.Unshippable:return E.translate("stock.unshippable_product.message",{count:ve.length});case C.Unfulfillable:return ze?E.translate("stock.unfulfillable_product.message",{delivery_method:ze,count:ve.length}):(F.error(new ee),E.translate("stock.unfulfillable_product.default_message",{count:ve.length}));default:return E.translate("stock.items_unavailable_notice")}};return n(O,{section:"stock-problems",children:[n(f,{children:Ae()}),n(y,{message:Ee(),errorType:k.InventoryError,children:n(m,{gap:"large-500",children:[n(M,{status:"warning",children:[n(v,{children:(()=>
1{if(!be.showLineItems)return be.title;switch(_e){case C.UnpurchasableB2B:return E.translate("stock.unpurchasable_product.header");case C.Unpurchasable:return E.translate("stock.unpurchasable_product_generic.header");case C.Unshippable:return E.translate("stock.unshippable_product.header",{count:ve.length});case C.Unfulfillable:return E.translate("stock.unfulfillable_product.title");default:return Ae()}})()}),n(U,{color:"subdued",children:Ee()})]}),n(I,{children:[ve.length>0&&be.showLineItems?n(w,{children:n(x,{children:n(q,{titleHidden:!0,border:"outer",spacing:"none",title:_e===C.QuantityChange?E.translate("stock.quantity_update.page_title"):Ae(),children:[n(j,{blockPadding:"base",children:[n(P,{hidden:!0,children:E.translate("order_summary.product_image_label")}),n(P,{primary:!0,children:n(_,{type:"strong",children:E.translate("order_summary.description_label")})}),n(P,{hidden:_e!==C.OutOfStock,children:n(_,{type:"strong",children:_e===C.OutOfStock?E.translate("order_summary.quantity_label"):E.translate("order_summary.description_label")})})]}),n(L,{children:ve.map(({proposed:e,negotiated:a})=>{const t=a??e,r=e?.quantity,l=a?.quantity,{stableId:s,image:i,title:c}=t;return n(S,{spacing:"base",blockPadding:"base",children:[n(T,{children:n(B,{src:i?.one,srcSet:i?`${i.one} 1x, ${i.two} 2x, ${i.four} 4x`:void 0,alt:i?.altText})}),n(T,{primary:!0,children:n(Q,{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(T,{noWrap:!0,children:null!=l&&l>0&&!ke.has(s)?n(m,{alignItems:"end",gap:"small-400",children:[n(re,{quantity:l,previousQuantity:r??0}),Pe?n(z,{id:`remove-${s}`,onClick:()=>(e=>{const a=he.peek();he.value=a.filter(({stableId:a,quantity:t})=>a!==e&&t>0),de("stock-problems-remove-item")})(s),children:E.translate("stock.remove")}):null]}):n(te,{merchandiseIssueType:_e})})]},s)})})]})})}):null,Oe||$e?n(A,{children:[Oe,$e]}):null]})]})})]})}function te({merchandiseIssueType:e}){const{i18n:a}=H();return n(F,{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(E,{children:(()=>{switch(e){case C.Unfulfillable:case C.Unavailable:return a.translate("contextual_availability.unavailable_label");case C.UnpurchasableB2B:return a.translate("stock.unpurchasable_product.status_column_header");case C.Unpurchasable:return a.translate("stock.unpurchasable_product_generic.status_column_header");case C.Unshippable:return a.translate("stock.unshippable_product.status_column_header");default:return a.translate("stock.sold_out_label")}})()})]})}function re({quantity:e,previousQuantity:a}){return n(m,{direction:"inline",gap:"small-200",children:[n(_,{color:"subdued",children:a}),n(_,{color:"subdued",children:"â"}),n(_,{type:"strong",children:e})]})}export{ae 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.