"use strict";(globalThis.webpackChunk_clerk_ui=globalThis.webpackChunk_clerk_ui||[]).push([["30"],{46334:function(e,n,l){l.r(n),l.d(n,{PricingTable:()=>i.n});var i=l(11217)},97288:function(e,n,l){l.d(n,{A$:()=>h,D:()=>f,Ij:()=>d,Rs:()=>m,eT:()=>g,mu:()=>b,wD:()=>p}),l(19161),l(89305),l(85074),l(95055);var i=l(90231),a=l(35074),t=l(57477),r=l(64148),o=l(65424),u=l(22861),s=l(46256);function d(e){return e.endsWith(".00")?e.slice(0,-3):e}let c=()=>{let e=(0,s.XX)(),n=(0,t.Fd)(e=>e({permission:"org:sys_billing:read"})||e({permission:"org:sys_billing:manage"})),l=(0,i.It)();return{for:e,keepPreviousData:!0,enabled:"organization"!==e||!!l&&n}},b=()=>{let e=c();return(0,i.X$)(e)},p=()=>{let e=c();return(0,i.t7)(e)},g=e=>{let n=c();return(0,i.tr)({...n,__experimental_mode:null==e?void 0:e.mode})},m=()=>{var e;let n=c(),l=(0,i.kH)(n),t=(0,a.useMemo)(()=>{var e;return(null==(e=l.data)?void 0:e.subscriptionItems)||[]},[null==(e=l.data)?void 0:e.subscriptionItems]);return{...l,subscriptionItems:t}},h=e=>{let n=(0,s.XX)();return(0,i.rg)({for:n,initialPage:1,pageSize:50,keepPreviousData:!0,enabled:!0,__experimental_mode:null==e?void 0:e.mode})},f=()=>{let e=(0,i.ho)(),{session:n}=(0,i.wV)(),l=(0,s.XX)(),t=(0,a.useMemo)(()=>{var n;return!!(!e.session||(null==e||null==(n=e.session)?void 0:n.checkAuthorization({permission:"org:sys_billing:manage"}))||"user"===l)},[e,l]),{subscriptionItems:d,revalidate:c,data:p}=m(),{data:f,revalidate:v}=h({mode:"cache"}),{revalidate:_}=g({mode:"cache"}),{revalidate:k}=b(),A=(0,a.useCallback)(()=>{c(),v(),_(),k()},[c,v,_,k]),C=(0,a.useMemo)(()=>0===d.length||!d.some(e=>!e.canceledAt),[d]),P=(0,a.useCallback)(e=>d.find(n=>n.plan.id===e.id),[d]),y=(0,a.useCallback)(e=>d.filter(n=>n.plan.id===e.id),[d]),G=(0,a.useCallback)(function(e){let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"month",l=y(e);if(l.length>1){let e=l.find(e=>e.planPeriod===n);return e||l[0]}if(1===l.length)return l[0]},[y]),T=(0,a.useCallback)(e=>{let{plan:n,subscription:l}=e,i=null!=l?l:n?P(n):void 0;return!i||!i.canceledAt},[P]),D=(0,a.useCallback)(e=>{let{plan:i,organization:a,subscription:o,isCompact:s=!1,selectedPlanPeriod:c="annual"}=e,b=null!=o?o:i?G(i,c):void 0,g="organization"===l&&!!a&&(0,r.iI)(i,a),m=c,h=!!(null==i?void 0:i.annualMonthlyFee);"annual"!==m||h||(m="month");let f=e=>{if(null==i?void 0:i.freeTrialEnabled){let e=!n,a=null==p?void 0:p.eligibleForFreeTrial;if(e||a){var l;return(0,u.G)("billing.startFreeTrial__days",{days:null!=(l=i.freeTrialDays)?l:0})}}return e};return{localizationKey:f((()=>{if(b){if(m!==b.planPeriod&&b.canceledAt){if("month"===m)return(0,u.G)("billing.switchToMonthly");if(h)return(0,u.G)("billing.switchToAnnual")}if(b.canceledAt)return(0,u.G)("billing.reSubscribe");if(m!==b.planPeriod){if("month"===m)return(0,u.G)("billing.switchToMonthly");if(h)return(0,u.G)("billing.switchToAnnual")}return(0,u.G)("billing.manageSubscription")}return d.filter(e=>!e.plan.isDefault).length>0?(0,u.G)("billing.switchPlan"):f((0,u.G)("billing.subscribe"))})()),variant:s?"bordered":"solid",colorScheme:s?"secondary":"primary",isDisabled:!t||g,disabled:!t||g}},[G,t,l,d,p]),w=(0,a.useCallback)(e=>e.pastDueAt?(0,u.G)("badge__pastDueAt",{date:e.pastDueAt}):"upcoming"===e.status?(0,u.G)("badge__startsAt",{date:e.periodStart}):e.canceledAt?(0,u.G)("badge__canceledEndsAt",{date:e.periodEnd}):e.periodEnd?(0,u.G)(e.isFreeTrial?"badge__trialEndsAt":"badge__renewsAt",{date:e.periodEnd}):void 0,[]),S=(0,a.useCallback)(n=>{let i=(0,o.J)("modal",n);e.__internal_openSubscriptionDetails({for:l,onSubscriptionCancel:()=>{A()},portalRoot:i})},[e,l,A]);return{activeOrUpcomingSubscription:P,activeAndUpcomingSubscriptions:y,activeOrUpcomingSubscriptionBasedOnPlanPeriod:G,isDefaultPlanImplicitlyActiveOrUpcoming:C,handleSelectPlan:(0,a.useCallback)(i=>{var a,t;let{plan:r,planPeriod:u,mode:s="mounted",event:d,appearance:c,newSubscriptionRedirectUrl:b}=i,p=(0,o.J)(s,d);e.__internal_openCheckout({planId:r.id,planPeriod:(a=r,"month"===(t=u)&&a.fee||"annual"===t&&a.annualMonthlyFee?t:"month"!==t||a.fee?"annual"!==t||a.annualMonthlyFee?t:"month":"annual"),for:l,onSubscriptionComplete:()=>{A()},onClose:()=>{(null==n?void 0:n.id)&&e.setActive({session:n.id})},appearance:c,portalRoot:p,newSubscriptionRedirectUrl:b})},[e,A,l,null==n?void 0:n.id]),openSubscriptionDetails:S,buttonPropsForPlan:D,canManageSubscription:T,captionForSubscription:w,defaultFreePlan:(0,a.useMemo)(()=>null==f?void 0:f.find(e=>e.isDefault),[f]),revalidateAll:A}}},46256:function(e,n,l){l.d(n,{N7:()=>o,XX:()=>r,m$:()=>t});var i=l(35074);let a="user",t=(0,i.createContext)(a),r=()=>(0,i.useContext)(t)||a,o=()=>"user"===r()?"userProfile":"organizationProfile"}}]);