@tinkerlandai/longplay-sdk 0.10.32 → 0.10.34

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +10 -6
  3. package/README.zh-CN.md +2 -0
  4. package/dist/chunk-3JJYWRA3.js +1 -0
  5. package/dist/chunk-4WZVC4TM.js +1 -0
  6. package/dist/chunk-5JWMP4YD.js +1 -0
  7. package/dist/{chunk-XH7RJPBV.js → chunk-6T575JKD.js} +1 -1
  8. package/dist/{chunk-EMVWUEW4.js → chunk-7NELM6EH.js} +1 -1
  9. package/dist/{chunk-KHM6IHPJ.js → chunk-7VRZYSTR.js} +1 -1
  10. package/dist/{chunk-P5K67CKS.js → chunk-ERJP2GBD.js} +1 -1
  11. package/dist/{chunk-4XC34JBS.js → chunk-I6TSQQ5N.js} +1 -1
  12. package/dist/{chunk-SP5AQION.js → chunk-ITGERPCJ.js} +1 -1
  13. package/dist/{chunk-EUVLXS2V.js → chunk-QBA3B4YK.js} +1 -1
  14. package/dist/chunk-RKPAIF6U.js +1 -0
  15. package/dist/chunk-TDSATEGE.js +10 -0
  16. package/dist/{chunk-GLQXJMKL.js → chunk-TYY3MUTF.js} +1 -1
  17. package/dist/chunk-U6UHASIB.js +1 -0
  18. package/dist/{chunk-CZ2RY6RG.js → chunk-WKIR2EQG.js} +1 -1
  19. package/dist/{chunk-ZIQENZDI.js → chunk-WTVLNUMS.js} +1 -1
  20. package/dist/{content-YRQSNKN7.js → content-ORU4ODJQ.js} +1 -1
  21. package/dist/funnel-host-purchase-BEFE3N3E.js +1 -0
  22. package/dist/{funnel-runtime-host-J2PQHVSO.js → funnel-runtime-host-V6TYIDX3.js} +1 -1
  23. package/dist/index.d.ts +8 -3
  24. package/dist/index.js +1 -1
  25. package/dist/native-shell.js +1 -1
  26. package/dist/openrouter.js +1 -1
  27. package/dist/page.js +1 -1
  28. package/dist/paywall-HO4PS472.js +1 -0
  29. package/dist/{paywall-session-PPECL5XK.js → paywall-session-MZXFOPTR.js} +1 -1
  30. package/dist/popup.d.ts +6 -2
  31. package/dist/popup.js +1 -1
  32. package/dist/{presentation-loading-iSaRiDP2.d.ts → presentation-loading-CFSiS0VX.d.ts} +502 -3
  33. package/dist/react-native.js +1 -1
  34. package/dist/{screen-renderer-NHLIJDCW.js → screen-renderer-W7ZGBFIR.js} +1 -1
  35. package/dist/server.d.ts +30 -0
  36. package/dist/server.js +3 -3
  37. package/dist/visual.js +1 -1
  38. package/package.json +1 -1
  39. package/dist/chunk-5UFRIIGC.js +0 -1
  40. package/dist/chunk-6KBCR7JJ.js +0 -10
  41. package/dist/chunk-EMYZUBWL.js +0 -1
  42. package/dist/chunk-HQPP76BS.js +0 -1
  43. package/dist/chunk-UESDHJRB.js +0 -1
  44. package/dist/chunk-Y3MQLWGD.js +0 -1
  45. package/dist/funnel-host-purchase-SWYFJOVN.js +0 -1
  46. package/dist/paywall-RQ66UZLW.js +0 -1
