@tinkerlandai/longplay-sdk 0.10.49 → 0.10.51
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 +12 -0
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/{ai-usage-B-qsCn-k.d.ts → ai-usage-gcDQqLb2.d.ts} +1 -1
- package/dist/{api-DpRb_Pd3.d.ts → api-D0Qu0isy.d.ts} +21 -21
- package/dist/chunk-2G23BYBI.js +1 -0
- package/dist/{chunk-ZV23WM25.js → chunk-3TSFGU4T.js} +1 -1
- package/dist/{chunk-JOTTHPSC.js → chunk-3Z3HL42M.js} +2 -2
- package/dist/{chunk-QRHCZEV6.js → chunk-4NO6U4X6.js} +1 -1
- package/dist/chunk-67LPUJMN.js +10 -0
- package/dist/chunk-7GU34JD4.js +1 -0
- package/dist/{chunk-CIYPQIPH.js → chunk-B4SM2KRI.js} +1 -1
- package/dist/chunk-CGJZIDG3.js +1 -0
- package/dist/{chunk-F4X2JSXX.js → chunk-DB5S72HJ.js} +1 -1
- package/dist/{chunk-JXWRLNK7.js → chunk-FN462OVO.js} +1 -1
- package/dist/{chunk-C5VTYFI7.js → chunk-GJSQZGBE.js} +1 -1
- package/dist/chunk-IXXVMGMF.js +1 -0
- package/dist/{chunk-KN2QFJOQ.js → chunk-MVUNV5XR.js} +1 -1
- package/dist/{chunk-IA66JXF6.js → chunk-TIUD3N72.js} +1 -1
- package/dist/chunk-TM72XBM5.js +1 -0
- package/dist/{chunk-MOHKDHS2.js → chunk-US65SQX4.js} +1 -1
- package/dist/{chunk-AACOUGCH.js → chunk-VPYKAEHU.js} +1 -1
- package/dist/{configuration-sync-7ruSsSrL.d.ts → configuration-sync-DObsuVof.d.ts} +3 -3
- package/dist/{content-B3RWDOOH.js → content-VTHRQSFT.js} +1 -1
- package/dist/funnel-host-purchase-HBQOWEES.js +1 -0
- package/dist/{funnel-local-client-BMxDQWE6.d.ts → funnel-local-client-DzRzPX4x.d.ts} +53 -53
- package/dist/{funnel-paywall-prerender-SM7FH55U.js → funnel-paywall-prerender-MD4UI2AP.js} +1 -1
- package/dist/{funnel-process-client-DNR9nHs8.d.ts → funnel-process-client-DGRmy5KN.d.ts} +28 -28
- package/dist/{funnel-runtime-host-T7QZU2NO.js → funnel-runtime-host-NZAV6C5O.js} +1 -1
- package/dist/index.d.ts +32 -18
- package/dist/index.js +1 -1
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.d.ts +3 -3
- package/dist/openrouter.js +1 -1
- package/dist/page.d.ts +2 -2
- package/dist/page.js +1 -1
- package/dist/paywall-DKTGQZDJ.js +1 -0
- package/dist/{paywall-content-MVU3X635.js → paywall-content-SML4CL2Q.js} +1 -1
- package/dist/{paywall-session-ISBKCULC.js → paywall-session-YKE2CHHI.js} +1 -1
- package/dist/popup.d.ts +7 -3
- package/dist/popup.js +1 -1
- package/dist/{presentation-loading-mEA1iohf.d.ts → presentation-loading-BWUNotNa.d.ts} +51 -6
- package/dist/react-native.d.ts +7 -7
- package/dist/react-native.js +1 -1
- package/dist/{screen-renderer-HOIWGE5V.js → screen-renderer-HW2WXDTR.js} +1 -1
- package/dist/server.d.ts +10 -10
- package/dist/server.js +1 -1
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-2UXX62Y4.js +0 -1
- package/dist/chunk-CMKMFT4H.js +0 -1
- package/dist/chunk-DEJKZZTA.js +0 -318
- package/dist/chunk-FEEBBJEK.js +0 -1
- package/dist/chunk-L7C5TKKV.js +0 -1
- package/dist/chunk-YONZ4NEY.js +0 -1
- package/dist/funnel-host-purchase-QRREIXEJ.js +0 -1
- package/dist/paywall-6OURDDMJ.js +0 -1
- package/dist/{chunk-JOTTHPSC.js.LEGAL.txt → chunk-3Z3HL42M.js.LEGAL.txt} +0 -0
- package/dist/{funnel-node-evaluation-COIh1hKs.d.ts → funnel-node-evaluation-CRRTh1je.d.ts} +3 -3
- package/dist/{screen-qUBRsUi9.d.ts → screen-CJepeiBT.d.ts} +21 -21
package/dist/openrouter.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { OpenRouter } from '@openrouter/sdk';
|
|
2
2
|
import { ChatUsage } from '@openrouter/sdk/models';
|
|
3
|
-
import { F as FoundationApi } from './api-
|
|
4
|
-
import { c as createAiPricing, A as AiUsageContext, a as AiTokenUsage, b as AiTokenQuote } from './ai-usage-
|
|
5
|
-
import './screen-
|
|
3
|
+
import { F as FoundationApi } from './api-D0Qu0isy.js';
|
|
4
|
+
import { c as createAiPricing, A as AiUsageContext, a as AiTokenUsage, b as AiTokenQuote } from './ai-usage-gcDQqLb2.js';
|
|
5
|
+
import './screen-CJepeiBT.js';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'zod/v4';
|
|
8
8
|
import '@ai-sdk/provider';
|
package/dist/openrouter.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-PJAZ2UP4.js";import"./chunk-IVXYLNAF.js";import"./chunk-
|
|
1
|
+
import"./chunk-PJAZ2UP4.js";import"./chunk-IVXYLNAF.js";import"./chunk-FN462OVO.js";import"./chunk-FRRKTQNZ.js";import{a as i}from"./chunk-ZDIWOE4Q.js";import"./chunk-FYD7CMS7.js";import"./chunk-B4SM2KRI.js";import{b as A}from"./chunk-XVCSRZX4.js";import"./chunk-WOT6VMZA.js";var c=A.number().int().min(0).max(1e9);function R(e,o){let a=c.parse(e.promptTokens),p=c.parse(e.completionTokens),s=c.parse(e.promptTokensDetails?.cachedTokens??0),t=c.parse(e.promptTokensDetails?.cacheWriteTokens??0),r=c.parse(e.promptTokensDetails?.audioTokens??0),l=c.parse(e.completionTokensDetails?.audioTokens??0),n=c.parse(e.completionTokensDetails?.reasoningTokens??0);if(c.parse(e.totalTokens)!==a+p||s+t+r>a||n+l>p||(e.promptTokensDetails?.videoTokens??0)>0)throw new i("AI_USAGE_UNAVAILABLE","Token pools must conserve usage; video needs an explicit token mapper");return{input:a-s-t-r,output:p-l-(o==="separate"?n:0),cache_read:s,cache_write:t,input_audio:r,output_audio:l,reasoning:o==="separate"?n:0}}function I(e){if(!Number.isFinite(e)||e<0)throw new i("AI_USAGE_UNAVAILABLE","Provider cost must be a nonnegative USD amount");let o=String(e),a=o.includes("e")?e.toFixed(18).replace(/0+$/,"").replace(/\.$/,""):o;if(!/^(0|[1-9]\d{0,11})(\.\d{1,18})?$/.test(a)||Number(a)!==e)throw new i("AI_USAGE_UNAVAILABLE","Provider cost exceeds the supported precision");return a}async function f(e){if(typeof window<"u")throw new i("SERVER_ONLY","OpenRouter accounting requires your backend");if(!["output","separate"].includes(e.reasoning)||!e.modelId||!e.generationId)throw new i("INVALID_REQUEST","Actual model, generation ID and reasoning pricing are required");let o={context:e.context,generationId:e.generationId,modelId:`openrouter/${e.modelId}`,usage:e.usage,tokens:null,quote:null,receipt:null,phase:"captured"};await e.persist(o);let a=e.mapTokens?e.mapTokens(e.usage):R(e.usage,e.reasoning),p=e.usage.cost==null?void 0:I(e.usage.cost),s=e.quote??await e.pricing.quoteTokens({modelId:o.modelId,tokens:a});if(s.pricing.modelId!==o.modelId||Object.keys(a).some(l=>a[l]!==s.tokens[l]))throw new i("INVALID_REQUEST","Saved quote must match the provider model and token pools");await e.persist({...o,tokens:a,quote:s,phase:"quoted"});let t=await e.pricing.trackTokens(e.client,{...e.context,quote:s,providerCostUsd:p,generationId:e.generationId});if(!t.receipt.accepted)throw new i("AI_BALANCE_REJECTED","OpenRouter usage was saved but the balance request was rejected");let r={...o,tokens:a,quote:s,receipt:t,phase:"settled"};return await e.persist(r),r}function T(e){if(typeof window<"u")throw new i("SERVER_ONLY","OpenRouter accounting requires your backend");if(!["output","separate"].includes(e.reasoning))throw new i("INVALID_REQUEST","Reasoning pricing is required");let o=e.openRouter.chat;async function a(t){if(!t.usage||!t.modelId||!t.generationId)throw new i("AI_USAGE_UNAVAILABLE","OpenRouter did not return final usage and the actual model");await f({...e,context:t.context,generationId:t.generationId,modelId:t.modelId.slice(11),usage:t.usage})}let p=async(t,r)=>{let n={context:await e.context(),generationId:null,modelId:null,usage:null,tokens:null,quote:null,receipt:null,phase:"incomplete"},d;try{d=await o.send(t,r)}catch(g){throw await e.persist(n),g}if(!(d instanceof ReadableStream)){if(n={...n,generationId:d.id,modelId:d.model?`openrouter/${d.model}`:null,usage:d.usage??null},!n.usage||!n.modelId)throw await e.persist(n),new i("AI_USAGE_UNAVAILABLE","OpenRouter omitted final accounting");return await a(n),d}let w=d.getReader(),m=!1;return new ReadableStream({async pull(g){try{let{value:u,done:k}=await w.read();if(k){if(m=!0,!n.usage||!n.modelId)throw await e.persist(n),new i("AI_USAGE_UNAVAILABLE","OpenRouter stream ended without final accounting");await a(n),g.close();return}if(u.error)throw new i("AI_PROVIDER_ERROR",u.error.message);u.usage&&(n={...n,generationId:u.id,modelId:u.model?`openrouter/${u.model}`:null,usage:u.usage}),g.enqueue(u)}catch(u){m||(m=!0,await e.persist(n)),await w.cancel(u),g.error(u)}},async cancel(g){m||(m=!0,await e.persist(n)),await w.cancel(g)}})},s=new Proxy(o,{get(t,r){return r==="send"?p:Reflect.get(t,r,t)}});return new Proxy(e.openRouter,{get(t,r){return r==="chat"?s:Reflect.get(t,r,t)}})}export{T as createOpenRouterUsageClient,f as trackOpenRouterUsage};
|
package/dist/page.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { C as ConfigurationSync } from './configuration-sync-
|
|
1
|
+
import { C as ConfigurationSync } from './configuration-sync-DObsuVof.js';
|
|
2
2
|
import { J as JsonValue, R as Result } from './growth-rules-B4YYy64R.js';
|
|
3
3
|
import { z } from 'zod';
|
|
4
|
-
import './screen-
|
|
4
|
+
import './screen-CJepeiBT.js';
|
|
5
5
|
|
|
6
6
|
/** GET /api/v1/page-experiments/{environmentId}: page experiments and the saved groups they reference only. */
|
|
7
7
|
declare const pageExperimentPayloadSchema: z.ZodObject<{
|
package/dist/page.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as o,e as r,f as e,g as f}from"./chunk-
|
|
1
|
+
import{d as o,e as r,f as e,g as f}from"./chunk-3Z3HL42M.js";import"./chunk-GJSQZGBE.js";import"./chunk-3VUPVXAV.js";import"./chunk-B4SM2KRI.js";import"./chunk-DSPLGTQI.js";import"./chunk-A5KU4MMN.js";import"./chunk-WPFTSHP2.js";import"./chunk-WOT6VMZA.js";export{f as createPageExperiments,o as mergeQueryStrings,r as pageAttributes,e as readPayload};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as Ft,c as qt,d as pt,f as mt,g as Gt,k as Wt}from"./chunk-7GU34JD4.js";import{b as dt}from"./chunk-W32FI2A2.js";import{d as Vt,e as $t,f as Qt,h as ft,i as qe,j as Ht,k as jt,l as Bt}from"./chunk-2G23BYBI.js";import{a as Lt,c as ct,d as Nt,e as _t}from"./chunk-LSHIR6QM.js";import{a as Fe,b as we,d as ut,f as Mt,j as Ut}from"./chunk-OPUIFAQS.js";import{b as de}from"./chunk-HYX3EDZS.js";import{B as S,C as Be,D as Re,E as Oe,y as Dt}from"./chunk-EGFVGCDG.js";import"./chunk-YFLVGOCJ.js";import"./chunk-VILB5M4X.js";import"./chunk-FN462OVO.js";import"./chunk-FRRKTQNZ.js";import{r as Pe,t as ye}from"./chunk-MQ5LJEWV.js";import{i as St}from"./chunk-JDIFYMSA.js";import{c as ue,j as Ae}from"./chunk-TNPBYYAX.js";import{c as lt}from"./chunk-KCN6OGYG.js";import"./chunk-PF6PRPRO.js";import{a as v}from"./chunk-ZDIWOE4Q.js";import"./chunk-FYD7CMS7.js";import"./chunk-B4SM2KRI.js";import"./chunk-XVCSRZX4.js";import{a as G}from"./chunk-DSPLGTQI.js";import"./chunk-A5KU4MMN.js";import"./chunk-WPFTSHP2.js";import"./chunk-WOT6VMZA.js";async function zt(_,r,x){if(!Re(r))throw new v("INVALID_RESPONSE","A verified completed purchase is required");let k=_?Ae.parse(_):null;if(await x.onComplete?.(r),!k||!x.check)return;let Q=Ae.parse(await x.check());if(Q.internal_feature_id!==k.internal_feature_id||Q.quantity!==k.quantity||k.observation!==void 0&&(Q.observation===void 0||Q.observation.requirementDigest!==k.observation.requirementDigest||Q.observation.authority!==k.observation.authority||lt(Q.observation.subject)!==lt(k.observation.subject)))throw new v("INVALID_RESPONSE","The access requirement changed");Q.allowed&&await x.onAccessGranted?.(Q)}function ht(_){return Object.entries(_.document.buttons).filter(([,r])=>r.type==="checkout"&&r.product.type==="fixed"&&!de(r.product,{},_.capabilities)).map(([r])=>r)}function Yt(_,r){let x=S(r)?void 0:r.lines[0];if(!S(r)&&(r.lines.length!==1||!x))return;let k=S(r)?r.productVersionId:x.productVersionId,{screen:Q,buttons:X}=_.document,R=new Map(S(r)?Object.entries(r.featureQuantities??{}):(x?.prepaid??[]).map(h=>[h.internal_feature_id,h.quantity]));function Z(h,m){if(h.hidden)return!1;if(h.type==="plan_picker"&&_.capabilities.pickers[h.id]?.options.includes(k))return m[h.id]=k,!0;if(h.type==="quantity_picker"){let Y=R.get(h.internalFeatureId);return Y!==void 0&&(!h.bind?.plan||h.bind.plan===k)&&(m[h.id]=Y),!1}if(h.type==="button"&&h.action){let Y=X[h.action];return Y?.type==="checkout"&&Y.product.type==="fixed"&&Y.product.productVersionId===k}if(h.type!=="stack")return!1;let z=h.interaction,i=h.bind?.plan===k;for(let[Y,f]of h.children.entries()){let ie={},L=Z(f,ie);if(z?.type==="toggle"||z?.type==="tabs"){if(!L)continue;return m[h.id]=z.type==="toggle"?Y===0:f.id,Object.assign(m,ie),!0}Object.assign(m,ie),L&&(i=!0,z?.type==="select"&&z.purpose==="product"&&z.pickerId&&f.type==="stack"&&f.bind?.plan===k&&(m[h.id]=f.id,m[z.pickerId]=k))}return i}for(let h of Q.pages){let m={__page:h.id};if(Z(h.root,m))return m}}async function Un(_,r,x){let k=r.focusAtReveal?()=>{}:ft(_.ownerDocument),Q=()=>{R.finish("dismissed"),k()},X=()=>Q(),R=Ht(_,r,"paywall",()=>{Q(),G(r.onDismiss)},Ft);r.signal?.throwIfAborted(),r.signal?.addEventListener("abort",X,{once:!0});let Z=null,h,m,z;try{if(R.start(!0,r.loadingDocument?.screen.strings.defaultLocale,r.loadingDocument??null),R.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(Z=r.check?Ae.parse(await R.wait(r.check(),qe)):null,Z?.allowed)return R.finish("skipped"),r.signal?.removeEventListener("abort",X),k(),await r.onAccessGranted?.(Z),{check:Z,host:null};let[e,n]=await Promise.allSettled([R.wait(import("./screen-renderer-HW2WXDTR.js")),R.wait(r.start().then(a=>(R.cancelled&&a.destroy(),a)),qe)]);if(e.status==="rejected")throw n.status==="fulfilled"&&n.value.destroy(),e.reason;if(n.status==="rejected")throw n.reason;z=e.value,h=n.value,r.signal?.throwIfAborted(),h.signal?.throwIfAborted(),h.signal?.addEventListener("abort",X,{once:!0});let t=h.view??await R.wait(h.refresh(),qe);if(!t)throw new v("INVALID_RESPONSE","Paywall presentation is missing");h.signal?.throwIfAborted(),m=t}catch(e){throw R.finish("error",e),r.signal?.removeEventListener("abort",X),h?.signal?.removeEventListener("abort",X),h?.destroy(),k(),e}let i=h,{mountScreenPreview:Y}=z,f=_.ownerDocument,ie=new AbortController,L=f.createElement("section"),ae=f.createElement("div"),J=f.createElement("div"),Ge=r.mountControls,W=Ge?f.createElement("div"):void 0,p=f.createElement("p"),C=f.createElement("button"),I=f.createElement("button"),E=f.createElement("dialog"),We=i.locale||m.document.screen.strings.defaultLocale,o=We.toLowerCase().startsWith("zh"),Jt=o?"正在处理…":"Processing…",Kt=o?"正在准备报价…":"Preparing your price…",M=qt(m.document.screen.theme);L.dataset.indianaPaywall="",L.setAttribute("aria-label",m.document.name),L.style.cssText=M.root,J.style.cssText=M.controls,p.style.cssText=M.message,p.setAttribute("role","status"),I.style.cssText=M.link,I.textContent=o?"关闭":"Close",C.style.cssText=M.secondary,C.textContent=o?"重试":"Retry",C.hidden=!0,J.append(p,C,I),W&&(W.style.cssText="flex:1 0 100%;min-width:0",W.hidden=!0,J.prepend(W)),L.append(ae,J);let ze=()=>{if(W){let a=!W.childElementCount&&!W.textContent?.trim();W.hidden!==a&&(W.hidden=a)}let e=se??J,n=[...e.children].every(a=>a===p?!p.textContent:a.hidden),t=[...e.children].some(a=>a===I?!1:a===p?!!p.textContent:!a.hidden);e.style.cssText=n?M.controls.replace(/padding:[^;]+/,"padding:0"):t?`${M.controls};${M.pinned}`:M.controls,Xe()},yt=typeof MutationObserver>"u"?void 0:new MutationObserver(ze);yt?.observe(L,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let Te=m.document.presentation,Xt=Object.entries(m.document.buttons).filter(([,e])=>e.type==="close").map(([e])=>e),B,wt,Ye=!1,gt=JSON.stringify(m.capabilities),Je=e=>oe&&!Ce?Object.entries(e.document.buttons).filter(([,n])=>n.type==="checkout").map(([n])=>n):ht(e);function Se(e){if(w)return;m=e;let n=JSON.stringify(e.capabilities);if(n!==gt){let t=!b&&!i.quote&&!i.operation?Fe(e,q,Ct):q;JSON.stringify(t)!==JSON.stringify(q)?(q=t,B?.update(e.document.screen,We,{capabilities:we(e),unavailableActions:Je(e),serverInput:{bindings:[],answers:{}},selection:q})):B?.updateCapabilities(we(e),Je(e)),gt=n}en(e),ke()}let O,Ke=0;function Xe(){let e=f.defaultView;if(!O?.responsive||!e)return;let n=se??J,t=e.innerHeight-(O.type==="modal"?32:0);n.style.maxHeight=`${Math.max(1,t)}px`,n.style.overflowY="auto",n.style.flexShrink="0",Ke=Math.max(1,t-n.getBoundingClientRect().height),B?.resizeViewport?.(Ke,e.innerWidth)}let w=!1,oe=!1,b=null,Ze,De=!1,bt=!1,fe=!1,et,tt=!1,ee,se;function Zt(){return oe||w||ee||tt?{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null}:ct(i)}let A=()=>!w&&!De&&!ee&&r.canInteract?.()!==!1,F,ge=!1,be=!1,u=null,te=null,nt="",pe=()=>r.checkoutNavigation==="after_confirmation"&&!!(r.terminateCheckout||r.resumeCheckout),q={},Ct=new Set,Ce,K=null;function ke(){if(!pe()||!B?.updateCheckoutControls)return;let e=i.quote,n=!K&&!!e&&!!i.operation&&T(i.operation).type==="checkout",t=Object.entries(m.document.buttons).flatMap(([a,c])=>c.type==="checkout"?[{actionId:a,policy:c}]:[]);B.updateCheckoutControls({actions:t.map(({actionId:a})=>a),resume:n?t.filter(({actionId:a,policy:c})=>Me(e,m,a,c.product,q)).map(({actionId:a})=>a):[],resumeLabel:o?"继续付款":"Continue checkout",busy:Ce})}function vt(){te?.remove(),te=null}async function rt(){if(K)return;if(r.resumeCheckout&&i.operation){await r.resumeCheckout(i.operation.operationId);return}let e=await i.read();if(T(e).type!=="checkout")return U(e,!1);A()&&(Ne.delete(e.operationId),await Ue(e))}function Pt(){p.textContent=o?"暂时无法打开付款页面。请重试。":"Couldn’t open checkout. Try again.",C.hidden=!0}async function kt(e=!1){let n=K;if(!n)return;C.hidden=!0;let t=Date.now()+2e4;for(;A();){let a=await i.read();if(a.operationId!==n.operationId)throw new v("PURCHASE_PENDING","The original Checkout changed");if(!A())break;let c=T(a);if(c.type==="native"){K=null,vt(),b=n.selection,F=n.coupon,ge=!1,be=!1,await Ie();return}if(c.type==="complete"||c.type==="fulfillment"||c.type==="recording"){K=null,await U(a,!1);return}if(e&&c.type==="checkout"){e=!1;try{await r.terminateCheckout(n.operationId)}catch(y){G(r.onError,y)}}if(Date.now()>=t)break;await dt(1e3,f,ie.signal)}w||Pt()}async function Et(e,n,t,a){if(u=()=>Et(e,n,t,a),await r.beforeCheckoutReplacement?.(structuredClone(a)),!A())return;let c=i.operation;if(c?.operationId!==e||T(c).type!=="checkout"){u=null,c&&await U(c,!1);return}K={operationId:e,selection:n,coupon:t};let y=!1;try{await r.terminateCheckout(e)}catch(l){if(l instanceof v&&["CAPABILITY_UNAVAILABLE","NOT_CONFIGURED"].includes(l.code)){K=null,p.textContent=o?"请继续原订单,或等待它过期后再更换方案。":"Continue your original checkout, or wait for it to expire before changing plans.",G(r.onError,l);return}y=l instanceof v&&(l.status??0)>=500,G(r.onError,l)}A()&&await kt(y)}function Le(e,n,t,a,c){let y=we(e).checkoutCoupons?.[n],l=y?y.products[t]:r.claimCoupon&&c?St(e.capabilities,c,a):void 0;return l?.couponId&&l.planVersionId===t?{id:l.couponId,offerId:l.offerId}:void 0}function en(e){oe||b||i.quote||i.operation||nt&&p.textContent===nt||(p.textContent=Object.values(e.capabilities.plans).some(n=>n.available)?"":o?"当前账号暂无可购买的方案。":"No plans are currently available for this account.")}let Ne=new Map,_e=!1;function Me(e,n,t,a,c,y){if(S(e)){let $=de(a,c,n.capabilities),ce=$&&Le(n,t,$,c,y),he=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0),$e=ye(n.document.screen,e.productVersionId,c,n.capabilities);return $===e.productVersionId&&Object.keys($e).length===Object.keys(e.featureQuantities??{}).length&&Object.entries($e).every(([Qe,He])=>e.featureQuantities?.[Qe]===He)&&(!ce||he?.couponId===ce.id&&(!ce.offerId||he.grantId===ce.offerId))}let l=e.lines.length===1?e.lines[0]:void 0,s=de(a,c,n.capabilities);if(!l||!s||l.productVersionId!==s)return!1;let N=Le(n,t,s,c,y);if((N||we(n).checkoutCoupons?.[t])&&(N?.id??null)!==(e.discount?.couponId??null))return!1;let V;try{V=ye(n.document.screen,s,c,n.capabilities)}catch{return!1}let ne=Object.fromEntries((l.prepaid??[]).map($=>[$.internal_feature_id,$.quantity]));return[...new Set([...Object.keys(V),...Object.keys(ne)])].every($=>(V[$]??0)===(ne[$]??0))}let T=e=>Lt({quote:i.quote,operation:e,requestId:null,pending:!1,destroyed:w,canReselect:i.canReselect});async function Ue(e){let n=e.merchantExecution,t=T(e),a=t.type==="checkout"?t.checkoutUrl:e.checkoutUrl;if(!(!A()||!a||Be(e)&&t.type!=="checkout"||r.checkoutNavigation==="after_confirmation"&&t.type!=="checkout"||n?.type==="purchase"&&!["not_started","pending"].includes(n.paymentStatus)||Ne.get(e.operationId)===a)){Ne.set(e.operationId,a);try{r.onCheckoutUrl?await r.onCheckoutUrl(a):f.defaultView?.location.assign(a)}catch(c){throw Ne.delete(e.operationId),c}}}let le=(e,n=!1)=>{if(e instanceof ut)u=null,p.textContent=e.customerMessage(o);else if(Gt(e))u=null,p.textContent=n?o?"当前无法在此购买,付款尚未开始。请联系商户。":"Purchases aren’t available here right now. Payment hasn’t started. Contact the merchant for help.":mt(e,o);else if(n){let t=e instanceof v?e.code:void 0;t==="CAPABILITY_UNAVAILABLE"||t==="NOT_CONFIGURED"?(u=null,p.textContent=o?"暂时无法为此套餐报价,付款尚未开始。":"Pricing for this plan is unavailable. Payment hasn’t started."):i.canReselect===!0&&!b?p.textContent=o?"未能取得报价,付款尚未开始。请重新选择套餐。":"We couldn’t prepare your price. Payment hasn’t started. Choose a plan again.":t==="COMMAND_PENDING"?p.textContent=o?"仍在准备报价,请重试以查看结果。":"Your price is still being prepared. Retry to check the result.":p.textContent=o?"未能取得报价,付款尚未开始。请重试。":"We couldn’t prepare your price. Payment hasn’t started. Try again."}else p.textContent=e instanceof v&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?mt(e,o):e instanceof v?e.message:o?"操作未完成,请重试。":"This action couldn’t be completed. Try again.";C.hidden=u===null,nt=p.textContent,n&&Ce===void 0&&!O?.responsive&&p.scrollIntoView?.({block:"nearest"}),G(n&&x?.quoteError?x.quoteError:r.onError,e)},Ee=new WeakMap;function xe(e){oe=e,C.disabled=e,B?.updateCapabilities?.(we(m),Je(m));for(let n of te?.querySelectorAll("button")??[])e?(Ee.has(n)||Ee.set(n,n.disabled),n.disabled=!0):Ee.has(n)&&(n.disabled=Ee.get(n),Ee.delete(n)),pt(n)}function it(){p.textContent=o?"暂时无法操作,请稍后重试。":"This action is unavailable right now. Try again in a moment."}async function tn(e){if(r.beforeAction)try{await r.beforeAction()}catch(n){throw n instanceof ut?(b=null,ge=!1,be=!1,u=null):u=e,n}}async function j(e,n){if(oe||w)return;if(!A()){it();return}let t=e===Ie,a=t?Kt:Jt,c=pe()&&n!==void 0;Ce=c?n:void 0,xe(!0),ke(),C.hidden=!0,p.textContent=c?"":a;try{if(e!==At&&(e!==rt||!r.resumeCheckout)&&await tn(e),w)return;if(!A()){u=e,C.hidden=!1,it();return}await e()}catch(y){w||le(y,t)}finally{Ce=void 0,xe(!1),ke(),p.textContent===a&&(p.textContent="")}}async function nn(e){await zt(Z,e,r)}function xt(e){return ct(i).type==="recording"||T(e).type==="recording"}function It(e){let n=e.merchantTerms,t=n?.subscriptionTerms?.items??[],a=n?n.totalMinor:S(e)?e.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),c=n?t.length===1&&t[0]?.amountMinor===a&&t[0]:!S(e)&&e.lines.length===1&&e.lines[0]?.catalogAmountMinor===a&&e.lines[0],y=a===null?ue(n.subtotalMinor-n.discountMinor,e.currency)+(o?" + 待确认税费":" + tax confirmed at checkout"):ue(a,e.currency)+(c?Pe(c.interval,o?"zh-CN":"en",c.intervalCount??1):""),l=S(e)?i.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(s=>s.productName).join(", ");return{label:l?`${l} · ${y}`:y,recurring:c}}async function U(e,n=r.checkoutNavigation!=="after_confirmation"){if(w)return;if(!A()){u=async()=>U(await i.read()),C.hidden=!1;return}if(p.textContent=Wt(e.status,o),xt(e)){let s=e.merchantExecution?.recordingStatus==="failed";p.textContent=s?o?"付款和商户处理已完成,但交易记录失败。请联系商户修复,勿重复购买。":"Payment and fulfillment succeeded, but recording failed. Contact the merchant to repair this purchase; do not buy again.":o?"付款和商户处理已完成,正在确认交易记录。请勿重复购买。":"Payment and merchant fulfillment are complete. Recording is pending confirmation; do not purchase again.",C.textContent=o?"查询记录":"Check recording",u=async()=>U(await i.read()),C.hidden=!1;return}if(e.problem&&T(e).type!=="native"){let s=e.problem;u=ve,C.textContent=o?"检查并恢复原操作":"Check and recover original purchase",le(new v(s.code,s.reason==="RESULT_UNKNOWN"?o?"付款结果尚未确定,请恢复原操作,暂勿重复购买。":"The payment result is unknown. Recover the original purchase before buying again.":s.phase==="fulfillment"?o?"付款已记录,商户权益处理需要核对。":"Payment was recorded. Access fulfillment needs attention.":s.code==="CAPABILITY_UNAVAILABLE"?o?"商户尚不支持本次购买所需的完整能力,请处理后恢复原操作。":"The merchant does not currently support all actions required by this purchase. Recover the original purchase after this is resolved.":s.code==="NOT_CONFIGURED"?o?"付款服务连接需要处理,请联系商户后恢复原操作。":"The payment connection needs attention. Contact the merchant, then recover the original purchase.":o?"原购买操作需要处理,请查询或恢复此操作。":"The original purchase needs attention. Check or recover this operation.",void 0,void 0,s));return}if((e.merchantExecution?.type==="purchase"&&e.merchantExecution.paymentStatus==="succeeded"||e.merchantExecution?.type==="subscription_change"&&e.merchantExecution.status==="applied")&&!["applied","not_applicable"].includes(e.merchantExecution.fulfillmentStatus)&&(p.textContent=o?"付款已记录,正在等待商户完成处理。":"Payment was recorded. Waiting for merchant fulfillment."),Re(e)&&T(e).type==="complete"){u=null,await nn(e);return}if(!Oe(e)&&T(e).type!=="fulfillment"){if(i.canReselect===!1){p.textContent=o?"正在核对原购买结果":"Checking the original purchase result",C.textContent=o?"查询结果":"Check result",u=async()=>U(await i.read()),C.hidden=!1;return}e.status==="cancelled"?p.textContent=o?"这笔购买已取消,可以重新选择方案。":"This purchase was cancelled. Choose a plan to start again.":e.status==="failed"&&(p.textContent=o?"这笔购买未能完成,可以重新选择方案。":"This purchase didn’t go through. Choose a plan to try again."),C.textContent=o?"重试":"Retry",u=null,b=null;return}if(!n&&T(e).type==="checkout"){if(K){Pt();return}if(pe()){p.textContent="",_e=!1,u=null,ke();return}let s=i.quote,N=s?.operationId===e.operationId?It(s).label:"";p.textContent=_e?N?o?`${N} 尚未付款。再次选择该方案即可继续付款。`:`${N} is still unpaid. Choose it again to continue paying.`:o?"之前的购买尚未付款。再次选择该方案即可继续付款。":"Your earlier purchase is still unpaid. Choose that plan again to continue paying.":"",_e=!1,u=null;return}await Ue(e);let t=Date.now(),a=t+6e5,c=2e3,y=T(e).type!=="checkout",l=()=>y&&Date.now()-t<15e3;Ye=!0,G(r.onObservationChange,!0);try{for(;!w&&Date.now()<a;){if(await dt(l()?700:c,f,ie.signal),w)return;if(!A()){u=async()=>U(await i.read()),C.hidden=!1;return}let s=await i.read();if(T(s).type==="checkout"&&(y=!1),!n&&T(s).type==="checkout"){await U(s,!1);return}if(!s.problem&&Oe(s)&&await Ue(s),!Oe(s)||s.problem||xt(s)){await U(s);return}l()||(c=Math.min(c*1.5,3e4))}}finally{Ye=!1,G(r.onObservationChange,!1)}u=async()=>U(await i.read()),C.hidden=!1}async function at(e=!1){let n=await i.read();if(w)return;if(!A()){u=()=>at(e),C.hidden=!1;return}let t=i.quote;if(t&&Mt(n,{operationId:t.operationId,currency:t.currency},"The original purchase operation changed"),t&&(Be(n)?["prepared","quoted"].includes(n.status):n.status==="pending")&&(Be(n)||n.quoteFinalized===!1)&&!n.confirmedAt&&!n.checkoutUrl&&!("nativePurchase"in n&&n.nativePurchase)&&!n.merchantExecution&&!n.problem&&!i.pendingCancellation){if(r.purchaseConfirmation!=="paywall"){e?await ve():u=null;return}setTimeout(Rt,0,t);return}await U(n,e||void 0)}async function At(){await at()}async function ve(){if(i.quote&&!(Date.parse(i.quote.expiresAt)>Date.now()))throw new v("INVALID_REQUEST",o?"此报价已过期,请重新选择套餐。":"This quote has expired. Choose a plan again.");vt(),u=ve;let e=await i.confirm();if(!A()){u=ve,C.hidden=!1;return}if(e.problem){await U(e);return}if(Oe(e)){if(T(e).type==="checkout")await Ue(e);else if(e.execution&&e.execution.provider!=="merchant"||"nativePurchase"in e&&e.nativePurchase){if(!r.onPurchase)throw new v("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await r.onPurchase({operation:e,signal:ie.signal})}}u=async()=>U(await i.read()),await U(e,!0)}function Rt(e){if(w)return;te?.remove();let n=!(Date.parse(e.expiresAt)>Date.now());p.textContent=n?o?"此报价已过期。请先取消,再重新选择。":"This quote has expired. Cancel it, then choose again.":"";let t=f.createElement("div"),a=f.createElement("button"),c=f.createElement("button"),y=f.createElement("div"),l=f.createElement("p"),s=e.merchantTerms,N=o?"zh-CN":"en",V=s?.subscriptionTerms?.items??[],ne=s?s.subscriptionTerms?.trial?.days:S(e)?void 0:e.lines.find(d=>d.trial)?.trial?.days,re=S(e)?s?s.totalMinor:e.totalMinor:ne===void 0?null:s?s.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(d=>d.trial)?0:null,$=(d,g)=>o?`${g} 天试用结束后 ${d}`:`Then ${d} after the ${g}-day trial`,{label:ce,recurring:he}=It(e),$e=S(e)?i.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(d=>d.productName).join(", "),Qe=re===null?"":`${o?"今天应付":"Due today"} ${ue(re,e.currency)}`;l.textContent=Qe?[$e,Qe].filter(Boolean).join(" · "):ce,a.textContent=S(e)?o?"确认变更":"Confirm change":o?"确认购买":"Confirm purchase",a.disabled=n,c.textContent=o?"取消":"Cancel",t.style.cssText=M.panel,l.style.cssText=M.summary,y.style.cssText=M.actions,a.style.cssText=M.primary,c.style.cssText=M.secondary,pt(a),a.onclick=()=>{j(ve)};let He=async()=>{let d=await i.cancel();w||(t.remove(),te=null,await U(d))};c.onclick=()=>{u=He,j(He)};let H=f.createElement("div");if(H.style.cssText=M.terms,S(e)){for(let[g,P]of Object.entries(e.featureQuantities??{})){let D=i.view?.capabilities.plans[e.productVersionId]?.prepaid?.find(rn=>rn.internalFeatureId===g),je=f.createElement("p");je.textContent=`${D?.name??g} · ${P} ${o?"份":"packs"}${D?` × ${D.terms.units}`:""}`,H.append(je)}for(let[g,P]of[[o?"原订阅抵扣":"Unused subscription credit",e.creditMinor],[o?"新套餐费用":"New plan charge",e.debitMinor],[o?"优惠减免":"Offer savings",s?.discountMinor??e.discountMinor],[o?"税费":"Tax",s?s.taxMinor:e.taxMinor]]){let D=f.createElement("p");D.textContent=`${g}: ${P===null?o?"结账时确认":"Confirmed at checkout":ue(P,e.currency)}`,H.append(D)}let d=f.createElement("p");d.textContent=`${o?"生效时间":"Effective"}: ${e.effectiveAt}`,H.append(d)}if(s){for(let g of V){if(re===null&&g===he)continue;let P=f.createElement("p"),D=ue(g.amountMinor,e.currency)+Pe(g.interval,N,g.intervalCount);P.textContent=re!==null&&ne!==void 0?$(D,ne):D,g.amountAfterOfferMinor!==void 0&&(P.textContent+=` · ${o?"优惠结束后":"After the offer"} ${ue(g.amountAfterOfferMinor,e.currency)}${Pe(g.interval,N,g.intervalCount)}`),H.append(P)}let d=s.subscriptionTerms?.trial;if(d){let g=f.createElement("p");g.textContent=o?`试用 ${d.days} 天;${d.cardRequired?"需要提供付款方式":"无需提供付款方式"}`:`Trial days: ${d.days}; ${d.cardRequired?"a payment method is required":"no payment method is required"}`,H.append(g)}for(let g of[...s.expectedEffects.map(P=>P.description),...s.requiredConsents.map(P=>P.summary)]){let P=f.createElement("p");P.textContent=g,H.append(P)}}else if(!S(e)){for(let d of e.lines){if(re!==null||d!==he){let g=f.createElement("p"),P=`${ue(d.catalogAmountMinor,e.currency)}${Pe(d.interval,N,d.intervalCount??1)}`;g.textContent=re!==null&&d.trial?(e.lines.length>1?`${d.productName} · `:"")+$(P,d.trial.days):`${d.productName} · ${P}`,H.append(g)}for(let g of d.prepaid??[]){let P=f.createElement("p"),D=i.view?.capabilities.plans[d.productVersionId]?.prepaid?.find(je=>je.internalFeatureId===g.internal_feature_id);P.textContent=`${D?.name??g.internal_feature_id} · ${g.quantity} ${o?"份":"packs"} × ${g.terms.units}`,D&&(P.textContent+=Pe(D.reset==="week"||D.reset==="month"||D.reset==="year"?D.reset:"one_time",N,D.resetCount)),H.append(P)}if(d.trial){let g=f.createElement("p");g.textContent=o?`试用 ${d.trial.days} 天;${d.trial.cardRequired?"需要提供付款方式":"无需提供付款方式"}`:`Trial days: ${d.trial.days}; ${d.trial.cardRequired?"a payment method is required":"no payment method is required"}`,H.append(g)}}if(!e.charge){let d=f.createElement("p");d.textContent=o?"目录价格;最终金额以结账时税费和试用规则为准。":"Catalog price; the final charge depends on checkout taxes and trial terms.",H.append(d)}}for(let d of H.children)d.style.margin="0";y.append(a,c),t.append(l,...H.childElementCount?[H]:[],y),J.prepend(t),O?.responsive||t.scrollIntoView?.({block:"nearest"}),a.focus({preventScroll:!0}),te=t,oe&&xe(!0),u=null}async function Ie(){if(!b)return;if(u=Ie,!ge){let t=i.view,a=t?.document.buttons[b.actionId],c=t&&a?.type==="checkout"?de(a.product,b.selection,t.capabilities):null;if(!t||!c)throw new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");if(!be){let l=await r.resolveSubscriptionChange?.({actionId:b.actionId,productVersionId:c,featureQuantities:ye(t.document.screen,c,b.selection,t.capabilities)});if(w)return;l!==void 0&&(b.subscriptionChange=Dt.parse(l)),be=!0}let y=F?.offerId;if(F&&!y){if(!r.claimCoupon)throw new v("CAPABILITY_UNAVAILABLE","Coupon claiming is unavailable");let{offer:l}=await r.claimCoupon(F.id,b.requestId);if(w)return;if(!l||l.couponId!==F.id||l.status!=="issued"||!(Date.parse(l.expiresAt)>Date.now()))throw b=null,F=void 0,u=async()=>{Se(await i.refresh()),u=null},new v("COUPON_UNAVAILABLE","This Coupon is no longer available for this purchase");y=l.id}if(!F&&!t.document.screen.actions.some(l=>l.id===b?.actionId&&typeof l.properties.couponBinding=="string")&&(y=await r.resolveOfferId?.({actionId:b.actionId,productVersionId:c,featureQuantities:ye(t.document.screen,c,b.selection,t.capabilities)})),w)return;y!==void 0&&(b.offerId=y),ge=!0}if(!A()){C.hidden=!1;return}let e;try{e=await i.preview(b)}catch(t){throw i.canReselect===!0&&(b=null,ge=!1,be=!1,F=void 0,u=null),t}if(F&&(S(e)?(()=>{let t=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0);return t?.couponId!==F.id||t.grantId!==b.offerId})():e.discount?.couponId!==F.id||e.discount.offerId!==b.offerId))throw new v("INVALID_RESPONSE","The quote did not apply the Coupon selected on this Paywall");if(w)return;let n=e.merchantTerms;if(r.purchaseConfirmation!=="paywall"||r.confirmOnHostedCheckout&&A()&&!S(e)&&e.provider==="merchant"&&e.billingSubscriptionId===null&&n?.request.action==="purchase"&&n.request.mode==="subscription"&&n.subscriptionTerms?.trial===null&&n.requiredConsents.length===0&&Date.parse(e.expiresAt)>Date.now()){if(!A()){C.hidden=!1;return}if(!(Date.parse(e.expiresAt)>Date.now()))throw new v("INVALID_REQUEST",o?"此报价已过期,请重新选择套餐。":"This quote has expired. Choose a plan again.");let t=Ce?"":o?"正在打开收银台…":"Opening checkout…";p.textContent=t;try{await ve()}catch(a){w||le(a)}finally{p.textContent===t&&(p.textContent="")}return}Rt(e)}function me(e="destroy",n=!1){if(w)return;w=!0;let t=Ze;Ze=void 0,G(t),r.signal?.removeEventListener("abort",X),i.signal?.removeEventListener("abort",X),R.finish("dismissed"),wt?.(),ie.abort(),yt?.disconnect(),B?.destroy(),i.destroy(),E.removeEventListener("cancel",Tt),I.remove(),L.remove(),n||Ot(),e==="dismiss"&&G(r.onDismiss)}function Ot(){O?.destroy(),E.open&&E.close(),E.remove(),k()}Q=me;async function Ve(){if(!fe||w||De||ee==="closing"||!ee&&!A())return;if(!x){me("dismiss");return}let e=f.createElement("p");e.setAttribute("role","status"),e.textContent=o?"正在关闭…":"Closing…",se||(se=f.createElement("div"),se.style.cssText=J.style.cssText,J.replaceWith(se),ae.inert=!0),I.hidden=!1,se.replaceChildren(e,I),ee="closing",I.setAttribute("aria-disabled","true"),I.focus({preventScroll:!0});try{await x.dismiss()}catch(n){w||G(r.onError,n)}w||(ee="retry",e.textContent=o?"未能确认关闭,请重试。":"Could not confirm closure. Try again.",I.textContent=o?"重试关闭":"Retry closing",I.removeAttribute("aria-label"),I.removeAttribute("aria-disabled"))}I.onclick=()=>{Ve()};function Tt(e){e.preventDefault(),Ve()}E.addEventListener("cancel",Tt),C.onclick=()=>{u&&j(u)};function ot(e){R.finish("error",e),me()}function st(){if(!(!bt||fe||w||De||O&&!A()))try{let e=n=>{r.focusAtReveal&&(k=ft(f)),B?.setHidden?.(!1),et?.(),O&&(E.showModal(),O.responsive&&E.focus({preventScroll:!0}),!n&&r.loading!=="host"&&$t(E,O.type,O.responsive)),n&&r.loading!=="host"&&typeof ae.animate=="function"&&!f.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches&&ae.animate([{opacity:.55},{opacity:1}],{duration:160,easing:"ease-out"}),fe=!0};x?x.present(n=>R.present(t=>e(n??t))):R.present(e)}catch(e){ot(e),le(e)}}try{if(Te.type==="inline"?(ze(),et=Bt(L,_),_.append(L)):(E.setAttribute("aria-label",m.document.name),I.textContent="×",I.setAttribute("aria-label",o?"关闭":"Close"),Qt(I,m.document.screen.theme),I.hidden=Ut(m.document),E.append(I,L),_.append(E),O=Vt(E,{...m.document.screen,presentation:Te},Xe),O.latch(),O.responsive&&(L.style.display="flex",L.style.flexDirection="column",L.style.maxHeight="100%",ae.style.overflow="clip",ae.style.minHeight="0"),et=jt(E)),Ge&&W){let t=Ge(W);if(typeof t=="function"&&(w?G(t):Ze=t),w)throw new DOMException("Presentation cancelled","AbortError");ze()}B=Y(ae,{mode:"live",loadingLayout:()=>R.getLoadingLayout?.()??x?.loadingLayout?.(),rendererUrl:"bundled",title:m.document.name,closeActions:Xt,onAuthoredClose(t){ee||w||(I.hidden=t)},hostPresentation:()=>O?.type??Te.type,reportContentHeight:O?.responsive,onResize:t=>{if(!O?.responsive)return;let a=Math.min(t,Ke);ae.style.height=`${a}px`,O.setContentHeight(a+(se??J).getBoundingClientRect().height)},onSelection(t){for(let[a,c]of Object.entries(t))typeof c=="number"&&typeof q[a]=="number"&&q[a]!==c&&Ct.add(a);q=t,ke()},onAction(t,a={},c,y){if(!fe||w||ee)return;let l=i.view,s=l?.document.buttons[t];if(!s)return;if(s.type==="close"&&x&&r.resumeCheckout&&i.operation&&Nt(T(i.operation))){Ve();return}if(oe)return;if(!A()){it();return}if(s.type==="close"){j(async()=>{x?.closeAction?await x.closeAction(t):await r.onAction?.(t),me(r.onAction?"action":"dismiss")});return}if(s.type==="action"){u=async()=>{if(s.action.type==="event"){if(!r.onEvent)throw new v("EVENT_HANDLER_REQUIRED","Provide the event handler");await r.onEvent(s.action.event)}else r.onOpenUrl?await r.onOpenUrl(s.action.url):f.defaultView?.location.assign(s.action.url);await r.onAction?.(t),u=null},j(u);return}if(r.allowNewPurchase===!1){pe()&&l&&i.quote&&i.operation&&T(i.operation).type==="checkout"&&Me(i.quote,l,t,s.product,a,y)?j(rt,t):p.textContent=o?"当前只能继续原订单。":"Only your original checkout is available.";return}if(te&&i.canReselect===!1){p.textContent=o?"请先确认或取消当前购买。":"Confirm or cancel the current purchase first.",O?.responsive||te.scrollIntoView?.({block:"nearest"}),te.querySelector("button")?.focus({preventScroll:!0});return}if(pe()&&K){K.selection.actionId===t&&j(()=>kt(!0),t);return}if(pe()&&r.terminateCheckout&&l&&i.quote&&i.operation&&i.canReselect===!1&&T(i.operation).type==="checkout"){if(Me(i.quote,l,t,s.product,a,y)){j(rt,t);return}let V=de(s.product,a,l.capabilities),ne;try{if(!V)throw new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");ne=ye(l.document.screen,V,a,l.capabilities)}catch(he){le(he);return}let re=i.operation.operationId,$={actionId:t,requestId:crypto.randomUUID(),selection:structuredClone(a)},ce=Le(l,t,V,a,y);j(()=>Et(re,$,ce,{actionId:t,productVersionId:V,selection:$.selection,featureQuantities:ne}),t);return}if((i.quote||b)&&i.canReselect===!1){let V=!!l&&!!i.quote&&Me(i.quote,l,t,s.product,a,y);_e=!!i.quote&&!V,u=i.quote?()=>at(V):Ie,j(u);return}let N=l&&de(s.product,a,l.capabilities);if(!l||!N){le(new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(r.onPurchaseIntent){u=null,j(async()=>{let V={actionId:t,productVersionId:N,selection:structuredClone(a),featureQuantities:ye(l.document.screen,N,a,l.capabilities)};tt=!0,await r.onPurchaseIntent(V)});return}if(b&&b.actionId!==t){le(new v("COMMAND_PENDING","Finish the current purchase"));return}b||(F=Le(l,t,N,a,y),b={requestId:crypto.randomUUID(),actionId:t,selection:structuredClone(a)},ge=!1,be=!1),j(Ie,t)},onEscape:()=>{Ve()},onError:t=>{let a=new Error(t);!fe&&!w&&ot(a),le(a)},onRendered:t=>{t&&E.setAttribute("aria-label",t),bt=!0,st()}}),B.setHidden?.(!0),Xe();let e=pe()&&!!i.quote&&!!i.operation&&T(i.operation).type==="checkout";q=i.quote?Yt(m,i.quote)??Fe(m,{}):Fe(m,{}),B.update(m.document.screen,We,{capabilities:we(m),unavailableActions:ht(m),serverInput:{bindings:[],answers:{}},...Object.keys(q).length?{selection:q}:{}}),wt=i.subscribe?.(Se),Se(i.view??m),await R.wait(B.ready);let n=i.operation;!e&&(i.quote||n&&(n.confirmedAt||n.checkoutUrl||Re(n)))&&(u=At,j(u))}catch(e){throw ot(e),e}return{check:Z,host:{get observing(){return Ye},get recovery(){return Zt()},async prepareFallback(){if(oe||w||ee||tt)return{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null};xe(!0);try{let e=await _t(i);return e.type==="native"&&me(),e}finally{xe(!1)}},setSuspended(e){De=e,L.hidden=e,e&&E.open?E.close():!e&&!fe?st():!e&&!w&&fe&&Te.type!=="inline"&&!E.open&&E.showModal()},destroy:me,retainPurchaseDialog(){if(!(w||!E.open||!E.isConnected))return me("destroy",!0),{dialog:E,release:Ot}},refresh:async()=>{if(!A()){if(i.view)return i.view;throw new v("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await i.refresh();return Se(e),st(),e}}}}export{Un as showPaywall};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as a}from"./chunk-
|
|
1
|
+
import{b as a}from"./chunk-US65SQX4.js";import"./chunk-HYCLLEFU.js";import"./chunk-KSME3N3A.js";import"./chunk-LE32WTZ7.js";import"./chunk-IDDPWGQE.js";import"./chunk-HYX3EDZS.js";import"./chunk-EGFVGCDG.js";import"./chunk-YFLVGOCJ.js";import"./chunk-VILB5M4X.js";import"./chunk-FN462OVO.js";import"./chunk-FRRKTQNZ.js";import"./chunk-MQ5LJEWV.js";import"./chunk-JDIFYMSA.js";import"./chunk-TNPBYYAX.js";import"./chunk-KCN6OGYG.js";import"./chunk-PF6PRPRO.js";import"./chunk-ZDIWOE4Q.js";import"./chunk-FYD7CMS7.js";import"./chunk-3VUPVXAV.js";import"./chunk-B4SM2KRI.js";import"./chunk-XVCSRZX4.js";import"./chunk-A5KU4MMN.js";import"./chunk-WPFTSHP2.js";import"./chunk-WOT6VMZA.js";export{a as readPaywallContent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-VPYKAEHU.js";import"./chunk-VKFLQEW4.js";import"./chunk-HP6OV6WF.js";import"./chunk-Y2ASROJH.js";import"./chunk-TIOPNTMP.js";import"./chunk-RFWVXTZ7.js";import"./chunk-US65SQX4.js";import"./chunk-HYCLLEFU.js";import"./chunk-KSME3N3A.js";import"./chunk-LE32WTZ7.js";import"./chunk-IDDPWGQE.js";import"./chunk-LSHIR6QM.js";import"./chunk-OPUIFAQS.js";import"./chunk-HYX3EDZS.js";import"./chunk-EGFVGCDG.js";import"./chunk-YFLVGOCJ.js";import"./chunk-VILB5M4X.js";import"./chunk-IVXYLNAF.js";import"./chunk-FN462OVO.js";import"./chunk-FRRKTQNZ.js";import"./chunk-MQ5LJEWV.js";import"./chunk-JDIFYMSA.js";import"./chunk-TNPBYYAX.js";import"./chunk-KCN6OGYG.js";import"./chunk-PF6PRPRO.js";import"./chunk-ZDIWOE4Q.js";import"./chunk-FYD7CMS7.js";import"./chunk-3VUPVXAV.js";import"./chunk-B4SM2KRI.js";import"./chunk-XVCSRZX4.js";import"./chunk-DSPLGTQI.js";import"./chunk-A5KU4MMN.js";import"./chunk-WPFTSHP2.js";import"./chunk-WOT6VMZA.js";export{a as createPaywallSession};
|
package/dist/popup.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { e as CustomerPageData, a as SurfaceData, P as PresentationLoadingOptions, L as LoadingLayout, f as ScreenParameters, g as ScreenRendererInput, S as ScreenAnswers, C as CustomerDataIntent } from './presentation-loading-BWUNotNa.js';
|
|
2
|
+
export { d as PresentationState } from './presentation-loading-BWUNotNa.js';
|
|
3
|
+
import { b as ScreenAction, c as ScreenNode, d as ScreenInteractivity, e as ScreenDocument } from './screen-CJepeiBT.js';
|
|
2
4
|
import { O as Offer, a as OfferUnavailableReason } from './coupon-kfkIVf9n.js';
|
|
3
|
-
import { e as CustomerPageData, a as SurfaceData, P as PresentationLoadingOptions, f as ScreenParameters, g as ScreenRendererInput, S as ScreenAnswers, C as CustomerDataIntent } from './presentation-loading-mEA1iohf.js';
|
|
4
|
-
export { d as PresentationState } from './presentation-loading-mEA1iohf.js';
|
|
5
5
|
import { WindowLike } from 'dompurify';
|
|
6
6
|
import 'zod';
|
|
7
7
|
|
|
@@ -137,6 +137,8 @@ declare function showPopup(input: ScreenDocument, options?: PopupOptions): Popup
|
|
|
137
137
|
* Destroy on unmount or identity change. Preparation emits no display or action events. */
|
|
138
138
|
declare function preparePopup(input: ScreenDocument, options?: PopupOptions): PreparedPopupHandle;
|
|
139
139
|
type ScreenPreviewHandle = {
|
|
140
|
+
/** Display state only, available on an inert loading preview. */
|
|
141
|
+
getLoadingLayout?(): LoadingLayout | undefined;
|
|
140
142
|
/** Rejects if the renderer cannot start; this does not grant customer authorization. */
|
|
141
143
|
ready: Promise<void>;
|
|
142
144
|
/** The document of the last update. */
|
|
@@ -180,6 +182,8 @@ declare function mountScreenPreview(container: HTMLElement, options?: {
|
|
|
180
182
|
title?: string;
|
|
181
183
|
/** Renders inert Paywall placeholders in the packaged shell. */
|
|
182
184
|
skeleton?: boolean;
|
|
185
|
+
/** Display state handed over by this presentation's own loading view. */
|
|
186
|
+
loadingLayout?: () => LoadingLayout | undefined;
|
|
183
187
|
/** Translate editor controls without changing authored text or the content locale. */
|
|
184
188
|
editorMessages?: RendererEditorMessages;
|
|
185
189
|
/** 固定模拟浏览器的高度;全屏铺满,其他展示方式在该视口内滚动。 */
|
package/dist/popup.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a}from"./chunk-
|
|
1
|
+
import{a as o,b as r,c as e,d as f,e as m,f as p,g as t,h as x,i as a}from"./chunk-67LPUJMN.js";import"./chunk-2G23BYBI.js";import"./chunk-MQ5LJEWV.js";import"./chunk-JDIFYMSA.js";import"./chunk-TNPBYYAX.js";import"./chunk-KCN6OGYG.js";import"./chunk-PF6PRPRO.js";import"./chunk-ZDIWOE4Q.js";import"./chunk-FYD7CMS7.js";import"./chunk-XVCSRZX4.js";import"./chunk-DSPLGTQI.js";import"./chunk-A5KU4MMN.js";import"./chunk-WPFTSHP2.js";import"./chunk-WOT6VMZA.js";export{p as formatCustomerDecimal,r as hostedRendererScript,o as hostedRendererShell,f as inspectCustomHtml,a as mountScreenPreview,x as preparePopup,m as prepareScreen,e as sanitizeCustomHtml,t as showPopup};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { S as StackNode, e as ScreenDocument } from './screen-
|
|
2
|
+
import { S as StackNode, e as ScreenDocument } from './screen-CJepeiBT.js';
|
|
3
3
|
|
|
4
4
|
declare const surfaceDataSchema: z.ZodObject<{
|
|
5
5
|
paywall: z.ZodOptional<z.ZodObject<{
|
|
@@ -997,14 +997,42 @@ declare const publicPaywallSchema: z.ZodObject<{
|
|
|
997
997
|
}, z.core.$strict>;
|
|
998
998
|
type PublicPaywall = z.infer<typeof publicPaywallSchema>;
|
|
999
999
|
|
|
1000
|
+
/** Display geometry only. It carries no Customer, pricing, purchase or selection data. */
|
|
1001
|
+
type LoadingLayout = {
|
|
1002
|
+
template: string;
|
|
1003
|
+
width: number;
|
|
1004
|
+
height: number;
|
|
1005
|
+
cards: {
|
|
1006
|
+
key: string;
|
|
1007
|
+
group?: string;
|
|
1008
|
+
x: number;
|
|
1009
|
+
y: number;
|
|
1010
|
+
width: number;
|
|
1011
|
+
height: number;
|
|
1012
|
+
}[];
|
|
1013
|
+
scrolls: {
|
|
1014
|
+
key: string;
|
|
1015
|
+
left: number;
|
|
1016
|
+
top: number;
|
|
1017
|
+
}[];
|
|
1018
|
+
};
|
|
1019
|
+
|
|
1020
|
+
type RetainedPurchaseDialog = {
|
|
1021
|
+
dialog: HTMLDialogElement;
|
|
1022
|
+
release(): void;
|
|
1023
|
+
};
|
|
1024
|
+
|
|
1000
1025
|
/** The display portion of an already available published Paywall document. */
|
|
1001
1026
|
type PaywallLoadingDocument = {
|
|
1002
1027
|
presentation: ScreenDocument["presentation"];
|
|
1003
1028
|
screen: ScreenDocument;
|
|
1004
1029
|
buttons?: PublicPaywall["buttons"];
|
|
1005
1030
|
};
|
|
1006
|
-
|
|
1007
|
-
|
|
1031
|
+
type PaywallLoadingView = (() => void) & {
|
|
1032
|
+
getLayout?: () => LoadingLayout | undefined;
|
|
1033
|
+
};
|
|
1034
|
+
/** Keep authored geometry around the inert loading projection and its live handoff. */
|
|
1035
|
+
declare function renderPaywallLoadingDocument(panel: HTMLElement, holder: HTMLElement, input: PaywallLoadingDocument, locale: string): PaywallLoadingView;
|
|
1008
1036
|
|
|
1009
1037
|
type Surface = "page" | "popup" | "banner" | "paywall" | "funnel";
|
|
1010
1038
|
type PresentationState = {
|
|
@@ -1027,10 +1055,12 @@ type PresentationLoadingOptions = {
|
|
|
1027
1055
|
signal?: AbortSignal;
|
|
1028
1056
|
};
|
|
1029
1057
|
/** One loading cycle. No authored content or controls are exposed during it. */
|
|
1030
|
-
declare function createPresentationLoading(container: HTMLElement | ShadowRoot, options: PresentationLoadingOptions, surface: Surface, onDismiss: () => void, renderPaywall?: typeof renderPaywallLoadingDocument): {
|
|
1058
|
+
declare function createPresentationLoading(container: HTMLElement | ShadowRoot, options: PresentationLoadingOptions, surface: Surface, onDismiss: () => void, renderPaywall?: typeof renderPaywallLoadingDocument): Omit<{
|
|
1031
1059
|
setDismissHandler(handler: () => void): void;
|
|
1032
1060
|
readonly active: boolean;
|
|
1033
1061
|
readonly cancelled: boolean;
|
|
1062
|
+
getLoadingLayout(): LoadingLayout | undefined;
|
|
1063
|
+
retainPurchaseDialog(): RetainedPurchaseDialog | undefined;
|
|
1034
1064
|
/** Null selects the Paywall loading status when its layout is unavailable. */
|
|
1035
1065
|
start(modal: boolean, locale?: string, paywall?: PaywallLoadingDocument | null): void;
|
|
1036
1066
|
/** Remove the placeholder and reveal in the same turn, before notifying the host. */
|
|
@@ -1040,6 +1070,21 @@ declare function createPresentationLoading(container: HTMLElement | ShadowRoot,
|
|
|
1040
1070
|
state: "loading";
|
|
1041
1071
|
}>["state"], error?: unknown) => void;
|
|
1042
1072
|
wait<T>(work: Promise<T>, timeoutMs?: number): Promise<T>;
|
|
1043
|
-
}
|
|
1073
|
+
}, "getLoadingLayout"> & Partial<Pick<{
|
|
1074
|
+
setDismissHandler(handler: () => void): void;
|
|
1075
|
+
readonly active: boolean;
|
|
1076
|
+
readonly cancelled: boolean;
|
|
1077
|
+
getLoadingLayout(): LoadingLayout | undefined;
|
|
1078
|
+
retainPurchaseDialog(): RetainedPurchaseDialog | undefined;
|
|
1079
|
+
/** Null selects the Paywall loading status when its layout is unavailable. */
|
|
1080
|
+
start(modal: boolean, locale?: string, paywall?: PaywallLoadingDocument | null): void;
|
|
1081
|
+
/** Remove the placeholder and reveal in the same turn, before notifying the host. */
|
|
1082
|
+
present(show: (hadPlaceholder: boolean) => void): void;
|
|
1083
|
+
dismiss: () => void;
|
|
1084
|
+
finish: (state: Exclude<PresentationState, {
|
|
1085
|
+
state: "loading";
|
|
1086
|
+
}>["state"], error?: unknown) => void;
|
|
1087
|
+
wait<T>(work: Promise<T>, timeoutMs?: number): Promise<T>;
|
|
1088
|
+
}, "getLoadingLayout">>;
|
|
1044
1089
|
|
|
1045
|
-
export { type CustomerDataIntent as C, type PresentationLoadingOptions as P, type ScreenAnswers as S, type SurfaceData as a, type PaywallLoadingDocument as b, createPresentationLoading as c, type PresentationState as d, type CustomerPageData as e, type ScreenParameters as f, type ScreenRendererInput as g, screenInputBindingsSchema as s };
|
|
1090
|
+
export { type CustomerDataIntent as C, type LoadingLayout as L, type PresentationLoadingOptions as P, type RetainedPurchaseDialog as R, type ScreenAnswers as S, type SurfaceData as a, type PaywallLoadingDocument as b, createPresentationLoading as c, type PresentationState as d, type CustomerPageData as e, type ScreenParameters as f, type ScreenRendererInput as g, screenInputBindingsSchema as s };
|
package/dist/react-native.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { f as createCustomerClient, d as createFunnelClient } from './funnel-process-client-
|
|
2
|
-
export { F as FunnelProcessAdapter, a as FunnelProcessOptions, c as createFunnelProcess } from './funnel-process-client-
|
|
3
|
-
import { I as IndianaOptions, S as SessionCredentials, N as Scope, B as createFunnelRunController, x as PaywallStartInput, l as createPaywallSession } from './funnel-local-client-
|
|
4
|
-
export { F as FunnelCommandStorage, g as FunnelRunController, u as LocalFunnelClientOptions, v as LongplayError, w as PaywallPurchaseInput, P as PaywallSession, y as PushHost, z as PushJournal, A as createFeatureClient, D as createLocalFunnelClient } from './funnel-local-client-
|
|
1
|
+
import { f as createCustomerClient, d as createFunnelClient } from './funnel-process-client-DGRmy5KN.js';
|
|
2
|
+
export { F as FunnelProcessAdapter, a as FunnelProcessOptions, c as createFunnelProcess } from './funnel-process-client-DGRmy5KN.js';
|
|
3
|
+
import { I as IndianaOptions, S as SessionCredentials, N as Scope, B as createFunnelRunController, x as PaywallStartInput, l as createPaywallSession } from './funnel-local-client-DzRzPX4x.js';
|
|
4
|
+
export { F as FunnelCommandStorage, g as FunnelRunController, u as LocalFunnelClientOptions, v as LongplayError, w as PaywallPurchaseInput, P as PaywallSession, y as PushHost, z as PushJournal, A as createFeatureClient, D as createLocalFunnelClient } from './funnel-local-client-DzRzPX4x.js';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { J as JsonValue } from './growth-rules-B4YYy64R.js';
|
|
7
|
-
export { a as ConfigurationStorage, b as ConfigurationSyncOptions, c as createConfigurationSync } from './configuration-sync-
|
|
8
|
-
import './api-
|
|
9
|
-
import './screen-
|
|
7
|
+
export { a as ConfigurationStorage, b as ConfigurationSyncOptions, c as createConfigurationSync } from './configuration-sync-DObsuVof.js';
|
|
8
|
+
import './api-D0Qu0isy.js';
|
|
9
|
+
import './screen-CJepeiBT.js';
|
|
10
10
|
import 'zod/v4';
|
|
11
11
|
import './coupon-kfkIVf9n.js';
|
|
12
12
|
|
package/dist/react-native.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as S,c as E,d as T}from"./chunk-
|
|
1
|
+
import{b as S,c as E,d as T}from"./chunk-4NO6U4X6.js";import"./chunk-3ITNAFAH.js";import{a as A}from"./chunk-VPYKAEHU.js";import{e as P}from"./chunk-VKFLQEW4.js";import"./chunk-HP6OV6WF.js";import{h as b,i as x,k as L}from"./chunk-DB5S72HJ.js";import{E as C}from"./chunk-3TSFGU4T.js";import"./chunk-W3B4GT74.js";import"./chunk-Y2ASROJH.js";import"./chunk-TIOPNTMP.js";import"./chunk-RFWVXTZ7.js";import"./chunk-US65SQX4.js";import"./chunk-HYCLLEFU.js";import"./chunk-KSME3N3A.js";import"./chunk-LE32WTZ7.js";import"./chunk-SZZIYCXK.js";import"./chunk-IDDPWGQE.js";import"./chunk-LSHIR6QM.js";import"./chunk-OPUIFAQS.js";import"./chunk-HYX3EDZS.js";import"./chunk-EGFVGCDG.js";import"./chunk-YFLVGOCJ.js";import"./chunk-VILB5M4X.js";import"./chunk-IVXYLNAF.js";import"./chunk-FN462OVO.js";import"./chunk-FRRKTQNZ.js";import"./chunk-MQ5LJEWV.js";import"./chunk-JDIFYMSA.js";import"./chunk-TNPBYYAX.js";import"./chunk-KCN6OGYG.js";import"./chunk-PF6PRPRO.js";import{a as r}from"./chunk-ZDIWOE4Q.js";import{h as R}from"./chunk-FYD7CMS7.js";import"./chunk-3VUPVXAV.js";import"./chunk-B4SM2KRI.js";import"./chunk-XVCSRZX4.js";import"./chunk-DSPLGTQI.js";import"./chunk-A5KU4MMN.js";import"./chunk-WPFTSHP2.js";import"./chunk-WOT6VMZA.js";function k(t,d){let n,a=0,m=-1,l,i=!1,y=()=>{if(i)throw new r("CLOSED","Native host was destroyed");if(!t.nativeModule)throw new r("CAPABILITY_UNAVAILABLE","Link IndianaBridge and supply nativeModule");return t.nativeModule},o=()=>new r("IDENTITY_CHANGED","Customer identity changed during the native operation"),h=d.subscribeIdentity(()=>{a++,m=-1;let e=a;n&&t.nativeModule&&n.then(c=>t.nativeModule.reset(c,e)).catch(()=>{})}),I=t.nativeEvents?.(e=>{!n||!t.nativeModule||typeof e?.requestId!="string"||(async()=>{let c=await n;if(e.instanceId!==c)return;if(e.kind==="credential"){let w=a,f=null;try{if(!i&&e.revision===w){let N=await d.access();!i&&a===w&&(f=N)}}finally{await t.nativeModule.provideCredential(c,e.requestId,f)}return}let s=!1,u=a;try{if(i||e.revision!==u||!t.onNativeAction)throw o();await t.onNativeAction(e.action),s=!i&&a===u}finally{await t.nativeModule.acknowledge(c,e.requestId,s)}})().catch(()=>{})});async function p(e,c={}){let s=y();if(d.snapshot()&&!t.nativeEvents)throw new r("CAPABILITY_UNAVAILABLE","Supply nativeEvents to share credential refresh with the native host");let u=a,w=await d.access();if(i||a!==u)throw o();if(!n){let v=s.create(JSON.stringify({baseUrl:t.baseUrl??"https://api.longplayai.com",scope:t.scope,timeout:(t.timeoutMs??15e3)/1e3,credentialEvents:!!t.nativeEvents}));n=v,v.catch(()=>{n===v&&(n=void 0)})}let f=await n;if(i||a!==u)throw o();if(m!==u){if(!l||l.epoch!==u){let O=(async()=>{if(await s.identify(f,JSON.stringify({revision:u,credentials:w})),i||a!==u)throw await s.reset(f,u),o();m=u})();l={epoch:u,task:O}}let v=l;try{await v.task}finally{l===v&&(l=void 0)}}let N=await s.invoke(f,e,JSON.stringify(c));if(i||a!==u)throw o();try{return JSON.parse(N)}catch{throw new r("INVALID_RESPONSE","Native host returned invalid JSON")}}async function g(e,c){let s=await p(e,c);if(!s||typeof s!="object"||Array.isArray(s)||s.status!=="complete"&&s.status!=="dismissed")throw new r("INVALID_RESPONSE","Native presentation returned an invalid result");return s}return{showFunnel(e){return g("showFunnel",{runToken:e})},showPaywall(e){return g("showPaywall",e)},showContent(e){return g("showContent",e)},purchaseSubscription(e,c){return p("purchaseSubscription",{operationId:e,accepted:c})},switchSubscription(e,c){return p("switchSubscription",{operationId:e,accepted:c})},restorePurchases(){return p("restorePurchases")},manageSubscriptions(e){return p("manageSubscriptions",e?{productId:e}:{})},async dismiss(){a++,m=-1,n&&await y().reset(await n,a)},async destroy(){i||(i=!0,a++,h(),I?.(),n&&t.nativeModule&&await t.nativeModule.destroy(await n))}}}var M=P.trackUsage.request.shape.command,U=P.trackUsage.response;function F(t){let d=R.parse(t.scope),n=S({...t,scope:d}),a={...t,scope:d,session:n.session},m=k(t,n.session),l=0,i=!1;n.subscribeIdentity(()=>{l++});let y=()=>{if(i)throw new r("CLOSED","SDK client was destroyed");let o=n.session.peek();if(!o)throw new r("UNAUTHENTICATED","Identify the Customer first");return o};return{...n,native:m,async destroy(){i||(i=!0,l++,n.destroy(),await m.destroy())},funnel(){return E({...a,customerToken:y()})},resumeFunnel(o){return y(),C({...a,runToken:o})},paywall(o){return A(a,{...o,customerToken:y()})},async trackUsage(o){if(y(),!t.usageReporter)throw new r("INVALID_REQUEST","Configure your authenticated backend usageReporter");let h=M.parse(o),I=l,p;try{p=await t.usageReporter(h)}catch(e){throw I!==l?new r("IDENTITY_CHANGED","Customer identity changed during usage reporting"):e}if(I!==l)throw new r("IDENTITY_CHANGED","Customer identity changed during usage reporting");let g=U.parse(p);if(g.scope.projectId!==d.projectId||g.scope.environment!==d.environment)throw new r("INVALID_RESPONSE","Usage response scope differs");return g}}}export{r as LongplayError,x as createConfigurationSync,b as createFeatureClient,T as createFunnelProcess,L as createLocalFunnelClient,F as createLongplayReactNative};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i}from"./chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i}from"./chunk-67LPUJMN.js";import"./chunk-2G23BYBI.js";import"./chunk-MQ5LJEWV.js";import"./chunk-JDIFYMSA.js";import"./chunk-TNPBYYAX.js";import"./chunk-KCN6OGYG.js";import"./chunk-PF6PRPRO.js";import"./chunk-ZDIWOE4Q.js";import"./chunk-FYD7CMS7.js";import"./chunk-XVCSRZX4.js";import"./chunk-DSPLGTQI.js";import"./chunk-A5KU4MMN.js";import"./chunk-WPFTSHP2.js";import"./chunk-WOT6VMZA.js";export{f as formatCustomerDecimal,b as hostedRendererScript,a as hostedRendererShell,d as inspectCustomHtml,i as mountScreenPreview,h as preparePopup,e as prepareScreen,c as sanitizeCustomHtml,g as showPopup};
|
package/dist/server.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { F as FoundationApi, I as InvoiceModeParams } from './api-
|
|
2
|
-
import { X as IndianaServerOptions, v as IndianaError, Y as FunnelProcessSuppression, Z as FunnelProcessCommand, T as FunnelProcessResponse, C as CustomerSession, Q as FunnelProcessOpenInput, V as FunnelProcessMutation, x as PaywallStartInput, P as PaywallSession, n as FeatureClientOptions, R as RemoteFeatureResult } from './funnel-local-client-
|
|
3
|
-
export { m as FeatureClient, c as FunnelStartInput, L as LocalFunnelClient, u as LocalFunnelClientOptions, A as createFeatureClient, _ as createFunnelStartClient, D as createLocalFunnelClient } from './funnel-local-client-
|
|
1
|
+
import { F as FoundationApi, I as InvoiceModeParams } from './api-D0Qu0isy.js';
|
|
2
|
+
import { X as IndianaServerOptions, v as IndianaError, Y as FunnelProcessSuppression, Z as FunnelProcessCommand, T as FunnelProcessResponse, C as CustomerSession, Q as FunnelProcessOpenInput, V as FunnelProcessMutation, x as PaywallStartInput, P as PaywallSession, n as FeatureClientOptions, R as RemoteFeatureResult } from './funnel-local-client-DzRzPX4x.js';
|
|
3
|
+
export { m as FeatureClient, c as FunnelStartInput, L as LocalFunnelClient, u as LocalFunnelClientOptions, A as createFeatureClient, _ as createFunnelStartClient, D as createLocalFunnelClient } from './funnel-local-client-DzRzPX4x.js';
|
|
4
4
|
import * as zod from 'zod';
|
|
5
5
|
import { z } from 'zod';
|
|
6
|
-
import { S as StackNode } from './screen-
|
|
7
|
-
import { C as ConfigurationSync } from './configuration-sync-
|
|
8
|
-
export { c as createConfigurationSync } from './configuration-sync-
|
|
6
|
+
import { S as StackNode } from './screen-CJepeiBT.js';
|
|
7
|
+
import { C as ConfigurationSync } from './configuration-sync-DObsuVof.js';
|
|
8
|
+
export { c as createConfigurationSync } from './configuration-sync-DObsuVof.js';
|
|
9
9
|
import { J as JsonValue, E as EvaluationContext, s as stickyAssignmentDocumentSchema, F as FeatureResult } from './growth-rules-B4YYy64R.js';
|
|
10
|
-
import { d as FunnelLocalConfiguration, f as MerchantBridgeCommand, M as MerchantBridgeManifest, m as merchantBridgeOperationInputSchema } from './funnel-node-evaluation-
|
|
11
|
-
export { F as FunnelNodeEvaluationContext, g as MerchantRequirementCheckInput, h as MerchantRequirementCheckResult, i as entitlementRequirementDigest, e as evaluateFunnelNode } from './funnel-node-evaluation-
|
|
12
|
-
export { d as AiPricingOptions, b as AiTokenQuote, a as AiTokenUsage, A as AiUsageContext, e as AiUsageMiddlewareOptions, f as AiUsageRecord, g as aiPriceSnapshotSchema, h as aiTokenQuoteSchema, c as createAiPricing, i as createAiUsageMiddleware, j as createConfiguredAiPricing } from './ai-usage-
|
|
10
|
+
import { d as FunnelLocalConfiguration, f as MerchantBridgeCommand, M as MerchantBridgeManifest, m as merchantBridgeOperationInputSchema } from './funnel-node-evaluation-CRRTh1je.js';
|
|
11
|
+
export { F as FunnelNodeEvaluationContext, g as MerchantRequirementCheckInput, h as MerchantRequirementCheckResult, i as entitlementRequirementDigest, e as evaluateFunnelNode } from './funnel-node-evaluation-CRRTh1je.js';
|
|
12
|
+
export { d as AiPricingOptions, b as AiTokenQuote, a as AiTokenUsage, A as AiUsageContext, e as AiUsageMiddlewareOptions, f as AiUsageRecord, g as aiPriceSnapshotSchema, h as aiTokenQuoteSchema, c as createAiPricing, i as createAiUsageMiddleware, j as createConfiguredAiPricing } from './ai-usage-gcDQqLb2.js';
|
|
13
13
|
import 'zod/v4';
|
|
14
14
|
import '@ai-sdk/provider';
|
|
15
15
|
|
|
@@ -2105,8 +2105,8 @@ declare const merchantBridgeCommandOutputs: {
|
|
|
2105
2105
|
productVersionId: z.ZodNullable<z.ZodUUID>;
|
|
2106
2106
|
status: z.ZodEnum<{
|
|
2107
2107
|
active: "active";
|
|
2108
|
-
trialing: "trialing";
|
|
2109
2108
|
cancelled: "cancelled";
|
|
2109
|
+
trialing: "trialing";
|
|
2110
2110
|
expired: "expired";
|
|
2111
2111
|
past_due: "past_due";
|
|
2112
2112
|
}>;
|
package/dist/server.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as pn}from"./chunk-
|
|
1
|
+
import{a as pn}from"./chunk-TM72XBM5.js";import{a as I}from"./chunk-2I2S5ZIH.js";import{a as fn,b as hn,c as gn,d as yn}from"./chunk-PJAZ2UP4.js";import{a as xt}from"./chunk-VPYKAEHU.js";import{a as Ue,b as Ve,c as qe,d as He,e as m}from"./chunk-VKFLQEW4.js";import"./chunk-HP6OV6WF.js";import{a as Te,b as ae,c as yt,d as It,e as wt,f as xe,g as vt,h as Me,i as dn,j as ln,k as mn}from"./chunk-DB5S72HJ.js";import{B as V,C as N,d as ft,e as ht,k as gt,l as z,m as St,p as Ct,q as Rt,r as bt,s as At,t as Ot,y as pe,z as Tt}from"./chunk-3TSFGU4T.js";import"./chunk-W3B4GT74.js";import{c as h}from"./chunk-Y2ASROJH.js";import"./chunk-TIOPNTMP.js";import{a as Et,b as _e}from"./chunk-RFWVXTZ7.js";import"./chunk-US65SQX4.js";import"./chunk-HYCLLEFU.js";import{e as at}from"./chunk-KSME3N3A.js";import{B as pt,C as de,D as Z,E as lt,J as mt,a as et,e as q,j as Re,k as st,l as ct,q as ut,r as dt,s as be,t as Ae}from"./chunk-LE32WTZ7.js";import{b as Oe}from"./chunk-SZZIYCXK.js";import{e as ve,i as Ze,l as it}from"./chunk-IDDPWGQE.js";import"./chunk-LSHIR6QM.js";import"./chunk-OPUIFAQS.js";import"./chunk-HYX3EDZS.js";import"./chunk-EGFVGCDG.js";import{A as W,B as oe,C as tt,D as Se,E as ie,G as se,H as Ce,M as j,O as ce,P as nt,R as Ee,S as rt,T as ot,f as Ge,g as je,j as we,r as ze,s as Ke,u as an,v as sn,y as cn,z as X}from"./chunk-YFLVGOCJ.js";import"./chunk-VILB5M4X.js";import"./chunk-IVXYLNAF.js";import"./chunk-FN462OVO.js";import{a as Ne,b as Le}from"./chunk-FRRKTQNZ.js";import{o as ue}from"./chunk-MQ5LJEWV.js";import"./chunk-JDIFYMSA.js";import{i as un,k as $e,l as Qe,m as Je}from"./chunk-TNPBYYAX.js";import{c as Ie}from"./chunk-KCN6OGYG.js";import{e as Xe,h as We}from"./chunk-PF6PRPRO.js";import{a as c}from"./chunk-ZDIWOE4Q.js";import{h as Y}from"./chunk-FYD7CMS7.js";import"./chunk-3VUPVXAV.js";import"./chunk-B4SM2KRI.js";import{b as u}from"./chunk-XVCSRZX4.js";import"./chunk-DSPLGTQI.js";import{a as Ye}from"./chunk-A5KU4MMN.js";import"./chunk-WPFTSHP2.js";import"./chunk-WOT6VMZA.js";var _t=4,Mt=[...tt,"requirement_checks","native_offers","preparations","benefit_claims","authorizations","business_results","checkout_termination"],In=u.enum(Mt),ee=(e,n)=>u.array(e).max(n).refine(t=>new Set(t).size===t.length,"Declarations must be unique"),ke=u.strictObject({...se.shape,bridgeVersion:u.literal(_t),capabilities:ee(In,Mt.length),checkKinds:ee(u.enum(["access","metered","credit"]),3),preparationActions:ee(u.enum(["purchase","subscription_change","refund"]),3),authorizationKinds:ee(u.enum(["auto_topup"]),1),nextActionTypes:ee(u.enum(["redirect","authenticate"]),2),resultEvents:ee(u.enum(["benefit.claimed","authorization.updated"]),2)}).superRefine((e,n)=>{e.capabilities.includes("catalog")!==(e.catalog!=="none")&&n.addIssue({code:"custom",path:["catalog"],message:"Catalog declaration differs from its capability"}),(e.capabilities.includes("billing_records")!==e.billingEvents.length>0||new Set(e.billingEvents).size!==e.billingEvents.length)&&n.addIssue({code:"custom",path:["billingEvents"],message:"Declare unique supported billing events"});let t=r=>e.capabilities.includes(r),o=(r,a)=>n.addIssue({code:"custom",path:[r],message:a});t("requirement_checks")!==e.checkKinds.length>0&&o("checkKinds","Declare the supported Check kinds"),t("preparations")!==e.preparationActions.length>0&&o("preparationActions","Declare the supported preparation actions"),t("authorizations")!==e.authorizationKinds.length>0&&o("authorizationKinds","Declare the supported authorization kinds"),t("business_results")!==e.resultEvents.length>0&&o("resultEvents","Declare the supported non-financial results");for(let[r,a,s]of[["purchases","purchase","purchase.completed"],["subscription_changes","subscription_change","subscription.change.completed"],["refunds","refund","refund.updated"]])t(r)&&(!t("operation_status")||!t("billing_records")||!t("preparations")||!e.preparationActions.includes(a)||!e.billingEvents.includes(s))&&o("capabilities",`${r} requires preparation, original lookup and its billing result`);t("purchases")&&!e.billingEvents.includes("purchase.closed")&&o("billingEvents","Purchase execution requires its terminal closure result"),t("checkout_termination")&&(!t("operation_status")||!t("billing_records")||!e.billingEvents.includes("purchase.closed"))&&o("capabilities","Checkout termination requires original lookup and purchase.closed"),t("subscription_changes")&&!e.billingEvents.includes("subscription.change.closed")&&o("billingEvents","Subscription change execution requires its terminal closure result");for(let[r,a]of[["benefit_claims","benefit.claimed"],["authorizations","authorization.updated"]])t(r)&&(!t("operation_status")||!t("business_results")||!e.resultEvents.includes(a))&&o("capabilities",`${r} requires original lookup and its non-financial result`)}),K={"bridge.ping":u.strictObject({challenge:u.uuid()}),"bridge.describe":u.strictObject({}),"requirement.check":$e,"operation.prepare":ze,"benefit.claim":Ue,"operation.read":qe,"purchase.terminate":j},wn={"bridge.ping":u.strictObject({challenge:u.uuid()}),"bridge.describe":ke,"requirement.check":Qe,"operation.prepare":Ke,"benefit.claim":Ve,"operation.read":He,"purchase.terminate":j.extend({outcome:u.enum(["requested","already_paid"])})},Gn=u.enum(["bridge.ping","bridge.describe","requirement.check","operation.prepare","benefit.claim","operation.read","purchase.terminate"]);function $(e,n){return u.strictObject({bridgeVersion:u.literal(_t),requestId:u.uuid(),scope:Ce,command:u.literal(e),data:n})}var kt=u.discriminatedUnion("command",[$("bridge.ping",K["bridge.ping"]),$("bridge.describe",K["bridge.describe"]),$("requirement.check",K["requirement.check"]),$("operation.prepare",K["operation.prepare"]),$("benefit.claim",K["benefit.claim"]),$("operation.read",K["operation.read"]),$("purchase.terminate",K["purchase.terminate"])]),Be=u.strictObject({code:u.string().regex(/^MERCHANT_BRIDGE_[A-Z_]+$/),message:u.string().min(1).max(500),retryable:u.boolean(),recovery:u.string().min(1).max(80),effect:u.enum(["none","unknown"])}).refine(e=>e.effect!=="unknown"||!e.retryable&&e.recovery==="recover_operation","Unknown effects require original-operation recovery");function Bt(e){let n={bridgeVersion:u.literal(4),requestId:u.uuid(),scope:Ce,command:u.literal(e)};return u.union([u.strictObject({...n,data:wn[e]}),u.strictObject({...n,error:Be})])}var Pt="X-Indiana-Bridge-Signature",Q="X-Indiana-Bridge-Key-Id";function vn(e){return new TextEncoder().encode(e)}function Dt(e){return Uint8Array.from(atob(e.replaceAll("-","+").replaceAll("_","/")),n=>n.charCodeAt(0))}function Ft(e,n,t,o){return vn(`indiana-merchant-bridge:${o}
|
|
2
2
|
${n}
|
|
3
3
|
POST
|
|
4
4
|
${W}
|
package/dist/visual.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as pe,c as fe}from"./chunk-RA7GZ67U.js";import{b as le}from"./chunk-J6KIN4RH.js";import{a as Ve,b as ce,c as de,d as ue}from"./chunk-SLUA7ABW.js";import{a as J,b as F,c as ge,e as me}from"./chunk-
|
|
1
|
+
import{a as pe,c as fe}from"./chunk-RA7GZ67U.js";import{b as le}from"./chunk-J6KIN4RH.js";import{a as Ve,b as ce,c as de,d as ue}from"./chunk-SLUA7ABW.js";import{a as J,b as F,c as ge,e as me}from"./chunk-3Z3HL42M.js";import{a as re,b as ae,c as se,d as oe}from"./chunk-GJSQZGBE.js";import"./chunk-3VUPVXAV.js";import"./chunk-B4SM2KRI.js";import{b as o}from"./chunk-XVCSRZX4.js";import"./chunk-DSPLGTQI.js";import{c as te,e as ie,g as M}from"./chunk-A5KU4MMN.js";import"./chunk-WPFTSHP2.js";import"./chunk-WOT6VMZA.js";var K="indiana-visual-diagnostics-v1",Ae=o.strictObject({environmentId:o.string().uuid(),release:o.string().regex(/^[a-f0-9]{64}$/).nullable(),generation:o.string().regex(/^[a-f0-9]{64}$/).nullable(),publishedGeneration:o.string().regex(/^[a-f0-9]{64}$/).nullable(),checkedAt:o.string().datetime(),origin:o.string().url(),pathname:o.string().max(2048),urlMatches:o.boolean(),stopped:o.boolean(),rows:o.array(o.strictObject({changeId:o.string().regex(/^[a-f0-9]{64}$/),experimentKey:o.string().max(256),variationKey:o.string().max(256),inExperiment:o.boolean(),fingerprint:o.string().regex(/^[a-f0-9]{64}$/),status:o.enum(["inactive","waiting","partial","applied","mismatch","no_changes","unavailable","error"]),total:o.number().int().min(0).max(600),applied:o.number().int().min(0).max(600)})).max(100)});function ye(e){let l=n=>Array.isArray(n)?"["+n.map(l).join(",")+"]":n&&typeof n=="object"?"{"+Object.entries(n).filter(([,c])=>c!==void 0).sort(([c],[y])=>c.localeCompare(y)).map(([c,y])=>JSON.stringify(c)+":"+l(y)).join(",")+"}":JSON.stringify(n);return l({css:e.css,js:e.js,domMutations:e.domMutations,...e.renderGuard?{renderGuard:e.renderGuard}:{}})}function he(e){let l=new URL(e.baseUrl),n=l.origin==="https://api.longplayai.com"||l.origin==="https://api.dev.longplayai.com"?l.hostname.slice(4):void 0,c=e.origins??(n?[`https://console.${n}`]:[]),y=new Set(c.filter(t=>{try{let i=new URL(t);return i.origin===t&&(i.protocol==="https:"||i.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(i.hostname))}catch{return!1}})),v=!1,I=!1,k=0,T=async t=>{if(v||I||!t.source||!y.has(t.origin)||!t.data||typeof t.data!="object")return;let i=t.data;if(!(i.channel!==K||i.type!=="inspect"||i.environmentId!==e.environmentId||typeof i.nonce!="string"||!/^[a-f0-9-]{36}$/i.test(i.nonce)||typeof i.changeId!="string"||!/^[a-f0-9]{64}$/.test(i.changeId)||typeof i.url!="string"||i.url.length>2048||Date.now()-k<250)){try{if(new URL(i.url).origin!==location.origin)return}catch{return}I=!0,k=Date.now();try{let x=await e.inspect(i.changeId,i.url);!v&&x.rows.some(S=>S.changeId===i.changeId)&&t.source.postMessage({channel:K,type:"result",nonce:i.nonce,snapshot:x},t.origin)}finally{I=!1}}},u=t=>{T(t).catch(()=>{})};return window.addEventListener("message",u),()=>{v=!0,window.removeEventListener("message",u)}}var R=e=>!!e&&typeof e=="object"&&!Array.isArray(e),E=(e,l)=>typeof e=="string"&&e.length<=l,Ee=e=>typeof e=="string"&&(["html","class","style","position","href","src","alt","title","id","role","hidden"].includes(e)||/^(aria|data)-[a-z0-9_-]+$/.test(e));function ke(e){if(!R(e)||!E(e.css??"",1e5)||!E(e.js??"",1e5)||!Array.isArray(e.domMutations??[])||Array.isArray(e.domMutations)&&e.domMutations.length>200)throw new Error("Invalid visual variation");let l=e.domMutations??[];for(let n of l)if(!R(n)||!E(n.selector,2048)||!n.selector||!Ee(n.attribute)||!["set","append","remove"].includes(String(n.action))||n.value!==void 0&&!E(n.value,5e4)||n.parentSelector!==void 0&&!E(n.parentSelector,2048)||n.insertBeforeSelector!==void 0&&!E(n.insertBeforeSelector,2048))throw new Error("Invalid visual mutation");return{css:e.css??"",js:e.js??"",domMutations:l,...e.renderGuard===void 0?{}:{renderGuard:le(e.renderGuard)}}}function q(e){if(!R(e)||typeof e.environmentId!="string"||typeof e.trackExposures!="boolean"||!/^[-a-f0-9]{36}$/i.test(e.environmentId)||typeof e.generation!="string"||!/^[a-f0-9]{64}$/.test(e.generation)||!Array.isArray(e.experiments)||e.experiments.length>100||!R(e.savedGroups))throw new Error("Invalid visual experiment payload");let l=e.experiments.map(n=>{if(!R(n)||!["key","changeId"].every(c=>typeof n[c]=="string"&&n[c])||!/^[a-f0-9]{64}$/.test(String(n.changeId))||["namespace","status","groups","url"].some(c=>Object.hasOwn(n,c))||n.hashVersion!==void 0&&n.hashVersion!==2||!Array.isArray(n.variations)||n.variations.length<2||n.variations.length>20||n.urlPatterns!==void 0&&!Array.isArray(n.urlPatterns))throw new Error("Invalid visual experiment");return{...n,variations:n.variations.map(ke)}});return{...e,experiments:l}}var ve=6e4;function qe(e){let l=se(e.baseUrl);if(e.appManifestRelease!==void 0&&!/^[a-f0-9]{64}$/.test(e.appManifestRelease))throw new Error("Invalid IAM manifest digest");if(!/^[0-9a-f-]{36}$/i.test(e.environmentId))throw new Error("Invalid App environment ID");let n=e.fetch??globalThis.fetch.bind(globalThis),c=F(n),y=F(n),v=`${l}/api/v1/visual-experiments/${e.environmentId}`,I=e.appManifestRelease?`${v}?iam=${e.appManifestRelease}`:v,k=re(e.deviceIdCookie??"indiana_did"),T=ae(),u=null,t=!1,i=!1,x="",S={...e.attributes??{}},G,B,D=0,H=-1/0,$,m=new Map,O=new Map,C=new Set,z=ge({endpoint:`${v}/events`,fetch:n,log:e.log,label:"Visual exposure"}),P=z.flush,W,b;function j(){clearTimeout(W),b?.remove(),b=void 0}function Y(s,d){let f=M(s,d);C.has(f)||e.trackExposures===!1||u?.trackExposures===!1||t||(C.add(f),z.push({eventUuid:crypto.randomUUID(),timestamp:new Date().toISOString(),deviceId:k,...T?{sessionId:T}:{},url:location.href,pageTitle:document.title.slice(0,512),experimentKey:s.key,variationKey:d.key}))}function we(s){if(!u||t)return;let d=new Set,f={onExperimentViewed:(r,p)=>{d.add(M(r,p))},url:location.href,attributes:{...me(k,location),...S,indianaAppManifestRelease:e.appManifestRelease??null},savedGroups:te(u.savedGroups),log:e.log},h=new Set;for(let r of u.experiments){if(de(`${e.environmentId}:${r.key}`))continue;let p=r;try{let a=ie(p,f);if(O.set(r.changeId,a),!a.inExperiment)continue;h.add(r.changeId);let w=JSON.stringify([a.key,a.value]),U=m.get(r.changeId);if(U?.signature===w){d.has(M(p,a))&&s.push(()=>{U.applied()&&Y(p,a)});continue}m.get(r.changeId)?.revert(),m.delete(r.changeId);let A=fe(a.value,{requireUniqueTargets:!!e.appManifestRelease&&Array.isArray(r.condition?.$and)&&r.condition.$and.some(g=>g!==null&&typeof g=="object"&&!Array.isArray(g)&&g.indianaAppManifestRelease===e.appManifestRelease),boundVariations:r.variations,allowJs:e.disableJsInjection===!1,nonce:e.nonce,onApplied:()=>{d.has(M(p,a))&&Y(p,a)},onError:g=>e.log?.("Visual experiment stopped",{experiment:r.key,changeId:r.changeId,variation:a.key,error:String(g)}),onTargetStatus:e.log?g=>e.log?.("Visual target status changed",{experiment:r.key,changeId:r.changeId,variation:a.key,...g}):void 0});m.set(r.changeId,{signature:w,revert:A.revert,applied:()=>A.applied,inspect:()=>A.inspect()})}catch(a){e.log?.("Skipping visual experiment",{experiment:r.key,error:String(a)})}}for(let[r,p]of m)h.has(r)||(p.revert(),m.delete(r));j()}let V=()=>{let s=[];pe(()=>we(s));for(let d of s)d()};async function _(){let s=++D,d;try{d=await c.read(I,J)}catch(h){if(t||s!==D)return!1;throw h}let f=q(d);if(f.environmentId.toLowerCase()!==e.environmentId.toLowerCase())throw new Error("Visual payload scope changed");return t||s!==D?!1:(u=f,H=performance.now(),!0)}async function Q(){!await _()||t||(N(),V())}function L(){clearTimeout($),$=setTimeout(()=>{if(document.visibilityState==="hidden")return L();Q().catch(s=>e.log?.("Visual payload refresh failed",{error:String(s)})).finally(()=>{t||L()})},ve)}let X=()=>{t||document.visibilityState==="hidden"||performance.now()-H<ve||(clearTimeout($),Q().catch(s=>e.log?.("Visual payload refresh failed",{error:String(s)})).finally(()=>{t||L()}))},Ie=()=>{x!==location.href&&(x=location.href,V())},Z=()=>{P(!0)},N=()=>{G||t||(G=oe(Ie),addEventListener("pagehide",Z),x=location.href)};async function ee(s,d){let f=location.href,h=u,r=[],p=null;if(!t)try{let a=q(await y.read(I,J));a.environmentId===e.environmentId&&(p=a.generation)}catch{}for(let a of h?.experiments??[]){if(s&&a.changeId!==s)continue;let w=O.get(a.changeId);if(!w)continue;let U=new TextEncoder().encode(ye(w.value)),A=[...new Uint8Array(await crypto.subtle.digest("SHA-256",U))].map(be=>be.toString(16).padStart(2,"0")).join(""),g=m.get(a.changeId)?.inspect()??{status:"inactive",total:0,applied:0};r.push({changeId:a.changeId,experimentKey:a.key,variationKey:w.key,inExperiment:w.inExperiment,fingerprint:A,...g})}return{environmentId:e.environmentId,release:e.appManifestRelease??null,generation:h?.generation??null,publishedGeneration:p,checkedAt:new Date().toISOString(),origin:location.origin,pathname:location.pathname,urlMatches:location.href===f&&(!d||d===f)&&h===u,stopped:t,rows:r}}let ne,xe=ue(()=>{i&&!t&&V()});return{async start(){if(!(i||t)){i=!0,e.appManifestRelease&&(B=ce(e.appManifestRelease)),e.antiFlicker&&(b=document.createElement("style"),e.nonce&&(b.nonce=e.nonce),b.textContent="body { visibility: hidden !important }",document.head.append(b),W=setTimeout(j,Math.min(3e3,Math.max(0,e.antiFlickerTimeout??1e3))));try{if(!await _()||t)return;N(),V()}finally{j(),t||(L(),document.addEventListener("visibilitychange",X),ne=he({environmentId:e.environmentId,baseUrl:l,origins:e.diagnosticsOrigins,inspect:ee}))}}},async refresh(){t||await _()&&(i&&N(),V())},setAttributes(s){S={...s},V()},flush:()=>P(),getDiagnostics:ee,getResults(){return new Map(O)},get generation(){return u?.generation??null},destroy(){t=!0,clearTimeout($),document.removeEventListener("visibilitychange",X),xe(),ne?.(),D++,c.destroy(),y.destroy(),G?.(),B?.destroy(),removeEventListener("pagehide",Z),j();for(let s of m.values())s.revert();m.clear(),P(!0),u=null,O.clear(),C.clear(),S={}}}}export{qe as createVisualExperiments,Ve as loadAppManifestRelease};
|
package/package.json
CHANGED
package/dist/chunk-2UXX62Y4.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as T}from"./chunk-PF6PRPRO.js";import{a as M}from"./chunk-DSPLGTQI.js";var z={sm:420,md:640,lg:900},A=767;function ue(e,r,o=()=>!0,s="Close"){let n=e.ownerDocument.defaultView,i=e.ownerDocument.createElement("button");i.type="button",i.setAttribute("aria-label",s),i.style.cssText="position:absolute;inset:0 48px auto;z-index:2;height:24px;border:0;padding:0;background:transparent;touch-action:none;cursor:grab";let c=e.ownerDocument.createElement("span");c.style.cssText="display:block;width:36px;height:4px;border-radius:4px;margin:8px auto 12px;background:currentColor;opacity:.22;pointer-events:none",i.append(c),e.prepend(i);let l,d=0,a=!1,f=()=>{i.hidden=e.dataset.presentation!=="sheet",i.setAttribute("aria-disabled",String(!o()))},g=t=>{f(),!(i.hidden||!o()||t.button!==0)&&(l={y:t.clientY,time:Date.now(),id:t.pointerId},d=0,a=!1,i.setPointerCapture?.(t.pointerId))},y=t=>{!l||t.pointerId!==l.id||(d=Math.max(0,t.clientY-l.y),e.style.transform=`translateY(${d}px)`)},w=t=>{if(!l||t.pointerId!==l.id)return;let p=Math.max(1,Date.now()-l.time),h=t.type!=="pointercancel"&&o()&&(d>120||d>40&&d/p>.5);a=d>6,l=void 0,i.releasePointerCapture?.(t.pointerId),e.style.transform="",h?r():d&&typeof e.animate=="function"&&!n?.matchMedia?.("(prefers-reduced-motion: reduce)").matches&&e.animate([{transform:`translateY(${d}px)`},{transform:"none"}],{duration:200,easing:"cubic-bezier(.2,.8,.2,1)"}),d=0},m=()=>{if(a){a=!1;return}!l&&d===0&&o()&&r()};i.addEventListener("pointerdown",g),i.addEventListener("pointermove",y),i.addEventListener("pointerup",w),i.addEventListener("pointercancel",w),i.addEventListener("click",m);let u=typeof MutationObserver=="function"?new MutationObserver(f):void 0;return u?.observe(e,{attributes:!0,attributeFilter:["data-presentation"]}),n?.addEventListener("resize",f),f(),()=>{u?.disconnect(),n?.removeEventListener("resize",f),i.remove(),e.style.transform=""}}function O(e,r,o=!1){return(e.type==="modal"||e.type==="sheet")&&e.mobile&&o&&r<=A?e.mobile:e.type}function W(e,r,o){let s=e.ownerDocument.defaultView,n=r.presentation,i;if((n.type==="modal"||n.type==="sheet")&&n.backdrop){let t=`lp-backdrop-${crypto.randomUUID()}`,p={none:"transparent",scrim:"#f2f2f2cc",dim:"#0006","strong-dim":"#000000bf",blur:"#0006"};e.dataset.indianaBackdrop=t,i=e.ownerDocument.createElement("style"),i.textContent=`dialog[data-indiana-backdrop="${t}"]::backdrop{background:${p[n.backdrop]};backdrop-filter:${n.backdrop==="blur"?"blur(16px)":"none"}}`,e.append(i)}let c=r.pages?.[0]?.root.style?.shape,l=c?.type==="pill"?"9999px":c?.type==="rect"?typeof c.radius=="number"?`${c.radius}px`:[c.radius.topLeft,c.radius.topRight,c.radius.bottomRight,c.radius.bottomLeft].map(t=>`${t}px`).join(" "):void 0,d=(n.type==="modal"||n.type==="sheet")&&(n.desktopWidth!==void 0||n.mobile!==void 0||n.type==="modal"&&n.position!==void 0),a=n.type,f,g,y=!1,w=t=>{y||!Number.isFinite(t)||t<0||(g=t,a!=="fullscreen"&&a!=="inline"&&(e.style.height=`min(${Math.max(t,40)}px, calc(100dvh - ${a==="sheet"?0:32}px))`))},m=()=>{if(!y&&(a=f??O(n,s?.innerWidth??1024,s?.matchMedia?.("(pointer: coarse)").matches===!0),e.dataset.presentation=a,!(!d||n.type!=="modal"&&n.type!=="sheet"))){if(e.style.boxSizing="border-box",e.style.padding="0",e.style.border="0",e.style.overflow="hidden",e.style.outline="none",e.tabIndex=-1,e.style.background=r.theme.background,e.style.color=r.theme.text,a==="fullscreen")e.style.width="100vw",e.style.height="100dvh",e.style.maxWidth="100vw",e.style.maxHeight="100dvh",e.style.margin="0",e.style.borderRadius="0";else{let t=n.mobile==="sheet"&&a==="sheet",p=n.desktopWidth,h=s?.innerWidth??1024;e.style.width=t?`${h}px`:p?`${Math.min(p.max,Math.max(h*p.viewport/100,p.min))}px`:`${T[n.size]}px`,e.style.maxWidth=`${Math.max(0,h-(a==="sheet"?0:32))}px`,e.style.maxHeight=a==="sheet"?"100dvh":"calc(100dvh - 32px)",e.style.margin=a==="sheet"?"auto auto 0":n.type==="modal"&&n.position==="top"?"16px auto auto":n.type==="modal"&&n.position==="bottom"?"auto auto 16px":"auto",e.style.borderRadius=l??(a==="sheet"?"16px 16px 0 0":"24px"),e.style.height="",g!==void 0&&w(g)}o?.(a)}},u=d?[s?.matchMedia?.(`(max-width: ${A}px)`),s?.matchMedia?.("(pointer: coarse)")].filter(t=>t!==void 0):[];if(d){s?.addEventListener("resize",m);for(let t of u)t.addEventListener?t.addEventListener("change",m):t.addListener?.(m)}return m(),{responsive:d,get type(){return a},latch(){y||f!==void 0||(m(),f=a)},setContentHeight:w,destroy(){if(!y){y=!0,i?.remove(),delete e.dataset.indianaBackdrop,s?.removeEventListener("resize",m);for(let t of u)t.removeEventListener?t.removeEventListener("change",m):t.removeListener?.(m)}}}}function me(e,r,o){let{presentation:s}=r,n="size"in s?`${z[s.size]}px`:"100vw";return e.style.cssText=`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${n}`,W(e,r,o)}function fe(e,r,o=!1){let s=e.ownerDocument.defaultView;if(typeof e.animate!="function"||s?.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return;let n=o?{duration:300,easing:"cubic-bezier(0.23, 1, 0.32, 1)"}:{duration:240,easing:"cubic-bezier(0.2, 0.8, 0.2, 1)"};e.animate(r==="sheet"?[{transform:"translateY(100%)"},{transform:"none"}]:r==="modal"?[{opacity:0,transform:o?"translateY(12px) scale(0.96)":"translateY(8px) scale(0.98)"},{opacity:1,transform:"none"}]:[{opacity:0},{opacity:1}],n);try{e.animate([{opacity:0},{opacity:1}],{...n,pseudoElement:"::backdrop"})}catch{}}function $(e,r){e.style.cssText=["position:absolute","z-index:1","top:calc(4px + env(safe-area-inset-top, 0px))","inset-inline-end:calc(4px + env(safe-area-inset-right, 0px))","width:44px","height:44px","padding:0","border:0","border-radius:50%","font:400 20px/1 system-ui,sans-serif","cursor:pointer","touch-action:manipulation"].join(";"),e.style.background=`radial-gradient(circle, ${r.background} 0 15px, color-mix(in srgb, ${r.text} 22%, ${r.background}) 15px 16px, transparent 16.5px)`,e.style.color=r.text}var C=new WeakMap;function he(e,r){return C.set(e,r),()=>C.delete(e)}function ye(e){let r=e.defaultView?.HTMLElement,o=e.activeElement;for(let n=0;n<16&&o?.shadowRoot?.activeElement;n++)o=o.shadowRoot.activeElement;let s=o?C.get(o)?.():void 0;return()=>{!o?.isConnected||!r||!(o instanceof r)||(o.focus({preventScroll:!0}),s?.())}}var we=15e3;function Ee(e,r,o,s,n){let i=e.ownerDocument,c=new AbortController,l=!1,d=!1,a,f;function g(){f?.(),f=void 0,a?.tagName==="DIALOG"&&a.close?.(),a?.remove(),a=void 0}function y(u,t){d||(d=!0,g(),(u==="dismissed"||u==="error")&&c.abort(t??new DOMException("Presentation cancelled","AbortError")),!(!l&&u!=="ready")&&M(r.onPresentationState,u==="error"?{surface:o,state:u,error:t}:{surface:o,state:u}))}let w=s,m=()=>{d||w()};return{setDismissHandler(u){w=u},get active(){return l&&!d},get cancelled(){return c.signal.aborted},start(u,t,p){if(!(l||d)){if(l=!0,r.loading!=="host"){let h=(t??i.documentElement.lang)||"en",v=u&&p?.presentation?.type!=="inline",E=p!==void 0,x=i.createElement(v?"dialog":"div");a=x,x.dataset.longplayLoading=o;let S=h.startsWith("zh"),I=E?S?"正在加载套餐":"Loading plans":S?"正在加载":"Loading",R=p?.screen.theme??{background:"Canvas",text:"CanvasText"};x.setAttribute("aria-label",I);let P=i.createElement("div");P.setAttribute("role","status");let D=i.createElement("div");D.setAttribute("aria-hidden","true"),E?(P.style.cssText="padding:calc(24px + env(safe-area-inset-top, 0px)) 24px 16px;padding-inline-end:68px;font:650 20px/1.3 system-ui,sans-serif;letter-spacing:-.015em",p||(P.style.paddingBlockEnd="24px")):P.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)",P.textContent=I;let b=i.createElement("button");b.type="button",b.textContent="×",b.setAttribute("aria-label",S?"取消加载":"Cancel loading"),$(b,R),E&&(b.style.borderRadius="50%",b.style.top="calc(15px + env(safe-area-inset-top, 0px))",b.style.insetInlineEnd="calc(15px + env(safe-area-inset-right, 0px))"),b.addEventListener("click",m),x.addEventListener("cancel",L=>{L.preventDefault(),m()});let H=i.createElement("style");H.textContent="[data-longplay-loading] > button:focus-visible{outline:2px solid currentColor;outline-offset:-2px}",x.append(P,D,b,H),e.append(x);let k=()=>{if(!d&&v){let L=x;L.showModal?L.showModal():L.open=!0,b.focus({preventScroll:!0})}};p&&n?(f=n(x,D,p,h),k()):E?(x.style.cssText=v?"padding:0;border:0;border-radius:24px;background:Canvas;color:CanvasText;width:min(420px,calc(100vw - 32px))":"position:relative;background:Canvas;color:CanvasText;width:100%",k()):(_(x,D,v,o),k())}M(r.onPresentationState,{surface:o,state:"loading",dismiss:m})}},present(u){if(d)return;let t=!!a;g(),u(t),y("ready")},dismiss:m,finish:y,async wait(u,t){let p=c.signal,h,v,E=new Promise((x,S)=>{v=()=>S(p.reason),p.aborted?v():p.addEventListener("abort",v,{once:!0}),t!==void 0&&(h=setTimeout(()=>S(new Error("Presentation data timed out")),t))});try{let x=await Promise.race([E,u]);return p.throwIfAborted(),x}finally{p.removeEventListener("abort",v),clearTimeout(h)}}}}function _(e,r,o,s){e.style.cssText="position:relative;box-sizing:border-box;background:Canvas;color:CanvasText;padding:24px 48px 24px 24px;"+(o?"position:fixed;width:min(480px,calc(100% - 32px));border:0;border-radius:16px;max-height:calc(100dvh - 32px)":"width:100%"),r.style.cssText="display:grid;gap:12px";let n=s==="banner"?[["72%",12],["44%",10]]:[["46%",20],["84%",12],["65%",12],["100%",64]];for(let[i,c]of n){let l=e.ownerDocument.createElement("div");l.style.cssText=`width:${i};height:${c}px;background:currentColor;opacity:.11;border-radius:6px`,r.append(l)}}function F(e){let r={display:"block",position:"fixed",top:"0",left:"0",opacity:"0",pointerEvents:"none",zIndex:"-1"},o=Object.keys(r).map(i=>{let c=i,l=e.style[c];return e.style[c]=r[c],[c,l]}),s=e.inert??!1,n=e.getAttribute("aria-hidden");return e.inert=!0,e.setAttribute("aria-hidden","true"),()=>{for(let[i,c]of o)e.style[i]=c;e.inert=s,n===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",n)}}function Pe(e,r){let o=e.style.width;e.style.width=`${r.getBoundingClientRect().width||r.ownerDocument.defaultView?.innerWidth||800}px`;let s=F(e);return()=>{s(),e.style.width=o}}export{ue as a,O as b,W as c,me as d,fe as e,$ as f,he as g,ye as h,we as i,Ee as j,F as k,Pe as l};
|
package/dist/chunk-CMKMFT4H.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{o as n,r as t}from"./chunk-ZV23WM25.js";function u(o,e,a){return n(o,e,a,t)}export{u as a};
|