@tinkerlandai/longplay-sdk 0.10.38 → 0.10.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +1 -1
  3. package/README.zh-CN.md +1 -1
  4. package/dist/check-response-DRQCUWDW.js +1 -0
  5. package/dist/{chunk-UFTLA3ZI.js → chunk-2DPNSTCN.js} +1 -1
  6. package/dist/{chunk-64ETX3AY.js → chunk-33ZVZOSC.js} +1 -1
  7. package/dist/{chunk-G7Y7LPOB.js → chunk-4TEZZZYK.js} +1 -1
  8. package/dist/{chunk-7PXJUHDS.js → chunk-57GPGWSK.js} +1 -1
  9. package/dist/{chunk-PLOUC66F.js → chunk-5DZJCFNQ.js} +1 -1
  10. package/dist/{chunk-IV6LKRYM.js → chunk-67AY54E2.js} +1 -1
  11. package/dist/{chunk-UAJTQ23E.js → chunk-6PG3AS3G.js} +1 -1
  12. package/dist/{chunk-6WEHTOED.js → chunk-7QDT6DO7.js} +1 -1
  13. package/dist/{chunk-DK5PHPSO.js → chunk-ASDJTOGM.js} +1 -1
  14. package/dist/{chunk-H2I37CQ4.js → chunk-AZFWG352.js} +1 -1
  15. package/dist/{chunk-5IGASP6C.js → chunk-BYP4KVB3.js} +1 -1
  16. package/dist/{chunk-QZRJ3ZXU.js → chunk-C2KT5ZFU.js} +1 -1
  17. package/dist/{chunk-XBCKVHOT.js → chunk-C3GYAKIU.js} +1 -1
  18. package/dist/{chunk-JXTJT2EW.js → chunk-CZ4TQCUV.js} +1 -1
  19. package/dist/{chunk-TLV3NVUU.js → chunk-EREQZWGI.js} +1 -1
  20. package/dist/{chunk-JBDNNV3P.js → chunk-ESAHTG3Y.js} +1 -1
  21. package/dist/{chunk-4E326NPY.js → chunk-FCDWCQYC.js} +1 -1
  22. package/dist/{chunk-WQZOT22S.js → chunk-GC6JBIRQ.js} +1 -1
  23. package/dist/chunk-IJKAQNK6.js +1 -0
  24. package/dist/{chunk-KQF4BVOL.js → chunk-IOJVF52Q.js} +1 -1
  25. package/dist/{chunk-UD7XPHE4.js → chunk-LSPHUA7V.js} +1 -1
  26. package/dist/{chunk-K3VQKR4G.js → chunk-OOD2VDDP.js} +1 -1
  27. package/dist/{chunk-YYXINZ4A.js → chunk-ORMQJAQE.js} +1 -1
  28. package/dist/{chunk-Y5RT7PAD.js → chunk-P23JOPR5.js} +1 -1
  29. package/dist/{chunk-DTWSDNYI.js → chunk-P6C3PNMQ.js} +1 -1
  30. package/dist/chunk-PJS7M6X3.js +1 -0
  31. package/dist/{chunk-IHB275C3.js → chunk-POCDWUD3.js} +1 -1
  32. package/dist/{chunk-WP3SZU24.js → chunk-PZOQV6MU.js} +1 -1
  33. package/dist/{chunk-RK7XOT3F.js → chunk-QZTTKH2H.js} +1 -1
  34. package/dist/{chunk-KTBXAATX.js → chunk-RFNIGJOL.js} +1 -1
  35. package/dist/{chunk-Q7K66FTS.js → chunk-RULQQ7WI.js} +1 -1
  36. package/dist/{chunk-EEYDOVVS.js → chunk-RV6UAUK2.js} +1 -1
  37. package/dist/chunk-U7GH4VME.js +1 -0
  38. package/dist/{chunk-L54MODP5.js → chunk-VC2HPREX.js} +1 -1
  39. package/dist/{chunk-SY7AYEDO.js → chunk-VOKEZHAH.js} +1 -1
  40. package/dist/{chunk-O5VA3E5D.js → chunk-WLGLQJ6M.js} +1 -1
  41. package/dist/{chunk-GEPX4AUR.js → chunk-X6ONZGRY.js} +1 -1
  42. package/dist/{chunk-HJVEVJXS.js → chunk-XDOKFAE6.js} +1 -1
  43. package/dist/{chunk-BDC7B4KM.js → chunk-Y6HL2IY2.js} +1 -1
  44. package/dist/{chunk-NK55HFFF.js → chunk-YLPQLD2A.js} +1 -1
  45. package/dist/{chunk-6QOJRLVM.js → chunk-YY445FBU.js} +1 -1
  46. package/dist/{content-B4CC4O23.js → content-QUEVNSXD.js} +1 -1
  47. package/dist/{funnel-host-purchase-AGBJG3RK.js → funnel-host-purchase-LMVMJNUO.js} +1 -1
  48. package/dist/funnel-paywall-prerender-LGUSHEP3.js +1 -0
  49. package/dist/funnel-runtime-host-H5FM67UC.js +1 -0
  50. package/dist/index.js +1 -1
  51. package/dist/merchant-bridge-contracts-LZSQYE3O.js +1 -0
  52. package/dist/native-shell.js +1 -1
  53. package/dist/openrouter.js +1 -1
  54. package/dist/operation-contracts-O7TCDGV4.js +1 -0
  55. package/dist/page.js +1 -1
  56. package/dist/paywall-UANWOKKC.js +1 -0
  57. package/dist/paywall-content-CHPX2P77.js +1 -0
  58. package/dist/paywall-session-3BNUC5ZE.js +1 -0
  59. package/dist/popup.js +1 -1
  60. package/dist/react-native.js +1 -1
  61. package/dist/screen-renderer-FFVZ64MR.js +1 -0
  62. package/dist/server.js +1 -1
  63. package/dist/visual.js +1 -1
  64. package/package.json +9 -10
  65. package/dist/check-response-Q7GOBUGJ.js +0 -1
  66. package/dist/chunk-2LND3R7K.js +0 -1
  67. package/dist/chunk-DSLJUN3P.js +0 -1
  68. package/dist/chunk-I7QTCEYR.js +0 -1
  69. package/dist/funnel-paywall-prerender-HHAQBIIB.js +0 -1
  70. package/dist/funnel-runtime-host-IJDKXLST.js +0 -1
  71. package/dist/merchant-bridge-contracts-KVOFRPKV.js +0 -1
  72. package/dist/operation-contracts-G4C7ZLEH.js +0 -1
  73. package/dist/paywall-TVCH6VQT.js +0 -1
  74. package/dist/paywall-content-QSTCRYU5.js +0 -1
  75. package/dist/paywall-session-UBQYU5XD.js +0 -1
  76. package/dist/screen-renderer-Q3VSMB2N.js +0 -1
  77. /package/dist/{chunk-42UXYMRZ.js → chunk-RGEBK6UF.js} +0 -0
