@tinkerlandai/longplay-sdk 0.10.49 → 0.10.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/README.zh-CN.md +1 -1
  4. package/dist/{ai-usage-B-qsCn-k.d.ts → ai-usage-gcDQqLb2.d.ts} +1 -1
  5. package/dist/{api-DpRb_Pd3.d.ts → api-D0Qu0isy.d.ts} +21 -21
  6. package/dist/chunk-2G23BYBI.js +1 -0
  7. package/dist/{chunk-ZV23WM25.js → chunk-3TSFGU4T.js} +1 -1
  8. package/dist/{chunk-JOTTHPSC.js → chunk-3Z3HL42M.js} +2 -2
  9. package/dist/{chunk-QRHCZEV6.js → chunk-4NO6U4X6.js} +1 -1
  10. package/dist/chunk-67LPUJMN.js +10 -0
  11. package/dist/chunk-7GU34JD4.js +1 -0
  12. package/dist/{chunk-CIYPQIPH.js → chunk-B4SM2KRI.js} +1 -1
  13. package/dist/chunk-CGJZIDG3.js +1 -0
  14. package/dist/{chunk-F4X2JSXX.js → chunk-DB5S72HJ.js} +1 -1
  15. package/dist/{chunk-JXWRLNK7.js → chunk-FN462OVO.js} +1 -1
  16. package/dist/{chunk-C5VTYFI7.js → chunk-GJSQZGBE.js} +1 -1
  17. package/dist/chunk-IXXVMGMF.js +1 -0
  18. package/dist/{chunk-KN2QFJOQ.js → chunk-MVUNV5XR.js} +1 -1
  19. package/dist/{chunk-IA66JXF6.js → chunk-TIUD3N72.js} +1 -1
  20. package/dist/chunk-TM72XBM5.js +1 -0
  21. package/dist/{chunk-MOHKDHS2.js → chunk-US65SQX4.js} +1 -1
  22. package/dist/{chunk-AACOUGCH.js → chunk-VPYKAEHU.js} +1 -1
  23. package/dist/{configuration-sync-7ruSsSrL.d.ts → configuration-sync-DObsuVof.d.ts} +3 -3
  24. package/dist/{content-B3RWDOOH.js → content-VTHRQSFT.js} +1 -1
  25. package/dist/funnel-host-purchase-HBQOWEES.js +1 -0
  26. package/dist/{funnel-local-client-BMxDQWE6.d.ts → funnel-local-client-DzRzPX4x.d.ts} +53 -53
  27. package/dist/{funnel-paywall-prerender-SM7FH55U.js → funnel-paywall-prerender-MD4UI2AP.js} +1 -1
  28. package/dist/{funnel-process-client-DNR9nHs8.d.ts → funnel-process-client-DGRmy5KN.d.ts} +28 -28
  29. package/dist/{funnel-runtime-host-T7QZU2NO.js → funnel-runtime-host-NZAV6C5O.js} +1 -1
  30. package/dist/index.d.ts +32 -18
  31. package/dist/index.js +1 -1
  32. package/dist/native-shell.js +1 -1
  33. package/dist/openrouter.d.ts +3 -3
  34. package/dist/openrouter.js +1 -1
  35. package/dist/page.d.ts +2 -2
  36. package/dist/page.js +1 -1
  37. package/dist/paywall-DKTGQZDJ.js +1 -0
  38. package/dist/{paywall-content-MVU3X635.js → paywall-content-SML4CL2Q.js} +1 -1
  39. package/dist/{paywall-session-ISBKCULC.js → paywall-session-YKE2CHHI.js} +1 -1
  40. package/dist/popup.d.ts +7 -3
  41. package/dist/popup.js +1 -1
  42. package/dist/{presentation-loading-mEA1iohf.d.ts → presentation-loading-BWUNotNa.d.ts} +51 -6
  43. package/dist/react-native.d.ts +7 -7
  44. package/dist/react-native.js +1 -1
  45. package/dist/{screen-renderer-HOIWGE5V.js → screen-renderer-HW2WXDTR.js} +1 -1
  46. package/dist/server.d.ts +10 -10
  47. package/dist/server.js +1 -1
  48. package/dist/visual.js +1 -1
  49. package/package.json +1 -1
  50. package/dist/chunk-2UXX62Y4.js +0 -1
  51. package/dist/chunk-CMKMFT4H.js +0 -1
  52. package/dist/chunk-DEJKZZTA.js +0 -318
  53. package/dist/chunk-FEEBBJEK.js +0 -1
  54. package/dist/chunk-L7C5TKKV.js +0 -1
  55. package/dist/chunk-YONZ4NEY.js +0 -1
  56. package/dist/funnel-host-purchase-QRREIXEJ.js +0 -1
  57. package/dist/paywall-6OURDDMJ.js +0 -1
  58. package/dist/{chunk-JOTTHPSC.js.LEGAL.txt → chunk-3Z3HL42M.js.LEGAL.txt} +0 -0
  59. package/dist/{funnel-node-evaluation-COIh1hKs.d.ts → funnel-node-evaluation-CRRTh1je.d.ts} +3 -3
  60. package/dist/{screen-qUBRsUi9.d.ts → screen-CJepeiBT.d.ts} +21 -21
