@tinkerlandai/longplay-sdk 0.10.72 → 0.10.73

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 (92) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/dist/check-response-2VZGH33N.js +1 -0
  3. package/dist/{chunk-6TX2UFWN.js → chunk-2XTBFJN4.js} +1 -1
  4. package/dist/{chunk-XHJ33SCP.js → chunk-4DMVOAXB.js} +1 -1
  5. package/dist/{chunk-FU4XNGGP.js → chunk-4ZIA22MI.js} +1 -1
  6. package/dist/{chunk-WWEHYERC.js → chunk-724YT3J5.js} +1 -1
  7. package/dist/{chunk-MYYLRNLZ.js → chunk-7KQWJBFQ.js} +1 -1
  8. package/dist/chunk-7XQKSA4R.js +1 -0
  9. package/dist/{chunk-ANNZWFFN.js → chunk-AVXJB4O6.js} +1 -1
  10. package/dist/{chunk-HATZIRVQ.js → chunk-CN2INQIX.js} +1 -1
  11. package/dist/{chunk-FXRBRAJR.js → chunk-DCPRELJA.js} +1 -1
  12. package/dist/{chunk-FZSVLHCH.js → chunk-DKEQCWIR.js} +2 -2
  13. package/dist/{chunk-NSNEBNOM.js → chunk-E3DRXDDQ.js} +1 -1
  14. package/dist/{chunk-UFEILUGE.js → chunk-EK5U2JOM.js} +1 -1
  15. package/dist/{chunk-6DE2YAGZ.js → chunk-GNRFL6KF.js} +1 -1
  16. package/dist/{chunk-DRY3ZZCD.js → chunk-GWREHUOB.js} +1 -1
  17. package/dist/{chunk-UZAJOV75.js → chunk-H4RDA4MD.js} +1 -1
  18. package/dist/{chunk-EHWMZCNT.js → chunk-HLK7L2RV.js} +1 -1
  19. package/dist/{chunk-5MX7OICH.js → chunk-HQWZWHHM.js} +1 -1
  20. package/dist/{chunk-X3VCEYMU.js → chunk-JFQBHUUN.js} +1 -1
  21. package/dist/{chunk-WO6BLOJI.js → chunk-KLPRVDHS.js} +1 -1
  22. package/dist/{chunk-64TKCCJF.js → chunk-KWOB5LYC.js} +1 -1
  23. package/dist/{chunk-6OXRK7PK.js → chunk-LM6TMEMB.js} +1 -1
  24. package/dist/{chunk-EU4XNTEE.js → chunk-MCFHMWLX.js} +1 -1
  25. package/dist/{chunk-Y7CKOODV.js → chunk-MQ3543DO.js} +1 -1
  26. package/dist/{chunk-GACCPVPU.js → chunk-MSRPJSCY.js} +1 -1
  27. package/dist/{chunk-FXKZJP4T.js → chunk-NE64O6U6.js} +2 -2
  28. package/dist/{chunk-2UB5RFXZ.js → chunk-NPDRXDI7.js} +1 -1
  29. package/dist/{chunk-4MGLQ6UP.js → chunk-O273JQ7U.js} +1 -1
  30. package/dist/{chunk-JR56NRGI.js → chunk-OHPNHCQS.js} +1 -1
  31. package/dist/{chunk-K3GKANLZ.js → chunk-PHUD42K4.js} +1 -1
  32. package/dist/{chunk-ZQZFQHV4.js → chunk-PLXNTIX4.js} +1 -1
  33. package/dist/{chunk-C57G3LX4.js → chunk-QLUP7E5M.js} +1 -1
  34. package/dist/{chunk-2WINZC4O.js → chunk-SOUVNTG4.js} +1 -1
  35. package/dist/{chunk-JLDKGCU2.js → chunk-SSVSXSYE.js} +1 -1
  36. package/dist/{chunk-TQM2JVHJ.js → chunk-SUAUY6IF.js} +1 -1
  37. package/dist/{chunk-V6RXIFHI.js → chunk-SZPHTRYE.js} +1 -1
  38. package/dist/{chunk-L5IBJODQ.js → chunk-T3JVQBQT.js} +1 -1
  39. package/dist/{chunk-QPCIIQ6Q.js → chunk-TY4PJ2AG.js} +1 -1
  40. package/dist/{chunk-2DAYQCEC.js → chunk-UG5RBIWP.js} +1 -1
  41. package/dist/{chunk-G7QLMLCR.js → chunk-V53RJR3S.js} +1 -1
  42. package/dist/{chunk-3TKVWOFW.js → chunk-VVZLNTWC.js} +1 -1
  43. package/dist/chunk-VWVLWUBX.js +1 -0
  44. package/dist/{chunk-RHARJTIX.js → chunk-WG2DKREQ.js} +1 -1
  45. package/dist/{chunk-X6IKITFV.js → chunk-WX55MS2F.js} +1 -1
  46. package/dist/{chunk-5HDJT7E5.js → chunk-XJTEGBPR.js} +1 -1
  47. package/dist/{chunk-RPN7SE4S.js → chunk-XOX4O4A7.js} +1 -1
  48. package/dist/{chunk-K55XWFEI.js → chunk-Y4MFO2FU.js} +1 -1
  49. package/dist/chunk-ZUBDANL4.js +1 -0
  50. package/dist/{chunk-3DW3Q6RU.js → chunk-ZZ4X4DMO.js} +1 -1
  51. package/dist/{content-KUCHBKX6.js → content-RJTGQ5OG.js} +1 -1
  52. package/dist/funnel-host-purchase-HBKEI5SU.js +1 -0
  53. package/dist/funnel-host-recovery-paywall-FVRMHF6K.js +1 -0
  54. package/dist/{funnel-paywall-copies-WAX7Q2N4.js → funnel-paywall-copies-E7GHHCVL.js} +1 -1
  55. package/dist/funnel-paywall-prerender-BU4VSPDB.js +1 -0
  56. package/dist/funnel-route-prediction-6IXHGQYB.js +1 -0
  57. package/dist/funnel-route-source-CALCHIZL.js +1 -0
  58. package/dist/funnel-runtime-host-GF6XCCO3.js +1 -0
  59. package/dist/index.d.ts +4 -1
  60. package/dist/index.js +1 -1
  61. package/dist/merchant-bridge-contracts-2TYLNFKF.js +1 -0
  62. package/dist/native-shell.js +1 -1
  63. package/dist/openrouter.js +1 -1
  64. package/dist/operation-contracts-KYYM2PJO.js +1 -0
  65. package/dist/page.js +1 -1
  66. package/dist/paywall-KGICSTDM.js +1 -0
  67. package/dist/paywall-content-7NCG5I7S.js +1 -0
  68. package/dist/paywall-session-AEDGMP7W.js +1 -0
  69. package/dist/popup.d.ts +2 -1
  70. package/dist/popup.js +1 -1
  71. package/dist/react-native.js +1 -1
  72. package/dist/screen-renderer-AVHPHFXT.js +1 -0
  73. package/dist/server.js +1 -1
  74. package/dist/visual.js +1 -1
  75. package/package.json +10 -9
  76. package/dist/check-response-FTYRCENP.js +0 -1
  77. package/dist/chunk-2WMBBFPQ.js +0 -1
  78. package/dist/chunk-JT5RMCS6.js +0 -1
  79. package/dist/funnel-host-purchase-WMAKTI2H.js +0 -1
  80. package/dist/funnel-host-recovery-paywall-YMOYXK4D.js +0 -1
  81. package/dist/funnel-paywall-prerender-U5BVF7QG.js +0 -1
  82. package/dist/funnel-route-prediction-EKSGU3ZG.js +0 -1
  83. package/dist/funnel-route-source-AV45OI6M.js +0 -1
  84. package/dist/funnel-runtime-host-SCBNV4VB.js +0 -1
  85. package/dist/merchant-bridge-contracts-LPMJFG7V.js +0 -1
  86. package/dist/operation-contracts-YFZHNHKS.js +0 -1
  87. package/dist/paywall-BHPQH2ZJ.js +0 -1
  88. package/dist/paywall-content-WAUQRLBP.js +0 -1
  89. package/dist/paywall-session-I2YT3WUZ.js +0 -1
  90. package/dist/screen-renderer-4X5MLXGZ.js +0 -1
  91. /package/dist/{chunk-RTKI4V2J.js → chunk-35JZDDF3.js} +0 -0
  92. /package/dist/{chunk-FZSVLHCH.js.LEGAL.txt → chunk-DKEQCWIR.js.LEGAL.txt} +0 -0
