@tinkerlandai/longplay-sdk 0.10.85 → 0.10.86

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 (98) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +2 -1
  3. package/dist/check-response-XGOTG3KL.js +1 -0
  4. package/dist/{chunk-5O6YRAHQ.js → chunk-2OBXRQMW.js} +1 -1
  5. package/dist/{chunk-F54HTDAC.js → chunk-3532HSBP.js} +1 -1
  6. package/dist/{chunk-Y7Z6F6Y3.js → chunk-5RWAJLB3.js} +1 -1
  7. package/dist/{chunk-WJDHBJGU.js → chunk-5U3QABVU.js} +1 -1
  8. package/dist/{chunk-ZMDKCBLI.js → chunk-67WFVDTV.js} +1 -1
  9. package/dist/{chunk-JTCS63ER.js → chunk-6VVQWTHV.js} +1 -1
  10. package/dist/{chunk-ZAD5WJWS.js → chunk-6XRQR43F.js} +1 -1
  11. package/dist/{chunk-XMZ2FNYA.js → chunk-7CZEXBQY.js} +1 -1
  12. package/dist/{chunk-E6ND7YQW.js → chunk-7QPCNDIY.js} +1 -1
  13. package/dist/{chunk-45PGU2HW.js → chunk-7ZAM4YRK.js} +1 -1
  14. package/dist/{chunk-DJTZR2NR.js → chunk-A5WUQLAO.js} +1 -1
  15. package/dist/{chunk-U2JO7MX2.js → chunk-BOT6ZDLK.js} +1 -1
  16. package/dist/{chunk-MDNT2TC3.js → chunk-BT7IC765.js} +1 -1
  17. package/dist/{chunk-AJHLDSPG.js → chunk-C4KLIT5L.js} +1 -1
  18. package/dist/{chunk-YEUQXQWK.js → chunk-CHRNCOXJ.js} +1 -1
  19. package/dist/{chunk-2FDRWKO4.js → chunk-CKMSSBJM.js} +1 -1
  20. package/dist/{chunk-TORHBU45.js → chunk-CO6HDNOC.js} +1 -1
  21. package/dist/{chunk-MMAMK7OQ.js → chunk-DUS5V65Z.js} +1 -1
  22. package/dist/{chunk-WFRZHLIV.js → chunk-EQUVI5QU.js} +1 -1
  23. package/dist/{chunk-3IDEYQBG.js → chunk-F4AIEI5N.js} +1 -1
  24. package/dist/{chunk-DT2OMMAT.js → chunk-FPJ3FE26.js} +1 -1
  25. package/dist/{chunk-VPT5MFDG.js → chunk-FYMVNLQN.js} +2 -2
  26. package/dist/{chunk-FGAIHKFS.js → chunk-FYUMVOCV.js} +1 -1
  27. package/dist/chunk-HXDWW6SU.js +1 -0
  28. package/dist/{chunk-7SQPGOJV.js → chunk-JS4K6SZB.js} +1 -1
  29. package/dist/{chunk-HSNAFHCP.js → chunk-KCUE2VFJ.js} +1 -1
  30. package/dist/{chunk-533YCYLO.js → chunk-KEM6QYLF.js} +1 -1
  31. package/dist/{chunk-MGVWCLVQ.js → chunk-KX67ZM7H.js} +1 -1
  32. package/dist/{chunk-CQYEM7U6.js → chunk-LFR2LWYC.js} +1 -1
  33. package/dist/{chunk-7C4OOGQX.js → chunk-LQV7EC5H.js} +1 -1
  34. package/dist/chunk-LXFNDTXL.js +1 -0
  35. package/dist/{chunk-MEBCS2JG.js → chunk-ME6QTD5Y.js} +1 -1
  36. package/dist/{chunk-MUU6LV3R.js → chunk-MOIVJERE.js} +1 -1
  37. package/dist/{chunk-LIWSSQAG.js → chunk-OQQXGPUR.js} +1 -1
  38. package/dist/{chunk-4SDB3T2F.js → chunk-PAKL7S5P.js} +1 -1
  39. package/dist/{chunk-BQUSJPMG.js → chunk-PPMGIETB.js} +1 -1
  40. package/dist/{chunk-FBHEBXK4.js → chunk-PUDTOCQF.js} +1 -1
  41. package/dist/{chunk-F53UXSUI.js → chunk-R2GBEHP2.js} +1 -1
  42. package/dist/chunk-RMELSVQL.js +1 -0
  43. package/dist/{chunk-BZ7HAITJ.js → chunk-S2S4ROGY.js} +1 -1
  44. package/dist/{chunk-RGXNLSFL.js → chunk-SX7U2ONB.js} +1 -1
  45. package/dist/{chunk-AECGOS7O.js → chunk-UGATOG2T.js} +1 -1
  46. package/dist/{chunk-EXHNZVTM.js → chunk-VXNN3RV3.js} +1 -1
  47. package/dist/{chunk-52G77TMV.js → chunk-WG53PTYZ.js} +2 -2
  48. package/dist/{chunk-KICIH4PE.js → chunk-WMUKARGY.js} +1 -1
  49. package/dist/{chunk-7ROXL6N2.js → chunk-XLGNBPGF.js} +1 -1
  50. package/dist/{chunk-JUI7TMIM.js → chunk-XUACQGUI.js} +1 -1
  51. package/dist/{chunk-OKHCU6ET.js → chunk-Y3W5G4BF.js} +1 -1
  52. package/dist/{chunk-HMT4SHIK.js → chunk-Y55OBV7D.js} +1 -1
  53. package/dist/{chunk-4HCUQJOA.js → chunk-Y6KA56V2.js} +1 -1
  54. package/dist/{content-KXWLR6IG.js → content-2NMAKYJP.js} +1 -1
  55. package/dist/{funnel-host-purchase-IT23CWX7.js → funnel-host-purchase-G7K233EQ.js} +1 -1
  56. package/dist/funnel-host-recovery-paywall-TCOEU3CT.js +1 -0
  57. package/dist/{funnel-paywall-copies-LZZILAWG.js → funnel-paywall-copies-LPOTYSTS.js} +1 -1
  58. package/dist/funnel-paywall-prerender-TDBKRRPB.js +1 -0
  59. package/dist/funnel-route-prediction-Q4HMRAVQ.js +1 -0
  60. package/dist/funnel-route-source-HYWJWEM3.js +1 -0
  61. package/dist/funnel-runtime-host-5LXWBUIN.js +1 -0
  62. package/dist/index.d.ts +7 -0
  63. package/dist/index.js +1 -1
  64. package/dist/merchant-bridge-contracts-OIYML3DE.js +1 -0
  65. package/dist/native-shell.js +1 -1
  66. package/dist/openrouter.js +1 -1
  67. package/dist/operation-contracts-YJM6772C.js +1 -0
  68. package/dist/page.js +1 -1
  69. package/dist/paywall-U4RTF4MV.js +1 -0
  70. package/dist/paywall-content-DIBAGNQG.js +1 -0
  71. package/dist/paywall-session-G24MWXYA.js +1 -0
  72. package/dist/popup.js +1 -1
  73. package/dist/react-native.js +1 -1
  74. package/dist/screen-renderer-HJOKBOZH.js +1 -0
  75. package/dist/server.js +1 -1
  76. package/dist/{visual-dom-5LUN4AHO.js → visual-dom-KUABNJV6.js} +1 -1
  77. package/dist/visual.js +1 -1
  78. package/package.json +1 -1
  79. package/dist/check-response-SOTWWQ3J.js +0 -1
  80. package/dist/chunk-JJEOS374.js +0 -1
  81. package/dist/chunk-OT6DGH5B.js +0 -1
  82. package/dist/chunk-YQ2TU6TG.js +0 -1
  83. package/dist/funnel-host-recovery-paywall-QGH574CM.js +0 -1
  84. package/dist/funnel-paywall-prerender-BKPL2SLY.js +0 -1
  85. package/dist/funnel-route-prediction-7B5FGESC.js +0 -1
  86. package/dist/funnel-route-source-F5OML4HC.js +0 -1
  87. package/dist/funnel-runtime-host-7UOEQRZV.js +0 -1
  88. package/dist/merchant-bridge-contracts-47PO4USZ.js +0 -1
  89. package/dist/operation-contracts-EDUVKUPX.js +0 -1
  90. package/dist/paywall-GUW4NI2B.js +0 -1
  91. package/dist/paywall-content-HMUHTWWL.js +0 -1
  92. package/dist/paywall-session-NJHRHCKM.js +0 -1
  93. package/dist/screen-renderer-XJDNUC7B.js +0 -1
  94. /package/dist/{chunk-CILM5XMH.js → chunk-FRK6322O.js} +0 -0
  95. /package/dist/{chunk-VPT5MFDG.js.LEGAL.txt → chunk-FYMVNLQN.js.LEGAL.txt} +0 -0
  96. /package/dist/{chunk-OJM6ORHE.js → chunk-KV5MZ4NI.js} +0 -0
  97. /package/dist/{chunk-ZL247MPX.js → chunk-W22ESUYY.js} +0 -0
  98. /package/dist/{chunk-52G77TMV.js.LEGAL.txt → chunk-WG53PTYZ.js.LEGAL.txt} +0 -0