@@ -1 +0,0 @@
1
- import{a as ye,b as we}from"./chunk-N3PZMMOO.js";import{d as pe,e as $}from"./chunk-OPUIFAQS.js";import{a as fe}from"./chunk-ZDIWOE4Q.js";import{a as P}from"./chunk-DSPLGTQI.js";var Ce=5*6e4,Ae=15e3,ge=new WeakMap;function Oe(i){return ge.get(i)}var C=i=>Array.isArray(i)?i.map(C):i&&typeof i=="object"?Object.fromEntries(Object.keys(i).sort().map(n=>[n,C(i[n])])):i,R=(i,n)=>JSON.stringify(C(i))===JSON.stringify(C(n)),me=i=>JSON.stringify(C([i.funnelId,i.locale??null,i.parameters??{}])),Ee=["onObservationChange","onPurchase","onCheckoutUrl","resumeCheckout","allowNewPurchase","checkoutNavigation","terminateCheckout","beforeCheckoutReplacement","purchaseConfirmation","confirmOnHostedCheckout","resolveOfferId","resolveSubscriptionChange","onOpenUrl","onEvent","onAction","onComplete","onError"];function Fe(i,n){let z=e=>structuredClone({funnelId:e.funnelId,locale:e.locale,parameters:e.parameters}),y,Q="",Y=n.start instanceof Promise?void 0:z(n.start),D=e=>e?.parameters?.commerce,Z=Promise.resolve(n.start).then(e=>e?z(e):void 0),M=n.maxAgeMs??Ce,ee=new AbortController,p=AbortSignal.any([ee.signal,n.client.identitySignal,...n.signal?[n.signal]:[]]),q=()=>o("released","aborted"),t="preparing",ne,_,x=()=>{},V=0,h=null,m=null,g=null,u=null,b,L,ae=new Map,f=null,O=new Set,S=new Map,j,te=new Promise(e=>j=e),T,he=new Promise(e=>T=e);function F(e,a){t!==e&&(t=e,ne=a,P(n.onState,e))}function be(){p.removeEventListener("abort",q),H(),m?.destroy(),m=null,h?.remove(),h=null,g=null}function o(e,a){["adopted","unavailable","released","closed"].includes(t)||(F(e,a),be(),j(!1),T(null))}let J=e=>`error:${e?.code??e?.name??"unknown"}`,U=i.ownerDocument.defaultView,A=!0,re=null,I=!1,ve=e=>e.storageArea===U?.localStorage&&(e.key===null||e.key.startsWith("indiana.funnel.purchases.")),oe=e=>{ve(e)&&N()},Pe=n.client.subscribe(()=>N());function H(){A&&(A=!1,U?.removeEventListener("storage",oe),Pe(),x())}let G=()=>A&&(t==="ready"||t==="preparing");function W(e){(t==="ready"||t==="preparing")&&o("unavailable",e)}function N(){if(t==="ready"&&Date.now()-V>=M)return H();I=!0,re??=(async()=>{for(;I&&y&&G();){I=!1;try{await n.client.retained()==="pending"&&W("purchase_pending")}catch(e){p.aborted?o("released","aborted"):W(J(e))}}})().finally(()=>{re=null,I&&y&&G()&&N()})}U?.addEventListener("storage",oe),p.addEventListener("abort",q,{once:!0});let le=n.client.findPurchase();le.catch(()=>{});let E;function K(e){let a=JSON.stringify(C(e)),r=ae.get(a);return r||(r=n.client.readPaywall({paywallVersionId:E?.paywallVersionId??n.paywallVersionId??u?.id,...E?.paywallVersionId||n.paywallVersionId||u?{}:{paywallId:E?.paywallId??n.paywallId},...e}),ae.set(a,r)),r}function B(e){let a=Object.values(e.capabilities.plans);return!(Object.values(e.document.buttons).some(c=>c.type==="checkout")&&a.length===0)&&!a.some(c=>!c.available)}function ie(e,a){if(u&&!$(e,u))return o("unavailable","paywall_changed"),!1;u=e,L=a;for(let r of S.keys())P(r,structuredClone(e));return!0}async function k(){let e=await he;if(!e)throw new fe("PURCHASE_PENDING","The purchase did not start; open it again");return e}let Se={get view(){return f?f.view:u},get signal(){return f?.signal??n.client.identitySignal},get quote(){return f?.quote??null},get operation(){return f?.operation??null},webViewUrl:"bundled",get canReselect(){return f?.canReselect},get recovery(){return f?.recovery},get pendingCancellation(){return f?.pendingCancellation},subscribe(e){return S.set(e,f?.subscribe?.(e)??(()=>{})),()=>{S.get(e)?.(),S.delete(e)}},refresh:async()=>f?f.refresh():structuredClone(u),preview:async e=>(await k()).preview(e),confirm:async()=>(await k()).confirm(),cancel:async()=>(await k()).cancel(),read:async()=>(await k()).read(),destroy(){f?.destroy()}},s={options:{},handoff:{}},se={loading:"host",focusAtReveal:!0,signal:n.client.identitySignal,start:async()=>Se,canInteract:()=>s.options.canInteract?s.options.canInteract():!["unavailable","released","closed"].includes(t),async beforeAction(){let e=t!=="adopted",a=u?.capabilities,r=await k();if(e&&!R(r.view?.capabilities,a))throw new pe;await s.options.beforeAction?.()}};for(let e of Ee)Object.defineProperty(se,e,{enumerable:!0,get:()=>s.options[e]});function X(){t!=="preparing"||!g||!m||!y||!R(L?.commerce,D(y))||L?.locale!==y.locale||(F("ready"),j(!0))}let ce={present(e){if(s.handoff.present)return s.handoff.present(e);t==="preparing"&&(g=e,V=Date.now(),X())},async dismiss(){if(s.handoff.dismiss)return s.handoff.dismiss();o("closed");for(let e of[...O])P(e)},async closeAction(e){if(s.handoff.closeAction)return s.handoff.closeAction(e);s.options.onAction?await s.options.onAction(e):await ce.dismiss()},quoteError(e){s.handoff.quoteError?s.handoff.quoteError(e):P(s.options.onError,e)}};async function Ie(){if(n.paywallVersionId||n.paywallId)return{paywallVersionId:n.paywallVersionId,paywallId:n.paywallId};let e=n.configuration;if(!e)return o("unavailable","paywall_missing"),null;let a=await Promise.resolve(n.start).catch(()=>null);if(!a||t!=="preparing")return null;let r=()=>ye(e,{funnelId:a.funnelId,customerId:n.client.customerId,parameters:a.parameters??{}});if(_=await r(),t!=="preparing")return null;let c=_;if(c.type!=="paywall")return o("unavailable",we(c)??"route"),null;let l=!1;return x=e.subscribe(()=>{l||!G()||(l=!0,r().then(d=>{!(d.type==="unavailable"&&!["funnel_stopped","route_unavailable"].includes(d.reason))&&(d.type!=="paywall"||d.paywallVersionId!==c.paywallVersionId)&&W("route_changed")}).finally(()=>l=!1))}),A||x(),{paywallVersionId:c.paywallVersionId}}(async()=>{try{let[{showPaywall:e},a]=await Promise.all([import("./paywall-6OURDDMJ.js"),Ie()]);if(p.throwIfAborted(),t!=="preparing"||!a)return;let r=n.commerce??D(Y),c=n.locale??Y?.locale;if(!r)return o("unavailable","commerce_missing");if(!c)return o("unavailable","locale_missing");E=a;let l={commerce:r,locale:c},d=await K(l);if(p.throwIfAborted(),t!=="preparing"||(!B(d)&&n.start instanceof Promise&&!b&&await Z,b&&!R(l,b)&&(l=b,d=await K(l)),p.throwIfAborted(),t!=="preparing"))return;if(!B(d))return o("unavailable","plan_unavailable");if(!ie(d,l))return;h=i.ownerDocument.createElement("div"),i.append(h);let v=setTimeout(()=>t==="preparing"&&o("unavailable","timeout"),Ae);te.then(()=>clearTimeout(v));let w=await e(h,se,ce);if(!w.host||p.aborted||t!=="preparing"){w.host?.destroy(),o(p.aborted?"released":"unavailable","error");return}m=w.host,X()}catch(e){o(p.aborted?"released":"unavailable",J(e))}})(),Z.then(async e=>{if(!e)return o("unavailable","gated");let a=e,r=D(a),c=n.commerce??r;if(!R(r&&{...r,intent:void 0},c&&{...c,intent:void 0})||n.locale!==void 0&&a.locale!==n.locale)return o("unavailable","start_mismatch");if(!r)return o("unavailable","commerce_missing");b={commerce:r,locale:a.locale};try{let l=await le,d=l==="pending"?"purchase_pending":l==="found"?"original_purchase":l==="blocked"?"purchase_blocked":void 0;if(d)return o("unavailable",d);if(t!=="preparing")return;if(A&&(I=!1,await n.client.retained()==="pending"))return o("unavailable","purchase_pending");if(E||n.paywallId||n.paywallVersionId||u){let v=await K(b);if(p.throwIfAborted(),t!=="preparing")return;if(u){if(!B(v))return o("unavailable","plan_unavailable");if(!ie(v,b))return}}}catch(l){return o(p.aborted?"released":"unavailable",J(l))}t==="preparing"&&(y=a,Q=me(a),X(),I&&N())},()=>o("unavailable","gated"));let de={get state(){return t},get reason(){return ne},ready:te,get start(){return y},get prediction(){return _?structuredClone(_):void 0},matches:e=>!!y&&me(e)===Q,open(){if(t==="preparing")return"pending";if(t!=="ready"||!g)return!1;if(Date.now()-V>=M)return o("unavailable","expired"),!1;let e=g;return g=null,H(),F("shown"),e(),"shown"},destroy(){ee.abort()}};return ge.set(de,{onClose(e){return t==="closed"?(P(e),()=>{}):(O.add(e),()=>{O.delete(e)})},claim(){H()},async adopt(e,a){let r=e.paywall?.resolution,c=e.paywall&&!e.paywall.quote&&!e.paywall.operation&&!e.paywall.purchaseRequestId&&!(e.paywall.selectionGeneration??0);if(t!=="shown"||!m||!u||!r||!c||e.source.id!==y?.funnelId||e.locale!==y?.locale||!R(e.parameters??{},y?.parameters??{})||!["running","waiting"].includes(e.status)||!$(r,u))return null;let l;try{l=await a.start()}catch{return null}if(t!=="shown"||!m)return l.destroy(),null;f=l,s.options=a.options,s.handoff=a.handoff;for(let[w]of S)S.set(w,l.subscribe?.(w)??(()=>{})),l.view&&P(w,structuredClone(l.view));p.removeEventListener("abort",q),F("adopted"),T(l),O.clear();let d=m,v=h;return m=null,h=null,g=null,new Proxy(d,{get(w,ue){return ue==="destroy"?()=>{w.destroy(),v?.remove()}:Reflect.get(w,ue,w)}})},get modal(){return u?.document.presentation.type!=="inline"},get revealable(){return t==="ready"&&!!g&&Date.now()-V<M},release(){o("released")}}),de}export{Ce as a,Oe as b,Fe as c};
@@ -1 +0,0 @@
1
- import{d as f}from"./chunk-2UXX62Y4.js";import{a as d}from"./chunk-ZDIWOE4Q.js";function $(e,o,t,r){let{presentation:n,screen:i}=t,p=(i.pages.find(c=>c.id===i.initialPageId)??i.pages[0])?.theme??i.theme,g={background:i.theme.background,text:i.theme.text};o.inert=!0,o.style.cssText="width:100%;min-width:0;overflow:hidden";let u=!1,s,l=n.type==="inline"?void 0:f(e,{...i,presentation:n,theme:g});return l?.latch(),e.style.background=p.background,e.style.color=p.text,l?(n.type==="fullscreen"||n.type==="sheet")&&(e.style.position="fixed"):e.style.position="relative",import("./screen-renderer-HOIWGE5V.js").then(({mountScreenPreview:c})=>{u||(s=c(o,{mode:"live",skeleton:!0,onError(){s&&(s.destroy(),s=void 0)}}),s.update({...i,presentation:n},r))}).catch(()=>{s?.destroy(),s=void 0}),()=>{u=!0,s?.destroy(),l?.destroy()}}var y={none:0,sm:4,md:8,lg:14,full:9999},h={system:"system-ui,sans-serif",serif:"Georgia,serif",rounded:"ui-rounded,system-ui,sans-serif",mono:"ui-monospace,monospace"},v={primary:"#172033",background:"#FFFFFF",text:"#172033",radius:"md",font:"system"};function m(e){let[o,t,r]=[1,3,5].map(n=>{let i=Number.parseInt(e.slice(n,n+2),16)/255;return i<=.03928?i/12.92:((i+.055)/1.055)**2.4});return .2126*o+.7152*t+.0722*r}function E(e,o=!0){let t=m(e.primary),r=(t+.05)/.05>1.05/(t+.05)?"#111318":"#FFFFFF",n=`color-mix(in srgb, ${e.text} 22%, ${e.background})`,i=`${y[e.radius]}px`,a=`appearance:none;margin:0;min-height:44px;padding:10px 18px;border:0;border-radius:${i};font:inherit;font-size:15px;font-weight:600;line-height:1.25;cursor:pointer;touch-action:manipulation`;return{root:`width:100%;box-sizing:border-box;${o?`background:${e.background};`:""}color:${e.text};font:14px/1.5 ${h[e.font]}`,controls:"display:flex;gap:12px;padding:0 20px 12px;align-items:center;flex-wrap:wrap",pinned:`position:sticky;bottom:0;z-index:1;box-sizing:border-box;padding-top:12px;background:${e.background};border-top:1px solid ${n}`,bar:`display:flex;gap:8px;padding:12px 16px;align-items:center;flex-wrap:wrap;border-top:1px solid ${n}`,message:"flex:1 1 200px;min-width:0;margin:0;font-size:13px",status:"margin:0;font-size:13px;opacity:.72",alert:`flex:1 1 200px;min-width:0;margin:0;font-size:13px;font-weight:500;color:${m(e.background)>.4?"#B42318":"#FDA29B"}`,panel:`flex:1 0 100%;box-sizing:border-box;display:flex;flex-direction:column;gap:8px;padding:16px;border:1px solid ${n};border-radius:${i}`,summary:"margin:0;font-size:15px;font-weight:600",terms:"display:flex;flex-direction:column;gap:4px;font-size:13px;opacity:.72",actions:"display:flex;gap:8px;flex-wrap:wrap;margin-top:4px",primary:`${a};background:${e.primary};color:${r}`,secondary:`${a};background:transparent;color:${e.text};box-shadow:inset 0 0 0 1px ${n}`,link:`${a};background:transparent;color:${e.text};opacity:.72;font-weight:500`,stage:"display:flex;justify-content:center;padding:24px 20px",history:"display:flex;flex-direction:column;gap:12px;padding:20px",historyTitle:"margin:0;padding-inline-end:40px;font-size:17px;font-weight:600;line-height:1.3",historyNote:"margin:0;font-size:13px;opacity:.72",historyPages:"display:flex;gap:8px;flex-wrap:wrap;margin:0;padding:0;list-style:none",historyPage:`border:1px solid ${n};border-radius:${i};overflow:hidden`,historyRecords:`display:flex;flex-direction:column;gap:4px;margin:0;padding:12px 0 0;list-style:none;font-size:13px;border-top:1px solid ${n}`,focus:e.text}}function P(e){e.style.opacity=e.disabled?".55":"",e.style.cursor=e.disabled?"not-allowed":"pointer"}function z(e,o){e.addEventListener("focus",()=>{let t=!0;try{t=e.matches(":focus-visible")}catch{}t&&(e.style.outline=`2px solid ${o()}`,e.style.outlineOffset="2px")}),e.addEventListener("blur",()=>{e.style.outline="",e.style.outlineOffset=""})}var x={en:{network:"Connection problem. Check your network and try again.",timeout:"This is taking longer than expected. Try again.",other:"Something went wrong. Try again.",required:"Answer the questions marked * to continue.",permission:"This isn’t available right now. Contact the merchant for help."},zh:{network:"网络连接异常,请检查网络后重试。",timeout:"响应时间过长,请重试。",other:"出了点问题,请重试。",required:"请先回答带 * 的问题。",permission:"当前无法完成此操作,请联系商户。"}};function R(e,o){let t=x[o?"zh":"en"],r=e instanceof d?e.code:void 0;return r==="NETWORK_ERROR"?t.network:r==="TIMEOUT"?t.timeout:b(e)?t.permission:t.other}function b(e){return e instanceof d&&(e.code==="FORBIDDEN"||e.recovery==="check_permissions")}function L(e,o){if(!(e instanceof d)||e.code!=="INVALID_REQUEST"||e.status===void 0||e.status>=500)return!1;let t=/^Required input: (.+)$/.exec(e.message)?.[1]?.trim();return t!==void 0&&o.some(r=>r.variable===t)}function S(e){return x[e?"zh":"en"].required}function q(e,o){return e.filter(({variable:t,required:r})=>{let n=o[t];return r&&(n==null||n===""||Array.isArray(n)&&n.length===0)})}var w={zh:{pending:"处理中",complete:"已完成",cancelled:"已取消",failed:"失败",unknown:"状态待确认",prepared:"报价待确认",quoted:"报价待确认",confirmed:"处理中",effective:"已生效",scheduled:"已安排续期变更"},en:{pending:"Processing",complete:"Completed",cancelled:"Cancelled",failed:"Failed",unknown:"Status unconfirmed",prepared:"Quote ready",quoted:"Quote ready",confirmed:"Processing",effective:"Effective",scheduled:"Scheduled for renewal"}};function O(e,o){return w[o?"zh":"en"][e]}export{$ as a,v as b,E as c,P as d,z as e,R as f,b as g,L as h,S as i,q as j,O as k};
@@ -1 +0,0 @@
1
- import{b as Kn}from"./chunk-FEEBBJEK.js";import{a as Jn,b as jn,c as mn,d as wn,e as $e,f as Bn,h as Wn,i as Yn,j as Xn,k as Zn}from"./chunk-L7C5TKKV.js";import{b as Sn,c as et}from"./chunk-IA66JXF6.js";import{a as Mn}from"./chunk-W32FI2A2.js";import{c as $n,e as xn,f as Gn,h as Qn,i as _e,j as tn,k as zn,l as rn}from"./chunk-2UXX62Y4.js";import{b as Fn}from"./chunk-W3B4GT74.js";import{K as nn}from"./chunk-LE32WTZ7.js";import{a as Me,d as Nn}from"./chunk-LSHIR6QM.js";import{c as On,e as _n,f as Ln,g as Hn,h as Vn,i as Un}from"./chunk-OPUIFAQS.js";import{b as Tn}from"./chunk-HYX3EDZS.js";import{B as fn}from"./chunk-EGFVGCDG.js";import{x as Dn}from"./chunk-YFLVGOCJ.js";import{t as An}from"./chunk-MQ5LJEWV.js";import{C as kn}from"./chunk-JDIFYMSA.js";import{a as m}from"./chunk-ZDIWOE4Q.js";import{a as Ee}from"./chunk-DSPLGTQI.js";async function yn(t){let{session:b,load:P}=ut(t);try{return await P(),b}catch(n){throw b.destroy(),n}}function ut(t){let b=t.view;if(!b?.paywall)throw new m("INVALID_REQUEST","The current node is not a Paywall");let P=b.paywall.receiptId,n=b.nodeId,g=b.visit,A=b.paywall.resolution,o=b.paywall,O="document"in A?{document:A.document,offering:A.offering,capabilities:A.capabilities}:null;function u(){let i=o.resolution;return"document"in i?i:O&&{...i,document:O.document,offering:O.offering,capabilities:On(i.capabilities,O.capabilities)}}function C(i){if(!_n(i,A))throw new m("INVALID_RESPONSE","The pinned Paywall binding changed")}let R=!1,x=new Set,ie=null;function w(){let i=u();if(i&&!R)for(let a of x)Ee(a,structuredClone(i))}async function _(){I();let i=u();if(i)return structuredClone(i);if(!ie){let a=(async()=>{if("document"in o.resolution||!t.resolvePaywall)throw new m("INVALID_RESPONSE","Public Paywall reader is unavailable");let q=await Sn(t,o.resolution);return I(),C(q),O={document:q.document,offering:q.offering,capabilities:q.capabilities},w(),u()})();ie=a;let s=()=>{ie===a&&(ie=null)};a.then(s,s)}return ie.then(a=>structuredClone(a))}let l=new AbortController,E=(t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[])).find(i=>i.operation==="submit"&&i.nodeId===n&&i.visit===g&&i.input.type==="paywall_quote")?.requestId??b.paywall.purchaseRequestId,S=0,re=null,U=new Set,M=null,z=new Map;function Q(i){if(i.purchase&&i.purchase.receiptId!==P)throw new m("INVALID_RESPONSE","Purchase receipt changed");let a=i.run.paywall;return i.purchase??(a?.receiptId===P?a:null)}function I(){if(R)throw new m("IDENTITY_CHANGED","Paywall presentation has closed")}function Z(i,a,s){if(I(),a!==S||s!==void 0&&o.quote?.operationId!==s)return!1;let q=o.selectionGeneration??0,f=i.run.paywall;if(f?.receiptId===P){if((f.selectionGeneration??0)<(o.selectionGeneration??0))return!1;C(f.resolution)}let p=Q(i),F=f?.receiptId===P&&(f.selectionGeneration??0)>q,y=F?p?.quote??null:p?.quote??o.quote,Y=p?.operation??(y?.operationId===o.quote?.operationId?o.operation:null);return o.quote&&y&&Vn(o.quote,y),y&&Y&&Ln(Y,{operationId:y.operationId,membershipId:fn(y)?y.membershipId:null,...fn(y)?{featureQuantities:y.featureQuantities??{}}:{}},"Purchase operation changed"),(F||y?.operationId!==o.quote?.operationId)&&(S++,f?.receiptId===P&&(E=f.purchaseRequestId)),f?.canReselect===!0&&f.purchaseRequestId===M&&!(t.pendingCommands??[t.pendingCommand]).some(X=>X?.requestId===M)&&(M=null),o={...o,...f?.receiptId===P?f:{},...s!==void 0&&!F&&p?.canReselect!==void 0?{canReselect:p.canReselect}:{},quote:y,operation:Un(o.operation,Y,!0)},w(),!0}function N(i,a,s){return new Promise((q,f)=>{let p=!1,F=()=>{clearTimeout(j),l.signal.removeEventListener("abort",X)},y=ge=>{p||(p=!0,F(),q(ge))},Y=ge=>{p||(p=!0,F(),f(ge))},X=()=>Y(new m("IDENTITY_CHANGED","Paywall presentation has closed")),j=setTimeout(()=>Y(new m("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,s)),Math.max(0,a-Date.now()));l.signal.addEventListener("abort",X,{once:!0}),l.signal.aborted&&X(),i.then(y,Y)})}function qe(i){return new Promise(a=>{let s=()=>{clearTimeout(q),l.signal.removeEventListener("abort",s),a()},q=setTimeout(s,i);l.signal.addEventListener("abort",s,{once:!0}),l.signal.aborted&&s()})}function he(i,a){I();let s=z.get(i)??t.pendingCommands?.find(p=>p.requestId===i)??t.pendingCommand;if(s?.operation==="submit"&&s.requestId===i&&s.nodeId===n&&s.visit===g){a.type==="paywall_quote"&&s.input.type==="paywall_quote"&&s.input.predecessor&&!a.predecessor&&(a={...a,predecessor:s.input.predecessor});let p=nn.parse(s),F=nn.parse({...s,input:a});if(p.operation!=="submit"||F.operation!=="submit"||JSON.stringify(p.input)!==JSON.stringify(F.input))throw new m("CONFLICT","A purchase request cannot change its input");return z.set(i,p),p}let q=t.view;if(!q||q.nodeId!==n||q.visit!==g||q.paywall?.receiptId!==P)throw new m("PRECONDITION_FAILED","The Paywall visit has changed");let f=nn.parse({operation:"submit",requestId:i,nodeId:n,visit:g,revision:q.revision,input:structuredClone(a)});if(f.operation!=="submit")throw new m("INVALID_REQUEST","A purchase submission is required");return z.set(i,f),f}async function we(i,a){I();let{requestId:s,input:q}=i,f=Date.now()+3e4;U.add(s);try{let p=await N(t.submit(i),f,s);for(;p.run.pendingRequest?.requestId===s&&Date.now()<f&&!R&&(await qe(Math.min(1e3,f-Date.now())),!(R||Date.now()>=f));)p=await N(t.resume(s),f,s);if(R)throw new m("IDENTITY_CHANGED","Paywall presentation has closed");if(p.run.pendingRequest?.requestId===s)throw new m("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,s);if(!Z(p,a,q.type==="paywall_confirm"||q.type==="paywall_cancel"?q.operationId:void 0))throw new m("PRECONDITION_FAILED","The purchase selection has changed");M===s&&(M=null)}catch(p){if(M=s,q.type==="paywall_quote"&&t.settle&&!R&&p instanceof m&&p.status!==void 0&&![401,425].includes(p.status)&&!p.retryable&&p.recovery!=="recover_operation")try{if((await N(t.settle(s),f,s)).settlement?.state==="settled"){let y=await N(t.get(),f,s);Z(y,a)&&y.run.paywall?.purchaseRequestId===s&&o.canReselect===!0&&z.delete(s)}}catch{}throw p instanceof m&&p.code==="COMMAND_PENDING"&&p.status===void 0&&z.delete(s),p}finally{U.delete(s)}}async function W(i){if(!o.quote)throw new m("INVALID_REQUEST","A quoted purchase is required");let a=i==="confirm"?"paywall_confirm":"paywall_cancel",s=[...z.values(),...t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[])].find(f=>f.operation==="submit"&&f.input.type===a&&"operationId"in f.input&&f.input.operationId===o.quote.operationId),q=s?.operation==="submit"&&s.input.type===a&&"operationId"in s.input&&s.input.operationId===o.quote.operationId?s.requestId:crypto.randomUUID();if(await we(he(q,{type:i==="confirm"?"paywall_confirm":"paywall_cancel",operationId:o.quote.operationId,...i==="confirm"&&o.quote.merchantTerms?{merchantConfirmation:Dn(o.quote.merchantTerms)}:{}}),S),!o.operation)throw new m("INVALID_RESPONSE","The accepted purchase result is missing");return structuredClone(o.operation)}let le={get view(){return structuredClone(u())},get quote(){return o.quote?structuredClone(o.quote):null},get operation(){return o.operation?structuredClone(o.operation):null},get webViewUrl(){return t.webViewUrl},get locale(){return t.view?.locale??b.locale},get canReselect(){return o.canReselect===!0&&M===null},get recovery(){let i=t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[]),a=t.pendingPurchase;if(a&&(a.receiptId!==P||a.operationId!==o.quote?.operationId))return{type:"recover",operationId:a.operationId,requestId:i[0]?.requestId??null};let s=Me({quote:o.quote,operation:o.operation,requestId:i[0]?.requestId??M??E,pending:U.size>0||i.length>0||M!==null,destroyed:R,canReselect:o.canReselect});return s.type==="recover"&&s.requestId===null&&!R&&t.hasDurableJournal===!0&&!o.quote&&!o.operation&&(o.selectionGeneration??0)===0&&!a&&!i.length&&!U.size&&!E?{type:"native",operationId:null}:s},get pendingCancellation(){return!R&&(t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[])).some(i=>i.operation==="submit"&&i.nodeId===n&&i.visit===g&&i.input.type==="paywall_cancel"&&i.input.operationId===o.quote?.operationId)},subscribe(i){return R?()=>{}:(x.add(i),()=>x.delete(i))},async refresh(){I();let i=S,a=await t.get();if(Z(a,i),a.run.paywall?.receiptId!==P)throw new m("PRECONDITION_FAILED","Paywall presentation has changed");return _()},preview(i){let a=u();if(!a)return Promise.reject(new m("PRECONDITION_FAILED","Load the Paywall presentation first"));if(E&&E!==i.requestId&&(re||o.canReselect!==!0))return Promise.reject(new m("COMMAND_PENDING","Retry the original purchase before starting another"));let s=a.document.buttons[i.actionId],q=s?.type==="checkout"?Tn(s.product,i.selection,a.capabilities):null;if(!q)return Promise.reject(new m("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));let f=An(a.document.screen,q,i.selection,a.capabilities),p=E!==i.requestId&&(o.selectionGeneration??0)>0?{operationId:o.quote?.operationId??null,generation:o.selectionGeneration??0}:void 0,F=t.view?.parameters.commerce;if(F&&typeof F=="object"&&!Array.isArray(F)&&F.intent==="subscription_change"&&!i.subscriptionChange)return Promise.reject(new m("INVALID_REQUEST","Choose the existing membership for this subscription change"));if(i.subscriptionChange&&i.nativeOffer)return Promise.reject(new m("INVALID_REQUEST","A web membership change cannot include a store offer"));if(p&&o.canReselect!==!0)return Promise.reject(new m("COMMAND_PENDING","Original purchase requires authoritative termination"));let y;try{y=he(i.requestId,{type:"paywall_quote",actionId:i.actionId,productVersionId:q,...Object.keys(f).length?{featureQuantities:f}:{},...p?{predecessor:p}:{},...i.offerId?{offerId:i.offerId}:{},...i.nativeOffer?{nativeOffer:i.nativeOffer}:{},...i.subscriptionChange?{subscriptionChange:i.subscriptionChange}:{}})}catch(j){return Promise.reject(j)}if(E===i.requestId&&re)return re;E!==i.requestId&&S++;let Y=S;E=i.requestId;let X=(async()=>{if(await we(y,Y),!o.quote)throw new m("INVALID_RESPONSE","The accepted quote is missing");return Hn(o.quote,{productVersionId:q,featureQuantities:f,subscriptionChange:i.subscriptionChange},"The selected purchase changed"),structuredClone(o.quote)})();return re=X,X.then(()=>{re===X&&(re=null)},j=>{re===X&&(re=null),E===i.requestId&&t.pendingCommand?.requestId!==i.requestId&&j instanceof m&&j.status!==void 0&&j.status<500&&![401,425].includes(j.status)&&(E=null)}),X},confirm:()=>W("confirm"),cancel:()=>W("cancel"),async read(){if(I(),!o.quote)throw new m("INVALID_REQUEST","A quoted purchase is required");let i=o.quote.operationId,a=S,s=t.pendingCommands?.find(y=>y.operation==="submit"&&(y.input.type==="paywall_confirm"||y.input.type==="paywall_cancel")&&y.input.operationId===i)??t.pendingCommand;s?.operation==="submit"&&(s.input.type==="paywall_confirm"||s.input.type==="paywall_cancel")&&s.input.operationId===i&&await t.settle?.(s.requestId);let q=await t.get(void 0,{receiptId:P,operationId:i});I();let f=Q(q);if(f?.quote&&f.quote.operationId!==i||f?.operation&&f.operation.operationId!==i)throw new m("INVALID_RESPONSE","Purchase operation changed");let p=Z(q,a,i),F=p?o.operation:f?.operation;if(!F)throw new m("INVALID_RESPONSE","The current purchase result is missing");return p&&U.size===0&&!(t.pendingCommands?.length??(t.pendingCommand?1:0))&&(M=null),structuredClone(F)},destroy(){R=!0,L(),x.clear(),l.abort(),z.clear()}},L=t.subscribe(i=>{R||i.nodeId!==n||i.visit!==g||i.paywall?.receiptId!==P||(i.paywall.selectionGeneration??0)<(o.selectionGeneration??0)||(C(i.paywall.resolution),o={...o,resolution:i.paywall.resolution},w())});return{session:le,load:_}}function nt(t){let b=new Set,P=new Set,n=null;async function g(u,C){let R=!1;for(;!t.stopped&&t.key===u&&t.client.pendingCommand?.requestId===C;){if(!t.client.settle)throw new m("COMMAND_PENDING","The original display acknowledgement is still pending");await t.client.settle(C),R=!0,t.client.pendingCommand?.requestId===C&&await new Promise(x=>setTimeout(x,1500))}t.stopped||t.key!==u||(R&&await t.client.get(),!(t.stopped||t.key!==u)&&b.add(u))}function A(u,C){n=C;let R=()=>{n===C&&(n=null),P.delete(u)};return C.then(R,x=>{R(),t.busy||t.fail(x)}),C}function o(u){if(t.reviewing||b.has(u)||P.has(u)||t.stopped)return;P.add(u);let C=async()=>{if(t.reviewing||t.stopped||t.key!==u||b.has(u)){P.delete(u);return}if(t.busy||t.client.pendingCommand){setTimeout(()=>{C()},250);return}let R=(async()=>{if(t.staleRead){if(await t.staleRead,t.stopped||t.key!==u)return;if(t.client.pendingCommand){setTimeout(()=>{C()},250);return}}let x=t.client.view,ie=t.expected(),w=ie.requestId;try{await t.client.submit({operation:"shown",...ie})}catch(_){if(!(_ instanceof m)||_.code!=="CONFLICT"||_.status!==409||t.client.pendingCommand)throw _;await t.client.get();let l=t.client.view;if(t.stopped||t.reviewing||t.key!==u||!l||!x||l.id!==x.id||l.source.versionId!==x.source.versionId||l.nodeId!==ie.nodeId||l.visit!==ie.visit||l.revision<=ie.revision||l.stopped||!l.screen&&(!l.paywall||l.paywall.receiptId!==x.paywall?.receiptId)||!["running","waiting"].includes(l.status)||t.client.pendingCommand)throw _;let c=t.expected();w=c.requestId,await t.client.submit({operation:"shown",...c})}await g(u,w)})();A(u,R)};C()}function O(){if(n)return n;let u=t.client.pendingCommand;if(u?.operation!=="shown")return null;let C=t.key;return P.add(C),A(C,(async()=>{await t.client.retry(),await g(C,u.requestId)})())}return{report:o,settled:O,get inFlight(){return n}}}function tt(t){let b={},P=new Map;async function n(g){let A=t.client.view,o=A?.screen,O=o?.customerData.nodes[g.nodeId];if(t.stopped||t.busy||!A||!o||!O)return;if(!["refresh","next","previous","filter","sources_next","sources_previous"].includes(g.action)){let _=t.document,l=_?kn(_,g.nodeId):null,c=l?.type==="customer_data"?l.data.outputs?.[g.action]:void 0;c&&o.outputs.includes(c)?await t.perform(()=>t.client.submit({operation:"submit",...t.expected(),input:{type:"screen",output:c,answers:t.answers,selection:g.value?{[g.nodeId]:g.value}:{}}})):await t.onIntent?.(g,A);return}let C=g.action.startsWith("sources_")?O.resources.find(_=>_.key===g.value):null;if(g.action.startsWith("sources_")&&!C)throw new m("INVALID_REQUEST","Choose a current resource");let R=`${A.visit}:${g.nodeId}:${C?.key??""}`,x=P.get(R)??[null],w=b[g.nodeId]??{page:1,after:null,filter:"all",...C?{resourceKey:C.key}:{}};if(g.action==="filter"){let _=g.value;if(!_||!(O.source==="offer_history"?["all","issued","reserved","redeemed","expired","revoked"]:["all","purchase","refund","source","usage","debt","settlement"]).includes(_))throw new m("INVALID_REQUEST","Unknown data filter");w={page:1,after:null,filter:_},x.splice(0,x.length,null)}else if(g.action==="next"||g.action==="sources_next"){let _=C?.sources.at(-1),l=C?_?{kind:"ledger",cursor:{at:_.detail[0],id:_.id,type:"source"}}:null:o.dataCursors[g.nodeId];if(!l||!C&&!O.hasNext)return;x[w.page]=l,w={...w,page:w.page+1,after:l}}else if(g.action==="previous"||g.action==="sources_previous"){if(w.page<=1)return;w={...w,page:w.page-1,after:x[w.page-2]??null}}P.set(R,x),b={...b,[g.nodeId]:w},await t.perform(()=>t.client.get({nodeId:A.nodeId,visit:A.visit,revision:A.revision,components:b}))}return{get queries(){return b},intent:n,reset(){b={},P.clear()}}}function it(t){let{doc:b,holder:P,reviewHolder:n,mountScreenPreview:g}=t,A=!1,o,O=0,u=null,C="",R,x=new Map,ie=l=>l?`${l.id}:${l.nodeId}:${l.visit}:${l.revision}:${l.paywall?.quote?.operationId??""}`:"";async function w(l){if(t.stopped||!t.client.review||A&&l===o&&R?.active)return;let c=!A||l!==o;A||(C=ie(t.client.view),x.set(C,structuredClone(t.answers))),A=!0,o=l,P.hidden=!0,t.suspend(!0),n.hidden=!1;let E=++O;c&&(R?.finish("dismissed"),u?.destroy(),u=null,n.replaceChildren(),R=tn(n,t.loadingOptions,"funnel",()=>{_()}));let S=c?R:void 0;try{if(S?.start(!1,t.client.view?.locale),E!==O||t.stopped)return;let re=t.client.review(l),U=await(S?.wait(re,_e)??re);if(t.stopped||E!==O||!A)return;if(!U.review)throw new m("INVALID_RESPONSE","Historical projection is missing");u?.destroy(),u=null,S||n.replaceChildren();let M=b.createElement("div"),z=S?rn(M,n):()=>{};n.append(M);let Q=U.run.locale.startsWith("zh"),I=t.chrome;M.style.cssText=I.history;let Z=b.createElement("p");Z.textContent=Q?"只读回看":"Read-only history",Z.style.cssText=I.historyTitle,M.append(Z);let N=b.createElement("p");N.style.cssText=I.historyNote,N.textContent=U.review.pages.length?Q?"选择一页查看当时的内容,回看不会改动任何信息。":"Choose a page to see it as it was. Nothing here can be changed.":Q?"还没有可回看的页面。":"There are no earlier pages yet.",M.append(N);let qe=U.review.page?.receiptId,he=b.createElement("div");he.style.cssText=I.historyPages;for(let[le,L]of U.review.pages.entries()){let i=b.createElement("button");i.type="button",i.textContent=Q?`第 ${le+1} 页`:`Page ${le+1}`;let a=qe!==void 0&&L.receiptId===qe;i.style.cssText=a?I.primary:I.secondary,a&&i.setAttribute("aria-current","page"),$e(i,()=>t.chrome.focus),i.onclick=()=>{w(L.receiptId)},he.append(i)}if(he.childElementCount&&M.append(he),U.review.page){let le=U.review.page,L=b.createElement("div");L.inert=!0,L.style.cssText=I.historyPage,M.append(L),u=g(L,{mode:"live",rendererUrl:t.client.webViewUrl,title:le.document.name,onAction:()=>{},onAnswers:()=>{},onCustomerDataIntent:()=>{},onRendered:()=>{E===O&&!t.stopped&&S?.present(z)},onError:a=>{if(E!==O||t.stopped)return;let s=new Error(a);S?.finish("error",s),u?.destroy(),u=null,M.remove(),t.fail(s)},onEscape:()=>{_()}});let i=u;if(i.update(le.document,U.run.locale,{serverInput:{bindings:le.inputs,answers:le.answers,values:le.values}}),await i.ready,t.stopped||E!==O||!A)return}let we=Q?{issued:"已领取",reserved:"已预留",redeemed:"已使用",expired:"已过期",revoked:"已撤销",unknown:"状态待确认"}:{issued:"Issued",reserved:"Reserved",redeemed:"Used",expired:"Expired",revoked:"Revoked",unknown:"Status unconfirmed"},W=b.createElement("div");W.style.cssText=I.historyRecords;for(let le of[...U.review.coupons.map((L,i)=>`${Q?"优惠券":"Coupon"} ${i+1}: ${we[L.status]}`),...U.review.purchases.map((L,i)=>`${Q?"购买":"Purchase"} ${i+1}: ${Zn(L.status,Q)}`)]){let L=b.createElement("p");L.textContent=le,L.style.margin="0",W.append(L)}W.childElementCount&&M.append(W),U.review.page||S?.present(z),t.client.view&&await t.enqueue(t.client.view)}catch(re){if(E!==O||t.stopped)return;S?.finish("error",re),u?.destroy(),u=null,n.replaceChildren(),t.fail(re)}}async function _(){if(!A||t.stopped||!t.client.review)return;let l=++O;R?.finish("dismissed");try{if(await t.client.review(),t.stopped||l!==O)return;A=!1,O++,R?.finish("dismissed"),u?.destroy(),u=null,n.replaceChildren(),n.hidden=!0,P.hidden=!1;let c=t.client.view;ie(c)!==C?(x.set(C,structuredClone(t.answers)),t.resetScreen()):(x.delete(C),t.suspend(!1)),c&&await t.enqueue(c)}catch(c){if(l!==O||t.stopped)return;u?.destroy(),u=null,n.replaceChildren(),t.fail(c)}}return{get active(){return A},get receipt(){return o},open:w,exit:_,get drafts(){return new Map([...x].map(([l,c])=>[l,structuredClone(c)]))},stop(){A=!1,O++,R?.finish("dismissed"),u?.destroy(),u=null,n.replaceChildren(),n.hidden=!0,P.hidden=!1}}}var hn=5e3;async function dt(t,b,P){let n=b,g=n.prepared&&Kn(n.prepared),A=()=>{};function o(){n.prepared&&n.prepared.state!=="adopted"&&g?.release()}let O=()=>n.prepared?.state==="shown"&&!!g?.modal,u=n.client.identitySignal,C;try{C=await Promise.all([import("./screen-renderer-HOIWGE5V.js"),import("./paywall-6OURDDMJ.js")]),n.signal?.throwIfAborted(),u?.throwIfAborted()}catch(e){throw o(),e}let[{mountScreenPreview:R},{showPaywall:x}]=C,ie=(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&n.appManifestRelease?et({client:n.client,appManifestRelease:n.appManifestRelease,onError:n.onError}):void 0;ie?.start();let w=t.ownerDocument,_=Qn(w),l=!1,c=w.createElement("section"),E=w.createElement("div"),S=w.createElement("div"),re=w.createElement("div"),U=w.createElement("button");re.hidden=!0,U.type="button";let M=w.createElement("p"),z=w.createElement("p"),Q=w.createElement("button"),I=w.createElement("button"),Z=w.createElement("button"),N=w.createElement("dialog"),qe,he=!1;c.dataset.indianaFunnel="",c.dataset.longplayCloseOwner="sdk",c.setAttribute("aria-busy","false"),M.setAttribute("role","status"),z.setAttribute("role","alert"),z.hidden=!0,Q.type=I.type=Z.type="button",S.append(Q,U,M,z,Z,I),c.append(E,re,S),t.append(c);let we=jn,W=mn(we),le="",L=(w.documentElement.lang||"").startsWith("zh"),i,a="",s;for(let e of[Q,U,Z,I])$e(e,()=>W.focus);function q(){let e=L?"关闭":"Close";I.parentElement===N?(I.textContent="×",I.setAttribute("aria-label",e),Gn(I,we)):(I.textContent=e,I.removeAttribute("aria-label"),I.style.cssText=W.link+";margin-inline-start:auto")}function f(e){let r=e?.screen?.content.document.theme??we,d=JSON.stringify([r.primary,r.background,r.text,r.radius,r.font,I.parentElement===N]);if(d===le)return;le=d,we=r;let H=I.parentElement===N;W=mn(we,H),c.style.cssText=W.root+";min-width:0"+(H?";display:flex;flex-direction:column;min-height:100%":""),S.style.cssText=W.bar+(H?";margin-top:auto":""),S.hidden&&(S.style.display="none"),Q.style.cssText=U.style.cssText=W.secondary,Z.style.cssText=W.primary,M.style.cssText=W.status,z.style.cssText=W.alert,q(),wn(Q)}function p(){S.hidden=Q.hidden&&U.hidden&&Z.hidden&&z.hidden&&!M.textContent&&(I.hidden||I.parentElement!==S),S.style.display=S.hidden?"none":"flex",i?.responsive&&s!==void 0&&i.setContentHeight(s+S.getBoundingClientRect().height)}f();let F=null,y=null,Y=null,X="",j="",ge=!1,xe="",on="",Ge="",h=!1,ue=0,Qe=!1,gn="",sn=null,an=Promise.resolve(),vn=!n.client.view,J=P,Ae,Le,ze="",Je,pe=!1,De=null,ve=!1,je=()=>n.client.pendingCommand?.operation==="close",fe=null,K=null,ln=Mn({document:w,run:async()=>{(!y?.observing||n.client.pendingCommand)&&await dn()},delay:()=>{if(!me.pending&&!(h||!Y||!["running","waiting"].includes(Y.status)&&!n.client.pendingCommand)&&!(y?.observing&&!n.client.pendingCommand))return Y.pendingRequest||n.client.pendingCommand?1500:hn},hiddenDelay:()=>!h&&!me.pending&&n.client.pendingCommand?15e3:void 0}),ne=null;function un(){return K&&n.client.hasDurableJournal===!0&&ne?.acknowledged===!0&&ne.operationId===K.operationId&&n.client.view?.id===ne.runId&&n.client.view?.status==="closed"&&n.client.view.revision===ne.revision+1&&!(n.client.pendingCommands?.length??(n.client.pendingCommand?1:0))&&!n.client.pendingPurchase?K:null}function In(e){let r=e.run.paywall;if(ne&&e.settlement?.requestId===ne.requestId&&e.settlement.state==="settled"&&e.settlement.operationId===null&&e.run.id===ne.runId&&e.run.status==="closed"&&!e.run.pendingRequest&&e.run.revision===ne.revision+1&&e.run.nodeId===ne.nodeId&&e.run.visit===ne.visit&&r?.receiptId===ne.receiptId&&r.selectionGeneration===ne.selectionGeneration&&(r.quote?.operationId??null)===ne.operationId&&(r.operation?.operationId??r.quote?.operationId??null)===ne.operationId){let d=ne.operationId===null&&r.selectionGeneration===0&&!r.quote&&!r.operation&&!r.purchaseRequestId,H=Me({quote:r.quote,operation:r.operation,requestId:r.purchaseRequestId,pending:!1,destroyed:!1,canReselect:r.canReselect});(d||r.canReselect===!0&&H.type==="native")&&(ne.acknowledged=!0)}}let ke=null,Be=new Set,Ie={},Se=!1,de=(e,r=null)=>{h||(e instanceof m&&e.status===409&&e.reason==="STATE_CHANGED"&&e.recovery==="recover_operation"&&ln.destroy(),ke=r,Se=!1,z.textContent=Bn(e,L),z.hidden=!1,Z.hidden=n.client.pendingCommand===null,p(),Ee(n.onError,e))},me=Fn({client:n.client,document:w,conceal(){h||(be(),J?.finish("dismissed"),c.hidden=!0,l||(l=!0,_()))},async receive(e){h||await ye(n.client.view??e.run)},failed(e){if(!h){if(!me.pending){ve=!1;let r=n.client.view;r&&ye(r).then(()=>de(e),de);return}Ze(),c.parentElement!==t&&t.append(c),c.hidden=!1,Q.hidden=U.hidden=I.hidden=!0,M.textContent="",f(),de(e,n.client.pendingCommand?.requestId??null)}}}),bn=()=>{h||(ke=null,z.textContent=Yn(L),z.hidden=!1,Z.hidden=!0,p())};function Te(){let e=n.client.view;if(!e)throw new m("INVALID_REQUEST","No current Run is available");return{requestId:crypto.randomUUID(),nodeId:e.nodeId,visit:e.visit,revision:e.revision}}let T=it({client:n.client,doc:w,holder:E,reviewHolder:re,mountScreenPreview:R,loadingOptions:n,get chrome(){return W},get stopped(){return h},get answers(){return Ie},suspend(e){y?.setSuspended(e)},resetScreen(){X="",j="",xe=""},enqueue:ye,fail:de}),He=nt({client:n.client,expected:Te,fail:de,get stopped(){return h},get reviewing(){return T.active},get key(){return X},get busy(){return ue},get staleRead(){return sn}}),We=tt({client:n.client,expected:Te,perform:Ne,onIntent:n.onCustomerDataIntent,get stopped(){return h},get busy(){return ue},get document(){return F?.document},get answers(){return Ie}}),Ye=e=>`${e.id}:${e.nodeId}:${e.visit}`,Fe=e=>e&&(e.screen||e.paywall)?Ye(e):"";function Pe(){let e=n.client.view;Q.disabled=!T.active&&(ue>0||!!n.client.pendingCommand||!e?.canBack||e.stopped||!["running","waiting"].includes(e.status)||!Fe(e)||j!==Fe(e)),Q.hidden=!T.active&&!e?.canBack,wn(Q);let r=!!y&&!T.active;I.hidden=r&&!J?.active||he&&!T.active,U.hidden=!n.client.review||!T.active&&!e?.canBack;let d=e?.locale.startsWith("zh");M.textContent=r?"":ue>0||e?.pendingRequest?d?"正在处理":"Processing":e?.instruction?.type==="wait"?d?"等待中":"Waiting":"",p()}async function Cn(e){if(!e)return;let r=n.client.view;await e;let d=n.client.view;if(!r||!d||d.id!==r.id||d.nodeId!==r.nodeId||d.visit!==r.visit||d.stopped||!["running","waiting"].includes(d.status))throw new m("PRECONDITION_FAILED","The screen changed while its display was acknowledged")}async function Ne(e,r=!1,d){if(!((ue||ve||fe||K)&&!r||h||T.active&&!r)){ue++,c.setAttribute("aria-busy","true"),z.hidden=!0,ke=null,Se=!1,Pe();try{if(r||await Cn(He.inFlight),h)return;let H=await e();h||await ye(n.client.view??H.run)}catch(H){d?.(H)&&n.client.pendingCommand===null?bn():me.pending||de(H,n.client.pendingCommand?.requestId??null)}finally{ue=Math.max(0,ue-1),c.setAttribute("aria-busy",String(ue>0)),h||(Z.hidden=n.client.pendingCommand===null,Pe())}}}function Ve(){ln.schedule()}async function dn(){if(!(h||Qe||ue)&&!me.pending){if(T.active){await T.open(T.receipt);return}Qe=!0;try{let e=n.client.pendingCommand;e&&n.client.settle&&await n.client.settle(e.requestId);let r=n.client.view,d=We.queries,H=await n.client.get(r?.screen&&Object.keys(d).length?{nodeId:r.nodeId,visit:r.visit,revision:r.revision,components:d}:void 0);Se&&!h&&(Se=!1,z.hidden=!0,p()),!h&&d===We.queries&&await ye(n.client.view??H.run)}catch(e){de(e),Se=!h}finally{Qe=!1}}}function Xe(e,r,d){if(J?.active){let ce=J;return ce.setDismissHandler(()=>Pn(ce)),ce}let H=tn(t,n,"funnel",()=>Pn(H),Jn);return J=H,H.start(e,r,d),H}function Pn(e){h||pe||(pe=!0,e.finish("dismissed"),be(),c.hidden=!0,n.client.view?Re().finally(oe):oe())}function cn(){clearTimeout(Je?.timeout),Je=void 0}function be(){he=!1,cn(),Ae?.abort(),Ae=void 0,F?.destroy(),F=null,y?.destroy(),y=null,Le?.(),Le=void 0,N.open&&N.close(),E.replaceChildren(),E.style.cssText="",s=void 0,X="",j="",ge=!1,xe="",Ge=""}function Rn(){let e=w.defaultView;i?.responsive&&e&&F?.resizeViewport?.(e.innerHeight,e.innerWidth)}function Ze(){i?.destroy(),i=void 0,a=""}function Ke(e){let r=e.screen?.presentation;if(!r||r.type==="inline"){N.open&&N.close(),Ze(),I.parentElement!==S&&S.append(I),c.parentElement!==t&&t.append(c);for(let ce of["flex","display","flex-direction","justify-content"])E.style.removeProperty(ce);f(e),p();return}c.parentElement!==N&&(N.append(I,c),t.append(N)),E.style.flex="1 0 auto",E.style.display="flex",E.style.flexDirection="column",E.style.justifyContent="center",f(e);let d=e.screen.content.document,H=JSON.stringify([r,le]);if(H!==a){Ze(),a=H;let ce={sm:420,md:640,lg:900},Ce="size"in r&&!r.backdrop?",0 0 0 100vmax #16142566":"";N.style.cssText=`box-sizing:border-box;padding:0;border:0;overflow:auto;background:${we.background};color:${we.text};`+(r.type==="fullscreen"?"width:100vw;height:100dvh;max-width:100vw;max-height:100dvh;margin:0;border-radius:0":`width:${ce[r.size]}px;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);box-shadow:0 24px 80px #0003${Ce};`+(r.type==="sheet"?"margin:auto auto 0;border-radius:14px 14px 0 0":"border-radius:14px")),i=$n(N,{presentation:r,theme:d.theme,pages:d.pages},Rn),i.latch()}p(),N.setAttribute("aria-label",(qe?.screen===e.screen?.content.document.name?qe?.label:void 0)??F?.document?.name??e.screen?.content.document.name??"Funnel")}async function rt(e){if(h||pe)return;if(me.observe(),me.pending){Y=e;return}if(ve&&(je()||["running","waiting"].includes(e.status))||(Y=e,ke&&n.client.pendingCommand?.requestId!==ke&&(z.hidden=!0,ke=null),L=e.locale.startsWith("zh"),U.textContent=L?"回看":"History",Q.textContent=T.active?L?"返回当前":"Return to current":L?"返回":"Back",q(),Z.textContent=L?"重试":"Retry",Z.hidden=n.client.pendingCommand===null,Pe(),gn!==`${e.revision}:${e.visit}:${e.status}:${e.stopped}`&&(gn=`${e.revision}:${e.visit}:${e.status}:${e.stopped}`,Ee(n.onState,structuredClone(e))),h||pe))return;if((!e.pendingRequest||ve&&e.status==="closed")&&["closed","ineligible","failed"].includes(e.status)){oe();return}if(e.stopped&&O()){oe();return}if(e.stopped||n.client.configurationReady===!1){T.stop(),o(),be(),J?.finish("skipped"),c.hidden=!0,Ve();return}if(c.hidden=!1,T.active){Ve();return}let r=Fe(e),d=n.client.view;if(d&&d.revision>e.revision&&Fe(d)!==r)return;let H=!e.instruction&&!e.pendingRequest&&e.nodeType==="screen"&&["running","waiting"].includes(e.status);r!==X&&(X&&J?.finish("dismissed"),be(),X=r,Ie={...e.answers},We.reset());let ce=Ye(e);if(ze===ce){c.hidden=!0;return}if(H&&!r){c.hidden=!0;let $=n.prepared?.state==="shown"?null:Xe(!0,e.locale);!h&&!pe&&Je?.key!==ce&&(cn(),Je={key:ce,timeout:setTimeout(()=>{let v=n.client.view;if(h||!$?.active&&n.prepared?.state!=="shown"||!v||Ye(v)!==ce)return;ze=ce;let B=new Error("Funnel screen preparation timed out");$?.finish("error",B),o(),be(),de(B)},_e)}),Ve();return}cn();let ee=$=>{let v=n.client.view;return!h&&!pe&&!De&&!$.aborted&&n.client.configurationReady!==!1&&!!v&&!v.stopped&&!["closed","ineligible","failed"].includes(v.status)&&Fe(v)===r},Ce=($,v)=>{ee(v)&&(ze=r,J?.finish("error",$),be(),c.hidden=!0,de($))};if(r||((e.instruction&&e.instruction.type!=="evaluate_segment"||!["running","waiting"].includes(e.status))&&o(),Ke(e),e.instruction?.type!=="event"&&e.instruction?.type!=="open_url"&&J?.finish("skipped")),e.screen){o();let $=e.screen.content;if(!F){let ae=e.screen.presentation.type!=="inline",G=Xe(ae,e.locale);if(h||pe)return;let te=(Ae=new AbortController).signal;Ke(e),Le=ae?zn(N):rn(c,t),F=R(E,{mode:"live",closeActions:Array.from(new Set([...n.closeActions??[],...$.document.actions.filter(V=>V.type==="event"&&V.close).map(V=>V.id)])),onAuthoredClose(V){ee(te)&&(he=V,Pe())},rendererUrl:n.client.webViewUrl,title:$.document.name,...ae?{hostPresentation:()=>i?.type??e.screen.presentation.type}:{},onResize:V=>{s=V,i?.responsive&&i.setContentHeight(V+S.getBoundingClientRect().height)},onAction(V,k={},Ue={}){if(T.active||!ee(te)||j!==r)return;Ie={...Ie,...Ue};let pn=e.screen?.inputs??[],qn=Object.fromEntries(pn.filter(({variable:Oe})=>Object.hasOwn(Ie,Oe)).map(({variable:Oe})=>[Oe,Ie[Oe]]));if(Xn(pn,qn).length){bn();return}Ne(()=>n.client.submit({operation:"submit",...Te(),input:{type:"screen",output:V,answers:qn,selection:k}}),!1,Oe=>Wn(Oe,pn))},onAnswers:V=>{T.active||!ee(te)||j!==r||(Ie={...Ie,...V})},onCustomerDataIntent:V=>{T.active||!ee(te)||j!==r||We.intent(V).catch(de)},onEscape:()=>{!ee(te)||j!==r||T.active||fe||K||Re()},onError:V=>{let k=new Error(V);j===r?de(k):Ce(k,te)},onRendered:V=>{if(!(!ee(te)||j===r))try{G.present(k=>{Le?.(),Le=void 0,V&&(qe={screen:$.document.name,label:V},N.setAttribute("aria-label",V)),ae&&(N.showModal(),l=!1,i?.responsive&&N.focus({preventScroll:!0}),!k&&n.loading!=="host"&&xn(N,i?.type??e.screen.presentation.type,i?.responsive)),j=r,ge=ae,Pe()}),ee(te)&&He.report(r)}catch(k){Ce(k,te)}}}),Rn()}let v={capabilities:e.screen.capabilities,customerData:e.screen.customerData,parameters:e.parameters,serverInput:{bindings:e.screen.inputs,answers:Ie,values:e.screen.values}},B=JSON.stringify([$,e.locale,v.parameters,e.screen.inputs,e.screen.values]);if(B!==xe)F.update($.document,e.locale,v),xe=B,on=JSON.stringify(v.capabilities),Ge=JSON.stringify(v.customerData);else{let ae=JSON.stringify(v.capabilities);ae!==on&&(F.updateCapabilities(v.capabilities),on=ae),JSON.stringify(v.customerData)!==Ge&&(F.updateCustomerData(v.customerData),Ge=JSON.stringify(v.customerData))}let se=F;if(se)try{await(J?.wait(se.ready)??se.ready)}catch(ae){Ae&&Ce(ae,Ae.signal)}}else if(e.paywall&&!y){let $=e.paywall.resolution,v="document"in $?$.document:null,B=g,se=n.mountPaywallControls,ae=null,G=(Ae=new AbortController).signal,te={loading:"host",signal:G,...se&&{mountControls:k=>se(k,e)},canInteract:()=>ee(G)&&!T.active&&!fe&&!K,beforeAction:async()=>{ue++;try{await Cn(He.settled()),z.hidden=!0,ke=null,Se=!1,p()}finally{ue=Math.max(0,ue-1)}},start:()=>yn(n.client),onObservationChange:Ve,onPurchase:n.onPurchase,onCheckoutUrl:n.onCheckoutUrl,resumeCheckout:n.resumeCheckout,allowNewPurchase:n.allowNewPurchase,checkoutNavigation:n.checkoutNavigation,terminateCheckout:n.terminateCheckout,beforeCheckoutReplacement:n.beforeCheckoutReplacement,purchaseConfirmation:n.purchaseConfirmation,confirmOnHostedCheckout:n.confirmOnHostedCheckout,resolveOfferId:n.resolveOfferId,resolveSubscriptionChange:n.resolveSubscriptionChange,claimCoupon:n.claimCoupon,onEvent:n.onEvent,onOpenUrl:k=>n.onOpenUrl?n.onOpenUrl({receiptId:e.paywall.receiptId,url:k,openIn:"same_window"}):w.defaultView?.location.assign(k),onAction:async k=>{if(T.active)return;let Ue=await n.client.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:e.nodeId,visit:e.visit,revision:n.client.view?.revision??e.revision,input:{type:"screen",output:k,answers:{}}});await ye(n.client.view??Ue.run)},onError:k=>{j===r?de(k):Ce(k,G)}},V={quoteError:k=>Ee(n.onError,k),present(k){ee(G)&&(ae?.present(()=>{k(),j=r,ge=!!E.querySelector("dialog[open]"),ge&&(l=!1),Pe()}),ee(G)&&He.report(r))},async closeAction(k){h||T.active||await me.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:e.nodeId,visit:e.visit,revision:n.client.view?.revision??e.revision,input:{type:"screen",output:k,answers:{}}})},async dismiss(){if(!(h||G.aborted||T.active||fe||K||!ve&&!ee(G))){if(ve=!0,(n.resumeCheckout||n.terminateCheckout)&&lt()){Y=n.client.view,oe();return}await Re()}}};if(B&&se)o();else if(B){let k=await B.adopt(e,{options:te,handoff:V,start:()=>yn(n.client)});k&&ee(G)&&!h?(Ke(e),y=k,J?.active&&J.present(()=>{}),j=r,ge=B.modal,ge&&(l=!1),Pe(),He.report(r),T.active&&y.setSuspended(!0)):(k?.destroy(),o())}if(h||pe)return;if(!y){if(ae=Xe(!0,e.locale,v),h||pe)return;Ke(e);let k=await x(E,te,V).catch(Ue=>(Ce(Ue,G),null));!ee(G)&&!(ve&&!h&&!G.aborted)?k?.host?.destroy():k&&(y=k.host,y?.setSuspended(T.active))}}if(h||pe)return;Pe();let D=e.instruction;if(D&&(D.type==="open_url"||D.type==="event")&&!Be.has(D.receiptId)){let $=w.createElement("button");$.type="button",$.style.cssText=W.primary,$e($,()=>W.focus),E.style.cssText=W.stage,$.textContent=D.type==="open_url"?`${L?"前往":"Continue to"} ${new URL(D.url).host}`:L?"继续":"Continue",$.onclick=()=>{let v=Te(),B=D.type==="open_url"&&!n.onOpenUrl&&D.openIn==="new_window"?ot(D.url):null;Ne(async()=>{let se="success";if(D.type==="open_url")if(n.onOpenUrl)try{se=await n.onOpenUrl({receiptId:D.receiptId,url:D.url,openIn:D.openIn})===!1?"failed":"opened"}catch(G){Ee(n.onError,G),se="failed"}else se=D.openIn==="new_window"&&!B?"failed":"opened";if(D.type==="event"){if(!n.onEvent)throw new m("EVENT_HANDLER_REQUIRED","Provide the event handler");await n.onEvent(D.event)}if(h||n.client.view?.nodeId!==v.nodeId||n.client.view.visit!==v.visit)throw new m("PRECONDITION_FAILED","The client action visit changed");let ae=await n.client.submit({operation:"submit",...v,input:{type:"client_action",receiptId:D.receiptId,outcome:se}});return Be.add(D.receiptId),D.type==="open_url"&&!n.onOpenUrl&&D.openIn==="same_window"&&w.defaultView?.location.assign(D.url),ae})},J?.active?J.present(()=>E.replaceChildren($)):E.replaceChildren($)}!e.pendingRequest&&e.status==="completed"&&!Be.has(`complete:${e.id}`)&&(Be.add(`complete:${e.id}`),Ee(n.onComplete,structuredClone(e))),Ve()}function ot(e){let r=w.defaultView?.open(e,"_blank")??null;return r&&(r.opener=null),r}function ye(e){return Pe(),an=an.catch(()=>{}).then(async()=>{try{await rt(e)}catch(r){throw J?.active&&(ze=Ye(e),J.finish("error",r),be(),c.hidden=!0),r}}),an}let st=n.client.subscribe(e=>{if(!vn){if(e.stopped&&(ge||O())&&!ve){Y=e,oe();return}!ve&&(e.stopped||n.client.configurationReady===!1||X&&j!==X&&(Fe(e)!==X||["closed","ineligible","failed"].includes(e.status)))&&(be(),J?.finish("dismissed"),c.hidden=!0),ye(e).catch(de)}}),at=n.client.subscribeError?.(e=>{me.pending||de(e)});function lt(){let e=n.client.view,r=e?.paywall;return!!r?.operation&&!!e&&["running","waiting"].includes(e.status)&&Nn(Me({quote:r.quote,operation:r.operation,requestId:r.purchaseRequestId,pending:!1,destroyed:!1,canReselect:r.canReselect}))}function Re(e){if(De)return De;if(h||!e&&(fe||K))return Promise.resolve();let r=!e&&je();return!r&&n.client.view&&!["running","waiting"].includes(n.client.view.status)?(Y=n.client.view,oe(),Promise.resolve()):(De=Ne(async()=>{let d=r?await n.client.retry():await(e?n.client.submit.bind(n.client):me.submit)({operation:"close",...e??Te()});return e&&In(d),d},!0).then(()=>{let d=n.client.view;d?.status==="closed"&&!je()&&(Y=d,oe())}).finally(()=>{De=null}),De)}function oe(){ie?.destroy(),!h&&(h=!0,me.destroy(),A(),o(),n.signal?.removeEventListener("abort",oe),u?.removeEventListener("abort",oe),J?.finish("dismissed"),ln.destroy(),st(),at?.(),be(),Ze(),T.stop(),N.remove(),c.remove(),l||_(),Ee(n.onDismiss,Y?structuredClone(Y):null))}Q.onclick=()=>{if(!Q.disabled){if(T.active){T.exit();return}Ne(()=>n.client.submit({operation:"back",...Te()}))}},U.onclick=()=>{T.open()},I.onclick=()=>{J?.active?J.dismiss():fe||Re()},Z.onclick=()=>{me.pending?me.retry().catch(()=>{}):je()?Re():Ne(()=>n.client.retry())},N.addEventListener("cancel",e=>{e.preventDefault(),J?.active?J.dismiss():fe||Re()}),n.signal?.addEventListener("abort",oe,{once:!0}),u?.addEventListener("abort",oe,{once:!0});let en=!1;g&&(A=g.onClose(()=>{h||pe||(pe=!0,J?.finish("dismissed"),be(),c.hidden=!0,n.client.view?Re().finally(oe):en=!0)}));let En={destroy:oe,refresh:dn,get recovery(){let e=un();if(e)return e;if(!h&&!ue&&!ve&&!fe&&y){let r=y.recovery;if(r.type!=="native")return r}return{type:"recover",operationId:n.client.pendingPurchase?.operationId??n.client.view?.paywall?.quote?.operationId??K?.operationId??null,requestId:n.client.pendingCommand?.requestId??null}},prepareFallback(){if(fe)return fe;let e=un();if(e)return Promise.resolve(e);let r=n.client.pendingPurchase?.operationId??n.client.view?.paywall?.quote?.operationId??K?.operationId??null,d=()=>({type:"recover",operationId:r,requestId:n.client.pendingCommand?.requestId??null});if(n.client.hasDurableJournal!==!0){let D=y?.recovery;return Promise.resolve(D&&D.type!=="native"&&D.type!=="cancel"?D:d())}let H=(n.client.pendingCommands??(n.client.pendingCommand?[n.client.pendingCommand]:[])).some(D=>D.operation==="close");if(h&&!(H||K&&n.client.view?.status==="closed")||ue||Qe||De||T.active||!y&&!K&&!H)return Promise.resolve(d());let ce=y,ee=(async()=>{try{if(!K&&H){let v=await n.client.retry();return await ye(n.client.view??v.run),d()}if(!K){let v=await ce.prepareFallback();if(v.type!=="native")return v;if(n.client.hasDurableJournal!==!0)return d();K=v}let D=n.client.pendingCommands??(n.client.pendingCommand?[n.client.pendingCommand]:[]);if(D.length){let v=D.find(se=>se.operation==="close");if(!v||!ne||v.requestId!==ne.requestId)return d();let B=await n.client.retry();In(B),await ye(n.client.view??B.run)}else{let v=n.client.view,B=v?.paywall;if(!v||!B||B.selectionGeneration===void 0||(B.quote?.operationId??null)!==K.operationId||K.operationId!==null&&B.canReselect!==!0)return d();let se=B.selectionGeneration,ae=await n.client.get();await ye(n.client.view??ae.run);let G=n.client.view,te=G?.paywall;if(!G||!te||!["running","waiting"].includes(G.status)||G.stopped||G.id!==v.id||G.nodeId!==v.nodeId||G.visit!==v.visit||te.receiptId!==B.receiptId||te.selectionGeneration!==se||(te.quote?.operationId??null)!==K.operationId||K.operationId!==null&&te.canReselect!==!0||n.client.pendingPurchase||(n.client.pendingCommands?.length??(n.client.pendingCommand?1:0)))return d();let V=Te();ne={runId:G.id,operationId:K.operationId,revision:V.revision,requestId:V.requestId,nodeId:G.nodeId,visit:G.visit,receiptId:te.receiptId,selectionGeneration:se,acknowledged:!1},await Re(V)}let $=un();return $?(oe(),$):d()}catch(D){return de(D),d()}})();fe=ee;let Ce=()=>{fe===ee&&(fe=null)};return ee.then(Ce,Ce),ee},review:T.open,exitReview:T.exit,get unappliedDrafts(){return T.drafts}};try{let e=n.client.view;if(e)((n.client.viewAgeMs??hn)>=hn||e.instruction?.type==="evaluate_segment")&&(sn=dn().finally(()=>{sn=null})),await ye(e);else{if(c.hidden=!0,h)throw new DOMException("Presentation cancelled","AbortError");let r=en||n.prepared?.state==="shown"?null:Xe(n.client.view?.screen?.presentation.type!=="inline",n.client.view?.locale);if(h||pe&&!en)throw new DOMException("Presentation cancelled","AbortError");let d=n.client.get(),H=await(r?r.wait(d,_e):ct(d,_e));if(vn=!1,en)return h||await Re().finally(oe),En;await ye(n.client.view??H.run)}}catch(e){throw J?.finish("error",e),oe(),e}return En}function ct(t,b){let P;return Promise.race([t,new Promise((n,g)=>{P=setTimeout(()=>g(new Error("Presentation data timed out")),b)})]).finally(()=>clearTimeout(P))}function Zt(t,b,P){return dt(t,b,P)}export{dt as a,Zt as b};
@@ -1 +0,0 @@
1
- import{b as ee}from"./chunk-YONZ4NEY.js";import{b as j}from"./chunk-FEEBBJEK.js";import"./chunk-N3PZMMOO.js";import"./chunk-2LEDTNKQ.js";import{a as Y}from"./chunk-L7C5TKKV.js";import{b as X}from"./chunk-KN2QFJOQ.js";import"./chunk-IA66JXF6.js";import"./chunk-W32FI2A2.js";import{f as Z,h as $,i as V,j as B}from"./chunk-2UXX62Y4.js";import"./chunk-3ITNAFAH.js";import"./chunk-2I2S5ZIH.js";import"./chunk-ZV23WM25.js";import"./chunk-W3B4GT74.js";import"./chunk-Y2ASROJH.js";import"./chunk-MOHKDHS2.js";import"./chunk-HYCLLEFU.js";import"./chunk-KSME3N3A.js";import"./chunk-LE32WTZ7.js";import"./chunk-SZZIYCXK.js";import"./chunk-IDDPWGQE.js";import"./chunk-LSHIR6QM.js";import"./chunk-OPUIFAQS.js";import"./chunk-HYX3EDZS.js";import"./chunk-EGFVGCDG.js";import"./chunk-YFLVGOCJ.js";import"./chunk-VILB5M4X.js";import"./chunk-JXWRLNK7.js";import"./chunk-FRRKTQNZ.js";import"./chunk-MQ5LJEWV.js";import"./chunk-JDIFYMSA.js";import"./chunk-TNPBYYAX.js";import"./chunk-KCN6OGYG.js";import"./chunk-PF6PRPRO.js";import{a as R}from"./chunk-ZDIWOE4Q.js";import"./chunk-FYD7CMS7.js";import"./chunk-SLUA7ABW.js";import"./chunk-C5VTYFI7.js";import"./chunk-3VUPVXAV.js";import"./chunk-CIYPQIPH.js";import"./chunk-XVCSRZX4.js";import{a as w}from"./chunk-DSPLGTQI.js";import"./chunk-A5KU4MMN.js";import"./chunk-WPFTSHP2.js";import"./chunk-WOT6VMZA.js";function te(S,e){let i=S.ownerDocument,v=(e.locale??i.documentElement.lang).startsWith("zh"),U=$(i),y=i.createElement("dialog"),E=i.createElement("h2"),h=i.createElement("p"),a=i.createElement("button"),f=i.createElement("button"),P=i.createElement("button");E.textContent=v?"购买状态":"Your purchase",E.style.cssText="margin:0;font-size:20px;line-height:1.3",y.setAttribute("aria-label",E.textContent),y.style.cssText="box-sizing:border-box;width:min(640px,calc(100% - 32px));max-height:calc(100dvh - 32px);padding:24px;border:0;border-radius:16px;background:Canvas;color:CanvasText;font:14px/1.5 system-ui,sans-serif",a.textContent="×",a.setAttribute("aria-label",v?"关闭":"Close"),Z(a,{background:"Canvas",text:"CanvasText"}),h.setAttribute("role","status"),P.textContent=v?"查询状态":"Check status";for(let o of[a,f,P])o.type="button";for(let o of[f,P])o.style.cssText="min-height:44px;padding:8px 14px;margin-inline-end:8px;border:1px solid ButtonBorder;border-radius:8px;font:inherit;cursor:pointer";y.append(E,a,h,f,P);let t=!1,s=!1,p=!1,c=e.initialState;function F(o){if(t)return;c=o;let m=c.actions.includes("continue_checkout"),M=e.allowConfirm&&c.actions.includes("confirm");f.hidden=!m&&!M,f.disabled=P.disabled=s,f.textContent=m?v?"继续付款":"Continue checkout":v?"确认购买":"Confirm purchase",h.textContent=p||c.status==="blocked"?v?"暂时无法确认购买状态。请重试。":"We couldn’t check your purchase. Try again.":c.status==="complete"?v?"购买已处理。":"Your purchase has been processed.":m?v?"可以继续原订单付款。":"You can continue your original checkout.":v?"正在核对购买状态…":"Checking your purchase…"}async function N(o){if(!(t||s)){s=!0,p=!1,F(c);try{await o()}catch(m){t||(p=!0,w(e.onError,m))}finally{s=!1,F(e.client.recovery)}}}let I=()=>N(e.refresh),_=e.client.subscribe(F);function C(){t||(t=!0,e.signal.removeEventListener("abort",C),i.removeEventListener("visibilitychange",x),_(),y.remove(),U(),e.onDismiss())}function x(){i.visibilityState==="visible"&&I()}return a.onclick=C,y.addEventListener("cancel",o=>{o.preventDefault(),C()}),P.onclick=()=>{I()},f.onclick=()=>{N(async()=>{c.actions.includes("continue_checkout")?await e.client.continueCheckout(o=>{if(e.signal.throwIfAborted(),!t)return e.onCheckoutUrl?e.onCheckoutUrl(o):i.defaultView?.location.assign(o)}):e.allowConfirm&&c.actions.includes("confirm")&&await e.client.confirm()})},e.signal.addEventListener("abort",C,{once:!0}),i.addEventListener("visibilitychange",x),F(c),e.loading.present(()=>{t||e.signal.aborted||(S.append(y),y.showModal?y.showModal():y.open=!0,a.focus({preventScroll:!0}))}),{destroy:C,refresh:I,get recovery(){let o=c.purchases.filter(m=>!["native","complete"].includes(m.type));return structuredClone(o.length===1?o[0]:{type:"recover",operationId:null,requestId:null})},async prepareFallback(){return{type:"recover",operationId:null,requestId:null}},async review(){},async exitReview(){},get unappliedDrafts(){return new Map}}}var H=new WeakMap,G=new WeakMap,J=new WeakSet;function pe(S,e){let i=e.prepared,v=()=>{i&&!J.has(i)&&j(i)?.release()},U=H.get(e.client);if(U)return v(),U;let y=t=>({...t,requestId:t.requestId??crypto.randomUUID()}),E=e.allowNewPurchase!==!1&&e.start instanceof Promise?e.start:void 0,h=e.allowNewPurchase===!1||!e.start||e.start instanceof Promise?void 0:y(e.start);h&&i?.state==="ready"&&i.matches(h)&&i.open();let a=i&&(h&&(i.state==="preparing"||["shown","closed"].includes(i.state)&&i.matches(h))||E&&["preparing","ready"].includes(i.state))?i:void 0;a?J.add(a):v();let f=a&&j(a);f?.claim();let P=Promise.resolve().then(async()=>{let t=!1,s,p=0,c,F,N=!1,I=()=>{},_=()=>{},C,x=!1,o=!1,m,M=!1,l=e.signal?AbortSignal.any([e.signal,e.client.identitySignal]):e.client.identitySignal,A=()=>{H.get(e.client)===P&&H.delete(e.client),l.removeEventListener("abort",q),I(),_(),a&&J.delete(a),f?.release()};function K(){if(m)return m;let r=new Promise(b=>m=b);return G.set(e.client,r),r.then(()=>{G.get(e.client)===r&&G.delete(e.client)}),H.get(e.client)===P&&H.delete(e.client),m}let u=B(S,e,"funnel",()=>L(),Y);function q(){L()}function L(r=!1){if(!t){if(t=!0,u.finish("dismissed"),s){s.destroy();return}if(r&&C){let b=K();M=!0,C.then(async d=>{d.mode==="run"&&d.status!=="blocked"&&e.client.controller&&e.client.attempt?.requestId===h?.requestId&&await e.client.close()}).catch(()=>{}).finally(()=>{b(),w(e.onDismiss,null)}),A();return}A(),w(e.onDismiss,null)}}let W={destroy:()=>L(),refresh:()=>s?.refresh()??c??Promise.resolve(),get recovery(){return s?.recovery??{type:"recover",operationId:null,requestId:null}},prepareFallback:()=>s?.prepareFallback()??Promise.resolve({type:"recover",operationId:null,requestId:null}),review:(...r)=>s?.review(...r)??Promise.resolve(),exitReview:(...r)=>s?.exitReview(...r)??Promise.resolve(),get unappliedDrafts(){return s?.unappliedDrafts??new Map}};l.addEventListener("abort",q,{once:!0}),f&&(_=f.onClose(()=>{x?t||K():L(!0)}));try{l.throwIfAborted();let r=e.client.controller?.view?.paywall?.resolution,b=r&&"document"in r?r.document:e.loadingDocument;u.start(!0,h?.locale??e.client.attempt?.locale??b?.screen.strings.defaultLocale,b??null);let d=E?u.wait(E.then(k=>k?y(k):null,()=>null),V):Promise.resolve(h??null);d.catch(()=>{}),a?.state==="shown"?(o=!0,u.present(()=>{})):a&&["preparing","ready"].includes(a.state)&&Promise.all([a.ready,d.catch(()=>null)]).then(([k,n])=>{if(k){if(t||!u.active||!n||!a.matches(n)||!f?.revealable)return f?.release();u.present(()=>{a.open()==="shown"?o=!0:f.release()})}});let D=G.get(e.client);if(D&&await u.wait(D),t)return null;if(l.throwIfAborted(),E){let k=await d;if(t)return null;if(l.throwIfAborted(),!k)return u.finish("skipped"),A(),null;h=k}C=h?e.client.start(h):e.client.refresh();let O=await u.wait(C,V);return t?null:(l.throwIfAborted(),await z(O,u))}catch(r){if(M||m?.(),t)return null;throw u.finish("error",r),A(),w(e.onError,r),r}function re(){p++;let r=s;s=void 0,I(),I=()=>{},r?.destroy(),l.addEventListener("abort",q,{once:!0})}function Q(){if(c)return c;if(t||l.aborted)return Promise.resolve();re(),u=B(S,e,"funnel",()=>L(),Y),u.start(!0,e.client.attempt?.locale);let r=Promise.resolve().then(async()=>{try{let d=await e.client.refresh();!t&&!l.aborted&&await z(d,u)}catch(d){!t&&!l.aborted&&(w(e.onError,d),await z({...e.client.recovery,mode:"blocked",status:"blocked"},u))}});c=r;let b=()=>{c===r&&(c=void 0)};return r.then(b,b),r}async function z(r,b){let d=e.client.controller;if(r.mode==="run"&&r.status!=="blocked"&&d)return ne(d,b);if(r.purchases.length||r.status==="blocked"&&x){let D=++p;return s=te(S,{client:e.client,signal:l,loading:u,locale:e.client.attempt?.locale,onCheckoutUrl:e.onCheckoutUrl,onError:e.onError,refresh:Q,initialState:r,allowConfirm:e.allowNewPurchase!==!1,onDismiss(){D===p&&(t=!0,A(),w(e.onDismiss,null))}}),W}return u.finish("skipped"),A(),(o||x)&&(t=!0,w(e.onDismiss,null)),null}async function ne(r,b){l.removeEventListener("abort",q),x=!0;function d(){!t&&!l.aborted&&!N&&F&&e.client.recovery.status==="complete"&&(N=!0,w(e.onComplete,structuredClone(F)))}function D(n){if(l.throwIfAborted(),t)throw new DOMException("Presentation dismissed","AbortError");return e.onCheckoutUrl?e.onCheckoutUrl(n):S.ownerDocument.defaultView?.location.assign(n)}I(),I=e.client.subscribe(d);let O=++p,k=await ee(S,{...e,prepared:a,client:r,signal:l,checkoutNavigation:"after_confirmation",resumeCheckout:n=>e.client.continueCheckout(D,n),terminateCheckout:e.allowNewPurchase===!1?void 0:n=>e.client.terminateCheckout(n),async onCheckoutUrl(n){if(l.throwIfAborted(),t)throw new DOMException("Presentation dismissed","AbortError");let g=e.client.recovery;if((!g.actions.includes("continue_checkout")||!g.purchases.some(T=>T.type==="checkout"&&T.checkoutUrl===n))&&(g=await e.client.refresh(),l.throwIfAborted(),t))throw new DOMException("Presentation dismissed","AbortError");if(X(g)!==n)throw new R("PURCHASE_PENDING","Checkout differs from the original recovery proof");return D(n)},async resolveOfferId(n){if(l.throwIfAborted(),t)throw new DOMException("Presentation dismissed","AbortError");let g=e.client.attempt;if(!g)throw new R("PURCHASE_PENDING","Read the original Start before selecting an offer");let T=await e.resolveOfferId?.(n,g);if(l.throwIfAborted(),t)throw new DOMException("Presentation dismissed","AbortError");if(e.client.attempt?.requestId!==g.requestId)throw new R("PURCHASE_STORAGE_CONFLICT","The original purchase changed while selecting an offer");return T},async resolveSubscriptionChange(n){l.throwIfAborted();let g=e.client.attempt;if(t||!g)throw new R("PURCHASE_PENDING","Read the original Start before selecting a membership");let T=await e.resolveSubscriptionChange?.(n);if(l.throwIfAborted(),t||e.client.attempt?.requestId!==g.requestId)throw new R("PURCHASE_STORAGE_CONFLICT","The original purchase changed while selecting a membership");return T},onPresentationState(n){O===p&&w(e.onPresentationState,n)},onComplete(n){O===p&&(F=n,d())},onError(n){O===p&&(w(e.onError,n),n instanceof R&&(n.status===401||n.status===409&&n.reason==="STATE_CHANGED"&&n.recovery==="recover_operation")&&!l.aborted&&Q().catch(g=>w(e.onError,g)))},onDismiss(n){O===p&&(t=!0,A(),m?.(),w(e.onDismiss,n))}},b);return O!==p||t||l.aborted?(k.destroy(),t||l.aborted?null:W):(s=k,W)}});return H.set(e.client,P),P}export{pe as showFunnelPurchase};
@@ -1 +0,0 @@
1
- import{a as jt,c as Bt,d as pt,f as mt,g as Ft,k as qt}from"./chunk-L7C5TKKV.js";import{b as dt}from"./chunk-W32FI2A2.js";import{d as Mt,e as Ut,f as Vt,h as ft,i as qe,j as $t,k as Qt,l as Ht}from"./chunk-2UXX62Y4.js";import{a as St,c as lt,d as Dt,e as Nt}from"./chunk-LSHIR6QM.js";import{a as Fe,b as ye,d as ut,f as _t,j as Lt}from"./chunk-OPUIFAQS.js";import{b as de}from"./chunk-HYX3EDZS.js";import{B as O,C as Be,D as Re,E as Oe,y as Tt}from"./chunk-EGFVGCDG.js";import"./chunk-YFLVGOCJ.js";import"./chunk-VILB5M4X.js";import"./chunk-JXWRLNK7.js";import"./chunk-FRRKTQNZ.js";import{r as Pe,t as he}from"./chunk-MQ5LJEWV.js";import{i as Ot}from"./chunk-JDIFYMSA.js";import{c as ue,j as Ae}from"./chunk-TNPBYYAX.js";import{c as ct}from"./chunk-KCN6OGYG.js";import"./chunk-PF6PRPRO.js";import{a as v}from"./chunk-ZDIWOE4Q.js";import"./chunk-FYD7CMS7.js";import"./chunk-CIYPQIPH.js";import"./chunk-XVCSRZX4.js";import{a as G}from"./chunk-DSPLGTQI.js";import"./chunk-A5KU4MMN.js";import"./chunk-WPFTSHP2.js";import"./chunk-WOT6VMZA.js";async function Gt(L,i,x){if(!Re(i))throw new v("INVALID_RESPONSE","A verified completed purchase is required");let k=L?Ae.parse(L):null;if(await x.onComplete?.(i),!k||!x.check)return;let Q=Ae.parse(await x.check());if(Q.internal_feature_id!==k.internal_feature_id||Q.quantity!==k.quantity||k.observation!==void 0&&(Q.observation===void 0||Q.observation.requirementDigest!==k.observation.requirementDigest||Q.observation.authority!==k.observation.authority||ct(Q.observation.subject)!==ct(k.observation.subject)))throw new v("INVALID_RESPONSE","The access requirement changed");Q.allowed&&await x.onAccessGranted?.(Q)}function ht(L){return Object.entries(L.document.buttons).filter(([,i])=>i.type==="checkout"&&i.product.type==="fixed"&&!de(i.product,{},L.capabilities)).map(([i])=>i)}function Wt(L,i){let x=O(i)?void 0:i.lines[0];if(!O(i)&&(i.lines.length!==1||!x))return;let k=O(i)?i.productVersionId:x.productVersionId,{screen:Q,buttons:X}=L.document,T=new Map(O(i)?Object.entries(i.featureQuantities??{}):(x?.prepaid??[]).map(h=>[h.internal_feature_id,h.quantity]));function Z(h,m){if(h.hidden)return!1;if(h.type==="plan_picker"&&L.capabilities.pickers[h.id]?.options.includes(k))return m[h.id]=k,!0;if(h.type==="quantity_picker"){let Y=T.get(h.internalFeatureId);return Y!==void 0&&(!h.bind?.plan||h.bind.plan===k)&&(m[h.id]=Y),!1}if(h.type==="button"&&h.action){let Y=X[h.action];return Y?.type==="checkout"&&Y.product.type==="fixed"&&Y.product.productVersionId===k}if(h.type!=="stack")return!1;let z=h.interaction,r=h.bind?.plan===k;for(let[Y,f]of h.children.entries()){let ie={},N=Z(f,ie);if(z?.type==="toggle"||z?.type==="tabs"){if(!N)continue;return m[h.id]=z.type==="toggle"?Y===0:f.id,Object.assign(m,ie),!0}Object.assign(m,ie),N&&(r=!0,z?.type==="select"&&z.purpose==="product"&&z.pickerId&&f.type==="stack"&&f.bind?.plan===k&&(m[h.id]=f.id,m[z.pickerId]=k))}return r}for(let h of Q.pages){let m={__page:h.id};if(Z(h.root,m))return m}}async function Ln(L,i,x){let k=i.focusAtReveal?()=>{}:ft(L.ownerDocument),Q=()=>{T.finish("dismissed"),k()},X=()=>Q(),T=$t(L,i,"paywall",()=>{Q(),G(i.onDismiss)},jt);i.signal?.throwIfAborted(),i.signal?.addEventListener("abort",X,{once:!0});let Z=null,h,m,z;try{if(T.start(!0,i.loadingDocument?.screen.strings.defaultLocale,i.loadingDocument??null),T.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(Z=i.check?Ae.parse(await T.wait(i.check(),qe)):null,Z?.allowed)return T.finish("skipped"),i.signal?.removeEventListener("abort",X),k(),await i.onAccessGranted?.(Z),{check:Z,host:null};let[e,t]=await Promise.allSettled([T.wait(import("./screen-renderer-HOIWGE5V.js")),T.wait(i.start().then(a=>(T.cancelled&&a.destroy(),a)),qe)]);if(e.status==="rejected")throw t.status==="fulfilled"&&t.value.destroy(),e.reason;if(t.status==="rejected")throw t.reason;z=e.value,h=t.value,i.signal?.throwIfAborted(),h.signal?.throwIfAborted(),h.signal?.addEventListener("abort",X,{once:!0});let n=h.view??await T.wait(h.refresh(),qe);if(!n)throw new v("INVALID_RESPONSE","Paywall presentation is missing");h.signal?.throwIfAborted(),m=n}catch(e){throw T.finish("error",e),i.signal?.removeEventListener("abort",X),h?.signal?.removeEventListener("abort",X),h?.destroy(),k(),e}let r=h,{mountScreenPreview:Y}=z,f=L.ownerDocument,ie=new AbortController,N=f.createElement("section"),ae=f.createElement("div"),J=f.createElement("div"),Ge=i.mountControls,W=Ge?f.createElement("div"):void 0,p=f.createElement("p"),C=f.createElement("button"),I=f.createElement("button"),S=f.createElement("dialog"),We=r.locale||m.document.screen.strings.defaultLocale,o=We.toLowerCase().startsWith("zh"),zt=o?"正在处理…":"Processing…",Yt=o?"正在准备报价…":"Preparing your price…",M=Bt(m.document.screen.theme);N.dataset.indianaPaywall="",N.setAttribute("aria-label",m.document.name),N.style.cssText=M.root,J.style.cssText=M.controls,p.style.cssText=M.message,p.setAttribute("role","status"),I.style.cssText=M.link,I.textContent=o?"关闭":"Close",C.style.cssText=M.secondary,C.textContent=o?"重试":"Retry",C.hidden=!0,J.append(p,C,I),W&&(W.style.cssText="flex:1 0 100%;min-width:0",W.hidden=!0,J.prepend(W)),N.append(ae,J);let ze=()=>{if(W){let a=!W.childElementCount&&!W.textContent?.trim();W.hidden!==a&&(W.hidden=a)}let e=se??J,t=[...e.children].every(a=>a===p?!p.textContent:a.hidden),n=[...e.children].some(a=>a===I?!1:a===p?!!p.textContent:!a.hidden);e.style.cssText=t?M.controls.replace(/padding:[^;]+/,"padding:0"):n?`${M.controls};${M.pinned}`:M.controls,Xe()},yt=typeof MutationObserver>"u"?void 0:new MutationObserver(ze);yt?.observe(N,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let Te=m.document.presentation,Jt=Object.entries(m.document.buttons).filter(([,e])=>e.type==="close").map(([e])=>e),B,wt,Ye=!1,gt=JSON.stringify(m.capabilities),Je=e=>oe&&!be?Object.entries(e.document.buttons).filter(([,t])=>t.type==="checkout").map(([t])=>t):ht(e);function Se(e){if(w)return;m=e;let t=JSON.stringify(e.capabilities);if(t!==gt){let n=!b&&!r.quote&&!r.operation?Fe(e,q,Ct):q;JSON.stringify(n)!==JSON.stringify(q)?(q=n,B?.update(e.document.screen,We,{capabilities:ye(e),unavailableActions:Je(e),serverInput:{bindings:[],answers:{}},selection:q})):B?.updateCapabilities(ye(e),Je(e)),gt=t}Xt(e),ke()}let A,Ke=0;function Xe(){let e=f.defaultView;if(!A?.responsive||!e)return;let t=se??J,n=e.innerHeight-(A.type==="modal"?32:0);t.style.maxHeight=`${Math.max(1,n)}px`,t.style.overflowY="auto",t.style.flexShrink="0",Ke=Math.max(1,n-t.getBoundingClientRect().height),B?.resizeViewport?.(Ke,e.innerWidth)}let w=!1,oe=!1,b=null,Ze,De=!1,bt=!1,fe=!1,et,tt=!1,ee,se;function Kt(){return oe||w||ee||tt?{type:"recover",operationId:r.operation?.operationId??r.quote?.operationId??null,requestId:null}:lt(r)}let E=()=>!w&&!De&&!ee&&i.canInteract?.()!==!1,F,we=!1,ge=!1,u=null,te=null,nt="",pe=()=>i.checkoutNavigation==="after_confirmation"&&!!(i.terminateCheckout||i.resumeCheckout),q={},Ct=new Set,be,K=null;function ke(){if(!pe()||!B?.updateCheckoutControls)return;let e=r.quote,t=!K&&!!e&&!!r.operation&&R(r.operation).type==="checkout",n=Object.entries(m.document.buttons).flatMap(([a,l])=>l.type==="checkout"?[{actionId:a,policy:l}]:[]);B.updateCheckoutControls({actions:n.map(({actionId:a})=>a),resume:t?n.filter(({actionId:a,policy:l})=>Me(e,m,a,l.product,q)).map(({actionId:a})=>a):[],resumeLabel:o?"继续付款":"Continue checkout",busy:be})}function vt(){te?.remove(),te=null}async function rt(){if(K)return;if(i.resumeCheckout&&r.operation){await i.resumeCheckout(r.operation.operationId);return}let e=await r.read();if(R(e).type!=="checkout")return U(e,!1);E()&&(_e.delete(e.operationId),await Ue(e))}function Pt(){p.textContent=o?"暂时无法打开付款页面。请重试。":"Couldn’t open checkout. Try again.",C.hidden=!0}async function kt(e=!1){let t=K;if(!t)return;C.hidden=!0;let n=Date.now()+2e4;for(;E();){let a=await r.read();if(a.operationId!==t.operationId)throw new v("PURCHASE_PENDING","The original Checkout changed");if(!E())break;let l=R(a);if(l.type==="native"){K=null,vt(),b=t.selection,F=t.coupon,we=!1,ge=!1,await Ie();return}if(l.type==="complete"||l.type==="fulfillment"||l.type==="recording"){K=null,await U(a,!1);return}if(e&&l.type==="checkout"){e=!1;try{await i.terminateCheckout(t.operationId)}catch(y){G(i.onError,y)}}if(Date.now()>=n)break;await dt(1e3,f,ie.signal)}w||Pt()}async function Et(e,t,n,a){if(u=()=>Et(e,t,n,a),await i.beforeCheckoutReplacement?.(structuredClone(a)),!E())return;let l=r.operation;if(l?.operationId!==e||R(l).type!=="checkout"){u=null,l&&await U(l,!1);return}K={operationId:e,selection:t,coupon:n};let y=!1;try{await i.terminateCheckout(e)}catch(c){if(c instanceof v&&["CAPABILITY_UNAVAILABLE","NOT_CONFIGURED"].includes(c.code)){K=null,p.textContent=o?"请继续原订单,或等待它过期后再更换方案。":"Continue your original checkout, or wait for it to expire before changing plans.",G(i.onError,c);return}y=c instanceof v&&(c.status??0)>=500,G(i.onError,c)}E()&&await kt(y)}function Ne(e,t,n,a,l){let y=ye(e).checkoutCoupons?.[t],c=y?y.products[n]:i.claimCoupon&&l?Ot(e.capabilities,l,a):void 0;return c?.couponId&&c.planVersionId===n?{id:c.couponId,offerId:c.offerId}:void 0}function Xt(e){oe||b||r.quote||r.operation||nt&&p.textContent===nt||(p.textContent=Object.values(e.capabilities.plans).some(t=>t.available)?"":o?"当前账号暂无可购买的方案。":"No plans are currently available for this account.")}let _e=new Map,Le=!1;function Me(e,t,n,a,l,y){if(O(e)){let $=de(a,l,t.capabilities),le=$&&Ne(t,n,$,l,y),me=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0),$e=he(t.document.screen,e.productVersionId,l,t.capabilities);return $===e.productVersionId&&Object.keys($e).length===Object.keys(e.featureQuantities??{}).length&&Object.entries($e).every(([Qe,He])=>e.featureQuantities?.[Qe]===He)&&(!le||me?.couponId===le.id&&(!le.offerId||me.grantId===le.offerId))}let c=e.lines.length===1?e.lines[0]:void 0,s=de(a,l,t.capabilities);if(!c||!s||c.productVersionId!==s)return!1;let _=Ne(t,n,s,l,y);if((_||ye(t).checkoutCoupons?.[n])&&(_?.id??null)!==(e.discount?.couponId??null))return!1;let V;try{V=he(t.document.screen,s,l,t.capabilities)}catch{return!1}let ne=Object.fromEntries((c.prepaid??[]).map($=>[$.internal_feature_id,$.quantity]));return[...new Set([...Object.keys(V),...Object.keys(ne)])].every($=>(V[$]??0)===(ne[$]??0))}let R=e=>St({quote:r.quote,operation:e,requestId:null,pending:!1,destroyed:w,canReselect:r.canReselect});async function Ue(e){let t=e.merchantExecution,n=R(e),a=n.type==="checkout"?n.checkoutUrl:e.checkoutUrl;if(!(!E()||!a||Be(e)&&n.type!=="checkout"||i.checkoutNavigation==="after_confirmation"&&n.type!=="checkout"||t?.type==="purchase"&&!["not_started","pending"].includes(t.paymentStatus)||_e.get(e.operationId)===a)){_e.set(e.operationId,a);try{i.onCheckoutUrl?await i.onCheckoutUrl(a):f.defaultView?.location.assign(a)}catch(l){throw _e.delete(e.operationId),l}}}let ce=(e,t=!1)=>{if(e instanceof ut)u=null,p.textContent=e.customerMessage(o);else if(Ft(e))u=null,p.textContent=t?o?"当前无法在此购买,付款尚未开始。请联系商户。":"Purchases aren’t available here right now. Payment hasn’t started. Contact the merchant for help.":mt(e,o);else if(t){let n=e instanceof v?e.code:void 0;n==="CAPABILITY_UNAVAILABLE"||n==="NOT_CONFIGURED"?(u=null,p.textContent=o?"暂时无法为此套餐报价,付款尚未开始。":"Pricing for this plan is unavailable. Payment hasn’t started."):r.canReselect===!0&&!b?p.textContent=o?"未能取得报价,付款尚未开始。请重新选择套餐。":"We couldn’t prepare your price. Payment hasn’t started. Choose a plan again.":n==="COMMAND_PENDING"?p.textContent=o?"仍在准备报价,请重试以查看结果。":"Your price is still being prepared. Retry to check the result.":p.textContent=o?"未能取得报价,付款尚未开始。请重试。":"We couldn’t prepare your price. Payment hasn’t started. Try again."}else p.textContent=e instanceof v&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?mt(e,o):e instanceof v?e.message:o?"操作未完成,请重试。":"This action couldn’t be completed. Try again.";C.hidden=u===null,nt=p.textContent,t&&be===void 0&&!A?.responsive&&p.scrollIntoView?.({block:"nearest"}),G(t&&x?.quoteError?x.quoteError:i.onError,e)},Ee=new WeakMap;function xe(e){oe=e,C.disabled=e,B?.updateCapabilities?.(ye(m),Je(m));for(let t of te?.querySelectorAll("button")??[])e?(Ee.has(t)||Ee.set(t,t.disabled),t.disabled=!0):Ee.has(t)&&(t.disabled=Ee.get(t),Ee.delete(t)),pt(t)}function it(){p.textContent=o?"暂时无法操作,请稍后重试。":"This action is unavailable right now. Try again in a moment."}async function Zt(e){if(i.beforeAction)try{await i.beforeAction()}catch(t){throw t instanceof ut?(b=null,we=!1,ge=!1,u=null):u=e,t}}async function j(e,t){if(oe||w)return;if(!E()){it();return}let n=e===Ie,a=n?Yt:zt,l=pe()&&t!==void 0;be=l?t:void 0,xe(!0),ke(),C.hidden=!0,p.textContent=l?"":a;try{if(e!==At&&(e!==rt||!i.resumeCheckout)&&await Zt(e),w)return;if(!E()){u=e,C.hidden=!1,it();return}await e()}catch(y){w||ce(y,n)}finally{be=void 0,xe(!1),ke(),p.textContent===a&&(p.textContent="")}}async function en(e){await Gt(Z,e,i)}function xt(e){return lt(r).type==="recording"||R(e).type==="recording"}function It(e){let t=e.merchantTerms,n=t?.subscriptionTerms?.items??[],a=t?t.totalMinor:O(e)?e.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),l=t?n.length===1&&n[0]?.amountMinor===a&&n[0]:!O(e)&&e.lines.length===1&&e.lines[0]?.catalogAmountMinor===a&&e.lines[0],y=a===null?ue(t.subtotalMinor-t.discountMinor,e.currency)+(o?" + 待确认税费":" + tax confirmed at checkout"):ue(a,e.currency)+(l?Pe(l.interval,o?"zh-CN":"en",l.intervalCount??1):""),c=O(e)?r.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(s=>s.productName).join(", ");return{label:c?`${c} · ${y}`:y,recurring:l}}async function U(e,t=i.checkoutNavigation!=="after_confirmation"){if(w)return;if(!E()){u=async()=>U(await r.read()),C.hidden=!1;return}if(p.textContent=qt(e.status,o),xt(e)){let s=e.merchantExecution?.recordingStatus==="failed";p.textContent=s?o?"付款和商户处理已完成,但交易记录失败。请联系商户修复,勿重复购买。":"Payment and fulfillment succeeded, but recording failed. Contact the merchant to repair this purchase; do not buy again.":o?"付款和商户处理已完成,正在确认交易记录。请勿重复购买。":"Payment and merchant fulfillment are complete. Recording is pending confirmation; do not purchase again.",C.textContent=o?"查询记录":"Check recording",u=async()=>U(await r.read()),C.hidden=!1;return}if(e.problem&&R(e).type!=="native"){let s=e.problem;u=Ce,C.textContent=o?"检查并恢复原操作":"Check and recover original purchase",ce(new v(s.code,s.reason==="RESULT_UNKNOWN"?o?"付款结果尚未确定,请恢复原操作,暂勿重复购买。":"The payment result is unknown. Recover the original purchase before buying again.":s.phase==="fulfillment"?o?"付款已记录,商户权益处理需要核对。":"Payment was recorded. Access fulfillment needs attention.":s.code==="CAPABILITY_UNAVAILABLE"?o?"商户尚不支持本次购买所需的完整能力,请处理后恢复原操作。":"The merchant does not currently support all actions required by this purchase. Recover the original purchase after this is resolved.":s.code==="NOT_CONFIGURED"?o?"付款服务连接需要处理,请联系商户后恢复原操作。":"The payment connection needs attention. Contact the merchant, then recover the original purchase.":o?"原购买操作需要处理,请查询或恢复此操作。":"The original purchase needs attention. Check or recover this operation.",void 0,void 0,s));return}if((e.merchantExecution?.type==="purchase"&&e.merchantExecution.paymentStatus==="succeeded"||e.merchantExecution?.type==="subscription_change"&&e.merchantExecution.status==="applied")&&!["applied","not_applicable"].includes(e.merchantExecution.fulfillmentStatus)&&(p.textContent=o?"付款已记录,正在等待商户完成处理。":"Payment was recorded. Waiting for merchant fulfillment."),Re(e)&&R(e).type==="complete"){u=null,await en(e);return}if(!Oe(e)&&R(e).type!=="fulfillment"){if(r.canReselect===!1){p.textContent=o?"正在核对原购买结果":"Checking the original purchase result",C.textContent=o?"查询结果":"Check result",u=async()=>U(await r.read()),C.hidden=!1;return}e.status==="cancelled"?p.textContent=o?"这笔购买已取消,可以重新选择方案。":"This purchase was cancelled. Choose a plan to start again.":e.status==="failed"&&(p.textContent=o?"这笔购买未能完成,可以重新选择方案。":"This purchase didn’t go through. Choose a plan to try again."),C.textContent=o?"重试":"Retry",u=null,b=null;return}if(!t&&R(e).type==="checkout"){if(K){Pt();return}if(pe()){p.textContent="",Le=!1,u=null,ke();return}let s=r.quote,_=s?.operationId===e.operationId?It(s).label:"";p.textContent=Le?_?o?`${_} 尚未付款。再次选择该方案即可继续付款。`:`${_} is still unpaid. Choose it again to continue paying.`:o?"之前的购买尚未付款。再次选择该方案即可继续付款。":"Your earlier purchase is still unpaid. Choose that plan again to continue paying.":"",Le=!1,u=null;return}await Ue(e);let n=Date.now(),a=n+6e5,l=2e3,y=R(e).type!=="checkout",c=()=>y&&Date.now()-n<15e3;Ye=!0,G(i.onObservationChange,!0);try{for(;!w&&Date.now()<a;){if(await dt(c()?700:l,f,ie.signal),w)return;if(!E()){u=async()=>U(await r.read()),C.hidden=!1;return}let s=await r.read();if(R(s).type==="checkout"&&(y=!1),!t&&R(s).type==="checkout"){await U(s,!1);return}if(!s.problem&&Oe(s)&&await Ue(s),!Oe(s)||s.problem||xt(s)){await U(s);return}c()||(l=Math.min(l*1.5,3e4))}}finally{Ye=!1,G(i.onObservationChange,!1)}u=async()=>U(await r.read()),C.hidden=!1}async function at(e=!1){let t=await r.read();if(w)return;if(!E()){u=()=>at(e),C.hidden=!1;return}let n=r.quote;if(n&&_t(t,{operationId:n.operationId,currency:n.currency},"The original purchase operation changed"),n&&(Be(t)?["prepared","quoted"].includes(t.status):t.status==="pending")&&(Be(t)||t.quoteFinalized===!1)&&!t.confirmedAt&&!t.checkoutUrl&&!("nativePurchase"in t&&t.nativePurchase)&&!t.merchantExecution&&!t.problem&&!r.pendingCancellation){if(i.purchaseConfirmation!=="paywall"){e?await Ce():u=null;return}setTimeout(Rt,0,n);return}await U(t,e||void 0)}async function At(){await at()}async function Ce(){if(r.quote&&!(Date.parse(r.quote.expiresAt)>Date.now()))throw new v("INVALID_REQUEST",o?"此报价已过期,请重新选择套餐。":"This quote has expired. Choose a plan again.");vt(),u=Ce;let e=await r.confirm();if(!E()){u=Ce,C.hidden=!1;return}if(e.problem){await U(e);return}if(Oe(e)){if(R(e).type==="checkout")await Ue(e);else if(e.execution&&e.execution.provider!=="merchant"||"nativePurchase"in e&&e.nativePurchase){if(!i.onPurchase)throw new v("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await i.onPurchase({operation:e,signal:ie.signal})}}u=async()=>U(await r.read()),await U(e,!0)}function Rt(e){if(w)return;te?.remove();let t=!(Date.parse(e.expiresAt)>Date.now());p.textContent=t?o?"此报价已过期。请先取消,再重新选择。":"This quote has expired. Cancel it, then choose again.":"";let n=f.createElement("div"),a=f.createElement("button"),l=f.createElement("button"),y=f.createElement("div"),c=f.createElement("p"),s=e.merchantTerms,_=o?"zh-CN":"en",V=s?.subscriptionTerms?.items??[],ne=s?s.subscriptionTerms?.trial?.days:O(e)?void 0:e.lines.find(d=>d.trial)?.trial?.days,re=O(e)?s?s.totalMinor:e.totalMinor:ne===void 0?null:s?s.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(d=>d.trial)?0:null,$=(d,g)=>o?`${g} 天试用结束后 ${d}`:`Then ${d} after the ${g}-day trial`,{label:le,recurring:me}=It(e),$e=O(e)?r.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(d=>d.productName).join(", "),Qe=re===null?"":`${o?"今天应付":"Due today"} ${ue(re,e.currency)}`;c.textContent=Qe?[$e,Qe].filter(Boolean).join(" · "):le,a.textContent=O(e)?o?"确认变更":"Confirm change":o?"确认购买":"Confirm purchase",a.disabled=t,l.textContent=o?"取消":"Cancel",n.style.cssText=M.panel,c.style.cssText=M.summary,y.style.cssText=M.actions,a.style.cssText=M.primary,l.style.cssText=M.secondary,pt(a),a.onclick=()=>{j(Ce)};let He=async()=>{let d=await r.cancel();w||(n.remove(),te=null,await U(d))};l.onclick=()=>{u=He,j(He)};let H=f.createElement("div");if(H.style.cssText=M.terms,O(e)){for(let[g,P]of Object.entries(e.featureQuantities??{})){let D=r.view?.capabilities.plans[e.productVersionId]?.prepaid?.find(tn=>tn.internalFeatureId===g),je=f.createElement("p");je.textContent=`${D?.name??g} · ${P} ${o?"份":"packs"}${D?` × ${D.terms.units}`:""}`,H.append(je)}for(let[g,P]of[[o?"原订阅抵扣":"Unused subscription credit",e.creditMinor],[o?"新套餐费用":"New plan charge",e.debitMinor],[o?"优惠减免":"Offer savings",s?.discountMinor??e.discountMinor],[o?"税费":"Tax",s?s.taxMinor:e.taxMinor]]){let D=f.createElement("p");D.textContent=`${g}: ${P===null?o?"结账时确认":"Confirmed at checkout":ue(P,e.currency)}`,H.append(D)}let d=f.createElement("p");d.textContent=`${o?"生效时间":"Effective"}: ${e.effectiveAt}`,H.append(d)}if(s){for(let g of V){if(re===null&&g===me)continue;let P=f.createElement("p"),D=ue(g.amountMinor,e.currency)+Pe(g.interval,_,g.intervalCount);P.textContent=re!==null&&ne!==void 0?$(D,ne):D,g.amountAfterOfferMinor!==void 0&&(P.textContent+=` · ${o?"优惠结束后":"After the offer"} ${ue(g.amountAfterOfferMinor,e.currency)}${Pe(g.interval,_,g.intervalCount)}`),H.append(P)}let d=s.subscriptionTerms?.trial;if(d){let g=f.createElement("p");g.textContent=o?`试用 ${d.days} 天;${d.cardRequired?"需要提供付款方式":"无需提供付款方式"}`:`Trial days: ${d.days}; ${d.cardRequired?"a payment method is required":"no payment method is required"}`,H.append(g)}for(let g of[...s.expectedEffects.map(P=>P.description),...s.requiredConsents.map(P=>P.summary)]){let P=f.createElement("p");P.textContent=g,H.append(P)}}else if(!O(e)){for(let d of e.lines){if(re!==null||d!==me){let g=f.createElement("p"),P=`${ue(d.catalogAmountMinor,e.currency)}${Pe(d.interval,_,d.intervalCount??1)}`;g.textContent=re!==null&&d.trial?(e.lines.length>1?`${d.productName} · `:"")+$(P,d.trial.days):`${d.productName} · ${P}`,H.append(g)}for(let g of d.prepaid??[]){let P=f.createElement("p"),D=r.view?.capabilities.plans[d.productVersionId]?.prepaid?.find(je=>je.internalFeatureId===g.internal_feature_id);P.textContent=`${D?.name??g.internal_feature_id} · ${g.quantity} ${o?"份":"packs"} × ${g.terms.units}`,D&&(P.textContent+=Pe(D.reset==="week"||D.reset==="month"||D.reset==="year"?D.reset:"one_time",_,D.resetCount)),H.append(P)}if(d.trial){let g=f.createElement("p");g.textContent=o?`试用 ${d.trial.days} 天;${d.trial.cardRequired?"需要提供付款方式":"无需提供付款方式"}`:`Trial days: ${d.trial.days}; ${d.trial.cardRequired?"a payment method is required":"no payment method is required"}`,H.append(g)}}if(!e.charge){let d=f.createElement("p");d.textContent=o?"目录价格;最终金额以结账时税费和试用规则为准。":"Catalog price; the final charge depends on checkout taxes and trial terms.",H.append(d)}}for(let d of H.children)d.style.margin="0";y.append(a,l),n.append(c,...H.childElementCount?[H]:[],y),J.prepend(n),A?.responsive||n.scrollIntoView?.({block:"nearest"}),a.focus({preventScroll:!0}),te=n,oe&&xe(!0),u=null}async function Ie(){if(!b)return;if(u=Ie,!we){let n=r.view,a=n?.document.buttons[b.actionId],l=n&&a?.type==="checkout"?de(a.product,b.selection,n.capabilities):null;if(!n||!l)throw new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");if(!ge){let c=await i.resolveSubscriptionChange?.({actionId:b.actionId,productVersionId:l,featureQuantities:he(n.document.screen,l,b.selection,n.capabilities)});if(w)return;c!==void 0&&(b.subscriptionChange=Tt.parse(c)),ge=!0}let y=F?.offerId;if(F&&!y){if(!i.claimCoupon)throw new v("CAPABILITY_UNAVAILABLE","Coupon claiming is unavailable");let{offer:c}=await i.claimCoupon(F.id,b.requestId);if(w)return;if(!c||c.couponId!==F.id||c.status!=="issued"||!(Date.parse(c.expiresAt)>Date.now()))throw b=null,F=void 0,u=async()=>{Se(await r.refresh()),u=null},new v("COUPON_UNAVAILABLE","This Coupon is no longer available for this purchase");y=c.id}if(!F&&!n.document.screen.actions.some(c=>c.id===b?.actionId&&typeof c.properties.couponBinding=="string")&&(y=await i.resolveOfferId?.({actionId:b.actionId,productVersionId:l,featureQuantities:he(n.document.screen,l,b.selection,n.capabilities)})),w)return;y!==void 0&&(b.offerId=y),we=!0}if(!E()){C.hidden=!1;return}let e;try{e=await r.preview(b)}catch(n){throw r.canReselect===!0&&(b=null,we=!1,ge=!1,F=void 0,u=null),n}if(F&&(O(e)?(()=>{let n=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0);return n?.couponId!==F.id||n.grantId!==b.offerId})():e.discount?.couponId!==F.id||e.discount.offerId!==b.offerId))throw new v("INVALID_RESPONSE","The quote did not apply the Coupon selected on this Paywall");if(w)return;let t=e.merchantTerms;if(i.purchaseConfirmation!=="paywall"||i.confirmOnHostedCheckout&&E()&&!O(e)&&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()){if(!E()){C.hidden=!1;return}if(!(Date.parse(e.expiresAt)>Date.now()))throw new v("INVALID_REQUEST",o?"此报价已过期,请重新选择套餐。":"This quote has expired. Choose a plan again.");let n=be?"":o?"正在打开收银台…":"Opening checkout…";p.textContent=n;try{await Ce()}catch(a){w||ce(a)}finally{p.textContent===n&&(p.textContent="")}return}Rt(e)}function ve(e="destroy"){if(w)return;w=!0;let t=Ze;Ze=void 0,G(t),i.signal?.removeEventListener("abort",X),r.signal?.removeEventListener("abort",X),T.finish("dismissed"),wt?.(),ie.abort(),yt?.disconnect(),A?.destroy(),B?.destroy(),r.destroy(),S.open&&S.close(),S.remove(),N.remove(),k(),e==="dismiss"&&G(i.onDismiss)}Q=ve;async function Ve(){if(!fe||w||De||ee==="closing"||!ee&&!E())return;if(!x){ve("dismiss");return}let e=f.createElement("p");e.setAttribute("role","status"),e.textContent=o?"正在关闭…":"Closing…",se||(se=f.createElement("div"),se.style.cssText=J.style.cssText,J.replaceWith(se),ae.inert=!0),I.hidden=!1,se.replaceChildren(e,I),ee="closing",I.setAttribute("aria-disabled","true"),I.focus({preventScroll:!0});try{await x.dismiss()}catch(t){w||G(i.onError,t)}w||(ee="retry",e.textContent=o?"未能确认关闭,请重试。":"Could not confirm closure. Try again.",I.textContent=o?"重试关闭":"Retry closing",I.removeAttribute("aria-label"),I.removeAttribute("aria-disabled"))}I.onclick=()=>{Ve()},S.addEventListener("cancel",e=>{e.preventDefault(),Ve()}),C.onclick=()=>{u&&j(u)};function ot(e){T.finish("error",e),ve()}function st(){if(!(!bt||fe||w||De||A&&!E()))try{let e=t=>{i.focusAtReveal&&(k=ft(f)),B?.setHidden?.(!1),et?.(),A&&(S.showModal(),A.responsive&&S.focus({preventScroll:!0}),!t&&i.loading!=="host"&&Ut(S,A.type,A.responsive)),t&&i.loading!=="host"&&typeof ae.animate=="function"&&!f.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches&&ae.animate([{opacity:.55},{opacity:1}],{duration:160,easing:"ease-out"}),fe=!0};x?x.present(()=>T.present(()=>e(!0))):T.present(e)}catch(e){ot(e),ce(e)}}try{if(Te.type==="inline"?(ze(),et=Ht(N,L),L.append(N)):(S.setAttribute("aria-label",m.document.name),I.textContent="×",I.setAttribute("aria-label",o?"关闭":"Close"),Vt(I,m.document.screen.theme),I.hidden=Lt(m.document),S.append(I,N),L.append(S),A=Mt(S,{...m.document.screen,presentation:Te},Xe),A.latch(),A.responsive&&(N.style.display="flex",N.style.flexDirection="column",N.style.maxHeight="100%",ae.style.overflow="clip",ae.style.minHeight="0"),et=Qt(S)),Ge&&W){let n=Ge(W);if(typeof n=="function"&&(w?G(n):Ze=n),w)throw new DOMException("Presentation cancelled","AbortError");ze()}B=Y(ae,{mode:"live",rendererUrl:r.webViewUrl,title:m.document.name,closeActions:Jt,onAuthoredClose(n){ee||w||(I.hidden=n)},hostPresentation:()=>A?.type??Te.type,reportContentHeight:A?.responsive,onResize:n=>{if(!A?.responsive)return;let a=Math.min(n,Ke);ae.style.height=`${a}px`,A.setContentHeight(a+(se??J).getBoundingClientRect().height)},onSelection(n){for(let[a,l]of Object.entries(n))typeof l=="number"&&typeof q[a]=="number"&&q[a]!==l&&Ct.add(a);q=n,ke()},onAction(n,a={},l,y){if(!fe||w||ee)return;let c=r.view,s=c?.document.buttons[n];if(!s)return;if(s.type==="close"&&x&&i.resumeCheckout&&r.operation&&Dt(R(r.operation))){Ve();return}if(oe)return;if(!E()){it();return}if(s.type==="close"){j(async()=>{x?.closeAction?await x.closeAction(n):await i.onAction?.(n),ve(i.onAction?"action":"dismiss")});return}if(s.type==="action"){u=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):f.defaultView?.location.assign(s.action.url);await i.onAction?.(n),u=null},j(u);return}if(i.allowNewPurchase===!1){pe()&&c&&r.quote&&r.operation&&R(r.operation).type==="checkout"&&Me(r.quote,c,n,s.product,a,y)?j(rt,n):p.textContent=o?"当前只能继续原订单。":"Only your original checkout is available.";return}if(te&&r.canReselect===!1){p.textContent=o?"请先确认或取消当前购买。":"Confirm or cancel the current purchase first.",A?.responsive||te.scrollIntoView?.({block:"nearest"}),te.querySelector("button")?.focus({preventScroll:!0});return}if(pe()&&K){K.selection.actionId===n&&j(()=>kt(!0),n);return}if(pe()&&i.terminateCheckout&&c&&r.quote&&r.operation&&r.canReselect===!1&&R(r.operation).type==="checkout"){if(Me(r.quote,c,n,s.product,a,y)){j(rt,n);return}let V=de(s.product,a,c.capabilities),ne;try{if(!V)throw new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");ne=he(c.document.screen,V,a,c.capabilities)}catch(me){ce(me);return}let re=r.operation.operationId,$={actionId:n,requestId:crypto.randomUUID(),selection:structuredClone(a)},le=Ne(c,n,V,a,y);j(()=>Et(re,$,le,{actionId:n,productVersionId:V,selection:$.selection,featureQuantities:ne}),n);return}if((r.quote||b)&&r.canReselect===!1){let V=!!c&&!!r.quote&&Me(r.quote,c,n,s.product,a,y);Le=!!r.quote&&!V,u=r.quote?()=>at(V):Ie,j(u);return}let _=c&&de(s.product,a,c.capabilities);if(!c||!_){ce(new v("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(i.onPurchaseIntent){u=null,j(async()=>{let V={actionId:n,productVersionId:_,selection:structuredClone(a),featureQuantities:he(c.document.screen,_,a,c.capabilities)};tt=!0,await i.onPurchaseIntent(V)});return}if(b&&b.actionId!==n){ce(new v("COMMAND_PENDING","Finish the current purchase"));return}b||(F=Ne(c,n,_,a,y),b={requestId:crypto.randomUUID(),actionId:n,selection:structuredClone(a)},we=!1,ge=!1),j(Ie,n)},onEscape:()=>{Ve()},onError:n=>{let a=new Error(n);!fe&&!w&&ot(a),ce(a)},onRendered:n=>{n&&S.setAttribute("aria-label",n),bt=!0,st()}}),B.setHidden?.(!0),Xe();let e=pe()&&!!r.quote&&!!r.operation&&R(r.operation).type==="checkout";q=r.quote?Wt(m,r.quote)??Fe(m,{}):Fe(m,{}),B.update(m.document.screen,We,{capabilities:ye(m),unavailableActions:ht(m),serverInput:{bindings:[],answers:{}},...Object.keys(q).length?{selection:q}:{}}),wt=r.subscribe?.(Se),Se(r.view??m),await T.wait(B.ready);let t=r.operation;!e&&(r.quote||t&&(t.confirmedAt||t.checkoutUrl||Re(t)))&&(u=At,j(u))}catch(e){throw ot(e),e}return{check:Z,host:{get observing(){return Ye},get recovery(){return Kt()},async prepareFallback(){if(oe||w||ee||tt)return{type:"recover",operationId:r.operation?.operationId??r.quote?.operationId??null,requestId:null};xe(!0);try{let e=await Nt(r);return e.type==="native"&&ve(),e}finally{xe(!1)}},setSuspended(e){De=e,N.hidden=e,e&&S.open?S.close():!e&&!fe?st():!e&&!w&&fe&&Te.type!=="inline"&&!S.open&&S.showModal()},destroy:ve,refresh:async()=>{if(!E()){if(r.view)return r.view;throw new v("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await r.refresh();return Se(e),st(),e}}}}export{Ln as showPaywall};
@@ -286,6 +286,7 @@ declare const funnelConfigurationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
286
286
  type: z.ZodEnum<{
287
287
  output: "output";
288
288
  action: "action";
289
+ wait: "wait";
289
290
  screen: "screen";
290
291
  end: "end";
291
292
  coupon: "coupon";
@@ -296,7 +297,6 @@ declare const funnelConfigurationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
296
297
  offering: "offering";
297
298
  entry: "entry";
298
299
  external_page: "external_page";
299
- wait: "wait";
300
300
  }>;
301
301
  outputs: z.ZodRecord<z.ZodString, z.ZodString>;
302
302
  writes: z.ZodRecord<z.ZodString, z.ZodString>;
@@ -331,6 +331,7 @@ declare const funnelConfigurationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
331
331
  type: z.ZodEnum<{
332
332
  output: "output";
333
333
  action: "action";
334
+ wait: "wait";
334
335
  screen: "screen";
335
336
  end: "end";
336
337
  coupon: "coupon";
@@ -341,7 +342,6 @@ declare const funnelConfigurationSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
341
342
  offering: "offering";
342
343
  entry: "entry";
343
344
  external_page: "external_page";
344
- wait: "wait";
345
345
  }>;
346
346
  outputs: z.ZodRecord<z.ZodString, z.ZodString>;
347
347
  writes: z.ZodRecord<z.ZodString, z.ZodString>;
@@ -550,6 +550,7 @@ declare const funnelLocalConfigurationSchema: z.ZodObject<{
550
550
  type: z.ZodEnum<{
551
551
  output: "output";
552
552
  action: "action";
553
+ wait: "wait";
553
554
  screen: "screen";
554
555
  end: "end";
555
556
  coupon: "coupon";
@@ -560,7 +561,6 @@ declare const funnelLocalConfigurationSchema: z.ZodObject<{
560
561
  offering: "offering";
561
562
  entry: "entry";
562
563
  external_page: "external_page";
563
- wait: "wait";
564
564
  }>;
565
565
  outputs: z.ZodRecord<z.ZodString, z.ZodString>;
566
566
  writes: z.ZodRecord<z.ZodString, z.ZodString>;
@@ -251,8 +251,8 @@ declare const textNodeSchema: z.ZodObject<{
251
251
  muted: "muted";
252
252
  }>, z.ZodString]>>;
253
253
  align: z.ZodOptional<z.ZodEnum<{
254
- center: "center";
255
254
  start: "start";
255
+ center: "center";
256
256
  end: "end";
257
257
  }>>;
258
258
  italic: z.ZodOptional<z.ZodBoolean>;
@@ -408,8 +408,8 @@ declare const imageNodeSchema: z.ZodObject<{
408
408
  muted: "muted";
409
409
  }>, z.ZodString]>>;
410
410
  align: z.ZodOptional<z.ZodEnum<{
411
- center: "center";
412
411
  start: "start";
412
+ center: "center";
413
413
  end: "end";
414
414
  }>>;
415
415
  italic: z.ZodOptional<z.ZodBoolean>;
@@ -565,8 +565,8 @@ declare const buttonNodeSchema: z.ZodObject<{
565
565
  muted: "muted";
566
566
  }>, z.ZodString]>>;
567
567
  align: z.ZodOptional<z.ZodEnum<{
568
- center: "center";
569
568
  start: "start";
569
+ center: "center";
570
570
  end: "end";
571
571
  }>>;
572
572
  italic: z.ZodOptional<z.ZodBoolean>;
@@ -704,8 +704,8 @@ declare const dividerNodeSchema: z.ZodObject<{
704
704
  muted: "muted";
705
705
  }>, z.ZodString]>>;
706
706
  align: z.ZodOptional<z.ZodEnum<{
707
- center: "center";
708
707
  start: "start";
708
+ center: "center";
709
709
  end: "end";
710
710
  }>>;
711
711
  italic: z.ZodOptional<z.ZodBoolean>;
@@ -873,8 +873,8 @@ declare const customerDataNodeSchema: z.ZodObject<{
873
873
  muted: "muted";
874
874
  }>, z.ZodString]>>;
875
875
  align: z.ZodOptional<z.ZodEnum<{
876
- center: "center";
877
876
  start: "start";
877
+ center: "center";
878
878
  end: "end";
879
879
  }>>;
880
880
  italic: z.ZodOptional<z.ZodBoolean>;
@@ -1021,8 +1021,8 @@ declare const spacerNodeSchema: z.ZodObject<{
1021
1021
  muted: "muted";
1022
1022
  }>, z.ZodString]>>;
1023
1023
  align: z.ZodOptional<z.ZodEnum<{
1024
- center: "center";
1025
1024
  start: "start";
1025
+ center: "center";
1026
1026
  end: "end";
1027
1027
  }>>;
1028
1028
  italic: z.ZodOptional<z.ZodBoolean>;
@@ -1261,8 +1261,8 @@ declare const customHtmlNodeSchema: z.ZodObject<{
1261
1261
  muted: "muted";
1262
1262
  }>, z.ZodString]>>;
1263
1263
  align: z.ZodOptional<z.ZodEnum<{
1264
- center: "center";
1265
1264
  start: "start";
1265
+ center: "center";
1266
1266
  end: "end";
1267
1267
  }>>;
1268
1268
  italic: z.ZodOptional<z.ZodBoolean>;
@@ -1399,8 +1399,8 @@ declare const priceNodeSchema: z.ZodObject<{
1399
1399
  muted: "muted";
1400
1400
  }>, z.ZodString]>>;
1401
1401
  align: z.ZodOptional<z.ZodEnum<{
1402
- center: "center";
1403
1402
  start: "start";
1403
+ center: "center";
1404
1404
  end: "end";
1405
1405
  }>>;
1406
1406
  italic: z.ZodOptional<z.ZodBoolean>;
@@ -1531,8 +1531,8 @@ declare const priceNodeSchema: z.ZodObject<{
1531
1531
  muted: "muted";
1532
1532
  }>, z.ZodString]>>;
1533
1533
  align: z.ZodOptional<z.ZodEnum<{
1534
- center: "center";
1535
1534
  start: "start";
1535
+ center: "center";
1536
1536
  end: "end";
1537
1537
  }>>;
1538
1538
  italic: z.ZodOptional<z.ZodBoolean>;
@@ -1663,8 +1663,8 @@ declare const priceNodeSchema: z.ZodObject<{
1663
1663
  muted: "muted";
1664
1664
  }>, z.ZodString]>>;
1665
1665
  align: z.ZodOptional<z.ZodEnum<{
1666
- center: "center";
1667
1666
  start: "start";
1667
+ center: "center";
1668
1668
  end: "end";
1669
1669
  }>>;
1670
1670
  italic: z.ZodOptional<z.ZodBoolean>;
@@ -1799,8 +1799,8 @@ declare const priceNodeSchema: z.ZodObject<{
1799
1799
  muted: "muted";
1800
1800
  }>, z.ZodString]>>;
1801
1801
  align: z.ZodOptional<z.ZodEnum<{
1802
- center: "center";
1803
1802
  start: "start";
1803
+ center: "center";
1804
1804
  end: "end";
1805
1805
  }>>;
1806
1806
  italic: z.ZodOptional<z.ZodBoolean>;
@@ -1939,8 +1939,8 @@ declare const couponCodeNodeSchema: z.ZodObject<{
1939
1939
  muted: "muted";
1940
1940
  }>, z.ZodString]>>;
