@tinkerlandai/longplay-sdk 0.10.76 → 0.10.78
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.
- package/CHANGELOG.md +9 -0
- package/dist/check-response-DO2R3PE6.js +1 -0
- package/dist/{chunk-4G52SO64.js → chunk-2HIWXIJE.js} +1 -1
- package/dist/{chunk-MWTSCBSY.js → chunk-4CJUGCMG.js} +1 -1
- package/dist/{chunk-YMTCZWZG.js → chunk-5MPALDJL.js} +1 -1
- package/dist/{chunk-E4B7243C.js → chunk-5X7PTCI4.js} +1 -1
- package/dist/{chunk-LYTPUZOW.js → chunk-6FWT2BXF.js} +1 -1
- package/dist/{chunk-Q6SK6G7T.js → chunk-6NDL2ELB.js} +1 -1
- package/dist/{chunk-YDGJ3KEY.js → chunk-7RBU7UEU.js} +1 -1
- package/dist/{chunk-65QMZQE6.js → chunk-ABLGIN4X.js} +1 -1
- package/dist/{chunk-EQJIC52H.js → chunk-BN6UIKEV.js} +1 -1
- package/dist/{chunk-CLV4ROBM.js → chunk-BSPJMJDI.js} +1 -1
- package/dist/{chunk-SHJUMRYM.js → chunk-CAOUMQZ6.js} +1 -1
- package/dist/{chunk-ES77Y76B.js → chunk-CDFRRXSQ.js} +1 -1
- package/dist/{chunk-DRCBHEC6.js → chunk-CW7MTKXP.js} +1 -1
- package/dist/{chunk-TDPFVHJM.js → chunk-CZ33YJWK.js} +1 -1
- package/dist/{chunk-BB6PDBS4.js → chunk-D7SPHHSF.js} +1 -1
- package/dist/{chunk-H3LBNH34.js → chunk-DLLC7CRI.js} +1 -1
- package/dist/chunk-E773KSFH.js +1 -0
- package/dist/{chunk-SUUBL2WC.js → chunk-EDZJ2IGA.js} +1 -1
- package/dist/{chunk-QJLVJLVX.js → chunk-FVYB2P6Y.js} +1 -1
- package/dist/{chunk-XSEYXS4X.js → chunk-FWM3577O.js} +1 -1
- package/dist/{chunk-TQKNQGWV.js → chunk-HEPQNLR2.js} +1 -1
- package/dist/chunk-HOX2FQQE.js +1 -0
- package/dist/{chunk-CJJ4R645.js → chunk-HXWWH644.js} +1 -1
- package/dist/{chunk-WTZQYCQ2.js → chunk-HXXUZ6RR.js} +2 -2
- package/dist/{chunk-3ZYWGEBY.js → chunk-IB6BBGLM.js} +1 -1
- package/dist/{chunk-ZL7YW35H.js → chunk-IEKRWGRV.js} +1 -1
- package/dist/{chunk-2AFZOVAE.js → chunk-IHAMRL3F.js} +1 -1
- package/dist/{chunk-QLMQI6SX.js → chunk-IXDARDPI.js} +1 -1
- package/dist/{chunk-DMMD4TMS.js → chunk-JXVZK3RZ.js} +1 -1
- package/dist/{chunk-T5QI2ZZR.js → chunk-L6XCRIR2.js} +1 -1
- package/dist/{chunk-66SRWQES.js → chunk-LUYWRWJ2.js} +1 -1
- package/dist/{chunk-X6ZYJHX4.js → chunk-LWIBARE4.js} +1 -1
- package/dist/{chunk-TZTWXL53.js → chunk-LZYQA3Q4.js} +1 -1
- package/dist/{chunk-KCRL2BDG.js → chunk-N6RBDJ5Y.js} +1 -1
- package/dist/{chunk-ZIYU3HLD.js → chunk-NJNENW5L.js} +1 -1
- package/dist/{chunk-B7CFFTJI.js → chunk-OZ32ZMZZ.js} +1 -1
- package/dist/{chunk-S5KGFAAW.js → chunk-PX7APKZR.js} +1 -1
- package/dist/{chunk-STASMAS7.js → chunk-R4ETTZ2H.js} +1 -1
- package/dist/{chunk-464CINQK.js → chunk-SQMA5YYI.js} +1 -1
- package/dist/{chunk-CWBL2S3A.js → chunk-T44KC4GO.js} +1 -1
- package/dist/{chunk-FINCNJBH.js → chunk-TJRXWGKB.js} +1 -1
- package/dist/{chunk-IEYSWIRA.js → chunk-VEGGHQTQ.js} +1 -1
- package/dist/{chunk-RM6RSLKI.js → chunk-VZMLPENL.js} +1 -1
- package/dist/{chunk-62MMCXIA.js → chunk-XLOCTL2Y.js} +1 -1
- package/dist/{chunk-5SNUVXZ7.js → chunk-XX5O7H6R.js} +1 -1
- package/dist/{chunk-JJIOGZIP.js → chunk-YXD5B3UB.js} +1 -1
- package/dist/{chunk-NUIKM2BY.js → chunk-ZBV6DOEY.js} +1 -1
- package/dist/chunk-ZP5XCBBK.js +1 -0
- package/dist/{content-XPEXTRMO.js → content-AD7CZRT4.js} +1 -1
- package/dist/{funnel-host-purchase-IKDKPYVN.js → funnel-host-purchase-45TUH4H2.js} +1 -1
- package/dist/funnel-host-recovery-paywall-JQWNXDLS.js +1 -0
- package/dist/{funnel-paywall-copies-43CVL4UQ.js → funnel-paywall-copies-BPHMFJ2K.js} +1 -1
- package/dist/funnel-paywall-prerender-RSXERNQ3.js +1 -0
- package/dist/funnel-route-prediction-G4OKIQGD.js +1 -0
- package/dist/funnel-route-source-W4R62B7H.js +1 -0
- package/dist/funnel-runtime-host-TQAFDG3X.js +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +1 -1
- package/dist/merchant-bridge-contracts-ADLTLAJJ.js +1 -0
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.js +1 -1
- package/dist/operation-contracts-WLKY7HAO.js +1 -0
- package/dist/page.js +1 -1
- package/dist/paywall-3P5YKZRE.js +1 -0
- package/dist/paywall-content-JJCSFM6J.js +1 -0
- package/dist/paywall-session-AWH5GSKC.js +1 -0
- package/dist/popup.js +1 -1
- package/dist/react-native.js +1 -1
- package/dist/screen-renderer-TZIU775B.js +1 -0
- package/dist/server.js +1 -1
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/check-response-LYK2HZFK.js +0 -1
- package/dist/chunk-4N7PVGHA.js +0 -1
- package/dist/chunk-KQE32GKG.js +0 -1
- package/dist/chunk-W6KE7753.js +0 -1
- package/dist/funnel-host-recovery-paywall-526KDYRO.js +0 -1
- package/dist/funnel-paywall-prerender-63YAPNPP.js +0 -1
- package/dist/funnel-route-prediction-DXMYNMCA.js +0 -1
- package/dist/funnel-route-source-2OGRCZKX.js +0 -1
- package/dist/funnel-runtime-host-NUYFCCBB.js +0 -1
- package/dist/merchant-bridge-contracts-MEMS65CV.js +0 -1
- package/dist/operation-contracts-L3CZMIL6.js +0 -1
- package/dist/paywall-ZFSJSI6N.js +0 -1
- package/dist/paywall-content-IERCHHQ5.js +0 -1
- package/dist/paywall-session-QDO32X66.js +0 -1
- package/dist/screen-renderer-IKROGLA7.js +0 -1
- /package/dist/{chunk-WTZQYCQ2.js.LEGAL.txt → chunk-HXXUZ6RR.js.LEGAL.txt} +0 -0
- /package/dist/{chunk-7RUOZL6C.js → chunk-J6MYX7WY.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as E,b as M,c as j,d as O,e as T}from"./chunk-
|
|
1
|
+
import{a as E,b as M,c as j,d as O,e as T}from"./chunk-HXWWH644.js";import{a as u}from"./chunk-5X7PTCI4.js";import{j as w}from"./chunk-XX5O7H6R.js";import{b as t}from"./chunk-J6MYX7WY.js";var _=E,V=t.string().regex(/^(0|[1-9]\d{0,5})(\.\d{1,12})?$/),C=t.strictObject(Object.fromEntries(_.map(i=>[i,t.number().int().nonnegative().max(1e9)]))),L=M,D=j,q=t.strictObject({modelId:L,source:t.enum(["models.dev","custom"]),fetchedAt:t.iso.datetime(),rates:O,contextTier:t.number().int().nonnegative(),markupPercent:D}),U=t.strictObject({pricing:q,tokens:C,quantity:w,digest:t.string().regex(/^[a-f0-9]{64}$/)}),z=i=>{let[s,o=""]=i.split(".");return BigInt(s)*10n**12n+BigInt(o.padEnd(12,"0"))};function $(i){if(typeof i!="number"||!Number.isFinite(i)||i<0)throw new u("AI_PRICE_UNAVAILABLE","A published token price is missing");let s=String(i),o=s.includes("e")?i.toFixed(12).replace(/0+$/,"").replace(/\.$/,""):s;if(Number(o)!==i||!V.safeParse(o).success)throw new u("AI_PRICE_UNAVAILABLE","Published price exceeds the supported precision");return o}var R=t.strictObject({input:t.number().nonnegative(),output:t.number().nonnegative(),cache_read:t.number().nonnegative().optional(),cache_write:t.number().nonnegative().optional(),reasoning:t.number().nonnegative().optional(),input_audio:t.number().nonnegative().optional(),output_audio:t.number().nonnegative().optional()}),F=R.extend({context_over_200k:t.unknown().optional(),tiers:t.array(R.extend({tier:t.strictObject({type:t.literal("context"),size:t.number().int().nonnegative()})})).max(20).refine(i=>new Set(i.map(s=>s.tier.size)).size===i.length).optional()});async function N(i,s,o){let d=new TextEncoder().encode(JSON.stringify({pricing:i,tokens:s,quantity:o}));return[...new Uint8Array(await crypto.subtle.digest("SHA-256",d))].map(m=>m.toString(16).padStart(2,"0")).join("")}function B(i,s){let o=0n;for(let c of _){if(!s[c])continue;let f=i.rates[c];if(f===void 0)throw new u("AI_PRICE_UNAVAILABLE",`No published price for ${c}; report exclusive token pools`);o+=z(f)*BigInt(s[c])}let[d,m="0"]=String(i.markupPercent).split("e"),r=(d.split(".")[1]?.length??0)-Number(m),e=10n**BigInt(Math.max(r,0)),n=BigInt(d.replace(".",""))*10n**BigInt(Math.max(-r,0)),g=100n*e+n,l=100n*e*1000000n,a=(o*g+l-1n)/l;return w.parse(`${a/1000000n}.${(a%1000000n).toString().padStart(6,"0")}`)}function K(i={}){if(typeof window<"u")throw new u("SERVER_ONLY","AI token pricing belongs on your backend");let s=T.parse({defaultMarkup:i.defaultMarkup??0,providerMarkups:i.providerMarkups??{},modelMarkups:i.modelMarkups??{},customModels:i.customModels??{}}),o=null,d=0;async function m(){if(!o||Date.now()>=d){d=Date.now()+15*6e4;let r=(async()=>{let e=await(i.fetch??fetch)("https://models.dev/api.json",{signal:AbortSignal.timeout(3e4)});if(!e.ok)throw new u("AI_PRICE_UNAVAILABLE","Models.dev pricing is unavailable");return{data:t.record(t.string(),t.object({models:t.record(t.string(),t.unknown())})).parse(await e.json()),fetchedAt:new Date().toISOString()}})().catch(e=>{throw o===r&&(o=null),e});o=r}return o}return{refreshPrices(){o=null,d=0},async quoteTokens(r){let e=L.parse(r.modelId),n=C.parse(r.tokens),[g,...l]=e.split("/"),a=s.customModels[e],c,f,p,y=0;if(a?.input!==void 0&&a.output!==void 0&&_.every(A=>n[A]===0||a[A]!==void 0))c={...a,input:a.input,output:a.output},f="custom",p=new Date().toISOString();else{let A=await m(),x=A.data[g]?.models[l.join("/")];if(!x)throw new u("AI_PRICE_UNAVAILABLE","Unknown model; configure a complete custom price");let{cost:I}=t.object({cost:F}).parse(x),P=n.input+n.cache_read+n.cache_write+n.input_audio;if(I.tiers===void 0&&I.context_over_200k!==void 0&&P>2e5)throw new u("AI_PRICE_UNAVAILABLE","A current context tier is required for this model");let b=I.tiers?.filter(k=>P>k.tier.size).sort((k,Q)=>Q.tier.size-k.tier.size)[0],v=b??I;b&&(y=b.tier.size),c=Object.fromEntries(_.filter(k=>v[k]!==void 0).map(k=>[k,$(v[k])])),c={...c,...a},f=a?"custom":"models.dev",p=A.fetchedAt}let h=q.parse({modelId:e,source:f,fetchedAt:p,rates:c,contextTier:y,markupPercent:s.modelMarkups[e]??s.providerMarkups[g]??s.defaultMarkup}),S=B(h,n);return U.parse({pricing:h,tokens:n,quantity:S,digest:await N(h,n,S)})},async trackTokens(r,e){let n=U.parse(e.quote);if(n.quantity!==B(n.pricing,n.tokens)||n.digest!==await N(n.pricing,n.tokens,n.quantity))throw new u("INVALID_REQUEST","AI quote changed after pricing");let g=e.properties??{},l=e.providerCostUsd===void 0?void 0:t.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,18})?$/).parse(e.providerCostUsd),a=e.generationId===void 0?void 0:t.string().min(1).max(120).parse(e.generationId),c=8+ +(l!==void 0)+ +(a!==void 0);if(Object.keys(g).some(p=>p.startsWith("ai_")))throw new u("INVALID_REQUEST","AI tracking reserves ai_ event properties");if(Object.keys(g).length>16-c)throw new u("INVALID_REQUEST","AI tracking properties exceed the available event budget");let f={operation:"consume",internal_feature_id:e.internal_feature_id,quantity:n.quantity,idempotencyKey:e.idempotencyKey,properties:{...g,...l!==void 0?{ai_provider_cost_usd:l}:{},...a!==void 0?{ai_generation_id:a}:{},ai_model:n.pricing.modelId,ai_source:n.pricing.source,ai_price_at:n.pricing.fetchedAt,ai_quote_hash:n.digest,ai_markup:String(n.pricing.markupPercent),ai_tier:String(n.pricing.contextTier),ai_tokens:_.map(p=>n.tokens[p]).join(","),ai_rates:"v1:"+_.map(p=>n.pricing.rates[p]===void 0?"-":z(n.pricing.rates[p]).toString(36)).join(",")},...e.entityId?{entityId:e.entityId}:{}};return r.mutateBalance({customerId:e.customerId,command:f})}}}async function Z(i,s,o={}){let{config:d,model_markups:m}=await i.readAiPricing(s);return K({defaultMarkup:d.default_markup??0,providerMarkups:Object.fromEntries(Object.entries(d.provider_markups??{}).map(([r,e])=>[r,e.markup])),modelMarkups:Object.fromEntries(Object.entries(m??{}).filter(([,r])=>r.markup!==void 0).map(([r,e])=>[r,e.markup])),customModels:Object.fromEntries(Object.entries(m??{}).filter(([,r])=>r.input_cost!==void 0||r.output_cost!==void 0).map(([r,e])=>[r,{...e.input_cost!==void 0?{input:String(e.input_cost)}:{},...e.output_cost!==void 0?{output:String(e.output_cost)}:{}}])),...o})}export{q as a,U as b,K as c,Z as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as d,D as u}from"./chunk-
|
|
1
|
+
import{C as d,D as u}from"./chunk-DLLC7CRI.js";function f(r){let{quote:o,operation:e,requestId:s}=r,a={type:"recover",operationId:e?.operationId??o?.operationId??null,requestId:s};if(r.destroyed||r.pending)return a;if(!e)return o?{type:"cancel",operationId:o.operationId}:a;let t=e.merchantExecution;if(d(e)){if(t&&t.type!=="subscription_change")return a;if(t?.type==="subscription_change"){if(["applied","scheduled"].includes(t.status))return!["applied","not_applicable"].includes(t.fulfillmentStatus)||e.problem?.phase==="fulfillment"||t.problem?.phase==="fulfillment"?{type:"fulfillment",operationId:e.operationId}:{type:t.recordingStatus==="accepted"&&u(e)&&!e.problem&&!t.problem?"complete":"recording",operationId:e.operationId};if(e.status==="pending"&&!e.problem&&!t.problem&&t.nextAction?.type==="redirect"&&(!e.checkoutUrl||t.nextAction.url===e.checkoutUrl)&&Date.parse(t.nextAction.expiresAt)>Date.now()&&t.status==="pending")return{type:"checkout",operationId:e.operationId,checkoutUrl:t.nextAction.url}}if(!e.problem&&!t?.problem&&u(e)&&e.executor!=="merchant")return{type:"complete",operationId:e.operationId};if(e.executor==="indiana"&&e.status==="pending"&&e.checkoutUrl&&!e.problem&&(!o||Date.parse(o.expiresAt)>Date.now()))return{type:"checkout",operationId:e.operationId,checkoutUrl:e.checkoutUrl};let n=p=>!p||p.phase==="execution"&&p.reason==="STATE_CHANGED";return r.canReselect===!0&&["cancelled","failed"].includes(e.status)&&!e.checkoutUrl&&!e.execution&&n(e.problem)&&n(t?.problem)&&(!t||t.status==="failed"&&t.recordingStatus==="accepted"&&t.fulfillmentStatus==="not_applicable")?{type:"native",operationId:e.operationId}:["prepared","quoted"].includes(e.status)&&!e.confirmedAt&&!t&&!e.checkoutUrl&&!e.problem?{type:"cancel",operationId:e.operationId}:a}if(t?.type==="purchase"){if(["succeeded","not_required"].includes(t.paymentStatus))return!["applied","not_applicable"].includes(t.fulfillmentStatus)||e.problem?.phase==="fulfillment"||t.problem?.phase==="fulfillment"?{type:"fulfillment",operationId:e.operationId}:{type:t.recordingStatus==="accepted"&&e.status==="complete"&&!e.problem&&!t.problem?"complete":"recording",operationId:e.operationId};if(e.status==="pending"&&e.checkoutUrl&&!e.problem&&!t.problem&&t.checkoutUrl===e.checkoutUrl&&t.checkoutExpiresAt&&Date.parse(t.checkoutExpiresAt)>Date.now()&&["not_started","pending"].includes(t.paymentStatus))return{type:"checkout",operationId:e.operationId,checkoutUrl:e.checkoutUrl}}if(e.executor==="indiana"&&e.status==="pending"&&e.checkoutUrl&&!e.problem&&!e.nativePurchase&&(!o||Date.parse(o.expiresAt)>Date.now()))return{type:"checkout",operationId:e.operationId,checkoutUrl:e.checkoutUrl};let c=[e.problem,t?.problem],i=c.every(n=>!n||n.phase==="execution"&&n.reason!=="RESULT_UNKNOWN"),y=e.status==="cancelled"&&!c.some(Boolean)&&t?.type==="purchase"&&["pending","not_started","expired"].includes(t.paymentStatus)&&["not_started","not_applicable"].includes(t.fulfillmentStatus);return r.canReselect===!0&&i&&["cancelled","failed"].includes(e.status)&&!e.checkoutUrl&&!e.execution&&!e.nativePurchase&&(e.executor!=="merchant"||!t||t.type==="purchase"&&!["succeeded","not_required"].includes(t.paymentStatus)&&(y||t.recordingStatus==="accepted"&&t.fulfillmentStatus==="not_applicable"))?{type:"native",operationId:e.operationId}:!c.some(Boolean)&&e.status==="complete"&&e.executor!=="merchant"?{type:"complete",operationId:e.operationId}:i&&r.canReselect!==!1&&["cancelled","failed"].includes(e.status)&&!e.checkoutUrl&&!e.execution&&!e.nativePurchase&&(e.executor!=="merchant"?!e.confirmedAt&&(e.status==="cancelled"||!e.quoteFinalized):!t&&!e.quoteFinalized||t?.type==="purchase"&&["failed","expired"].includes(t.paymentStatus)&&t.fulfillmentStatus==="not_applicable"&&t.recordingStatus==="accepted")?{type:"native",operationId:e.operationId}:e.status==="pending"&&i&&!e.quoteFinalized&&!t&&!e.checkoutUrl&&!e.execution&&!e.nativePurchase?{type:"cancel",operationId:e.operationId}:a}function h(r,o=!0){if(!r)return!1;let e=f({quote:r.quote??null,operation:r,requestId:null,pending:!1,destroyed:!1,canReselect:o});return e.type==="complete"||e.type==="native"}function l(r){return r.recovery??{type:"recover",operationId:r.operation?.operationId??r.quote?.operationId??null,requestId:null}}function b(r){return!!(r?.operationId&&(r.type==="checkout"||r.type==="recover"||r.type==="fulfillment"||r.type==="recording"))}async function g(r){let o=l(r);if(o.type==="recover"&&r.quote)try{await r.read(),o=l(r)}catch{return o}if(o.type!=="cancel"&&!(o.type==="recover"&&r.pendingCancellation))return o;try{await r.cancel();let e=l(r);return e.type==="cancel"?{type:"recover",operationId:o.operationId,requestId:null}:e}catch{let e=l(r);return e.type==="recover"?e:{type:"recover",operationId:o.operationId,requestId:null}}}export{f as a,h as b,l as c,b as d,g as e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s,b as c,c as u}from"./chunk-
|
|
1
|
+
import{a as s,b as c,c as u}from"./chunk-LWIBARE4.js";import{j as m,m as p}from"./chunk-XX5O7H6R.js";import{b as e}from"./chunk-J6MYX7WY.js";var y=["USD","EUR","CNY","GBP","JPY","CAD","AUD","NZD","CHF","HKD","SGD","KRW","INR","BRL","MXN","TWD","THB","IDR","MYR","PHP","VND","ZAR","AED","SAR","SEK","NOK","DKK","PLN","CZK","HUF","ILS","TRY","RON"],i=e.enum(y);function x(t){let n=i.parse(t.toUpperCase());return["JPY","KRW","VND"].includes(n)?0:2}function I(t,n,r="en",f={}){let a=i.parse(n.toUpperCase());return new Intl.NumberFormat(r,{style:"currency",currency:a,...f}).format(t/10**x(a))}var l=e.enum(["stripe","apple","google","merchant"]),w=e.enum(["membership","credit_pack","lifetime"]),v=e.enum(["active","grace","suspended","inactive","revoked"]),z=e.strictObject({currency:e.string().regex(/^[A-Z]{3}$/),micros:e.string().regex(/^(0|[1-9][0-9]{0,29})$/)});var d=e.object({provider:l,currency:i,intent:e.literal("subscription_change").optional()}).strict();var o=e.strictObject({internal_feature_id:e.uuid(),quantity:m.refine(t=>/[1-9]/.test(t)),properties:p,entityId:e.uuid().optional()}),B=e.strictObject({requirement:o,commerce:d.optional(),paywallId:e.uuid().optional()}),g=e.enum(["not_entitled","insufficient_balance","capacity_exceeded","limit_exceeded","awaiting_topup","authorization_required","payment_blocked","cash_budget_exceeded","unavailable","authentication_required"]),b=e.strictObject({productId:e.string().min(1),productVersionId:e.string().min(1),name:e.string().min(1).max(120),action:e.enum(["purchase","upgrade","addon","topup"]),membershipId:e.string().min(1).nullable(),featureQuantities:e.record(e.uuid(),e.number().int().min(0).max(1e4)).refine(t=>Object.keys(t).length<=100).optional(),currency:i,amountMinor:e.string().regex(/^(0|[1-9]\d{0,8})$/),interval:e.enum(["free","week","month","year","one_time"]),intervalCount:e.number().int().min(1).max(156)}),h=e.strictObject({subject:c,authority:e.enum(["longplay","merchant"]),observedAt:e.iso.datetime({offset:!0}),sourceRevision:e.string().min(1).max(128),requirementDigest:s});function S(t,n){return u({subject:c.parse(t),requirement:o.parse(n)})}var C=e.strictObject({internal_feature_id:e.string().min(1),name:e.string().min(1).max(120),kind:e.enum(["access","metered","credit"]),quantity:m,allowed:e.boolean(),observation:h.optional(),reason:g.nullable(),preview:e.strictObject({scenario:e.enum(["feature_flag","usage_limit"]),candidates:e.array(b).max(20)}).nullable()}).superRefine((t,n)=>{(t.allowed!==(t.reason===null)||t.allowed&&t.preview!==null||new Set(t.preview?.candidates.map(r=>r.productVersionId)).size!==(t.preview?.candidates.length??0)||t.preview?.candidates.some(r=>r.action==="upgrade"!=(r.membershipId!==null)))&&n.addIssue({code:"custom",message:"Invalid access recommendation"})}),T=e.strictObject({paywallId:e.uuid(),requirement:o}),U=e.strictObject({subject:c,requirement:o}),$=C.safeExtend({observation:h.extend({authority:e.literal("merchant")})});function F(t,n){let r=o.parse(t);return n.internal_feature_id===r.internal_feature_id&&n.quantity===r.quantity&&(!n.observation||n.observation.requirementDigest===S(n.observation.subject,r))}export{i as a,x as b,I as c,w as d,d as e,o as f,B as g,b as h,S as i,C as j,U as k,$ as l,F as m};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as e}from"./chunk-
|
|
1
|
+
import{b as e}from"./chunk-J6MYX7WY.js";var y=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),z=e.discriminatedUnion("type",[e.object({type:e.literal("fixed"),productVersionId:e.string().min(1).max(200)}).strict(),e.object({type:e.literal("picker"),pickerId:y,allowedProductVersionIds:e.array(e.string().min(1).max(200)).min(1).max(20)}).strict().refine(t=>new Set(t.allowedProductVersionIds).size===t.allowedProductVersionIds.length,"Product choices must be unique")]),x=e.strictObject({min:e.number().finite().min(1).max(1800),max:e.number().finite().min(1).max(1800),viewport:e.number().finite().min(1).max(100)}).refine(t=>t.min<=t.max,"Desktop width range is reversed"),f={desktopWidth:x.optional(),mobile:e.enum(["sheet","fullscreen"]).optional(),backdrop:e.enum(["none","scrim","dim","strong-dim","blur"]).optional()},G=e.discriminatedUnion("type",[e.strictObject({type:e.literal("modal"),position:e.enum(["center","top","bottom"]).optional(),size:e.enum(["sm","md","lg"]),...f}),e.strictObject({type:e.literal("sheet"),size:e.enum(["sm","md","lg"]),...f}),e.strictObject({type:e.literal("fullscreen")}),e.strictObject({type:e.literal("inline")})]),V={sm:360,md:420,lg:560};var c=e.json().superRefine((t,i)=>{let s=0;function o(n,r){if(++s>1e4||r>20){i.addIssue({code:"custom",message:"JSON exceeds its depth or node budget"});return}if(typeof n=="string"&&(n.includes("\0")||/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(n))&&i.addIssue({code:"custom",message:"JSON text must contain valid Unicode without NUL"}),Array.isArray(n))n.forEach(a=>o(a,r+1));else if(n&&typeof n=="object")for(let[a,u]of Object.entries(n))(a.includes("\0")||/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(a)||["__proto__","prototype","constructor"].includes(a))&&i.addIssue({code:"custom",message:"Reserved JSON property"}),o(u,r+1)}o(t,0),new TextEncoder().encode(JSON.stringify(t)).byteLength>65536&&i.addIssue({code:"custom",message:"JSON exceeds 64 KiB"})}),l=e.record(e.string().min(1).max(128),c).superRefine((t,i)=>{(!c.safeParse(t).success||Object.keys(t).length>128||new TextEncoder().encode(JSON.stringify(t)).byteLength>65536||["__proto__","constructor","prototype"].some(s=>Object.hasOwn(t,s)))&&i.addIssue({code:"custom",message:"Attribute document exceeds its budget or uses a reserved key"})}),S=new Set(["$in","$ini","$inGroup","$nin","$nini","$notInGroup","$gt","$gte","$lt","$lte","$regex","$regexi","$ne","$eq","$size","$elemMatch","$all","$alli","$not","$type","$exists","$vgt","$vgte","$vlt","$vlte","$vne","$veq","$and","$or","$nor","$savedGroup"]),d=l.superRefine((t,i)=>{function s(o){if(Array.isArray(o))o.forEach(s);else if(o&&typeof o=="object")for(let[n,r]of Object.entries(o)){if(n==="$savedGroup"&&!e.strictObject({id:e.uuid(),attributeKey:e.string().min(1).max(128).optional()}).safeParse(r).success&&i.addIssue({code:"custom",message:"Saved groups use v2 object references"}),!n.startsWith("$")&&n.split(".").some(a=>["__proto__","prototype","constructor"].includes(a))&&i.addIssue({code:"custom",message:"Reserved attribute path"}),n.startsWith("$")&&!S.has(n)&&i.addIssue({code:"custom",message:`Unknown GrowthBook operator: ${n}`}),["$regex","$regexi"].includes(n)&&typeof r=="string"){(/\(\?[<!=]|\\[0-9]|\\k</.test(r)||[...r.matchAll(/\{(\d+)(?:,(\d*))?\}/g)].some(a=>Number(a[1])>255||Number(a[2]||0)>255)||n==="$regexi"&&/[^\x00-\x7f]/.test(r.replace(/\\u([0-9a-f]{4})/gi,(a,u)=>String.fromCharCode(Number.parseInt(u,16)))))&&i.addIssue({code:"custom",message:"Regex is outside the shared TS/SQL subset"});try{new RegExp(r)}catch{i.addIssue({code:"custom",message:"Invalid regular expression"})}}s(r)}}typeof t.source=="string"&&["all","any","group","parameter","answer","attribute","result"].includes(t.source)&&("operator"in t||"predicates"in t||"groupId"in t)&&i.addIssue({code:"custom",message:"Obsolete condition protocol"}),s(t)}),w=e.discriminatedUnion("type",[e.strictObject({type:e.literal("condition"),condition:d}),e.strictObject({type:e.literal("list"),attributeKey:e.string().min(1).max(128),values:e.array(e.union([e.string(),e.number().finite()])).max(1e5)})]).refine(t=>t.type!=="list"||new TextEncoder().encode(JSON.stringify(t.values)).byteLength<=1048576,"Saved group list exceeds 1 MiB");function $(t){let i=new Set;function s(o){if(Array.isArray(o))o.forEach(s);else if(o&&typeof o=="object")for(let[n,r]of Object.entries(o))n==="$savedGroup"&&r&&typeof r=="object"&&!Array.isArray(r)&&typeof r.id=="string"?i.add(r.id):["$inGroup","$notInGroup"].includes(n)&&typeof r=="string"?i.add(r):["$eq","$ne","$in","$nin","$ini","$nini"].includes(n)||s(r)}return s(t),[...i]}var O=e.record(e.uuid(),w).superRefine((t,i)=>{let s=new Set,o=new Set;function n(r){if(s.has(r)){i.addIssue({code:"custom",message:"Cyclic saved group dependency"});return}if(o.has(r))return;let a=t[r];if(!a){i.addIssue({code:"custom",message:"Missing saved group dependency"});return}s.add(r),a.type==="condition"&&$(a.condition).forEach(n),s.delete(r),o.add(r)}Object.keys(t).forEach(n)}),g=e.tuple([e.number().min(0).max(1),e.number().min(0).max(1)]).refine(([t,i])=>t<=i),h=e.strictObject({attribute:e.string().optional(),seed:e.string().min(1),hashVersion:e.literal(2),ranges:e.array(g).min(1).max(100)}),j=e.strictObject({id:e.string().min(1).max(128),condition:d,gate:e.boolean().optional()}),p={id:e.string().max(128).optional(),condition:d.optional(),parentConditions:e.array(j).max(50).optional(),filters:e.array(h).max(20).optional()},v=e.union([e.strictObject({...p}),e.strictObject({...p,force:c,coverage:e.number().min(0).max(1).optional(),range:g.optional(),seed:e.string().min(1).optional(),hashAttribute:e.string().optional(),hashVersion:e.literal(2).optional()}),e.strictObject({...p,type:e.literal("experiment-ref"),experimentId:e.uuid(),values:e.record(e.string().min(1),c),meta:e.record(e.string().min(1),e.strictObject({passthrough:e.boolean()})).optional()})]),k=e.strictObject({defaultValue:c,rules:e.array(v).max(100)}),U=e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,127}$/),k).superRefine((t,i)=>{Object.keys(t).length>100&&i.addIssue({code:"custom",message:"Too many Features"});let s=new Set,o=new Set;function n(r){if(s.has(r)){i.addIssue({code:"custom",message:`Cyclic Feature dependency: ${r}`});return}if(o.has(r))return;let a=t[r];if(!a){i.addIssue({code:"custom",message:`Unknown prerequisite Feature: ${r}`});return}s.add(r);for(let u of a.rules)for(let m of u.parentConditions??[])n(m.id);s.delete(r),o.add(r)}Object.keys(t).forEach(n)}),F=e.strictObject({name:e.string().max(80),reason:e.string().max(500),dateStarted:e.iso.datetime({offset:!0}),dateEnded:e.iso.datetime({offset:!0}).nullable(),coverage:e.number().min(0).max(1),variationWeights:e.array(e.number().min(0).max(1)).min(2).max(20).refine(t=>Math.abs(t.reduce((i,s)=>i+s,0)-1)<=.01),condition:d,savedGroups:e.array(e.strictObject({match:e.enum(["any","all","none"]),ids:e.array(e.uuid()).min(1)})).max(50),namespace:e.strictObject({id:e.uuid(),ranges:e.array(g).min(1)}).nullable(),seed:e.string().min(1).max(128)}),A=e.strictObject({key:e.string().min(1).max(128),name:e.string().min(1).max(80),hypothesis:e.string().max(2e3),status:e.enum(["draft","running","stopped"]),hashAttribute:e.string().min(1).max(128),fallbackAttribute:e.string().max(128).nullable(),hashVersion:e.literal(2),disableStickyBucketing:e.boolean(),bucketVersion:e.number().int().min(0).max(1e3),minBucketVersion:e.number().int().min(0).max(1e3),variations:e.array(e.strictObject({id:e.string().min(1),key:e.string().min(1),name:e.string().max(80),description:e.string().max(500)})).min(2).max(20),phases:e.array(F).min(1).max(100),releasedVariationId:e.string().nullable(),excludeFromPayload:e.boolean(),statusSchedule:e.strictObject({startAt:e.iso.datetime({offset:!0}).nullable(),stopAt:e.iso.datetime({offset:!0}).nullable(),stopAfter:e.strictObject({value:e.number().int().positive().max(36500),unit:e.enum(["hours","days"])}).nullable().optional()}).nullable()}).superRefine((t,i)=>{(t.minBucketVersion>t.bucketVersion||t.statusSchedule?.stopAt&&t.statusSchedule?.stopAfter||t.phases.some((s,o)=>{if(o===0)return!1;let n=t.phases[o-1];return!n?.dateEnded||Date.parse(s.dateStarted)<Date.parse(n.dateStarted)||Date.parse(n.dateEnded)>Date.parse(s.dateStarted)})||new Set(t.variations.map(s=>s.key)).size!==t.variations.length||new Set(t.variations.map(s=>s.id)).size!==t.variations.length||t.releasedVariationId!==null&&!t.variations.some(s=>s.id===t.releasedVariationId)||t.statusSchedule?.startAt&&t.statusSchedule?.stopAt&&Date.parse(t.statusSchedule.startAt)>=Date.parse(t.statusSchedule.stopAt)||t.phases.some(s=>s.dateEnded&&Date.parse(s.dateStarted)>=Date.parse(s.dateEnded)||s.namespace?.ranges.some(([o,n],r,a)=>o>=n||a.some(([u,m],b)=>b!==r&&o<m&&u<n)))||t.phases.some(s=>s.variationWeights.length!==t.variations.length))&&i.addIssue({code:"custom",message:"Invalid experiment versions, variation keys or weights"})});var I=A.safeExtend({filters:e.array(h).optional()}),D=e.strictObject({experiments:e.record(e.uuid(),I),savedGroups:O}),E=e.strictObject({attributeName:e.string(),attributeValue:e.string(),assignments:e.record(e.string(),e.string())}),M=e.strictObject({snapshot:D,attributes:l,results:l,stickyBucketAssignmentDocs:e.record(e.string(),E)}),W=e.strictObject({variantKey:e.string().nullable(),bucketVersion:e.number().int().min(0),source:e.enum(["unknownFeature","defaultValue","force","override","experiment","prerequisite","cyclicPrerequisite"]),bucket:e.number().min(0).max(1).optional(),stickyBucketUsed:e.boolean().optional(),hashUsed:e.boolean().optional()});export{z as a,G as b,V as c,c as d,l as e,d as f,$ as g,E as h};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as c}from"./chunk-
|
|
1
|
+
import{e as c}from"./chunk-FWM3577O.js";import{a as s}from"./chunk-5X7PTCI4.js";function h(e,o,t){let{presentation:i,screen:n}=t,a=(n.pages.find(l=>l.id===n.initialPageId)??n.pages[0])?.theme??n.theme;o.inert=!0,o.style.cssText="display:grid;gap:12px;padding:0 24px 24px";for(let l of[72,72,72,48]){let p=e.ownerDocument.createElement("div");p.style.cssText=`height:${l}px;background:currentColor;opacity:.08;border-radius:16px`,o.append(p)}let d=i.type==="inline"?void 0:c(e,{...n,presentation:i,theme:{background:n.theme.background,text:n.theme.text}});return d?.latch(),e.style.background=a.background,e.style.color=a.text,d?(i.type==="fullscreen"||i.type==="sheet")&&(e.style.position="fixed"):e.style.position="relative",()=>d?.destroy()}var f={none:0,sm:4,md:8,lg:14,full:9999},g={system:"system-ui,sans-serif",serif:"Georgia,serif",rounded:"ui-rounded,system-ui,sans-serif",mono:"ui-monospace,monospace"},k={primary:"#172033",background:"#FFFFFF",text:"#172033",radius:"md",font:"system"};function u(e){let[o,t,i]=[1,3,5].map(n=>{let r=Number.parseInt(e.slice(n,n+2),16)/255;return r<=.03928?r/12.92:((r+.055)/1.055)**2.4});return .2126*o+.7152*t+.0722*i}function $(e,o=!0){let t=u(e.primary),i=(t+.05)/.05>1.05/(t+.05)?"#111318":"#FFFFFF",n=`color-mix(in srgb, ${e.text} 22%, ${e.background})`,r=`${f[e.radius]}px`,a=`appearance:none;margin:0;min-height:44px;padding:10px 18px;border:0;border-radius:${r};font:inherit;font-size:15px;font-weight:600;line-height:1.25;cursor:pointer;touch-action:manipulation`;return{root:`width:100%;box-sizing:border-box;${o?`background:${e.background};`:""}color:${e.text};font:14px/1.5 ${g[e.font]}`,controls:"display:flex;gap:12px;padding:0 20px 12px;align-items:center;flex-wrap:wrap",pinned:`position:sticky;bottom:0;z-index:1;box-sizing:border-box;padding-top:12px;background:${e.background};border-top:1px solid ${n}`,bar:`display:flex;gap:8px;padding:12px 16px;align-items:center;flex-wrap:wrap;border-top:1px solid ${n}`,message:"flex:1 1 200px;min-width:0;margin:0;font-size:13px",status:"margin:0;font-size:13px;opacity:.72",alert:`flex:1 1 200px;min-width:0;margin:0;font-size:13px;font-weight:500;color:${u(e.background)>.4?"#B42318":"#FDA29B"}`,panel:`flex:1 0 100%;box-sizing:border-box;display:flex;flex-direction:column;gap:8px;padding:16px;border:1px solid ${n};border-radius:${r}`,summary:"margin:0;font-size:15px;font-weight:600",terms:"display:flex;flex-direction:column;gap:4px;font-size:13px;opacity:.72",actions:"display:flex;gap:8px;flex-wrap:wrap;margin-top:4px",primary:`${a};background:${e.primary};color:${i}`,secondary:`${a};background:transparent;color:${e.text};box-shadow:inset 0 0 0 1px ${n}`,link:`${a};background:transparent;color:${e.text};opacity:.72;font-weight:500`,stage:"display:flex;justify-content:center;padding:24px 20px",history:"display:flex;flex-direction:column;gap:12px;padding:20px",historyTitle:"margin:0;padding-inline-end:40px;font-size:17px;font-weight:600;line-height:1.3",historyNote:"margin:0;font-size:13px;opacity:.72",historyPages:"display:flex;gap:8px;flex-wrap:wrap;margin:0;padding:0;list-style:none",historyPage:`border:1px solid ${n};border-radius:${r};overflow:hidden`,historyRecords:`display:flex;flex-direction:column;gap:4px;margin:0;padding:12px 0 0;list-style:none;font-size:13px;border-top:1px solid ${n}`,focus:e.text}}function T(e){e.style.opacity=e.disabled?".55":"",e.style.cursor=e.disabled?"not-allowed":"pointer"}function E(e,o){e.addEventListener("focus",()=>{let t=!0;try{t=e.matches(":focus-visible")}catch{}t&&(e.style.outline=`2px solid ${o()}`,e.style.outlineOffset="2px")}),e.addEventListener("blur",()=>{e.style.outline="",e.style.outlineOffset=""})}var x={en:{network:"Connection problem. Check your network and try again.",timeout:"This is taking longer than expected. Try again.",other:"Something went wrong. Try again.",required:"Answer the questions marked * to continue.",permission:"This isn’t available right now. Contact the merchant for help."},zh:{network:"网络连接异常,请检查网络后重试。",timeout:"响应时间过长,请重试。",other:"出了点问题,请重试。",required:"请先回答带 * 的问题。",permission:"当前无法完成此操作,请联系商户。"}};function z(e,o){let t=x[o?"zh":"en"],i=e instanceof s?e.code:void 0;return i==="NETWORK_ERROR"?t.network:i==="TIMEOUT"?t.timeout:m(e)?t.permission:t.other}function m(e){return e instanceof s&&(e.code==="FORBIDDEN"||e.recovery==="check_permissions")}function D(e,o){if(!(e instanceof s)||e.code!=="INVALID_REQUEST"||e.status===void 0||e.status>=500)return!1;let t=/^Required input: (.+)$/.exec(e.message)?.[1]?.trim();return t!==void 0&&o.some(i=>i.variable===t)}function F(e){return x[e?"zh":"en"].required}function R(e,o){return e.filter(({variable:t,required:i})=>{let n=o[t];return i&&(n==null||n===""||Array.isArray(n)&&n.length===0)})}var y={zh:{pending:"处理中",complete:"已完成",cancelled:"已取消",failed:"失败",unknown:"状态待确认",prepared:"报价待确认",quoted:"报价待确认",confirmed:"处理中",effective:"已生效",scheduled:"已安排续期变更"},en:{pending:"Processing",complete:"Completed",cancelled:"Cancelled",failed:"Failed",unknown:"Status unconfirmed",prepared:"Quote ready",quoted:"Quote ready",confirmed:"Processing",effective:"Effective",scheduled:"Scheduled for renewal"}};function S(e,o){return y[o?"zh":"en"][e]}export{h as a,k as b,$ as c,T as d,E as e,z as f,m as g,D as h,F as i,R as j,S as k};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as c}from"./chunk-
|
|
1
|
+
import{h as c}from"./chunk-HEPQNLR2.js";import{b as p}from"./chunk-J6MYX7WY.js";import{d as x,e as y,f as g}from"./chunk-VPT5MFDG.js";import{a as m,b as d}from"./chunk-CILM5XMH.js";var u=class extends Error{constructor(t){super(t),this.name="FunnelCalculationError"}};function F(e,t,f){let i={},l,s,n,o="next",a;switch(e.type){case"entry":a=e.next;break;case"condition":{let r=e.cases.findIndex(b=>x(t.attributes??{},b.condition,t.savedGroups??{}));o=r<0?"default":`case:${r}`,a=r<0?e.default:e.cases[r].target;break}case"feature":if(!Object.hasOwn(t.features??{},e.featureKey))throw new u("Required GB Feature is unavailable");l=g(e.featureKey,t),n=l.value,Object.assign(i,c(e,{value:n})),a=e.next;break;case"split":{let r=f[e.experimentId];if(!r)throw new u("Required GB Experiment is unavailable");if(s=y(r,t),n=s.value,o=s.inExperiment&&!s.passthrough&&typeof n=="string"?n:"notParticipating",a=o==="notParticipating"?e.notParticipating:e.routes[o],!a)throw new u("Experiment Variation has no published route");break}case"offering":{let r=e.configuration.source==="fixed"?e.configuration.versionId:g(e.configuration.featureKey,t).value;n={type:"offering_version",id:p.uuid().parse(r)},Object.assign(i,c(e,{value:n})),a=e.next;break}case"coupon":case"coupons":n=e.type==="coupons"?e.couponIds.map(r=>({type:"reward",id:r})):{type:"reward",id:e.couponId},Object.assign(i,c(e,{value:n})),a=e.next;break}return{port:o,target:a,projections:i,...n===void 0?{}:{value:n},...l?{feature:l}:{},...s?{experiment:s}:{}}}function E(e,t,f){p.uuid().parse(e),p.number().int().nonnegative().parse(t);let i=m(d(new TextEncoder().encode(JSON.stringify([e,t,f])))).slice(0,32);return`${i.slice(0,8)}-${i.slice(8,12)}-5${i.slice(13,16)}-a${i.slice(17,20)}-${i.slice(20)}`}export{F as a,E as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as t}from"./chunk-
|
|
1
|
+
import{d as t}from"./chunk-IXDARDPI.js";async function u(e,n){try{let{route:r}=await e.funnelRoute(n.funnelId),a=t(r,{customerId:n.customerId,parameters:n.parameters??{}});return{funnelId:n.funnelId,...a}}catch(r){return{funnelId:n.funnelId,type:"unavailable",reason:r?.code?.toLowerCase()??"error",path:[]}}}function l(e){switch(e.type){case"paywall":return null;case"screen":return`first_screen_${e.surface}`;case"external_page":return"first_screen_external_page";case"end":return`route_end_${e.outcome}`;case"unknown":return`route_unknown_${e.reason}`;case"unavailable":return e.reason.startsWith("route_")?e.reason:`route_${e.reason}`}}async function s(e,n){if(n.type!=="paywall")return null;try{let{document:r}=await e.paywall(n.paywallId,n.paywallVersionId);return{presentation:r.presentation,screen:r.screen,buttons:r.buttons}}catch{return null}}export{u as a,l as b,s as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as r}from"./chunk-
|
|
1
|
+
import{b as r}from"./chunk-J6MYX7WY.js";var R=r.enum(["INVALID_PROTOCOL_VERSION","UNSUPPORTED_PROTOCOL_VERSION","PROTOCOL_RETIRED","UNAUTHENTICATED","FORBIDDEN","SCOPE_MISMATCH","INVALID_REQUEST","NOT_FOUND","CONFLICT","PAYLOAD_TOO_LARGE","RATE_LIMITED","SERVICE_UNAVAILABLE","NOT_CONFIGURED","CAPABILITY_UNAVAILABLE","INTERNAL_ERROR"]),H=r.enum([...R.options,"INVALID_SERVER_RESPONSE","RESPONSE_TOO_LARGE","AMBIGUOUS_AUTHENTICATION","BROWSER_REQUIRED","INVALID_REDIRECT_URI","AUTHORIZATION_UNAVAILABLE","UNREGISTERED_CLIENT","MANAGEMENT_OPERATION_FAILED","SENSITIVE_OUTPUT_REQUIRED"]),j=r.enum([...R.options,"stale_revision"]),v=r.enum(["fix_request","authenticate","check_permissions","check_scope","resolve_conflict","reload_state","retry_same_request","configure_integration","check_availability","upgrade_sdk","recover_operation","contact_support"]),x=r.enum(["CAPABILITY_NOT_ENABLED","INTEGRATION_MISSING","PROVIDER_CREDENTIAL_REJECTED","PRICE_BINDING_REQUIRED","IDEMPOTENCY_CONFLICT","RESULT_UNKNOWN","STATE_CHANGED","IDENTITY_CONTEXT_CHANGED","CUSTOMER_BINDING_CONFLICT","RUN_CONTRACT_MISMATCH","OPERATION_IN_PROGRESS","FUNNEL_VERSION_RETIRED","FUNNEL_PAUSED"]),L={INVALID_PROTOCOL_VERSION:{status:400,recovery:"fix_request"},UNSUPPORTED_PROTOCOL_VERSION:{status:400,recovery:"upgrade_sdk"},PROTOCOL_RETIRED:{status:410,recovery:"upgrade_sdk"},UNAUTHENTICATED:{status:401,recovery:"authenticate"},FORBIDDEN:{status:403,recovery:"check_permissions"},SCOPE_MISMATCH:{status:403,recovery:"check_scope"},INVALID_REQUEST:{status:400,recovery:"fix_request"},NOT_FOUND:{status:404,recovery:"fix_request"},CONFLICT:{status:409,recovery:"resolve_conflict"},PAYLOAD_TOO_LARGE:{status:413,recovery:"fix_request"},RATE_LIMITED:{status:429,recovery:"retry_same_request"},SERVICE_UNAVAILABLE:{status:503,recovery:"retry_same_request"},NOT_CONFIGURED:{status:501,recovery:"configure_integration"},CAPABILITY_UNAVAILABLE:{status:501,recovery:"check_availability"},INTERNAL_ERROR:{status:500,recovery:"recover_operation"}};var S={TIMEOUT:"recover_operation",NETWORK_ERROR:"recover_operation",HTTP_ERROR:"recover_operation",INVALID_RESPONSE:"recover_operation",NOT_IDENTIFIED:"authenticate",CUSTOMER_SESSION_REQUIRED:"authenticate",INVALID_TOKEN:"authenticate",INVALID_URL:"fix_request",INVALID_TIMEOUT:"fix_request",SERVER_ONLY:"fix_request",PROTOCOL_MISMATCH:"upgrade_sdk",IDENTITY_CHANGED:"reload_state",INVALID_STATE:"reload_state",EVENT_QUEUE_FULL:"retry_same_request",COMMAND_PENDING:"recover_operation",PURCHASE_PENDING:"recover_operation",DECISION_PENDING:"recover_operation",DECISION_ACCEPTANCE_UNKNOWN:"recover_operation",RUN_RECONCILIATION_REQUIRED:"recover_operation",DECISION_FAILED:"contact_support",COMMAND_STORAGE_CONFLICT:"resolve_conflict",COMMAND_STORAGE_INVALID:"fix_request",PURCHASE_STORAGE_CONFLICT:"resolve_conflict",PURCHASE_STORAGE_INVALID:"recover_operation",EXECUTION_POLICY_REFUSED:"fix_request",CONFIGURATION_UNAVAILABLE:"check_availability",CONFIGURATION_EXPIRED:"reload_state",CONFIGURATION_CHANGED:"reload_state",CONFIGURATION_DISPOSED:"reload_state",UNSUPPORTED_SCHEMA:"upgrade_sdk",FUNNEL_STOPPED:"check_availability",PAYWALL_UNAVAILABLE:"check_availability",ROUTE_UNAVAILABLE:"check_availability",EVALUATION_MODE:"reload_state",SERVER_REQUIRED:"fix_request",STICKY_SAVE_FAILED:"retry_same_request",TRANSITION_LIMIT:"resolve_conflict",PRECONDITION_FAILED:"reload_state",PRODUCT_UNAVAILABLE:"fix_request",COUPON_UNAVAILABLE:"reload_state",PURCHASE_HANDLER_REQUIRED:"fix_request",EVENT_HANDLER_REQUIRED:"fix_request",CLOSED:"fix_request",BRIDGE_UNAVAILABLE:"check_availability",INVALID_CONFIGURATION:"fix_request",NATIVE_OPERATION_FAILED:"contact_support",AI_PRICE_UNAVAILABLE:"fix_request",AI_USAGE_UNAVAILABLE:"recover_operation",AI_PROVIDER_ERROR:"check_availability",AI_BALANCE_REJECTED:"resolve_conflict"};function g(e,o){if(e==="CONFLICT"&&o===425)return{retryable:!0,recovery:"retry_same_request"};if(e==="CONFLICT"&&o===412)return{retryable:!1,recovery:"reload_state"};if(e==="INVALID_SERVER_RESPONSE")return{retryable:!1,recovery:"recover_operation"};if(e==="AMBIGUOUS_AUTHENTICATION"||e==="SENSITIVE_OUTPUT_REQUIRED")return{retryable:!1,recovery:"fix_request"};if(Object.hasOwn(S,e)){let n=S[e];return{retryable:n==="retry_same_request",recovery:n}}let t=R.safeParse(e);return t.success?{retryable:e==="RATE_LIMITED"||e==="SERVICE_UNAVAILABLE",recovery:L[t.data].recovery}:{retryable:!1,recovery:"contact_support"}}function Q(e,o){let t=R.safeParse(e);if(t.success)return e==="CONFLICT"?[409,412,425].includes(o):e==="SERVICE_UNAVAILABLE"?[408,502,503,504].includes(o):e==="INVALID_REQUEST"?[400,405,415,422].includes(o):e==="NOT_CONFIGURED"?[501,503].includes(o):L[t.data].status===o;let n={INVALID_SERVER_RESPONSE:[502],RESPONSE_TOO_LARGE:[502],AMBIGUOUS_AUTHENTICATION:[400],SENSITIVE_OUTPUT_REQUIRED:[400],BROWSER_REQUIRED:[403],INVALID_REDIRECT_URI:[403],AUTHORIZATION_UNAVAILABLE:[400],UNREGISTERED_CLIENT:[403],MANAGEMENT_OPERATION_FAILED:[400,422,500]};return Object.hasOwn(n,e)&&(n[e]?.includes(o)??!1)}function P(e,o=Date.now()){if(e===null)return;let t=e.trim();if(/^\d+$/.test(t)){let s=Number(t);return Number.isSafeInteger(s)?s:void 0}if(!/^[A-Za-z]{3}, \d{2} [A-Za-z]{3} \d{4} \d{2}:\d{2}:\d{2} GMT$/.test(t))return;let n=Date.parse(t);return Number.isFinite(n)?Math.max(0,Math.ceil((n-o)/1e3)):void 0}var y=r.object({retryable:r.boolean(),recovery:v,reason:x.optional(),retryAfterSeconds:r.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).optional()}),b=r.object({requestId:r.uuid().optional(),error:r.object({code:r.string().regex(/^[A-Z][A-Z0-9_]{0,95}$/),message:r.string(),...y.partial().shape})}),z=r.object({error:b.shape.error.extend({requestId:r.uuid().optional()})}),Y=r.object({error:r.string(),code:r.string().regex(/^[A-Za-z][A-Za-z0-9_]{0,95}$/),requestId:r.uuid(),...y.shape});function $(e,o,t={}){let n=g(e,o),s=t.reason==="RESULT_UNKNOWN"?"recover_operation":t.recovery??n.recovery,A=n.retryable&&t.retryable!==!1&&s!=="recover_operation",i=A?P(t.retryAfter??null):void 0;return{...n,retryable:A,recovery:s,...i===void 0?{}:{retryAfterSeconds:i},...t.reason?{reason:t.reason}:{}}}var V=r.enum(["sandbox","live"]),W=r.object({projectId:r.string().min(1),environment:V}).strict();var J=r.string().regex(/^(0|[1-9]\d{0,12})(\.\d{1,12})?$/),u=r.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/).transform(e=>e.includes(".")?e.replace(/0+$/,"").replace(/\.$/,""):e),M=r.string().regex(/^-?(0|[1-9]\d{0,11})(\.\d{1,6})?$/).transform(e=>{let o=e.includes(".")?e.replace(/0+$/,"").replace(/\.$/,""):e;return o==="-0"?"0":o}),p=u.refine(e=>/[1-9]/.test(e),"数量必须大于 0"),D=r.string().min(1).max(64),B=r.string().min(1).regex(/^[a-zA-Z0-9_-]+$/),C=r.string().min(1).max(64).refine(e=>!e.includes("::"),"Dimension IDs cannot contain ::"),ee=r.record(D,r.union([r.string().max(120),r.number().finite(),r.boolean()])).refine(e=>Object.keys(e).length<=16,"最多 16 个计价属性").transform(e=>Object.fromEntries(Object.entries(e).map(([o,t])=>[o,String(t)]))),U=r.record(D,r.union([r.string().max(120),r.number().finite(),r.boolean()]).transform(String)).refine(e=>Object.keys(e).length<=8,"匹配条件最多 8 个属性"),I=e=>{let o=e.startsWith("-");o&&(e=e.slice(1));let[t,n=""]=e.split(".");if(t===void 0||t==="")throw new Error("Invalid decimal value");let s=BigInt(t)*BigInt("1000000")+BigInt(n.padEnd(6,"0"));return o?-s:s},h=r.array(r.object({upTo:p.nullable(),cost:u}).strict()).min(1).max(12).refine(e=>e.at(-1)?.upTo===null&&e.slice(0,-1).every((o,t)=>{let n=e[t-1]?.upTo;return o.upTo!==null&&(t===0||n!=null&&I(o.upTo)>I(n))}),"阶梯上限必须递增,最后一档为无限"),G=r.object({key:C,match:U,priority:r.number().int().default(0),cost:u.optional(),tiers:h.optional()}).strict().refine(e=>e.cost!==void 0||e.tiers!==void 0,"维度需要指定单价或阶梯"),F=r.object({key:C,match:U,factor:p.optional(),add:M.optional()}).strict().refine(e=>e.factor!==void 0||e.add!==void 0,"A multiplier needs a factor or an add").transform(e=>({...e,factor:e.factor??"1",add:e.add??"0"})),k=r.object({units:p.default("1"),cost:u,tiers:h.optional(),dimensions:r.array(G).max(12).optional(),multipliers:r.array(F).max(4).optional()}).strict().superRefine((e,o)=>{let t=e.dimensions??[],n=e.multipliers??[];(new Set(t.map(i=>i.key)).size!==t.length||new Set(n.map(i=>i.key)).size!==n.length)&&o.addIssue({code:"custom",message:"维度和倍率的 ID 不能重复"});for(let[i,a]of t.entries())for(let c of t.slice(i+1))Object.keys(a.match).length===Object.keys(c.match).length&&a.priority===c.priority&&!Object.keys(a.match).some(E=>c.match[E]!==void 0&&c.match[E]!==a.match[E])&&o.addIssue({code:"custom",message:"维度可能同时匹配,请调整优先级"});let s=[e.cost,...(e.tiers??[]).map(i=>i.cost),...t.flatMap(i=>[...i.cost===void 0?[]:[i.cost],...(i.tiers??[]).map(a=>a.cost)])],A=I(e.units);for(let i of s)for(let a=0;a<1<<n.length;a++){let c=n.filter((N,_)=>a&1<<_);if(c.some((N,_)=>c.slice(_+1).some(d=>Object.keys(N.match).some(l=>d.match[l]!==void 0&&d.match[l]!==N.match[l]))))continue;let E=I(i),O=BigInt("1"),f=BigInt("0");for(let[N,_]of n.entries())a&1<<N&&(E*=I(_.factor??"1"),O*=BigInt("1000000"),f+=I(_.add??"0"));let T=(E+f*O)*BigInt("1000000"),m=O*A;(T<BigInt("0")||T%m!==BigInt("0")||T/m>BigInt("999999999999999999"))&&o.addIssue({code:"custom",message:"每个业务单位的最终单价必须非负、在范围内且能精确表示为最多 6 位小数"})}}),re=k.safeExtend({featureKey:B});export{R as a,v as b,x as c,Q as d,b as e,$ as f,V as g,W as h,J as i,u as j,M as k,B as l,ee as m};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as w,f as b}from"./chunk-
|
|
1
|
+
import{e as w,f as b}from"./chunk-JXVZK3RZ.js";import{n as h,s as u}from"./chunk-6NDL2ELB.js";import{a as y}from"./chunk-L6XCRIR2.js";import{a as n}from"./chunk-5X7PTCI4.js";import{a as g}from"./chunk-3VUPVXAV.js";import{a as f}from"./chunk-5MRSFLQA.js";function p(r,s){let a=typeof r=="string"?new TextEncoder().encode(r):r;return a.byteLength===s.byteLength&&u(a)===s.sha256}async function _(r,s){let a=w.parse(s),{artifact:i,environmentId:P}=a.content,m=new y(r.baseUrl??f).origin,e=new y(i.url,m);if(e.origin!==m||e.username||e.password||e.search||e.hash||e.pathname!==`/api/v1/configuration/${P}/artifacts/${i.sha256}`)throw new n("INVALID_RESPONSE","Public Paywall locator is not trusted");let o=new AbortController,d,I=new Promise((t,l)=>{d=setTimeout(()=>{let c=new n("TIMEOUT","Public Paywall read timed out");o.abort(c),l(c)},h.initializationMs)}),E=(async()=>{let t=await(r.fetch??globalThis.fetch)(e,{method:"GET",credentials:"omit",redirect:"error",cache:"default",signal:o.signal});if(o.signal.aborted&&(t.body?.cancel().catch(()=>{}),o.signal.throwIfAborted()),!t.ok||!t.headers.get("content-type")?.toLowerCase().startsWith("application/json")||Number(t.headers.get("content-length"))>i.byteLength)throw t.body?.cancel().catch(()=>{}),new n("INVALID_RESPONSE","Public Paywall is unavailable");let l=await g(t,i.byteLength,{signal:o.signal,error:c=>new n("INVALID_RESPONSE",c==="missing"?"Public Paywall body is missing":"Public Paywall exceeds its byte limit")});if(!p(l,i))throw new n("INVALID_RESPONSE","Public Paywall digest or size changed");return b(a,JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(l)))})();try{return await Promise.race([E,I])}finally{clearTimeout(d)}}export{p as a,_ as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b as o,c as i}from"./chunk-
|
|
1
|
+
import{a,b as o,c as i}from"./chunk-5MPALDJL.js";import{a as p}from"./chunk-5X7PTCI4.js";function c(e){if(e!==null&&typeof e=="object"&&"customerId"in e)throw new p("INVALID_REQUEST","Customer requests use the verified session identity")}function I(e){return{async previewUpdate(t){t=a(t),c(t);let r=await o(e,"previewUpdate");return i(e,r,t)},async update(t){t=a(t),c(t);let r=await o(e,"update");return i(e,r,t)},async readSubscriptionUpdate(t){t=a(t),c(t);let r=await o(e,"readSubscriptionUpdate");return i(e,r,t)},async restoreNativePurchase(t){t=a(t),c(t);let r=await o(e,"restoreNativePurchase");return i(e,r,t)},async previewAttach(t){t=a(t),c(t);let r=await o(e,"previewAttach");return i(e,r,t)},async attach(t){t=a(t),c(t);let r=await o(e,"attach");return i(e,r,t)},async readSubscriptionOperation(t){t=a(t),c(t);let r=await o(e,"readSubscriptionOperation");return i(e,r,t)}}}export{c as a,I as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as Rn}from"./chunk-HOX2FQQE.js";import{a as Pn}from"./chunk-4CJUGCMG.js";import{a as jn,b as Zn,c as Cn,d as bn,e as Be,f as Kn,h as et,i as nt,j as tt,k as it}from"./chunk-VEGGHQTQ.js";import{a as rt}from"./chunk-45PGU2HW.js";import{a as Jn}from"./chunk-W32FI2A2.js";import{a as zn,d as Gn,f as Qn,g as Wn,j as Yn,k as _e,l as sn,m as Xn,n as an}from"./chunk-FWM3577O.js";import{b as xn}from"./chunk-D7SPHHSF.js";import{a as In,d as Bn}from"./chunk-SQMA5YYI.js";import{C as $n}from"./chunk-2HIWXIJE.js";import{a as ne}from"./chunk-5X7PTCI4.js";import{a as ke}from"./chunk-DSPLGTQI.js";function ot(i){let E=new Set,q=new Set,n=null;async function u(o,p){let A=!1;for(;!i.stopped&&i.key===o&&i.client.pendingCommand?.requestId===p;){if(!i.client.settle)throw new ne("COMMAND_PENDING","The original display acknowledgement is still pending");await i.client.settle(p),A=!0,i.client.pendingCommand?.requestId===p&&await new Promise(v=>setTimeout(v,1500))}i.stopped||i.key!==o||(A&&await i.client.get(),!(i.stopped||i.key!==o)&&E.add(o))}function y(o,p){n=p;let A=()=>{n===p&&(n=null),q.delete(o)};return p.then(A,v=>{A(),i.busy||i.fail(v)}),p}function W(o){if(i.reviewing||E.has(o)||q.has(o)||i.stopped)return;q.add(o);let p=async()=>{if(i.reviewing||i.stopped||i.key!==o||E.has(o)){q.delete(o);return}if(i.busy||i.client.pendingCommand){setTimeout(()=>{p()},250);return}let A=(async()=>{if(i.staleRead){if(await i.staleRead,i.stopped||i.key!==o)return;if(i.client.pendingCommand){setTimeout(()=>{p()},250);return}}let v=i.client.view,de=i.expected(),O=de.requestId;try{await i.client.submit({operation:"shown",...de})}catch(k){if(!(k instanceof ne)||k.code!=="CONFLICT"||k.status!==409||i.client.pendingCommand)throw k;await i.client.get();let c=i.client.view;if(i.stopped||i.reviewing||i.key!==o||!c||!v||c.id!==v.id||c.source.versionId!==v.source.versionId||c.nodeId!==de.nodeId||c.visit!==de.visit||c.revision<=de.revision||c.stopped||!c.screen&&(!c.paywall||c.paywall.receiptId!==v.paywall?.receiptId)||!["running","waiting"].includes(c.status)||i.client.pendingCommand)throw k;let _=i.expected();O=_.requestId,await i.client.submit({operation:"shown",..._})}await u(o,O)})();y(o,A)};p()}function R(){if(n)return n;let o=i.client.pendingCommand;if(o?.operation!=="shown")return null;let p=i.key;return q.add(p),y(p,(async()=>{await i.client.retry(),await u(p,o.requestId)})())}return{report:W,settled:R,get inFlight(){return n}}}function st(i){let E={},q=new Map;async function n(u){let y=i.client.view,W=y?.screen,R=W?.customerData.nodes[u.nodeId];if(i.stopped||i.busy||!y||!W||!R)return;if(!["refresh","next","previous","filter","sources_next","sources_previous"].includes(u.action)){let k=i.document,c=k?$n(k,u.nodeId):null,_=c?.type==="customer_data"?c.data.outputs?.[u.action]:void 0;_&&W.outputs.includes(_)?await i.perform(()=>i.client.submit({operation:"submit",...i.expected(),input:{type:"screen",output:_,answers:i.answers,selection:u.value?{[u.nodeId]:u.value}:{}}})):await i.onIntent?.(u,y);return}let p=u.action.startsWith("sources_")?R.resources.find(k=>k.key===u.value):null;if(u.action.startsWith("sources_")&&!p)throw new ne("INVALID_REQUEST","Choose a current resource");let A=`${y.visit}:${u.nodeId}:${p?.key??""}`,v=q.get(A)??[null],O=E[u.nodeId]??{page:1,after:null,filter:"all",...p?{resourceKey:p.key}:{}};if(u.action==="filter"){let k=u.value;if(!k||!(R.source==="offer_history"?["all","issued","reserved","redeemed","expired","revoked"]:["all","purchase","refund","source","usage","debt","settlement"]).includes(k))throw new ne("INVALID_REQUEST","Unknown data filter");O={page:1,after:null,filter:k},v.splice(0,v.length,null)}else if(u.action==="next"||u.action==="sources_next"){let k=p?.sources.at(-1),c=p?k?{kind:"ledger",cursor:{at:k.detail[0],id:k.id,type:"source"}}:null:W.dataCursors[u.nodeId];if(!c||!p&&!R.hasNext)return;v[O.page]=c,O={...O,page:O.page+1,after:c}}else if(u.action==="previous"||u.action==="sources_previous"){if(O.page<=1)return;O={...O,page:O.page-1,after:v[O.page-2]??null}}q.set(A,v),E={...E,[u.nodeId]:O},await i.perform(()=>i.client.get({nodeId:y.nodeId,visit:y.visit,revision:y.revision,components:E}))}return{get queries(){return E},intent:n,reset(){E={},q.clear()}}}function at(i){let{doc:E,holder:q,reviewHolder:n,mountScreenPreview:u}=i,y=!1,W,R=0,o=null,p="",A,v=new Map,de=c=>c?`${c.id}:${c.nodeId}:${c.visit}:${c.revision}:${c.paywall?.quote?.operationId??""}`:"";async function O(c){if(i.stopped||!i.client.review||y&&c===W&&A?.active)return;let _=!y||c!==W;y||(p=de(i.client.view),v.set(p,structuredClone(i.answers))),y=!0,W=c,q.hidden=!0,i.suspend(!0),n.hidden=!1;let ve=++R;_&&(A?.finish("dismissed"),o?.destroy(),o=null,n.replaceChildren(),A=sn(n,i.loadingOptions,"funnel",()=>{k()}));let g=_?A:void 0;try{if(g?.start(!1,i.client.view?.locale),ve!==R||i.stopped)return;let Ie=i.client.review(c),V=await(g?.wait(Ie,_e)??Ie);if(i.stopped||ve!==R||!y)return;if(!V.review)throw new ne("INVALID_RESPONSE","Historical projection is missing");o?.destroy(),o=null,g||n.replaceChildren();let d=E.createElement("div"),x=g?an(d,n):()=>{};n.append(d);let F=V.run.locale.startsWith("zh"),te=i.chrome;d.style.cssText=te.history;let ie=E.createElement("p");ie.textContent=F?"只读回看":"Read-only history",ie.style.cssText=te.historyTitle,d.append(ie);let me=E.createElement("p");me.style.cssText=te.historyNote,me.textContent=V.review.pages.length?F?"选择一页查看当时的内容,回看不会改动任何信息。":"Choose a page to see it as it was. Nothing here can be changed.":F?"还没有可回看的页面。":"There are no earlier pages yet.",d.append(me);let j=V.review.page?.receiptId,B=E.createElement("div");B.style.cssText=te.historyPages;for(let[m,U]of V.review.pages.entries()){let J=E.createElement("button");J.type="button",J.textContent=F?`第 ${m+1} 页`:`Page ${m+1}`;let ue=j!==void 0&&U.receiptId===j;J.style.cssText=ue?te.primary:te.secondary,ue&&J.setAttribute("aria-current","page"),Be(J,()=>i.chrome.focus),J.onclick=()=>{O(U.receiptId)},B.append(J)}if(B.childElementCount&&d.append(B),V.review.page){let m=V.review.page,U=E.createElement("div");U.inert=!0,U.style.cssText=te.historyPage,d.append(U),o=u(U,{mode:"live",rendererUrl:i.client.webViewUrl,title:m.document.name,onAction:()=>{},onAnswers:()=>{},onCustomerDataIntent:()=>{},onRendered:()=>{ve===R&&!i.stopped&&g?.present(x)},onError:ue=>{if(ve!==R||i.stopped)return;let X=new Error(ue);g?.finish("error",X),o?.destroy(),o=null,d.remove(),i.fail(X)},onEscape:()=>{k()}});let J=o;if(J.update(m.document,V.run.locale,{serverInput:{bindings:m.inputs,answers:m.answers,values:m.values}}),await J.ready,i.stopped||ve!==R||!y)return}let D=F?{issued:"已领取",reserved:"已预留",redeemed:"已使用",expired:"已过期",revoked:"已撤销",unknown:"状态待确认"}:{issued:"Issued",reserved:"Reserved",redeemed:"Used",expired:"Expired",revoked:"Revoked",unknown:"Status unconfirmed"},Y=E.createElement("div");Y.style.cssText=te.historyRecords;for(let m of[...V.review.coupons.map((U,J)=>`${F?"优惠券":"Coupon"} ${J+1}: ${D[U.status]}`),...V.review.purchases.map((U,J)=>`${F?"购买":"Purchase"} ${J+1}: ${it(U.status,F)}`)]){let U=E.createElement("p");U.textContent=m,U.style.margin="0",Y.append(U)}Y.childElementCount&&d.append(Y),V.review.page||g?.present(x),i.client.view&&await i.enqueue(i.client.view)}catch(Ie){if(ve!==R||i.stopped)return;g?.finish("error",Ie),o?.destroy(),o=null,n.replaceChildren(),i.fail(Ie)}}async function k(){if(!y||i.stopped||!i.client.review)return;let c=++R;A?.finish("dismissed");try{if(await i.client.review(),i.stopped||c!==R)return;y=!1,R++,A?.finish("dismissed"),o?.destroy(),o=null,n.replaceChildren(),n.hidden=!0,q.hidden=!1;let _=i.client.view;de(_)!==p?(v.set(p,structuredClone(i.answers)),i.resetScreen()):(v.delete(p),i.suspend(!1)),_&&await i.enqueue(_)}catch(_){if(c!==R||i.stopped)return;o?.destroy(),o=null,n.replaceChildren(),i.fail(_)}}return{get active(){return y},get receipt(){return W},open:O,exit:k,get drafts(){return new Map([...v].map(([c,_])=>[c,structuredClone(_)]))},stop(){y=!1,R++,A?.finish("dismissed"),o?.destroy(),o=null,n.replaceChildren(),n.hidden=!0,q.hidden=!1}}}var En=5e3,ft="position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip-path:inset(50%);white-space:nowrap";async function mt(i,E,q){let n=E,u=n.prepared,y=u&&Rn(u),W=()=>{},R,o;function p(e){for(let t of R?.copies.values()??[])t!==e&&t.destroy();R=void 0}let A;function v(){u&&u.state!=="adopted"&&y?.release()}let de=()=>u?.state==="shown"&&!!y?.modal,O=n.client.identitySignal,k;try{k=await Promise.all([import("./screen-renderer-TZIU775B.js"),import("./paywall-3P5YKZRE.js")]),n.signal?.throwIfAborted(),O?.throwIfAborted()}catch(e){throw v(),e}let[{mountScreenPreview:c},{showPaywall:_}]=k,ve=(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&n.appManifestRelease?rt({client:n.client,appManifestRelease:n.appManifestRelease,onError:n.onError}):void 0;ve?.start();let g=i.ownerDocument,Ie=Yn(g),V=!1,d=g.createElement("section"),x=g.createElement("div"),F=g.createElement("div"),te=g.createElement("div"),ie=g.createElement("button");te.hidden=!0,ie.type="button";let me=g.createElement("p"),j=g.createElement("p"),B=g.createElement("button"),D=g.createElement("button"),Y=g.createElement("button"),m=g.createElement("dialog"),U,J=!1;d.dataset.indianaFunnel="",d.dataset.longplayCloseOwner="sdk",d.setAttribute("aria-busy","false"),me.setAttribute("role","status"),j.setAttribute("role","alert"),j.hidden=!0,B.type=D.type=Y.type="button",F.append(B,ie,me,j,Y,D),d.append(x,te,F),i.append(d);let ue=Zn,X=Cn(ue),ln="",we=(g.documentElement.lang||"").startsWith("zh"),K,dn="",Je,kn=!1,un=!1;for(let e of[B,ie,Y,D])Be(e,()=>X.focus);function Fn(){let e=we?"关闭":"Close";D.parentElement===m?(D.textContent="×",D.setAttribute("aria-label",e),Wn(D,ue)):(D.textContent=e,D.removeAttribute("aria-label"),D.style.cssText=X.link+";margin-inline-start:auto")}function ze(e){let t=e?.screen?.content.document.theme??ue,r=JSON.stringify([t.primary,t.background,t.text,t.radius,t.font,D.parentElement===m]);if(r===ln)return;ln=r,ue=t;let b=D.parentElement===m;X=Cn(ue,b),d.style.cssText=X.root+";min-width:0"+(b?";display:flex;flex-direction:column;min-height:100%":""),F.style.cssText=Dn(),F.hidden&&(F.style.display="none"),B.style.cssText=ie.style.cssText=X.secondary,Y.style.cssText=X.primary,me.style.cssText=X.status,j.style.cssText=X.alert,Fn(),bn(B)}function Dn(){let e=D.parentElement===m,t=e&&K?.responsive===!0;return X.bar+(e?";margin-top:auto":"")+(t?`;position:sticky;bottom:0;z-index:1;background:${ue.background}`:"")+(un?`;${ft}`:"")}function Tn(){return F.hidden||un?0:F.getBoundingClientRect().height}function Fe(){let e=D.parentElement===m,t=B.hidden&&ie.hidden&&Y.hidden&&j.hidden&&(D.hidden||D.parentElement!==F);un=e&&kn&&!!t,F.hidden=t&&!me.textContent,F.style.cssText=Dn(),F.style.display=F.hidden?"none":"flex",K?.responsive&&Je!==void 0&&K.setContentHeight(Je+Tn())}ze();let pe=null,C=null,re=null,Ce="",ee="",De=!1,Ge="",cn="",Qe="",s=!1,G=0,We=!1,An="",pn=null,fn=Promise.resolve(),Sn=!n.client.view,Ve,mn=!1,T=q,je=n.hostPaywallTarget,Ne,Ue,Ye="",Xe,oe=!1,Te=null,ye=!1,Ze=()=>n.client.pendingCommand?.operation==="close",se=null,H=null,wn=Jn({document:g,run:async()=>{(!C?.observing||n.client.pendingCommand)&&await gn()},delay:()=>{if(!ae.pending&&!(s||!re||!["running","waiting"].includes(re.status)&&!n.client.pendingCommand)&&!(C?.observing&&!n.client.pendingCommand))return re.pendingRequest||n.client.pendingCommand?1500:En},hiddenDelay:()=>!s&&!ae.pending&&n.client.pendingCommand?15e3:void 0}),M=null;function yn(){return H&&n.client.hasDurableJournal===!0&&M?.acknowledged===!0&&M.operationId===H.operationId&&n.client.view?.id===M.runId&&n.client.view?.status==="closed"&&n.client.view.revision===M.revision+1&&!(n.client.pendingCommands?.length??(n.client.pendingCommand?1:0))&&!n.client.pendingPurchase?H:null}function On(e){let t=e.run.paywall;if(M&&e.settlement?.requestId===M.requestId&&e.settlement.state==="settled"&&e.settlement.operationId===null&&e.run.id===M.runId&&e.run.status==="closed"&&!e.run.pendingRequest&&e.run.revision===M.revision+1&&e.run.nodeId===M.nodeId&&e.run.visit===M.visit&&t?.receiptId===M.receiptId&&t.selectionGeneration===M.selectionGeneration&&(t.quote?.operationId??null)===M.operationId&&(t.operation?.operationId??t.quote?.operationId??null)===M.operationId){let r=M.operationId===null&&t.selectionGeneration===0&&!t.quote&&!t.operation&&!t.purchaseRequestId,b=In({quote:t.quote,operation:t.operation,requestId:t.purchaseRequestId,pending:!1,destroyed:!1,canReselect:t.canReselect});(r||t.canReselect===!0&&b.type==="native")&&(M.acknowledged=!0)}}let Ae=null,Me=new Set,ge={},qe=!1,Z=(e,t=null)=>{s||(e instanceof ne&&e.status===409&&e.reason==="STATE_CHANGED"&&e.recovery==="recover_operation"&&wn.destroy(),Ae=t,qe=!1,j.textContent=Kn(e,we),j.hidden=!1,Y.hidden=n.client.pendingCommand===null,Fe(),ke(n.onError,e))},ae=xn({client:n.client,document:g,conceal(){s||(he(),T?.finish("dismissed"),d.hidden=!0,V||(V=!0,Ie()))},async receive(e){s||await ce(n.client.view??e.run)},failed(e){if(!s){if(!ae.pending){ye=!1;let t=n.client.view;t&&ce(t).then(()=>Z(e),Z);return}tn(),d.parentElement!==i&&i.append(d),d.hidden=!1,B.hidden=ie.hidden=D.hidden=!0,me.textContent="",ze(),Z(e,n.client.pendingCommand?.requestId??null)}}}),Nn=()=>{s||(Ae=null,j.textContent=nt(we),j.hidden=!1,Y.hidden=!0,Fe())};function Se(){let e=n.client.view;if(!e)throw new ne("INVALID_REQUEST","No current Run is available");return{requestId:crypto.randomUUID(),nodeId:e.nodeId,visit:e.visit,revision:e.revision}}let h=at({client:n.client,doc:g,holder:x,reviewHolder:te,mountScreenPreview:c,loadingOptions:n,get chrome(){return X},get stopped(){return s},get answers(){return ge},suspend(e){C?.setSuspended(e)},resetScreen(){Ce="",ee="",Ge=""},enqueue:ce,fail:Z}),$e=ot({client:n.client,expected:Se,fail:Z,get stopped(){return s},get reviewing(){return h.active},get key(){return Ce},get busy(){return G},get staleRead(){return pn}}),Ke=st({client:n.client,expected:Se,perform:He,onIntent:n.onCustomerDataIntent,get stopped(){return s},get busy(){return G},get document(){return pe?.document},get answers(){return ge}}),en=e=>`${e.id}:${e.nodeId}:${e.visit}`,Oe=e=>e&&(e.screen||e.paywall)?en(e):"";function be(){let e=n.client.view;B.disabled=!h.active&&(G>0||!!n.client.pendingCommand||!e?.canBack||e.stopped||!["running","waiting"].includes(e.status)||!Oe(e)||ee!==Oe(e)),B.hidden=!h.active&&!e?.canBack,bn(B);let t=!!C&&!h.active;D.hidden=t&&!T?.active||J&&!h.active,ie.hidden=!n.client.review||!h.active&&!e?.canBack;let r=e?.locale.startsWith("zh");kn=!t&&(G>0||!!e?.pendingRequest),me.textContent=t?"":G>0||e?.pendingRequest?r?"正在处理":"Processing":e?.instruction?.type==="wait"?r?"等待中":"Waiting":"",Fe()}async function qn(e){if(!e)return;let t=n.client.view;await e;let r=n.client.view;if(!t||!r||r.id!==t.id||r.nodeId!==t.nodeId||r.visit!==t.visit||r.stopped||!["running","waiting"].includes(r.status))throw new ne("PRECONDITION_FAILED","The screen changed while its display was acknowledged")}async function He(e,t=!1,r){if(!((G||ye||se||H)&&!t||s||h.active&&!t)){G++,d.setAttribute("aria-busy","true"),j.hidden=!0,Ae=null,qe=!1,be();try{if(t||await qn($e.inFlight),s)return;let b=await e();s||await ce(n.client.view??b.run)}catch(b){r?.(b)&&n.client.pendingCommand===null?Nn():ae.pending||Z(b,n.client.pendingCommand?.requestId??null)}finally{G=Math.max(0,G-1),d.setAttribute("aria-busy",String(G>0)),s||(Y.hidden=n.client.pendingCommand===null,be())}}}function Le(){wn.schedule()}async function gn(){if(!(s||We||G)&&!ae.pending){if(h.active){await h.open(h.receipt);return}We=!0;try{let e=n.client.pendingCommand;e&&n.client.settle&&await n.client.settle(e.requestId);let t=n.client.view,r=Ke.queries,b=await n.client.get(t?.screen&&Object.keys(r).length?{nodeId:t.nodeId,visit:t.visit,revision:t.revision,components:r}:void 0);qe&&!s&&(qe=!1,j.hidden=!0,Fe()),!s&&r===Ke.queries&&await ce(n.client.view??b.run)}catch(e){Z(e),qe=!s}finally{We=!1}}}function nn(e,t,r){if(T?.active){let le=T;return le.setDismissHandler(()=>Hn(le)),le}let b=sn(i,n,"funnel",()=>Hn(b),jn);return T=b,b.start(e,t,r),b}function Hn(e){s||oe||(oe=!0,e.finish("dismissed"),he(),d.hidden=!0,n.client.view?Pe().finally(z):z())}function hn(){clearTimeout(Xe?.timeout),Xe=void 0}function he(e){J=!1,hn(),Ne?.abort(),Ne=void 0,pe?.destroy(),pe=null,C?.destroy(),C=null,Ve=void 0,Ue?.(),Ue=void 0,m.open&&m.close();for(let t of Array.from(x.children))(!e||!t.contains(e))&&t.remove();x.style.cssText="",Je=void 0,Ce="",ee="",De=!1,Ge="",Qe=""}function Ln(){let e=g.defaultView;K?.responsive&&e&&pe?.resizeViewport?.(e.innerHeight,e.innerWidth)}function tn(){K?.destroy(),K=void 0,dn=""}function rn(e){let t=e.screen?.presentation;if(!t||t.type==="inline"){m.open&&m.close(),tn(),D.parentElement!==F&&F.append(D),d.parentElement!==i&&i.append(d);for(let le of["flex","display","flex-direction","justify-content"])x.style.removeProperty(le);ze(e),Fe();return}d.parentElement!==m&&(m.append(D,d),i.append(m)),x.style.flex="1 0 auto",x.style.display="flex",x.style.flexDirection="column",x.style.justifyContent="center",ze(e);let r=e.screen.content.document,b=JSON.stringify([t,ln]);b!==dn&&(tn(),dn=b,m.style.cssText=zn("funnel",t,ue),K=Gn(m,{presentation:t,theme:r.theme,pages:r.pages},Ln),K.latch()),Fe(),m.setAttribute("aria-label",(U?.screen===e.screen?.content.document.name?U?.label:void 0)??pe?.document?.name??e.screen?.content.document.name??"Funnel")}async function lt(e){if(s||oe)return;if(ae.observe(),ae.pending){re=e;return}if(ye&&(Ze()||["running","waiting"].includes(e.status))||(re=e,Ae&&n.client.pendingCommand?.requestId!==Ae&&(j.hidden=!0,Ae=null),we=e.locale.startsWith("zh"),ie.textContent=we?"回看":"History",B.textContent=h.active?we?"返回当前":"Return to current":we?"返回":"Back",Fn(),Y.textContent=we?"重试":"Retry",Y.hidden=n.client.pendingCommand===null,be(),An!==`${e.revision}:${e.visit}:${e.status}:${e.stopped}`&&(An=`${e.revision}:${e.visit}:${e.status}:${e.stopped}`,ke(n.onState,structuredClone(e))),s||oe))return;if((!e.pendingRequest||ye&&e.status==="closed")&&["closed","ineligible","failed"].includes(e.status)){z();return}if(e.stopped&&de()){z();return}if(e.stopped||n.client.configurationReady===!1){h.stop(),v(),he(),T?.finish("skipped"),d.hidden=!0,Le();return}if(d.hidden=!1,h.active){Le();return}if(e.status==="completed"&&C?.subscriptionUpgradeActive){Le();return}let t=Oe(e),r=n.client.view;if(r&&r.revision>e.revision&&Oe(r)!==t)return;let b=!e.instruction&&!e.pendingRequest&&e.nodeType==="screen"&&["running","waiting"].includes(e.status);t!==Ce&&(Ce&&T?.finish("dismissed"),he(),Ce=t,ge={...e.answers},Ke.reset());let le=en(e);if(Ye===le){d.hidden=!0;return}if(b&&!t){d.hidden=!0;let P=u?.state==="shown"?null:nn(!0,e.locale);!s&&!oe&&Xe?.key!==le&&(hn(),Xe={key:le,timeout:setTimeout(()=>{let l=n.client.view;if(s||!P?.active&&u?.state!=="shown"||!l||en(l)!==le)return;Ye=le;let S=new Error("Funnel screen preparation timed out");P?.finish("error",S),v(),he(),Z(S)},_e)}),Le();return}hn();let $=P=>{let l=n.client.view;return!s&&!oe&&!Te&&!P.aborted&&n.client.configurationReady!==!1&&!!l&&!l.stopped&&!["closed","ineligible","failed"].includes(l.status)&&(Oe(l)===t||l.status==="completed"&&C?.subscriptionUpgradeActive===!0)},Ee=(P,l)=>{$(l)&&(Ye=t,T?.finish("error",P),he(),d.hidden=!0,Z(P))};if(t||((e.instruction&&e.instruction.type!=="evaluate_segment"||!["running","waiting"].includes(e.status))&&v(),rn(e),e.instruction?.type!=="event"&&e.instruction?.type!=="open_url"&&T?.finish("skipped")),e.screen){if(mn=!0,je=void 0,v(),n.prepareNextPaywall&&R?.key!==t){p();let L=new Map;for(let[I,N]of Object.entries(e.screen.nextPaywalls??{})){if(!e.screen.outputs.includes(I))continue;let f=n.prepareNextPaywall({run:e,paywallVersionId:N.paywallVersionId});f&&L.set(I,f)}R={key:t,copies:L}}let P=e.screen.content;if(!pe){let L=e.screen.presentation.type!=="inline",I=nn(L,e.locale);if(s||oe)return;let N=(Ne=new AbortController).signal;rn(e),Ue=L?Xn(m):an(d,i),pe=c(x,{mode:"live",closeActions:Array.from(new Set([...n.closeActions??[],...P.document.actions.filter(f=>f.type==="event"&&f.close).map(f=>f.id)])),onAuthoredClose(f){$(N)&&(J=f,be())},rendererUrl:n.client.webViewUrl,title:P.document.name,...L?{hostPresentation:()=>K?.type??e.screen.presentation.type}:{},onResize:f=>{Je=f,K?.responsive&&K.setContentHeight(f+Tn())},onAction(f,a={},fe={}){if(h.active||!$(N)||ee!==t)return;ge={...ge,...fe};let vn=e.screen?.inputs??[],Mn=Object.fromEntries(vn.filter(({variable:Re})=>Object.hasOwn(ge,Re)).map(({variable:Re})=>[Re,ge[Re]]));if(tt(vn,Mn).length){Nn();return}let xe=!G&&R?.key===t?R.copies.get(f):void 0;xe?.state==="ready"&&xe.open()==="shown"&&(p(xe),v(),W(),u=xe,y=Rn(xe),W=y?.onClose(Vn)??(()=>{}),o=t),He(()=>n.client.submit({operation:"submit",...Se(),input:{type:"screen",output:f,answers:Mn,selection:a}}),!1,Re=>et(Re,vn)).finally(()=>{let Re=n.client.view;o===t&&(!Re||Oe(Re)===t)&&(o=void 0,v())})},onAnswers:f=>{h.active||!$(N)||ee!==t||(ge={...ge,...f})},onCustomerDataIntent:f=>{h.active||!$(N)||ee!==t||Ke.intent(f).catch(Z)},onEscape:()=>{!$(N)||ee!==t||h.active||se||H||Pe()},onError:f=>{let a=new Error(f);ee===t?Z(a):Ee(a,N)},onRendered:f=>{if(!(!$(N)||ee===t))try{I.present(a=>{Ue?.(),Ue=void 0,f&&(U={screen:P.document.name,label:f},m.setAttribute("aria-label",f)),L&&(m.showModal(),V=!1,K?.responsive&&m.focus({preventScroll:!0}),!a&&n.loading!=="host"&&Qn(m,K?.type??e.screen.presentation.type,K?.responsive)),ee=t,De=L,be()}),$(N)&&$e.report(t)}catch(a){Ee(a,N)}}}),Ln()}let l={capabilities:e.screen.capabilities,customerData:e.screen.customerData,parameters:e.parameters,serverInput:{bindings:e.screen.inputs,answers:ge,values:e.screen.values}},S=JSON.stringify([P,e.locale,l.parameters,e.screen.inputs,e.screen.values]);if(S!==Ge)pe.update(P.document,e.locale,l),Ge=S,cn=JSON.stringify(l.capabilities),Qe=JSON.stringify(l.customerData);else{let L=JSON.stringify(l.capabilities);L!==cn&&(pe.updateCapabilities(l.capabilities),cn=L),JSON.stringify(l.customerData)!==Qe&&(pe.updateCustomerData(l.customerData),Qe=JSON.stringify(l.customerData))}let Q=pe;if(Q)try{await(T?.wait(Q.ready)??Q.ready)}catch(L){Ne&&Ee(L,Ne.signal)}}else if(e.paywall&&!C){mn=!0,p();let P=e.paywall.resolution,l="document"in P?P.document:null,S=y,Q=n.mountPaywallControls,L=null,I=(Ne=new AbortController).signal,N={loading:"host",signal:I,...Q&&{mountControls:a=>Q(a,e)},canInteract:()=>$(I)&&!h.active&&!se&&!H,beforeAction:async()=>{G++;try{await qn($e.settled()),j.hidden=!0,Ae=null,qe=!1,Fe()}finally{G=Math.max(0,G-1)}},start:async()=>{let a=await Pn(n.client),fe=A;return A=void 0,a.view&&fe?.(a.view),a},onObservationChange:Le,...n.onPurchaseIntent&&{onPurchaseIntent:a=>n.onPurchaseIntent(a,structuredClone(e))},onPurchase:n.onPurchase,onCheckoutUrl:n.onCheckoutUrl,resumeCheckout:n.resumeCheckout,allowNewPurchase:n.allowNewPurchase,checkoutNavigation:n.checkoutNavigation,terminateCheckout:n.terminateCheckout,beforeCheckoutReplacement:n.beforeCheckoutReplacement,purchaseConfirmation:n.purchaseConfirmation,confirmOnHostedCheckout:n.confirmOnHostedCheckout,resolveOfferId:n.resolveOfferId,prepareSubscriptionChange:n.prepareSubscriptionChange,resolveSubscriptionChange:n.resolveSubscriptionChange,claimCoupon:n.claimCoupon,onEvent:n.onEvent,onOpenUrl:a=>n.onOpenUrl?n.onOpenUrl({receiptId:e.paywall.receiptId,url:a,openIn:"same_window"}):g.defaultView?.location.assign(a),onAction:async a=>{if(h.active)return;let fe=await n.client.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:e.nodeId,visit:e.visit,revision:n.client.view?.revision??e.revision,input:{type:"screen",output:a,answers:{}}});await ce(n.client.view??fe.run)},onError:a=>{ee===t?Z(a):Ee(a,I)}},f={quoteError:a=>ke(n.onError,a),present(a){$(I)&&(L?.present(fe=>{a(fe),ee=t,De=f.retainedDialog?.dialog.open??!!x.querySelector("dialog[open]"),De&&(V=!1),be()}),$(I)&&$e.report(t))},async closeAction(a){s||h.active||await ae.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:e.nodeId,visit:e.visit,revision:n.client.view?.revision??e.revision,input:{type:"screen",output:a,answers:{}}})},async dismiss(){if(s||I.aborted||h.active||se||H||!ye&&!$(I))return;ye=!0;let a=n.client.view;if(a?.status==="completed"&&C?.subscriptionUpgradeActive){Me.add(`complete:${a.id}`),ke(n.onComplete,structuredClone(a)),z();return}if((n.resumeCheckout||n.terminateCheckout)&&pt()){re=n.client.view,z();return}await Pe()}};if(S&&Q)v();else if(S){let a=await S.adopt(e,{options:N,handoff:f,start:()=>Pn(n.client)});o=void 0,a&&$(I)&&!s?(rn(e),C=a,Ve={runId:e.id,receiptId:e.paywall.receiptId},T?.active&&T.present(()=>{}),ee=t,De=S.modal,De&&(V=!1),be(),$e.report(t),h.active&&C.setSuspended(!0)):(a?.destroy(),v(),A=fe=>y?.remember(fe))}if(s||oe)return;if(!C){if(L=nn(!0,e.locale,l),s||oe)return;(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&n.loading==="host"&&je?.ownerDocument===g&&(f.hostPaywallTarget=je),je=void 0,rn(e);let a=await _(x,N,f).catch(fe=>(Ee(fe,I),null));!$(I)&&!(ye&&!s&&!I.aborted)?a?.host?.destroy():a&&(C=a.host,C&&(Ve={runId:e.id,receiptId:e.paywall.receiptId}),C?.setSuspended(h.active))}}if(s||oe)return;be();let w=e.instruction;if(w&&(w.type==="open_url"||w.type==="event")&&!Me.has(w.receiptId)){let P=g.createElement("button");P.type="button",P.style.cssText=X.primary,Be(P,()=>X.focus),x.style.cssText=X.stage,P.textContent=w.type==="open_url"?`${we?"前往":"Continue to"} ${new URL(w.url).host}`:we?"继续":"Continue",P.onclick=()=>{let l=Se(),S=w.type==="open_url"&&!n.onOpenUrl&&w.openIn==="new_window"?dt(w.url):null;He(async()=>{let Q="success";if(w.type==="open_url")if(n.onOpenUrl)try{Q=await n.onOpenUrl({receiptId:w.receiptId,url:w.url,openIn:w.openIn})===!1?"failed":"opened"}catch(I){ke(n.onError,I),Q="failed"}else Q=w.openIn==="new_window"&&!S?"failed":"opened";if(w.type==="event"){if(!n.onEvent)throw new ne("EVENT_HANDLER_REQUIRED","Provide the event handler");await n.onEvent(w.event)}if(s||n.client.view?.nodeId!==l.nodeId||n.client.view.visit!==l.visit)throw new ne("PRECONDITION_FAILED","The client action visit changed");let L=await n.client.submit({operation:"submit",...l,input:{type:"client_action",receiptId:w.receiptId,outcome:Q}});return Me.add(w.receiptId),w.type==="open_url"&&!n.onOpenUrl&&w.openIn==="same_window"&&g.defaultView?.location.assign(w.url),L})},T?.active?T.present(()=>x.replaceChildren(P)):x.replaceChildren(P)}!e.pendingRequest&&e.status==="completed"&&!Me.has(`complete:${e.id}`)&&(Me.add(`complete:${e.id}`),ke(n.onComplete,structuredClone(e))),Le()}function dt(e){let t=g.defaultView?.open(e,"_blank")??null;return t&&(t.opener=null),t}function ce(e){return be(),fn=fn.catch(()=>{}).then(async()=>{try{await lt(e)}catch(t){throw T?.active&&(Ye=en(e),T.finish("error",t),he(),d.hidden=!0),t}}),fn}let ut=n.client.subscribe(e=>{if(!Sn){if(e.stopped&&(De||de())&&!ye){re=e,z();return}!ye&&(e.stopped||n.client.configurationReady===!1||Ce&&ee!==Ce&&(Oe(e)!==Ce||["closed","ineligible","failed"].includes(e.status)))&&(he(),T?.finish("dismissed"),d.hidden=!0),ce(e).catch(Z)}}),ct=n.client.subscribeError?.(e=>{ae.pending||Z(e)});function pt(){let e=n.client.view,t=e?.paywall;return!!t?.operation&&!!e&&["running","waiting"].includes(e.status)&&Bn(In({quote:t.quote,operation:t.operation,requestId:t.purchaseRequestId,pending:!1,destroyed:!1,canReselect:t.canReselect}))}function Pe(e){if(Te)return Te;if(s||!e&&(se||H))return Promise.resolve();let t=!e&&Ze();return!t&&n.client.view&&!["running","waiting"].includes(n.client.view.status)?(re=n.client.view,z(),Promise.resolve()):(Te=He(async()=>{let r=t?await n.client.retry():await(e?n.client.submit.bind(n.client):ae.submit)({operation:"close",...e??Se()});return e&&On(r),r},!0).then(()=>{let r=n.client.view;r?.status==="closed"&&!Ze()&&(re=r,z())}).finally(()=>{Te=null}),Te)}function z(){_n()}function _n(e){ve?.destroy(),!s&&(s=!0,ae.destroy(),W(),p(),!mn&&(re?.status==="ineligible"||re?.status==="completed")&&y?.withhold(),v(),n.signal?.removeEventListener("abort",z),O?.removeEventListener("abort",z),T?.finish("dismissed"),wn.destroy(),ut(),ct?.(),he(e),tn(),h.stop(),m.remove(),!e||!d.contains(e)?d.remove():(F.remove(),te.remove()),!e&&!V&&Ie(),ke(n.onDismiss,re?structuredClone(re):null))}B.onclick=()=>{if(!B.disabled){if(h.active){h.exit();return}He(()=>n.client.submit({operation:"back",...Se()}))}},ie.onclick=()=>{h.open()},D.onclick=()=>{T?.active?T.dismiss():se||Pe()},Y.onclick=()=>{ae.pending?ae.retry().catch(()=>{}):Ze()?Pe():He(()=>n.client.retry())},m.addEventListener("cancel",e=>{e.preventDefault(),T?.active?T.dismiss():se||Pe()}),n.signal?.addEventListener("abort",z,{once:!0}),O?.addEventListener("abort",z,{once:!0});let on=!1;function Vn(){s||oe||(oe=!0,T?.finish("dismissed"),he(),d.hidden=!0,n.client.view?Pe().finally(z):on=!0)}y&&(W=y.onClose(Vn));let Un={destroy:z,refresh:gn,get recoveryPaywall(){if(C&&Ve)return{...Ve,view:C.currentResolution}},setPurchaseRecovery(e,t){return C?.setPurchaseRecovery(e,t),C!==null},retainPurchaseDialog(){let e=C?.retainPurchaseDialog();if(e)return C=null,_n(e.dialog),{dialog:e.dialog,release(){e.release(),d.remove(),V||Ie()}}},get recovery(){let e=yn();if(e)return e;if(!s&&!G&&!ye&&!se&&C){let t=C.recovery;if(t.type!=="native")return t}return{type:"recover",operationId:n.client.pendingPurchase?.operationId??n.client.view?.paywall?.quote?.operationId??H?.operationId??null,requestId:n.client.pendingCommand?.requestId??null}},prepareFallback(){if(se)return se;let e=yn();if(e)return Promise.resolve(e);let t=n.client.pendingPurchase?.operationId??n.client.view?.paywall?.quote?.operationId??H?.operationId??null,r=()=>({type:"recover",operationId:t,requestId:n.client.pendingCommand?.requestId??null});if(n.client.hasDurableJournal!==!0){let w=C?.recovery;return Promise.resolve(w&&w.type!=="native"&&w.type!=="cancel"?w:r())}let b=(n.client.pendingCommands??(n.client.pendingCommand?[n.client.pendingCommand]:[])).some(w=>w.operation==="close");if(s&&!(b||H&&n.client.view?.status==="closed")||G||We||Te||h.active||!C&&!H&&!b)return Promise.resolve(r());let le=C,$=(async()=>{try{if(!H&&b){let l=await n.client.retry();return await ce(n.client.view??l.run),r()}if(!H){let l=await le.prepareFallback();if(l.type!=="native")return l;if(n.client.hasDurableJournal!==!0)return r();H=l}let w=n.client.pendingCommands??(n.client.pendingCommand?[n.client.pendingCommand]:[]);if(w.length){let l=w.find(Q=>Q.operation==="close");if(!l||!M||l.requestId!==M.requestId)return r();let S=await n.client.retry();On(S),await ce(n.client.view??S.run)}else{let l=n.client.view,S=l?.paywall;if(!l||!S||S.selectionGeneration===void 0||(S.quote?.operationId??null)!==H.operationId||H.operationId!==null&&S.canReselect!==!0)return r();let Q=S.selectionGeneration,L=await n.client.get();await ce(n.client.view??L.run);let I=n.client.view,N=I?.paywall;if(!I||!N||!["running","waiting"].includes(I.status)||I.stopped||I.id!==l.id||I.nodeId!==l.nodeId||I.visit!==l.visit||N.receiptId!==S.receiptId||N.selectionGeneration!==Q||(N.quote?.operationId??null)!==H.operationId||H.operationId!==null&&N.canReselect!==!0||n.client.pendingPurchase||(n.client.pendingCommands?.length??(n.client.pendingCommand?1:0)))return r();let f=Se();M={runId:I.id,operationId:H.operationId,revision:f.revision,requestId:f.requestId,nodeId:I.nodeId,visit:I.visit,receiptId:N.receiptId,selectionGeneration:Q,acknowledged:!1},await Pe(f)}let P=yn();return P?(z(),P):r()}catch(w){return Z(w),r()}})();se=$;let Ee=()=>{se===$&&(se=null)};return $.then(Ee,Ee),$},review:h.open,exitReview:h.exit,get unappliedDrafts(){return h.drafts}};try{let e=n.client.view;if(e)((n.client.viewAgeMs??En)>=En||e.instruction?.type==="evaluate_segment")&&(pn=gn().finally(()=>{pn=null})),await ce(e);else{if(d.hidden=!0,s)throw new DOMException("Presentation cancelled","AbortError");let t=on||u?.state==="shown"?null:nn(n.client.view?.screen?.presentation.type!=="inline",n.client.view?.locale);if(s||oe&&!on)throw new DOMException("Presentation cancelled","AbortError");let r=n.client.get(),b=await(t?t.wait(r,_e):wt(r,_e));if(Sn=!1,on)return s||await Pe().finally(z),Un;await ce(n.client.view??b.run)}}catch(e){throw T?.finish("error",e),z(),e}return Un}function wt(i,E){let q;return Promise.race([i,new Promise((n,u)=>{q=setTimeout(()=>u(new Error("Presentation data timed out")),E)})]).finally(()=>clearTimeout(q))}function zt(i,E,q){return mt(i,E,q)}export{mt as a,zt as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as ie}from"./chunk-
|
|
1
|
+
import{i as ie}from"./chunk-FVYB2P6Y.js";import{a as N,b as Z,d as ee,f as te,g as ne,j as M,l as re,m as oe,n as se}from"./chunk-FWM3577O.js";import{b as K}from"./chunk-N6RBDJ5Y.js";import{r as V}from"./chunk-6NDL2ELB.js";import"./chunk-6FWT2BXF.js";import"./chunk-LZYQA3Q4.js";import"./chunk-DLLC7CRI.js";import"./chunk-CW7MTKXP.js";import"./chunk-HEPQNLR2.js";import"./chunk-VILB5M4X.js";import"./chunk-L6XCRIR2.js";import"./chunk-LUYWRWJ2.js";import{o as X,p as Y}from"./chunk-EDZJ2IGA.js";import{A as G}from"./chunk-2HIWXIJE.js";import"./chunk-T44KC4GO.js";import"./chunk-LWIBARE4.js";import{d as R}from"./chunk-TJRXWGKB.js";import{a as p}from"./chunk-5X7PTCI4.js";import"./chunk-XX5O7H6R.js";import"./chunk-NJNENW5L.js";import"./chunk-5MRSFLQA.js";import{b as u}from"./chunk-J6MYX7WY.js";import{a as h}from"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";var z=new WeakMap;function ce(o){let t={string:u.string(),number:u.number().finite(),boolean:u.boolean(),strings:u.array(u.string()),json:R}[o.type];return o.nullable?t.nullable():t}function ae(o,t){let f=u.record(u.string(),R).parse(o);if(Object.keys(f).length>40)throw new p("INVALID_REQUEST","Too many content inputs");for(let[m,n]of Object.entries(f))X.parse({[m]:n});if(Object.keys(f).some(m=>!Object.hasOwn(t.inputs,m)))throw new p("INVALID_REQUEST","Undeclared content input");for(let[m,n]of Object.entries(t.inputs))if(Object.hasOwn(f,m))ce(n).parse(f[m]);else if(n.required)throw new p("INVALID_REQUEST",`Missing content input ${m}`);return f}async function Ve(o,t){return le(o,t,!1)}async function Ae(o,t){return le(o,t,!0)}async function le(o,t,f){t.signal?.throwIfAborted();let m=K.parse(t.content),n=m.document;if(t.closeControl==="content"&&!n.screen.actions.some(e=>e.type==="event"&&e.close))throw new p("INVALID_REQUEST","An authored Close control requires a declared Close action");if(z.has(o))throw new p("CONFLICT","Content is already mounted in this container");let g=ae(t.inputs??{},n.contract),T=new Set(u.array(u.string()).max(40).parse(t.mutableInputs??[]));if(T.size!==(t.mutableInputs?.length??0)||[...T].some(e=>!Object.hasOwn(n.contract.inputs,e)))throw new p("INVALID_REQUEST","Mutable content inputs must name unique declared inputs");for(let e of Object.keys(n.contract.outputs))if(typeof t.actions[e]!="function")throw new p("INVALID_REQUEST",`Missing host handler for ${e}`);let q=Y.parse(t.bindings??[]),d=o.ownerDocument,ue=o.clientHeight||d.defaultView?.innerHeight||800,P,w,a,_,H=n.kind==="popup",r=H?d.createElement("dialog"):null,c=d.createElement("div");if(c.dataset.indianaContent=n.kind,c.setAttribute("aria-label",n.name),c.style.cssText="width:100%;min-width:0",r){r.setAttribute("aria-label",n.name);let e=n.screen.presentation;r.style.cssText=e.type==="inline"?N("content",{type:"fullscreen"},n.screen.theme):N("content",e,n.screen.theme),a=ee(r,n.screen,()=>{w?.resizeViewport(d.defaultView?.innerHeight||800,d.defaultView?.innerWidth||1024)}),r.append(c),o.append(r)}else o.append(c);let i=!1,A=!1,C=!1,D=!1,de=r?oe(r):se(c,o),S=re(o,t,n.kind,()=>{k()&&(v(),h(t.onDismiss))}),F,j,L=new Promise((e,s)=>{F=e,j=s});L.catch(()=>{});let y=null,E=structuredClone(n.screen),J=G(E,[t.locale,...d.defaultView?.navigator.languages??[]]),x=t.capabilities;E.actions=E.actions.map(e=>e.type==="event"?{...e,close:!1}:e);function v(){i||(i=!0,t.signal?.removeEventListener("abort",v),S.finish("dismissed"),j(new Error("Content preparation cancelled")),a?.destroy(),_?.(),w?.destroy(),r?.close(),r?.remove(),c.remove(),z.delete(o),r&&P?.())}let I=()=>{!C||!k()||(v(),h(t.onDismiss))};function k(){try{return t.canDismiss?.()!==!1}catch(e){return h(t.onError,e),!1}}if(r&&t.closeControl!=="content"){let e=d.createElement("button");e.type="button",e.textContent="×",e.setAttribute("aria-label",t.locale?.startsWith("zh")?"关闭":"Close"),ne(e,n.screen.theme),e.addEventListener("click",I),r.prepend(e)}r&&a?.responsive&&(_=Z(r,I,k,t.locale?.startsWith("zh")?"关闭":"Close")),r?.addEventListener("cancel",e=>{e.preventDefault(),I()}),r?.addEventListener("keydown",e=>{e.key==="Escape"&&(e.preventDefault(),I())});async function Q(){if(i||!C||A||!y)return;let e=y;A=!0,c.setAttribute("aria-busy","true");try{await t.actions[e.actionId](structuredClone(e)),y=null}catch(s){i||h(t.onError,s)}finally{A=!1,i||c.removeAttribute("aria-busy")}}function W(){if(i)throw new p("CONFLICT","Content host has been destroyed");C||!D||(P??=M(d),S.present(e=>{de(),r&&(a?.latch(),r.showModal(),a?.responsive&&r.focus({preventScroll:!0}),!e&&t.loading!=="host"&&te(r,a?.type??n.screen.presentation.type,a?.responsive)),C=!0}))}function U(e){S.finish("error",e),j(e instanceof Error?e:new Error(String(e))),v()}let B={destroy:v,show:W,get pendingAction(){return y?structuredClone(y):null},retryAction:Q,updateInputs(e){if(i)throw new p("CONFLICT","Content host has been destroyed");let s=u.record(u.string(),R).parse(e),b=ae({...g,...s},n.contract);for(let l of Object.keys(s))if(!T.has(l)&&(!Object.hasOwn(g,l)||V(g[l])!==V(b[l])))throw new p("PRECONDITION_FAILED","This content input is frozen; prepare a new presentation");V(g)!==V(b)&&(w?.update(E,J,{capabilities:x,serverInput:{bindings:q,answers:{},values:b}}),g=b)},updateCapabilities(e){if(i)return;let s=structuredClone(e);w?.updateCapabilities(s),x=s}};z.set(o,B),t.signal?.addEventListener("abort",v,{once:!0});try{if(t.signal?.throwIfAborted(),f||(P=M(d),S.start(H,t.locale??n.screen.strings.defaultLocale),i&&await L),w=ie(c,{mode:"live",rendererUrl:t.rendererUrl,title:n.name,viewportHeight:n.kind==="page"?ue:a?.responsive?d.defaultView?.innerHeight||800:void 0,...a?.responsive?{viewportWidth:d.defaultView?.innerWidth||1024,hostPresentation:()=>a.type}:{},onResize:e=>{i||a?.responsive&&(c.style.height=`${e}px`,c.style.overflow="clip",a.setContentHeight(e))},onRendered:e=>{if(!i&&(e&&r?.setAttribute("aria-label",e),!D))try{D=!0,f||W(),F()}catch(s){U(s),h(t.onError,s)}},onError:e=>{if(i)return;let s=new Error(e);D||U(s),h(t.onError,s)},onEscape:H?I:void 0,onAction:(e,s,b)=>{if(i||!C||A||y)return;let l=n.screen.actions.find(O=>O.id===e),$=n.contract.outputs[e];if(!(l?.type!=="event"||!$)&&!(l.close&&!k()))try{let O=ce($).parse(Object.hasOwn(l.properties,"value")?l.properties.value:l.properties);y=structuredClone({requestId:crypto.randomUUID(),contentVersionId:m.id,actionId:e,event:l.event,value:O,selection:s??{},answers:b??{},requestedClose:l.close}),Q()}catch(O){h(t.onError,O)}}}),w.update(E,J,{capabilities:x,serverInput:{bindings:q,answers:{},values:g}}),await Promise.race([w.ready,L]),f&&await L,i)throw new Error("Content preparation cancelled");return B}catch(e){throw U(e),e}}export{Ve as mountContent,Ae as prepareContent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as ce}from"./chunk-W6KE7753.js";import{b as W,d as oe}from"./chunk-4N7PVGHA.js";import{b as ue}from"./chunk-65QMZQE6.js";import{a as se}from"./chunk-S5KGFAAW.js";import"./chunk-MWTSCBSY.js";import{a as X}from"./chunk-IEYSWIRA.js";import"./chunk-62MMCXIA.js";import"./chunk-QLMQI6SX.js";import{b as ie}from"./chunk-TDPFVHJM.js";import"./chunk-45PGU2HW.js";import"./chunk-AEQUKR4O.js";import"./chunk-W32FI2A2.js";import{k as H,l as Y}from"./chunk-XSEYXS4X.js";import"./chunk-NUIKM2BY.js";import"./chunk-CLV4ROBM.js";import"./chunk-ZL7YW35H.js";import"./chunk-BB6PDBS4.js";import"./chunk-YMTCZWZG.js";import"./chunk-464CINQK.js";import"./chunk-EQJIC52H.js";import"./chunk-JJIOGZIP.js";import"./chunk-DMMD4TMS.js";import"./chunk-Q6SK6G7T.js";import"./chunk-LYTPUZOW.js";import"./chunk-TZTWXL53.js";import"./chunk-H3LBNH34.js";import"./chunk-DRCBHEC6.js";import"./chunk-RM6RSLKI.js";import"./chunk-TQKNQGWV.js";import"./chunk-VILB5M4X.js";import"./chunk-T5QI2ZZR.js";import"./chunk-66SRWQES.js";import"./chunk-SUUBL2WC.js";import"./chunk-4G52SO64.js";import"./chunk-CWBL2S3A.js";import"./chunk-X6ZYJHX4.js";import"./chunk-FINCNJBH.js";import{a as g}from"./chunk-E4B7243C.js";import"./chunk-5SNUVXZ7.js";import"./chunk-SLUA7ABW.js";import"./chunk-MB2U2GWJ.js";import"./chunk-3VUPVXAV.js";import"./chunk-ZIYU3HLD.js";import"./chunk-5MRSFLQA.js";import"./chunk-7RUOZL6C.js";import{a as h}from"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";var D=new WeakMap,V=new WeakMap,Z=new WeakSet;function be(R,e){let w=e.hostPaywallTarget?void 0:e.prepared,$=()=>{e.prepared&&!Z.has(e.prepared)&&W(e.prepared)?.release()},ee=D.get(e.client);if(ee)return $(),ee;let te=n=>({...n,requestId:n.requestId??crypto.randomUUID()}),N=e.allowNewPurchase!==!1&&e.start instanceof Promise?e.start:void 0,m=e.allowNewPurchase===!1||!e.start||e.start instanceof Promise?void 0:te(e.start);m&&w?.state==="ready"&&w.matches(m)&&w.open();let f=w&&(m&&(w.state==="preparing"||["shown","closed"].includes(w.state)&&w.matches(m))||N&&["preparing","ready"].includes(w.state)||w.state==="shown"&&W(w)?.recovering)?w:void 0;f?Z.add(f):$();let P=f&&W(f);P?.claim();let z=()=>!!P?.recovering&&f?.state==="shown",T=Promise.resolve().then(async()=>{let n=!1,c,b=!1,j,C=0,S,I,U=!1,E=()=>{},re=()=>{},_,B=!1,J=!1,O,ne=!1,a=e.signal?AbortSignal.any([e.signal,e.client.identitySignal]):e.client.identitySignal,v=()=>{D.get(e.client)===T&&D.delete(e.client),a.removeEventListener("abort",F),E(),re(),f&&Z.delete(f),P?.release()};function ae(){if(O)return O;let t=new Promise(o=>O=o);return V.set(e.client,t),t.then(()=>{V.get(e.client)===t&&V.delete(e.client)}),D.get(e.client)===T&&D.delete(e.client),O}let l=Y(R,e,"funnel",()=>k(),X);function F(){k()}function k(t=!1){if(!n){if(n=!0,l.finish("dismissed"),c){c.destroy();return}if(t&&_){let o=ae();ne=!0,_.then(async s=>{s.mode==="run"&&s.status!=="blocked"&&e.client.controller&&e.client.attempt?.requestId===m?.requestId&&await e.client.close()}).catch(()=>{}).finally(()=>{o(),h(e.onDismiss,null)}),v();return}v(),h(e.onDismiss,null)}}let q={destroy:()=>k(),refresh:()=>S??(b?Q():c?.refresh())??Promise.resolve(),get recovery(){return c?.recovery??{type:"recover",operationId:null,requestId:null}},prepareFallback:()=>c?.prepareFallback()??Promise.resolve({type:"recover",operationId:null,requestId:null}),review:(...t)=>c?.review(...t)??Promise.resolve(),exitReview:(...t)=>c?.exitReview(...t)??Promise.resolve(),get unappliedDrafts(){return c?.unappliedDrafts??new Map}};a.addEventListener("abort",F,{once:!0}),P&&(re=P.onClose(()=>{B?n||ae():k(!0)}));try{a.throwIfAborted();let t=e.client.controller?.view?.paywall?.resolution,o=t&&"document"in t?t.document:e.loadingDocument;l.start(!0,m?.locale??e.client.attempt?.locale??o?.screen.strings.defaultLocale,o??null);let s=N?l.wait(N.then(r=>r?te(r):null,()=>null),H):Promise.resolve(m??null);s.catch(()=>{}),f?.state==="shown"?(J=!0,l.present(()=>{})):f&&["preparing","ready"].includes(f.state)&&Promise.all([f.ready,s.catch(()=>null)]).then(([r,i])=>{if(r){if(n||!l.active||!i||!f.matches(i)||!P?.revealable)return P?.release();l.present(()=>{f.open()==="shown"?J=!0:P.release()})}});let d=V.get(e.client);if(d&&await l.wait(d),n)return null;if(a.throwIfAborted(),N){let r=await s;if(n)return null;if(a.throwIfAborted(),!r&&!z())return l.finish("skipped"),v(),null;m=r??void 0}_=m?e.client.start(m):e.client.refresh({reuseRecentRead:!0});let u=await l.wait(_,H);return n?null:(a.throwIfAborted(),await le(u,l))}catch(t){if(ne||O?.(),n)return null;throw l.finish("error",t),v(),h(e.onError,t),t}function K(t=!1){C++;let o=c;c=void 0,E(),E=()=>{};let s=t?o?.retainPurchaseDialog?.():void 0;return o?.destroy(),a.addEventListener("abort",F,{once:!0}),s}function x(t){b=!0;let o=e.client.attempt?.locale??m?.locale,s=o?.startsWith("zh"),d=t?s?"正在查询原订单…":"Checking your purchase…":s?"暂时无法确认原订单,请重试。":"Could not check your original purchase. Try again.",u=t?void 0:()=>{Q()};c?.setPurchaseRecovery?.(d,u)||(c&&K(),l.active||(l=Y(R,e,"funnel",()=>k(),X),l.start(!0,o,e.loadingDocument??null)),l.setPurchaseRecovery(d,u))}function Q(){if(S)return S;if(n||a.aborted)return Promise.resolve();j??=c?.recoveryPaywall,a.addEventListener("abort",F,{once:!0}),x(!0);let t=Promise.resolve().then(async()=>{try{let s=await l.wait(e.client.refresh(),H);!n&&!a.aborted&&await le(s,l)}catch(s){!n&&!a.aborted&&(h(e.onError,s),x(!1))}});S=t;let o=()=>{S===t&&(S=void 0)};return t.then(o,o),t}async function le(t,o){let s=e.client.controller;if(t.mode==="run"&&t.status!=="blocked"&&s)return b&&c&&K(),b=!1,j=void 0,de(s,o?.active?o:void 0);if(t.mode==="operation"&&t.purchases.length){z()||x(!0);let d=await l.wait(e.client.recoverPurchasePaywall(j).then(u=>((n||a.aborted)&&u?.destroy(),u)),H).catch(u=>(!n&&!a.aborted&&h(e.onError,u),null));if(n||a.aborted)return null;if(d){if(n||a.aborted)return d.destroy(),null;let u=K(!0)??P?.retainPurchaseDialog?.()??l.retainPurchaseDialog();P?.release();let r=m,i=ue({client:e.client,session:d,start:e.allowNewPurchase===!1||!r?void 0:async()=>{let{requestId:p,...G}=r;return G},signal:a}),y=()=>{!n&&!a.aborted&&!U&&I&&e.client.recovery.status==="complete"&&(U=!0,h(e.onComplete,structuredClone(I)))},A=await se(R,{signal:a,loading:"host",start:async()=>i.session,checkoutNavigation:"after_confirmation",allowNewPurchase:!1,resumeCheckout:p=>e.client.continueCheckout(L,p),...i.prepare&&{prepareUpgradeReplacement:i.prepare,terminateCheckout:p=>e.client.terminateCheckout(p),beforeCheckoutReplacement:e.beforeCheckoutReplacement,purchaseConfirmation:e.purchaseConfirmation,confirmOnHostedCheckout:e.confirmOnHostedCheckout,claimCoupon:e.claimCoupon,prepareSubscriptionChange:e.prepareSubscriptionChange,resolveSubscriptionChange:e.resolveSubscriptionChange,onPurchase:e.onPurchase,onCheckoutUrl:L,async resolveOfferId(p){let G=e.client.attempt;if(!G)throw new g("PURCHASE_PENDING","Read the new Start before selecting an offer");return e.resolveOfferId?.(p,G)},onComplete(){I=structuredClone(e.client.controller?.view)??I,E(),E=e.client.subscribe(y),y()}},onError:e.onError,onDismiss:()=>{n||k()}},{retainedDialog:u,present(p){l.active?l.present(p):p(!!u)},async dismiss(){k()}});if(!A.host||n||a.aborted)return A.host?.destroy(),u?.release(),v(),null;let M=A.host;return b=!1,c={destroy(){M.destroy(),v(),h(e.onDismiss,null)},refresh:async()=>{await M.refresh()},get recovery(){return M.recovery},prepareFallback:()=>M.prepareFallback(),review:async()=>{},exitReview:async()=>{},unappliedDrafts:new Map},q}}return t.purchases.length||b?(z()&&P?.release(),x(!1),q):(l.finish("skipped"),v(),(J||B)&&(n=!0,h(e.onDismiss,null)),null)}function L(t){if(a.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");return e.onCheckoutUrl?e.onCheckoutUrl(t):R.ownerDocument.defaultView?.location.assign(t)}async function de(t,o){a.removeEventListener("abort",F),B=!0;function s(){!n&&!a.aborted&&!b&&!U&&I&&e.client.recovery.status==="complete"&&(U=!0,h(e.onComplete,structuredClone(I)))}E(),E=e.client.subscribe(s);let d=++C,u=await ce(R,{...e,prepared:f,client:t,signal:a,prepareNextPaywall:({run:r,paywallVersionId:i})=>oe(R,{client:e.client,run:r,paywallVersionId:i,signal:a}),checkoutNavigation:"after_confirmation",resumeCheckout:r=>e.client.continueCheckout(L,r),terminateCheckout:e.allowNewPurchase===!1?void 0:r=>e.client.terminateCheckout(r),async onCheckoutUrl(r){if(a.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");let i=e.client.recovery;if((!i.actions.includes("continue_checkout")||!i.purchases.some(y=>y.type==="checkout"&&y.checkoutUrl===r))&&(i=await e.client.refresh(),a.throwIfAborted(),n))throw new DOMException("Presentation dismissed","AbortError");if(ie(i)!==r)throw new g("PURCHASE_PENDING","Checkout differs from the original recovery proof");return L(r)},async resolveOfferId(r){if(a.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");let i=e.client.attempt;if(!i)throw new g("PURCHASE_PENDING","Read the original Start before selecting an offer");let y=await e.resolveOfferId?.(r,i);if(a.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");if(e.client.attempt?.requestId!==i.requestId)throw new g("PURCHASE_STORAGE_CONFLICT","The original purchase changed while selecting an offer");return y},async resolveSubscriptionChange(r,...i){a.throwIfAborted();let y=e.client.attempt;if(n||!y)throw new g("PURCHASE_PENDING","Read the original Start before selecting a membership");let A=e.resolveSubscriptionChange?await e.resolveSubscriptionChange(r,...i):await i[0]?.();if(a.throwIfAborted(),n||e.client.attempt?.requestId!==y.requestId)throw new g("PURCHASE_STORAGE_CONFLICT","The original purchase changed while selecting a membership");return A},onPresentationState(r){d===C&&h(e.onPresentationState,r)},onComplete(r){d===C&&(I=r,s())},onError(r){d===C&&(h(e.onError,r),r instanceof g&&(r.status===401||r.status===409&&r.reason==="STATE_CHANGED"&&r.recovery==="recover_operation")&&!a.aborted&&Q().catch(i=>h(e.onError,i)))},onDismiss(r){d===C&&(n=!0,v(),O?.(),h(e.onDismiss,r))}},o);return d!==C||n||a.aborted?(u.destroy(),n||a.aborted?null:q):(c=u,q)}});return D.set(e.client,T),T}export{be as showFunnelPurchase};
|
|
1
|
+
import{b as ce}from"./chunk-ZP5XCBBK.js";import{b as W,d as oe}from"./chunk-HOX2FQQE.js";import{b as ue}from"./chunk-ABLGIN4X.js";import{a as se}from"./chunk-PX7APKZR.js";import"./chunk-4CJUGCMG.js";import{a as X}from"./chunk-VEGGHQTQ.js";import"./chunk-XLOCTL2Y.js";import"./chunk-IXDARDPI.js";import{b as ie}from"./chunk-CZ33YJWK.js";import"./chunk-45PGU2HW.js";import"./chunk-AEQUKR4O.js";import"./chunk-W32FI2A2.js";import{k as H,l as Y}from"./chunk-FWM3577O.js";import"./chunk-ZBV6DOEY.js";import"./chunk-BSPJMJDI.js";import"./chunk-IEKRWGRV.js";import"./chunk-D7SPHHSF.js";import"./chunk-5MPALDJL.js";import"./chunk-SQMA5YYI.js";import"./chunk-BN6UIKEV.js";import"./chunk-YXD5B3UB.js";import"./chunk-JXVZK3RZ.js";import"./chunk-6NDL2ELB.js";import"./chunk-6FWT2BXF.js";import"./chunk-LZYQA3Q4.js";import"./chunk-DLLC7CRI.js";import"./chunk-CW7MTKXP.js";import"./chunk-VZMLPENL.js";import"./chunk-HEPQNLR2.js";import"./chunk-VILB5M4X.js";import"./chunk-L6XCRIR2.js";import"./chunk-LUYWRWJ2.js";import"./chunk-EDZJ2IGA.js";import"./chunk-2HIWXIJE.js";import"./chunk-T44KC4GO.js";import"./chunk-LWIBARE4.js";import"./chunk-TJRXWGKB.js";import{a as g}from"./chunk-5X7PTCI4.js";import"./chunk-XX5O7H6R.js";import"./chunk-SLUA7ABW.js";import"./chunk-MB2U2GWJ.js";import"./chunk-3VUPVXAV.js";import"./chunk-NJNENW5L.js";import"./chunk-5MRSFLQA.js";import"./chunk-J6MYX7WY.js";import{a as h}from"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";var D=new WeakMap,V=new WeakMap,Z=new WeakSet;function be(R,e){let w=e.hostPaywallTarget?void 0:e.prepared,$=()=>{e.prepared&&!Z.has(e.prepared)&&W(e.prepared)?.release()},ee=D.get(e.client);if(ee)return $(),ee;let te=n=>({...n,requestId:n.requestId??crypto.randomUUID()}),N=e.allowNewPurchase!==!1&&e.start instanceof Promise?e.start:void 0,m=e.allowNewPurchase===!1||!e.start||e.start instanceof Promise?void 0:te(e.start);m&&w?.state==="ready"&&w.matches(m)&&w.open();let f=w&&(m&&(w.state==="preparing"||["shown","closed"].includes(w.state)&&w.matches(m))||N&&["preparing","ready"].includes(w.state)||w.state==="shown"&&W(w)?.recovering)?w:void 0;f?Z.add(f):$();let P=f&&W(f);P?.claim();let z=()=>!!P?.recovering&&f?.state==="shown",T=Promise.resolve().then(async()=>{let n=!1,c,b=!1,j,C=0,S,I,U=!1,E=()=>{},re=()=>{},_,B=!1,J=!1,O,ne=!1,a=e.signal?AbortSignal.any([e.signal,e.client.identitySignal]):e.client.identitySignal,v=()=>{D.get(e.client)===T&&D.delete(e.client),a.removeEventListener("abort",F),E(),re(),f&&Z.delete(f),P?.release()};function ae(){if(O)return O;let t=new Promise(o=>O=o);return V.set(e.client,t),t.then(()=>{V.get(e.client)===t&&V.delete(e.client)}),D.get(e.client)===T&&D.delete(e.client),O}let l=Y(R,e,"funnel",()=>k(),X);function F(){k()}function k(t=!1){if(!n){if(n=!0,l.finish("dismissed"),c){c.destroy();return}if(t&&_){let o=ae();ne=!0,_.then(async s=>{s.mode==="run"&&s.status!=="blocked"&&e.client.controller&&e.client.attempt?.requestId===m?.requestId&&await e.client.close()}).catch(()=>{}).finally(()=>{o(),h(e.onDismiss,null)}),v();return}v(),h(e.onDismiss,null)}}let q={destroy:()=>k(),refresh:()=>S??(b?Q():c?.refresh())??Promise.resolve(),get recovery(){return c?.recovery??{type:"recover",operationId:null,requestId:null}},prepareFallback:()=>c?.prepareFallback()??Promise.resolve({type:"recover",operationId:null,requestId:null}),review:(...t)=>c?.review(...t)??Promise.resolve(),exitReview:(...t)=>c?.exitReview(...t)??Promise.resolve(),get unappliedDrafts(){return c?.unappliedDrafts??new Map}};a.addEventListener("abort",F,{once:!0}),P&&(re=P.onClose(()=>{B?n||ae():k(!0)}));try{a.throwIfAborted();let t=e.client.controller?.view?.paywall?.resolution,o=t&&"document"in t?t.document:e.loadingDocument;l.start(!0,m?.locale??e.client.attempt?.locale??o?.screen.strings.defaultLocale,o??null);let s=N?l.wait(N.then(r=>r?te(r):null,()=>null),H):Promise.resolve(m??null);s.catch(()=>{}),f?.state==="shown"?(J=!0,l.present(()=>{})):f&&["preparing","ready"].includes(f.state)&&Promise.all([f.ready,s.catch(()=>null)]).then(([r,i])=>{if(r){if(n||!l.active||!i||!f.matches(i)||!P?.revealable)return P?.release();l.present(()=>{f.open()==="shown"?J=!0:P.release()})}});let d=V.get(e.client);if(d&&await l.wait(d),n)return null;if(a.throwIfAborted(),N){let r=await s;if(n)return null;if(a.throwIfAborted(),!r&&!z())return l.finish("skipped"),v(),null;m=r??void 0}_=m?e.client.start(m):e.client.refresh({reuseRecentRead:!0});let u=await l.wait(_,H);return n?null:(a.throwIfAborted(),await le(u,l))}catch(t){if(ne||O?.(),n)return null;throw l.finish("error",t),v(),h(e.onError,t),t}function K(t=!1){C++;let o=c;c=void 0,E(),E=()=>{};let s=t?o?.retainPurchaseDialog?.():void 0;return o?.destroy(),a.addEventListener("abort",F,{once:!0}),s}function x(t){b=!0;let o=e.client.attempt?.locale??m?.locale,s=o?.startsWith("zh"),d=t?s?"正在查询原订单…":"Checking your purchase…":s?"暂时无法确认原订单,请重试。":"Could not check your original purchase. Try again.",u=t?void 0:()=>{Q()};c?.setPurchaseRecovery?.(d,u)||(c&&K(),l.active||(l=Y(R,e,"funnel",()=>k(),X),l.start(!0,o,e.loadingDocument??null)),l.setPurchaseRecovery(d,u))}function Q(){if(S)return S;if(n||a.aborted)return Promise.resolve();j??=c?.recoveryPaywall,a.addEventListener("abort",F,{once:!0}),x(!0);let t=Promise.resolve().then(async()=>{try{let s=await l.wait(e.client.refresh(),H);!n&&!a.aborted&&await le(s,l)}catch(s){!n&&!a.aborted&&(h(e.onError,s),x(!1))}});S=t;let o=()=>{S===t&&(S=void 0)};return t.then(o,o),t}async function le(t,o){let s=e.client.controller;if(t.mode==="run"&&t.status!=="blocked"&&s)return b&&c&&K(),b=!1,j=void 0,de(s,o?.active?o:void 0);if(t.mode==="operation"&&t.purchases.length){z()||x(!0);let d=await l.wait(e.client.recoverPurchasePaywall(j).then(u=>((n||a.aborted)&&u?.destroy(),u)),H).catch(u=>(!n&&!a.aborted&&h(e.onError,u),null));if(n||a.aborted)return null;if(d){if(n||a.aborted)return d.destroy(),null;let u=K(!0)??P?.retainPurchaseDialog?.()??l.retainPurchaseDialog();P?.release();let r=m,i=ue({client:e.client,session:d,start:e.allowNewPurchase===!1||!r?void 0:async()=>{let{requestId:p,...G}=r;return G},signal:a}),y=()=>{!n&&!a.aborted&&!U&&I&&e.client.recovery.status==="complete"&&(U=!0,h(e.onComplete,structuredClone(I)))},A=await se(R,{signal:a,loading:"host",start:async()=>i.session,checkoutNavigation:"after_confirmation",allowNewPurchase:!1,resumeCheckout:p=>e.client.continueCheckout(L,p),...i.prepare&&{prepareUpgradeReplacement:i.prepare,terminateCheckout:p=>e.client.terminateCheckout(p),beforeCheckoutReplacement:e.beforeCheckoutReplacement,purchaseConfirmation:e.purchaseConfirmation,confirmOnHostedCheckout:e.confirmOnHostedCheckout,claimCoupon:e.claimCoupon,prepareSubscriptionChange:e.prepareSubscriptionChange,resolveSubscriptionChange:e.resolveSubscriptionChange,onPurchase:e.onPurchase,onCheckoutUrl:L,async resolveOfferId(p){let G=e.client.attempt;if(!G)throw new g("PURCHASE_PENDING","Read the new Start before selecting an offer");return e.resolveOfferId?.(p,G)},onComplete(){I=structuredClone(e.client.controller?.view)??I,E(),E=e.client.subscribe(y),y()}},onError:e.onError,onDismiss:()=>{n||k()}},{retainedDialog:u,present(p){l.active?l.present(p):p(!!u)},async dismiss(){k()}});if(!A.host||n||a.aborted)return A.host?.destroy(),u?.release(),v(),null;let M=A.host;return b=!1,c={destroy(){M.destroy(),v(),h(e.onDismiss,null)},refresh:async()=>{await M.refresh()},get recovery(){return M.recovery},prepareFallback:()=>M.prepareFallback(),review:async()=>{},exitReview:async()=>{},unappliedDrafts:new Map},q}}return t.purchases.length||b?(z()&&P?.release(),x(!1),q):(l.finish("skipped"),v(),(J||B)&&(n=!0,h(e.onDismiss,null)),null)}function L(t){if(a.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");return e.onCheckoutUrl?e.onCheckoutUrl(t):R.ownerDocument.defaultView?.location.assign(t)}async function de(t,o){a.removeEventListener("abort",F),B=!0;function s(){!n&&!a.aborted&&!b&&!U&&I&&e.client.recovery.status==="complete"&&(U=!0,h(e.onComplete,structuredClone(I)))}E(),E=e.client.subscribe(s);let d=++C,u=await ce(R,{...e,prepared:f,client:t,signal:a,prepareNextPaywall:({run:r,paywallVersionId:i})=>oe(R,{client:e.client,run:r,paywallVersionId:i,signal:a}),checkoutNavigation:"after_confirmation",resumeCheckout:r=>e.client.continueCheckout(L,r),terminateCheckout:e.allowNewPurchase===!1?void 0:r=>e.client.terminateCheckout(r),async onCheckoutUrl(r){if(a.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");let i=e.client.recovery;if((!i.actions.includes("continue_checkout")||!i.purchases.some(y=>y.type==="checkout"&&y.checkoutUrl===r))&&(i=await e.client.refresh(),a.throwIfAborted(),n))throw new DOMException("Presentation dismissed","AbortError");if(ie(i)!==r)throw new g("PURCHASE_PENDING","Checkout differs from the original recovery proof");return L(r)},async resolveOfferId(r){if(a.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");let i=e.client.attempt;if(!i)throw new g("PURCHASE_PENDING","Read the original Start before selecting an offer");let y=await e.resolveOfferId?.(r,i);if(a.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");if(e.client.attempt?.requestId!==i.requestId)throw new g("PURCHASE_STORAGE_CONFLICT","The original purchase changed while selecting an offer");return y},async resolveSubscriptionChange(r,...i){a.throwIfAborted();let y=e.client.attempt;if(n||!y)throw new g("PURCHASE_PENDING","Read the original Start before selecting a membership");let A=e.resolveSubscriptionChange?await e.resolveSubscriptionChange(r,...i):await i[0]?.();if(a.throwIfAborted(),n||e.client.attempt?.requestId!==y.requestId)throw new g("PURCHASE_STORAGE_CONFLICT","The original purchase changed while selecting a membership");return A},onPresentationState(r){d===C&&h(e.onPresentationState,r)},onComplete(r){d===C&&(I=r,s())},onError(r){d===C&&(h(e.onError,r),r instanceof g&&(r.status===401||r.status===409&&r.reason==="STATE_CHANGED"&&r.recovery==="recover_operation")&&!a.aborted&&Q().catch(i=>h(e.onError,i)))},onDismiss(r){d===C&&(n=!0,v(),O?.(),h(e.onDismiss,r))}},o);return d!==C||n||a.aborted?(u.destroy(),n||a.aborted?null:q):(c=u,q)}});return D.set(e.client,T),T}export{be as showFunnelPurchase};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b}from"./chunk-ABLGIN4X.js";import"./chunk-PX7APKZR.js";import"./chunk-4CJUGCMG.js";import"./chunk-VEGGHQTQ.js";import"./chunk-AEQUKR4O.js";import"./chunk-W32FI2A2.js";import"./chunk-FWM3577O.js";import"./chunk-SQMA5YYI.js";import"./chunk-BN6UIKEV.js";import"./chunk-6FWT2BXF.js";import"./chunk-LZYQA3Q4.js";import"./chunk-DLLC7CRI.js";import"./chunk-CW7MTKXP.js";import"./chunk-HEPQNLR2.js";import"./chunk-VILB5M4X.js";import"./chunk-L6XCRIR2.js";import"./chunk-LUYWRWJ2.js";import"./chunk-EDZJ2IGA.js";import"./chunk-2HIWXIJE.js";import"./chunk-T44KC4GO.js";import"./chunk-LWIBARE4.js";import"./chunk-TJRXWGKB.js";import"./chunk-5X7PTCI4.js";import"./chunk-XX5O7H6R.js";import"./chunk-NJNENW5L.js";import"./chunk-5MRSFLQA.js";import"./chunk-J6MYX7WY.js";import"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as mountFunnelRecoveryPaywall,b as replaceableOriginalSession};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as p}from"./chunk-
|
|
1
|
+
import{d as p}from"./chunk-JXVZK3RZ.js";import"./chunk-6NDL2ELB.js";import"./chunk-6FWT2BXF.js";import"./chunk-LZYQA3Q4.js";import"./chunk-DLLC7CRI.js";import"./chunk-CW7MTKXP.js";import"./chunk-HEPQNLR2.js";import"./chunk-VILB5M4X.js";import"./chunk-LUYWRWJ2.js";import"./chunk-EDZJ2IGA.js";import"./chunk-2HIWXIJE.js";import"./chunk-T44KC4GO.js";import"./chunk-LWIBARE4.js";import"./chunk-TJRXWGKB.js";import"./chunk-XX5O7H6R.js";import{a as g}from"./chunk-5MRSFLQA.js";import{b as t}from"./chunk-J6MYX7WY.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";var m=1440*6e4,f=8,y=512*1024,h=t.strictObject({savedAt:t.number().int().nonnegative(),funnelId:t.string().min(1),context:t.strictObject({commerce:t.strictObject({provider:t.string(),currency:t.string(),intent:t.literal("subscription_change").optional()}),locale:t.string()}),resolution:p}),w=t.strictObject({savedAt:t.number().int().nonnegative(),funnelId:t.string().min(1),presented:t.literal("nothing")}),d=t.union([h,w]),S=t.strictObject({copies:t.record(t.string(),t.unknown())});function v(c){let u=(async()=>{let n=c.storage??globalThis.localStorage;if(!n||!globalThis.crypto?.subtle)return null;let s=new TextEncoder().encode(JSON.stringify([new URL(c.baseUrl??g).href,c.scope.projectId,c.scope.environment,c.customerId])),e=new Uint8Array(await crypto.subtle.digest("SHA-256",s));return{storage:n,key:"indiana.funnel.paywalls.v1."+Array.from(e,o=>o.toString(16).padStart(2,"0")).join("")}})().catch(()=>null);async function l(){let n=await u;if(!n)return null;try{let s=n.storage.getItem(n.key),e=s&&s.length<=y?S.safeParse(JSON.parse(s)):null;return{...n,copies:e?.success?e.data.copies:{}}}catch{return{...n,copies:{}}}}return{async read(n){let s=await l(),e=d.safeParse(s?.copies[n]);if(!e.success)return null;if("presented"in e.data)return e.data;let o=Date.now()-e.data.savedAt;return o>=0&&o<m?e.data:null},async write(n,s){let e=await l();if(!e)return;let o={...e.copies};delete o[n];let i=[...s?[[n,s]]:[],...Object.entries(o).map(([r,a])=>[r,d.safeParse(a)]).flatMap(([r,a])=>a.success?[[r,a.data]]:[]).sort(([,r],[,a])=>a.savedAt-r.savedAt)].slice(0,f);try{for(;i.length;){let r=JSON.stringify({copies:Object.fromEntries(i)});if(r.length<=y){e.storage.setItem(e.key,r);return}i.pop()}e.storage.removeItem(e.key)}catch{}}}}export{m as PAYWALL_COPY_MAX_AGE_MS,v as createPaywallCopies};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d}from"./chunk-HOX2FQQE.js";import"./chunk-XLOCTL2Y.js";import"./chunk-IXDARDPI.js";import"./chunk-BN6UIKEV.js";import"./chunk-DLLC7CRI.js";import"./chunk-CW7MTKXP.js";import"./chunk-VZMLPENL.js";import"./chunk-HEPQNLR2.js";import"./chunk-VILB5M4X.js";import"./chunk-LUYWRWJ2.js";import"./chunk-2HIWXIJE.js";import"./chunk-T44KC4GO.js";import"./chunk-LWIBARE4.js";import"./chunk-TJRXWGKB.js";import"./chunk-5X7PTCI4.js";import"./chunk-XX5O7H6R.js";import"./chunk-J6MYX7WY.js";import"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as PRERENDER_MAX_AGE_MS,b as preparedInternals,c as prerenderFunnelPurchase,d as prerenderRunPaywall};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c}from"./chunk-XLOCTL2Y.js";import"./chunk-IXDARDPI.js";import"./chunk-VZMLPENL.js";import"./chunk-HEPQNLR2.js";import"./chunk-VILB5M4X.js";import"./chunk-TJRXWGKB.js";import"./chunk-J6MYX7WY.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as predictFunnelStart,c as predictedPaywallLoadingDocument,b as predictionRefusal};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e,b as o,c as n}from"./chunk-IXDARDPI.js";import"./chunk-VZMLPENL.js";import"./chunk-HEPQNLR2.js";import"./chunk-VILB5M4X.js";import"./chunk-TJRXWGKB.js";import"./chunk-J6MYX7WY.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{e as FUNNEL_ROUTE_LIMITS,o as funnelRouteSchema,n as projectFunnelRoute};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b}from"./chunk-ZP5XCBBK.js";import"./chunk-HOX2FQQE.js";import"./chunk-4CJUGCMG.js";import"./chunk-VEGGHQTQ.js";import"./chunk-XLOCTL2Y.js";import"./chunk-IXDARDPI.js";import"./chunk-45PGU2HW.js";import"./chunk-AEQUKR4O.js";import"./chunk-W32FI2A2.js";import"./chunk-FWM3577O.js";import"./chunk-D7SPHHSF.js";import"./chunk-SQMA5YYI.js";import"./chunk-BN6UIKEV.js";import"./chunk-6FWT2BXF.js";import"./chunk-LZYQA3Q4.js";import"./chunk-DLLC7CRI.js";import"./chunk-CW7MTKXP.js";import"./chunk-VZMLPENL.js";import"./chunk-HEPQNLR2.js";import"./chunk-VILB5M4X.js";import"./chunk-L6XCRIR2.js";import"./chunk-LUYWRWJ2.js";import"./chunk-EDZJ2IGA.js";import"./chunk-2HIWXIJE.js";import"./chunk-T44KC4GO.js";import"./chunk-LWIBARE4.js";import"./chunk-TJRXWGKB.js";import"./chunk-5X7PTCI4.js";import"./chunk-XX5O7H6R.js";import"./chunk-SLUA7ABW.js";import"./chunk-MB2U2GWJ.js";import"./chunk-NJNENW5L.js";import"./chunk-5MRSFLQA.js";import"./chunk-J6MYX7WY.js";import"./chunk-DSPLGTQI.js";import"./chunk-VPT5MFDG.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as showFunnelRun,b as showObservedFunnelRun};
|
package/dist/index.d.ts
CHANGED
|
@@ -384,6 +384,11 @@ type PaywallPurchaseIntent = {
|
|
|
384
384
|
productVersionId: string;
|
|
385
385
|
selection: ScreenSelection;
|
|
386
386
|
featureQuantities: Record<string, number>;
|
|
387
|
+
/** The Coupon the clicked button carries for this Product, when it carries one. */
|
|
388
|
+
coupon?: {
|
|
389
|
+
id: string;
|
|
390
|
+
offerId?: string;
|
|
391
|
+
};
|
|
387
392
|
};
|
|
388
393
|
type SubscriptionChangeSelection = Pick<PaywallPurchaseIntent, "actionId" | "productVersionId"> & {
|
|
389
394
|
featureQuantities: Readonly<Record<string, number>>;
|
|
@@ -2920,6 +2925,11 @@ type FunnelHostOptions = PresentationLoadingOptions & {
|
|
|
2920
2925
|
appManifestRelease?: string;
|
|
2921
2926
|
/** Mount merchant-owned UI in a Paywall for this Run. */
|
|
2922
2927
|
mountPaywallControls?: (container: HTMLElement, run: FunnelRunView) => void | (() => void);
|
|
2928
|
+
/**
|
|
2929
|
+
* Hand a purchase selection in this Run's Paywall to the host instead of creating a quote or
|
|
2930
|
+
* commercial operation. The host owns the purchase from there; the Run records none.
|
|
2931
|
+
*/
|
|
2932
|
+
onPurchaseIntent?: (intent: PaywallPurchaseIntent, run: FunnelRunView) => unknown | Promise<unknown>;
|
|
2923
2933
|
onPurchase?: PaywallHostOptions["onPurchase"];
|
|
2924
2934
|
onCheckoutUrl?: PaywallHostOptions["onCheckoutUrl"];
|
|
2925
2935
|
resumeCheckout?: PaywallHostOptions["resumeCheckout"];
|