@stigg/react-sdk 7.18.2 → 7.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5145,7 +5145,7 @@ ${e.o5f}`,e.zBW=r.default`
5145
5145
  display: flex;
5146
5146
  flex-direction: column;
5147
5147
  align-items: center;
5148
- `,bx=({plans:t,customer:e,currentSubscription:n,highlightedPlanId:r,selectedBillingPeriod:i,onBillingPeriodChanged:o,availableBillingPeriods:s,isCustomerOnTrial:l,onPlanSelected:p,paywallLocale:f,locale:b,shouldHidePlan:S,selectDefaultTierIndex:P,currentSubscriptionOverride:I,hideCompatibleAddons:T,showWatermark:F})=>{let k=mx(t),R=t.some(Y=>!!Y.description),N=bv(t,Se.Monthly),j=bv(t,Se.Annually),H=yx(t,i,S),Q=g0.useCallback((Y,ot,pt)=>p({plan:Y,customer:e,subscription:n,intentionType:ot,selectedBillingPeriod:i,billableFeatures:pt}),[e,i,n,p]),it=!!n&&n.plan.pricingType===On.Custom,st=g0.useMemo(()=>H.some(Y=>{var ut;let ot=Y.pricePoints.filter(mt=>mt.billingPeriod===i),pt=(ut=Y.paywallCalculatedPricePoints)==null?void 0:ut.find(mt=>mt.billingPeriod===i);return ot.length>1&&!!(pt!=null&&pt.additionalChargesMayApply)}),[i,H]),U=g0.useMemo(()=>H.some(Y=>!!Ih(Y,i,f,b,N).unit),[i,N,b,f,H]),V=g0.useMemo(()=>!it&&H.some(Y=>{let ot=Th({plan:Y,billingPeriod:i,currentSubscription:n,currentSubscriptionOverride:I});return Object.values(ot).length>0}),[i,n,I,it,H]),dt=H.some(Y=>Y.isCurrentCustomerPlan&&Y.trialDaysLeft);return jsxRuntime.jsx(TF,{className:"stigg-paywall-container",children:jsxRuntime.jsxs(IF,{className:"stigg-paywall-layout",children:[jsxRuntime.jsx(ux,{onBillingPeriodChanged:o,selectedBillingPeriod:i,availableBillingPeriods:s,discountRate:k}),jsxRuntime.jsx(EF,{className:"stigg-paywall-plans-layout",children:H.map(Y=>jsxRuntime.jsx(cx,{withUnitPriceRow:U,withTiersRow:V,withTrialLeftRow:dt,shouldShowDescriptionSection:R,hasMonthlyPrice:N,hasAnnuallyPrice:j,plan:Y,withStartingAtRow:st,currentSubscription:n,currentSubscriptionOverride:I,billingPeriod:i,isHighlighted:Y.id===r,isCustomerOnTrial:l,onPlanSelected:(ot,pt)=>Q(Y,ot,pt),paywallLocale:f,locale:b,customer:e,isCustomerInCustomPlan:it,selectDefaultTierIndex:P,hideCompatibleAddons:T},Y.id))}),jsxRuntime.jsx(go,{source:"paywall",align:"end",style:{marginTop:16},showWatermark:F})]})})};var Cv=class{error(e,n,...r){console.error(e,n||{},r);}log(e,n){console.log(e,n||{});}debug(e,n){console.debug(e,n||{});}},sc=new Cv;function vx(t,e,n){let r=t.flatMap(l=>l.pricePoints).map(l=>l.billingPeriod),i=lodash.countBy(r),o=lodash.uniq(r),s;if(n&&o.includes(n))s=n;else if(e){let l=e.find(p=>p.status===_i.Active);l&&l.prices.length>0&&(s=l==null?void 0:l.prices[0].billingPeriod);}return s||(s=(i[Se.Monthly]||0)>(i[Se.Annually]||0)?Se.Monthly:Se.Annually),{defaultBillingPeriod:s,availableBillingPeriods:o}}function Sx(t){return E1__default.default.utc(t).diff(E1__default.default.utc(),"days",false)+1}var Dh={h1:{fontSize:"24px",fontWeight:"bold",semanticElement:"h1"},h2:{fontSize:"16px",fontWeight:"normal",semanticElement:"h2"},h3:{fontSize:"16px",fontWeight:"normal",semanticElement:"h3"},body:{fontSize:"14px",fontWeight:"normal",semanticElement:"p"}};function cc(t,e="px"){if(t)return `${t}${e}`}function kh(t){if(!t)return "normal";switch(t){case zb.Normal:return "normal";case zb.Bold:return "bold";default:return "normal"}}function of(t,e){var r,i,o,s,l,p,f,b;let n=e||{h1:{fontSize:"32px",fontWeight:"bold",semanticElement:"h1"},h2:{fontSize:"24px",fontWeight:"normal",semanticElement:"h2"},h3:{fontSize:"16px",fontWeight:"normal",semanticElement:"h3"},body:{fontSize:"14px",fontWeight:"normal",semanticElement:"p"}};return {fontFamilyUrl:(t==null?void 0:t.fontFamily)||void 0,h1:{fontSize:cc((r=t==null?void 0:t.h1)==null?void 0:r.fontSize)||n.h1.fontSize,fontWeight:kh((i=t==null?void 0:t.h1)==null?void 0:i.fontWeight)||n.h1.fontWeight,semanticElement:n.h1.semanticElement},h2:{fontSize:cc((o=t==null?void 0:t.h2)==null?void 0:o.fontSize)||n.h2.fontSize,fontWeight:kh((s=t==null?void 0:t.h2)==null?void 0:s.fontWeight)||n.h2.fontWeight,semanticElement:n.h2.semanticElement},h3:{fontSize:cc((l=t==null?void 0:t.h3)==null?void 0:l.fontSize)||n.h3.fontSize,fontWeight:kh((p=t==null?void 0:t.h3)==null?void 0:p.fontWeight)||n.h3.fontWeight,semanticElement:n.h3.semanticElement},body:{fontSize:cc((f=t==null?void 0:t.body)==null?void 0:f.fontSize)||n.body.fontSize,fontWeight:kh((b=t==null?void 0:t.body)==null?void 0:b.fontWeight)||n.body.fontWeight,semanticElement:n.body.semanticElement}}}function Sv(t){if(t)switch(t){case hh.Left:return "left";case hh.Center:return "center";case hh.Right:return "right";default:return}}function xx(t){let{palette:e,customCss:n,typography:r}=t;return {palette:{primary:(e==null?void 0:e.primary)||void 0,backgroundPaper:(e==null?void 0:e.paywallBackgroundColor)||void 0,outlinedBorder:(e==null?void 0:e.borderColor)||void 0,backgroundHighlight:(e==null?void 0:e.currentPlanBackground)||void 0,text:{primary:(e==null?void 0:e.textColor)||void 0}},typography:of(r),customCss:n||void 0}}function Px(t){let{palette:e,layout:n,customCss:r,typography:i}=t;return {customCss:r||void 0,palette:{primary:(e==null?void 0:e.primary)||void 0,backgroundPaper:(e==null?void 0:e.backgroundColor)||void 0,outlinedBorder:(e==null?void 0:e.borderColor)||void 0,backgroundHighlight:(e==null?void 0:e.currentPlanBackground)||void 0,text:{primary:(e==null?void 0:e.textColor)||void 0}},typography:of(i),layout:{ctaAlignment:Sv(n==null?void 0:n.alignment),headerAlignment:Sv(n==null?void 0:n.alignment),descriptionAlignment:Sv(n==null?void 0:n.alignment),planMaxWidth:cc(n==null?void 0:n.planWidth),planMinWidth:cc(n==null?void 0:n.planWidth),planMargin:cc(n==null?void 0:n.planMargin),planPadding:cc(n==null?void 0:n.planPadding)}}}function _x(t){let{palette:e,typography:n,customCss:r}=t;return {palette:{primary:(e==null?void 0:e.primary)||void 0,backgroundPaper:(e==null?void 0:e.backgroundColor)||void 0,outlinedBorder:(e==null?void 0:e.borderColor)||void 0,text:{primary:(e==null?void 0:e.textColor)||void 0},backgroundHighlight:(e==null?void 0:e.summaryBackgroundColor)||void 0},typography:of(n,Dh),customCss:r||void 0}}function FF(t){let e=true,n=(t==null?void 0:t.find(o=>o.status===_i.InTrial))||null,r=n==null?void 0:n.plan,i=n!=null&&n.trialEndDate?Sx(n.trialEndDate):void 0;return r||(e=false,n=(t==null?void 0:t.find(o=>o.status===_i.Active))||null,r=n==null?void 0:n.plan),{currentSubscription:n,currentPlan:r,isCustomerOnTrial:e,trialDaysLeft:i}}function Tx(t,e,n){var H,Q;let{plans:r,currency:i,configuration:o,customer:s,activeSubscriptions:l,paywallCalculatedPricePoints:p}=t||{},{currentSubscription:f,currentPlan:b,isCustomerOnTrial:S,trialDaysLeft:P}=FF(l),I=n==null?void 0:n({currentSubscription:f}),T=(f==null?void 0:f.scheduledUpdates)||[],F=(H=f==null?void 0:f.price)==null?void 0:H.billingPeriod,k=T.find(({subscriptionScheduleType:it})=>it===Wi.Downgrade),R=T.find(({subscriptionScheduleType:it})=>it===Wi.BillingPeriod),N=o___default.default(r,it=>it.order).map(it=>{var dt;let st=(dt=s==null?void 0:s.eligibleForTrial)==null?void 0:dt.find(Y=>Y.productId===it.product.id),U=I!=null&&I.planId?(I==null?void 0:I.planId)===it.id:it.id===(b==null?void 0:b.id),V=Y=>{var mt;let ot=k==null?void 0:k.scheduleVariables,pt=R==null?void 0:R.scheduleVariables,ut=it.pricePoints.some(bt=>bt.billingPeriod===Y);return k?((mt=k.targetPackage)==null?void 0:mt.refId)===it.id&&(!ut||ot.billingPeriod===Y):R&&U?pt.billingPeriod===Y:false};return vt(q({},it),{paywallCalculatedPricePoints:p==null?void 0:p.filter(Y=>Y.planId===it.id),isTriable:!Eh__default.default(it.defaultTrialConfig)&&(!st||st.eligible),isCurrentCustomerPlan:U,currentCustomerPlanBillingPeriod:F,isUpcomingPlan:false,trialDaysLeft:P,isNextPlan:V,paywallCurrency:i,scheduledUpdate:k||R})});if(r&&b){let it=b&&((Q=r==null?void 0:r.find(st=>st.id===(b==null?void 0:b.id)))==null?void 0:Q.order);Eh__default.default(it)||(N=N.map(st=>vt(q({},st),{isLowerThanCurrentPlan:it>st.order})),e&&(N=N.filter(st=>st.order>=it)));}let j=o?Px(o):void 0;return {currentPlan:b,currentSubscription:f,currentSubscriptionOverride:I,isCustomerOnTrial:S,plans:N,paywallConfiguration:j}}var wx="7.18.2";var Ax="@stigg/react-sdk";var af=g0__default.default.createContext(null);af.displayName="StiggContext";var LF="en-US",BF=({apiKey:t,baseUri:e,baseEdgeUri:n,enableEdge:r,customerId:i,customerToken:o,resourceId:s,theme:l,locale:p,cacheTtlMs:f,useEntitlementPolling:b,entitlementPollingInterval:S,entitlementsFallback:P,stiggClient:I,children:T,offline:F,clientName:k=Ax,clientVersion:R=wx})=>{let N=g0.useRef(t),j={apiKey:t,customerId:i,customerToken:o,resourceId:s,baseUri:e,baseEdgeUri:n,enableEdge:r,entitlementsFallback:P,cacheTtlMs:f,useEntitlementPolling:b,entitlementPollingInterval:S,clientName:k,clientVersion:R,offline:F},[H,Q]=g0.useState(()=>({stigg:I!=null?I:qb.initialize(vt(q({},j),{lazyLoad:true})),locale:p||LF,isInitialized:false,theme:l,refreshData:()=>ie(null,null,function*(){Q(it=>vt(q({},it),{customerPortalUpdatedAt:new Date})),yield H.stigg.refresh();})}));return g0.useEffect(()=>{let it=true,st=Y=>{it&&Q(Y);},U=()=>st(Y=>vt(q({},Y),{updatedAt:new Date})),V=Y=>st(ot=>(ot.stigg&&ot.stigg.removeListener("entitlementsUpdated",U),Y.addListener("entitlementsUpdated",U),vt(q({},ot),{stigg:Y,isInitialized:true,updatedAt:new Date})));return ie(null,null,function*(){let Y=H.stigg;t!==N.current&&(sc.log("Updating stigg client",{apiKey:t}),N.current=t,Y=qb.initialize(q({},j)),st(ot=>vt(q({},ot),{isInitialized:false,updatedAt:new Date}))),yield Y.waitForInitialization(),V(Y);}),()=>{it=false,H.stigg.removeListener("entitlementsUpdated",U),H.stigg.clearCustomer();}},[t]),g0.useEffect(()=>{let it=H.stigg;i?it.setCustomerId(i,o,s):it.clearCustomer();},[i,o,s]),g0.useEffect(()=>{Q(it=>vt(q({},it),{theme:l}));},[l]),jsxRuntime.jsx(af.Provider,{value:H,children:jsxRuntime.jsx(lc.SkeletonTheme,{baseColor:"#F5F6F9",highlightColor:"#e5e6ea",children:T})})};function ce(t){let{optional:e}=t||{},n=g0.useContext(af);if(!n&&!e)throw new Error("Could not find Stigg context; You need to wrap your app in an <StiggProvider> component.");return n}function kx({productId:t,resourceId:e,showOnlyEligiblePlans:n,billingCountryCode:r,preferredBillingPeriod:i,currentSubscriptionOverrideFn:o}){let{stigg:s,locale:l}=ce(),[p,f]=g0.useState(Se.Annually),[b,S]=g0.useState([]),[P,I]=g0.useState(null),[T,F]=g0.useState(true);g0.useEffect(()=>{ie(null,null,function*(){try{F(!0),yield s.waitForInitialization();let N=yield s.getPaywall({productId:t,resourceId:e,billingCountryCode:r}),{availableBillingPeriods:j,defaultBillingPeriod:H}=vx(N.plans,N.activeSubscriptions,i);I(N),S(j),f(H);}catch(N){sc.error(`Failed to load paywall ${N==null?void 0:N.message}`,N);}finally{F(false);}});},[s,t,s.isCustomerLoaded,r,e,i]);let k=Tx(P,n,o);return q({customer:(P==null?void 0:P.customer)||null,isLoading:T,selectedBillingPeriod:p,setSelectedBillingPeriod:f,availableBillingPeriods:b,locale:l,configuration:k.paywallConfiguration,showWatermark:s.getShowWatermark()},k)}function Fx(t){return n2__default.default({highlightChip:"Recommended",addonsTitle:"Available add-ons:",planCTAButton:{upgrade:"Upgrade",downgrade:"Downgrade",startTrial:n=>{var r;return `Start ${(r=n.defaultTrialConfig)==null?void 0:r.duration} day trial`},custom:"Contact us",currentPlan:"Current plan",startNew:"Get started",switchToBillingPeriod:n=>n===Se.Monthly?"Switch to monthly billing":"Switch to annual billing",cancelScheduledUpdate:"Cancel"},price:{startingAtCaption:"Starts at",pricePeriod:n=>n===Se.Monthly?"/ month":"/ year",free:n=>({price:`${n==null?void 0:n.symbol}0`}),custom:"Custom",priceNotSet:"Price not set"}},t)}var VF=t=>jsxRuntime.jsx("svg",vt(q({width:15,height:11,viewBox:"0 0 15 11",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t),{children:jsxRuntime.jsx("path",{d:"M5.59 7.9899L2.125 4.5249C1.73524 4.13514 1.10365 4.13402 0.712509 4.52241V4.52241C0.319409 4.91274 0.318286 5.54819 0.710005 5.9399L5.59 10.8199L14.2948 2.11513C14.6843 1.72565 14.6843 1.09417 14.2948 0.704691V0.704691C13.9055 0.315381 13.2743 0.315184 12.8848 0.70425L5.59 7.9899Z",fill:"#B2BBD3"})})),Ox=VF;var jF=W.div`
5148
+ `,bx=({plans:t,customer:e,currentSubscription:n,highlightedPlanId:r,selectedBillingPeriod:i,onBillingPeriodChanged:o,availableBillingPeriods:s,isCustomerOnTrial:l,onPlanSelected:p,paywallLocale:f,locale:b,shouldHidePlan:S,selectDefaultTierIndex:P,currentSubscriptionOverride:I,hideCompatibleAddons:T,showWatermark:F})=>{let k=mx(t),R=t.some(Y=>!!Y.description),N=bv(t,Se.Monthly),j=bv(t,Se.Annually),H=yx(t,i,S),Q=g0.useCallback((Y,ot,pt)=>p({plan:Y,customer:e,subscription:n,intentionType:ot,selectedBillingPeriod:i,billableFeatures:pt}),[e,i,n,p]),it=!!n&&n.plan.pricingType===On.Custom,st=g0.useMemo(()=>H.some(Y=>{var ut;let ot=Y.pricePoints.filter(mt=>mt.billingPeriod===i),pt=(ut=Y.paywallCalculatedPricePoints)==null?void 0:ut.find(mt=>mt.billingPeriod===i);return ot.length>1&&!!(pt!=null&&pt.additionalChargesMayApply)}),[i,H]),U=g0.useMemo(()=>H.some(Y=>!!Ih(Y,i,f,b,N).unit),[i,N,b,f,H]),V=g0.useMemo(()=>!it&&H.some(Y=>{let ot=Th({plan:Y,billingPeriod:i,currentSubscription:n,currentSubscriptionOverride:I});return Object.values(ot).length>0}),[i,n,I,it,H]),dt=H.some(Y=>Y.isCurrentCustomerPlan&&Y.trialDaysLeft);return jsxRuntime.jsx(TF,{className:"stigg-paywall-container",children:jsxRuntime.jsxs(IF,{className:"stigg-paywall-layout",children:[jsxRuntime.jsx(ux,{onBillingPeriodChanged:o,selectedBillingPeriod:i,availableBillingPeriods:s,discountRate:k}),jsxRuntime.jsx(EF,{className:"stigg-paywall-plans-layout",children:H.map(Y=>jsxRuntime.jsx(cx,{withUnitPriceRow:U,withTiersRow:V,withTrialLeftRow:dt,shouldShowDescriptionSection:R,hasMonthlyPrice:N,hasAnnuallyPrice:j,plan:Y,withStartingAtRow:st,currentSubscription:n,currentSubscriptionOverride:I,billingPeriod:i,isHighlighted:Y.id===r,isCustomerOnTrial:l,onPlanSelected:(ot,pt)=>Q(Y,ot,pt),paywallLocale:f,locale:b,customer:e,isCustomerInCustomPlan:it,selectDefaultTierIndex:P,hideCompatibleAddons:T},Y.id))}),jsxRuntime.jsx(go,{source:"paywall",align:"end",style:{marginTop:16},showWatermark:F})]})})};var Cv=class{error(e,n,...r){console.error(e,n||{},r);}log(e,n){console.log(e,n||{});}debug(e,n){console.debug(e,n||{});}},sc=new Cv;function vx(t,e,n){let r=t.flatMap(l=>l.pricePoints).map(l=>l.billingPeriod),i=lodash.countBy(r),o=lodash.uniq(r),s;if(n&&o.includes(n))s=n;else if(e){let l=e.find(p=>p.status===_i.Active);l&&l.prices.length>0&&(s=l==null?void 0:l.prices[0].billingPeriod);}return s||(s=(i[Se.Monthly]||0)>(i[Se.Annually]||0)?Se.Monthly:Se.Annually),{defaultBillingPeriod:s,availableBillingPeriods:o}}function Sx(t){return E1__default.default.utc(t).diff(E1__default.default.utc(),"days",false)+1}var Dh={h1:{fontSize:"24px",fontWeight:"bold",semanticElement:"h1"},h2:{fontSize:"16px",fontWeight:"normal",semanticElement:"h2"},h3:{fontSize:"16px",fontWeight:"normal",semanticElement:"h3"},body:{fontSize:"14px",fontWeight:"normal",semanticElement:"p"}};function cc(t,e="px"){if(t)return `${t}${e}`}function kh(t){if(!t)return "normal";switch(t){case zb.Normal:return "normal";case zb.Bold:return "bold";default:return "normal"}}function of(t,e){var r,i,o,s,l,p,f,b;let n=e||{h1:{fontSize:"32px",fontWeight:"bold",semanticElement:"h1"},h2:{fontSize:"24px",fontWeight:"normal",semanticElement:"h2"},h3:{fontSize:"16px",fontWeight:"normal",semanticElement:"h3"},body:{fontSize:"14px",fontWeight:"normal",semanticElement:"p"}};return {fontFamilyUrl:(t==null?void 0:t.fontFamily)||void 0,h1:{fontSize:cc((r=t==null?void 0:t.h1)==null?void 0:r.fontSize)||n.h1.fontSize,fontWeight:kh((i=t==null?void 0:t.h1)==null?void 0:i.fontWeight)||n.h1.fontWeight,semanticElement:n.h1.semanticElement},h2:{fontSize:cc((o=t==null?void 0:t.h2)==null?void 0:o.fontSize)||n.h2.fontSize,fontWeight:kh((s=t==null?void 0:t.h2)==null?void 0:s.fontWeight)||n.h2.fontWeight,semanticElement:n.h2.semanticElement},h3:{fontSize:cc((l=t==null?void 0:t.h3)==null?void 0:l.fontSize)||n.h3.fontSize,fontWeight:kh((p=t==null?void 0:t.h3)==null?void 0:p.fontWeight)||n.h3.fontWeight,semanticElement:n.h3.semanticElement},body:{fontSize:cc((f=t==null?void 0:t.body)==null?void 0:f.fontSize)||n.body.fontSize,fontWeight:kh((b=t==null?void 0:t.body)==null?void 0:b.fontWeight)||n.body.fontWeight,semanticElement:n.body.semanticElement}}}function Sv(t){if(t)switch(t){case hh.Left:return "left";case hh.Center:return "center";case hh.Right:return "right";default:return}}function xx(t){let{palette:e,customCss:n,typography:r}=t;return {palette:{primary:(e==null?void 0:e.primary)||void 0,backgroundPaper:(e==null?void 0:e.paywallBackgroundColor)||void 0,outlinedBorder:(e==null?void 0:e.borderColor)||void 0,backgroundHighlight:(e==null?void 0:e.currentPlanBackground)||void 0,text:{primary:(e==null?void 0:e.textColor)||void 0}},typography:of(r),customCss:n||void 0}}function Px(t){let{palette:e,layout:n,customCss:r,typography:i}=t;return {customCss:r||void 0,palette:{primary:(e==null?void 0:e.primary)||void 0,backgroundPaper:(e==null?void 0:e.backgroundColor)||void 0,outlinedBorder:(e==null?void 0:e.borderColor)||void 0,backgroundHighlight:(e==null?void 0:e.currentPlanBackground)||void 0,text:{primary:(e==null?void 0:e.textColor)||void 0}},typography:of(i),layout:{ctaAlignment:Sv(n==null?void 0:n.alignment),headerAlignment:Sv(n==null?void 0:n.alignment),descriptionAlignment:Sv(n==null?void 0:n.alignment),planMaxWidth:cc(n==null?void 0:n.planWidth),planMinWidth:cc(n==null?void 0:n.planWidth),planMargin:cc(n==null?void 0:n.planMargin),planPadding:cc(n==null?void 0:n.planPadding)}}}function _x(t){let{palette:e,typography:n,customCss:r}=t;return {palette:{primary:(e==null?void 0:e.primary)||void 0,backgroundPaper:(e==null?void 0:e.backgroundColor)||void 0,outlinedBorder:(e==null?void 0:e.borderColor)||void 0,text:{primary:(e==null?void 0:e.textColor)||void 0},backgroundHighlight:(e==null?void 0:e.summaryBackgroundColor)||void 0},typography:of(n,Dh),customCss:r||void 0}}function FF(t){let e=true,n=(t==null?void 0:t.find(o=>o.status===_i.InTrial))||null,r=n==null?void 0:n.plan,i=n!=null&&n.trialEndDate?Sx(n.trialEndDate):void 0;return r||(e=false,n=(t==null?void 0:t.find(o=>o.status===_i.Active))||null,r=n==null?void 0:n.plan),{currentSubscription:n,currentPlan:r,isCustomerOnTrial:e,trialDaysLeft:i}}function Tx(t,e,n){var H,Q;let{plans:r,currency:i,configuration:o,customer:s,activeSubscriptions:l,paywallCalculatedPricePoints:p}=t||{},{currentSubscription:f,currentPlan:b,isCustomerOnTrial:S,trialDaysLeft:P}=FF(l),I=n==null?void 0:n({currentSubscription:f}),T=(f==null?void 0:f.scheduledUpdates)||[],F=(H=f==null?void 0:f.price)==null?void 0:H.billingPeriod,k=T.find(({subscriptionScheduleType:it})=>it===Wi.Downgrade),R=T.find(({subscriptionScheduleType:it})=>it===Wi.BillingPeriod),N=o___default.default(r,it=>it.order).map(it=>{var dt;let st=(dt=s==null?void 0:s.eligibleForTrial)==null?void 0:dt.find(Y=>Y.productId===it.product.id),U=I!=null&&I.planId?(I==null?void 0:I.planId)===it.id:it.id===(b==null?void 0:b.id),V=Y=>{var mt;let ot=k==null?void 0:k.scheduleVariables,pt=R==null?void 0:R.scheduleVariables,ut=it.pricePoints.some(bt=>bt.billingPeriod===Y);return k?((mt=k.targetPackage)==null?void 0:mt.refId)===it.id&&(!ut||ot.billingPeriod===Y):R&&U?pt.billingPeriod===Y:false};return vt(q({},it),{paywallCalculatedPricePoints:p==null?void 0:p.filter(Y=>Y.planId===it.id),isTriable:!Eh__default.default(it.defaultTrialConfig)&&(!st||st.eligible),isCurrentCustomerPlan:U,currentCustomerPlanBillingPeriod:F,isUpcomingPlan:false,trialDaysLeft:P,isNextPlan:V,paywallCurrency:i,scheduledUpdate:k||R})});if(r&&b){let it=b&&((Q=r==null?void 0:r.find(st=>st.id===(b==null?void 0:b.id)))==null?void 0:Q.order);Eh__default.default(it)||(N=N.map(st=>vt(q({},st),{isLowerThanCurrentPlan:it>st.order})),e&&(N=N.filter(st=>st.order>=it)));}let j=o?Px(o):void 0;return {currentPlan:b,currentSubscription:f,currentSubscriptionOverride:I,isCustomerOnTrial:S,plans:N,paywallConfiguration:j}}var wx="7.19.0";var Ax="@stigg/react-sdk";var af=g0__default.default.createContext(null);af.displayName="StiggContext";var LF="en-US",BF=({apiKey:t,baseUri:e,baseEdgeUri:n,enableEdge:r,customerId:i,customerToken:o,resourceId:s,theme:l,locale:p,cacheTtlMs:f,useEntitlementPolling:b,entitlementPollingInterval:S,entitlementsFallback:P,stiggClient:I,children:T,offline:F,clientName:k=Ax,clientVersion:R=wx})=>{let N=g0.useRef(t),j={apiKey:t,customerId:i,customerToken:o,resourceId:s,baseUri:e,baseEdgeUri:n,enableEdge:r,entitlementsFallback:P,cacheTtlMs:f,useEntitlementPolling:b,entitlementPollingInterval:S,clientName:k,clientVersion:R,offline:F},[H,Q]=g0.useState(()=>({stigg:I!=null?I:qb.initialize(vt(q({},j),{lazyLoad:true})),locale:p||LF,isInitialized:false,theme:l,refreshData:()=>ie(null,null,function*(){Q(it=>vt(q({},it),{customerPortalUpdatedAt:new Date})),yield H.stigg.refresh();})}));return g0.useEffect(()=>{let it=true,st=Y=>{it&&Q(Y);},U=()=>st(Y=>vt(q({},Y),{updatedAt:new Date})),V=Y=>st(ot=>(ot.stigg&&ot.stigg.removeListener("entitlementsUpdated",U),Y.addListener("entitlementsUpdated",U),vt(q({},ot),{stigg:Y,isInitialized:true,updatedAt:new Date})));return ie(null,null,function*(){let Y=H.stigg;t!==N.current&&(sc.log("Updating stigg client",{apiKey:t}),N.current=t,Y=qb.initialize(q({},j)),st(ot=>vt(q({},ot),{isInitialized:false,updatedAt:new Date}))),yield Y.waitForInitialization(),V(Y);}),()=>{it=false,H.stigg.removeListener("entitlementsUpdated",U),H.stigg.clearCustomer();}},[t]),g0.useEffect(()=>{let it=H.stigg;i?it.setCustomerId(i,o,s):it.clearCustomer();},[i,o,s]),g0.useEffect(()=>{Q(it=>vt(q({},it),{theme:l}));},[l]),jsxRuntime.jsx(af.Provider,{value:H,children:jsxRuntime.jsx(lc.SkeletonTheme,{baseColor:"#F5F6F9",highlightColor:"#e5e6ea",children:T})})};function ce(t){let{optional:e}=t||{},n=g0.useContext(af);if(!n&&!e)throw new Error("Could not find Stigg context; You need to wrap your app in an <StiggProvider> component.");return n}function kx({productId:t,resourceId:e,showOnlyEligiblePlans:n,billingCountryCode:r,preferredBillingPeriod:i,currentSubscriptionOverrideFn:o}){let{stigg:s,locale:l}=ce(),[p,f]=g0.useState(Se.Annually),[b,S]=g0.useState([]),[P,I]=g0.useState(null),[T,F]=g0.useState(true);g0.useEffect(()=>{ie(null,null,function*(){try{F(!0),yield s.waitForInitialization();let N=yield s.getPaywall({productId:t,resourceId:e,billingCountryCode:r}),{availableBillingPeriods:j,defaultBillingPeriod:H}=vx(N.plans,N.activeSubscriptions,i);I(N),S(j),f(H);}catch(N){sc.error(`Failed to load paywall ${N==null?void 0:N.message}`,N);}finally{F(false);}});},[s,t,s.isCustomerLoaded,r,e,i]);let k=Tx(P,n,o);return q({customer:(P==null?void 0:P.customer)||null,isLoading:T,selectedBillingPeriod:p,setSelectedBillingPeriod:f,availableBillingPeriods:b,locale:l,configuration:k.paywallConfiguration,showWatermark:s.getShowWatermark()},k)}function Fx(t){return n2__default.default({highlightChip:"Recommended",addonsTitle:"Available add-ons:",planCTAButton:{upgrade:"Upgrade",downgrade:"Downgrade",startTrial:n=>{var r;return `Start ${(r=n.defaultTrialConfig)==null?void 0:r.duration} day trial`},custom:"Contact us",currentPlan:"Current plan",startNew:"Get started",switchToBillingPeriod:n=>n===Se.Monthly?"Switch to monthly billing":"Switch to annual billing",cancelScheduledUpdate:"Cancel"},price:{startingAtCaption:"Starts at",pricePeriod:n=>n===Se.Monthly?"/ month":"/ year",free:n=>({price:`${n==null?void 0:n.symbol}0`}),custom:"Custom",priceNotSet:"Price not set"}},t)}var VF=t=>jsxRuntime.jsx("svg",vt(q({width:15,height:11,viewBox:"0 0 15 11",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t),{children:jsxRuntime.jsx("path",{d:"M5.59 7.9899L2.125 4.5249C1.73524 4.13514 1.10365 4.13402 0.712509 4.52241V4.52241C0.319409 4.91274 0.318286 5.54819 0.710005 5.9399L5.59 10.8199L14.2948 2.11513C14.6843 1.72565 14.6843 1.09417 14.2948 0.704691V0.704691C13.9055 0.315381 13.2743 0.315184 12.8848 0.70425L5.59 7.9899Z",fill:"#B2BBD3"})})),Ox=VF;var jF=W.div`
5149
5149
  display: flex;