1941
1941
  align: z.ZodOptional<z.ZodEnum<{
1942
- center: "center";
1943
1942
  start: "start";
1943
+ center: "center";
1944
1944
  end: "end";
1945
1945
  }>>;
1946
1946
  italic: z.ZodOptional<z.ZodBoolean>;
@@ -2091,8 +2091,8 @@ declare const countdownNodeSchema: z.ZodObject<{
2091
2091
  muted: "muted";
2092
2092
  }>, z.ZodString]>>;
2093
2093
  align: z.ZodOptional<z.ZodEnum<{
2094
- center: "center";
2095
2094
  start: "start";
2095
+ center: "center";
2096
2096
  end: "end";
2097
2097
  }>>;
2098
2098
  italic: z.ZodOptional<z.ZodBoolean>;
@@ -2248,8 +2248,8 @@ declare const planPickerNodeSchema: z.ZodObject<{
2248
2248
  muted: "muted";
2249
2249
  }>, z.ZodString]>>;
2250
2250
  align: z.ZodOptional<z.ZodEnum<{
2251
- center: "center";
2252
2251
  start: "start";
2252
+ center: "center";
2253
2253
  end: "end";
2254
2254
  }>>;
2255
2255
  italic: z.ZodOptional<z.ZodBoolean>;
