import{c as x,d as E,w as K,u as r,k as f}from"./vendor.BXe-L2nx.js";import{gS as _,u_ as N,aQ as L,u$ as D,v0 as G,eY as W,ag as Q,b as c,bC as V,fy as z,aL as q,x as j,fa as J,dL as $,bm as X,nF as Z,bQ as I,gw as ee,jC as se,ir as te,v1 as re,G as ne,v2 as ae,v3 as oe,aU as ie,cP as ce,e2 as F,T as U,L as k,a3 as T}from"./app.aa9qjHTz.js";const le={id:"0c62c3aaedf84bd307e1134828e5fcc88a47d83c453c97544a6cc8711e6444af",type:"mutation",name:"SubscribeForShippingUpdates",source:""};class v extends Error{name="SubscribeForShippingUpdateError"}function ye(){const e=x(),{client:s,telemetryClient:n}=c(),a=s.unstable_getSerialization("sessionToken"),[t,l]=E(),[u,o]=E("idle"),p=_()?.orderIdentity?.id;async function P(d){if(o("loading"),l(void 0),!a||!p){o("failed"),l("SUBSCRIPTION_FAILED"),n.error(new v("Missing sessionToken or orderId"));return}const{data:i}=await e.mutate(le,{variables:{sessionToken:a,orderId:p,email:d}});if(i){const{__typename:h}=i?.subscribeForShippingUpdates;switch(h){case"SubscribeForShippingUpdatesSuccess":o("subscribed");return;case"SubscribeForShippingUpdatesFailure":o("failed"),l(i?.subscribeForShippingUpdates.code);return;default:o("idle"),n.error(new v("Undefined subscribeForShippingUpdates type"))}}}return{submitSubscribeForShippingUpdate:P,status:u,error:t}}function be(){const{purchasingCompany:e}=L(),s=D(),n=G(),a=W();return n&&!a?.value?.email&&!e&&!s}function Pe(){const e=y(),s=!!e?.shopAppEligible,n=!!e?.shopAppQrCodeKillswitch;return s&&!n}function Se(){const e=N(),s=y();return e&&!!s?.installmentsHighlightEligible}function y(){const e=_();if(e)return{...e.shopAppLinksAndResources}}function ge(){const e=_();if(e?.orderIdentity?.id)return Number(Q(e.orderIdentity.id))}function Ae(){const{cart:e,embed:s,mobileCheckoutSdk:n,shopPay:a,shop:t}=c(),{purchasingCompany:l}=L(),u=V(),o=z(),b=q(),p=y(),d=j().paymentLines.value,{value:i}=J(),{value:h}=$(),{currentDetour:S}=X(),w=Z(),g=!I(ee),m=!I(se),{shopPayAvailableForSellerOfRecord:H}=te(),{hasSavedCreditCards:R}=re(),{value:M}=ne(),A=ce({managedByMarketsPro:M}),B=e.proposal.negotiated.fields.mustSelectProvidedAddress.value,Y=K().searchParams.get(ae);return w?.shopPayOptInEnabled===!1||l||!H||u?.__typename==="CustomerProfile"&&o&&(!b||!R)||a.userIdentified||a.isActive||Y||B||s||n.enabled||m&&p?.shopPayOrder||t.enabledFlags.includes(oe)&&!h?.some(C=>C.type==="wallet"&&C.name==="SHOP_PAY")&&S?.type!=="thankYou"?!1:S?.type==="thankYou"?i?O({paymentLines:i.lines,isIdealEnabledForShopPay:A,isUsdcEnabled:g,isApplePayInShopPayAvailable:m}):!1:O({paymentLines:d,isIdealEnabledForShopPay:A,isUsdcEnabled:g,isApplePayInShopPayAvailable:m})}const O=({paymentLines:e,isIdealEnabledForShopPay:s,isUsdcEnabled:n,isApplePayInShopPayAvailable:a})=>{if(!e?.length||!e[0].method)return!1;const{method:t}=e[0];return t.type==="customOnsite"?!!(t.paymentBrands?.includes("bogus_app_coin")||n&&t.paymentBrands?.includes("usdc")||s&&t.paymentBrands?.includes("ideal")):!!(t.type==="direct"||t.type===ie.CreditCard||s&&t.type==="local"&&t.name==="IDEAL"||a&&t.type==="wallet"&&t.name==="APPLE_PAY")};function pe(){const{i18n:e}=c();return r(U,{size:"small",color:"subdued",children:r(F,{children:e.translate("shop_pay_remember_me.terms_and_privacy_html",{privacy_href:r(de,{}),terms_href:r(ue,{})})})})}function ue(){const{i18n:e}=c();return r(f,{children:r(k,{target:"_blank",href:"https://shop.app/terms-of-service",tone:"monochrome",accessibilityLabel:e.translate("shop_pay_remember_me.new_window_disclaimer"),children:[e.translate("shop_pay_remember_me.terms_of_service"),r(T,{type:"external",size:"small",display:"inline"})]})})}function de(){const{i18n:e}=c();return r(f,{children:r(k,{target:"_blank",href:"https://www.shopify.com/legal/privacy/app-users",tone:"monochrome",accessibilityLabel:e.translate("shop_pay_remember_me.new_window_disclaimer"),children:[e.translate("shop_pay_remember_me.privacy_policy"),r(T,{type:"external",size:"small",display:"inline"})]})})}function Ce({field:e="phone",link:s}){const{i18n:n}=c();return r(f,{children:[r(U,{color:"subdued",children:r(F,{children:[e==="phone"?n.translate("shop_pay_remember_me.description_html"):n.translate("shop_pay_remember_me.email_description_html")," ",s]})}),r(pe,{})]})}export{Ce as R,ye as a,ge as b,y as c,Pe as d,Se as e,be as f,Ae as u};
