import{x as W,a as F,u as t,k as A,T as q,c as v,j as $,f as H,q as z,y as J}from"./dist-vendor.DBR6g02j.js";import{bH as X,bI as j,h as m,bJ as K,bK as Q,bL as Z,bM as ee,bN as te,bO as k,bP as ne,bc as se,ao as x,bQ as ie,bR as oe,R as ae,t as re,k as I,bS as B,bT as ce,bU as le,A as de,bb as ue,bV as pe,v as O,bW as ye,bX as he,bY as C,T as me}from"./shop-pay-ButtonWithRegisterWebPixel.Tzqfwpmo.js";import{a as R,k as fe,a8 as L,f as Se,b as _,ar as ge,as as Ee,J as Ae,a0 as D,j as b,at as _e,au as Re,av as Pe,aw as Ce,ax as Te,ay as be,az as Ne,aA as Ie,aB as Oe,ap as ve,aC as ke,aD as P,aE as xe,aF as Be,aG as Le,y as De,aH as Ve,aI as Me}from"./shop-pay-FullScreenBackground.C1_sL6Wu.js";import{R as we,S as Ue}from"./captcha-SeparatePaymentsNotice.DwO3hYyZ.js";import{S as Ge}from"./hooks-ShopPayOptInDisclaimer.DjL5oNJu.js";function Ye(){const{shopPay:{visibility:{shouldRenderFloatingShopPayButton:e}},embed:n}=R(),s=fe(),{payButton:i}=L(),u=Se(),{buyerIdentity:p,managedByMarketsPro:r}=_(),f=ge(),d=X().some(N=>"registrationId"in N&&j.has(N.registrationId)),o=m("Checkout::Actions::RenderBefore"),y=m("Checkout::CartLineDetails::RenderAfter"),c=m("Checkout::CartLines::RenderAfter"),l=m("Checkout::Reductions::RenderBefore"),S=m("Checkout::Reductions::RenderAfter"),h=m("Checkout::Dynamic::Render","ORDER_SUMMARY1"),E=m("Checkout::Dynamic::Render","ORDER_SUMMARY2"),V=m("Checkout::Dynamic::Render","ORDER_SUMMARY3"),M=m("Checkout::Dynamic::Render","ORDER_SUMMARY4"),w=m("Checkout::Dynamic::Render","PAYMENT4"),U=m("purchase.checkout.footer.render-after"),G=K([...o,...y,...c,...l,...S,...h,...E,...V,...M,...w,...U]),Y=p.value?.countryCode;return!(u.value||d||r.value&&!f||Ee(Y))&&!G&&!n&&!e&&s&&i?.position==="sticky"}const We="GsMGr",Fe="eDhAI",qe="P0xJW",$e="COpTB",g={Wrapper:We,Container:Fe,Section:qe,"Container-fixed":"iRlFp","Container-fixed-entering":"_24aJk","Container-fixed-exiting":"ktbnR","Container-fixed-enter":"PCKgT","Container-fixed-exited":"DvZWz",Shadow:$e,"Shadow-enter":"_0hDB9","Shadow-exiting":"P1NPi","Shadow-exited":"lQN1j"},He=new Set([...Re,...Pe,...Ce,...Te,...be,...Ne,...Ie,...Oe,"BUYER_IDENTITY_PRESENTMENT_CURRENCY_DOES_NOT_MATCH","WAITING_PENDING_TERMS"]);function ze(e){return e?.length?e.some(n=>!He.has(n.code)):!1}function Je(){const e=W(Q),{billing:n,contact:s,payment:i,shipping:u}=Ae(),p=Z(),r=D(),{deliveryNext:f,allViolations:a}=_(),d=ee(),{billingAddressOption:o}=b();return F(()=>{const y=e?.value??{contact:!1,delivery:!1,payment:!1,billing:!1},c=ze(a.value),l=y.contact||s.value,S=!r.value||_e(f.value)||y.delivery||u.value,h=!p.value||y.payment||i.value,E=d==="hidden"||d==="inContext"&&y.payment||y.billing||o.value!=="custom"||n.value;return!c&&l&&S&&h&&E})}function Xe({children:e}){const n=Ye(),s=ve({base:!0,medium:!1});return!n||!s?t(A,{children:e}):t(je,{children:e})}function je({children:e}){const n=Je().value,{entry:s,ref:i}=te({threshold:1}),u=n&&s!=null&&!s.isIntersecting&&s.boundingClientRect.bottom>(s.rootBounds?.bottom??0),p=k(n,"base"),{registerStickyElement:r,height:f}=ne("pay_button",{active:u}),{main:a}=L(),d=!!(s&&!s.isIntersecting&&p!=="exited"),o=a.section?.padding,y=a.section?.borderWidth,c=a.section?.border,l=q(()=>{if(!d)return;const S=Array.isArray(o)?o[1]:o,h=Array.isArray(o)?o[3]:o;return{padding:["none",S??"none","none",h??S??"none"],borderWidth:y,border:c}},[d,o,y,c]);return t("div",{ref:i,className:g.Wrapper,style:{...d?{"--container-block-size":`${f.value}px`}:void 0},children:t("div",{ref:r,className:v(g.Container,d&&[g["Container-fixed"],g[`Container-fixed-${p}`]]),children:[t(Ke,{visible:d}),t(se,{style:l,children:t(x,{className:g.Section,accessibilityRole:"presentation",children:e})})]})})}function Ke({visible:e}){const n=k(e,"faster");return n==="exited"?null:t("div",{className:v(g.Shadow,g[`Shadow-${n}`]),"aria-hidden":"true"})}const Qe=e=>t(ce,{children:t(x,{children:e})}),Ze="disable-view-transitions-for-pay-button-section",T="checkout-pay-button-section";function et(){const e=document.createElement("style");return e.setAttribute("id",Ze),e.textContent=`
    #${T}, #${T} * {
      view-transition-name: none !important;
    }
  `,document.head.appendChild(e),e}function yt({buttonHidden:e=!1}){const n=m("Checkout::Actions::RenderBefore"),s=ke(),{PayButton:i}=ie(),{offsitePopupController:u}=R();return $(()=>{if(u.isOpen.value){const p=et();return()=>{p.remove()}}}),t(B,{target:"cart.paymentLines[0]",children:t(oe,{impressionType:"pay_now_button",impressionFeatures:[],children:[n.length!==0&&t(A,{children:[t(ae,{extensions:n,render:Qe}),t(re,{blockSize:"base"})]}),t(I,{gap:"base",ref:s,id:T,children:[t(Xe,{children:t(I,{gap:"base",children:[t(nt,{}),e?t(i,{hidden:!0}):t(we,{children:t(i,{})})]})}),!e&&t(A,{children:[t(Ge,{}),t(Ue,{})]})]})]})})}const tt=new Map([["PAYMENTS_UNACCEPTABLE_PAYMENT_AMOUNT",{status:"warning",priority:-1,negotiationStage:"completion"}],["TAX_NEW_TAX_MUST_BE_ACCEPTED",{status:"warning",priority:-2,negotiationStage:"completion"}]]);function nt(){const{allViolations:e}=_(),{paymentLines:n}=b(),s=st(n.value),i=it(e.value,tt,s);return t(B,{target:"cart.paymentLines[0]",children:i.map(u=>t(le,{notice:u,errorType:de.PaymentError},u.code))})}function st(e){if(!e)return!1;const n=P(e,"APPLE_PAY");if(n&&!xe(n)||P(e,"GOOGLE_PAY")&&!Be({paymentLines:e}))return!0;const i=P(e,"PAYPAL_EXPRESS");return!!(i&&!Le(i))}function it(e,n,s){const i=ue(),[u,p]=H([]),r=z(({violations:a,negotiationStage:d})=>{const o=[],y=a.some(c=>pe.has(c.code));for(const c of a)if(!ot(c)&&n.has(c.code)){if(y||s)continue;const l=n.get(c.code);d&&d===l?.negotiationStage&&o.push({...c,tone:l?.tone,priority:l?.priority})}if(o.length>=1){const l=o.map(h=>h.priority??0).reduce((h,E)=>h>E?h:E);return o.filter(h=>(h.priority??0)>=l)}return o},[n,s]);return J(()=>{e&&p(r({violations:e}))},[r]),De(a=>{a.type==="complete"||a.type==="invalid"||a.type==="failed"||!i.current||p(r({violations:a.violations,negotiationStage:a.negotiationStage}))}),u.filter(Ve("localizedMessage"))}function ot(e){return e.__typename!=="ConfirmChangeViolation"&&e.__typename!=="UnprocessableTermViolation"&&e.__typename!=="RemoveTermViolation"}function ht(){const{i18n:e,cart:n}=R(),s=D(),i=b().shippingAddress.value,{value:u}=_().deliveryNext,p=n.proposal.facts.delivery??[],r=p[0],f=_().buyerIdentity.value?.purchasingCompany,a=f?.location.name,d=!!f&&!!a;if((!p.length||!r?.lines?.length)&&!s.value)return null;if(r.pickupAddress)return t(at,{address:r.pickupAddress??void 0,locationName:r.pickupAddressName});const o=u?.status==="unavailable"?i:r.deliveryAddress,y=t(A,{children:[d?t(O,{children:a}):null,o?t(ye,{address:o}):t(O,{color:"subdued",children:e.translate("review.blocks.no_address")})]}),c=r.lines.length?r.lines.filter(({deliveryChange:l,isFulfilled:S})=>l!=="REMOVED"&&!S).map(l=>t(he,{line:l},l.title)):null;return t(A,{children:[t(C,{id:"address",label:e.translate("review.blocks.shipping_address_title"),summary:y}),c?t(C,{id:"shipping",label:e.translate("review.blocks.shipping_method_title"),summary:c}):null]})}function at({address:e,locationName:n}){const{i18n:s}=R(),i=Me(e,{hiddenFields:["postalCode","countryCode","phone"]});return!n||!i?null:t(C,{id:"delivery",label:s.translate("review.blocks.pick_up_in_store_shipping_method_html",{location_name:n}),summary:t(me,{children:i})})}export{ht as O,yt as P};