@@ -2384,8 +2384,8 @@ declare const planPickerNodeSchema: z.ZodObject<{
2384
2384
  muted: "muted";
2385
2385
  }>, z.ZodString]>>;
2386
2386
  align: z.ZodOptional<z.ZodEnum<{
2387
- center: "center";
2388
2387
  start: "start";
2388
+ center: "center";
2389
2389
  end: "end";
2390
2390
  }>>;
2391
2391
  italic: z.ZodOptional<z.ZodBoolean>;
@@ -2536,8 +2536,8 @@ declare const quantityPickerNodeSchema: z.ZodObject<{
2536
2536
  muted: "muted";
2537
2537
  }>, z.ZodString]>>;
2538
2538
  align: z.ZodOptional<z.ZodEnum<{
2539
- center: "center";
2540
2539
  start: "start";
2540
+ center: "center";
2541
2541
  end: "end";
2542
2542
  }>>;
2543
2543
  italic: z.ZodOptional<z.ZodBoolean>;
@@ -2574,14 +2574,14 @@ declare const stackNodeFields: {
2574
2574
  overlay: "overlay";
2575
2575
  }>;
2576
2576
  align: z.ZodEnum<{
2577
- center: "center";
2578
2577
  start: "start";
2578
+ center: "center";
2579
2579
  end: "end";
2580
2580
  stretch: "stretch";
2581
2581
  }>;
