1import{k as H,h as E,q as w,u as t,A as de,e as le,G as qe,N as Le,o as De,S as ce}from"./esnext-vendor.BDPAaZdq.js";import{C as Se}from"./Checkbox.CiixBh9Z.js";import{d0 as Ue,c as R,o as g,L as W,aa as Je,bY as Ke,l as Ye,dg as He}from"./hydrate.B0xlt2dG.js";import{Q as te,aS as Qe,O as B,bg as Ne,bh as ue,aq as Q,cm as pe,bi as Ze,P as $e,cB as je}from"./hooks-useReplaceShopPayInHistory.C8UL-mAH.js";import{a as Ae,b as ze,c as Xe,d as et}from"./RememberMeSection.BvcUNZhk.js";import{u as Fe,a as tt}from"./AddressPresenter.B0qw2vWQ.js";import{E as nt}from"./EmailField.BtJiNLVF.js";import{P as ot}from"./PhoneField.ykPh8SPx.js";import"./app.D1P6yWfp.js";import"./helpers-getNormalizedPaymentMethodName.B-mE5wnL.js";import"./shared-permissions.BaDWlj5_.js";import"./hooks-useShopPayExternalAppContext.DyGXtar4.js";import"./amazon-pay-useAmazonPayPaymentLine.BXwZMsYY.js";import"./ChangeCompanyLocationLink.Ci5U9F_D.js";import"./BillingAddressForm.aTSlVDrG.js";import"./FormLayout.CMVyKzjL.js";import"./Popover.BUTwaoOa.js";import"./Choice.BIzIW4rp.js";import"./components-PaymentMethodProgressionHost.BmXVNMRw.js";import"./graphql-PaymentSessionMutation.BhOnX3QJ.js";import"./Section._KuAKpGQ.js";import"./ImpressionEventCapture.iMEQlBKs.js";import"./components-useVaultedMsiInstallments.Br5peiWP.js";import"./PaymentIcon.CQXs-ePm.js";import"./PaymentLine.BkPc0Zsc.js";import"./EmptyState.b83C9ddY.js";import"./localization-index.Bo8bPuxq.js";import"./helpers-credit-card-disabled.BnSr1GsQ.js";import"./hooks-useUpdateCheckoutAddress.xu8w67CI.js";import"./helpers-derivations.DLW2fhKL.js";import"./money-toShopPayMoneyInput.-nuohgDW.js";import"./redemption-promotions.CgqGtCd-.js";import"./shop-pay-normalizeBuyerDetails.ThnUnxcv.js";import"./checkout-updaters-helpers.BAeH3ddd.js";import"./helpers-setAddressErrors.BA8OjimY.js";import"./hooks-useShopPayProgressIntercepts.Sxhi7oHx.js";import"./MissingFields.DB7ri4eR.js";import"./components-RedirectionNotice.module.BGJWZ6-9.js";import"./useAddressMutationsWithNegotiation.BfzEjUy6.js";import"./Rollup.iQVJ47hC.js";import"./utilities-publishMessage.BORnEDuA.js";import"./utilities-stable-ref.Dvd2X3ul.js";import"./PayButton-helpers.Dg5kgVMm.js";import"./hooks-useGeneralPaymentErrorMessage.Zl8_48Ok.js";import"./hooks-useShowShopPayOptin.DZ4Mf9YD.js";import"./hooks-useSuppressShopPayModalOnLoad.brztd70E.js";const we="shop_pay_sign_up";function rt({artifact:e,isAvailable:n,setOptIn:o}){const a=()=>!!e.value?.optIn;return{key:we,read(){if(n())return{key:we,purpose:"dev.shopify.shopping.declared_fields.generic",title:"Save my information with Shop Pay",description:"Save the buyer's contact details with Shop Pay for a faster checkout next time: the same choice as the Remember me checkbox. Send true to opt in and false to opt out; omitting the field or sending null keeps the buyer's current choice.",value_schema:{type:"boolean"},value:a(),required:!1}},prepare(s){if(s!==null&&typeof s!="boolean")return{requirement:"must be a boolean or null"};const l=s??void 0;return{phase:"negotiate",get changed(){return l!==void 0&&l!==a()},async apply(){return l===void 0||!n()?!1:(o(l),a()===l)}}}}}function at(){const{formatPhoneNumber:e}=Fe();return e}const me="invalid_phone_number";function it(e,n=!1,o=!1,a=!1){const s=te().shopPayArtifact,{rememberMePhoneErrorSignal:l}=Qe(),{validatePhoneNumber:m}=Fe(),{checkout:_}=B(),c=_.configuration.layout.isOnePage.value,[b,d]=H(void 0);return E(()=>{(!n&&b||o)&&(d(void 0),l.value=void 0)},[n,b,o,d,l]),Ne(s,l,i=>{const p=i?.optIn?i.optIn.vaultPhone:void 0;if(!c||!n||o||p===void 0)return;const y=p.trim()?m(p,e):a;if(!y&&!b&&d(me),!y)return me},ue.InvalidOptInPhone,()=>!!_.wallets.activeSession.value),{error:b,validate:o?m:(i,p)=>{const y=a&&i.trim()===""||m(i,p),S=y?void 0:me;return d(S),l.value=S,y}}}function Me(){const e=te().shopPayArtifact,n=e.value,o=w(a=>{if(!a){e.value={optIn:!1};return}if("optInFirstName"in a){const u=e.value;e.value=u?.optIn?{optIn:{...u.optIn,vaultFirstName:a.optInFirstName}}:{optIn:{vaultFirstName:a.optInFirstName,vaultPhone:"",optInSource:"REMEMBER_ME"}};return}const{optInEmail:s,optInPhone:l,isAutoOptIn:m}=a,c=e.value?.optIn||void 0,{isAutoOptIn:b,...d}=c??{};e.value=c?{optIn:{...d,vaultEmail:s,vaultPhone:l,...m!==void 0&&{isAutoOptIn:m}}}:{optIn:{vaultEmail:s,vaultPhone:l,optInSource:"REMEMBER_ME",...m!==void 0&&{isAutoOptIn:m}}}},[e]);return[n?.optIn,o]}function st({defaultEmail:e}){const{userEvents:n,source:o,checkout:a,shop:s}=B(),{autoOptIn:l,isOptedIn:m}=Ae(),[_,c]=H(e),b=de(void 0),d=w(()=>{_!==b.current&&(b.current=_,n.monorailEvent({schemaId:"shopify_pay_user_optin_ui_interaction/3.2",payload:{...Q(o,a,s),action:"update_email_input",email:_,source:"checkout_page",trigger:l&&m?"auto":"manual"}}))},[l,m,_,n,o,a,s]);return{value:_,handleInput:u=>{c(u)},handleBlur:()=>{d()}}}function lt({value:e,onInput:n,onBlur:o,showOptionalLabel:a=!1}){const{i18n:s}=B(),{value:l,handleInput:m,handleBlur:_}=st({defaultEmail:e});return t(nt,{id:"email",name:"email",label:a?s.translate("shop_pay_remember_me.email_label_optional"):s.translate("shop_pay_remember_me.email_label"),value:l,onInput:c=>{m(c),n?.(c)},onBlur:()=>{_(),o?.()},required:!1})}function Ce(){const e=le(void 0),n=le(void 0),{i18n:o,checkout:a}=B(),s=te(),[,l]=Me(),m=a.configuration.addressSettings.nonBillingAddressSettings.value,_=s.shippingAddress.fields.firstName.value,c=!m.isRequired("firstName")&&!pe(_),b=w(y=>{if(!pe(y))return o.translate("field_errors.address_first_name_blank")},[o]),d=w(y=>{if(!c||a.wallets.activeSession.value)return;if(!pe(y))return n.value=ue.InvalidOptInName,o.translate("field_errors.address_first_name_blank");const L=e.value||"";l({optInFirstName:L})},[c,e,l,o,n,a.wallets]),u=le(void 0),i=a.wallets.activeSession.value?u:n,p=Ze(e,n,b);return Ne(e,i,d,ue.InvalidOptInName),c?t(R,{gap:"base",children:t(Ue,{name:"shopFirstName",label:o.translate("contact.first_name_label"),required:!0,...p})}):null}const ct="ysFmy",pt="tCcLb",mt="TpOxv",X={CheckboxWrapper:ct,CheckboxWithFieldWrapper:pt,FullWidth:mt};function ee(e){e.stopPropagation()}function ht(e){return{terms_href:t("span",{onClick:ee,children:t(W,{target:"_blank",href:"https://shop.app/terms-of-service",tone
1:"monochrome",children:e.translate("shop_pay_remember_me.terms")})}),privacy_href:t("span",{onClick:ee,children:t(W,{target:"_blank",href:"https://www.shopify.com/legal/privacy/app-users",tone:"monochrome",children:e.translate("shop_pay_remember_me.privacy_policy")})})}}function Oe(e){return t(g,{color:"subdued",type:"small",children:e.translate("shop_pay_remember_me.consent_with_checkbox_only",ht(e))})}function ut({checked:e,onChange:n,phoneField:o}){const{i18n:a}=B(),s=a.translate("shop_pay_remember_me.label"),l=()=>{n(!e)},m=t("span",{onClick:ee,children:t(Se,{checked:e,onChange:n,accessibilityLabel:s})});return o?t("div",{className:X.CheckboxWithFieldWrapper,onClick:l,children:[m,t(g,{accessibilityVisibility:"hidden",children:s}),t("span",{className:X.FullWidth,onClick:ee,children:o}),t("div",{className:X.FullWidth,children:Oe(a)})]}):t("div",{className:X.CheckboxWrapper,onClick:l,children:[m,t(R,{children:[t(g,{accessibilityVisibility:"hidden",children:s}),Oe(a)]})]})}function _t({countryCode:e,validationError:n,value:o,accessoryVariant:a="country",errorVariant:s="long",showOptionalLabel:l=!1,onBlur:m=()=>{},onInput:_=()=>{}}){const{i18n:c,userEvents:b,source:d,checkout:u,shop:i}=B(),p=de(""),y=w(C=>{b.monorailEvent({schemaId:"shopify_pay_user_optin_ui_interaction/3.2",payload:{...Q(d,u,i),action:"update_phone_input",phoneNumber:p.current,source:"checkout_page",trigger:C}})},[b,d,u,i]);E(()=>{p.current!==o&&(p.current=o,y("auto"))},[y,o]);const S=a==="clear"?t(W,{onClick:()=>{_?.("",e),p.current=""},textDecoration:"none",children:c.translate("shop_pay_remember_me.clear")}):void 0,L=l?c.translate("shop_pay_remember_me.mobile_phone_optional"):c.translate("shop_pay_remember_me.mobile_phone_number"),T=s==="short"?c.translate("shop_pay_remember_me.mobile_phone_invalid"):c.translate("general.errors.buyer_identity.phone_number_does_not_match_expected_pattern");return t(ot,{error:n?t(g,{children:T}):void 0,countryCode:e,label:L,value:o,icon:"mobile",prefillCountryCode:!!e,accessoryEnd:S,hideCountries:!!S,onInputValueChange:C=>{_?.(C,e),p.current=C},onBlur:()=>{y("manual"),m?.()},onSelectedCountryChange:(C,v)=>{_?.(v,C),p.current=v}})}const dt="_9uM9Z",ft="sBuoU",he={NoInputTreatmentWrapper:dt,NoInputTreatmentOptOut:ft},bt={gdpr_prefilled:"remember_me_checkbox_reason_gdpr_prefilled",apple_pay_wallet:"remember_me_checkbox_reason_apple_pay_wallet",artifact_empty_field_on_mount:"remember_me_checkbox_reason_artifact_empty_field_on_mount",no_input_treatment:"no_input_treatment",gdpr_consent_checkbox:"gdpr_consent_checkbox"};function yt(){const{i18n:e,userEvents:n,source:o,checkout:a,shop:s,webMcp:l,shop:{name:m},checkout:{wallets:_}}=B(),c=te();E(()=>{c.shopPayRememberMeVisible.value=!0},[c.shopPayRememberMeVisible]);const{value:b}=$e().buyerIdentity,{autoOptIn:d}=Ae(),{storeOptOutPreference:u}=ze(),[i,p]=Me(),y=c.phone.value,S=c.email.value,L=je().value??!1,{shopPayOptInPhone:T}=b||{},C=tt(),[v,fe]=H(qe(()=>C.value)),{kind:f,isApplePayWalletSelected:D,requiresExplicitConsent:N,validatedProposedPhone:Z}=Xe(v);let h;D?h=null:y?h="email":h="phone";const Re=f==="standaloneGdprPhone"||f==="gdprCheckboxWithPhone",be=Ke(),We=h!=="phone"||D||!i||f==="noInputRow"||f==="gdprCheckboxOnly",{validate:ye,error:Be}=it(v,!0,We,Re),V=at(),Te=!!(i&&i.isAutoOptIn),ne=i&&i.vaultPhone;let G="";ne?G=ne:T?G=T:N?G=Z||"":G=d&&Z||"";const oe=w(r=>{n.monorailEvent({schemaId:"shopify_pay_user_optin_ui_interaction/3.2",payload:{...Q(o,a,s),action:"prefill_phone",source:"checkout_page",trigger:r}})},[n,o,a,s]),A=w(r=>{n.monorailEvent({schemaId:"shopify_pay_user_optin_ui_impression/1.0",payload:{...Q(o,a,s),elementType:r,source:"checkout_page"}})},[n,o,a,s]);let q=null;Te?q="was_previously_auto_opted_in":!ne&&G.trim().length>0&&(q="have_phone_to_prefill_on_mount");const[x,$]=Le(vt,{value:G,isPrefilled:!!q,wasEverPrefilled:!!q});E(()=>{q&&oe(q)},[]);const[U,re]=H(i&&i?.vaultEmail||S||""),[ae]=H(()=>!!i&&(h==="phone"&&x.value===""||h==="email"&&U===""));let I=null;N&&x.wasEverPrefilled&&(I="gdpr_prefilled"),D&&(I="apple_pay_wallet"),ae&&(I="artifact_empty_field_on_mount"),f==="noInputRow"&&(I="no_input_treatment"),(f==="gdprCheckboxWithPhone"||f==="gdprCheckboxOnly")&&(I="gdpr_consent_checkbox"),f==="standaloneGdprPhone"&&h==="phone"&&(I=null);const P=!!I,J=P&&!!i;E(()=>{f==="standaloneGdprPhone"&&ae&&h==="phone"&&p(!1)},[ae,h,p,f]);const j=w(r=>{ye(r,v)||be("violationError",{error:{message:"The specified phone number does not match the expected pattern",code:"remember_me_phone_error",field:"phone",origin:"client",type:"inline-validation"},timestamp:new Date})},[v,ye,be]),ie=w(({type:r,value:k})=>{if(k.trim().length===0&&!P){p(!1),u(!0);return}const O=V(k,v)??k,Ee=P?!1:r==="prefill";if(!(i&&i.vaultPhone===O&&(i.vaultEmail??"")===""&&i.isAutoOptIn===Ee)){if(P&&i){p({optInPhone:O,optInEmail:"",isAutoOptIn:!1});return}P||(p({optInPhone:O,optInEmail:"",isAutoOptIn:Ee}),u(!1))}},[v,V,P,p,i,u]),Ve=w(r=>{if(r.trim().length===0&&!P){p(!1),u(!0);return}const M=c.phone.value,O=V(M,v);i&&i.vaultPhone===O&&i.vaultEmail===r||(p({optInPhone:O??M,optInEmail:r,isAutoOptIn:!1}),u(!1))},[P,c.phone,v,i,V,p,u]),F=w((r,{isAuto:k=!1}={})=>
1{if(r){u(!1);const O=V(x.value,v)??x.value;p(h==="phone"?{optInPhone:O,optInEmail:"",isAutoOptIn:k}:{optInPhone:O,optInEmail:U,isAutoOptIn:k})}else u(!0),p(!1),$({type:"input",value:""}),re("");let M=r?"click_remember_me_box":"unclick_remember_me_box";I==="no_input_treatment"&&(M=r?"click_remember_me_save":"click_remember_me_not_now"),n.monorailEvent({schemaId:"shopify_pay_user_optin_ui_interaction/3.2",payload:{...Q(o,a,s),action:M,phoneNumber:x.value,email:U,source:"checkout_page",trigger:k?"auto":"manual"}})},[o,a,s,n,h,U,x,v,p,u,V,$,re,I]);E(()=>l?.unstable_registerDeclaredField(rt({artifact:c.shopPayArtifact,isAvailable:()=>P&&!N,setOptIn:r=>F(r,{isAuto:!1})})),[l,c.shopPayArtifact,P,N,F]);const Ge=D&&_.activeSession.value?.asPaymentMethod!==!1,ve=d&&i===void 0&&(Ge||f==="noInputRow");E(()=>{ve&&F(!0,{isAuto:!0})},[ve,F]);const Pe=de(null);E(()=>{if(h!=="phone"||!N&&!d)return;const r=(Z||T||"").trim();r.length===0||r===Pe.current||i===void 0&&(Pe.current=r,j(r),$({type:"prefill",value:r}),oe("received_phone_to_prefill"),N||ie({type:"prefill",value:r}))},[i,h,N,d,Z,T,j,ie,oe]),De(()=>{fe(C.value)}),E(()=>{if(!P)return;A("remember_me_experimental_checkbox"),A(J?"remember_me_experimental_checkbox_checked":"remember_me_experimental_checkbox_unchecked");const r=I?bt[I]:null;r&&A(r)},[P,J,A,I]),E(()=>{let r="remember_me_field_none";h==="phone"?r="remember_me_field_phone":h==="email"&&(r="remember_me_field_email"),A(r)},[h,A]),E(()=>{A("remember_me_box"),i&&A("remember_me_box_with_artifact"),x.value&&j(x.value)},[]);let ke="country";!N&&x.isPrefilled&&(ke="clear");let z,K,Y;D?(K=!1,z=!0,Y="consent_with_checkbox_only"):P?(z=!1,K=!1,Y=h==="email"?"consent_with_checkbox_optional_no_brackets_email":"consent_with_checkbox_optional_no_brackets"):(z=!1,K=!0,Y=h==="email"?"consent_with_email":"consent_with_phone");const Ie=r=>h==="phone"?t(_t,{countryCode:v,validationError:Be,value:x.value,accessoryVariant:ke,errorVariant:"short",showOptionalLabel:r,onInput:(k,M)=>{$({type:"input",value:k}),ie({type:"input",value:k}),fe(M)},onBlur:()=>j(x.value)}):null,ge=Ie(K);let se=null;if(h==="phone"?se=t(ce,{children:[ge,i&&t(Ce,{})]}):h==="email"&&(se=t(ce,{children:[t(lt,{value:U,onInput:r=>{re(r),Ve(r)},showOptionalLabel:K}),i&&t(Ce,{})]})),f==="noInputRow")if(J){const r={terms_href:t(W,{target:"_blank",href:"https://shop.app/terms-of-service",tone:"monochrome",children:e.translate("shop_pay_remember_me.terms")}),privacy_href:t(W,{target:"_blank",href:"https://www.shopify.com/legal/privacy/app-users",tone:"monochrome",children:e.translate("shop_pay_remember_me.privacy_policy")})},k=L?e.translate("shop_pay_remember_me.consent_by_completing_order",r):e.translate("shop_pay_remember_me.consent_by_paying",r);return t("div",{className:he.NoInputTreatmentWrapper,children:[t(R,{children:[t(g,{children:e.translate("shop_pay_remember_me.label")}),t(g,{color:"subdued",type:"small",children:k})]}),t("div",{className:he.NoInputTreatmentOptOut,children:t(W,{onClick:()=>F(!1),textDecoration:"none",children:e.translate("shop_pay_remember_me.not_now")})})]})}else return t("div",{className:he.NoInputTreatmentWrapper,children:[t(R,{children:[t(g,{children:e.translate("shop_pay_remember_me.label")}),t(g,{color:"subdued",type:"small",children:e.translate("shop_pay_remember_me.value_prop_shop_name_verbose",{shop_name:m})})]}),t(Ye,{variant:"secondary",onClick:()=>F(!0),children:e.translate("shop_pay_remember_me.save")})]});if(f==="standaloneGdprPhone")return t(R,{gap:"base",children:[t(g,{children:e.translate("shop_pay_remember_me.label")}),ge,t(_e,{variant:Y})]});if(f==="gdprCheckboxWithPhone"||f==="gdprCheckboxOnly")return t(ut,{checked:J,onChange:F,phoneField:f==="gdprCheckboxWithPhone"?Ie(!0):void 0});const xe=t(R,{direction:"inline",gap:"small-400",children:[t(g,{children:e.translate("shop_pay_remember_me.label")}),z&&t(g,{color:"subdued",children:e.translate("shop_pay_remember_me.optional_chip")})]});return t(R,{gap:"base",children:[t(R,{direction:"inline",gap:"base",children:P?t(Se,{id:"remember_me_checkbox",checked:J,onChange:F,label:xe}):t(ce,{children:xe})}),se,t(_e,{variant:Y})]})}function un({title:e,compact:n}){return t(He,{sectionId:"rememberMe",children:t(et,{title:e,compact:n,children:t(yt,{})})})}function _e({variant:e}){const{i18n:n}=B(),o={terms_href:t(W,{target:"_blank",href:"https://shop.app/terms-of-service",tone
1:"monochrome",children:n.translate("shop_pay_remember_me.terms")}),privacy_href:t(W,{target:"_blank",href:"https://www.shopify.com/legal/privacy/app-users",tone:"monochrome",children:n.translate("shop_pay_remember_me.privacy_policy")})};function a(){switch(e){case"consent_with_phone":return n.translate("shop_pay_remember_me.consent_with_phone",o);case"consent_with_email":return n.translate("shop_pay_remember_me.consent_with_email",o);case"consent_with_checkbox":return n.translate("shop_pay_remember_me.consent_with_checkbox",o);case"consent_with_checkbox_optional_no_brackets":return n.translate("shop_pay_remember_me.consent_with_checkbox_optional_no_brackets",o);case"consent_with_checkbox_optional_no_brackets_email":return n.translate("shop_pay_remember_me.consent_with_checkbox_optional_no_brackets_email",o);case"consent_with_checkbox_only":return n.translate("shop_pay_remember_me.consent_with_checkbox_only",o);default:return""}}return t(g,{color:"subdued",type:"small",children:t(Je,{children:a()},e)})}_e.displayName="DisclaimerText";function vt(e,n){switch(n.type){case"prefill":return{value:n.value,isPrefilled:!0,wasEverPrefilled:!0};case"input":return{value:n.value,isPrefilled:!1,wasEverPrefilled:e.wasEverPrefilled}}}export{_e as DisclaimerText,yt as RememberMe,un as RememberMeSurface};
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.