@@ -1 +0,0 @@
1
- import{b as y}from"./chunk-UESDHJRB.js";import{d as A}from"./chunk-EMYZUBWL.js";import"./chunk-HQPP76BS.js";import{f as g,g as I}from"./chunk-Y3MQLWGD.js";import"./chunk-4XC34JBS.js";import"./chunk-UWLEGMWX.js";import"./chunk-EUVLXS2V.js";import"./chunk-SP5AQION.js";import"./chunk-THMGTRXP.js";import"./chunk-NAZU3EEJ.js";import"./chunk-SCC3O2RD.js";import"./chunk-R23IGK5U.js";import"./chunk-ZGCKQWQ5.js";import"./chunk-EHDHWYVJ.js";import"./chunk-BXPXJARS.js";import"./chunk-ZIQENZDI.js";import"./chunk-VYFSRHXM.js";import"./chunk-N7YXDSQL.js";import"./chunk-MIBRUDIS.js";import{a as c}from"./chunk-X4W22IH6.js";import"./chunk-R4FDIYMN.js";import"./chunk-SLUA7ABW.js";import"./chunk-XH7RJPBV.js";import"./chunk-3VUPVXAV.js";import"./chunk-CZ2RY6RG.js";import"./chunk-VF6QMMEA.js";import{a as i}from"./chunk-DSPLGTQI.js";import"./chunk-7QL4GF4C.js";import"./chunk-BID4UGWB.js";import"./chunk-WOT6VMZA.js";var d=new WeakMap;function T(h,e){let P=d.get(e.client);if(P)return P;let m=Promise.resolve().then(async()=>{let n=!1,s,w,E=!1,v=()=>{},r=e.signal?AbortSignal.any([e.signal,e.client.identitySignal]):e.client.identitySignal,u=()=>{d.get(e.client)===m&&d.delete(e.client),r.removeEventListener("abort",f),v()},o=I(h,e,"funnel",f);function f(){n||(n=!0,o.finish("dismissed"),s?s.destroy():(u(),i(e.onDismiss,null)))}r.addEventListener("abort",f,{once:!0});try{let b=function(){!n&&!r.aborted&&!E&&w&&e.client.recovery.status==="complete"&&(E=!0,i(e.onComplete,structuredClone(w)))};var C=b;r.throwIfAborted(),o.start(!0,e.start?.locale);let l=await o.wait(e.start?e.client.start(e.start):e.client.refresh(),g);r.throwIfAborted();let O=e.client.controller;return l.mode!=="run"||l.status==="blocked"||!O?(o.finish("skipped"),u(),null):(r.removeEventListener("abort",f),v=e.client.subscribe(b),s=await A(h,{...e,client:O,signal:r,checkoutNavigation:"after_confirmation",onCheckoutUrl(t){if(r.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");if(y(e.client.recovery)!==t)throw new c("PURCHASE_PENDING","Checkout differs from the original recovery proof");return e.onCheckoutUrl?e.onCheckoutUrl(t):h.ownerDocument.defaultView?.location.assign(t)},async resolveOfferId(t){if(r.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");let a=e.client.attempt;if(!a)throw new c("PURCHASE_PENDING","Read the original Start before selecting an offer");let F=await e.resolveOfferId?.(t,a);if(r.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");if(e.client.attempt?.requestId!==a.requestId)throw new c("PURCHASE_STORAGE_CONFLICT","The original purchase changed while selecting an offer");return F},onComplete(t){w=t,b()},onError(t){i(e.onError,t),t instanceof c&&t.status===401&&!r.aborted&&e.client.refresh().catch(a=>i(e.onError,a))},onDismiss(t){n=!0,u(),i(e.onDismiss,t)}},o),n||r.aborted?(s.destroy(),null):s)}catch(l){if(n)return null;throw o.finish("error",l),u(),i(e.onError,l),l}});return d.set(e.client,m),m}export{T as showFunnelPurchase};
@@ -1 +0,0 @@
1
- import{b as at,c as Ne,e as ot,g as st,h as ct}from"./chunk-HQPP76BS.js";import{c as Xe,d as Ze,e as et,f as pe,g as tt,h as nt,i as rt,k as it}from"./chunk-Y3MQLWGD.js";import{a as Ge,c as Se,d as Ye,g as Je,j as Ke}from"./chunk-EHDHWYVJ.js";import{b as te}from"./chunk-BXPXJARS.js";import"./chunk-ZIQENZDI.js";import"./chunk-VYFSRHXM.js";import{c as ee,o as re,oa as ie,qa as Oe}from"./chunk-N7YXDSQL.js";import{c as Te}from"./chunk-MIBRUDIS.js";import{a as k}from"./chunk-X4W22IH6.js";import"./chunk-R4FDIYMN.js";import"./chunk-CZ2RY6RG.js";import"./chunk-VF6QMMEA.js";import{a as W}from"./chunk-DSPLGTQI.js";import"./chunk-7QL4GF4C.js";import"./chunk-BID4UGWB.js";import"./chunk-WOT6VMZA.js";async function lt(T,r,D){if(r.status!=="complete")throw new k("INVALID_RESPONSE","A verified completed purchase is required");let O=T?re.parse(T):null;if(await D.onComplete?.(r),!O||!D.check)return;let S=re.parse(await D.check());if(S.internal_feature_id!==O.internal_feature_id||S.quantity!==O.quantity||O.observation!==void 0&&(S.observation===void 0||S.observation.requirementDigest!==O.observation.requirementDigest||S.observation.authority!==O.observation.authority||Te(S.observation.subject)!==Te(O.observation.subject)))throw new k("INVALID_RESPONSE","The access requirement changed");S.allowed&&await D.onAccessGranted?.(S)}function De(T){return Object.entries(T.document.buttons).filter(([,r])=>r.type==="checkout"&&r.product.type==="fixed"&&!te(r.product,{},T.capabilities)).map(([r])=>r)}async function zt(T,r,D){let O=it(T.ownerDocument),S=()=>{C.finish("dismissed"),O()},B=()=>S(),C=tt(T,r,"paywall",()=>{S(),W(r.onDismiss)});r.signal?.throwIfAborted(),r.signal?.addEventListener("abort",B,{once:!0});let G=null,_,h,Le;try{if(C.start(!0),C.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(G=r.check?re.parse(await C.wait(r.check(),pe)):null,G?.allowed)return C.finish("skipped"),r.signal?.removeEventListener("abort",B),O(),await r.onAccessGranted?.(G),{check:G,host:null};let[e,t]=await Promise.allSettled([C.wait(import("./screen-renderer-NHLIJDCW.js")),C.wait(r.start().then(s=>(C.cancelled&&s.destroy(),s)),pe)]);if(e.status==="rejected")throw t.status==="fulfilled"&&t.value.destroy(),e.reason;if(t.status==="rejected")throw t.reason;Le=e.value,_=t.value,r.signal?.throwIfAborted(),_.signal?.throwIfAborted(),_.signal?.addEventListener("abort",B,{once:!0});let n=_.view??await C.wait(_.refresh(),pe);if(!n)throw new k("INVALID_RESPONSE","Paywall presentation is missing");_.signal?.throwIfAborted(),h=n}catch(e){throw C.finish("error",e),r.signal?.removeEventListener("abort",B),_?.signal?.removeEventListener("abort",B),_?.destroy(),O(),e}let i=_,{mountScreenPreview:ut}=Le,d=T.ownerDocument,fe=new AbortController,I=d.createElement("section"),Y=d.createElement("div"),U=d.createElement("div"),u=d.createElement("p"),y=d.createElement("button"),b=d.createElement("button"),w=d.createElement("dialog"),a=h.document.screen.strings.defaultLocale.startsWith("zh"),dt=a?"\u6B63\u5728\u5904\u7406\u2026":"Processing\u2026",pt=a?"\u6B63\u5728\u51C6\u5907\u62A5\u4EF7\u2026":"Preparing your price\u2026",P=at(h.document.screen.theme);I.dataset.indianaPaywall="",I.setAttribute("aria-label",h.document.name),I.style.cssText=P.root,U.style.cssText=P.controls,u.style.cssText=P.message,u.setAttribute("role","status"),b.style.cssText=P.link,b.textContent=a?"\u5173\u95ED":"Close",y.style.cssText=P.secondary,y.textContent=a?"\u91CD\u8BD5":"Retry",y.hidden=!0,U.append(u,y,b),I.append(Y,U);let Me=()=>{let e=H??U,t=[...e.children].every(s=>s===u?!u.textContent:s.hidden),n=[...e.children].some(s=>s===b?!1:s===u?!!u.textContent:!s.hidden);e.style.cssText=t?P.controls.replace(/padding:[^;]+/,"padding:0"):n?`${P.controls};${P.pinned}`:P.controls,we()},_e=typeof MutationObserver>"u"?void 0:new MutationObserver(Me);_e?.observe(I,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let J=h.document.presentation,F,Ue,me=!1,$e=JSON.stringify(h.capabilities),qe=e=>K?Object.entries(e.document.buttons).filter(([,t])=>t.type==="checkout").map(([t])=>t):De(e);function he(e){if(p)return;h=e;let t=JSON.stringify(e.capabilities);t!==$e&&(F?.updateCapabilities(e.capabilities,qe(e)),$e=t),mt(e)}let g,ye=0;function we(){let e=d.defaultView;if(!g?.responsive||!e)return;let t=H??U,n=e.innerHeight-(g.type==="modal"?32:0);t.style.maxHeight=`${Math.max(1,n)}px`,t.style.overflowY="auto",t.style.flexShrink="0",ye=Math.max(1,n-t.getBoundingClientRect().height),F?.resizeViewport?.(ye,e.innerWidth)}let p=!1,K=!1,E=null,ae=!1,Ve=!1,j=!1,be,ge=!1,V,H;function ft(){return K||p||V||ge?{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null}:Se(i)}let R=()=>!p&&!ae&&!V&&r.canInteract?.()!==!1,oe=!1,l=null,$=null;function mt(e){K||E||i.quote||i.operation||(u.textContent=Object.values(e.capabilities.plans).some(t=>t.available)?"":a?"\u5F53\u524D\u8D26\u53F7\u6682\u65E0\u53EF\u8D2D\u4E70\u7684\u65B9\u6848\u3002":"No plans are currently available for this account.")}let ve=new Map,Ce=!1;function ht(e,t,n,s){let o=e.lines.length===1?e.lines[0]:void 0,m=te(n,s,t.capabilities);if(!o||!m||o.productVersionId!==m)return!1;let x;try{x=Oe(t.document.screen,m,s,t.capabilities)}catch{return!1}let A=Object.fromEntries((o.prepaid??[]).map(z=>[z.internal_feature_id,z.quantity]));return[...new Set([...Object.keys(x),...Object.keys(A)])].every(z=>(x[z]??0)===(A[z]??0))}let se=e=>Ge({quote:i.quote,operation:e,requestId:null,pending:!1,destroyed:p,canReselect:i.canReselect});async function Pe(e){let t=e.merchantExecution;if(!(!R()||!e.checkoutUrl||r.checkoutNavigation==="after_confirmation"&&se(e).type!=="checkout"||t?.type==="purchase"&&!["not_started","pending"].includes(t.paymentStatus)||ve.get(e.operationId)===e.checkoutUrl)){ve.set(e.operationId,e.checkoutUrl);try{r.onCheckoutUrl?await r.onCheckoutUrl(e.checkoutUrl):d.defaultView?.location.assign(e.checkoutUrl)}catch(n){throw ve.delete(e.operationId),n}}}let Q=(e,t=!1)=>{if(t){let n=e instanceof k?e.code:void 0;n==="CAPABILITY_UNAVAILABLE"||n==="NOT_CONFIGURED"?(l=null,u.textContent=a?"\u6682\u65F6\u65E0\u6CD5\u4E3A\u6B64\u5957\u9910\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002":"Pricing for this plan is unavailable. Payment hasn\u2019t started."):i.canReselect===!0&&!E?u.textContent=a?"\u672A\u80FD\u53D6\u5F97\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002\u8BF7\u91CD\u65B0\u9009\u62E9\u5957\u9910\u3002":"We couldn\u2019t prepare your price. Payment hasn\u2019t started. Choose a plan again.":n==="COMMAND_PENDING"?u.textContent=a?"\u4ECD\u5728\u51C6\u5907\u62A5\u4EF7\uFF0C\u8BF7\u91CD\u8BD5\u4EE5\u67E5\u770B\u7ED3\u679C\u3002":"Your price is still being prepared. Retry to check the result.":u.textContent=a?"\u672A\u80FD\u53D6\u5F97\u62A5\u4EF7\uFF0C\u4ED8\u6B3E\u5C1A\u672A\u5F00\u59CB\u3002\u8BF7\u91CD\u8BD5\u3002":"We couldn\u2019t prepare your price. Payment hasn\u2019t started. Try again."}else u.textContent=e instanceof k&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?ot(e,a):e instanceof k?e.message:a?"\u64CD\u4F5C\u672A\u5B8C\u6210\uFF0C\u8BF7\u91CD\u8BD5\u3002":"This action couldn\u2019t be completed. Try again.";y.hidden=l===null,t&&!g?.responsive&&u.scrollIntoView?.({block:"nearest"}),W(t&&D?.quoteError?D.quoteError:r.onError,e)},ce=new WeakMap;function le(e){K=e,F?.updateCapabilities?.(h.capabilities,qe(h));for(let t of $?.querySelectorAll("button")??[])e?(ce.set(t,t.disabled),t.disabled=!0):ce.has(t)&&(t.disabled=ce.get(t),ce.delete(t)),Ne(t)}function Ee(){u.textContent=a?"\u6682\u65F6\u65E0\u6CD5\u64CD\u4F5C\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002":"This action is unavailable right now. Try again in a moment."}async function yt(e){if(r.beforeAction)try{await r.beforeAction()}catch(t){throw l=e,t}}async function q(e){if(K||p)return;if(!R()){Ee();return}let t=e===ue,n=t?pt:dt;le(!0),y.hidden=!0,u.textContent=n;try{if(await yt(e),p)return;if(!R()){l=e,y.hidden=!1,Ee();return}await e()}catch(s){p||Q(s,t)}finally{le(!1),u.textContent===n&&(u.textContent="")}}async function wt(e){await lt(G,e,r)}function He(e){return Se(i).type==="recording"||se(e).type==="recording"}function Be(e){let t=e.merchantTerms,n=t?.subscriptionTerms?.items??[],s=t?t.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),o=t?n.length===1&&n[0]?.amountMinor===s&&n[0]:e.lines.length===1&&e.lines[0]?.catalogAmountMinor===s&&e.lines[0],m=s===null?ee(t.subtotalMinor-t.discountMinor,e.currency)+(a?" + \u5F85\u786E\u8BA4\u7A0E\u8D39":" + tax confirmed at checkout"):ee(s,e.currency)+(o?ie(o.interval,a?"zh-CN":"en",o.intervalCount??1):""),x=e.lines.map(A=>A.productName).join(", ");return{label:x?`${x} \xB7 ${m}`:m,recurring:o}}async function N(e,t=r.checkoutNavigation!=="after_confirmation"){if(p)return;if(!R()){l=async()=>N(await i.read()),y.hidden=!1;return}if(u.textContent=ct(e.status,a),He(e)){let o=e.merchantExecution?.type==="purchase"&&e.merchantExecution.recordingStatus==="failed";u.textContent=o?a?"\u4ED8\u6B3E\u548C\u5546\u6237\u5904\u7406\u5DF2\u5B8C\u6210\uFF0C\u4F46\u4EA4\u6613\u8BB0\u5F55\u5931\u8D25\u3002\u8BF7\u8054\u7CFB\u5546\u6237\u4FEE\u590D\uFF0C\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"Payment and fulfillment succeeded, but recording failed. Contact the merchant to repair this purchase; do not buy again.":a?"\u4ED8\u6B3E\u548C\u5546\u6237\u5904\u7406\u5DF2\u5B8C\u6210\uFF0C\u6B63\u5728\u786E\u8BA4\u4EA4\u6613\u8BB0\u5F55\u3002\u8BF7\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"Payment and merchant fulfillment are complete. Recording is pending confirmation; do not purchase again.",y.textContent=a?"\u67E5\u8BE2\u8BB0\u5F55":"Check recording",l=async()=>N(await i.read()),y.hidden=!1;return}if(e.problem){let o=e.problem;l=ne,y.textContent=a?"\u68C0\u67E5\u5E76\u6062\u590D\u539F\u64CD\u4F5C":"Check and recover original purchase",Q(new k(o.code,o.reason==="RESULT_UNKNOWN"?a?"\u4ED8\u6B3E\u7ED3\u679C\u5C1A\u672A\u786E\u5B9A\uFF0C\u8BF7\u6062\u590D\u539F\u64CD\u4F5C\uFF0C\u6682\u52FF\u91CD\u590D\u8D2D\u4E70\u3002":"The payment result is unknown. Recover the original purchase before buying again.":o.phase==="fulfillment"?a?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u5546\u6237\u6743\u76CA\u5904\u7406\u9700\u8981\u6838\u5BF9\u3002":"Payment was recorded. Access fulfillment needs attention.":o.code==="CAPABILITY_UNAVAILABLE"?a?"\u5546\u6237\u5C1A\u4E0D\u652F\u6301\u672C\u6B21\u8D2D\u4E70\u6240\u9700\u7684\u5B8C\u6574\u80FD\u529B\uFF0C\u8BF7\u5904\u7406\u540E\u6062\u590D\u539F\u64CD\u4F5C\u3002":"The merchant does not currently support all actions required by this purchase. Recover the original purchase after this is resolved.":o.code==="NOT_CONFIGURED"?a?"\u4ED8\u6B3E\u670D\u52A1\u8FDE\u63A5\u9700\u8981\u5904\u7406\uFF0C\u8BF7\u8054\u7CFB\u5546\u6237\u540E\u6062\u590D\u539F\u64CD\u4F5C\u3002":"The payment connection needs attention. Contact the merchant, then recover the original purchase.":a?"\u539F\u8D2D\u4E70\u64CD\u4F5C\u9700\u8981\u5904\u7406\uFF0C\u8BF7\u67E5\u8BE2\u6216\u6062\u590D\u6B64\u64CD\u4F5C\u3002":"The original purchase needs attention. Check or recover this operation.",void 0,void 0,o));return}if(e.merchantExecution?.type==="purchase"&&e.merchantExecution.paymentStatus==="succeeded"&&!["applied","not_applicable"].includes(e.merchantExecution.fulfillmentStatus)&&(u.textContent=a?"\u4ED8\u6B3E\u5DF2\u8BB0\u5F55\uFF0C\u6B63\u5728\u7B49\u5F85\u5546\u6237\u5B8C\u6210\u5904\u7406\u3002":"Payment was recorded. Waiting for merchant fulfillment."),e.status==="complete"){l=null,await wt(e);return}if(e.status!=="pending"){if(i.canReselect===!1){u.textContent=a?"\u6B63\u5728\u6838\u5BF9\u539F\u8D2D\u4E70\u7ED3\u679C":"Checking the original purchase result",y.textContent=a?"\u67E5\u8BE2\u7ED3\u679C":"Check result",l=async()=>N(await i.read()),y.hidden=!1;return}e.status==="cancelled"?u.textContent=a?"\u8FD9\u7B14\u8D2D\u4E70\u5DF2\u53D6\u6D88\uFF0C\u53EF\u4EE5\u91CD\u65B0\u9009\u62E9\u65B9\u6848\u3002":"This purchase was cancelled. Choose a plan to start again.":e.status==="failed"&&(u.textContent=a?"\u8FD9\u7B14\u8D2D\u4E70\u672A\u80FD\u5B8C\u6210\uFF0C\u53EF\u4EE5\u91CD\u65B0\u9009\u62E9\u65B9\u6848\u3002":"This purchase didn\u2019t go through. Choose a plan to try again."),y.textContent=a?"\u91CD\u8BD5":"Retry",l=null,E=null;return}if(!t&&se(e).type==="checkout"){let o=i.quote,m=o?.operationId===e.operationId?Be(o).label:"";u.textContent=Ce?m?a?`${m} \u5C1A\u672A\u4ED8\u6B3E\u3002\u518D\u6B21\u9009\u62E9\u8BE5\u65B9\u6848\u5373\u53EF\u7EE7\u7EED\u4ED8\u6B3E\u3002`:`${m} is still unpaid. Choose it again to continue paying.`:a?"\u4E4B\u524D\u7684\u8D2D\u4E70\u5C1A\u672A\u4ED8\u6B3E\u3002\u518D\u6B21\u9009\u62E9\u8BE5\u65B9\u6848\u5373\u53EF\u7EE7\u7EED\u4ED8\u6B3E\u3002":"Your earlier purchase is still unpaid. Choose that plan again to continue paying.":"",Ce=!1,l=null;return}await Pe(e);let n=Date.now()+6e5,s=2e3;me=!0,W(r.onObservationChange,!0);try{for(;!p&&Date.now()<n;){if(await st(s,d,fe.signal),p)return;if(!R()){l=async()=>N(await i.read()),y.hidden=!1;return}let o=await i.read();if(!t&&se(o).type==="checkout"){await N(o,!1);return}if(!o.problem&&o.status==="pending"&&await Pe(o),o.status!=="pending"||o.problem||He(o)){await N(o);return}s=Math.min(s*1.5,3e4)}}finally{me=!1,W(r.onObservationChange,!1)}l=async()=>N(await i.read()),y.hidden=!1}async function xe(e=!1){let t=await i.read();if(p)return;if(!R()){l=()=>xe(e),y.hidden=!1;return}let n=i.quote;if(n&&Je(t,{operationId:n.operationId,currency:n.currency},"The original purchase operation changed"),n&&t.status==="pending"&&t.quoteFinalized===!1&&!t.confirmedAt&&!t.checkoutUrl&&!t.nativePurchase&&!t.merchantExecution&&!t.problem&&!i.pendingCancellation){Fe(n);return}await N(t,e||void 0)}async function ne(){$?.remove(),$=null,l=ne;let e=await i.confirm();if(!R()){l=ne,y.hidden=!1;return}if(e.problem){await N(e);return}if(e.status==="pending"){if(e.checkoutUrl)await Pe(e);else if(e.execution&&e.execution.provider!=="merchant"||e.nativePurchase){if(!r.onPurchase)throw new k("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await r.onPurchase({operation:e,signal:fe.signal})}}l=async()=>N(await i.read()),await N(e,!0)}function Fe(e){$?.remove();let t=!(Date.parse(e.expiresAt)>Date.now());u.textContent=t?a?"\u6B64\u62A5\u4EF7\u5DF2\u8FC7\u671F\u3002\u8BF7\u5148\u53D6\u6D88\uFF0C\u518D\u91CD\u65B0\u9009\u62E9\u3002":"This quote has expired. Cancel it, then choose again.":"";let n=d.createElement("div"),s=d.createElement("button"),o=d.createElement("button"),m=d.createElement("div"),x=d.createElement("p"),A=e.merchantTerms,de=a?"zh-CN":"en",z=A?.subscriptionTerms?.items??[],Re=A?A.subscriptionTerms?.trial?.days:e.lines.find(c=>c.trial)?.trial?.days,Z=Re===void 0?null:A?A.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(c=>c.trial)?0:null,je=(c,f)=>a?`${f} \u5929\u8BD5\u7528\u7ED3\u675F\u540E ${c}`:`Then ${c} after the ${f}-day trial`,{label:bt,recurring:Qe}=Be(e),gt=e.lines.map(c=>c.productName).join(", "),ze=Z===null?"":`${a?"\u4ECA\u5929\u5E94\u4ED8":"Due today"} ${ee(Z,e.currency)}`;x.textContent=ze?[gt,ze].filter(Boolean).join(" \xB7 "):bt,s.textContent=a?"\u786E\u8BA4\u8D2D\u4E70":"Confirm purchase",s.disabled=t,o.textContent=a?"\u53D6\u6D88":"Cancel",n.style.cssText=P.panel,x.style.cssText=P.summary,m.style.cssText=P.actions,s.style.cssText=P.primary,o.style.cssText=P.secondary,Ne(s),s.onclick=()=>{q(ne)};let We=async()=>{let c=await i.cancel();p||(n.remove(),$=null,await N(c))};o.onclick=()=>{l=We,q(We)};let L=d.createElement("div");if(L.style.cssText=P.terms,A){for(let f of z){if(Z===null&&f===Qe)continue;let v=d.createElement("p"),M=ee(f.amountMinor,e.currency)+ie(f.interval,de,f.intervalCount);v.textContent=Z!==null&&Re!==void 0?je(M,Re):M,L.append(v)}let c=A.subscriptionTerms?.trial;if(c){let f=d.createElement("p");f.textContent=a?`\u8BD5\u7528 ${c.days} \u5929\uFF1B${c.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${c.days}; ${c.cardRequired?"a payment method is required":"no payment method is required"}`,L.append(f)}for(let f of[...A.expectedEffects.map(v=>v.description),...A.requiredConsents.map(v=>v.summary)]){let v=d.createElement("p");v.textContent=f,L.append(v)}}else{for(let c of e.lines){if(Z!==null||c!==Qe){let f=d.createElement("p"),v=`${ee(c.catalogAmountMinor,e.currency)}${ie(c.interval,de,c.intervalCount??1)}`;f.textContent=Z!==null&&c.trial?(e.lines.length>1?`${c.productName} \xB7 `:"")+je(v,c.trial.days):`${c.productName} \xB7 ${v}`,L.append(f)}for(let f of c.prepaid??[]){let v=d.createElement("p"),M=i.view?.capabilities.plans[c.productVersionId]?.prepaid?.find(vt=>vt.internalFeatureId===f.internal_feature_id);v.textContent=`${M?.name??f.internal_feature_id} \xB7 ${f.quantity} ${a?"\u4EFD":"packs"} \xD7 ${f.terms.units}`,M&&(v.textContent+=ie(M.reset==="week"||M.reset==="month"||M.reset==="year"?M.reset:"one_time",de,M.resetCount)),L.append(v)}if(c.trial){let f=d.createElement("p");f.textContent=a?`\u8BD5\u7528 ${c.trial.days} \u5929\uFF1B${c.trial.cardRequired?"\u9700\u8981\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F":"\u65E0\u9700\u63D0\u4F9B\u4ED8\u6B3E\u65B9\u5F0F"}`:`Trial days: ${c.trial.days}; ${c.trial.cardRequired?"a payment method is required":"no payment method is required"}`,L.append(f)}}if(!e.charge){let c=d.createElement("p");c.textContent=a?"\u76EE\u5F55\u4EF7\u683C\uFF1B\u6700\u7EC8\u91D1\u989D\u4EE5\u7ED3\u8D26\u65F6\u7A0E\u8D39\u548C\u8BD5\u7528\u89C4\u5219\u4E3A\u51C6\u3002":"Catalog price; the final charge depends on checkout taxes and trial terms.",L.append(c)}}for(let c of L.children)c.style.margin="0";m.append(s,o),n.append(x,...L.childElementCount?[L]:[],m),U.prepend(n),g?.responsive||n.scrollIntoView?.({block:"nearest"}),s.focus({preventScroll:!0}),$=n,l=null}async function ue(){if(!E)return;if(l=ue,!oe){let n=i.view,s=n?.document.buttons[E.actionId],o=n&&s?.type==="checkout"?te(s.product,E.selection,n.capabilities):null;if(!o)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let m=await r.resolveOfferId?.({actionId:E.actionId,productVersionId:o});if(p)return;m!==void 0&&(E.offerId=m),oe=!0}if(!R()){y.hidden=!1;return}let e;try{e=await i.preview(E)}catch(n){throw i.canReselect===!0&&(E=null,oe=!1,l=null),n}if(p)return;let t=e.merchantTerms;if(r.confirmOnHostedCheckout&&R()&&e.provider==="merchant"&&e.billingSubscriptionId===null&&t?.request.action==="purchase"&&t.request.mode==="subscription"&&t.subscriptionTerms?.trial===null&&t.requiredConsents.length===0&&Date.parse(e.expiresAt)>Date.now()){let n=a?"\u6B63\u5728\u6253\u5F00\u6536\u94F6\u53F0\u2026":"Opening checkout\u2026";u.textContent=n;try{await ne()}catch(s){p||Q(s)}finally{u.textContent===n&&(u.textContent="")}return}Fe(e)}function X(e="destroy"){p||(p=!0,r.signal?.removeEventListener("abort",B),i.signal?.removeEventListener("abort",B),C.finish("dismissed"),Ue?.(),fe.abort(),_e?.disconnect(),g?.destroy(),F?.destroy(),i.destroy(),w.open&&w.close(),w.remove(),I.remove(),O(),e==="dismiss"&&W(r.onDismiss))}S=X;async function ke(){if(!j||p||ae||V==="closing"||!V&&!R())return;if(!D){X("dismiss");return}let e=d.createElement("p");e.setAttribute("role","status"),e.textContent=a?"\u6B63\u5728\u5173\u95ED\u2026":"Closing\u2026",H||(H=d.createElement("div"),H.style.cssText=U.style.cssText,U.replaceWith(H),Y.inert=!0),b.hidden=!1,H.replaceChildren(e,b),V="closing",b.setAttribute("aria-disabled","true"),b.focus({preventScroll:!0});try{await D.dismiss()}catch(t){p||W(r.onError,t)}p||(V="retry",e.textContent=a?"\u672A\u80FD\u786E\u8BA4\u5173\u95ED\uFF0C\u8BF7\u91CD\u8BD5\u3002":"Could not confirm closure. Try again.",b.textContent=a?"\u91CD\u8BD5\u5173\u95ED":"Retry closing",b.removeAttribute("aria-label"),b.removeAttribute("aria-disabled"))}b.onclick=()=>{ke()},w.addEventListener("cancel",e=>{e.preventDefault(),ke()}),y.onclick=()=>{l&&q(l)};function Ie(e){C.finish("error",e),X()}function Ae(){if(!(!Ve||j||p||ae||g&&!R()))try{let e=t=>{be?.(),g&&(w.showModal(),g.responsive&&w.focus({preventScroll:!0}),!t&&r.loading!=="host"&&Ze(w,g.type,g.responsive)),j=!0};D?D.present(()=>C.present(()=>e(!0))):C.present(e)}catch(e){Ie(e),Q(e)}}try{if(J.type==="inline")b.hidden=Object.values(h.document.buttons).some(t=>t.type==="close"),Me(),be=rt(I,T),T.append(I);else{let t={sm:420,md:640,lg:900};w.style.cssText=`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${"size"in J?t[J.size]+"px":"100vw"}`,w.setAttribute("aria-label",h.document.name),b.textContent="\xD7",b.setAttribute("aria-label",a?"\u5173\u95ED":"Close"),et(b,h.document.screen.theme),Ke(h.document)?(b.hidden=!0,w.append(I)):w.append(b,I),T.append(w),g=Xe(w,{...h.document.screen,presentation:J},we),g.latch(),g.responsive&&(I.style.display="flex",I.style.flexDirection="column",I.style.maxHeight="100%",Y.style.overflow="clip",Y.style.minHeight="0"),be=nt(w)}F=ut(Y,{mode:"live",rendererUrl:i.webViewUrl,title:h.document.name,hostPresentation:()=>g?.type??J.type,reportContentHeight:g?.responsive,onResize:t=>{if(!g?.responsive)return;let n=Math.min(t,ye);Y.style.height=`${n}px`,g.setContentHeight(n+(H??U).getBoundingClientRect().height)},onAction(t,n={}){if(!j||p||V)return;if(!R()){Ee();return}let s=i.view,o=s?.document.buttons[t];if(!o)return;if(o.type==="close"){q(async()=>{await r.onAction?.(t),X(r.onAction?"action":"dismiss")});return}if(o.type==="action"){l=async()=>{if(o.action.type==="event"){if(!r.onEvent)throw new k("EVENT_HANDLER_REQUIRED","Provide the event handler");await r.onEvent(o.action.event)}else r.onOpenUrl?await r.onOpenUrl(o.action.url):d.defaultView?.location.assign(o.action.url);await r.onAction?.(t),l=null},q(l);return}if($&&i.canReselect===!1){u.textContent=a?"\u8BF7\u5148\u786E\u8BA4\u6216\u53D6\u6D88\u5F53\u524D\u8D2D\u4E70\u3002":"Confirm or cancel the current purchase first.",g?.responsive||$.scrollIntoView?.({block:"nearest"}),$.querySelector("button")?.focus({preventScroll:!0});return}if((i.quote||E)&&i.canReselect===!1){let x=!!s&&!!i.quote&&ht(i.quote,s,o.product,n);Ce=!!i.quote&&!x,l=i.quote?()=>xe(x):ue,q(l);return}let m=s&&te(o.product,n,s.capabilities);if(!s||!m){Q(new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(r.onPurchaseIntent){l=null,q(async()=>{let x={actionId:t,productVersionId:m,selection:structuredClone(n),featureQuantities:Oe(s.document.screen,m,n,s.capabilities)};ge=!0,await r.onPurchaseIntent(x)});return}if(E&&E.actionId!==t){Q(new k("COMMAND_PENDING","Finish the current purchase"));return}E||(E={requestId:crypto.randomUUID(),actionId:t,selection:n},oe=!1),q(ue)},onEscape:()=>{ke()},onError:t=>{let n=new Error(t);!j&&!p&&Ie(n),Q(n)},onRendered:t=>{t&&w.setAttribute("aria-label",t),Ve=!0,Ae()}}),we(),F.update(h.document.screen,h.document.screen.strings.defaultLocale,{capabilities:h.capabilities,unavailableActions:De(h),serverInput:{bindings:[],answers:{}}}),Ue=i.subscribe?.(he),he(i.view??h),await C.wait(F.ready);let e=i.operation;(i.quote||e&&(e.confirmedAt||e.checkoutUrl||e.status==="complete"))&&(l=()=>xe(),q(l))}catch(e){throw Ie(e),e}return{check:G,host:{get observing(){return me},get recovery(){return ft()},async prepareFallback(){if(K||p||V||ge)return{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null};le(!0);try{let e=await Ye(i);return e.type==="native"&&X(),e}finally{le(!1)}},setSuspended(e){ae=e,I.hidden=e,e&&w.open?w.close():!e&&!j?Ae():!e&&!p&&j&&J.type!=="inline"&&!w.open&&w.showModal()},destroy:X,refresh:async()=>{if(!R()){if(i.view)return i.view;throw new k("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await i.refresh();return he(e),Ae(),e}}}}export{zt as showPaywall};