1import{u as n,T as I,k as R,q as h,h as k,f as Q,i as W}from"./esnext-vendor.BDPAaZdq.js";import{bw as K,B,F as V,c as F,o as q,l as N,h as U,bx as Y,e as $,R as X,by as Z,bz as ee,E as te,bA as ne,V as ae,bB as oe}from"./hydrate.B0xlt2dG.js";import{O as g,bv as L,P as re,ba as ie,Q as se,bw as le,aS as ce}from"./hooks-useReplaceShopPayInHistory.C8UL-mAH.js";import{u as de}from"./stock-problems-useStockProblemsState.C8oRqc0h.js";import{U as ue}from"./embed-deferred.BpEUhGVz.js";import{u as me,S as T}from"./hooks-usePostPurchase.BPY08f0g.js";import{S as pe}from"./StockProblems-StockProblemsLineItemList.Cyf0iJV_.js";import"./app.D1P6yWfp.js";import"./helpers-getNormalizedPaymentMethodName.B-mE5wnL.js";import"./shared-permissions.BaDWlj5_.js";import"./hooks-useShopPayExternalAppContext.DyGXtar4.js";function z({progressing:e,onClick:t,cartEmpty:o,inlineSize:a}){const{i18n:r,embed:d}=g(),s=o&&!L(d?.embedder);return n(N,{variant:"primary",disabled:e,loading:e,onClick:t,inlineSize:a,children:s?r.translate("stock.return_to_store_label"):r.translate("stock.continue_cta_label")})}function be({progressing:e,onSecondaryClick:t}){const{i18n:o,url:a,observability:r}=g();return n(N,{onClick:async()=>{try{await t()}catch(s){r.leaveErrorBreadcrumb("Error negotiating before returning to cart",{error:s})}finally{window.location.replace(a.cart())}},variant:"plain",disabled:e,children:n(F,{direction:"inline",gap:"small-200",alignItems:"center",children:n(q,{children:o.translate("general.back_to_cart")})})})}function he(e){const{shop:t,embed:o}=g(),{isAppLayout:a}=K(),r=L(o?.embedder);if(!t.hasStorefront&&e.cartEmpty&&!r)return null;const{primary:d,secondary:s}=ge(t.hasStorefront,e,a,r);return n(V,{alignItems:"center",alignContent:"center",gridTemplateRows:"minmax(auto, max-content)",gridAutoRows:"minmax(auto, max-content)",gap:"large-300",...r?{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:[n(B,{display:"@media (inline-size >= extraSmall) auto, none",children:s}),d,n(B,{display:"@media (inline-size >= extraSmall) none, auto",inlineAlignment:"center",children:s})]})}function ge(e,t,o,a){return e?{primary:t.cartEmpty&&o&&!a?null:n(z,{...t,inlineSize:a?"fill":void 0}),secondary:t.cartEmpty||a||o&&!t.cartEmpty?null:n(be,{...t})}:!e&&!t.cartEmpty?{primary:n(z,{...t,inlineSize:a?"fill":void 0})}:{}}function ye({lineItems:e,showLineItems:t=!0,cartEmpty:o,type:a,subtitle:r}){const d=re(),{value:s}=d.merchandiseLines,p=ie("merchandiseLines").value,{progress:b,progressing:P}=U(),u=se().merchandiseLines,f=Y(),{observability:x,router:_,embed:v}=g(),{currentDetour:w}=$().value,M=I(()=>s?.lines??[],[s]),[C,D]=R(p);X("stock_problems"),me({stage:C?T.Loading:T.Complete,id:"StockProblems"});const G=o&&L(v?.embedder),E=h(l=>{const i=u.value;u.value=i.filter(({stableId:y})=>!l.includes(y))},[u]),J=h(()=>{le(v,ue)},[v]),O=I(()=>M.reduce((l,i)=>({...l,[i.stableId]:i}),{}),[M]),S=h(({removeUnavailableMerchandise:l=!1}={})=>{const i=u.value,y=i.flatMap(m=>{const c=O[m.stableId];return l&&(!c||c.quantity===0)?[]:!c||c.quantity===0?[m]:m.quantity===c.quantity&&m.totalPrice===c.totalPrice?[m]:[{...m,quantity:c.quantity,totalPrice:c.totalPrice}]});y.length===i.length&&y.every((m,c)=>m===i[c])||(u.value=y)},[O,u]),j=h(async()=>{const l=e.filter(({problem:i})=>Z(i.type)).map(({line:i})=>i.stableId);l.length&&E(l),S({removeUnavailableMerchandise:!0}),x.log("stock_problems_actions_submitted","Stock problems actions submitted",{unshippableMerchandiseIds:JSON.stringify(l),currentDetour:JSON.stringify(w),routerCurrentUrl:_.currentUrl.value.normalizedPath}),await b("checkout-stock-problems-submit")},[w,e,x,b,E,_,S]),A=ee(),H=h(async()=>{await A(e)},[A,e]);return k(function(){S()},[M,S]),k(()=>{p||(D(!1),f.notify({checkout_in_progress:!1}))},[p,C,f]),n(ne,{message:r,errorType:te.InventoryError,children:n(F,{gap:"large-200",children:[n(q,{children:r}),t&&e.length>0?n(pe,{lineItems:e,loading:C,type:a}):null,n(he,{cartEmpty:o,progressing:P.value,onClick:G?J:j,onSecondaryClick:H})]})})}function Oe(){const{observability:e,checkout:{wallets:t}}=g(),{canBeDismissed:o,...a}=de(),{progress:r}=U(),[d,s]=R(!0),p=Q(()=>t.activeSession.value?.wallet!=="GOOGLE_PAY"),{checkoutProtocolModalEventSignal:b}=ce(),P=h(()=>{r("stock-problems-modal-close",()=>{s(!1)})},[r]),u=o?{blocking:!1,onHide:P}:{blocking:!0};k(()=>()=>{b.value="none"},[b]);const f=()=>{e.leaveErrorBreadcrumb("Stock problems modal opened",{type:a.type}),b.value="stockProblems"};return n(W,{when:p,children:[n(fe,{state:a}),n(ae,{section:"stock-problems",children:n(oe,{id:"stock-problems-modal",open:d,heading:a.title,size:"large",onShow:f,...u,children:n(ye,{...a}
1)})})]})}function fe({state:e}){const{observability:t}=g();return k(()=>{e.lineItems.length!==0&&t.leaveErrorBreadcrumb("Displaying stock problems modal",{type:e.type,lineItems:e.lineItems.map(o=>({stableId:o.line.stableId,problem:o.problem.type}))})},[t,e.lineItems,e.type]),null}export{Oe 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.