@@ -1 +1 @@
1
- import{b as d}from"./chunk-EEYDOVVS.js";import{a as u}from"./chunk-DSPLGTQI.js";function m(e){if(!/^[A-Za-z0-9_-]{1,64}$/.test(e))throw new Error("Invalid device cookie name");let t="";for(let i of document.cookie.split(";"))if(i.trim().startsWith(`${e}=`))try{t=decodeURIComponent(i.trim().slice(e.length+1))}catch{}return/^[A-Za-z0-9_-]{8,128}$/.test(t)||(t=crypto.randomUUID(),document.cookie=`${e}=${encodeURIComponent(t)}; path=/; max-age=${400*24*3600}; SameSite=Lax`),t}function y(){try{let e=sessionStorage.getItem("indiana_sid");return e||(e=crypto.randomUUID(),sessionStorage.setItem("indiana_sid",e)),e}catch{return}}function g(e=d){let t=new URL(e);if(t.protocol!=="https:"&&!(t.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(t.hostname))||t.username||t.password||t.search||t.hash)throw new Error("baseUrl must be an https origin without credentials");return t.origin}var o=new Set,s;function S(e){let t=()=>e();if(o.add(t),!s){let i=!0,a=history.pushState,p=history.replaceState,r=()=>{if(i)for(let n of[...o])o.has(n)&&u(n)},c=function(...n){a.apply(this,n),r()},h=function(...n){p.apply(this,n),r()};history.pushState=c,history.replaceState=h,addEventListener("popstate",r),addEventListener("hashchange",r),s=()=>{i=!1,history.pushState===c&&(history.pushState=a),history.replaceState===h&&(history.replaceState=p),removeEventListener("popstate",r),removeEventListener("hashchange",r)}}return()=>{o.delete(t)&&(o.size||(s?.(),s=void 0))}}export{m as a,y as b,g as c,S as d};
1
+ import{b as d}from"./chunk-RV6UAUK2.js";import{a as u}from"./chunk-DSPLGTQI.js";function m(e){if(!/^[A-Za-z0-9_-]{1,64}$/.test(e))throw new Error("Invalid device cookie name");let t="";for(let i of document.cookie.split(";"))if(i.trim().startsWith(`${e}=`))try{t=decodeURIComponent(i.trim().slice(e.length+1))}catch{}return/^[A-Za-z0-9_-]{8,128}$/.test(t)||(t=crypto.randomUUID(),document.cookie=`${e}=${encodeURIComponent(t)}; path=/; max-age=${400*24*3600}; SameSite=Lax`),t}function y(){try{let e=sessionStorage.getItem("indiana_sid");return e||(e=crypto.randomUUID(),sessionStorage.setItem("indiana_sid",e)),e}catch{return}}function g(e=d){let t=new URL(e);if(t.protocol!=="https:"&&!(t.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(t.hostname))||t.username||t.password||t.search||t.hash)throw new Error("baseUrl must be an https origin without credentials");return t.origin}var o=new Set,s;function S(e){let t=()=>e();if(o.add(t),!s){let i=!0,a=history.pushState,p=history.replaceState,r=()=>{if(i)for(let n of[...o])o.has(n)&&u(n)},c=function(...n){a.apply(this,n),r()},h=function(...n){p.apply(this,n),r()};history.pushState=c,history.replaceState=h,addEventListener("popstate",r),addEventListener("hashchange",r),s=()=>{i=!1,history.pushState===c&&(history.pushState=a),history.replaceState===h&&(history.replaceState=p),removeEventListener("popstate",r),removeEventListener("hashchange",r)}}return()=>{o.delete(t)&&(o.size||(s?.(),s=void 0))}}export{m as a,y as b,g as c,S as d};
@@ -1 +1 @@
1
- import{e as P}from"./chunk-PLOUC66F.js";import{c as V}from"./chunk-IHB275C3.js";import{b as j}from"./chunk-6WEHTOED.js";import{v as L}from"./chunk-UAJTQ23E.js";import{b as x}from"./chunk-GEPX4AUR.js";import{a as K}from"./chunk-3NCMYTNG.js";import{b as U}from"./chunk-64ETX3AY.js";import{d as H,e as W,f as B,g as F}from"./chunk-SY7AYEDO.js";import{b as J}from"./chunk-WP3SZU24.js";import{a as M}from"./chunk-4E326NPY.js";import{ea as G}from"./chunk-HJVEVJXS.js";import{a as l}from"./chunk-O5VA3E5D.js";import{a as $}from"./chunk-DSPLGTQI.js";function X(w){let r=[...new Set(w.map(({path:a})=>{let m=a.map(String).join(".");return m.startsWith("selector")?"paywallId or paywallVersionId":m||"input"}))],O=r.includes("locale")?` Pass locale, the Customer's language such as "en" or "zh-CN".`:"";return new l("INVALID_REQUEST",`createPaywallSession input is invalid: ${r.join(", ")}.${O}`)}async function de(w,r){if(!M.test(r.customerToken))throw new l("INVALID_TOKEN","A verified Customer credential is required");if(w.session&&w.session.peek()!==r.customerToken)throw new l("SCOPE_MISMATCH","Paywall credential does not match the shared session");let O=P.resolvePaywall.request.safeParse({funnelId:r.funnelId,funnelVersionId:r.funnelVersionId,selector:r.paywallVersionId?{type:"version",versionId:r.paywallVersionId}:{type:"paywall",paywallId:r.paywallId},commerce:r.commerce,locale:r.locale,...r.requirement?{requirement:r.requirement}:{}});if(!O.success)throw X(O.error.issues);let a=O.data,m=J(w);w.session||m.identify(r.customerToken);let t=null,g=!1,_=new AbortController,c=null,u=null,v=null,h=null,R=null,d=null,f=null,N=0,C=null,k="",E=0,b=new Map,q=new Set;function S(){if(g)throw new l("IDENTITY_CHANGED","Paywall is closed")}function Q(){let e=JSON.stringify([N,f!==null]);if(!C||e!==k){k=e;let n=z(++E);C=n;let i=()=>{C===n&&(C=null)};n.then(i,i)}return C.then(n=>structuredClone(n))}async function z(e){S();let n=P.resolvePaywall,i=await V(m.request,n,{...a,selector:t?{type:"version",versionId:t.id}:a.selector});j(a,i.paywall.check,i.scope);let s=await x(w,i.paywall);if(S(),r.paywallVersionId?s.id!==r.paywallVersionId:s.paywallId!==r.paywallId)throw new l("INVALID_RESPONSE","The requested Paywall changed");if(t&&(!H(s,t)||s.paywallId!==t.paywallId))throw new l("INVALID_RESPONSE","The pinned Paywall or Offering Version changed");if(e!==E)return structuredClone(t??s);t=s;for(let I of q)$(I,structuredClone(t));return structuredClone(t)}async function T(e){if(S(),h&&e!=="read")throw new l("COMMAND_PENDING","Wait for the original quote");if(!c)throw new l("INVALID_REQUEST","A quoted purchase is required");let n=c;if(e!=="read"){if(f){if(d===e)return f;throw new l("COMMAND_PENDING","Wait for the original purchase command")}if(d&&d!==e)throw new l("COMMAND_PENDING","Read the original purchase before changing an uncertain command");d=e,N++,E++}let i=d,s=N,I=e==="read"&&f===null,p=JSON.stringify([n.operationId,s,f!==null]);if(e==="read"&&b.has(p))return b.get(p).then(o=>structuredClone(o));let A=e==="read"?P.readSubscriptionOperation:P.attach,y=(async()=>{let o=await V(m.request,A,{operationId:n.operationId,...e==="read"?{}:{intent:e},...e==="confirm"&&n.merchantTerms?{merchantConfirmation:L(n.merchantTerms)}:{}});return W(o.operation,{operationId:n.operationId,currency:a.commerce.currency},"The purchase operation changed"),S(),c?.operationId!==n.operationId?structuredClone(o.operation):(u=F(u,o.operation),(e!=="read"||I&&f===null)&&N===s&&d===i&&(d=null),structuredClone(u))})();if(e!=="read"){f=y;let o=()=>{f===y&&(f=null)};y.then(o,o)}else{b.set(p,y);let o=()=>{b.get(p)===y&&b.delete(p)};y.then(o,o)}return y.then(o=>structuredClone(o))}let D={signal:_.signal,get view(){return t?structuredClone(t):null},get quote(){return c?structuredClone(c):null},get operation(){return u?structuredClone(u):null},get webViewUrl(){return"bundled"},get locale(){return a.locale},get recovery(){return K({quote:c,operation:u,requestId:R,pending:h!==null||d!==null,destroyed:g})},get pendingCancellation(){return!g&&d==="cancel"},refresh:Q,subscribe(e){return g?()=>{}:(q.add(e),()=>q.delete(e))},async preview(e){if(S(),!t)throw new l("INVALID_REQUEST","Load the Paywall first");let n=t.document.buttons[e.actionId];if(n?.type!=="checkout")throw new l("INVALID_REQUEST","Choose an authored purchase action");let i=U(n.product,e.selection,t.capabilities);if(!i)throw new l("PRODUCT_UNAVAILABLE","Choose an available Product");let s=G(t.document.screen,i,e.selection,t.capabilities),I=P.previewAttach.request.parse({funnelId:a.funnelId,funnelVersionId:a.funnelVersionId,requestId:e.requestId,plans:[{productVersionId:i,...Object.keys(s).length?{featureQuantities:s}:{}}],provider:a.commerce.provider,currency:a.commerce.currency,...e.offerId?{offerId:e.offerId}:{},...e.nativeOffer?{nativeOffer:e.nativeOffer}:{}}),p=JSON.stringify(I);if(v&&v!==p&&(h||d||!u||u.status==="pending"))throw new l("COMMAND_PENDING","Finish or cancel the original purchase before changing it");if(v===p){if(h)return h;if(c)return structuredClone(c)}v!==p&&(c=null,u=null),v=p,R=I.requestId;let A=(async()=>{let y=P.previewAttach,o=await V(m.request,y,I);return S(),B(o.quote,{productVersionId:i,featureQuantities:s,currency:a.commerce.currency,provider:a.commerce.provider},"The purchase quote changed its selected Product or presentment"),c=o.quote,u=null,structuredClone(c)})();h=A;try{return await A}finally{h===A&&(h=null)}},confirm:()=>T("confirm"),cancel:()=>T("cancel"),read:()=>T("read"),destroy(){g||(g=!0,_.abort(),q.clear(),b.clear(),Y?.(),m.dispose(),t=null,c=null,u=null,v=null,R=null)}},Y=w.session?.subscribeIdentity(D.destroy);try{return await Q(),D}catch(e){throw D.destroy(),e}}export{de as a};
1
+ import{e as P}from"./chunk-5DZJCFNQ.js";import{c as V}from"./chunk-POCDWUD3.js";import{b as j}from"./chunk-7QDT6DO7.js";import{v as L}from"./chunk-6PG3AS3G.js";import{b as x}from"./chunk-X6ONZGRY.js";import{a as K}from"./chunk-3NCMYTNG.js";import{b as U}from"./chunk-33ZVZOSC.js";import{d as H,e as W,f as B,g as F}from"./chunk-VOKEZHAH.js";import{b as J}from"./chunk-PZOQV6MU.js";import{a as M}from"./chunk-FCDWCQYC.js";import{ea as G}from"./chunk-XDOKFAE6.js";import{a as l}from"./chunk-WLGLQJ6M.js";import{a as $}from"./chunk-DSPLGTQI.js";function X(w){let r=[...new Set(w.map(({path:a})=>{let m=a.map(String).join(".");return m.startsWith("selector")?"paywallId or paywallVersionId":m||"input"}))],O=r.includes("locale")?` Pass locale, the Customer's language such as "en" or "zh-CN".`:"";return new l("INVALID_REQUEST",`createPaywallSession input is invalid: ${r.join(", ")}.${O}`)}async function de(w,r){if(!M.test(r.customerToken))throw new l("INVALID_TOKEN","A verified Customer credential is required");if(w.session&&w.session.peek()!==r.customerToken)throw new l("SCOPE_MISMATCH","Paywall credential does not match the shared session");let O=P.resolvePaywall.request.safeParse({funnelId:r.funnelId,funnelVersionId:r.funnelVersionId,selector:r.paywallVersionId?{type:"version",versionId:r.paywallVersionId}:{type:"paywall",paywallId:r.paywallId},commerce:r.commerce,locale:r.locale,...r.requirement?{requirement:r.requirement}:{}});if(!O.success)throw X(O.error.issues);let a=O.data,m=J(w);w.session||m.identify(r.customerToken);let t=null,g=!1,_=new AbortController,c=null,u=null,v=null,h=null,R=null,d=null,f=null,N=0,C=null,k="",E=0,b=new Map,q=new Set;function S(){if(g)throw new l("IDENTITY_CHANGED","Paywall is closed")}function Q(){let e=JSON.stringify([N,f!==null]);if(!C||e!==k){k=e;let n=z(++E);C=n;let i=()=>{C===n&&(C=null)};n.then(i,i)}return C.then(n=>structuredClone(n))}async function z(e){S();let n=P.resolvePaywall,i=await V(m.request,n,{...a,selector:t?{type:"version",versionId:t.id}:a.selector});j(a,i.paywall.check,i.scope);let s=await x(w,i.paywall);if(S(),r.paywallVersionId?s.id!==r.paywallVersionId:s.paywallId!==r.paywallId)throw new l("INVALID_RESPONSE","The requested Paywall changed");if(t&&(!H(s,t)||s.paywallId!==t.paywallId))throw new l("INVALID_RESPONSE","The pinned Paywall or Offering Version changed");if(e!==E)return structuredClone(t??s);t=s;for(let I of q)$(I,structuredClone(t));return structuredClone(t)}async function T(e){if(S(),h&&e!=="read")throw new l("COMMAND_PENDING","Wait for the original quote");if(!c)throw new l("INVALID_REQUEST","A quoted purchase is required");let n=c;if(e!=="read"){if(f){if(d===e)return f;throw new l("COMMAND_PENDING","Wait for the original purchase command")}if(d&&d!==e)throw new l("COMMAND_PENDING","Read the original purchase before changing an uncertain command");d=e,N++,E++}let i=d,s=N,I=e==="read"&&f===null,p=JSON.stringify([n.operationId,s,f!==null]);if(e==="read"&&b.has(p))return b.get(p).then(o=>structuredClone(o));let A=e==="read"?P.readSubscriptionOperation:P.attach,y=(async()=>{let o=await V(m.request,A,{operationId:n.operationId,...e==="read"?{}:{intent:e},...e==="confirm"&&n.merchantTerms?{merchantConfirmation:L(n.merchantTerms)}:{}});return W(o.operation,{operationId:n.operationId,currency:a.commerce.currency},"The purchase operation changed"),S(),c?.operationId!==n.operationId?structuredClone(o.operation):(u=F(u,o.operation),(e!=="read"||I&&f===null)&&N===s&&d===i&&(d=null),structuredClone(u))})();if(e!=="read"){f=y;let o=()=>{f===y&&(f=null)};y.then(o,o)}else{b.set(p,y);let o=()=>{b.get(p)===y&&b.delete(p)};y.then(o,o)}return y.then(o=>structuredClone(o))}let D={signal:_.signal,get view(){return t?structuredClone(t):null},get quote(){return c?structuredClone(c):null},get operation(){return u?structuredClone(u):null},get webViewUrl(){return"bundled"},get locale(){return a.locale},get recovery(){return K({quote:c,operation:u,requestId:R,pending:h!==null||d!==null,destroyed:g})},get pendingCancellation(){return!g&&d==="cancel"},refresh:Q,subscribe(e){return g?()=>{}:(q.add(e),()=>q.delete(e))},async preview(e){if(S(),!t)throw new l("INVALID_REQUEST","Load the Paywall first");let n=t.document.buttons[e.actionId];if(n?.type!=="checkout")throw new l("INVALID_REQUEST","Choose an authored purchase action");let i=U(n.product,e.selection,t.capabilities);if(!i)throw new l("PRODUCT_UNAVAILABLE","Choose an available Product");let s=G(t.document.screen,i,e.selection,t.capabilities),I=P.previewAttach.request.parse({funnelId:a.funnelId,funnelVersionId:a.funnelVersionId,requestId:e.requestId,plans:[{productVersionId:i,...Object.keys(s).length?{featureQuantities:s}:{}}],provider:a.commerce.provider,currency:a.commerce.currency,...e.offerId?{offerId:e.offerId}:{},...e.nativeOffer?{nativeOffer:e.nativeOffer}:{}}),p=JSON.stringify(I);if(v&&v!==p&&(h||d||!u||u.status==="pending"))throw new l("COMMAND_PENDING","Finish or cancel the original purchase before changing it");if(v===p){if(h)return h;if(c)return structuredClone(c)}v!==p&&(c=null,u=null),v=p,R=I.requestId;let A=(async()=>{let y=P.previewAttach,o=await V(m.request,y,I);return S(),B(o.quote,{productVersionId:i,featureQuantities:s,currency:a.commerce.currency,provider:a.commerce.provider},"The purchase quote changed its selected Product or presentment"),c=o.quote,u=null,structuredClone(c)})();h=A;try{return await A}finally{h===A&&(h=null)}},confirm:()=>T("confirm"),cancel:()=>T("cancel"),read:()=>T("read"),destroy(){g||(g=!0,_.abort(),q.clear(),b.clear(),Y?.(),m.dispose(),t=null,c=null,u=null,v=null,R=null)}},Y=w.session?.subscribeIdentity(D.destroy);try{return await Q(),D}catch(e){throw D.destroy(),e}}export{de as a};
@@ -1 +1 @@
1
- import{d as x}from"./chunk-DTWSDNYI.js";import{a as l}from"./chunk-O5VA3E5D.js";function F(e,t,n,s,i){let{presentation:o,screen:a}=n,b=Object.entries(n.buttons??{}).filter(([,p])=>p.type==="close").map(([p])=>p),c=e.ownerDocument.defaultView,u=a.pages.find(p=>p.id===a.initialPageId)?.theme??a.theme,w={background:a.theme.background,text:a.theme.text};t.inert=!0,t.style.cssText="width:100%;min-width:0;overflow:hidden;visibility:hidden";let f=!1,d,m=p=>{c&&d?.resizeViewport(Math.max(1,c.innerHeight-(p==="modal"?32:0)),c.innerWidth)},r=o.type==="inline"?void 0:x(e,{...a,presentation:o,theme:w},m);return r?.latch(),c&&r?.responsive&&r.setContentHeight(c.innerHeight-(r.type==="modal"?32:0)),e.style.background=u.background,e.style.color=u.text,r?(o.type==="fullscreen"||o.type==="sheet")&&(e.style.position="fixed"):e.style.position="relative",import("./screen-renderer-Q3VSMB2N.js").then(({mountScreenPreview:p})=>{f||(d=p(t,{mode:"live",skeleton:!0,closeActions:b,hostPresentation:()=>r?.type??o.type,reportContentHeight:r?.responsive,onResize(k){if(!c||!r?.responsive)return;let $=r.type==="modal"?32:0,g=Math.min(k,Math.max(0,c.innerHeight-$));t.style.height=`${g}px`,r.setContentHeight(g)},onRendered:i,onError(){d&&(d.destroy(),d=void 0)}}),r?.responsive&&m(r.type),d.update({...a,presentation:o},s,{serverInput:{bindings:[],answers:{}}}))}).catch(()=>{d?.destroy(),d=void 0}),()=>{f=!0,d?.destroy(),r?.destroy()}}var v={none:0,sm:4,md:8,lg:14,full:9999},T={system:"system-ui,sans-serif",serif:"Georgia,serif",rounded:"ui-rounded,system-ui,sans-serif",mono:"ui-monospace,monospace"},P={primary:"#172033",background:"#FFFFFF",text:"#172033",radius:"md",font:"system"};function y(e){let[t,n,s]=[1,3,5].map(i=>{let o=Number.parseInt(e.slice(i,i+2),16)/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4});return .2126*t+.7152*n+.0722*s}function S(e,t=!0){let n=y(e.primary),s=(n+.05)/.05>1.05/(n+.05)?"#111318":"#FFFFFF",i=`color-mix(in srgb, ${e.text} 22%, ${e.background})`,o=`${v[e.radius]}px`,a=`appearance:none;margin:0;min-height:44px;padding:10px 18px;border:0;border-radius:${o};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;${t?`background:${e.background};`:""}color:${e.text};font:14px/1.5 ${T[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 ${i}`,bar:`display:flex;gap:8px;padding:12px 16px;align-items:center;flex-wrap:wrap;border-top:1px solid ${i}`,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:${y(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 ${i};border-radius:${o}`,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:${s}`,secondary:`${a};background:transparent;color:${e.text};box-shadow:inset 0 0 0 1px ${i}`,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 ${i};border-radius:${o};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 ${i}`,focus:e.text}}function H(e){e.style.opacity=e.disabled?".55":"",e.style.cursor=e.disabled?"not-allowed":"pointer"}function L(e,t){e.addEventListener("focus",()=>{let n=!0;try{n=e.matches(":focus-visible")}catch{}n&&(e.style.outline=`2px solid ${t()}`,e.style.outlineOffset="2px")}),e.addEventListener("blur",()=>{e.style.outline="",e.style.outlineOffset=""})}var h={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\u2019t available right now. Contact the merchant for help."},zh:{network:"\u7F51\u7EDC\u8FDE\u63A5\u5F02\u5E38\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\u91CD\u8BD5\u3002",timeout:"\u54CD\u5E94\u65F6\u95F4\u8FC7\u957F\uFF0C\u8BF7\u91CD\u8BD5\u3002",other:"\u51FA\u4E86\u70B9\u95EE\u9898\uFF0C\u8BF7\u91CD\u8BD5\u3002",required:"\u8BF7\u5148\u56DE\u7B54\u5E26 * \u7684\u95EE\u9898\u3002",permission:"\u5F53\u524D\u65E0\u6CD5\u5B8C\u6210\u6B64\u64CD\u4F5C\uFF0C\u8BF7\u8054\u7CFB\u5546\u6237\u3002"}};function O(e,t){let n=h[t?"zh":"en"],s=e instanceof l?e.code:void 0;return s==="NETWORK_ERROR"?n.network:s==="TIMEOUT"?n.timeout:z(e)?n.permission:n.other}function z(e){return e instanceof l&&(e.code==="FORBIDDEN"||e.recovery==="check_permissions")}function q(e,t){if(!(e instanceof l)||e.code!=="INVALID_REQUEST"||e.status===void 0||e.status>=500)return!1;let n=/^Required input: (.+)$/.exec(e.message)?.[1]?.trim();return n!==void 0&&t.some(s=>s.variable===n)}function C(e){return h[e?"zh":"en"].required}function I(e,t){return e.filter(({variable:n,required:s})=>{let i=t[n];return s&&(i==null||i===""||Array.isArray(i)&&i.length===0)})}var D={zh:{pending:"\u5904\u7406\u4E2D",complete:"\u5DF2\u5B8C\u6210",cancelled:"\u5DF2\u53D6\u6D88",failed:"\u5931\u8D25",unknown:"\u72B6\u6001\u5F85\u786E\u8BA4"},en:{pending:"Processing",complete:"Completed",cancelled:"Cancelled",failed:"Failed",unknown:"Status unconfirmed"}};function _(e,t){return D[t?"zh":"en"][e]}export{F as a,P as b,S as c,H as d,L as e,O as f,z as g,q as h,C as i,I as j,_ as k};
1
+ import{d as x}from"./chunk-P6C3PNMQ.js";import{a as l}from"./chunk-WLGLQJ6M.js";function F(e,t,n,s,i){let{presentation:o,screen:a}=n,b=Object.entries(n.buttons??{}).filter(([,p])=>p.type==="close").map(([p])=>p),c=e.ownerDocument.defaultView,u=a.pages.find(p=>p.id===a.initialPageId)?.theme??a.theme,w={background:a.theme.background,text:a.theme.text};t.inert=!0,t.style.cssText="width:100%;min-width:0;overflow:hidden;visibility:hidden";let f=!1,d,m=p=>{c&&d?.resizeViewport(Math.max(1,c.innerHeight-(p==="modal"?32:0)),c.innerWidth)},r=o.type==="inline"?void 0:x(e,{...a,presentation:o,theme:w},m);return r?.latch(),c&&r?.responsive&&r.setContentHeight(c.innerHeight-(r.type==="modal"?32:0)),e.style.background=u.background,e.style.color=u.text,r?(o.type==="fullscreen"||o.type==="sheet")&&(e.style.position="fixed"):e.style.position="relative",import("./screen-renderer-FFVZ64MR.js").then(({mountScreenPreview:p})=>{f||(d=p(t,{mode:"live",skeleton:!0,closeActions:b,hostPresentation:()=>r?.type??o.type,reportContentHeight:r?.responsive,onResize(k){if(!c||!r?.responsive)return;let $=r.type==="modal"?32:0,g=Math.min(k,Math.max(0,c.innerHeight-$));t.style.height=`${g}px`,r.setContentHeight(g)},onRendered:i,onError(){d&&(d.destroy(),d=void 0)}}),r?.responsive&&m(r.type),d.update({...a,presentation:o},s,{serverInput:{bindings:[],answers:{}}}))}).catch(()=>{d?.destroy(),d=void 0}),()=>{f=!0,d?.destroy(),r?.destroy()}}var v={none:0,sm:4,md:8,lg:14,full:9999},T={system:"system-ui,sans-serif",serif:"Georgia,serif",rounded:"ui-rounded,system-ui,sans-serif",mono:"ui-monospace,monospace"},P={primary:"#172033",background:"#FFFFFF",text:"#172033",radius:"md",font:"system"};function y(e){let[t,n,s]=[1,3,5].map(i=>{let o=Number.parseInt(e.slice(i,i+2),16)/255;return o<=.03928?o/12.92:((o+.055)/1.055)**2.4});return .2126*t+.7152*n+.0722*s}function S(e,t=!0){let n=y(e.primary),s=(n+.05)/.05>1.05/(n+.05)?"#111318":"#FFFFFF",i=`color-mix(in srgb, ${e.text} 22%, ${e.background})`,o=`${v[e.radius]}px`,a=`appearance:none;margin:0;min-height:44px;padding:10px 18px;border:0;border-radius:${o};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;${t?`background:${e.background};`:""}color:${e.text};font:14px/1.5 ${T[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 ${i}`,bar:`display:flex;gap:8px;padding:12px 16px;align-items:center;flex-wrap:wrap;border-top:1px solid ${i}`,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:${y(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 ${i};border-radius:${o}`,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:${s}`,secondary:`${a};background:transparent;color:${e.text};box-shadow:inset 0 0 0 1px ${i}`,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 ${i};border-radius:${o};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 ${i}`,focus:e.text}}function H(e){e.style.opacity=e.disabled?".55":"",e.style.cursor=e.disabled?"not-allowed":"pointer"}function L(e,t){e.addEventListener("focus",()=>{let n=!0;try{n=e.matches(":focus-visible")}catch{}n&&(e.style.outline=`2px solid ${t()}`,e.style.outlineOffset="2px")}),e.addEventListener("blur",()=>{e.style.outline="",e.style.outlineOffset=""})}var h={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\u2019t available right now. Contact the merchant for help."},zh:{network:"\u7F51\u7EDC\u8FDE\u63A5\u5F02\u5E38\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\u91CD\u8BD5\u3002",timeout:"\u54CD\u5E94\u65F6\u95F4\u8FC7\u957F\uFF0C\u8BF7\u91CD\u8BD5\u3002",other:"\u51FA\u4E86\u70B9\u95EE\u9898\uFF0C\u8BF7\u91CD\u8BD5\u3002",required:"\u8BF7\u5148\u56DE\u7B54\u5E26 * \u7684\u95EE\u9898\u3002",permission:"\u5F53\u524D\u65E0\u6CD5\u5B8C\u6210\u6B64\u64CD\u4F5C\uFF0C\u8BF7\u8054\u7CFB\u5546\u6237\u3002"}};function O(e,t){let n=h[t?"zh":"en"],s=e instanceof l?e.code:void 0;return s==="NETWORK_ERROR"?n.network:s==="TIMEOUT"?n.timeout:z(e)?n.permission:n.other}function z(e){return e instanceof l&&(e.code==="FORBIDDEN"||e.recovery==="check_permissions")}function q(e,t){if(!(e instanceof l)||e.code!=="INVALID_REQUEST"||e.status===void 0||e.status>=500)return!1;let n=/^Required input: (.+)$/.exec(e.message)?.[1]?.trim();return n!==void 0&&t.some(s=>s.variable===n)}function C(e){return h[e?"zh":"en"].required}function I(e,t){return e.filter(({variable:n,required:s})=>{let i=t[n];return s&&(i==null||i===""||Array.isArray(i)&&i.length===0)})}var D={zh:{pending:"\u5904\u7406\u4E2D",complete:"\u5DF2\u5B8C\u6210",cancelled:"\u5DF2\u53D6\u6D88",failed:"\u5931\u8D25",unknown:"\u72B6\u6001\u5F85\u786E\u8BA4"},en:{pending:"Processing",complete:"Completed",cancelled:"Cancelled",failed:"Failed",unknown:"Status unconfirmed"}};function _(e,t){return D[t?"zh":"en"][e]}export{F as a,P as b,S as c,H as d,L as e,O as f,z as g,q as h,C as i,I as j,_ as k};
@@ -1 +1 @@
1
- import{a as m,m as f,p as y}from"./chunk-Y5RT7PAD.js";import{g as d}from"./chunk-HJVEVJXS.js";import{e as l,f as u,j as p}from"./chunk-BDC7B4KM.js";import{b as e}from"./chunk-42UXYMRZ.js";var h={funnelId:e.uuid().optional(),funnelVersionId:e.uuid().optional()};var w=e.strictObject({runId:e.uuid(),bindingId:e.uuid(),receiptId:e.uuid()});var q=e.strictObject({processContext:w.optional(),...h,selector:e.discriminatedUnion("type",[e.strictObject({type:e.literal("paywall"),paywallId:e.uuid()}),e.strictObject({type:e.literal("version"),versionId:e.uuid()})]),customerId:e.uuid().optional(),commerce:l,locale:e.string().min(1).max(35),requirement:u.optional()}),c=e.strictObject({id:e.uuid(),paywallId:e.uuid(),version:e.number().int().positive(),document:m.omit({requirement:!0,offeringId:!0}),offering:e.strictObject({id:e.uuid()}),content:e.strictObject({environmentId:e.uuid(),offeringVersionId:e.uuid(),artifact:y.refine(n=>n.kind==="paywall"&&n.formatVersion===1)}).optional(),capabilities:d,check:p.nullable()}).superRefine((n,r)=>{let t=new Set(n.document.products.items.map(o=>o.productVersionId));(n.document.offeringVersionId!==n.offering.id||Object.values(n.capabilities.plans).some(o=>!t.has(o.versionId)))&&r.addIssue({code:"custom",message:"Paywall resolution must preserve the exact Offering Version and displayed Product subset"})}),M=e.strictObject(c.shape).omit({document:!0,offering:!0}).extend({content:c.shape.content.unwrap()});function _(n,r){let t=f.parse(r);if(t.offeringVersionId!==n.content.offeringVersionId)throw new Error("Public Paywall Offering pin changed");let o=structuredClone(n.capabilities);for(let[g,i]of Object.entries(t.catalog)){let a=o.plans[g],s=i.channels.stripe?.prices.find(I=>I.currency===a?.currency);a&&s&&Object.assign(a,{amountMinor:s.amountMinor,interval:i.interval,intervalCount:i.intervalCount,...i.prepaid?.length?{prepaid:i.prepaid}:{}})}return c.parse({...n,capabilities:o,document:{schemaVersion:3,kind:t.kind,name:t.name,presentation:t.presentation,products:t.products,offeringVersionId:t.offeringVersionId,screen:t.screen,buttons:t.buttons},offering:{id:t.offeringVersionId}})}export{h as a,w as b,q as c,c as d,M as e,_ as f};
1
+ import{a as m,m as f,p as y}from"./chunk-P23JOPR5.js";import{g as d}from"./chunk-XDOKFAE6.js";import{e as l,f as u,j as p}from"./chunk-Y6HL2IY2.js";import{b as e}from"./chunk-RGEBK6UF.js";var h={funnelId:e.uuid().optional(),funnelVersionId:e.uuid().optional()};var w=e.strictObject({runId:e.uuid(),bindingId:e.uuid(),receiptId:e.uuid()});var q=e.strictObject({processContext:w.optional(),...h,selector:e.discriminatedUnion("type",[e.strictObject({type:e.literal("paywall"),paywallId:e.uuid()}),e.strictObject({type:e.literal("version"),versionId:e.uuid()})]),customerId:e.uuid().optional(),commerce:l,locale:e.string().min(1).max(35),requirement:u.optional()}),c=e.strictObject({id:e.uuid(),paywallId:e.uuid(),version:e.number().int().positive(),document:m.omit({requirement:!0,offeringId:!0}),offering:e.strictObject({id:e.uuid()}),content:e.strictObject({environmentId:e.uuid(),offeringVersionId:e.uuid(),artifact:y.refine(n=>n.kind==="paywall"&&n.formatVersion===1)}).optional(),capabilities:d,check:p.nullable()}).superRefine((n,r)=>{let t=new Set(n.document.products.items.map(o=>o.productVersionId));(n.document.offeringVersionId!==n.offering.id||Object.values(n.capabilities.plans).some(o=>!t.has(o.versionId)))&&r.addIssue({code:"custom",message:"Paywall resolution must preserve the exact Offering Version and displayed Product subset"})}),M=e.strictObject(c.shape).omit({document:!0,offering:!0}).extend({content:c.shape.content.unwrap()});function _(n,r){let t=f.parse(r);if(t.offeringVersionId!==n.content.offeringVersionId)throw new Error("Public Paywall Offering pin changed");let o=structuredClone(n.capabilities);for(let[g,i]of Object.entries(t.catalog)){let a=o.plans[g],s=i.channels.stripe?.prices.find(I=>I.currency===a?.currency);a&&s&&Object.assign(a,{amountMinor:s.amountMinor,interval:i.interval,intervalCount:i.intervalCount,...i.prepaid?.length?{prepaid:i.prepaid}:{}})}return c.parse({...n,capabilities:o,document:{schemaVersion:3,kind:t.kind,name:t.name,presentation:t.presentation,products:t.products,offeringVersionId:t.offeringVersionId,screen:t.screen,buttons:t.buttons},offering:{id:t.offeringVersionId}})}export{h as a,w as b,q as c,c as d,M as e,_ as f};
@@ -1 +1 @@
1
- import{c as ee,d as ne}from"./chunk-SY7AYEDO.js";import{a as Z}from"./chunk-O5VA3E5D.js";import{a as b}from"./chunk-DSPLGTQI.js";var ue=5*6e4,pe=15e3,re=new WeakMap;function me(t){return re.get(t)}var E=t=>Array.isArray(t)?t.map(E):t&&typeof t=="object"?Object.fromEntries(Object.keys(t).sort().map(n=>[n,E(t[n])])):t,ae=(t,n)=>JSON.stringify(E(t))===JSON.stringify(E(n)),te=t=>JSON.stringify(E([t.funnelId,t.locale??null,t.parameters??{}])),fe=["onObservationChange","onPurchase","onCheckoutUrl","resumeCheckout","allowNewPurchase","checkoutNavigation","terminateCheckout","confirmOnHostedCheckout","resolveOfferId","onOpenUrl","onEvent","onAction","onComplete","onError"];function he(t,n){let V=e=>structuredClone({funnelId:e.funnelId,locale:e.locale,parameters:e.parameters}),y,j="",T=n.start instanceof Promise?void 0:V(n.start),O=e=>e?.parameters?.commerce,_=n.maxAgeMs??ue,J=new AbortController,d=AbortSignal.any([J.signal,n.client.identitySignal,...n.signal?[n.signal]:[]]),F=()=>r("released","aborted"),a="preparing",U,k=0,g=null,p=null,f=null,u=null,l=null,A=new Set,v=new Map,N,G=new Promise(e=>N=e),D,oe=new Promise(e=>D=e);function I(e,o){a!==e&&(a=e,U=o,b(n.onState,e))}function le(){d.removeEventListener("abort",F),R(),p?.destroy(),p=null,g?.remove(),g=null,f=null}function r(e,o){["adopted","unavailable","released","closed"].includes(a)||(I(e,o),le(),N(!1),D(null))}let q=e=>`error:${e?.code??e?.name??"unknown"}`,M=t.ownerDocument.defaultView,C=!0,W=null,h=!1,se=e=>e.storageArea===M?.localStorage&&(e.key===null||e.key.startsWith("indiana.funnel.purchases.")),K=e=>{se(e)&&H()},ie=n.client.subscribe(()=>H());function R(){C&&(C=!1,M?.removeEventListener("storage",K),ie())}let B=()=>C&&(a==="ready"||a==="preparing");function X(e){(a==="ready"||a==="preparing")&&r("unavailable",e)}function H(){if(a==="ready"&&Date.now()-k>=_)return R();h=!0,W??=(async()=>{for(;h&&y&&B();){h=!1;try{await n.client.retained()==="pending"&&X("purchase_pending")}catch(e){d.aborted?r("released","aborted"):X(q(e))}}})().finally(()=>{W=null,h&&y&&B()&&H()})}M?.addEventListener("storage",K),d.addEventListener("abort",F,{once:!0});let $=n.client.findPurchase();$.catch(()=>{});async function P(){let e=await oe;if(!e)throw new Z("PURCHASE_PENDING","The purchase did not start; open it again");return e}let ce={get view(){return l?l.view:u},get signal(){return l?.signal??n.client.identitySignal},get quote(){return l?.quote??null},get operation(){return l?.operation??null},webViewUrl:"bundled",get canReselect(){return l?.canReselect},get recovery(){return l?.recovery},get pendingCancellation(){return l?.pendingCancellation},subscribe(e){return v.set(e,l?.subscribe?.(e)??(()=>{})),()=>{v.get(e)?.(),v.delete(e)}},refresh:async()=>l?l.refresh():structuredClone(u),preview:async e=>(await P()).preview(e),confirm:async()=>(await P()).confirm(),cancel:async()=>(await P()).cancel(),read:async()=>(await P()).read(),destroy(){l?.destroy()}},s={options:{},handoff:{}},z={loading:"host",focusAtReveal:!0,signal:n.client.identitySignal,start:async()=>ce,canInteract:()=>s.options.canInteract?s.options.canInteract():!["unavailable","released","closed"].includes(a),async beforeAction(){let e=a!=="adopted",o=u?.capabilities,i=await P();if(e&&!ae(i.view?.capabilities,o))throw new ee;await s.options.beforeAction?.()}};for(let e of fe)Object.defineProperty(z,e,{enumerable:!0,get:()=>s.options[e]});function x(){a!=="preparing"||!f||!p||!y||(I("ready"),N(!0))}let de={present(e){if(s.handoff.present)return s.handoff.present(e);a==="preparing"&&(f=e,k=Date.now(),x())},async dismiss(){if(s.handoff.dismiss)return s.handoff.dismiss();r("closed");for(let e of[...A])b(e)},quoteError(e){s.handoff.quoteError?s.handoff.quoteError(e):b(s.options.onError,e)}};(async()=>{try{let{showPaywall:e}=await import("./paywall-TVCH6VQT.js");if(d.throwIfAborted(),a!=="preparing")return;let o=n.commerce??O(T),i=n.locale??T?.locale;if(!o)return r("unavailable","commerce_missing");if(!i)return r("unavailable","locale_missing");if(u=await n.client.readPaywall({paywallVersionId:n.paywallVersionId,paywallId:n.paywallId,commerce:o,locale:i}),d.throwIfAborted(),a!=="preparing")return;let m=Object.values(u.capabilities.plans);if(Object.values(u.document.buttons).some(c=>c.type==="checkout")&&m.length===0||m.some(c=>!c.available))return r("unavailable","plan_unavailable");g=t.ownerDocument.createElement("div"),t.append(g);let L=setTimeout(()=>a==="preparing"&&r("unavailable","timeout"),pe);G.then(()=>clearTimeout(L));let S=await e(g,z,de);if(!S.host||d.aborted||a!=="preparing"){S.host?.destroy(),r(d.aborted?"released":"unavailable","error");return}p=S.host,x()}catch(e){r(d.aborted?"released":"unavailable",q(e))}})(),Promise.resolve(n.start).then(async e=>{if(!e)return r("unavailable","gated");let o=V(e);if(!ae(O(o),n.commerce??O(o))||n.locale!==void 0&&o.locale!==n.locale)return r("unavailable","start_mismatch");try{let i=await $,m=i==="pending"?"purchase_pending":i==="found"?"original_purchase":i==="blocked"?"purchase_blocked":void 0;if(m)return r("unavailable",m);if(a!=="preparing")return;if(C&&(h=!1,await n.client.retained()==="pending"))return r("unavailable","purchase_pending")}catch(i){return r(d.aborted?"released":"unavailable",q(i))}a==="preparing"&&(y=o,j=te(o),x(),h&&H())},()=>r("unavailable","gated"));let Q={get state(){return a},get reason(){return U},ready:G,get start(){return y},matches:e=>!!y&&te(e)===j,open(){if(a==="preparing")return"pending";if(a!=="ready"||!f)return!1;if(Date.now()-k>=_)return r("unavailable","expired"),!1;let e=f;return f=null,R(),I("shown"),e(),"shown"},destroy(){J.abort()}};return re.set(Q,{onClose(e){return a==="closed"?(b(e),()=>{}):(A.add(e),()=>{A.delete(e)})},claim(){R()},async adopt(e,o){let i=e.paywall?.resolution,m=e.paywall&&!e.paywall.quote&&!e.paywall.operation&&!e.paywall.purchaseRequestId&&!(e.paywall.selectionGeneration??0);if(a!=="shown"||!p||!u||!i||!m||e.source.id!==y?.funnelId||!["running","waiting"].includes(e.status)||!ne(i,u))return null;let w;try{w=await o.start()}catch{return null}if(a!=="shown"||!p)return w.destroy(),null;l=w,s.options=o.options,s.handoff=o.handoff;for(let[c]of v)v.set(c,w.subscribe?.(c)??(()=>{})),w.view&&b(c,structuredClone(w.view));d.removeEventListener("abort",F),I("adopted"),D(w),A.clear();let L=p,S=g;return p=null,g=null,f=null,new Proxy(L,{get(c,Y){return Y==="destroy"?()=>{c.destroy(),S?.remove()}:Reflect.get(c,Y,c)}})},get modal(){return u?.document.presentation.type!=="inline"},get revealable(){return a==="ready"&&!!f&&Date.now()-k<_},release(){r("released")}}),Q}export{ue as a,me as b,he as c};
1
+ import{c as ee,d as ne}from"./chunk-VOKEZHAH.js";import{a as Z}from"./chunk-WLGLQJ6M.js";import{a as b}from"./chunk-DSPLGTQI.js";var ue=5*6e4,pe=15e3,re=new WeakMap;function me(t){return re.get(t)}var E=t=>Array.isArray(t)?t.map(E):t&&typeof t=="object"?Object.fromEntries(Object.keys(t).sort().map(n=>[n,E(t[n])])):t,ae=(t,n)=>JSON.stringify(E(t))===JSON.stringify(E(n)),te=t=>JSON.stringify(E([t.funnelId,t.locale??null,t.parameters??{}])),fe=["onObservationChange","onPurchase","onCheckoutUrl","resumeCheckout","allowNewPurchase","checkoutNavigation","terminateCheckout","confirmOnHostedCheckout","resolveOfferId","onOpenUrl","onEvent","onAction","onComplete","onError"];function he(t,n){let V=e=>structuredClone({funnelId:e.funnelId,locale:e.locale,parameters:e.parameters}),y,j="",T=n.start instanceof Promise?void 0:V(n.start),O=e=>e?.parameters?.commerce,_=n.maxAgeMs??ue,J=new AbortController,d=AbortSignal.any([J.signal,n.client.identitySignal,...n.signal?[n.signal]:[]]),F=()=>r("released","aborted"),a="preparing",U,k=0,g=null,p=null,f=null,u=null,l=null,A=new Set,v=new Map,N,G=new Promise(e=>N=e),D,oe=new Promise(e=>D=e);function I(e,o){a!==e&&(a=e,U=o,b(n.onState,e))}function le(){d.removeEventListener("abort",F),R(),p?.destroy(),p=null,g?.remove(),g=null,f=null}function r(e,o){["adopted","unavailable","released","closed"].includes(a)||(I(e,o),le(),N(!1),D(null))}let q=e=>`error:${e?.code??e?.name??"unknown"}`,M=t.ownerDocument.defaultView,C=!0,W=null,h=!1,se=e=>e.storageArea===M?.localStorage&&(e.key===null||e.key.startsWith("indiana.funnel.purchases.")),K=e=>{se(e)&&H()},ie=n.client.subscribe(()=>H());function R(){C&&(C=!1,M?.removeEventListener("storage",K),ie())}let B=()=>C&&(a==="ready"||a==="preparing");function X(e){(a==="ready"||a==="preparing")&&r("unavailable",e)}function H(){if(a==="ready"&&Date.now()-k>=_)return R();h=!0,W??=(async()=>{for(;h&&y&&B();){h=!1;try{await n.client.retained()==="pending"&&X("purchase_pending")}catch(e){d.aborted?r("released","aborted"):X(q(e))}}})().finally(()=>{W=null,h&&y&&B()&&H()})}M?.addEventListener("storage",K),d.addEventListener("abort",F,{once:!0});let $=n.client.findPurchase();$.catch(()=>{});async function P(){let e=await oe;if(!e)throw new Z("PURCHASE_PENDING","The purchase did not start; open it again");return e}let ce={get view(){return l?l.view:u},get signal(){return l?.signal??n.client.identitySignal},get quote(){return l?.quote??null},get operation(){return l?.operation??null},webViewUrl:"bundled",get canReselect(){return l?.canReselect},get recovery(){return l?.recovery},get pendingCancellation(){return l?.pendingCancellation},subscribe(e){return v.set(e,l?.subscribe?.(e)??(()=>{})),()=>{v.get(e)?.(),v.delete(e)}},refresh:async()=>l?l.refresh():structuredClone(u),preview:async e=>(await P()).preview(e),confirm:async()=>(await P()).confirm(),cancel:async()=>(await P()).cancel(),read:async()=>(await P()).read(),destroy(){l?.destroy()}},s={options:{},handoff:{}},z={loading:"host",focusAtReveal:!0,signal:n.client.identitySignal,start:async()=>ce,canInteract:()=>s.options.canInteract?s.options.canInteract():!["unavailable","released","closed"].includes(a),async beforeAction(){let e=a!=="adopted",o=u?.capabilities,i=await P();if(e&&!ae(i.view?.capabilities,o))throw new ee;await s.options.beforeAction?.()}};for(let e of fe)Object.defineProperty(z,e,{enumerable:!0,get:()=>s.options[e]});function x(){a!=="preparing"||!f||!p||!y||(I("ready"),N(!0))}let de={present(e){if(s.handoff.present)return s.handoff.present(e);a==="preparing"&&(f=e,k=Date.now(),x())},async dismiss(){if(s.handoff.dismiss)return s.handoff.dismiss();r("closed");for(let e of[...A])b(e)},quoteError(e){s.handoff.quoteError?s.handoff.quoteError(e):b(s.options.onError,e)}};(async()=>{try{let{showPaywall:e}=await import("./paywall-UANWOKKC.js");if(d.throwIfAborted(),a!=="preparing")return;let o=n.commerce??O(T),i=n.locale??T?.locale;if(!o)return r("unavailable","commerce_missing");if(!i)return r("unavailable","locale_missing");if(u=await n.client.readPaywall({paywallVersionId:n.paywallVersionId,paywallId:n.paywallId,commerce:o,locale:i}),d.throwIfAborted(),a!=="preparing")return;let m=Object.values(u.capabilities.plans);if(Object.values(u.document.buttons).some(c=>c.type==="checkout")&&m.length===0||m.some(c=>!c.available))return r("unavailable","plan_unavailable");g=t.ownerDocument.createElement("div"),t.append(g);let L=setTimeout(()=>a==="preparing"&&r("unavailable","timeout"),pe);G.then(()=>clearTimeout(L));let S=await e(g,z,de);if(!S.host||d.aborted||a!=="preparing"){S.host?.destroy(),r(d.aborted?"released":"unavailable","error");return}p=S.host,x()}catch(e){r(d.aborted?"released":"unavailable",q(e))}})(),Promise.resolve(n.start).then(async e=>{if(!e)return r("unavailable","gated");let o=V(e);if(!ae(O(o),n.commerce??O(o))||n.locale!==void 0&&o.locale!==n.locale)return r("unavailable","start_mismatch");try{let i=await $,m=i==="pending"?"purchase_pending":i==="found"?"original_purchase":i==="blocked"?"purchase_blocked":void 0;if(m)return r("unavailable",m);if(a!=="preparing")return;if(C&&(h=!1,await n.client.retained()==="pending"))return r("unavailable","purchase_pending")}catch(i){return r(d.aborted?"released":"unavailable",q(i))}a==="preparing"&&(y=o,j=te(o),x(),h&&H())},()=>r("unavailable","gated"));let Q={get state(){return a},get reason(){return U},ready:G,get start(){return y},matches:e=>!!y&&te(e)===j,open(){if(a==="preparing")return"pending";if(a!=="ready"||!f)return!1;if(Date.now()-k>=_)return r("unavailable","expired"),!1;let e=f;return f=null,R(),I("shown"),e(),"shown"},destroy(){J.abort()}};return re.set(Q,{onClose(e){return a==="closed"?(b(e),()=>{}):(A.add(e),()=>{A.delete(e)})},claim(){R()},async adopt(e,o){let i=e.paywall?.resolution,m=e.paywall&&!e.paywall.quote&&!e.paywall.operation&&!e.paywall.purchaseRequestId&&!(e.paywall.selectionGeneration??0);if(a!=="shown"||!p||!u||!i||!m||e.source.id!==y?.funnelId||!["running","waiting"].includes(e.status)||!ne(i,u))return null;let w;try{w=await o.start()}catch{return null}if(a!=="shown"||!p)return w.destroy(),null;l=w,s.options=o.options,s.handoff=o.handoff;for(let[c]of v)v.set(c,w.subscribe?.(c)??(()=>{})),w.view&&b(c,structuredClone(w.view));d.removeEventListener("abort",F),I("adopted"),D(w),A.clear();let L=p,S=g;return p=null,g=null,f=null,new Proxy(L,{get(c,Y){return Y==="destroy"?()=>{c.destroy(),S?.remove()}:Reflect.get(c,Y,c)}})},get modal(){return u?.document.presentation.type!=="inline"},get revealable(){return a==="ready"&&!!f&&Date.now()-k<_},release(){r("released")}}),Q}export{ue as a,me as b,he as c};
@@ -1 +1 @@
1
- import{b as e}from"./chunk-42UXYMRZ.js";var s=/^gg_ct_[A-Za-z0-9_-]{32,128}$/,o=e.object({customerId:e.uuid(),sessionId:e.uuid(),accessToken:e.string().regex(/^gg_ct_[A-Za-z0-9_-]{43}$/),refreshToken:e.string().regex(/^gg_rt_[A-Za-z0-9_-]{43}$/),expiresAt:e.iso.datetime(),refreshExpiresAt:e.iso.datetime()});export{s as a,o as b};
1
+ import{b as e}from"./chunk-RGEBK6UF.js";var s=/^gg_ct_[A-Za-z0-9_-]{32,128}$/,o=e.object({customerId:e.uuid(),sessionId:e.uuid(),accessToken:e.string().regex(/^gg_ct_[A-Za-z0-9_-]{43}$/),refreshToken:e.string().regex(/^gg_rt_[A-Za-z0-9_-]{43}$/),expiresAt:e.iso.datetime(),refreshExpiresAt:e.iso.datetime()});export{s as a,o as b};
@@ -1 +1 @@
1
- import{a as Mn,b as Un,c as un,d as dn,e as Me,f as $n,h as xn,i as Gn,j as Qn,k as Jn}from"./chunk-JXTJT2EW.js";import{b as zn}from"./chunk-JBDNNV3P.js";import{b as qn,c as Bn}from"./chunk-L54MODP5.js";import{a as On}from"./chunk-W32FI2A2.js";import{c as Sn,e as _n,f as Ln,h as Hn,i as Se,j as Ze,k as Vn,l as Ke}from"./chunk-DTWSDNYI.js";import{aa as Xe}from"./chunk-KQF4BVOL.js";import{a as Ve,d as Dn}from"./chunk-3NCMYTNG.js";import{b as Rn}from"./chunk-64ETX3AY.js";import{b as kn,d as Tn,e as An,f as Nn,g as Fn}from"./chunk-SY7AYEDO.js";import{F as Pn,ea as En}from"./chunk-HJVEVJXS.js";import{a as y}from"./chunk-O5VA3E5D.js";import{a as Ce}from"./chunk-DSPLGTQI.js";async function cn(t){let{session:v,load:C}=it(t);try{return await C(),v}catch(e){throw v.destroy(),e}}function it(t){let v=t.view;if(!v?.paywall)throw new y("INVALID_REQUEST","The current node is not a Paywall");let C=v.paywall.receiptId,e=v.nodeId,w=v.visit,N=v.paywall.resolution,s=v.paywall,_="document"in N?{document:N.document,offering:N.offering,capabilities:N.capabilities}:null;function d(){let i=s.resolution;return"document"in i?i:_&&{...i,document:_.document,offering:_.offering,capabilities:kn(i.capabilities,_.capabilities)}}function I(i){if(!Tn(i,N))throw new y("INVALID_RESPONSE","The pinned Paywall binding changed")}let P=!1,$=new Set,ne=null;function m(){let i=d();if(i&&!P)for(let l of $)Ce(l,structuredClone(i))}async function V(){O();let i=d();if(i)return structuredClone(i);if(!ne){let l=(async()=>{if("document"in s.resolution||!t.resolvePaywall)throw new y("INVALID_RESPONSE","Public Paywall reader is unavailable");let b=await qn(t,s.resolution);return O(),I(b),_={document:b.document,offering:b.offering,capabilities:b.capabilities},m(),d()})();ne=l;let a=()=>{ne===l&&(ne=null)};l.then(a,a)}return ne.then(l=>structuredClone(l))}let o=new AbortController,k=(t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[])).find(i=>i.operation==="submit"&&i.nodeId===e&&i.visit===w&&i.input.type==="paywall_quote")?.requestId??v.paywall.purchaseRequestId,Y=0,J=null,Q=new Set,E=null,z=new Map;function T(i){if(i.purchase&&i.purchase.receiptId!==C)throw new y("INVALID_RESPONSE","Purchase receipt changed");let l=i.run.paywall;return i.purchase??(l?.receiptId===C?l:null)}function O(){if(P)throw new y("IDENTITY_CHANGED","Paywall presentation has closed")}function S(i,l,a){if(O(),l!==Y||a!==void 0&&s.quote?.operationId!==a)return!1;let b=s.selectionGeneration??0,c=i.run.paywall;if(c?.receiptId===C){if((c.selectionGeneration??0)<(s.selectionGeneration??0))return!1;I(c.resolution)}let u=T(i),q=c?.receiptId===C&&(c.selectionGeneration??0)>b,L=q?u?.quote??null:u?.quote??s.quote,B=u?.operation??(L?.operationId===s.quote?.operationId?s.operation:null);return L&&B&&An(B,{operationId:L.operationId},"Purchase operation changed"),(q||L?.operationId!==s.quote?.operationId)&&(Y++,c?.receiptId===C&&(k=c.purchaseRequestId)),c?.canReselect===!0&&c.purchaseRequestId===E&&!(t.pendingCommands??[t.pendingCommand]).some(M=>M?.requestId===E)&&(E=null),s={...s,...c?.receiptId===C?c:{},...a!==void 0&&!q&&u?.canReselect!==void 0?{canReselect:u.canReselect}:{},quote:L,operation:Fn(s.operation,B,!0)},m(),!0}function ce(i,l,a){return new Promise((b,c)=>{let u=!1,q=()=>{clearTimeout(Ee),o.signal.removeEventListener("abort",M)},L=Re=>{u||(u=!0,q(),b(Re))},B=Re=>{u||(u=!0,q(),c(Re))},M=()=>B(new y("IDENTITY_CHANGED","Paywall presentation has closed")),Ee=setTimeout(()=>B(new y("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,a)),Math.max(0,l-Date.now()));o.signal.addEventListener("abort",M,{once:!0}),o.signal.aborted&&M(),i.then(L,B)})}function Pe(i){return new Promise(l=>{let a=()=>{clearTimeout(b),o.signal.removeEventListener("abort",a),l()},b=setTimeout(a,i);o.signal.addEventListener("abort",a,{once:!0}),o.signal.aborted&&a()})}function se(i,l){O();let a=z.get(i)??t.pendingCommands?.find(u=>u.requestId===i)??t.pendingCommand;if(a?.operation==="submit"&&a.requestId===i&&a.nodeId===e&&a.visit===w){l.type==="paywall_quote"&&a.input.type==="paywall_quote"&&a.input.predecessor&&!l.predecessor&&(l={...l,predecessor:a.input.predecessor});let u=Xe.parse(a),q=Xe.parse({...a,input:l});if(u.operation!=="submit"||q.operation!=="submit"||JSON.stringify(u.input)!==JSON.stringify(q.input))throw new y("CONFLICT","A purchase request cannot change its input");return z.set(i,u),u}let b=t.view;if(!b||b.nodeId!==e||b.visit!==w||b.paywall?.receiptId!==C)throw new y("PRECONDITION_FAILED","The Paywall visit has changed");let c=Xe.parse({operation:"submit",requestId:i,nodeId:e,visit:w,revision:b.revision,input:structuredClone(l)});if(c.operation!=="submit")throw new y("INVALID_REQUEST","A purchase submission is required");return z.set(i,c),c}async function te(i,l){O();let{requestId:a,input:b}=i,c=Date.now()+3e4;Q.add(a);try{let u=await ce(t.submit(i),c,a);for(;u.run.pendingRequest?.requestId===a&&Date.now()<c&&!P&&(await Pe(Math.min(1e3,c-Date.now())),!(P||Date.now()>=c));)u=await ce(t.resume(a),c,a);if(P)throw new y("IDENTITY_CHANGED","Paywall presentation has closed");if(u.run.pendingRequest?.requestId===a)throw new y("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,a);if(!S(u,l,b.type==="paywall_confirm"||b.type==="paywall_cancel"?b.operationId:void 0))throw new y("PRECONDITION_FAILED","The purchase selection has changed");E===a&&(E=null)}catch(u){if(E=a,b.type==="paywall_quote"&&t.settle&&!P&&u instanceof y&&u.status!==void 0&&![401,425].includes(u.status)&&!u.retryable&&u.recovery!=="recover_operation")try{if((await ce(t.settle(a),c,a)).settlement?.state==="settled"){let L=await ce(t.get(),c,a);S(L,l)&&L.run.paywall?.purchaseRequestId===a&&s.canReselect===!0&&z.delete(a)}}catch{}throw u instanceof y&&u.code==="COMMAND_PENDING"&&u.status===void 0&&z.delete(a),u}finally{Q.delete(a)}}async function me(i){if(!s.quote)throw new y("INVALID_REQUEST","A quoted purchase is required");let l=i==="confirm"?"paywall_confirm":"paywall_cancel",a=[...z.values(),...t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[])].find(c=>c.operation==="submit"&&c.input.type===l&&"operationId"in c.input&&c.input.operationId===s.quote.operationId),b=a?.operation==="submit"&&a.input.type===l&&"operationId"in a.input&&a.input.operationId===s.quote.operationId?a.requestId:crypto.randomUUID();if(await te(se(b,{type:i==="confirm"?"paywall_confirm":"paywall_cancel",operationId:s.quote.operationId}),Y),!s.operation)throw new y("INVALID_RESPONSE","The accepted purchase result is missing");return structuredClone(s.operation)}let G={get view(){return structuredClone(d())},get quote(){return s.quote?structuredClone(s.quote):null},get operation(){return s.operation?structuredClone(s.operation):null},get webViewUrl(){return t.webViewUrl},get locale(){return t.view?.locale??v.locale},get canReselect(){return s.canReselect===!0&&E===null},get recovery(){let i=t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[]),l=t.pendingPurchase;if(l&&(l.receiptId!==C||l.operationId!==s.quote?.operationId))return{type:"recover",operationId:l.operationId,requestId:i[0]?.requestId??null};let a=Ve({quote:s.quote,operation:s.operation,requestId:i[0]?.requestId??E??k,pending:Q.size>0||i.length>0||E!==null,destroyed:P,canReselect:s.canReselect});return a.type==="recover"&&a.requestId===null&&!P&&t.hasDurableJournal===!0&&!s.quote&&!s.operation&&(s.selectionGeneration??0)===0&&!l&&!i.length&&!Q.size&&!k?{type:"native",operationId:null}:a},get pendingCancellation(){return!P&&(t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[])).some(i=>i.operation==="submit"&&i.nodeId===e&&i.visit===w&&i.input.type==="paywall_cancel"&&i.input.operationId===s.quote?.operationId)},subscribe(i){return P?()=>{}:($.add(i),()=>$.delete(i))},async refresh(){O();let i=Y,l=await t.get();if(S(l,i),l.run.paywall?.receiptId!==C)throw new y("PRECONDITION_FAILED","Paywall presentation has changed");return V()},preview(i){let l=d();if(!l)return Promise.reject(new y("PRECONDITION_FAILED","Load the Paywall presentation first"));if(k&&k!==i.requestId&&(J||s.canReselect!==!0))return Promise.reject(new y("COMMAND_PENDING","Retry the original purchase before starting another"));let a=l.document.buttons[i.actionId],b=a?.type==="checkout"?Rn(a.product,i.selection,l.capabilities):null;if(!b)return Promise.reject(new y("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));let c=En(l.document.screen,b,i.selection,l.capabilities),u=k!==i.requestId&&(s.selectionGeneration??0)>0?{operationId:s.quote?.operationId??null,generation:s.selectionGeneration??0}:void 0;if(u&&s.canReselect!==!0)return Promise.reject(new y("COMMAND_PENDING","Original purchase requires authoritative termination"));let q;try{q=se(i.requestId,{type:"paywall_quote",actionId:i.actionId,productVersionId:b,...Object.keys(c).length?{featureQuantities:c}:{},...u?{predecessor:u}:{},...i.offerId?{offerId:i.offerId}:{},...i.nativeOffer?{nativeOffer:i.nativeOffer}:{}})}catch(M){return Promise.reject(M)}if(k===i.requestId&&J)return J;k!==i.requestId&&Y++;let L=Y;k=i.requestId;let B=(async()=>{if(await te(q,L),!s.quote)throw new y("INVALID_RESPONSE","The accepted quote is missing");return Nn(s.quote,{productVersionId:b,featureQuantities:c},"The selected purchase changed"),structuredClone(s.quote)})();return J=B,B.then(()=>{J===B&&(J=null)},M=>{J===B&&(J=null),k===i.requestId&&t.pendingCommand?.requestId!==i.requestId&&M instanceof y&&M.status!==void 0&&M.status<500&&![401,425].includes(M.status)&&(k=null)}),B},confirm:()=>me("confirm"),cancel:()=>me("cancel"),async read(){if(O(),!s.quote)throw new y("INVALID_REQUEST","A quoted purchase is required");let i=s.quote.operationId,l=Y,a=t.pendingCommands?.find(L=>L.operation==="submit"&&(L.input.type==="paywall_confirm"||L.input.type==="paywall_cancel")&&L.input.operationId===i)??t.pendingCommand;a?.operation==="submit"&&(a.input.type==="paywall_confirm"||a.input.type==="paywall_cancel")&&a.input.operationId===i&&await t.settle?.(a.requestId);let b=await t.get(void 0,{receiptId:C,operationId:i});O();let c=T(b);if(c?.quote&&c.quote.operationId!==i||c?.operation&&c.operation.operationId!==i)throw new y("INVALID_RESPONSE","Purchase operation changed");let u=S(b,l,i),q=u?s.operation:c?.operation;if(!q)throw new y("INVALID_RESPONSE","The current purchase result is missing");return u&&Q.size===0&&!(t.pendingCommands?.length??(t.pendingCommand?1:0))&&(E=null),structuredClone(q)},destroy(){P=!0,A(),$.clear(),o.abort(),z.clear()}},A=t.subscribe(i=>{P||i.nodeId!==e||i.visit!==w||i.paywall?.receiptId!==C||(i.paywall.selectionGeneration??0)<(s.selectionGeneration??0)||(I(i.paywall.resolution),s={...s,resolution:i.paywall.resolution},m())});return{session:G,load:V}}function jn(t){let v=new Set,C=new Set,e=null;async function w(d,I){let P=!1;for(;!t.stopped&&t.key===d&&t.client.pendingCommand?.requestId===I;){if(!t.client.settle)throw new y("COMMAND_PENDING","The original display acknowledgement is still pending");await t.client.settle(I),P=!0,t.client.pendingCommand?.requestId===I&&await new Promise($=>setTimeout($,1500))}t.stopped||t.key!==d||(P&&await t.client.get(),!(t.stopped||t.key!==d)&&v.add(d))}function N(d,I){e=I;let P=()=>{e===I&&(e=null),C.delete(d)};return I.then(P,$=>{P(),t.busy||t.fail($)}),I}function s(d){if(t.reviewing||v.has(d)||C.has(d)||t.stopped)return;C.add(d);let I=async()=>{if(t.reviewing||t.stopped||t.key!==d||v.has(d)){C.delete(d);return}if(t.busy||t.client.pendingCommand){setTimeout(()=>{I()},250);return}let P=(async()=>{if(t.staleRead){if(await t.staleRead,t.stopped||t.key!==d)return;if(t.client.pendingCommand){setTimeout(()=>{I()},250);return}}let $=t.client.view,ne=t.expected(),m=ne.requestId;try{await t.client.submit({operation:"shown",...ne})}catch(V){if(!(V instanceof y)||V.code!=="CONFLICT"||V.status!==409||t.client.pendingCommand)throw V;await t.client.get();let o=t.client.view;if(t.stopped||t.reviewing||t.key!==d||!o||!$||o.id!==$.id||o.source.versionId!==$.source.versionId||o.nodeId!==ne.nodeId||o.visit!==ne.visit||o.revision<=ne.revision||o.stopped||!o.screen&&(!o.paywall||o.paywall.receiptId!==$.paywall?.receiptId)||!["running","waiting"].includes(o.status)||t.client.pendingCommand)throw V;let R=t.expected();m=R.requestId,await t.client.submit({operation:"shown",...R})}await w(d,m)})();N(d,P)};I()}function _(){if(e)return e;let d=t.client.pendingCommand;if(d?.operation!=="shown")return null;let I=t.key;return C.add(I),N(I,(async()=>{await t.client.retry(),await w(I,d.requestId)})())}return{report:s,settled:_,get inFlight(){return e}}}function Wn(t){let v={},C=new Map;async function e(w){let N=t.client.view,s=N?.screen,_=s?.customerData.nodes[w.nodeId];if(t.stopped||t.busy||!N||!s||!_)return;if(!["refresh","next","previous","filter","sources_next","sources_previous"].includes(w.action)){let V=t.document,o=V?Pn(V,w.nodeId):null,R=o?.type==="customer_data"?o.data.outputs?.[w.action]:void 0;R&&s.outputs.includes(R)?await t.perform(()=>t.client.submit({operation:"submit",...t.expected(),input:{type:"screen",output:R,answers:t.answers,selection:w.value?{[w.nodeId]:w.value}:{}}})):await t.onIntent?.(w,N);return}let I=w.action.startsWith("sources_")?_.resources.find(V=>V.key===w.value):null;if(w.action.startsWith("sources_")&&!I)throw new y("INVALID_REQUEST","Choose a current resource");let P=`${N.visit}:${w.nodeId}:${I?.key??""}`,$=C.get(P)??[null],m=v[w.nodeId]??{page:1,after:null,filter:"all",...I?{resourceKey:I.key}:{}};if(w.action==="filter"){let V=w.value;if(!V||!(_.source==="offer_history"?["all","issued","reserved","redeemed","expired","revoked"]:["all","purchase","refund","source","usage","debt","settlement"]).includes(V))throw new y("INVALID_REQUEST","Unknown data filter");m={page:1,after:null,filter:V},$.splice(0,$.length,null)}else if(w.action==="next"||w.action==="sources_next"){let V=I?.sources.at(-1),o=I?V?{kind:"ledger",cursor:{at:V.detail[0],id:V.id,type:"source"}}:null:s.dataCursors[w.nodeId];if(!o||!I&&!_.hasNext)return;$[m.page]=o,m={...m,page:m.page+1,after:o}}else if(w.action==="previous"||w.action==="sources_previous"){if(m.page<=1)return;m={...m,page:m.page-1,after:$[m.page-2]??null}}C.set(P,$),v={...v,[w.nodeId]:m},await t.perform(()=>t.client.get({nodeId:N.nodeId,visit:N.visit,revision:N.revision,components:v}))}return{get queries(){return v},intent:e,reset(){v={},C.clear()}}}function Yn(t){let{doc:v,holder:C,reviewHolder:e,mountScreenPreview:w}=t,N=!1,s,_=0,d=null,I="",P,$=new Map,ne=o=>o?`${o.id}:${o.nodeId}:${o.visit}:${o.revision}:${o.paywall?.quote?.operationId??""}`:"";async function m(o){if(t.stopped||!t.client.review||N&&o===s&&P?.active)return;let R=!N||o!==s;N||(I=ne(t.client.view),$.set(I,structuredClone(t.answers))),N=!0,s=o,C.hidden=!0,t.suspend(!0),e.hidden=!1;let k=++_;R&&(P?.finish("dismissed"),d?.destroy(),d=null,e.replaceChildren(),P=Ze(e,t.loadingOptions,"funnel",()=>{V()}));let Y=R?P:void 0;try{if(Y?.start(!1,t.client.view?.locale),k!==_||t.stopped)return;let J=t.client.review(o),Q=await(Y?.wait(J,Se)??J);if(t.stopped||k!==_||!N)return;if(!Q.review)throw new y("INVALID_RESPONSE","Historical projection is missing");d?.destroy(),d=null,Y||e.replaceChildren();let E=v.createElement("div"),z=Y?Ke(E,e):()=>{};e.append(E);let T=Q.run.locale.startsWith("zh"),O=t.chrome;E.style.cssText=O.history;let S=v.createElement("p");S.textContent=T?"\u53EA\u8BFB\u56DE\u770B":"Read-only history",S.style.cssText=O.historyTitle,E.append(S);let ce=v.createElement("p");ce.style.cssText=O.historyNote,ce.textContent=Q.review.pages.length?T?"\u9009\u62E9\u4E00\u9875\u67E5\u770B\u5F53\u65F6\u7684\u5185\u5BB9\uFF0C\u56DE\u770B\u4E0D\u4F1A\u6539\u52A8\u4EFB\u4F55\u4FE1\u606F\u3002":"Choose a page to see it as it was. Nothing here can be changed.":T?"\u8FD8\u6CA1\u6709\u53EF\u56DE\u770B\u7684\u9875\u9762\u3002":"There are no earlier pages yet.",E.append(ce);let Pe=Q.review.page?.receiptId,se=v.createElement("div");se.style.cssText=O.historyPages;for(let[G,A]of Q.review.pages.entries()){let i=v.createElement("button");i.type="button",i.textContent=T?`\u7B2C ${G+1} \u9875`:`Page ${G+1}`;let l=Pe!==void 0&&A.receiptId===Pe;i.style.cssText=l?O.primary:O.secondary,l&&i.setAttribute("aria-current","page"),Me(i,()=>t.chrome.focus),i.onclick=()=>{m(A.receiptId)},se.append(i)}if(se.childElementCount&&E.append(se),Q.review.page){let G=Q.review.page,A=v.createElement("div");A.inert=!0,A.style.cssText=O.historyPage,E.append(A),d=w(A,{mode:"live",rendererUrl:t.client.webViewUrl,title:G.document.name,onAction:()=>{},onAnswers:()=>{},onCustomerDataIntent:()=>{},onRendered:()=>{k===_&&!t.stopped&&Y?.present(z)},onError:l=>{if(k!==_||t.stopped)return;let a=new Error(l);Y?.finish("error",a),d?.destroy(),d=null,E.remove(),t.fail(a)},onEscape:()=>{V()}});let i=d;if(i.update(G.document,Q.run.locale,{serverInput:{bindings:G.inputs,answers:G.answers,values:G.values}}),await i.ready,t.stopped||k!==_||!N)return}let te=T?{issued:"\u5DF2\u9886\u53D6",reserved:"\u5DF2\u9884\u7559",redeemed:"\u5DF2\u4F7F\u7528",expired:"\u5DF2\u8FC7\u671F",revoked:"\u5DF2\u64A4\u9500",unknown:"\u72B6\u6001\u5F85\u786E\u8BA4"}:{issued:"Issued",reserved:"Reserved",redeemed:"Used",expired:"Expired",revoked:"Revoked",unknown:"Status unconfirmed"},me=v.createElement("div");me.style.cssText=O.historyRecords;for(let G of[...Q.review.coupons.map((A,i)=>`${T?"\u4F18\u60E0\u5238":"Coupon"} ${i+1}: ${te[A.status]}`),...Q.review.purchases.map((A,i)=>`${T?"\u8D2D\u4E70":"Purchase"} ${i+1}: ${Jn(A.status,T)}`)]){let A=v.createElement("p");A.textContent=G,A.style.margin="0",me.append(A)}me.childElementCount&&E.append(me),Q.review.page||Y?.present(z),t.client.view&&await t.enqueue(t.client.view)}catch(J){if(k!==_||t.stopped)return;Y?.finish("error",J),d?.destroy(),d=null,e.replaceChildren(),t.fail(J)}}async function V(){if(!N||t.stopped||!t.client.review)return;let o=++_;P?.finish("dismissed");try{if(await t.client.review(),t.stopped||o!==_)return;N=!1,_++,P?.finish("dismissed"),d?.destroy(),d=null,e.replaceChildren(),e.hidden=!0,C.hidden=!1;let R=t.client.view;ne(R)!==I?($.set(I,structuredClone(t.answers)),t.resetScreen()):($.delete(I),t.suspend(!1)),R&&await t.enqueue(R)}catch(R){if(o!==_||t.stopped)return;d?.destroy(),d=null,e.replaceChildren(),t.fail(R)}}return{get active(){return N},get receipt(){return s},open:m,exit:V,get drafts(){return new Map([...$].map(([o,R])=>[o,structuredClone(R)]))},stop(){N=!1,_++,P?.finish("dismissed"),d?.destroy(),d=null,e.replaceChildren(),e.hidden=!0,C.hidden=!1}}}var pn=5e3;async function rt(t,v,C){let e=v,w=e.prepared&&zn(e.prepared),N=()=>{};function s(){e.prepared&&e.prepared.state!=="adopted"&&w?.release()}let _=()=>e.prepared?.state==="shown"&&!!w?.modal,d=e.client.identitySignal,I;try{I=await Promise.all([import("./screen-renderer-Q3VSMB2N.js"),import("./paywall-TVCH6VQT.js")]),e.signal?.throwIfAborted(),d?.throwIfAborted()}catch(n){throw s(),n}let[{mountScreenPreview:P},{showPaywall:$}]=I,ne=(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&e.appManifestRelease?Bn({client:e.client,appManifestRelease:e.appManifestRelease,onError:e.onError}):void 0;ne?.start();let m=t.ownerDocument,V=Hn(m),o=m.createElement("section"),R=m.createElement("div"),k=m.createElement("div"),Y=m.createElement("div"),J=m.createElement("button");Y.hidden=!0,J.type="button";let Q=m.createElement("p"),E=m.createElement("p"),z=m.createElement("button"),T=m.createElement("button"),O=m.createElement("button"),S=m.createElement("dialog"),ce,Pe=!1;o.dataset.indianaFunnel="",o.dataset.longplayCloseOwner="sdk",o.setAttribute("aria-busy","false"),Q.setAttribute("role","status"),E.setAttribute("role","alert"),E.hidden=!0,z.type=T.type=O.type="button",k.append(z,J,Q,E,O,T),o.append(R,Y,k),t.append(o);let se=Un,te=un(se),me="",G=(m.documentElement.lang||"").startsWith("zh"),A,i="",l;for(let n of[z,J,O,T])Me(n,()=>te.focus);function a(){let n=G?"\u5173\u95ED":"Close";T.parentElement===S?(T.textContent="\xD7",T.setAttribute("aria-label",n),Ln(T,se)):(T.textContent=n,T.removeAttribute("aria-label"),T.style.cssText=te.link+";margin-inline-start:auto")}function b(n){let r=n?.screen?.content.document.theme??se,p=JSON.stringify([r.primary,r.background,r.text,r.radius,r.font,T.parentElement===S]);if(p===me)return;me=p,se=r;let H=T.parentElement===S;te=un(se,H),o.style.cssText=te.root+";min-width:0"+(H?";display:flex;flex-direction:column;min-height:100%":""),k.style.cssText=te.bar+(H?";margin-top:auto":""),k.hidden&&(k.style.display="none"),z.style.cssText=J.style.cssText=te.secondary,O.style.cssText=te.primary,Q.style.cssText=te.status,E.style.cssText=te.alert,a(),dn(z)}function c(){k.hidden=z.hidden&&J.hidden&&O.hidden&&E.hidden&&!Q.textContent&&(T.hidden||T.parentElement!==k),k.style.display=k.hidden?"none":"flex",A?.responsive&&l!==void 0&&A.setContentHeight(l+k.getBoundingClientRect().height)}b();let u=null,q=null,L=null,B="",M="",Ee=!1,Re="",en="",Ue="",h=!1,le=0,$e=!1,fn="",nn=null,tn=Promise.resolve(),mn=!e.client.view,j=C,Te,_e,xe="",Ge,ue=!1,qe=null,he=!1,Qe=()=>e.client.pendingCommand?.operation==="close",de=null,X=null,wn=On({document:m,run:async()=>{(!q?.observing||e.client.pendingCommand)&&await on()},delay:()=>{if(!(h||!L||!["running","waiting"].includes(L.status)&&!e.client.pendingCommand)&&!(q?.observing&&!e.client.pendingCommand))return L.pendingRequest||e.client.pendingCommand?1500:pn},hiddenDelay:()=>!h&&e.client.pendingCommand?15e3:void 0}),K=null;function rn(){return X&&e.client.hasDurableJournal===!0&&K?.acknowledged===!0&&K.operationId===X.operationId&&e.client.view?.id===K.runId&&e.client.view?.status==="closed"&&e.client.view.revision===K.revision+1&&!(e.client.pendingCommands?.length??(e.client.pendingCommand?1:0))&&!e.client.pendingPurchase?X:null}function yn(n){let r=n.run.paywall;if(K&&n.settlement?.requestId===K.requestId&&n.settlement.state==="settled"&&n.settlement.operationId===null&&n.run.id===K.runId&&n.run.status==="closed"&&!n.run.pendingRequest&&n.run.revision===K.revision+1&&n.run.nodeId===K.nodeId&&n.run.visit===K.visit&&r?.receiptId===K.receiptId&&r.selectionGeneration===K.selectionGeneration&&(r.quote?.operationId??null)===K.operationId&&(r.operation?.operationId??r.quote?.operationId??null)===K.operationId){let p=K.operationId===null&&r.selectionGeneration===0&&!r.quote&&!r.operation&&!r.purchaseRequestId,H=Ve({quote:r.quote,operation:r.operation,requestId:r.purchaseRequestId,pending:!1,destroyed:!1,canReselect:r.canReselect});(p||r.canReselect===!0&&H.type==="native")&&(K.acknowledged=!0)}}let De=null,Je=new Set,we={},Ae=!1,pe=(n,r=null)=>{h||(De=r,Ae=!1,E.textContent=$n(n,G),E.hidden=!1,O.hidden=e.client.pendingCommand===null,c(),Ce(e.onError,n))},gn=()=>{h||(De=null,E.textContent=Gn(G),E.hidden=!1,O.hidden=!0,c())};function ke(){let n=e.client.view;if(!n)throw new y("INVALID_REQUEST","No current Run is available");return{requestId:crypto.randomUUID(),nodeId:n.nodeId,visit:n.visit,revision:n.revision}}let F=Yn({client:e.client,doc:m,holder:R,reviewHolder:Y,mountScreenPreview:P,loadingOptions:e,get chrome(){return te},get stopped(){return h},get answers(){return we},suspend(n){q?.setSuspended(n)},resetScreen(){B="",M="",Re=""},enqueue:ye,fail:pe}),Le=jn({client:e.client,expected:ke,fail:pe,get stopped(){return h},get reviewing(){return F.active},get key(){return B},get busy(){return le},get staleRead(){return nn}}),ze=Wn({client:e.client,expected:ke,perform:Fe,onIntent:e.onCustomerDataIntent,get stopped(){return h},get busy(){return le},get document(){return u?.document},get answers(){return we}}),Be=n=>`${n.id}:${n.nodeId}:${n.visit}`,Ne=n=>n&&(n.screen||n.paywall)?Be(n):"";function ve(){let n=e.client.view;z.disabled=!F.active&&(le>0||!!e.client.pendingCommand||!n?.canBack||n.stopped||!["running","waiting"].includes(n.status)||!Ne(n)||M!==Ne(n)),z.hidden=!F.active&&!n?.canBack,dn(z);let r=!!q&&!F.active;T.hidden=r&&!j?.active||Pe&&!F.active,J.hidden=!e.client.review||!F.active&&!n?.canBack,r&&(Q.textContent=""),c()}async function hn(n){if(!n)return;let r=e.client.view;await n;let p=e.client.view;if(!r||!p||p.id!==r.id||p.nodeId!==r.nodeId||p.visit!==r.visit||p.stopped||!["running","waiting"].includes(p.status))throw new y("PRECONDITION_FAILED","The screen changed while its display was acknowledged")}async function Fe(n,r=!1,p){if(!((le||he||de||X)&&!r||h||F.active&&!r)){le++,o.setAttribute("aria-busy","true"),E.hidden=!0,De=null,Ae=!1,ve();try{if(r||await hn(Le.inFlight),h)return;let H=await n();h||await ye(e.client.view??H.run)}catch(H){p?.(H)&&e.client.pendingCommand===null?gn():pe(H,e.client.pendingCommand?.requestId??null)}finally{le=Math.max(0,le-1),o.setAttribute("aria-busy",String(le>0)),h||(O.hidden=e.client.pendingCommand===null,ve())}}}function He(){wn.schedule()}async function on(){if(!(h||$e||le)){if(F.active){await F.open(F.receipt);return}$e=!0;try{let n=e.client.pendingCommand;n&&e.client.settle&&await e.client.settle(n.requestId);let r=e.client.view,p=ze.queries,H=await e.client.get(r?.screen&&Object.keys(p).length?{nodeId:r.nodeId,visit:r.visit,revision:r.revision,components:p}:void 0);Ae&&!h&&(Ae=!1,E.hidden=!0,c()),!h&&p===ze.queries&&await ye(e.client.view??H.run)}catch(n){pe(n),Ae=!h}finally{$e=!1}}}function je(n,r,p){if(j?.active){let ae=j;return ae.setDismissHandler(()=>vn(ae)),ae}let H=Ze(t,e,"funnel",()=>vn(H),Mn);return j=H,H.start(n,r,p),H}function vn(n){h||ue||(ue=!0,n.finish("dismissed"),Ie(),o.hidden=!0,e.client.view?be().finally(ie):ie())}function sn(){clearTimeout(Ge?.timeout),Ge=void 0}function Ie(){Pe=!1,sn(),Te?.abort(),Te=void 0,u?.destroy(),u=null,q?.destroy(),q=null,_e?.(),_e=void 0,S.open&&S.close(),R.replaceChildren(),R.style.cssText="",l=void 0,B="",M="",Ee=!1,Re="",Ue=""}function In(){let n=m.defaultView;A?.responsive&&n&&u?.resizeViewport?.(n.innerHeight,n.innerWidth)}function an(){A?.destroy(),A=void 0,i=""}function We(n){let r=n.screen?.presentation;if(!r||r.type==="inline"){S.open&&S.close(),an(),T.parentElement!==k&&k.append(T),o.parentElement!==t&&t.append(o);for(let ae of["flex","display","flex-direction","justify-content"])R.style.removeProperty(ae);b(n),c();return}o.parentElement!==S&&(S.append(T,o),t.append(S)),R.style.flex="1 0 auto",R.style.display="flex",R.style.flexDirection="column",R.style.justifyContent="center",b(n);let p=n.screen.content.document,H=JSON.stringify([r,me]);if(H!==i){an(),i=H;let ae={sm:420,md:640,lg:900},ge="size"in r&&!r.backdrop?",0 0 0 100vmax #16142566":"";S.style.cssText=`box-sizing:border-box;padding:0;border:0;overflow:auto;background:${se.background};color:${se.text};`+(r.type==="fullscreen"?"width:100vw;height:100dvh;max-width:100vw;max-height:100dvh;margin:0;border-radius:0":`width:${ae[r.size]}px;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);box-shadow:0 24px 80px #0003${ge};`+(r.type==="sheet"?"margin:auto auto 0;border-radius:14px 14px 0 0":"border-radius:14px")),A=Sn(S,{presentation:r,theme:p.theme,pages:p.pages},In),A.latch()}c(),S.setAttribute("aria-label",(ce?.screen===n.screen?.content.document.name?ce?.label:void 0)??u?.document?.name??n.screen?.content.document.name??"Funnel")}async function Xn(n){if(h||ue||he&&(Qe()||["running","waiting"].includes(n.status))||(L=n,De&&e.client.pendingCommand?.requestId!==De&&(E.hidden=!0,De=null),G=n.locale.startsWith("zh"),J.textContent=G?"\u56DE\u770B":"History",z.textContent=F.active?G?"\u8FD4\u56DE\u5F53\u524D":"Return to current":G?"\u8FD4\u56DE":"Back",a(),O.textContent=G?"\u91CD\u8BD5":"Retry",O.hidden=e.client.pendingCommand===null,Q.textContent=n.pendingRequest?G?"\u6B63\u5728\u5904\u7406":"Processing":n.instruction?.type==="wait"?G?"\u7B49\u5F85\u4E2D":"Waiting":"",ve(),fn!==`${n.revision}:${n.visit}:${n.status}:${n.stopped}`&&(fn=`${n.revision}:${n.visit}:${n.status}:${n.stopped}`,Ce(e.onState,structuredClone(n))),h||ue))return;if((!n.pendingRequest||he&&n.status==="closed")&&["closed","ineligible","failed"].includes(n.status)){ie();return}if(n.stopped&&_()){ie();return}if(n.stopped||e.client.configurationReady===!1){F.stop(),s(),Ie(),j?.finish("skipped"),o.hidden=!0,He();return}if(o.hidden=!1,F.active){He();return}let r=Ne(n),p=e.client.view;if(p&&p.revision>n.revision&&Ne(p)!==r)return;let H=!n.instruction&&!n.pendingRequest&&n.nodeType==="screen"&&["running","waiting"].includes(n.status);r!==B&&(B&&j?.finish("dismissed"),Ie(),B=r,we={...n.answers},ze.reset());let ae=Be(n);if(xe===ae){o.hidden=!0;return}if(H&&!r){o.hidden=!0;let U=e.prepared?.state==="shown"?null:je(!0,n.locale);!h&&!ue&&Ge?.key!==ae&&(sn(),Ge={key:ae,timeout:setTimeout(()=>{let g=e.client.view;if(h||!U?.active&&e.prepared?.state!=="shown"||!g||Be(g)!==ae)return;xe=ae;let W=new Error("Funnel screen preparation timed out");U?.finish("error",W),s(),Ie(),pe(W)},Se)}),He();return}sn();let Z=U=>{let g=e.client.view;return!h&&!ue&&!qe&&!U.aborted&&e.client.configurationReady!==!1&&!!g&&!g.stopped&&!["closed","ineligible","failed"].includes(g.status)&&Ne(g)===r},ge=(U,g)=>{Z(g)&&(xe=r,j?.finish("error",U),Ie(),o.hidden=!0,pe(U))};if(r||((n.instruction&&n.instruction.type!=="evaluate_segment"||!["running","waiting"].includes(n.status))&&s(),We(n),n.instruction?.type!=="event"&&n.instruction?.type!=="open_url"&&j?.finish("skipped")),n.screen){s();let U=n.screen.content;if(!u){let x=n.screen.presentation.type!=="inline",re=je(x,n.locale);if(h||ue)return;let ee=(Te=new AbortController).signal;We(n),_e=x?Vn(S):Ke(o,t),u=P(R,{mode:"live",closeActions:Array.from(new Set([...e.closeActions??[],...U.document.actions.filter(f=>f.type==="event"&&f.close).map(f=>f.id)])),onAuthoredClose(f){Z(ee)&&(Pe=f,ve())},rendererUrl:e.client.webViewUrl,title:U.document.name,...x?{hostPresentation:()=>A?.type??n.screen.presentation.type}:{},onResize:f=>{l=f,A?.responsive&&A.setContentHeight(f+k.getBoundingClientRect().height)},onAction(f,fe={},tt={}){if(F.active||!Z(ee)||M!==r)return;we={...we,...tt};let ln=n.screen?.inputs??[],Cn=Object.fromEntries(ln.filter(({variable:Oe})=>Object.hasOwn(we,Oe)).map(({variable:Oe})=>[Oe,we[Oe]]));if(Qn(ln,Cn).length){gn();return}Fe(()=>e.client.submit({operation:"submit",...ke(),input:{type:"screen",output:f,answers:Cn,selection:fe}}),!1,Oe=>xn(Oe,ln))},onAnswers:f=>{F.active||!Z(ee)||M!==r||(we={...we,...f})},onCustomerDataIntent:f=>{F.active||!Z(ee)||M!==r||ze.intent(f).catch(pe)},onEscape:()=>{!Z(ee)||M!==r||F.active||de||X||be()},onError:f=>{let fe=new Error(f);M===r?pe(fe):ge(fe,ee)},onRendered:f=>{if(!(!Z(ee)||M===r))try{re.present(fe=>{_e?.(),_e=void 0,f&&(ce={screen:U.document.name,label:f},S.setAttribute("aria-label",f)),x&&(S.showModal(),A?.responsive&&S.focus({preventScroll:!0}),!fe&&e.loading!=="host"&&_n(S,A?.type??n.screen.presentation.type,A?.responsive)),M=r,Ee=x,ve()}),Z(ee)&&Le.report(r)}catch(fe){ge(fe,ee)}}}),In()}let g={capabilities:n.screen.capabilities,customerData:n.screen.customerData,parameters:n.parameters,serverInput:{bindings:n.screen.inputs,answers:we,values:n.screen.values}},W=JSON.stringify([U,n.locale,g.parameters,n.screen.inputs,n.screen.values]);if(W!==Re)u.update(U.document,n.locale,g),Re=W,en=JSON.stringify(g.capabilities),Ue=JSON.stringify(g.customerData);else{let x=JSON.stringify(g.capabilities);x!==en&&(u.updateCapabilities(g.capabilities),en=x),JSON.stringify(g.customerData)!==Ue&&(u.updateCustomerData(g.customerData),Ue=JSON.stringify(g.customerData))}let oe=u;if(oe)try{await(j?.wait(oe.ready)??oe.ready)}catch(x){Te&&ge(x,Te.signal)}}else if(n.paywall&&!q){let U=n.paywall.resolution,g="document"in U?U.document:null,W=w,oe=null,x=(Te=new AbortController).signal,re={loading:"host",signal:x,canInteract:()=>Z(x)&&!F.active&&!de&&!X,beforeAction:async()=>{le++;try{await hn(Le.settled()),E.hidden=!0,De=null,Ae=!1,c()}finally{le=Math.max(0,le-1)}},start:()=>cn(e.client),onObservationChange:He,onPurchase:e.onPurchase,onCheckoutUrl:e.onCheckoutUrl,resumeCheckout:e.resumeCheckout,allowNewPurchase:e.allowNewPurchase,checkoutNavigation:e.checkoutNavigation,terminateCheckout:e.terminateCheckout,confirmOnHostedCheckout:e.confirmOnHostedCheckout,resolveOfferId:e.resolveOfferId,claimCoupon:e.claimCoupon,onEvent:e.onEvent,onOpenUrl:f=>e.onOpenUrl?e.onOpenUrl({receiptId:n.paywall.receiptId,url:f,openIn:"same_window"}):m.defaultView?.location.assign(f),onAction:async f=>{if(F.active)return;let fe=await e.client.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:n.nodeId,visit:n.visit,revision:e.client.view?.revision??n.revision,input:{type:"screen",output:f,answers:{}}});await ye(e.client.view??fe.run)},onError:f=>{M===r?pe(f):ge(f,x)}},ee={quoteError:f=>Ce(e.onError,f),present(f){Z(x)&&(oe?.present(()=>{f(),M=r,Ee=!!R.querySelector("dialog[open]"),ve()}),Z(x)&&Le.report(r))},async dismiss(){if(!(h||x.aborted||F.active||de||X||!he&&!Z(x))){if(he=!0,(e.resumeCheckout||e.terminateCheckout)&&nt()){L=e.client.view,ie();return}await be()}}};if(W){let f=await W.adopt(n,{options:re,handoff:ee,start:()=>cn(e.client)});f&&Z(x)&&!h?(We(n),q=f,j?.active&&j.present(()=>{}),M=r,Ee=W.modal,ve(),Le.report(r),F.active&&q.setSuspended(!0)):(f?.destroy(),s())}if(h||ue)return;if(!q){if(oe=je(!0,n.locale,g),h||ue)return;We(n);let f=await $(R,re,ee).catch(fe=>(ge(fe,x),null));!Z(x)&&!(he&&!h&&!x.aborted)?f?.host?.destroy():f&&(q=f.host,q?.setSuspended(F.active))}}if(h||ue)return;ve();let D=n.instruction;if(D&&(D.type==="open_url"||D.type==="event")&&!Je.has(D.receiptId)){let U=m.createElement("button");U.type="button",U.style.cssText=te.primary,Me(U,()=>te.focus),R.style.cssText=te.stage,U.textContent=D.type==="open_url"?`${G?"\u524D\u5F80":"Continue to"} ${new URL(D.url).host}`:G?"\u7EE7\u7EED":"Continue",U.onclick=()=>{let g=ke(),W=D.type==="open_url"&&!e.onOpenUrl&&D.openIn==="new_window"?Zn(D.url):null;Fe(async()=>{let oe="success";if(D.type==="open_url")if(e.onOpenUrl)try{oe=await e.onOpenUrl({receiptId:D.receiptId,url:D.url,openIn:D.openIn})===!1?"failed":"opened"}catch(re){Ce(e.onError,re),oe="failed"}else oe=D.openIn==="new_window"&&!W?"failed":"opened";if(D.type==="event"){if(!e.onEvent)throw new y("EVENT_HANDLER_REQUIRED","Provide the event handler");await e.onEvent(D.event)}if(h||e.client.view?.nodeId!==g.nodeId||e.client.view.visit!==g.visit)throw new y("PRECONDITION_FAILED","The client action visit changed");let x=await e.client.submit({operation:"submit",...g,input:{type:"client_action",receiptId:D.receiptId,outcome:oe}});return Je.add(D.receiptId),D.type==="open_url"&&!e.onOpenUrl&&D.openIn==="same_window"&&m.defaultView?.location.assign(D.url),x})},j?.active?j.present(()=>R.replaceChildren(U)):R.replaceChildren(U)}!n.pendingRequest&&n.status==="completed"&&!Je.has(`complete:${n.id}`)&&(Je.add(`complete:${n.id}`),Ce(e.onComplete,structuredClone(n))),He()}function Zn(n){let r=m.defaultView?.open(n,"_blank")??null;return r&&(r.opener=null),r}function ye(n){return ve(),tn=tn.catch(()=>{}).then(async()=>{try{await Xn(n)}catch(r){throw j?.active&&(xe=Be(n),j.finish("error",r),Ie(),o.hidden=!0),r}}),tn}let Kn=e.client.subscribe(n=>{if(!mn){if(n.stopped&&(Ee||_())&&!he){L=n,ie();return}!he&&(n.stopped||e.client.configurationReady===!1||B&&M!==B&&(Ne(n)!==B||["closed","ineligible","failed"].includes(n.status)))&&(Ie(),j?.finish("dismissed"),o.hidden=!0),ye(n).catch(pe)}}),et=e.client.subscribeError?.(pe);function nt(){let n=e.client.view,r=n?.paywall;return!!r?.operation&&!!n&&["running","waiting"].includes(n.status)&&Dn(Ve({quote:r.quote,operation:r.operation,requestId:r.purchaseRequestId,pending:!1,destroyed:!1,canReselect:r.canReselect}))}function be(n){if(qe)return qe;if(h||!n&&(de||X))return Promise.resolve();let r=!n&&Qe();return!r&&e.client.view&&!["running","waiting"].includes(e.client.view.status)?(L=e.client.view,ie(),Promise.resolve()):(qe=Fe(async()=>{let p=r?await e.client.retry():await e.client.submit({operation:"close",...n??ke()});return n&&yn(p),p},!0).then(()=>{let p=e.client.view;p?.status==="closed"&&!Qe()&&(L=p,ie())}).finally(()=>{qe=null}),qe)}function ie(){ne?.destroy(),!h&&(h=!0,N(),s(),e.signal?.removeEventListener("abort",ie),d?.removeEventListener("abort",ie),j?.finish("dismissed"),wn.destroy(),Kn(),et?.(),Ie(),an(),F.stop(),S.remove(),o.remove(),V(),Ce(e.onDismiss,L?structuredClone(L):null))}z.onclick=()=>{if(!z.disabled){if(F.active){F.exit();return}Fe(()=>e.client.submit({operation:"back",...ke()}))}},J.onclick=()=>{F.open()},T.onclick=()=>{j?.active?j.dismiss():de||be()},O.onclick=()=>{Qe()?be():Fe(()=>e.client.retry())},S.addEventListener("cancel",n=>{n.preventDefault(),j?.active?j.dismiss():de||be()}),e.signal?.addEventListener("abort",ie,{once:!0}),d?.addEventListener("abort",ie,{once:!0});let Ye=!1;w&&(N=w.onClose(()=>{h||ue||(ue=!0,j?.finish("dismissed"),Ie(),o.hidden=!0,e.client.view?be().finally(ie):Ye=!0)}));let bn={destroy:ie,refresh:on,get recovery(){let n=rn();if(n)return n;if(!h&&!le&&!he&&!de&&q){let r=q.recovery;if(r.type!=="native")return r}return{type:"recover",operationId:e.client.pendingPurchase?.operationId??e.client.view?.paywall?.quote?.operationId??X?.operationId??null,requestId:e.client.pendingCommand?.requestId??null}},prepareFallback(){if(de)return de;let n=rn();if(n)return Promise.resolve(n);let r=e.client.pendingPurchase?.operationId??e.client.view?.paywall?.quote?.operationId??X?.operationId??null,p=()=>({type:"recover",operationId:r,requestId:e.client.pendingCommand?.requestId??null});if(e.client.hasDurableJournal!==!0){let D=q?.recovery;return Promise.resolve(D&&D.type!=="native"&&D.type!=="cancel"?D:p())}let H=(e.client.pendingCommands??(e.client.pendingCommand?[e.client.pendingCommand]:[])).some(D=>D.operation==="close");if(h&&!(H||X&&e.client.view?.status==="closed")||le||$e||qe||F.active||!q&&!X&&!H)return Promise.resolve(p());let ae=q,Z=(async()=>{try{if(!X&&H){let g=await e.client.retry();return await ye(e.client.view??g.run),p()}if(!X){let g=await ae.prepareFallback();if(g.type!=="native")return g;if(e.client.hasDurableJournal!==!0)return p();X=g}let D=e.client.pendingCommands??(e.client.pendingCommand?[e.client.pendingCommand]:[]);if(D.length){let g=D.find(oe=>oe.operation==="close");if(!g||!K||g.requestId!==K.requestId)return p();let W=await e.client.retry();yn(W),await ye(e.client.view??W.run)}else{let g=e.client.view,W=g?.paywall;if(!g||!W||W.selectionGeneration===void 0||(W.quote?.operationId??null)!==X.operationId||X.operationId!==null&&W.canReselect!==!0)return p();let oe=W.selectionGeneration,x=await e.client.get();await ye(e.client.view??x.run);let re=e.client.view,ee=re?.paywall;if(!re||!ee||!["running","waiting"].includes(re.status)||re.stopped||re.id!==g.id||re.nodeId!==g.nodeId||re.visit!==g.visit||ee.receiptId!==W.receiptId||ee.selectionGeneration!==oe||(ee.quote?.operationId??null)!==X.operationId||X.operationId!==null&&ee.canReselect!==!0||e.client.pendingPurchase||(e.client.pendingCommands?.length??(e.client.pendingCommand?1:0)))return p();let f=ke();K={runId:re.id,operationId:X.operationId,revision:f.revision,requestId:f.requestId,nodeId:re.nodeId,visit:re.visit,receiptId:ee.receiptId,selectionGeneration:oe,acknowledged:!1},await be(f)}let U=rn();return U?(ie(),U):p()}catch(D){return pe(D),p()}})();de=Z;let ge=()=>{de===Z&&(de=null)};return Z.then(ge,ge),Z},review:F.open,exitReview:F.exit,get unappliedDrafts(){return F.drafts}};try{let n=e.client.view;if(n)((e.client.viewAgeMs??pn)>=pn||n.instruction?.type==="evaluate_segment")&&(nn=on().finally(()=>{nn=null})),await ye(n);else{if(o.hidden=!0,h)throw new DOMException("Presentation cancelled","AbortError");let r=Ye||e.prepared?.state==="shown"?null:je(e.client.view?.screen?.presentation.type!=="inline",e.client.view?.locale);if(h||ue&&!Ye)throw new DOMException("Presentation cancelled","AbortError");let p=e.client.get(),H=await(r?r.wait(p,Se):ot(p,Se));if(mn=!1,Ye)return h||await be().finally(ie),bn;await ye(e.client.view??H.run)}}catch(n){throw j?.finish("error",n),ie(),n}return bn}function ot(t,v){let C;return Promise.race([t,new Promise((e,w)=>{C=setTimeout(()=>w(new Error("Presentation data timed out")),v)})]).finally(()=>clearTimeout(C))}function Gt(t,v,C){return rt(t,v,C)}export{rt as a,Gt as b};
1
+ import{a as Mn,b as Un,c as un,d as dn,e as Me,f as $n,h as xn,i as Gn,j as Qn,k as Jn}from"./chunk-CZ4TQCUV.js";import{b as zn}from"./chunk-ESAHTG3Y.js";import{b as qn,c as Bn}from"./chunk-VC2HPREX.js";import{a as On}from"./chunk-W32FI2A2.js";import{c as Sn,e as _n,f as Ln,h as Hn,i as Se,j as Ze,k as Vn,l as Ke}from"./chunk-P6C3PNMQ.js";import{aa as Xe}from"./chunk-IOJVF52Q.js";import{a as Ve,d as Dn}from"./chunk-3NCMYTNG.js";import{b as Rn}from"./chunk-33ZVZOSC.js";import{b as kn,d as Tn,e as An,f as Nn,g as Fn}from"./chunk-VOKEZHAH.js";import{F as Pn,ea as En}from"./chunk-XDOKFAE6.js";import{a as y}from"./chunk-WLGLQJ6M.js";import{a as Ce}from"./chunk-DSPLGTQI.js";async function cn(t){let{session:v,load:C}=it(t);try{return await C(),v}catch(e){throw v.destroy(),e}}function it(t){let v=t.view;if(!v?.paywall)throw new y("INVALID_REQUEST","The current node is not a Paywall");let C=v.paywall.receiptId,e=v.nodeId,w=v.visit,N=v.paywall.resolution,s=v.paywall,_="document"in N?{document:N.document,offering:N.offering,capabilities:N.capabilities}:null;function d(){let i=s.resolution;return"document"in i?i:_&&{...i,document:_.document,offering:_.offering,capabilities:kn(i.capabilities,_.capabilities)}}function I(i){if(!Tn(i,N))throw new y("INVALID_RESPONSE","The pinned Paywall binding changed")}let P=!1,$=new Set,ne=null;function m(){let i=d();if(i&&!P)for(let l of $)Ce(l,structuredClone(i))}async function V(){O();let i=d();if(i)return structuredClone(i);if(!ne){let l=(async()=>{if("document"in s.resolution||!t.resolvePaywall)throw new y("INVALID_RESPONSE","Public Paywall reader is unavailable");let b=await qn(t,s.resolution);return O(),I(b),_={document:b.document,offering:b.offering,capabilities:b.capabilities},m(),d()})();ne=l;let a=()=>{ne===l&&(ne=null)};l.then(a,a)}return ne.then(l=>structuredClone(l))}let o=new AbortController,k=(t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[])).find(i=>i.operation==="submit"&&i.nodeId===e&&i.visit===w&&i.input.type==="paywall_quote")?.requestId??v.paywall.purchaseRequestId,Y=0,J=null,Q=new Set,E=null,z=new Map;function T(i){if(i.purchase&&i.purchase.receiptId!==C)throw new y("INVALID_RESPONSE","Purchase receipt changed");let l=i.run.paywall;return i.purchase??(l?.receiptId===C?l:null)}function O(){if(P)throw new y("IDENTITY_CHANGED","Paywall presentation has closed")}function S(i,l,a){if(O(),l!==Y||a!==void 0&&s.quote?.operationId!==a)return!1;let b=s.selectionGeneration??0,c=i.run.paywall;if(c?.receiptId===C){if((c.selectionGeneration??0)<(s.selectionGeneration??0))return!1;I(c.resolution)}let u=T(i),q=c?.receiptId===C&&(c.selectionGeneration??0)>b,L=q?u?.quote??null:u?.quote??s.quote,B=u?.operation??(L?.operationId===s.quote?.operationId?s.operation:null);return L&&B&&An(B,{operationId:L.operationId},"Purchase operation changed"),(q||L?.operationId!==s.quote?.operationId)&&(Y++,c?.receiptId===C&&(k=c.purchaseRequestId)),c?.canReselect===!0&&c.purchaseRequestId===E&&!(t.pendingCommands??[t.pendingCommand]).some(M=>M?.requestId===E)&&(E=null),s={...s,...c?.receiptId===C?c:{},...a!==void 0&&!q&&u?.canReselect!==void 0?{canReselect:u.canReselect}:{},quote:L,operation:Fn(s.operation,B,!0)},m(),!0}function ce(i,l,a){return new Promise((b,c)=>{let u=!1,q=()=>{clearTimeout(Ee),o.signal.removeEventListener("abort",M)},L=Re=>{u||(u=!0,q(),b(Re))},B=Re=>{u||(u=!0,q(),c(Re))},M=()=>B(new y("IDENTITY_CHANGED","Paywall presentation has closed")),Ee=setTimeout(()=>B(new y("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,a)),Math.max(0,l-Date.now()));o.signal.addEventListener("abort",M,{once:!0}),o.signal.aborted&&M(),i.then(L,B)})}function Pe(i){return new Promise(l=>{let a=()=>{clearTimeout(b),o.signal.removeEventListener("abort",a),l()},b=setTimeout(a,i);o.signal.addEventListener("abort",a,{once:!0}),o.signal.aborted&&a()})}function se(i,l){O();let a=z.get(i)??t.pendingCommands?.find(u=>u.requestId===i)??t.pendingCommand;if(a?.operation==="submit"&&a.requestId===i&&a.nodeId===e&&a.visit===w){l.type==="paywall_quote"&&a.input.type==="paywall_quote"&&a.input.predecessor&&!l.predecessor&&(l={...l,predecessor:a.input.predecessor});let u=Xe.parse(a),q=Xe.parse({...a,input:l});if(u.operation!=="submit"||q.operation!=="submit"||JSON.stringify(u.input)!==JSON.stringify(q.input))throw new y("CONFLICT","A purchase request cannot change its input");return z.set(i,u),u}let b=t.view;if(!b||b.nodeId!==e||b.visit!==w||b.paywall?.receiptId!==C)throw new y("PRECONDITION_FAILED","The Paywall visit has changed");let c=Xe.parse({operation:"submit",requestId:i,nodeId:e,visit:w,revision:b.revision,input:structuredClone(l)});if(c.operation!=="submit")throw new y("INVALID_REQUEST","A purchase submission is required");return z.set(i,c),c}async function te(i,l){O();let{requestId:a,input:b}=i,c=Date.now()+3e4;Q.add(a);try{let u=await ce(t.submit(i),c,a);for(;u.run.pendingRequest?.requestId===a&&Date.now()<c&&!P&&(await Pe(Math.min(1e3,c-Date.now())),!(P||Date.now()>=c));)u=await ce(t.resume(a),c,a);if(P)throw new y("IDENTITY_CHANGED","Paywall presentation has closed");if(u.run.pendingRequest?.requestId===a)throw new y("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,a);if(!S(u,l,b.type==="paywall_confirm"||b.type==="paywall_cancel"?b.operationId:void 0))throw new y("PRECONDITION_FAILED","The purchase selection has changed");E===a&&(E=null)}catch(u){if(E=a,b.type==="paywall_quote"&&t.settle&&!P&&u instanceof y&&u.status!==void 0&&![401,425].includes(u.status)&&!u.retryable&&u.recovery!=="recover_operation")try{if((await ce(t.settle(a),c,a)).settlement?.state==="settled"){let L=await ce(t.get(),c,a);S(L,l)&&L.run.paywall?.purchaseRequestId===a&&s.canReselect===!0&&z.delete(a)}}catch{}throw u instanceof y&&u.code==="COMMAND_PENDING"&&u.status===void 0&&z.delete(a),u}finally{Q.delete(a)}}async function me(i){if(!s.quote)throw new y("INVALID_REQUEST","A quoted purchase is required");let l=i==="confirm"?"paywall_confirm":"paywall_cancel",a=[...z.values(),...t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[])].find(c=>c.operation==="submit"&&c.input.type===l&&"operationId"in c.input&&c.input.operationId===s.quote.operationId),b=a?.operation==="submit"&&a.input.type===l&&"operationId"in a.input&&a.input.operationId===s.quote.operationId?a.requestId:crypto.randomUUID();if(await te(se(b,{type:i==="confirm"?"paywall_confirm":"paywall_cancel",operationId:s.quote.operationId}),Y),!s.operation)throw new y("INVALID_RESPONSE","The accepted purchase result is missing");return structuredClone(s.operation)}let G={get view(){return structuredClone(d())},get quote(){return s.quote?structuredClone(s.quote):null},get operation(){return s.operation?structuredClone(s.operation):null},get webViewUrl(){return t.webViewUrl},get locale(){return t.view?.locale??v.locale},get canReselect(){return s.canReselect===!0&&E===null},get recovery(){let i=t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[]),l=t.pendingPurchase;if(l&&(l.receiptId!==C||l.operationId!==s.quote?.operationId))return{type:"recover",operationId:l.operationId,requestId:i[0]?.requestId??null};let a=Ve({quote:s.quote,operation:s.operation,requestId:i[0]?.requestId??E??k,pending:Q.size>0||i.length>0||E!==null,destroyed:P,canReselect:s.canReselect});return a.type==="recover"&&a.requestId===null&&!P&&t.hasDurableJournal===!0&&!s.quote&&!s.operation&&(s.selectionGeneration??0)===0&&!l&&!i.length&&!Q.size&&!k?{type:"native",operationId:null}:a},get pendingCancellation(){return!P&&(t.pendingCommands??(t.pendingCommand?[t.pendingCommand]:[])).some(i=>i.operation==="submit"&&i.nodeId===e&&i.visit===w&&i.input.type==="paywall_cancel"&&i.input.operationId===s.quote?.operationId)},subscribe(i){return P?()=>{}:($.add(i),()=>$.delete(i))},async refresh(){O();let i=Y,l=await t.get();if(S(l,i),l.run.paywall?.receiptId!==C)throw new y("PRECONDITION_FAILED","Paywall presentation has changed");return V()},preview(i){let l=d();if(!l)return Promise.reject(new y("PRECONDITION_FAILED","Load the Paywall presentation first"));if(k&&k!==i.requestId&&(J||s.canReselect!==!0))return Promise.reject(new y("COMMAND_PENDING","Retry the original purchase before starting another"));let a=l.document.buttons[i.actionId],b=a?.type==="checkout"?Rn(a.product,i.selection,l.capabilities):null;if(!b)return Promise.reject(new y("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));let c=En(l.document.screen,b,i.selection,l.capabilities),u=k!==i.requestId&&(s.selectionGeneration??0)>0?{operationId:s.quote?.operationId??null,generation:s.selectionGeneration??0}:void 0;if(u&&s.canReselect!==!0)return Promise.reject(new y("COMMAND_PENDING","Original purchase requires authoritative termination"));let q;try{q=se(i.requestId,{type:"paywall_quote",actionId:i.actionId,productVersionId:b,...Object.keys(c).length?{featureQuantities:c}:{},...u?{predecessor:u}:{},...i.offerId?{offerId:i.offerId}:{},...i.nativeOffer?{nativeOffer:i.nativeOffer}:{}})}catch(M){return Promise.reject(M)}if(k===i.requestId&&J)return J;k!==i.requestId&&Y++;let L=Y;k=i.requestId;let B=(async()=>{if(await te(q,L),!s.quote)throw new y("INVALID_RESPONSE","The accepted quote is missing");return Nn(s.quote,{productVersionId:b,featureQuantities:c},"The selected purchase changed"),structuredClone(s.quote)})();return J=B,B.then(()=>{J===B&&(J=null)},M=>{J===B&&(J=null),k===i.requestId&&t.pendingCommand?.requestId!==i.requestId&&M instanceof y&&M.status!==void 0&&M.status<500&&![401,425].includes(M.status)&&(k=null)}),B},confirm:()=>me("confirm"),cancel:()=>me("cancel"),async read(){if(O(),!s.quote)throw new y("INVALID_REQUEST","A quoted purchase is required");let i=s.quote.operationId,l=Y,a=t.pendingCommands?.find(L=>L.operation==="submit"&&(L.input.type==="paywall_confirm"||L.input.type==="paywall_cancel")&&L.input.operationId===i)??t.pendingCommand;a?.operation==="submit"&&(a.input.type==="paywall_confirm"||a.input.type==="paywall_cancel")&&a.input.operationId===i&&await t.settle?.(a.requestId);let b=await t.get(void 0,{receiptId:C,operationId:i});O();let c=T(b);if(c?.quote&&c.quote.operationId!==i||c?.operation&&c.operation.operationId!==i)throw new y("INVALID_RESPONSE","Purchase operation changed");let u=S(b,l,i),q=u?s.operation:c?.operation;if(!q)throw new y("INVALID_RESPONSE","The current purchase result is missing");return u&&Q.size===0&&!(t.pendingCommands?.length??(t.pendingCommand?1:0))&&(E=null),structuredClone(q)},destroy(){P=!0,A(),$.clear(),o.abort(),z.clear()}},A=t.subscribe(i=>{P||i.nodeId!==e||i.visit!==w||i.paywall?.receiptId!==C||(i.paywall.selectionGeneration??0)<(s.selectionGeneration??0)||(I(i.paywall.resolution),s={...s,resolution:i.paywall.resolution},m())});return{session:G,load:V}}function jn(t){let v=new Set,C=new Set,e=null;async function w(d,I){let P=!1;for(;!t.stopped&&t.key===d&&t.client.pendingCommand?.requestId===I;){if(!t.client.settle)throw new y("COMMAND_PENDING","The original display acknowledgement is still pending");await t.client.settle(I),P=!0,t.client.pendingCommand?.requestId===I&&await new Promise($=>setTimeout($,1500))}t.stopped||t.key!==d||(P&&await t.client.get(),!(t.stopped||t.key!==d)&&v.add(d))}function N(d,I){e=I;let P=()=>{e===I&&(e=null),C.delete(d)};return I.then(P,$=>{P(),t.busy||t.fail($)}),I}function s(d){if(t.reviewing||v.has(d)||C.has(d)||t.stopped)return;C.add(d);let I=async()=>{if(t.reviewing||t.stopped||t.key!==d||v.has(d)){C.delete(d);return}if(t.busy||t.client.pendingCommand){setTimeout(()=>{I()},250);return}let P=(async()=>{if(t.staleRead){if(await t.staleRead,t.stopped||t.key!==d)return;if(t.client.pendingCommand){setTimeout(()=>{I()},250);return}}let $=t.client.view,ne=t.expected(),m=ne.requestId;try{await t.client.submit({operation:"shown",...ne})}catch(V){if(!(V instanceof y)||V.code!=="CONFLICT"||V.status!==409||t.client.pendingCommand)throw V;await t.client.get();let o=t.client.view;if(t.stopped||t.reviewing||t.key!==d||!o||!$||o.id!==$.id||o.source.versionId!==$.source.versionId||o.nodeId!==ne.nodeId||o.visit!==ne.visit||o.revision<=ne.revision||o.stopped||!o.screen&&(!o.paywall||o.paywall.receiptId!==$.paywall?.receiptId)||!["running","waiting"].includes(o.status)||t.client.pendingCommand)throw V;let R=t.expected();m=R.requestId,await t.client.submit({operation:"shown",...R})}await w(d,m)})();N(d,P)};I()}function _(){if(e)return e;let d=t.client.pendingCommand;if(d?.operation!=="shown")return null;let I=t.key;return C.add(I),N(I,(async()=>{await t.client.retry(),await w(I,d.requestId)})())}return{report:s,settled:_,get inFlight(){return e}}}function Wn(t){let v={},C=new Map;async function e(w){let N=t.client.view,s=N?.screen,_=s?.customerData.nodes[w.nodeId];if(t.stopped||t.busy||!N||!s||!_)return;if(!["refresh","next","previous","filter","sources_next","sources_previous"].includes(w.action)){let V=t.document,o=V?Pn(V,w.nodeId):null,R=o?.type==="customer_data"?o.data.outputs?.[w.action]:void 0;R&&s.outputs.includes(R)?await t.perform(()=>t.client.submit({operation:"submit",...t.expected(),input:{type:"screen",output:R,answers:t.answers,selection:w.value?{[w.nodeId]:w.value}:{}}})):await t.onIntent?.(w,N);return}let I=w.action.startsWith("sources_")?_.resources.find(V=>V.key===w.value):null;if(w.action.startsWith("sources_")&&!I)throw new y("INVALID_REQUEST","Choose a current resource");let P=`${N.visit}:${w.nodeId}:${I?.key??""}`,$=C.get(P)??[null],m=v[w.nodeId]??{page:1,after:null,filter:"all",...I?{resourceKey:I.key}:{}};if(w.action==="filter"){let V=w.value;if(!V||!(_.source==="offer_history"?["all","issued","reserved","redeemed","expired","revoked"]:["all","purchase","refund","source","usage","debt","settlement"]).includes(V))throw new y("INVALID_REQUEST","Unknown data filter");m={page:1,after:null,filter:V},$.splice(0,$.length,null)}else if(w.action==="next"||w.action==="sources_next"){let V=I?.sources.at(-1),o=I?V?{kind:"ledger",cursor:{at:V.detail[0],id:V.id,type:"source"}}:null:s.dataCursors[w.nodeId];if(!o||!I&&!_.hasNext)return;$[m.page]=o,m={...m,page:m.page+1,after:o}}else if(w.action==="previous"||w.action==="sources_previous"){if(m.page<=1)return;m={...m,page:m.page-1,after:$[m.page-2]??null}}C.set(P,$),v={...v,[w.nodeId]:m},await t.perform(()=>t.client.get({nodeId:N.nodeId,visit:N.visit,revision:N.revision,components:v}))}return{get queries(){return v},intent:e,reset(){v={},C.clear()}}}function Yn(t){let{doc:v,holder:C,reviewHolder:e,mountScreenPreview:w}=t,N=!1,s,_=0,d=null,I="",P,$=new Map,ne=o=>o?`${o.id}:${o.nodeId}:${o.visit}:${o.revision}:${o.paywall?.quote?.operationId??""}`:"";async function m(o){if(t.stopped||!t.client.review||N&&o===s&&P?.active)return;let R=!N||o!==s;N||(I=ne(t.client.view),$.set(I,structuredClone(t.answers))),N=!0,s=o,C.hidden=!0,t.suspend(!0),e.hidden=!1;let k=++_;R&&(P?.finish("dismissed"),d?.destroy(),d=null,e.replaceChildren(),P=Ze(e,t.loadingOptions,"funnel",()=>{V()}));let Y=R?P:void 0;try{if(Y?.start(!1,t.client.view?.locale),k!==_||t.stopped)return;let J=t.client.review(o),Q=await(Y?.wait(J,Se)??J);if(t.stopped||k!==_||!N)return;if(!Q.review)throw new y("INVALID_RESPONSE","Historical projection is missing");d?.destroy(),d=null,Y||e.replaceChildren();let E=v.createElement("div"),z=Y?Ke(E,e):()=>{};e.append(E);let T=Q.run.locale.startsWith("zh"),O=t.chrome;E.style.cssText=O.history;let S=v.createElement("p");S.textContent=T?"\u53EA\u8BFB\u56DE\u770B":"Read-only history",S.style.cssText=O.historyTitle,E.append(S);let ce=v.createElement("p");ce.style.cssText=O.historyNote,ce.textContent=Q.review.pages.length?T?"\u9009\u62E9\u4E00\u9875\u67E5\u770B\u5F53\u65F6\u7684\u5185\u5BB9\uFF0C\u56DE\u770B\u4E0D\u4F1A\u6539\u52A8\u4EFB\u4F55\u4FE1\u606F\u3002":"Choose a page to see it as it was. Nothing here can be changed.":T?"\u8FD8\u6CA1\u6709\u53EF\u56DE\u770B\u7684\u9875\u9762\u3002":"There are no earlier pages yet.",E.append(ce);let Pe=Q.review.page?.receiptId,se=v.createElement("div");se.style.cssText=O.historyPages;for(let[G,A]of Q.review.pages.entries()){let i=v.createElement("button");i.type="button",i.textContent=T?`\u7B2C ${G+1} \u9875`:`Page ${G+1}`;let l=Pe!==void 0&&A.receiptId===Pe;i.style.cssText=l?O.primary:O.secondary,l&&i.setAttribute("aria-current","page"),Me(i,()=>t.chrome.focus),i.onclick=()=>{m(A.receiptId)},se.append(i)}if(se.childElementCount&&E.append(se),Q.review.page){let G=Q.review.page,A=v.createElement("div");A.inert=!0,A.style.cssText=O.historyPage,E.append(A),d=w(A,{mode:"live",rendererUrl:t.client.webViewUrl,title:G.document.name,onAction:()=>{},onAnswers:()=>{},onCustomerDataIntent:()=>{},onRendered:()=>{k===_&&!t.stopped&&Y?.present(z)},onError:l=>{if(k!==_||t.stopped)return;let a=new Error(l);Y?.finish("error",a),d?.destroy(),d=null,E.remove(),t.fail(a)},onEscape:()=>{V()}});let i=d;if(i.update(G.document,Q.run.locale,{serverInput:{bindings:G.inputs,answers:G.answers,values:G.values}}),await i.ready,t.stopped||k!==_||!N)return}let te=T?{issued:"\u5DF2\u9886\u53D6",reserved:"\u5DF2\u9884\u7559",redeemed:"\u5DF2\u4F7F\u7528",expired:"\u5DF2\u8FC7\u671F",revoked:"\u5DF2\u64A4\u9500",unknown:"\u72B6\u6001\u5F85\u786E\u8BA4"}:{issued:"Issued",reserved:"Reserved",redeemed:"Used",expired:"Expired",revoked:"Revoked",unknown:"Status unconfirmed"},me=v.createElement("div");me.style.cssText=O.historyRecords;for(let G of[...Q.review.coupons.map((A,i)=>`${T?"\u4F18\u60E0\u5238":"Coupon"} ${i+1}: ${te[A.status]}`),...Q.review.purchases.map((A,i)=>`${T?"\u8D2D\u4E70":"Purchase"} ${i+1}: ${Jn(A.status,T)}`)]){let A=v.createElement("p");A.textContent=G,A.style.margin="0",me.append(A)}me.childElementCount&&E.append(me),Q.review.page||Y?.present(z),t.client.view&&await t.enqueue(t.client.view)}catch(J){if(k!==_||t.stopped)return;Y?.finish("error",J),d?.destroy(),d=null,e.replaceChildren(),t.fail(J)}}async function V(){if(!N||t.stopped||!t.client.review)return;let o=++_;P?.finish("dismissed");try{if(await t.client.review(),t.stopped||o!==_)return;N=!1,_++,P?.finish("dismissed"),d?.destroy(),d=null,e.replaceChildren(),e.hidden=!0,C.hidden=!1;let R=t.client.view;ne(R)!==I?($.set(I,structuredClone(t.answers)),t.resetScreen()):($.delete(I),t.suspend(!1)),R&&await t.enqueue(R)}catch(R){if(o!==_||t.stopped)return;d?.destroy(),d=null,e.replaceChildren(),t.fail(R)}}return{get active(){return N},get receipt(){return s},open:m,exit:V,get drafts(){return new Map([...$].map(([o,R])=>[o,structuredClone(R)]))},stop(){N=!1,_++,P?.finish("dismissed"),d?.destroy(),d=null,e.replaceChildren(),e.hidden=!0,C.hidden=!1}}}var pn=5e3;async function rt(t,v,C){let e=v,w=e.prepared&&zn(e.prepared),N=()=>{};function s(){e.prepared&&e.prepared.state!=="adopted"&&w?.release()}let _=()=>e.prepared?.state==="shown"&&!!w?.modal,d=e.client.identitySignal,I;try{I=await Promise.all([import("./screen-renderer-FFVZ64MR.js"),import("./paywall-UANWOKKC.js")]),e.signal?.throwIfAborted(),d?.throwIfAborted()}catch(n){throw s(),n}let[{mountScreenPreview:P},{showPaywall:$}]=I,ne=(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&e.appManifestRelease?Bn({client:e.client,appManifestRelease:e.appManifestRelease,onError:e.onError}):void 0;ne?.start();let m=t.ownerDocument,V=Hn(m),o=m.createElement("section"),R=m.createElement("div"),k=m.createElement("div"),Y=m.createElement("div"),J=m.createElement("button");Y.hidden=!0,J.type="button";let Q=m.createElement("p"),E=m.createElement("p"),z=m.createElement("button"),T=m.createElement("button"),O=m.createElement("button"),S=m.createElement("dialog"),ce,Pe=!1;o.dataset.indianaFunnel="",o.dataset.longplayCloseOwner="sdk",o.setAttribute("aria-busy","false"),Q.setAttribute("role","status"),E.setAttribute("role","alert"),E.hidden=!0,z.type=T.type=O.type="button",k.append(z,J,Q,E,O,T),o.append(R,Y,k),t.append(o);let se=Un,te=un(se),me="",G=(m.documentElement.lang||"").startsWith("zh"),A,i="",l;for(let n of[z,J,O,T])Me(n,()=>te.focus);function a(){let n=G?"\u5173\u95ED":"Close";T.parentElement===S?(T.textContent="\xD7",T.setAttribute("aria-label",n),Ln(T,se)):(T.textContent=n,T.removeAttribute("aria-label"),T.style.cssText=te.link+";margin-inline-start:auto")}function b(n){let r=n?.screen?.content.document.theme??se,p=JSON.stringify([r.primary,r.background,r.text,r.radius,r.font,T.parentElement===S]);if(p===me)return;me=p,se=r;let H=T.parentElement===S;te=un(se,H),o.style.cssText=te.root+";min-width:0"+(H?";display:flex;flex-direction:column;min-height:100%":""),k.style.cssText=te.bar+(H?";margin-top:auto":""),k.hidden&&(k.style.display="none"),z.style.cssText=J.style.cssText=te.secondary,O.style.cssText=te.primary,Q.style.cssText=te.status,E.style.cssText=te.alert,a(),dn(z)}function c(){k.hidden=z.hidden&&J.hidden&&O.hidden&&E.hidden&&!Q.textContent&&(T.hidden||T.parentElement!==k),k.style.display=k.hidden?"none":"flex",A?.responsive&&l!==void 0&&A.setContentHeight(l+k.getBoundingClientRect().height)}b();let u=null,q=null,L=null,B="",M="",Ee=!1,Re="",en="",Ue="",h=!1,le=0,$e=!1,fn="",nn=null,tn=Promise.resolve(),mn=!e.client.view,j=C,Te,_e,xe="",Ge,ue=!1,qe=null,he=!1,Qe=()=>e.client.pendingCommand?.operation==="close",de=null,X=null,wn=On({document:m,run:async()=>{(!q?.observing||e.client.pendingCommand)&&await on()},delay:()=>{if(!(h||!L||!["running","waiting"].includes(L.status)&&!e.client.pendingCommand)&&!(q?.observing&&!e.client.pendingCommand))return L.pendingRequest||e.client.pendingCommand?1500:pn},hiddenDelay:()=>!h&&e.client.pendingCommand?15e3:void 0}),K=null;function rn(){return X&&e.client.hasDurableJournal===!0&&K?.acknowledged===!0&&K.operationId===X.operationId&&e.client.view?.id===K.runId&&e.client.view?.status==="closed"&&e.client.view.revision===K.revision+1&&!(e.client.pendingCommands?.length??(e.client.pendingCommand?1:0))&&!e.client.pendingPurchase?X:null}function yn(n){let r=n.run.paywall;if(K&&n.settlement?.requestId===K.requestId&&n.settlement.state==="settled"&&n.settlement.operationId===null&&n.run.id===K.runId&&n.run.status==="closed"&&!n.run.pendingRequest&&n.run.revision===K.revision+1&&n.run.nodeId===K.nodeId&&n.run.visit===K.visit&&r?.receiptId===K.receiptId&&r.selectionGeneration===K.selectionGeneration&&(r.quote?.operationId??null)===K.operationId&&(r.operation?.operationId??r.quote?.operationId??null)===K.operationId){let p=K.operationId===null&&r.selectionGeneration===0&&!r.quote&&!r.operation&&!r.purchaseRequestId,H=Ve({quote:r.quote,operation:r.operation,requestId:r.purchaseRequestId,pending:!1,destroyed:!1,canReselect:r.canReselect});(p||r.canReselect===!0&&H.type==="native")&&(K.acknowledged=!0)}}let De=null,Je=new Set,we={},Ae=!1,pe=(n,r=null)=>{h||(De=r,Ae=!1,E.textContent=$n(n,G),E.hidden=!1,O.hidden=e.client.pendingCommand===null,c(),Ce(e.onError,n))},gn=()=>{h||(De=null,E.textContent=Gn(G),E.hidden=!1,O.hidden=!0,c())};function ke(){let n=e.client.view;if(!n)throw new y("INVALID_REQUEST","No current Run is available");return{requestId:crypto.randomUUID(),nodeId:n.nodeId,visit:n.visit,revision:n.revision}}let F=Yn({client:e.client,doc:m,holder:R,reviewHolder:Y,mountScreenPreview:P,loadingOptions:e,get chrome(){return te},get stopped(){return h},get answers(){return we},suspend(n){q?.setSuspended(n)},resetScreen(){B="",M="",Re=""},enqueue:ye,fail:pe}),Le=jn({client:e.client,expected:ke,fail:pe,get stopped(){return h},get reviewing(){return F.active},get key(){return B},get busy(){return le},get staleRead(){return nn}}),ze=Wn({client:e.client,expected:ke,perform:Fe,onIntent:e.onCustomerDataIntent,get stopped(){return h},get busy(){return le},get document(){return u?.document},get answers(){return we}}),Be=n=>`${n.id}:${n.nodeId}:${n.visit}`,Ne=n=>n&&(n.screen||n.paywall)?Be(n):"";function ve(){let n=e.client.view;z.disabled=!F.active&&(le>0||!!e.client.pendingCommand||!n?.canBack||n.stopped||!["running","waiting"].includes(n.status)||!Ne(n)||M!==Ne(n)),z.hidden=!F.active&&!n?.canBack,dn(z);let r=!!q&&!F.active;T.hidden=r&&!j?.active||Pe&&!F.active,J.hidden=!e.client.review||!F.active&&!n?.canBack,r&&(Q.textContent=""),c()}async function hn(n){if(!n)return;let r=e.client.view;await n;let p=e.client.view;if(!r||!p||p.id!==r.id||p.nodeId!==r.nodeId||p.visit!==r.visit||p.stopped||!["running","waiting"].includes(p.status))throw new y("PRECONDITION_FAILED","The screen changed while its display was acknowledged")}async function Fe(n,r=!1,p){if(!((le||he||de||X)&&!r||h||F.active&&!r)){le++,o.setAttribute("aria-busy","true"),E.hidden=!0,De=null,Ae=!1,ve();try{if(r||await hn(Le.inFlight),h)return;let H=await n();h||await ye(e.client.view??H.run)}catch(H){p?.(H)&&e.client.pendingCommand===null?gn():pe(H,e.client.pendingCommand?.requestId??null)}finally{le=Math.max(0,le-1),o.setAttribute("aria-busy",String(le>0)),h||(O.hidden=e.client.pendingCommand===null,ve())}}}function He(){wn.schedule()}async function on(){if(!(h||$e||le)){if(F.active){await F.open(F.receipt);return}$e=!0;try{let n=e.client.pendingCommand;n&&e.client.settle&&await e.client.settle(n.requestId);let r=e.client.view,p=ze.queries,H=await e.client.get(r?.screen&&Object.keys(p).length?{nodeId:r.nodeId,visit:r.visit,revision:r.revision,components:p}:void 0);Ae&&!h&&(Ae=!1,E.hidden=!0,c()),!h&&p===ze.queries&&await ye(e.client.view??H.run)}catch(n){pe(n),Ae=!h}finally{$e=!1}}}function je(n,r,p){if(j?.active){let ae=j;return ae.setDismissHandler(()=>vn(ae)),ae}let H=Ze(t,e,"funnel",()=>vn(H),Mn);return j=H,H.start(n,r,p),H}function vn(n){h||ue||(ue=!0,n.finish("dismissed"),Ie(),o.hidden=!0,e.client.view?be().finally(ie):ie())}function sn(){clearTimeout(Ge?.timeout),Ge=void 0}function Ie(){Pe=!1,sn(),Te?.abort(),Te=void 0,u?.destroy(),u=null,q?.destroy(),q=null,_e?.(),_e=void 0,S.open&&S.close(),R.replaceChildren(),R.style.cssText="",l=void 0,B="",M="",Ee=!1,Re="",Ue=""}function In(){let n=m.defaultView;A?.responsive&&n&&u?.resizeViewport?.(n.innerHeight,n.innerWidth)}function an(){A?.destroy(),A=void 0,i=""}function We(n){let r=n.screen?.presentation;if(!r||r.type==="inline"){S.open&&S.close(),an(),T.parentElement!==k&&k.append(T),o.parentElement!==t&&t.append(o);for(let ae of["flex","display","flex-direction","justify-content"])R.style.removeProperty(ae);b(n),c();return}o.parentElement!==S&&(S.append(T,o),t.append(S)),R.style.flex="1 0 auto",R.style.display="flex",R.style.flexDirection="column",R.style.justifyContent="center",b(n);let p=n.screen.content.document,H=JSON.stringify([r,me]);if(H!==i){an(),i=H;let ae={sm:420,md:640,lg:900},ge="size"in r&&!r.backdrop?",0 0 0 100vmax #16142566":"";S.style.cssText=`box-sizing:border-box;padding:0;border:0;overflow:auto;background:${se.background};color:${se.text};`+(r.type==="fullscreen"?"width:100vw;height:100dvh;max-width:100vw;max-height:100dvh;margin:0;border-radius:0":`width:${ae[r.size]}px;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);box-shadow:0 24px 80px #0003${ge};`+(r.type==="sheet"?"margin:auto auto 0;border-radius:14px 14px 0 0":"border-radius:14px")),A=Sn(S,{presentation:r,theme:p.theme,pages:p.pages},In),A.latch()}c(),S.setAttribute("aria-label",(ce?.screen===n.screen?.content.document.name?ce?.label:void 0)??u?.document?.name??n.screen?.content.document.name??"Funnel")}async function Xn(n){if(h||ue||he&&(Qe()||["running","waiting"].includes(n.status))||(L=n,De&&e.client.pendingCommand?.requestId!==De&&(E.hidden=!0,De=null),G=n.locale.startsWith("zh"),J.textContent=G?"\u56DE\u770B":"History",z.textContent=F.active?G?"\u8FD4\u56DE\u5F53\u524D":"Return to current":G?"\u8FD4\u56DE":"Back",a(),O.textContent=G?"\u91CD\u8BD5":"Retry",O.hidden=e.client.pendingCommand===null,Q.textContent=n.pendingRequest?G?"\u6B63\u5728\u5904\u7406":"Processing":n.instruction?.type==="wait"?G?"\u7B49\u5F85\u4E2D":"Waiting":"",ve(),fn!==`${n.revision}:${n.visit}:${n.status}:${n.stopped}`&&(fn=`${n.revision}:${n.visit}:${n.status}:${n.stopped}`,Ce(e.onState,structuredClone(n))),h||ue))return;if((!n.pendingRequest||he&&n.status==="closed")&&["closed","ineligible","failed"].includes(n.status)){ie();return}if(n.stopped&&_()){ie();return}if(n.stopped||e.client.configurationReady===!1){F.stop(),s(),Ie(),j?.finish("skipped"),o.hidden=!0,He();return}if(o.hidden=!1,F.active){He();return}let r=Ne(n),p=e.client.view;if(p&&p.revision>n.revision&&Ne(p)!==r)return;let H=!n.instruction&&!n.pendingRequest&&n.nodeType==="screen"&&["running","waiting"].includes(n.status);r!==B&&(B&&j?.finish("dismissed"),Ie(),B=r,we={...n.answers},ze.reset());let ae=Be(n);if(xe===ae){o.hidden=!0;return}if(H&&!r){o.hidden=!0;let U=e.prepared?.state==="shown"?null:je(!0,n.locale);!h&&!ue&&Ge?.key!==ae&&(sn(),Ge={key:ae,timeout:setTimeout(()=>{let g=e.client.view;if(h||!U?.active&&e.prepared?.state!=="shown"||!g||Be(g)!==ae)return;xe=ae;let W=new Error("Funnel screen preparation timed out");U?.finish("error",W),s(),Ie(),pe(W)},Se)}),He();return}sn();let Z=U=>{let g=e.client.view;return!h&&!ue&&!qe&&!U.aborted&&e.client.configurationReady!==!1&&!!g&&!g.stopped&&!["closed","ineligible","failed"].includes(g.status)&&Ne(g)===r},ge=(U,g)=>{Z(g)&&(xe=r,j?.finish("error",U),Ie(),o.hidden=!0,pe(U))};if(r||((n.instruction&&n.instruction.type!=="evaluate_segment"||!["running","waiting"].includes(n.status))&&s(),We(n),n.instruction?.type!=="event"&&n.instruction?.type!=="open_url"&&j?.finish("skipped")),n.screen){s();let U=n.screen.content;if(!u){let x=n.screen.presentation.type!=="inline",re=je(x,n.locale);if(h||ue)return;let ee=(Te=new AbortController).signal;We(n),_e=x?Vn(S):Ke(o,t),u=P(R,{mode:"live",closeActions:Array.from(new Set([...e.closeActions??[],...U.document.actions.filter(f=>f.type==="event"&&f.close).map(f=>f.id)])),onAuthoredClose(f){Z(ee)&&(Pe=f,ve())},rendererUrl:e.client.webViewUrl,title:U.document.name,...x?{hostPresentation:()=>A?.type??n.screen.presentation.type}:{},onResize:f=>{l=f,A?.responsive&&A.setContentHeight(f+k.getBoundingClientRect().height)},onAction(f,fe={},tt={}){if(F.active||!Z(ee)||M!==r)return;we={...we,...tt};let ln=n.screen?.inputs??[],Cn=Object.fromEntries(ln.filter(({variable:Oe})=>Object.hasOwn(we,Oe)).map(({variable:Oe})=>[Oe,we[Oe]]));if(Qn(ln,Cn).length){gn();return}Fe(()=>e.client.submit({operation:"submit",...ke(),input:{type:"screen",output:f,answers:Cn,selection:fe}}),!1,Oe=>xn(Oe,ln))},onAnswers:f=>{F.active||!Z(ee)||M!==r||(we={...we,...f})},onCustomerDataIntent:f=>{F.active||!Z(ee)||M!==r||ze.intent(f).catch(pe)},onEscape:()=>{!Z(ee)||M!==r||F.active||de||X||be()},onError:f=>{let fe=new Error(f);M===r?pe(fe):ge(fe,ee)},onRendered:f=>{if(!(!Z(ee)||M===r))try{re.present(fe=>{_e?.(),_e=void 0,f&&(ce={screen:U.document.name,label:f},S.setAttribute("aria-label",f)),x&&(S.showModal(),A?.responsive&&S.focus({preventScroll:!0}),!fe&&e.loading!=="host"&&_n(S,A?.type??n.screen.presentation.type,A?.responsive)),M=r,Ee=x,ve()}),Z(ee)&&Le.report(r)}catch(fe){ge(fe,ee)}}}),In()}let g={capabilities:n.screen.capabilities,customerData:n.screen.customerData,parameters:n.parameters,serverInput:{bindings:n.screen.inputs,answers:we,values:n.screen.values}},W=JSON.stringify([U,n.locale,g.parameters,n.screen.inputs,n.screen.values]);if(W!==Re)u.update(U.document,n.locale,g),Re=W,en=JSON.stringify(g.capabilities),Ue=JSON.stringify(g.customerData);else{let x=JSON.stringify(g.capabilities);x!==en&&(u.updateCapabilities(g.capabilities),en=x),JSON.stringify(g.customerData)!==Ue&&(u.updateCustomerData(g.customerData),Ue=JSON.stringify(g.customerData))}let oe=u;if(oe)try{await(j?.wait(oe.ready)??oe.ready)}catch(x){Te&&ge(x,Te.signal)}}else if(n.paywall&&!q){let U=n.paywall.resolution,g="document"in U?U.document:null,W=w,oe=null,x=(Te=new AbortController).signal,re={loading:"host",signal:x,canInteract:()=>Z(x)&&!F.active&&!de&&!X,beforeAction:async()=>{le++;try{await hn(Le.settled()),E.hidden=!0,De=null,Ae=!1,c()}finally{le=Math.max(0,le-1)}},start:()=>cn(e.client),onObservationChange:He,onPurchase:e.onPurchase,onCheckoutUrl:e.onCheckoutUrl,resumeCheckout:e.resumeCheckout,allowNewPurchase:e.allowNewPurchase,checkoutNavigation:e.checkoutNavigation,terminateCheckout:e.terminateCheckout,confirmOnHostedCheckout:e.confirmOnHostedCheckout,resolveOfferId:e.resolveOfferId,claimCoupon:e.claimCoupon,onEvent:e.onEvent,onOpenUrl:f=>e.onOpenUrl?e.onOpenUrl({receiptId:n.paywall.receiptId,url:f,openIn:"same_window"}):m.defaultView?.location.assign(f),onAction:async f=>{if(F.active)return;let fe=await e.client.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:n.nodeId,visit:n.visit,revision:e.client.view?.revision??n.revision,input:{type:"screen",output:f,answers:{}}});await ye(e.client.view??fe.run)},onError:f=>{M===r?pe(f):ge(f,x)}},ee={quoteError:f=>Ce(e.onError,f),present(f){Z(x)&&(oe?.present(()=>{f(),M=r,Ee=!!R.querySelector("dialog[open]"),ve()}),Z(x)&&Le.report(r))},async dismiss(){if(!(h||x.aborted||F.active||de||X||!he&&!Z(x))){if(he=!0,(e.resumeCheckout||e.terminateCheckout)&&nt()){L=e.client.view,ie();return}await be()}}};if(W){let f=await W.adopt(n,{options:re,handoff:ee,start:()=>cn(e.client)});f&&Z(x)&&!h?(We(n),q=f,j?.active&&j.present(()=>{}),M=r,Ee=W.modal,ve(),Le.report(r),F.active&&q.setSuspended(!0)):(f?.destroy(),s())}if(h||ue)return;if(!q){if(oe=je(!0,n.locale,g),h||ue)return;We(n);let f=await $(R,re,ee).catch(fe=>(ge(fe,x),null));!Z(x)&&!(he&&!h&&!x.aborted)?f?.host?.destroy():f&&(q=f.host,q?.setSuspended(F.active))}}if(h||ue)return;ve();let D=n.instruction;if(D&&(D.type==="open_url"||D.type==="event")&&!Je.has(D.receiptId)){let U=m.createElement("button");U.type="button",U.style.cssText=te.primary,Me(U,()=>te.focus),R.style.cssText=te.stage,U.textContent=D.type==="open_url"?`${G?"\u524D\u5F80":"Continue to"} ${new URL(D.url).host}`:G?"\u7EE7\u7EED":"Continue",U.onclick=()=>{let g=ke(),W=D.type==="open_url"&&!e.onOpenUrl&&D.openIn==="new_window"?Zn(D.url):null;Fe(async()=>{let oe="success";if(D.type==="open_url")if(e.onOpenUrl)try{oe=await e.onOpenUrl({receiptId:D.receiptId,url:D.url,openIn:D.openIn})===!1?"failed":"opened"}catch(re){Ce(e.onError,re),oe="failed"}else oe=D.openIn==="new_window"&&!W?"failed":"opened";if(D.type==="event"){if(!e.onEvent)throw new y("EVENT_HANDLER_REQUIRED","Provide the event handler");await e.onEvent(D.event)}if(h||e.client.view?.nodeId!==g.nodeId||e.client.view.visit!==g.visit)throw new y("PRECONDITION_FAILED","The client action visit changed");let x=await e.client.submit({operation:"submit",...g,input:{type:"client_action",receiptId:D.receiptId,outcome:oe}});return Je.add(D.receiptId),D.type==="open_url"&&!e.onOpenUrl&&D.openIn==="same_window"&&m.defaultView?.location.assign(D.url),x})},j?.active?j.present(()=>R.replaceChildren(U)):R.replaceChildren(U)}!n.pendingRequest&&n.status==="completed"&&!Je.has(`complete:${n.id}`)&&(Je.add(`complete:${n.id}`),Ce(e.onComplete,structuredClone(n))),He()}function Zn(n){let r=m.defaultView?.open(n,"_blank")??null;return r&&(r.opener=null),r}function ye(n){return ve(),tn=tn.catch(()=>{}).then(async()=>{try{await Xn(n)}catch(r){throw j?.active&&(xe=Be(n),j.finish("error",r),Ie(),o.hidden=!0),r}}),tn}let Kn=e.client.subscribe(n=>{if(!mn){if(n.stopped&&(Ee||_())&&!he){L=n,ie();return}!he&&(n.stopped||e.client.configurationReady===!1||B&&M!==B&&(Ne(n)!==B||["closed","ineligible","failed"].includes(n.status)))&&(Ie(),j?.finish("dismissed"),o.hidden=!0),ye(n).catch(pe)}}),et=e.client.subscribeError?.(pe);function nt(){let n=e.client.view,r=n?.paywall;return!!r?.operation&&!!n&&["running","waiting"].includes(n.status)&&Dn(Ve({quote:r.quote,operation:r.operation,requestId:r.purchaseRequestId,pending:!1,destroyed:!1,canReselect:r.canReselect}))}function be(n){if(qe)return qe;if(h||!n&&(de||X))return Promise.resolve();let r=!n&&Qe();return!r&&e.client.view&&!["running","waiting"].includes(e.client.view.status)?(L=e.client.view,ie(),Promise.resolve()):(qe=Fe(async()=>{let p=r?await e.client.retry():await e.client.submit({operation:"close",...n??ke()});return n&&yn(p),p},!0).then(()=>{let p=e.client.view;p?.status==="closed"&&!Qe()&&(L=p,ie())}).finally(()=>{qe=null}),qe)}function ie(){ne?.destroy(),!h&&(h=!0,N(),s(),e.signal?.removeEventListener("abort",ie),d?.removeEventListener("abort",ie),j?.finish("dismissed"),wn.destroy(),Kn(),et?.(),Ie(),an(),F.stop(),S.remove(),o.remove(),V(),Ce(e.onDismiss,L?structuredClone(L):null))}z.onclick=()=>{if(!z.disabled){if(F.active){F.exit();return}Fe(()=>e.client.submit({operation:"back",...ke()}))}},J.onclick=()=>{F.open()},T.onclick=()=>{j?.active?j.dismiss():de||be()},O.onclick=()=>{Qe()?be():Fe(()=>e.client.retry())},S.addEventListener("cancel",n=>{n.preventDefault(),j?.active?j.dismiss():de||be()}),e.signal?.addEventListener("abort",ie,{once:!0}),d?.addEventListener("abort",ie,{once:!0});let Ye=!1;w&&(N=w.onClose(()=>{h||ue||(ue=!0,j?.finish("dismissed"),Ie(),o.hidden=!0,e.client.view?be().finally(ie):Ye=!0)}));let bn={destroy:ie,refresh:on,get recovery(){let n=rn();if(n)return n;if(!h&&!le&&!he&&!de&&q){let r=q.recovery;if(r.type!=="native")return r}return{type:"recover",operationId:e.client.pendingPurchase?.operationId??e.client.view?.paywall?.quote?.operationId??X?.operationId??null,requestId:e.client.pendingCommand?.requestId??null}},prepareFallback(){if(de)return de;let n=rn();if(n)return Promise.resolve(n);let r=e.client.pendingPurchase?.operationId??e.client.view?.paywall?.quote?.operationId??X?.operationId??null,p=()=>({type:"recover",operationId:r,requestId:e.client.pendingCommand?.requestId??null});if(e.client.hasDurableJournal!==!0){let D=q?.recovery;return Promise.resolve(D&&D.type!=="native"&&D.type!=="cancel"?D:p())}let H=(e.client.pendingCommands??(e.client.pendingCommand?[e.client.pendingCommand]:[])).some(D=>D.operation==="close");if(h&&!(H||X&&e.client.view?.status==="closed")||le||$e||qe||F.active||!q&&!X&&!H)return Promise.resolve(p());let ae=q,Z=(async()=>{try{if(!X&&H){let g=await e.client.retry();return await ye(e.client.view??g.run),p()}if(!X){let g=await ae.prepareFallback();if(g.type!=="native")return g;if(e.client.hasDurableJournal!==!0)return p();X=g}let D=e.client.pendingCommands??(e.client.pendingCommand?[e.client.pendingCommand]:[]);if(D.length){let g=D.find(oe=>oe.operation==="close");if(!g||!K||g.requestId!==K.requestId)return p();let W=await e.client.retry();yn(W),await ye(e.client.view??W.run)}else{let g=e.client.view,W=g?.paywall;if(!g||!W||W.selectionGeneration===void 0||(W.quote?.operationId??null)!==X.operationId||X.operationId!==null&&W.canReselect!==!0)return p();let oe=W.selectionGeneration,x=await e.client.get();await ye(e.client.view??x.run);let re=e.client.view,ee=re?.paywall;if(!re||!ee||!["running","waiting"].includes(re.status)||re.stopped||re.id!==g.id||re.nodeId!==g.nodeId||re.visit!==g.visit||ee.receiptId!==W.receiptId||ee.selectionGeneration!==oe||(ee.quote?.operationId??null)!==X.operationId||X.operationId!==null&&ee.canReselect!==!0||e.client.pendingPurchase||(e.client.pendingCommands?.length??(e.client.pendingCommand?1:0)))return p();let f=ke();K={runId:re.id,operationId:X.operationId,revision:f.revision,requestId:f.requestId,nodeId:re.nodeId,visit:re.visit,receiptId:ee.receiptId,selectionGeneration:oe,acknowledged:!1},await be(f)}let U=rn();return U?(ie(),U):p()}catch(D){return pe(D),p()}})();de=Z;let ge=()=>{de===Z&&(de=null)};return Z.then(ge,ge),Z},review:F.open,exitReview:F.exit,get unappliedDrafts(){return F.drafts}};try{let n=e.client.view;if(n)((e.client.viewAgeMs??pn)>=pn||n.instruction?.type==="evaluate_segment")&&(nn=on().finally(()=>{nn=null})),await ye(n);else{if(o.hidden=!0,h)throw new DOMException("Presentation cancelled","AbortError");let r=Ye||e.prepared?.state==="shown"?null:je(e.client.view?.screen?.presentation.type!=="inline",e.client.view?.locale);if(h||ue&&!Ye)throw new DOMException("Presentation cancelled","AbortError");let p=e.client.get(),H=await(r?r.wait(p,Se):ot(p,Se));if(mn=!1,Ye)return h||await be().finally(ie),bn;await ye(e.client.view??H.run)}}catch(n){throw j?.finish("error",n),ie(),n}return bn}function ot(t,v){let C;return Promise.race([t,new Promise((e,w)=>{C=setTimeout(()=>w(new Error("Presentation data timed out")),v)})]).finally(()=>clearTimeout(C))}function Gt(t,v,C){return rt(t,v,C)}export{rt as a,Gt as b};
@@ -0,0 +1 @@
1
+ import{p as n,s as t}from"./chunk-4TEZZZYK.js";function u(o,e,a){return n(o,e,a,t)}export{u as a};