@@ -1 +1 @@
1
- import{a as xn,c as Sn,d as Lt,f as Mt,g as Tn,k as On}from"./chunk-YEUQXQWK.js";import{a as Cn,b as Ye}from"./chunk-W32FI2A2.js";import{e as Pn,f as vn,g as kn,h as In,j as Ut,k as ct,l as En,m as An,n as Rn}from"./chunk-TORHBU45.js";import{a as Ot,b as yn,d as Nt,e as gn,f as wn}from"./chunk-HMT4SHIK.js";import{a as st,b as oe,d as Dt,f as _t,j as bn}from"./chunk-MUU6LV3R.js";import{b as ke}from"./chunk-ZAD5WJWS.js";import{B as L,C as ot,D as Ge,E as Se,y as mn}from"./chunk-F54HTDAC.js";import{r as Le,t as Ie}from"./chunk-OKHCU6ET.js";import{i as hn}from"./chunk-FGAIHKFS.js";import{c as ve,j as We}from"./chunk-MMAMK7OQ.js";import{c as Tt}from"./chunk-U2JO7MX2.js";import{a as k}from"./chunk-AECGOS7O.js";import{a as K}from"./chunk-DSPLGTQI.js";async function Nn(j,a,A){if(!Ge(a))throw new k("INVALID_RESPONSE","A verified completed purchase is required");let N=j?We.parse(j):null;if(await A.onComplete?.(a),!N||!A.check)return;let G=We.parse(await A.check());if(G.internal_feature_id!==N.internal_feature_id||G.quantity!==N.quantity||N.observation!==void 0&&(G.observation===void 0||G.observation.requirementDigest!==N.observation.requirementDigest||G.observation.authority!==N.observation.authority||Tt(G.observation.subject)!==Tt(N.observation.subject)))throw new k("INVALID_RESPONSE","The access requirement changed");G.allowed&&await A.onAccessGranted?.(G)}function Dn(j){return Object.entries(j.document.buttons).filter(([,a])=>a.type==="checkout"&&a.product.type==="fixed"&&!ke(a.product,{},j.capabilities)).map(([a])=>a)}function _n(j,a){let A=L(a)?void 0:a.lines[0];if(!L(a)&&(a.lines.length!==1||!A))return;let N=L(a)?a.productVersionId:A.productVersionId,{screen:G,buttons:se}=j.document,Q=new Map(L(a)?Object.entries(a.featureQuantities??{}):(A?.prepaid??[]).map(C=>[C.internal_feature_id,C.quantity]));function ce(C,d){if(C.hidden)return!1;if(C.type==="plan_picker"&&j.capabilities.pickers[C.id]?.options.includes(N))return d[C.id]=N,!0;if(C.type==="quantity_picker"){let ne=Q.get(C.internalFeatureId);return ne!==void 0&&(!C.bind?.plan||C.bind.plan===N)&&(d[C.id]=ne),!1}if(C.type==="button"&&C.action){let ne=se[C.action];return ne?.type==="checkout"&&ne.product.type==="fixed"&&ne.product.productVersionId===N}if(C.type!=="stack")return!1;let te=C.interaction,i=C.bind?.plan===N;for(let[ne,h]of C.children.entries()){let Z={},M=ce(h,Z);if(te?.type==="toggle"||te?.type==="tabs"){if(!M)continue;return d[C.id]=te.type==="toggle"?ne===0:h.id,Object.assign(d,Z),!0}Object.assign(d,Z),M&&(i=!0,te?.type==="select"&&te.purpose==="product"&&te.pickerId&&h.type==="stack"&&h.bind?.plan===N&&(d[C.id]=h.id,d[te.pickerId]=N))}return i}for(let C of G.pages){let d={__page:C.id};if(ce(C.root,d))return d}}var qn="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 kr(j,a,A){let N=a.focusAtReveal?()=>{}:Ut(j.ownerDocument),G=()=>{Q.finish("dismissed"),N()},se=()=>G(),Q=En(j,a,"paywall",()=>{G(),K(a.onDismiss)},xn);a.signal?.throwIfAborted(),a.signal?.addEventListener("abort",se,{once:!0});let ce=null,C,d,te;try{if(Q.start(!0,a.loadingDocument?.screen.strings.defaultLocale,a.loadingDocument??null),Q.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(ce=a.check?We.parse(await Q.wait(a.check(),ct)):null,ce?.allowed)return Q.finish("skipped"),a.signal?.removeEventListener("abort",se),N(),await a.onAccessGranted?.(ce),{check:ce,host:null};let[e,n]=await Promise.allSettled([Q.wait(import("./screen-renderer-XJDNUC7B.js")),Q.wait(a.start().then(r=>(Q.cancelled&&r.destroy(),r)),ct)]);if(e.status==="rejected")throw n.status==="fulfilled"&&n.value.destroy(),e.reason;if(n.status==="rejected")throw n.reason;te=e.value,C=n.value,a.signal?.throwIfAborted(),C.signal?.throwIfAborted(),C.signal?.addEventListener("abort",se,{once:!0});let t=C.view??await Q.wait(C.refresh(),ct);if(!t)throw new k("INVALID_RESPONSE","Paywall presentation is missing");C.signal?.throwIfAborted(),d=t}catch(e){throw Q.finish("error",e),A?.retainedDialog?.release(),a.signal?.removeEventListener("abort",se),C?.signal?.removeEventListener("abort",se),C?.destroy(),N(),e}let i=C,{mountScreenPreview:ne}=te,h=j.ownerDocument,Z=new AbortController,M=h.createElement("section"),pe=h.createElement("div"),Y=h.createElement("div"),lt=a.mountControls,ee=lt?h.createElement("div"):void 0,f=h.createElement("p"),y=h.createElement("button"),le=h.createElement("button"),_=h.createElement("button");(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&A?.hostPaywallTarget&&!A.retainedDialog&&d.document.presentation.type==="modal"&&(A.retainedDialog=In(A.hostPaywallTarget));let ue=A?.retainedDialog,S=ue?.dialog??h.createElement("dialog"),Me=ue&&d.document.presentation.type==="inline"?{type:"modal",size:"md"}:d.document.presentation,re=Me.type==="inline"?Y:h.createElement("div"),ut=i.locale||d.document.screen.strings.defaultLocale,o=ut.toLowerCase().startsWith("zh"),Un=o?"正在处理…":"Processing…",Ln=o?"正在准备报价…":"Preparing your price…",U=Sn(d.document.screen.theme);M.dataset.indianaPaywall="",M.setAttribute("aria-label",d.document.name),M.style.cssText=U.root,Y.style.cssText=U.controls,f.style.cssText=U.message,f.setAttribute("role","status"),_.style.cssText=U.link,_.textContent=o?"关闭":"Close",y.style.cssText=U.secondary,y.textContent=o?"重试":"Retry",y.hidden=!0,le.type="button",le.style.cssText=U.primary,le.textContent=o?"继续付款":"Continue payment",le.hidden=!0,re.append(f,le,y),Y.append(_),ee&&(ee.style.cssText="flex:1 0 100%;min-width:0",ee.hidden=!0,Y.prepend(ee)),re!==Y&&(re.dataset.indianaPaywallStatus="",re.style.cssText="display:none;padding:0",M.append(re)),M.append(pe,Y);let dt=()=>{let e=$n();f.style.cssText=e?`${U.message};${qn}`:U.message,Kt();let n=c=>!c.hidden&&(c!==f||!!f.textContent&&!e);if(re!==Y&&(re.style.cssText=!ie&&[...re.children].some(n)?`${U.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 t=me??Y,r=![...t.children].some(n),l=[...t.children].some(c=>c!==_&&n(c));t.style.cssText=r?U.controls.replace(/padding:[^;]+/,"padding:0"):l?`${U.controls};${U.pinned}`:U.controls,ft()},Vt=typeof MutationObserver>"u"?void 0:new MutationObserver(dt);Vt?.observe(M,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let Mn=Object.entries(d.document.buttons).filter(([,e])=>e.type==="close").map(([e])=>e),D,$t,Ve=!1,Ht=JSON.stringify(d.capabilities),q;function xe(e){let n=Dn(e);if(q||fe&&!ae||F&&(P||!be()||we))return Oe(e).map(({actionId:r})=>r);if(Ct()||!P&&be())return n;let t=P?bt(e):Pt(e);return[...new Set([...n,...Oe(e).map(({actionId:r})=>r).filter(r=>!t.includes(r))])]}function $e(e){if(w)return;let n=d.id!==e.id;d=e;let t=JSON.stringify(e.capabilities);if(n||t!==Ht){let r=!b&&!i.quote&&!i.operation?st(e,J,jt):J;n||JSON.stringify(r)!==JSON.stringify(J)?(J=r,D?.update(e.document.screen,ut,{capabilities:oe(e),unavailableActions:xe(e),serverInput:{bindings:[],answers:{}},selection:J})):D?.updateCapabilities(oe(e),xe(e)),Ht=t}Hn(e),Ee(),Ze()}let V,pt=0;function Qt(){return(me??Y).getBoundingClientRect().height+(re===Y?0:re.getBoundingClientRect().height)}function ft(){let e=h.defaultView;if(!V?.responsive||!e)return;let n=me??Y,t=e.innerHeight-(V.type==="modal"?32:0);n.style.maxHeight=`${Math.max(1,t)}px`,n.style.overflowY="auto",n.style.flexShrink="0",pt=Math.max(1,t-Qt()),D?.resizeViewport?.(pt,e.innerWidth)}let w=!1,fe=!1,b=null,ht,ze=!1,Bt=!1,he=!1,mt,Ke=!1,ie,me;function Vn(){return fe||w||ie||Ke?{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null}:Nt(i)}let E=()=>!w&&!ze&&!ie&&a.canInteract?.()!==!1,$,ye=!1,Te=!1,yt,m=null,de=null,Je="",ge=()=>a.checkoutNavigation==="after_confirmation"&&!!(a.terminateCheckout||a.resumeCheckout),J={},jt=new Set,ae,P;function gt(e){return!!e&&L(e)&&e.timing==="immediate"&&e.execution.provider==="merchant"}let wt=o?"正在确认付款…":"Confirming payment…",F=null,we,Xe,qt=!1,be=()=>a.allowNewPurchase!==!1||qt;function Ft(){return JSON.stringify([d.id,d.capabilities])}function Wt(){let e=yt;return e&&e.read===a.prepareSubscriptionChange&&e.basis===Ft()?e:void 0}function Ze(){let e=a.prepareSubscriptionChange;if(!e||!he||!E()||!be()||a.onPurchaseIntent||h.visibilityState==="hidden"||b||i.quote||i.operation||!Oe(d).length||Wt())return;let n=Z.signal,t=new Promise(r=>{let l=()=>r(void 0);n.addEventListener("abort",l,{once:!0}),Promise.resolve().then(()=>(n.throwIfAborted(),e(n))).then(c=>r(n.aborted?void 0:c),l).finally(()=>n.removeEventListener("abort",l))});yt={read:e,basis:Ft(),result:t}}let Gt=()=>{h.visibilityState==="hidden"?yt=void 0:Ze()};h.addEventListener("visibilitychange",Gt);function Oe(e){return Object.entries(e.document.buttons).flatMap(([n,t])=>t.type==="checkout"?[{actionId:n,policy:t}]:[])}function Yt(e){let n=P?.quote;return n?Oe(e).filter(({actionId:t,policy:r})=>Ne(n,e,t,r.product,J)).map(({actionId:t})=>t):[]}function bt(e){return P?.phase==="payment"?Yt(e):[]}function Ct(){return(P?P.phase==="payment":!be())&&(be()||!!a.prepareUpgradeReplacement)&&ge()&&!!a.terminateCheckout&&!!i.quote&&i.canReselect===!1&&!!i.operation&&R(i.operation).type==="checkout"}function Pt(e){let n=i.quote;return!ge()||F||!n||!i.operation||R(i.operation).type!=="checkout"?[]:Oe(e).filter(({actionId:t,policy:r})=>Ne(n,e,t,r.product,J)).map(({actionId:t})=>t)}function Ee(){let e=q?[]:P?bt(d):Pt(d),n=a.allowNewPurchase===!1&&!!i.operation&&R(i.operation).type==="checkout";le.hidden=!!q||(P?P.phase!=="payment":!n)||e.length>0,Kt(e)}function zt(){if(!(ae===void 0||q))return f.textContent?f.textContent:P?.phase==="checking"?wt:void 0}function $n(){return!!D?.updateCheckoutControls&&!!f.textContent&&zt()!==void 0}let et;function Kt(e=q?[]:P?bt(d):Pt(d)){if(!D?.updateCheckoutControls)return;let n=zt(),t=ge()||!!P;if(!n&&!t&&et?.on!==D)return;let r={actions:Oe(d).map(({actionId:c})=>c),resume:n?[ae]:t?e:[],resumeLabel:n??(o?"继续付款":P?"Continue payment":"Continue checkout"),busy:ae},l=JSON.stringify(r);et?.on===D&&et.key===l||(et={on:D,key:l},D.updateCheckoutControls(r))}function Jt(){de?.remove(),de=null}async function tt(){if(F)return;if(a.resumeCheckout&&i.operation){let n=i.operation.operationId;try{await a.resumeCheckout(n)}catch(t){if(!(t instanceof k&&t.code==="PURCHASE_PENDING"))throw t;let r=await i.read();if(!E())return;if(r.operationId!==n||R(r).type==="checkout")throw t;await H(r,!1)}return}let e=await i.read();if(R(e).type!=="checkout")return H(e,!1);E()&&(He.delete(e.operationId),await Qe(e))}function vt(){we?.destroy(),we=void 0,Xe=void 0}function Xt(){let e=F;if(!e||we)return;let n=o?"仍在核对原订单,暂时无法更换套餐。":"We’re still checking the original purchase before changing plans.",t=Date.now()+6e5,r=Cn({document:h,delay:()=>Date.now()<t?5e3:void 0,async run(){if(!E())return;let l=await i.read();if(we!==r||!E())return;if(l.operationId!==e.operationId)throw new k("PURCHASE_PENDING","The original Checkout changed");let c=R(l);c.type==="native"?(vt(),f.textContent=o?"原订单已关闭。你可以继续更换套餐。":"The original checkout is closed. You can continue changing plans.",y.textContent=o?"继续更换套餐":"Continue changing plans",m=()=>nt(),y.hidden=!1):(c.type==="complete"||c.type==="fulfillment"||c.type==="recording")&&(vt(),F=null,y.hidden=!0,await H(l,!1))}});we=r,Xe=async()=>{try{await r.refresh()}finally{we===r&&(f.textContent=n,y.hidden=!1)}},m=Xe,y.textContent=o?"查询结果":"Check result",y.hidden=!1,f.textContent=n,r.schedule()}async function nt(e=!1,n=!1){let t=F;if(!t)return;m=()=>nt(),P&&(y.textContent=o?"查询状态":"Check status"),y.hidden=!0;let r=async()=>{if(!be()&&a.prepareUpgradeReplacement){let c=await a.prepareUpgradeReplacement(t.operationId,t.intent);if(!E())return;qt=!0,$e(c)}F=null,P&&De(P.quote),Jt(),b=t.selection,$=t.coupon,ye=!1,Te=!1,await qe()};if(n&&!be()&&a.prepareUpgradeReplacement)return r();let l=Date.now()+2e4;for(;E();){let c=await i.read();if(c.operationId!==t.operationId)throw new k("PURCHASE_PENDING","The original Checkout changed");if(!E())break;let s=R(c);if(s.type==="native"){await r();return}if(s.type==="complete"||s.type==="fulfillment"||s.type==="recording"){F=null,P?await Ae(P.quote,c):await H(c,!1);return}if(e&&s.type==="checkout"){e=!1;try{await a.terminateCheckout(t.operationId)}catch(u){K(a.onError,u)}}if(Date.now()>=l){P&&s.type==="checkout"&&(F=null,await Ae(P.quote,c));break}await Ye(1e3,h,Z.signal)}!F||w||(P?(f.textContent=o?"仍在核对原升级单,暂时无法更换套餐。":"We’re still checking the original upgrade before changing plans.",y.hidden=!1):Xt())}async function Zt(e,n,t,r){if(m=()=>Zt(e,n,t,r),await a.beforeCheckoutReplacement?.(structuredClone(r)),!E())return;let l=i.operation;if(l?.operationId!==e||R(l).type!=="checkout"){m=null,l&&await H(l,!1);return}F={operationId:e,selection:n,coupon:t,intent:r},P&&(f.textContent=o?"正在切换套餐…":"Changing plan…",y.hidden=!0);let c=!1,s=!1;try{let u=await a.terminateCheckout(e);s=(Array.isArray(u?.purchases)?u.purchases:[]).some(p=>p.operationId===e&&p.type==="native")}catch(u){if(u instanceof k&&["CAPABILITY_UNAVAILABLE","NOT_CONFIGURED"].includes(u.code)){F=null,P&&(m=It,y.textContent=o?"查询状态":"Check status",y.hidden=!1),f.textContent=o?"请继续原订单,或等待它过期后再更换方案。":"Continue your original checkout, or wait for it to expire before changing plans.",K(a.onError,u);return}c=u instanceof k&&(u.status??0)>=500,K(a.onError,u)}E()&&await nt(c,s)}function rt(e,n,t,r,l){let c=oe(e).checkoutCoupons?.[n],s=c?c.products[t]:a.claimCoupon&&l?hn(e.capabilities,l,r):void 0;return s?.couponId&&s.planVersionId===t?{id:s.couponId,offerId:s.offerId}:void 0}function Hn(e){fe||b||i.quote||i.operation||Je&&f.textContent===Je||(f.textContent=Object.values(e.capabilities.plans).some(n=>n.available)?"":o?"当前账号暂无可购买的方案。":"No plans are currently available for this account.")}let He=new Map,it=!1;function Ne(e,n,t,r,l,c){let s=L(e),u=!s&&e.lines.length===1?e.lines[0]:void 0,I=ke(r,l,n.capabilities);if(!I||I!==(s?e.productVersionId:u?.productVersionId))return!1;let p=rt(n,t,I,l,c),x;try{x=Ie(n.document.screen,I,l,n.capabilities)}catch{return!1}if(s){let X=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0);return Object.keys(x).length===Object.keys(e.featureQuantities??{}).length&&Object.entries(x).every(([Ue,St])=>e.featureQuantities?.[Ue]===St)&&(!p||X?.couponId===p.id&&(!p.offerId||X.grantId===p.offerId))}if((p||oe(n).checkoutCoupons?.[t])&&(p?.id??null)!==(e.discount?.couponId??null))return!1;let T=Object.fromEntries((u?.prepaid??[]).map(X=>[X.internal_feature_id,X.quantity]));return[...new Set([...Object.keys(x),...Object.keys(T)])].every(X=>(x[X]??0)===(T[X]??0))}let R=e=>yn({quote:i.quote,operation:e,requestId:null,pending:!1,destroyed:w,canReselect:i.canReselect});async function Qe(e){let n=e.merchantExecution,t=R(e),r=t.type==="checkout"?t.checkoutUrl:e.checkoutUrl;if(!(!E()||!r||ot(e)&&t.type!=="checkout"||a.checkoutNavigation==="after_confirmation"&&t.type!=="checkout"||n?.type==="purchase"&&!["not_started","pending"].includes(n.paymentStatus)||He.get(e.operationId)===r)){He.set(e.operationId,r);try{a.onCheckoutUrl?await a.onCheckoutUrl(r):h.defaultView?.location.assign(r)}catch(l){throw He.delete(e.operationId),l}}}let Ce=(e,n=!1)=>{if(e instanceof Dt)m=null,f.textContent=e.customerMessage(o);else if(Tn(e))m=null,f.textContent=n?o?"当前无法在此购买,付款尚未开始。请联系商户。":"Purchases aren’t available here right now. Payment hasn’t started. Contact the merchant for help.":Mt(e,o);else if(n){let t=e instanceof k?e.code:void 0;t==="CAPABILITY_UNAVAILABLE"||t==="NOT_CONFIGURED"?(m=null,f.textContent=o?"暂时无法为此套餐报价,付款尚未开始。":"Pricing for this plan is unavailable. Payment hasn’t started."):i.canReselect===!0&&!b?f.textContent=o?"未能取得报价,付款尚未开始。请重新选择套餐。":"We couldn’t prepare your price. Payment hasn’t started. Choose a plan again.":t==="COMMAND_PENDING"?f.textContent=o?"仍在准备报价,请重试以查看结果。":"Your price is still being prepared. Retry to check the result.":f.textContent=o?"未能取得报价,付款尚未开始。请重试。":"We couldn’t prepare your price. Payment hasn’t started. Try again."}else f.textContent=e instanceof k&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?Mt(e,o):e instanceof k?e.message:o?"操作未完成,请重试。":"This action couldn’t be completed. Try again.";y.hidden=m===null,Je=f.textContent,n&&ae===void 0&&!V?.responsive&&f.scrollIntoView?.({block:"nearest"}),K(n&&A?.quoteError?A.quoteError:a.onError,e)},Be=new WeakMap;function je(e){fe=e,y.disabled=e,le.disabled=e,D?.updateCapabilities?.(oe(d),xe(d));for(let n of de?.querySelectorAll("button")??[])e?(Be.has(n)||Be.set(n,n.disabled),n.disabled=!0):Be.has(n)&&(n.disabled=Be.get(n),Be.delete(n)),Lt(n)}function en(){q&&(f.textContent=q.message,y.textContent=o?"重试":"Retry",y.disabled=!1,y.hidden=!q.retry,le.disabled=!0)}function kt(){f.textContent=o?"暂时无法操作,请稍后重试。":"This action is unavailable right now. Try again in a moment."}let tn=new WeakSet;async function Qn(e){if(a.beforeAction)try{await a.beforeAction({purchaseIntent:tn.has(e)})}catch(n){throw n instanceof Dt?(b=null,ye=!1,Te=!1,m=null):m=e,n}}async function W(e,n){if(fe||w||q)return;if(!E()){kt();return}let t=e===qe,r=t?Ln:Un;ae=n!==void 0&&D?.updateCheckoutControls?n:void 0,f.textContent=r,je(!0),Ee(),y.hidden=!0;try{if(e!==cn&&e!==It&&e!==xt&&e!==Xe&&(e!==tt||!a.resumeCheckout)&&await Qn(e),w||q)return;if(!E()){m=e,y.hidden=!1,kt();return}await e()}catch(l){w||Ce(l,t)}finally{ae=void 0,je(!1),Ee(),q?en():f.textContent===r&&(f.textContent="")}}async function nn(e){await Nn(ce,e,a)}function De(e,n){P=n?{quote:e,phase:n}:void 0,n==="checking"?(ae??=b?.actionId??Yt(d)[0],f.textContent=wt,m=It,y.textContent=o?"查询状态":"Check status",y.hidden=!0):ae=void 0,D?.updateCapabilities(oe(d),xe(d)),Ee()}function rn(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 an(e,n){_t(e,{...n,featureQuantities:n.featureQuantities??{}},"Purchase operation changed")}async function It(){P&&await Ae(P.quote)}async function Ae(e,n){De(e,"checking"),Je="";let t=1e3;Ve=!0,K(a.onObservationChange,!0);try{for(let r=n;E();r=void 0){if(!r){try{r=await i.read()}catch(l){if(!rn(l))throw l}if(!E())return}if(r){an(r,e);let l=R(r);if(l.type==="checkout"){De(e,"payment"),f.textContent=o?"请先完成原订单的付款。":"Finish paying for this upgrade.",y.hidden=!1;return}if(l.type==="complete"){De(e,"complete"),m=null;let c=d.capabilities.plans[e.productVersionId]?.name,s=e.merchantTerms?.subscriptionTerms?.items,u=s?.length===1?s[0].interval:void 0,I=u==="year"?o?"年付":"annual billing":u==="month"?o?"月付":"monthly billing":null;f.textContent=c?o?`已升级到 ${c}${I?" "+I:""}。`:`Upgraded to ${c}${I?" ("+I+")":""}.`:o?"已成功升级。":"Plan upgraded.",await nn(r);return}if(l.type==="native"&&!Se(r)){De(e),b=null,m=null,f.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(t,h,Z.signal),t=Math.min(t*1.5,15e3)}}finally{Ve=!1,K(a.onObservationChange,!1)}}async function xt(){let e=P?.quote;if(!e)return;let n=await i.read();if(an(n,e),R(n).type!=="checkout")return Ae(e,n);if(a.resumeCheckout){await a.resumeCheckout(n.operationId);return}He.delete(n.operationId),await Qe(n)}function on(e){return Nt(i).type==="recording"||R(e).type==="recording"}function sn(e){let n=e.merchantTerms,t=n?.subscriptionTerms?.items??[],r=n?n.totalMinor:L(e)?e.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),l=n?t.length===1&&t[0]?.amountMinor===r&&t[0]:!L(e)&&e.lines.length===1&&e.lines[0]?.catalogAmountMinor===r&&e.lines[0],c=r===null?ve(n.subtotalMinor-n.discountMinor,e.currency)+(o?" + 待确认税费":" + tax confirmed at checkout"):ve(r,e.currency)+(l?Le(l.interval,o?"zh-CN":"en",l.intervalCount??1):""),s=L(e)?i.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(u=>u.productName).join(", ");return{label:s?`${s} · ${c}`:c,recurring:l}}async function H(e,n=a.checkoutNavigation!=="after_confirmation"){if(w)return;if(!E()){m=async()=>H(await i.read()),y.hidden=!1;return}let t=e.quote??i.quote;if(gt(t)&&(e.confirmedAt||e.merchantExecution))return Ae(t,e);if(f.textContent=On(e.status,o),on(e)){let p=e.merchantExecution?.recordingStatus==="failed";f.textContent=p?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",m=async()=>H(await i.read()),y.hidden=!1;return}if(e.problem&&R(e).type!=="native"){let p=e.problem;m=_e,y.textContent=o?"检查并恢复原操作":"Check and recover original purchase",Ce(new k(p.code,p.reason==="RESULT_UNKNOWN"?o?"付款结果尚未确定,请恢复原操作,暂勿重复购买。":"The payment result is unknown. Recover the original purchase before buying again.":p.phase==="fulfillment"?o?"付款已记录,商户权益处理需要核对。":"Payment was recorded. Access fulfillment needs attention.":p.code==="CAPABILITY_UNAVAILABLE"?o?"商户尚不支持本次购买所需的完整能力,请处理后恢复原操作。":"The merchant does not currently support all actions required by this purchase. Recover the original purchase after this is resolved.":p.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,p));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)&&(f.textContent=o?"付款已记录,正在等待商户完成处理。":"Payment was recorded. Waiting for merchant fulfillment."),Ge(e)&&R(e).type==="complete"){m=null,await nn(e);return}let r=Ot(e);if((r||!Se(e))&&R(e).type!=="fulfillment"){if(i.canReselect===!1||r&&Se(e)&&i.canReselect!==!0){f.textContent=o?"正在核对原购买结果":"Checking the original purchase result",y.textContent=o?"查询结果":"Check result",m=async()=>H(await i.read()),y.hidden=!1;return}r?f.textContent=o?"结账未启动,可以重新选择方案。":"Checkout didn’t start. Choose a plan to try again.":e.status==="cancelled"?f.textContent=o?"这笔购买已取消,可以重新选择方案。":"This purchase was cancelled. Choose a plan to start again.":e.status==="failed"&&(f.textContent=o?"这笔购买未能完成,可以重新选择方案。":"This purchase didn’t go through. Choose a plan to try again."),y.textContent=o?"重试":"Retry",m=null,b=null;return}if(!n&&R(e).type==="checkout"){if(F){Xt();return}if(ge()){f.textContent="",it=!1,m=null,y.hidden=!0,D?.updateCapabilities?.(oe(d),xe(d)),Ee();return}let p=i.quote,x=p?.operationId===e.operationId?sn(p).label:"";f.textContent=it?x?o?`${x} 尚未付款。再次选择该方案即可继续付款。`:`${x} is still unpaid. Choose it again to continue paying.`:o?"之前的购买尚未付款。再次选择该方案即可继续付款。":"Your earlier purchase is still unpaid. Choose that plan again to continue paying.":"",it=!1,m=null;return}await Qe(e);let l=Date.now(),c=l+6e5,s=2e3,u=R(e).type!=="checkout",I=()=>u&&Date.now()-l<15e3;Ve=!0,K(a.onObservationChange,!0);try{for(;!w&&Date.now()<c;){if(await Ye(I()?700:s,h,Z.signal),w)return;if(!E()){m=async()=>H(await i.read()),y.hidden=!1;return}let p=await i.read();if(R(p).type==="checkout"&&(u=!1),!n&&R(p).type==="checkout"){await H(p,!1);return}if(!p.problem&&Se(p)&&await Qe(p),!Se(p)||Ot(p)||p.problem||on(p)){await H(p);return}I()||(s=Math.min(s*1.5,3e4))}}finally{Ve=!1,K(a.onObservationChange,!1)}m=async()=>H(await i.read()),y.hidden=!1}async function Et(e=!1){let n=await i.read();if(w)return;if(!E()){m=()=>Et(e),y.hidden=!1;return}let t=i.quote;if(t&&_t(n,{operationId:t.operationId,currency:t.currency},"The original purchase operation changed"),t&&(ot(n)?["prepared","quoted"].includes(n.status):n.status==="pending")&&(ot(n)||n.quoteFinalized===!1)&&!n.confirmedAt&&!n.checkoutUrl&&!("nativePurchase"in n&&n.nativePurchase)&&!n.merchantExecution&&!n.problem&&!i.pendingCancellation){if(a.purchaseConfirmation!=="paywall"){e?await _e():m=null;return}setTimeout(ln,0,t);return}await H(n,e||void 0)}async function cn(){await Et()}async function Bn(e){f.textContent=wt;let n=Date.now()+12e3;for(;!w&&Date.now()<n&&(await Ye(1500,h,Z.signal),!(w||!E()));){let t;try{t=await i.read()}catch{break}if(t.problem?.reason!=="RESULT_UNKNOWN")return t}return e}async function _e(){if(i.quote&&!(Date.parse(i.quote.expiresAt)>Date.now()))throw new k("INVALID_REQUEST",o?"此报价已过期,请重新选择套餐。":"This quote has expired. Choose a plan again.");Jt();let e=i.quote;if(gt(e)){De(e,"checking");let t;try{t=await i.confirm()}catch(r){if(!rn(r))throw r;return Ae(e)}return Ae(e,t)}m=_e;let n=await i.confirm();if(!E()){m=_e,y.hidden=!1;return}if(n.problem?.reason==="RESULT_UNKNOWN"&&(n=await Bn(n)),n.problem){await H(n);return}if(Se(n)){if(R(n).type==="checkout")await Qe(n);else if(n.execution&&n.execution.provider!=="merchant"||"nativePurchase"in n&&n.nativePurchase){if(!a.onPurchase)throw new k("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await a.onPurchase({operation:n,signal:Z.signal})}}m=async()=>H(await i.read()),await H(n,!0)}function ln(e){if(w)return;de?.remove();let n=!(Date.parse(e.expiresAt)>Date.now());f.textContent=n?o?"此报价已过期。请先取消,再重新选择。":"This quote has expired. Cancel it, then choose again.":"";let t=h.createElement("div"),r=h.createElement("button"),l=h.createElement("button"),c=h.createElement("div"),s=h.createElement("p"),u=e.merchantTerms,I=o?"zh-CN":"en",p=u?.subscriptionTerms?.items??[],x=u?u.subscriptionTerms?.trial?.days:L(e)?void 0:e.lines.find(g=>g.trial)?.trial?.days,T=L(e)?u?u.totalMinor:e.totalMinor:x===void 0?null:u?u.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(g=>g.trial)?0:null,Pe=(g,v)=>o?`${v} 天试用结束后 ${g}`:`Then ${g} after the ${v}-day trial`,{label:X,recurring:Ue}=sn(e),St=L(e)?i.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(g=>g.productName).join(", "),pn=T===null?"":`${o?"今天应付":"Due today"} ${ve(T,e.currency)}`;s.textContent=pn?[St,pn].filter(Boolean).join(" · "):X,r.textContent=L(e)?o?"确认变更":"Confirm change":o?"确认购买":"Confirm purchase",r.disabled=n,l.textContent=o?"取消":"Cancel",t.style.cssText=U.panel,s.style.cssText=U.summary,c.style.cssText=U.actions,r.style.cssText=U.primary,l.style.cssText=U.secondary,Lt(r),r.onclick=()=>{W(_e)};let fn=async()=>{let g=await i.cancel();w||(t.remove(),de=null,await H(g))};l.onclick=()=>{m=fn,W(fn)};let z=h.createElement("div");if(z.style.cssText=U.terms,L(e)){for(let[v,O]of Object.entries(e.featureQuantities??{})){let B=i.view?.capabilities.plans[e.productVersionId]?.prepaid?.find(jn=>jn.internalFeatureId===v),at=h.createElement("p");at.textContent=`${B?.name??v} · ${O} ${o?"份":"packs"}${B?` × ${B.terms.units}`:""}`,z.append(at)}for(let[v,O]of[[o?"原订阅抵扣":"Unused subscription credit",e.creditMinor],[o?"新套餐费用":"New plan charge",e.debitMinor],[o?"优惠减免":"Offer savings",u?.discountMinor??e.discountMinor],[o?"税费":"Tax",u?u.taxMinor:e.taxMinor]]){let B=h.createElement("p");B.textContent=`${v}: ${O===null?o?"结账时确认":"Confirmed at checkout":ve(O,e.currency)}`,z.append(B)}let g=h.createElement("p");g.textContent=`${o?"生效时间":"Effective"}: ${e.effectiveAt}`,z.append(g)}if(u){for(let v of p){if(T===null&&v===Ue)continue;let O=h.createElement("p"),B=ve(v.amountMinor,e.currency)+Le(v.interval,I,v.intervalCount);O.textContent=T!==null&&x!==void 0?Pe(B,x):B,v.amountAfterOfferMinor!==void 0&&(O.textContent+=` · ${o?"优惠结束后":"After the offer"} ${ve(v.amountAfterOfferMinor,e.currency)}${Le(v.interval,I,v.intervalCount)}`),z.append(O)}let g=u.subscriptionTerms?.trial;if(g){let v=h.createElement("p");v.textContent=o?`试用 ${g.days} 天;${g.cardRequired?"需要提供付款方式":"无需提供付款方式"}`:`Trial days: ${g.days}; ${g.cardRequired?"a payment method is required":"no payment method is required"}`,z.append(v)}for(let v of[...u.expectedEffects.map(O=>O.description),...u.requiredConsents.map(O=>O.summary)]){let O=h.createElement("p");O.textContent=v,z.append(O)}}else if(!L(e)){for(let g of e.lines){if(T!==null||g!==Ue){let v=h.createElement("p"),O=`${ve(g.catalogAmountMinor,e.currency)}${Le(g.interval,I,g.intervalCount??1)}`;v.textContent=T!==null&&g.trial?(e.lines.length>1?`${g.productName} · `:"")+Pe(O,g.trial.days):`${g.productName} · ${O}`,z.append(v)}for(let v of g.prepaid??[]){let O=h.createElement("p"),B=i.view?.capabilities.plans[g.productVersionId]?.prepaid?.find(at=>at.internalFeatureId===v.internal_feature_id);O.textContent=`${B?.name??v.internal_feature_id} · ${v.quantity} ${o?"份":"packs"} × ${v.terms.units}`,B&&(O.textContent+=Le(B.reset==="week"||B.reset==="month"||B.reset==="year"?B.reset:"one_time",I,B.resetCount)),z.append(O)}if(g.trial){let v=h.createElement("p");v.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"}`,z.append(v)}}if(!e.charge){let g=h.createElement("p");g.textContent=o?"目录价格;最终金额以结账时税费和试用规则为准。":"Catalog price; the final charge depends on checkout taxes and trial terms.",z.append(g)}}for(let g of z.children)g.style.margin="0";c.append(r,l),t.append(s,...z.childElementCount?[z]:[],c),Y.prepend(t),V?.responsive||t.scrollIntoView?.({block:"nearest"}),r.focus({preventScroll:!0}),de=t,fe&&je(!0),m=null}async function qe(){if(!b)return;if(a.onPurchaseIntent&&!ye&&!i.quote&&!i.operation){let t=b,r=i.view,l=r?.document.buttons[t.actionId],c=r&&l?.type==="checkout"?ke(l.product,t.selection,r.capabilities):null;if(!r||!c)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let s={actionId:t.actionId,productVersionId:c,selection:structuredClone(t.selection),featureQuantities:Ie(r.document.screen,c,t.selection,r.capabilities),...$&&{coupon:{id:$.id,...$.offerId&&{offerId:$.offerId}}}};b=null,$=void 0,m=null,Ke=!0,await a.onPurchaseIntent(s);return}if(m=qe,!ye){let t=i.view,r=t?.document.buttons[b.actionId],l=t&&r?.type==="checkout"?ke(r.product,b.selection,t.capabilities):null;if(!t||!l)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");if(!Te){let s=Wt(),u=s?await s.result:void 0;if(w)return;let I=a.resolveSubscriptionChange;if(I||u){let p={actionId:b.actionId,productVersionId:l,featureQuantities:Ie(t.document.screen,l,b.selection,t.capabilities)},x=u?[async()=>u(p)]:[],T=I?await I(p,...x):await x[0]?.();if(w)return;T!==void 0&&(b.subscriptionChange=mn.parse(T))}Te=!0}let c=$?.offerId;if($&&!c){if(!a.claimCoupon)throw new k("CAPABILITY_UNAVAILABLE","Coupon claiming is unavailable");let{offer:s}=await a.claimCoupon($.id,b.requestId);if(w)return;if(!s||s.couponId!==$.id||s.status!=="issued"||!(Date.parse(s.expiresAt)>Date.now()))throw b=null,$=void 0,m=async()=>{$e(await i.refresh()),m=null},new k("COUPON_UNAVAILABLE","This Coupon is no longer available for this purchase");c=s.id}if(!$&&!t.document.screen.actions.some(s=>s.id===b?.actionId&&typeof s.properties.couponBinding=="string")&&(c=await a.resolveOfferId?.({actionId:b.actionId,productVersionId:l,featureQuantities:Ie(t.document.screen,l,b.selection,t.capabilities)})),w)return;c!==void 0&&(b.offerId=c),ye=!0}if(!E()){y.hidden=!1;return}let e;try{e=await i.preview(b)}catch(t){throw i.canReselect===!0&&(b=null,ye=!1,Te=!1,$=void 0,m=null),t}if(b.acceptHostedMonthly!==void 0){let t=i.operation;if(!t||t.operationId!==e.operationId||!t.confirmedAt)throw new k("INVALID_RESPONSE","The confirmed Checkout is missing");w||await H(t,!0);return}if($&&(L(e)?(()=>{let t=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0);return t?.couponId!==$.id||t.grantId!==b.offerId})():e.discount?.couponId!==$.id||e.discount.offerId!==b.offerId))throw new k("INVALID_RESPONSE","The quote did not apply the Coupon selected on this Paywall");if(w)return;let n=e.merchantTerms;if(a.purchaseConfirmation!=="paywall"||a.confirmOnHostedCheckout&&E()&&!L(e)&&e.provider==="merchant"&&e.billingSubscriptionId===null&&n?.request.action==="purchase"&&n.request.mode==="subscription"&&n.subscriptionTerms?.trial===null&&n.requiredConsents.length===0&&Date.parse(e.expiresAt)>Date.now()){if(!E()){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 t=ae?"":o?"正在打开收银台…":"Opening checkout…";f.textContent=t;try{await _e()}catch(r){w||Ce(r)}finally{f.textContent===t&&(f.textContent="")}return}ln(e)}function Re(e="destroy",n=!1){if(w)return;w=!0;let t=ht;ht=void 0,K(t),a.signal?.removeEventListener("abort",se),i.signal?.removeEventListener("abort",se),Q.finish("dismissed"),$t?.(),vt(),h.removeEventListener("visibilitychange",Gt),Z.abort(),Vt?.disconnect(),D?.destroy(),i.destroy(),S.removeEventListener("cancel",dn),_.remove(),M.remove(),n||un(),e==="dismiss"&&K(a.onDismiss)}function un(){if(V?.destroy(),ue){ue.release();return}S.open&&S.close(),S.remove(),N()}G=Re;async function Fe(){if(!he||w||ze||ie==="closing"||!ie&&!E())return;if(!A){Re("dismiss");return}let e=h.createElement("p");e.setAttribute("role","status"),e.textContent=o?"正在关闭…":"Closing…",me||(me=h.createElement("div"),me.style.cssText=Y.style.cssText,Y.replaceWith(me),pe.inert=!0),_.hidden=!1,me.replaceChildren(e,_),ie="closing",_.setAttribute("aria-disabled","true"),_.focus({preventScroll:!0});try{await A.dismiss()}catch(n){w||K(a.onError,n)}w||(ie="retry",e.textContent=o?"未能确认关闭,请重试。":"Could not confirm closure. Try again.",_.textContent=o?"重试关闭":"Retry closing",_.removeAttribute("aria-label"),_.removeAttribute("aria-disabled"))}_.onclick=()=>{Fe()};function dn(e){e.preventDefault(),Fe()}S.addEventListener("cancel",dn),le.onclick=()=>{W(P?xt:tt)},y.onclick=()=>{if(q){q.retry?.();return}m&&W(m)};function At(e){Q.finish("error",e),Re()}function Rt(){if(!(!Bt||he||w||ze||V&&!E()))try{let e=n=>{a.focusAtReveal&&(N=Ut(h)),a.settleMotionAtReveal?D?.setHidden?.(!1,!0):D?.setHidden?.(!1),mt?.(),V&&(S.open||S.showModal(),V.responsive&&S.focus({preventScroll:!0}),!n&&a.loading!=="host"&&vn(S,V.type,V.responsive)),n&&a.loading!=="host"&&typeof pe.animate=="function"&&!h.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches&&pe.animate([{opacity:.55},{opacity:1}],{duration:160,easing:"ease-out"}),he=!0,Ze()};A?A.present(n=>Q.present(t=>e(n??t))):Q.present(e)}catch(e){At(e),Ce(e)}}try{if(Me.type==="inline"?(dt(),mt=Rn(M,j),j.append(M)):(S.setAttribute("aria-label",d.document.name),_.textContent="×",_.setAttribute("aria-label",o?"关闭":"Close"),kn(_,d.document.screen.theme),_.hidden=bn(d.document),(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&ue?.content?ue.content.append(_,M):S.replaceChildren(_,M),ue||j.append(S),V=Pn(S,{...d.document.screen,presentation:Me},ft),V.latch(),V.responsive&&(M.style.display="flex",M.style.flexDirection="column",M.style.maxHeight="100%",pe.style.overflow="clip",pe.style.minHeight="0"),ue||(mt=An(S))),lt&&ee){let t=lt(ee);if(typeof t=="function"&&(w?K(t):ht=t),w)throw new DOMException("Presentation cancelled","AbortError");dt()}D=ne(pe,{mode:"live",rendererUrl:"bundled",title:d.document.name,closeActions:Mn,onAuthoredClose(t){ie||w||(_.hidden=t)},hostPresentation:()=>V?.type??Me.type,reportContentHeight:V?.responsive,onResize:t=>{if(!V?.responsive)return;let r=Math.min(t,pt);pe.style.height=`${r}px`,V.setContentHeight(r+Qt())},onSelection(t){for(let[r,l]of Object.entries(t))typeof l=="number"&&typeof J[r]=="number"&&J[r]!==l&&jt.add(r);J=t,Ee(),Ze()},onAction(t,r={},l,c){if(!he||w||ie)return;let s=i.view,u=s?.document.buttons[t];if(!u)return;if(q){u.type==="close"&&Fe();return}if(u.type==="close"&&A&&a.resumeCheckout&&i.operation&&gn(R(i.operation))){Fe();return}if(fe)return;if(!E()){kt();return}if(u.type==="close"){W(async()=>{A?.closeAction?await A.closeAction(t):await a.onAction?.(t),Re(a.onAction?"action":"dismiss")});return}if(u.type==="action"){m=async()=>{if(u.action.type==="event"){if(!a.onEvent)throw new k("EVENT_HANDLER_REQUIRED","Provide the event handler");await a.onEvent(u.action.event)}else a.onOpenUrl?await a.onOpenUrl(u.action.url):h.defaultView?.location.assign(u.action.url);await a.onAction?.(t),m=null},W(m);return}if(ge()&&F){!we&&F.selection.actionId===t&&W(()=>nt(!0),t);return}if(P){if(P.phase==="payment"&&s&&Ne(P.quote,s,t,u.product,r,c)){W(xt,t);return}if(!Ct())return}if(!be()&&!Ct()){ge()&&s&&i.quote&&i.operation&&R(i.operation).type==="checkout"&&Ne(i.quote,s,t,u.product,r,c)?W(tt,t):f.textContent=o?"当前只能继续原订单。":"Only your original checkout is available.";return}if(de&&i.canReselect===!1){f.textContent=o?"请先确认或取消当前购买。":"Confirm or cancel the current purchase first.",V?.responsive||de.scrollIntoView?.({block:"nearest"}),de.querySelector("button")?.focus({preventScroll:!0});return}if(ge()&&a.terminateCheckout&&s&&i.quote&&i.operation&&i.canReselect===!1&&R(i.operation).type==="checkout"){if(Ne(i.quote,s,t,u.product,r,c)){W(tt,t);return}let p=ke(u.product,r,s.capabilities),x;try{if(!p)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");x=Ie(s.document.screen,p,r,s.capabilities)}catch(Ue){Ce(Ue);return}let T=i.operation.operationId,Pe={actionId:t,requestId:crypto.randomUUID(),selection:structuredClone(r)},X=rt(s,t,p,r,c);W(()=>Zt(T,Pe,X,{actionId:t,productVersionId:p,selection:Pe.selection,featureQuantities:x}),t);return}if((i.quote||b)&&i.canReselect===!1){let p=!!s&&!!i.quote&&Ne(i.quote,s,t,u.product,r,c);it=!!i.quote&&!p,m=i.quote?()=>Et(p):qe,W(m,t);return}let I=s&&ke(u.product,r,s.capabilities);if(!s||!I){Ce(new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(a.onPurchaseIntent){m=null;let p=async()=>{let x={actionId:t,productVersionId:I,selection:structuredClone(r),featureQuantities:Ie(s.document.screen,I,r,s.capabilities)},T=rt(s,t,I,r,c);T&&(x.coupon={id:T.id,...T.offerId&&{offerId:T.offerId}}),Ke=!0,await a.onPurchaseIntent(x)};tn.add(p),W(p,t);return}if(b&&b.actionId!==t){Ce(new k("COMMAND_PENDING","Finish the current purchase"));return}if(!b){$=rt(s,t,I,r,c),b={requestId:crypto.randomUUID(),actionId:t,selection:structuredClone(r)};let p=s.document.screen.actions.find(Pe=>Pe.id===t)?.properties,x=p?.hostedMonthlyPriceMinor,T=p?.hostedMonthlyAutomaticTax;a.purchaseConfirmation==="purchase_button"&&a.confirmOnHostedCheckout&&i.supportsHostedCheckout===!0&&!$&&u.product.type==="fixed"&&typeof T=="boolean"&&typeof x=="number"&&Number.isSafeInteger(x)&&x>0&&x<=1e8&&Object.keys(Ie(s.document.screen,I,r,s.capabilities)).length===0&&(b.acceptHostedMonthly={amountMinor:x,automaticTax:T}),ye=b.acceptHostedMonthly!==void 0,Te=ye}W(qe,t)},onEscape:()=>{Fe()},onError:t=>{let r=new Error(t);!he&&!w&&At(r),Ce(r)},onRendered:t=>{t&&S.setAttribute("aria-label",t),Bt=!0,Rt()}}),D.setHidden?.(!0),ft();let e=ge()&&!!i.quote&&!!i.operation&&R(i.operation).type==="checkout";J=i.quote?_n(d,i.quote)??st(d,{}):st(d,{}),D.update(d.document.screen,ut,{capabilities:oe(d),unavailableActions:xe(d),serverInput:{bindings:[],answers:{}},...Object.keys(J).length?{selection:J}:{}}),$t=i.subscribe?.($e),$e(i.view??d),await Q.wait(D.ready);let n=i.operation;(!e||gt(i.quote))&&(i.quote||n&&(n.confirmedAt||n.checkoutUrl||Ge(n)))&&(m=cn,W(m))}catch(e){throw At(e),e}return{check:ce,host:{get currentResolution(){return d},setPurchaseRecovery(e,n){q={message:e,retry:n},D?.updateCapabilities?.(oe(d),xe(d)),Ee(),en()},get subscriptionUpgradeActive(){return P!==void 0},get observing(){return Ve},get recovery(){return Vn()},async prepareFallback(){if(fe||w||ie||Ke)return{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null};je(!0);try{let e=await wn(i);return e.type==="native"&&Re(),e}finally{je(!1)}},setSuspended(e){ze=e,M.hidden=e,e&&S.open?S.close():!e&&!he?Rt():!e&&!w&&he&&Me.type!=="inline"&&!S.open&&S.showModal()},destroy:Re,retainPurchaseDialog(){if(!(w||!S.open||!S.isConnected))return Re("destroy",!0),{dialog:S,content:ue?.content,release:un}},refresh:async()=>{if(!E()){if(i.view)return i.view;throw new k("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await i.refresh();return $e(e),Rt(),e}}}}export{kr as a};
1
+ import{a as xn,c as Sn,d as Lt,f as Mt,g as Tn,k as On}from"./chunk-CHRNCOXJ.js";import{a as Cn,b as Ye}from"./chunk-W32FI2A2.js";import{e as Pn,f as vn,g as kn,h as In,j as Ut,k as ct,l as En,m as An,n as Rn}from"./chunk-CO6HDNOC.js";import{a as Ot,b as yn,d as Nt,e as gn,f as wn}from"./chunk-Y55OBV7D.js";import{a as st,b as oe,d as Dt,f as _t,j as bn}from"./chunk-MOIVJERE.js";import{b as ke}from"./chunk-6XRQR43F.js";import{B as L,C as ot,D as Ge,E as Se,y as mn}from"./chunk-3532HSBP.js";import{r as Le,t as Ie}from"./chunk-Y3W5G4BF.js";import{i as hn}from"./chunk-FYUMVOCV.js";import{c as ve,j as We}from"./chunk-DUS5V65Z.js";import{c as Tt}from"./chunk-BOT6ZDLK.js";import{a as k}from"./chunk-UGATOG2T.js";import{a as K}from"./chunk-DSPLGTQI.js";async function Nn(j,a,A){if(!Ge(a))throw new k("INVALID_RESPONSE","A verified completed purchase is required");let N=j?We.parse(j):null;if(await A.onComplete?.(a),!N||!A.check)return;let G=We.parse(await A.check());if(G.internal_feature_id!==N.internal_feature_id||G.quantity!==N.quantity||N.observation!==void 0&&(G.observation===void 0||G.observation.requirementDigest!==N.observation.requirementDigest||G.observation.authority!==N.observation.authority||Tt(G.observation.subject)!==Tt(N.observation.subject)))throw new k("INVALID_RESPONSE","The access requirement changed");G.allowed&&await A.onAccessGranted?.(G)}function Dn(j){return Object.entries(j.document.buttons).filter(([,a])=>a.type==="checkout"&&a.product.type==="fixed"&&!ke(a.product,{},j.capabilities)).map(([a])=>a)}function _n(j,a){let A=L(a)?void 0:a.lines[0];if(!L(a)&&(a.lines.length!==1||!A))return;let N=L(a)?a.productVersionId:A.productVersionId,{screen:G,buttons:se}=j.document,Q=new Map(L(a)?Object.entries(a.featureQuantities??{}):(A?.prepaid??[]).map(C=>[C.internal_feature_id,C.quantity]));function ce(C,d){if(C.hidden)return!1;if(C.type==="plan_picker"&&j.capabilities.pickers[C.id]?.options.includes(N))return d[C.id]=N,!0;if(C.type==="quantity_picker"){let ne=Q.get(C.internalFeatureId);return ne!==void 0&&(!C.bind?.plan||C.bind.plan===N)&&(d[C.id]=ne),!1}if(C.type==="button"&&C.action){let ne=se[C.action];return ne?.type==="checkout"&&ne.product.type==="fixed"&&ne.product.productVersionId===N}if(C.type!=="stack")return!1;let te=C.interaction,i=C.bind?.plan===N;for(let[ne,h]of C.children.entries()){let Z={},M=ce(h,Z);if(te?.type==="toggle"||te?.type==="tabs"){if(!M)continue;return d[C.id]=te.type==="toggle"?ne===0:h.id,Object.assign(d,Z),!0}Object.assign(d,Z),M&&(i=!0,te?.type==="select"&&te.purpose==="product"&&te.pickerId&&h.type==="stack"&&h.bind?.plan===N&&(d[C.id]=h.id,d[te.pickerId]=N))}return i}for(let C of G.pages){let d={__page:C.id};if(ce(C.root,d))return d}}var qn="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 kr(j,a,A){let N=a.focusAtReveal?()=>{}:Ut(j.ownerDocument),G=()=>{Q.finish("dismissed"),N()},se=()=>G(),Q=En(j,a,"paywall",()=>{G(),K(a.onDismiss)},xn);a.signal?.throwIfAborted(),a.signal?.addEventListener("abort",se,{once:!0});let ce=null,C,d,te;try{if(Q.start(!0,a.loadingDocument?.screen.strings.defaultLocale,a.loadingDocument??null),Q.cancelled)throw new DOMException("Presentation cancelled","AbortError");if(ce=a.check?We.parse(await Q.wait(a.check(),ct)):null,ce?.allowed)return Q.finish("skipped"),a.signal?.removeEventListener("abort",se),N(),await a.onAccessGranted?.(ce),{check:ce,host:null};let[e,n]=await Promise.allSettled([Q.wait(import("./screen-renderer-HJOKBOZH.js")),Q.wait(a.start().then(r=>(Q.cancelled&&r.destroy(),r)),ct)]);if(e.status==="rejected")throw n.status==="fulfilled"&&n.value.destroy(),e.reason;if(n.status==="rejected")throw n.reason;te=e.value,C=n.value,a.signal?.throwIfAborted(),C.signal?.throwIfAborted(),C.signal?.addEventListener("abort",se,{once:!0});let t=C.view??await Q.wait(C.refresh(),ct);if(!t)throw new k("INVALID_RESPONSE","Paywall presentation is missing");C.signal?.throwIfAborted(),d=t}catch(e){throw Q.finish("error",e),A?.retainedDialog?.release(),a.signal?.removeEventListener("abort",se),C?.signal?.removeEventListener("abort",se),C?.destroy(),N(),e}let i=C,{mountScreenPreview:ne}=te,h=j.ownerDocument,Z=new AbortController,M=h.createElement("section"),pe=h.createElement("div"),Y=h.createElement("div"),lt=a.mountControls,ee=lt?h.createElement("div"):void 0,f=h.createElement("p"),y=h.createElement("button"),le=h.createElement("button"),_=h.createElement("button");(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&A?.hostPaywallTarget&&!A.retainedDialog&&d.document.presentation.type==="modal"&&(A.retainedDialog=In(A.hostPaywallTarget));let ue=A?.retainedDialog,S=ue?.dialog??h.createElement("dialog"),Me=ue&&d.document.presentation.type==="inline"?{type:"modal",size:"md"}:d.document.presentation,re=Me.type==="inline"?Y:h.createElement("div"),ut=i.locale||d.document.screen.strings.defaultLocale,o=ut.toLowerCase().startsWith("zh"),Un=o?"正在处理…":"Processing…",Ln=o?"正在准备报价…":"Preparing your price…",U=Sn(d.document.screen.theme);M.dataset.indianaPaywall="",M.setAttribute("aria-label",d.document.name),M.style.cssText=U.root,Y.style.cssText=U.controls,f.style.cssText=U.message,f.setAttribute("role","status"),_.style.cssText=U.link,_.textContent=o?"关闭":"Close",y.style.cssText=U.secondary,y.textContent=o?"重试":"Retry",y.hidden=!0,le.type="button",le.style.cssText=U.primary,le.textContent=o?"继续付款":"Continue payment",le.hidden=!0,re.append(f,le,y),Y.append(_),ee&&(ee.style.cssText="flex:1 0 100%;min-width:0",ee.hidden=!0,Y.prepend(ee)),re!==Y&&(re.dataset.indianaPaywallStatus="",re.style.cssText="display:none;padding:0",M.append(re)),M.append(pe,Y);let dt=()=>{let e=$n();f.style.cssText=e?`${U.message};${qn}`:U.message,Kt();let n=c=>!c.hidden&&(c!==f||!!f.textContent&&!e);if(re!==Y&&(re.style.cssText=!ie&&[...re.children].some(n)?`${U.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 t=me??Y,r=![...t.children].some(n),l=[...t.children].some(c=>c!==_&&n(c));t.style.cssText=r?U.controls.replace(/padding:[^;]+/,"padding:0"):l?`${U.controls};${U.pinned}`:U.controls,ft()},Vt=typeof MutationObserver>"u"?void 0:new MutationObserver(dt);Vt?.observe(M,{attributes:!0,attributeFilter:["hidden"],characterData:!0,childList:!0,subtree:!0});let Mn=Object.entries(d.document.buttons).filter(([,e])=>e.type==="close").map(([e])=>e),D,$t,Ve=!1,Ht=JSON.stringify(d.capabilities),q;function xe(e){let n=Dn(e);if(q||fe&&!ae||F&&(P||!be()||we))return Oe(e).map(({actionId:r})=>r);if(Ct()||!P&&be())return n;let t=P?bt(e):Pt(e);return[...new Set([...n,...Oe(e).map(({actionId:r})=>r).filter(r=>!t.includes(r))])]}function $e(e){if(w)return;let n=d.id!==e.id;d=e;let t=JSON.stringify(e.capabilities);if(n||t!==Ht){let r=!b&&!i.quote&&!i.operation?st(e,J,jt):J;n||JSON.stringify(r)!==JSON.stringify(J)?(J=r,D?.update(e.document.screen,ut,{capabilities:oe(e),unavailableActions:xe(e),serverInput:{bindings:[],answers:{}},selection:J})):D?.updateCapabilities(oe(e),xe(e)),Ht=t}Hn(e),Ee(),Ze()}let V,pt=0;function Qt(){return(me??Y).getBoundingClientRect().height+(re===Y?0:re.getBoundingClientRect().height)}function ft(){let e=h.defaultView;if(!V?.responsive||!e)return;let n=me??Y,t=e.innerHeight-(V.type==="modal"?32:0);n.style.maxHeight=`${Math.max(1,t)}px`,n.style.overflowY="auto",n.style.flexShrink="0",pt=Math.max(1,t-Qt()),D?.resizeViewport?.(pt,e.innerWidth)}let w=!1,fe=!1,b=null,ht,ze=!1,Bt=!1,he=!1,mt,Ke=!1,ie,me;function Vn(){return fe||w||ie||Ke?{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null}:Nt(i)}let E=()=>!w&&!ze&&!ie&&a.canInteract?.()!==!1,$,ye=!1,Te=!1,yt,m=null,de=null,Je="",ge=()=>a.checkoutNavigation==="after_confirmation"&&!!(a.terminateCheckout||a.resumeCheckout),J={},jt=new Set,ae,P;function gt(e){return!!e&&L(e)&&e.timing==="immediate"&&e.execution.provider==="merchant"}let wt=o?"正在确认付款…":"Confirming payment…",F=null,we,Xe,qt=!1,be=()=>a.allowNewPurchase!==!1||qt;function Ft(){return JSON.stringify([d.id,d.capabilities])}function Wt(){let e=yt;return e&&e.read===a.prepareSubscriptionChange&&e.basis===Ft()?e:void 0}function Ze(){let e=a.prepareSubscriptionChange;if(!e||!he||!E()||!be()||a.onPurchaseIntent||h.visibilityState==="hidden"||b||i.quote||i.operation||!Oe(d).length||Wt())return;let n=Z.signal,t=new Promise(r=>{let l=()=>r(void 0);n.addEventListener("abort",l,{once:!0}),Promise.resolve().then(()=>(n.throwIfAborted(),e(n))).then(c=>r(n.aborted?void 0:c),l).finally(()=>n.removeEventListener("abort",l))});yt={read:e,basis:Ft(),result:t}}let Gt=()=>{h.visibilityState==="hidden"?yt=void 0:Ze()};h.addEventListener("visibilitychange",Gt);function Oe(e){return Object.entries(e.document.buttons).flatMap(([n,t])=>t.type==="checkout"?[{actionId:n,policy:t}]:[])}function Yt(e){let n=P?.quote;return n?Oe(e).filter(({actionId:t,policy:r})=>Ne(n,e,t,r.product,J)).map(({actionId:t})=>t):[]}function bt(e){return P?.phase==="payment"?Yt(e):[]}function Ct(){return(P?P.phase==="payment":!be())&&(be()||!!a.prepareUpgradeReplacement)&&ge()&&!!a.terminateCheckout&&!!i.quote&&i.canReselect===!1&&!!i.operation&&R(i.operation).type==="checkout"}function Pt(e){let n=i.quote;return!ge()||F||!n||!i.operation||R(i.operation).type!=="checkout"?[]:Oe(e).filter(({actionId:t,policy:r})=>Ne(n,e,t,r.product,J)).map(({actionId:t})=>t)}function Ee(){let e=q?[]:P?bt(d):Pt(d),n=a.allowNewPurchase===!1&&!!i.operation&&R(i.operation).type==="checkout";le.hidden=!!q||(P?P.phase!=="payment":!n)||e.length>0,Kt(e)}function zt(){if(!(ae===void 0||q))return f.textContent?f.textContent:P?.phase==="checking"?wt:void 0}function $n(){return!!D?.updateCheckoutControls&&!!f.textContent&&zt()!==void 0}let et;function Kt(e=q?[]:P?bt(d):Pt(d)){if(!D?.updateCheckoutControls)return;let n=zt(),t=ge()||!!P;if(!n&&!t&&et?.on!==D)return;let r={actions:Oe(d).map(({actionId:c})=>c),resume:n?[ae]:t?e:[],resumeLabel:n??(o?"继续付款":P?"Continue payment":"Continue checkout"),busy:ae},l=JSON.stringify(r);et?.on===D&&et.key===l||(et={on:D,key:l},D.updateCheckoutControls(r))}function Jt(){de?.remove(),de=null}async function tt(){if(F)return;if(a.resumeCheckout&&i.operation){let n=i.operation.operationId;try{await a.resumeCheckout(n)}catch(t){if(!(t instanceof k&&t.code==="PURCHASE_PENDING"))throw t;let r=await i.read();if(!E())return;if(r.operationId!==n||R(r).type==="checkout")throw t;await H(r,!1)}return}let e=await i.read();if(R(e).type!=="checkout")return H(e,!1);E()&&(He.delete(e.operationId),await Qe(e))}function vt(){we?.destroy(),we=void 0,Xe=void 0}function Xt(){let e=F;if(!e||we)return;let n=o?"仍在核对原订单,暂时无法更换套餐。":"We’re still checking the original purchase before changing plans.",t=Date.now()+6e5,r=Cn({document:h,delay:()=>Date.now()<t?5e3:void 0,async run(){if(!E())return;let l=await i.read();if(we!==r||!E())return;if(l.operationId!==e.operationId)throw new k("PURCHASE_PENDING","The original Checkout changed");let c=R(l);c.type==="native"?(vt(),f.textContent=o?"原订单已关闭。你可以继续更换套餐。":"The original checkout is closed. You can continue changing plans.",y.textContent=o?"继续更换套餐":"Continue changing plans",m=()=>nt(),y.hidden=!1):(c.type==="complete"||c.type==="fulfillment"||c.type==="recording")&&(vt(),F=null,y.hidden=!0,await H(l,!1))}});we=r,Xe=async()=>{try{await r.refresh()}finally{we===r&&(f.textContent=n,y.hidden=!1)}},m=Xe,y.textContent=o?"查询结果":"Check result",y.hidden=!1,f.textContent=n,r.schedule()}async function nt(e=!1,n=!1){let t=F;if(!t)return;m=()=>nt(),P&&(y.textContent=o?"查询状态":"Check status"),y.hidden=!0;let r=async()=>{if(!be()&&a.prepareUpgradeReplacement){let c=await a.prepareUpgradeReplacement(t.operationId,t.intent);if(!E())return;qt=!0,$e(c)}F=null,P&&De(P.quote),Jt(),b=t.selection,$=t.coupon,ye=!1,Te=!1,await qe()};if(n&&!be()&&a.prepareUpgradeReplacement)return r();let l=Date.now()+2e4;for(;E();){let c=await i.read();if(c.operationId!==t.operationId)throw new k("PURCHASE_PENDING","The original Checkout changed");if(!E())break;let s=R(c);if(s.type==="native"){await r();return}if(s.type==="complete"||s.type==="fulfillment"||s.type==="recording"){F=null,P?await Ae(P.quote,c):await H(c,!1);return}if(e&&s.type==="checkout"){e=!1;try{await a.terminateCheckout(t.operationId)}catch(u){K(a.onError,u)}}if(Date.now()>=l){P&&s.type==="checkout"&&(F=null,await Ae(P.quote,c));break}await Ye(1e3,h,Z.signal)}!F||w||(P?(f.textContent=o?"仍在核对原升级单,暂时无法更换套餐。":"We’re still checking the original upgrade before changing plans.",y.hidden=!1):Xt())}async function Zt(e,n,t,r){if(m=()=>Zt(e,n,t,r),await a.beforeCheckoutReplacement?.(structuredClone(r)),!E())return;let l=i.operation;if(l?.operationId!==e||R(l).type!=="checkout"){m=null,l&&await H(l,!1);return}F={operationId:e,selection:n,coupon:t,intent:r},P&&(f.textContent=o?"正在切换套餐…":"Changing plan…",y.hidden=!0);let c=!1,s=!1;try{let u=await a.terminateCheckout(e);s=(Array.isArray(u?.purchases)?u.purchases:[]).some(p=>p.operationId===e&&p.type==="native")}catch(u){if(u instanceof k&&["CAPABILITY_UNAVAILABLE","NOT_CONFIGURED"].includes(u.code)){F=null,P&&(m=It,y.textContent=o?"查询状态":"Check status",y.hidden=!1),f.textContent=o?"请继续原订单,或等待它过期后再更换方案。":"Continue your original checkout, or wait for it to expire before changing plans.",K(a.onError,u);return}c=u instanceof k&&(u.status??0)>=500,K(a.onError,u)}E()&&await nt(c,s)}function rt(e,n,t,r,l){let c=oe(e).checkoutCoupons?.[n],s=c?c.products[t]:a.claimCoupon&&l?hn(e.capabilities,l,r):void 0;return s?.couponId&&s.planVersionId===t?{id:s.couponId,offerId:s.offerId}:void 0}function Hn(e){fe||b||i.quote||i.operation||Je&&f.textContent===Je||(f.textContent=Object.values(e.capabilities.plans).some(n=>n.available)?"":o?"当前账号暂无可购买的方案。":"No plans are currently available for this account.")}let He=new Map,it=!1;function Ne(e,n,t,r,l,c){let s=L(e),u=!s&&e.lines.length===1?e.lines[0]:void 0,I=ke(r,l,n.capabilities);if(!I||I!==(s?e.productVersionId:u?.productVersionId))return!1;let p=rt(n,t,I,l,c),x;try{x=Ie(n.document.screen,I,l,n.capabilities)}catch{return!1}if(s){let X=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0);return Object.keys(x).length===Object.keys(e.featureQuantities??{}).length&&Object.entries(x).every(([Ue,St])=>e.featureQuantities?.[Ue]===St)&&(!p||X?.couponId===p.id&&(!p.offerId||X.grantId===p.offerId))}if((p||oe(n).checkoutCoupons?.[t])&&(p?.id??null)!==(e.discount?.couponId??null))return!1;let T=Object.fromEntries((u?.prepaid??[]).map(X=>[X.internal_feature_id,X.quantity]));return[...new Set([...Object.keys(x),...Object.keys(T)])].every(X=>(x[X]??0)===(T[X]??0))}let R=e=>yn({quote:i.quote,operation:e,requestId:null,pending:!1,destroyed:w,canReselect:i.canReselect});async function Qe(e){let n=e.merchantExecution,t=R(e),r=t.type==="checkout"?t.checkoutUrl:e.checkoutUrl;if(!(!E()||!r||ot(e)&&t.type!=="checkout"||a.checkoutNavigation==="after_confirmation"&&t.type!=="checkout"||n?.type==="purchase"&&!["not_started","pending"].includes(n.paymentStatus)||He.get(e.operationId)===r)){He.set(e.operationId,r);try{a.onCheckoutUrl?await a.onCheckoutUrl(r):h.defaultView?.location.assign(r)}catch(l){throw He.delete(e.operationId),l}}}let Ce=(e,n=!1)=>{if(e instanceof Dt)m=null,f.textContent=e.customerMessage(o);else if(Tn(e))m=null,f.textContent=n?o?"当前无法在此购买,付款尚未开始。请联系商户。":"Purchases aren’t available here right now. Payment hasn’t started. Contact the merchant for help.":Mt(e,o);else if(n){let t=e instanceof k?e.code:void 0;t==="CAPABILITY_UNAVAILABLE"||t==="NOT_CONFIGURED"?(m=null,f.textContent=o?"暂时无法为此套餐报价,付款尚未开始。":"Pricing for this plan is unavailable. Payment hasn’t started."):i.canReselect===!0&&!b?f.textContent=o?"未能取得报价,付款尚未开始。请重新选择套餐。":"We couldn’t prepare your price. Payment hasn’t started. Choose a plan again.":t==="COMMAND_PENDING"?f.textContent=o?"仍在准备报价,请重试以查看结果。":"Your price is still being prepared. Retry to check the result.":f.textContent=o?"未能取得报价,付款尚未开始。请重试。":"We couldn’t prepare your price. Payment hasn’t started. Try again."}else f.textContent=e instanceof k&&(e.code==="NETWORK_ERROR"||e.code==="TIMEOUT")?Mt(e,o):e instanceof k?e.message:o?"操作未完成,请重试。":"This action couldn’t be completed. Try again.";y.hidden=m===null,Je=f.textContent,n&&ae===void 0&&!V?.responsive&&f.scrollIntoView?.({block:"nearest"}),K(n&&A?.quoteError?A.quoteError:a.onError,e)},Be=new WeakMap;function je(e){fe=e,y.disabled=e,le.disabled=e,D?.updateCapabilities?.(oe(d),xe(d));for(let n of de?.querySelectorAll("button")??[])e?(Be.has(n)||Be.set(n,n.disabled),n.disabled=!0):Be.has(n)&&(n.disabled=Be.get(n),Be.delete(n)),Lt(n)}function en(){q&&(f.textContent=q.message,y.textContent=o?"重试":"Retry",y.disabled=!1,y.hidden=!q.retry,le.disabled=!0)}function kt(){f.textContent=o?"暂时无法操作,请稍后重试。":"This action is unavailable right now. Try again in a moment."}let tn=new WeakSet;async function Qn(e){if(a.beforeAction)try{await a.beforeAction({purchaseIntent:tn.has(e)})}catch(n){throw n instanceof Dt?(b=null,ye=!1,Te=!1,m=null):m=e,n}}async function W(e,n){if(fe||w||q)return;if(!E()){kt();return}let t=e===qe,r=t?Ln:Un;ae=n!==void 0&&D?.updateCheckoutControls?n:void 0,f.textContent=r,je(!0),Ee(),y.hidden=!0;try{if(e!==cn&&e!==It&&e!==xt&&e!==Xe&&(e!==tt||!a.resumeCheckout)&&await Qn(e),w||q)return;if(!E()){m=e,y.hidden=!1,kt();return}await e()}catch(l){w||Ce(l,t)}finally{ae=void 0,je(!1),Ee(),q?en():f.textContent===r&&(f.textContent="")}}async function nn(e){await Nn(ce,e,a)}function De(e,n){P=n?{quote:e,phase:n}:void 0,n==="checking"?(ae??=b?.actionId??Yt(d)[0],f.textContent=wt,m=It,y.textContent=o?"查询状态":"Check status",y.hidden=!0):ae=void 0,D?.updateCapabilities(oe(d),xe(d)),Ee()}function rn(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 an(e,n){_t(e,{...n,featureQuantities:n.featureQuantities??{}},"Purchase operation changed")}async function It(){P&&await Ae(P.quote)}async function Ae(e,n){De(e,"checking"),Je="";let t=1e3;Ve=!0,K(a.onObservationChange,!0);try{for(let r=n;E();r=void 0){if(!r){try{r=await i.read()}catch(l){if(!rn(l))throw l}if(!E())return}if(r){an(r,e);let l=R(r);if(l.type==="checkout"){De(e,"payment"),f.textContent=o?"请先完成原订单的付款。":"Finish paying for this upgrade.",y.hidden=!1;return}if(l.type==="complete"){De(e,"complete"),m=null;let c=d.capabilities.plans[e.productVersionId]?.name,s=e.merchantTerms?.subscriptionTerms?.items,u=s?.length===1?s[0].interval:void 0,I=u==="year"?o?"年付":"annual billing":u==="month"?o?"月付":"monthly billing":null;f.textContent=c?o?`已升级到 ${c}${I?" "+I:""}。`:`Upgraded to ${c}${I?" ("+I+")":""}.`:o?"已成功升级。":"Plan upgraded.",await nn(r);return}if(l.type==="native"&&!Se(r)){De(e),b=null,m=null,f.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(t,h,Z.signal),t=Math.min(t*1.5,15e3)}}finally{Ve=!1,K(a.onObservationChange,!1)}}async function xt(){let e=P?.quote;if(!e)return;let n=await i.read();if(an(n,e),R(n).type!=="checkout")return Ae(e,n);if(a.resumeCheckout){await a.resumeCheckout(n.operationId);return}He.delete(n.operationId),await Qe(n)}function on(e){return Nt(i).type==="recording"||R(e).type==="recording"}function sn(e){let n=e.merchantTerms,t=n?.subscriptionTerms?.items??[],r=n?n.totalMinor:L(e)?e.totalMinor:e.charge?.totalMinor??e.catalogAmountMinor-(e.discount?.amountMinor??0),l=n?t.length===1&&t[0]?.amountMinor===r&&t[0]:!L(e)&&e.lines.length===1&&e.lines[0]?.catalogAmountMinor===r&&e.lines[0],c=r===null?ve(n.subtotalMinor-n.discountMinor,e.currency)+(o?" + 待确认税费":" + tax confirmed at checkout"):ve(r,e.currency)+(l?Le(l.interval,o?"zh-CN":"en",l.intervalCount??1):""),s=L(e)?i.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(u=>u.productName).join(", ");return{label:s?`${s} · ${c}`:c,recurring:l}}async function H(e,n=a.checkoutNavigation!=="after_confirmation"){if(w)return;if(!E()){m=async()=>H(await i.read()),y.hidden=!1;return}let t=e.quote??i.quote;if(gt(t)&&(e.confirmedAt||e.merchantExecution))return Ae(t,e);if(f.textContent=On(e.status,o),on(e)){let p=e.merchantExecution?.recordingStatus==="failed";f.textContent=p?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",m=async()=>H(await i.read()),y.hidden=!1;return}if(e.problem&&R(e).type!=="native"){let p=e.problem;m=_e,y.textContent=o?"检查并恢复原操作":"Check and recover original purchase",Ce(new k(p.code,p.reason==="RESULT_UNKNOWN"?o?"付款结果尚未确定,请恢复原操作,暂勿重复购买。":"The payment result is unknown. Recover the original purchase before buying again.":p.phase==="fulfillment"?o?"付款已记录,商户权益处理需要核对。":"Payment was recorded. Access fulfillment needs attention.":p.code==="CAPABILITY_UNAVAILABLE"?o?"商户尚不支持本次购买所需的完整能力,请处理后恢复原操作。":"The merchant does not currently support all actions required by this purchase. Recover the original purchase after this is resolved.":p.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,p));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)&&(f.textContent=o?"付款已记录,正在等待商户完成处理。":"Payment was recorded. Waiting for merchant fulfillment."),Ge(e)&&R(e).type==="complete"){m=null,await nn(e);return}let r=Ot(e);if((r||!Se(e))&&R(e).type!=="fulfillment"){if(i.canReselect===!1||r&&Se(e)&&i.canReselect!==!0){f.textContent=o?"正在核对原购买结果":"Checking the original purchase result",y.textContent=o?"查询结果":"Check result",m=async()=>H(await i.read()),y.hidden=!1;return}r?f.textContent=o?"结账未启动,可以重新选择方案。":"Checkout didn’t start. Choose a plan to try again.":e.status==="cancelled"?f.textContent=o?"这笔购买已取消,可以重新选择方案。":"This purchase was cancelled. Choose a plan to start again.":e.status==="failed"&&(f.textContent=o?"这笔购买未能完成,可以重新选择方案。":"This purchase didn’t go through. Choose a plan to try again."),y.textContent=o?"重试":"Retry",m=null,b=null;return}if(!n&&R(e).type==="checkout"){if(F){Xt();return}if(ge()){f.textContent="",it=!1,m=null,y.hidden=!0,D?.updateCapabilities?.(oe(d),xe(d)),Ee();return}let p=i.quote,x=p?.operationId===e.operationId?sn(p).label:"";f.textContent=it?x?o?`${x} 尚未付款。再次选择该方案即可继续付款。`:`${x} is still unpaid. Choose it again to continue paying.`:o?"之前的购买尚未付款。再次选择该方案即可继续付款。":"Your earlier purchase is still unpaid. Choose that plan again to continue paying.":"",it=!1,m=null;return}await Qe(e);let l=Date.now(),c=l+6e5,s=2e3,u=R(e).type!=="checkout",I=()=>u&&Date.now()-l<15e3;Ve=!0,K(a.onObservationChange,!0);try{for(;!w&&Date.now()<c;){if(await Ye(I()?700:s,h,Z.signal),w)return;if(!E()){m=async()=>H(await i.read()),y.hidden=!1;return}let p=await i.read();if(R(p).type==="checkout"&&(u=!1),!n&&R(p).type==="checkout"){await H(p,!1);return}if(!p.problem&&Se(p)&&await Qe(p),!Se(p)||Ot(p)||p.problem||on(p)){await H(p);return}I()||(s=Math.min(s*1.5,3e4))}}finally{Ve=!1,K(a.onObservationChange,!1)}m=async()=>H(await i.read()),y.hidden=!1}async function Et(e=!1){let n=await i.read();if(w)return;if(!E()){m=()=>Et(e),y.hidden=!1;return}let t=i.quote;if(t&&_t(n,{operationId:t.operationId,currency:t.currency},"The original purchase operation changed"),t&&(ot(n)?["prepared","quoted"].includes(n.status):n.status==="pending")&&(ot(n)||n.quoteFinalized===!1)&&!n.confirmedAt&&!n.checkoutUrl&&!("nativePurchase"in n&&n.nativePurchase)&&!n.merchantExecution&&!n.problem&&!i.pendingCancellation){if(a.purchaseConfirmation!=="paywall"){e?await _e():m=null;return}setTimeout(ln,0,t);return}await H(n,e||void 0)}async function cn(){await Et()}async function Bn(e){f.textContent=wt;let n=Date.now()+12e3;for(;!w&&Date.now()<n&&(await Ye(1500,h,Z.signal),!(w||!E()));){let t;try{t=await i.read()}catch{break}if(t.problem?.reason!=="RESULT_UNKNOWN")return t}return e}async function _e(){if(i.quote&&!(Date.parse(i.quote.expiresAt)>Date.now()))throw new k("INVALID_REQUEST",o?"此报价已过期,请重新选择套餐。":"This quote has expired. Choose a plan again.");Jt();let e=i.quote;if(gt(e)){De(e,"checking");let t;try{t=await i.confirm()}catch(r){if(!rn(r))throw r;return Ae(e)}return Ae(e,t)}m=_e;let n=await i.confirm();if(!E()){m=_e,y.hidden=!1;return}if(n.problem?.reason==="RESULT_UNKNOWN"&&(n=await Bn(n)),n.problem){await H(n);return}if(Se(n)){if(R(n).type==="checkout")await Qe(n);else if(n.execution&&n.execution.provider!=="merchant"||"nativePurchase"in n&&n.nativePurchase){if(!a.onPurchase)throw new k("PURCHASE_HANDLER_REQUIRED","Provide the merchant or native purchase handler");await a.onPurchase({operation:n,signal:Z.signal})}}m=async()=>H(await i.read()),await H(n,!0)}function ln(e){if(w)return;de?.remove();let n=!(Date.parse(e.expiresAt)>Date.now());f.textContent=n?o?"此报价已过期。请先取消,再重新选择。":"This quote has expired. Cancel it, then choose again.":"";let t=h.createElement("div"),r=h.createElement("button"),l=h.createElement("button"),c=h.createElement("div"),s=h.createElement("p"),u=e.merchantTerms,I=o?"zh-CN":"en",p=u?.subscriptionTerms?.items??[],x=u?u.subscriptionTerms?.trial?.days:L(e)?void 0:e.lines.find(g=>g.trial)?.trial?.days,T=L(e)?u?u.totalMinor:e.totalMinor:x===void 0?null:u?u.totalMinor:e.charge?e.charge.totalMinor:e.lines.every(g=>g.trial)?0:null,Pe=(g,v)=>o?`${v} 天试用结束后 ${g}`:`Then ${g} after the ${v}-day trial`,{label:X,recurring:Ue}=sn(e),St=L(e)?i.view?.capabilities.plans[e.productVersionId]?.name??"":e.lines.map(g=>g.productName).join(", "),pn=T===null?"":`${o?"今天应付":"Due today"} ${ve(T,e.currency)}`;s.textContent=pn?[St,pn].filter(Boolean).join(" · "):X,r.textContent=L(e)?o?"确认变更":"Confirm change":o?"确认购买":"Confirm purchase",r.disabled=n,l.textContent=o?"取消":"Cancel",t.style.cssText=U.panel,s.style.cssText=U.summary,c.style.cssText=U.actions,r.style.cssText=U.primary,l.style.cssText=U.secondary,Lt(r),r.onclick=()=>{W(_e)};let fn=async()=>{let g=await i.cancel();w||(t.remove(),de=null,await H(g))};l.onclick=()=>{m=fn,W(fn)};let z=h.createElement("div");if(z.style.cssText=U.terms,L(e)){for(let[v,O]of Object.entries(e.featureQuantities??{})){let B=i.view?.capabilities.plans[e.productVersionId]?.prepaid?.find(jn=>jn.internalFeatureId===v),at=h.createElement("p");at.textContent=`${B?.name??v} · ${O} ${o?"份":"packs"}${B?` × ${B.terms.units}`:""}`,z.append(at)}for(let[v,O]of[[o?"原订阅抵扣":"Unused subscription credit",e.creditMinor],[o?"新套餐费用":"New plan charge",e.debitMinor],[o?"优惠减免":"Offer savings",u?.discountMinor??e.discountMinor],[o?"税费":"Tax",u?u.taxMinor:e.taxMinor]]){let B=h.createElement("p");B.textContent=`${v}: ${O===null?o?"结账时确认":"Confirmed at checkout":ve(O,e.currency)}`,z.append(B)}let g=h.createElement("p");g.textContent=`${o?"生效时间":"Effective"}: ${e.effectiveAt}`,z.append(g)}if(u){for(let v of p){if(T===null&&v===Ue)continue;let O=h.createElement("p"),B=ve(v.amountMinor,e.currency)+Le(v.interval,I,v.intervalCount);O.textContent=T!==null&&x!==void 0?Pe(B,x):B,v.amountAfterOfferMinor!==void 0&&(O.textContent+=` · ${o?"优惠结束后":"After the offer"} ${ve(v.amountAfterOfferMinor,e.currency)}${Le(v.interval,I,v.intervalCount)}`),z.append(O)}let g=u.subscriptionTerms?.trial;if(g){let v=h.createElement("p");v.textContent=o?`试用 ${g.days} 天;${g.cardRequired?"需要提供付款方式":"无需提供付款方式"}`:`Trial days: ${g.days}; ${g.cardRequired?"a payment method is required":"no payment method is required"}`,z.append(v)}for(let v of[...u.expectedEffects.map(O=>O.description),...u.requiredConsents.map(O=>O.summary)]){let O=h.createElement("p");O.textContent=v,z.append(O)}}else if(!L(e)){for(let g of e.lines){if(T!==null||g!==Ue){let v=h.createElement("p"),O=`${ve(g.catalogAmountMinor,e.currency)}${Le(g.interval,I,g.intervalCount??1)}`;v.textContent=T!==null&&g.trial?(e.lines.length>1?`${g.productName} · `:"")+Pe(O,g.trial.days):`${g.productName} · ${O}`,z.append(v)}for(let v of g.prepaid??[]){let O=h.createElement("p"),B=i.view?.capabilities.plans[g.productVersionId]?.prepaid?.find(at=>at.internalFeatureId===v.internal_feature_id);O.textContent=`${B?.name??v.internal_feature_id} · ${v.quantity} ${o?"份":"packs"} × ${v.terms.units}`,B&&(O.textContent+=Le(B.reset==="week"||B.reset==="month"||B.reset==="year"?B.reset:"one_time",I,B.resetCount)),z.append(O)}if(g.trial){let v=h.createElement("p");v.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"}`,z.append(v)}}if(!e.charge){let g=h.createElement("p");g.textContent=o?"目录价格;最终金额以结账时税费和试用规则为准。":"Catalog price; the final charge depends on checkout taxes and trial terms.",z.append(g)}}for(let g of z.children)g.style.margin="0";c.append(r,l),t.append(s,...z.childElementCount?[z]:[],c),Y.prepend(t),V?.responsive||t.scrollIntoView?.({block:"nearest"}),r.focus({preventScroll:!0}),de=t,fe&&je(!0),m=null}async function qe(){if(!b)return;if(a.onPurchaseIntent&&!ye&&!i.quote&&!i.operation){let t=b,r=i.view,l=r?.document.buttons[t.actionId],c=r&&l?.type==="checkout"?ke(l.product,t.selection,r.capabilities):null;if(!r||!c)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");let s={actionId:t.actionId,productVersionId:c,selection:structuredClone(t.selection),featureQuantities:Ie(r.document.screen,c,t.selection,r.capabilities),...$&&{coupon:{id:$.id,...$.offerId&&{offerId:$.offerId}}}};b=null,$=void 0,m=null,Ke=!0,await a.onPurchaseIntent(s);return}if(m=qe,!ye){let t=i.view,r=t?.document.buttons[b.actionId],l=t&&r?.type==="checkout"?ke(r.product,b.selection,t.capabilities):null;if(!t||!l)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");if(!Te){let s=Wt(),u=s?await s.result:void 0;if(w)return;let I=a.resolveSubscriptionChange;if(I||u){let p={actionId:b.actionId,productVersionId:l,featureQuantities:Ie(t.document.screen,l,b.selection,t.capabilities)},x=u?[async()=>u(p)]:[],T=I?await I(p,...x):await x[0]?.();if(w)return;T!==void 0&&(b.subscriptionChange=mn.parse(T))}Te=!0}let c=$?.offerId;if($&&!c){if(!a.claimCoupon)throw new k("CAPABILITY_UNAVAILABLE","Coupon claiming is unavailable");let{offer:s}=await a.claimCoupon($.id,b.requestId);if(w)return;if(!s||s.couponId!==$.id||s.status!=="issued"||!(Date.parse(s.expiresAt)>Date.now()))throw b=null,$=void 0,m=async()=>{$e(await i.refresh()),m=null},new k("COUPON_UNAVAILABLE","This Coupon is no longer available for this purchase");c=s.id}if(!$&&!t.document.screen.actions.some(s=>s.id===b?.actionId&&typeof s.properties.couponBinding=="string")&&(c=await a.resolveOfferId?.({actionId:b.actionId,productVersionId:l,featureQuantities:Ie(t.document.screen,l,b.selection,t.capabilities)})),w)return;c!==void 0&&(b.offerId=c),ye=!0}if(!E()){y.hidden=!1;return}let e;try{e=await i.preview(b)}catch(t){throw i.canReselect===!0&&(b=null,ye=!1,Te=!1,$=void 0,m=null),t}if(b.acceptHostedMonthly!==void 0){let t=i.operation;if(!t||t.operationId!==e.operationId||!t.confirmedAt)throw new k("INVALID_RESPONSE","The confirmed Checkout is missing");w||await H(t,!0);return}if($&&(L(e)?(()=>{let t=e.merchantTerms?.discount??(e.execution.provider==="merchant"?e.execution.discount:void 0);return t?.couponId!==$.id||t.grantId!==b.offerId})():e.discount?.couponId!==$.id||e.discount.offerId!==b.offerId))throw new k("INVALID_RESPONSE","The quote did not apply the Coupon selected on this Paywall");if(w)return;let n=e.merchantTerms;if(a.purchaseConfirmation!=="paywall"||a.confirmOnHostedCheckout&&E()&&!L(e)&&e.provider==="merchant"&&e.billingSubscriptionId===null&&n?.request.action==="purchase"&&n.request.mode==="subscription"&&n.subscriptionTerms?.trial===null&&n.requiredConsents.length===0&&Date.parse(e.expiresAt)>Date.now()){if(!E()){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 t=ae?"":o?"正在打开收银台…":"Opening checkout…";f.textContent=t;try{await _e()}catch(r){w||Ce(r)}finally{f.textContent===t&&(f.textContent="")}return}ln(e)}function Re(e="destroy",n=!1){if(w)return;w=!0;let t=ht;ht=void 0,K(t),a.signal?.removeEventListener("abort",se),i.signal?.removeEventListener("abort",se),Q.finish("dismissed"),$t?.(),vt(),h.removeEventListener("visibilitychange",Gt),Z.abort(),Vt?.disconnect(),D?.destroy(),i.destroy(),S.removeEventListener("cancel",dn),_.remove(),M.remove(),n||un(),e==="dismiss"&&K(a.onDismiss)}function un(){if(V?.destroy(),ue){ue.release();return}S.open&&S.close(),S.remove(),N()}G=Re;async function Fe(){if(!he||w||ze||ie==="closing"||!ie&&!E())return;if(!A){Re("dismiss");return}let e=h.createElement("p");e.setAttribute("role","status"),e.textContent=o?"正在关闭…":"Closing…",me||(me=h.createElement("div"),me.style.cssText=Y.style.cssText,Y.replaceWith(me),pe.inert=!0),_.hidden=!1,me.replaceChildren(e,_),ie="closing",_.setAttribute("aria-disabled","true"),_.focus({preventScroll:!0});try{await A.dismiss()}catch(n){w||K(a.onError,n)}w||(ie="retry",e.textContent=o?"未能确认关闭,请重试。":"Could not confirm closure. Try again.",_.textContent=o?"重试关闭":"Retry closing",_.removeAttribute("aria-label"),_.removeAttribute("aria-disabled"))}_.onclick=()=>{Fe()};function dn(e){e.preventDefault(),Fe()}S.addEventListener("cancel",dn),le.onclick=()=>{W(P?xt:tt)},y.onclick=()=>{if(q){q.retry?.();return}m&&W(m)};function At(e){Q.finish("error",e),Re()}function Rt(){if(!(!Bt||he||w||ze||V&&!E()))try{let e=n=>{a.focusAtReveal&&(N=Ut(h)),a.settleMotionAtReveal?D?.setHidden?.(!1,!0):D?.setHidden?.(!1),mt?.(),V&&(S.open||S.showModal(),V.responsive&&S.focus({preventScroll:!0}),!n&&a.loading!=="host"&&vn(S,V.type,V.responsive)),n&&a.loading!=="host"&&typeof pe.animate=="function"&&!h.defaultView?.matchMedia?.("(prefers-reduced-motion: reduce)").matches&&pe.animate([{opacity:.55},{opacity:1}],{duration:160,easing:"ease-out"}),he=!0,Ze()};A?A.present(n=>Q.present(t=>e(n??t))):Q.present(e)}catch(e){At(e),Ce(e)}}try{if(Me.type==="inline"?(dt(),mt=Rn(M,j),j.append(M)):(S.setAttribute("aria-label",d.document.name),_.textContent="×",_.setAttribute("aria-label",o?"关闭":"Close"),kn(_,d.document.screen.theme),_.hidden=bn(d.document),(typeof INDIANA_NATIVE_SHELL_BUILD>"u"||!INDIANA_NATIVE_SHELL_BUILD)&&ue?.content?ue.content.append(_,M):S.replaceChildren(_,M),ue||j.append(S),V=Pn(S,{...d.document.screen,presentation:Me},ft),V.latch(),V.responsive&&(M.style.display="flex",M.style.flexDirection="column",M.style.maxHeight="100%",pe.style.overflow="clip",pe.style.minHeight="0"),ue||(mt=An(S))),lt&&ee){let t=lt(ee);if(typeof t=="function"&&(w?K(t):ht=t),w)throw new DOMException("Presentation cancelled","AbortError");dt()}D=ne(pe,{mode:"live",rendererUrl:"bundled",title:d.document.name,closeActions:Mn,onAuthoredClose(t){ie||w||(_.hidden=t)},hostPresentation:()=>V?.type??Me.type,reportContentHeight:V?.responsive,onResize:t=>{if(!V?.responsive)return;let r=Math.min(t,pt);pe.style.height=`${r}px`,V.setContentHeight(r+Qt())},onSelection(t){for(let[r,l]of Object.entries(t))typeof l=="number"&&typeof J[r]=="number"&&J[r]!==l&&jt.add(r);J=t,Ee(),Ze()},onAction(t,r={},l,c){if(!he||w||ie)return;let s=i.view,u=s?.document.buttons[t];if(!u)return;if(q){u.type==="close"&&Fe();return}if(u.type==="close"&&A&&a.resumeCheckout&&i.operation&&gn(R(i.operation))){Fe();return}if(fe)return;if(!E()){kt();return}if(u.type==="close"){W(async()=>{A?.closeAction?await A.closeAction(t):await a.onAction?.(t),Re(a.onAction?"action":"dismiss")});return}if(u.type==="action"){m=async()=>{if(u.action.type==="event"){if(!a.onEvent)throw new k("EVENT_HANDLER_REQUIRED","Provide the event handler");await a.onEvent(u.action.event)}else a.onOpenUrl?await a.onOpenUrl(u.action.url):h.defaultView?.location.assign(u.action.url);await a.onAction?.(t),m=null},W(m);return}if(ge()&&F){!we&&F.selection.actionId===t&&W(()=>nt(!0),t);return}if(P){if(P.phase==="payment"&&s&&Ne(P.quote,s,t,u.product,r,c)){W(xt,t);return}if(!Ct())return}if(!be()&&!Ct()){ge()&&s&&i.quote&&i.operation&&R(i.operation).type==="checkout"&&Ne(i.quote,s,t,u.product,r,c)?W(tt,t):f.textContent=o?"当前只能继续原订单。":"Only your original checkout is available.";return}if(de&&i.canReselect===!1){f.textContent=o?"请先确认或取消当前购买。":"Confirm or cancel the current purchase first.",V?.responsive||de.scrollIntoView?.({block:"nearest"}),de.querySelector("button")?.focus({preventScroll:!0});return}if(ge()&&a.terminateCheckout&&s&&i.quote&&i.operation&&i.canReselect===!1&&R(i.operation).type==="checkout"){if(Ne(i.quote,s,t,u.product,r,c)){W(tt,t);return}let p=ke(u.product,r,s.capabilities),x;try{if(!p)throw new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area");x=Ie(s.document.screen,p,r,s.capabilities)}catch(Ue){Ce(Ue);return}let T=i.operation.operationId,Pe={actionId:t,requestId:crypto.randomUUID(),selection:structuredClone(r)},X=rt(s,t,p,r,c);W(()=>Zt(T,Pe,X,{actionId:t,productVersionId:p,selection:Pe.selection,featureQuantities:x}),t);return}if((i.quote||b)&&i.canReselect===!1){let p=!!s&&!!i.quote&&Ne(i.quote,s,t,u.product,r,c);it=!!i.quote&&!p,m=i.quote?()=>Et(p):qe,W(m,t);return}let I=s&&ke(u.product,r,s.capabilities);if(!s||!I){Ce(new k("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));return}if(a.onPurchaseIntent){m=null;let p=async()=>{let x={actionId:t,productVersionId:I,selection:structuredClone(r),featureQuantities:Ie(s.document.screen,I,r,s.capabilities)},T=rt(s,t,I,r,c);T&&(x.coupon={id:T.id,...T.offerId&&{offerId:T.offerId}}),Ke=!0,await a.onPurchaseIntent(x)};tn.add(p),W(p,t);return}if(b&&b.actionId!==t){Ce(new k("COMMAND_PENDING","Finish the current purchase"));return}if(!b){$=rt(s,t,I,r,c),b={requestId:crypto.randomUUID(),actionId:t,selection:structuredClone(r)};let p=s.document.screen.actions.find(Pe=>Pe.id===t)?.properties,x=p?.hostedMonthlyPriceMinor,T=p?.hostedMonthlyAutomaticTax;a.purchaseConfirmation==="purchase_button"&&a.confirmOnHostedCheckout&&i.supportsHostedCheckout===!0&&!$&&u.product.type==="fixed"&&typeof T=="boolean"&&typeof x=="number"&&Number.isSafeInteger(x)&&x>0&&x<=1e8&&Object.keys(Ie(s.document.screen,I,r,s.capabilities)).length===0&&(b.acceptHostedMonthly={amountMinor:x,automaticTax:T}),ye=b.acceptHostedMonthly!==void 0,Te=ye}W(qe,t)},onEscape:()=>{Fe()},onError:t=>{let r=new Error(t);!he&&!w&&At(r),Ce(r)},onRendered:t=>{t&&S.setAttribute("aria-label",t),Bt=!0,Rt()}}),D.setHidden?.(!0),ft();let e=ge()&&!!i.quote&&!!i.operation&&R(i.operation).type==="checkout";J=i.quote?_n(d,i.quote)??st(d,{}):st(d,{}),D.update(d.document.screen,ut,{capabilities:oe(d),unavailableActions:xe(d),serverInput:{bindings:[],answers:{}},...Object.keys(J).length?{selection:J}:{}}),$t=i.subscribe?.($e),$e(i.view??d),await Q.wait(D.ready);let n=i.operation;(!e||gt(i.quote))&&(i.quote||n&&(n.confirmedAt||n.checkoutUrl||Ge(n)))&&(m=cn,W(m))}catch(e){throw At(e),e}return{check:ce,host:{get currentResolution(){return d},setPurchaseRecovery(e,n){q={message:e,retry:n},D?.updateCapabilities?.(oe(d),xe(d)),Ee(),en()},get subscriptionUpgradeActive(){return P!==void 0},get observing(){return Ve},get recovery(){return Vn()},async prepareFallback(){if(fe||w||ie||Ke)return{type:"recover",operationId:i.operation?.operationId??i.quote?.operationId??null,requestId:null};je(!0);try{let e=await wn(i);return e.type==="native"&&Re(),e}finally{je(!1)}},setSuspended(e){ze=e,M.hidden=e,e&&S.open?S.close():!e&&!he?Rt():!e&&!w&&he&&Me.type!=="inline"&&!S.open&&S.showModal()},destroy:Re,retainPurchaseDialog(){if(!(w||!S.open||!S.isConnected))return Re("destroy",!0),{dialog:S,content:ue?.content,release:un}},refresh:async()=>{if(!E()){if(i.view)return i.view;throw new k("PRECONDITION_FAILED","Paywall presentation is suspended")}let e=await i.refresh();return $e(e),Rt(),e}}}}export{kr as a};
@@ -1 +1 @@
1
- import{b as e}from"./chunk-ZL247MPX.js";var s=/^gg_ct_[A-Za-z0-9_-]{32,128}$/,o=e.object({customerId:e.uuid(),sessionId:e.uuid(),accessToken:e.string().regex(/^gg_ct_[A-Za-z0-9_-]{43}$/),refreshToken:e.string().regex(/^gg_rt_[A-Za-z0-9_-]{43}$/),expiresAt:e.iso.datetime(),refreshExpiresAt:e.iso.datetime()});export{s as a,o as b};
1
+ import{b as e}from"./chunk-W22ESUYY.js";var s=/^gg_ct_[A-Za-z0-9_-]{32,128}$/,o=e.object({customerId:e.uuid(),sessionId:e.uuid(),accessToken:e.string().regex(/^gg_ct_[A-Za-z0-9_-]{43}$/),refreshToken:e.string().regex(/^gg_rt_[A-Za-z0-9_-]{43}$/),expiresAt:e.iso.datetime(),refreshExpiresAt:e.iso.datetime()});export{s as a,o as b};
@@ -1 +1 @@
1
- import{b as $A}from"./chunk-HSNAFHCP.js";import{a as P}from"./chunk-AECGOS7O.js";import{a as BA,c as jA,d as xA,e as MA,f as UA,h as sA}from"./chunk-CQYEM7U6.js";import{a as zA}from"./chunk-WJDHBJGU.js";import{a as FA}from"./chunk-5MRSFLQA.js";function I(A){return typeof A=="string"?A:String(A)}var Se=/[\ud800-\udbff](?![\udc00-\udfff])|(^|[^\ud800-\udbff])[\udc00-\udfff]/g;function Ie(A){return A.replace(Se,"$1�")}function mA(A,e){if(typeof A!="object"||A==null){let t="";throw t+="The provided value is not an object",new TypeError(t)}return A}function ZA(A){if(A!=null&&(typeof A=="object"||typeof A=="function")){let e=A[Symbol.iterator];if(e==null)return;if(typeof e!="function")throw new TypeError("The provided value is not iterable");let t=e.call(A);if(!t||typeof t!="object")throw new TypeError("Result of the Symbol.iterator method is not an object");return t}}function QA(A){let e;if(Array.isArray(A)){let t=A.map(I);if(t.length===2)return t}else if((e=ZA(A))!=null){let t=mA(e.next()),n=mA(e.next());if(!t.done&&!n.done)return[I(t.value),I(n.value)]}throw new TypeError("Each query pair must be an iterable [name, value] tuple")}var GA="0123456789ABCDEF",Ce=/(?:%[0-9A-Fa-f]{2})+/g;function M(A){return`%${GA[A>>4&15]}${GA[15&A]}`}function Ae(A,e,t=!1){return A>=55296&&A<=57343&&(A=65533),A<=127?t&&A===32?"+":e(A)?M(A):String.fromCharCode(A):A<=2047?M(192|A>>6)+M(128|63&A):A<=65535?M(224|A>>12)+M(128|A>>6&63)+M(128|63&A):M(240|A>>18)+M(128|A>>12&63)+M(128|A>>6&63)+M(128|63&A)}function yA(A){return A>=48&&A<=57?A-48:A>=65&&A<=70?A-65+10:A>=97&&A<=102?A-97+10:-1}function PA(A,e=!1){let t=0;for(;t<A.length;t++){let n=A.charCodeAt(t);if(n===37||e&&n===43)break}return t===A.length?A:(e?A.replace(/\+/g," "):A).replace(Ce,n=>{try{return decodeURIComponent(n)}catch{return"�".repeat(n.length/3)}})}function AA(A){return A<=31||A>126}function be(A){switch(A){case 32:case 34:case 60:case 62:case 96:return!0;default:return AA(A)}}function TA(A){switch(A){case 32:case 34:case 35:case 60:case 62:return!0;default:return AA(A)}}function Ee(A){return TA(A)||A===39}function DA(A){switch(A){case 63:case 94:case 96:case 123:case 125:return!0;default:return TA(A)}}function cA(A){switch(A){case 47:case 58:case 59:case 61:case 64:case 91:case 92:case 93:case 124:return!0;default:return DA(A)}}function KA(A){switch(A){case 33:case 39:case 40:case 41:case 126:return!0;default:return(function(t){switch(t){case 36:case 37:case 38:case 43:case 44:return!0;default:return cA(t)}})(A)}}function ee(A,e){return Ae(A=A||0,e)}function U(A,e,t=!1){let n=0;for(;n<A.length;n++){let u=A.charCodeAt(n);if(u>=128||t&&u===32||e(u))break}if(n===A.length)return A;let r=A.slice(0,n);for(;n<A.length;n++){let u=A.charCodeAt(n),l=u;if(u>=55296&&u<=56319&&n+1<A.length){let a=A.charCodeAt(n+1);a>=56320&&a<=57343&&(l=(u-55296<<10)+a-56320+65536,n++)}r+=Ae(l,e,t)}return r}function vA(A){let e=[],t=0,n=0;for(;n<=A.length;){if(n=A.indexOf("&",t),n<0&&(n=A.length),n!==t){let r=A.slice(t,n),u=r.indexOf("=");u<0&&(u=r.length),e.push([PA(r.slice(0,u),!0),PA(r.slice(u+1),!0)])}if(t=n+1,n===A.length)break}return e}function SA(A){let e="";for(let t=0;t<A.length;t++){let n=U(A[t][0],KA,!0),r=U(A[t][1],KA,!0);e+=t!==0?`&${n}=${r}`:`${n}=${r}`}return e}var Te=[2191,2191,3164,3164,3292,3292,6863,6877,6880,6891,8385,8385,11158,11158,42958,42959,42962,42962,42964,42964,42993,42993,64451,64466,64912,64913,64968,64974,67904,67929,69317,69319,69328,69336,69370,69371,72544,72551,73136,73179,73184,73193,93856,93880,93883,93907,94194,94198,100344,100351,101641,101662,101760,101874,118010,118012,118458,118480,118496,118512,124608,124638,124640,124661,124670,124671,128728,128728,128887,128890,129232,129240,129620,129623,129674,129674,129678,129678,129736,129736,129741,129741,129770,129770,129775,129775,130042,130042,177978,177983,183970,183981,205744,210041],ve=[7296,7297,7298,7299,7300,7301,7302,7303,7304,42958,42962,42964,42993],Oe=["в","д","о","с","т","т","ъ","ѣ","ꙋ","꟏","ꟓ","ꟕ","s"],Re=[2381,2381,2509,2509,2637,2637,2765,2765,2893,2893,3021,3021,3149,3149,3277,3277,3387,3388,3405,3405,3530,3530,3642,3642,3770,3770,3972,3972,4153,4154,5908,5909,5940,5940,6098,6098,6752,6752,6980,6980,7082,7083,7154,7155,11647,11647,43014,43014,43052,43052,43204,43204,43347,43347,43456,43456,43766,43766,44013,44013,68159,68159,69702,69702,69744,69744,69759,69759,69817,69817,69939,69940,70080,70080,70197,70197,70378,70378,70477,70477,70606,70608,70722,70722,70850,70850,71103,71103,71231,71231,71350,71350,71467,71467,71737,71737,71997,71998,72160,72160,72244,72244,72263,72263,72345,72345,72767,72767,73028,73029,73111,73111,73537,73538,90415,90415];function ke(A){for(let e=0;e<A.length;e++){let t=A.codePointAt(e);if(t>65535&&e++,t<=32||t===37||t===127||t>=55296&&t<=57343||t>=128&&t<=159||t>=64976&&t<=65007||!(65534&~t)||t===65533)return!0}return!1}var[qe,Ne,Le,YA]=[[[],"0,6,7,8,m,w,10,1b,1d,1f,72,73,7k,8k,dt,2rk","AAAAAAAAAAAAAAAAAAAAAP////8AAAAAAAAAAAAAAAA/AAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAADAAABwfwAAAAAAAMADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//w8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAhAAAAQAAAAAAAAQCAAABAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgACAAAAAAAAAAAAAAAAD//wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAP///////////////wAAAAAAAAAAAAAAAAAAAAA="],[[],"6,7,8,o,4o,7e,7f,7h,7i,7j,dl","AAAAAEF9+P/+BwAAAMAA//8AAPz/////BlADAAAAAJwAAPz///8AAADA//H/5+X8AAAAAAAAAAAA/P///wcAAAAAAAAAAAAAPv0vAD0BAABA/gAA/5/5/f8BAAAAAAAAgAAAAP//////////////AYD/////BQAAAAAAAAAAAAAAAAAAAAAAAP///////wcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD8g+N8B+AAAAAAAAAAAAAAAAAAAAAAAAP//AwAAYAAAAAAAAAAAAAD/////CwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANgAAAAAAAAAAAAAAAAA//8fAB4AAAD//wMAAAAAAH3/HgwAAAAAAAD//////////w8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="],[[],"6,7,8,o,4o,7e,7f,7h,7i,7j,dl","AAAAAP3////+BwAAAMDu//////////////8vAADAAJwAAP3///8AAADg////////AAAAAAAAAAAA/P///wcAAAAAAAAAAAAA////Ab0H//9H/gAA/9////8BAAAAAAAAgAAAAP//////////////AYD/////BQAAAAAAAAAAAAAAAAAAAAAAAP///////wcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAL/G//8T+AAAAAAAAAAAAAAAAAAAAAAAAP//AwAAfgAAAAAAAAAAAAD+////DwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANwAAAAAAAAAAAAAAAAA//8fAB4AAAD//wMAAAAAAH3/Hg4AAAAAAAD//////////w8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="],[[],"0,3,4,5,6,7,8,9,a,b,c,d,e,f,g,j,n,o,p,q,r,s,t,w,18,19,1c,4m,4o,4p,4q,4r,6z,72,73,75,76,77,7e,7h,7i,7j,7k,7l,7m,7n,7o,7p,7q,7r,7s,7t,7u,7v,7w,7x,7y,7z,8k,9t,a2,a3,a7,cc,cv,cx,cy,d6,dc,dd,de,dg,dh,di,dk,dl,2rk,2rl","AAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAD//////////////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD4AwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/v////+/tgAAAAAAAAAAAP8XAAAAAAD4//8AAAEAAAAAAAAAAAAAAMCfnz0AAACAAgAAAP///wcAAAAAAAAAAAAAwP8BAAAAAAAA+A8gAADA++8+AAAAAAAOAAAAAAAAgP8AAAAAAPz///v///8HAAAAAAAAFP4h/gAMAAAAAgAAAAAAABAeIAAADAAAQAYAAAAAAAAQhjkCAAAAIwAGAAAAAAAAEL4hAAAMAAD8AgAAAAAAAJAeIGAADAAAAAQAAAAAAAAAASAAAAAAAAARAAAAAAAA0ME9YAAMAAAAAgAAAAAAAJBAMAAADAAAAAMAAAAAAAAYHiAAAAwAAAACAAAAAAAAAAAEXAAAAAAAAAAAAAAA8geAfwAAAAAAAAAAAAAAAPIfAH8AAAAAAAAAAAADAACgAgAAAAAAAP5/3+D//v///x9AAAAAAAAAAAAAAAAA4P1mAAAAwwEAHgBkIAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAMAAAADAAAAAwAAAAAAAAAsD9A/g8gAAAAAAC4AAAAAAAAAAAAAAAAAABgAAAAAAIAAAAAAAAAAAAAAAAAAIcBBA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAJAAAAAAAAQH/lH/ifAAAAAAAA//////8//w8AAA8AAAAAANAXBAAAAAD4DwADAAAAPDsAAAAAAABAowMAAAAAAADwzwAAAAAAAAAAAAAAAAAAAAAAAAD3//0hEAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////wDIAAAAfAAAAAAAAB/8AAAAAAAAAAAAAAAA/////wEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAwAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAA/////wAAAAAAPAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAID3PwAAAMAAAAAAAAAAAAAAAwBECAAAYBAAAAAAAAAAAAAAAAAAAAAAAAAwAAAA//8DgAAAAADAPwAAgP8DAAAAAAAHAAAAAADIMwAAAAAgAAAAAAAAAAB+ZgAIEAAAAAAAEAAAAAAAAJ3BAgAAAAAwQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAICEAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//8AAP//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAMAHAAAAAAAAAAAAAAAAAAAAAG7wAAAAAACHAAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAAAAAAPAAAAAAAAAAAD4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAA/AAAAAAAAAAAwP8BAAAAAAA8AAAAAAAAAAAAAAAAAAAAAgAAAAAAAP9/AAAAAAAZgAMAAAAAAHgGBAAAAAAAAAAHAAAAgO8fAAAAAAAAAAgAAwAAAAAAwH8AngAAAAAAAAAAAAAAgNNAAgAAAAAAAAAAAAAAAAAAAAAAAID4BwAAAwAAAAAAABgBAAAAwB8fAAAAAAAAAAD4AUAFAAYAAAAAAAAAAAAA/1wAAEAAAAAAAAAAAAAA+IUNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8sAEAADAAAAAAAAAAAAAA+KcBAAAAAAAAAAAAAAAAKL8AAAAAAAAAAAAAAACgvA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgP8GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFgIAAAAAAAAAAAAAAAAAAAAAADwDAEAAAD+BwAAAAD4eYAAfg4AAAAAAPx/AwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAf78AAAAAAAAAAAAA/P///G0AAAAAAAAAAAAAAAAAAAB+tL8AAAAAAAAAAACjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAwAcFAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//4H/PwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMD/4wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHwAAAAAAAAB/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAcAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAPAAAAAAAAAAAAAAD//////z///38AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAD+P/nDwAAADwAAAAAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////9/+P//////HyAAEAAA+P7/AAAAAAAAAAAAAH////nbBwAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAfwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASMAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAfwAAAAAAAAAAAAAAAADwDwAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAA////////////////AAAAAAAAAAAAAAAAAAAAAP///////////////////////////////////////wAA"]].map(function([e,t,n]){return[e,t.split(",").map(r=>parseInt(r,36)),Uint8Array.from(atob(n),r=>r.charCodeAt(0))]});function He(A,e){return e===931||e===1010||e===120531||e===120589||e===120647||e===120705||e===120763?"σ":e>=5112&&e<=5117?String.fromCodePoint(e-8):e>=43888&&e<=43967?String.fromCodePoint(e-38864):e>=93856&&e<=93880?String.fromCodePoint(e+27):e===837||e===890||e>=8064&&e<=8111||e>=8114&&e<=8188?A.normalize("NFD").replace(/\u0345/g,"ι").normalize("NFC").toLowerCase():""}function te(A,e){for(let t=0;t<A.length;t+=2)if(e>=A[t]&&e<=A[t+1])return!0;return!1}function W(A,e){let[t,n,r]=A,u=e>>8;for(let h=0;h<t.length;h+=2)if(u>=t[h]&&u<=t[h+1])return!0;let l=n.indexOf(u);if(l<0)return!1;let a=255&e;return!!(r[32*l+(a>>3)]&1<<(7&a))}function _e(A){let e=Array.from(A,t=>t.codePointAt(0));for(let t=0;t<e.length;t++){let n=e[t];if(n!==8204&&n!==8205||t>0&&te(Re,e[t-1]))continue;if(n===8205)return!1;let r=t-1;for(;r>=0&&W(YA,e[r]);)r--;let u=t+1;for(;u<e.length&&W(YA,e[u]);)u++;if(!(r>=0&&u<e.length&&W(Ne,e[r])&&W(Le,e[u])))return!1}return!0}var Be=/(?![\p{Mark}\p{Decimal_Number}])[\p{Script=Arabic}\p{Script=Hebrew}]/u,je=/\p{Script=Latin}/u;function xe(A){return!Be.test(A)||!je.test(A)}var F=36,iA=1,IA=26,Me=38,Ue=700,$e=72,ze=128,Fe=2147483647;function VA(A){return String.fromCharCode(A+22+75*+(A<26))}function Qe(A,e,t){let n=0;for(A=t?Math.floor(A/Ue):A>>1,A+=Math.floor(A/e);A>(F-iA)*IA>>1;n+=F)A=Math.floor(A/(F-iA));return Math.floor(n+(F-iA+1)*A/(A+Me))}function Ge(A){let e=Array.from(A,h=>h.codePointAt(0)),t="",n=0;for(let h=0;h<e.length;h++){let f=e[h];f<128&&(t+=String.fromCharCode(f),n++)}let r=n;r&&(t+="-");let u=ze,l=0,a=$e;for(;n<e.length;){let h=Fe;for(let f=0;f<e.length;f++){let g=e[f];g>=u&&g<h&&(h=g)}l+=(h-u)*(n+1),u=h;for(let f=0;f<e.length;f++){let g=e[f];if(g<u&&l++,g===u){let p=l;for(let m=F;;m+=F){let y=m<=a?iA:m>=a+IA?IA:m-a;if(p<y)break;t+=VA(y+(p-y)%(F-y)),p=Math.floor((p-y)/(F-y))}t+=VA(p),a=Qe(l,n+1,n===r),l=0,n++}}l++,u++}return t}function pA(A){let e=10;if(A.length>=2&&A[0]==="0"&&(A[1]==="x"||A[1]==="X"))A=A.slice(2),e=16;else if(A.length>=2&&A[0]==="0")A=A.slice(1),e=8;else if(A==="")return-1;let t=0;for(let n=0;n<A.length;n++){let r=yA(A.charCodeAt(n));if(r>=e||r<0)return-1;t=t*e+r}return t}function XA(A){switch(A){case".":case"%2e":case"%2E":return!0;default:return!1}}function ne(A,e){return(A>=65&&A<=90||A>=97&&A<=122)&&(e===58||e===124)}function re(A){return A.length===2&&ne(A.codePointAt(0),A.codePointAt(1))}function JA(A){return A.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|\/|:|<|>|\?|@|\[|\\|\]|\^|\|/u)!==-1}function b(A){switch(A){case"ftp":case"http":case"https":case"ws":case"wss":case"file":return!0;default:return!1}}function se(A){switch(A){case"ftp":return 21;case"http":case"ws":return 80;case"https":case"wss":return 443;default:return null}}function CA(A,e){if(A[0]==="[")return A[A.length-1]==="]"?(function(n){let r=[0,0,0,0,0,0,0,0],u=null,l=0,a=0,h=Array.from(n,f=>f.codePointAt(0));if(h[a]===58){if(h[a+1]!==58)return null;a+=2,l++,u=l}for(;a<h.length;){if(l===8)return null;if(h[a]===58){if(u!==null)return null;a++,l++,u=l;continue}let f=0,g=0,p=0;for(;p<4&&(f=yA(h[a]))>=0;)g=(g<<4)+f,a++,p++;if(h[a]===46){if(p===0||l>6)return null;a-=p;let m=0;for(;h[a]!==void 0;){let y=0;if(m>0)if(h[a]===46&&m<4)a++;else return null;if(h[a]==null||h[a]<48||h[a]>57)return null;for(;h[a]>=48&&h[a]<=57;){if(y=10*y+yA(h[a]),y>255)return null;a++}r[l]=256*r[l]+y,m++,m%2==0&&l++}if(m!==4)return null;break}else if(h[a]===58){if(h[++a]===void 0)return null}else if(h[a]!==void 0)return null;r[l]=g,l++}if(u!==null){let f=l-u;for(l=7;l!==0&&f>0;){let g=r[u+f-1];r[u+f-1]=r[l],r[l]=g,l--,f--}}else if(u===null&&l!==8)return null;return r})(A.substring(1,A.length-1)):null;if(e)return(function(n){return JA(n)?null:U(n,AA)})(A);{let t=(function(r){let u=!1,l=!1;for(let h=0;h<r.length;h++){let f=r.charCodeAt(h);if(f<=32||f===37||f===127)return null;if(f>=128){u=!0;break}f>=65&&f<=90&&(l=!0)}if(!u)return r!==""?l?r.toLowerCase():r:null;if((function(f){for(let g of f){let p=g.codePointAt(0);if(/[\p{Cn}\p{Co}\p{Cs}\p{Noncharacter_Code_Point}]/u.test(g)&&!te(Te,p)||W(qe,p))return!0}return!1})(r))return null;let a=(r=(function(f){let g="";for(let p of f){let m=p.codePointAt(0);if(m!==8204&&m!==8205&&/\p{Default_Ignorable_Code_Point}/u.test(p))continue;let y=He(p,m);if(y){g+=y;continue}let k=ve.indexOf(m);g+=k<0?p:Oe[k]}return g})(r).normalize("NFKC").replace(/[\u3002\uff0e\uff61]/g,".").toLowerCase()).split(".");for(let h=0;h<a.length;h++){let f=a[h];if(f==="")continue;let g=/[^\0-\x7f]/.test(f);if(ke(f)||g&&(/^\p{Mark}/u.test(f)||!_e(f)||!xe(f)||f.startsWith("xn--")))return null;g&&(a[h]=`xn--${Ge(f)}`)}return(r=a.join("."))!==""?r:null})(A.indexOf("%")===-1?A:PA(A));return t===null||JA(t)?null:(function(r){let u=r.length,l=r.lastIndexOf(".",u-2)+1;if(r.charCodeAt(u-1)===46&&u--,u<=l)return!1;if(pA(r.slice(l,u))>=0)return!0;for(;l<u;l++){let a=r.charCodeAt(l);if(a<48||a>57)return!1}return!0})(t)?(function(r){let u=r.split("."),l=u.length;if(u[l-1]||l--,l>4)return null;let a=0;for(let f=0;f<l-1;f++){let g=pA(u[f]);if(g<0||g>255)return null;a+=g*(1<<8*(3-f))}let h=pA(u[l-1]);return h<0||h>=256**(5-l)?null:(a+=h,a)})(t):t}}function bA(A){return typeof A=="number"?(function(t){let r="";return r+=`${(t>>>24&255).toString(10)}.`,r+=`${(t>>>16&255).toString(10)}.`,r+=`${(t>>>8&255).toString(10)}.`,r+=(t&255).toString(10),r})(A):Array.isArray(A)?`[${(function(t){let n=(function(a){let h=-1,f=-1,g=1,p=0;for(let m=0;m<a.length;++m)a[m]!==0?(p>g&&(h=f,g=p),f=-1,p=0):(f===-1&&(f=m),++p);return p>g?f:h})(t),r="",u=!1;for(let l=0;l<=7;++l)if(!(u&&t[l]===0)){if(u&&(u=!1),n===l){r+=l===0?"::":":",u=!0;continue}r+=t[l].toString(16),l!==7&&(r+=":")}return r})(A)}]`:A}function oe(A){A.path.length>0&&(A.path.length!==1||A.scheme!=="file"||!(function(t){return/^[A-Za-z]:$/u.test(t)})(A.path[0]))&&A.path.pop()}function ie(A){return A.username!==""||A.password!==""}function gA(A){return A.host===null||A.host===""||A.scheme==="file"}var s=0,o="",w="",D=null,i,lA=!1,uA=!1,G=!1,E;function H(A,e,t,n){e||(A=(function(l){let a=0,h=l.length;for(;a<h&&!(l.charCodeAt(a)>32);++a);for(;h>a&&!(l.charCodeAt(h-1)>32);--h);return l.substring(a,h)})(A)),A=(function(l){let a=0;for(;a<l.length;a++){let f=l.charCodeAt(a);if(f===9||f===10||f===13)break}if(a===l.length)return l;let h=l.slice(0,a);for(;a<l.length;a++){let f=l.charCodeAt(a);f!==9&&f!==10&&f!==13&&(h+=l[a])}return h})(A),s=0,o=A,w="",D=t||null,i=e||{scheme:"",username:"",password:"",host:null,port:null,path:[],query:null,fragment:null,opaquePath:!1},lA=!1,uA=!1,G=!1,E=n||0;let r=Ke;switch(n){case 3:case 4:r=aA;break;case 5:r=RA;break;case 6:r=K;break;case 7:r=Q;break;case 8:r=$}return r(c(A,s))!==1?i:null}function d(A,e){return s+=s===A?j(e):1,s<=o.length}function c(A,e){return e<A.length?A.codePointAt(e):void 0}function j(A){return A!=null&&A>65535?2:1}function le(A){return A==null?"":A<=65535?String.fromCharCode(A):String.fromCodePoint(A)}var Ke=A=>{let e=s;if(A!=null&&(A>=65&&A<=90||A>=97&&A<=122)){let t=s+1;for(A=o.charCodeAt(t);A===43||A===45||A===46||A>=65&&A<=90||A>=97&&A<=122||A>=48&&A<=57;)t++,A=o.charCodeAt(t);return w=o.slice(s,t).toLowerCase(),s=t,Ye(t<o.length?A:void 0)}else return E?1:(--s,d(e,A)?ue(c(o,s)):0)},Ye=A=>{let e=s;if(A===58){if(E){if(b(i.scheme)!==b(w))return 0;if((ie(i)||i.port!==null)&&w==="file")return 0;if(i.scheme==="file"&&i.host==="")return 0}return i.scheme=w,E?(i.port===se(i.scheme)&&(i.port=null),0):(w="",i.scheme==="file"?d(e,A)?kA(c(o,s)):0:b(i.scheme)&&D!==null&&D.scheme===i.scheme?d(e,A)?Ve(c(o,s)):0:b(i.scheme)?d(e,A)?Je(c(o,s)):0:c(o,s+1)===47?(s++,d(e,A)?Xe(c(o,s)):0):(i.path=[""],i.opaquePath=!0,d(e,A)?ae(c(o,s)):0))}else return E?1:(w="",s=-1,d(e,A)?ue(c(o,s)):0)},ue=A=>{let e=s;return D===null||D.opaquePath&&A!==35?1:D.opaquePath&&A===35?(i.scheme=D.scheme,i.path=D.path.slice(),i.opaquePath=D.opaquePath,i.query=D.query,i.fragment="",d(e,A)?$(c(o,s)):0):D.scheme==="file"?(s--,d(e,A)?kA(c(o,s)):0):(s--,d(e,A)?OA(c(o,s)):0)},Ve=A=>{let e=s;return A===47&&c(o,s+1)===47?(++s,d(e,A)?hA(c(o,s)):0):(s--,d(e,A)?OA(c(o,s)):0)},Xe=A=>{let e=s;return A===47?d(e,A)?J(c(o,s)):0:(s--,d(e,A)?x(c(o,s)):0)},OA=A=>{let e=s;return i.scheme=D.scheme,A===47||b(i.scheme)&&A===92?d(e,A)?WA(c(o,s)):0:(i.username=D.username,i.password=D.password,i.host=D.host,i.port=D.port,i.path=D.path.slice(),i.query=D.query,A===63?(i.query="",d(e,A)?Q(c(o,s)):0):A===35?(i.fragment="",d(e,A)?$(c(o,s)):0):A!=null?(i.query=null,i.path.pop(),s--,d(e,A)?x(c(o,s)):0):d(e,A)?OA(c(o,s)):0)},WA=A=>{let e=s;return b(i.scheme)&&(A===47||A===92)?d(e,A)?hA(c(o,s)):0:A===47?d(e,A)?J(c(o,s)):0:(i.username=D.username,i.password=D.password,i.host=D.host,i.port=D.port,s--,d(e,A)?x(c(o,s)):0)},Je=A=>{let e=s;return A===47&&c(o,s+1)===47?s++:s--,d(e,A)?hA(c(o,s)):0},hA=A=>{let e=s;return A!==47&&A!==92?(s--,d(e,A)?J(c(o,s)):0):d(e,A)?hA(c(o,s)):0},J=A=>{let e=s;if(A!=null&&A!==64&&A!==35&&A!==47&&A!==63&&(A!==92||!b(i.scheme))){let t=s+j(A);for(;t<o.length;){let n=c(o,t);if(n==null||n===64||n===35||n===47||n===63||n===92&&b(i.scheme))break;t+=j(n)}return w+=o.slice(s,t),s=t-1,d(e,A)?J(c(o,s)):0}if(A===64){lA&&(w=`%40${w}`),lA=!0;for(let t=0;t<w.length;t++){let n=w.codePointAt(t);if(n===58&&!uA){uA=!0;continue}let r=ee(n,cA);uA?i.password+=r:i.username+=r,n!=null&&n>65535&&t++}return w="",d(e,A)?J(c(o,s)):0}else return A==null||A===35||A===47||A===63||A===92&&b(i.scheme)?lA&&w===""?1:(s-=w.length+1,w="",d(e,A)?aA(c(o,s)):0):(w+=le(A),d(e,A)?J(c(o,s)):0)},aA=A=>{let e=s;if(E&&i.scheme==="file")return s--,d(e,A)?qA(c(o,s)):0;if(A!=null&&A!==58&&A!==35&&A!==47&&A!==63&&(A!==92||!b(i.scheme))){let t=s+j(A);for(A===91?G=!0:A===93&&(G=!1);t<o.length;){let n=c(o,t);if(n==null||!G&&n===58||n===35||n===47||n===63||n===92&&b(i.scheme))break;n===91?G=!0:n===93&&(G=!1),t+=j(n)}return w+=o.slice(s,t),s=t-1,d(e,A)?aA(c(o,s)):0}else if(A===58&&!G){if(w===""||E===4)return 1;let t=CA(w,!b(i.scheme));return t===null?1:(i.host=bA(t),w="",d(e,A)?RA(c(o,s)):0)}else if(A==null||A===35||A===47||A===63||A===92&&b(i.scheme)){if(s--,b(i.scheme)&&w==="")return 1;if(E&&w===""&&(ie(i)||i.port!==null))return 1;let t=CA(w,!b(i.scheme));return t===null?1:(i.host=bA(t),w="",E?0:d(e,A)?K(c(o,s)):0)}else return w+=le(A),d(e,A)?aA(c(o,s)):0},RA=A=>{let e=s;if(A!=null&&A>=48&&A<=57){let t=s+1;for(;t<o.length;){let n=o.charCodeAt(t);if(n<48||n>57)break;t++}return w+=o.slice(s,t),s=t-1,d(e,A)?RA(c(o,s)):0}else if(E||A==null||A===35||A===47||A===63||A===92&&b(i.scheme)){if(w!==""){let t=parseInt(w,10);if(t>65535)return 1;if(i.port=t===se(i.scheme)?null:t,w="",E)return 0}return E?1:(s--,d(e,A)?K(c(o,s)):0)}else return 1};function ce(A,e){let t=A.length-e;if(t<2)return!1;if(ne(c(A,e),c(A,e+1))){if(t===2)return!0;{let n=c(A,e+2);return n===47||n===92||n===63||n===35}}else return!1}var kA=A=>{let e=s;return i.scheme="file",i.host="",A===47||A===92?d(e,A)?We(c(o,s)):0:D?.scheme==="file"?(i.host=D.host,i.path=D.path.slice(),i.opaquePath=D.opaquePath,i.query=D.query,A===63?(i.query="",d(e,A)?Q(c(o,s)):0):A===35?(i.fragment="",d(e,A)?$(c(o,s)):0):A!=null?(i.query=null,ce(o,s)?i.path=[]:oe(i),s--,d(e,A)?x(c(o,s)):0):d(e,A)?kA(c(o,s)):0):(s--,d(e,A)?x(c(o,s)):0)},We=A=>{let e=s;return A===47||A===92?d(e,A)?qA(c(o,s)):0:(D!==null&&D.scheme==="file"&&(!ce(o,s)&&(function(n){if(n.length===2){let r=n.codePointAt(0),u=n.codePointAt(1);return(r>=65&&r<=90||r>=97&&r<=122)&&u===58}else return!1})(D.path[0])&&i.path.push(D.path[0]),i.host=D.host),s--,d(e,A)?x(c(o,s)):0)},qA=A=>{let e=s;if(A!=null&&A!==47&&A!==92&&A!==63&&A!==35){let t=s+j(A);for(;t<o.length;){let n=c(o,t);if(n==null||n===47||n===92||n===63||n===35)break;t+=j(n)}return w+=o.slice(s,t),s=t-1,d(e,A)?qA(c(o,s)):0}else if(A==null||A===47||A===92||A===63||A===35){if(s--,!E&&re(w))return d(e,A)?x(c(o,s)):0;if(w==="")return i.host="",E?0:d(e,A)?K(c(o,s)):0;{let t=CA(w,!b(i.scheme));return t===null?1:(t==="localhost"&&(t=""),i.host=bA(t),w="",E?0:d(e,A)?K(c(o,s)):0)}}return 1},K=A=>{let e=s;return b(i.scheme)?(A!==92&&A!==47&&s--,d(e,A)?x(c(o,s)):0):!E&&A===63?(i.query="",d(e,A)?Q(c(o,s)):0):!E&&A===35?(i.fragment="",d(e,A)?$(c(o,s)):0):A!=null?(A!==47&&s--,d(e,A)?x(c(o,s)):0):(E&&i.host===null&&i.path.push(""),d(e,A)?K(c(o,s)):0)},x=A=>{let e=s;if(A!=null&&A!==47&&(!b(i.scheme)||A!==92)&&(E||A!==63&&A!==35)){let t=s+j(A);for(;t<o.length;){let n=c(o,t);if(n==null||n===47||b(i.scheme)&&n===92||!E&&(n===63||n===35))break;t+=j(n)}w+=U(o.slice(s,t),DA),s=t,A=c(o,t)}if(A==null||A===47||b(i.scheme)&&A===92||!E&&(A===63||A===35)){let t=b(i.scheme)&&A===92;return(function(r){switch(r){case"..":case"%2e.":case"%2E.":case".%2e":case".%2E":case"%2e%2e":case"%2E%2e":case"%2e%2E":case"%2E%2E":return!0;default:return!1}})(w)?(oe(i),A!==47&&!t&&i.path.push("")):XA(w)&&A!==47&&!t?i.path.push(""):XA(w)||(i.scheme==="file"&&i.path.length===0&&re(w)&&(w=`${w[0]}:`),i.path.push(w)),w="",A===63?(i.query="",d(e,A)?Q(c(o,s)):0):A===35?(i.fragment="",d(e,A)?$(c(o,s)):0):d(e,A)?x(c(o,s)):0}else return w+=ee(A,DA),d(e,A)?x(c(o,s)):0},ae=A=>{let e=s;if(A===63)return i.query="",d(e,A)?Q(c(o,s)):0;if(A===35)return i.fragment="",d(e,A)?$(c(o,s)):0;if(A!=null){let t=s+j(A);for(;t<o.length;){let r=c(o,t);if(r===63||r===35)break;t+=j(r)}let n=o.slice(s,t);if(t<o.length&&n.charCodeAt(n.length-1)===32?i.path[0]+=U(n.slice(0,-1),AA)+"%20":i.path[0]+=U(n,AA),s=t,(A=c(o,t))===63)return i.query="",d(e,A)?Q(c(o,s)):0;if(A===35)return i.fragment="",d(e,A)?$(c(o,s)):0}return d(e,A)?ae(c(o,s)):0},Q=A=>{let e=s,t=s;if(A!=null){if(E)t=o.length;else{let r=o.indexOf("#",s);t=r===-1?o.length:r}let n=b(i.scheme)?Ee:TA;i.query+=U(o.slice(s,t),n)}return s=t,c(o,t)===35&&!E?(i.fragment="",d(e,A)?$(c(o,s)):0):d(e,A)?Q(c(o,s)):0},$=A=>{let e=s;return A!=null&&(i.fragment+=U(o.slice(s),be),s=o.length),d(e,A)?$(c(o,s)):0};function EA(A){if(A.opaquePath)return A.path[0];{let e="";for(let t of A.path)e+=`/${t}`;return e}}function fe(A){switch(A.scheme){case"blob":{let e=H(EA(A),null,null,0);return e===null||e.scheme!=="http"&&e.scheme!=="https"?"null":fe(e)}case"ftp":case"http":case"https":case"ws":case"wss":return(function(t){let n=`${t.scheme}://`;return n+=t.host,t.port!==null&&(n+=`:${t.port}`),n})(A);default:return"null"}}var S=Symbol("URLImpl"),eA=class A{constructor(e,t){if(e===void 0&&t===void 0)throw new TypeError('The "url" argument must be specified.');e=I(e),t!=null&&(t=I(t));let n=null;if(t!=null&&(n=H(t,null,null,0),n==null))throw new TypeError(`Invalid base URL: ${t}`);let r=H(e,null,n,0);if(r==null)throw new TypeError(`Invalid URL: ${e}`);this[S]={url:r,query:null}}static createObjectURL(e){throw new TypeError("URL.createObjetURL is unsupported")}static revokeObjectURL(e){}static parse(e,t){e=I(e),t!==void 0&&(t=I(t));try{return new A(e,t)}catch{return null}}static canParse(e,t){e=I(e),t!==void 0&&(t=I(t));let n=null;return t!=null&&(n=H(t,null,null,0),n==null)?!1:H(e,null,n,0)!=null}get href(){return(function(t){let n=`${t.scheme}:`;return t.host!==null&&(n+="//",(t.username!==""||t.password!=="")&&(n+=t.username,t.password!==""&&(n+=`:${t.password}`),n+="@"),n+=t.host,t.port!==null&&(n+=`:${t.port}`)),t.host===null&&!t.opaquePath&&t.path.length>1&&t.path[0]===""&&(n+="/."),n+=EA(t),t.query!==null&&(n+=`?${t.query}`),t.fragment!==null&&(n+=`#${t.fragment}`),n})(this[S].url)}set href(e){let t=H(e=I(e),null,null,0);if(t==null)throw new TypeError(`Invalid URL: ${e}`);this[S].url=t,this[S].query&&wA(this[S].query,t.query)}get origin(){return fe(this[S].url)}get protocol(){return`${this[S].url.scheme}:`}set protocol(e){H(`${e=I(e)}:`,this[S].url,null,2)}get username(){return this[S].url.username}set username(e){e=I(e),gA(this[S].url)||(function(n,r){n.username=U(r,cA)})(this[S].url,e)}get password(){return this[S].url.password}set password(e){e=I(e),gA(this[S].url)||(function(n,r){n.password=U(r,cA)})(this[S].url,e)}get host(){let{url:e}=this[S];return e.host==null?"":e.port==null?e.host:`${e.host}:${e.port}`}set host(e){e=I(e),this[S].url.opaquePath||H(e,this[S].url,null,3)}get hostname(){let{url:e}=this[S];return e.host!=null?e.host:""}set hostname(e){e=I(e),this[S].url.opaquePath||H(e,this[S].url,null,4)}get port(){let{url:e}=this[S];return e.port!=null?`${e.port}`:""}set port(e){e=I(e);let{url:t}=this[S];gA(t)||(e?H(e,t,null,5):t.port=null)}get pathname(){return EA(this[S].url)}set pathname(e){e=I(e);let{url:t}=this[S];t.opaquePath||(t.path=[],H(e,t,null,6))}get search(){let{url:e}=this[S];return e.query?`?${e.query}`:""}set search(e){e=I(e);let{url:t,query:n}=this[S];if(!e)t.query=null,n&&wA(n,null);else{let r=e[0]==="?"?e.substring(1):e;t.query="",H(r,t,null,7),n&&wA(n,t.query)}}get searchParams(){let e=this[S],t=e.query;return t==null&&(t=e.query=(function(r,u){let l=new fA;return l[C].url=r,l[C].serialized=u==null,u&&(l[C].list=vA(u)),l})(this,e.url.query)),t}get hash(){let{url:e}=this[S];return e.fragment?`#${e.fragment}`:""}set hash(e){e=I(e);let{url:t}=this[S];if(!e)t.fragment=null;else{let n=e[0]==="#"?e.substring(1):e;t.fragment="",H(n,t,null,8)}}toJSON(){return this.href}toString(){return this.href}};Object.defineProperty(eA.prototype,Symbol.toStringTag,{value:"URL",configurable:!0});var C=Symbol("URLSearchParamsImpl"),Ze=Symbol.dispose||Symbol.for("dispose");function wA(A,e){e?A[C].list=vA(e):A[C].list.length=0,A[C].serialized=e==null}function oA(A){if(A.url){let e=SA(A.list);(function(n,r){n[S].url.query=r})(A.url,e||null),A.serialized=!0}}var At=typeof Iterator<"u"?Iterator:Object,Z=class extends At{constructor(e,t){super(),this[C]={ptr:e,map:t,index:0}}next(){let e=this[C];return e.index<e.ptr.list.length?{value:e.map(e.ptr.list[e.index++]),done:!1}:{value:void 0,done:!0}}[Symbol.iterator](){return this}[Ze](){}},fA=class{constructor(e){let t=this[C]={list:[],url:null,serialized:!0},n;if(Array.isArray(e))for(let r=0;r<e.length;r++)t.list.push(QA(e[r]));else if((n=ZA(e))!=null){let r;for(;!(r=mA(n.next())).done;)t.list.push(QA(r.value))}else if((typeof e=="object"||typeof e=="function")&&e!=null){let r=Object.keys(e);for(let u=0;u<r.length;u++){let l=r[u],a=Ie(l),h=I(e[l]),f=t.list.find(g=>g[0]===a);f?f[1]=h:t.list.push([a,h])}}else if(e!==void 0){let r=I(e);r=r[0]==="?"?r.substring(1):r,t.list=vA(r)}}get size(){return this[C].list.length}append(e,t){e=I(e),t=I(t),this[C].list.push([e,t]);let n=this[C];n.url&&n.serialized?(function(u,l){let a=u[S].url;a.query=a.query?`${a.query}&${l}`:l})(n.url,SA([[e,t]])):oA(n)}delete(e,t){e=I(e),t=t!=null?I(t):void 0;let{list:n}=this[C],r=0;for(;r<n.length;)n[r][0]===e&&(t==null||n[r][1]===t)?n.splice(r,1):r++;oA(this[C])}get(e){e=I(e);let{list:t}=this[C];for(let n=0;n<t.length;n++)if(t[n][0]===e)return t[n][1];return null}getAll(e){e=I(e);let t=[],{list:n}=this[C];for(let r=0;r<n.length;r++)n[r][0]===e&&t.push(n[r][1]);return t}has(e,t){e=I(e),t=t!=null?I(t):void 0;let{list:n}=this[C];for(let r=0;r<n.length;r++)if(n[r][0]===e&&(t==null||n[r][1]===t))return!0;return!1}set(e,t){e=I(e),t=I(t);let{list:n}=this[C],r=!1,u=!1,l=0;for(;l<n.length;)n[l][0]===e?r?(n.splice(l,1),u=!0):(r=!0,n[l][1]!==t&&(n[l][1]=t,u=!0),l++):l++;r||(n.push([e,t]),u=!0),u&&oA(this[C])}sort(){this[C].list.sort((e,t)=>e[0]<t[0]?-1:e[0]>t[0]?1:0),oA(this[C])}forEach(e,t){if(typeof e!="function")throw new TypeError('The "callback" argument must be of type function');let{list:n}=this[C];for(let r=0;r<n.length;r++)e.call(t,n[r][1],n[r][0],this)}entries(){return new Z(this[C],e=>e)}keys(){return new Z(this[C],e=>e[0])}values(){return new Z(this[C],e=>e[1])}toString(){return SA(this[C].list)}[Symbol.iterator](){return this.entries()}};Object.defineProperty(fA.prototype,Symbol.toStringTag,{value:"URLSearchParams",configurable:!0});var NA="X-Indiana-Protocol",he="X-Indiana-SDK-Version";var LA={current:"0.10"};function de(A){let e,t=()=>typeof e=="string"?e:e?.accessToken,n=0,r,u=new Map,l=()=>{for(let p of[...u.keys()])try{p()}catch{}};function a(p){let m=++n;r=void 0,e=void 0;for(let y of[...u.values()])try{y?.()}catch{}m===n&&(e=p,l())}let h=()=>a();function f(p,m=!1){let y=$A.safeParse(p);if(!y.success||m&&Date.parse(y.data.expiresAt)<=Date.now()||Date.parse(y.data.refreshExpiresAt)<=Date.now()||Date.parse(y.data.refreshExpiresAt)<Date.parse(y.data.expiresAt))throw new P("INVALID_RESPONSE","Invalid customer session credentials");return y.data}async function g(){if(r)return r;let p=typeof e=="object"?e:void 0,m=n;if(!p||Date.parse(p.refreshExpiresAt)<=Date.now())throw p&&h(),new P("UNAUTHENTICATED","Customer authentication is required",401);let y=(async()=>{try{let k=await A(p.refreshToken);if(m!==n)throw new P("IDENTITY_CHANGED","Customer identity changed during refresh");let Y=f(k,!0);if(Y.customerId!==p.customerId||Y.sessionId!==p.sessionId)throw new P("SCOPE_MISMATCH","Refresh changed the customer session");return e=Y,{...Y}}catch(k){throw m!==n?new P("IDENTITY_CHANGED","Customer identity changed during refresh"):(k instanceof P&&k.status===401&&h(),k)}})();r=y;try{return await y}finally{r===y&&(r=void 0)}}return{identify(p){let m=typeof p=="string"?p:f(p),y=typeof m=="string"?m:m.accessToken;if(!y.trim()||/\s/.test(y)||y.length>4096)throw new P("INVALID_TOKEN","A server-issued token is required");a(m)},reset:h,subscribeIdentity(p,m){return u.set(p,m),()=>{u.delete(p)}},access(){let p=typeof e=="object"?e:void 0;if(p&&Date.parse(p.expiresAt)<=Date.now()+3e4){let y=n;return g().then(()=>{let k=t();if(y!==n||!k)throw new P("IDENTITY_CHANGED","Customer identity changed during refresh");return k})}let m=t();if(!m)throw new P("NOT_IDENTIFIED","Identify a customer session before making a request");return m},peek:t,snapshot:()=>typeof e=="object"?{...e}:void 0,refresh:g}}var pe=Symbol("IndianaNoContent");function gt(A,e,t=eA){let n=A.configuration?.scope,r=A.scope??(n&&{projectId:n.projectId,environment:n.environment}),u=r?sA.parse(r):void 0;if(u&&n&&(u.projectId!==n.projectId||u.environment!==n.environment))throw new P("SCOPE_MISMATCH","Configuration belongs to another App/environment");let l=new t(A.baseUrl??FA);if(l.username||l.password||l.search||l.hash)throw new P("INVALID_URL","baseUrl must not contain credentials, query, or fragment");if(l.protocol!=="https:"&&!(l.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(l.hostname)))throw new P("INVALID_URL","Use HTTPS, or HTTP on localhost during development");let a=A.fetch??globalThis.fetch.bind(globalThis),h=A.timeoutMs??1e4;if(!Number.isFinite(h)||h<1||h>12e4)throw new P("INVALID_TIMEOUT","timeoutMs must be between 1 and 120000");let f=!1,g=0,p=null,m=new Set,y=A.session??de(async v=>{let R=await tA("customer-sessions/refresh",{},"POST",{},v);if(!R||typeof R!="object")throw new P("INVALID_RESPONSE","Invalid refresh response");let{requestId:_,scope:B,...V}=R;return V});function k(){g+=1,p=null;for(let v of m)v.abort();m.clear()}let Y=y.subscribeIdentity(k);function ge(){f||y.reset()}async function tA(v,R={},_="POST",B={},V){let N=B.installationDetach===!0;if(N&&(v!=="push/installations/detach"||_!=="POST"))throw new P("INVALID_REQUEST","Installation authority only detaches this installation");if(!V&&!N)throw new P("NOT_IDENTIFIED","Call identify with a server-issued customer token first");let X=g,L=new AbortController;N||m.add(L);let nA=()=>!N&&X!==g?new P("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):new P("TIMEOUT","The request timed out"),dA,ye=new Promise((O,q)=>{dA=()=>q(nA()),L.signal.addEventListener("abort",dA,{once:!0})}),Pe=setTimeout(()=>L.abort(),B.timeoutMs??h),De=async()=>{let O=await a(`${l.href.replace(/\/$/,"")}/api/v1/${v}`,{method:_,headers:{...B.headers,"Content-Type":"application/json",...N?{}:{Authorization:`Bearer ${V}`},[NA]:LA.current,[he]:zA.version,...u?{"X-Indiana-Project":u.projectId,"X-Indiana-Environment":u.environment}:{}},body:_==="POST"?JSON.stringify(R):void 0,signal:L.signal,credentials:"omit",cache:_==="POST"&&typeof document<"u"?"default":"no-store",redirect:"error",...B.keepalive?{keepalive:!0}:{}});if(L.signal.aborted)throw nA();let q;try{q=O.status===204?pe:await O.json()}catch{throw L.signal.aborted?nA():new P(O.ok?"INVALID_RESPONSE":"HTTP_ERROR","The gateway returned an unreadable response",O.status,O.headers.get("X-Request-Id")??void 0)}if(L.signal.aborted)throw nA();if(!N&&X!==g)throw new P("IDENTITY_CHANGED","Customer identity changed while the request was in flight");if(!O.ok){let T=MA.safeParse(et(q)),z=T.success&&(!BA.safeParse(T.data.error.code).success||xA(T.data.error.code,O.status)),HA=z?T.data.error.code:"HTTP_ERROR",_A=UA(HA,O.status,{retryAfter:O.headers.get("Retry-After"),recovery:z?T.data.error.recovery:void 0,reason:z?T.data.error.reason:void 0});throw new P(HA,z?T.data.error.message:"The request failed",O.status,O.headers.get("X-Request-Id")??(T.success?T.data.requestId:void 0),{..._A,...T.success&&T.data.error.retryable===!1?{retryable:!1}:{},..._A.retryAfterSeconds===void 0&&T.success&&T.data.error.retryAfterSeconds!==void 0?{retryAfterSeconds:T.data.error.retryAfterSeconds}:{}})}if(O.headers.get(NA)!==LA.current)throw new P("PROTOCOL_MISMATCH","Response protocol does not match this SDK");if(u&&q!==pe){let T=q&&typeof q=="object"&&"scope"in q?q:q&&typeof q=="object"&&"configuration"in q?q.configuration:null;if(!T||typeof T!="object"||!("scope"in T))throw new P("INVALID_RESPONSE","Response is missing its App/environment scope");let z=sA.safeParse(T.scope);if(!z.success||z.data.projectId!==u.projectId||z.data.environment!==u.environment)throw new P("SCOPE_MISMATCH","Response scope does not match this SDK instance")}let rA=O.headers.get("X-Indiana-Telemetry-Subject");if(rA){if(!/^[a-f0-9]{64}$/.test(rA))throw new P("INVALID_RESPONSE","Invalid telemetry identity");p!==rA&&(p=rA,e?.(p))}return q};try{return await Promise.race([De(),ye])}catch(O){throw!N&&X!==g?new P("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):O instanceof P?O:new P(L.signal.aborted?"TIMEOUT":"NETWORK_ERROR",L.signal.aborted?"The request timed out":"Unable to read the response")}finally{clearTimeout(Pe),L.signal.removeEventListener("abort",dA),m.delete(L)}}function we(v,R={},_="POST",B={}){if(f)return Promise.reject(new P("CLOSED","SDK client was destroyed"));if(B.installationDetach)return tA(v,R,_,B);let V=g;try{let N=y.access(),X=L=>{if(V!==g)throw new P("IDENTITY_CHANGED","Customer identity changed before dispatch");return tA(v,R,_,B,L)};return typeof N=="string"?X(N):N.then(X)}catch(N){return Promise.reject(N)}}let me=Object.assign(we,{captureIdentity(){let v=g,R=f,_=!!y.peek();return()=>{if(R)throw new P("CLOSED","SDK client was destroyed");if(!_)throw new P("NOT_IDENTIFIED","Call identify with a server-issued customer token first");if(v!==g)throw new P("IDENTITY_CHANGED","Customer identity changed before dispatch")}}});return{session:y,requestWithCredential(v,R,_,B={}){return f?Promise.reject(new P("CLOSED","SDK client was destroyed")):tA(v,R,"POST",B,_)},subjectKey:()=>p,identify(v){if(f)throw new P("CLOSED","SDK client was destroyed");if(u&&typeof v=="object"&&"scope"in v){let R=sA.safeParse(v.scope);if(!R.success||R.data.projectId!==u.projectId||R.data.environment!==u.environment)throw new P("SCOPE_MISMATCH","Customer session belongs to another App/environment")}y.identify(v)},reset:ge,dispose(){f||(f=!0,Y(),k())},request:me}}function et(A){if(!A||typeof A!="object"||!("error"in A))return A;let e=A.error;if(!e||typeof e!="object"||!("reason"in e)||jA.safeParse(e.reason).success)return A;let{reason:t,...n}=e;return{...A,error:n}}export{eA as a,gt as b};
1
+ import{b as $A}from"./chunk-KCUE2VFJ.js";import{a as P}from"./chunk-UGATOG2T.js";import{a as BA,c as jA,d as xA,e as MA,f as UA,h as sA}from"./chunk-LFR2LWYC.js";import{a as zA}from"./chunk-5U3QABVU.js";import{a as FA}from"./chunk-5MRSFLQA.js";function I(A){return typeof A=="string"?A:String(A)}var Se=/[\ud800-\udbff](?![\udc00-\udfff])|(^|[^\ud800-\udbff])[\udc00-\udfff]/g;function Ie(A){return A.replace(Se,"$1�")}function mA(A,e){if(typeof A!="object"||A==null){let t="";throw t+="The provided value is not an object",new TypeError(t)}return A}function ZA(A){if(A!=null&&(typeof A=="object"||typeof A=="function")){let e=A[Symbol.iterator];if(e==null)return;if(typeof e!="function")throw new TypeError("The provided value is not iterable");let t=e.call(A);if(!t||typeof t!="object")throw new TypeError("Result of the Symbol.iterator method is not an object");return t}}function QA(A){let e;if(Array.isArray(A)){let t=A.map(I);if(t.length===2)return t}else if((e=ZA(A))!=null){let t=mA(e.next()),n=mA(e.next());if(!t.done&&!n.done)return[I(t.value),I(n.value)]}throw new TypeError("Each query pair must be an iterable [name, value] tuple")}var GA="0123456789ABCDEF",Ce=/(?:%[0-9A-Fa-f]{2})+/g;function M(A){return`%${GA[A>>4&15]}${GA[15&A]}`}function Ae(A,e,t=!1){return A>=55296&&A<=57343&&(A=65533),A<=127?t&&A===32?"+":e(A)?M(A):String.fromCharCode(A):A<=2047?M(192|A>>6)+M(128|63&A):A<=65535?M(224|A>>12)+M(128|A>>6&63)+M(128|63&A):M(240|A>>18)+M(128|A>>12&63)+M(128|A>>6&63)+M(128|63&A)}function yA(A){return A>=48&&A<=57?A-48:A>=65&&A<=70?A-65+10:A>=97&&A<=102?A-97+10:-1}function PA(A,e=!1){let t=0;for(;t<A.length;t++){let n=A.charCodeAt(t);if(n===37||e&&n===43)break}return t===A.length?A:(e?A.replace(/\+/g," "):A).replace(Ce,n=>{try{return decodeURIComponent(n)}catch{return"�".repeat(n.length/3)}})}function AA(A){return A<=31||A>126}function be(A){switch(A){case 32:case 34:case 60:case 62:case 96:return!0;default:return AA(A)}}function TA(A){switch(A){case 32:case 34:case 35:case 60:case 62:return!0;default:return AA(A)}}function Ee(A){return TA(A)||A===39}function DA(A){switch(A){case 63:case 94:case 96:case 123:case 125:return!0;default:return TA(A)}}function cA(A){switch(A){case 47:case 58:case 59:case 61:case 64:case 91:case 92:case 93:case 124:return!0;default:return DA(A)}}function KA(A){switch(A){case 33:case 39:case 40:case 41:case 126:return!0;default:return(function(t){switch(t){case 36:case 37:case 38:case 43:case 44:return!0;default:return cA(t)}})(A)}}function ee(A,e){return Ae(A=A||0,e)}function U(A,e,t=!1){let n=0;for(;n<A.length;n++){let u=A.charCodeAt(n);if(u>=128||t&&u===32||e(u))break}if(n===A.length)return A;let r=A.slice(0,n);for(;n<A.length;n++){let u=A.charCodeAt(n),l=u;if(u>=55296&&u<=56319&&n+1<A.length){let a=A.charCodeAt(n+1);a>=56320&&a<=57343&&(l=(u-55296<<10)+a-56320+65536,n++)}r+=Ae(l,e,t)}return r}function vA(A){let e=[],t=0,n=0;for(;n<=A.length;){if(n=A.indexOf("&",t),n<0&&(n=A.length),n!==t){let r=A.slice(t,n),u=r.indexOf("=");u<0&&(u=r.length),e.push([PA(r.slice(0,u),!0),PA(r.slice(u+1),!0)])}if(t=n+1,n===A.length)break}return e}function SA(A){let e="";for(let t=0;t<A.length;t++){let n=U(A[t][0],KA,!0),r=U(A[t][1],KA,!0);e+=t!==0?`&${n}=${r}`:`${n}=${r}`}return e}var Te=[2191,2191,3164,3164,3292,3292,6863,6877,6880,6891,8385,8385,11158,11158,42958,42959,42962,42962,42964,42964,42993,42993,64451,64466,64912,64913,64968,64974,67904,67929,69317,69319,69328,69336,69370,69371,72544,72551,73136,73179,73184,73193,93856,93880,93883,93907,94194,94198,100344,100351,101641,101662,101760,101874,118010,118012,118458,118480,118496,118512,124608,124638,124640,124661,124670,124671,128728,128728,128887,128890,129232,129240,129620,129623,129674,129674,129678,129678,129736,129736,129741,129741,129770,129770,129775,129775,130042,130042,177978,177983,183970,183981,205744,210041],ve=[7296,7297,7298,7299,7300,7301,7302,7303,7304,42958,42962,42964,42993],Oe=["в","д","о","с","т","т","ъ","ѣ","ꙋ","꟏","ꟓ","ꟕ","s"],Re=[2381,2381,2509,2509,2637,2637,2765,2765,2893,2893,3021,3021,3149,3149,3277,3277,3387,3388,3405,3405,3530,3530,3642,3642,3770,3770,3972,3972,4153,4154,5908,5909,5940,5940,6098,6098,6752,6752,6980,6980,7082,7083,7154,7155,11647,11647,43014,43014,43052,43052,43204,43204,43347,43347,43456,43456,43766,43766,44013,44013,68159,68159,69702,69702,69744,69744,69759,69759,69817,69817,69939,69940,70080,70080,70197,70197,70378,70378,70477,70477,70606,70608,70722,70722,70850,70850,71103,71103,71231,71231,71350,71350,71467,71467,71737,71737,71997,71998,72160,72160,72244,72244,72263,72263,72345,72345,72767,72767,73028,73029,73111,73111,73537,73538,90415,90415];function ke(A){for(let e=0;e<A.length;e++){let t=A.codePointAt(e);if(t>65535&&e++,t<=32||t===37||t===127||t>=55296&&t<=57343||t>=128&&t<=159||t>=64976&&t<=65007||!(65534&~t)||t===65533)return!0}return!1}var[qe,Ne,Le,YA]=[[[],"0,6,7,8,m,w,10,1b,1d,1f,72,73,7k,8k,dt,2rk","AAAAAAAAAAAAAAAAAAAAAP////8AAAAAAAAAAAAAAAA/AAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAADAAABwfwAAAAAAAMADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//w8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAhAAAAQAAAAAAAAQCAAABAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgACAAAAAAAAAAAAAAAAD//wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAP///////////////wAAAAAAAAAAAAAAAAAAAAA="],[[],"6,7,8,o,4o,7e,7f,7h,7i,7j,dl","AAAAAEF9+P/+BwAAAMAA//8AAPz/////BlADAAAAAJwAAPz///8AAADA//H/5+X8AAAAAAAAAAAA/P///wcAAAAAAAAAAAAAPv0vAD0BAABA/gAA/5/5/f8BAAAAAAAAgAAAAP//////////////AYD/////BQAAAAAAAAAAAAAAAAAAAAAAAP///////wcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD8g+N8B+AAAAAAAAAAAAAAAAAAAAAAAAP//AwAAYAAAAAAAAAAAAAD/////CwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANgAAAAAAAAAAAAAAAAA//8fAB4AAAD//wMAAAAAAH3/HgwAAAAAAAD//////////w8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="],[[],"6,7,8,o,4o,7e,7f,7h,7i,7j,dl","AAAAAP3////+BwAAAMDu//////////////8vAADAAJwAAP3///8AAADg////////AAAAAAAAAAAA/P///wcAAAAAAAAAAAAA////Ab0H//9H/gAA/9////8BAAAAAAAAgAAAAP//////////////AYD/////BQAAAAAAAAAAAAAAAAAAAAAAAP///////wcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAL/G//8T+AAAAAAAAAAAAAAAAAAAAAAAAP//AwAAfgAAAAAAAAAAAAD+////DwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANwAAAAAAAAAAAAAAAAA//8fAB4AAAD//wMAAAAAAH3/Hg4AAAAAAAD//////////w8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="],[[],"0,3,4,5,6,7,8,9,a,b,c,d,e,f,g,j,n,o,p,q,r,s,t,w,18,19,1c,4m,4o,4p,4q,4r,6z,72,73,75,76,77,7e,7h,7i,7j,7k,7l,7m,7n,7o,7p,7q,7r,7s,7t,7u,7v,7w,7x,7y,7z,8k,9t,a2,a3,a7,cc,cv,cx,cy,d6,dc,dd,de,dg,dh,di,dk,dl,2rk,2rl","AAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAD//////////////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD4AwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/v////+/tgAAAAAAAAAAAP8XAAAAAAD4//8AAAEAAAAAAAAAAAAAAMCfnz0AAACAAgAAAP///wcAAAAAAAAAAAAAwP8BAAAAAAAA+A8gAADA++8+AAAAAAAOAAAAAAAAgP8AAAAAAPz///v///8HAAAAAAAAFP4h/gAMAAAAAgAAAAAAABAeIAAADAAAQAYAAAAAAAAQhjkCAAAAIwAGAAAAAAAAEL4hAAAMAAD8AgAAAAAAAJAeIGAADAAAAAQAAAAAAAAAASAAAAAAAAARAAAAAAAA0ME9YAAMAAAAAgAAAAAAAJBAMAAADAAAAAMAAAAAAAAYHiAAAAwAAAACAAAAAAAAAAAEXAAAAAAAAAAAAAAA8geAfwAAAAAAAAAAAAAAAPIfAH8AAAAAAAAAAAADAACgAgAAAAAAAP5/3+D//v///x9AAAAAAAAAAAAAAAAA4P1mAAAAwwEAHgBkIAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAMAAAADAAAAAwAAAAAAAAAsD9A/g8gAAAAAAC4AAAAAAAAAAAAAAAAAABgAAAAAAIAAAAAAAAAAAAAAAAAAIcBBA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAJAAAAAAAAQH/lH/ifAAAAAAAA//////8//w8AAA8AAAAAANAXBAAAAAD4DwADAAAAPDsAAAAAAABAowMAAAAAAADwzwAAAAAAAAAAAAAAAAAAAAAAAAD3//0hEAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////wDIAAAAfAAAAAAAAB/8AAAAAAAAAAAAAAAA/////wEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAwAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAA/////wAAAAAAPAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAID3PwAAAMAAAAAAAAAAAAAAAwBECAAAYBAAAAAAAAAAAAAAAAAAAAAAAAAwAAAA//8DgAAAAADAPwAAgP8DAAAAAAAHAAAAAADIMwAAAAAgAAAAAAAAAAB+ZgAIEAAAAAAAEAAAAAAAAJ3BAgAAAAAwQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAICEAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//8AAP//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAMAHAAAAAAAAAAAAAAAAAAAAAG7wAAAAAACHAAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAAAAAAPAAAAAAAAAAAD4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAA/AAAAAAAAAAAwP8BAAAAAAA8AAAAAAAAAAAAAAAAAAAAAgAAAAAAAP9/AAAAAAAZgAMAAAAAAHgGBAAAAAAAAAAHAAAAgO8fAAAAAAAAAAgAAwAAAAAAwH8AngAAAAAAAAAAAAAAgNNAAgAAAAAAAAAAAAAAAAAAAAAAAID4BwAAAwAAAAAAABgBAAAAwB8fAAAAAAAAAAD4AUAFAAYAAAAAAAAAAAAA/1wAAEAAAAAAAAAAAAAA+IUNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8sAEAADAAAAAAAAAAAAAA+KcBAAAAAAAAAAAAAAAAKL8AAAAAAAAAAAAAAACgvA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgP8GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFgIAAAAAAAAAAAAAAAAAAAAAADwDAEAAAD+BwAAAAD4eYAAfg4AAAAAAPx/AwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAf78AAAAAAAAAAAAA/P///G0AAAAAAAAAAAAAAAAAAAB+tL8AAAAAAAAAAACjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAwAcFAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//4H/PwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMD/4wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHwAAAAAAAAB/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAcAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAPAAAAAAAAAAAAAAD//////z///38AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAD+P/nDwAAADwAAAAAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////9/+P//////HyAAEAAA+P7/AAAAAAAAAAAAAH////nbBwAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAfwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASMAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAfwAAAAAAAAAAAAAAAADwDwAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAA////////////////AAAAAAAAAAAAAAAAAAAAAP///////////////////////////////////////wAA"]].map(function([e,t,n]){return[e,t.split(",").map(r=>parseInt(r,36)),Uint8Array.from(atob(n),r=>r.charCodeAt(0))]});function He(A,e){return e===931||e===1010||e===120531||e===120589||e===120647||e===120705||e===120763?"σ":e>=5112&&e<=5117?String.fromCodePoint(e-8):e>=43888&&e<=43967?String.fromCodePoint(e-38864):e>=93856&&e<=93880?String.fromCodePoint(e+27):e===837||e===890||e>=8064&&e<=8111||e>=8114&&e<=8188?A.normalize("NFD").replace(/\u0345/g,"ι").normalize("NFC").toLowerCase():""}function te(A,e){for(let t=0;t<A.length;t+=2)if(e>=A[t]&&e<=A[t+1])return!0;return!1}function W(A,e){let[t,n,r]=A,u=e>>8;for(let h=0;h<t.length;h+=2)if(u>=t[h]&&u<=t[h+1])return!0;let l=n.indexOf(u);if(l<0)return!1;let a=255&e;return!!(r[32*l+(a>>3)]&1<<(7&a))}function _e(A){let e=Array.from(A,t=>t.codePointAt(0));for(let t=0;t<e.length;t++){let n=e[t];if(n!==8204&&n!==8205||t>0&&te(Re,e[t-1]))continue;if(n===8205)return!1;let r=t-1;for(;r>=0&&W(YA,e[r]);)r--;let u=t+1;for(;u<e.length&&W(YA,e[u]);)u++;if(!(r>=0&&u<e.length&&W(Ne,e[r])&&W(Le,e[u])))return!1}return!0}var Be=/(?![\p{Mark}\p{Decimal_Number}])[\p{Script=Arabic}\p{Script=Hebrew}]/u,je=/\p{Script=Latin}/u;function xe(A){return!Be.test(A)||!je.test(A)}var F=36,iA=1,IA=26,Me=38,Ue=700,$e=72,ze=128,Fe=2147483647;function VA(A){return String.fromCharCode(A+22+75*+(A<26))}function Qe(A,e,t){let n=0;for(A=t?Math.floor(A/Ue):A>>1,A+=Math.floor(A/e);A>(F-iA)*IA>>1;n+=F)A=Math.floor(A/(F-iA));return Math.floor(n+(F-iA+1)*A/(A+Me))}function Ge(A){let e=Array.from(A,h=>h.codePointAt(0)),t="",n=0;for(let h=0;h<e.length;h++){let f=e[h];f<128&&(t+=String.fromCharCode(f),n++)}let r=n;r&&(t+="-");let u=ze,l=0,a=$e;for(;n<e.length;){let h=Fe;for(let f=0;f<e.length;f++){let g=e[f];g>=u&&g<h&&(h=g)}l+=(h-u)*(n+1),u=h;for(let f=0;f<e.length;f++){let g=e[f];if(g<u&&l++,g===u){let p=l;for(let m=F;;m+=F){let y=m<=a?iA:m>=a+IA?IA:m-a;if(p<y)break;t+=VA(y+(p-y)%(F-y)),p=Math.floor((p-y)/(F-y))}t+=VA(p),a=Qe(l,n+1,n===r),l=0,n++}}l++,u++}return t}function pA(A){let e=10;if(A.length>=2&&A[0]==="0"&&(A[1]==="x"||A[1]==="X"))A=A.slice(2),e=16;else if(A.length>=2&&A[0]==="0")A=A.slice(1),e=8;else if(A==="")return-1;let t=0;for(let n=0;n<A.length;n++){let r=yA(A.charCodeAt(n));if(r>=e||r<0)return-1;t=t*e+r}return t}function XA(A){switch(A){case".":case"%2e":case"%2E":return!0;default:return!1}}function ne(A,e){return(A>=65&&A<=90||A>=97&&A<=122)&&(e===58||e===124)}function re(A){return A.length===2&&ne(A.codePointAt(0),A.codePointAt(1))}function JA(A){return A.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|\/|:|<|>|\?|@|\[|\\|\]|\^|\|/u)!==-1}function b(A){switch(A){case"ftp":case"http":case"https":case"ws":case"wss":case"file":return!0;default:return!1}}function se(A){switch(A){case"ftp":return 21;case"http":case"ws":return 80;case"https":case"wss":return 443;default:return null}}function CA(A,e){if(A[0]==="[")return A[A.length-1]==="]"?(function(n){let r=[0,0,0,0,0,0,0,0],u=null,l=0,a=0,h=Array.from(n,f=>f.codePointAt(0));if(h[a]===58){if(h[a+1]!==58)return null;a+=2,l++,u=l}for(;a<h.length;){if(l===8)return null;if(h[a]===58){if(u!==null)return null;a++,l++,u=l;continue}let f=0,g=0,p=0;for(;p<4&&(f=yA(h[a]))>=0;)g=(g<<4)+f,a++,p++;if(h[a]===46){if(p===0||l>6)return null;a-=p;let m=0;for(;h[a]!==void 0;){let y=0;if(m>0)if(h[a]===46&&m<4)a++;else return null;if(h[a]==null||h[a]<48||h[a]>57)return null;for(;h[a]>=48&&h[a]<=57;){if(y=10*y+yA(h[a]),y>255)return null;a++}r[l]=256*r[l]+y,m++,m%2==0&&l++}if(m!==4)return null;break}else if(h[a]===58){if(h[++a]===void 0)return null}else if(h[a]!==void 0)return null;r[l]=g,l++}if(u!==null){let f=l-u;for(l=7;l!==0&&f>0;){let g=r[u+f-1];r[u+f-1]=r[l],r[l]=g,l--,f--}}else if(u===null&&l!==8)return null;return r})(A.substring(1,A.length-1)):null;if(e)return(function(n){return JA(n)?null:U(n,AA)})(A);{let t=(function(r){let u=!1,l=!1;for(let h=0;h<r.length;h++){let f=r.charCodeAt(h);if(f<=32||f===37||f===127)return null;if(f>=128){u=!0;break}f>=65&&f<=90&&(l=!0)}if(!u)return r!==""?l?r.toLowerCase():r:null;if((function(f){for(let g of f){let p=g.codePointAt(0);if(/[\p{Cn}\p{Co}\p{Cs}\p{Noncharacter_Code_Point}]/u.test(g)&&!te(Te,p)||W(qe,p))return!0}return!1})(r))return null;let a=(r=(function(f){let g="";for(let p of f){let m=p.codePointAt(0);if(m!==8204&&m!==8205&&/\p{Default_Ignorable_Code_Point}/u.test(p))continue;let y=He(p,m);if(y){g+=y;continue}let k=ve.indexOf(m);g+=k<0?p:Oe[k]}return g})(r).normalize("NFKC").replace(/[\u3002\uff0e\uff61]/g,".").toLowerCase()).split(".");for(let h=0;h<a.length;h++){let f=a[h];if(f==="")continue;let g=/[^\0-\x7f]/.test(f);if(ke(f)||g&&(/^\p{Mark}/u.test(f)||!_e(f)||!xe(f)||f.startsWith("xn--")))return null;g&&(a[h]=`xn--${Ge(f)}`)}return(r=a.join("."))!==""?r:null})(A.indexOf("%")===-1?A:PA(A));return t===null||JA(t)?null:(function(r){let u=r.length,l=r.lastIndexOf(".",u-2)+1;if(r.charCodeAt(u-1)===46&&u--,u<=l)return!1;if(pA(r.slice(l,u))>=0)return!0;for(;l<u;l++){let a=r.charCodeAt(l);if(a<48||a>57)return!1}return!0})(t)?(function(r){let u=r.split("."),l=u.length;if(u[l-1]||l--,l>4)return null;let a=0;for(let f=0;f<l-1;f++){let g=pA(u[f]);if(g<0||g>255)return null;a+=g*(1<<8*(3-f))}let h=pA(u[l-1]);return h<0||h>=256**(5-l)?null:(a+=h,a)})(t):t}}function bA(A){return typeof A=="number"?(function(t){let r="";return r+=`${(t>>>24&255).toString(10)}.`,r+=`${(t>>>16&255).toString(10)}.`,r+=`${(t>>>8&255).toString(10)}.`,r+=(t&255).toString(10),r})(A):Array.isArray(A)?`[${(function(t){let n=(function(a){let h=-1,f=-1,g=1,p=0;for(let m=0;m<a.length;++m)a[m]!==0?(p>g&&(h=f,g=p),f=-1,p=0):(f===-1&&(f=m),++p);return p>g?f:h})(t),r="",u=!1;for(let l=0;l<=7;++l)if(!(u&&t[l]===0)){if(u&&(u=!1),n===l){r+=l===0?"::":":",u=!0;continue}r+=t[l].toString(16),l!==7&&(r+=":")}return r})(A)}]`:A}function oe(A){A.path.length>0&&(A.path.length!==1||A.scheme!=="file"||!(function(t){return/^[A-Za-z]:$/u.test(t)})(A.path[0]))&&A.path.pop()}function ie(A){return A.username!==""||A.password!==""}function gA(A){return A.host===null||A.host===""||A.scheme==="file"}var s=0,o="",w="",D=null,i,lA=!1,uA=!1,G=!1,E;function H(A,e,t,n){e||(A=(function(l){let a=0,h=l.length;for(;a<h&&!(l.charCodeAt(a)>32);++a);for(;h>a&&!(l.charCodeAt(h-1)>32);--h);return l.substring(a,h)})(A)),A=(function(l){let a=0;for(;a<l.length;a++){let f=l.charCodeAt(a);if(f===9||f===10||f===13)break}if(a===l.length)return l;let h=l.slice(0,a);for(;a<l.length;a++){let f=l.charCodeAt(a);f!==9&&f!==10&&f!==13&&(h+=l[a])}return h})(A),s=0,o=A,w="",D=t||null,i=e||{scheme:"",username:"",password:"",host:null,port:null,path:[],query:null,fragment:null,opaquePath:!1},lA=!1,uA=!1,G=!1,E=n||0;let r=Ke;switch(n){case 3:case 4:r=aA;break;case 5:r=RA;break;case 6:r=K;break;case 7:r=Q;break;case 8:r=$}return r(c(A,s))!==1?i:null}function d(A,e){return s+=s===A?j(e):1,s<=o.length}function c(A,e){return e<A.length?A.codePointAt(e):void 0}function j(A){return A!=null&&A>65535?2:1}function le(A){return A==null?"":A<=65535?String.fromCharCode(A):String.fromCodePoint(A)}var Ke=A=>{let e=s;if(A!=null&&(A>=65&&A<=90||A>=97&&A<=122)){let t=s+1;for(A=o.charCodeAt(t);A===43||A===45||A===46||A>=65&&A<=90||A>=97&&A<=122||A>=48&&A<=57;)t++,A=o.charCodeAt(t);return w=o.slice(s,t).toLowerCase(),s=t,Ye(t<o.length?A:void 0)}else return E?1:(--s,d(e,A)?ue(c(o,s)):0)},Ye=A=>{let e=s;if(A===58){if(E){if(b(i.scheme)!==b(w))return 0;if((ie(i)||i.port!==null)&&w==="file")return 0;if(i.scheme==="file"&&i.host==="")return 0}return i.scheme=w,E?(i.port===se(i.scheme)&&(i.port=null),0):(w="",i.scheme==="file"?d(e,A)?kA(c(o,s)):0:b(i.scheme)&&D!==null&&D.scheme===i.scheme?d(e,A)?Ve(c(o,s)):0:b(i.scheme)?d(e,A)?Je(c(o,s)):0:c(o,s+1)===47?(s++,d(e,A)?Xe(c(o,s)):0):(i.path=[""],i.opaquePath=!0,d(e,A)?ae(c(o,s)):0))}else return E?1:(w="",s=-1,d(e,A)?ue(c(o,s)):0)},ue=A=>{let e=s;return D===null||D.opaquePath&&A!==35?1:D.opaquePath&&A===35?(i.scheme=D.scheme,i.path=D.path.slice(),i.opaquePath=D.opaquePath,i.query=D.query,i.fragment="",d(e,A)?$(c(o,s)):0):D.scheme==="file"?(s--,d(e,A)?kA(c(o,s)):0):(s--,d(e,A)?OA(c(o,s)):0)},Ve=A=>{let e=s;return A===47&&c(o,s+1)===47?(++s,d(e,A)?hA(c(o,s)):0):(s--,d(e,A)?OA(c(o,s)):0)},Xe=A=>{let e=s;return A===47?d(e,A)?J(c(o,s)):0:(s--,d(e,A)?x(c(o,s)):0)},OA=A=>{let e=s;return i.scheme=D.scheme,A===47||b(i.scheme)&&A===92?d(e,A)?WA(c(o,s)):0:(i.username=D.username,i.password=D.password,i.host=D.host,i.port=D.port,i.path=D.path.slice(),i.query=D.query,A===63?(i.query="",d(e,A)?Q(c(o,s)):0):A===35?(i.fragment="",d(e,A)?$(c(o,s)):0):A!=null?(i.query=null,i.path.pop(),s--,d(e,A)?x(c(o,s)):0):d(e,A)?OA(c(o,s)):0)},WA=A=>{let e=s;return b(i.scheme)&&(A===47||A===92)?d(e,A)?hA(c(o,s)):0:A===47?d(e,A)?J(c(o,s)):0:(i.username=D.username,i.password=D.password,i.host=D.host,i.port=D.port,s--,d(e,A)?x(c(o,s)):0)},Je=A=>{let e=s;return A===47&&c(o,s+1)===47?s++:s--,d(e,A)?hA(c(o,s)):0},hA=A=>{let e=s;return A!==47&&A!==92?(s--,d(e,A)?J(c(o,s)):0):d(e,A)?hA(c(o,s)):0},J=A=>{let e=s;if(A!=null&&A!==64&&A!==35&&A!==47&&A!==63&&(A!==92||!b(i.scheme))){let t=s+j(A);for(;t<o.length;){let n=c(o,t);if(n==null||n===64||n===35||n===47||n===63||n===92&&b(i.scheme))break;t+=j(n)}return w+=o.slice(s,t),s=t-1,d(e,A)?J(c(o,s)):0}if(A===64){lA&&(w=`%40${w}`),lA=!0;for(let t=0;t<w.length;t++){let n=w.codePointAt(t);if(n===58&&!uA){uA=!0;continue}let r=ee(n,cA);uA?i.password+=r:i.username+=r,n!=null&&n>65535&&t++}return w="",d(e,A)?J(c(o,s)):0}else return A==null||A===35||A===47||A===63||A===92&&b(i.scheme)?lA&&w===""?1:(s-=w.length+1,w="",d(e,A)?aA(c(o,s)):0):(w+=le(A),d(e,A)?J(c(o,s)):0)},aA=A=>{let e=s;if(E&&i.scheme==="file")return s--,d(e,A)?qA(c(o,s)):0;if(A!=null&&A!==58&&A!==35&&A!==47&&A!==63&&(A!==92||!b(i.scheme))){let t=s+j(A);for(A===91?G=!0:A===93&&(G=!1);t<o.length;){let n=c(o,t);if(n==null||!G&&n===58||n===35||n===47||n===63||n===92&&b(i.scheme))break;n===91?G=!0:n===93&&(G=!1),t+=j(n)}return w+=o.slice(s,t),s=t-1,d(e,A)?aA(c(o,s)):0}else if(A===58&&!G){if(w===""||E===4)return 1;let t=CA(w,!b(i.scheme));return t===null?1:(i.host=bA(t),w="",d(e,A)?RA(c(o,s)):0)}else if(A==null||A===35||A===47||A===63||A===92&&b(i.scheme)){if(s--,b(i.scheme)&&w==="")return 1;if(E&&w===""&&(ie(i)||i.port!==null))return 1;let t=CA(w,!b(i.scheme));return t===null?1:(i.host=bA(t),w="",E?0:d(e,A)?K(c(o,s)):0)}else return w+=le(A),d(e,A)?aA(c(o,s)):0},RA=A=>{let e=s;if(A!=null&&A>=48&&A<=57){let t=s+1;for(;t<o.length;){let n=o.charCodeAt(t);if(n<48||n>57)break;t++}return w+=o.slice(s,t),s=t-1,d(e,A)?RA(c(o,s)):0}else if(E||A==null||A===35||A===47||A===63||A===92&&b(i.scheme)){if(w!==""){let t=parseInt(w,10);if(t>65535)return 1;if(i.port=t===se(i.scheme)?null:t,w="",E)return 0}return E?1:(s--,d(e,A)?K(c(o,s)):0)}else return 1};function ce(A,e){let t=A.length-e;if(t<2)return!1;if(ne(c(A,e),c(A,e+1))){if(t===2)return!0;{let n=c(A,e+2);return n===47||n===92||n===63||n===35}}else return!1}var kA=A=>{let e=s;return i.scheme="file",i.host="",A===47||A===92?d(e,A)?We(c(o,s)):0:D?.scheme==="file"?(i.host=D.host,i.path=D.path.slice(),i.opaquePath=D.opaquePath,i.query=D.query,A===63?(i.query="",d(e,A)?Q(c(o,s)):0):A===35?(i.fragment="",d(e,A)?$(c(o,s)):0):A!=null?(i.query=null,ce(o,s)?i.path=[]:oe(i),s--,d(e,A)?x(c(o,s)):0):d(e,A)?kA(c(o,s)):0):(s--,d(e,A)?x(c(o,s)):0)},We=A=>{let e=s;return A===47||A===92?d(e,A)?qA(c(o,s)):0:(D!==null&&D.scheme==="file"&&(!ce(o,s)&&(function(n){if(n.length===2){let r=n.codePointAt(0),u=n.codePointAt(1);return(r>=65&&r<=90||r>=97&&r<=122)&&u===58}else return!1})(D.path[0])&&i.path.push(D.path[0]),i.host=D.host),s--,d(e,A)?x(c(o,s)):0)},qA=A=>{let e=s;if(A!=null&&A!==47&&A!==92&&A!==63&&A!==35){let t=s+j(A);for(;t<o.length;){let n=c(o,t);if(n==null||n===47||n===92||n===63||n===35)break;t+=j(n)}return w+=o.slice(s,t),s=t-1,d(e,A)?qA(c(o,s)):0}else if(A==null||A===47||A===92||A===63||A===35){if(s--,!E&&re(w))return d(e,A)?x(c(o,s)):0;if(w==="")return i.host="",E?0:d(e,A)?K(c(o,s)):0;{let t=CA(w,!b(i.scheme));return t===null?1:(t==="localhost"&&(t=""),i.host=bA(t),w="",E?0:d(e,A)?K(c(o,s)):0)}}return 1},K=A=>{let e=s;return b(i.scheme)?(A!==92&&A!==47&&s--,d(e,A)?x(c(o,s)):0):!E&&A===63?(i.query="",d(e,A)?Q(c(o,s)):0):!E&&A===35?(i.fragment="",d(e,A)?$(c(o,s)):0):A!=null?(A!==47&&s--,d(e,A)?x(c(o,s)):0):(E&&i.host===null&&i.path.push(""),d(e,A)?K(c(o,s)):0)},x=A=>{let e=s;if(A!=null&&A!==47&&(!b(i.scheme)||A!==92)&&(E||A!==63&&A!==35)){let t=s+j(A);for(;t<o.length;){let n=c(o,t);if(n==null||n===47||b(i.scheme)&&n===92||!E&&(n===63||n===35))break;t+=j(n)}w+=U(o.slice(s,t),DA),s=t,A=c(o,t)}if(A==null||A===47||b(i.scheme)&&A===92||!E&&(A===63||A===35)){let t=b(i.scheme)&&A===92;return(function(r){switch(r){case"..":case"%2e.":case"%2E.":case".%2e":case".%2E":case"%2e%2e":case"%2E%2e":case"%2e%2E":case"%2E%2E":return!0;default:return!1}})(w)?(oe(i),A!==47&&!t&&i.path.push("")):XA(w)&&A!==47&&!t?i.path.push(""):XA(w)||(i.scheme==="file"&&i.path.length===0&&re(w)&&(w=`${w[0]}:`),i.path.push(w)),w="",A===63?(i.query="",d(e,A)?Q(c(o,s)):0):A===35?(i.fragment="",d(e,A)?$(c(o,s)):0):d(e,A)?x(c(o,s)):0}else return w+=ee(A,DA),d(e,A)?x(c(o,s)):0},ae=A=>{let e=s;if(A===63)return i.query="",d(e,A)?Q(c(o,s)):0;if(A===35)return i.fragment="",d(e,A)?$(c(o,s)):0;if(A!=null){let t=s+j(A);for(;t<o.length;){let r=c(o,t);if(r===63||r===35)break;t+=j(r)}let n=o.slice(s,t);if(t<o.length&&n.charCodeAt(n.length-1)===32?i.path[0]+=U(n.slice(0,-1),AA)+"%20":i.path[0]+=U(n,AA),s=t,(A=c(o,t))===63)return i.query="",d(e,A)?Q(c(o,s)):0;if(A===35)return i.fragment="",d(e,A)?$(c(o,s)):0}return d(e,A)?ae(c(o,s)):0},Q=A=>{let e=s,t=s;if(A!=null){if(E)t=o.length;else{let r=o.indexOf("#",s);t=r===-1?o.length:r}let n=b(i.scheme)?Ee:TA;i.query+=U(o.slice(s,t),n)}return s=t,c(o,t)===35&&!E?(i.fragment="",d(e,A)?$(c(o,s)):0):d(e,A)?Q(c(o,s)):0},$=A=>{let e=s;return A!=null&&(i.fragment+=U(o.slice(s),be),s=o.length),d(e,A)?$(c(o,s)):0};function EA(A){if(A.opaquePath)return A.path[0];{let e="";for(let t of A.path)e+=`/${t}`;return e}}function fe(A){switch(A.scheme){case"blob":{let e=H(EA(A),null,null,0);return e===null||e.scheme!=="http"&&e.scheme!=="https"?"null":fe(e)}case"ftp":case"http":case"https":case"ws":case"wss":return(function(t){let n=`${t.scheme}://`;return n+=t.host,t.port!==null&&(n+=`:${t.port}`),n})(A);default:return"null"}}var S=Symbol("URLImpl"),eA=class A{constructor(e,t){if(e===void 0&&t===void 0)throw new TypeError('The "url" argument must be specified.');e=I(e),t!=null&&(t=I(t));let n=null;if(t!=null&&(n=H(t,null,null,0),n==null))throw new TypeError(`Invalid base URL: ${t}`);let r=H(e,null,n,0);if(r==null)throw new TypeError(`Invalid URL: ${e}`);this[S]={url:r,query:null}}static createObjectURL(e){throw new TypeError("URL.createObjetURL is unsupported")}static revokeObjectURL(e){}static parse(e,t){e=I(e),t!==void 0&&(t=I(t));try{return new A(e,t)}catch{return null}}static canParse(e,t){e=I(e),t!==void 0&&(t=I(t));let n=null;return t!=null&&(n=H(t,null,null,0),n==null)?!1:H(e,null,n,0)!=null}get href(){return(function(t){let n=`${t.scheme}:`;return t.host!==null&&(n+="//",(t.username!==""||t.password!=="")&&(n+=t.username,t.password!==""&&(n+=`:${t.password}`),n+="@"),n+=t.host,t.port!==null&&(n+=`:${t.port}`)),t.host===null&&!t.opaquePath&&t.path.length>1&&t.path[0]===""&&(n+="/."),n+=EA(t),t.query!==null&&(n+=`?${t.query}`),t.fragment!==null&&(n+=`#${t.fragment}`),n})(this[S].url)}set href(e){let t=H(e=I(e),null,null,0);if(t==null)throw new TypeError(`Invalid URL: ${e}`);this[S].url=t,this[S].query&&wA(this[S].query,t.query)}get origin(){return fe(this[S].url)}get protocol(){return`${this[S].url.scheme}:`}set protocol(e){H(`${e=I(e)}:`,this[S].url,null,2)}get username(){return this[S].url.username}set username(e){e=I(e),gA(this[S].url)||(function(n,r){n.username=U(r,cA)})(this[S].url,e)}get password(){return this[S].url.password}set password(e){e=I(e),gA(this[S].url)||(function(n,r){n.password=U(r,cA)})(this[S].url,e)}get host(){let{url:e}=this[S];return e.host==null?"":e.port==null?e.host:`${e.host}:${e.port}`}set host(e){e=I(e),this[S].url.opaquePath||H(e,this[S].url,null,3)}get hostname(){let{url:e}=this[S];return e.host!=null?e.host:""}set hostname(e){e=I(e),this[S].url.opaquePath||H(e,this[S].url,null,4)}get port(){let{url:e}=this[S];return e.port!=null?`${e.port}`:""}set port(e){e=I(e);let{url:t}=this[S];gA(t)||(e?H(e,t,null,5):t.port=null)}get pathname(){return EA(this[S].url)}set pathname(e){e=I(e);let{url:t}=this[S];t.opaquePath||(t.path=[],H(e,t,null,6))}get search(){let{url:e}=this[S];return e.query?`?${e.query}`:""}set search(e){e=I(e);let{url:t,query:n}=this[S];if(!e)t.query=null,n&&wA(n,null);else{let r=e[0]==="?"?e.substring(1):e;t.query="",H(r,t,null,7),n&&wA(n,t.query)}}get searchParams(){let e=this[S],t=e.query;return t==null&&(t=e.query=(function(r,u){let l=new fA;return l[C].url=r,l[C].serialized=u==null,u&&(l[C].list=vA(u)),l})(this,e.url.query)),t}get hash(){let{url:e}=this[S];return e.fragment?`#${e.fragment}`:""}set hash(e){e=I(e);let{url:t}=this[S];if(!e)t.fragment=null;else{let n=e[0]==="#"?e.substring(1):e;t.fragment="",H(n,t,null,8)}}toJSON(){return this.href}toString(){return this.href}};Object.defineProperty(eA.prototype,Symbol.toStringTag,{value:"URL",configurable:!0});var C=Symbol("URLSearchParamsImpl"),Ze=Symbol.dispose||Symbol.for("dispose");function wA(A,e){e?A[C].list=vA(e):A[C].list.length=0,A[C].serialized=e==null}function oA(A){if(A.url){let e=SA(A.list);(function(n,r){n[S].url.query=r})(A.url,e||null),A.serialized=!0}}var At=typeof Iterator<"u"?Iterator:Object,Z=class extends At{constructor(e,t){super(),this[C]={ptr:e,map:t,index:0}}next(){let e=this[C];return e.index<e.ptr.list.length?{value:e.map(e.ptr.list[e.index++]),done:!1}:{value:void 0,done:!0}}[Symbol.iterator](){return this}[Ze](){}},fA=class{constructor(e){let t=this[C]={list:[],url:null,serialized:!0},n;if(Array.isArray(e))for(let r=0;r<e.length;r++)t.list.push(QA(e[r]));else if((n=ZA(e))!=null){let r;for(;!(r=mA(n.next())).done;)t.list.push(QA(r.value))}else if((typeof e=="object"||typeof e=="function")&&e!=null){let r=Object.keys(e);for(let u=0;u<r.length;u++){let l=r[u],a=Ie(l),h=I(e[l]),f=t.list.find(g=>g[0]===a);f?f[1]=h:t.list.push([a,h])}}else if(e!==void 0){let r=I(e);r=r[0]==="?"?r.substring(1):r,t.list=vA(r)}}get size(){return this[C].list.length}append(e,t){e=I(e),t=I(t),this[C].list.push([e,t]);let n=this[C];n.url&&n.serialized?(function(u,l){let a=u[S].url;a.query=a.query?`${a.query}&${l}`:l})(n.url,SA([[e,t]])):oA(n)}delete(e,t){e=I(e),t=t!=null?I(t):void 0;let{list:n}=this[C],r=0;for(;r<n.length;)n[r][0]===e&&(t==null||n[r][1]===t)?n.splice(r,1):r++;oA(this[C])}get(e){e=I(e);let{list:t}=this[C];for(let n=0;n<t.length;n++)if(t[n][0]===e)return t[n][1];return null}getAll(e){e=I(e);let t=[],{list:n}=this[C];for(let r=0;r<n.length;r++)n[r][0]===e&&t.push(n[r][1]);return t}has(e,t){e=I(e),t=t!=null?I(t):void 0;let{list:n}=this[C];for(let r=0;r<n.length;r++)if(n[r][0]===e&&(t==null||n[r][1]===t))return!0;return!1}set(e,t){e=I(e),t=I(t);let{list:n}=this[C],r=!1,u=!1,l=0;for(;l<n.length;)n[l][0]===e?r?(n.splice(l,1),u=!0):(r=!0,n[l][1]!==t&&(n[l][1]=t,u=!0),l++):l++;r||(n.push([e,t]),u=!0),u&&oA(this[C])}sort(){this[C].list.sort((e,t)=>e[0]<t[0]?-1:e[0]>t[0]?1:0),oA(this[C])}forEach(e,t){if(typeof e!="function")throw new TypeError('The "callback" argument must be of type function');let{list:n}=this[C];for(let r=0;r<n.length;r++)e.call(t,n[r][1],n[r][0],this)}entries(){return new Z(this[C],e=>e)}keys(){return new Z(this[C],e=>e[0])}values(){return new Z(this[C],e=>e[1])}toString(){return SA(this[C].list)}[Symbol.iterator](){return this.entries()}};Object.defineProperty(fA.prototype,Symbol.toStringTag,{value:"URLSearchParams",configurable:!0});var NA="X-Indiana-Protocol",he="X-Indiana-SDK-Version";var LA={current:"0.10"};function de(A){let e,t=()=>typeof e=="string"?e:e?.accessToken,n=0,r,u=new Map,l=()=>{for(let p of[...u.keys()])try{p()}catch{}};function a(p){let m=++n;r=void 0,e=void 0;for(let y of[...u.values()])try{y?.()}catch{}m===n&&(e=p,l())}let h=()=>a();function f(p,m=!1){let y=$A.safeParse(p);if(!y.success||m&&Date.parse(y.data.expiresAt)<=Date.now()||Date.parse(y.data.refreshExpiresAt)<=Date.now()||Date.parse(y.data.refreshExpiresAt)<Date.parse(y.data.expiresAt))throw new P("INVALID_RESPONSE","Invalid customer session credentials");return y.data}async function g(){if(r)return r;let p=typeof e=="object"?e:void 0,m=n;if(!p||Date.parse(p.refreshExpiresAt)<=Date.now())throw p&&h(),new P("UNAUTHENTICATED","Customer authentication is required",401);let y=(async()=>{try{let k=await A(p.refreshToken);if(m!==n)throw new P("IDENTITY_CHANGED","Customer identity changed during refresh");let Y=f(k,!0);if(Y.customerId!==p.customerId||Y.sessionId!==p.sessionId)throw new P("SCOPE_MISMATCH","Refresh changed the customer session");return e=Y,{...Y}}catch(k){throw m!==n?new P("IDENTITY_CHANGED","Customer identity changed during refresh"):(k instanceof P&&k.status===401&&h(),k)}})();r=y;try{return await y}finally{r===y&&(r=void 0)}}return{identify(p){let m=typeof p=="string"?p:f(p),y=typeof m=="string"?m:m.accessToken;if(!y.trim()||/\s/.test(y)||y.length>4096)throw new P("INVALID_TOKEN","A server-issued token is required");a(m)},reset:h,subscribeIdentity(p,m){return u.set(p,m),()=>{u.delete(p)}},access(){let p=typeof e=="object"?e:void 0;if(p&&Date.parse(p.expiresAt)<=Date.now()+3e4){let y=n;return g().then(()=>{let k=t();if(y!==n||!k)throw new P("IDENTITY_CHANGED","Customer identity changed during refresh");return k})}let m=t();if(!m)throw new P("NOT_IDENTIFIED","Identify a customer session before making a request");return m},peek:t,snapshot:()=>typeof e=="object"?{...e}:void 0,refresh:g}}var pe=Symbol("IndianaNoContent");function gt(A,e,t=eA){let n=A.configuration?.scope,r=A.scope??(n&&{projectId:n.projectId,environment:n.environment}),u=r?sA.parse(r):void 0;if(u&&n&&(u.projectId!==n.projectId||u.environment!==n.environment))throw new P("SCOPE_MISMATCH","Configuration belongs to another App/environment");let l=new t(A.baseUrl??FA);if(l.username||l.password||l.search||l.hash)throw new P("INVALID_URL","baseUrl must not contain credentials, query, or fragment");if(l.protocol!=="https:"&&!(l.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(l.hostname)))throw new P("INVALID_URL","Use HTTPS, or HTTP on localhost during development");let a=A.fetch??globalThis.fetch.bind(globalThis),h=A.timeoutMs??1e4;if(!Number.isFinite(h)||h<1||h>12e4)throw new P("INVALID_TIMEOUT","timeoutMs must be between 1 and 120000");let f=!1,g=0,p=null,m=new Set,y=A.session??de(async v=>{let R=await tA("customer-sessions/refresh",{},"POST",{},v);if(!R||typeof R!="object")throw new P("INVALID_RESPONSE","Invalid refresh response");let{requestId:_,scope:B,...V}=R;return V});function k(){g+=1,p=null;for(let v of m)v.abort();m.clear()}let Y=y.subscribeIdentity(k);function ge(){f||y.reset()}async function tA(v,R={},_="POST",B={},V){let N=B.installationDetach===!0;if(N&&(v!=="push/installations/detach"||_!=="POST"))throw new P("INVALID_REQUEST","Installation authority only detaches this installation");if(!V&&!N)throw new P("NOT_IDENTIFIED","Call identify with a server-issued customer token first");let X=g,L=new AbortController;N||m.add(L);let nA=()=>!N&&X!==g?new P("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):new P("TIMEOUT","The request timed out"),dA,ye=new Promise((O,q)=>{dA=()=>q(nA()),L.signal.addEventListener("abort",dA,{once:!0})}),Pe=setTimeout(()=>L.abort(),B.timeoutMs??h),De=async()=>{let O=await a(`${l.href.replace(/\/$/,"")}/api/v1/${v}`,{method:_,headers:{...B.headers,"Content-Type":"application/json",...N?{}:{Authorization:`Bearer ${V}`},[NA]:LA.current,[he]:zA.version,...u?{"X-Indiana-Project":u.projectId,"X-Indiana-Environment":u.environment}:{}},body:_==="POST"?JSON.stringify(R):void 0,signal:L.signal,credentials:"omit",cache:_==="POST"&&typeof document<"u"?"default":"no-store",redirect:"error",...B.keepalive?{keepalive:!0}:{}});if(L.signal.aborted)throw nA();let q;try{q=O.status===204?pe:await O.json()}catch{throw L.signal.aborted?nA():new P(O.ok?"INVALID_RESPONSE":"HTTP_ERROR","The gateway returned an unreadable response",O.status,O.headers.get("X-Request-Id")??void 0)}if(L.signal.aborted)throw nA();if(!N&&X!==g)throw new P("IDENTITY_CHANGED","Customer identity changed while the request was in flight");if(!O.ok){let T=MA.safeParse(et(q)),z=T.success&&(!BA.safeParse(T.data.error.code).success||xA(T.data.error.code,O.status)),HA=z?T.data.error.code:"HTTP_ERROR",_A=UA(HA,O.status,{retryAfter:O.headers.get("Retry-After"),recovery:z?T.data.error.recovery:void 0,reason:z?T.data.error.reason:void 0});throw new P(HA,z?T.data.error.message:"The request failed",O.status,O.headers.get("X-Request-Id")??(T.success?T.data.requestId:void 0),{..._A,...T.success&&T.data.error.retryable===!1?{retryable:!1}:{},..._A.retryAfterSeconds===void 0&&T.success&&T.data.error.retryAfterSeconds!==void 0?{retryAfterSeconds:T.data.error.retryAfterSeconds}:{}})}if(O.headers.get(NA)!==LA.current)throw new P("PROTOCOL_MISMATCH","Response protocol does not match this SDK");if(u&&q!==pe){let T=q&&typeof q=="object"&&"scope"in q?q:q&&typeof q=="object"&&"configuration"in q?q.configuration:null;if(!T||typeof T!="object"||!("scope"in T))throw new P("INVALID_RESPONSE","Response is missing its App/environment scope");let z=sA.safeParse(T.scope);if(!z.success||z.data.projectId!==u.projectId||z.data.environment!==u.environment)throw new P("SCOPE_MISMATCH","Response scope does not match this SDK instance")}let rA=O.headers.get("X-Indiana-Telemetry-Subject");if(rA){if(!/^[a-f0-9]{64}$/.test(rA))throw new P("INVALID_RESPONSE","Invalid telemetry identity");p!==rA&&(p=rA,e?.(p))}return q};try{return await Promise.race([De(),ye])}catch(O){throw!N&&X!==g?new P("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):O instanceof P?O:new P(L.signal.aborted?"TIMEOUT":"NETWORK_ERROR",L.signal.aborted?"The request timed out":"Unable to read the response")}finally{clearTimeout(Pe),L.signal.removeEventListener("abort",dA),m.delete(L)}}function we(v,R={},_="POST",B={}){if(f)return Promise.reject(new P("CLOSED","SDK client was destroyed"));if(B.installationDetach)return tA(v,R,_,B);let V=g;try{let N=y.access(),X=L=>{if(V!==g)throw new P("IDENTITY_CHANGED","Customer identity changed before dispatch");return tA(v,R,_,B,L)};return typeof N=="string"?X(N):N.then(X)}catch(N){return Promise.reject(N)}}let me=Object.assign(we,{captureIdentity(){let v=g,R=f,_=!!y.peek();return()=>{if(R)throw new P("CLOSED","SDK client was destroyed");if(!_)throw new P("NOT_IDENTIFIED","Call identify with a server-issued customer token first");if(v!==g)throw new P("IDENTITY_CHANGED","Customer identity changed before dispatch")}}});return{session:y,requestWithCredential(v,R,_,B={}){return f?Promise.reject(new P("CLOSED","SDK client was destroyed")):tA(v,R,"POST",B,_)},subjectKey:()=>p,identify(v){if(f)throw new P("CLOSED","SDK client was destroyed");if(u&&typeof v=="object"&&"scope"in v){let R=sA.safeParse(v.scope);if(!R.success||R.data.projectId!==u.projectId||R.data.environment!==u.environment)throw new P("SCOPE_MISMATCH","Customer session belongs to another App/environment")}y.identify(v)},reset:ge,dispose(){f||(f=!0,Y(),k())},request:me}}function et(A){if(!A||typeof A!="object"||!("error"in A))return A;let e=A.error;if(!e||typeof e!="object"||!("reason"in e)||jA.safeParse(e.reason).success)return A;let{reason:t,...n}=e;return{...A,error:n}}export{eA as a,gt as b};
@@ -1 +1 @@
1
- import{h as c}from"./chunk-JTCS63ER.js";import{b as p}from"./chunk-ZL247MPX.js";import{d as x,e as y,f as g}from"./chunk-VPT5MFDG.js";import{a as m,b as d}from"./chunk-CILM5XMH.js";var u=class extends Error{constructor(t){super(t),this.name="FunnelCalculationError"}};function F(e,t,f){let i={},l,s,n,o="next",a;switch(e.type){case"entry":a=e.next;break;case"condition":{let r=e.cases.findIndex(b=>x(t.attributes??{},b.condition,t.savedGroups??{}));o=r<0?"default":`case:${r}`,a=r<0?e.default:e.cases[r].target;break}case"feature":if(!Object.hasOwn(t.features??{},e.featureKey))throw new u("Required GB Feature is unavailable");l=g(e.featureKey,t),n=l.value,Object.assign(i,c(e,{value:n})),a=e.next;break;case"split":{let r=f[e.experimentId];if(!r)throw new u("Required GB Experiment is unavailable");if(s=y(r,t),n=s.value,o=s.inExperiment&&!s.passthrough&&typeof n=="string"?n:"notParticipating",a=o==="notParticipating"?e.notParticipating:e.routes[o],!a)throw new u("Experiment Variation has no published route");break}case"offering":{let r=e.configuration.source==="fixed"?e.configuration.versionId:g(e.configuration.featureKey,t).value;n={type:"offering_version",id:p.uuid().parse(r)},Object.assign(i,c(e,{value:n})),a=e.next;break}case"coupon":case"coupons":n=e.type==="coupons"?e.couponIds.map(r=>({type:"reward",id:r})):{type:"reward",id:e.couponId},Object.assign(i,c(e,{value:n})),a=e.next;break}return{port:o,target:a,projections:i,...n===void 0?{}:{value:n},...l?{feature:l}:{},...s?{experiment:s}:{}}}function E(e,t,f){p.uuid().parse(e),p.number().int().nonnegative().parse(t);let i=m(d(new TextEncoder().encode(JSON.stringify([e,t,f])))).slice(0,32);return`${i.slice(0,8)}-${i.slice(8,12)}-5${i.slice(13,16)}-a${i.slice(17,20)}-${i.slice(20)}`}export{F as a,E as b};
1
+ import{h as c}from"./chunk-6VVQWTHV.js";import{b as p}from"./chunk-W22ESUYY.js";import{d as x,e as y,f as g}from"./chunk-FYMVNLQN.js";import{a as m,b as d}from"./chunk-FRK6322O.js";var u=class extends Error{constructor(t){super(t),this.name="FunnelCalculationError"}};function F(e,t,f){let i={},l,s,n,o="next",a;switch(e.type){case"entry":a=e.next;break;case"condition":{let r=e.cases.findIndex(b=>x(t.attributes??{},b.condition,t.savedGroups??{}));o=r<0?"default":`case:${r}`,a=r<0?e.default:e.cases[r].target;break}case"feature":if(!Object.hasOwn(t.features??{},e.featureKey))throw new u("Required GB Feature is unavailable");l=g(e.featureKey,t),n=l.value,Object.assign(i,c(e,{value:n})),a=e.next;break;case"split":{let r=f[e.experimentId];if(!r)throw new u("Required GB Experiment is unavailable");if(s=y(r,t),n=s.value,o=s.inExperiment&&!s.passthrough&&typeof n=="string"?n:"notParticipating",a=o==="notParticipating"?e.notParticipating:e.routes[o],!a)throw new u("Experiment Variation has no published route");break}case"offering":{let r=e.configuration.source==="fixed"?e.configuration.versionId:g(e.configuration.featureKey,t).value;n={type:"offering_version",id:p.uuid().parse(r)},Object.assign(i,c(e,{value:n})),a=e.next;break}case"coupon":case"coupons":n=e.type==="coupons"?e.couponIds.map(r=>({type:"reward",id:r})):{type:"reward",id:e.couponId},Object.assign(i,c(e,{value:n})),a=e.next;break}return{port:o,target:a,projections:i,...n===void 0?{}:{value:n},...l?{feature:l}:{},...s?{experiment:s}:{}}}function E(e,t,f){p.uuid().parse(e),p.number().int().nonnegative().parse(t);let i=m(d(new TextEncoder().encode(JSON.stringify([e,t,f])))).slice(0,32);return`${i.slice(0,8)}-${i.slice(8,12)}-5${i.slice(13,16)}-a${i.slice(17,20)}-${i.slice(20)}`}export{F as a,E as b};
@@ -1 +1 @@
1
- import{b as r}from"./chunk-ZL247MPX.js";var R=r.enum(["INVALID_PROTOCOL_VERSION","UNSUPPORTED_PROTOCOL_VERSION","PROTOCOL_RETIRED","UNAUTHENTICATED","FORBIDDEN","SCOPE_MISMATCH","INVALID_REQUEST","NOT_FOUND","CONFLICT","PAYLOAD_TOO_LARGE","RATE_LIMITED","SERVICE_UNAVAILABLE","NOT_CONFIGURED","CAPABILITY_UNAVAILABLE","INTERNAL_ERROR"]),H=r.enum([...R.options,"INVALID_SERVER_RESPONSE","RESPONSE_TOO_LARGE","AMBIGUOUS_AUTHENTICATION","BROWSER_REQUIRED","INVALID_REDIRECT_URI","AUTHORIZATION_UNAVAILABLE","UNREGISTERED_CLIENT","MANAGEMENT_OPERATION_FAILED","SENSITIVE_OUTPUT_REQUIRED"]),j=r.enum([...R.options,"stale_revision"]),v=r.enum(["fix_request","authenticate","check_permissions","check_scope","resolve_conflict","reload_state","retry_same_request","configure_integration","check_availability","upgrade_sdk","recover_operation","contact_support"]),x=r.enum(["CAPABILITY_NOT_ENABLED","INTEGRATION_MISSING","PROVIDER_CREDENTIAL_REJECTED","PRICE_BINDING_REQUIRED","IDEMPOTENCY_CONFLICT","RESULT_UNKNOWN","STATE_CHANGED","IDENTITY_CONTEXT_CHANGED","CUSTOMER_BINDING_CONFLICT","RUN_CONTRACT_MISMATCH","OPERATION_IN_PROGRESS","FUNNEL_VERSION_RETIRED","FUNNEL_PAUSED"]),L={INVALID_PROTOCOL_VERSION:{status:400,recovery:"fix_request"},UNSUPPORTED_PROTOCOL_VERSION:{status:400,recovery:"upgrade_sdk"},PROTOCOL_RETIRED:{status:410,recovery:"upgrade_sdk"},UNAUTHENTICATED:{status:401,recovery:"authenticate"},FORBIDDEN:{status:403,recovery:"check_permissions"},SCOPE_MISMATCH:{status:403,recovery:"check_scope"},INVALID_REQUEST:{status:400,recovery:"fix_request"},NOT_FOUND:{status:404,recovery:"fix_request"},CONFLICT:{status:409,recovery:"resolve_conflict"},PAYLOAD_TOO_LARGE:{status:413,recovery:"fix_request"},RATE_LIMITED:{status:429,recovery:"retry_same_request"},SERVICE_UNAVAILABLE:{status:503,recovery:"retry_same_request"},NOT_CONFIGURED:{status:501,recovery:"configure_integration"},CAPABILITY_UNAVAILABLE:{status:501,recovery:"check_availability"},INTERNAL_ERROR:{status:500,recovery:"recover_operation"}};var S={TIMEOUT:"recover_operation",NETWORK_ERROR:"recover_operation",HTTP_ERROR:"recover_operation",INVALID_RESPONSE:"recover_operation",NOT_IDENTIFIED:"authenticate",CUSTOMER_SESSION_REQUIRED:"authenticate",INVALID_TOKEN:"authenticate",INVALID_URL:"fix_request",INVALID_TIMEOUT:"fix_request",SERVER_ONLY:"fix_request",PROTOCOL_MISMATCH:"upgrade_sdk",IDENTITY_CHANGED:"reload_state",INVALID_STATE:"reload_state",EVENT_QUEUE_FULL:"retry_same_request",COMMAND_PENDING:"recover_operation",PURCHASE_PENDING:"recover_operation",DECISION_PENDING:"recover_operation",DECISION_ACCEPTANCE_UNKNOWN:"recover_operation",RUN_RECONCILIATION_REQUIRED:"recover_operation",DECISION_FAILED:"contact_support",COMMAND_STORAGE_CONFLICT:"resolve_conflict",COMMAND_STORAGE_INVALID:"fix_request",PURCHASE_STORAGE_CONFLICT:"resolve_conflict",PURCHASE_STORAGE_INVALID:"recover_operation",EXECUTION_POLICY_REFUSED:"fix_request",CONFIGURATION_UNAVAILABLE:"check_availability",CONFIGURATION_EXPIRED:"reload_state",CONFIGURATION_CHANGED:"reload_state",CONFIGURATION_DISPOSED:"reload_state",UNSUPPORTED_SCHEMA:"upgrade_sdk",FUNNEL_STOPPED:"check_availability",PAYWALL_UNAVAILABLE:"check_availability",ROUTE_UNAVAILABLE:"check_availability",EVALUATION_MODE:"reload_state",SERVER_REQUIRED:"fix_request",STICKY_SAVE_FAILED:"retry_same_request",TRANSITION_LIMIT:"resolve_conflict",PRECONDITION_FAILED:"reload_state",PRODUCT_UNAVAILABLE:"fix_request",COUPON_UNAVAILABLE:"reload_state",PURCHASE_HANDLER_REQUIRED:"fix_request",EVENT_HANDLER_REQUIRED:"fix_request",CLOSED:"fix_request",BRIDGE_UNAVAILABLE:"check_availability",INVALID_CONFIGURATION:"fix_request",NATIVE_OPERATION_FAILED:"contact_support",AI_PRICE_UNAVAILABLE:"fix_request",AI_USAGE_UNAVAILABLE:"recover_operation",AI_PROVIDER_ERROR:"check_availability",AI_BALANCE_REJECTED:"resolve_conflict"};function g(e,o){if(e==="CONFLICT"&&o===425)return{retryable:!0,recovery:"retry_same_request"};if(e==="CONFLICT"&&o===412)return{retryable:!1,recovery:"reload_state"};if(e==="INVALID_SERVER_RESPONSE")return{retryable:!1,recovery:"recover_operation"};if(e==="AMBIGUOUS_AUTHENTICATION"||e==="SENSITIVE_OUTPUT_REQUIRED")return{retryable:!1,recovery:"fix_request"};if(Object.hasOwn(S,e)){let n=S[e];return{retryable:n==="retry_same_request",recovery:n}}let t=R.safeParse(e);return t.success?{retryable:e==="RATE_LIMITED"||e==="SERVICE_UNAVAILABLE",recovery:L[t.data].recovery}:{retryable:!1,recovery:"contact_support"}}function Q(e,o){let t=R.safeParse(e);if(t.success)return e==="CONFLICT"?[409,412,425].includes(o):e==="SERVICE_UNAVAILABLE"?[408,502,503,504].includes(o):e==="INVALID_REQUEST"?[400,405,415,422].includes(o):e==="NOT_CONFIGURED"?[501,503].includes(o):L[t.data].status===o;let n={INVALID_SERVER_RESPONSE:[502],RESPONSE_TOO_LARGE:[502],AMBIGUOUS_AUTHENTICATION:[400],SENSITIVE_OUTPUT_REQUIRED:[400],BROWSER_REQUIRED:[403],INVALID_REDIRECT_URI:[403],AUTHORIZATION_UNAVAILABLE:[400],UNREGISTERED_CLIENT:[403],MANAGEMENT_OPERATION_FAILED:[400,422,500]};return Object.hasOwn(n,e)&&(n[e]?.includes(o)??!1)}function P(e,o=Date.now()){if(e===null)return;let t=e.trim();if(/^\d+$/.test(t)){let s=Number(t);return Number.isSafeInteger(s)?s:void 0}if(!/^[A-Za-z]{3}, \d{2} [A-Za-z]{3} \d{4} \d{2}:\d{2}:\d{2} GMT$/.test(t))return;let n=Date.parse(t);return Number.isFinite(n)?Math.max(0,Math.ceil((n-o)/1e3)):void 0}var y=r.object({retryable:r.boolean(),recovery:v,reason:x.optional(),retryAfterSeconds:r.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).optional()}),b=r.object({requestId:r.uuid().optional(),error:r.object({code:r.string().regex(/^[A-Z][A-Z0-9_]{0,95}$/),message:r.string(),...y.partial().shape})}),z=r.object({error:b.shape.error.extend({requestId:r.uuid().optional()})}),Y=r.object({error:r.string(),code:r.string().regex(/^[A-Za-z][A-Za-z0-9_]{0,95}$/),requestId:r.uuid(),...y.shape});function $(e,o,t={}){let n=g(e,o),s=t.reason==="RESULT_UNKNOWN"?"recover_operation":t.recovery??n.recovery,A=n.retryable&&t.retryable!==!1&&s!=="recover_operation",i=A?P(t.retryAfter??null):void 0;return{...n,retryable:A,recovery:s,...i===void 0?{}:{retryAfterSeconds:i},...t.reason?{reason:t.reason}:{}}}var V=r.enum(["sandbox","live"]),W=r.object({projectId:r.string().min(1),environment:V}).strict();var J=r.string().regex(/^(0|[1-9]\d{0,12})(\.\d{1,12})?$/),u=r.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/).transform(e=>e.includes(".")?e.replace(/0+$/,"").replace(/\.$/,""):e),M=r.string().regex(/^-?(0|[1-9]\d{0,11})(\.\d{1,6})?$/).transform(e=>{let o=e.includes(".")?e.replace(/0+$/,"").replace(/\.$/,""):e;return o==="-0"?"0":o}),p=u.refine(e=>/[1-9]/.test(e),"数量必须大于 0"),D=r.string().min(1).max(64),B=r.string().min(1).regex(/^[a-zA-Z0-9_-]+$/),C=r.string().min(1).max(64).refine(e=>!e.includes("::"),"Dimension IDs cannot contain ::"),ee=r.record(D,r.union([r.string().max(120),r.number().finite(),r.boolean()])).refine(e=>Object.keys(e).length<=16,"最多 16 个计价属性").transform(e=>Object.fromEntries(Object.entries(e).map(([o,t])=>[o,String(t)]))),U=r.record(D,r.union([r.string().max(120),r.number().finite(),r.boolean()]).transform(String)).refine(e=>Object.keys(e).length<=8,"匹配条件最多 8 个属性"),I=e=>{let o=e.startsWith("-");o&&(e=e.slice(1));let[t,n=""]=e.split(".");if(t===void 0||t==="")throw new Error("Invalid decimal value");let s=BigInt(t)*BigInt("1000000")+BigInt(n.padEnd(6,"0"));return o?-s:s},h=r.array(r.object({upTo:p.nullable(),cost:u}).strict()).min(1).max(12).refine(e=>e.at(-1)?.upTo===null&&e.slice(0,-1).every((o,t)=>{let n=e[t-1]?.upTo;return o.upTo!==null&&(t===0||n!=null&&I(o.upTo)>I(n))}),"阶梯上限必须递增,最后一档为无限"),G=r.object({key:C,match:U,priority:r.number().int().default(0),cost:u.optional(),tiers:h.optional()}).strict().refine(e=>e.cost!==void 0||e.tiers!==void 0,"维度需要指定单价或阶梯"),F=r.object({key:C,match:U,factor:p.optional(),add:M.optional()}).strict().refine(e=>e.factor!==void 0||e.add!==void 0,"A multiplier needs a factor or an add").transform(e=>({...e,factor:e.factor??"1",add:e.add??"0"})),k=r.object({units:p.default("1"),cost:u,tiers:h.optional(),dimensions:r.array(G).max(12).optional(),multipliers:r.array(F).max(4).optional()}).strict().superRefine((e,o)=>{let t=e.dimensions??[],n=e.multipliers??[];(new Set(t.map(i=>i.key)).size!==t.length||new Set(n.map(i=>i.key)).size!==n.length)&&o.addIssue({code:"custom",message:"维度和倍率的 ID 不能重复"});for(let[i,a]of t.entries())for(let c of t.slice(i+1))Object.keys(a.match).length===Object.keys(c.match).length&&a.priority===c.priority&&!Object.keys(a.match).some(E=>c.match[E]!==void 0&&c.match[E]!==a.match[E])&&o.addIssue({code:"custom",message:"维度可能同时匹配,请调整优先级"});let s=[e.cost,...(e.tiers??[]).map(i=>i.cost),...t.flatMap(i=>[...i.cost===void 0?[]:[i.cost],...(i.tiers??[]).map(a=>a.cost)])],A=I(e.units);for(let i of s)for(let a=0;a<1<<n.length;a++){let c=n.filter((N,_)=>a&1<<_);if(c.some((N,_)=>c.slice(_+1).some(d=>Object.keys(N.match).some(l=>d.match[l]!==void 0&&d.match[l]!==N.match[l]))))continue;let E=I(i),O=BigInt("1"),f=BigInt("0");for(let[N,_]of n.entries())a&1<<N&&(E*=I(_.factor??"1"),O*=BigInt("1000000"),f+=I(_.add??"0"));let T=(E+f*O)*BigInt("1000000"),m=O*A;(T<BigInt("0")||T%m!==BigInt("0")||T/m>BigInt("999999999999999999"))&&o.addIssue({code:"custom",message:"每个业务单位的最终单价必须非负、在范围内且能精确表示为最多 6 位小数"})}}),re=k.safeExtend({featureKey:B});export{R as a,v as b,x as c,Q as d,b as e,$ as f,V as g,W as h,J as i,u as j,M as k,B as l,ee as m};
1
+ import{b as r}from"./chunk-W22ESUYY.js";var R=r.enum(["INVALID_PROTOCOL_VERSION","UNSUPPORTED_PROTOCOL_VERSION","PROTOCOL_RETIRED","UNAUTHENTICATED","FORBIDDEN","SCOPE_MISMATCH","INVALID_REQUEST","NOT_FOUND","CONFLICT","PAYLOAD_TOO_LARGE","RATE_LIMITED","SERVICE_UNAVAILABLE","NOT_CONFIGURED","CAPABILITY_UNAVAILABLE","INTERNAL_ERROR"]),H=r.enum([...R.options,"INVALID_SERVER_RESPONSE","RESPONSE_TOO_LARGE","AMBIGUOUS_AUTHENTICATION","BROWSER_REQUIRED","INVALID_REDIRECT_URI","AUTHORIZATION_UNAVAILABLE","UNREGISTERED_CLIENT","MANAGEMENT_OPERATION_FAILED","SENSITIVE_OUTPUT_REQUIRED"]),j=r.enum([...R.options,"stale_revision"]),v=r.enum(["fix_request","authenticate","check_permissions","check_scope","resolve_conflict","reload_state","retry_same_request","configure_integration","check_availability","upgrade_sdk","recover_operation","contact_support"]),x=r.enum(["CAPABILITY_NOT_ENABLED","INTEGRATION_MISSING","PROVIDER_CREDENTIAL_REJECTED","PRICE_BINDING_REQUIRED","IDEMPOTENCY_CONFLICT","RESULT_UNKNOWN","STATE_CHANGED","IDENTITY_CONTEXT_CHANGED","CUSTOMER_BINDING_CONFLICT","RUN_CONTRACT_MISMATCH","OPERATION_IN_PROGRESS","FUNNEL_VERSION_RETIRED","FUNNEL_PAUSED"]),L={INVALID_PROTOCOL_VERSION:{status:400,recovery:"fix_request"},UNSUPPORTED_PROTOCOL_VERSION:{status:400,recovery:"upgrade_sdk"},PROTOCOL_RETIRED:{status:410,recovery:"upgrade_sdk"},UNAUTHENTICATED:{status:401,recovery:"authenticate"},FORBIDDEN:{status:403,recovery:"check_permissions"},SCOPE_MISMATCH:{status:403,recovery:"check_scope"},INVALID_REQUEST:{status:400,recovery:"fix_request"},NOT_FOUND:{status:404,recovery:"fix_request"},CONFLICT:{status:409,recovery:"resolve_conflict"},PAYLOAD_TOO_LARGE:{status:413,recovery:"fix_request"},RATE_LIMITED:{status:429,recovery:"retry_same_request"},SERVICE_UNAVAILABLE:{status:503,recovery:"retry_same_request"},NOT_CONFIGURED:{status:501,recovery:"configure_integration"},CAPABILITY_UNAVAILABLE:{status:501,recovery:"check_availability"},INTERNAL_ERROR:{status:500,recovery:"recover_operation"}};var S={TIMEOUT:"recover_operation",NETWORK_ERROR:"recover_operation",HTTP_ERROR:"recover_operation",INVALID_RESPONSE:"recover_operation",NOT_IDENTIFIED:"authenticate",CUSTOMER_SESSION_REQUIRED:"authenticate",INVALID_TOKEN:"authenticate",INVALID_URL:"fix_request",INVALID_TIMEOUT:"fix_request",SERVER_ONLY:"fix_request",PROTOCOL_MISMATCH:"upgrade_sdk",IDENTITY_CHANGED:"reload_state",INVALID_STATE:"reload_state",EVENT_QUEUE_FULL:"retry_same_request",COMMAND_PENDING:"recover_operation",PURCHASE_PENDING:"recover_operation",DECISION_PENDING:"recover_operation",DECISION_ACCEPTANCE_UNKNOWN:"recover_operation",RUN_RECONCILIATION_REQUIRED:"recover_operation",DECISION_FAILED:"contact_support",COMMAND_STORAGE_CONFLICT:"resolve_conflict",COMMAND_STORAGE_INVALID:"fix_request",PURCHASE_STORAGE_CONFLICT:"resolve_conflict",PURCHASE_STORAGE_INVALID:"recover_operation",EXECUTION_POLICY_REFUSED:"fix_request",CONFIGURATION_UNAVAILABLE:"check_availability",CONFIGURATION_EXPIRED:"reload_state",CONFIGURATION_CHANGED:"reload_state",CONFIGURATION_DISPOSED:"reload_state",UNSUPPORTED_SCHEMA:"upgrade_sdk",FUNNEL_STOPPED:"check_availability",PAYWALL_UNAVAILABLE:"check_availability",ROUTE_UNAVAILABLE:"check_availability",EVALUATION_MODE:"reload_state",SERVER_REQUIRED:"fix_request",STICKY_SAVE_FAILED:"retry_same_request",TRANSITION_LIMIT:"resolve_conflict",PRECONDITION_FAILED:"reload_state",PRODUCT_UNAVAILABLE:"fix_request",COUPON_UNAVAILABLE:"reload_state",PURCHASE_HANDLER_REQUIRED:"fix_request",EVENT_HANDLER_REQUIRED:"fix_request",CLOSED:"fix_request",BRIDGE_UNAVAILABLE:"check_availability",INVALID_CONFIGURATION:"fix_request",NATIVE_OPERATION_FAILED:"contact_support",AI_PRICE_UNAVAILABLE:"fix_request",AI_USAGE_UNAVAILABLE:"recover_operation",AI_PROVIDER_ERROR:"check_availability",AI_BALANCE_REJECTED:"resolve_conflict"};function g(e,o){if(e==="CONFLICT"&&o===425)return{retryable:!0,recovery:"retry_same_request"};if(e==="CONFLICT"&&o===412)return{retryable:!1,recovery:"reload_state"};if(e==="INVALID_SERVER_RESPONSE")return{retryable:!1,recovery:"recover_operation"};if(e==="AMBIGUOUS_AUTHENTICATION"||e==="SENSITIVE_OUTPUT_REQUIRED")return{retryable:!1,recovery:"fix_request"};if(Object.hasOwn(S,e)){let n=S[e];return{retryable:n==="retry_same_request",recovery:n}}let t=R.safeParse(e);return t.success?{retryable:e==="RATE_LIMITED"||e==="SERVICE_UNAVAILABLE",recovery:L[t.data].recovery}:{retryable:!1,recovery:"contact_support"}}function Q(e,o){let t=R.safeParse(e);if(t.success)return e==="CONFLICT"?[409,412,425].includes(o):e==="SERVICE_UNAVAILABLE"?[408,502,503,504].includes(o):e==="INVALID_REQUEST"?[400,405,415,422].includes(o):e==="NOT_CONFIGURED"?[501,503].includes(o):L[t.data].status===o;let n={INVALID_SERVER_RESPONSE:[502],RESPONSE_TOO_LARGE:[502],AMBIGUOUS_AUTHENTICATION:[400],SENSITIVE_OUTPUT_REQUIRED:[400],BROWSER_REQUIRED:[403],INVALID_REDIRECT_URI:[403],AUTHORIZATION_UNAVAILABLE:[400],UNREGISTERED_CLIENT:[403],MANAGEMENT_OPERATION_FAILED:[400,422,500]};return Object.hasOwn(n,e)&&(n[e]?.includes(o)??!1)}function P(e,o=Date.now()){if(e===null)return;let t=e.trim();if(/^\d+$/.test(t)){let s=Number(t);return Number.isSafeInteger(s)?s:void 0}if(!/^[A-Za-z]{3}, \d{2} [A-Za-z]{3} \d{4} \d{2}:\d{2}:\d{2} GMT$/.test(t))return;let n=Date.parse(t);return Number.isFinite(n)?Math.max(0,Math.ceil((n-o)/1e3)):void 0}var y=r.object({retryable:r.boolean(),recovery:v,reason:x.optional(),retryAfterSeconds:r.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).optional()}),b=r.object({requestId:r.uuid().optional(),error:r.object({code:r.string().regex(/^[A-Z][A-Z0-9_]{0,95}$/),message:r.string(),...y.partial().shape})}),z=r.object({error:b.shape.error.extend({requestId:r.uuid().optional()})}),Y=r.object({error:r.string(),code:r.string().regex(/^[A-Za-z][A-Za-z0-9_]{0,95}$/),requestId:r.uuid(),...y.shape});function $(e,o,t={}){let n=g(e,o),s=t.reason==="RESULT_UNKNOWN"?"recover_operation":t.recovery??n.recovery,A=n.retryable&&t.retryable!==!1&&s!=="recover_operation",i=A?P(t.retryAfter??null):void 0;return{...n,retryable:A,recovery:s,...i===void 0?{}:{retryAfterSeconds:i},...t.reason?{reason:t.reason}:{}}}var V=r.enum(["sandbox","live"]),W=r.object({projectId:r.string().min(1),environment:V}).strict();var J=r.string().regex(/^(0|[1-9]\d{0,12})(\.\d{1,12})?$/),u=r.string().regex(/^(0|[1-9]\d{0,11})(\.\d{1,6})?$/).transform(e=>e.includes(".")?e.replace(/0+$/,"").replace(/\.$/,""):e),M=r.string().regex(/^-?(0|[1-9]\d{0,11})(\.\d{1,6})?$/).transform(e=>{let o=e.includes(".")?e.replace(/0+$/,"").replace(/\.$/,""):e;return o==="-0"?"0":o}),p=u.refine(e=>/[1-9]/.test(e),"数量必须大于 0"),D=r.string().min(1).max(64),B=r.string().min(1).regex(/^[a-zA-Z0-9_-]+$/),C=r.string().min(1).max(64).refine(e=>!e.includes("::"),"Dimension IDs cannot contain ::"),ee=r.record(D,r.union([r.string().max(120),r.number().finite(),r.boolean()])).refine(e=>Object.keys(e).length<=16,"最多 16 个计价属性").transform(e=>Object.fromEntries(Object.entries(e).map(([o,t])=>[o,String(t)]))),U=r.record(D,r.union([r.string().max(120),r.number().finite(),r.boolean()]).transform(String)).refine(e=>Object.keys(e).length<=8,"匹配条件最多 8 个属性"),I=e=>{let o=e.startsWith("-");o&&(e=e.slice(1));let[t,n=""]=e.split(".");if(t===void 0||t==="")throw new Error("Invalid decimal value");let s=BigInt(t)*BigInt("1000000")+BigInt(n.padEnd(6,"0"));return o?-s:s},h=r.array(r.object({upTo:p.nullable(),cost:u}).strict()).min(1).max(12).refine(e=>e.at(-1)?.upTo===null&&e.slice(0,-1).every((o,t)=>{let n=e[t-1]?.upTo;return o.upTo!==null&&(t===0||n!=null&&I(o.upTo)>I(n))}),"阶梯上限必须递增,最后一档为无限"),G=r.object({key:C,match:U,priority:r.number().int().default(0),cost:u.optional(),tiers:h.optional()}).strict().refine(e=>e.cost!==void 0||e.tiers!==void 0,"维度需要指定单价或阶梯"),F=r.object({key:C,match:U,factor:p.optional(),add:M.optional()}).strict().refine(e=>e.factor!==void 0||e.add!==void 0,"A multiplier needs a factor or an add").transform(e=>({...e,factor:e.factor??"1",add:e.add??"0"})),k=r.object({units:p.default("1"),cost:u,tiers:h.optional(),dimensions:r.array(G).max(12).optional(),multipliers:r.array(F).max(4).optional()}).strict().superRefine((e,o)=>{let t=e.dimensions??[],n=e.multipliers??[];(new Set(t.map(i=>i.key)).size!==t.length||new Set(n.map(i=>i.key)).size!==n.length)&&o.addIssue({code:"custom",message:"维度和倍率的 ID 不能重复"});for(let[i,a]of t.entries())for(let c of t.slice(i+1))Object.keys(a.match).length===Object.keys(c.match).length&&a.priority===c.priority&&!Object.keys(a.match).some(E=>c.match[E]!==void 0&&c.match[E]!==a.match[E])&&o.addIssue({code:"custom",message:"维度可能同时匹配,请调整优先级"});let s=[e.cost,...(e.tiers??[]).map(i=>i.cost),...t.flatMap(i=>[...i.cost===void 0?[]:[i.cost],...(i.tiers??[]).map(a=>a.cost)])],A=I(e.units);for(let i of s)for(let a=0;a<1<<n.length;a++){let c=n.filter((N,_)=>a&1<<_);if(c.some((N,_)=>c.slice(_+1).some(d=>Object.keys(N.match).some(l=>d.match[l]!==void 0&&d.match[l]!==N.match[l]))))continue;let E=I(i),O=BigInt("1"),f=BigInt("0");for(let[N,_]of n.entries())a&1<<N&&(E*=I(_.factor??"1"),O*=BigInt("1000000"),f+=I(_.add??"0"));let T=(E+f*O)*BigInt("1000000"),m=O*A;(T<BigInt("0")||T%m!==BigInt("0")||T/m>BigInt("999999999999999999"))&&o.addIssue({code:"custom",message:"每个业务单位的最终单价必须非负、在范围内且能精确表示为最多 6 位小数"})}}),re=k.safeExtend({featureKey:B});export{R as a,v as b,x as c,Q as d,b as e,$ as f,V as g,W as h,J as i,u as j,M as k,B as l,ee as m};