1import{j as e,r as o,a4 as te,u as X,s as Y,p as Z,t as w,eH as q,eC as $,en as C,e6 as B,ac as se,eE as re,G as oe,q as de,aX as le,V as _,e7 as ce,aZ as me,bn as V}from"./index-CNagSlXC.js";import{S as L,P as ue}from"./PackageColumn-CtQNP4z1.js";import{i as pe}from"./index.esm-NlnVx5jx.js";import{f as N,c as I,V as D,L as ke,T as R,p as ve,_ as ge,m as O,g as he}from"./PricingCheckoutAuthentication-cxWGf0_x.js";import{m as A}from"./PricingPage-intl-BLRRDS88.js";import{m as fe}from"./PlanCheckoutSummary-intl-Wi2zzhQr.js";import{m as F}from"./PayForm-intl-CoeWmjB8.js";import{m as M}from"./Alugha2GoVideoMeta-intl-BF2qUw12.js";import{C as ye,b as xe,c as be,d as Se,e as Pe,f as je,g as Ce,h as Ne,I as Fe,i as we,P as Ie,j as De,k as Oe,S as Le}from"./IconX-BSBK_nYo.js";import{u as Te}from"./useMount-index-Dkg_MXfU.js";import{a as Ee}from"./SubscriptionUser-BdGpNzRB.js";import{P as W,L as Q,B as U,a as z,W as qe,b as G,c as H,f as $e}from"./PricingCheckoutPage-styled-BT-Jin5A.js";import{E as Be}from"./Error-D7UaxmAi.js";import"./PublisherDropzone-intl-D6kZyBaS.js";import"./Elements-intl-DKaDo41Q.js";import"./ProjectOverview-intl-BsiKiFjt.js";import"./ProducerPage-intl-CE2p6d1k.js";import"./AnimatedButton.styled-CMZ4Mm8E.js";import"./Authentication-index-B11cp1zH.js";import"./customerData-BGtEJCBa.js";import"./array-BKiU2Bbv.js";import"./_baseAssignValue-B9b5URRE.js";import"./zxcvbn-lib-main-BlMimuUc.js";import"./useChatwoot-DcYXye79.js";import"./formValidation-CEs0nq_H.js";import"./AcceptPrivacyTos-index-DBJbT31d.js";import"./CheckBox-CW170eiZ.js";import"./plane-DUpr7nB-.js";import"./lottie-BeikJyiQ.js";import"./loadable-BUkpCPp0.js";import"./vsc-index-BqgmN9Y_.js";import"./gridBackground-CrXQ4BPa.js";const _e=({onAccept:t})=>e.jsxs(e.Fragment,{children:[e.jsx("h2",{children:"Active Paddle Classic Subscription"}),e.jsx("p",{children:"Thank you for being with us for so long. We changed our subscription system internally and therefore, your running subscription may not be modified anymore. You may keep it the way it is, but if you want to perform an up- or downgrade, you must start a new subscription instead"}),e.jsx(L,{variant:"button",onClick:t,text:"I understand"})]}),Ve=`query PaddleDiscountQuery($paymentOptionId: ID!, $coupon: String) { 2 subscriptionPaymentOption(id: $paymentOptionId) { 3 id 4 discount(coupon: $coupon) { 5 id 6 code 7 amount 8 } 9 } 10} 11`,Re={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"PaddleDiscountQuery"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"paymentOptionId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}},directives:[]},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"coupon"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"subscriptionPaymentOption"},arguments:[{kind:"Argument",name:{kind:"Name",value:"id"},value:{kind:"Variable",name:{kind:"Name",value:"paymentOptionId"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"discount"},arguments:[{kind:"Argument",name:{kind:"Name",value:"coupon"},value:{kind:"Variable",name:{kind:"Name",value:"coupon"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"code"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"amount"},arguments:[],directives:[]}]}}]}}]}}],loc:{start:0,end:242,source:{name:"GraphQL request",locationOffset:{line:1,column:1},body:Ve}}},Ae=t=>t%1===0?0:2,Me=({paymentOption:t,viewer:l})=>{const[r,p]=o.useState(null),[s,h]=o.useState(null),[v,f]=o.useState(!1),[u,c]=o.useState(""),[i,a]=o.useState(""),[n,d]=o.useState(""),y=te(),{refetch:x,loading:S,data:P}=X(Re,{skip:!0,variables:{paymentOptionId:t.id,coupon:i}});o.useEffect(()=>{P&&(P?.subscriptionPaymentOption?.discount?(d(P.subscriptionPaymentOption.discount.id),a(P.subscriptionPaymentOption.discount.code)):(d(""),a("")))},[P]);const{error:J}=Y(),{formatMessage:m}=Z();Te(()=>{(async()=>{try{const g=await pe({token:"test_cbfa9471b21f4adf80cfc2e3514",environment:"sandbox"});if(!y.current)return;g!=null&&p(g)}catch{J("Could not load Paddle SDK v2")}})()});const j=o.useMemo(()=>[{priceId:t.paddleSubscriptionPlanId,quantity:1}],[t.paddleSubscriptionPlanId]);o.useEffect(()=>{if(r==null)return;const k=async()=>{f(!0);const g=await r.TransactionPreview({items:j,discountId:n.length>0?n:void 0});y.current&&(h(g),f(!1))};j.length>0&&k()},[n,y,j,r]);const T=o.useCallback(k=>{const g=k.trim().replace(/\W/g,"");c(g),x({coupon:g})},[x]),ee=o.useCallback(()=>{c(""),a(""),d(""),x({coupon:null})},[x,c]),ie=o.useCallback(k=>{k.preventDefault(),T(u)},[T,u]),E=o.useMemo(()=>!S&&!v&&!n&&i.length>0,[S,v,n,i.length]),ne=o.useMemo(()=>s?.data.details.lineItems.reduce((k,g)=>k+Number.parseFloat(g.totals.total),0)??0,[s]),ae=o.useCallback(()=>{r&&r.Checkout.open({items:j,customer:{email:l.email}
11,customData:{alughaUserId:l.id},discountCode:i,settings:{allowLogout:!1,variant:"multi-page"}})},[i,j,r,l.email,l.id]);return r==null||s==null?e.jsx(w,{centered:!0}):e.jsxs(e.Fragment,{children:[e.jsxs(N,{children:[e.jsx(I,{children:m(q.newPlanInfo,{planName:t.plan.name,commitment:t.commitment,termType:m(t.termType===$.month?A.monthly:A.yearlyBilling)})}),e.jsx(D,{children:e.jsx(C,{style:"currency",currency:s.data.currencyCode,value:parseFloat(s.data.details.totals.subtotal)/100,minimumFractionDigits:2,maximumFractionDigits:2})})]}),s.data.discountId&&e.jsxs(N,{children:[e.jsx(I,{children:m(F.Coupon)}),e.jsx(D,{children:e.jsx(C,{style:"currency",currency:s.data.currencyCode,value:parseFloat(s.data.details.totals.discount)/100*-1,minimumFractionDigits:2,maximumFractionDigits:2})})]}),e.jsxs(N,{children:[e.jsx(I,{children:m(fe.tax)}),e.jsx(D,{children:e.jsx(C,{style:"currency",currency:s.data.currencyCode,value:parseFloat(s.data.details.totals.tax)/100,minimumFractionDigits:2,maximumFractionDigits:2})})]}),e.jsx(ke,{}),e.jsxs(N,{children:[e.jsx(R,{children:m(q.total)}),e.jsxs(R,{id:"amountTotal",children:[e.jsx(C,{style:"currency",currency:s.data.currencyCode,value:parseFloat(s.data.details.totals.total)/100,minimumFractionDigits:Ae(parseFloat(s.data.details.lineItems[0].totals.total)),maximumFractionDigits:2}),"/",m(t.termType===$.month?B.perMonth:B.perYear),"*"]})]}),e.jsxs(ye,{as:"form",onSubmit:ie,children:[e.jsx(xe,{id:"couponLabel",htmlFor:"couponInput",children:m(M.existingVouche)}),e.jsx(be,{children:S&&i?e.jsx(w,{size:"1rem",thickness:"2px",centered:!0}):e.jsxs(e.Fragment,{children:[e.jsxs(Se,{children:[e.jsx(Pe,{id:"couponInput",type:"text",value:n.length>0?"":u,placeholder:m(M.pasteCode),onChange:k=>{c(k.target.value)},"aria-labelledby":"couponLabel",$isInvalid:E,disabled:n.length>0,pattern:"^[a-zA-Z0-9]{1,32}$"}),e.jsx(je,{disabled:S||u==""||n.length>0,type:"submit",children:v||S?e.jsx(w,{size:"1rem",thickness:"2px",centered:!0}):m(se.apply)})]}),E&&e.jsxs(Ce,{children:[e.jsx(re,{}),m(oe.invalid)]}),n&&e.jsxs(Ne,{children:[e.jsx("span",{children:i}),e.jsx(Fe,{onClick:ee,children:e.jsx(we,{size:16})})]})]})})]}),e.jsx(Ie,{children:e.jsx(L,{variant:"button",onClick:ae,text:m(ne>0?F.actionBuy:F.actionVerify)})}),e.jsxs(De,{children:[e.jsx(Oe,{children:m(F.poweredBy)}),e.jsx("a",{href:"https://paddle.com/",target:"_blank",rel:"noopener noreferrer",children:e.jsx(Le,{src:ve,alt:"Paddle Logo"})})]})]})},We=`#import "@web/app/graphql/fragments/SubscriptionUser.graphql" 12#import "../fragments/PricingCheckoutPaymentOption.graphql" 13 14query PaddleBillingCheckoutPageQuery( 15 $paymentOptionId: ID! 16 $coupons: [String!] 17) { 18 paymentOption: subscriptionPaymentOption(id: $paymentOptionId) { 19 id 20 paddleSubscriptionPlanId 21 isBilling 22 commitment 23 termType 24 termLength 25 state 26 plan { 27 id 28 name 29 maxTracks 30 maxAudioChannels 31 maxWatchlists 32 maxWatchlistEntries 33 maxPlatformChannels 34 maxPodcasts 35 maxPodcastEpisodes 36 maxManagers 37 maxVideoResolution 38 monthlyCredits 39 optionalFeatures 40 } 41 ...PricingCheckoutPaymentOption 42 } 43 viewer { 44 id 45 email 46 planId 47 plan { 48 name 49 id 50 } 51 } 52 viewerAsSubscriber { 53 ...SubscriptionUser 54 } 55} 56`,b={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"PaddleBillingCheckoutPageQuery"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"paymentOptionId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"ID"}}},directives:[]},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"coupons"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",alias:{kind:"Name",value:"paymentOption"},name:{kind:"Name",value:"subscriptionPaymentOption"},arguments:[{kind:"Argument",name:{kind:"Name",value:"id"},value:{kind:"Variable",name:{kind:"Name",value:"paymentOptionId"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"paddleSubscriptionPlanId"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"isBilling"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"commitment"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"termType"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"termLength"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"state"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"plan"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"maxTracks"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"maxAudioChannels"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"maxWatchlists"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"maxWatchlistEntries"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"maxPlatformChannels"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"maxPodcasts"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"maxPodcastEpisodes"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"maxManagers"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"maxVideoResolution"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"monthlyCredits"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"optionalFeatures"},arguments:[],directives:[]}]}},{kind:"FragmentSpread",name:{kind:"Name",value:"PricingCheckoutPaymentOption"},directives:[]}]}},{kind:"Field",name:{kind:"Name",value:"viewer"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"email"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"planId"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"plan"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]}]}}]}},{kind:"Field",name:{kind:"Name",value:"viewerAsSubscriber"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"SubscriptionUser"},directives:[]}]}}]}}],loc:{start:0,end:870,source:{name:"GraphQL request",locationOffset:{line:1,column:1},body:We}}},K=t=>{const l={};return t.filter(function(r){if(r.kind!=="FragmentDefinition")return!0;const p=r.name.value;return l[p]?!1:(l[p]=!0,!0)})};b.definitions=K(b.definitions.concat(Ee.definitions));b.definitions=K(b.definitions.concat(ge.definitions));const Qe=(t,l)=>{const r=(i,a)=>
56{if(i.kind==="FragmentSpread")a.add(i.name.value);else if(i.kind==="VariableDefinition"){const n=i.type;n.kind==="NamedType"&&a.add(n.name.value)}return i&&"selectionSet"in i&&i.selectionSet&&i.selectionSet.selections.forEach(n=>{r(n,a)}),i&&"variableDefinitions"in i&&i.variableDefinitions&&i.variableDefinitions.forEach(n=>{r(n,a)}),i&&"definitions"in i&&i.definitions&&i.definitions.forEach(n=>{r(n,a)}),a},p=i=>{const a={};return i.definitions.forEach(function(n){"name"in n&&n.name&&(a[n.name.value]=r(n,new Set))}),a},s=(i,a)=>{for(let n=0;n<i.definitions.length;n++){const d=i.definitions[n];if(d&&"name"in d&&d.name&&d.name.value==a)return d}},h=p(t),v=Object.assign({},t,{definitions:[s(t,l)]}),f=h[l]||new Set,u=new Set;let c=new Set;for(f.forEach(i=>{c.add(i)});c.size>0;){const i=c;c=new Set,i.forEach(a=>{u.has(a)||(u.add(a),(h[a]||new Set).forEach(d=>{c.add(d)}))})}return u.forEach(i=>{const a=s(t,i);a&&v.definitions.push(a)}),v};Qe(b,"PaddleBillingCheckoutPageQuery");const ji=({match:{params:{paymentOptionId:t}}})=>{const l=de(),r=le(),{formatMessage:p}=Z(),[s,h]=o.useState(!1),{graphqlError:v}=Y(),f=_(ce),u=_(me),c=u==="pre-confirmation"||u==="post-confirmation",{data:i,loading:a,error:n}=X(b,{variables:{paymentOptionId:t}});o.useEffect(()=>{n&&v(n)},[n,v]);const d=i?.viewerAsSubscriber?.__typename=="PaddleClassicSubscriber",y=i?.viewerAsSubscriber?.__typename=="PaddleBillingSubscriber",x=i?.paymentOption&&l.toBillingCheckout(i.paymentOption.id,r);return!a&&i==null?e.jsx("h2",{children:e.jsx(Be,{children:"Something is wrong"})}):a?e.jsxs(W,{$withLowerHeight:!1,children:[e.jsx(Q,{children:e.jsxs(U,{to:l.toPlans(new URLSearchParams(location.search)),children:[e.jsx(V,{}),e.jsx(z,{children:p(O.backToPlans)})]})}),e.jsx(w,{centered:!0})]}):e.jsxs(W,{$withLowerHeight:!1,children:[e.jsx(Q,{children:e.jsxs(U,{to:l.toPlans(new URLSearchParams(location.search)),children:[e.jsx(V,{}),e.jsx(z,{children:p(O.backToPlans)})]})}
56),f==null?e.jsx(qe,{children:e.jsx(G,{children:e.jsx(H,{$forConfirmation:c,children:e.jsx(he,{successRedirect:x})})})}):e.jsxs(G,{children:[i?.paymentOption.plan&&e.jsx(ue,{plan:{...i.paymentOption.plan,subscriptionPaymentOptions:[i.paymentOption],price:i.paymentOption.paddleProduct.listPrice.gross,paddlePlanId:i.paymentOption.paddleSubscriptionPlanId},selectedPaymentOption:i.paymentOption,viewerHasPlan:i.viewer?.plan?.id===i.paymentOption?.plan.id,forCheckoutPage:!0}),!a&&!i?.paymentOption&&e.jsx($e,{children:p(O.unknownPlan)}),e.jsxs(H,{children:[i?.paymentOption&&i?.viewer&&(d&&s||d===!1&&y===!1)?e.jsx(Me,{paymentOption:i.paymentOption,viewer:i.viewer}):null,s&&e.jsx(L,{variant:"button",onClick:()=>{h(!1)},text:"Stay on classic subscription"}),d&&s===!1&&e.jsx(_e,{onAccept:()=>{h(!0)}}),d===!1&&y&&e.jsx("div",{style:{height:"10rem",background:"#fafafa",color:"#00afaa"},children:"Update Subscription Form"})]})]})]})};export{ji 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.