5150
5150
  flex-direction: column;
5151
5151
  align-items: center;
@@ -5145,7 +5145,7 @@ ${e.o5f}`,e.zBW=r.default`
5145
5145
  display: flex;
5146
5146
  flex-direction: column;
5147
5147
  align-items: center;
5148
- `,bx=({plans:t,customer:e,currentSubscription:n,highlightedPlanId:r,selectedBillingPeriod:i,onBillingPeriodChanged:o,availableBillingPeriods:s,isCustomerOnTrial:l,onPlanSelected:p,paywallLocale:f,locale:b,shouldHidePlan:S,selectDefaultTierIndex:P,currentSubscriptionOverride:I,hideCompatibleAddons:T,showWatermark:F})=>{let k=mx(t),R=t.some(Y=>!!Y.description),N=bv(t,Se.Monthly),j=bv(t,Se.Annually),H=yx(t,i,S),Q=useCallback((Y,ot,pt)=>p({plan:Y,customer:e,subscription:n,intentionType:ot,selectedBillingPeriod:i,billableFeatures:pt}),[e,i,n,p]),it=!!n&&n.plan.pricingType===On.Custom,st=useMemo(()=>H.some(Y=>{var ut;let ot=Y.pricePoints.filter(mt=>mt.billingPeriod===i),pt=(ut=Y.paywallCalculatedPricePoints)==null?void 0:ut.find(mt=>mt.billingPeriod===i);return ot.length>1&&!!(pt!=null&&pt.additionalChargesMayApply)}),[i,H]),U=useMemo(()=>H.some(Y=>!!Ih(Y,i,f,b,N).unit),[i,N,b,f,H]),V=useMemo(()=>!it&&H.some(Y=>{let ot=Th({plan:Y,billingPeriod:i,currentSubscription:n,currentSubscriptionOverride:I});return Object.values(ot).length>0}),[i,n,I,it,H]),dt=H.some(Y=>Y.isCurrentCustomerPlan&&Y.trialDaysLeft);return jsx(TF,{className:"stigg-paywall-container",children:jsxs(IF,{className:"stigg-paywall-layout",children:[jsx(ux,{onBillingPeriodChanged:o,selectedBillingPeriod:i,availableBillingPeriods:s,discountRate:k}),jsx(EF,{className:"stigg-paywall-plans-layout",children:H.map(Y=>jsx(cx,{withUnitPriceRow:U,withTiersRow:V,withTrialLeftRow:dt,shouldShowDescriptionSection:R,hasMonthlyPrice:N,hasAnnuallyPrice:j,plan:Y,withStartingAtRow:st,currentSubscription:n,currentSubscriptionOverride:I,billingPeriod:i,isHighlighted:Y.id===r,isCustomerOnTrial:l,onPlanSelected:(ot,pt)=>Q(Y,ot,pt),paywallLocale:f,locale:b,customer:e,isCustomerInCustomPlan:it,selectDefaultTierIndex:P,hideCompatibleAddons:T},Y.id))}),jsx(go,{source:"paywall",align:"end",style:{marginTop:16},showWatermark:F})]})})};var Cv=class{error(e,n,...r){console.error(e,n||{},r);}log(e,n){console.log(e,n||{});}debug(e,n){console.debug(e,n||{});}},sc=new Cv;function vx(t,e,n){let r=t.flatMap(l=>l.pricePoints).map(l=>l.billingPeriod),i=countBy(r),o=uniq(r),s;if(n&&o.includes(n))s=n;else if(e){let l=e.find(p=>p.status===_i.Active);l&&l.prices.length>0&&(s=l==null?void 0:l.prices[0].billingPeriod);}return s||(s=(i[Se.Monthly]||0)>(i[Se.Annually]||0)?Se.Monthly:Se.Annually),{defaultBillingPeriod:s,availableBillingPeriods:o}}function Sx(t){return E1.utc(t).diff(E1.utc(),"days",false)+1}var Dh={h1:{fontSize:"24px",fontWeight:"bold",semanticElement:"h1"},h2:{fontSize:"16px",fontWeight:"normal",semanticElement:"h2"},h3:{fontSize:"16px",fontWeight:"normal",semanticElement:"h3"},body:{fontSize:"14px",fontWeight:"normal",semanticElement:"p"}};function cc(t,e="px"){if(t)return `${t}${e}`}function kh(t){if(!t)return "normal";switch(t){case zb.Normal:return "normal";case zb.Bold:return "bold";default:return "normal"}}function of(t,e){var r,i,o,s,l,p,f,b;let n=e||{h1:{fontSize:"32px",fontWeight:"bold",semanticElement:"h1"},h2:{fontSize:"24px",fontWeight:"normal",semanticElement:"h2"},h3:{fontSize:"16px",fontWeight:"normal",semanticElement:"h3"},body:{fontSize:"14px",fontWeight:"normal",semanticElement:"p"}};return {fontFamilyUrl:(t==null?void 0:t.fontFamily)||void 0,h1:{fontSize:cc((r=t==null?void 0:t.h1)==null?void 0:r.fontSize)||n.h1.fontSize,fontWeight:kh((i=t==null?void 0:t.h1)==null?void 0:i.fontWeight)||n.h1.fontWeight,semanticElement:n.h1.semanticElement},h2:{fontSize:cc((o=t==null?void 0:t.h2)==null?void 0:o.fontSize)||n.h2.fontSize,fontWeight:kh((s=t==null?void 0:t.h2)==null?void 0:s.fontWeight)||n.h2.fontWeight,semanticElement:n.h2.semanticElement},h3:{fontSize:cc((l=t==null?void 0:t.h3)==null?void 0:l.fontSize)||n.h3.fontSize,fontWeight:kh((p=t==null?void 0:t.h3)==null?void 0:p.fontWeight)||n.h3.fontWeight,semanticElement:n.h3.semanticElement},body:{fontSize:cc((f=t==null?void 0:t.body)==null?void 0:f.fontSize)||n.body.fontSize,fontWeight:kh((b=t==null?void 0:t.body)==null?void 0:b.fontWeight)||n.body.fontWeight,semanticElement:n.body.semanticElement}}}function Sv(t){if(t)switch(t){case hh.Left:return "left";case hh.Center:return "center";case hh.Right:return "right";default:return}}function xx(t){let{palette:e,customCss:n,typography:r}=t;return {palette:{primary:(e==null?void 0:e.primary)||void 0,backgroundPaper:(e==null?void 0:e.paywallBackgroundColor)||void 0,outlinedBorder:(e==null?void 0:e.borderColor)||void 0,backgroundHighlight:(e==null?void 0:e.currentPlanBackground)||void 0,text:{primary:(e==null?void 0:e.textColor)||void 0}},typography:of(r),customCss:n||void 0}}function Px(t){let{palette:e,layout:n,customCss:r,typography:i}=t;return {customCss:r||void 0,palette:{primary:(e==null?void 0:e.primary)||void 0,backgroundPaper:(e==null?void 0:e.backgroundColor)||void 0,outlinedBorder:(e==null?void 0:e.borderColor)||void 0,backgroundHighlight:(e==null?void 0:e.currentPlanBackground)||void 0,text:{primary:(e==null?void 0:e.textColor)||void 0}},typography:of(i),layout:{ctaAlignment:Sv(n==null?void 0:n.alignment),headerAlignment:Sv(n==null?void 0:n.alignment),descriptionAlignment:Sv(n==null?void 0:n.alignment),planMaxWidth:cc(n==null?void 0:n.planWidth),planMinWidth:cc(n==null?void 0:n.planWidth),planMargin:cc(n==null?void 0:n.planMargin),planPadding:cc(n==null?void 0:n.planPadding)}}}function _x(t){let{palette:e,typography:n,customCss:r}=t;return {palette:{primary:(e==null?void 0:e.primary)||void 0,backgroundPaper:(e==null?void 0:e.backgroundColor)||void 0,outlinedBorder:(e==null?void 0:e.borderColor)||void 0,text:{primary:(e==null?void 0:e.textColor)||void 0},backgroundHighlight:(e==null?void 0:e.summaryBackgroundColor)||void 0},typography:of(n,Dh),customCss:r||void 0}}function FF(t){let e=true,n=(t==null?void 0:t.find(o=>o.status===_i.InTrial))||null,r=n==null?void 0:n.plan,i=n!=null&&n.trialEndDate?Sx(n.trialEndDate):void 0;return r||(e=false,n=(t==null?void 0:t.find(o=>o.status===_i.Active))||null,r=n==null?void 0:n.plan),{currentSubscription:n,currentPlan:r,isCustomerOnTrial:e,trialDaysLeft:i}}function Tx(t,e,n){var H,Q;let{plans:r,currency:i,configuration:o,customer:s,activeSubscriptions:l,paywallCalculatedPricePoints:p}=t||{},{currentSubscription:f,currentPlan:b,isCustomerOnTrial:S,trialDaysLeft:P}=FF(l),I=n==null?void 0:n({currentSubscription:f}),T=(f==null?void 0:f.scheduledUpdates)||[],F=(H=f==null?void 0:f.price)==null?void 0:H.billingPeriod,k=T.find(({subscriptionScheduleType:it})=>it===Wi.Downgrade),R=T.find(({subscriptionScheduleType:it})=>it===Wi.BillingPeriod),N=o_(r,it=>it.order).map(it=>{var dt;let st=(dt=s==null?void 0:s.eligibleForTrial)==null?void 0:dt.find(Y=>Y.productId===it.product.id),U=I!=null&&I.planId?(I==null?void 0:I.planId)===it.id:it.id===(b==null?void 0:b.id),V=Y=>{var mt;let ot=k==null?void 0:k.scheduleVariables,pt=R==null?void 0:R.scheduleVariables,ut=it.pricePoints.some(bt=>bt.billingPeriod===Y);return k?((mt=k.targetPackage)==null?void 0:mt.refId)===it.id&&(!ut||ot.billingPeriod===Y):R&&U?pt.billingPeriod===Y:false};return vt(q({},it),{paywallCalculatedPricePoints:p==null?void 0:p.filter(Y=>Y.planId===it.id),isTriable:!Eh(it.defaultTrialConfig)&&(!st||st.eligible),isCurrentCustomerPlan:U,currentCustomerPlanBillingPeriod:F,isUpcomingPlan:false,trialDaysLeft:P,isNextPlan:V,paywallCurrency:i,scheduledUpdate:k||R})});if(r&&b){let it=b&&((Q=r==null?void 0:r.find(st=>st.id===(b==null?void 0:b.id)))==null?void 0:Q.order);Eh(it)||(N=N.map(st=>vt(q({},st),{isLowerThanCurrentPlan:it>st.order})),e&&(N=N.filter(st=>st.order>=it)));}let j=o?Px(o):void 0;return {currentPlan:b,currentSubscription:f,currentSubscriptionOverride:I,isCustomerOnTrial:S,plans:N,paywallConfiguration:j}}var wx="7.18.2";var Ax="@stigg/react-sdk";var af=g0.createContext(null);af.displayName="StiggContext";var LF="en-US",BF=({apiKey:t,baseUri:e,baseEdgeUri:n,enableEdge:r,customerId:i,customerToken:o,resourceId:s,theme:l,locale:p,cacheTtlMs:f,useEntitlementPolling:b,entitlementPollingInterval:S,entitlementsFallback:P,stiggClient:I,children:T,offline:F,clientName:k=Ax,clientVersion:R=wx})=>{let N=useRef(t),j={apiKey:t,customerId:i,customerToken:o,resourceId:s,baseUri:e,baseEdgeUri:n,enableEdge:r,entitlementsFallback:P,cacheTtlMs:f,useEntitlementPolling:b,entitlementPollingInterval:S,clientName:k,clientVersion:R,offline:F},[H,Q]=useState(()=>({stigg:I!=null?I:qb.initialize(vt(q({},j),{lazyLoad:true})),locale:p||LF,isInitialized:false,theme:l,refreshData:()=>ie(null,null,function*(){Q(it=>vt(q({},it),{customerPortalUpdatedAt:new Date})),yield H.stigg.refresh();})}));return useEffect(()=>{let it=true,st=Y=>{it&&Q(Y);},U=()=>st(Y=>vt(q({},Y),{updatedAt:new Date})),V=Y=>st(ot=>(ot.stigg&&ot.stigg.removeListener("entitlementsUpdated",U),Y.addListener("entitlementsUpdated",U),vt(q({},ot),{stigg:Y,isInitialized:true,updatedAt:new Date})));return ie(null,null,function*(){let Y=H.stigg;t!==N.current&&(sc.log("Updating stigg client",{apiKey:t}),N.current=t,Y=qb.initialize(q({},j)),st(ot=>vt(q({},ot),{isInitialized:false,updatedAt:new Date}))),yield Y.waitForInitialization(),V(Y);}),()=>{it=false,H.stigg.removeListener("entitlementsUpdated",U),H.stigg.clearCustomer();}},[t]),useEffect(()=>{let it=H.stigg;i?it.setCustomerId(i,o,s):it.clearCustomer();},[i,o,s]),useEffect(()=>{Q(it=>vt(q({},it),{theme:l}));},[l]),jsx(af.Provider,{value:H,children:jsx(SkeletonTheme,{baseColor:"#F5F6F9",highlightColor:"#e5e6ea",children:T})})};function ce(t){let{optional:e}=t||{},n=useContext(af);if(!n&&!e)throw new Error("Could not find Stigg context; You need to wrap your app in an <StiggProvider> component.");return n}function kx({productId:t,resourceId:e,showOnlyEligiblePlans:n,billingCountryCode:r,preferredBillingPeriod:i,currentSubscriptionOverrideFn:o}){let{stigg:s,locale:l}=ce(),[p,f]=useState(Se.Annually),[b,S]=useState([]),[P,I]=useState(null),[T,F]=useState(true);useEffect(()=>{ie(null,null,function*(){try{F(!0),yield s.waitForInitialization();let N=yield s.getPaywall({productId:t,resourceId:e,billingCountryCode:r}),{availableBillingPeriods:j,defaultBillingPeriod:H}=vx(N.plans,N.activeSubscriptions,i);I(N),S(j),f(H);}catch(N){sc.error(`Failed to load paywall ${N==null?void 0:N.message}`,N);}finally{F(false);}});},[s,t,s.isCustomerLoaded,r,e,i]);let k=Tx(P,n,o);return q({customer:(P==null?void 0:P.customer)||null,isLoading:T,selectedBillingPeriod:p,setSelectedBillingPeriod:f,availableBillingPeriods:b,locale:l,configuration:k.paywallConfiguration,showWatermark:s.getShowWatermark()},k)}function Fx(t){return n2({highlightChip:"Recommended",addonsTitle:"Available add-ons:",planCTAButton:{upgrade:"Upgrade",downgrade:"Downgrade",startTrial:n=>{var r;return `Start ${(r=n.defaultTrialConfig)==null?void 0:r.duration} day trial`},custom:"Contact us",currentPlan:"Current plan",startNew:"Get started",switchToBillingPeriod:n=>n===Se.Monthly?"Switch to monthly billing":"Switch to annual billing",cancelScheduledUpdate:"Cancel"},price:{startingAtCaption:"Starts at",pricePeriod:n=>n===Se.Monthly?"/ month":"/ year",free:n=>({price:`${n==null?void 0:n.symbol}0`}),custom:"Custom",priceNotSet:"Price not set"}},t)}var VF=t=>jsx("svg",vt(q({width:15,height:11,viewBox:"0 0 15 11",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t),{children:jsx("path",{d:"M5.59 7.9899L2.125 4.5249C1.73524 4.13514 1.10365 4.13402 0.712509 4.52241V4.52241C0.319409 4.91274 0.318286 5.54819 0.710005 5.9399L5.59 10.8199L14.2948 2.11513C14.6843 1.72565 14.6843 1.09417 14.2948 0.704691V0.704691C13.9055 0.315381 13.2743 0.315184 12.8848 0.70425L5.59 7.9899Z",fill:"#B2BBD3"})})),Ox=VF;var jF=W.div`
5148
+ `,bx=({plans:t,customer:e,currentSubscription:n,highlightedPlanId:r,selectedBillingPeriod:i,onBillingPeriodChanged:o,availableBillingPeriods:s,isCustomerOnTrial:l,onPlanSelected:p,paywallLocale:f,locale:b,shouldHidePlan:S,selectDefaultTierIndex:P,currentSubscriptionOverride:I,hideCompatibleAddons:T,showWatermark:F})=>{let k=mx(t),R=t.some(Y=>!!Y.description),N=bv(t,Se.Monthly),j=bv(t,Se.Annually),H=yx(t,i,S),Q=useCallback((Y,ot,pt)=>p({plan:Y,customer:e,subscription:n,intentionType:ot,selectedBillingPeriod:i,billableFeatures:pt}),[e,i,n,p]),it=!!n&&n.plan.pricingType===On.Custom,st=useMemo(()=>H.some(Y=>{var ut;let ot=Y.pricePoints.filter(mt=>mt.billingPeriod===i),pt=(ut=Y.paywallCalculatedPricePoints)==null?void 0:ut.find(mt=>mt.billingPeriod===i);return ot.length>1&&!!(pt!=null&&pt.additionalChargesMayApply)}),[i,H]),U=useMemo(()=>H.some(Y=>!!Ih(Y,i,f,b,N).unit),[i,N,b,f,H]),V=useMemo(()=>!it&&H.some(Y=>{let ot=Th({plan:Y,billingPeriod:i,currentSubscription:n,currentSubscriptionOverride:I});return Object.values(ot).length>0}),[i,n,I,it,H]),dt=H.some(Y=>Y.isCurrentCustomerPlan&&Y.trialDaysLeft);return jsx(TF,{className:"stigg-paywall-container",children:jsxs(IF,{className:"stigg-paywall-layout",children:[jsx(ux,{onBillingPeriodChanged:o,selectedBillingPeriod:i,availableBillingPeriods:s,discountRate:k}),jsx(EF,{className:"stigg-paywall-plans-layout",children:H.map(Y=>jsx(cx,{withUnitPriceRow:U,withTiersRow:V,withTrialLeftRow:dt,shouldShowDescriptionSection:R,hasMonthlyPrice:N,hasAnnuallyPrice:j,plan:Y,withStartingAtRow:st,currentSubscription:n,currentSubscriptionOverride:I,billingPeriod:i,isHighlighted:Y.id===r,isCustomerOnTrial:l,onPlanSelected:(ot,pt)=>Q(Y,ot,pt),paywallLocale:f,locale:b,customer:e,isCustomerInCustomPlan:it,selectDefaultTierIndex:P,hideCompatibleAddons:T},Y.id))}),jsx(go,{source:"paywall",align:"end",style:{marginTop:16},showWatermark:F})]})})};var Cv=class{error(e,n,...r){console.error(e,n||{},r);}log(e,n){console.log(e,n||{});}debug(e,n){console.debug(e,n||{});}},sc=new Cv;function vx(t,e,n){let r=t.flatMap(l=>l.pricePoints).map(l=>l.billingPeriod),i=countBy(r),o=uniq(r),s;if(n&&o.includes(n))s=n;else if(e){let l=e.find(p=>p.status===_i.Active);l&&l.prices.length>0&&(s=l==null?void 0:l.prices[0].billingPeriod);}return s||(s=(i[Se.Monthly]||0)>(i[Se.Annually]||0)?Se.Monthly:Se.Annually),{defaultBillingPeriod:s,availableBillingPeriods:o}}function Sx(t){return E1.utc(t).diff(E1.utc(),"days",false)+1}var Dh={h1:{fontSize:"24px",fontWeight:"bold",semanticElement:"h1"},h2:{fontSize:"16px",fontWeight:"normal",semanticElement:"h2"},h3:{fontSize:"16px",fontWeight:"normal",semanticElement:"h3"},body:{fontSize:"14px",fontWeight:"normal",semanticElement:"p"}};function cc(t,e="px"){if(t)return `${t}${e}`}function kh(t){if(!t)return "normal";switch(t){case zb.Normal:return "normal";case zb.Bold:return "bold";default:return "normal"}}function of(t,e){var r,i,o,s,l,p,f,b;let n=e||{h1:{fontSize:"32px",fontWeight:"bold",semanticElement:"h1"},h2:{fontSize:"24px",fontWeight:"normal",semanticElement:"h2"},h3:{fontSize:"16px",fontWeight:"normal",semanticElement:"h3"},body:{fontSize:"14px",fontWeight:"normal",semanticElement:"p"}};return {fontFamilyUrl:(t==null?void 0:t.fontFamily)||void 0,h1:{fontSize:cc((r=t==null?void 0:t.h1)==null?void 0:r.fontSize)||n.h1.fontSize,fontWeight:kh((i=t==null?void 0:t.h1)==null?void 0:i.fontWeight)||n.h1.fontWeight,semanticElement:n.h1.semanticElement},h2:{fontSize:cc((o=t==null?void 0:t.h2)==null?void 0:o.fontSize)||n.h2.fontSize,fontWeight:kh((s=t==null?void 0:t.h2)==null?void 0:s.fontWeight)||n.h2.fontWeight,semanticElement:n.h2.semanticElement},h3:{fontSize:cc((l=t==null?void 0:t.h3)==null?void 0:l.fontSize)||n.h3.fontSize,fontWeight:kh((p=t==null?void 0:t.h3)==null?void 0:p.fontWeight)||n.h3.fontWeight,semanticElement:n.h3.semanticElement},body:{fontSize:cc((f=t==null?void 0:t.body)==null?void 0:f.fontSize)||n.body.fontSize,fontWeight:kh((b=t==null?void 0:t.body)==null?void 0:b.fontWeight)||n.body.fontWeight,semanticElement:n.body.semanticElement}}}function Sv(t){if(t)switch(t){case hh.Left:return "left";case hh.Center:return "center";case hh.Right:return "right";default:return}}function xx(t){let{palette:e,customCss:n,typography:r}=t;return {palette:{primary:(e==null?void 0:e.primary)||void 0,backgroundPaper:(e==null?void 0:e.paywallBackgroundColor)||void 0,outlinedBorder:(e==null?void 0:e.borderColor)||void 0,backgroundHighlight:(e==null?void 0:e.currentPlanBackground)||void 0,text:{primary:(e==null?void 0:e.textColor)||void 0}},typography:of(r),customCss:n||void 0}}function Px(t){let{palette:e,layout:n,customCss:r,typography:i}=t;return {customCss:r||void 0,palette:{primary:(e==null?void 0:e.primary)||void 0,backgroundPaper:(e==null?void 0:e.backgroundColor)||void 0,outlinedBorder:(e==null?void 0:e.borderColor)||void 0,backgroundHighlight:(e==null?void 0:e.currentPlanBackground)||void 0,text:{primary:(e==null?void 0:e.textColor)||void 0}},typography:of(i),layout:{ctaAlignment:Sv(n==null?void 0:n.alignment),headerAlignment:Sv(n==null?void 0:n.alignment),descriptionAlignment:Sv(n==null?void 0:n.alignment),planMaxWidth:cc(n==null?void 0:n.planWidth),planMinWidth:cc(n==null?void 0:n.planWidth),planMargin:cc(n==null?void 0:n.planMargin),planPadding:cc(n==null?void 0:n.planPadding)}}}function _x(t){let{palette:e,typography:n,customCss:r}=t;return {palette:{primary:(e==null?void 0:e.primary)||void 0,backgroundPaper:(e==null?void 0:e.backgroundColor)||void 0,outlinedBorder:(e==null?void 0:e.borderColor)||void 0,text:{primary:(e==null?void 0:e.textColor)||void 0},backgroundHighlight:(e==null?void 0:e.summaryBackgroundColor)||void 0},typography:of(n,Dh),customCss:r||void 0}}function FF(t){let e=true,n=(t==null?void 0:t.find(o=>o.status===_i.InTrial))||null,r=n==null?void 0:n.plan,i=n!=null&&n.trialEndDate?Sx(n.trialEndDate):void 0;return r||(e=false,n=(t==null?void 0:t.find(o=>o.status===_i.Active))||null,r=n==null?void 0:n.plan),{currentSubscription:n,currentPlan:r,isCustomerOnTrial:e,trialDaysLeft:i}}function Tx(t,e,n){var H,Q;let{plans:r,currency:i,configuration:o,customer:s,activeSubscriptions:l,paywallCalculatedPricePoints:p}=t||{},{currentSubscription:f,currentPlan:b,isCustomerOnTrial:S,trialDaysLeft:P}=FF(l),I=n==null?void 0:n({currentSubscription:f}),T=(f==null?void 0:f.scheduledUpdates)||[],F=(H=f==null?void 0:f.price)==null?void 0:H.billingPeriod,k=T.find(({subscriptionScheduleType:it})=>it===Wi.Downgrade),R=T.find(({subscriptionScheduleType:it})=>it===Wi.BillingPeriod),N=o_(r,it=>it.order).map(it=>{var dt;let st=(dt=s==null?void 0:s.eligibleForTrial)==null?void 0:dt.find(Y=>Y.productId===it.product.id),U=I!=null&&I.planId?(I==null?void 0:I.planId)===it.id:it.id===(b==null?void 0:b.id),V=Y=>{var mt;let ot=k==null?void 0:k.scheduleVariables,pt=R==null?void 0:R.scheduleVariables,ut=it.pricePoints.some(bt=>bt.billingPeriod===Y);return k?((mt=k.targetPackage)==null?void 0:mt.refId)===it.id&&(!ut||ot.billingPeriod===Y):R&&U?pt.billingPeriod===Y:false};return vt(q({},it),{paywallCalculatedPricePoints:p==null?void 0:p.filter(Y=>Y.planId===it.id),isTriable:!Eh(it.defaultTrialConfig)&&(!st||st.eligible),isCurrentCustomerPlan:U,currentCustomerPlanBillingPeriod:F,isUpcomingPlan:false,trialDaysLeft:P,isNextPlan:V,paywallCurrency:i,scheduledUpdate:k||R})});if(r&&b){let it=b&&((Q=r==null?void 0:r.find(st=>st.id===(b==null?void 0:b.id)))==null?void 0:Q.order);Eh(it)||(N=N.map(st=>vt(q({},st),{isLowerThanCurrentPlan:it>st.order})),e&&(N=N.filter(st=>st.order>=it)));}let j=o?Px(o):void 0;return {currentPlan:b,currentSubscription:f,currentSubscriptionOverride:I,isCustomerOnTrial:S,plans:N,paywallConfiguration:j}}var wx="7.19.0";var Ax="@stigg/react-sdk";var af=g0.createContext(null);af.displayName="StiggContext";var LF="en-US",BF=({apiKey:t,baseUri:e,baseEdgeUri:n,enableEdge:r,customerId:i,customerToken:o,resourceId:s,theme:l,locale:p,cacheTtlMs:f,useEntitlementPolling:b,entitlementPollingInterval:S,entitlementsFallback:P,stiggClient:I,children:T,offline:F,clientName:k=Ax,clientVersion:R=wx})=>{let N=useRef(t),j={apiKey:t,customerId:i,customerToken:o,resourceId:s,baseUri:e,baseEdgeUri:n,enableEdge:r,entitlementsFallback:P,cacheTtlMs:f,useEntitlementPolling:b,entitlementPollingInterval:S,clientName:k,clientVersion:R,offline:F},[H,Q]=useState(()=>({stigg:I!=null?I:qb.initialize(vt(q({},j),{lazyLoad:true})),locale:p||LF,isInitialized:false,theme:l,refreshData:()=>ie(null,null,function*(){Q(it=>vt(q({},it),{customerPortalUpdatedAt:new Date})),yield H.stigg.refresh();})}));return useEffect(()=>{let it=true,st=Y=>{it&&Q(Y);},U=()=>st(Y=>vt(q({},Y),{updatedAt:new Date})),V=Y=>st(ot=>(ot.stigg&&ot.stigg.removeListener("entitlementsUpdated",U),Y.addListener("entitlementsUpdated",U),vt(q({},ot),{stigg:Y,isInitialized:true,updatedAt:new Date})));return ie(null,null,function*(){let Y=H.stigg;t!==N.current&&(sc.log("Updating stigg client",{apiKey:t}),N.current=t,Y=qb.initialize(q({},j)),st(ot=>vt(q({},ot),{isInitialized:false,updatedAt:new Date}))),yield Y.waitForInitialization(),V(Y);}),()=>{it=false,H.stigg.removeListener("entitlementsUpdated",U),H.stigg.clearCustomer();}},[t]),useEffect(()=>{let it=H.stigg;i?it.setCustomerId(i,o,s):it.clearCustomer();},[i,o,s]),useEffect(()=>{Q(it=>vt(q({},it),{theme:l}));},[l]),jsx(af.Provider,{value:H,children:jsx(SkeletonTheme,{baseColor:"#F5F6F9",highlightColor:"#e5e6ea",children:T})})};function ce(t){let{optional:e}=t||{},n=useContext(af);if(!n&&!e)throw new Error("Could not find Stigg context; You need to wrap your app in an <StiggProvider> component.");return n}function kx({productId:t,resourceId:e,showOnlyEligiblePlans:n,billingCountryCode:r,preferredBillingPeriod:i,currentSubscriptionOverrideFn:o}){let{stigg:s,locale:l}=ce(),[p,f]=useState(Se.Annually),[b,S]=useState([]),[P,I]=useState(null),[T,F]=useState(true);useEffect(()=>{ie(null,null,function*(){try{F(!0),yield s.waitForInitialization();let N=yield s.getPaywall({productId:t,resourceId:e,billingCountryCode:r}),{availableBillingPeriods:j,defaultBillingPeriod:H}=vx(N.plans,N.activeSubscriptions,i);I(N),S(j),f(H);}catch(N){sc.error(`Failed to load paywall ${N==null?void 0:N.message}`,N);}finally{F(false);}});},[s,t,s.isCustomerLoaded,r,e,i]);let k=Tx(P,n,o);return q({customer:(P==null?void 0:P.customer)||null,isLoading:T,selectedBillingPeriod:p,setSelectedBillingPeriod:f,availableBillingPeriods:b,locale:l,configuration:k.paywallConfiguration,showWatermark:s.getShowWatermark()},k)}function Fx(t){return n2({highlightChip:"Recommended",addonsTitle:"Available add-ons:",planCTAButton:{upgrade:"Upgrade",downgrade:"Downgrade",startTrial:n=>{var r;return `Start ${(r=n.defaultTrialConfig)==null?void 0:r.duration} day trial`},custom:"Contact us",currentPlan:"Current plan",startNew:"Get started",switchToBillingPeriod:n=>n===Se.Monthly?"Switch to monthly billing":"Switch to annual billing",cancelScheduledUpdate:"Cancel"},price:{startingAtCaption:"Starts at",pricePeriod:n=>n===Se.Monthly?"/ month":"/ year",free:n=>({price:`${n==null?void 0:n.symbol}0`}),custom:"Custom",priceNotSet:"Price not set"}},t)}var VF=t=>jsx("svg",vt(q({width:15,height:11,viewBox:"0 0 15 11",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t),{children:jsx("path",{d:"M5.59 7.9899L2.125 4.5249C1.73524 4.13514 1.10365 4.13402 0.712509 4.52241V4.52241C0.319409 4.91274 0.318286 5.54819 0.710005 5.9399L5.59 10.8199L14.2948 2.11513C14.6843 1.72565 14.6843 1.09417 14.2948 0.704691V0.704691C13.9055 0.315381 13.2743 0.315184 12.8848 0.70425L5.59 7.9899Z",fill:"#B2BBD3"})})),Ox=VF;var jF=W.div`
5149
5149
  display: flex;
5150
5150
  flex-direction: column;
5151
5151
  align-items: center;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "7.18.2",
2
+ "version": "7.19.0",
3
3
  "license": "MIT",
4
4
  "main": "dist/stigg-sdk.cjs.js",
5
5
  "types": "dist/index.d.ts",