@tinkerlandai/longplay-sdk 0.10.31 → 0.10.32
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 +6 -0
- package/dist/{ai-usage-E4c9NSJK.d.ts → ai-usage-T62xehqa.d.ts} +1 -1
- package/dist/{api-BpeJkr6U.d.ts → api-Do-6AyWa.d.ts} +24 -0
- package/dist/{chunk-2TPPGW7V.js → chunk-4XC34JBS.js} +1 -1
- package/dist/{chunk-BQLT2LDP.js → chunk-5HJYR6Z4.js} +1 -1
- package/dist/chunk-5UFRIIGC.js +1 -0
- package/dist/{chunk-TF2OFTYS.js → chunk-6KBCR7JJ.js} +1 -1
- package/dist/{chunk-JNSU2AP2.js → chunk-7MNJH5GB.js} +1 -1
- package/dist/{chunk-6BTJNSQQ.js → chunk-7QL4GF4C.js} +1 -1
- package/dist/{chunk-ACFQLHJR.js → chunk-BXPXJARS.js} +1 -1
- package/dist/{chunk-FVGUBIVT.js → chunk-CZ2RY6RG.js} +1 -1
- package/dist/{chunk-B3KFE57L.js → chunk-EHDHWYVJ.js} +1 -1
- package/dist/{chunk-D3UU546S.js → chunk-EMVWUEW4.js} +1 -1
- package/dist/{chunk-PI25NLDV.js → chunk-EMYZUBWL.js} +1 -1
- package/dist/{chunk-YXCEZAQL.js → chunk-EQPEUPMG.js} +1 -1
- package/dist/{chunk-7Z7JT4HE.js → chunk-EUVLXS2V.js} +1 -1
- package/dist/{chunk-23WNEOK4.js → chunk-FYQXSGRT.js} +1 -1
- package/dist/{chunk-S5H3WJVQ.js → chunk-GLQXJMKL.js} +1 -1
- package/dist/{chunk-5N7QFF5M.js → chunk-HQITRRHF.js} +1 -1
- package/dist/{chunk-UWYL2QCF.js → chunk-HQPP76BS.js} +1 -1
- package/dist/{chunk-EZ5RCVVY.js → chunk-ILEDKSRQ.js} +1 -1
- package/dist/{chunk-2QQZSMTB.js → chunk-KHM6IHPJ.js} +1 -1
- package/dist/{chunk-FJGJQGYF.js → chunk-MIBRUDIS.js} +1 -1
- package/dist/{chunk-WRUW2UIJ.js → chunk-N7YXDSQL.js} +1 -1
- package/dist/{chunk-4ZVVG5LM.js → chunk-NAZU3EEJ.js} +1 -1
- package/dist/{chunk-S57HRPT2.js → chunk-P5K67CKS.js} +1 -1
- package/dist/{chunk-ITVSLSRM.js → chunk-R23IGK5U.js} +1 -1
- package/dist/chunk-R4FDIYMN.js +1 -0
- package/dist/{chunk-LZV4QJ5E.js → chunk-SCC3O2RD.js} +1 -1
- package/dist/{chunk-WK4WQZHK.js → chunk-SP5AQION.js} +1 -1
- package/dist/{chunk-QPHT6QHE.js → chunk-THMGTRXP.js} +1 -1
- package/dist/{chunk-YEXRETKV.js → chunk-UESDHJRB.js} +1 -1
- package/dist/{chunk-TMZGZAWM.js → chunk-UWLEGMWX.js} +1 -1
- package/dist/{chunk-J4VTKRH7.js → chunk-VYFSRHXM.js} +1 -1
- package/dist/{chunk-HJLGRW4A.js → chunk-X4W22IH6.js} +1 -1
- package/dist/{chunk-ZYTT7ZAB.js → chunk-XH7RJPBV.js} +1 -1
- package/dist/{chunk-RBMOWJGE.js → chunk-Y3MQLWGD.js} +1 -1
- package/dist/chunk-ZGCKQWQ5.js +1 -0
- package/dist/chunk-ZIQENZDI.js +1 -0
- package/dist/{content-OY5MRXF5.js → content-YRQSNKN7.js} +1 -1
- package/dist/{funnel-host-purchase-IRFPNIZY.js → funnel-host-purchase-SWYFJOVN.js} +1 -1
- package/dist/{funnel-local-client-D7e3rP5-.d.ts → funnel-local-client-BeGBvi3z.d.ts} +66 -37
- package/dist/{funnel-process-client-BEPv6guV.d.ts → funnel-process-client-C6QKDZun.d.ts} +46 -46
- package/dist/funnel-runtime-host-J2PQHVSO.js +1 -0
- package/dist/index.d.ts +10 -10
- package/dist/index.js +1 -1
- package/dist/merchant-bridge-contracts-ZUQ6SGXZ.js +1 -0
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.d.ts +2 -2
- package/dist/openrouter.js +1 -1
- package/dist/operation-contracts-443N2P3A.js +1 -0
- package/dist/page.js +1 -1
- package/dist/{paywall-DI62MX5L.js → paywall-RQ66UZLW.js} +1 -1
- package/dist/paywall-session-PPECL5XK.js +1 -0
- package/dist/popup.js +1 -1
- package/dist/react-native.d.ts +5 -5
- package/dist/react-native.js +1 -1
- package/dist/screen-renderer-NHLIJDCW.js +1 -0
- package/dist/server.d.ts +64 -52
- package/dist/server.js +1 -1
- package/dist/{visual-dom-32PB6MMP.js → visual-dom-6DCUZGPB.js} +1 -1
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-NH5ML5SB.js +0 -1
- package/dist/chunk-SJSCROSL.js +0 -1
- package/dist/chunk-XIP32WI7.js +0 -1
- package/dist/chunk-XZEGVBAI.js +0 -1
- package/dist/funnel-runtime-host-CJTPLZ4N.js +0 -1
- package/dist/merchant-bridge-contracts-LJKL7PNJ.js +0 -1
- package/dist/operation-contracts-SP2RZUT3.js +0 -1
- package/dist/paywall-session-AW6R3PJB.js +0 -1
- package/dist/screen-renderer-W5MP4KVG.js +0 -1
- /package/dist/{chunk-PWXN3W4Q.js → chunk-BID4UGWB.js} +0 -0
- /package/dist/{chunk-RFUXSC52.js → chunk-UKMEW5I7.js} +0 -0
- /package/dist/{chunk-ZY4XAKNQ.js → chunk-VF6QMMEA.js} +0 -0
package/dist/openrouter.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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-
|
|
3
|
+
import { F as FoundationApi } from './api-Do-6AyWa.js';
|
|
4
|
+
import { c as createAiPricing, A as AiUsageContext, a as AiTokenUsage, b as AiTokenQuote } from './ai-usage-T62xehqa.js';
|
|
5
5
|
import './screen-CGCJ46b1.js';
|
|
6
6
|
import 'zod';
|
|
7
7
|
import 'zod/v4';
|
package/dist/openrouter.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-
|
|
1
|
+
import"./chunk-HQITRRHF.js";import"./chunk-5HJYR6Z4.js";import"./chunk-ZIQENZDI.js";import"./chunk-VYFSRHXM.js";import{a as i}from"./chunk-X4W22IH6.js";import"./chunk-R4FDIYMN.js";import"./chunk-CZ2RY6RG.js";import{b as A}from"./chunk-VF6QMMEA.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{e as o}from"./chunk-ILEDKSRQ.js";import"./chunk-EQPEUPMG.js";import"./chunk-7MNJH5GB.js";import"./chunk-THMGTRXP.js";import"./chunk-NAZU3EEJ.js";import"./chunk-SCC3O2RD.js";import"./chunk-R23IGK5U.js";import"./chunk-ZGCKQWQ5.js";import"./chunk-BXPXJARS.js";import"./chunk-5HJYR6Z4.js";import"./chunk-VYFSRHXM.js";import"./chunk-N7YXDSQL.js";import"./chunk-MIBRUDIS.js";import"./chunk-R4FDIYMN.js";import"./chunk-VF6QMMEA.js";import"./chunk-7QL4GF4C.js";import"./chunk-BID4UGWB.js";import"./chunk-WOT6VMZA.js";export{o as apiOperations};
|
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-GLQXJMKL.js";import"./chunk-XH7RJPBV.js";import"./chunk-3VUPVXAV.js";import"./chunk-CZ2RY6RG.js";import"./chunk-DSPLGTQI.js";import"./chunk-7QL4GF4C.js";import"./chunk-BID4UGWB.js";import"./chunk-WOT6VMZA.js";export{f as createPageExperiments,o as mergeQueryStrings,r as pageAttributes,e as readPayload};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as at,c as Ne,e as ot,g as st,h as ct}from"./chunk-UWYL2QCF.js";import{c as Xe,d as Ze,e as et,f as pe,g as tt,h as nt,i as rt,k as it}from"./chunk-RBMOWJGE.js";import{a as Ge,c as Se,d as Ye,g as Je,j as Ke}from"./chunk-B3KFE57L.js";import{b as te}from"./chunk-ACFQLHJR.js";import"./chunk-XZEGVBAI.js";import"./chunk-J4VTKRH7.js";import{c as ee,o as re,oa as ie,qa as Oe}from"./chunk-WRUW2UIJ.js";import{c as Te}from"./chunk-FJGJQGYF.js";import{a as k}from"./chunk-HJLGRW4A.js";import"./chunk-XIP32WI7.js";import"./chunk-FVGUBIVT.js";import"./chunk-ZY4XAKNQ.js";import{a as W}from"./chunk-DSPLGTQI.js";import"./chunk-6BTJNSQQ.js";import"./chunk-PWXN3W4Q.js";import"./chunk-WOT6VMZA.js";async function lt(T,r,D){if(r.status!=="complete")throw new k("INVALID_RESPONSE","A verified completed purchase is required");let O=T?re.parse(T):null;if(await D.onComplete?.(r),!O||!D.check)return;let S=re.parse(await D.check());if(S.internal_feature_id!==O.internal_feature_id||S.quantity!==O.quantity||O.observation!==void 0&&(S.observation===void 0||S.observation.requirementDigest!==O.observation.requirementDigest||S.observation.authority!==O.observation.authority||Te(S.observation.subject)!==Te(O.observation.subject)))throw new k("INVALID_RESPONSE","The access requirement changed");S.allowed&&await D.onAccessGranted?.(S)}function De(T){return Object.entries(T.document.buttons).filter(([,r])=>r.type==="checkout"&&r.product.type==="fixed"&&!te(r.product,{},T.capabilities)).map(([r])=>r)}async function zt(T,r,D){let O=it(T.ownerDocument),S=()=>{C.finish("dismissed"),O()},B=()=>S(),C=tt(T,r,"paywall",()=>{S(),W(r.onDismiss)});r.signal?.throwIfAborted(),r.signal?.addEventListener("abort",B,{once:!0});let G=null,_,h,Le;try{if(C.start(!0),C.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(G=r.check?re.parse(await C.wait(r.check(),pe)):null,G?.allowed)return C.finish("skipped"),r.signal?.removeEventListener("abort",B),O(),await r.onAccessGranted?.(G),{check:G,host:null};let[e,t]=await Promise.allSettled([C.wait(import("./screen-renderer-W5MP4KVG.js")),C.wait(r.start().then(s=>(C.cancelled&&s.destroy(),s)),pe)]);if(e.status==="rejected")throw t.status==="fulfilled"&&t.value.destroy(),e.reason;if(t.status==="rejected")throw t.reason;Le=e.value,_=t.value,r.signal?.throwIfAborted(),_.signal?.throwIfAborted(),_.signal?.addEventListener("abort",B,{once:!0});let n=_.view??await C.wait(_.refresh(),pe);if(!n)throw new k("INVALID_RESPONSE","Paywall presentation is missing");_.signal?.throwIfAborted(),h=n}catch(e){throw C.finish("error",e),r.signal?.removeEventListener("abort",B),_?.signal?.removeEventListener("abort",B),_?.destroy(),O(),e}let i=_,{mountScreenPreview:ut}=Le,d=T.ownerDocument,fe=new AbortController,I=d.createElement("section"),Y=d.createElement("div"),U=d.createElement("div"),u=d.createElement("p"),y=d.createElement("button"),b=d.createElement("button"),w=d.createElement("dialog"),a=h.document.screen.strings.defaultLocale.startsWith("zh"),dt=a?"\u6B63\u5728\u5904\u7406\u2026":"Processing\u2026",pt=a?"\u6B63\u5728\u51C6\u5907\u62A5\u4EF7\u2026":"Preparing your price\u2026",P=at(h.document.screen.theme);I.dataset.indianaPaywall="",I.setAttribute("aria-label",h.document.name),I.style.cssText=P.root,U.style.cssText=P.controls,u.style.cssText=P.message,u.setAttribute("role","status"),b.style.cssText=P.link,b.textContent=a?"\u5173\u95ED":"Close",y.style.cssText=P.secondary,y.textContent=a?"\u91CD\u8BD5":"Retry",y.hidden=!0,U.append(u,y,b),I.append(Y,U);let Me=()=>{let e=H??U,t=[...e.children].every(s=>s===u?!u.textContent:s.hidden),n=[...e.children].some(s=>s===b?!1:s===u?!!u.textContent:!s.hidden);e.style.cssText=t?P.controls.replace(/padding:[^;]+/,"padding:0"):n?`${P.controls};${P.pinned}`:P.controls,we()},_e=typeof MutationObserver>"u"?void 0:new MutationObserver(Me);_e?.observe(I,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let J=h.document.presentation,F,Ue,me=!1,$e=JSON.stringify(h.capabilities),qe=e=>K?Object.entries(e.document.buttons).filter(([,t])=>t.type==="checkout").map(([t])=>t):De(e);function he(e){if(p)return;h=e;let t=JSON.stringify(e.capabilities);t!==$e&&(F?.updateCapabilities(e.capabilities,qe(e)),$e=t),mt(e)}let g,ye=0;function we(){let e=d.defaultView;if(!g?.responsive||!e)return;let t=H??U,n=e.innerHeight-(g.type==="modal"?32:0);t.style.maxHeight=`${Math.max(1,n)}px`,t.style.overflowY="auto",t.style.flexShrink="0",ye=Math.max(1,n-t.getBoundingClientRect().height),F?.resizeViewport?.(ye,e.innerWidth)}let p=!1,K=!1,E=null,ae=!1,Ve=!1,j=!1,be,ge=!1,V,H;function ft(){return K||p||V||ge?{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null}:Se(i)}let R=()=>!p&&!ae&&!V&&r.canInteract?.()!==!1,oe=!1,l=null,$=null;function mt(e){K||E||i.quote||i.operation||(u.textContent=Object.values(e.capabilities.plans).some(t=>t.available)?"":a?"\u5F53\u524D\u8D26\u53F7\u6682\u65E0\u53EF\u8D2D\u4E70\u7684\u65B9\u6848\u3002":"No plans are currently available for this account.")}let ve=new Map,Ce=!1;function ht(e,t,n,s){let o=e.lines.length===1?e.lines[0]:void 0,m=te(n,s,t.capabilities);if(!o||!m||o.productVersionId!==m)return!1;let x;try{x=Oe(t.document.screen,m,s,t.capabilities)}catch{return!1}let A=Object.fromEntries((o.prepaid??[]).map(z=>[z.internal_feature_id,z.quantity]));return[...new Set([...Object.keys(x),...Object.keys(A)])].every(z=>(x[z]??0)===(A[z]??0))}let se=e=>Ge({quote:i.quote,operation:e,requestId:null,pending:!1,destroyed:p,canReselect:i.canReselect});async function Pe(e){let t=e.merchantExecution;if(!(!R()||!e.checkoutUrl||r.checkoutNavigation==="after_confirmation"&&se(e).type!=="checkout"||t?.type==="purchase"&&!["not_started","pending"].includes(t.paymentStatus)||ve.get(e.operationId)===e.checkoutUrl)){ve.set(e.operationId,e.checkoutUrl);try{r.onCheckoutUrl?await r.onCheckoutUrl(e.checkoutUrl):d.defaultView?.location.assign(e.checkoutUrl)}catch(n){throw ve.delete(e.operationId),n}}}let Q=(e,t=!1)=>{if(t){let n=e instanceof k?e.code:void 0;n==="CAPABILITY_UNAVAILABLE"||n==="NOT_CONFIGURED"?(l=null,u.textContent=a?"\u6682\u65F6\u65E0\u6CD5\u4E3A\u6B64\u5957\u9910\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002":"Pricing for this plan is unavailable. Payment hasn\u2019t started."):i.canReselect===!0&&!E?u.textContent=a?"\u672A\u80FD\u53D6\u5F97\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002\u8BF7\u91CD\u65B0\u9009\u62E9\u5957\u9910\u3002":"We couldn\u2019t prepare your price. Payment hasn\u2019t started. Choose a plan again.":n==="COMMAND_PENDING"?u.textContent=a?"\u4ECD\u5728\u51C6\u5907\u62A5\u4EF7\uFF0C\u8BF7\u91CD\u8BD5\u4EE5\u67E5\u770B\u7ED3\u679C\u3002":"Your price is still being prepared. Retry to check the result.":u.textContent=a?"\u672A\u80FD\u53D6\u5F97\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002\u8BF7\u91CD\u8BD5\u3002":"We couldn\u2019t prepare your price. Payment hasn\u2019t started. Try again."}else u.textContent=e instanceof k&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?ot(e,a):e instanceof k?e.message:a?"\u64CD\u4F5C\u672A\u5B8C\u6210\uFF0C\u8BF7\u91CD\u8BD5\u3002":"This action couldn\u2019t be completed. Try again.";y.hidden=l===null,t&&!g?.responsive&&u.scrollIntoView?.({block:"nearest"}),W(t&&D?.quoteError?D.quoteError:r.onError,e)},ce=new WeakMap;function le(e){K=e,F?.updateCapabilities?.(h.capabilities,qe(h));for(let t of $?.querySelectorAll("button")??[])e?(ce.set(t,t.disabled),t.disabled=!0):ce.has(t)&&(t.disabled=ce.get(t),ce.delete(t)),Ne(t)}function Ee(){u.textContent=a?"\u6682\u65F6\u65E0\u6CD5\u64CD\u4F5C\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002":"This action is unavailable right now. Try again in a moment."}async function yt(e){if(r.beforeAction)try{await r.beforeAction()}catch(t){throw l=e,t}}async function q(e){if(K||p)return;if(!R()){Ee();return}let t=e===ue,n=t?pt:dt;le(!0),y.hidden=!0,u.textContent=n;try{if(await yt(e),p)return;if(!R()){l=e,y.hidden=!1,Ee();return}await e()}catch(s){p||Q(s,t)}finally{le(!1),u.textContent===n&&(u.textContent="")}}async function wt(e){await lt(G,e,r)}function He(e){return Se(i).type==="recording"||se(e).type==="recording"}function Be(e){let t=e.merchantTerms,n=t?.subscriptionTerms?.items??[],s=t?t.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),o=t?n.length===1&&n[0]?.amountMinor===s&&n[0]:e.lines.length===1&&e.lines[0]?.catalogAmountMinor===s&&e.lines[0],m=s===null?ee(t.subtotalMinor-t.discountMinor,e.currency)+(a?" + \u5F85\u786E\u8BA4\u7A0E\u8D39":" + tax confirmed at checkout"):ee(s,e.currency)+(o?ie(o.interval,a?"zh-CN":"en",o.intervalCount??1):""),x=e.lines.map(A=>A.productName).join(", ");return{label:x?`${x} \xB7 ${m}`:m,recurring:o}}async function N(e,t=r.checkoutNavigation!=="after_confirmation"){if(p)return;if(!R()){l=async()=>N(await i.read()),y.hidden=!1;return}if(u.textContent=ct(e.status,a),He(e)){let o=e.merchantExecution?.type==="purchase"&&e.merchantExecution.recordingStatus==="failed";u.textContent=o?a?"\u4ED8\u6B3E\u548C\u5546\u6237\u5904\u7406\u5DF2\u5B8C\u6210\uFF0C\u4F46\u4EA4\u6613\u8BB0\u5F55\u5931\u8D25\u3002\u8BF7\u8054\u7CFB\u5546\u6237\u4FEE\u590D\uFF0C\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"Payment and fulfillment succeeded, but recording failed. Contact the merchant to repair this purchase; do not buy again.":a?"\u4ED8\u6B3E\u548C\u5546\u6237\u5904\u7406\u5DF2\u5B8C\u6210\uFF0C\u6B63\u5728\u786E\u8BA4\u4EA4\u6613\u8BB0\u5F55\u3002\u8BF7\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"Payment and merchant fulfillment are complete. Recording is pending confirmation; do not purchase again.",y.textContent=a?"\u67E5\u8BE2\u8BB0\u5F55":"Check recording",l=async()=>N(await i.read()),y.hidden=!1;return}if(e.problem){let o=e.problem;l=ne,y.textContent=a?"\u68C0\u67E5\u5E76\u6062\u590D\u539F\u64CD\u4F5C":"Check and recover original purchase",Q(new k(o.code,o.reason==="RESULT_UNKNOWN"?a?"\u4ED8\u6B3E\u7ED3\u679C\u5C1A\u672A\u786E\u5B9A\uFF0C\u8BF7\u6062\u590D\u539F\u64CD\u4F5C\uFF0C\u6682\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"The payment result is unknown. Recover the original purchase before buying again.":o.phase==="fulfillment"?a?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u5546\u6237\u6743\u76CA\u5904\u7406\u9700\u8981\u6838\u5BF9\u3002":"Payment was recorded. Access fulfillment needs attention.":o.code==="CAPABILITY_UNAVAILABLE"?a?"\u5546\u6237\u5C1A\u4E0D\u652F\u6301\u672C\u6B21\u8D2D\u4E70\u6240\u9700\u7684\u5B8C\u6574\u80FD\u529B\uFF0C\u8BF7\u5904\u7406\u540E\u6062\u590D\u539F\u64CD\u4F5C\u3002":"The merchant does not currently support all actions required by this purchase. Recover the original purchase after this is resolved.":o.code==="NOT_CONFIGURED"?a?"\u4ED8\u6B3E\u670D\u52A1\u8FDE\u63A5\u9700\u8981\u5904\u7406\uFF0C\u8BF7\u8054\u7CFB\u5546\u6237\u540E\u6062\u590D\u539F\u64CD\u4F5C\u3002":"The payment connection needs attention. Contact the merchant, then recover the original purchase.":a?"\u539F\u8D2D\u4E70\u64CD\u4F5C\u9700\u8981\u5904\u7406\uFF0C\u8BF7\u67E5\u8BE2\u6216\u6062\u590D\u6B64\u64CD\u4F5C\u3002":"The original purchase needs attention. Check or recover this operation.",void 0,void 0,o));return}if(e.merchantExecution?.type==="purchase"&&e.merchantExecution.paymentStatus==="succeeded"&&!["applied","not_applicable"].includes(e.merchantExecution.fulfillmentStatus)&&(u.textContent=a?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u6B63\u5728\u7B49\u5F85\u5546\u6237\u5B8C\u6210\u5904\u7406\u3002":"Payment was recorded. Waiting for merchant fulfillment."),e.status==="complete"){l=null,await wt(e);return}if(e.status!=="pending"){if(i.canReselect===!1){u.textContent=a?"\u6B63\u5728\u6838\u5BF9\u539F\u8D2D\u4E70\u7ED3\u679C":"Checking the original purchase result",y.textContent=a?"\u67E5\u8BE2\u7ED3\u679C":"Check result",l=async()=>N(await i.read()),y.hidden=!1;return}e.status==="cancelled"?u.textContent=a?"\u8FD9\u7B14\u8D2D\u4E70\u5DF2\u53D6\u6D88\uFF0C\u53EF\u4EE5\u91CD\u65B0\u9009\u62E9\u65B9\u6848\u3002":"This purchase was cancelled. Choose a plan to start again.":e.status==="failed"&&(u.textContent=a?"\u8FD9\u7B14\u8D2D\u4E70\u672A\u80FD\u5B8C\u6210\uFF0C\u53EF\u4EE5\u91CD\u65B0\u9009\u62E9\u65B9\u6848\u3002":"This purchase didn\u2019t go through. Choose a plan to try again."),y.textContent=a?"\u91CD\u8BD5":"Retry",l=null,E=null;return}if(!t&&se(e).type==="checkout"){let o=i.quote,m=o?.operationId===e.operationId?Be(o).label:"";u.textContent=Ce?m?a?`${m} \u5C1A\u672A\u4ED8\u6B3E\u3002\u518D\u6B21\u9009\u62E9\u8BE5\u65B9\u6848\u5373\u53EF\u7EE7\u7EED\u4ED8\u6B3E\u3002`:`${m} is still unpaid. Choose it again to continue paying.`:a?"\u4E4B\u524D\u7684\u8D2D\u4E70\u5C1A\u672A\u4ED8\u6B3E\u3002\u518D\u6B21\u9009\u62E9\u8BE5\u65B9\u6848\u5373\u53EF\u7EE7\u7EED\u4ED8\u6B3E\u3002":"Your earlier purchase is still unpaid. Choose that plan again to continue paying.":"",Ce=!1,l=null;return}await Pe(e);let n=Date.now()+6e5,s=2e3;me=!0,W(r.onObservationChange,!0);try{for(;!p&&Date.now()<n;){if(await st(s,d,fe.signal),p)return;if(!R()){l=async()=>N(await i.read()),y.hidden=!1;return}let o=await i.read();if(!t&&se(o).type==="checkout"){await N(o,!1);return}if(!o.problem&&o.status==="pending"&&await Pe(o),o.status!=="pending"||o.problem||He(o)){await N(o);return}s=Math.min(s*1.5,3e4)}}finally{me=!1,W(r.onObservationChange,!1)}l=async()=>N(await i.read()),y.hidden=!1}async function xe(e=!1){let t=await i.read();if(p)return;if(!R()){l=()=>xe(e),y.hidden=!1;return}let n=i.quote;if(n&&Je(t,{operationId:n.operationId,currency:n.currency},"The original purchase operation changed"),n&&t.status==="pending"&&t.quoteFinalized===!1&&!t.confirmedAt&&!t.checkoutUrl&&!t.nativePurchase&&!t.merchantExecution&&!t.problem&&!i.pendingCancellation){Fe(n);return}await N(t,e||void 0)}async function ne(){$?.remove(),$=null,l=ne;let e=await i.confirm();if(!R()){l=ne,y.hidden=!1;return}if(e.problem){await N(e);return}if(e.status==="pending"){if(e.checkoutUrl)await Pe(e);else if(e.execution&&e.execution.provider!=="merchant"||e.nativePurchase){if(!r.onPurchase)throw new k("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await r.onPurchase({operation:e,signal:fe.signal})}}l=async()=>N(await i.read()),await N(e,!0)}function Fe(e){$?.remove();let t=!(Date.parse(e.expiresAt)>Date.now());u.textContent=t?a?"\u6B64\u62A5\u4EF7\u5DF2\u8FC7\u671F\u3002\u8BF7\u5148\u53D6\u6D88\uFF0C\u518D\u91CD\u65B0\u9009\u62E9\u3002":"This quote has expired. Cancel it, then choose again.":"";let n=d.createElement("div"),s=d.createElement("button"),o=d.createElement("button"),m=d.createElement("div"),x=d.createElement("p"),A=e.merchantTerms,de=a?"zh-CN":"en",z=A?.subscriptionTerms?.items??[],Re=A?A.subscriptionTerms?.trial?.days:e.lines.find(c=>c.trial)?.trial?.days,Z=Re===void 0?null:A?A.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(c=>c.trial)?0:null,je=(c,f)=>a?`${f} \u5929\u8BD5\u7528\u7ED3\u675F\u540E ${c}`:`Then ${c} after the ${f}-day trial`,{label:bt,recurring:Qe}=Be(e),gt=e.lines.map(c=>c.productName).join(", "),ze=Z===null?"":`${a?"\u4ECA\u5929\u5E94\u4ED8":"Due today"} ${ee(Z,e.currency)}`;x.textContent=ze?[gt,ze].filter(Boolean).join(" \xB7 "):bt,s.textContent=a?"\u786E\u8BA4\u8D2D\u4E70":"Confirm purchase",s.disabled=t,o.textContent=a?"\u53D6\u6D88":"Cancel",n.style.cssText=P.panel,x.style.cssText=P.summary,m.style.cssText=P.actions,s.style.cssText=P.primary,o.style.cssText=P.secondary,Ne(s),s.onclick=()=>{q(ne)};let We=async()=>{let c=await i.cancel();p||(n.remove(),$=null,await N(c))};o.onclick=()=>{l=We,q(We)};let L=d.createElement("div");if(L.style.cssText=P.terms,A){for(let f of z){if(Z===null&&f===Qe)continue;let v=d.createElement("p"),M=ee(f.amountMinor,e.currency)+ie(f.interval,de,f.intervalCount);v.textContent=Z!==null&&Re!==void 0?je(M,Re):M,L.append(v)}let c=A.subscriptionTerms?.trial;if(c){let f=d.createElement("p");f.textContent=a?`\u8BD5\u7528 ${c.days} \u5929\uFF1B${c.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${c.days}; ${c.cardRequired?"a payment method is required":"no payment method is required"}`,L.append(f)}for(let f of[...A.expectedEffects.map(v=>v.description),...A.requiredConsents.map(v=>v.summary)]){let v=d.createElement("p");v.textContent=f,L.append(v)}}else{for(let c of e.lines){if(Z!==null||c!==Qe){let f=d.createElement("p"),v=`${ee(c.catalogAmountMinor,e.currency)}${ie(c.interval,de,c.intervalCount??1)}`;f.textContent=Z!==null&&c.trial?(e.lines.length>1?`${c.productName} \xB7 `:"")+je(v,c.trial.days):`${c.productName} \xB7 ${v}`,L.append(f)}for(let f of c.prepaid??[]){let v=d.createElement("p"),M=i.view?.capabilities.plans[c.productVersionId]?.prepaid?.find(vt=>vt.internalFeatureId===f.internal_feature_id);v.textContent=`${M?.name??f.internal_feature_id} \xB7 ${f.quantity} ${a?"\u4EFD":"packs"} \xD7 ${f.terms.units}`,M&&(v.textContent+=ie(M.reset==="week"||M.reset==="month"||M.reset==="year"?M.reset:"one_time",de,M.resetCount)),L.append(v)}if(c.trial){let f=d.createElement("p");f.textContent=a?`\u8BD5\u7528 ${c.trial.days} \u5929\uFF1B${c.trial.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${c.trial.days}; ${c.trial.cardRequired?"a payment method is required":"no payment method is required"}`,L.append(f)}}if(!e.charge){let c=d.createElement("p");c.textContent=a?"\u76EE\u5F55\u4EF7\u683C\uFF1B\u6700\u7EC8\u91D1\u989D\u4EE5\u7ED3\u8D26\u65F6\u7A0E\u8D39\u548C\u8BD5\u7528\u89C4\u5219\u4E3A\u51C6\u3002":"Catalog price; the final charge depends on checkout taxes and trial terms.",L.append(c)}}for(let c of L.children)c.style.margin="0";m.append(s,o),n.append(x,...L.childElementCount?[L]:[],m),U.prepend(n),g?.responsive||n.scrollIntoView?.({block:"nearest"}),s.focus({preventScroll:!0}),$=n,l=null}async function ue(){if(!E)return;if(l=ue,!oe){let n=i.view,s=n?.document.buttons[E.actionId],o=n&&s?.type==="checkout"?te(s.product,E.selection,n.capabilities):null;if(!o)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let m=await r.resolveOfferId?.({actionId:E.actionId,productVersionId:o});if(p)return;m!==void 0&&(E.offerId=m),oe=!0}if(!R()){y.hidden=!1;return}let e;try{e=await i.preview(E)}catch(n){throw i.canReselect===!0&&(E=null,oe=!1,l=null),n}if(p)return;let t=e.merchantTerms;if(r.confirmOnHostedCheckout&&R()&&e.provider==="merchant"&&e.billingSubscriptionId===null&&t?.request.action==="purchase"&&t.request.mode==="subscription"&&t.subscriptionTerms?.trial===null&&t.requiredConsents.length===0&&Date.parse(e.expiresAt)>Date.now()){let n=a?"\u6B63\u5728\u6253\u5F00\u6536\u94F6\u53F0\u2026":"Opening checkout\u2026";u.textContent=n;try{await ne()}catch(s){p||Q(s)}finally{u.textContent===n&&(u.textContent="")}return}Fe(e)}function X(e="destroy"){p||(p=!0,r.signal?.removeEventListener("abort",B),i.signal?.removeEventListener("abort",B),C.finish("dismissed"),Ue?.(),fe.abort(),_e?.disconnect(),g?.destroy(),F?.destroy(),i.destroy(),w.open&&w.close(),w.remove(),I.remove(),O(),e==="dismiss"&&W(r.onDismiss))}S=X;async function ke(){if(!j||p||ae||V==="closing"||!V&&!R())return;if(!D){X("dismiss");return}let e=d.createElement("p");e.setAttribute("role","status"),e.textContent=a?"\u6B63\u5728\u5173\u95ED\u2026":"Closing\u2026",H||(H=d.createElement("div"),H.style.cssText=U.style.cssText,U.replaceWith(H),Y.inert=!0),b.hidden=!1,H.replaceChildren(e,b),V="closing",b.setAttribute("aria-disabled","true"),b.focus({preventScroll:!0});try{await D.dismiss()}catch(t){p||W(r.onError,t)}p||(V="retry",e.textContent=a?"\u672A\u80FD\u786E\u8BA4\u5173\u95ED\uFF0C\u8BF7\u91CD\u8BD5\u3002":"Could not confirm closure. Try again.",b.textContent=a?"\u91CD\u8BD5\u5173\u95ED":"Retry closing",b.removeAttribute("aria-label"),b.removeAttribute("aria-disabled"))}b.onclick=()=>{ke()},w.addEventListener("cancel",e=>{e.preventDefault(),ke()}),y.onclick=()=>{l&&q(l)};function Ie(e){C.finish("error",e),X()}function Ae(){if(!(!Ve||j||p||ae||g&&!R()))try{let e=t=>{be?.(),g&&(w.showModal(),g.responsive&&w.focus({preventScroll:!0}),!t&&r.loading!=="host"&&Ze(w,g.type,g.responsive)),j=!0};D?D.present(()=>C.present(()=>e(!0))):C.present(e)}catch(e){Ie(e),Q(e)}}try{if(J.type==="inline")b.hidden=Object.values(h.document.buttons).some(t=>t.type==="close"),Me(),be=rt(I,T),T.append(I);else{let t={sm:420,md:640,lg:900};w.style.cssText=`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${"size"in J?t[J.size]+"px":"100vw"}`,w.setAttribute("aria-label",h.document.name),b.textContent="\xD7",b.setAttribute("aria-label",a?"\u5173\u95ED":"Close"),et(b,h.document.screen.theme),Ke(h.document)?(b.hidden=!0,w.append(I)):w.append(b,I),T.append(w),g=Xe(w,{...h.document.screen,presentation:J},we),g.latch(),g.responsive&&(I.style.display="flex",I.style.flexDirection="column",I.style.maxHeight="100%",Y.style.overflow="clip",Y.style.minHeight="0"),be=nt(w)}F=ut(Y,{mode:"live",rendererUrl:i.webViewUrl,title:h.document.name,hostPresentation:()=>g?.type??J.type,reportContentHeight:g?.responsive,onResize:t=>{if(!g?.responsive)return;let n=Math.min(t,ye);Y.style.height=`${n}px`,g.setContentHeight(n+(H??U).getBoundingClientRect().height)},onAction(t,n={}){if(!j||p||V)return;if(!R()){Ee();return}let s=i.view,o=s?.document.buttons[t];if(!o)return;if(o.type==="close"){q(async()=>{await r.onAction?.(t),X(r.onAction?"action":"dismiss")});return}if(o.type==="action"){l=async()=>{if(o.action.type==="event"){if(!r.onEvent)throw new k("EVENT_HANDLER_REQUIRED","Provide the event handler");await r.onEvent(o.action.event)}else r.onOpenUrl?await r.onOpenUrl(o.action.url):d.defaultView?.location.assign(o.action.url);await r.onAction?.(t),l=null},q(l);return}if($&&i.canReselect===!1){u.textContent=a?"\u8BF7\u5148\u786E\u8BA4\u6216\u53D6\u6D88\u5F53\u524D\u8D2D\u4E70\u3002":"Confirm or cancel the current purchase first.",g?.responsive||$.scrollIntoView?.({block:"nearest"}),$.querySelector("button")?.focus({preventScroll:!0});return}if((i.quote||E)&&i.canReselect===!1){let x=!!s&&!!i.quote&&ht(i.quote,s,o.product,n);Ce=!!i.quote&&!x,l=i.quote?()=>xe(x):ue,q(l);return}let m=s&&te(o.product,n,s.capabilities);if(!s||!m){Q(new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(r.onPurchaseIntent){l=null,q(async()=>{let x={actionId:t,productVersionId:m,selection:structuredClone(n),featureQuantities:Oe(s.document.screen,m,n,s.capabilities)};ge=!0,await r.onPurchaseIntent(x)});return}if(E&&E.actionId!==t){Q(new k("COMMAND_PENDING","Finish the current purchase"));return}E||(E={requestId:crypto.randomUUID(),actionId:t,selection:n},oe=!1),q(ue)},onEscape:()=>{ke()},onError:t=>{let n=new Error(t);!j&&!p&&Ie(n),Q(n)},onRendered:t=>{t&&w.setAttribute("aria-label",t),Ve=!0,Ae()}}),we(),F.update(h.document.screen,h.document.screen.strings.defaultLocale,{capabilities:h.capabilities,unavailableActions:De(h),serverInput:{bindings:[],answers:{}}}),Ue=i.subscribe?.(he),he(i.view??h),await C.wait(F.ready);let e=i.operation;(i.quote||e&&(e.confirmedAt||e.checkoutUrl||e.status==="complete"))&&(l=()=>xe(),q(l))}catch(e){throw Ie(e),e}return{check:G,host:{get observing(){return me},get recovery(){return ft()},async prepareFallback(){if(K||p||V||ge)return{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null};le(!0);try{let e=await Ye(i);return e.type==="native"&&X(),e}finally{le(!1)}},setSuspended(e){ae=e,I.hidden=e,e&&w.open?w.close():!e&&!j?Ae():!e&&!p&&j&&J.type!=="inline"&&!w.open&&w.showModal()},destroy:X,refresh:async()=>{if(!R()){if(i.view)return i.view;throw new k("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await i.refresh();return he(e),Ae(),e}}}}export{zt as showPaywall};
|
|
1
|
+
import{b as at,c as Ne,e as ot,g as st,h as ct}from"./chunk-HQPP76BS.js";import{c as Xe,d as Ze,e as et,f as pe,g as tt,h as nt,i as rt,k as it}from"./chunk-Y3MQLWGD.js";import{a as Ge,c as Se,d as Ye,g as Je,j as Ke}from"./chunk-EHDHWYVJ.js";import{b as te}from"./chunk-BXPXJARS.js";import"./chunk-ZIQENZDI.js";import"./chunk-VYFSRHXM.js";import{c as ee,o as re,oa as ie,qa as Oe}from"./chunk-N7YXDSQL.js";import{c as Te}from"./chunk-MIBRUDIS.js";import{a as k}from"./chunk-X4W22IH6.js";import"./chunk-R4FDIYMN.js";import"./chunk-CZ2RY6RG.js";import"./chunk-VF6QMMEA.js";import{a as W}from"./chunk-DSPLGTQI.js";import"./chunk-7QL4GF4C.js";import"./chunk-BID4UGWB.js";import"./chunk-WOT6VMZA.js";async function lt(T,r,D){if(r.status!=="complete")throw new k("INVALID_RESPONSE","A verified completed purchase is required");let O=T?re.parse(T):null;if(await D.onComplete?.(r),!O||!D.check)return;let S=re.parse(await D.check());if(S.internal_feature_id!==O.internal_feature_id||S.quantity!==O.quantity||O.observation!==void 0&&(S.observation===void 0||S.observation.requirementDigest!==O.observation.requirementDigest||S.observation.authority!==O.observation.authority||Te(S.observation.subject)!==Te(O.observation.subject)))throw new k("INVALID_RESPONSE","The access requirement changed");S.allowed&&await D.onAccessGranted?.(S)}function De(T){return Object.entries(T.document.buttons).filter(([,r])=>r.type==="checkout"&&r.product.type==="fixed"&&!te(r.product,{},T.capabilities)).map(([r])=>r)}async function zt(T,r,D){let O=it(T.ownerDocument),S=()=>{C.finish("dismissed"),O()},B=()=>S(),C=tt(T,r,"paywall",()=>{S(),W(r.onDismiss)});r.signal?.throwIfAborted(),r.signal?.addEventListener("abort",B,{once:!0});let G=null,_,h,Le;try{if(C.start(!0),C.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(G=r.check?re.parse(await C.wait(r.check(),pe)):null,G?.allowed)return C.finish("skipped"),r.signal?.removeEventListener("abort",B),O(),await r.onAccessGranted?.(G),{check:G,host:null};let[e,t]=await Promise.allSettled([C.wait(import("./screen-renderer-NHLIJDCW.js")),C.wait(r.start().then(s=>(C.cancelled&&s.destroy(),s)),pe)]);if(e.status==="rejected")throw t.status==="fulfilled"&&t.value.destroy(),e.reason;if(t.status==="rejected")throw t.reason;Le=e.value,_=t.value,r.signal?.throwIfAborted(),_.signal?.throwIfAborted(),_.signal?.addEventListener("abort",B,{once:!0});let n=_.view??await C.wait(_.refresh(),pe);if(!n)throw new k("INVALID_RESPONSE","Paywall presentation is missing");_.signal?.throwIfAborted(),h=n}catch(e){throw C.finish("error",e),r.signal?.removeEventListener("abort",B),_?.signal?.removeEventListener("abort",B),_?.destroy(),O(),e}let i=_,{mountScreenPreview:ut}=Le,d=T.ownerDocument,fe=new AbortController,I=d.createElement("section"),Y=d.createElement("div"),U=d.createElement("div"),u=d.createElement("p"),y=d.createElement("button"),b=d.createElement("button"),w=d.createElement("dialog"),a=h.document.screen.strings.defaultLocale.startsWith("zh"),dt=a?"\u6B63\u5728\u5904\u7406\u2026":"Processing\u2026",pt=a?"\u6B63\u5728\u51C6\u5907\u62A5\u4EF7\u2026":"Preparing your price\u2026",P=at(h.document.screen.theme);I.dataset.indianaPaywall="",I.setAttribute("aria-label",h.document.name),I.style.cssText=P.root,U.style.cssText=P.controls,u.style.cssText=P.message,u.setAttribute("role","status"),b.style.cssText=P.link,b.textContent=a?"\u5173\u95ED":"Close",y.style.cssText=P.secondary,y.textContent=a?"\u91CD\u8BD5":"Retry",y.hidden=!0,U.append(u,y,b),I.append(Y,U);let Me=()=>{let e=H??U,t=[...e.children].every(s=>s===u?!u.textContent:s.hidden),n=[...e.children].some(s=>s===b?!1:s===u?!!u.textContent:!s.hidden);e.style.cssText=t?P.controls.replace(/padding:[^;]+/,"padding:0"):n?`${P.controls};${P.pinned}`:P.controls,we()},_e=typeof MutationObserver>"u"?void 0:new MutationObserver(Me);_e?.observe(I,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let J=h.document.presentation,F,Ue,me=!1,$e=JSON.stringify(h.capabilities),qe=e=>K?Object.entries(e.document.buttons).filter(([,t])=>t.type==="checkout").map(([t])=>t):De(e);function he(e){if(p)return;h=e;let t=JSON.stringify(e.capabilities);t!==$e&&(F?.updateCapabilities(e.capabilities,qe(e)),$e=t),mt(e)}let g,ye=0;function we(){let e=d.defaultView;if(!g?.responsive||!e)return;let t=H??U,n=e.innerHeight-(g.type==="modal"?32:0);t.style.maxHeight=`${Math.max(1,n)}px`,t.style.overflowY="auto",t.style.flexShrink="0",ye=Math.max(1,n-t.getBoundingClientRect().height),F?.resizeViewport?.(ye,e.innerWidth)}let p=!1,K=!1,E=null,ae=!1,Ve=!1,j=!1,be,ge=!1,V,H;function ft(){return K||p||V||ge?{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null}:Se(i)}let R=()=>!p&&!ae&&!V&&r.canInteract?.()!==!1,oe=!1,l=null,$=null;function mt(e){K||E||i.quote||i.operation||(u.textContent=Object.values(e.capabilities.plans).some(t=>t.available)?"":a?"\u5F53\u524D\u8D26\u53F7\u6682\u65E0\u53EF\u8D2D\u4E70\u7684\u65B9\u6848\u3002":"No plans are currently available for this account.")}let ve=new Map,Ce=!1;function ht(e,t,n,s){let o=e.lines.length===1?e.lines[0]:void 0,m=te(n,s,t.capabilities);if(!o||!m||o.productVersionId!==m)return!1;let x;try{x=Oe(t.document.screen,m,s,t.capabilities)}catch{return!1}let A=Object.fromEntries((o.prepaid??[]).map(z=>[z.internal_feature_id,z.quantity]));return[...new Set([...Object.keys(x),...Object.keys(A)])].every(z=>(x[z]??0)===(A[z]??0))}let se=e=>Ge({quote:i.quote,operation:e,requestId:null,pending:!1,destroyed:p,canReselect:i.canReselect});async function Pe(e){let t=e.merchantExecution;if(!(!R()||!e.checkoutUrl||r.checkoutNavigation==="after_confirmation"&&se(e).type!=="checkout"||t?.type==="purchase"&&!["not_started","pending"].includes(t.paymentStatus)||ve.get(e.operationId)===e.checkoutUrl)){ve.set(e.operationId,e.checkoutUrl);try{r.onCheckoutUrl?await r.onCheckoutUrl(e.checkoutUrl):d.defaultView?.location.assign(e.checkoutUrl)}catch(n){throw ve.delete(e.operationId),n}}}let Q=(e,t=!1)=>{if(t){let n=e instanceof k?e.code:void 0;n==="CAPABILITY_UNAVAILABLE"||n==="NOT_CONFIGURED"?(l=null,u.textContent=a?"\u6682\u65F6\u65E0\u6CD5\u4E3A\u6B64\u5957\u9910\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002":"Pricing for this plan is unavailable. Payment hasn\u2019t started."):i.canReselect===!0&&!E?u.textContent=a?"\u672A\u80FD\u53D6\u5F97\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002\u8BF7\u91CD\u65B0\u9009\u62E9\u5957\u9910\u3002":"We couldn\u2019t prepare your price. Payment hasn\u2019t started. Choose a plan again.":n==="COMMAND_PENDING"?u.textContent=a?"\u4ECD\u5728\u51C6\u5907\u62A5\u4EF7\uFF0C\u8BF7\u91CD\u8BD5\u4EE5\u67E5\u770B\u7ED3\u679C\u3002":"Your price is still being prepared. Retry to check the result.":u.textContent=a?"\u672A\u80FD\u53D6\u5F97\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002\u8BF7\u91CD\u8BD5\u3002":"We couldn\u2019t prepare your price. Payment hasn\u2019t started. Try again."}else u.textContent=e instanceof k&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?ot(e,a):e instanceof k?e.message:a?"\u64CD\u4F5C\u672A\u5B8C\u6210\uFF0C\u8BF7\u91CD\u8BD5\u3002":"This action couldn\u2019t be completed. Try again.";y.hidden=l===null,t&&!g?.responsive&&u.scrollIntoView?.({block:"nearest"}),W(t&&D?.quoteError?D.quoteError:r.onError,e)},ce=new WeakMap;function le(e){K=e,F?.updateCapabilities?.(h.capabilities,qe(h));for(let t of $?.querySelectorAll("button")??[])e?(ce.set(t,t.disabled),t.disabled=!0):ce.has(t)&&(t.disabled=ce.get(t),ce.delete(t)),Ne(t)}function Ee(){u.textContent=a?"\u6682\u65F6\u65E0\u6CD5\u64CD\u4F5C\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002":"This action is unavailable right now. Try again in a moment."}async function yt(e){if(r.beforeAction)try{await r.beforeAction()}catch(t){throw l=e,t}}async function q(e){if(K||p)return;if(!R()){Ee();return}let t=e===ue,n=t?pt:dt;le(!0),y.hidden=!0,u.textContent=n;try{if(await yt(e),p)return;if(!R()){l=e,y.hidden=!1,Ee();return}await e()}catch(s){p||Q(s,t)}finally{le(!1),u.textContent===n&&(u.textContent="")}}async function wt(e){await lt(G,e,r)}function He(e){return Se(i).type==="recording"||se(e).type==="recording"}function Be(e){let t=e.merchantTerms,n=t?.subscriptionTerms?.items??[],s=t?t.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),o=t?n.length===1&&n[0]?.amountMinor===s&&n[0]:e.lines.length===1&&e.lines[0]?.catalogAmountMinor===s&&e.lines[0],m=s===null?ee(t.subtotalMinor-t.discountMinor,e.currency)+(a?" + \u5F85\u786E\u8BA4\u7A0E\u8D39":" + tax confirmed at checkout"):ee(s,e.currency)+(o?ie(o.interval,a?"zh-CN":"en",o.intervalCount??1):""),x=e.lines.map(A=>A.productName).join(", ");return{label:x?`${x} \xB7 ${m}`:m,recurring:o}}async function N(e,t=r.checkoutNavigation!=="after_confirmation"){if(p)return;if(!R()){l=async()=>N(await i.read()),y.hidden=!1;return}if(u.textContent=ct(e.status,a),He(e)){let o=e.merchantExecution?.type==="purchase"&&e.merchantExecution.recordingStatus==="failed";u.textContent=o?a?"\u4ED8\u6B3E\u548C\u5546\u6237\u5904\u7406\u5DF2\u5B8C\u6210\uFF0C\u4F46\u4EA4\u6613\u8BB0\u5F55\u5931\u8D25\u3002\u8BF7\u8054\u7CFB\u5546\u6237\u4FEE\u590D\uFF0C\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"Payment and fulfillment succeeded, but recording failed. Contact the merchant to repair this purchase; do not buy again.":a?"\u4ED8\u6B3E\u548C\u5546\u6237\u5904\u7406\u5DF2\u5B8C\u6210\uFF0C\u6B63\u5728\u786E\u8BA4\u4EA4\u6613\u8BB0\u5F55\u3002\u8BF7\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"Payment and merchant fulfillment are complete. Recording is pending confirmation; do not purchase again.",y.textContent=a?"\u67E5\u8BE2\u8BB0\u5F55":"Check recording",l=async()=>N(await i.read()),y.hidden=!1;return}if(e.problem){let o=e.problem;l=ne,y.textContent=a?"\u68C0\u67E5\u5E76\u6062\u590D\u539F\u64CD\u4F5C":"Check and recover original purchase",Q(new k(o.code,o.reason==="RESULT_UNKNOWN"?a?"\u4ED8\u6B3E\u7ED3\u679C\u5C1A\u672A\u786E\u5B9A\uFF0C\u8BF7\u6062\u590D\u539F\u64CD\u4F5C\uFF0C\u6682\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"The payment result is unknown. Recover the original purchase before buying again.":o.phase==="fulfillment"?a?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u5546\u6237\u6743\u76CA\u5904\u7406\u9700\u8981\u6838\u5BF9\u3002":"Payment was recorded. Access fulfillment needs attention.":o.code==="CAPABILITY_UNAVAILABLE"?a?"\u5546\u6237\u5C1A\u4E0D\u652F\u6301\u672C\u6B21\u8D2D\u4E70\u6240\u9700\u7684\u5B8C\u6574\u80FD\u529B\uFF0C\u8BF7\u5904\u7406\u540E\u6062\u590D\u539F\u64CD\u4F5C\u3002":"The merchant does not currently support all actions required by this purchase. Recover the original purchase after this is resolved.":o.code==="NOT_CONFIGURED"?a?"\u4ED8\u6B3E\u670D\u52A1\u8FDE\u63A5\u9700\u8981\u5904\u7406\uFF0C\u8BF7\u8054\u7CFB\u5546\u6237\u540E\u6062\u590D\u539F\u64CD\u4F5C\u3002":"The payment connection needs attention. Contact the merchant, then recover the original purchase.":a?"\u539F\u8D2D\u4E70\u64CD\u4F5C\u9700\u8981\u5904\u7406\uFF0C\u8BF7\u67E5\u8BE2\u6216\u6062\u590D\u6B64\u64CD\u4F5C\u3002":"The original purchase needs attention. Check or recover this operation.",void 0,void 0,o));return}if(e.merchantExecution?.type==="purchase"&&e.merchantExecution.paymentStatus==="succeeded"&&!["applied","not_applicable"].includes(e.merchantExecution.fulfillmentStatus)&&(u.textContent=a?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u6B63\u5728\u7B49\u5F85\u5546\u6237\u5B8C\u6210\u5904\u7406\u3002":"Payment was recorded. Waiting for merchant fulfillment."),e.status==="complete"){l=null,await wt(e);return}if(e.status!=="pending"){if(i.canReselect===!1){u.textContent=a?"\u6B63\u5728\u6838\u5BF9\u539F\u8D2D\u4E70\u7ED3\u679C":"Checking the original purchase result",y.textContent=a?"\u67E5\u8BE2\u7ED3\u679C":"Check result",l=async()=>N(await i.read()),y.hidden=!1;return}e.status==="cancelled"?u.textContent=a?"\u8FD9\u7B14\u8D2D\u4E70\u5DF2\u53D6\u6D88\uFF0C\u53EF\u4EE5\u91CD\u65B0\u9009\u62E9\u65B9\u6848\u3002":"This purchase was cancelled. Choose a plan to start again.":e.status==="failed"&&(u.textContent=a?"\u8FD9\u7B14\u8D2D\u4E70\u672A\u80FD\u5B8C\u6210\uFF0C\u53EF\u4EE5\u91CD\u65B0\u9009\u62E9\u65B9\u6848\u3002":"This purchase didn\u2019t go through. Choose a plan to try again."),y.textContent=a?"\u91CD\u8BD5":"Retry",l=null,E=null;return}if(!t&&se(e).type==="checkout"){let o=i.quote,m=o?.operationId===e.operationId?Be(o).label:"";u.textContent=Ce?m?a?`${m} \u5C1A\u672A\u4ED8\u6B3E\u3002\u518D\u6B21\u9009\u62E9\u8BE5\u65B9\u6848\u5373\u53EF\u7EE7\u7EED\u4ED8\u6B3E\u3002`:`${m} is still unpaid. Choose it again to continue paying.`:a?"\u4E4B\u524D\u7684\u8D2D\u4E70\u5C1A\u672A\u4ED8\u6B3E\u3002\u518D\u6B21\u9009\u62E9\u8BE5\u65B9\u6848\u5373\u53EF\u7EE7\u7EED\u4ED8\u6B3E\u3002":"Your earlier purchase is still unpaid. Choose that plan again to continue paying.":"",Ce=!1,l=null;return}await Pe(e);let n=Date.now()+6e5,s=2e3;me=!0,W(r.onObservationChange,!0);try{for(;!p&&Date.now()<n;){if(await st(s,d,fe.signal),p)return;if(!R()){l=async()=>N(await i.read()),y.hidden=!1;return}let o=await i.read();if(!t&&se(o).type==="checkout"){await N(o,!1);return}if(!o.problem&&o.status==="pending"&&await Pe(o),o.status!=="pending"||o.problem||He(o)){await N(o);return}s=Math.min(s*1.5,3e4)}}finally{me=!1,W(r.onObservationChange,!1)}l=async()=>N(await i.read()),y.hidden=!1}async function xe(e=!1){let t=await i.read();if(p)return;if(!R()){l=()=>xe(e),y.hidden=!1;return}let n=i.quote;if(n&&Je(t,{operationId:n.operationId,currency:n.currency},"The original purchase operation changed"),n&&t.status==="pending"&&t.quoteFinalized===!1&&!t.confirmedAt&&!t.checkoutUrl&&!t.nativePurchase&&!t.merchantExecution&&!t.problem&&!i.pendingCancellation){Fe(n);return}await N(t,e||void 0)}async function ne(){$?.remove(),$=null,l=ne;let e=await i.confirm();if(!R()){l=ne,y.hidden=!1;return}if(e.problem){await N(e);return}if(e.status==="pending"){if(e.checkoutUrl)await Pe(e);else if(e.execution&&e.execution.provider!=="merchant"||e.nativePurchase){if(!r.onPurchase)throw new k("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await r.onPurchase({operation:e,signal:fe.signal})}}l=async()=>N(await i.read()),await N(e,!0)}function Fe(e){$?.remove();let t=!(Date.parse(e.expiresAt)>Date.now());u.textContent=t?a?"\u6B64\u62A5\u4EF7\u5DF2\u8FC7\u671F\u3002\u8BF7\u5148\u53D6\u6D88\uFF0C\u518D\u91CD\u65B0\u9009\u62E9\u3002":"This quote has expired. Cancel it, then choose again.":"";let n=d.createElement("div"),s=d.createElement("button"),o=d.createElement("button"),m=d.createElement("div"),x=d.createElement("p"),A=e.merchantTerms,de=a?"zh-CN":"en",z=A?.subscriptionTerms?.items??[],Re=A?A.subscriptionTerms?.trial?.days:e.lines.find(c=>c.trial)?.trial?.days,Z=Re===void 0?null:A?A.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(c=>c.trial)?0:null,je=(c,f)=>a?`${f} \u5929\u8BD5\u7528\u7ED3\u675F\u540E ${c}`:`Then ${c} after the ${f}-day trial`,{label:bt,recurring:Qe}=Be(e),gt=e.lines.map(c=>c.productName).join(", "),ze=Z===null?"":`${a?"\u4ECA\u5929\u5E94\u4ED8":"Due today"} ${ee(Z,e.currency)}`;x.textContent=ze?[gt,ze].filter(Boolean).join(" \xB7 "):bt,s.textContent=a?"\u786E\u8BA4\u8D2D\u4E70":"Confirm purchase",s.disabled=t,o.textContent=a?"\u53D6\u6D88":"Cancel",n.style.cssText=P.panel,x.style.cssText=P.summary,m.style.cssText=P.actions,s.style.cssText=P.primary,o.style.cssText=P.secondary,Ne(s),s.onclick=()=>{q(ne)};let We=async()=>{let c=await i.cancel();p||(n.remove(),$=null,await N(c))};o.onclick=()=>{l=We,q(We)};let L=d.createElement("div");if(L.style.cssText=P.terms,A){for(let f of z){if(Z===null&&f===Qe)continue;let v=d.createElement("p"),M=ee(f.amountMinor,e.currency)+ie(f.interval,de,f.intervalCount);v.textContent=Z!==null&&Re!==void 0?je(M,Re):M,L.append(v)}let c=A.subscriptionTerms?.trial;if(c){let f=d.createElement("p");f.textContent=a?`\u8BD5\u7528 ${c.days} \u5929\uFF1B${c.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${c.days}; ${c.cardRequired?"a payment method is required":"no payment method is required"}`,L.append(f)}for(let f of[...A.expectedEffects.map(v=>v.description),...A.requiredConsents.map(v=>v.summary)]){let v=d.createElement("p");v.textContent=f,L.append(v)}}else{for(let c of e.lines){if(Z!==null||c!==Qe){let f=d.createElement("p"),v=`${ee(c.catalogAmountMinor,e.currency)}${ie(c.interval,de,c.intervalCount??1)}`;f.textContent=Z!==null&&c.trial?(e.lines.length>1?`${c.productName} \xB7 `:"")+je(v,c.trial.days):`${c.productName} \xB7 ${v}`,L.append(f)}for(let f of c.prepaid??[]){let v=d.createElement("p"),M=i.view?.capabilities.plans[c.productVersionId]?.prepaid?.find(vt=>vt.internalFeatureId===f.internal_feature_id);v.textContent=`${M?.name??f.internal_feature_id} \xB7 ${f.quantity} ${a?"\u4EFD":"packs"} \xD7 ${f.terms.units}`,M&&(v.textContent+=ie(M.reset==="week"||M.reset==="month"||M.reset==="year"?M.reset:"one_time",de,M.resetCount)),L.append(v)}if(c.trial){let f=d.createElement("p");f.textContent=a?`\u8BD5\u7528 ${c.trial.days} \u5929\uFF1B${c.trial.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${c.trial.days}; ${c.trial.cardRequired?"a payment method is required":"no payment method is required"}`,L.append(f)}}if(!e.charge){let c=d.createElement("p");c.textContent=a?"\u76EE\u5F55\u4EF7\u683C\uFF1B\u6700\u7EC8\u91D1\u989D\u4EE5\u7ED3\u8D26\u65F6\u7A0E\u8D39\u548C\u8BD5\u7528\u89C4\u5219\u4E3A\u51C6\u3002":"Catalog price; the final charge depends on checkout taxes and trial terms.",L.append(c)}}for(let c of L.children)c.style.margin="0";m.append(s,o),n.append(x,...L.childElementCount?[L]:[],m),U.prepend(n),g?.responsive||n.scrollIntoView?.({block:"nearest"}),s.focus({preventScroll:!0}),$=n,l=null}async function ue(){if(!E)return;if(l=ue,!oe){let n=i.view,s=n?.document.buttons[E.actionId],o=n&&s?.type==="checkout"?te(s.product,E.selection,n.capabilities):null;if(!o)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let m=await r.resolveOfferId?.({actionId:E.actionId,productVersionId:o});if(p)return;m!==void 0&&(E.offerId=m),oe=!0}if(!R()){y.hidden=!1;return}let e;try{e=await i.preview(E)}catch(n){throw i.canReselect===!0&&(E=null,oe=!1,l=null),n}if(p)return;let t=e.merchantTerms;if(r.confirmOnHostedCheckout&&R()&&e.provider==="merchant"&&e.billingSubscriptionId===null&&t?.request.action==="purchase"&&t.request.mode==="subscription"&&t.subscriptionTerms?.trial===null&&t.requiredConsents.length===0&&Date.parse(e.expiresAt)>Date.now()){let n=a?"\u6B63\u5728\u6253\u5F00\u6536\u94F6\u53F0\u2026":"Opening checkout\u2026";u.textContent=n;try{await ne()}catch(s){p||Q(s)}finally{u.textContent===n&&(u.textContent="")}return}Fe(e)}function X(e="destroy"){p||(p=!0,r.signal?.removeEventListener("abort",B),i.signal?.removeEventListener("abort",B),C.finish("dismissed"),Ue?.(),fe.abort(),_e?.disconnect(),g?.destroy(),F?.destroy(),i.destroy(),w.open&&w.close(),w.remove(),I.remove(),O(),e==="dismiss"&&W(r.onDismiss))}S=X;async function ke(){if(!j||p||ae||V==="closing"||!V&&!R())return;if(!D){X("dismiss");return}let e=d.createElement("p");e.setAttribute("role","status"),e.textContent=a?"\u6B63\u5728\u5173\u95ED\u2026":"Closing\u2026",H||(H=d.createElement("div"),H.style.cssText=U.style.cssText,U.replaceWith(H),Y.inert=!0),b.hidden=!1,H.replaceChildren(e,b),V="closing",b.setAttribute("aria-disabled","true"),b.focus({preventScroll:!0});try{await D.dismiss()}catch(t){p||W(r.onError,t)}p||(V="retry",e.textContent=a?"\u672A\u80FD\u786E\u8BA4\u5173\u95ED\uFF0C\u8BF7\u91CD\u8BD5\u3002":"Could not confirm closure. Try again.",b.textContent=a?"\u91CD\u8BD5\u5173\u95ED":"Retry closing",b.removeAttribute("aria-label"),b.removeAttribute("aria-disabled"))}b.onclick=()=>{ke()},w.addEventListener("cancel",e=>{e.preventDefault(),ke()}),y.onclick=()=>{l&&q(l)};function Ie(e){C.finish("error",e),X()}function Ae(){if(!(!Ve||j||p||ae||g&&!R()))try{let e=t=>{be?.(),g&&(w.showModal(),g.responsive&&w.focus({preventScroll:!0}),!t&&r.loading!=="host"&&Ze(w,g.type,g.responsive)),j=!0};D?D.present(()=>C.present(()=>e(!0))):C.present(e)}catch(e){Ie(e),Q(e)}}try{if(J.type==="inline")b.hidden=Object.values(h.document.buttons).some(t=>t.type==="close"),Me(),be=rt(I,T),T.append(I);else{let t={sm:420,md:640,lg:900};w.style.cssText=`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${"size"in J?t[J.size]+"px":"100vw"}`,w.setAttribute("aria-label",h.document.name),b.textContent="\xD7",b.setAttribute("aria-label",a?"\u5173\u95ED":"Close"),et(b,h.document.screen.theme),Ke(h.document)?(b.hidden=!0,w.append(I)):w.append(b,I),T.append(w),g=Xe(w,{...h.document.screen,presentation:J},we),g.latch(),g.responsive&&(I.style.display="flex",I.style.flexDirection="column",I.style.maxHeight="100%",Y.style.overflow="clip",Y.style.minHeight="0"),be=nt(w)}F=ut(Y,{mode:"live",rendererUrl:i.webViewUrl,title:h.document.name,hostPresentation:()=>g?.type??J.type,reportContentHeight:g?.responsive,onResize:t=>{if(!g?.responsive)return;let n=Math.min(t,ye);Y.style.height=`${n}px`,g.setContentHeight(n+(H??U).getBoundingClientRect().height)},onAction(t,n={}){if(!j||p||V)return;if(!R()){Ee();return}let s=i.view,o=s?.document.buttons[t];if(!o)return;if(o.type==="close"){q(async()=>{await r.onAction?.(t),X(r.onAction?"action":"dismiss")});return}if(o.type==="action"){l=async()=>{if(o.action.type==="event"){if(!r.onEvent)throw new k("EVENT_HANDLER_REQUIRED","Provide the event handler");await r.onEvent(o.action.event)}else r.onOpenUrl?await r.onOpenUrl(o.action.url):d.defaultView?.location.assign(o.action.url);await r.onAction?.(t),l=null},q(l);return}if($&&i.canReselect===!1){u.textContent=a?"\u8BF7\u5148\u786E\u8BA4\u6216\u53D6\u6D88\u5F53\u524D\u8D2D\u4E70\u3002":"Confirm or cancel the current purchase first.",g?.responsive||$.scrollIntoView?.({block:"nearest"}),$.querySelector("button")?.focus({preventScroll:!0});return}if((i.quote||E)&&i.canReselect===!1){let x=!!s&&!!i.quote&&ht(i.quote,s,o.product,n);Ce=!!i.quote&&!x,l=i.quote?()=>xe(x):ue,q(l);return}let m=s&&te(o.product,n,s.capabilities);if(!s||!m){Q(new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(r.onPurchaseIntent){l=null,q(async()=>{let x={actionId:t,productVersionId:m,selection:structuredClone(n),featureQuantities:Oe(s.document.screen,m,n,s.capabilities)};ge=!0,await r.onPurchaseIntent(x)});return}if(E&&E.actionId!==t){Q(new k("COMMAND_PENDING","Finish the current purchase"));return}E||(E={requestId:crypto.randomUUID(),actionId:t,selection:n},oe=!1),q(ue)},onEscape:()=>{ke()},onError:t=>{let n=new Error(t);!j&&!p&&Ie(n),Q(n)},onRendered:t=>{t&&w.setAttribute("aria-label",t),Ve=!0,Ae()}}),we(),F.update(h.document.screen,h.document.screen.strings.defaultLocale,{capabilities:h.capabilities,unavailableActions:De(h),serverInput:{bindings:[],answers:{}}}),Ue=i.subscribe?.(he),he(i.view??h),await C.wait(F.ready);let e=i.operation;(i.quote||e&&(e.confirmedAt||e.checkoutUrl||e.status==="complete"))&&(l=()=>xe(),q(l))}catch(e){throw Ie(e),e}return{check:G,host:{get observing(){return me},get recovery(){return ft()},async prepareFallback(){if(K||p||V||ge)return{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null};le(!0);try{let e=await Ye(i);return e.type==="native"&&X(),e}finally{le(!1)}},setSuspended(e){ae=e,I.hidden=e,e&&w.open?w.close():!e&&!j?Ae():!e&&!p&&j&&J.type!=="inline"&&!w.open&&w.showModal()},destroy:X,refresh:async()=>{if(!R()){if(i.view)return i.view;throw new k("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await i.refresh();return he(e),Ae(),e}}}}export{zt as showPaywall};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-P5K67CKS.js";import"./chunk-ILEDKSRQ.js";import"./chunk-EQPEUPMG.js";import"./chunk-FYQXSGRT.js";import"./chunk-7MNJH5GB.js";import"./chunk-SP5AQION.js";import"./chunk-THMGTRXP.js";import"./chunk-NAZU3EEJ.js";import"./chunk-SCC3O2RD.js";import"./chunk-R23IGK5U.js";import"./chunk-ZGCKQWQ5.js";import"./chunk-EHDHWYVJ.js";import"./chunk-BXPXJARS.js";import"./chunk-5HJYR6Z4.js";import"./chunk-ZIQENZDI.js";import"./chunk-VYFSRHXM.js";import"./chunk-N7YXDSQL.js";import"./chunk-MIBRUDIS.js";import"./chunk-X4W22IH6.js";import"./chunk-R4FDIYMN.js";import"./chunk-3VUPVXAV.js";import"./chunk-CZ2RY6RG.js";import"./chunk-VF6QMMEA.js";import"./chunk-DSPLGTQI.js";import"./chunk-7QL4GF4C.js";import"./chunk-BID4UGWB.js";import"./chunk-WOT6VMZA.js";export{a as createPaywallSession};
|
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-6KBCR7JJ.js";import"./chunk-Y3MQLWGD.js";import"./chunk-N7YXDSQL.js";import"./chunk-MIBRUDIS.js";import"./chunk-X4W22IH6.js";import"./chunk-R4FDIYMN.js";import"./chunk-VF6QMMEA.js";import"./chunk-DSPLGTQI.js";import"./chunk-7QL4GF4C.js";import"./chunk-BID4UGWB.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};
|
package/dist/react-native.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
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, d as SessionCredentials, E as Scope, z as createFunnelRunController, v as PaywallStartInput, j as createPaywallSession } from './funnel-local-client-
|
|
4
|
-
export { c as FunnelCommandStorage, F as FunnelRunController, r as LocalFunnelClientOptions, t as LongplayError, u as PaywallPurchaseInput, P as PaywallSession, w as PushHost, x as PushJournal, y as createFeatureClient, A as createLocalFunnelClient } from './funnel-local-client-
|
|
1
|
+
import { f as createCustomerClient, d as createFunnelClient } from './funnel-process-client-C6QKDZun.js';
|
|
2
|
+
export { F as FunnelProcessAdapter, a as FunnelProcessOptions, c as createFunnelProcess } from './funnel-process-client-C6QKDZun.js';
|
|
3
|
+
import { I as IndianaOptions, d as SessionCredentials, E as Scope, z as createFunnelRunController, v as PaywallStartInput, j as createPaywallSession } from './funnel-local-client-BeGBvi3z.js';
|
|
4
|
+
export { c as FunnelCommandStorage, F as FunnelRunController, r as LocalFunnelClientOptions, t as LongplayError, u as PaywallPurchaseInput, P as PaywallSession, w as PushHost, x as PushJournal, y as createFeatureClient, A as createLocalFunnelClient } from './funnel-local-client-BeGBvi3z.js';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
import { J as JsonValue } from './growth-rules-B4YYy64R.js';
|
|
7
7
|
export { C as ConfigurationStorage, b as ConfigurationSyncOptions, c as createConfigurationSync } from './configuration-sync-DdTRUv7A.js';
|
|
8
|
-
import './api-
|
|
8
|
+
import './api-Do-6AyWa.js';
|
|
9
9
|
import './screen-CGCJ46b1.js';
|
|
10
10
|
import 'zod/v4';
|
|
11
11
|
import './coupon-kfkIVf9n.js';
|
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-EMVWUEW4.js";import"./chunk-4XC34JBS.js";import{a as A}from"./chunk-P5K67CKS.js";import{e as P}from"./chunk-ILEDKSRQ.js";import"./chunk-EQPEUPMG.js";import{h as b,i as x,k as L}from"./chunk-KHM6IHPJ.js";import"./chunk-FYQXSGRT.js";import"./chunk-7MNJH5GB.js";import{F as C}from"./chunk-EUVLXS2V.js";import"./chunk-SP5AQION.js";import"./chunk-THMGTRXP.js";import"./chunk-NAZU3EEJ.js";import"./chunk-SCC3O2RD.js";import"./chunk-R23IGK5U.js";import"./chunk-ZGCKQWQ5.js";import"./chunk-EHDHWYVJ.js";import"./chunk-BXPXJARS.js";import"./chunk-5HJYR6Z4.js";import"./chunk-ZIQENZDI.js";import"./chunk-VYFSRHXM.js";import"./chunk-N7YXDSQL.js";import"./chunk-MIBRUDIS.js";import{a as r}from"./chunk-X4W22IH6.js";import{h as R}from"./chunk-R4FDIYMN.js";import"./chunk-3VUPVXAV.js";import"./chunk-CZ2RY6RG.js";import"./chunk-VF6QMMEA.js";import"./chunk-DSPLGTQI.js";import"./chunk-7QL4GF4C.js";import"./chunk-BID4UGWB.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i}from"./chunk-6KBCR7JJ.js";import"./chunk-Y3MQLWGD.js";import"./chunk-N7YXDSQL.js";import"./chunk-MIBRUDIS.js";import"./chunk-X4W22IH6.js";import"./chunk-R4FDIYMN.js";import"./chunk-VF6QMMEA.js";import"./chunk-DSPLGTQI.js";import"./chunk-7QL4GF4C.js";import"./chunk-BID4UGWB.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};
|