@tinkerlandai/longplay-sdk 0.10.38 → 0.10.40
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 +11 -0
- package/README.md +1 -1
- package/README.zh-CN.md +1 -1
- package/dist/check-response-DRQCUWDW.js +1 -0
- package/dist/{chunk-UFTLA3ZI.js → chunk-2DPNSTCN.js} +1 -1
- package/dist/{chunk-64ETX3AY.js → chunk-33ZVZOSC.js} +1 -1
- package/dist/{chunk-G7Y7LPOB.js → chunk-4TEZZZYK.js} +1 -1
- package/dist/{chunk-7PXJUHDS.js → chunk-57GPGWSK.js} +1 -1
- package/dist/{chunk-PLOUC66F.js → chunk-5DZJCFNQ.js} +1 -1
- package/dist/{chunk-IV6LKRYM.js → chunk-67AY54E2.js} +1 -1
- package/dist/{chunk-UAJTQ23E.js → chunk-6PG3AS3G.js} +1 -1
- package/dist/{chunk-6WEHTOED.js → chunk-7QDT6DO7.js} +1 -1
- package/dist/{chunk-DK5PHPSO.js → chunk-ASDJTOGM.js} +1 -1
- package/dist/{chunk-H2I37CQ4.js → chunk-AZFWG352.js} +1 -1
- package/dist/{chunk-5IGASP6C.js → chunk-BYP4KVB3.js} +1 -1
- package/dist/{chunk-QZRJ3ZXU.js → chunk-C2KT5ZFU.js} +1 -1
- package/dist/{chunk-XBCKVHOT.js → chunk-C3GYAKIU.js} +1 -1
- package/dist/{chunk-JXTJT2EW.js → chunk-CZ4TQCUV.js} +1 -1
- package/dist/{chunk-TLV3NVUU.js → chunk-EREQZWGI.js} +1 -1
- package/dist/{chunk-JBDNNV3P.js → chunk-ESAHTG3Y.js} +1 -1
- package/dist/{chunk-4E326NPY.js → chunk-FCDWCQYC.js} +1 -1
- package/dist/{chunk-WQZOT22S.js → chunk-GC6JBIRQ.js} +1 -1
- package/dist/chunk-IJKAQNK6.js +1 -0
- package/dist/{chunk-KQF4BVOL.js → chunk-IOJVF52Q.js} +1 -1
- package/dist/{chunk-UD7XPHE4.js → chunk-LSPHUA7V.js} +1 -1
- package/dist/{chunk-K3VQKR4G.js → chunk-OOD2VDDP.js} +1 -1
- package/dist/{chunk-YYXINZ4A.js → chunk-ORMQJAQE.js} +1 -1
- package/dist/{chunk-Y5RT7PAD.js → chunk-P23JOPR5.js} +1 -1
- package/dist/{chunk-DTWSDNYI.js → chunk-P6C3PNMQ.js} +1 -1
- package/dist/chunk-PJS7M6X3.js +1 -0
- package/dist/{chunk-IHB275C3.js → chunk-POCDWUD3.js} +1 -1
- package/dist/{chunk-WP3SZU24.js → chunk-PZOQV6MU.js} +1 -1
- package/dist/{chunk-RK7XOT3F.js → chunk-QZTTKH2H.js} +1 -1
- package/dist/{chunk-KTBXAATX.js → chunk-RFNIGJOL.js} +1 -1
- package/dist/{chunk-Q7K66FTS.js → chunk-RULQQ7WI.js} +1 -1
- package/dist/{chunk-EEYDOVVS.js → chunk-RV6UAUK2.js} +1 -1
- package/dist/chunk-U7GH4VME.js +1 -0
- package/dist/{chunk-L54MODP5.js → chunk-VC2HPREX.js} +1 -1
- package/dist/{chunk-SY7AYEDO.js → chunk-VOKEZHAH.js} +1 -1
- package/dist/{chunk-O5VA3E5D.js → chunk-WLGLQJ6M.js} +1 -1
- package/dist/{chunk-GEPX4AUR.js → chunk-X6ONZGRY.js} +1 -1
- package/dist/{chunk-HJVEVJXS.js → chunk-XDOKFAE6.js} +1 -1
- package/dist/{chunk-BDC7B4KM.js → chunk-Y6HL2IY2.js} +1 -1
- package/dist/{chunk-NK55HFFF.js → chunk-YLPQLD2A.js} +1 -1
- package/dist/{chunk-6QOJRLVM.js → chunk-YY445FBU.js} +1 -1
- package/dist/{content-B4CC4O23.js → content-QUEVNSXD.js} +1 -1
- package/dist/{funnel-host-purchase-AGBJG3RK.js → funnel-host-purchase-LMVMJNUO.js} +1 -1
- package/dist/funnel-paywall-prerender-LGUSHEP3.js +1 -0
- package/dist/funnel-runtime-host-H5FM67UC.js +1 -0
- package/dist/index.js +1 -1
- package/dist/merchant-bridge-contracts-LZSQYE3O.js +1 -0
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.js +1 -1
- package/dist/operation-contracts-O7TCDGV4.js +1 -0
- package/dist/page.js +1 -1
- package/dist/paywall-UANWOKKC.js +1 -0
- package/dist/paywall-content-CHPX2P77.js +1 -0
- package/dist/paywall-session-3BNUC5ZE.js +1 -0
- package/dist/popup.js +1 -1
- package/dist/react-native.js +1 -1
- package/dist/screen-renderer-FFVZ64MR.js +1 -0
- package/dist/server.js +1 -1
- package/dist/visual.js +1 -1
- package/package.json +9 -10
- package/dist/check-response-Q7GOBUGJ.js +0 -1
- package/dist/chunk-2LND3R7K.js +0 -1
- package/dist/chunk-DSLJUN3P.js +0 -1
- package/dist/chunk-I7QTCEYR.js +0 -1
- package/dist/funnel-paywall-prerender-HHAQBIIB.js +0 -1
- package/dist/funnel-runtime-host-IJDKXLST.js +0 -1
- package/dist/merchant-bridge-contracts-KVOFRPKV.js +0 -1
- package/dist/operation-contracts-G4C7ZLEH.js +0 -1
- package/dist/paywall-TVCH6VQT.js +0 -1
- package/dist/paywall-content-QSTCRYU5.js +0 -1
- package/dist/paywall-session-UBQYU5XD.js +0 -1
- package/dist/screen-renderer-Q3VSMB2N.js +0 -1
- /package/dist/{chunk-42UXYMRZ.js → chunk-RGEBK6UF.js} +0 -0
package/dist/openrouter.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-
|
|
1
|
+
import"./chunk-YY445FBU.js";import"./chunk-57GPGWSK.js";import"./chunk-PZOQV6MU.js";import"./chunk-FCDWCQYC.js";import"./chunk-OOD2VDDP.js";import{a as i}from"./chunk-WLGLQJ6M.js";import"./chunk-RULQQ7WI.js";import"./chunk-RV6UAUK2.js";import{b as A}from"./chunk-RGEBK6UF.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-5DZJCFNQ.js";import"./chunk-YLPQLD2A.js";import"./chunk-ORMQJAQE.js";import"./chunk-RFNIGJOL.js";import"./chunk-6PG3AS3G.js";import"./chunk-EREQZWGI.js";import"./chunk-P23JOPR5.js";import"./chunk-IOJVF52Q.js";import"./chunk-U7GH4VME.js";import"./chunk-33ZVZOSC.js";import"./chunk-57GPGWSK.js";import"./chunk-FCDWCQYC.js";import"./chunk-XDOKFAE6.js";import"./chunk-Y6HL2IY2.js";import"./chunk-LSPHUA7V.js";import"./chunk-OOD2VDDP.js";import"./chunk-RULQQ7WI.js";import"./chunk-RGEBK6UF.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.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-2DPNSTCN.js";import"./chunk-C2KT5ZFU.js";import"./chunk-3VUPVXAV.js";import"./chunk-RV6UAUK2.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.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 Tt,c as Ot,d as et,f as tt,g as Dt,k as Lt}from"./chunk-CZ4TQCUV.js";import{b as Xe}from"./chunk-W32FI2A2.js";import{d as Et,e as xt,f as It,h as Ze,i as De,j as At,k as Rt,l as St}from"./chunk-P6C3PNMQ.js";import{a as bt,c as Je,d as Ct,e as vt}from"./chunk-3NCMYTNG.js";import{b as ce}from"./chunk-33ZVZOSC.js";import{a as pe,c as Ke,e as Pt,h as kt}from"./chunk-VOKEZHAH.js";import"./chunk-PZOQV6MU.js";import"./chunk-FCDWCQYC.js";import{ca as Ce,ea as ve,i as gt}from"./chunk-XDOKFAE6.js";import{c as fe,j as be}from"./chunk-Y6HL2IY2.js";import{c as Ye}from"./chunk-LSPHUA7V.js";import"./chunk-OOD2VDDP.js";import{a as v}from"./chunk-WLGLQJ6M.js";import"./chunk-RULQQ7WI.js";import"./chunk-RV6UAUK2.js";import"./chunk-RGEBK6UF.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import{a as q}from"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";async function Nt(O,i,R){if(i.status!=="complete")throw new v("INVALID_RESPONSE","A verified completed purchase is required");let P=O?be.parse(O):null;if(await R.onComplete?.(i),!P||!R.check)return;let N=be.parse(await R.check());if(N.internal_feature_id!==P.internal_feature_id||N.quantity!==P.quantity||P.observation!==void 0&&(N.observation===void 0||N.observation.requirementDigest!==P.observation.requirementDigest||N.observation.authority!==P.observation.authority||Ye(N.observation.subject)!==Ye(P.observation.subject)))throw new v("INVALID_RESPONSE","The access requirement changed");N.allowed&&await R.onAccessGranted?.(N)}function nt(O){return Object.entries(O.document.buttons).filter(([,i])=>i.type==="checkout"&&i.product.type==="fixed"&&!ce(i.product,{},O.capabilities)).map(([i])=>i)}function _t(O,i){let R=i.lines[0];if(i.lines.length!==1||!R)return;let P=R.productVersionId,{screen:N,buttons:J}=O.document,x=new Map((R.prepaid??[]).map(m=>[m.internal_feature_id,m.quantity]));function K(m,h){if(m.hidden)return!1;if(m.type==="plan_picker"&&O.capabilities.pickers[m.id]?.options.includes(P))return h[m.id]=P,!0;if(m.type==="quantity_picker"){let Q=x.get(m.internalFeatureId);return Q!==void 0&&(!m.bind?.plan||m.bind.plan===P)&&(h[m.id]=Q),!1}if(m.type==="button"&&m.action){let Q=J[m.action];return Q?.type==="checkout"&&Q.product.type==="fixed"&&Q.product.productVersionId===P}if(m.type!=="stack")return!1;let j=m.interaction,r=m.bind?.plan===P;for(let[Q,p]of m.children.entries()){let te={},S=K(p,te);if(j?.type==="toggle"||j?.type==="tabs"){if(!S)continue;return h[m.id]=j.type==="toggle"?Q===0:p.id,Object.assign(h,te),!0}Object.assign(h,te),S&&(r=!0,j?.type==="select"&&j.purpose==="product"&&j.pickerId&&p.type==="stack"&&p.bind?.plan===P&&(h[m.id]=p.id,h[j.pickerId]=P))}return r}for(let m of N.pages){let h={__page:m.id};if(K(m.root,h))return h}}async function Pn(O,i,R){let P=i.focusAtReveal?()=>{}:Ze(O.ownerDocument),N=()=>{x.finish("dismissed"),P()},J=()=>N(),x=At(O,i,"paywall",()=>{N(),q(i.onDismiss)},Tt);i.signal?.throwIfAborted(),i.signal?.addEventListener("abort",J,{once:!0});let K=null,m,h,j;try{if(x.start(!0,i.loadingDocument?.screen.strings.defaultLocale,i.loadingDocument??null),x.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(K=i.check?be.parse(await x.wait(i.check(),De)):null,K?.allowed)return x.finish("skipped"),i.signal?.removeEventListener("abort",J),P(),await i.onAccessGranted?.(K),{check:K,host:null};let[e,t]=await Promise.allSettled([x.wait(import("./screen-renderer-FFVZ64MR.js")),x.wait(i.start().then(o=>(x.cancelled&&o.destroy(),o)),De)]);if(e.status==="rejected")throw t.status==="fulfilled"&&t.value.destroy(),e.reason;if(t.status==="rejected")throw t.reason;j=e.value,m=t.value,i.signal?.throwIfAborted(),m.signal?.throwIfAborted(),m.signal?.addEventListener("abort",J,{once:!0});let n=m.view??await x.wait(m.refresh(),De);if(!n)throw new v("INVALID_RESPONSE","Paywall presentation is missing");m.signal?.throwIfAborted(),h=n}catch(e){throw x.finish("error",e),i.signal?.removeEventListener("abort",J),m?.signal?.removeEventListener("abort",J),m?.destroy(),P(),e}let r=m,{mountScreenPreview:Q}=j,p=O.ownerDocument,te=new AbortController,S=p.createElement("section"),le=p.createElement("div"),G=p.createElement("div"),Le=i.mountControls,V=Le?p.createElement("div"):void 0,u=p.createElement("p"),g=p.createElement("button"),k=p.createElement("button"),I=p.createElement("dialog"),rt=r.locale||h.document.screen.strings.defaultLocale,a=rt.toLowerCase().startsWith("zh"),Ut=a?"\u6B63\u5728\u5904\u7406\u2026":"Processing\u2026",Mt=a?"\u6B63\u5728\u51C6\u5907\u62A5\u4EF7\u2026":"Preparing your price\u2026",D=Ot(h.document.screen.theme);S.dataset.indianaPaywall="",S.setAttribute("aria-label",h.document.name),S.style.cssText=D.root,G.style.cssText=D.controls,u.style.cssText=D.message,u.setAttribute("role","status"),k.style.cssText=D.link,k.textContent=a?"\u5173\u95ED":"Close",g.style.cssText=D.secondary,g.textContent=a?"\u91CD\u8BD5":"Retry",g.hidden=!0,G.append(u,g,k),V&&(V.style.cssText="flex:1 0 100%;min-width:0",V.hidden=!0,G.prepend(V)),S.append(le,G);let Ne=()=>{if(V){let o=!V.childElementCount&&!V.textContent?.trim();V.hidden!==o&&(V.hidden=o)}let e=ne??G,t=[...e.children].every(o=>o===u?!u.textContent:o.hidden),n=[...e.children].some(o=>o===k?!1:o===u?!!u.textContent:!o.hidden);e.style.cssText=t?D.controls.replace(/padding:[^;]+/,"padding:0"):n?`${D.controls};${D.pinned}`:D.controls,Me()},it=typeof MutationObserver>"u"?void 0:new MutationObserver(Ne);it?.observe(S,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let Pe=h.document.presentation,qt=Object.entries(h.document.buttons).filter(([,e])=>e.type==="close").map(([e])=>e),$,ot,_e=!1,at=JSON.stringify(h.capabilities),st=e=>oe&&!he?Object.entries(e.document.buttons).filter(([,t])=>t.type==="checkout").map(([t])=>t):nt(e);function ke(e){if(y)return;h=e;let t=JSON.stringify(e.capabilities);t!==at&&($?.updateCapabilities(pe(e),st(e)),at=t),Ht(e),ye()}let E,Ue=0;function Me(){let e=p.defaultView;if(!E?.responsive||!e)return;let t=ne??G,n=e.innerHeight-(E.type==="modal"?32:0);t.style.maxHeight=`${Math.max(1,n)}px`,t.style.overflowY="auto",t.style.flexShrink="0",Ue=Math.max(1,n-t.getBoundingClientRect().height),$?.resizeViewport?.(Ue,e.innerWidth)}let y=!1,oe=!1,C=null,qe,Ee=!1,ct=!1,ae=!1,Ve,$e=!1,X,ne;function Vt(){return oe||y||X||$e?{type:"recover",operationId:r.operation?.operationId??r.quote?.operationId??null,requestId:null}:Je(r)}let A=()=>!y&&!Ee&&!X&&i.canInteract?.()!==!1,H,ue=!1,d=null,Z=null,He="",se=()=>i.checkoutNavigation==="after_confirmation"&&!!(i.terminateCheckout||i.resumeCheckout),me={},he,W=null;function ye(){if(!se()||!$?.updateCheckoutControls)return;let e=r.quote,t=!W&&!!e&&!!r.operation&&B(r.operation).type==="checkout",n=Object.entries(h.document.buttons).flatMap(([o,c])=>c.type==="checkout"?[{actionId:o,policy:c}]:[]);$.updateCheckoutControls({actions:n.map(({actionId:o})=>o),resume:t?n.filter(({actionId:o,policy:c})=>Ae(e,h,o,c.product,me)).map(({actionId:o})=>o):[],resumeLabel:a?"\u7EE7\u7EED\u4ED8\u6B3E":"Continue checkout",busy:he})}function lt(){Z?.remove(),Z=null}async function Be(){if(W)return;if(i.resumeCheckout&&r.operation){await i.resumeCheckout(r.operation.operationId);return}let e=await r.read();if(B(e).type!=="checkout")return _(e,!1);A()&&(xe.delete(e.operationId),await Re(e))}function ut(){u.textContent=a?"\u6682\u65F6\u65E0\u6CD5\u6253\u5F00\u4ED8\u6B3E\u9875\u9762\u3002\u8BF7\u91CD\u8BD5\u3002":"Couldn\u2019t open checkout. Try again.",g.hidden=!0}async function dt(e=!1){let t=W;if(!t)return;g.hidden=!0;let n=Date.now()+2e4;for(;A();){let o=await r.read();if(o.operationId!==t.operationId)throw new v("PURCHASE_PENDING","The original Checkout changed");if(!A())break;let c=B(o);if(c.type==="native"){W=null,lt(),C=t.selection,H=t.coupon,ue=!1,await ge();return}if(c.type==="complete"||c.type==="fulfillment"||c.type==="recording"){W=null,await _(o,!1);return}if(e&&c.type==="checkout"){e=!1;try{await i.terminateCheckout(t.operationId)}catch(w){q(i.onError,w)}}if(Date.now()>=n)break;await Xe(1e3,p,te.signal)}y||ut()}async function $t(e,t,n){W={operationId:e,selection:t,coupon:n};let o=!1;try{await i.terminateCheckout(e)}catch(c){if(c instanceof v&&["CAPABILITY_UNAVAILABLE","NOT_CONFIGURED"].includes(c.code)){W=null,u.textContent=a?"\u8BF7\u7EE7\u7EED\u539F\u8BA2\u5355\uFF0C\u6216\u7B49\u5F85\u5B83\u8FC7\u671F\u540E\u518D\u66F4\u6362\u65B9\u6848\u3002":"Continue your original checkout, or wait for it to expire before changing plans.",q(i.onError,c);return}o=c instanceof v&&(c.status??0)>=500,q(i.onError,c)}A()&&await dt(o)}function Fe(e,t,n,o,c){let w=pe(e).checkoutCoupons?.[t],l=w?w.products[n]:i.claimCoupon&&c?gt(e.capabilities,c,o):void 0;return l?.couponId&&l.planVersionId===n?{id:l.couponId,offerId:l.offerId}:void 0}function Ht(e){oe||C||r.quote||r.operation||He&&u.textContent===He||(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 xe=new Map,Ie=!1;function Ae(e,t,n,o,c,w){let l=e.lines.length===1?e.lines[0]:void 0,s=ce(o,c,t.capabilities);if(!l||!s||l.productVersionId!==s)return!1;let L=Fe(t,n,s,c,w);if((L||pe(t).checkoutCoupons?.[n])&&(L?.id??null)!==(e.discount?.couponId??null))return!1;let U;try{U=ve(t.document.screen,s,c,t.capabilities)}catch{return!1}let ie=Object.fromEntries((l.prepaid??[]).map(z=>[z.internal_feature_id,z.quantity]));return[...new Set([...Object.keys(U),...Object.keys(ie)])].every(z=>(U[z]??0)===(ie[z]??0))}let B=e=>bt({quote:r.quote,operation:e,requestId:null,pending:!1,destroyed:y,canReselect:r.canReselect});async function Re(e){let t=e.merchantExecution;if(!(!A()||!e.checkoutUrl||i.checkoutNavigation==="after_confirmation"&&B(e).type!=="checkout"||t?.type==="purchase"&&!["not_started","pending"].includes(t.paymentStatus)||xe.get(e.operationId)===e.checkoutUrl)){xe.set(e.operationId,e.checkoutUrl);try{i.onCheckoutUrl?await i.onCheckoutUrl(e.checkoutUrl):p.defaultView?.location.assign(e.checkoutUrl)}catch(n){throw xe.delete(e.operationId),n}}}let re=(e,t=!1)=>{if(e instanceof Ke)d=null,u.textContent=e.customerMessage(a);else if(Dt(e))d=null,u.textContent=t?a?"\u5F53\u524D\u65E0\u6CD5\u5728\u6B64\u8D2D\u4E70\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002\u8BF7\u8054\u7CFB\u5546\u6237\u3002":"Purchases aren\u2019t available here right now. Payment hasn\u2019t started. Contact the merchant for help.":tt(e,a);else if(t){let n=e instanceof v?e.code:void 0;n==="CAPABILITY_UNAVAILABLE"||n==="NOT_CONFIGURED"?(d=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."):r.canReselect===!0&&!C?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 v&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?tt(e,a):e instanceof v?e.message:a?"\u64CD\u4F5C\u672A\u5B8C\u6210\uFF0C\u8BF7\u91CD\u8BD5\u3002":"This action couldn\u2019t be completed. Try again.";g.hidden=d===null,He=u.textContent,t&&!E?.responsive&&u.scrollIntoView?.({block:"nearest"}),q(t&&R?.quoteError?R.quoteError:i.onError,e)},Se=new WeakMap;function Te(e){oe=e,g.disabled=e,$?.updateCapabilities?.(pe(h),st(h));for(let t of Z?.querySelectorAll("button")??[])e?(Se.set(t,t.disabled),t.disabled=!0):Se.has(t)&&(t.disabled=Se.get(t),Se.delete(t)),et(t)}function je(){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 Bt(e){if(i.beforeAction)try{await i.beforeAction()}catch(t){throw t instanceof Ke?(C=null,ue=!1,d=null):d=e,t}}async function M(e,t){if(oe||y)return;if(!A()){je();return}let n=e===ge,o=n?Mt:Ut,c=se()&&t!==void 0;he=c?t:void 0,Te(!0),ye(),g.hidden=!0,u.textContent=c?"":o;try{if((e!==Be||!i.resumeCheckout)&&await Bt(e),y)return;if(!A()){d=e,g.hidden=!1,je();return}await e()}catch(w){y||re(w,n&&!c)}finally{he=void 0,Te(!1),ye(),u.textContent===o&&(u.textContent="")}}async function Ft(e){await Nt(K,e,i)}function ft(e){return Je(r).type==="recording"||B(e).type==="recording"}function pt(e){let t=e.merchantTerms,n=t?.subscriptionTerms?.items??[],o=t?t.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),c=t?n.length===1&&n[0]?.amountMinor===o&&n[0]:e.lines.length===1&&e.lines[0]?.catalogAmountMinor===o&&e.lines[0],w=o===null?fe(t.subtotalMinor-t.discountMinor,e.currency)+(a?" + \u5F85\u786E\u8BA4\u7A0E\u8D39":" + tax confirmed at checkout"):fe(o,e.currency)+(c?Ce(c.interval,a?"zh-CN":"en",c.intervalCount??1):""),l=e.lines.map(s=>s.productName).join(", ");return{label:l?`${l} \xB7 ${w}`:w,recurring:c}}async function _(e,t=i.checkoutNavigation!=="after_confirmation"){if(y)return;if(!A()){d=async()=>_(await r.read()),g.hidden=!1;return}if(u.textContent=Lt(e.status,a),ft(e)){let s=e.merchantExecution?.type==="purchase"&&e.merchantExecution.recordingStatus==="failed";u.textContent=s?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.",g.textContent=a?"\u67E5\u8BE2\u8BB0\u5F55":"Check recording",d=async()=>_(await r.read()),g.hidden=!1;return}if(e.problem){let s=e.problem;d=we,g.textContent=a?"\u68C0\u67E5\u5E76\u6062\u590D\u539F\u64CD\u4F5C":"Check and recover original purchase",re(new v(s.code,s.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.":s.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.":s.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.":s.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,s));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"){d=null,await Ft(e);return}if(e.status!=="pending"){if(r.canReselect===!1){u.textContent=a?"\u6B63\u5728\u6838\u5BF9\u539F\u8D2D\u4E70\u7ED3\u679C":"Checking the original purchase result",g.textContent=a?"\u67E5\u8BE2\u7ED3\u679C":"Check result",d=async()=>_(await r.read()),g.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."),g.textContent=a?"\u91CD\u8BD5":"Retry",d=null,C=null;return}if(!t&&B(e).type==="checkout"){if(W){ut();return}if(se()){u.textContent="",Ie=!1,d=null,ye();return}let s=r.quote,L=s?.operationId===e.operationId?pt(s).label:"";u.textContent=Ie?L?a?`${L} \u5C1A\u672A\u4ED8\u6B3E\u3002\u518D\u6B21\u9009\u62E9\u8BE5\u65B9\u6848\u5373\u53EF\u7EE7\u7EED\u4ED8\u6B3E\u3002`:`${L} 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.":"",Ie=!1,d=null;return}await Re(e);let n=Date.now(),o=n+6e5,c=2e3,w=!e.checkoutUrl,l=()=>w&&Date.now()-n<15e3;_e=!0,q(i.onObservationChange,!0);try{for(;!y&&Date.now()<o;){if(await Xe(l()?700:c,p,te.signal),y)return;if(!A()){d=async()=>_(await r.read()),g.hidden=!1;return}let s=await r.read();if(s.checkoutUrl&&(w=!1),!t&&B(s).type==="checkout"){await _(s,!1);return}if(!s.problem&&s.status==="pending"&&await Re(s),s.status!=="pending"||s.problem||ft(s)){await _(s);return}l()||(c=Math.min(c*1.5,3e4))}}finally{_e=!1,q(i.onObservationChange,!1)}d=async()=>_(await r.read()),g.hidden=!1}async function Qe(e=!1){let t=await r.read();if(y)return;if(!A()){d=()=>Qe(e),g.hidden=!1;return}let n=r.quote;if(n&&Pt(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&&!r.pendingCancellation){mt(n);return}await _(t,e||void 0)}async function we(){lt(),d=we;let e=await r.confirm();if(!A()){d=we,g.hidden=!1;return}if(e.problem){await _(e);return}if(e.status==="pending"){if(e.checkoutUrl)await Re(e);else if(e.execution&&e.execution.provider!=="merchant"||e.nativePurchase){if(!i.onPurchase)throw new v("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await i.onPurchase({operation:e,signal:te.signal})}}d=async()=>_(await r.read()),await _(e,!0)}function mt(e){Z?.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=p.createElement("div"),o=p.createElement("button"),c=p.createElement("button"),w=p.createElement("div"),l=p.createElement("p"),s=e.merchantTerms,L=a?"zh-CN":"en",U=s?.subscriptionTerms?.items??[],ie=s?s.subscriptionTerms?.trial?.days:e.lines.find(f=>f.trial)?.trial?.days,ee=ie===void 0?null:s?s.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(f=>f.trial)?0:null,z=(f,b)=>a?`${b} \u5929\u8BD5\u7528\u7ED3\u675F\u540E ${f}`:`Then ${f} after the ${b}-day trial`,{label:ze,recurring:ht}=pt(e),jt=e.lines.map(f=>f.productName).join(", "),yt=ee===null?"":`${a?"\u4ECA\u5929\u5E94\u4ED8":"Due today"} ${fe(ee,e.currency)}`;l.textContent=yt?[jt,yt].filter(Boolean).join(" \xB7 "):ze,o.textContent=a?"\u786E\u8BA4\u8D2D\u4E70":"Confirm purchase",o.disabled=t,c.textContent=a?"\u53D6\u6D88":"Cancel",n.style.cssText=D.panel,l.style.cssText=D.summary,w.style.cssText=D.actions,o.style.cssText=D.primary,c.style.cssText=D.secondary,et(o),o.onclick=()=>{M(we)};let wt=async()=>{let f=await r.cancel();y||(n.remove(),Z=null,await _(f))};c.onclick=()=>{d=wt,M(wt)};let F=p.createElement("div");if(F.style.cssText=D.terms,s){for(let b of U){if(ee===null&&b===ht)continue;let T=p.createElement("p"),Y=fe(b.amountMinor,e.currency)+Ce(b.interval,L,b.intervalCount);T.textContent=ee!==null&&ie!==void 0?z(Y,ie):Y,F.append(T)}let f=s.subscriptionTerms?.trial;if(f){let b=p.createElement("p");b.textContent=a?`\u8BD5\u7528 ${f.days} \u5929\uFF1B${f.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${f.days}; ${f.cardRequired?"a payment method is required":"no payment method is required"}`,F.append(b)}for(let b of[...s.expectedEffects.map(T=>T.description),...s.requiredConsents.map(T=>T.summary)]){let T=p.createElement("p");T.textContent=b,F.append(T)}}else{for(let f of e.lines){if(ee!==null||f!==ht){let b=p.createElement("p"),T=`${fe(f.catalogAmountMinor,e.currency)}${Ce(f.interval,L,f.intervalCount??1)}`;b.textContent=ee!==null&&f.trial?(e.lines.length>1?`${f.productName} \xB7 `:"")+z(T,f.trial.days):`${f.productName} \xB7 ${T}`,F.append(b)}for(let b of f.prepaid??[]){let T=p.createElement("p"),Y=r.view?.capabilities.plans[f.productVersionId]?.prepaid?.find(Qt=>Qt.internalFeatureId===b.internal_feature_id);T.textContent=`${Y?.name??b.internal_feature_id} \xB7 ${b.quantity} ${a?"\u4EFD":"packs"} \xD7 ${b.terms.units}`,Y&&(T.textContent+=Ce(Y.reset==="week"||Y.reset==="month"||Y.reset==="year"?Y.reset:"one_time",L,Y.resetCount)),F.append(T)}if(f.trial){let b=p.createElement("p");b.textContent=a?`\u8BD5\u7528 ${f.trial.days} \u5929\uFF1B${f.trial.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${f.trial.days}; ${f.trial.cardRequired?"a payment method is required":"no payment method is required"}`,F.append(b)}}if(!e.charge){let f=p.createElement("p");f.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.",F.append(f)}}for(let f of F.children)f.style.margin="0";w.append(o,c),n.append(l,...F.childElementCount?[F]:[],w),G.prepend(n),E?.responsive||n.scrollIntoView?.({block:"nearest"}),o.focus({preventScroll:!0}),Z=n,d=null}async function ge(){if(!C)return;if(d=ge,!ue){let n=r.view,o=n?.document.buttons[C.actionId],c=n&&o?.type==="checkout"?ce(o.product,C.selection,n.capabilities):null;if(!n||!c)throw new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let w=H?.offerId;if(H&&!w){if(!i.claimCoupon)throw new v("CAPABILITY_UNAVAILABLE","Coupon claiming is unavailable");let{offer:l}=await i.claimCoupon(H.id,C.requestId);if(y)return;if(!l||l.couponId!==H.id||l.status!=="issued"||!(Date.parse(l.expiresAt)>Date.now()))throw C=null,H=void 0,d=async()=>{ke(await r.refresh()),d=null},new v("COUPON_UNAVAILABLE","This Coupon is no longer available for this purchase");w=l.id}if(!H&&!n.document.screen.actions.some(l=>l.id===C?.actionId&&typeof l.properties.couponBinding=="string")&&(w=await i.resolveOfferId?.({actionId:C.actionId,productVersionId:c,featureQuantities:ve(n.document.screen,c,C.selection,n.capabilities)})),y)return;w!==void 0&&(C.offerId=w),ue=!0}if(!A()){g.hidden=!1;return}let e;try{e=await r.preview(C)}catch(n){throw r.canReselect===!0&&(C=null,ue=!1,H=void 0,d=null),n}if(H&&(e.discount?.couponId!==H.id||e.discount.offerId!==C.offerId))throw new v("INVALID_RESPONSE","The quote did not apply the Coupon selected on this Paywall");if(y)return;let t=e.merchantTerms;if(i.confirmOnHostedCheckout&&A()&&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=he?"":a?"\u6B63\u5728\u6253\u5F00\u6536\u94F6\u53F0\u2026":"Opening checkout\u2026";u.textContent=n;try{await we()}catch(o){y||re(o)}finally{u.textContent===n&&(u.textContent="")}return}mt(e)}function de(e="destroy"){if(y)return;y=!0;let t=qe;qe=void 0,q(t),i.signal?.removeEventListener("abort",J),r.signal?.removeEventListener("abort",J),x.finish("dismissed"),ot?.(),te.abort(),it?.disconnect(),E?.destroy(),$?.destroy(),r.destroy(),I.open&&I.close(),I.remove(),S.remove(),P(),e==="dismiss"&&q(i.onDismiss)}N=de;async function Oe(){if(!ae||y||Ee||X==="closing"||!X&&!A())return;if(!R){de("dismiss");return}let e=p.createElement("p");e.setAttribute("role","status"),e.textContent=a?"\u6B63\u5728\u5173\u95ED\u2026":"Closing\u2026",ne||(ne=p.createElement("div"),ne.style.cssText=G.style.cssText,G.replaceWith(ne),le.inert=!0),k.hidden=!1,ne.replaceChildren(e,k),X="closing",k.setAttribute("aria-disabled","true"),k.focus({preventScroll:!0});try{await R.dismiss()}catch(t){y||q(i.onError,t)}y||(X="retry",e.textContent=a?"\u672A\u80FD\u786E\u8BA4\u5173\u95ED\uFF0C\u8BF7\u91CD\u8BD5\u3002":"Could not confirm closure. Try again.",k.textContent=a?"\u91CD\u8BD5\u5173\u95ED":"Retry closing",k.removeAttribute("aria-label"),k.removeAttribute("aria-disabled"))}k.onclick=()=>{Oe()},I.addEventListener("cancel",e=>{e.preventDefault(),Oe()}),g.onclick=()=>{d&&M(d)};function Ge(e){x.finish("error",e),de()}function We(){if(!(!ct||ae||y||Ee||E&&!A()))try{let e=t=>{i.focusAtReveal&&(P=Ze(p)),$?.setHidden?.(!1),Ve?.(),E&&(I.showModal(),E.responsive&&I.focus({preventScroll:!0}),!t&&i.loading!=="host"&&xt(I,E.type,E.responsive)),ae=!0};R?R.present(()=>x.present(()=>e(!0))):x.present(e)}catch(e){Ge(e),re(e)}}try{if(Pe.type==="inline"?(Ne(),Ve=St(S,O),O.append(S)):(I.setAttribute("aria-label",h.document.name),k.textContent="\xD7",k.setAttribute("aria-label",a?"\u5173\u95ED":"Close"),It(k,h.document.screen.theme),k.hidden=kt(h.document),I.append(k,S),O.append(I),E=Et(I,{...h.document.screen,presentation:Pe},Me),E.latch(),E.responsive&&(S.style.display="flex",S.style.flexDirection="column",S.style.maxHeight="100%",le.style.overflow="clip",le.style.minHeight="0"),Ve=Rt(I)),Le&&V){let n=Le(V);if(typeof n=="function"&&(y?q(n):qe=n),y)throw new DOMException("Presentation cancelled","AbortError");Ne()}$=Q(le,{mode:"live",rendererUrl:r.webViewUrl,title:h.document.name,closeActions:qt,onAuthoredClose(n){X||y||(k.hidden=n)},hostPresentation:()=>E?.type??Pe.type,reportContentHeight:E?.responsive,onResize:n=>{if(!E?.responsive)return;let o=Math.min(n,Ue);le.style.height=`${o}px`,E.setContentHeight(o+(ne??G).getBoundingClientRect().height)},onSelection(n){me=n,ye()},onAction(n,o={},c,w){if(!ae||y||X)return;let l=r.view,s=l?.document.buttons[n];if(!s)return;if(s.type==="close"&&R&&i.resumeCheckout&&r.operation&&Ct(B(r.operation))){Oe();return}if(oe)return;if(!A()){je();return}if(s.type==="close"){M(async()=>{await i.onAction?.(n),de(i.onAction?"action":"dismiss")});return}if(s.type==="action"){d=async()=>{if(s.action.type==="event"){if(!i.onEvent)throw new v("EVENT_HANDLER_REQUIRED","Provide the event handler");await i.onEvent(s.action.event)}else i.onOpenUrl?await i.onOpenUrl(s.action.url):p.defaultView?.location.assign(s.action.url);await i.onAction?.(n),d=null},M(d);return}if(i.allowNewPurchase===!1){se()&&l&&r.quote&&r.operation&&B(r.operation).type==="checkout"&&Ae(r.quote,l,n,s.product,o,w)?M(Be,n):u.textContent=a?"\u5F53\u524D\u53EA\u80FD\u7EE7\u7EED\u539F\u8BA2\u5355\u3002":"Only your original checkout is available.";return}if(Z&&r.canReselect===!1){u.textContent=a?"\u8BF7\u5148\u786E\u8BA4\u6216\u53D6\u6D88\u5F53\u524D\u8D2D\u4E70\u3002":"Confirm or cancel the current purchase first.",E?.responsive||Z.scrollIntoView?.({block:"nearest"}),Z.querySelector("button")?.focus({preventScroll:!0});return}if(se()&&W){W.selection.actionId===n&&M(()=>dt(!0),n);return}if(se()&&i.terminateCheckout&&l&&r.quote&&r.operation&&r.canReselect===!1&&B(r.operation).type==="checkout"){if(Ae(r.quote,l,n,s.product,o,w)){M(Be,n);return}let U=ce(s.product,o,l.capabilities);try{if(!U)throw new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");ve(l.document.screen,U,o,l.capabilities)}catch(ze){re(ze);return}let ie=r.operation.operationId,ee={actionId:n,requestId:crypto.randomUUID(),selection:structuredClone(o)},z=Fe(l,n,U,o,w);M(()=>$t(ie,ee,z),n);return}if((r.quote||C)&&r.canReselect===!1){let U=!!l&&!!r.quote&&Ae(r.quote,l,n,s.product,o,w);Ie=!!r.quote&&!U,d=r.quote?()=>Qe(U):ge,M(d);return}let L=l&&ce(s.product,o,l.capabilities);if(!l||!L){re(new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(i.onPurchaseIntent){d=null,M(async()=>{let U={actionId:n,productVersionId:L,selection:structuredClone(o),featureQuantities:ve(l.document.screen,L,o,l.capabilities)};$e=!0,await i.onPurchaseIntent(U)});return}if(C&&C.actionId!==n){re(new v("COMMAND_PENDING","Finish the current purchase"));return}C||(H=Fe(l,n,L,o,w),C={requestId:crypto.randomUUID(),actionId:n,selection:structuredClone(o)},ue=!1),M(ge,n)},onEscape:()=>{Oe()},onError:n=>{let o=new Error(n);!ae&&!y&&Ge(o),re(o)},onRendered:n=>{n&&I.setAttribute("aria-label",n),ct=!0,We()}}),$.setHidden?.(!0),Me();let e=se()&&!!r.quote&&!!r.operation&&B(r.operation).type==="checkout";me=e?_t(h,r.quote)??{}:{},$.update(h.document.screen,rt,{capabilities:pe(h),unavailableActions:nt(h),serverInput:{bindings:[],answers:{}},...Object.keys(me).length?{selection:me}:{}}),ot=r.subscribe?.(ke),ke(r.view??h),await x.wait($.ready);let t=r.operation;!e&&(r.quote||t&&(t.confirmedAt||t.checkoutUrl||t.status==="complete"))&&(d=()=>Qe(),M(d))}catch(e){throw Ge(e),e}return{check:K,host:{get observing(){return _e},get recovery(){return Vt()},async prepareFallback(){if(oe||y||X||$e)return{type:"recover",operationId:r.operation?.operationId??r.quote?.operationId??null,requestId:null};Te(!0);try{let e=await vt(r);return e.type==="native"&&de(),e}finally{Te(!1)}},setSuspended(e){Ee=e,S.hidden=e,e&&I.open?I.close():!e&&!ae?We():!e&&!y&&ae&&Pe.type!=="inline"&&!I.open&&I.showModal()},destroy:de,refresh:async()=>{if(!A()){if(r.view)return r.view;throw new v("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await r.refresh();return ke(e),We(),e}}}}export{Pn as showPaywall};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as a}from"./chunk-X6ONZGRY.js";import"./chunk-EREQZWGI.js";import"./chunk-P23JOPR5.js";import"./chunk-IOJVF52Q.js";import"./chunk-U7GH4VME.js";import"./chunk-33ZVZOSC.js";import"./chunk-PZOQV6MU.js";import"./chunk-FCDWCQYC.js";import"./chunk-XDOKFAE6.js";import"./chunk-Y6HL2IY2.js";import"./chunk-LSPHUA7V.js";import"./chunk-OOD2VDDP.js";import"./chunk-WLGLQJ6M.js";import"./chunk-RULQQ7WI.js";import"./chunk-3VUPVXAV.js";import"./chunk-RV6UAUK2.js";import"./chunk-RGEBK6UF.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as readPaywallContent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a}from"./chunk-C3GYAKIU.js";import"./chunk-5DZJCFNQ.js";import"./chunk-YLPQLD2A.js";import"./chunk-POCDWUD3.js";import"./chunk-ORMQJAQE.js";import"./chunk-RFNIGJOL.js";import"./chunk-7QDT6DO7.js";import"./chunk-6PG3AS3G.js";import"./chunk-X6ONZGRY.js";import"./chunk-EREQZWGI.js";import"./chunk-P23JOPR5.js";import"./chunk-IOJVF52Q.js";import"./chunk-U7GH4VME.js";import"./chunk-3NCMYTNG.js";import"./chunk-33ZVZOSC.js";import"./chunk-VOKEZHAH.js";import"./chunk-57GPGWSK.js";import"./chunk-PZOQV6MU.js";import"./chunk-FCDWCQYC.js";import"./chunk-XDOKFAE6.js";import"./chunk-Y6HL2IY2.js";import"./chunk-LSPHUA7V.js";import"./chunk-OOD2VDDP.js";import"./chunk-WLGLQJ6M.js";import"./chunk-RULQQ7WI.js";import"./chunk-3VUPVXAV.js";import"./chunk-RV6UAUK2.js";import"./chunk-RGEBK6UF.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.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-BYP4KVB3.js";import"./chunk-P6C3PNMQ.js";import"./chunk-XDOKFAE6.js";import"./chunk-Y6HL2IY2.js";import"./chunk-LSPHUA7V.js";import"./chunk-OOD2VDDP.js";import"./chunk-WLGLQJ6M.js";import"./chunk-RULQQ7WI.js";import"./chunk-RGEBK6UF.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.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.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-QZTTKH2H.js";import"./chunk-ASDJTOGM.js";import{a as A}from"./chunk-C3GYAKIU.js";import{e as P}from"./chunk-5DZJCFNQ.js";import"./chunk-YLPQLD2A.js";import{h as b,i as x,k as L}from"./chunk-AZFWG352.js";import{F as C}from"./chunk-4TEZZZYK.js";import"./chunk-POCDWUD3.js";import"./chunk-ORMQJAQE.js";import"./chunk-RFNIGJOL.js";import"./chunk-7QDT6DO7.js";import"./chunk-6PG3AS3G.js";import"./chunk-X6ONZGRY.js";import"./chunk-EREQZWGI.js";import"./chunk-P23JOPR5.js";import"./chunk-IOJVF52Q.js";import"./chunk-U7GH4VME.js";import"./chunk-3NCMYTNG.js";import"./chunk-33ZVZOSC.js";import"./chunk-VOKEZHAH.js";import"./chunk-57GPGWSK.js";import"./chunk-PZOQV6MU.js";import"./chunk-FCDWCQYC.js";import"./chunk-XDOKFAE6.js";import"./chunk-Y6HL2IY2.js";import"./chunk-LSPHUA7V.js";import{b as R}from"./chunk-OOD2VDDP.js";import{a as r}from"./chunk-WLGLQJ6M.js";import"./chunk-RULQQ7WI.js";import"./chunk-3VUPVXAV.js";import"./chunk-RV6UAUK2.js";import"./chunk-RGEBK6UF.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.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-BYP4KVB3.js";import"./chunk-P6C3PNMQ.js";import"./chunk-XDOKFAE6.js";import"./chunk-Y6HL2IY2.js";import"./chunk-LSPHUA7V.js";import"./chunk-OOD2VDDP.js";import"./chunk-WLGLQJ6M.js";import"./chunk-RULQQ7WI.js";import"./chunk-RGEBK6UF.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.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.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as pn}from"./chunk-
|
|
1
|
+
import{a as pn}from"./chunk-IJKAQNK6.js";import{a as I}from"./chunk-67AY54E2.js";import{a as fn,b as hn,c as gn,d as yn}from"./chunk-YY445FBU.js";import{a as xt}from"./chunk-C3GYAKIU.js";import{a as Ue,b as Ve,c as qe,d as He,e as m}from"./chunk-5DZJCFNQ.js";import"./chunk-YLPQLD2A.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-AZFWG352.js";import{A as Tt,C as V,D as N,a as Oe,e as ft,f as ht,l as gt,m as z,n as St,q as Ct,r as Rt,s as bt,t as At,u as Ot,z as pe}from"./chunk-4TEZZZYK.js";import{c as h}from"./chunk-POCDWUD3.js";import"./chunk-ORMQJAQE.js";import"./chunk-RFNIGJOL.js";import{a as Et,b as _e}from"./chunk-7QDT6DO7.js";import{A as tt,B as Se,C as ie,E as se,F as Ce,K as j,M as ce,N as nt,P as Ee,Q as rt,R as ot,d as Ge,e as je,h as we,p as ze,q as Ke,s as an,t as sn,w as cn,x as X,y as W,z as oe}from"./chunk-6PG3AS3G.js";import"./chunk-X6ONZGRY.js";import"./chunk-EREQZWGI.js";import{e as at}from"./chunk-P23JOPR5.js";import{$ as mt,A as it,B as Re,C as st,D as ct,I as ut,J as dt,K as be,L as Ae,T as pt,U as de,V as Z,W as lt,d as ve,f as Ze,g as et,u as q}from"./chunk-IOJVF52Q.js";import"./chunk-U7GH4VME.js";import"./chunk-3NCMYTNG.js";import"./chunk-33ZVZOSC.js";import"./chunk-VOKEZHAH.js";import"./chunk-57GPGWSK.js";import"./chunk-PZOQV6MU.js";import{a as Ne,b as Le}from"./chunk-FCDWCQYC.js";import{$ as ue,J as Xe,M as We}from"./chunk-XDOKFAE6.js";import{i as un,k as $e,l as Qe,m as Je}from"./chunk-Y6HL2IY2.js";import{c as Ie}from"./chunk-LSPHUA7V.js";import{b as Y}from"./chunk-OOD2VDDP.js";import{a as c}from"./chunk-WLGLQJ6M.js";import"./chunk-RULQQ7WI.js";import"./chunk-3VUPVXAV.js";import"./chunk-RV6UAUK2.js";import{b as u}from"./chunk-RGEBK6UF.js";import{a as Ye}from"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.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-OJM6ORHE.js";import{a as Ve,b as ce,c as de,d as ue}from"./chunk-SLUA7ABW.js";import{b as le}from"./chunk-J6KIN4RH.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-OJM6ORHE.js";import{a as Ve,b as ce,c as de,d as ue}from"./chunk-SLUA7ABW.js";import{b as le}from"./chunk-J6KIN4RH.js";import{a as J,b as F,c as ge,e as me}from"./chunk-2DPNSTCN.js";import{a as re,b as ae,c as se,d as oe}from"./chunk-C2KT5ZFU.js";import"./chunk-3VUPVXAV.js";import"./chunk-RV6UAUK2.js";import{b as o}from"./chunk-RGEBK6UF.js";import{c as te,e as ie,g as M}from"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tinkerlandai/longplay-sdk",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.40",
|
|
4
4
|
"description": "Framework-independent Longplay SDK for customer identity, entitlements, credits, offers and growth surfaces.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -60,12 +60,6 @@
|
|
|
60
60
|
"import": "./dist/visual.js"
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
|
-
"scripts": {
|
|
64
|
-
"build": "tsup",
|
|
65
|
-
"prepack": "pnpm run build",
|
|
66
|
-
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
|
|
67
|
-
"lint": "node ../../scripts/ci/lint.mjs --workspace packages/sdk"
|
|
68
|
-
},
|
|
69
63
|
"dependencies": {
|
|
70
64
|
"@ai-sdk/provider": "4.0.26",
|
|
71
65
|
"@types/json-schema": "7.0.15",
|
|
@@ -75,13 +69,13 @@
|
|
|
75
69
|
"zod": "4.6.6"
|
|
76
70
|
},
|
|
77
71
|
"devDependencies": {
|
|
78
|
-
"@indiana/contracts": "workspace:*",
|
|
79
72
|
"@openrouter/sdk": "^1.4.25",
|
|
80
73
|
"@types/css-tree": "^3.2.0",
|
|
81
74
|
"ai": "7.0.136",
|
|
82
75
|
"tsup": "^8.5.1",
|
|
83
76
|
"typescript": "^5.9.3",
|
|
84
|
-
"whatwg-url-minimum": "0.2.0"
|
|
77
|
+
"whatwg-url-minimum": "0.2.0",
|
|
78
|
+
"@indiana/contracts": "0.1.0"
|
|
85
79
|
},
|
|
86
80
|
"peerDependencies": {
|
|
87
81
|
"@openrouter/sdk": "^1.4.25"
|
|
@@ -90,5 +84,10 @@
|
|
|
90
84
|
"@openrouter/sdk": {
|
|
91
85
|
"optional": true
|
|
92
86
|
}
|
|
87
|
+
},
|
|
88
|
+
"scripts": {
|
|
89
|
+
"build": "tsup",
|
|
90
|
+
"typecheck": "tsc --noEmit && tsc --noEmit -p tsconfig.test.json",
|
|
91
|
+
"lint": "node ../../scripts/ci/lint.mjs --workspace packages/sdk"
|
|
93
92
|
}
|
|
94
|
-
}
|
|
93
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b}from"./chunk-6WEHTOED.js";import"./chunk-BDC7B4KM.js";import"./chunk-UD7XPHE4.js";import"./chunk-K3VQKR4G.js";import"./chunk-O5VA3E5D.js";import"./chunk-Q7K66FTS.js";import"./chunk-42UXYMRZ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as validateEntitlementCheck,b as validateResourceCheck};
|
package/dist/chunk-2LND3R7K.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as e}from"./chunk-42UXYMRZ.js";var c=e.enum(["replace","stack_native"]);export{c as a};
|
package/dist/chunk-DSLJUN3P.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as Re}from"./chunk-DK5PHPSO.js";import{a as G}from"./chunk-IV6LKRYM.js";import{A as _e,E as W,G as ke,d as Pe,f as x,k as Se,v as Ee,w as be,y as Oe}from"./chunk-G7Y7LPOB.js";import{a as we,b as ge,c as ye}from"./chunk-IHB275C3.js";import{aa as U}from"./chunk-KQF4BVOL.js";import{a as X}from"./chunk-3NCMYTNG.js";import{g as Z}from"./chunk-SY7AYEDO.js";import{b as ve}from"./chunk-WP3SZU24.js";import{b as $}from"./chunk-K3VQKR4G.js";import{a as l}from"./chunk-O5VA3E5D.js";import{b as Ce}from"./chunk-EEYDOVVS.js";import{b as n}from"./chunk-42UXYMRZ.js";import{a as ue}from"./chunk-DSPLGTQI.js";var g=U.options,Ve=n.discriminatedUnion("operation",[g[1].omit({customerToken:!0}),g[2].omit({customerToken:!0}),g[3].omit({customerToken:!0}),g[4].omit({customerToken:!0}),g[5].omit({customerToken:!0}),g[6].omit({customerToken:!0}),g[7].omit({customerToken:!0}),g[8].omit({customerToken:!0}),Se.omit({customerToken:!0})]),ce=n.strictObject({receiptId:n.uuid(),operationId:n.uuid()}),We=n.discriminatedUnion("operation",[n.strictObject({operation:n.literal("find_purchase")}),n.strictObject({operation:n.literal("recover_start"),intent:n.enum(["lookup","resume"]),start:n.strictObject({requestId:g[0].shape.requestId,funnelId:g[0].shape.funnelId,locale:g[0].shape.locale,parameters:g[0].shape.parameters})}),n.strictObject({operation:n.literal("recover_run"),runId:n.uuid(),funnelId:n.uuid()}),n.strictObject({operation:n.literal("recover_purchase"),runId:n.uuid(),funnelId:n.uuid(),purchase:ce}),n.strictObject({operation:n.literal("terminate_checkout"),runId:n.uuid(),funnelId:n.uuid(),purchase:ce}),n.strictObject({operation:n.literal("settle_command"),runId:n.uuid(),funnelId:n.uuid(),requestId:n.uuid(),command:n.discriminatedUnion("operation",[g[3].omit({customerToken:!0}),g[4].omit({customerToken:!0}),g[5].omit({customerToken:!0}),g[6].omit({customerToken:!0}),g[7].omit({customerToken:!0})]).optional()}).refine(a=>!a.command||a.requestId===a.command.requestId),n.strictObject({operation:n.literal("run_command"),runId:n.uuid(),funnelId:n.uuid(),command:Ve})]),ee=n.strictObject({runId:n.uuid(),funnelId:n.uuid(),versionId:n.uuid(),startRequestId:n.uuid(),runExpiresAt:n.iso.datetime({offset:!0}),status:x.shape.run.shape.status}),N={scope:$,customerId:n.uuid()},Fe=n.discriminatedUnion("outcome",[n.strictObject({...N,outcome:n.literal("unknown"),target:n.null(),view:n.null(),access:n.null()}),n.strictObject({...N,outcome:n.literal("resolved"),target:ee,view:x.shape.run.nullable(),access:n.discriminatedUnion("type",[n.strictObject({type:n.literal("customer")}),n.strictObject({type:n.literal("operation_only"),cause:n.enum(["run_terminal","run_expired","run_revoked","issuer_unavailable"])})])})]).superRefine((a,d)=>{a.outcome==="resolved"&&(a.access.type==="customer"!=(a.view!==null)||a.view&&(a.view.id!==a.target.runId||a.view.source.id!==a.target.funnelId||a.view.source.versionId!==a.target.versionId||a.view.status!==a.target.status||a.view.runExpiresAt!==a.target.runExpiresAt||a.view.credentialExpiresAt!==null))&&d.addIssue({code:"custom",message:"Recovery view and original Run binding differ"})}),qe=n.strictObject({...N,target:ee,view:x.shape.run.nullable(),settlement:n.strictObject({requestId:n.uuid(),state:n.enum(["pending","unknown","settled"]),acceptance:n.enum(["accepted","not_accepted","unknown"]),receiptPhase:n.enum(["accepted","processing","done"]).nullable(),basis:n.enum(["receipt","run_terminal","position_advanced","none"]),receiptId:n.uuid().nullable(),operationId:n.uuid().nullable()}),purchase:x.shape.purchase.unwrap().nullable()}).superRefine((a,d)=>{let p=a.settlement;(p.acceptance==="accepted"!=(p.receiptPhase!==null)||p.acceptance==="accepted"&&p.basis!=="receipt"||p.acceptance==="unknown"&&(p.state!=="unknown"||p.basis!=="none")||p.acceptance!=="accepted"&&(p.operationId!==null||p.receiptId!==null)||p.acceptance==="not_accepted"&&(p.state!=="settled"||!["run_terminal","position_advanced"].includes(p.basis))||a.purchase&&(a.purchase.receiptId!==p.receiptId||a.purchase.operation&&a.purchase.operation.operationId!==p.operationId||a.purchase.quote&&a.purchase.quote.operationId!==p.operationId)||a.view&&(a.view.id!==a.target.runId||a.view.source.id!==a.target.funnelId||a.view.source.versionId!==a.target.versionId||a.view.status!==a.target.status||a.view.runExpiresAt!==a.target.runExpiresAt||a.view.credentialExpiresAt!==null))&&d.addIssue({code:"custom",message:"Original command settlement binding differs"})}),Ae=n.strictObject({...N,target:ee,purchase:x.shape.purchase.unwrap()}).superRefine((a,d)=>{(!a.purchase.operation||typeof a.purchase.canReselect!="boolean"||a.purchase.quote&&a.purchase.quote.operationId!==a.purchase.operation.operationId)&&d.addIssue({code:"custom",message:"Original purchase proof is incomplete"})}),Ne=n.discriminatedUnion("outcome",[n.strictObject({...N,outcome:n.literal("none")}),n.strictObject({...N,outcome:n.literal("blocked")}),n.strictObject({...N,outcome:n.literal("found"),target:ee,start:n.strictObject({locale:g[0].shape.locale,parameters:g[0].shape.parameters}),purchase:ce})]);var Ge=U.options[0].refine(a=>!a.customer&&!a.customerData),Me=n.strictObject({receiptId:n.uuid(),operationId:n.uuid(),terminal:n.enum(["complete","native"]).nullable()}),je=n.strictObject({schemaVersion:n.literal(1),baseUrl:n.url(),scope:$,customerId:n.uuid(),sessionId:n.uuid(),start:Ge,allowed:n.array(n.enum(["merchant","record_only","indiana","native"])),run:n.strictObject({id:n.uuid(),versionId:n.uuid(),status:Pe.shape.status,revision:n.number().int().nonnegative(),runExpiresAt:n.iso.datetime({offset:!0}).optional()}).optional(),purchases:n.array(Me).max(100),operationCommand:n.strictObject({operationId:n.uuid(),intent:n.literal("confirm")}).optional(),journal:n.strictObject({revision:n.number().int().nonnegative(),entry:Ee.nullable()})});function Te(a){return Oe({...a,namespace:"purchases",identity:[a.scope.projectId,a.scope.environment,a.customerId]})}function Ue(a){let d=new URL(a.baseUrl??Ce).href,p=()=>new l("PURCHASE_STORAGE_INVALID","Purchase recovery storage is unavailable or invalid; native fallback is not authorized");async function S(){a.assertCurrent();try{let C=await a.storage.read();if(a.assertCurrent(),!Number.isSafeInteger(C.revision)||C.revision<0)throw p();let u=C.entry===null?null:je.parse(C.entry);if(u&&(u.baseUrl!==d||u.customerId!==a.customerId||u.scope.projectId!==a.scope.projectId||u.scope.environment!==a.scope.environment))throw new l("SCOPE_MISMATCH","Purchase recovery belongs to another Customer or environment");if(u?.journal.entry&&(u.journal.entry.scope.projectId!==u.scope.projectId||u.journal.entry.scope.environment!==u.scope.environment||u.journal.entry.funnelId!==u.start.funnelId||u.journal.entry.runId!==u.run?.id||u.journal.entry.versionId!==u.run?.versionId)||u?.operationCommand&&!u.purchases.some(E=>E.operationId===u.operationCommand?.operationId))throw p();return{revision:C.revision,entry:u}}catch(C){throw C instanceof l?C:p()}}async function M(C){for(let u=0;u<8;u++){let E=await S(),O=C(structuredClone(E.entry));if(JSON.stringify(O)===JSON.stringify(E.entry))return O;O&&je.parse(O),a.assertCurrent();let R;try{R=await a.storage.write(E.revision,O)}catch{throw p()}if(a.assertCurrent(),R!==null){if(!Number.isSafeInteger(R)||R<=E.revision)throw p();return O}}throw new l("PURCHASE_STORAGE_CONFLICT","Another consumer changed this purchase; recover the original attempt")}return{read:S,update:M,baseUrl:d}}var ze=5*6e4;function Be(a,d){let p=a.purchases.find(S=>S.type==="checkout");if(!a.actions.includes("continue_checkout")||p?.type!=="checkout"||d!==void 0&&p.operationId!==d)throw new l("PURCHASE_PENDING","No single resumable Checkout is confirmed");return p.checkoutUrl}function Ct(a){let d={...a,scope:{...a.scope},executionPolicy:structuredClone(a.executionPolicy)},p=d.session.snapshot();if(!p)throw new l("CUSTOMER_SESSION_REQUIRED","Purchase recovery requires a verified Customer session");let{customerId:S,sessionId:M}=p,C=!1,u=null,E,O=null,R=!1,q,z,B,k={mode:"idle",status:"idle",actions:["start"],purchases:[]},y=new Map,j=new Map,le=new AbortController,Q=new Set,D=ve(d),de=Re(D.request);function H(e){return{code:e instanceof l?e.code:"PURCHASE_RECOVERY_BLOCKED",message:e instanceof Error?e.message:"The original purchase requires server confirmation",...e instanceof l&&e.status!==void 0?{status:e.status}:{}}}function w(){if(C||d.session.snapshot()?.customerId!==S)throw new l("IDENTITY_CHANGED","The original purchase Customer changed")}let f=Ue({...d,customerId:S,assertCurrent:w,storage:d.storage??Te({baseUrl:d.baseUrl,scope:d.scope,customerId:S})}),xe=d.session.subscribeIdentity(pe);function pe(){C||(C=!0,clearTimeout(B),le.abort(new l("IDENTITY_CHANGED","Purchase consumer was destroyed")),xe(),u?.reset(),u=null,O=null,D.dispose(),Q.clear(),y.clear(),j.clear())}function P(e){w();let t=JSON.stringify(e)!==JSON.stringify(k);k=e,clearTimeout(B),(e.mode==="operation"||e.mode==="run"&&!e.actions.includes("close"))&&["waiting_result","fulfillment","recording"].includes(e.status)&&(B=setTimeout(()=>{T().catch(()=>{})},5e3)),t&&ue(d.onRecovery,structuredClone(e));for(let r of t?Q:[]){if(C)break;ue(r,structuredClone(e))}return structuredClone(e)}function I(e){if(w(),!e||e.start.requestId!==E)throw new l("PURCHASE_STORAGE_CONFLICT","This purchase was superseded; the old consumer cannot dispatch")}function b(e){let t=[...e.purchases],r=e.journal.entry?.purchase;return r&&!t.some(o=>o.operationId===r.operationId)&&t.push({receiptId:r.receiptId,operationId:r.operationId,terminal:null}),t}function A(e){return e.run&&!["running","waiting"].includes(e.run.status)&&!e.journal.entry?.command&&!e.journal.entry?.closeCommand&&!e.operationCommand&&b(e).every(t=>t.terminal!==null)}function _(e,t){let r=e.journal.entry?.command??e.journal.entry?.closeCommand,o=b(e).map(v=>{let se=y.get(v.operationId);return v.terminal&&!se?{type:v.terminal,operationId:v.operationId}:X({quote:se?.quote??null,operation:se??null,requestId:r?.requestId??null,pending:!1,destroyed:!1,canReselect:j.get(v.operationId)===!0})}),c=o.filter(v=>!["complete","native"].includes(v.type)),i=c[0],s=c.length===1&&i?.operationId?y.get(i.operationId):void 0;if(s&&(i?.type==="checkout"||i?.type==="cancel"))try{W({allowed:e.allowed.filter(v=>d.executionPolicy.allowed.includes(v))},s.quote)}catch(v){return{mode:t,status:"blocked",actions:["refresh",...t==="run"&&e.run&&["running","waiting"].includes(e.run.status)?["close"]:[]],purchases:o,error:H(v)}}let m;if(t==="operation"&&!r&&i?.type==="cancel"&&s?.quote&&!s.problem&&!s.confirmedAt)try{W({allowed:e.allowed.filter(v=>d.executionPolicy.allowed.includes(v))},s.quote),Date.parse(s.quote.expiresAt)>Date.now()&&(m={operationId:s.operationId,quote:s.quote})}catch{}let h=o.length>0&&c.length===0,V=A(e)||t==="operation"&&h&&!r&&!e.operationCommand?"complete":i?.type==="checkout"?"checkout":i?.type==="fulfillment"?"fulfillment":i?.type==="recording"?"recording":r||e.operationCommand||i&&i.type!=="cancel"||t==="operation"&&!m?"waiting_result":"ready";return{mode:t,status:V,purchases:o,...m?{confirmation:structuredClone(m)}:{},actions:["refresh",...A(e)?["start"]:[],...t==="run"&&e.run&&["running","waiting"].includes(e.run.status)?["close"]:[],...e.operationCommand?["retry"]:m?["confirm"]:[],...c.length===1&&i?.type==="checkout"?["continue_checkout"]:[]]}}function te(e){let t=X({quote:e?.quote??null,operation:e??null,requestId:null,pending:!1,destroyed:!1,canReselect:e&&j.get(e.operationId)===!0});return t.type==="complete"||t.type==="native"?t.type:null}function ne(e){if(!e.operation)return;let t={...e.operation,...e.operation.quote?{}:e.quote?{quote:e.quote}:{}};if(t.merchantExecution&&t.merchantExecution.customerId!==S)throw new l("SCOPE_MISMATCH","Purchase execution belongs to another Customer");let r=Z(y.get(t.operationId)??null,t);y.set(t.operationId,r),r===t&&j.set(t.operationId,e.canReselect===!0)}async function De(e){w();for(let r of[e.purchase,e.run.paywall])r&&ne(r);let t=await f.update(r=>{if(I(r),r.run&&(r.run.id!==e.run.id||r.run.versionId!==e.run.source.versionId))throw new l("SCOPE_MISMATCH","The original purchase Run changed");let o=b(r);for(let c of[e.purchase,e.run.paywall]){let i=c?.operation?.operationId??c?.quote?.operationId;if(!c||!i)continue;let s=o.find(h=>h.operationId===i);if(s&&s.receiptId!==c.receiptId)throw new l("INVALID_RESPONSE","The original purchase Receipt changed");let m=te(y.get(i));s?s.terminal??=m:o.push({receiptId:c.receiptId,operationId:i,terminal:m})}return{...r,purchases:o,run:r.run&&(r.run.revision>e.run.revision||!["running","waiting"].includes(r.run.status)&&["running","waiting"].includes(e.run.status))?r.run:{id:e.run.id,versionId:e.run.source.versionId,status:e.run.status,revision:e.run.revision,runExpiresAt:e.run.runExpiresAt}}});I(t),t.run&&!["running","waiting"].includes(t.run.status)&&b(t).some(r=>!r.terminal)&&(t=await L(t,!t.journal.entry?.command&&!t.journal.entry?.closeCommand,new Set([e.purchase?.operation?.operationId,e.run.paywall?.operation?.operationId].filter(r=>!!r)))),I(t),P(_(t,"run"))}function He(){return{async read(){let{entry:e}=await f.read();return I(e),structuredClone(e.journal)},async write(e,t){let r=null;return await f.update(o=>{if(I(o),o.operationCommand&&t?.command&&t.command.operation!=="close")throw new l("PURCHASE_PENDING","Recover the original Operation command before dispatching a Run mutation");return r=null,o.journal.revision!==e?o:(r=e+1,{...o,journal:{revision:r,entry:t}})}),r}}}async function L(e,t=!1,r=new Set){I(e);let o=b(e);for(let i of o){if(i.terminal)continue;let s=r.has(i.operationId)?y.get(i.operationId):void 0;if(s??=await oe(e,i),w(),s.operationId!==i.operationId)throw new l("INVALID_RESPONSE","Original Operation changed");if(s.merchantExecution&&s.merchantExecution.customerId!==S)throw new l("SCOPE_MISMATCH","Purchase execution belongs to another Customer");if(t&&!e.operationCommand&&X({quote:s.quote??null,operation:s,requestId:null,pending:!1,destroyed:!1}).type==="cancel"){if({operation:s}=await de.attach({operationId:i.operationId,intent:"cancel"}),w(),s.operationId!==i.operationId)throw new l("INVALID_RESPONSE","Original cancellation Operation changed");s=await oe(e,i)}y.set(i.operationId,Z(y.get(i.operationId)??null,s))}let c=await f.update(i=>{I(i);let s=i.operationCommand&&y.get(i.operationCommand.operationId);return{...i,...s&&(s.confirmedAt||s.merchantExecution||s.status!=="pending")?{operationCommand:void 0}:{},purchases:b(i).map(m=>({...m,terminal:m.terminal??te(y.get(m.operationId))}))}});return I(c),c}async function Y(e){w();let t=await D.request("funnels",e);return w(),t}async function Le(){let e=G(Ne,await Y({operation:"find_purchase"}));if(e.customerId!==S||e.scope.projectId!==d.scope.projectId||e.scope.environment!==d.scope.environment)throw new l("SCOPE_MISMATCH","Recovery Customer or environment changed");if(e.outcome!=="found")return e.outcome;let{target:t,purchase:r}=e;return await f.update(o=>o&&!A(o)?o:{schemaVersion:1,baseUrl:f.baseUrl,scope:d.scope,customerId:S,sessionId:M,start:{operation:"start",requestId:t.startRequestId,funnelId:t.funnelId,...e.start},allowed:[...d.executionPolicy.allowed],run:{id:t.runId,versionId:t.versionId,status:t.status,revision:0,runExpiresAt:t.runExpiresAt},purchases:[{...r,terminal:null}],journal:{revision:0,entry:null}}),"found"}let J;function re(e){let t=J;if(t&&(!t.outcome||e&&t.outcome==="none"&&Date.now()-t.at<ze))return t.job;let r={at:Date.now(),job:Le().then(o=>(r.outcome=o,r.at=Date.now(),o),o=>{throw J===r&&(J=void 0),o})};return J=r,r.job}async function oe(e,t,r="recover_purchase"){let o=G(Ae,await Y({operation:r,runId:e.run.id,funnelId:e.start.funnelId,purchase:{receiptId:t.receiptId,operationId:t.operationId}}));if(ae(e,o),o.purchase.receiptId!==t.receiptId||o.purchase.operation?.operationId!==t.operationId)throw new l("INVALID_RESPONSE","Original purchase reference changed");return ne(o.purchase),y.get(t.operationId)}async function me(e){for(let t of[e.journal.entry?.command,e.journal.entry?.closeCommand]){if(!t)continue;let r=G(qe,await Y({operation:"settle_command",runId:e.run.id,funnelId:e.start.funnelId,requestId:t.requestId,...t.operation==="resume"?{}:{command:t}}));if(ae(e,r),r.settlement.requestId!==t.requestId)throw new l("INVALID_RESPONSE","Original command settlement changed");r.purchase&&ne(r.purchase);let o=await f.update(c=>{I(c);let i=b(c),{receiptId:s,operationId:m}=r.settlement;if(s&&m){let V=i.find(v=>v.operationId===m);if(V&&V.receiptId!==s)throw new l("INVALID_RESPONSE","Original Receipt changed");V||i.push({receiptId:s,operationId:m,terminal:te(y.get(m))})}let h=r.settlement.state==="settled"?be(c.journal.entry,t.requestId):c.journal.entry;return{...c,purchases:i,journal:h===c.journal.entry?c.journal:{revision:c.journal.revision+1,entry:h}}});I(o),e=o}return e}function ae(e,t){if(t.customerId!==S||t.scope.projectId!==d.scope.projectId||t.scope.environment!==d.scope.environment||t.target.funnelId!==e.start.funnelId||t.target.startRequestId!==e.start.requestId||e.run&&(t.target.runId!==e.run.id||t.target.versionId!==e.run.versionId))throw new l("SCOPE_MISMATCH","The original recovery binding changed")}async function ie(e,t){if(I(e),e.run&&(e=await me(e)),!b(e).length&&A(e))return P(_(e,"operation"));if(!b(e).length)return P({mode:"blocked",status:"blocked",actions:["refresh"],purchases:[],error:H(t)});R=!0;let r=await L(e);return P(_(r,"operation"))}async function K(e,t=!1,r=!0){if(E=e.start.requestId,O=structuredClone({requestId:e.start.requestId,funnelId:e.start.funnelId,locale:e.start.locale,parameters:e.start.parameters}),!u){let o=e.run?{operation:"recover_run",runId:e.run.id,funnelId:e.start.funnelId}:{operation:"recover_start",intent:t?"resume":"lookup",start:{requestId:e.start.requestId,funnelId:e.start.funnelId,locale:e.start.locale,parameters:e.start.parameters}},c;try{c=await Y(o)}catch(h){if(!e.run&&h instanceof l&&(h.status===void 0||h.status>=500))return P({mode:"blocked",status:"blocked",actions:["refresh","retry"],purchases:k.purchases,error:H(h)});throw h}let i=G(Fe,c);if(i.customerId!==S||i.scope.projectId!==d.scope.projectId||i.scope.environment!==d.scope.environment)throw new l("SCOPE_MISMATCH","Recovery Customer or environment changed");if(i.outcome==="unknown")return P({mode:"blocked",status:"blocked",actions:["refresh","retry"],purchases:k.purchases,error:{code:"RESULT_UNKNOWN",message:"The original Start outcome remains unknown; retry only its original input"}});ae(e,i);let s=await f.update(h=>(I(h),{...h,run:{id:i.target.runId,versionId:i.target.versionId,status:i.target.status,revision:i.view?.revision??h.run?.revision??0,runExpiresAt:i.target.runExpiresAt}}));if(I(s),e=s,i.access.type==="operation_only")return ie(e,new l("RUN_RECONCILIATION_REQUIRED","Only the original command and Operation can be recovered"));e=await me(e);let m=i.view;if(m.locale!==e.start.locale||!_e(m.parameters,e.start.parameters))throw new l("INVALID_RESPONSE","The original Start input changed");u=ke({...d,customerRun:{runId:i.target.runId,customerId:S,startRequestId:e.start.requestId},funnelId:e.start.funnelId,funnelExecutionPolicy:{allowed:e.allowed.filter(h=>d.executionPolicy.allowed.includes(h))},funnelCommandStorage:He(),onAcceptedResponse:De},{scope:i.scope,run:m})}try{await u.get(),u.view?.pendingRequest?.requestId===e.start.requestId&&!u.pendingCommands?.length&&await u.resume(u.view.pendingRequest.requestId);for(let c of u.pendingCommands??[])c.operation!=="close"&&await u.settle?.(c.requestId);u.pendingCommands?.length&&await u.retry(),w();let o=(await f.read()).entry;return I(o),P(_(o,"run"))}catch(o){if(w(),r&&o instanceof l&&(o.status===401||o.status===409&&o.reason==="STATE_CHANGED")){u.reset(),u=null;let c=(await f.read()).entry;return I(c),K(c,!1,!1)}throw o}}function F(e,t="read",r){if(w(),q)return t==="read"||t===z?q:q.then(()=>F(e,t,r),()=>F(e,t,r));clearTimeout(B);let o=e().catch(c=>{throw!C&&!r?.(c)&&P({mode:"blocked",status:"blocked",actions:["refresh"],purchases:k.purchases,error:H(c)}),c});return q=o,z=t,o.then(()=>{q===o&&(q=void 0,z=void 0)},()=>{q===o&&(q=void 0,z=void 0)}),o}function T(){return F(async()=>{let{entry:e}=await f.read();if(!e||A(e)){if(await re(!1)==="blocked")return fe();({entry:e}=await f.read())}return e?(E&&e.start.requestId!==E&&(u?.reset(),u=null,y.clear(),j.clear(),R=!1),R&&E===e.start.requestId?ie(e,k.error):K(e)):P({mode:"idle",status:"idle",actions:["start"],purchases:[]})})}function fe(){return P({mode:"blocked",status:"blocked",actions:["refresh"],purchases:[],error:H(new l("PURCHASE_PENDING","Check the outstanding purchases before starting another"))})}async function he(){let e=await T();return e.mode==="operation"&&!e.actions.includes("confirm")&&!e.actions.includes("retry")?e:F(async()=>{let t=(await f.read()).entry;if(I(t),!R){if(!u?.view?.paywall?.quote)throw new l("PURCHASE_PENDING","Read the original quote before confirming");let s=u.view.paywall.operation;if(s?.confirmedAt||s?.merchantExecution||s&&s.status!=="pending")return P(_(t,"run"));if(u.pendingCommands?.length)await u.retry();else{let h=u.view;await u.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:h.nodeId,visit:h.visit,revision:h.revision,input:{type:"paywall_confirm",operationId:h.paywall.quote.operationId}})}let m=(await f.read()).entry;return I(m),P(_(m,"run"))}let r=t.operationCommand?.operationId??k.confirmation?.operationId,o=r&&y.get(r);if(!r||!o||t.journal.entry?.command||t.journal.entry?.closeCommand)throw new l("PURCHASE_PENDING","The original Run command must be settled before Operation confirmation");W({allowed:t.allowed.filter(s=>d.executionPolicy.allowed.includes(s))},o.quote),await f.update(s=>{if(I(s),s.journal.entry?.command||s.journal.entry?.closeCommand||s.operationCommand&&s.operationCommand.operationId!==r)throw new l("PURCHASE_PENDING","Another original command is pending");return{...s,operationCommand:{operationId:r,intent:"confirm"}}});let c=await de.attach({operationId:r,intent:"confirm"});if(w(),c.operation.operationId!==r)throw new l("INVALID_RESPONSE","Original confirmation Operation changed");y.set(r,Z(o,c.operation));let i=(await f.read()).entry;return I(i),P(_(await L(i,!1,new Set([r])),"operation"))},"confirm")}async function Ie(){w();let{entry:e}=await f.read();return e?A(e)?"finished":"pending":"none"}return{get controller(){return u},get recovery(){return structuredClone(k)},get attempt(){return w(),structuredClone(O)},get identitySignal(){return le.signal},retained:Ie,async findPurchase(){let e=await Ie();if(e==="pending")return e;let t=await re(!0);return w(),t==="none"?e:t},async readPaywall(e){w();let t=we(e),[r,{readPaywallContent:o},{validateResourceCheck:c}]=await Promise.all([ge(D.request,"resolvePaywall"),import("./paywall-content-QSTCRYU5.js"),import("./check-response-Q7GOBUGJ.js")]);w();let i=r.request.parse({selector:t.paywallVersionId?{type:"version",versionId:t.paywallVersionId}:{type:"paywall",paywallId:t.paywallId},commerce:t.commerce,locale:t.locale}),s=await ye(D.request,r,i);c(i,s.paywall.check,s.scope);let m=await o(d,s.paywall);if(w(),t.paywallVersionId?m.id!==t.paywallVersionId:m.paywallId!==t.paywallId)throw new l("INVALID_RESPONSE","The requested Paywall changed");return m},start(e){let t=U.parse({...structuredClone(e),operation:"start",requestId:e.requestId??crypto.randomUUID()});if(t.operation!=="start"||t.customer||t.customerData)throw new l("INVALID_REQUEST","A Customer-owned Funnel start is required");return F(async()=>{let r=(await f.read()).entry;if((!r||A(r))&&await re(!0)==="blocked")return fe();let o=await f.update(c=>{if(c&&!A(c)){if(c.start.funnelId!==t.funnelId)throw new l("PURCHASE_PENDING","Recover the original Funnel before starting another purchase");return c}return{schemaVersion:1,baseUrl:f.baseUrl,scope:d.scope,customerId:S,sessionId:M,start:t,allowed:[...d.executionPolicy.allowed],purchases:[],journal:{revision:0,entry:null}}});if(!o)throw new l("PURCHASE_STORAGE_INVALID","Original start was not retained");return E!==o.start.requestId&&(u?.reset(),u=null,y.clear(),j.clear(),R=!1),R?ie(o,k.error):K(o,!0)},`start:${t.funnelId}`)},refresh:T,confirm:he,retry:()=>R?he():F(async()=>{let{entry:e}=await f.read();return e?K(e,!0):P({mode:"idle",status:"idle",actions:["start"],purchases:[]})},"retry"),async close(){return u?.view?F(async()=>{if(!u?.view)throw new l("PURCHASE_PENDING","Recover the original Run before closing");if(u.pendingCommands?.find(r=>r.operation==="close"))await u.retry();else if(["running","waiting"].includes(u.view.status)){let r=u.view;await u.submit({operation:"close",requestId:crypto.randomUUID(),nodeId:r.nodeId,visit:r.visit,revision:r.revision})}let t=(await f.read()).entry;return I(t),P(_(t,"run"))},"close"):T()},async continueCheckout(e,t){let r=t?await F(async()=>{let{entry:o}=await f.read();if(I(o),!o.run||!b(o).some(i=>i.operationId===t&&!i.terminal))throw new l("PURCHASE_PENDING","The original Checkout changed");let c=await L(o);return P(_(c,R?"operation":"run"))},`continue:${t}`,o=>o instanceof l&&o.code==="PURCHASE_PENDING"):await T();w(),await e(Be(r,t))},async terminateCheckout(e){let t=await T();if(!t.purchases.find(o=>o.type==="checkout"&&o.operationId===e)||!t.actions.includes("continue_checkout"))throw new l("PURCHASE_PENDING","The original Checkout has changed");return F(async()=>{let{entry:o}=await f.read();I(o);let c=b(o).find(s=>s.operationId===e&&!s.terminal);if(!c||!o.run)throw new l("PURCHASE_PENDING","The original Checkout has changed");await oe(o,c,"terminate_checkout");let i=await L(o,!1,new Set([e]));return P(_(i,R?"operation":"run"))},`terminate:${e}`,o=>o instanceof l&&["CAPABILITY_UNAVAILABLE","NOT_CONFIGURED"].includes(o.code))},subscribe(e){return Q.add(e),()=>{Q.delete(e)}},destroy:pe}}export{Te as a,Be as b,Ct as c};
|
package/dist/chunk-I7QTCEYR.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{p as n,s as t}from"./chunk-G7Y7LPOB.js";function u(o,e,a){return n(o,e,a,t)}export{u as a};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b,c}from"./chunk-JBDNNV3P.js";import"./chunk-SY7AYEDO.js";import"./chunk-O5VA3E5D.js";import"./chunk-Q7K66FTS.js";import"./chunk-42UXYMRZ.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";export{a as PRERENDER_MAX_AGE_MS,b as preparedInternals,c as prerenderFunnelPurchase};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b}from"./chunk-WQZOT22S.js";import"./chunk-JXTJT2EW.js";import"./chunk-JBDNNV3P.js";import"./chunk-L54MODP5.js";import"./chunk-W32FI2A2.js";import"./chunk-DTWSDNYI.js";import"./chunk-KQF4BVOL.js";import"./chunk-2LND3R7K.js";import"./chunk-3NCMYTNG.js";import"./chunk-64ETX3AY.js";import"./chunk-SY7AYEDO.js";import"./chunk-WP3SZU24.js";import"./chunk-4E326NPY.js";import"./chunk-HJVEVJXS.js";import"./chunk-BDC7B4KM.js";import"./chunk-UD7XPHE4.js";import"./chunk-K3VQKR4G.js";import"./chunk-O5VA3E5D.js";import"./chunk-Q7K66FTS.js";import"./chunk-SLUA7ABW.js";import"./chunk-QZRJ3ZXU.js";import"./chunk-EEYDOVVS.js";import"./chunk-42UXYMRZ.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";export{a as showFunnelRun,b as showObservedFunnelRun};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{N as r,O as m,h as e}from"./chunk-UAJTQ23E.js";import"./chunk-2LND3R7K.js";import"./chunk-4E326NPY.js";import"./chunk-UD7XPHE4.js";import"./chunk-K3VQKR4G.js";import"./chunk-Q7K66FTS.js";import"./chunk-42UXYMRZ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{m as merchantBridgeCommerceSchema,r as merchantBridgeOperationSchema,e as merchantOperationLookupSchema};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{e as o}from"./chunk-PLOUC66F.js";import"./chunk-NK55HFFF.js";import"./chunk-YYXINZ4A.js";import"./chunk-KTBXAATX.js";import"./chunk-UAJTQ23E.js";import"./chunk-TLV3NVUU.js";import"./chunk-Y5RT7PAD.js";import"./chunk-KQF4BVOL.js";import"./chunk-2LND3R7K.js";import"./chunk-64ETX3AY.js";import"./chunk-7PXJUHDS.js";import"./chunk-4E326NPY.js";import"./chunk-HJVEVJXS.js";import"./chunk-BDC7B4KM.js";import"./chunk-UD7XPHE4.js";import"./chunk-K3VQKR4G.js";import"./chunk-Q7K66FTS.js";import"./chunk-42UXYMRZ.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{o as apiOperations};
|
package/dist/paywall-TVCH6VQT.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as Tt,c as Ot,d as et,f as tt,g as Dt,k as Lt}from"./chunk-JXTJT2EW.js";import{b as Xe}from"./chunk-W32FI2A2.js";import{d as Et,e as xt,f as It,h as Ze,i as De,j as At,k as Rt,l as St}from"./chunk-DTWSDNYI.js";import{a as bt,c as Je,d as Ct,e as vt}from"./chunk-3NCMYTNG.js";import{b as ce}from"./chunk-64ETX3AY.js";import{a as pe,c as Ke,e as Pt,h as kt}from"./chunk-SY7AYEDO.js";import"./chunk-WP3SZU24.js";import"./chunk-4E326NPY.js";import{ca as Ce,ea as ve,i as gt}from"./chunk-HJVEVJXS.js";import{c as fe,j as be}from"./chunk-BDC7B4KM.js";import{c as Ye}from"./chunk-UD7XPHE4.js";import"./chunk-K3VQKR4G.js";import{a as v}from"./chunk-O5VA3E5D.js";import"./chunk-Q7K66FTS.js";import"./chunk-EEYDOVVS.js";import"./chunk-42UXYMRZ.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import{a as M}from"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";async function Nt(O,o,R){if(o.status!=="complete")throw new v("INVALID_RESPONSE","A verified completed purchase is required");let P=O?be.parse(O):null;if(await R.onComplete?.(o),!P||!R.check)return;let L=be.parse(await R.check());if(L.internal_feature_id!==P.internal_feature_id||L.quantity!==P.quantity||P.observation!==void 0&&(L.observation===void 0||L.observation.requirementDigest!==P.observation.requirementDigest||L.observation.authority!==P.observation.authority||Ye(L.observation.subject)!==Ye(P.observation.subject)))throw new v("INVALID_RESPONSE","The access requirement changed");L.allowed&&await R.onAccessGranted?.(L)}function nt(O){return Object.entries(O.document.buttons).filter(([,o])=>o.type==="checkout"&&o.product.type==="fixed"&&!ce(o.product,{},O.capabilities)).map(([o])=>o)}function _t(O,o){let R=o.lines[0];if(o.lines.length!==1||!R)return;let P=R.productVersionId,{screen:L,buttons:J}=O.document,x=new Map((R.prepaid??[]).map(p=>[p.internal_feature_id,p.quantity]));function K(p,m){if(p.hidden)return!1;if(p.type==="plan_picker"&&O.capabilities.pickers[p.id]?.options.includes(P))return m[p.id]=P,!0;if(p.type==="quantity_picker"){let Q=x.get(p.internalFeatureId);return Q!==void 0&&(!p.bind?.plan||p.bind.plan===P)&&(m[p.id]=Q),!1}if(p.type==="button"&&p.action){let Q=J[p.action];return Q?.type==="checkout"&&Q.product.type==="fixed"&&Q.product.productVersionId===P}if(p.type!=="stack")return!1;let j=p.interaction,r=p.bind?.plan===P;for(let[Q,f]of p.children.entries()){let te={},S=K(f,te);if(j?.type==="toggle"||j?.type==="tabs"){if(!S)continue;return m[p.id]=j.type==="toggle"?Q===0:f.id,Object.assign(m,te),!0}Object.assign(m,te),S&&(r=!0,j?.type==="select"&&j.purpose==="product"&&j.pickerId&&f.type==="stack"&&f.bind?.plan===P&&(m[p.id]=f.id,m[j.pickerId]=P))}return r}for(let p of L.pages){let m={__page:p.id};if(K(p.root,m))return m}}async function Pn(O,o,R){let P=o.focusAtReveal?()=>{}:Ze(O.ownerDocument),L=()=>{x.finish("dismissed"),P()},J=()=>L(),x=At(O,o,"paywall",()=>{L(),M(o.onDismiss)},Tt);o.signal?.throwIfAborted(),o.signal?.addEventListener("abort",J,{once:!0});let K=null,p,m,j;try{if(x.start(!0,o.loadingDocument?.screen.strings.defaultLocale,o.loadingDocument??null),x.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(K=o.check?be.parse(await x.wait(o.check(),De)):null,K?.allowed)return x.finish("skipped"),o.signal?.removeEventListener("abort",J),P(),await o.onAccessGranted?.(K),{check:K,host:null};let[e,t]=await Promise.allSettled([x.wait(import("./screen-renderer-Q3VSMB2N.js")),x.wait(o.start().then(i=>(x.cancelled&&i.destroy(),i)),De)]);if(e.status==="rejected")throw t.status==="fulfilled"&&t.value.destroy(),e.reason;if(t.status==="rejected")throw t.reason;j=e.value,p=t.value,o.signal?.throwIfAborted(),p.signal?.throwIfAborted(),p.signal?.addEventListener("abort",J,{once:!0});let n=p.view??await x.wait(p.refresh(),De);if(!n)throw new v("INVALID_RESPONSE","Paywall presentation is missing");p.signal?.throwIfAborted(),m=n}catch(e){throw x.finish("error",e),o.signal?.removeEventListener("abort",J),p?.signal?.removeEventListener("abort",J),p?.destroy(),P(),e}let r=p,{mountScreenPreview:Q}=j,f=O.ownerDocument,te=new AbortController,S=f.createElement("section"),le=f.createElement("div"),G=f.createElement("div"),Le=o.mountControls,q=Le?f.createElement("div"):void 0,l=f.createElement("p"),g=f.createElement("button"),k=f.createElement("button"),I=f.createElement("dialog"),rt=r.locale||m.document.screen.strings.defaultLocale,s=rt.toLowerCase().startsWith("zh"),Ut=s?"\u6B63\u5728\u5904\u7406\u2026":"Processing\u2026",Mt=s?"\u6B63\u5728\u51C6\u5907\u62A5\u4EF7\u2026":"Preparing your price\u2026",D=Ot(m.document.screen.theme);S.dataset.indianaPaywall="",S.setAttribute("aria-label",m.document.name),S.style.cssText=D.root,G.style.cssText=D.controls,l.style.cssText=D.message,l.setAttribute("role","status"),k.style.cssText=D.link,k.textContent=s?"\u5173\u95ED":"Close",g.style.cssText=D.secondary,g.textContent=s?"\u91CD\u8BD5":"Retry",g.hidden=!0,G.append(l,g,k),q&&(q.style.cssText="flex:1 0 100%;min-width:0",q.hidden=!0,G.prepend(q)),S.append(le,G);let Ne=()=>{if(q){let i=!q.childElementCount&&!q.textContent?.trim();q.hidden!==i&&(q.hidden=i)}let e=ne??G,t=[...e.children].every(i=>i===l?!l.textContent:i.hidden),n=[...e.children].some(i=>i===k?!1:i===l?!!l.textContent:!i.hidden);e.style.cssText=t?D.controls.replace(/padding:[^;]+/,"padding:0"):n?`${D.controls};${D.pinned}`:D.controls,Me()},it=typeof MutationObserver>"u"?void 0:new MutationObserver(Ne);it?.observe(S,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let Pe=m.document.presentation,qt=Object.entries(m.document.buttons).filter(([,e])=>e.type==="close").map(([e])=>e),V,ot,_e=!1,at=JSON.stringify(m.capabilities),st=e=>oe&&!he?Object.entries(e.document.buttons).filter(([,t])=>t.type==="checkout").map(([t])=>t):nt(e);function ke(e){if(y)return;m=e;let t=JSON.stringify(e.capabilities);t!==at&&(V?.updateCapabilities(pe(e),st(e)),at=t),Ht(e),ye()}let E,Ue=0;function Me(){let e=f.defaultView;if(!E?.responsive||!e)return;let t=ne??G,n=e.innerHeight-(E.type==="modal"?32:0);t.style.maxHeight=`${Math.max(1,n)}px`,t.style.overflowY="auto",t.style.flexShrink="0",Ue=Math.max(1,n-t.getBoundingClientRect().height),V?.resizeViewport?.(Ue,e.innerWidth)}let y=!1,oe=!1,C=null,qe,Ee=!1,ct=!1,ae=!1,Ve,$e=!1,X,ne;function Vt(){return oe||y||X||$e?{type:"recover",operationId:r.operation?.operationId??r.quote?.operationId??null,requestId:null}:Je(r)}let A=()=>!y&&!Ee&&!X&&o.canInteract?.()!==!1,$,ue=!1,u=null,Z=null,He="",se=()=>o.checkoutNavigation==="after_confirmation"&&!!(o.terminateCheckout||o.resumeCheckout),me={},he,W=null;function ye(){if(!se()||!V?.updateCheckoutControls)return;let e=r.quote,t=!W&&!!e&&!!r.operation&&H(r.operation).type==="checkout",n=Object.entries(m.document.buttons).flatMap(([i,a])=>a.type==="checkout"?[{actionId:i,policy:a}]:[]);V.updateCheckoutControls({actions:n.map(({actionId:i})=>i),resume:t?n.filter(({actionId:i,policy:a})=>Ae(e,m,i,a.product,me)).map(({actionId:i})=>i):[],resumeLabel:s?"\u7EE7\u7EED\u4ED8\u6B3E":"Continue checkout",busy:he})}function lt(){Z?.remove(),Z=null}async function Be(){if(W)return;if(o.resumeCheckout&&r.operation){await o.resumeCheckout(r.operation.operationId);return}let e=await r.read();if(H(e).type!=="checkout")return N(e,!1);A()&&(xe.delete(e.operationId),await Re(e))}function ut(){l.textContent=s?"\u6682\u65F6\u65E0\u6CD5\u6253\u5F00\u4ED8\u6B3E\u9875\u9762\u3002\u8BF7\u91CD\u8BD5\u3002":"Couldn\u2019t open checkout. Try again.",g.hidden=!0}async function dt(e=!1){let t=W;if(!t)return;g.hidden=!0;let n=Date.now()+2e4;for(;A();){let i=await r.read();if(i.operationId!==t.operationId)throw new v("PURCHASE_PENDING","The original Checkout changed");if(!A())break;let a=H(i);if(a.type==="native"){W=null,lt(),C=t.selection,$=t.coupon,ue=!1,await ge();return}if(a.type==="complete"||a.type==="fulfillment"||a.type==="recording"){W=null,await N(i,!1);return}if(e&&a.type==="checkout"){e=!1;try{await o.terminateCheckout(t.operationId)}catch(h){M(o.onError,h)}}if(Date.now()>=n)break;await Xe(1e3,f,te.signal)}y||ut()}async function $t(e,t,n){W={operationId:e,selection:t,coupon:n};let i=!1;try{await o.terminateCheckout(e)}catch(a){if(a instanceof v&&["CAPABILITY_UNAVAILABLE","NOT_CONFIGURED"].includes(a.code)){W=null,l.textContent=s?"\u8BF7\u7EE7\u7EED\u539F\u8BA2\u5355\uFF0C\u6216\u7B49\u5F85\u5B83\u8FC7\u671F\u540E\u518D\u66F4\u6362\u65B9\u6848\u3002":"Continue your original checkout, or wait for it to expire before changing plans.",M(o.onError,a);return}i=a instanceof v&&(a.status??0)>=500,M(o.onError,a)}A()&&await dt(i)}function Fe(e,t,n,i,a){let h=pe(e).checkoutCoupons?.[t],c=h?h.products[n]:o.claimCoupon&&a?gt(e.capabilities,a,i):void 0;return c?.couponId&&c.planVersionId===n?{id:c.couponId,offerId:c.offerId}:void 0}function Ht(e){oe||C||r.quote||r.operation||He&&l.textContent===He||(l.textContent=Object.values(e.capabilities.plans).some(t=>t.available)?"":s?"\u5F53\u524D\u8D26\u53F7\u6682\u65E0\u53EF\u8D2D\u4E70\u7684\u65B9\u6848\u3002":"No plans are currently available for this account.")}let xe=new Map,Ie=!1;function Ae(e,t,n,i,a,h){let c=e.lines.length===1?e.lines[0]:void 0,w=ce(i,a,t.capabilities);if(!c||!w||c.productVersionId!==w)return!1;let B=Fe(t,n,w,a,h);if((B||pe(t).checkoutCoupons?.[n])&&(B?.id??null)!==(e.discount?.couponId??null))return!1;let _;try{_=ve(t.document.screen,w,a,t.capabilities)}catch{return!1}let ie=Object.fromEntries((c.prepaid??[]).map(z=>[z.internal_feature_id,z.quantity]));return[...new Set([...Object.keys(_),...Object.keys(ie)])].every(z=>(_[z]??0)===(ie[z]??0))}let H=e=>bt({quote:r.quote,operation:e,requestId:null,pending:!1,destroyed:y,canReselect:r.canReselect});async function Re(e){let t=e.merchantExecution;if(!(!A()||!e.checkoutUrl||o.checkoutNavigation==="after_confirmation"&&H(e).type!=="checkout"||t?.type==="purchase"&&!["not_started","pending"].includes(t.paymentStatus)||xe.get(e.operationId)===e.checkoutUrl)){xe.set(e.operationId,e.checkoutUrl);try{o.onCheckoutUrl?await o.onCheckoutUrl(e.checkoutUrl):f.defaultView?.location.assign(e.checkoutUrl)}catch(n){throw xe.delete(e.operationId),n}}}let re=(e,t=!1)=>{if(e instanceof Ke)u=null,l.textContent=e.customerMessage(s);else if(Dt(e))u=null,l.textContent=t?s?"\u5F53\u524D\u65E0\u6CD5\u5728\u6B64\u8D2D\u4E70\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002\u8BF7\u8054\u7CFB\u5546\u6237\u3002":"Purchases aren\u2019t available here right now. Payment hasn\u2019t started. Contact the merchant for help.":tt(e,s);else if(t){let n=e instanceof v?e.code:void 0;n==="CAPABILITY_UNAVAILABLE"||n==="NOT_CONFIGURED"?(u=null,l.textContent=s?"\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."):r.canReselect===!0&&!C?l.textContent=s?"\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"?l.textContent=s?"\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.":l.textContent=s?"\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 l.textContent=e instanceof v&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?tt(e,s):e instanceof v?e.message:s?"\u64CD\u4F5C\u672A\u5B8C\u6210\uFF0C\u8BF7\u91CD\u8BD5\u3002":"This action couldn\u2019t be completed. Try again.";g.hidden=u===null,He=l.textContent,t&&!E?.responsive&&l.scrollIntoView?.({block:"nearest"}),M(t&&R?.quoteError?R.quoteError:o.onError,e)},Se=new WeakMap;function Te(e){oe=e,g.disabled=e,V?.updateCapabilities?.(pe(m),st(m));for(let t of Z?.querySelectorAll("button")??[])e?(Se.set(t,t.disabled),t.disabled=!0):Se.has(t)&&(t.disabled=Se.get(t),Se.delete(t)),et(t)}function je(){l.textContent=s?"\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 Bt(e){if(o.beforeAction)try{await o.beforeAction()}catch(t){throw t instanceof Ke?(C=null,ue=!1,u=null):u=e,t}}async function U(e,t){if(oe||y)return;if(!A()){je();return}let n=e===ge,i=n?Mt:Ut,a=se()&&t!==void 0;he=a?t:void 0,Te(!0),ye(),g.hidden=!0,l.textContent=a?"":i;try{if((e!==Be||!o.resumeCheckout)&&await Bt(e),y)return;if(!A()){u=e,g.hidden=!1,je();return}await e()}catch(h){y||re(h,n&&!a)}finally{he=void 0,Te(!1),ye(),l.textContent===i&&(l.textContent="")}}async function Ft(e){await Nt(K,e,o)}function ft(e){return Je(r).type==="recording"||H(e).type==="recording"}function pt(e){let t=e.merchantTerms,n=t?.subscriptionTerms?.items??[],i=t?t.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),a=t?n.length===1&&n[0]?.amountMinor===i&&n[0]:e.lines.length===1&&e.lines[0]?.catalogAmountMinor===i&&e.lines[0],h=i===null?fe(t.subtotalMinor-t.discountMinor,e.currency)+(s?" + \u5F85\u786E\u8BA4\u7A0E\u8D39":" + tax confirmed at checkout"):fe(i,e.currency)+(a?Ce(a.interval,s?"zh-CN":"en",a.intervalCount??1):""),c=e.lines.map(w=>w.productName).join(", ");return{label:c?`${c} \xB7 ${h}`:h,recurring:a}}async function N(e,t=o.checkoutNavigation!=="after_confirmation"){if(y)return;if(!A()){u=async()=>N(await r.read()),g.hidden=!1;return}if(l.textContent=Lt(e.status,s),ft(e)){let a=e.merchantExecution?.type==="purchase"&&e.merchantExecution.recordingStatus==="failed";l.textContent=a?s?"\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.":s?"\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.",g.textContent=s?"\u67E5\u8BE2\u8BB0\u5F55":"Check recording",u=async()=>N(await r.read()),g.hidden=!1;return}if(e.problem){let a=e.problem;u=we,g.textContent=s?"\u68C0\u67E5\u5E76\u6062\u590D\u539F\u64CD\u4F5C":"Check and recover original purchase",re(new v(a.code,a.reason==="RESULT_UNKNOWN"?s?"\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.":a.phase==="fulfillment"?s?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u5546\u6237\u6743\u76CA\u5904\u7406\u9700\u8981\u6838\u5BF9\u3002":"Payment was recorded. Access fulfillment needs attention.":a.code==="CAPABILITY_UNAVAILABLE"?s?"\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.":a.code==="NOT_CONFIGURED"?s?"\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.":s?"\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,a));return}if(e.merchantExecution?.type==="purchase"&&e.merchantExecution.paymentStatus==="succeeded"&&!["applied","not_applicable"].includes(e.merchantExecution.fulfillmentStatus)&&(l.textContent=s?"\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"){u=null,await Ft(e);return}if(e.status!=="pending"){if(r.canReselect===!1){l.textContent=s?"\u6B63\u5728\u6838\u5BF9\u539F\u8D2D\u4E70\u7ED3\u679C":"Checking the original purchase result",g.textContent=s?"\u67E5\u8BE2\u7ED3\u679C":"Check result",u=async()=>N(await r.read()),g.hidden=!1;return}e.status==="cancelled"?l.textContent=s?"\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"&&(l.textContent=s?"\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."),g.textContent=s?"\u91CD\u8BD5":"Retry",u=null,C=null;return}if(!t&&H(e).type==="checkout"){if(W){ut();return}if(se()){l.textContent="",Ie=!1,u=null,ye();return}let a=r.quote,h=a?.operationId===e.operationId?pt(a).label:"";l.textContent=Ie?h?s?`${h} \u5C1A\u672A\u4ED8\u6B3E\u3002\u518D\u6B21\u9009\u62E9\u8BE5\u65B9\u6848\u5373\u53EF\u7EE7\u7EED\u4ED8\u6B3E\u3002`:`${h} is still unpaid. Choose it again to continue paying.`:s?"\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.":"",Ie=!1,u=null;return}await Re(e);let n=Date.now()+6e5,i=2e3;_e=!0,M(o.onObservationChange,!0);try{for(;!y&&Date.now()<n;){if(await Xe(i,f,te.signal),y)return;if(!A()){u=async()=>N(await r.read()),g.hidden=!1;return}let a=await r.read();if(!t&&H(a).type==="checkout"){await N(a,!1);return}if(!a.problem&&a.status==="pending"&&await Re(a),a.status!=="pending"||a.problem||ft(a)){await N(a);return}i=Math.min(i*1.5,3e4)}}finally{_e=!1,M(o.onObservationChange,!1)}u=async()=>N(await r.read()),g.hidden=!1}async function Qe(e=!1){let t=await r.read();if(y)return;if(!A()){u=()=>Qe(e),g.hidden=!1;return}let n=r.quote;if(n&&Pt(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&&!r.pendingCancellation){mt(n);return}await N(t,e||void 0)}async function we(){lt(),u=we;let e=await r.confirm();if(!A()){u=we,g.hidden=!1;return}if(e.problem){await N(e);return}if(e.status==="pending"){if(e.checkoutUrl)await Re(e);else if(e.execution&&e.execution.provider!=="merchant"||e.nativePurchase){if(!o.onPurchase)throw new v("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await o.onPurchase({operation:e,signal:te.signal})}}u=async()=>N(await r.read()),await N(e,!0)}function mt(e){Z?.remove();let t=!(Date.parse(e.expiresAt)>Date.now());l.textContent=t?s?"\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=f.createElement("div"),i=f.createElement("button"),a=f.createElement("button"),h=f.createElement("div"),c=f.createElement("p"),w=e.merchantTerms,B=s?"zh-CN":"en",_=w?.subscriptionTerms?.items??[],ie=w?w.subscriptionTerms?.trial?.days:e.lines.find(d=>d.trial)?.trial?.days,ee=ie===void 0?null:w?w.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(d=>d.trial)?0:null,z=(d,b)=>s?`${b} \u5929\u8BD5\u7528\u7ED3\u675F\u540E ${d}`:`Then ${d} after the ${b}-day trial`,{label:ze,recurring:ht}=pt(e),jt=e.lines.map(d=>d.productName).join(", "),yt=ee===null?"":`${s?"\u4ECA\u5929\u5E94\u4ED8":"Due today"} ${fe(ee,e.currency)}`;c.textContent=yt?[jt,yt].filter(Boolean).join(" \xB7 "):ze,i.textContent=s?"\u786E\u8BA4\u8D2D\u4E70":"Confirm purchase",i.disabled=t,a.textContent=s?"\u53D6\u6D88":"Cancel",n.style.cssText=D.panel,c.style.cssText=D.summary,h.style.cssText=D.actions,i.style.cssText=D.primary,a.style.cssText=D.secondary,et(i),i.onclick=()=>{U(we)};let wt=async()=>{let d=await r.cancel();y||(n.remove(),Z=null,await N(d))};a.onclick=()=>{u=wt,U(wt)};let F=f.createElement("div");if(F.style.cssText=D.terms,w){for(let b of _){if(ee===null&&b===ht)continue;let T=f.createElement("p"),Y=fe(b.amountMinor,e.currency)+Ce(b.interval,B,b.intervalCount);T.textContent=ee!==null&&ie!==void 0?z(Y,ie):Y,F.append(T)}let d=w.subscriptionTerms?.trial;if(d){let b=f.createElement("p");b.textContent=s?`\u8BD5\u7528 ${d.days} \u5929\uFF1B${d.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${d.days}; ${d.cardRequired?"a payment method is required":"no payment method is required"}`,F.append(b)}for(let b of[...w.expectedEffects.map(T=>T.description),...w.requiredConsents.map(T=>T.summary)]){let T=f.createElement("p");T.textContent=b,F.append(T)}}else{for(let d of e.lines){if(ee!==null||d!==ht){let b=f.createElement("p"),T=`${fe(d.catalogAmountMinor,e.currency)}${Ce(d.interval,B,d.intervalCount??1)}`;b.textContent=ee!==null&&d.trial?(e.lines.length>1?`${d.productName} \xB7 `:"")+z(T,d.trial.days):`${d.productName} \xB7 ${T}`,F.append(b)}for(let b of d.prepaid??[]){let T=f.createElement("p"),Y=r.view?.capabilities.plans[d.productVersionId]?.prepaid?.find(Qt=>Qt.internalFeatureId===b.internal_feature_id);T.textContent=`${Y?.name??b.internal_feature_id} \xB7 ${b.quantity} ${s?"\u4EFD":"packs"} \xD7 ${b.terms.units}`,Y&&(T.textContent+=Ce(Y.reset==="week"||Y.reset==="month"||Y.reset==="year"?Y.reset:"one_time",B,Y.resetCount)),F.append(T)}if(d.trial){let b=f.createElement("p");b.textContent=s?`\u8BD5\u7528 ${d.trial.days} \u5929\uFF1B${d.trial.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${d.trial.days}; ${d.trial.cardRequired?"a payment method is required":"no payment method is required"}`,F.append(b)}}if(!e.charge){let d=f.createElement("p");d.textContent=s?"\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.",F.append(d)}}for(let d of F.children)d.style.margin="0";h.append(i,a),n.append(c,...F.childElementCount?[F]:[],h),G.prepend(n),E?.responsive||n.scrollIntoView?.({block:"nearest"}),i.focus({preventScroll:!0}),Z=n,u=null}async function ge(){if(!C)return;if(u=ge,!ue){let n=r.view,i=n?.document.buttons[C.actionId],a=n&&i?.type==="checkout"?ce(i.product,C.selection,n.capabilities):null;if(!n||!a)throw new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let h=$?.offerId;if($&&!h){if(!o.claimCoupon)throw new v("CAPABILITY_UNAVAILABLE","Coupon claiming is unavailable");let{offer:c}=await o.claimCoupon($.id,C.requestId);if(y)return;if(!c||c.couponId!==$.id||c.status!=="issued"||!(Date.parse(c.expiresAt)>Date.now()))throw C=null,$=void 0,u=async()=>{ke(await r.refresh()),u=null},new v("COUPON_UNAVAILABLE","This Coupon is no longer available for this purchase");h=c.id}if(!$&&!n.document.screen.actions.some(c=>c.id===C?.actionId&&typeof c.properties.couponBinding=="string")&&(h=await o.resolveOfferId?.({actionId:C.actionId,productVersionId:a,featureQuantities:ve(n.document.screen,a,C.selection,n.capabilities)})),y)return;h!==void 0&&(C.offerId=h),ue=!0}if(!A()){g.hidden=!1;return}let e;try{e=await r.preview(C)}catch(n){throw r.canReselect===!0&&(C=null,ue=!1,$=void 0,u=null),n}if($&&(e.discount?.couponId!==$.id||e.discount.offerId!==C.offerId))throw new v("INVALID_RESPONSE","The quote did not apply the Coupon selected on this Paywall");if(y)return;let t=e.merchantTerms;if(o.confirmOnHostedCheckout&&A()&&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=he?"":s?"\u6B63\u5728\u6253\u5F00\u6536\u94F6\u53F0\u2026":"Opening checkout\u2026";l.textContent=n;try{await we()}catch(i){y||re(i)}finally{l.textContent===n&&(l.textContent="")}return}mt(e)}function de(e="destroy"){if(y)return;y=!0;let t=qe;qe=void 0,M(t),o.signal?.removeEventListener("abort",J),r.signal?.removeEventListener("abort",J),x.finish("dismissed"),ot?.(),te.abort(),it?.disconnect(),E?.destroy(),V?.destroy(),r.destroy(),I.open&&I.close(),I.remove(),S.remove(),P(),e==="dismiss"&&M(o.onDismiss)}L=de;async function Oe(){if(!ae||y||Ee||X==="closing"||!X&&!A())return;if(!R){de("dismiss");return}let e=f.createElement("p");e.setAttribute("role","status"),e.textContent=s?"\u6B63\u5728\u5173\u95ED\u2026":"Closing\u2026",ne||(ne=f.createElement("div"),ne.style.cssText=G.style.cssText,G.replaceWith(ne),le.inert=!0),k.hidden=!1,ne.replaceChildren(e,k),X="closing",k.setAttribute("aria-disabled","true"),k.focus({preventScroll:!0});try{await R.dismiss()}catch(t){y||M(o.onError,t)}y||(X="retry",e.textContent=s?"\u672A\u80FD\u786E\u8BA4\u5173\u95ED\uFF0C\u8BF7\u91CD\u8BD5\u3002":"Could not confirm closure. Try again.",k.textContent=s?"\u91CD\u8BD5\u5173\u95ED":"Retry closing",k.removeAttribute("aria-label"),k.removeAttribute("aria-disabled"))}k.onclick=()=>{Oe()},I.addEventListener("cancel",e=>{e.preventDefault(),Oe()}),g.onclick=()=>{u&&U(u)};function Ge(e){x.finish("error",e),de()}function We(){if(!(!ct||ae||y||Ee||E&&!A()))try{let e=t=>{o.focusAtReveal&&(P=Ze(f)),V?.setHidden?.(!1),Ve?.(),E&&(I.showModal(),E.responsive&&I.focus({preventScroll:!0}),!t&&o.loading!=="host"&&xt(I,E.type,E.responsive)),ae=!0};R?R.present(()=>x.present(()=>e(!0))):x.present(e)}catch(e){Ge(e),re(e)}}try{if(Pe.type==="inline"?(Ne(),Ve=St(S,O),O.append(S)):(I.setAttribute("aria-label",m.document.name),k.textContent="\xD7",k.setAttribute("aria-label",s?"\u5173\u95ED":"Close"),It(k,m.document.screen.theme),k.hidden=kt(m.document),I.append(k,S),O.append(I),E=Et(I,{...m.document.screen,presentation:Pe},Me),E.latch(),E.responsive&&(S.style.display="flex",S.style.flexDirection="column",S.style.maxHeight="100%",le.style.overflow="clip",le.style.minHeight="0"),Ve=Rt(I)),Le&&q){let n=Le(q);if(typeof n=="function"&&(y?M(n):qe=n),y)throw new DOMException("Presentation cancelled","AbortError");Ne()}V=Q(le,{mode:"live",rendererUrl:r.webViewUrl,title:m.document.name,closeActions:qt,onAuthoredClose(n){X||y||(k.hidden=n)},hostPresentation:()=>E?.type??Pe.type,reportContentHeight:E?.responsive,onResize:n=>{if(!E?.responsive)return;let i=Math.min(n,Ue);le.style.height=`${i}px`,E.setContentHeight(i+(ne??G).getBoundingClientRect().height)},onSelection(n){me=n,ye()},onAction(n,i={},a,h){if(!ae||y||X)return;let c=r.view,w=c?.document.buttons[n];if(!w)return;if(w.type==="close"&&R&&o.resumeCheckout&&r.operation&&Ct(H(r.operation))){Oe();return}if(oe)return;if(!A()){je();return}if(w.type==="close"){U(async()=>{await o.onAction?.(n),de(o.onAction?"action":"dismiss")});return}if(w.type==="action"){u=async()=>{if(w.action.type==="event"){if(!o.onEvent)throw new v("EVENT_HANDLER_REQUIRED","Provide the event handler");await o.onEvent(w.action.event)}else o.onOpenUrl?await o.onOpenUrl(w.action.url):f.defaultView?.location.assign(w.action.url);await o.onAction?.(n),u=null},U(u);return}if(o.allowNewPurchase===!1){se()&&c&&r.quote&&r.operation&&H(r.operation).type==="checkout"&&Ae(r.quote,c,n,w.product,i,h)?U(Be,n):l.textContent=s?"\u5F53\u524D\u53EA\u80FD\u7EE7\u7EED\u539F\u8BA2\u5355\u3002":"Only your original checkout is available.";return}if(Z&&r.canReselect===!1){l.textContent=s?"\u8BF7\u5148\u786E\u8BA4\u6216\u53D6\u6D88\u5F53\u524D\u8D2D\u4E70\u3002":"Confirm or cancel the current purchase first.",E?.responsive||Z.scrollIntoView?.({block:"nearest"}),Z.querySelector("button")?.focus({preventScroll:!0});return}if(se()&&W){W.selection.actionId===n&&U(()=>dt(!0),n);return}if(se()&&o.terminateCheckout&&c&&r.quote&&r.operation&&r.canReselect===!1&&H(r.operation).type==="checkout"){if(Ae(r.quote,c,n,w.product,i,h)){U(Be,n);return}let _=ce(w.product,i,c.capabilities);try{if(!_)throw new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");ve(c.document.screen,_,i,c.capabilities)}catch(ze){re(ze);return}let ie=r.operation.operationId,ee={actionId:n,requestId:crypto.randomUUID(),selection:structuredClone(i)},z=Fe(c,n,_,i,h);U(()=>$t(ie,ee,z),n);return}if((r.quote||C)&&r.canReselect===!1){let _=!!c&&!!r.quote&&Ae(r.quote,c,n,w.product,i,h);Ie=!!r.quote&&!_,u=r.quote?()=>Qe(_):ge,U(u);return}let B=c&&ce(w.product,i,c.capabilities);if(!c||!B){re(new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(o.onPurchaseIntent){u=null,U(async()=>{let _={actionId:n,productVersionId:B,selection:structuredClone(i),featureQuantities:ve(c.document.screen,B,i,c.capabilities)};$e=!0,await o.onPurchaseIntent(_)});return}if(C&&C.actionId!==n){re(new v("COMMAND_PENDING","Finish the current purchase"));return}C||($=Fe(c,n,B,i,h),C={requestId:crypto.randomUUID(),actionId:n,selection:structuredClone(i)},ue=!1),U(ge,n)},onEscape:()=>{Oe()},onError:n=>{let i=new Error(n);!ae&&!y&&Ge(i),re(i)},onRendered:n=>{n&&I.setAttribute("aria-label",n),ct=!0,We()}}),V.setHidden?.(!0),Me();let e=se()&&!!r.quote&&!!r.operation&&H(r.operation).type==="checkout";me=e?_t(m,r.quote)??{}:{},V.update(m.document.screen,rt,{capabilities:pe(m),unavailableActions:nt(m),serverInput:{bindings:[],answers:{}},...Object.keys(me).length?{selection:me}:{}}),ot=r.subscribe?.(ke),ke(r.view??m),await x.wait(V.ready);let t=r.operation;!e&&(r.quote||t&&(t.confirmedAt||t.checkoutUrl||t.status==="complete"))&&(u=()=>Qe(),U(u))}catch(e){throw Ge(e),e}return{check:K,host:{get observing(){return _e},get recovery(){return Vt()},async prepareFallback(){if(oe||y||X||$e)return{type:"recover",operationId:r.operation?.operationId??r.quote?.operationId??null,requestId:null};Te(!0);try{let e=await vt(r);return e.type==="native"&&de(),e}finally{Te(!1)}},setSuspended(e){Ee=e,S.hidden=e,e&&I.open?I.close():!e&&!ae?We():!e&&!y&&ae&&Pe.type!=="inline"&&!I.open&&I.showModal()},destroy:de,refresh:async()=>{if(!A()){if(r.view)return r.view;throw new v("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await r.refresh();return ke(e),We(),e}}}}export{Pn as showPaywall};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as a}from"./chunk-GEPX4AUR.js";import"./chunk-TLV3NVUU.js";import"./chunk-Y5RT7PAD.js";import"./chunk-KQF4BVOL.js";import"./chunk-2LND3R7K.js";import"./chunk-64ETX3AY.js";import"./chunk-WP3SZU24.js";import"./chunk-4E326NPY.js";import"./chunk-HJVEVJXS.js";import"./chunk-BDC7B4KM.js";import"./chunk-UD7XPHE4.js";import"./chunk-K3VQKR4G.js";import"./chunk-O5VA3E5D.js";import"./chunk-Q7K66FTS.js";import"./chunk-3VUPVXAV.js";import"./chunk-EEYDOVVS.js";import"./chunk-42UXYMRZ.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";export{a as readPaywallContent};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a}from"./chunk-XBCKVHOT.js";import"./chunk-PLOUC66F.js";import"./chunk-NK55HFFF.js";import"./chunk-IHB275C3.js";import"./chunk-YYXINZ4A.js";import"./chunk-KTBXAATX.js";import"./chunk-6WEHTOED.js";import"./chunk-UAJTQ23E.js";import"./chunk-GEPX4AUR.js";import"./chunk-TLV3NVUU.js";import"./chunk-Y5RT7PAD.js";import"./chunk-KQF4BVOL.js";import"./chunk-2LND3R7K.js";import"./chunk-3NCMYTNG.js";import"./chunk-64ETX3AY.js";import"./chunk-SY7AYEDO.js";import"./chunk-7PXJUHDS.js";import"./chunk-WP3SZU24.js";import"./chunk-4E326NPY.js";import"./chunk-HJVEVJXS.js";import"./chunk-BDC7B4KM.js";import"./chunk-UD7XPHE4.js";import"./chunk-K3VQKR4G.js";import"./chunk-O5VA3E5D.js";import"./chunk-Q7K66FTS.js";import"./chunk-3VUPVXAV.js";import"./chunk-EEYDOVVS.js";import"./chunk-42UXYMRZ.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.js";import"./chunk-WOT6VMZA.js";export{a as createPaywallSession};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i}from"./chunk-5IGASP6C.js";import"./chunk-DTWSDNYI.js";import"./chunk-HJVEVJXS.js";import"./chunk-BDC7B4KM.js";import"./chunk-UD7XPHE4.js";import"./chunk-K3VQKR4G.js";import"./chunk-O5VA3E5D.js";import"./chunk-Q7K66FTS.js";import"./chunk-42UXYMRZ.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-DSPLGTQI.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};
|
|
File without changes
|