1import{T,k as ue,q as v,h as j,u as e}from"./2c1ab0fe.DYQSH7bT.js";import{h as de,K as pe,br as he,M as me,c8 as be,c9 as ge,bq as fe,bt as _e,l as K,c as P,I as V,n as g,bu as ye,A as ke,H as ve,P as Pe,_ as Le,ak as Ue,ah as Ie,ai as w,aa as a,aj as Me,ae as Se,ab as A,af as Ce,ag as Te,L as we,N as Ae,ar as xe,bY as Oe,y as qe}from"./164ad2e3.BcELPLd1.js";import{C as Be}from"./611e718a.DaFvJTe3.js";import{P as Re,a as Ee,b as De,d as Fe,c as He}from"./a25deb9a.CAfvS0fR.js";import{T as Ne}from"./65f3d4da.CPQqj7Ry.js";import{O as Y,P as G,bb as Qe,Q as ze,aU as $e,bx as We,by as je}from"./4c290a1e.CvCmFIo_.js";import{U as Ke}from"./5c5c2e96.CcHFIXu5.js";import{u as Ge,S as J}from"./ca5e9c49.CRSUYPwQ.js";import{u as Je,N as Ve}from"./f5a7bb50.CrLvuR9a.js";import"./app.Bvc4uxd4.js";import"./60a453ce.BJZuodLH.js";import"./0a7dffce.BF-zuF6E.js";import"./bb728e1c.D4AahLMP.js";import"./f78726c8.CLlB5yjH.js";function mt(){const{i18n:t,observability:c,shop:x,url:O,source:X,router:L,embed:U}=Y(),{value:q}=G().allViolations,{value:B}=G().merchandiseLines,R=Qe("merchandiseLines").value,{progress:I}=de(),{previousPage:Z}=pe(),p=ze().merchandiseLines,E=he(),i=Je(),u=i.type,{value:D}=$e();me("stock_problems");const M=T(()=>B?.lines??[],[B]),[f]=ue(p.peek()),h=be(f,q),d=ge(f,M,q),ee=X.type==="draftOrder",_=We(U?.embedder),{hasStorefront:S}=x,{isAppLayout:F}=fe(),m=i.cartEmpty,te=m||!f?0:f.length,ae=S||te>1,H=T(()=>M.reduce((o,r)=>({...o,[r.stableId]:r}),{}),[M]),y=v(({removeUnavailableMerchandise:o=!1}={})=>{const r=p.value,n=r.flatMap(s=>{const l=H[s.stableId];return o&&(!l||l.quantity===0||h.has(s.stableId))?[]:!l||l.quantity===0||h.has(s.stableId)?[s]:s.quantity===l.quantity&&s.totalPrice===l.totalPrice?[s]:[{...s,quantity:l.quantity,totalPrice:l.totalPrice}]});n.length===r.length&&n.every((s,l)=>s===r[l])||(p.value=n)},[H,p,h]),re=v(()=>{je(U,Ke)},[U]),ne=v(()=>{y({removeUnavailableMerchandise:!0}),I("stock-problems-submit")},[I,y]),N=_e(),se=v(async()=>{await N(i.lineItems),window.location.replace(O.cart())},[N,i.lineItems,O]),le=o=>{const r=p.peek();p.value=r.filter(({stableId:n,quantity:s})=>n!==o&&s>0),I("stock-problems-remove-item")};j(()=>{E.notify({checkout_in_progress:!1})},[E]),Ge({stage:R?J.Loading:J.Complete,id:"StockProblems"}),j(()=>{let o=L.currentUrl.value;return L.currentUrl.subscribe(r=>{o!==r&&(o=r,y())})},[L,y]);const Q=T(()=>u===a.Unfulfillable?xe([...h],D):null,[D,u,h]),C=()=>{if(!i.showLineItems)return i.title;switch(u){case a.Unavailable:return t.translate("contextual_availability.title",{count:d.length});case a.UnpurchasableB2B:return t.translate("stock.unpurchasable_product.title");case a.Unpurchasable:return t.translate("stock.unpurchasable_product_generic.title");case a.QuantityChange:return t.translate("stock.quantity_update.title");case a.Unshippable:return t.translate("stock.unshippable_product.title");case a.Unfulfillable:return t.translate("stock.unfulfillable_product.title");default:return t.translate("stock.title")}},ie=()=>{if(!i.showLineItems)return i.title;switch(u){case a.UnpurchasableB2B:return t.translate("stock.unpurchasable_product.header");case a.Unpurchasable:return t.translate("stock.unpurchasable_product_generic.header");case a.Unshippable:return t.translate("stock.unshippable_product.header",{count:d.length});case a.Unfulfillable:return t.translate("stock.unfulfillable_product.title");default:return C()}},z=S&&!(F&&m)||_?e(Re,{children:e(K,{variant:"primary",size:"large",inlineSize:"fill",onClick:m&&_?re:ne,loading:R,children:ee||m&&!_?t.translate("stock.return_to_store_label"):t.translate("general.continue_button_label")})}):null,$=S&&Z.route&&!F&&!m&&!_?e(Ee,{children:e(K,{onClick:async()=>{await se()},variant:"plain",inlineSize:"fill",textDecoration:"none",children:e(P,{direction:"inline",gap:"small-200",alignItems:"center",children:[e(V,{type:"chevron-left",size:"small"}),e(g,{children:t.translate("general.back_to_cart")})]})})}):null,W=()=>{if(!i.showLineItems)return i.subtitle;switch(u){case a.Unavailable:return m?t.translate("contextual_availability.all_products_in_cart_unavailable",{count:d.length}):t.translate("contextual_availability.products_not_available",{count:d.length});case a.UnpurchasableB2B:return t.translate("stock.unpurchasable_product.message");case a.Unpurchasable:return t.translate("stock.unpurchasable_product_generic.message");case a.QuantityChange:return t.translate("stock.quantity_update.description");case a.Unshippable:return t.translate("stock.unshippable_product.message",{count:d.length});case a.Unfulfillable:return Q?t.translate("stock.unfulfillable_product.message",{delivery_method:Q,count:d.length}):(c.error(new Ve),t.translate("stock.unfulfillable_product.default_message",{count:d.length}));default:return t.translate("stock.items_unavailable_notice")}},oe=()=>u===a.QuantityChange?t.translate("stock.quantity_update.page_title"):C();return e(Ae,{section:"stock-problems",children:[e(Ne,{children:C()}),e(ye,{message:W(),errorType:ke.InventoryError,children:e(P,{gap:"large-500",children:[e(Be,{status:"warning",children:[e(ve,{children:ie()}),e(Pe,{color:"subdued",children:W()})]}),e(De,{children:[d.length>0&&i.showLineItems?e(Fe,{children:e(Le,{children:e(Ue,{titleHidden:!0,border:"outer",spacing:"none",title:oe(),children:[e(Ie,{blockPadding:"base",children:[e(w,{hidden:!0,children:t.translate("order_summary.product_image_label")}),e(w,{primary:!0,children:e(g,{type:"strong",children:t.translate("order_summary.description_label")})}),e(w,{hidden:u!==a.OutOfStock,children:e(g,{type:"strong",children:u===a.OutOfStock?t.translate("order_summary.quantity_label"):t.translate("order_summary.description_label")})})]}),e(Me,{children:d.map(({proposed:o,negotiated:r})=>{const n=r??o,s=o?.quantity,l=r?.quantity,{stableId:k,image:b,title:ce}=n;return e(Se,{spacing:"base",blockPadding:"base",children:[e(A,{children:e(Ce,{src:b?.one,srcSet:b?`${b.one} 1x, ${b.two} 2x, ${b.four} 4x`:void 0,alt:b?.altText})}),e(A,{primary:!0,children:e(Te,{id:null,deferredAmount:n.deferredAmount,options:n.options,properties:n.properties,recurringTotal:n.recurringTotal,sellingPlan:n.sellingPlan,subtitle:n.subtitle,title:ce,totalPrice:n.totalPrice})}),e(A,{noWrap:!0,children:l!=null&&l>0&&!h.has(k)?e(P,{alignItems:"end",gap:"small-400",children:[e(Xe,{quantity:l,previousQuantity:s??0}),ae?e(we,{id:`remove-${k}`,onClick:()=>le(k),children:t.translate("stock.remove")}):null]}):e(Ye,{merchandiseIssueType:u})})]},k)})})]})})}):null,z||$?e(He,{children:[z,$]}):null]})]})})]})}function Ye({merchandiseIssueType:t}){const{i18n:c}=Y();return e(qe,{gridAutoFlow:"column",gridAutoColumns:"minmax(auto, max-content)",gridTemplateColumns:"minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",gap:"small-400",alignItems:"center",alignContent:"center",children:[e(V,{type:"disabled",tone:"critical",size:"small"}),e(Oe,{children:(()=>{switch(t){case a.Unfulfillable:case a.Unavailable:return c.translate("contextual_availability.unavailable_label");case a.UnpurchasableB2B:return c.translate("stock.unpurchasable_product.status_column_header");case a.Unpurchasable:return c.translate("stock.unpurchasable_product_generic.status_column_header");case a.Unshippable:return c.translate("stock.unshippable_product.status_column_header");default:return c.translate("stock.sold_out_label")}})()})]})}function Xe({quantity:t,previousQuantity:c}){return e(P,{direction:"inline",gap:"small-200",children:[e(g,{color:"subdued",children:c}),e(g,{color:"subdued",children:"â"}),e(g,{type:"strong",children:t})]})}
1export{mt 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.