@@ -1 +1 @@
1
- import{c as I}from"./chunk-RHARJTIX.js";import{a as z}from"./chunk-DSPLGTQI.js";var F={sm:420,md:640,lg:900},B=767;function q(e,t,r=()=>!0,a="Close"){let n=e.ownerDocument.defaultView,o=e.ownerDocument.createElement("button");o.type="button",o.setAttribute("aria-label",a),o.style.cssText="position:absolute;inset:0 48px auto;z-index:2;height:24px;border:0;padding:0;background:transparent;touch-action:none;cursor:grab";let s=e.ownerDocument.createElement("span");s.style.cssText="display:block;width:36px;height:4px;border-radius:4px;margin:8px auto 12px;background:currentColor;opacity:.22;pointer-events:none",o.append(s),e.prepend(o);let d,l=0,c=!1,p=()=>{o.hidden=e.dataset.presentation!=="sheet",o.setAttribute("aria-disabled",String(!r()))},b=i=>{p(),!(o.hidden||!r()||i.button!==0)&&(d={y:i.clientY,time:Date.now(),id:i.pointerId},l=0,c=!1,o.setPointerCapture?.(i.pointerId))},x=i=>{!d||i.pointerId!==d.id||(l=Math.max(0,i.clientY-d.y),e.style.transform=`translateY(${l}px)`)},v=i=>{if(!d||i.pointerId!==d.id)return;let g=Math.max(1,Date.now()-d.time),P=i.type!=="pointercancel"&&r()&&(l>120||l>40&&l/g>.5);c=l>6,d=void 0,o.releasePointerCapture?.(i.pointerId),e.style.transform="",P?t():l&&typeof e.animate=="function"&&!n?.matchMedia?.("(prefers-reduced-motion: reduce)").matches&&e.animate([{transform:`translateY(${l}px)`},{transform:"none"}],{duration:200,easing:"cubic-bezier(.2,.8,.2,1)"}),l=0},m=()=>{if(c){c=!1;return}!d&&l===0&&r()&&t()};o.addEventListener("pointerdown",b),o.addEventListener("pointermove",x),o.addEventListener("pointerup",v),o.addEventListener("pointercancel",v),o.addEventListener("click",m);let D=typeof MutationObserver=="function"?new MutationObserver(p):void 0;return D?.observe(e,{attributes:!0,attributeFilter:["data-presentation"]}),n?.addEventListener("resize",p),p(),()=>{D?.disconnect(),n?.removeEventListener("resize",p),o.remove(),e.style.transform=""}}function X(e,t,r){if(e==="paywall")return`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${t.type==="fullscreen"?"100vw":`${F[t.size]}px`}`;if(e==="content")return"box-sizing:border-box;padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;"+(t.type==="fullscreen"?"width:100vw":`width:${I[t.size]}px${t.type==="sheet"?";margin:auto auto 0":""}`);let a=t.type!=="fullscreen"&&!t.backdrop?",0 0 0 100vmax #16142566":"";return`box-sizing:border-box;padding:0;border:0;overflow:auto;background:${r.background};color:${r.text};`+(t.type==="fullscreen"?"width:100vw;height:100dvh;max-width:100vw;max-height:100dvh;margin:0;border-radius:0":`width:${F[t.size]}px;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);box-shadow:0 24px 80px #0003${a};`+(t.type==="sheet"?"margin:auto auto 0;border-radius:14px 14px 0 0":"border-radius:14px"))}function De(e,t,r,a){let n=q(e,t,r,a),o=s=>{if(s.target!==e)return;let d=e.getBoundingClientRect();(s.clientX<d.left||s.clientX>d.right||s.clientY<d.top||s.clientY>d.bottom)&&t()};return e.addEventListener("click",o),()=>{n(),e.removeEventListener("click",o)}}function j(e,t,r=!1){return(e.type==="modal"||e.type==="sheet")&&e.mobile&&r&&t<=B?e.mobile:e.type}function J(e,t,r){let a=e.ownerDocument.defaultView,n=t.presentation,o;if((n.type==="modal"||n.type==="sheet")&&n.backdrop){let i=`lp-backdrop-${crypto.randomUUID()}`,g={none:"transparent",scrim:"#f2f2f2cc",dim:"#0006","strong-dim":"#000000bf",blur:"#0006"};e.dataset.indianaBackdrop=i,o=e.ownerDocument.createElement("style"),o.textContent=`dialog[data-indiana-backdrop="${i}"]::backdrop{background:${g[n.backdrop]};backdrop-filter:${n.backdrop==="blur"?"blur(16px)":"none"}}`,e.append(o)}let s=t.pages?.[0]?.root.style?.shape,d=s?.type==="pill"?"9999px":s?.type==="rect"?typeof s.radius=="number"?`${s.radius}px`:[s.radius.topLeft,s.radius.topRight,s.radius.bottomRight,s.radius.bottomLeft].map(i=>`${i}px`).join(" "):void 0,l=(n.type==="modal"||n.type==="sheet")&&(n.desktopWidth!==void 0||n.mobile!==void 0||n.type==="modal"&&n.position!==void 0),c=n.type,p,b,x=!1,v=i=>{x||!Number.isFinite(i)||i<0||(b=i,c!=="fullscreen"&&c!=="inline"&&(e.style.height=`min(${Math.max(i,40)}px, calc(100dvh - ${c==="sheet"?0:32}px))`))},m=()=>{if(!x&&(c=p??j(n,a?.innerWidth??1024,a?.matchMedia?.("(pointer: coarse)").matches===!0),e.dataset.presentation=c,!(!l||n.type!=="modal"&&n.type!=="sheet"))){if(e.style.boxSizing="border-box",e.style.padding="0",e.style.border="0",e.style.overflow="hidden",e.style.outline="none",e.tabIndex=-1,e.style.background=t.theme.background,e.style.color=t.theme.text,c==="fullscreen")e.style.width="100vw",e.style.height="100dvh",e.style.maxWidth="100vw",e.style.maxHeight="100dvh",e.style.margin="0",e.style.borderRadius="0";else{let i=n.mobile==="sheet"&&c==="sheet",g=n.desktopWidth,P=a?.innerWidth??1024;e.style.width=i?`${P}px`:g?`${Math.min(g.max,Math.max(P*g.viewport/100,g.min))}px`:`${I[n.size]}px`,e.style.maxWidth=`${Math.max(0,P-(c==="sheet"?0:32))}px`,e.style.maxHeight=c==="sheet"?"100dvh":"calc(100dvh - 32px)",e.style.margin=c==="sheet"?"auto auto 0":n.type==="modal"&&n.position==="top"?"16px auto auto":n.type==="modal"&&n.position==="bottom"?"auto auto 16px":"auto",e.style.borderRadius=d??(c==="sheet"?"16px 16px 0 0":"24px"),e.style.height="",b!==void 0&&v(b)}r?.(c)}},D=l?[a?.matchMedia?.(`(max-width: ${B}px)`),a?.matchMedia?.("(pointer: coarse)")].filter(i=>i!==void 0):[];if(l){a?.addEventListener("resize",m);for(let i of D)i.addEventListener?i.addEventListener("change",m):i.addListener?.(m)}return m(),{responsive:l,get type(){return c},latch(){x||p!==void 0||(m(),p=c)},setContentHeight:v,destroy(){if(!x){x=!0,o?.remove(),delete e.dataset.indianaBackdrop,a?.removeEventListener("resize",m);for(let i of D)i.removeEventListener?i.removeEventListener("change",m):i.removeListener?.(m)}}}}function Le(e,t,r){let{presentation:a}=t;return e.style.cssText=X("paywall",a.type==="inline"?{type:"fullscreen"}:a,t.theme),J(e,t,r)}function Te(e,t,r=!1){let a=e.ownerDocument.defaultView;if(typeof e.animate!="function"||a?.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return;let n=r?{duration:300,easing:"cubic-bezier(0.23, 1, 0.32, 1)"}:{duration:240,easing:"cubic-bezier(0.2, 0.8, 0.2, 1)"};e.animate(t==="sheet"?[{transform:"translateY(100%)"},{transform:"none"}]:t==="modal"?[{opacity:0,transform:r?"translateY(12px) scale(0.96)":"translateY(8px) scale(0.98)"},{opacity:1,transform:"none"}]:[{opacity:0},{opacity:1}],n);try{e.animate([{opacity:0},{opacity:1}],{...n,pseudoElement:"::backdrop"})}catch{}}function V(e,t){e.style.cssText=["position:absolute","z-index:1","top:calc(4px + env(safe-area-inset-top, 0px))","inset-inline-end:calc(4px + env(safe-area-inset-right, 0px))","width:44px","height:44px","padding:0","border:0","border-radius:50%","font:400 20px/1 system-ui,sans-serif","cursor:pointer","touch-action:manipulation"].join(";"),e.style.background=`radial-gradient(circle, ${t.background} 0 15px, color-mix(in srgb, ${t.text} 22%, ${t.background}) 15px 16px, transparent 16.5px)`,e.style.color=t.text}function ke(e){let t=e.closest("dialog");if(!t?.open||!t.isConnected)return;let r=["style","tabindex","aria-label","data-presentation","data-indiana-backdrop"].map(a=>[a,t.getAttribute(a)]);return{dialog:t,content:e,release(){for(let[a,n]of r)n===null?t.removeAttribute(a):t.setAttribute(a,n)}}}var O=new WeakMap;function Ce(e,t){return O.set(e,t),()=>O.delete(e)}function Y(e){let t=e.defaultView?.HTMLElement,r=e.activeElement;for(let n=0;n<16&&r?.shadowRoot?.activeElement;n++)r=r.shadowRoot.activeElement;let a=r?O.get(r)?.():void 0;return()=>{!r?.isConnected||!t||!(r instanceof t)||(r.focus({preventScroll:!0}),a?.())}}var $e=15e3;function ze(e,t,r,a,n){let o=e.ownerDocument,s=new AbortController,d=!1,l=!1,c,p,b,x,v,m;function D(){clearTimeout(m),m=void 0,b?.(),b=void 0,c?.tagName==="DIALOG"&&c.close?.(),c?.remove(),c=void 0,p=void 0,v=void 0}function i(u,w){l||(l=!0,D(),(u==="dismissed"||u==="error")&&s.abort(w??new DOMException("Presentation cancelled","AbortError")),!(!d&&u!=="ready")&&z(t.onPresentationState,u==="error"?{surface:r,state:u,error:w}:{surface:r,state:u}))}let g=a,P=()=>{l||g()};return{setDismissHandler(u){g=u},get active(){return d&&!l},get cancelled(){return s.signal.aborted},retainPurchaseDialog(){return p?.()},setPurchaseRecovery(u,w){x={message:u,retry:w},v?.()},start(u,w,h){if(d||l)return;d=!0;let C=()=>{if(!l&&t.loading!=="host"){let k=(w??o.documentElement.lang)||"en",M=u&&h?.presentation?.type!=="inline",L=h!==void 0,y=o.createElement(M?"dialog":"div");c=y,y.dataset.longplayLoading=r;let R=k.startsWith("zh"),W=L?R?"正在加载套餐":"Loading plans":R?"正在加载":"Loading",N=h?.screen.theme??{background:"Canvas",text:"CanvasText"};y.setAttribute("aria-label",W);let S=o.createElement("div");S.setAttribute("role","status");let H=o.createElement("div");H.setAttribute("aria-hidden","true"),L?(S.style.cssText="padding:calc(24px + env(safe-area-inset-top, 0px)) 24px 16px;padding-inline-end:68px;font:650 20px/1.3 system-ui,sans-serif;letter-spacing:-.015em",h||(S.style.paddingBlockEnd="24px")):S.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)",S.textContent=W;let T=o.createElement("button");T.type="button",T.textContent=R?"重试":"Retry",T.style.cssText="margin:0 24px 20px;padding:8px 16px",T.onclick=()=>x?.retry?.(),v=()=>{x&&(S.textContent=x.message,x.retry?S.after(T):T.remove())};let E=o.createElement("button");E.type="button",E.textContent="×",E.setAttribute("aria-label",R?"取消加载":"Cancel loading"),V(E,N),L&&(E.style.borderRadius="50%",E.style.top="calc(15px + env(safe-area-inset-top, 0px))",E.style.insetInlineEnd="calc(15px + env(safe-area-inset-right, 0px))"),E.addEventListener("click",P);let _=f=>{f.preventDefault(),P()};y.addEventListener("cancel",_);let A=o.createElement("style");A.textContent="[data-longplay-loading] > button:focus-visible{outline:2px solid currentColor;outline-offset:-2px}",y.append(S,H,E,A),v(),e.append(y);let $=()=>{if(!l&&M){let f=y,G=Y(o);f.showModal?f.showModal():f.open=!0,E.focus({preventScroll:!0}),p=()=>{if(!f.open||!f.isConnected)return;let U=b;return b=void 0,c=void 0,p=void 0,delete f.dataset.longplayLoading,f.removeAttribute("aria-label"),f.style.padding="0",f.removeEventListener("cancel",_),S.remove(),H.remove(),E.remove(),A.remove(),T.remove(),v=void 0,{dialog:f,release(){U?.(),f.close?.(),f.remove(),G()}}}}};h&&n?(b=n(y,H,h),$()):L?(y.style.cssText=M?"padding:0;border:0;border-radius:24px;background:Canvas;color:CanvasText;width:min(420px,calc(100vw - 32px))":"position:relative;background:Canvas;color:CanvasText;width:100%",$()):(K(y,H,M,r),$())}};h!==void 0&&t.loading!=="host"?m=setTimeout(C,120):C(),z(t.onPresentationState,{surface:r,state:"loading",dismiss:P})},present(u){if(l)return;let w=!!c;D(),u(w),i("ready")},dismiss:P,finish:i,async wait(u,w){let h=s.signal,C,k,M=new Promise((L,y)=>{k=()=>y(h.reason),h.aborted?k():h.addEventListener("abort",k,{once:!0}),w!==void 0&&(C=setTimeout(()=>y(new Error("Presentation data timed out")),w))});try{let L=await Promise.race([M,u]);return h.throwIfAborted(),L}finally{h.removeEventListener("abort",k),clearTimeout(C)}}}}function K(e,t,r,a){e.style.cssText="position:relative;box-sizing:border-box;background:Canvas;color:CanvasText;padding:24px 48px 24px 24px;"+(r?"position:fixed;width:min(480px,calc(100% - 32px));border:0;border-radius:16px;max-height:calc(100dvh - 32px)":"width:100%"),t.style.cssText="display:grid;gap:12px";let n=a==="banner"?[["72%",12],["44%",10]]:[["46%",20],["84%",12],["65%",12],["100%",64]];for(let[o,s]of n){let d=e.ownerDocument.createElement("div");d.style.cssText=`width:${o};height:${s}px;background:currentColor;opacity:.11;border-radius:6px`,t.append(d)}}function Q(e){let t={display:"block",position:"fixed",top:"0",left:"0",opacity:"0",pointerEvents:"none",zIndex:"-1"},r=Object.keys(t).map(o=>{let s=o,d=e.style[s];return e.style[s]=t[s],[s,d]}),a=e.inert??!1,n=e.getAttribute("aria-hidden");return e.inert=!0,e.setAttribute("aria-hidden","true"),()=>{for(let[o,s]of r)e.style[o]=s;e.inert=a,n===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",n)}}function We(e,t){let r=e.style.width;e.style.width=`${t.getBoundingClientRect().width||t.ownerDocument.defaultView?.innerWidth||800}px`;let a=Q(e);return()=>{a(),e.style.width=r}}export{X as a,De as b,j as c,J as d,Le as e,Te as f,V as g,ke as h,Ce as i,Y as j,$e as k,ze as l,Q as m,We as n};
1
+ import{c as I}from"./chunk-WG2DKREQ.js";import{a as z}from"./chunk-DSPLGTQI.js";var F={sm:420,md:640,lg:900},B=767;function q(e,t,r=()=>!0,a="Close"){let n=e.ownerDocument.defaultView,o=e.ownerDocument.createElement("button");o.type="button",o.setAttribute("aria-label",a),o.style.cssText="position:absolute;inset:0 48px auto;z-index:2;height:24px;border:0;padding:0;background:transparent;touch-action:none;cursor:grab";let s=e.ownerDocument.createElement("span");s.style.cssText="display:block;width:36px;height:4px;border-radius:4px;margin:8px auto 12px;background:currentColor;opacity:.22;pointer-events:none",o.append(s),e.prepend(o);let d,l=0,c=!1,p=()=>{o.hidden=e.dataset.presentation!=="sheet",o.setAttribute("aria-disabled",String(!r()))},b=i=>{p(),!(o.hidden||!r()||i.button!==0)&&(d={y:i.clientY,time:Date.now(),id:i.pointerId},l=0,c=!1,o.setPointerCapture?.(i.pointerId))},x=i=>{!d||i.pointerId!==d.id||(l=Math.max(0,i.clientY-d.y),e.style.transform=`translateY(${l}px)`)},v=i=>{if(!d||i.pointerId!==d.id)return;let g=Math.max(1,Date.now()-d.time),P=i.type!=="pointercancel"&&r()&&(l>120||l>40&&l/g>.5);c=l>6,d=void 0,o.releasePointerCapture?.(i.pointerId),e.style.transform="",P?t():l&&typeof e.animate=="function"&&!n?.matchMedia?.("(prefers-reduced-motion: reduce)").matches&&e.animate([{transform:`translateY(${l}px)`},{transform:"none"}],{duration:200,easing:"cubic-bezier(.2,.8,.2,1)"}),l=0},m=()=>{if(c){c=!1;return}!d&&l===0&&r()&&t()};o.addEventListener("pointerdown",b),o.addEventListener("pointermove",x),o.addEventListener("pointerup",v),o.addEventListener("pointercancel",v),o.addEventListener("click",m);let D=typeof MutationObserver=="function"?new MutationObserver(p):void 0;return D?.observe(e,{attributes:!0,attributeFilter:["data-presentation"]}),n?.addEventListener("resize",p),p(),()=>{D?.disconnect(),n?.removeEventListener("resize",p),o.remove(),e.style.transform=""}}function X(e,t,r){if(e==="paywall")return`padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;width:${t.type==="fullscreen"?"100vw":`${F[t.size]}px`}`;if(e==="content")return"box-sizing:border-box;padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto;"+(t.type==="fullscreen"?"width:100vw":`width:${I[t.size]}px${t.type==="sheet"?";margin:auto auto 0":""}`);let a=t.type!=="fullscreen"&&!t.backdrop?",0 0 0 100vmax #16142566":"";return`box-sizing:border-box;padding:0;border:0;overflow:auto;background:${r.background};color:${r.text};`+(t.type==="fullscreen"?"width:100vw;height:100dvh;max-width:100vw;max-height:100dvh;margin:0;border-radius:0":`width:${F[t.size]}px;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);box-shadow:0 24px 80px #0003${a};`+(t.type==="sheet"?"margin:auto auto 0;border-radius:14px 14px 0 0":"border-radius:14px"))}function De(e,t,r,a){let n=q(e,t,r,a),o=s=>{if(s.target!==e)return;let d=e.getBoundingClientRect();(s.clientX<d.left||s.clientX>d.right||s.clientY<d.top||s.clientY>d.bottom)&&t()};return e.addEventListener("click",o),()=>{n(),e.removeEventListener("click",o)}}function j(e,t,r=!1){return(e.type==="modal"||e.type==="sheet")&&e.mobile&&r&&t<=B?e.mobile:e.type}function J(e,t,r){let a=e.ownerDocument.defaultView,n=t.presentation,o;if((n.type==="modal"||n.type==="sheet")&&n.backdrop){let i=`lp-backdrop-${crypto.randomUUID()}`,g={none:"transparent",scrim:"#f2f2f2cc",dim:"#0006","strong-dim":"#000000bf",blur:"#0006"};e.dataset.indianaBackdrop=i,o=e.ownerDocument.createElement("style"),o.textContent=`dialog[data-indiana-backdrop="${i}"]::backdrop{background:${g[n.backdrop]};backdrop-filter:${n.backdrop==="blur"?"blur(16px)":"none"}}`,e.append(o)}let s=t.pages?.[0]?.root.style?.shape,d=s?.type==="pill"?"9999px":s?.type==="rect"?typeof s.radius=="number"?`${s.radius}px`:[s.radius.topLeft,s.radius.topRight,s.radius.bottomRight,s.radius.bottomLeft].map(i=>`${i}px`).join(" "):void 0,l=(n.type==="modal"||n.type==="sheet")&&(n.desktopWidth!==void 0||n.mobile!==void 0||n.type==="modal"&&n.position!==void 0),c=n.type,p,b,x=!1,v=i=>{x||!Number.isFinite(i)||i<0||(b=i,c!=="fullscreen"&&c!=="inline"&&(e.style.height=`min(${Math.max(i,40)}px, calc(100dvh - ${c==="sheet"?0:32}px))`))},m=()=>{if(!x&&(c=p??j(n,a?.innerWidth??1024,a?.matchMedia?.("(pointer: coarse)").matches===!0),e.dataset.presentation=c,!(!l||n.type!=="modal"&&n.type!=="sheet"))){if(e.style.boxSizing="border-box",e.style.padding="0",e.style.border="0",e.style.overflow="hidden",e.style.outline="none",e.tabIndex=-1,e.style.background=t.theme.background,e.style.color=t.theme.text,c==="fullscreen")e.style.width="100vw",e.style.height="100dvh",e.style.maxWidth="100vw",e.style.maxHeight="100dvh",e.style.margin="0",e.style.borderRadius="0";else{let i=n.mobile==="sheet"&&c==="sheet",g=n.desktopWidth,P=a?.innerWidth??1024;e.style.width=i?`${P}px`:g?`${Math.min(g.max,Math.max(P*g.viewport/100,g.min))}px`:`${I[n.size]}px`,e.style.maxWidth=`${Math.max(0,P-(c==="sheet"?0:32))}px`,e.style.maxHeight=c==="sheet"?"100dvh":"calc(100dvh - 32px)",e.style.margin=c==="sheet"?"auto auto 0":n.type==="modal"&&n.position==="top"?"16px auto auto":n.type==="modal"&&n.position==="bottom"?"auto auto 16px":"auto",e.style.borderRadius=d??(c==="sheet"?"16px 16px 0 0":"24px"),e.style.height="",b!==void 0&&v(b)}r?.(c)}},D=l?[a?.matchMedia?.(`(max-width: ${B}px)`),a?.matchMedia?.("(pointer: coarse)")].filter(i=>i!==void 0):[];if(l){a?.addEventListener("resize",m);for(let i of D)i.addEventListener?i.addEventListener("change",m):i.addListener?.(m)}return m(),{responsive:l,get type(){return c},latch(){x||p!==void 0||(m(),p=c)},setContentHeight:v,destroy(){if(!x){x=!0,o?.remove(),delete e.dataset.indianaBackdrop,a?.removeEventListener("resize",m);for(let i of D)i.removeEventListener?i.removeEventListener("change",m):i.removeListener?.(m)}}}}function Le(e,t,r){let{presentation:a}=t;return e.style.cssText=X("paywall",a.type==="inline"?{type:"fullscreen"}:a,t.theme),J(e,t,r)}function Te(e,t,r=!1){let a=e.ownerDocument.defaultView;if(typeof e.animate!="function"||a?.matchMedia?.("(prefers-reduced-motion: reduce)").matches)return;let n=r?{duration:300,easing:"cubic-bezier(0.23, 1, 0.32, 1)"}:{duration:240,easing:"cubic-bezier(0.2, 0.8, 0.2, 1)"};e.animate(t==="sheet"?[{transform:"translateY(100%)"},{transform:"none"}]:t==="modal"?[{opacity:0,transform:r?"translateY(12px) scale(0.96)":"translateY(8px) scale(0.98)"},{opacity:1,transform:"none"}]:[{opacity:0},{opacity:1}],n);try{e.animate([{opacity:0},{opacity:1}],{...n,pseudoElement:"::backdrop"})}catch{}}function V(e,t){e.style.cssText=["position:absolute","z-index:1","top:calc(4px + env(safe-area-inset-top, 0px))","inset-inline-end:calc(4px + env(safe-area-inset-right, 0px))","width:44px","height:44px","padding:0","border:0","border-radius:50%","font:400 20px/1 system-ui,sans-serif","cursor:pointer","touch-action:manipulation"].join(";"),e.style.background=`radial-gradient(circle, ${t.background} 0 15px, color-mix(in srgb, ${t.text} 22%, ${t.background}) 15px 16px, transparent 16.5px)`,e.style.color=t.text}function ke(e){let t=e.closest("dialog");if(!t?.open||!t.isConnected)return;let r=["style","tabindex","aria-label","data-presentation","data-indiana-backdrop"].map(a=>[a,t.getAttribute(a)]);return{dialog:t,content:e,release(){for(let[a,n]of r)n===null?t.removeAttribute(a):t.setAttribute(a,n)}}}var O=new WeakMap;function Ce(e,t){return O.set(e,t),()=>O.delete(e)}function Y(e){let t=e.defaultView?.HTMLElement,r=e.activeElement;for(let n=0;n<16&&r?.shadowRoot?.activeElement;n++)r=r.shadowRoot.activeElement;let a=r?O.get(r)?.():void 0;return()=>{!r?.isConnected||!t||!(r instanceof t)||(r.focus({preventScroll:!0}),a?.())}}var $e=15e3;function ze(e,t,r,a,n){let o=e.ownerDocument,s=new AbortController,d=!1,l=!1,c,p,b,x,v,m;function D(){clearTimeout(m),m=void 0,b?.(),b=void 0,c?.tagName==="DIALOG"&&c.close?.(),c?.remove(),c=void 0,p=void 0,v=void 0}function i(u,w){l||(l=!0,D(),(u==="dismissed"||u==="error")&&s.abort(w??new DOMException("Presentation cancelled","AbortError")),!(!d&&u!=="ready")&&z(t.onPresentationState,u==="error"?{surface:r,state:u,error:w}:{surface:r,state:u}))}let g=a,P=()=>{l||g()};return{setDismissHandler(u){g=u},get active(){return d&&!l},get cancelled(){return s.signal.aborted},retainPurchaseDialog(){return p?.()},setPurchaseRecovery(u,w){x={message:u,retry:w},v?.()},start(u,w,h){if(d||l)return;d=!0;let C=()=>{if(!l&&t.loading!=="host"){let k=(w??o.documentElement.lang)||"en",M=u&&h?.presentation?.type!=="inline",L=h!==void 0,y=o.createElement(M?"dialog":"div");c=y,y.dataset.longplayLoading=r;let R=k.startsWith("zh"),W=L?R?"正在加载套餐":"Loading plans":R?"正在加载":"Loading",N=h?.screen.theme??{background:"Canvas",text:"CanvasText"};y.setAttribute("aria-label",W);let S=o.createElement("div");S.setAttribute("role","status");let H=o.createElement("div");H.setAttribute("aria-hidden","true"),L?(S.style.cssText="padding:calc(24px + env(safe-area-inset-top, 0px)) 24px 16px;padding-inline-end:68px;font:650 20px/1.3 system-ui,sans-serif;letter-spacing:-.015em",h||(S.style.paddingBlockEnd="24px")):S.style.cssText="position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)",S.textContent=W;let T=o.createElement("button");T.type="button",T.textContent=R?"重试":"Retry",T.style.cssText="margin:0 24px 20px;padding:8px 16px",T.onclick=()=>x?.retry?.(),v=()=>{x&&(S.textContent=x.message,x.retry?S.after(T):T.remove())};let E=o.createElement("button");E.type="button",E.textContent="×",E.setAttribute("aria-label",R?"取消加载":"Cancel loading"),V(E,N),L&&(E.style.borderRadius="50%",E.style.top="calc(15px + env(safe-area-inset-top, 0px))",E.style.insetInlineEnd="calc(15px + env(safe-area-inset-right, 0px))"),E.addEventListener("click",P);let _=f=>{f.preventDefault(),P()};y.addEventListener("cancel",_);let A=o.createElement("style");A.textContent="[data-longplay-loading] > button:focus-visible{outline:2px solid currentColor;outline-offset:-2px}",y.append(S,H,E,A),v(),e.append(y);let $=()=>{if(!l&&M){let f=y,G=Y(o);f.showModal?f.showModal():f.open=!0,E.focus({preventScroll:!0}),p=()=>{if(!f.open||!f.isConnected)return;let U=b;return b=void 0,c=void 0,p=void 0,delete f.dataset.longplayLoading,f.removeAttribute("aria-label"),f.style.padding="0",f.removeEventListener("cancel",_),S.remove(),H.remove(),E.remove(),A.remove(),T.remove(),v=void 0,{dialog:f,release(){U?.(),f.close?.(),f.remove(),G()}}}}};h&&n?(b=n(y,H,h),$()):L?(y.style.cssText=M?"padding:0;border:0;border-radius:24px;background:Canvas;color:CanvasText;width:min(420px,calc(100vw - 32px))":"position:relative;background:Canvas;color:CanvasText;width:100%",$()):(K(y,H,M,r),$())}};h!==void 0&&t.loading!=="host"?m=setTimeout(C,120):C(),z(t.onPresentationState,{surface:r,state:"loading",dismiss:P})},present(u){if(l)return;let w=!!c;D(),u(w),i("ready")},dismiss:P,finish:i,async wait(u,w){let h=s.signal,C,k,M=new Promise((L,y)=>{k=()=>y(h.reason),h.aborted?k():h.addEventListener("abort",k,{once:!0}),w!==void 0&&(C=setTimeout(()=>y(new Error("Presentation data timed out")),w))});try{let L=await Promise.race([M,u]);return h.throwIfAborted(),L}finally{h.removeEventListener("abort",k),clearTimeout(C)}}}}function K(e,t,r,a){e.style.cssText="position:relative;box-sizing:border-box;background:Canvas;color:CanvasText;padding:24px 48px 24px 24px;"+(r?"position:fixed;width:min(480px,calc(100% - 32px));border:0;border-radius:16px;max-height:calc(100dvh - 32px)":"width:100%"),t.style.cssText="display:grid;gap:12px";let n=a==="banner"?[["72%",12],["44%",10]]:[["46%",20],["84%",12],["65%",12],["100%",64]];for(let[o,s]of n){let d=e.ownerDocument.createElement("div");d.style.cssText=`width:${o};height:${s}px;background:currentColor;opacity:.11;border-radius:6px`,t.append(d)}}function Q(e){let t={display:"block",position:"fixed",top:"0",left:"0",opacity:"0",pointerEvents:"none",zIndex:"-1"},r=Object.keys(t).map(o=>{let s=o,d=e.style[s];return e.style[s]=t[s],[s,d]}),a=e.inert??!1,n=e.getAttribute("aria-hidden");return e.inert=!0,e.setAttribute("aria-hidden","true"),()=>{for(let[o,s]of r)e.style[o]=s;e.inert=a,n===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",n)}}function We(e,t){let r=e.style.width;e.style.width=`${t.getBoundingClientRect().width||t.ownerDocument.defaultView?.innerWidth||800}px`;let a=Q(e);return()=>{a(),e.style.width=r}}export{X as a,De as b,j as c,J as d,Le as e,Te as f,V as g,ke as h,Ce as i,Y as j,$e as k,ze as l,Q as m,We as n};
@@ -0,0 +1 @@
1
+ import{a as we,b as ye}from"./chunk-SOUVNTG4.js";import{d as Fe,e as $}from"./chunk-DCPRELJA.js";import{a as De}from"./chunk-HLK7L2RV.js";import{a as A}from"./chunk-DSPLGTQI.js";var je=5*6e4,Je=15e3,He=new WeakMap;function $e(c){return He.get(c)}var R=c=>Array.isArray(c)?c.map(R):c&&typeof c=="object"?Object.fromEntries(Object.keys(c).sort().map(n=>[n,R(c[n])])):c,M=(c,n)=>JSON.stringify(R(c))===JSON.stringify(R(n)),z=c=>JSON.stringify(R([c.funnelId,c.locale??null,c.parameters??{}])),Ue=["onObservationChange","onPurchase","onCheckoutUrl","resumeCheckout","allowNewPurchase","checkoutNavigation","terminateCheckout","beforeCheckoutReplacement","purchaseConfirmation","confirmOnHostedCheckout","resolveOfferId","prepareSubscriptionChange","resolveSubscriptionChange","onOpenUrl","onEvent","onAction","onComplete","onError"];function Ge(c,n,S){let F=e=>structuredClone({funnelId:e.funnelId,locale:e.locale,parameters:e.parameters}),m,q="",k=n.start instanceof Promise?void 0:F(n.start),Q=e=>e?.parameters?.commerce,L=Promise.resolve(n.start).then(e=>e?F(e):void 0),Y=n.maxAgeMs??je,me=new AbortController,w=AbortSignal.any([me.signal,n.client.identitySignal,...n.signal?[n.signal]:[]]),Z=()=>d("released","aborted"),t="preparing",ge,T,ee=()=>{},j=0,b=null,P=null,v=null,y=null,g,H,ne,he=new Map,h=null,J=new Set,E=new Map,re,Pe=new Promise(e=>re=e),U,be=new Promise(e=>U=e),ae,Oe=new Promise(e=>ae=e);function G(e,r){t!==e&&(t=e,ge=r,A(n.onState,e))}function Ne(){w.removeEventListener("abort",Z),W(),P?.destroy(),P=null,b?.remove(),b=null,v=null}function d(e,r){["adopted","unavailable","released","closed"].includes(t)||(G(e,r),Ne(),re(!1),U(!1),ae(null))}function O(e){t!=="shown"&&d("unavailable",e)}let p,te=!1,V=n.client.paywallCopies,oe,ve=new Promise(e=>oe=e),le=!1;function Ie(e){ve.then(r=>{r&&V&&V.write(r,e).catch(()=>{})})}function Se(e){ve.then(async r=>{if(!r||!V)return;let a=await V.read(r);te||a&&"presented"in a||await V.write(r,e)}).catch(()=>{})}let ie=e=>`error:${e?.code??e?.name??"unknown"}`,se=c.ownerDocument.defaultView,N=!S,Ce=null,_=!1,xe=e=>e.storageArea===se?.localStorage&&(e.key===null||e.key.startsWith("indiana.funnel.purchases.")),Ae=e=>{xe(e)&&K()},Me=S?()=>{}:n.client.subscribe(()=>K());function W(){N&&(N=!1,se?.removeEventListener("storage",Ae),Me(),ee())}let ce=()=>N&&(t==="ready"||t==="preparing");function de(e){(t==="ready"||t==="preparing")&&d("unavailable",e)}function K(){if(t==="ready"&&Date.now()-j>=Y)return W();_=!0,Ce??=(async()=>{for(;_&&m&&ce();){_=!1;try{await n.client.retained()==="pending"&&de("purchase_pending")}catch(e){w.aborted?d("released","aborted"):de(ie(e))}}})().finally(()=>{Ce=null,_&&m&&ce()&&K()})}S||se?.addEventListener("storage",Ae),w.addEventListener("abort",Z,{once:!0});let Re=S?Promise.resolve("none"):n.client.findPurchase();Re.catch(()=>{});let B;function X(e){let r=B?.paywallVersionId??n.paywallVersionId??p?.resolution.id??y?.id,a=JSON.stringify(R([r??null,e])),l=he.get(a);return l||(l=n.client.readPaywall({paywallVersionId:r,...r?{}:{paywallId:B?.paywallId??n.paywallId},...e}),he.set(a,l)),l}function D(e,r){let a=Object.values(e.capabilities.plans),l=Object.values(e.document.buttons).some(i=>i.type==="checkout");return l&&a.length===0?!1:r.intent==="subscription_change"&&l?a.some(i=>i.available):a.every(i=>i.available)}function ue(e,r){if(y&&!$(e,y))return d("unavailable","paywall_changed"),!1;y=e,ne=r;for(let a of E.keys())A(a,structuredClone(e));return!0}function ke(e,r){if(!(!y||!["preparing","ready","shown"].includes(t))){if(!$(e,y))return O("paywall_changed");if(!D(e,r.commerce))return O("plan_unavailable");ue(e,r)}}async function x(){let e=await Oe;if(!e)throw new De("PURCHASE_PENDING","The purchase did not start; open it again");return e}let qe={get view(){return h?h.view:y},get signal(){return h?.signal??n.client.identitySignal},get quote(){return h?.quote??null},get operation(){return h?.operation??null},webViewUrl:"bundled",get canReselect(){return h?.canReselect},get recovery(){return h?.recovery},get pendingCancellation(){return h?.pendingCancellation},subscribe(e){return E.set(e,h?.subscribe?.(e)??(()=>{})),()=>{E.get(e)?.(),E.delete(e)}},refresh:async()=>h?h.refresh():structuredClone(y),preview:async e=>(await x()).preview(e),confirm:async()=>(await x()).confirm(),cancel:async()=>(await x()).cancel(),read:async()=>(await x()).read(),destroy(){h?.destroy()}},u={options:{},handoff:{}},Ee={loading:"host",focusAtReveal:!0,settleMotionAtReveal:!0,signal:n.client.identitySignal,start:async()=>qe,canInteract:()=>u.options.canInteract?u.options.canInteract():!["unavailable","released","closed"].includes(t),async beforeAction(){let e=t!=="adopted",r=y?.capabilities,a=await x();if(e&&!M(a.view?.capabilities,r))throw new Fe;await u.options.beforeAction?.()}};for(let e of Ue)Object.defineProperty(Ee,e,{enumerable:!0,get:()=>u.options[e]});function fe(){t!=="preparing"||!v||!P||!p&&(!m||!M(ne?.commerce,Q(m))||ne?.locale!==m.locale)||(G("ready"),re(!0))}let Ve={present(e){if(u.handoff.present)return u.handoff.present(e);t==="preparing"&&(v=e,j=Date.now(),fe())},async dismiss(){if(u.handoff.dismiss)return u.handoff.dismiss();d("closed");for(let e of[...J])A(e)},async closeAction(e){if(u.handoff.closeAction)return u.handoff.closeAction(e);u.options.onAction?await u.options.onAction(e):await Ve.dismiss()},quoteError(e){u.handoff.quoteError?u.handoff.quoteError(e):A(u.options.onError,e)}};async function Le(){if(n.paywallVersionId||n.paywallId)return{paywallVersionId:n.paywallVersionId,paywallId:n.paywallId};let e=n.configuration;if(!e)return d("unavailable","paywall_missing"),null;let r=await Promise.resolve(n.start).catch(()=>null);if(!r||t!=="preparing")return null;let a=()=>we(e,{funnelId:r.funnelId,customerId:n.client.customerId,parameters:r.parameters??{}});if(T=await a(),t!=="preparing")return null;let l=T;if(l.type!=="paywall")return d("unavailable",ye(l)??"route"),null;let i=!1;return ee=e.subscribe(()=>{i||!ce()||(i=!0,a().then(s=>{!(s.type==="unavailable"&&!["funnel_stopped","route_unavailable"].includes(s.reason))&&(s.type!=="paywall"||s.paywallVersionId!==l.paywallVersionId)&&de("route_changed")}).finally(()=>i=!1))}),N||ee(),{paywallVersionId:l.paywallVersionId}}(async()=>{try{let[{showPaywall:e},r]=await Promise.all([import("./paywall-KGICSTDM.js"),Le()]),a=n.commerce??Q(k),l=n.locale??k?.locale,i=r&&a&&l?JSON.stringify(R([r.paywallVersionId??null,r.paywallId??null,{commerce:a,locale:l}])):null;if(oe(i),w.throwIfAborted(),t!=="preparing"||!r)return;if(!a)return d("unavailable","commerce_missing");if(!l)return d("unavailable","locale_missing");B=r;let s={commerce:a,locale:l},f=i?await V?.read(i).catch(()=>null):null;if(le=!!f&&"presented"in f&&(!k||f.funnelId===k.funnelId),w.throwIfAborted(),t!=="preparing"||le)return;f&&!("presented"in f)&&(!k||f.funnelId===k.funnelId)&&D(f.resolution,f.context.commerce)&&(p=f),U(!!p);let o;if(p){let pe=p.context;s=pe,o=structuredClone(p.resolution),X(pe).then(Te=>ke(Te,pe),()=>{})}else o=await X(s);if(w.throwIfAborted(),t!=="preparing"||(!D(o,s.commerce)&&n.start instanceof Promise&&!g&&await L,!p&&g&&!M(s,g)&&(s=g,o=await X(s)),w.throwIfAborted(),t!=="preparing"))return;if(!D(o,s.commerce))return d("unavailable","plan_unavailable");if(!ue(o,s))return;b=c.ownerDocument.createElement("div"),c.append(b);let C=setTimeout(()=>t==="preparing"&&d("unavailable","timeout"),Je);Pe.then(()=>clearTimeout(C));let I=await e(b,Ee,Ve);if(!I.host||w.aborted||t!=="preparing"){I.host?.destroy(),d(w.aborted?"released":"unavailable","error");return}P=I.host,fe()}catch(e){d(w.aborted?"released":"unavailable",ie(e))}finally{oe(null),U(!1)}})(),L.then(async e=>{let r=s=>{Se(null),O(s)};if(!e)return r("gated");let a=e,l=Q(a),i=n.commerce??l;if(!M(l&&{...l,intent:void 0},i&&{...i,intent:void 0})||n.locale!==void 0&&a.locale!==n.locale)return r("start_mismatch");if(!l)return r("commerce_missing");g={commerce:l,locale:a.locale},H=a,p&&["preparing","ready","shown"].includes(t)&&(m=a,q=z(a));try{let s=await Re,f=s==="pending"?"purchase_pending":s==="found"?"original_purchase":s==="blocked"?"purchase_blocked":void 0;if(f)return r(f);if(!["preparing","ready","shown"].includes(t))return;if(n.configuration&&(n.paywallId||n.paywallVersionId)){let o=await we(n.configuration,{funnelId:a.funnelId,customerId:n.client.customerId,parameters:a.parameters??{}});w.throwIfAborted();let C=o.type==="unknown"||o.type==="unavailable"&&o.reason!=="funnel_stopped";if(o.type==="paywall"?p?o.paywallId!==p.resolution.paywallId:n.paywallVersionId?o.paywallVersionId!==n.paywallVersionId:o.paywallId!==n.paywallId:!C)return r(ye(o)??"route_changed")}if(N&&(_=!1,await n.client.retained()==="pending"))return r("purchase_pending");if(await be,le){m=a,q=z(a);return}if(B||n.paywallId||n.paywallVersionId||y){let o=await X(g);if(w.throwIfAborted(),Se(D(o,g.commerce)?{savedAt:Date.now(),funnelId:a.funnelId,context:g,resolution:o}:null),p)ke(o,g);else{if(t!=="preparing")return;if(y){if(!D(o,g.commerce))return d("unavailable","plan_unavailable");if(!ue(o,g))return}}}}catch(s){return w.aborted?d("released","aborted"):O(ie(s))}["preparing","ready","shown"].includes(t)&&(m=a,q=z(a),fe(),_&&K())},()=>O("gated"));let _e={get state(){return t},get reason(){return ge},ready:Pe,local:be,get start(){return m},get prediction(){return T?structuredClone(T):void 0},matches:e=>m?z(e)===q:!!p&&e.funnelId===p.funnelId&&e.locale===p.context.locale,open(){if(t==="preparing")return"pending";if(t!=="ready"||!v)return!1;if(Date.now()-j>=Y)return d("unavailable","expired"),!1;let e=v;return v=null,W(),G("shown"),e(),"shown"},destroy(){me.abort()}};return He.set(_e,{onClose(e){return t==="closed"?(A(e),()=>{}):(J.add(e),()=>{J.delete(e)})},claim(){W()},remember(e){te=!0;let r=structuredClone(e);L.then(()=>{!H||!g||Ie({savedAt:Date.now(),funnelId:H.funnelId,context:g,resolution:r})},()=>{})},withhold(){te=!0,L.then(()=>{H&&Ie({savedAt:Date.now(),funnelId:H.funnelId,presented:"nothing"})},()=>{})},async adopt(e,r){let a=e.paywall?.resolution,l=e.paywall&&!e.paywall.quote&&!e.paywall.operation&&!e.paywall.purchaseRequestId&&!(e.paywall.selectionGeneration??0);if(t!=="shown"||!P||!y||!a||!l||e.source.id!==m?.funnelId||e.locale!==m?.locale||!M(e.parameters??{},m?.parameters??{})||!["running","waiting"].includes(e.status)||!$(a,y))return null;let i;try{i=await r.start()}catch{return null}if(t!=="shown"||!P)return i.destroy(),null;h=i,u.options=r.options,u.handoff=r.handoff;for(let[o]of E)E.set(o,i.subscribe?.(o)??(()=>{})),i.view&&A(o,structuredClone(i.view));w.removeEventListener("abort",Z),G("adopted"),ae(i),J.clear();let s=P,f=b;return P=null,b=null,v=null,new Proxy(s,{get(o,C){return C==="destroy"?()=>{o.destroy(),f?.remove()}:C==="retainPurchaseDialog"?()=>{let I=o.retainPurchaseDialog();if(I)return{dialog:I.dialog,release(){I.release(),f?.remove()}}}:Reflect.get(o,C,o)}})},retainPurchaseDialog(){if(t!=="shown")return;let e=P?.retainPurchaseDialog();if(!e)return;let r=b;return P=null,b=null,d("released"),{dialog:e.dialog,release(){e.release(),r?.remove()}}},get modal(){return y?.document.presentation.type!=="inline"},get revealable(){return t==="ready"&&!!v&&Date.now()-j<Y},release(){d("released")}}),_e}function ze(c,n){let S=n.run.parameters??{},F=S?.commerce;return Ge(c,{client:n.client,start:{funnelId:n.run.source.id,locale:n.run.locale,parameters:S},paywallVersionId:n.paywallVersionId,...F&&{commerce:F},locale:n.run.locale,signal:n.signal},{run:!0})}export{je as a,$e as b,Ge as c,ze as d};
@@ -1 +1 @@
1
- import{b as e}from"./chunk-RTKI4V2J.js";var y=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),z=e.discriminatedUnion("type",[e.object({type:e.literal("fixed"),productVersionId:e.string().min(1).max(200)}).strict(),e.object({type:e.literal("picker"),pickerId:y,allowedProductVersionIds:e.array(e.string().min(1).max(200)).min(1).max(20)}).strict().refine(t=>new Set(t.allowedProductVersionIds).size===t.allowedProductVersionIds.length,"Product choices must be unique")]),x=e.strictObject({min:e.number().finite().min(1).max(1800),max:e.number().finite().min(1).max(1800),viewport:e.number().finite().min(1).max(100)}).refine(t=>t.min<=t.max,"Desktop width range is reversed"),f={desktopWidth:x.optional(),mobile:e.enum(["sheet","fullscreen"]).optional(),backdrop:e.enum(["none","scrim","dim","strong-dim","blur"]).optional()},G=e.discriminatedUnion("type",[e.strictObject({type:e.literal("modal"),position:e.enum(["center","top","bottom"]).optional(),size:e.enum(["sm","md","lg"]),...f}),e.strictObject({type:e.literal("sheet"),size:e.enum(["sm","md","lg"]),...f}),e.strictObject({type:e.literal("fullscreen")}),e.strictObject({type:e.literal("inline")})]),V={sm:360,md:420,lg:560};var c=e.json().superRefine((t,i)=>{let s=0;function o(n,r){if(++s>1e4||r>20){i.addIssue({code:"custom",message:"JSON exceeds its depth or node budget"});return}if(typeof n=="string"&&(n.includes("\0")||/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(n))&&i.addIssue({code:"custom",message:"JSON text must contain valid Unicode without NUL"}),Array.isArray(n))n.forEach(a=>o(a,r+1));else if(n&&typeof n=="object")for(let[a,u]of Object.entries(n))(a.includes("\0")||/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(a)||["__proto__","prototype","constructor"].includes(a))&&i.addIssue({code:"custom",message:"Reserved JSON property"}),o(u,r+1)}o(t,0),new TextEncoder().encode(JSON.stringify(t)).byteLength>65536&&i.addIssue({code:"custom",message:"JSON exceeds 64 KiB"})}),l=e.record(e.string().min(1).max(128),c).superRefine((t,i)=>{(!c.safeParse(t).success||Object.keys(t).length>128||new TextEncoder().encode(JSON.stringify(t)).byteLength>65536||["__proto__","constructor","prototype"].some(s=>Object.hasOwn(t,s)))&&i.addIssue({code:"custom",message:"Attribute document exceeds its budget or uses a reserved key"})}),S=new Set(["$in","$ini","$inGroup","$nin","$nini","$notInGroup","$gt","$gte","$lt","$lte","$regex","$regexi","$ne","$eq","$size","$elemMatch","$all","$alli","$not","$type","$exists","$vgt","$vgte","$vlt","$vlte","$vne","$veq","$and","$or","$nor","$savedGroup"]),d=l.superRefine((t,i)=>{function s(o){if(Array.isArray(o))o.forEach(s);else if(o&&typeof o=="object")for(let[n,r]of Object.entries(o)){if(n==="$savedGroup"&&!e.strictObject({id:e.uuid(),attributeKey:e.string().min(1).max(128).optional()}).safeParse(r).success&&i.addIssue({code:"custom",message:"Saved groups use v2 object references"}),!n.startsWith("$")&&n.split(".").some(a=>["__proto__","prototype","constructor"].includes(a))&&i.addIssue({code:"custom",message:"Reserved attribute path"}),n.startsWith("$")&&!S.has(n)&&i.addIssue({code:"custom",message:`Unknown GrowthBook operator: ${n}`}),["$regex","$regexi"].includes(n)&&typeof r=="string"){(/\(\?[<!=]|\\[0-9]|\\k</.test(r)||[...r.matchAll(/\{(\d+)(?:,(\d*))?\}/g)].some(a=>Number(a[1])>255||Number(a[2]||0)>255)||n==="$regexi"&&/[^\x00-\x7f]/.test(r.replace(/\\u([0-9a-f]{4})/gi,(a,u)=>String.fromCharCode(Number.parseInt(u,16)))))&&i.addIssue({code:"custom",message:"Regex is outside the shared TS/SQL subset"});try{new RegExp(r)}catch{i.addIssue({code:"custom",message:"Invalid regular expression"})}}s(r)}}typeof t.source=="string"&&["all","any","group","parameter","answer","attribute","result"].includes(t.source)&&("operator"in t||"predicates"in t||"groupId"in t)&&i.addIssue({code:"custom",message:"Obsolete condition protocol"}),s(t)}),w=e.discriminatedUnion("type",[e.strictObject({type:e.literal("condition"),condition:d}),e.strictObject({type:e.literal("list"),attributeKey:e.string().min(1).max(128),values:e.array(e.union([e.string(),e.number().finite()])).max(1e5)})]).refine(t=>t.type!=="list"||new TextEncoder().encode(JSON.stringify(t.values)).byteLength<=1048576,"Saved group list exceeds 1 MiB");function $(t){let i=new Set;function s(o){if(Array.isArray(o))o.forEach(s);else if(o&&typeof o=="object")for(let[n,r]of Object.entries(o))n==="$savedGroup"&&r&&typeof r=="object"&&!Array.isArray(r)&&typeof r.id=="string"?i.add(r.id):["$inGroup","$notInGroup"].includes(n)&&typeof r=="string"?i.add(r):["$eq","$ne","$in","$nin","$ini","$nini"].includes(n)||s(r)}return s(t),[...i]}var O=e.record(e.uuid(),w).superRefine((t,i)=>{let s=new Set,o=new Set;function n(r){if(s.has(r)){i.addIssue({code:"custom",message:"Cyclic saved group dependency"});return}if(o.has(r))return;let a=t[r];if(!a){i.addIssue({code:"custom",message:"Missing saved group dependency"});return}s.add(r),a.type==="condition"&&$(a.condition).forEach(n),s.delete(r),o.add(r)}Object.keys(t).forEach(n)}),g=e.tuple([e.number().min(0).max(1),e.number().min(0).max(1)]).refine(([t,i])=>t<=i),h=e.strictObject({attribute:e.string().optional(),seed:e.string().min(1),hashVersion:e.literal(2),ranges:e.array(g).min(1).max(100)}),j=e.strictObject({id:e.string().min(1).max(128),condition:d,gate:e.boolean().optional()}),p={id:e.string().max(128).optional(),condition:d.optional(),parentConditions:e.array(j).max(50).optional(),filters:e.array(h).max(20).optional()},v=e.union([e.strictObject({...p}),e.strictObject({...p,force:c,coverage:e.number().min(0).max(1).optional(),range:g.optional(),seed:e.string().min(1).optional(),hashAttribute:e.string().optional(),hashVersion:e.literal(2).optional()}),e.strictObject({...p,type:e.literal("experiment-ref"),experimentId:e.uuid(),values:e.record(e.string().min(1),c),meta:e.record(e.string().min(1),e.strictObject({passthrough:e.boolean()})).optional()})]),k=e.strictObject({defaultValue:c,rules:e.array(v).max(100)}),U=e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,127}$/),k).superRefine((t,i)=>{Object.keys(t).length>100&&i.addIssue({code:"custom",message:"Too many Features"});let s=new Set,o=new Set;function n(r){if(s.has(r)){i.addIssue({code:"custom",message:`Cyclic Feature dependency: ${r}`});return}if(o.has(r))return;let a=t[r];if(!a){i.addIssue({code:"custom",message:`Unknown prerequisite Feature: ${r}`});return}s.add(r);for(let u of a.rules)for(let m of u.parentConditions??[])n(m.id);s.delete(r),o.add(r)}Object.keys(t).forEach(n)}),F=e.strictObject({name:e.string().max(80),reason:e.string().max(500),dateStarted:e.iso.datetime({offset:!0}),dateEnded:e.iso.datetime({offset:!0}).nullable(),coverage:e.number().min(0).max(1),variationWeights:e.array(e.number().min(0).max(1)).min(2).max(20).refine(t=>Math.abs(t.reduce((i,s)=>i+s,0)-1)<=.01),condition:d,savedGroups:e.array(e.strictObject({match:e.enum(["any","all","none"]),ids:e.array(e.uuid()).min(1)})).max(50),namespace:e.strictObject({id:e.uuid(),ranges:e.array(g).min(1)}).nullable(),seed:e.string().min(1).max(128)}),A=e.strictObject({key:e.string().min(1).max(128),name:e.string().min(1).max(80),hypothesis:e.string().max(2e3),status:e.enum(["draft","running","stopped"]),hashAttribute:e.string().min(1).max(128),fallbackAttribute:e.string().max(128).nullable(),hashVersion:e.literal(2),disableStickyBucketing:e.boolean(),bucketVersion:e.number().int().min(0).max(1e3),minBucketVersion:e.number().int().min(0).max(1e3),variations:e.array(e.strictObject({id:e.string().min(1),key:e.string().min(1),name:e.string().max(80),description:e.string().max(500)})).min(2).max(20),phases:e.array(F).min(1).max(100),releasedVariationId:e.string().nullable(),excludeFromPayload:e.boolean(),statusSchedule:e.strictObject({startAt:e.iso.datetime({offset:!0}).nullable(),stopAt:e.iso.datetime({offset:!0}).nullable(),stopAfter:e.strictObject({value:e.number().int().positive().max(36500),unit:e.enum(["hours","days"])}).nullable().optional()}).nullable()}).superRefine((t,i)=>{(t.minBucketVersion>t.bucketVersion||t.statusSchedule?.stopAt&&t.statusSchedule?.stopAfter||t.phases.some((s,o)=>{if(o===0)return!1;let n=t.phases[o-1];return!n?.dateEnded||Date.parse(s.dateStarted)<Date.parse(n.dateStarted)||Date.parse(n.dateEnded)>Date.parse(s.dateStarted)})||new Set(t.variations.map(s=>s.key)).size!==t.variations.length||new Set(t.variations.map(s=>s.id)).size!==t.variations.length||t.releasedVariationId!==null&&!t.variations.some(s=>s.id===t.releasedVariationId)||t.statusSchedule?.startAt&&t.statusSchedule?.stopAt&&Date.parse(t.statusSchedule.startAt)>=Date.parse(t.statusSchedule.stopAt)||t.phases.some(s=>s.dateEnded&&Date.parse(s.dateStarted)>=Date.parse(s.dateEnded)||s.namespace?.ranges.some(([o,n],r,a)=>o>=n||a.some(([u,m],b)=>b!==r&&o<m&&u<n)))||t.phases.some(s=>s.variationWeights.length!==t.variations.length))&&i.addIssue({code:"custom",message:"Invalid experiment versions, variation keys or weights"})});var I=A.safeExtend({filters:e.array(h).optional()}),D=e.strictObject({experiments:e.record(e.uuid(),I),savedGroups:O}),E=e.strictObject({attributeName:e.string(),attributeValue:e.string(),assignments:e.record(e.string(),e.string())}),M=e.strictObject({snapshot:D,attributes:l,results:l,stickyBucketAssignmentDocs:e.record(e.string(),E)}),W=e.strictObject({variantKey:e.string().nullable(),bucketVersion:e.number().int().min(0),source:e.enum(["unknownFeature","defaultValue","force","override","experiment","prerequisite","cyclicPrerequisite"]),bucket:e.number().min(0).max(1).optional(),stickyBucketUsed:e.boolean().optional(),hashUsed:e.boolean().optional()});export{z as a,G as b,V as c,c as d,l as e,d as f,$ as g,E as h};
1
+ import{b as e}from"./chunk-35JZDDF3.js";var y=e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,63}$/),z=e.discriminatedUnion("type",[e.object({type:e.literal("fixed"),productVersionId:e.string().min(1).max(200)}).strict(),e.object({type:e.literal("picker"),pickerId:y,allowedProductVersionIds:e.array(e.string().min(1).max(200)).min(1).max(20)}).strict().refine(t=>new Set(t.allowedProductVersionIds).size===t.allowedProductVersionIds.length,"Product choices must be unique")]),x=e.strictObject({min:e.number().finite().min(1).max(1800),max:e.number().finite().min(1).max(1800),viewport:e.number().finite().min(1).max(100)}).refine(t=>t.min<=t.max,"Desktop width range is reversed"),f={desktopWidth:x.optional(),mobile:e.enum(["sheet","fullscreen"]).optional(),backdrop:e.enum(["none","scrim","dim","strong-dim","blur"]).optional()},G=e.discriminatedUnion("type",[e.strictObject({type:e.literal("modal"),position:e.enum(["center","top","bottom"]).optional(),size:e.enum(["sm","md","lg"]),...f}),e.strictObject({type:e.literal("sheet"),size:e.enum(["sm","md","lg"]),...f}),e.strictObject({type:e.literal("fullscreen")}),e.strictObject({type:e.literal("inline")})]),V={sm:360,md:420,lg:560};var c=e.json().superRefine((t,i)=>{let s=0;function o(n,r){if(++s>1e4||r>20){i.addIssue({code:"custom",message:"JSON exceeds its depth or node budget"});return}if(typeof n=="string"&&(n.includes("\0")||/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(n))&&i.addIssue({code:"custom",message:"JSON text must contain valid Unicode without NUL"}),Array.isArray(n))n.forEach(a=>o(a,r+1));else if(n&&typeof n=="object")for(let[a,u]of Object.entries(n))(a.includes("\0")||/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u.test(a)||["__proto__","prototype","constructor"].includes(a))&&i.addIssue({code:"custom",message:"Reserved JSON property"}),o(u,r+1)}o(t,0),new TextEncoder().encode(JSON.stringify(t)).byteLength>65536&&i.addIssue({code:"custom",message:"JSON exceeds 64 KiB"})}),l=e.record(e.string().min(1).max(128),c).superRefine((t,i)=>{(!c.safeParse(t).success||Object.keys(t).length>128||new TextEncoder().encode(JSON.stringify(t)).byteLength>65536||["__proto__","constructor","prototype"].some(s=>Object.hasOwn(t,s)))&&i.addIssue({code:"custom",message:"Attribute document exceeds its budget or uses a reserved key"})}),S=new Set(["$in","$ini","$inGroup","$nin","$nini","$notInGroup","$gt","$gte","$lt","$lte","$regex","$regexi","$ne","$eq","$size","$elemMatch","$all","$alli","$not","$type","$exists","$vgt","$vgte","$vlt","$vlte","$vne","$veq","$and","$or","$nor","$savedGroup"]),d=l.superRefine((t,i)=>{function s(o){if(Array.isArray(o))o.forEach(s);else if(o&&typeof o=="object")for(let[n,r]of Object.entries(o)){if(n==="$savedGroup"&&!e.strictObject({id:e.uuid(),attributeKey:e.string().min(1).max(128).optional()}).safeParse(r).success&&i.addIssue({code:"custom",message:"Saved groups use v2 object references"}),!n.startsWith("$")&&n.split(".").some(a=>["__proto__","prototype","constructor"].includes(a))&&i.addIssue({code:"custom",message:"Reserved attribute path"}),n.startsWith("$")&&!S.has(n)&&i.addIssue({code:"custom",message:`Unknown GrowthBook operator: ${n}`}),["$regex","$regexi"].includes(n)&&typeof r=="string"){(/\(\?[<!=]|\\[0-9]|\\k</.test(r)||[...r.matchAll(/\{(\d+)(?:,(\d*))?\}/g)].some(a=>Number(a[1])>255||Number(a[2]||0)>255)||n==="$regexi"&&/[^\x00-\x7f]/.test(r.replace(/\\u([0-9a-f]{4})/gi,(a,u)=>String.fromCharCode(Number.parseInt(u,16)))))&&i.addIssue({code:"custom",message:"Regex is outside the shared TS/SQL subset"});try{new RegExp(r)}catch{i.addIssue({code:"custom",message:"Invalid regular expression"})}}s(r)}}typeof t.source=="string"&&["all","any","group","parameter","answer","attribute","result"].includes(t.source)&&("operator"in t||"predicates"in t||"groupId"in t)&&i.addIssue({code:"custom",message:"Obsolete condition protocol"}),s(t)}),w=e.discriminatedUnion("type",[e.strictObject({type:e.literal("condition"),condition:d}),e.strictObject({type:e.literal("list"),attributeKey:e.string().min(1).max(128),values:e.array(e.union([e.string(),e.number().finite()])).max(1e5)})]).refine(t=>t.type!=="list"||new TextEncoder().encode(JSON.stringify(t.values)).byteLength<=1048576,"Saved group list exceeds 1 MiB");function $(t){let i=new Set;function s(o){if(Array.isArray(o))o.forEach(s);else if(o&&typeof o=="object")for(let[n,r]of Object.entries(o))n==="$savedGroup"&&r&&typeof r=="object"&&!Array.isArray(r)&&typeof r.id=="string"?i.add(r.id):["$inGroup","$notInGroup"].includes(n)&&typeof r=="string"?i.add(r):["$eq","$ne","$in","$nin","$ini","$nini"].includes(n)||s(r)}return s(t),[...i]}var O=e.record(e.uuid(),w).superRefine((t,i)=>{let s=new Set,o=new Set;function n(r){if(s.has(r)){i.addIssue({code:"custom",message:"Cyclic saved group dependency"});return}if(o.has(r))return;let a=t[r];if(!a){i.addIssue({code:"custom",message:"Missing saved group dependency"});return}s.add(r),a.type==="condition"&&$(a.condition).forEach(n),s.delete(r),o.add(r)}Object.keys(t).forEach(n)}),g=e.tuple([e.number().min(0).max(1),e.number().min(0).max(1)]).refine(([t,i])=>t<=i),h=e.strictObject({attribute:e.string().optional(),seed:e.string().min(1),hashVersion:e.literal(2),ranges:e.array(g).min(1).max(100)}),j=e.strictObject({id:e.string().min(1).max(128),condition:d,gate:e.boolean().optional()}),p={id:e.string().max(128).optional(),condition:d.optional(),parentConditions:e.array(j).max(50).optional(),filters:e.array(h).max(20).optional()},v=e.union([e.strictObject({...p}),e.strictObject({...p,force:c,coverage:e.number().min(0).max(1).optional(),range:g.optional(),seed:e.string().min(1).optional(),hashAttribute:e.string().optional(),hashVersion:e.literal(2).optional()}),e.strictObject({...p,type:e.literal("experiment-ref"),experimentId:e.uuid(),values:e.record(e.string().min(1),c),meta:e.record(e.string().min(1),e.strictObject({passthrough:e.boolean()})).optional()})]),k=e.strictObject({defaultValue:c,rules:e.array(v).max(100)}),U=e.record(e.string().regex(/^[a-zA-Z][a-zA-Z0-9_.-]{0,127}$/),k).superRefine((t,i)=>{Object.keys(t).length>100&&i.addIssue({code:"custom",message:"Too many Features"});let s=new Set,o=new Set;function n(r){if(s.has(r)){i.addIssue({code:"custom",message:`Cyclic Feature dependency: ${r}`});return}if(o.has(r))return;let a=t[r];if(!a){i.addIssue({code:"custom",message:`Unknown prerequisite Feature: ${r}`});return}s.add(r);for(let u of a.rules)for(let m of u.parentConditions??[])n(m.id);s.delete(r),o.add(r)}Object.keys(t).forEach(n)}),F=e.strictObject({name:e.string().max(80),reason:e.string().max(500),dateStarted:e.iso.datetime({offset:!0}),dateEnded:e.iso.datetime({offset:!0}).nullable(),coverage:e.number().min(0).max(1),variationWeights:e.array(e.number().min(0).max(1)).min(2).max(20).refine(t=>Math.abs(t.reduce((i,s)=>i+s,0)-1)<=.01),condition:d,savedGroups:e.array(e.strictObject({match:e.enum(["any","all","none"]),ids:e.array(e.uuid()).min(1)})).max(50),namespace:e.strictObject({id:e.uuid(),ranges:e.array(g).min(1)}).nullable(),seed:e.string().min(1).max(128)}),A=e.strictObject({key:e.string().min(1).max(128),name:e.string().min(1).max(80),hypothesis:e.string().max(2e3),status:e.enum(["draft","running","stopped"]),hashAttribute:e.string().min(1).max(128),fallbackAttribute:e.string().max(128).nullable(),hashVersion:e.literal(2),disableStickyBucketing:e.boolean(),bucketVersion:e.number().int().min(0).max(1e3),minBucketVersion:e.number().int().min(0).max(1e3),variations:e.array(e.strictObject({id:e.string().min(1),key:e.string().min(1),name:e.string().max(80),description:e.string().max(500)})).min(2).max(20),phases:e.array(F).min(1).max(100),releasedVariationId:e.string().nullable(),excludeFromPayload:e.boolean(),statusSchedule:e.strictObject({startAt:e.iso.datetime({offset:!0}).nullable(),stopAt:e.iso.datetime({offset:!0}).nullable(),stopAfter:e.strictObject({value:e.number().int().positive().max(36500),unit:e.enum(["hours","days"])}).nullable().optional()}).nullable()}).superRefine((t,i)=>{(t.minBucketVersion>t.bucketVersion||t.statusSchedule?.stopAt&&t.statusSchedule?.stopAfter||t.phases.some((s,o)=>{if(o===0)return!1;let n=t.phases[o-1];return!n?.dateEnded||Date.parse(s.dateStarted)<Date.parse(n.dateStarted)||Date.parse(n.dateEnded)>Date.parse(s.dateStarted)})||new Set(t.variations.map(s=>s.key)).size!==t.variations.length||new Set(t.variations.map(s=>s.id)).size!==t.variations.length||t.releasedVariationId!==null&&!t.variations.some(s=>s.id===t.releasedVariationId)||t.statusSchedule?.startAt&&t.statusSchedule?.stopAt&&Date.parse(t.statusSchedule.startAt)>=Date.parse(t.statusSchedule.stopAt)||t.phases.some(s=>s.dateEnded&&Date.parse(s.dateStarted)>=Date.parse(s.dateEnded)||s.namespace?.ranges.some(([o,n],r,a)=>o>=n||a.some(([u,m],b)=>b!==r&&o<m&&u<n)))||t.phases.some(s=>s.variationWeights.length!==t.variations.length))&&i.addIssue({code:"custom",message:"Invalid experiment versions, variation keys or weights"})});var I=A.safeExtend({filters:e.array(h).optional()}),D=e.strictObject({experiments:e.record(e.uuid(),I),savedGroups:O}),E=e.strictObject({attributeName:e.string(),attributeValue:e.string(),assignments:e.record(e.string(),e.string())}),M=e.strictObject({snapshot:D,attributes:l,results:l,stickyBucketAssignmentDocs:e.record(e.string(),E)}),W=e.strictObject({variantKey:e.string().nullable(),bucketVersion:e.number().int().min(0),source:e.enum(["unknownFeature","defaultValue","force","override","experiment","prerequisite","cyclicPrerequisite"]),bucket:e.number().min(0).max(1).optional(),stickyBucketUsed:e.boolean().optional(),hashUsed:e.boolean().optional()});export{z as a,G as b,V as c,c as d,l as e,d as f,$ as g,E as h};
@@ -1 +1 @@
1
- import{a as kn,c as Rn,d as Ut,f as Lt,g as An,k as Sn}from"./chunk-2DAYQCEC.js";import{a as wn,b as Ye}from"./chunk-W32FI2A2.js";import{e as bn,f as Cn,g as Pn,h as vn,j as _t,k as ot,l as In,m as En,n as xn}from"./chunk-3TKVWOFW.js";import{a as hn,c as Ot,d as mn,e as yn}from"./chunk-QPCIIQ6Q.js";import{a as at,b as oe,d as Nt,f as Dt,j as gn}from"./chunk-FXRBRAJR.js";import{b as Ee}from"./chunk-JLDKGCU2.js";import{B as _,C as it,D as Ge,E as _e,y as fn}from"./chunk-WO6BLOJI.js";import{r as Ue,t as Le}from"./chunk-5MX7OICH.js";import{i as pn}from"./chunk-2UB5RFXZ.js";import{c as be,j as We}from"./chunk-5HDJT7E5.js";import{c as Tt}from"./chunk-MYYLRNLZ.js";import{a as k}from"./chunk-EHWMZCNT.js";import{a as z}from"./chunk-DSPLGTQI.js";async function Tn(H,a,x){if(!Ge(a))throw new k("INVALID_RESPONSE","A verified completed purchase is required");let T=H?We.parse(H):null;if(await x.onComplete?.(a),!T||!x.check)return;let F=We.parse(await x.check());if(F.internal_feature_id!==T.internal_feature_id||F.quantity!==T.quantity||T.observation!==void 0&&(F.observation===void 0||F.observation.requirementDigest!==T.observation.requirementDigest||F.observation.authority!==T.observation.authority||Tt(F.observation.subject)!==Tt(T.observation.subject)))throw new k("INVALID_RESPONSE","The access requirement changed");F.allowed&&await x.onAccessGranted?.(F)}function On(H){return Object.entries(H.document.buttons).filter(([,a])=>a.type==="checkout"&&a.product.type==="fixed"&&!Ee(a.product,{},H.capabilities)).map(([a])=>a)}function Nn(H,a){let x=_(a)?void 0:a.lines[0];if(!_(a)&&(a.lines.length!==1||!x))return;let T=_(a)?a.productVersionId:x.productVersionId,{screen:F,buttons:se}=H.document,M=new Map(_(a)?Object.entries(a.featureQuantities??{}):(x?.prepaid??[]).map(b=>[b.internal_feature_id,b.quantity]));function le(b,u){if(b.hidden)return!1;if(b.type==="plan_picker"&&H.capabilities.pickers[b.id]?.options.includes(T))return u[b.id]=T,!0;if(b.type==="quantity_picker"){let ne=M.get(b.internalFeatureId);return ne!==void 0&&(!b.bind?.plan||b.bind.plan===T)&&(u[b.id]=ne),!1}if(b.type==="button"&&b.action){let ne=se[b.action];return ne?.type==="checkout"&&ne.product.type==="fixed"&&ne.product.productVersionId===T}if(b.type!=="stack")return!1;let te=b.interaction,i=b.bind?.plan===T;for(let[ne,p]of b.children.entries()){let Z={},U=le(p,Z);if(te?.type==="toggle"||te?.type==="tabs"){if(!U)continue;return u[b.id]=te.type==="toggle"?ne===0:p.id,Object.assign(u,Z),!0}Object.assign(u,Z),U&&(i=!0,te?.type==="select"&&te.purpose==="product"&&te.pickerId&&p.type==="stack"&&p.bind?.plan===T&&(u[b.id]=p.id,u[te.pickerId]=T))}return i}for(let b of F.pages){let u={__page:b.id};if(le(b.root,u))return u}}var Bn="position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0";async function Pr(H,a,x){let T=a.focusAtReveal?()=>{}:_t(H.ownerDocument),F=()=>{M.finish("dismissed"),T()},se=()=>F(),M=In(H,a,"paywall",()=>{F(),z(a.onDismiss)},kn);a.signal?.throwIfAborted(),a.signal?.addEventListener("abort",se,{once:!0});let le=null,b,u,te;try{if(M.start(!0,a.loadingDocument?.screen.strings.defaultLocale,a.loadingDocument??null),M.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(le=a.check?We.parse(await M.wait(a.check(),ot)):null,le?.allowed)return M.finish("skipped"),a.signal?.removeEventListener("abort",se),T(),await a.onAccessGranted?.(le),{check:le,host:null};let[e,t]=await Promise.allSettled([M.wait(import("./screen-renderer-4X5MLXGZ.js")),M.wait(a.start().then(r=>(M.cancelled&&r.destroy(),r)),ot)]);if(e.status==="rejected")throw t.status==="fulfilled"&&t.value.destroy(),e.reason;if(t.status==="rejected")throw t.reason;te=e.value,b=t.value,a.signal?.throwIfAborted(),b.signal?.throwIfAborted(),b.signal?.addEventListener("abort",se,{once:!0});let n=b.view??await M.wait(b.refresh(),ot);if(!n)throw new k("INVALID_RESPONSE","Paywall presentation is missing");b.signal?.throwIfAborted(),u=n}catch(e){throw M.finish("error",e),x?.retainedDialog?.release(),a.signal?.removeEventListener("abort",se),b?.signal?.removeEventListener("abort",se),b?.destroy(),T(),e}let i=b,{mountScreenPreview:ne}=te,p=H.ownerDocument,Z=new AbortController,U=p.createElement("section"),pe=p.createElement("div"),W=p.createElement("div"),st=a.mountControls,ee=st?p.createElement("div"):void 0,d=p.createElement("p"),y=p.createElement("button"),ce=p.createElement("button"),O=p.createElement("button");(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&x?.hostPaywallTarget&&!x.retainedDialog&&u.document.presentation.type==="modal"&&(x.retainedDialog=vn(x.hostPaywallTarget));let ue=x?.retainedDialog,A=ue?.dialog??p.createElement("dialog"),Me=ue&&u.document.presentation.type==="inline"?{type:"modal",size:"md"}:u.document.presentation,re=Me.type==="inline"?W:p.createElement("div"),lt=i.locale||u.document.screen.strings.defaultLocale,o=lt.toLowerCase().startsWith("zh"),Dn=o?"正在处理…":"Processing…",_n=o?"正在准备报价…":"Preparing your price…",D=Rn(u.document.screen.theme);U.dataset.indianaPaywall="",U.setAttribute("aria-label",u.document.name),U.style.cssText=D.root,W.style.cssText=D.controls,d.style.cssText=D.message,d.setAttribute("role","status"),O.style.cssText=D.link,O.textContent=o?"关闭":"Close",y.style.cssText=D.secondary,y.textContent=o?"重试":"Retry",y.hidden=!0,ce.type="button",ce.style.cssText=D.primary,ce.textContent=o?"继续付款":"Continue payment",ce.hidden=!0,re.append(d,ce,y),W.append(O),ee&&(ee.style.cssText="flex:1 0 100%;min-width:0",ee.hidden=!0,W.prepend(ee)),re!==W&&(re.dataset.indianaPaywallStatus="",re.style.cssText="display:none;padding:0",U.append(re)),U.append(pe,W);let ct=()=>{let e=Mn();d.style.cssText=e?`${D.message};${Bn}`:D.message,zt();let t=c=>!c.hidden&&(c!==d||!!d.textContent&&!e);if(re!==W&&(re.style.cssText=!ie&&[...re.children].some(t)?`${D.controls};padding:12px 64px 12px 20px;flex-shrink:0`:e?"padding:0":"display:none;padding:0"),ee){let c=!ee.childElementCount&&!ee.textContent?.trim();ee.hidden!==c&&(ee.hidden=c)}let n=me??W,r=![...n.children].some(t),s=[...n.children].some(c=>c!==O&&t(c));n.style.cssText=r?D.controls.replace(/padding:[^;]+/,"padding:0"):s?`${D.controls};${D.pinned}`:D.controls,dt()},Mt=typeof MutationObserver>"u"?void 0:new MutationObserver(ct);Mt?.observe(U,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let Un=Object.entries(u.document.buttons).filter(([,e])=>e.type==="close").map(([e])=>e),N,Vt,Ve=!1,$t=JSON.stringify(u.capabilities),Q;function Ce(e){let t=On(e);if(Q||fe&&!ae||B&&(C||!Pe()||ge))return Ae(e).map(({actionId:r})=>r);if(bt()||!C&&Pe())return t;let n=C?wt(e):Ct(e);return[...new Set([...t,...Ae(e).map(({actionId:r})=>r).filter(r=>!n.includes(r))])]}function $e(e){if(w)return;let t=u.id!==e.id;u=e;let n=JSON.stringify(e.capabilities);if(t||n!==$t){let r=!v&&!i.quote&&!i.operation?at(e,K,Bt):K;t||JSON.stringify(r)!==JSON.stringify(K)?(K=r,N?.update(e.document.screen,lt,{capabilities:oe(e),unavailableActions:Ce(e),serverInput:{bindings:[],answers:{}},selection:K})):N?.updateCapabilities(oe(e),Ce(e)),$t=n}Vn(e),ve(),Xe()}let L,ut=0;function Ht(){return(me??W).getBoundingClientRect().height+(re===W?0:re.getBoundingClientRect().height)}function dt(){let e=p.defaultView;if(!L?.responsive||!e)return;let t=me??W,n=e.innerHeight-(L.type==="modal"?32:0);t.style.maxHeight=`${Math.max(1,n)}px`,t.style.overflowY="auto",t.style.flexShrink="0",ut=Math.max(1,n-Ht()),N?.resizeViewport?.(ut,e.innerWidth)}let w=!1,fe=!1,v=null,pt,ze=!1,Qt=!1,he=!1,ft,ht=!1,ie,me;function Ln(){return fe||w||ie||ht?{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null}:Ot(i)}let I=()=>!w&&!ze&&!ie&&a.canInteract?.()!==!1,J,xe=!1,Re=!1,mt,f=null,de=null,Ke="",ye=()=>a.checkoutNavigation==="after_confirmation"&&!!(a.terminateCheckout||a.resumeCheckout),K={},Bt=new Set,ae,C;function yt(e){return!!e&&_(e)&&e.timing==="immediate"&&e.execution.provider==="merchant"}let gt=o?"正在确认付款…":"Confirming payment…",B=null,ge,Je,jt=!1,Pe=()=>a.allowNewPurchase!==!1||jt;function qt(){return JSON.stringify([u.id,u.capabilities])}function Ft(){let e=mt;return e&&e.read===a.prepareSubscriptionChange&&e.basis===qt()?e:void 0}function Xe(){let e=a.prepareSubscriptionChange;if(!e||!he||!I()||!Pe()||a.onPurchaseIntent||p.visibilityState==="hidden"||v||i.quote||i.operation||!Ae(u).length||Ft())return;let t=Z.signal,n=new Promise(r=>{let s=()=>r(void 0);t.addEventListener("abort",s,{once:!0}),Promise.resolve().then(()=>(t.throwIfAborted(),e(t))).then(c=>r(t.aborted?void 0:c),s).finally(()=>t.removeEventListener("abort",s))});mt={read:e,basis:qt(),result:n}}let Wt=()=>{p.visibilityState==="hidden"?mt=void 0:Xe()};p.addEventListener("visibilitychange",Wt);function Ae(e){return Object.entries(e.document.buttons).flatMap(([t,n])=>n.type==="checkout"?[{actionId:t,policy:n}]:[])}function Gt(e){let t=C?.quote;return t?Ae(e).filter(({actionId:n,policy:r})=>Se(t,e,n,r.product,K)).map(({actionId:n})=>n):[]}function wt(e){return C?.phase==="payment"?Gt(e):[]}function bt(){return(C?C.phase==="payment":!Pe())&&(Pe()||!!a.prepareUpgradeReplacement)&&ye()&&!!a.terminateCheckout&&!!i.quote&&i.canReselect===!1&&!!i.operation&&R(i.operation).type==="checkout"}function Ct(e){let t=i.quote;return!ye()||B||!t||!i.operation||R(i.operation).type!=="checkout"?[]:Ae(e).filter(({actionId:n,policy:r})=>Se(t,e,n,r.product,K)).map(({actionId:n})=>n)}function ve(){let e=Q?[]:C?wt(u):Ct(u),t=a.allowNewPurchase===!1&&!!i.operation&&R(i.operation).type==="checkout";ce.hidden=!!Q||(C?C.phase!=="payment":!t)||e.length>0,zt(e)}function Yt(){if(!(ae===void 0||Q))return d.textContent?d.textContent:C?.phase==="checking"?gt:void 0}function Mn(){return!!N?.updateCheckoutControls&&!!d.textContent&&Yt()!==void 0}let Ze;function zt(e=Q?[]:C?wt(u):Ct(u)){if(!N?.updateCheckoutControls)return;let t=Yt(),n=ye()||!!C;if(!t&&!n&&Ze?.on!==N)return;let r={actions:Ae(u).map(({actionId:c})=>c),resume:t?[ae]:n?e:[],resumeLabel:t??(o?"继续付款":C?"Continue payment":"Continue checkout"),busy:ae},s=JSON.stringify(r);Ze?.on===N&&Ze.key===s||(Ze={on:N,key:s},N.updateCheckoutControls(r))}function Kt(){de?.remove(),de=null}async function et(){if(B)return;if(a.resumeCheckout&&i.operation){let t=i.operation.operationId;try{await a.resumeCheckout(t)}catch(n){if(!(n instanceof k&&n.code==="PURCHASE_PENDING"))throw n;let r=await i.read();if(!I())return;if(r.operationId!==t||R(r).type==="checkout")throw n;await V(r,!1)}return}let e=await i.read();if(R(e).type!=="checkout")return V(e,!1);I()&&(He.delete(e.operationId),await Qe(e))}function Pt(){ge?.destroy(),ge=void 0,Je=void 0}function Jt(){let e=B;if(!e||ge)return;let t=o?"仍在核对原订单,暂时无法更换套餐。":"We’re still checking the original purchase before changing plans.",n=Date.now()+6e5,r=wn({document:p,delay:()=>Date.now()<n?5e3:void 0,async run(){if(!I())return;let s=await i.read();if(ge!==r||!I())return;if(s.operationId!==e.operationId)throw new k("PURCHASE_PENDING","The original Checkout changed");let c=R(s);c.type==="native"?(Pt(),d.textContent=o?"原订单已关闭。你可以继续更换套餐。":"The original checkout is closed. You can continue changing plans.",y.textContent=o?"继续更换套餐":"Continue changing plans",f=()=>tt(),y.hidden=!1):(c.type==="complete"||c.type==="fulfillment"||c.type==="recording")&&(Pt(),B=null,y.hidden=!0,await V(s,!1))}});ge=r,Je=async()=>{try{await r.refresh()}finally{ge===r&&(d.textContent=t,y.hidden=!1)}},f=Je,y.textContent=o?"查询结果":"Check result",y.hidden=!1,d.textContent=t,r.schedule()}async function tt(e=!1){let t=B;if(!t)return;f=()=>tt(),C&&(y.textContent=o?"查询状态":"Check status"),y.hidden=!0;let n=Date.now()+2e4;for(;I();){let r=await i.read();if(r.operationId!==t.operationId)throw new k("PURCHASE_PENDING","The original Checkout changed");if(!I())break;let s=R(r);if(s.type==="native"){if(!Pe()&&a.prepareUpgradeReplacement){let c=await a.prepareUpgradeReplacement(t.operationId,t.intent);if(!I())return;jt=!0,$e(c)}B=null,C&&Te(C.quote),Kt(),v=t.selection,J=t.coupon,xe=!1,Re=!1,await qe();return}if(s.type==="complete"||s.type==="fulfillment"||s.type==="recording"){B=null,C?await ke(C.quote,r):await V(r,!1);return}if(e&&s.type==="checkout"){e=!1;try{await a.terminateCheckout(t.operationId)}catch(c){z(a.onError,c)}}if(Date.now()>=n){C&&s.type==="checkout"&&(B=null,await ke(C.quote,r));break}await Ye(1e3,p,Z.signal)}!B||w||(C?(d.textContent=o?"仍在核对原升级单,暂时无法更换套餐。":"We’re still checking the original upgrade before changing plans.",y.hidden=!1):Jt())}async function Xt(e,t,n,r){if(f=()=>Xt(e,t,n,r),await a.beforeCheckoutReplacement?.(structuredClone(r)),!I())return;let s=i.operation;if(s?.operationId!==e||R(s).type!=="checkout"){f=null,s&&await V(s,!1);return}B={operationId:e,selection:t,coupon:n,intent:r},C&&(d.textContent=o?"正在切换套餐…":"Changing plan…",y.hidden=!0);let c=!1;try{await a.terminateCheckout(e)}catch(l){if(l instanceof k&&["CAPABILITY_UNAVAILABLE","NOT_CONFIGURED"].includes(l.code)){B=null,C&&(f=It,y.textContent=o?"查询状态":"Check status",y.hidden=!1),d.textContent=o?"请继续原订单,或等待它过期后再更换方案。":"Continue your original checkout, or wait for it to expire before changing plans.",z(a.onError,l);return}c=l instanceof k&&(l.status??0)>=500,z(a.onError,l)}I()&&await tt(c)}function vt(e,t,n,r,s){let c=oe(e).checkoutCoupons?.[t],l=c?c.products[n]:a.claimCoupon&&s?pn(e.capabilities,s,r):void 0;return l?.couponId&&l.planVersionId===n?{id:l.couponId,offerId:l.offerId}:void 0}function Vn(e){fe||v||i.quote||i.operation||Ke&&d.textContent===Ke||(d.textContent=Object.values(e.capabilities.plans).some(t=>t.available)?"":o?"当前账号暂无可购买的方案。":"No plans are currently available for this account.")}let He=new Map,nt=!1;function Se(e,t,n,r,s,c){let l=_(e),m=!l&&e.lines.length===1?e.lines[0]:void 0,h=Ee(r,s,t.capabilities);if(!h||h!==(l?e.productVersionId:m?.productVersionId))return!1;let E=vt(t,n,h,s,c),q;try{q=Le(t.document.screen,h,s,t.capabilities)}catch{return!1}if(l){let X=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0);return Object.keys(q).length===Object.keys(e.featureQuantities??{}).length&&Object.entries(q).every(([De,St])=>e.featureQuantities?.[De]===St)&&(!E||X?.couponId===E.id&&(!E.offerId||X.grantId===E.offerId))}if((E||oe(t).checkoutCoupons?.[n])&&(E?.id??null)!==(e.discount?.couponId??null))return!1;let G=Object.fromEntries((m?.prepaid??[]).map(X=>[X.internal_feature_id,X.quantity]));return[...new Set([...Object.keys(q),...Object.keys(G)])].every(X=>(q[X]??0)===(G[X]??0))}let R=e=>hn({quote:i.quote,operation:e,requestId:null,pending:!1,destroyed:w,canReselect:i.canReselect});async function Qe(e){let t=e.merchantExecution,n=R(e),r=n.type==="checkout"?n.checkoutUrl:e.checkoutUrl;if(!(!I()||!r||it(e)&&n.type!=="checkout"||a.checkoutNavigation==="after_confirmation"&&n.type!=="checkout"||t?.type==="purchase"&&!["not_started","pending"].includes(t.paymentStatus)||He.get(e.operationId)===r)){He.set(e.operationId,r);try{a.onCheckoutUrl?await a.onCheckoutUrl(r):p.defaultView?.location.assign(r)}catch(s){throw He.delete(e.operationId),s}}}let we=(e,t=!1)=>{if(e instanceof Nt)f=null,d.textContent=e.customerMessage(o);else if(An(e))f=null,d.textContent=t?o?"当前无法在此购买,付款尚未开始。请联系商户。":"Purchases aren’t available here right now. Payment hasn’t started. Contact the merchant for help.":Lt(e,o);else if(t){let n=e instanceof k?e.code:void 0;n==="CAPABILITY_UNAVAILABLE"||n==="NOT_CONFIGURED"?(f=null,d.textContent=o?"暂时无法为此套餐报价,付款尚未开始。":"Pricing for this plan is unavailable. Payment hasn’t started."):i.canReselect===!0&&!v?d.textContent=o?"未能取得报价,付款尚未开始。请重新选择套餐。":"We couldn’t prepare your price. Payment hasn’t started. Choose a plan again.":n==="COMMAND_PENDING"?d.textContent=o?"仍在准备报价,请重试以查看结果。":"Your price is still being prepared. Retry to check the result.":d.textContent=o?"未能取得报价,付款尚未开始。请重试。":"We couldn’t prepare your price. Payment hasn’t started. Try again."}else d.textContent=e instanceof k&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?Lt(e,o):e instanceof k?e.message:o?"操作未完成,请重试。":"This action couldn’t be completed. Try again.";y.hidden=f===null,Ke=d.textContent,t&&ae===void 0&&!L?.responsive&&d.scrollIntoView?.({block:"nearest"}),z(t&&x?.quoteError?x.quoteError:a.onError,e)},Be=new WeakMap;function je(e){fe=e,y.disabled=e,ce.disabled=e,N?.updateCapabilities?.(oe(u),Ce(u));for(let t of de?.querySelectorAll("button")??[])e?(Be.has(t)||Be.set(t,t.disabled),t.disabled=!0):Be.has(t)&&(t.disabled=Be.get(t),Be.delete(t)),Ut(t)}function Zt(){Q&&(d.textContent=Q.message,y.textContent=o?"重试":"Retry",y.disabled=!1,y.hidden=!Q.retry,ce.disabled=!0)}function kt(){d.textContent=o?"暂时无法操作,请稍后重试。":"This action is unavailable right now. Try again in a moment."}async function $n(e){if(a.beforeAction)try{await a.beforeAction()}catch(t){throw t instanceof Nt?(v=null,xe=!1,Re=!1,f=null):f=e,t}}async function j(e,t){if(fe||w||Q)return;if(!I()){kt();return}let n=e===qe,r=n?_n:Dn;ae=t!==void 0&&N?.updateCheckoutControls?t:void 0,d.textContent=r,je(!0),ve(),y.hidden=!0;try{if(e!==on&&e!==It&&e!==Et&&e!==Je&&(e!==et||!a.resumeCheckout)&&await $n(e),w||Q)return;if(!I()){f=e,y.hidden=!1,kt();return}await e()}catch(s){w||we(s,n)}finally{ae=void 0,je(!1),ve(),Q?Zt():d.textContent===r&&(d.textContent="")}}async function en(e){await Tn(le,e,a)}function Te(e,t){C=t?{quote:e,phase:t}:void 0,t==="checking"?(ae??=v?.actionId??Gt(u)[0],d.textContent=gt,f=It,y.textContent=o?"查询状态":"Check status",y.hidden=!0):ae=void 0,N?.updateCapabilities(oe(u),Ce(u)),ve()}function tn(e){return e instanceof k&&(e.code==="COMMAND_PENDING"||e.reason==="RESULT_UNKNOWN"||e.code==="NETWORK_ERROR"||e.code==="TIMEOUT"||e.status===429||(e.status??0)>=500)}function nn(e,t){Dt(e,{...t,featureQuantities:t.featureQuantities??{}},"Purchase operation changed")}async function It(){C&&await ke(C.quote)}async function ke(e,t){Te(e,"checking"),Ke="";let n=1e3;Ve=!0,z(a.onObservationChange,!0);try{for(let r=t;I();r=void 0){if(!r){try{r=await i.read()}catch(s){if(!tn(s))throw s}if(!I())return}if(r){nn(r,e);let s=R(r);if(s.type==="checkout"){Te(e,"payment"),d.textContent=o?"请先完成原订单的付款。":"Finish paying for this upgrade.",y.hidden=!1;return}if(s.type==="complete"){Te(e,"complete"),f=null;let c=u.capabilities.plans[e.productVersionId]?.name,l=e.merchantTerms?.subscriptionTerms?.items,m=l?.length===1?l[0].interval:void 0,h=m==="year"?o?"年付":"annual billing":m==="month"?o?"月付":"monthly billing":null;d.textContent=c?o?`已升级到 ${c}${h?" "+h:""}。`:`Upgraded to ${c}${h?" ("+h+")":""}.`:o?"已成功升级。":"Plan upgraded.",await en(r);return}if(s.type==="native"&&!_e(r)){Te(e),v=null,f=null,d.textContent=o?"付款没有成功,套餐未变更。请检查付款方式后重新选择套餐。":"Your payment didn’t go through, so your plan is unchanged. Check your payment method, then choose a plan again.",y.textContent=o?"重试":"Retry";return}if(r.problem&&!["RESULT_UNKNOWN","STATE_CHANGED"].includes(r.problem.reason??""))throw new k(r.problem.code,o?"暂时无法完成升级。":"The upgrade needs attention.",void 0,void 0,r.problem)}await Ye(n,p,Z.signal),n=Math.min(n*1.5,15e3)}}finally{Ve=!1,z(a.onObservationChange,!1)}}async function Et(){let e=C?.quote;if(!e)return;let t=await i.read();if(nn(t,e),R(t).type!=="checkout")return ke(e,t);if(a.resumeCheckout){await a.resumeCheckout(t.operationId);return}He.delete(t.operationId),await Qe(t)}function rn(e){return Ot(i).type==="recording"||R(e).type==="recording"}function an(e){let t=e.merchantTerms,n=t?.subscriptionTerms?.items??[],r=t?t.totalMinor:_(e)?e.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),s=t?n.length===1&&n[0]?.amountMinor===r&&n[0]:!_(e)&&e.lines.length===1&&e.lines[0]?.catalogAmountMinor===r&&e.lines[0],c=r===null?be(t.subtotalMinor-t.discountMinor,e.currency)+(o?" + 待确认税费":" + tax confirmed at checkout"):be(r,e.currency)+(s?Ue(s.interval,o?"zh-CN":"en",s.intervalCount??1):""),l=_(e)?i.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(m=>m.productName).join(", ");return{label:l?`${l} · ${c}`:c,recurring:s}}async function V(e,t=a.checkoutNavigation!=="after_confirmation"){if(w)return;if(!I()){f=async()=>V(await i.read()),y.hidden=!1;return}let n=e.quote??i.quote;if(yt(n)&&(e.confirmedAt||e.merchantExecution))return ke(n,e);if(d.textContent=Sn(e.status,o),rn(e)){let h=e.merchantExecution?.recordingStatus==="failed";d.textContent=h?o?"付款和商户处理已完成,但交易记录失败。请联系商户修复,勿重复购买。":"Payment and fulfillment succeeded, but recording failed. Contact the merchant to repair this purchase; do not buy again.":o?"付款和商户处理已完成,正在确认交易记录。请勿重复购买。":"Payment and merchant fulfillment are complete. Recording is pending confirmation; do not purchase again.",y.textContent=o?"查询记录":"Check recording",f=async()=>V(await i.read()),y.hidden=!1;return}if(e.problem&&R(e).type!=="native"){let h=e.problem;f=Oe,y.textContent=o?"检查并恢复原操作":"Check and recover original purchase",we(new k(h.code,h.reason==="RESULT_UNKNOWN"?o?"付款结果尚未确定,请恢复原操作,暂勿重复购买。":"The payment result is unknown. Recover the original purchase before buying again.":h.phase==="fulfillment"?o?"付款已记录,商户权益处理需要核对。":"Payment was recorded. Access fulfillment needs attention.":h.code==="CAPABILITY_UNAVAILABLE"?o?"商户尚不支持本次购买所需的完整能力,请处理后恢复原操作。":"The merchant does not currently support all actions required by this purchase. Recover the original purchase after this is resolved.":h.code==="NOT_CONFIGURED"?o?"付款服务连接需要处理,请联系商户后恢复原操作。":"The payment connection needs attention. Contact the merchant, then recover the original purchase.":o?"原购买操作需要处理,请查询或恢复此操作。":"The original purchase needs attention. Check or recover this operation.",void 0,void 0,h));return}if((e.merchantExecution?.type==="purchase"&&e.merchantExecution.paymentStatus==="succeeded"||e.merchantExecution?.type==="subscription_change"&&e.merchantExecution.status==="applied")&&!["applied","not_applicable"].includes(e.merchantExecution.fulfillmentStatus)&&(d.textContent=o?"付款已记录,正在等待商户完成处理。":"Payment was recorded. Waiting for merchant fulfillment."),Ge(e)&&R(e).type==="complete"){f=null,await en(e);return}if(!_e(e)&&R(e).type!=="fulfillment"){if(i.canReselect===!1){d.textContent=o?"正在核对原购买结果":"Checking the original purchase result",y.textContent=o?"查询结果":"Check result",f=async()=>V(await i.read()),y.hidden=!1;return}e.status==="cancelled"?d.textContent=o?"这笔购买已取消,可以重新选择方案。":"This purchase was cancelled. Choose a plan to start again.":e.status==="failed"&&(d.textContent=o?"这笔购买未能完成,可以重新选择方案。":"This purchase didn’t go through. Choose a plan to try again."),y.textContent=o?"重试":"Retry",f=null,v=null;return}if(!t&&R(e).type==="checkout"){if(B){Jt();return}if(ye()){d.textContent="",nt=!1,f=null,y.hidden=!0,N?.updateCapabilities?.(oe(u),Ce(u)),ve();return}let h=i.quote,E=h?.operationId===e.operationId?an(h).label:"";d.textContent=nt?E?o?`${E} 尚未付款。再次选择该方案即可继续付款。`:`${E} is still unpaid. Choose it again to continue paying.`:o?"之前的购买尚未付款。再次选择该方案即可继续付款。":"Your earlier purchase is still unpaid. Choose that plan again to continue paying.":"",nt=!1,f=null;return}await Qe(e);let r=Date.now(),s=r+6e5,c=2e3,l=R(e).type!=="checkout",m=()=>l&&Date.now()-r<15e3;Ve=!0,z(a.onObservationChange,!0);try{for(;!w&&Date.now()<s;){if(await Ye(m()?700:c,p,Z.signal),w)return;if(!I()){f=async()=>V(await i.read()),y.hidden=!1;return}let h=await i.read();if(R(h).type==="checkout"&&(l=!1),!t&&R(h).type==="checkout"){await V(h,!1);return}if(!h.problem&&_e(h)&&await Qe(h),!_e(h)||h.problem||rn(h)){await V(h);return}m()||(c=Math.min(c*1.5,3e4))}}finally{Ve=!1,z(a.onObservationChange,!1)}f=async()=>V(await i.read()),y.hidden=!1}async function xt(e=!1){let t=await i.read();if(w)return;if(!I()){f=()=>xt(e),y.hidden=!1;return}let n=i.quote;if(n&&Dt(t,{operationId:n.operationId,currency:n.currency},"The original purchase operation changed"),n&&(it(t)?["prepared","quoted"].includes(t.status):t.status==="pending")&&(it(t)||t.quoteFinalized===!1)&&!t.confirmedAt&&!t.checkoutUrl&&!("nativePurchase"in t&&t.nativePurchase)&&!t.merchantExecution&&!t.problem&&!i.pendingCancellation){if(a.purchaseConfirmation!=="paywall"){e?await Oe():f=null;return}setTimeout(sn,0,n);return}await V(t,e||void 0)}async function on(){await xt()}async function Hn(e){d.textContent=gt;let t=Date.now()+12e3;for(;!w&&Date.now()<t&&(await Ye(1500,p,Z.signal),!(w||!I()));){let n;try{n=await i.read()}catch{break}if(n.problem?.reason!=="RESULT_UNKNOWN")return n}return e}async function Oe(){if(i.quote&&!(Date.parse(i.quote.expiresAt)>Date.now()))throw new k("INVALID_REQUEST",o?"此报价已过期,请重新选择套餐。":"This quote has expired. Choose a plan again.");Kt();let e=i.quote;if(yt(e)){Te(e,"checking");let n;try{n=await i.confirm()}catch(r){if(!tn(r))throw r;return ke(e)}return ke(e,n)}f=Oe;let t=await i.confirm();if(!I()){f=Oe,y.hidden=!1;return}if(t.problem?.reason==="RESULT_UNKNOWN"&&(t=await Hn(t)),t.problem){await V(t);return}if(_e(t)){if(R(t).type==="checkout")await Qe(t);else if(t.execution&&t.execution.provider!=="merchant"||"nativePurchase"in t&&t.nativePurchase){if(!a.onPurchase)throw new k("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await a.onPurchase({operation:t,signal:Z.signal})}}f=async()=>V(await i.read()),await V(t,!0)}function sn(e){if(w)return;de?.remove();let t=!(Date.parse(e.expiresAt)>Date.now());d.textContent=t?o?"此报价已过期。请先取消,再重新选择。":"This quote has expired. Cancel it, then choose again.":"";let n=p.createElement("div"),r=p.createElement("button"),s=p.createElement("button"),c=p.createElement("div"),l=p.createElement("p"),m=e.merchantTerms,h=o?"zh-CN":"en",E=m?.subscriptionTerms?.items??[],q=m?m.subscriptionTerms?.trial?.days:_(e)?void 0:e.lines.find(g=>g.trial)?.trial?.days,G=_(e)?m?m.totalMinor:e.totalMinor:q===void 0?null:m?m.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(g=>g.trial)?0:null,Ne=(g,P)=>o?`${P} 天试用结束后 ${g}`:`Then ${g} after the ${P}-day trial`,{label:X,recurring:De}=an(e),St=_(e)?i.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(g=>g.productName).join(", "),un=G===null?"":`${o?"今天应付":"Due today"} ${be(G,e.currency)}`;l.textContent=un?[St,un].filter(Boolean).join(" · "):X,r.textContent=_(e)?o?"确认变更":"Confirm change":o?"确认购买":"Confirm purchase",r.disabled=t,s.textContent=o?"取消":"Cancel",n.style.cssText=D.panel,l.style.cssText=D.summary,c.style.cssText=D.actions,r.style.cssText=D.primary,s.style.cssText=D.secondary,Ut(r),r.onclick=()=>{j(Oe)};let dn=async()=>{let g=await i.cancel();w||(n.remove(),de=null,await V(g))};s.onclick=()=>{f=dn,j(dn)};let Y=p.createElement("div");if(Y.style.cssText=D.terms,_(e)){for(let[P,S]of Object.entries(e.featureQuantities??{})){let $=i.view?.capabilities.plans[e.productVersionId]?.prepaid?.find(Qn=>Qn.internalFeatureId===P),rt=p.createElement("p");rt.textContent=`${$?.name??P} · ${S} ${o?"份":"packs"}${$?` × ${$.terms.units}`:""}`,Y.append(rt)}for(let[P,S]of[[o?"原订阅抵扣":"Unused subscription credit",e.creditMinor],[o?"新套餐费用":"New plan charge",e.debitMinor],[o?"优惠减免":"Offer savings",m?.discountMinor??e.discountMinor],[o?"税费":"Tax",m?m.taxMinor:e.taxMinor]]){let $=p.createElement("p");$.textContent=`${P}: ${S===null?o?"结账时确认":"Confirmed at checkout":be(S,e.currency)}`,Y.append($)}let g=p.createElement("p");g.textContent=`${o?"生效时间":"Effective"}: ${e.effectiveAt}`,Y.append(g)}if(m){for(let P of E){if(G===null&&P===De)continue;let S=p.createElement("p"),$=be(P.amountMinor,e.currency)+Ue(P.interval,h,P.intervalCount);S.textContent=G!==null&&q!==void 0?Ne($,q):$,P.amountAfterOfferMinor!==void 0&&(S.textContent+=` · ${o?"优惠结束后":"After the offer"} ${be(P.amountAfterOfferMinor,e.currency)}${Ue(P.interval,h,P.intervalCount)}`),Y.append(S)}let g=m.subscriptionTerms?.trial;if(g){let P=p.createElement("p");P.textContent=o?`试用 ${g.days} 天;${g.cardRequired?"需要提供付款方式":"无需提供付款方式"}`:`Trial days: ${g.days}; ${g.cardRequired?"a payment method is required":"no payment method is required"}`,Y.append(P)}for(let P of[...m.expectedEffects.map(S=>S.description),...m.requiredConsents.map(S=>S.summary)]){let S=p.createElement("p");S.textContent=P,Y.append(S)}}else if(!_(e)){for(let g of e.lines){if(G!==null||g!==De){let P=p.createElement("p"),S=`${be(g.catalogAmountMinor,e.currency)}${Ue(g.interval,h,g.intervalCount??1)}`;P.textContent=G!==null&&g.trial?(e.lines.length>1?`${g.productName} · `:"")+Ne(S,g.trial.days):`${g.productName} · ${S}`,Y.append(P)}for(let P of g.prepaid??[]){let S=p.createElement("p"),$=i.view?.capabilities.plans[g.productVersionId]?.prepaid?.find(rt=>rt.internalFeatureId===P.internal_feature_id);S.textContent=`${$?.name??P.internal_feature_id} · ${P.quantity} ${o?"份":"packs"} × ${P.terms.units}`,$&&(S.textContent+=Ue($.reset==="week"||$.reset==="month"||$.reset==="year"?$.reset:"one_time",h,$.resetCount)),Y.append(S)}if(g.trial){let P=p.createElement("p");P.textContent=o?`试用 ${g.trial.days} 天;${g.trial.cardRequired?"需要提供付款方式":"无需提供付款方式"}`:`Trial days: ${g.trial.days}; ${g.trial.cardRequired?"a payment method is required":"no payment method is required"}`,Y.append(P)}}if(!e.charge){let g=p.createElement("p");g.textContent=o?"目录价格;最终金额以结账时税费和试用规则为准。":"Catalog price; the final charge depends on checkout taxes and trial terms.",Y.append(g)}}for(let g of Y.children)g.style.margin="0";c.append(r,s),n.append(l,...Y.childElementCount?[Y]:[],c),W.prepend(n),L?.responsive||n.scrollIntoView?.({block:"nearest"}),r.focus({preventScroll:!0}),de=n,fe&&je(!0),f=null}async function qe(){if(!v)return;if(f=qe,!xe){let n=i.view,r=n?.document.buttons[v.actionId],s=n&&r?.type==="checkout"?Ee(r.product,v.selection,n.capabilities):null;if(!n||!s)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");if(!Re){let l=Ft(),m=l?await l.result:void 0;if(w)return;let h=a.resolveSubscriptionChange;if(h||m){let E={actionId:v.actionId,productVersionId:s,featureQuantities:Le(n.document.screen,s,v.selection,n.capabilities)},q=m?[async()=>m(E)]:[],G=h?await h(E,...q):await q[0]?.();if(w)return;G!==void 0&&(v.subscriptionChange=fn.parse(G))}Re=!0}let c=J?.offerId;if(J&&!c){if(!a.claimCoupon)throw new k("CAPABILITY_UNAVAILABLE","Coupon claiming is unavailable");let{offer:l}=await a.claimCoupon(J.id,v.requestId);if(w)return;if(!l||l.couponId!==J.id||l.status!=="issued"||!(Date.parse(l.expiresAt)>Date.now()))throw v=null,J=void 0,f=async()=>{$e(await i.refresh()),f=null},new k("COUPON_UNAVAILABLE","This Coupon is no longer available for this purchase");c=l.id}if(!J&&!n.document.screen.actions.some(l=>l.id===v?.actionId&&typeof l.properties.couponBinding=="string")&&(c=await a.resolveOfferId?.({actionId:v.actionId,productVersionId:s,featureQuantities:Le(n.document.screen,s,v.selection,n.capabilities)})),w)return;c!==void 0&&(v.offerId=c),xe=!0}if(!I()){y.hidden=!1;return}let e;try{e=await i.preview(v)}catch(n){throw i.canReselect===!0&&(v=null,xe=!1,Re=!1,J=void 0,f=null),n}if(J&&(_(e)?(()=>{let n=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0);return n?.couponId!==J.id||n.grantId!==v.offerId})():e.discount?.couponId!==J.id||e.discount.offerId!==v.offerId))throw new k("INVALID_RESPONSE","The quote did not apply the Coupon selected on this Paywall");if(w)return;let t=e.merchantTerms;if(a.purchaseConfirmation!=="paywall"||a.confirmOnHostedCheckout&&I()&&!_(e)&&e.provider==="merchant"&&e.billingSubscriptionId===null&&t?.request.action==="purchase"&&t.request.mode==="subscription"&&t.subscriptionTerms?.trial===null&&t.requiredConsents.length===0&&Date.parse(e.expiresAt)>Date.now()){if(!I()){y.hidden=!1;return}if(!(Date.parse(e.expiresAt)>Date.now()))throw new k("INVALID_REQUEST",o?"此报价已过期,请重新选择套餐。":"This quote has expired. Choose a plan again.");let n=ae?"":o?"正在打开收银台…":"Opening checkout…";d.textContent=n;try{await Oe()}catch(r){w||we(r)}finally{d.textContent===n&&(d.textContent="")}return}sn(e)}function Ie(e="destroy",t=!1){if(w)return;w=!0;let n=pt;pt=void 0,z(n),a.signal?.removeEventListener("abort",se),i.signal?.removeEventListener("abort",se),M.finish("dismissed"),Vt?.(),Pt(),p.removeEventListener("visibilitychange",Wt),Z.abort(),Mt?.disconnect(),N?.destroy(),i.destroy(),A.removeEventListener("cancel",cn),O.remove(),U.remove(),t||ln(),e==="dismiss"&&z(a.onDismiss)}function ln(){if(L?.destroy(),ue){ue.release();return}A.open&&A.close(),A.remove(),T()}F=Ie;async function Fe(){if(!he||w||ze||ie==="closing"||!ie&&!I())return;if(!x){Ie("dismiss");return}let e=p.createElement("p");e.setAttribute("role","status"),e.textContent=o?"正在关闭…":"Closing…",me||(me=p.createElement("div"),me.style.cssText=W.style.cssText,W.replaceWith(me),pe.inert=!0),O.hidden=!1,me.replaceChildren(e,O),ie="closing",O.setAttribute("aria-disabled","true"),O.focus({preventScroll:!0});try{await x.dismiss()}catch(t){w||z(a.onError,t)}w||(ie="retry",e.textContent=o?"未能确认关闭,请重试。":"Could not confirm closure. Try again.",O.textContent=o?"重试关闭":"Retry closing",O.removeAttribute("aria-label"),O.removeAttribute("aria-disabled"))}O.onclick=()=>{Fe()};function cn(e){e.preventDefault(),Fe()}A.addEventListener("cancel",cn),ce.onclick=()=>{j(C?Et:et)},y.onclick=()=>{if(Q){Q.retry?.();return}f&&j(f)};function Rt(e){M.finish("error",e),Ie()}function At(){if(!(!Qt||he||w||ze||L&&!I()))try{let e=t=>{a.focusAtReveal&&(T=_t(p)),N?.setHidden?.(!1),ft?.(),L&&(A.open||A.showModal(),L.responsive&&A.focus({preventScroll:!0}),!t&&a.loading!=="host"&&Cn(A,L.type,L.responsive)),t&&a.loading!=="host"&&typeof pe.animate=="function"&&!p.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches&&pe.animate([{opacity:.55},{opacity:1}],{duration:160,easing:"ease-out"}),he=!0,Xe()};x?x.present(t=>M.present(n=>e(t??n))):M.present(e)}catch(e){Rt(e),we(e)}}try{if(Me.type==="inline"?(ct(),ft=xn(U,H),H.append(U)):(A.setAttribute("aria-label",u.document.name),O.textContent="×",O.setAttribute("aria-label",o?"关闭":"Close"),Pn(O,u.document.screen.theme),O.hidden=gn(u.document),(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&ue?.content?ue.content.append(O,U):A.replaceChildren(O,U),ue||H.append(A),L=bn(A,{...u.document.screen,presentation:Me},dt),L.latch(),L.responsive&&(U.style.display="flex",U.style.flexDirection="column",U.style.maxHeight="100%",pe.style.overflow="clip",pe.style.minHeight="0"),ue||(ft=En(A))),st&&ee){let n=st(ee);if(typeof n=="function"&&(w?z(n):pt=n),w)throw new DOMException("Presentation cancelled","AbortError");ct()}N=ne(pe,{mode:"live",rendererUrl:"bundled",title:u.document.name,closeActions:Un,onAuthoredClose(n){ie||w||(O.hidden=n)},hostPresentation:()=>L?.type??Me.type,reportContentHeight:L?.responsive,onResize:n=>{if(!L?.responsive)return;let r=Math.min(n,ut);pe.style.height=`${r}px`,L.setContentHeight(r+Ht())},onSelection(n){for(let[r,s]of Object.entries(n))typeof s=="number"&&typeof K[r]=="number"&&K[r]!==s&&Bt.add(r);K=n,ve(),Xe()},onAction(n,r={},s,c){if(!he||w||ie)return;let l=i.view,m=l?.document.buttons[n];if(!m)return;if(Q){m.type==="close"&&Fe();return}if(m.type==="close"&&x&&a.resumeCheckout&&i.operation&&mn(R(i.operation))){Fe();return}if(fe)return;if(!I()){kt();return}if(m.type==="close"){j(async()=>{x?.closeAction?await x.closeAction(n):await a.onAction?.(n),Ie(a.onAction?"action":"dismiss")});return}if(m.type==="action"){f=async()=>{if(m.action.type==="event"){if(!a.onEvent)throw new k("EVENT_HANDLER_REQUIRED","Provide the event handler");await a.onEvent(m.action.event)}else a.onOpenUrl?await a.onOpenUrl(m.action.url):p.defaultView?.location.assign(m.action.url);await a.onAction?.(n),f=null},j(f);return}if(ye()&&B){!ge&&B.selection.actionId===n&&j(()=>tt(!0),n);return}if(C){if(C.phase==="payment"&&l&&Se(C.quote,l,n,m.product,r,c)){j(Et,n);return}if(!bt())return}if(!Pe()&&!bt()){ye()&&l&&i.quote&&i.operation&&R(i.operation).type==="checkout"&&Se(i.quote,l,n,m.product,r,c)?j(et,n):d.textContent=o?"当前只能继续原订单。":"Only your original checkout is available.";return}if(de&&i.canReselect===!1){d.textContent=o?"请先确认或取消当前购买。":"Confirm or cancel the current purchase first.",L?.responsive||de.scrollIntoView?.({block:"nearest"}),de.querySelector("button")?.focus({preventScroll:!0});return}if(ye()&&a.terminateCheckout&&l&&i.quote&&i.operation&&i.canReselect===!1&&R(i.operation).type==="checkout"){if(Se(i.quote,l,n,m.product,r,c)){j(et,n);return}let E=Ee(m.product,r,l.capabilities),q;try{if(!E)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");q=Le(l.document.screen,E,r,l.capabilities)}catch(De){we(De);return}let G=i.operation.operationId,Ne={actionId:n,requestId:crypto.randomUUID(),selection:structuredClone(r)},X=vt(l,n,E,r,c);j(()=>Xt(G,Ne,X,{actionId:n,productVersionId:E,selection:Ne.selection,featureQuantities:q}),n);return}if((i.quote||v)&&i.canReselect===!1){let E=!!l&&!!i.quote&&Se(i.quote,l,n,m.product,r,c);nt=!!i.quote&&!E,f=i.quote?()=>xt(E):qe,j(f,n);return}let h=l&&Ee(m.product,r,l.capabilities);if(!l||!h){we(new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(a.onPurchaseIntent){f=null,j(async()=>{let E={actionId:n,productVersionId:h,selection:structuredClone(r),featureQuantities:Le(l.document.screen,h,r,l.capabilities)};ht=!0,await a.onPurchaseIntent(E)},n);return}if(v&&v.actionId!==n){we(new k("COMMAND_PENDING","Finish the current purchase"));return}v||(J=vt(l,n,h,r,c),v={requestId:crypto.randomUUID(),actionId:n,selection:structuredClone(r)},xe=!1,Re=!1),j(qe,n)},onEscape:()=>{Fe()},onError:n=>{let r=new Error(n);!he&&!w&&Rt(r),we(r)},onRendered:n=>{n&&A.setAttribute("aria-label",n),Qt=!0,At()}}),N.setHidden?.(!0),dt();let e=ye()&&!!i.quote&&!!i.operation&&R(i.operation).type==="checkout";K=i.quote?Nn(u,i.quote)??at(u,{}):at(u,{}),N.update(u.document.screen,lt,{capabilities:oe(u),unavailableActions:Ce(u),serverInput:{bindings:[],answers:{}},...Object.keys(K).length?{selection:K}:{}}),Vt=i.subscribe?.($e),$e(i.view??u),await M.wait(N.ready);let t=i.operation;(!e||yt(i.quote))&&(i.quote||t&&(t.confirmedAt||t.checkoutUrl||Ge(t)))&&(f=on,j(f))}catch(e){throw Rt(e),e}return{check:le,host:{get currentResolution(){return u},setPurchaseRecovery(e,t){Q={message:e,retry:t},N?.updateCapabilities?.(oe(u),Ce(u)),ve(),Zt()},get subscriptionUpgradeActive(){return C!==void 0},get observing(){return Ve},get recovery(){return Ln()},async prepareFallback(){if(fe||w||ie||ht)return{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null};je(!0);try{let e=await yn(i);return e.type==="native"&&Ie(),e}finally{je(!1)}},setSuspended(e){ze=e,U.hidden=e,e&&A.open?A.close():!e&&!he?At():!e&&!w&&he&&Me.type!=="inline"&&!A.open&&A.showModal()},destroy:Ie,retainPurchaseDialog(){if(!(w||!A.open||!A.isConnected))return Ie("destroy",!0),{dialog:A,content:ue?.content,release:ln}},refresh:async()=>{if(!I()){if(i.view)return i.view;throw new k("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await i.refresh();return $e(e),At(),e}}}}export{Pr as a};
1
+ import{a as kn,c as Rn,d as Ut,f as Lt,g as An,k as Sn}from"./chunk-UG5RBIWP.js";import{a as wn,b as Ye}from"./chunk-W32FI2A2.js";import{e as bn,f as Cn,g as Pn,h as vn,j as _t,k as ot,l as In,m as En,n as xn}from"./chunk-VVZLNTWC.js";import{a as hn,c as Ot,d as mn,e as yn}from"./chunk-TY4PJ2AG.js";import{a as at,b as oe,d as Nt,f as Dt,j as gn}from"./chunk-DCPRELJA.js";import{b as Ee}from"./chunk-SSVSXSYE.js";import{B as _,C as it,D as Ge,E as _e,y as fn}from"./chunk-KLPRVDHS.js";import{r as Ue,t as Le}from"./chunk-HQWZWHHM.js";import{i as pn}from"./chunk-NPDRXDI7.js";import{c as be,j as We}from"./chunk-XJTEGBPR.js";import{c as Tt}from"./chunk-7KQWJBFQ.js";import{a as k}from"./chunk-HLK7L2RV.js";import{a as z}from"./chunk-DSPLGTQI.js";async function Tn(H,a,x){if(!Ge(a))throw new k("INVALID_RESPONSE","A verified completed purchase is required");let T=H?We.parse(H):null;if(await x.onComplete?.(a),!T||!x.check)return;let F=We.parse(await x.check());if(F.internal_feature_id!==T.internal_feature_id||F.quantity!==T.quantity||T.observation!==void 0&&(F.observation===void 0||F.observation.requirementDigest!==T.observation.requirementDigest||F.observation.authority!==T.observation.authority||Tt(F.observation.subject)!==Tt(T.observation.subject)))throw new k("INVALID_RESPONSE","The access requirement changed");F.allowed&&await x.onAccessGranted?.(F)}function On(H){return Object.entries(H.document.buttons).filter(([,a])=>a.type==="checkout"&&a.product.type==="fixed"&&!Ee(a.product,{},H.capabilities)).map(([a])=>a)}function Nn(H,a){let x=_(a)?void 0:a.lines[0];if(!_(a)&&(a.lines.length!==1||!x))return;let T=_(a)?a.productVersionId:x.productVersionId,{screen:F,buttons:se}=H.document,M=new Map(_(a)?Object.entries(a.featureQuantities??{}):(x?.prepaid??[]).map(b=>[b.internal_feature_id,b.quantity]));function le(b,u){if(b.hidden)return!1;if(b.type==="plan_picker"&&H.capabilities.pickers[b.id]?.options.includes(T))return u[b.id]=T,!0;if(b.type==="quantity_picker"){let ne=M.get(b.internalFeatureId);return ne!==void 0&&(!b.bind?.plan||b.bind.plan===T)&&(u[b.id]=ne),!1}if(b.type==="button"&&b.action){let ne=se[b.action];return ne?.type==="checkout"&&ne.product.type==="fixed"&&ne.product.productVersionId===T}if(b.type!=="stack")return!1;let te=b.interaction,i=b.bind?.plan===T;for(let[ne,p]of b.children.entries()){let Z={},U=le(p,Z);if(te?.type==="toggle"||te?.type==="tabs"){if(!U)continue;return u[b.id]=te.type==="toggle"?ne===0:p.id,Object.assign(u,Z),!0}Object.assign(u,Z),U&&(i=!0,te?.type==="select"&&te.purpose==="product"&&te.pickerId&&p.type==="stack"&&p.bind?.plan===T&&(u[b.id]=p.id,u[te.pickerId]=T))}return i}for(let b of F.pages){let u={__page:b.id};if(le(b.root,u))return u}}var Bn="position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0";async function Pr(H,a,x){let T=a.focusAtReveal?()=>{}:_t(H.ownerDocument),F=()=>{M.finish("dismissed"),T()},se=()=>F(),M=In(H,a,"paywall",()=>{F(),z(a.onDismiss)},kn);a.signal?.throwIfAborted(),a.signal?.addEventListener("abort",se,{once:!0});let le=null,b,u,te;try{if(M.start(!0,a.loadingDocument?.screen.strings.defaultLocale,a.loadingDocument??null),M.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(le=a.check?We.parse(await M.wait(a.check(),ot)):null,le?.allowed)return M.finish("skipped"),a.signal?.removeEventListener("abort",se),T(),await a.onAccessGranted?.(le),{check:le,host:null};let[e,t]=await Promise.allSettled([M.wait(import("./screen-renderer-AVHPHFXT.js")),M.wait(a.start().then(r=>(M.cancelled&&r.destroy(),r)),ot)]);if(e.status==="rejected")throw t.status==="fulfilled"&&t.value.destroy(),e.reason;if(t.status==="rejected")throw t.reason;te=e.value,b=t.value,a.signal?.throwIfAborted(),b.signal?.throwIfAborted(),b.signal?.addEventListener("abort",se,{once:!0});let n=b.view??await M.wait(b.refresh(),ot);if(!n)throw new k("INVALID_RESPONSE","Paywall presentation is missing");b.signal?.throwIfAborted(),u=n}catch(e){throw M.finish("error",e),x?.retainedDialog?.release(),a.signal?.removeEventListener("abort",se),b?.signal?.removeEventListener("abort",se),b?.destroy(),T(),e}let i=b,{mountScreenPreview:ne}=te,p=H.ownerDocument,Z=new AbortController,U=p.createElement("section"),pe=p.createElement("div"),W=p.createElement("div"),st=a.mountControls,ee=st?p.createElement("div"):void 0,d=p.createElement("p"),y=p.createElement("button"),ce=p.createElement("button"),N=p.createElement("button");(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&x?.hostPaywallTarget&&!x.retainedDialog&&u.document.presentation.type==="modal"&&(x.retainedDialog=vn(x.hostPaywallTarget));let ue=x?.retainedDialog,A=ue?.dialog??p.createElement("dialog"),Me=ue&&u.document.presentation.type==="inline"?{type:"modal",size:"md"}:u.document.presentation,re=Me.type==="inline"?W:p.createElement("div"),lt=i.locale||u.document.screen.strings.defaultLocale,o=lt.toLowerCase().startsWith("zh"),Dn=o?"正在处理…":"Processing…",_n=o?"正在准备报价…":"Preparing your price…",D=Rn(u.document.screen.theme);U.dataset.indianaPaywall="",U.setAttribute("aria-label",u.document.name),U.style.cssText=D.root,W.style.cssText=D.controls,d.style.cssText=D.message,d.setAttribute("role","status"),N.style.cssText=D.link,N.textContent=o?"关闭":"Close",y.style.cssText=D.secondary,y.textContent=o?"重试":"Retry",y.hidden=!0,ce.type="button",ce.style.cssText=D.primary,ce.textContent=o?"继续付款":"Continue payment",ce.hidden=!0,re.append(d,ce,y),W.append(N),ee&&(ee.style.cssText="flex:1 0 100%;min-width:0",ee.hidden=!0,W.prepend(ee)),re!==W&&(re.dataset.indianaPaywallStatus="",re.style.cssText="display:none;padding:0",U.append(re)),U.append(pe,W);let ct=()=>{let e=Mn();d.style.cssText=e?`${D.message};${Bn}`:D.message,zt();let t=c=>!c.hidden&&(c!==d||!!d.textContent&&!e);if(re!==W&&(re.style.cssText=!ie&&[...re.children].some(t)?`${D.controls};padding:12px 64px 12px 20px;flex-shrink:0`:e?"padding:0":"display:none;padding:0"),ee){let c=!ee.childElementCount&&!ee.textContent?.trim();ee.hidden!==c&&(ee.hidden=c)}let n=me??W,r=![...n.children].some(t),s=[...n.children].some(c=>c!==N&&t(c));n.style.cssText=r?D.controls.replace(/padding:[^;]+/,"padding:0"):s?`${D.controls};${D.pinned}`:D.controls,dt()},Mt=typeof MutationObserver>"u"?void 0:new MutationObserver(ct);Mt?.observe(U,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let Un=Object.entries(u.document.buttons).filter(([,e])=>e.type==="close").map(([e])=>e),O,Vt,Ve=!1,$t=JSON.stringify(u.capabilities),Q;function Ce(e){let t=On(e);if(Q||fe&&!ae||B&&(C||!Pe()||ge))return Ae(e).map(({actionId:r})=>r);if(bt()||!C&&Pe())return t;let n=C?wt(e):Ct(e);return[...new Set([...t,...Ae(e).map(({actionId:r})=>r).filter(r=>!n.includes(r))])]}function $e(e){if(w)return;let t=u.id!==e.id;u=e;let n=JSON.stringify(e.capabilities);if(t||n!==$t){let r=!v&&!i.quote&&!i.operation?at(e,K,Bt):K;t||JSON.stringify(r)!==JSON.stringify(K)?(K=r,O?.update(e.document.screen,lt,{capabilities:oe(e),unavailableActions:Ce(e),serverInput:{bindings:[],answers:{}},selection:K})):O?.updateCapabilities(oe(e),Ce(e)),$t=n}Vn(e),ve(),Xe()}let L,ut=0;function Ht(){return(me??W).getBoundingClientRect().height+(re===W?0:re.getBoundingClientRect().height)}function dt(){let e=p.defaultView;if(!L?.responsive||!e)return;let t=me??W,n=e.innerHeight-(L.type==="modal"?32:0);t.style.maxHeight=`${Math.max(1,n)}px`,t.style.overflowY="auto",t.style.flexShrink="0",ut=Math.max(1,n-Ht()),O?.resizeViewport?.(ut,e.innerWidth)}let w=!1,fe=!1,v=null,pt,ze=!1,Qt=!1,he=!1,ft,ht=!1,ie,me;function Ln(){return fe||w||ie||ht?{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null}:Ot(i)}let I=()=>!w&&!ze&&!ie&&a.canInteract?.()!==!1,J,xe=!1,Re=!1,mt,f=null,de=null,Ke="",ye=()=>a.checkoutNavigation==="after_confirmation"&&!!(a.terminateCheckout||a.resumeCheckout),K={},Bt=new Set,ae,C;function yt(e){return!!e&&_(e)&&e.timing==="immediate"&&e.execution.provider==="merchant"}let gt=o?"正在确认付款…":"Confirming payment…",B=null,ge,Je,jt=!1,Pe=()=>a.allowNewPurchase!==!1||jt;function qt(){return JSON.stringify([u.id,u.capabilities])}function Ft(){let e=mt;return e&&e.read===a.prepareSubscriptionChange&&e.basis===qt()?e:void 0}function Xe(){let e=a.prepareSubscriptionChange;if(!e||!he||!I()||!Pe()||a.onPurchaseIntent||p.visibilityState==="hidden"||v||i.quote||i.operation||!Ae(u).length||Ft())return;let t=Z.signal,n=new Promise(r=>{let s=()=>r(void 0);t.addEventListener("abort",s,{once:!0}),Promise.resolve().then(()=>(t.throwIfAborted(),e(t))).then(c=>r(t.aborted?void 0:c),s).finally(()=>t.removeEventListener("abort",s))});mt={read:e,basis:qt(),result:n}}let Wt=()=>{p.visibilityState==="hidden"?mt=void 0:Xe()};p.addEventListener("visibilitychange",Wt);function Ae(e){return Object.entries(e.document.buttons).flatMap(([t,n])=>n.type==="checkout"?[{actionId:t,policy:n}]:[])}function Gt(e){let t=C?.quote;return t?Ae(e).filter(({actionId:n,policy:r})=>Se(t,e,n,r.product,K)).map(({actionId:n})=>n):[]}function wt(e){return C?.phase==="payment"?Gt(e):[]}function bt(){return(C?C.phase==="payment":!Pe())&&(Pe()||!!a.prepareUpgradeReplacement)&&ye()&&!!a.terminateCheckout&&!!i.quote&&i.canReselect===!1&&!!i.operation&&R(i.operation).type==="checkout"}function Ct(e){let t=i.quote;return!ye()||B||!t||!i.operation||R(i.operation).type!=="checkout"?[]:Ae(e).filter(({actionId:n,policy:r})=>Se(t,e,n,r.product,K)).map(({actionId:n})=>n)}function ve(){let e=Q?[]:C?wt(u):Ct(u),t=a.allowNewPurchase===!1&&!!i.operation&&R(i.operation).type==="checkout";ce.hidden=!!Q||(C?C.phase!=="payment":!t)||e.length>0,zt(e)}function Yt(){if(!(ae===void 0||Q))return d.textContent?d.textContent:C?.phase==="checking"?gt:void 0}function Mn(){return!!O?.updateCheckoutControls&&!!d.textContent&&Yt()!==void 0}let Ze;function zt(e=Q?[]:C?wt(u):Ct(u)){if(!O?.updateCheckoutControls)return;let t=Yt(),n=ye()||!!C;if(!t&&!n&&Ze?.on!==O)return;let r={actions:Ae(u).map(({actionId:c})=>c),resume:t?[ae]:n?e:[],resumeLabel:t??(o?"继续付款":C?"Continue payment":"Continue checkout"),busy:ae},s=JSON.stringify(r);Ze?.on===O&&Ze.key===s||(Ze={on:O,key:s},O.updateCheckoutControls(r))}function Kt(){de?.remove(),de=null}async function et(){if(B)return;if(a.resumeCheckout&&i.operation){let t=i.operation.operationId;try{await a.resumeCheckout(t)}catch(n){if(!(n instanceof k&&n.code==="PURCHASE_PENDING"))throw n;let r=await i.read();if(!I())return;if(r.operationId!==t||R(r).type==="checkout")throw n;await V(r,!1)}return}let e=await i.read();if(R(e).type!=="checkout")return V(e,!1);I()&&(He.delete(e.operationId),await Qe(e))}function Pt(){ge?.destroy(),ge=void 0,Je=void 0}function Jt(){let e=B;if(!e||ge)return;let t=o?"仍在核对原订单,暂时无法更换套餐。":"We’re still checking the original purchase before changing plans.",n=Date.now()+6e5,r=wn({document:p,delay:()=>Date.now()<n?5e3:void 0,async run(){if(!I())return;let s=await i.read();if(ge!==r||!I())return;if(s.operationId!==e.operationId)throw new k("PURCHASE_PENDING","The original Checkout changed");let c=R(s);c.type==="native"?(Pt(),d.textContent=o?"原订单已关闭。你可以继续更换套餐。":"The original checkout is closed. You can continue changing plans.",y.textContent=o?"继续更换套餐":"Continue changing plans",f=()=>tt(),y.hidden=!1):(c.type==="complete"||c.type==="fulfillment"||c.type==="recording")&&(Pt(),B=null,y.hidden=!0,await V(s,!1))}});ge=r,Je=async()=>{try{await r.refresh()}finally{ge===r&&(d.textContent=t,y.hidden=!1)}},f=Je,y.textContent=o?"查询结果":"Check result",y.hidden=!1,d.textContent=t,r.schedule()}async function tt(e=!1){let t=B;if(!t)return;f=()=>tt(),C&&(y.textContent=o?"查询状态":"Check status"),y.hidden=!0;let n=Date.now()+2e4;for(;I();){let r=await i.read();if(r.operationId!==t.operationId)throw new k("PURCHASE_PENDING","The original Checkout changed");if(!I())break;let s=R(r);if(s.type==="native"){if(!Pe()&&a.prepareUpgradeReplacement){let c=await a.prepareUpgradeReplacement(t.operationId,t.intent);if(!I())return;jt=!0,$e(c)}B=null,C&&Te(C.quote),Kt(),v=t.selection,J=t.coupon,xe=!1,Re=!1,await qe();return}if(s.type==="complete"||s.type==="fulfillment"||s.type==="recording"){B=null,C?await ke(C.quote,r):await V(r,!1);return}if(e&&s.type==="checkout"){e=!1;try{await a.terminateCheckout(t.operationId)}catch(c){z(a.onError,c)}}if(Date.now()>=n){C&&s.type==="checkout"&&(B=null,await ke(C.quote,r));break}await Ye(1e3,p,Z.signal)}!B||w||(C?(d.textContent=o?"仍在核对原升级单,暂时无法更换套餐。":"We’re still checking the original upgrade before changing plans.",y.hidden=!1):Jt())}async function Xt(e,t,n,r){if(f=()=>Xt(e,t,n,r),await a.beforeCheckoutReplacement?.(structuredClone(r)),!I())return;let s=i.operation;if(s?.operationId!==e||R(s).type!=="checkout"){f=null,s&&await V(s,!1);return}B={operationId:e,selection:t,coupon:n,intent:r},C&&(d.textContent=o?"正在切换套餐…":"Changing plan…",y.hidden=!0);let c=!1;try{await a.terminateCheckout(e)}catch(l){if(l instanceof k&&["CAPABILITY_UNAVAILABLE","NOT_CONFIGURED"].includes(l.code)){B=null,C&&(f=It,y.textContent=o?"查询状态":"Check status",y.hidden=!1),d.textContent=o?"请继续原订单,或等待它过期后再更换方案。":"Continue your original checkout, or wait for it to expire before changing plans.",z(a.onError,l);return}c=l instanceof k&&(l.status??0)>=500,z(a.onError,l)}I()&&await tt(c)}function vt(e,t,n,r,s){let c=oe(e).checkoutCoupons?.[t],l=c?c.products[n]:a.claimCoupon&&s?pn(e.capabilities,s,r):void 0;return l?.couponId&&l.planVersionId===n?{id:l.couponId,offerId:l.offerId}:void 0}function Vn(e){fe||v||i.quote||i.operation||Ke&&d.textContent===Ke||(d.textContent=Object.values(e.capabilities.plans).some(t=>t.available)?"":o?"当前账号暂无可购买的方案。":"No plans are currently available for this account.")}let He=new Map,nt=!1;function Se(e,t,n,r,s,c){let l=_(e),m=!l&&e.lines.length===1?e.lines[0]:void 0,h=Ee(r,s,t.capabilities);if(!h||h!==(l?e.productVersionId:m?.productVersionId))return!1;let E=vt(t,n,h,s,c),q;try{q=Le(t.document.screen,h,s,t.capabilities)}catch{return!1}if(l){let X=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0);return Object.keys(q).length===Object.keys(e.featureQuantities??{}).length&&Object.entries(q).every(([De,St])=>e.featureQuantities?.[De]===St)&&(!E||X?.couponId===E.id&&(!E.offerId||X.grantId===E.offerId))}if((E||oe(t).checkoutCoupons?.[n])&&(E?.id??null)!==(e.discount?.couponId??null))return!1;let G=Object.fromEntries((m?.prepaid??[]).map(X=>[X.internal_feature_id,X.quantity]));return[...new Set([...Object.keys(q),...Object.keys(G)])].every(X=>(q[X]??0)===(G[X]??0))}let R=e=>hn({quote:i.quote,operation:e,requestId:null,pending:!1,destroyed:w,canReselect:i.canReselect});async function Qe(e){let t=e.merchantExecution,n=R(e),r=n.type==="checkout"?n.checkoutUrl:e.checkoutUrl;if(!(!I()||!r||it(e)&&n.type!=="checkout"||a.checkoutNavigation==="after_confirmation"&&n.type!=="checkout"||t?.type==="purchase"&&!["not_started","pending"].includes(t.paymentStatus)||He.get(e.operationId)===r)){He.set(e.operationId,r);try{a.onCheckoutUrl?await a.onCheckoutUrl(r):p.defaultView?.location.assign(r)}catch(s){throw He.delete(e.operationId),s}}}let we=(e,t=!1)=>{if(e instanceof Nt)f=null,d.textContent=e.customerMessage(o);else if(An(e))f=null,d.textContent=t?o?"当前无法在此购买,付款尚未开始。请联系商户。":"Purchases aren’t available here right now. Payment hasn’t started. Contact the merchant for help.":Lt(e,o);else if(t){let n=e instanceof k?e.code:void 0;n==="CAPABILITY_UNAVAILABLE"||n==="NOT_CONFIGURED"?(f=null,d.textContent=o?"暂时无法为此套餐报价,付款尚未开始。":"Pricing for this plan is unavailable. Payment hasn’t started."):i.canReselect===!0&&!v?d.textContent=o?"未能取得报价,付款尚未开始。请重新选择套餐。":"We couldn’t prepare your price. Payment hasn’t started. Choose a plan again.":n==="COMMAND_PENDING"?d.textContent=o?"仍在准备报价,请重试以查看结果。":"Your price is still being prepared. Retry to check the result.":d.textContent=o?"未能取得报价,付款尚未开始。请重试。":"We couldn’t prepare your price. Payment hasn’t started. Try again."}else d.textContent=e instanceof k&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?Lt(e,o):e instanceof k?e.message:o?"操作未完成,请重试。":"This action couldn’t be completed. Try again.";y.hidden=f===null,Ke=d.textContent,t&&ae===void 0&&!L?.responsive&&d.scrollIntoView?.({block:"nearest"}),z(t&&x?.quoteError?x.quoteError:a.onError,e)},Be=new WeakMap;function je(e){fe=e,y.disabled=e,ce.disabled=e,O?.updateCapabilities?.(oe(u),Ce(u));for(let t of de?.querySelectorAll("button")??[])e?(Be.has(t)||Be.set(t,t.disabled),t.disabled=!0):Be.has(t)&&(t.disabled=Be.get(t),Be.delete(t)),Ut(t)}function Zt(){Q&&(d.textContent=Q.message,y.textContent=o?"重试":"Retry",y.disabled=!1,y.hidden=!Q.retry,ce.disabled=!0)}function kt(){d.textContent=o?"暂时无法操作,请稍后重试。":"This action is unavailable right now. Try again in a moment."}async function $n(e){if(a.beforeAction)try{await a.beforeAction()}catch(t){throw t instanceof Nt?(v=null,xe=!1,Re=!1,f=null):f=e,t}}async function j(e,t){if(fe||w||Q)return;if(!I()){kt();return}let n=e===qe,r=n?_n:Dn;ae=t!==void 0&&O?.updateCheckoutControls?t:void 0,d.textContent=r,je(!0),ve(),y.hidden=!0;try{if(e!==on&&e!==It&&e!==Et&&e!==Je&&(e!==et||!a.resumeCheckout)&&await $n(e),w||Q)return;if(!I()){f=e,y.hidden=!1,kt();return}await e()}catch(s){w||we(s,n)}finally{ae=void 0,je(!1),ve(),Q?Zt():d.textContent===r&&(d.textContent="")}}async function en(e){await Tn(le,e,a)}function Te(e,t){C=t?{quote:e,phase:t}:void 0,t==="checking"?(ae??=v?.actionId??Gt(u)[0],d.textContent=gt,f=It,y.textContent=o?"查询状态":"Check status",y.hidden=!0):ae=void 0,O?.updateCapabilities(oe(u),Ce(u)),ve()}function tn(e){return e instanceof k&&(e.code==="COMMAND_PENDING"||e.reason==="RESULT_UNKNOWN"||e.code==="NETWORK_ERROR"||e.code==="TIMEOUT"||e.status===429||(e.status??0)>=500)}function nn(e,t){Dt(e,{...t,featureQuantities:t.featureQuantities??{}},"Purchase operation changed")}async function It(){C&&await ke(C.quote)}async function ke(e,t){Te(e,"checking"),Ke="";let n=1e3;Ve=!0,z(a.onObservationChange,!0);try{for(let r=t;I();r=void 0){if(!r){try{r=await i.read()}catch(s){if(!tn(s))throw s}if(!I())return}if(r){nn(r,e);let s=R(r);if(s.type==="checkout"){Te(e,"payment"),d.textContent=o?"请先完成原订单的付款。":"Finish paying for this upgrade.",y.hidden=!1;return}if(s.type==="complete"){Te(e,"complete"),f=null;let c=u.capabilities.plans[e.productVersionId]?.name,l=e.merchantTerms?.subscriptionTerms?.items,m=l?.length===1?l[0].interval:void 0,h=m==="year"?o?"年付":"annual billing":m==="month"?o?"月付":"monthly billing":null;d.textContent=c?o?`已升级到 ${c}${h?" "+h:""}。`:`Upgraded to ${c}${h?" ("+h+")":""}.`:o?"已成功升级。":"Plan upgraded.",await en(r);return}if(s.type==="native"&&!_e(r)){Te(e),v=null,f=null,d.textContent=o?"付款没有成功,套餐未变更。请检查付款方式后重新选择套餐。":"Your payment didn’t go through, so your plan is unchanged. Check your payment method, then choose a plan again.",y.textContent=o?"重试":"Retry";return}if(r.problem&&!["RESULT_UNKNOWN","STATE_CHANGED"].includes(r.problem.reason??""))throw new k(r.problem.code,o?"暂时无法完成升级。":"The upgrade needs attention.",void 0,void 0,r.problem)}await Ye(n,p,Z.signal),n=Math.min(n*1.5,15e3)}}finally{Ve=!1,z(a.onObservationChange,!1)}}async function Et(){let e=C?.quote;if(!e)return;let t=await i.read();if(nn(t,e),R(t).type!=="checkout")return ke(e,t);if(a.resumeCheckout){await a.resumeCheckout(t.operationId);return}He.delete(t.operationId),await Qe(t)}function rn(e){return Ot(i).type==="recording"||R(e).type==="recording"}function an(e){let t=e.merchantTerms,n=t?.subscriptionTerms?.items??[],r=t?t.totalMinor:_(e)?e.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),s=t?n.length===1&&n[0]?.amountMinor===r&&n[0]:!_(e)&&e.lines.length===1&&e.lines[0]?.catalogAmountMinor===r&&e.lines[0],c=r===null?be(t.subtotalMinor-t.discountMinor,e.currency)+(o?" + 待确认税费":" + tax confirmed at checkout"):be(r,e.currency)+(s?Ue(s.interval,o?"zh-CN":"en",s.intervalCount??1):""),l=_(e)?i.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(m=>m.productName).join(", ");return{label:l?`${l} · ${c}`:c,recurring:s}}async function V(e,t=a.checkoutNavigation!=="after_confirmation"){if(w)return;if(!I()){f=async()=>V(await i.read()),y.hidden=!1;return}let n=e.quote??i.quote;if(yt(n)&&(e.confirmedAt||e.merchantExecution))return ke(n,e);if(d.textContent=Sn(e.status,o),rn(e)){let h=e.merchantExecution?.recordingStatus==="failed";d.textContent=h?o?"付款和商户处理已完成,但交易记录失败。请联系商户修复,勿重复购买。":"Payment and fulfillment succeeded, but recording failed. Contact the merchant to repair this purchase; do not buy again.":o?"付款和商户处理已完成,正在确认交易记录。请勿重复购买。":"Payment and merchant fulfillment are complete. Recording is pending confirmation; do not purchase again.",y.textContent=o?"查询记录":"Check recording",f=async()=>V(await i.read()),y.hidden=!1;return}if(e.problem&&R(e).type!=="native"){let h=e.problem;f=Oe,y.textContent=o?"检查并恢复原操作":"Check and recover original purchase",we(new k(h.code,h.reason==="RESULT_UNKNOWN"?o?"付款结果尚未确定,请恢复原操作,暂勿重复购买。":"The payment result is unknown. Recover the original purchase before buying again.":h.phase==="fulfillment"?o?"付款已记录,商户权益处理需要核对。":"Payment was recorded. Access fulfillment needs attention.":h.code==="CAPABILITY_UNAVAILABLE"?o?"商户尚不支持本次购买所需的完整能力,请处理后恢复原操作。":"The merchant does not currently support all actions required by this purchase. Recover the original purchase after this is resolved.":h.code==="NOT_CONFIGURED"?o?"付款服务连接需要处理,请联系商户后恢复原操作。":"The payment connection needs attention. Contact the merchant, then recover the original purchase.":o?"原购买操作需要处理,请查询或恢复此操作。":"The original purchase needs attention. Check or recover this operation.",void 0,void 0,h));return}if((e.merchantExecution?.type==="purchase"&&e.merchantExecution.paymentStatus==="succeeded"||e.merchantExecution?.type==="subscription_change"&&e.merchantExecution.status==="applied")&&!["applied","not_applicable"].includes(e.merchantExecution.fulfillmentStatus)&&(d.textContent=o?"付款已记录,正在等待商户完成处理。":"Payment was recorded. Waiting for merchant fulfillment."),Ge(e)&&R(e).type==="complete"){f=null,await en(e);return}if(!_e(e)&&R(e).type!=="fulfillment"){if(i.canReselect===!1){d.textContent=o?"正在核对原购买结果":"Checking the original purchase result",y.textContent=o?"查询结果":"Check result",f=async()=>V(await i.read()),y.hidden=!1;return}e.status==="cancelled"?d.textContent=o?"这笔购买已取消,可以重新选择方案。":"This purchase was cancelled. Choose a plan to start again.":e.status==="failed"&&(d.textContent=o?"这笔购买未能完成,可以重新选择方案。":"This purchase didn’t go through. Choose a plan to try again."),y.textContent=o?"重试":"Retry",f=null,v=null;return}if(!t&&R(e).type==="checkout"){if(B){Jt();return}if(ye()){d.textContent="",nt=!1,f=null,y.hidden=!0,O?.updateCapabilities?.(oe(u),Ce(u)),ve();return}let h=i.quote,E=h?.operationId===e.operationId?an(h).label:"";d.textContent=nt?E?o?`${E} 尚未付款。再次选择该方案即可继续付款。`:`${E} is still unpaid. Choose it again to continue paying.`:o?"之前的购买尚未付款。再次选择该方案即可继续付款。":"Your earlier purchase is still unpaid. Choose that plan again to continue paying.":"",nt=!1,f=null;return}await Qe(e);let r=Date.now(),s=r+6e5,c=2e3,l=R(e).type!=="checkout",m=()=>l&&Date.now()-r<15e3;Ve=!0,z(a.onObservationChange,!0);try{for(;!w&&Date.now()<s;){if(await Ye(m()?700:c,p,Z.signal),w)return;if(!I()){f=async()=>V(await i.read()),y.hidden=!1;return}let h=await i.read();if(R(h).type==="checkout"&&(l=!1),!t&&R(h).type==="checkout"){await V(h,!1);return}if(!h.problem&&_e(h)&&await Qe(h),!_e(h)||h.problem||rn(h)){await V(h);return}m()||(c=Math.min(c*1.5,3e4))}}finally{Ve=!1,z(a.onObservationChange,!1)}f=async()=>V(await i.read()),y.hidden=!1}async function xt(e=!1){let t=await i.read();if(w)return;if(!I()){f=()=>xt(e),y.hidden=!1;return}let n=i.quote;if(n&&Dt(t,{operationId:n.operationId,currency:n.currency},"The original purchase operation changed"),n&&(it(t)?["prepared","quoted"].includes(t.status):t.status==="pending")&&(it(t)||t.quoteFinalized===!1)&&!t.confirmedAt&&!t.checkoutUrl&&!("nativePurchase"in t&&t.nativePurchase)&&!t.merchantExecution&&!t.problem&&!i.pendingCancellation){if(a.purchaseConfirmation!=="paywall"){e?await Oe():f=null;return}setTimeout(sn,0,n);return}await V(t,e||void 0)}async function on(){await xt()}async function Hn(e){d.textContent=gt;let t=Date.now()+12e3;for(;!w&&Date.now()<t&&(await Ye(1500,p,Z.signal),!(w||!I()));){let n;try{n=await i.read()}catch{break}if(n.problem?.reason!=="RESULT_UNKNOWN")return n}return e}async function Oe(){if(i.quote&&!(Date.parse(i.quote.expiresAt)>Date.now()))throw new k("INVALID_REQUEST",o?"此报价已过期,请重新选择套餐。":"This quote has expired. Choose a plan again.");Kt();let e=i.quote;if(yt(e)){Te(e,"checking");let n;try{n=await i.confirm()}catch(r){if(!tn(r))throw r;return ke(e)}return ke(e,n)}f=Oe;let t=await i.confirm();if(!I()){f=Oe,y.hidden=!1;return}if(t.problem?.reason==="RESULT_UNKNOWN"&&(t=await Hn(t)),t.problem){await V(t);return}if(_e(t)){if(R(t).type==="checkout")await Qe(t);else if(t.execution&&t.execution.provider!=="merchant"||"nativePurchase"in t&&t.nativePurchase){if(!a.onPurchase)throw new k("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await a.onPurchase({operation:t,signal:Z.signal})}}f=async()=>V(await i.read()),await V(t,!0)}function sn(e){if(w)return;de?.remove();let t=!(Date.parse(e.expiresAt)>Date.now());d.textContent=t?o?"此报价已过期。请先取消,再重新选择。":"This quote has expired. Cancel it, then choose again.":"";let n=p.createElement("div"),r=p.createElement("button"),s=p.createElement("button"),c=p.createElement("div"),l=p.createElement("p"),m=e.merchantTerms,h=o?"zh-CN":"en",E=m?.subscriptionTerms?.items??[],q=m?m.subscriptionTerms?.trial?.days:_(e)?void 0:e.lines.find(g=>g.trial)?.trial?.days,G=_(e)?m?m.totalMinor:e.totalMinor:q===void 0?null:m?m.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(g=>g.trial)?0:null,Ne=(g,P)=>o?`${P} 天试用结束后 ${g}`:`Then ${g} after the ${P}-day trial`,{label:X,recurring:De}=an(e),St=_(e)?i.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(g=>g.productName).join(", "),un=G===null?"":`${o?"今天应付":"Due today"} ${be(G,e.currency)}`;l.textContent=un?[St,un].filter(Boolean).join(" · "):X,r.textContent=_(e)?o?"确认变更":"Confirm change":o?"确认购买":"Confirm purchase",r.disabled=t,s.textContent=o?"取消":"Cancel",n.style.cssText=D.panel,l.style.cssText=D.summary,c.style.cssText=D.actions,r.style.cssText=D.primary,s.style.cssText=D.secondary,Ut(r),r.onclick=()=>{j(Oe)};let dn=async()=>{let g=await i.cancel();w||(n.remove(),de=null,await V(g))};s.onclick=()=>{f=dn,j(dn)};let Y=p.createElement("div");if(Y.style.cssText=D.terms,_(e)){for(let[P,S]of Object.entries(e.featureQuantities??{})){let $=i.view?.capabilities.plans[e.productVersionId]?.prepaid?.find(Qn=>Qn.internalFeatureId===P),rt=p.createElement("p");rt.textContent=`${$?.name??P} · ${S} ${o?"份":"packs"}${$?` × ${$.terms.units}`:""}`,Y.append(rt)}for(let[P,S]of[[o?"原订阅抵扣":"Unused subscription credit",e.creditMinor],[o?"新套餐费用":"New plan charge",e.debitMinor],[o?"优惠减免":"Offer savings",m?.discountMinor??e.discountMinor],[o?"税费":"Tax",m?m.taxMinor:e.taxMinor]]){let $=p.createElement("p");$.textContent=`${P}: ${S===null?o?"结账时确认":"Confirmed at checkout":be(S,e.currency)}`,Y.append($)}let g=p.createElement("p");g.textContent=`${o?"生效时间":"Effective"}: ${e.effectiveAt}`,Y.append(g)}if(m){for(let P of E){if(G===null&&P===De)continue;let S=p.createElement("p"),$=be(P.amountMinor,e.currency)+Ue(P.interval,h,P.intervalCount);S.textContent=G!==null&&q!==void 0?Ne($,q):$,P.amountAfterOfferMinor!==void 0&&(S.textContent+=` · ${o?"优惠结束后":"After the offer"} ${be(P.amountAfterOfferMinor,e.currency)}${Ue(P.interval,h,P.intervalCount)}`),Y.append(S)}let g=m.subscriptionTerms?.trial;if(g){let P=p.createElement("p");P.textContent=o?`试用 ${g.days} 天;${g.cardRequired?"需要提供付款方式":"无需提供付款方式"}`:`Trial days: ${g.days}; ${g.cardRequired?"a payment method is required":"no payment method is required"}`,Y.append(P)}for(let P of[...m.expectedEffects.map(S=>S.description),...m.requiredConsents.map(S=>S.summary)]){let S=p.createElement("p");S.textContent=P,Y.append(S)}}else if(!_(e)){for(let g of e.lines){if(G!==null||g!==De){let P=p.createElement("p"),S=`${be(g.catalogAmountMinor,e.currency)}${Ue(g.interval,h,g.intervalCount??1)}`;P.textContent=G!==null&&g.trial?(e.lines.length>1?`${g.productName} · `:"")+Ne(S,g.trial.days):`${g.productName} · ${S}`,Y.append(P)}for(let P of g.prepaid??[]){let S=p.createElement("p"),$=i.view?.capabilities.plans[g.productVersionId]?.prepaid?.find(rt=>rt.internalFeatureId===P.internal_feature_id);S.textContent=`${$?.name??P.internal_feature_id} · ${P.quantity} ${o?"份":"packs"} × ${P.terms.units}`,$&&(S.textContent+=Ue($.reset==="week"||$.reset==="month"||$.reset==="year"?$.reset:"one_time",h,$.resetCount)),Y.append(S)}if(g.trial){let P=p.createElement("p");P.textContent=o?`试用 ${g.trial.days} 天;${g.trial.cardRequired?"需要提供付款方式":"无需提供付款方式"}`:`Trial days: ${g.trial.days}; ${g.trial.cardRequired?"a payment method is required":"no payment method is required"}`,Y.append(P)}}if(!e.charge){let g=p.createElement("p");g.textContent=o?"目录价格;最终金额以结账时税费和试用规则为准。":"Catalog price; the final charge depends on checkout taxes and trial terms.",Y.append(g)}}for(let g of Y.children)g.style.margin="0";c.append(r,s),n.append(l,...Y.childElementCount?[Y]:[],c),W.prepend(n),L?.responsive||n.scrollIntoView?.({block:"nearest"}),r.focus({preventScroll:!0}),de=n,fe&&je(!0),f=null}async function qe(){if(!v)return;if(f=qe,!xe){let n=i.view,r=n?.document.buttons[v.actionId],s=n&&r?.type==="checkout"?Ee(r.product,v.selection,n.capabilities):null;if(!n||!s)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");if(!Re){let l=Ft(),m=l?await l.result:void 0;if(w)return;let h=a.resolveSubscriptionChange;if(h||m){let E={actionId:v.actionId,productVersionId:s,featureQuantities:Le(n.document.screen,s,v.selection,n.capabilities)},q=m?[async()=>m(E)]:[],G=h?await h(E,...q):await q[0]?.();if(w)return;G!==void 0&&(v.subscriptionChange=fn.parse(G))}Re=!0}let c=J?.offerId;if(J&&!c){if(!a.claimCoupon)throw new k("CAPABILITY_UNAVAILABLE","Coupon claiming is unavailable");let{offer:l}=await a.claimCoupon(J.id,v.requestId);if(w)return;if(!l||l.couponId!==J.id||l.status!=="issued"||!(Date.parse(l.expiresAt)>Date.now()))throw v=null,J=void 0,f=async()=>{$e(await i.refresh()),f=null},new k("COUPON_UNAVAILABLE","This Coupon is no longer available for this purchase");c=l.id}if(!J&&!n.document.screen.actions.some(l=>l.id===v?.actionId&&typeof l.properties.couponBinding=="string")&&(c=await a.resolveOfferId?.({actionId:v.actionId,productVersionId:s,featureQuantities:Le(n.document.screen,s,v.selection,n.capabilities)})),w)return;c!==void 0&&(v.offerId=c),xe=!0}if(!I()){y.hidden=!1;return}let e;try{e=await i.preview(v)}catch(n){throw i.canReselect===!0&&(v=null,xe=!1,Re=!1,J=void 0,f=null),n}if(J&&(_(e)?(()=>{let n=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0);return n?.couponId!==J.id||n.grantId!==v.offerId})():e.discount?.couponId!==J.id||e.discount.offerId!==v.offerId))throw new k("INVALID_RESPONSE","The quote did not apply the Coupon selected on this Paywall");if(w)return;let t=e.merchantTerms;if(a.purchaseConfirmation!=="paywall"||a.confirmOnHostedCheckout&&I()&&!_(e)&&e.provider==="merchant"&&e.billingSubscriptionId===null&&t?.request.action==="purchase"&&t.request.mode==="subscription"&&t.subscriptionTerms?.trial===null&&t.requiredConsents.length===0&&Date.parse(e.expiresAt)>Date.now()){if(!I()){y.hidden=!1;return}if(!(Date.parse(e.expiresAt)>Date.now()))throw new k("INVALID_REQUEST",o?"此报价已过期,请重新选择套餐。":"This quote has expired. Choose a plan again.");let n=ae?"":o?"正在打开收银台…":"Opening checkout…";d.textContent=n;try{await Oe()}catch(r){w||we(r)}finally{d.textContent===n&&(d.textContent="")}return}sn(e)}function Ie(e="destroy",t=!1){if(w)return;w=!0;let n=pt;pt=void 0,z(n),a.signal?.removeEventListener("abort",se),i.signal?.removeEventListener("abort",se),M.finish("dismissed"),Vt?.(),Pt(),p.removeEventListener("visibilitychange",Wt),Z.abort(),Mt?.disconnect(),O?.destroy(),i.destroy(),A.removeEventListener("cancel",cn),N.remove(),U.remove(),t||ln(),e==="dismiss"&&z(a.onDismiss)}function ln(){if(L?.destroy(),ue){ue.release();return}A.open&&A.close(),A.remove(),T()}F=Ie;async function Fe(){if(!he||w||ze||ie==="closing"||!ie&&!I())return;if(!x){Ie("dismiss");return}let e=p.createElement("p");e.setAttribute("role","status"),e.textContent=o?"正在关闭…":"Closing…",me||(me=p.createElement("div"),me.style.cssText=W.style.cssText,W.replaceWith(me),pe.inert=!0),N.hidden=!1,me.replaceChildren(e,N),ie="closing",N.setAttribute("aria-disabled","true"),N.focus({preventScroll:!0});try{await x.dismiss()}catch(t){w||z(a.onError,t)}w||(ie="retry",e.textContent=o?"未能确认关闭,请重试。":"Could not confirm closure. Try again.",N.textContent=o?"重试关闭":"Retry closing",N.removeAttribute("aria-label"),N.removeAttribute("aria-disabled"))}N.onclick=()=>{Fe()};function cn(e){e.preventDefault(),Fe()}A.addEventListener("cancel",cn),ce.onclick=()=>{j(C?Et:et)},y.onclick=()=>{if(Q){Q.retry?.();return}f&&j(f)};function Rt(e){M.finish("error",e),Ie()}function At(){if(!(!Qt||he||w||ze||L&&!I()))try{let e=t=>{a.focusAtReveal&&(T=_t(p)),a.settleMotionAtReveal?O?.setHidden?.(!1,!0):O?.setHidden?.(!1),ft?.(),L&&(A.open||A.showModal(),L.responsive&&A.focus({preventScroll:!0}),!t&&a.loading!=="host"&&Cn(A,L.type,L.responsive)),t&&a.loading!=="host"&&typeof pe.animate=="function"&&!p.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches&&pe.animate([{opacity:.55},{opacity:1}],{duration:160,easing:"ease-out"}),he=!0,Xe()};x?x.present(t=>M.present(n=>e(t??n))):M.present(e)}catch(e){Rt(e),we(e)}}try{if(Me.type==="inline"?(ct(),ft=xn(U,H),H.append(U)):(A.setAttribute("aria-label",u.document.name),N.textContent="×",N.setAttribute("aria-label",o?"关闭":"Close"),Pn(N,u.document.screen.theme),N.hidden=gn(u.document),(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&ue?.content?ue.content.append(N,U):A.replaceChildren(N,U),ue||H.append(A),L=bn(A,{...u.document.screen,presentation:Me},dt),L.latch(),L.responsive&&(U.style.display="flex",U.style.flexDirection="column",U.style.maxHeight="100%",pe.style.overflow="clip",pe.style.minHeight="0"),ue||(ft=En(A))),st&&ee){let n=st(ee);if(typeof n=="function"&&(w?z(n):pt=n),w)throw new DOMException("Presentation cancelled","AbortError");ct()}O=ne(pe,{mode:"live",rendererUrl:"bundled",title:u.document.name,closeActions:Un,onAuthoredClose(n){ie||w||(N.hidden=n)},hostPresentation:()=>L?.type??Me.type,reportContentHeight:L?.responsive,onResize:n=>{if(!L?.responsive)return;let r=Math.min(n,ut);pe.style.height=`${r}px`,L.setContentHeight(r+Ht())},onSelection(n){for(let[r,s]of Object.entries(n))typeof s=="number"&&typeof K[r]=="number"&&K[r]!==s&&Bt.add(r);K=n,ve(),Xe()},onAction(n,r={},s,c){if(!he||w||ie)return;let l=i.view,m=l?.document.buttons[n];if(!m)return;if(Q){m.type==="close"&&Fe();return}if(m.type==="close"&&x&&a.resumeCheckout&&i.operation&&mn(R(i.operation))){Fe();return}if(fe)return;if(!I()){kt();return}if(m.type==="close"){j(async()=>{x?.closeAction?await x.closeAction(n):await a.onAction?.(n),Ie(a.onAction?"action":"dismiss")});return}if(m.type==="action"){f=async()=>{if(m.action.type==="event"){if(!a.onEvent)throw new k("EVENT_HANDLER_REQUIRED","Provide the event handler");await a.onEvent(m.action.event)}else a.onOpenUrl?await a.onOpenUrl(m.action.url):p.defaultView?.location.assign(m.action.url);await a.onAction?.(n),f=null},j(f);return}if(ye()&&B){!ge&&B.selection.actionId===n&&j(()=>tt(!0),n);return}if(C){if(C.phase==="payment"&&l&&Se(C.quote,l,n,m.product,r,c)){j(Et,n);return}if(!bt())return}if(!Pe()&&!bt()){ye()&&l&&i.quote&&i.operation&&R(i.operation).type==="checkout"&&Se(i.quote,l,n,m.product,r,c)?j(et,n):d.textContent=o?"当前只能继续原订单。":"Only your original checkout is available.";return}if(de&&i.canReselect===!1){d.textContent=o?"请先确认或取消当前购买。":"Confirm or cancel the current purchase first.",L?.responsive||de.scrollIntoView?.({block:"nearest"}),de.querySelector("button")?.focus({preventScroll:!0});return}if(ye()&&a.terminateCheckout&&l&&i.quote&&i.operation&&i.canReselect===!1&&R(i.operation).type==="checkout"){if(Se(i.quote,l,n,m.product,r,c)){j(et,n);return}let E=Ee(m.product,r,l.capabilities),q;try{if(!E)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");q=Le(l.document.screen,E,r,l.capabilities)}catch(De){we(De);return}let G=i.operation.operationId,Ne={actionId:n,requestId:crypto.randomUUID(),selection:structuredClone(r)},X=vt(l,n,E,r,c);j(()=>Xt(G,Ne,X,{actionId:n,productVersionId:E,selection:Ne.selection,featureQuantities:q}),n);return}if((i.quote||v)&&i.canReselect===!1){let E=!!l&&!!i.quote&&Se(i.quote,l,n,m.product,r,c);nt=!!i.quote&&!E,f=i.quote?()=>xt(E):qe,j(f,n);return}let h=l&&Ee(m.product,r,l.capabilities);if(!l||!h){we(new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(a.onPurchaseIntent){f=null,j(async()=>{let E={actionId:n,productVersionId:h,selection:structuredClone(r),featureQuantities:Le(l.document.screen,h,r,l.capabilities)};ht=!0,await a.onPurchaseIntent(E)},n);return}if(v&&v.actionId!==n){we(new k("COMMAND_PENDING","Finish the current purchase"));return}v||(J=vt(l,n,h,r,c),v={requestId:crypto.randomUUID(),actionId:n,selection:structuredClone(r)},xe=!1,Re=!1),j(qe,n)},onEscape:()=>{Fe()},onError:n=>{let r=new Error(n);!he&&!w&&Rt(r),we(r)},onRendered:n=>{n&&A.setAttribute("aria-label",n),Qt=!0,At()}}),O.setHidden?.(!0),dt();let e=ye()&&!!i.quote&&!!i.operation&&R(i.operation).type==="checkout";K=i.quote?Nn(u,i.quote)??at(u,{}):at(u,{}),O.update(u.document.screen,lt,{capabilities:oe(u),unavailableActions:Ce(u),serverInput:{bindings:[],answers:{}},...Object.keys(K).length?{selection:K}:{}}),Vt=i.subscribe?.($e),$e(i.view??u),await M.wait(O.ready);let t=i.operation;(!e||yt(i.quote))&&(i.quote||t&&(t.confirmedAt||t.checkoutUrl||Ge(t)))&&(f=on,j(f))}catch(e){throw Rt(e),e}return{check:le,host:{get currentResolution(){return u},setPurchaseRecovery(e,t){Q={message:e,retry:t},O?.updateCapabilities?.(oe(u),Ce(u)),ve(),Zt()},get subscriptionUpgradeActive(){return C!==void 0},get observing(){return Ve},get recovery(){return Ln()},async prepareFallback(){if(fe||w||ie||ht)return{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null};je(!0);try{let e=await yn(i);return e.type==="native"&&Ie(),e}finally{je(!1)}},setSuspended(e){ze=e,U.hidden=e,e&&A.open?A.close():!e&&!he?At():!e&&!w&&he&&Me.type!=="inline"&&!A.open&&A.showModal()},destroy:Ie,retainPurchaseDialog(){if(!(w||!A.open||!A.isConnected))return Ie("destroy",!0),{dialog:A,content:ue?.content,release:ln}},refresh:async()=>{if(!I()){if(i.view)return i.view;throw new k("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await i.refresh();return $e(e),At(),e}}}}export{Pr as a};
@@ -1 +1 @@
1
- import{a as s,b as c,c as u}from"./chunk-MYYLRNLZ.js";import{j as m,m as p}from"./chunk-6DE2YAGZ.js";import{b as e}from"./chunk-RTKI4V2J.js";var y=["USD","EUR","CNY","GBP","JPY","CAD","AUD","NZD","CHF","HKD","SGD","KRW","INR","BRL","MXN","TWD","THB","IDR","MYR","PHP","VND","ZAR","AED","SAR","SEK","NOK","DKK","PLN","CZK","HUF","ILS","TRY","RON"],i=e.enum(y);function x(t){let n=i.parse(t.toUpperCase());return["JPY","KRW","VND"].includes(n)?0:2}function I(t,n,r="en",f={}){let a=i.parse(n.toUpperCase());return new Intl.NumberFormat(r,{style:"currency",currency:a,...f}).format(t/10**x(a))}var l=e.enum(["stripe","apple","google","merchant"]),w=e.enum(["membership","credit_pack","lifetime"]),v=e.enum(["active","grace","suspended","inactive","revoked"]),z=e.strictObject({currency:e.string().regex(/^[A-Z]{3}$/),micros:e.string().regex(/^(0|[1-9][0-9]{0,29})$/)});var d=e.object({provider:l,currency:i,intent:e.literal("subscription_change").optional()}).strict();var o=e.strictObject({internal_feature_id:e.uuid(),quantity:m.refine(t=>/[1-9]/.test(t)),properties:p,entityId:e.uuid().optional()}),B=e.strictObject({requirement:o,commerce:d.optional(),paywallId:e.uuid().optional()}),g=e.enum(["not_entitled","insufficient_balance","capacity_exceeded","limit_exceeded","awaiting_topup","authorization_required","payment_blocked","cash_budget_exceeded","unavailable","authentication_required"]),b=e.strictObject({productId:e.string().min(1),productVersionId:e.string().min(1),name:e.string().min(1).max(120),action:e.enum(["purchase","upgrade","addon","topup"]),membershipId:e.string().min(1).nullable(),featureQuantities:e.record(e.uuid(),e.number().int().min(0).max(1e4)).refine(t=>Object.keys(t).length<=100).optional(),currency:i,amountMinor:e.string().regex(/^(0|[1-9]\d{0,8})$/),interval:e.enum(["free","week","month","year","one_time"]),intervalCount:e.number().int().min(1).max(156)}),h=e.strictObject({subject:c,authority:e.enum(["longplay","merchant"]),observedAt:e.iso.datetime({offset:!0}),sourceRevision:e.string().min(1).max(128),requirementDigest:s});function S(t,n){return u({subject:c.parse(t),requirement:o.parse(n)})}var C=e.strictObject({internal_feature_id:e.string().min(1),name:e.string().min(1).max(120),kind:e.enum(["access","metered","credit"]),quantity:m,allowed:e.boolean(),observation:h.optional(),reason:g.nullable(),preview:e.strictObject({scenario:e.enum(["feature_flag","usage_limit"]),candidates:e.array(b).max(20)}).nullable()}).superRefine((t,n)=>{(t.allowed!==(t.reason===null)||t.allowed&&t.preview!==null||new Set(t.preview?.candidates.map(r=>r.productVersionId)).size!==(t.preview?.candidates.length??0)||t.preview?.candidates.some(r=>r.action==="upgrade"!=(r.membershipId!==null)))&&n.addIssue({code:"custom",message:"Invalid access recommendation"})}),T=e.strictObject({paywallId:e.uuid(),requirement:o}),U=e.strictObject({subject:c,requirement:o}),$=C.safeExtend({observation:h.extend({authority:e.literal("merchant")})});function F(t,n){let r=o.parse(t);return n.internal_feature_id===r.internal_feature_id&&n.quantity===r.quantity&&(!n.observation||n.observation.requirementDigest===S(n.observation.subject,r))}export{i as a,x as b,I as c,w as d,d as e,o as f,B as g,b as h,S as i,C as j,U as k,$ as l,F as m};
1
+ import{a as s,b as c,c as u}from"./chunk-7KQWJBFQ.js";import{j as m,m as p}from"./chunk-GNRFL6KF.js";import{b as e}from"./chunk-35JZDDF3.js";var y=["USD","EUR","CNY","GBP","JPY","CAD","AUD","NZD","CHF","HKD","SGD","KRW","INR","BRL","MXN","TWD","THB","IDR","MYR","PHP","VND","ZAR","AED","SAR","SEK","NOK","DKK","PLN","CZK","HUF","ILS","TRY","RON"],i=e.enum(y);function x(t){let n=i.parse(t.toUpperCase());return["JPY","KRW","VND"].includes(n)?0:2}function I(t,n,r="en",f={}){let a=i.parse(n.toUpperCase());return new Intl.NumberFormat(r,{style:"currency",currency:a,...f}).format(t/10**x(a))}var l=e.enum(["stripe","apple","google","merchant"]),w=e.enum(["membership","credit_pack","lifetime"]),v=e.enum(["active","grace","suspended","inactive","revoked"]),z=e.strictObject({currency:e.string().regex(/^[A-Z]{3}$/),micros:e.string().regex(/^(0|[1-9][0-9]{0,29})$/)});var d=e.object({provider:l,currency:i,intent:e.literal("subscription_change").optional()}).strict();var o=e.strictObject({internal_feature_id:e.uuid(),quantity:m.refine(t=>/[1-9]/.test(t)),properties:p,entityId:e.uuid().optional()}),B=e.strictObject({requirement:o,commerce:d.optional(),paywallId:e.uuid().optional()}),g=e.enum(["not_entitled","insufficient_balance","capacity_exceeded","limit_exceeded","awaiting_topup","authorization_required","payment_blocked","cash_budget_exceeded","unavailable","authentication_required"]),b=e.strictObject({productId:e.string().min(1),productVersionId:e.string().min(1),name:e.string().min(1).max(120),action:e.enum(["purchase","upgrade","addon","topup"]),membershipId:e.string().min(1).nullable(),featureQuantities:e.record(e.uuid(),e.number().int().min(0).max(1e4)).refine(t=>Object.keys(t).length<=100).optional(),currency:i,amountMinor:e.string().regex(/^(0|[1-9]\d{0,8})$/),interval:e.enum(["free","week","month","year","one_time"]),intervalCount:e.number().int().min(1).max(156)}),h=e.strictObject({subject:c,authority:e.enum(["longplay","merchant"]),observedAt:e.iso.datetime({offset:!0}),sourceRevision:e.string().min(1).max(128),requirementDigest:s});function S(t,n){return u({subject:c.parse(t),requirement:o.parse(n)})}var C=e.strictObject({internal_feature_id:e.string().min(1),name:e.string().min(1).max(120),kind:e.enum(["access","metered","credit"]),quantity:m,allowed:e.boolean(),observation:h.optional(),reason:g.nullable(),preview:e.strictObject({scenario:e.enum(["feature_flag","usage_limit"]),candidates:e.array(b).max(20)}).nullable()}).superRefine((t,n)=>{(t.allowed!==(t.reason===null)||t.allowed&&t.preview!==null||new Set(t.preview?.candidates.map(r=>r.productVersionId)).size!==(t.preview?.candidates.length??0)||t.preview?.candidates.some(r=>r.action==="upgrade"!=(r.membershipId!==null)))&&n.addIssue({code:"custom",message:"Invalid access recommendation"})}),T=e.strictObject({paywallId:e.uuid(),requirement:o}),U=e.strictObject({subject:c,requirement:o}),$=C.safeExtend({observation:h.extend({authority:e.literal("merchant")})});function F(t,n){let r=o.parse(t);return n.internal_feature_id===r.internal_feature_id&&n.quantity===r.quantity&&(!n.observation||n.observation.requirementDigest===S(n.observation.subject,r))}export{i as a,x as b,I as c,w as d,d as e,o as f,B as g,b as h,S as i,C as j,U as k,$ as l,F as m};
@@ -1 +1 @@
1
- import{b as e}from"./chunk-RTKI4V2J.js";var r=e.number().int().min(1).max(Number.MAX_SAFE_INTEGER),m=e.enum(["unknown","denied","provisional","granted"]),d=e.enum(["ios","android"]),i=e.strictObject({installationId:e.uuid(),publicKey:e.string().regex(/^[A-Za-z0-9_-]{80,200}$/),issuedAt:e.iso.datetime({offset:!0}),signature:e.string().regex(/^[A-Za-z0-9_-]{86}$/)}),a=e.string().regex(/^[a-f0-9]{64}$/),p=i.extend({sequence:r,platform:d,credentialDigest:a}),f=i.extend({credentialDigest:a}),x=i.extend({sequence:r,platform:d}),l=i.extend({sequence:r,credentialDigest:a,connectionId:e.uuid().nullable(),kind:e.enum(["fcm_token","apns_token"]).nullable(),token:e.string().regex(/^[\x21-\x7e]{16,4096}$/).nullable(),permission:m}),g=l,b=l.extend({challenge:e.string().regex(/^[A-Za-z0-9_-]{100,3500}$/)}),S=e.strictObject({requested:e.literal(!0),expiresAt:e.iso.datetime({offset:!0})}),A=e.strictObject({installationId:e.uuid(),bound:e.boolean(),identitySeq:r,bindingGeneration:r,addressSeq:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),addressRevision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),connectionId:e.uuid().nullable(),addressStatus:e.enum(["active","invalid"]).nullable(),permission:m}),I=e.strictObject({channel:e.enum(["email","sms","voice","push"]),state:e.enum(["unknown","allowed","denied"]),revision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),updatedAt:e.iso.datetime({offset:!0}).nullable()}),P=e.strictObject({state:e.enum(["allowed","denied"]),revision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER-1)});function y(s,c,t){let n=["indiana_push_v1",s,c.projectId,c.environment,t.installationId,t.publicKey,t.issuedAt];s==="bind"?n.push(t.sequence,t.platform,t.credentialDigest):s==="detach"?n.push(t.sequence,t.platform):s==="read"?n.push(t.credentialDigest):n.push(t.sequence,t.credentialDigest,t.connectionId,t.kind,t.token,t.permission),s==="recovery_confirm"&&n.push(t.challenge);let u=JSON.stringify(n);if([...u].some(o=>o.charCodeAt(0)>127))throw new Error("Push proof fields must be ASCII");return Uint8Array.from(u,o=>o.charCodeAt(0))}export{p as a,f as b,x as c,l as d,g as e,b as f,S as g,A as h,I as i,y as j};
1
+ import{b as e}from"./chunk-35JZDDF3.js";var r=e.number().int().min(1).max(Number.MAX_SAFE_INTEGER),m=e.enum(["unknown","denied","provisional","granted"]),d=e.enum(["ios","android"]),i=e.strictObject({installationId:e.uuid(),publicKey:e.string().regex(/^[A-Za-z0-9_-]{80,200}$/),issuedAt:e.iso.datetime({offset:!0}),signature:e.string().regex(/^[A-Za-z0-9_-]{86}$/)}),a=e.string().regex(/^[a-f0-9]{64}$/),p=i.extend({sequence:r,platform:d,credentialDigest:a}),f=i.extend({credentialDigest:a}),x=i.extend({sequence:r,platform:d}),l=i.extend({sequence:r,credentialDigest:a,connectionId:e.uuid().nullable(),kind:e.enum(["fcm_token","apns_token"]).nullable(),token:e.string().regex(/^[\x21-\x7e]{16,4096}$/).nullable(),permission:m}),g=l,b=l.extend({challenge:e.string().regex(/^[A-Za-z0-9_-]{100,3500}$/)}),S=e.strictObject({requested:e.literal(!0),expiresAt:e.iso.datetime({offset:!0})}),A=e.strictObject({installationId:e.uuid(),bound:e.boolean(),identitySeq:r,bindingGeneration:r,addressSeq:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),addressRevision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),connectionId:e.uuid().nullable(),addressStatus:e.enum(["active","invalid"]).nullable(),permission:m}),I=e.strictObject({channel:e.enum(["email","sms","voice","push"]),state:e.enum(["unknown","allowed","denied"]),revision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),updatedAt:e.iso.datetime({offset:!0}).nullable()}),P=e.strictObject({state:e.enum(["allowed","denied"]),revision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER-1)});function y(s,c,t){let n=["indiana_push_v1",s,c.projectId,c.environment,t.installationId,t.publicKey,t.issuedAt];s==="bind"?n.push(t.sequence,t.platform,t.credentialDigest):s==="detach"?n.push(t.sequence,t.platform):s==="read"?n.push(t.credentialDigest):n.push(t.sequence,t.credentialDigest,t.connectionId,t.kind,t.token,t.permission),s==="recovery_confirm"&&n.push(t.challenge);let u=JSON.stringify(n);if([...u].some(o=>o.charCodeAt(0)>127))throw new Error("Push proof fields must be ASCII");return Uint8Array.from(u,o=>o.charCodeAt(0))}export{p as a,f as b,x as c,l as d,g as e,b as f,S as g,A as h,I as i,y as j};