2582
2582
  justify: z.ZodEnum<{
2583
- center: "center";
2584
2583
  start: "start";
2584
+ center: "center";
2585
2585
  end: "end";
2586
2586
  between: "between";
2587
2587
  }>;
@@ -2734,8 +2734,8 @@ declare const stackNodeFields: {
2734
2734
  muted: "muted";
2735
2735
  }>, z.ZodString]>>;
2736
2736
  align: z.ZodOptional<z.ZodEnum<{
2737
- center: "center";
2738
2737
  start: "start";
2738
+ center: "center";
2739
2739
  end: "end";
2740
2740
  }>>;
2741
2741
  italic: z.ZodOptional<z.ZodBoolean>;
@@ -2880,8 +2880,8 @@ declare const stackNodeFields: {
2880
2880
  muted: "muted";
2881
2881
  }>, z.ZodString]>>;
2882
2882
  align: z.ZodOptional<z.ZodEnum<{
2883
- center: "center";
2884
2883
  start: "start";
2884
+ center: "center";
2885
2885
  end: "end";
2886
2886
  }>>;
2887
2887
  italic: z.ZodOptional<z.ZodBoolean>;
@@ -3031,8 +3031,8 @@ declare const stackNodeFields: {
3031
3031
  muted: "muted";
3032
3032
  }>, z.ZodString]>>;
3033
3033
  align: z.ZodOptional<z.ZodEnum<{
3034
- center: "center";
3035
3034
  start: "start";
3035
+ center: "center";
3036
3036
  end: "end";
3037
3037
  }>>;
3038
3038
  italic: z.ZodOptional<z.ZodBoolean>;