1import{u as e,T as t,z as a,q as n,h as r,k as i,w as o}from"./2c1ab0fe.DlNazk3M.js";import{bK as l,b as s,ab as c,S as m,j as d,B as u,v as p,bL as b,k as y,bM as g,bN as f,aa as h,bO as v,af as k,M as S}from"./164ad2e3.CR6m0m--.js";import{c as I,I as j,b9 as x,bb as E}from"./4b4bc88f.DJ4vpQqJ.js";import{u as _}from"./f5a7bb50.D3PnmI6I.js";import{U as w}from"./5c5c2e96.BzutapeJ.js";import{u as z}from"./9f047e05.lZ3NAtFn.js";import{u as C,S as P}from"./71ae3d5c.0c8Rx8xO.js";import{S as L}from"./f3e117aa.FuaakSB0.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";function B({progressing:t,onClick:a,cartEmpty:n,inlineSize:r}){const{i18n:i,embed:o}=I(),l=n&&!j(o?.embedder);return e(u,{variant:"primary",disabled:t,loading:t,onClick:a,inlineSize:r,children:l?i.translate("stock.return_to_store_label"):i.translate("stock.continue_cta_label")})}function M({progressing:t,onSecondaryClick:a}){const{i18n:n,url:r,observability:i}=I();return e(u,{onClick:async()=>{try{await a()}catch(e){i.leaveErrorBreadcrumb("Error negotiating before returning to cart",{error:e})}finally{window.location.replace(r.cart())}},variant:"plain",disabled:t,children:e(m,{direction:"inline",gap:"small-200",alignItems:"center",children:e(d,{children:n.translate("general.back_to_cart")})})})}function q(t){const{shop:a,embed:n}=I(),{isAppLayout:r}=l(),i=j(n?.embedder);if(!a.hasStorefront&&t.cartEmpty&&!i)return null;const{primary:o,secondary:m}=function(t,a,n,r){return t?{primary:a.cartEmpty&&n&&!r?null:e(B,{...a,inlineSize:r?"fill":void 0}),secondary:a.cartEmpty||r||n&&!a.cartEmpty?null:e(M,{...a})}:t||a.cartEmpty?{}:{primary:e(B,{...a,inlineSize:r?"fill":void 0})}}(a.hasStorefront,t,r,i);return e(c,{alignItems:"center",alignContent:"center",gridTemplateRows:"minmax(auto, max-content)",gridAutoRows:"minmax(auto, max-content)",gap:"large-300",...i?{gridTemplateColumns:"1fr",inlineSize:"100%"}:{gridTemplateColumns:"@media (inline-size >= extraSmall) 'minmax(auto, max-content) minmax(auto, max-content)', none",justifyContent:"@media (inline-size >= extraSmall) end, ''",justifyItems:"@media (inline-size >= extraSmall) end, ''"},children:[e(s,{display:"@media (inline-size >= extraSmall) auto, none",children:m}),o,e(s,{display:"@media (inline-size >= extraSmall) none, auto",inlineAlignment:"center",children:m})]})}function D({lineItems:i,showLineItems:o=!0,cartEmpty:l,type:s,subtitle:c}){const{observability:u,router:k,embed:S,checkout:{negotiator:_}}=I(),{value:B}=_.current.fields.merchandiseLines,M=x("merchandiseLines").value,{progress:D,progressing:O}=p(),T=_.parts.merchandiseLines,U=b(),{currentDetour:A}=y().value,N=t(()=>B?.lines??[],[B]),[G,J]=a(M);z("stock_problems"),C({stage:G?P.Loading:P.Complete,id:"StockProblems"});const R=l&&j(S?.embedder),Y=n(e=>{const t=T.value;T.value=t.filter(({stableId:t})=>!e.includes(t))},[T]),H=n(()=>{E(S,w)},[S]),K=t(()=>N.reduce((e,t)=>({...e,[t.stableId]:t}),{}),[N]),Q=n(({removeUnavailableMerchandise:e=!1}={})=>{const t=T.value,a=t.flatMap(t=>{const a=K[t.stableId];return!e||a&&0!==a.quantity?a&&0!==a.quantity?t.quantity===a.quantity&&t.totalPrice===a.totalPrice?[t]:[{...t,quantity:a.quantity,totalPrice:a.totalPrice}]:[t]:[]});a.length===t.length&&a.every((e,a)=>e===t[a])||(T.value=a)},[K,T]),F=n(async()=>{const e=i.filter(({problem:e})=>g(e.type)).map(({line:e})=>e.stableId);e.length&&Y(e),Q({removeUnavailableMerchandise:!0}),u.log("stock_problems_actions_submitted","Stock problems actions submitted",{unshippableMerchandiseIds:JSON.stringify(e),currentDetour:JSON.stringify(A),routerCurrentUrl:k.currentUrl.value.normalizedPath}),await D("checkout-stock-problems-submit")},[A,i,u,D,Y,k,Q]),V=f(),W=n(async()=>{await V(i)},[V,i]);return r(function(){Q()},[N,Q]),r(()=>{M||(J(!1),U.notify({checkout_in_progress:!1}))},[M,G,U]),e(v,{message:c,errorType:h.InventoryError,children:e(m,{gap:"large-200",children:[e(d,{children:c}),o&&i.length>0?e(L,{lineItems:i,loading:G,type:s}):null,e(q,{cartEmpty:l,progressing:O.value,onClick:R?H:F,onSecondaryClick:W})]})})}function O(){const{observability:t,checkout:{wallets:l,negotiator:s}}=I(),{canBeDismissed:c,...m}=_(),{progress:d}=p(),[u,b]=a(!0),y=i(()=>
1"GOOGLE_PAY"!==l.activeSession.value?.wallet),{checkoutProtocolModalEventSignal:g}=s.context,f=n(()=>{d("stock-problems-modal-close",()=>{b(!1)})},[d]),h=c?{blocking:!1,onHide:f}:{blocking:!0};return r(()=>()=>{g.value="none"},[g]),e(o,{when:y,children:[e(T,{state:m}),e(k,{section:"stock-problems",children:e(S,{id:"stock-problems-modal",open:u,heading:m.title,size:"large",onShow:()=>{t.leaveErrorBreadcrumb("Stock problems modal opened",{type:m.type}),g.value="stockProblems"},...h,children:e(D,{...m})})})]})}function T({state:e}){const{observability:t}=I();return r(()=>{0!==e.lineItems.length&&t.leaveErrorBreadcrumb("Displaying stock problems modal",{type:e.type,lineItems:e.lineItems.map(e=>({stableId:e.line.stableId,problem:e.problem.type}))})},[t,e.lineItems,e.type]),null}export{O 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.