@tinkerlandai/longplay-sdk 0.10.83 → 0.10.84
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.
- package/CHANGELOG.md +4 -0
- package/dist/check-response-AB52X53M.js +1 -0
- package/dist/{chunk-PUDTOCQF.js → chunk-25LM2JXB.js} +1 -1
- package/dist/{chunk-2MJ5IOPR.js → chunk-3AUMX2ZW.js} +1 -1
- package/dist/{chunk-3532HSBP.js → chunk-3QRVHAWK.js} +1 -1
- package/dist/{chunk-7ZAM4YRK.js → chunk-45PGU2HW.js} +1 -1
- package/dist/{chunk-GVUUADNK.js → chunk-45RTRADT.js} +1 -1
- package/dist/{chunk-AVR5EUXS.js → chunk-4CWYR6NX.js} +1 -1
- package/dist/chunk-57NEGKC5.js +1 -0
- package/dist/{chunk-EQUVI5QU.js → chunk-AH36XJ2P.js} +1 -1
- package/dist/{chunk-A5WUQLAO.js → chunk-B3FNR6MN.js} +1 -1
- package/dist/{chunk-LFR2LWYC.js → chunk-BJSY53HD.js} +1 -1
- package/dist/{chunk-X6KUYCLZ.js → chunk-BKN33GVY.js} +1 -1
- package/dist/{chunk-UGATOG2T.js → chunk-BNVQIMXY.js} +1 -1
- package/dist/{chunk-VXNN3RV3.js → chunk-CTDXIKX3.js} +1 -1
- package/dist/{chunk-ME6QTD5Y.js → chunk-DGGXLPHI.js} +1 -1
- package/dist/{chunk-KX67ZM7H.js → chunk-EPKQGOCT.js} +1 -1
- package/dist/{chunk-KCUE2VFJ.js → chunk-FRWORXER.js} +1 -1
- package/dist/{chunk-Y6KA56V2.js → chunk-HFLMTQ5S.js} +1 -1
- package/dist/{chunk-67WFVDTV.js → chunk-HJLZY2VK.js} +1 -1
- package/dist/{chunk-7QPCNDIY.js → chunk-HVDAQX2D.js} +1 -1
- package/dist/{chunk-EZCP464L.js → chunk-HVWHUYSF.js} +2 -2
- package/dist/{chunk-JKBPDJVJ.js → chunk-J6F2XFDL.js} +1 -1
- package/dist/chunk-K6Q64QHZ.js +1 -0
- package/dist/{chunk-FWQO3IKX.js → chunk-KHJZA73V.js} +1 -1
- package/dist/{chunk-F4AIEI5N.js → chunk-MCQGIPH7.js} +1 -1
- package/dist/{chunk-6VVQWTHV.js → chunk-NBIHNC2C.js} +1 -1
- package/dist/{chunk-SX7U2ONB.js → chunk-OT3ED6TT.js} +1 -1
- package/dist/{chunk-CKMSSBJM.js → chunk-P6O6ULXW.js} +1 -1
- package/dist/{chunk-S2S4ROGY.js → chunk-Q2ZKKRIB.js} +1 -1
- package/dist/{chunk-BOT6ZDLK.js → chunk-Q3K63EFB.js} +1 -1
- package/dist/{chunk-6XRQR43F.js → chunk-R6NVHYXW.js} +1 -1
- package/dist/{chunk-CO6HDNOC.js → chunk-RWGMLH42.js} +1 -1
- package/dist/{chunk-FPJ3FE26.js → chunk-S7UDY3NL.js} +1 -1
- package/dist/{chunk-JS4K6SZB.js → chunk-SBZFPW6N.js} +1 -1
- package/dist/{chunk-LQV7EC5H.js → chunk-SY3GVNMT.js} +1 -1
- package/dist/{chunk-Y55OBV7D.js → chunk-TG7FSNRF.js} +1 -1
- package/dist/{chunk-FOWGE6WT.js → chunk-TGY77F4A.js} +1 -1
- package/dist/{chunk-NVFF3E4O.js → chunk-TQIZN3GB.js} +1 -1
- package/dist/{chunk-2OBXRQMW.js → chunk-U3TW2YVO.js} +1 -1
- package/dist/{chunk-C4KLIT5L.js → chunk-UDVFPFL6.js} +1 -1
- package/dist/{chunk-HQYLR4N6.js → chunk-UO3DDQEW.js} +1 -1
- package/dist/{chunk-MOIVJERE.js → chunk-VJXGTINT.js} +1 -1
- package/dist/{chunk-FYMVNLQN.js → chunk-VPT5MFDG.js} +2 -2
- package/dist/{chunk-DUS5V65Z.js → chunk-VUGDBVIZ.js} +1 -1
- package/dist/{chunk-FYUMVOCV.js → chunk-W5MSVU2K.js} +1 -1
- package/dist/{chunk-7CZEXBQY.js → chunk-X6WXJJED.js} +1 -1
- package/dist/{chunk-Y3W5G4BF.js → chunk-YBDTPMGD.js} +1 -1
- package/dist/{chunk-XLGNBPGF.js → chunk-YJHL2DPP.js} +1 -1
- package/dist/{chunk-CHRNCOXJ.js → chunk-YMNCFP4X.js} +1 -1
- package/dist/{chunk-LOTEP3DL.js → chunk-Z42LII54.js} +1 -1
- package/dist/{chunk-BT7IC765.js → chunk-ZBVIIFB4.js} +1 -1
- package/dist/{content-J5XJC5D5.js → content-YCHZNM7Y.js} +1 -1
- package/dist/{funnel-host-purchase-PU42GTYT.js → funnel-host-purchase-O2XMLQLO.js} +1 -1
- package/dist/funnel-host-recovery-paywall-3OLSW5TK.js +1 -0
- package/dist/{funnel-paywall-copies-LPOTYSTS.js → funnel-paywall-copies-GHMZFYUK.js} +1 -1
- package/dist/funnel-paywall-prerender-ZUE3E5CD.js +1 -0
- package/dist/funnel-route-prediction-EFAGTU7F.js +1 -0
- package/dist/funnel-route-source-D66HFVVK.js +1 -0
- package/dist/funnel-runtime-host-CHUEAXTG.js +1 -0
- package/dist/index.js +1 -1
- package/dist/merchant-bridge-contracts-RF4XQQTE.js +1 -0
- package/dist/openrouter.js +1 -1
- package/dist/operation-contracts-IAMHNJCL.js +1 -0
- package/dist/page.js +1 -1
- package/dist/paywall-SMS52HSX.js +1 -0
- package/dist/paywall-content-ZJWLT3BD.js +1 -0
- package/dist/paywall-session-YNYTE7BE.js +1 -0
- package/dist/popup.js +1 -1
- package/dist/react-native.js +1 -1
- package/dist/screen-renderer-MVJ5BKQS.js +1 -0
- package/dist/server.js +1 -1
- package/dist/{visual-dom-KUABNJV6.js → visual-dom-5LUN4AHO.js} +1 -1
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/check-response-XGOTG3KL.js +0 -1
- package/dist/chunk-5IUMSED3.js +0 -1
- package/dist/chunk-HNRSQSVT.js +0 -1
- package/dist/funnel-host-recovery-paywall-U2K5YJUR.js +0 -1
- package/dist/funnel-paywall-prerender-RLIUPW3S.js +0 -1
- package/dist/funnel-route-prediction-Q4HMRAVQ.js +0 -1
- package/dist/funnel-route-source-HYWJWEM3.js +0 -1
- package/dist/funnel-runtime-host-WUAMLZZR.js +0 -1
- package/dist/merchant-bridge-contracts-OIYML3DE.js +0 -1
- package/dist/operation-contracts-YJM6772C.js +0 -1
- package/dist/paywall-DV3BHCTF.js +0 -1
- package/dist/paywall-content-PCQEYRWF.js +0 -1
- package/dist/paywall-session-WOFTNQLE.js +0 -1
- package/dist/screen-renderer-HJOKBOZH.js +0 -1
- /package/dist/{chunk-FRK6322O.js → chunk-CILM5XMH.js} +0 -0
- /package/dist/{chunk-EZCP464L.js.LEGAL.txt → chunk-HVWHUYSF.js.LEGAL.txt} +0 -0
- /package/dist/{chunk-KV5MZ4NI.js → chunk-OJM6ORHE.js} +0 -0
- /package/dist/{chunk-W22ESUYY.js → chunk-VITB5MIL.js} +0 -0
- /package/dist/{chunk-FYMVNLQN.js.LEGAL.txt → chunk-VPT5MFDG.js.LEGAL.txt} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as u,D as d}from"./chunk-
|
|
1
|
+
import{C as u,D as d}from"./chunk-3QRVHAWK.js";function f(r){if(u(r)||r.executor!=="merchant")return!1;let o=r.merchantExecution;return["pending","failed"].includes(r.status)&&o?.type==="purchase"&&o.operationId===r.operationId&&o.paymentStatus==="failed"&&o.fulfillmentStatus==="not_applicable"&&o.recordingStatus==="accepted"&&o.merchantOrderId===null&&!o.checkoutUrl&&!o.problem&&!r.checkoutUrl&&!r.nativePurchase&&!r.problem}function m(r){let{quote:o,operation:e,requestId:s}=r,a={type:"recover",operationId:e?.operationId??o?.operationId??null,requestId:s};if(r.destroyed||r.pending)return a;if(!e)return o?{type:"cancel",operationId:o.operationId}:a;let t=e.merchantExecution;if(u(e)){if(t&&t.type!=="subscription_change")return a;if(t?.type==="subscription_change"){if(["applied","scheduled"].includes(t.status))return!["applied","not_applicable"].includes(t.fulfillmentStatus)||e.problem?.phase==="fulfillment"||t.problem?.phase==="fulfillment"?{type:"fulfillment",operationId:e.operationId}:{type:t.recordingStatus==="accepted"&&d(e)&&!e.problem&&!t.problem?"complete":"recording",operationId:e.operationId};if(e.status==="pending"&&!e.problem&&!t.problem&&t.nextAction?.type==="redirect"&&(!e.checkoutUrl||t.nextAction.url===e.checkoutUrl)&&Date.parse(t.nextAction.expiresAt)>Date.now()&&t.status==="pending")return{type:"checkout",operationId:e.operationId,checkoutUrl:t.nextAction.url}}if(!e.problem&&!t?.problem&&d(e)&&e.executor!=="merchant")return{type:"complete",operationId:e.operationId};if(e.executor==="indiana"&&e.status==="pending"&&e.checkoutUrl&&!e.problem&&(!o||Date.parse(o.expiresAt)>Date.now()))return{type:"checkout",operationId:e.operationId,checkoutUrl:e.checkoutUrl};let n=p=>!p||p.phase==="execution"&&p.reason==="STATE_CHANGED";return r.canReselect===!0&&["cancelled","failed"].includes(e.status)&&!e.checkoutUrl&&!e.execution&&n(e.problem)&&n(t?.problem)&&(!t||t.status==="failed"&&t.recordingStatus==="accepted"&&t.fulfillmentStatus==="not_applicable")?{type:"native",operationId:e.operationId}:["prepared","quoted"].includes(e.status)&&!e.confirmedAt&&!t&&!e.checkoutUrl&&!e.problem?{type:"cancel",operationId:e.operationId}:a}if(t?.type==="purchase"){if(["succeeded","not_required"].includes(t.paymentStatus))return!["applied","not_applicable"].includes(t.fulfillmentStatus)||e.problem?.phase==="fulfillment"||t.problem?.phase==="fulfillment"?{type:"fulfillment",operationId:e.operationId}:{type:t.recordingStatus==="accepted"&&e.status==="complete"&&!e.problem&&!t.problem?"complete":"recording",operationId:e.operationId};if(e.status==="pending"&&e.checkoutUrl&&!e.problem&&!t.problem&&t.checkoutUrl===e.checkoutUrl&&t.checkoutExpiresAt&&Date.parse(t.checkoutExpiresAt)>Date.now()&&["not_started","pending"].includes(t.paymentStatus))return{type:"checkout",operationId:e.operationId,checkoutUrl:e.checkoutUrl}}if(r.canReselect===!0&&f(e))return{type:"native",operationId:e.operationId};if(e.executor==="indiana"&&e.status==="pending"&&e.checkoutUrl&&!e.problem&&!e.nativePurchase&&(!o||Date.parse(o.expiresAt)>Date.now()))return{type:"checkout",operationId:e.operationId,checkoutUrl:e.checkoutUrl};let c=[e.problem,t?.problem],i=c.every(n=>!n||n.phase==="execution"&&n.reason!=="RESULT_UNKNOWN"),y=e.status==="cancelled"&&!c.some(Boolean)&&t?.type==="purchase"&&["pending","not_started","expired"].includes(t.paymentStatus)&&["not_started","not_applicable"].includes(t.fulfillmentStatus);return r.canReselect===!0&&i&&["cancelled","failed"].includes(e.status)&&!e.checkoutUrl&&!e.execution&&!e.nativePurchase&&(e.executor!=="merchant"||!t||t.type==="purchase"&&!["succeeded","not_required"].includes(t.paymentStatus)&&(y||t.recordingStatus==="accepted"&&t.fulfillmentStatus==="not_applicable"))?{type:"native",operationId:e.operationId}:!c.some(Boolean)&&e.status==="complete"&&e.executor!=="merchant"?{type:"complete",operationId:e.operationId}:i&&r.canReselect!==!1&&["cancelled","failed"].includes(e.status)&&!e.checkoutUrl&&!e.execution&&!e.nativePurchase&&(e.executor!=="merchant"?!e.confirmedAt&&(e.status==="cancelled"||!e.quoteFinalized):!t&&!e.quoteFinalized||t?.type==="purchase"&&["failed","expired"].includes(t.paymentStatus)&&t.fulfillmentStatus==="not_applicable"&&t.recordingStatus==="accepted")?{type:"native",operationId:e.operationId}:e.status==="pending"&&i&&!e.quoteFinalized&&!t&&!e.checkoutUrl&&!e.execution&&!e.nativePurchase?{type:"cancel",operationId:e.operationId}:a}function b(r,o=!0){if(!r)return!1;let e=m({quote:r.quote??null,operation:r,requestId:null,pending:!1,destroyed:!1,canReselect:o});return e.type==="complete"||e.type==="native"}function l(r){return r.recovery??{type:"recover",operationId:r.operation?.operationId??r.quote?.operationId??null,requestId:null}}function g(r){return!!(r?.operationId&&(r.type==="checkout"||r.type==="recover"||r.type==="fulfillment"||r.type==="recording"))}async function x(r){let o=l(r);if(o.type==="recover"&&r.quote)try{await r.read(),o=l(r)}catch{return o}if(o.type!=="cancel"&&!(o.type==="recover"&&r.pendingCancellation))return o;try{await r.cancel();let e=l(r);return e.type==="cancel"?{type:"recover",operationId:o.operationId,requestId:null}:e}catch{let e=l(r);return e.type==="recover"?e:{type:"recover",operationId:o.operationId,requestId:null}}}export{f as a,m as b,b as c,l as d,g as e,x as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as T,b as se}from"./chunk-XLGNBPGF.js";import{b as re,h as ae,j as ce}from"./chunk-AVR5EUXS.js";import{E as M,a as J}from"./chunk-X6KUYCLZ.js";import{a as b,b as f,c as m}from"./chunk-S2S4ROGY.js";import{c as Z,e as ee,f as te,g as H,h as G,j as ne}from"./chunk-2OBXRQMW.js";import{a as oe,b as j}from"./chunk-PUDTOCQF.js";import{b as W,j as X}from"./chunk-BT7IC765.js";import{n as $}from"./chunk-ME6QTD5Y.js";import{b as ie}from"./chunk-NVFF3E4O.js";import{a as B}from"./chunk-KCUE2VFJ.js";import{a as s}from"./chunk-UGATOG2T.js";import{h as Q}from"./chunk-LFR2LWYC.js";import{b as K}from"./chunk-W22ESUYY.js";import{a as z}from"./chunk-DSPLGTQI.js";var U=t=>{if(!Number.isSafeInteger(t)||t<0||t>=Number.MAX_SAFE_INTEGER)throw new s("INVALID_STATE","Installation sequence exhausted");return t+1},Se=async t=>[...new Uint8Array(await crypto.subtle.digest("SHA-256",Uint8Array.from(t,e=>e.charCodeAt(0))))].map(e=>e.toString(16).padStart(2,"0")).join("");function _(t,e){return t.transaction(n=>{if(!Number.isSafeInteger(n.identitySeq)||n.identitySeq<0||!Number.isSafeInteger(n.addressSeq)||n.addressSeq<0||n.detachSeq!==null&&(!Number.isSafeInteger(n.detachSeq)||n.detachSeq<1||n.detachSeq>n.identitySeq))throw new s("INVALID_STATE","Installation journal is invalid");return e({...n})})}function ue(t,e,n){let r=null,o=0,a=0,d=0,y=Promise.resolve(),g=!1;if(t&&(!n||Q.parse(t.scope).projectId!==n.projectId||t.scope.environment!==n.environment))throw new s("SCOPE_MISMATCH","Push installation belongs to another scope");let l=()=>{if(g)throw new s("CLOSED","SDK client was destroyed");if(!t)throw new s("NOT_CONFIGURED","Configure this client's native Push host first");return t},O=i=>{if(i!==o)throw new s("IDENTITY_CHANGED","Identity changed during Push operation")};async function F(i){let c=l();if(!c.sha256&&!globalThis.crypto?.subtle)throw new s("NOT_CONFIGURED","Configure native SHA-256 for this Push host");let u=c.sha256?await c.sha256(Uint8Array.from(i,A=>A.charCodeAt(0))):await Se(i);if(!/^[a-f0-9]{64}$/.test(u))throw new s("INVALID_STATE","Push credential digest is invalid");return u}function p(i){let c=G.parse(i);if(c.installationId.toLowerCase()!==l().installationId.toLowerCase())throw new s("INVALID_RESPONSE","Push response belongs to another installation");return c}async function S(i,c){let u=l(),A={installationId:u.installationId,publicKey:u.publicKey,issuedAt:new Date().toISOString(),...c},w=await u.sign(ne(i,u.scope,A));return{...A,signature:w}}let I=(i,c,u)=>e.requestWithCredential?e.requestWithCredential(i,c,u):e.request(i,c);async function q(){let i=l(),c=o,u=r?await(e.session?.access()??r):null,A=_(i,v=>v),w;if(A.detachSeq!==null){let v=A.detachSeq,V=Z.parse(await S("detach",{sequence:v,platform:i.platform}));try{let k=await e.request("push/installations/detach",{...i.scope,...V},"POST",{installationDetach:!0});if(!k||typeof k!="object"||!("installation"in k))throw new s("INVALID_RESPONSE","Push detach acknowledgement is invalid");let x=p(k.installation);if(x.bound||x.identitySeq!==v)throw new s("INVALID_RESPONSE","Push detach acknowledgement does not match its intent")}catch(k){if(k instanceof s&&k.status===404)w=k;else if(!(k instanceof s)||k.status!==412)throw k}w||_(i,k=>({...k,detachSeq:k.detachSeq===v?null:k.detachSeq}))}if(O(c),!u){if(w)throw w;return null}let C=(await import("./operation-contracts-YJM6772C.js")).apiOperations.bindPushInstallation,D=C.request.parse(await S("bind",{sequence:d,platform:i.platform,credentialDigest:await F(u)}));O(c);let R=C.response.parse(await I(C.path,D,u));O(c);let N=p(R.installation);if(!N.bound||N.identitySeq!==d)throw new s("INVALID_RESPONSE","Push binding acknowledgement does not match its intent");return w&&A.detachSeq!==null&&d>A.detachSeq&&_(i,v=>({...v,detachSeq:v.detachSeq===A.detachSeq?null:v.detachSeq})),N}async function h(){l();let i=o,c=r?await(e.session?.access()??r):null;if(!c)throw new s("NOT_IDENTIFIED","Identify before reading this installation");let u=(await import("./operation-contracts-YJM6772C.js")).apiOperations.readPushInstallation,A=u.request.parse(await S("read",{credentialDigest:await F(c)}));O(i);let w=u.response.parse(await I(u.path,A,c));return O(i),p(w.installation)}function P(i=q){let c=y.catch(()=>{}).then(i);return y=c,c.catch(u=>{try{t?.onError?.(u instanceof Error?u:new Error("Push synchronization failed"))}catch{}}),c}async function E(i,c,u){let A=l(),w=c.identity,C=c.observation,D=r?await(e.session?.access()??r):null;if(O(w),C!==a)throw new s("INVALID_STATE","Push observation changed during recovery");if(!D)throw new s("NOT_IDENTIFIED","Identify before recovering a Push address");if(!i.connectionId||!i.kind||!i.token||!["granted","provisional"].includes(i.permission))throw new s("INVALID_REQUEST","Recovery needs a provider token and notification permission");return await P(async()=>{if(O(w),await q(),O(w),C!==a)throw new s("INVALID_STATE","Push observation changed during recovery");let R=_(A,x=>u?x:{...x,addressSeq:U(x.addressSeq)}),v=await S(u?"recovery_confirm":"recovery_request",{...i,sequence:R.addressSeq,credentialDigest:await F(D),...u?{challenge:u}:{}}),V=u?te.parse(v):ee.parse(v);if(O(w),C!==a)throw new s("INVALID_STATE","Push observation changed during recovery");let k=await I(`push/installations/recovery/${u?"confirm":"request"}`,V,D);if(O(w),C!==a||_(A,x=>x).addressSeq!==R.addressSeq)throw new s("INVALID_STATE","Push observation changed during recovery");if(u){let{apiOperations:x}=await import("./operation-contracts-YJM6772C.js");if(O(w),C!==a||_(A,Oe=>Oe).addressSeq!==R.addressSeq)throw new s("INVALID_STATE","Push observation changed during recovery");let Ae=x.updatePushAddress.response.parse(k),L=p(Ae.installation);if(!L.bound||L.identitySeq!==d||L.addressSeq!==R.addressSeq||L.connectionId!==i.connectionId||L.addressStatus!=="active")throw new s("INVALID_RESPONSE","Push recovery acknowledgement does not match its intent");return L}if(!k||typeof k!="object"||!("recovery"in k))throw new s("INVALID_RESPONSE","Push recovery acknowledgement is invalid");return H.parse(k.recovery)})}return{recoveryObserver(){l();let i={identity:o,observation:++a};return{async request(c){return H.parse(await E(c,i))},async confirm(c,u){return G.parse(await E(u,i,c))}}},identify(i){if(!t)return;d=_(t,u=>({...u,identitySeq:U(u.identitySeq)})).identitySeq,r=i,o++,a++},reset(){if(t)try{_(t,i=>{let c=U(i.identitySeq);return{...i,identitySeq:c,detachSeq:c}})}finally{r=null,o++,a++}},start(){t&&!g&&P()},destroy(){g=!0,r=null,o++,a++},async sync(){return await P()},read:h,async recover(){let i=l(),c=o,u=d;return a++,await P(async()=>{O(c);let A=await h();return O(c),d=_(i,C=>{if(C.identitySeq!==u)throw new s("IDENTITY_CHANGED","A newer installation intent exists");return{...C,identitySeq:U(Math.max(C.identitySeq,A.identitySeq)),addressSeq:Math.max(C.addressSeq,A.addressSeq)}}).identitySeq,await q()})},tokenObserver(){l();let i=++a,c=o;return async u=>{if(i!==a||c!==o)return null;let A=l(),w=r?await(e.session?.access()??r):null;if(!w)throw new s("NOT_IDENTIFIED","Identify before registering a Push token");if(await P(),O(c),i!==a)return null;let C=_(A,v=>({...v,addressSeq:U(v.addressSeq)})),D=(await import("./operation-contracts-YJM6772C.js")).apiOperations.updatePushAddress,R=D.request.parse(await S("address",{...u,sequence:C.addressSeq,credentialDigest:await F(w)}));if(O(c),i!==a)return null;let N=await I(D.path,R,w);return O(c),i!==a||_(A,v=>v).addressSeq!==C.addressSeq?null:p(D.response.parse(N).installation)}}}}function de(t,e){let n={async preference(r){let o=await f(t,"readMessagingPreference");return(await m(t,o,{channel:r})).preference},async setPreference(r){r=b(r);let o=await f(t,"setMessagingPreference");return(await m(t,o,r)).preference}};return{messaging:n,push:{sync:e.sync,read:e.read,recover:e.recover,tokenObserver:e.tokenObserver,recoveryObserver:e.recoveryObserver,async preference(){return n.preference("push")},async setPreference(r){return r=b(r),n.setPreference({...r,channel:"push"})}}}}function le(t,e,n={}){let r=!1;function o(){if(r)throw new s("CLOSED","SDK client was destroyed")}let a=new Set,d=g=>{for(let l of a)try{l(g)}catch{}},y=t.session.subscribeIdentity(()=>{d(!!t.session.peek()),n.afterChange?.()},()=>{e()});return{assertActive:o,isIdentified:()=>!r&&!!t.session.peek(),methods:{subscribeIdentity(g){return o(),a.add(g),()=>{a.delete(g)}},identify(g){o();let l=typeof g=="string"?g:g.accessToken;if(!B.test(l))throw new s("INVALID_TOKEN","Browser SDK requires a customer session");n.beforeIdentify?.(l),t.identify(g)},reset(){if(!r)try{n.beforeReset?.()}finally{t.reset()}},destroy(){if(!r){r=!0,y(),a.clear();try{n.beforeDestroy?.(),e()}finally{t.dispose()}}}}}}function pe(t){return{async checkEntitlement(e){e=b(e),T(e);let n=await f(t,"checkEntitlement"),r=n.request.parse(e),o=await m(t,n,r);return oe(r.requirement,o.check,void 0,o.scope),o},async readHoldings(e={}){e=b(e);let n=await f(t,"readHoldings"),r={...n,request:n.request.omit({customerId:!0})};return m(t,r,e)}}}function fe(t){return{async readLedger(e){e=b(e);let n=await f(t,"readLedger");return m(t,n,{query:e})},async readCreditStatement(e){e=b(e),T(e);let n=await f(t,"readCreditStatement");return m(t,n,e)},async quoteBalance(e){e=b(e),T(e);let n=await f(t,"quoteBalance");return m(t,n,{command:e})}}}function me(t){return{async setupPayment(e){e=b(e),T(e);let n=await f(t,"setupPayment");return m(t,n,e)},async readPaymentSetup(e){e=b(e),T(e);let n=await f(t,"readPaymentSetup");return m(t,n,e)},async readBillingInvoice(e){e=b(e),T(e);let n=await f(t,"readBillingInvoice");return m(t,n,e)},async readBillingControls(e={}){e=b(e),T(e);let n=await f(t,"readBillingControls");return m(t,n,e)},async prepareBillingAuthorization(e){e=b(e),T(e);let n=await f(t,"prepareBillingAuthorization");return m(t,n,e)},async confirmBillingAuthorization(e){e=b(e),T(e);let n=await f(t,"confirmBillingAuthorization");return m(t,n,e)},async setBillingCoupons(e){e=b(e),T(e);let n=await f(t,"setBillingCoupons");return m(t,n,e,{request:"Invalid billing coupon list",response:"Invalid billing coupon receipt"})},async revokeBillingAuthorization(e){e=b(e),T(e);let n=await f(t,"revokeBillingAuthorization");return m(t,n,e)},async listBillingInvoices(e={after:null,limit:25}){e=b(e),T(e);let n=await f(t,"listBillingInvoices");return m(t,n,e)},async confirmBillingAdjustment(e){e=b(e),T(e);let n=await f(t,"confirmBillingAdjustment");return m(t,n,e)}}}function ye(t){return{async redeemReward(e){return e=b(e),T(e),(await m(t,await f(t,"redeemReward"),{...e,requestId:e.requestId??crypto.randomUUID()},{request:"Invalid reward redemption",response:"Invalid reward receipt"})).redemption},async claimRewardProduct(e){return e=b(e),T(e),(await m(t,await f(t,"claimRewardProduct"),e,{request:"Invalid reward product claim",response:"Invalid reward product checkout"})).checkout},async createReferralCode(e){return e=b(e),T(e),(await m(t,await f(t,"createReferralCode"),{...e,requestId:e.requestId??crypto.randomUUID()},{request:"Invalid referral program",response:"Invalid referral code"})).referralCode},async redeemCoupon(e,n=crypto.randomUUID()){typeof e=="string"&&(e=e.trim().toUpperCase());let r=await m(t,await f(t,"redeemCoupon"),{code:e,requestId:n},{request:"Invalid coupon code",response:"Invalid Coupon receipt"});return{offer:r.offer,reason:r.reason}},async claimCoupon(e,n=crypto.randomUUID()){let r=await m(t,await f(t,"grantOffer"),{couponId:e,requestId:n},{request:"Invalid Coupon claim",response:"Invalid Coupon receipt"});return{offer:r.offer,reason:r.reason}},async listOffers(){return(await m(t,await f(t,"listOffers"),{},{response:"Invalid offers response"})).offers}}}function Ie(t){return{...pe(t),...fe(t),...me(t),...se(t),...ye(t)}}function he(t){return{async resolveContent(e){e=b(e),T(e);let n=await f(t,"resolveContent");return m(t,n,e)},async resolvePaywall(e){e=b(e),T(e);let n=await f(t,"resolvePaywall"),r=n.request.parse(e),o=await m(t,n,r);return j(r,o.paywall.check,o.scope),o},async resolveOffering(e){e=b(e),T(e);let n=await f(t,"resolveOffering"),r=n.request.parse(e),o=await m(t,n,r);return j(r,o.check,o.scope),o}}}var Y=t=>new TextEncoder().encode(JSON.stringify(t)).length,we=16384,Pe=5e3,Ce=6e4,Re=5;function Te(t){return t instanceof s&&t.status!==void 0&&t.status>=400&&t.status<500&&!t.retryable}function ge(t,e){let n=0,r,o=h=>{r={config:structuredClone(h),until:Date.now()+3e4}},a=[],d=null,y,g=0;function l(){if(!e())throw new s("NOT_IDENTIFIED","Call identify before using Features or events")}function O(){y||!a.length||!e()||(y=setTimeout(()=>{y=void 0,S().catch(()=>{}).finally(O)},Math.min(Pe*2**g,Ce)),typeof y=="object"&&"unref"in y&&y.unref())}function F(h){if(l(),r&&Date.now()<r.until&&!W(r.config,h.kind))return;q();let P=X.parse({events:[{...h,eventUuid:crypto.randomUUID(),timestamp:new Date().toISOString()}]}).events[0];if(Y({events:[P]})>we)throw new s("INVALID_REQUEST","Event exceeds the delivery size limit");if(a.length>=500)throw new s("EVENT_QUEUE_FULL","Flush pending events before tracking more");a.push(structuredClone(P)),O()}function p(h,P={},E={}){F({kind:"custom",name:h,properties:P,...E})}async function S(h=!1){if(l(),d)return d;let P=n,E=(async()=>{let i={inserted:0,duplicates:0,rejected:0,skipped:0,rejections:[]},c=a.length;for(;c&&P===n;){let u=[],A=Y({events:[]});for(let C of a.slice(0,Math.min(c,100))){let D=Y(C)+(u.length?1:0);if(u.length&&A+D>we)break;u.push(C),A+=D}let w;try{let C=await f(t,"trackEvents");if(w=await m(t,C,{events:u},void 0,{keepalive:h}),P!==n)throw new s("IDENTITY_CHANGED","Event identity changed during delivery");if(w.inserted+w.duplicates+w.rejected+w.skipped!==u.length||w.rejections.length!==w.rejected)throw new s("INVALID_RESPONSE","Incomplete event acknowledgement")}catch(C){throw P===n&&(g++,(Te(C)||g>=Re)&&(a.splice(0,u.length),g=0)),C}g=0,o(w.analyticsConfig),a.splice(0,u.length),c-=u.length,i.inserted+=w.inserted,i.duplicates+=w.duplicates,i.rejected+=w.rejected,i.skipped+=w.skipped,i.rejections.push(...w.rejections)}return i})();d=E;try{return await E}finally{d===E&&(d=null)}}let I;function q(){if(I||typeof document>"u")return;let h=()=>{document.visibilityState==="hidden"&&e()&&a.length&&S(!0).catch(()=>{})};document.addEventListener("visibilitychange",h),I=()=>document.removeEventListener("visibilitychange",h)}return{rememberConfiguration:o,track:p,observe:F,flush:S,reset(){n++,r=void 0,clearTimeout(y),y=void 0,a=[],g=0,d=null},detachVisibility(){I?.(),I=void 0}}}function ve(t){let e=t.merchandise;if(typeof t.merchandiseId=="string")return{internalId:t.merchandiseId};if(!(!e||typeof e!="object"||Array.isArray(e))){if(typeof e.internalId=="string")return{internalId:e.internalId};if(typeof e.externalId=="string")return{id:e.externalId};if(typeof e.id=="string")return{id:e.id}}}var qe=new Set([...$,"merchandiseId","merchandise"]);function ke(t){let e=ve(t);return{...Object.fromEntries(Object.entries(t).filter(([r])=>!qe.has(r))),...e?{merchandise:e}:{}}}function Ee(t,e,n,r,o){if(o&&r&&(o.scope.projectId!==r.projectId||o.scope.environment!==r.environment))throw new s("SCOPE_MISMATCH","Configuration belongs to another App/environment");let a=0,d=new Set;function y(){if(!e())throw new s("NOT_IDENTIFIED","Call identify before using Features or events")}async function g(l={}){o||y();let O=a,F=!1,p=async()=>{if(F||O!==a)throw new s("IDENTITY_CHANGED","Feature identity changed");let R=o?{scope:{projectId:o.scope.projectId,environment:o.scope.environment},payload:await o.features()}:await m(t,await f(t,"getFeatures"),{});if(O!==a)throw new s("IDENTITY_CHANGED","Feature identity changed");if(r&&(R.scope.projectId!==r.projectId||R.scope.environment!==r.environment))throw new s("INVALID_RESPONSE","Feature response scope changed");return n.rememberConfiguration(R.payload.analyticsConfig),R},S=await p(),I=!0,q,h=R=>{try{l.onError?.(R)}catch{}},P=(R,N)=>{try{let v=ve(N);n.observe({...R,...v?{merchandise:v}:{}})}catch(v){h(v)}},E=ae({assertUsable:o?.assertFeatures,scope:S.scope,attributes:l.attributes,onError:l.onError,load:async()=>I?(I=!1,S.payload):(await p()).payload,evaluateRemote:async R=>{if(O!==a)throw new s("IDENTITY_CHANGED","Feature identity changed");let N=await f(t,"evaluateFeatures"),v=await m(t,N,{...R,attributes:ke(R.attributes)});if(v.scope.projectId!==S.scope.projectId||v.scope.environment!==S.scope.environment)throw new s("INVALID_RESPONSE","Remote Feature response scope changed");return{generation:v.generation,evaluatedAt:v.evaluatedAt,expiresAt:v.expiresAt,features:v.features,...v.merchandiseContext?{merchandiseContext:v.merchandiseContext}:{}}},onExperimentViewed:(R,N,v,V)=>P({kind:"experiment_exposure",generation:V,experimentId:R.key,variationId:N.key},v),onFeatureUsage:(R,N,v,V)=>P({kind:"feature_usage",generation:V,feature:R,value:N.value??null,source:N.source,ruleId:N.ruleId,...N.experimentResult?{variationId:N.experimentResult.key}:{}},v)}),i=E.refresh;function c(){clearTimeout(q),!o&&(F||O!==a||!E.expiresAt||(q=setTimeout(()=>{u().catch(h)},Math.min(2147483647,Math.max(1e3,Date.parse(E.expiresAt)-Date.now()))),typeof q=="object"&&"unref"in q&&q.unref()))}async function u(){try{return await i()}finally{c()}}let A=()=>{F||u().catch(h)},w=E.subscribe(c),C=o?.subscribe(()=>{!F&&o.fresh&&u().catch(h)});function D(){F||(F=!0,clearTimeout(q),typeof window<"u"&&window.removeEventListener("focus",A),w(),C?.(),E.reset(),d.delete(D))}d.add(D);try{await E.init(),(l.attributes?.merchandise||l.attributes?.merchandiseId)&&await E.refreshRemote()}catch(R){throw D(),R}return c(),!o&&typeof window<"u"&&window.addEventListener("focus",A),Object.assign(E,{refresh:u,destroy:D})}return{features:g,reset(l){a++,l();for(let O of d)O()}}}function be(t,e){let n="source"in e?{funnelId:e.source.id,funnelVersionId:e.source.versionId}:"versionId"in e?{funnelId:e.funnelId,funnelVersionId:e.versionId}:e,r=K.object({funnelId:J.shape.id,funnelVersionId:J.shape.versionId.optional()}).safeParse(n);if(!r.success)throw new s("INVALID_REQUEST","A valid Funnel source is required");let o=Object.freeze(r.data);function a(d){if("customerId"in d)throw new s("INVALID_REQUEST","Customer identity cannot be overridden");if("funnelId"in d&&d.funnelId!==void 0&&d.funnelId!==o.funnelId||"funnelVersionId"in d&&d.funnelVersionId!==void 0&&d.funnelVersionId!==o.funnelVersionId)throw new s("SCOPE_MISMATCH","The original Funnel source cannot change");return{...d,...o}}return{async claimCoupon(d,y=crypto.randomUUID()){let g=await f(t,"grantOffer"),l=await m(t,g,a({couponId:d,requestId:y}));return{offer:l.offer,reason:l.reason}},async resolveOffering(d){d=b(d);let y=await f(t,"resolveOffering"),g=y.request.parse(a(d)),l=await m(t,y,g);return j(g,l.check,l.scope),l},async resolvePaywall(d){d=b(d);let y=await f(t,"resolvePaywall"),g=y.request.parse(a(d)),l=await m(t,y,g);return j(g,l.paywall.check,l.scope),l},async previewAttach(d){d=b(d);let y=await f(t,"previewAttach");return m(t,y,a(d))}}}function xt(t){return Ne(t)}function Ne(t){let e=ie(t),n=e.request,r;try{r=ue(t.push,e,t.scope??t.configuration?.scope)}catch(y){throw e.dispose(),y}let o=le(e,()=>{d.reset(a.reset),a.detachVisibility()},{beforeIdentify:r.identify,beforeReset:r.reset,afterChange:r.start,beforeDestroy:r.destroy}),a=ge(n,o.isIdentified),d=Ee(n,o.isIdentified,a,t.scope,t.configuration);return{session:e.session,...de(n,r),...Ie(n),...he(n),forFunnel(y){return o.assertActive(),be(n,y)},async features(y={}){return o.assertActive(),d.features(y)},track(y,g,l={}){return a.track(y,g,l)},flush(){return a.flush()},...o.methods}}function Mt(t){if(!B.test(t.customerToken))throw new s("INVALID_TOKEN","A customer credential is required");if(!t.scope)throw new s("INVALID_REQUEST","An explicit App and environment scope is required");let e=ce({...t,scope:t.scope,apiKey:t.customerToken});return{async start(n){let r=await e.start(n),o=M({...t,runToken:r.runToken,initialResponse:r});o.identify(t.customerToken);let a=await o.get();return{...r,...a,controller:o}}}}function Kt(t){if(!t.scope)throw new s("INVALID_CONFIGURATION","An explicit process App/environment scope is required");if(t.session!==void 0)throw new s("INVALID_CONFIGURATION","The merchant process adapter owns the session");let e=null,n,r=0,o=new Set,a=new Map,d=new Map;async function y(p){let S,I=new Promise((q,h)=>{S=setTimeout(()=>h(new s("TIMEOUT","Process bridge request timed out")),t.timeoutMs??35e3)});try{return await Promise.race([Promise.resolve().then(p),I])}finally{clearTimeout(S)}}function g(p){throw p instanceof s&&(p.status===401||p.reason==="CUSTOMER_BINDING_CONFLICT")&&(r++,n?.reset(),n=void 0,e=null,a.clear(),d.clear()),p}function l(p,S){if(S!==r)throw new s("IDENTITY_CHANGED","Process was detached during a request");let I=re.parse(p);if(I.scope.projectId!==t.scope.projectId||I.scope.environment!==t.scope.environment)throw new s("SCOPE_MISMATCH","Process response belongs to another App/environment");if(e&&(e.run.id!==I.run.id||e.run.source.versionId!==I.run.source.versionId||e.run.source.id!==I.run.source.id||e.run.runExpiresAt!==I.run.runExpiresAt||e.run.identity.startedAs!==I.run.identity.startedAs||e.run.identity.participantId!==I.run.identity.participantId||e.run.identity.binding&&I.run.identity.binding&&e.run.identity.binding.id!==I.run.identity.binding.id))throw new s("INVALID_RESPONSE","The process changed its Run or Customer binding");if(!e||I.run.revision>=e.run.revision){if(e?.run.identity.binding&&!I.run.identity.binding)throw new s("INVALID_RESPONSE","The process lost its Customer binding");e=I;for(let A of o)z(A,I.run);I.run.instruction?.type==="authentication_required"&&z(t.onAuthenticationRequired,I.run)}I.settlement?.accepted!==void 0&&d.set(I.settlement.requestId,I.settlement.accepted);let{identity:q,instruction:h,...P}=I.run,{contract:E,settlement:i,...c}=I,u=i&&(({accepted:A,...w})=>w)(i);return{...c,run:{...P,authenticated:q.binding!==null,instruction:h?.type==="authentication_required"?null:h},...u?{settlement:u}:{}}}let O=p=>(a.has(p)||a.set(p,e?.run.identity.binding?.id??null),a.get(p));async function F(p){let S=r,I=e?.run.identity.binding?.id??null,q=P=>{if(I!==(e?.run.identity.binding?.id??null))throw P;return g(P)};if(p.operation==="page_experiments"){if(!t.adapter.pageExperiments)throw new s("CAPABILITY_UNAVAILABLE","Process page experiments are unavailable",501);return y(()=>t.adapter.pageExperiments(p.release,p.usedReceiptIds)).catch(q)}let h;if(p.operation==="get"){let{operation:P,customerToken:E,...i}=p;h=await y(()=>t.adapter.get({...i,...i.settlementRequestId?{settlementBindingId:O(i.settlementRequestId)}:{}})).catch(q)}else if(p.operation==="review")h=await y(()=>t.adapter.review(p.receiptId)).catch(q);else{if(p.operation==="start")throw new s("INVALID_REQUEST","Use process.open for entry");{let{customerToken:P,...E}=p;h=await y(()=>t.adapter.command(E,O(E.requestId))).catch(q)}}return l(h,S)}return{get view(){return e?.run??null},get controller(){return n},async open(p){let S=r,I=await y(()=>t.adapter.open(p)).catch(g),q=l(I,S);if(!n){n=M({...t,runToken:I.runToken,initialResponse:q,process:{request:F,binding:O,restore(E){for(let[i,c]of Object.entries(E))a.set(i,c)}}});let h=n,P=h.submit;h.submit=async E=>{try{return await P(E)}catch(i){if(!(i instanceof s)||i.reason!=="IDENTITY_CONTEXT_CHANGED"||E.operation!=="submit"||E.input.type!=="screen"||a.get(E.requestId)!==null)throw i;await h.settle?.(E.requestId),await h.get();let c=h.view;if(d.get(E.requestId)!==!1||!c||c.id!==e?.run.id||c.nodeId!==E.nodeId||c.visit!==E.visit||!e?.run.identity.binding)throw i;return P({...E,requestId:crypto.randomUUID(),revision:c.revision})}}}await n.get();for(let h of n.pendingCommands??[])a.has(h.requestId)&&a.get(h.requestId)!==(e?.run.identity.binding?.id??null)&&await n.settle?.(h.requestId);return{run:e.run,controller:n}},async syncIdentity(){let p=r;l(await y(()=>t.adapter.syncIdentity()).catch(g),p),await n?.get();for(let S of n?.pendingCommands??[])a.has(S.requestId)&&a.get(S.requestId)!==(e?.run.identity.binding?.id??null)&&await n?.settle?.(S.requestId);return e.run},async detach(){r++,n?.reset(),n=void 0,e=null,a.clear(),d.clear(),await y(()=>t.adapter.detach())},forProcess(p){if(!e?.run.identity.binding)throw new s("UNAUTHENTICATED","Sign in before a commercial operation",401);return{runId:e.run.id,bindingId:e.run.identity.binding.id,receiptId:p}},subscribe(p){return o.add(p),()=>{o.delete(p)}},destroy(){r++,n?.reset(),n=void 0,e=null,a.clear(),d.clear(),o.clear()}}}export{xt as a,Ne as b,Mt as c,Kt as d};
|
|
1
|
+
import{a as T,b as se}from"./chunk-YJHL2DPP.js";import{b as re,h as ae,j as ce}from"./chunk-4CWYR6NX.js";import{E as M,a as J}from"./chunk-BKN33GVY.js";import{a as b,b as f,c as m}from"./chunk-Q2ZKKRIB.js";import{c as Z,e as ee,f as te,g as H,h as G,j as ne}from"./chunk-U3TW2YVO.js";import{a as oe,b as j}from"./chunk-25LM2JXB.js";import{b as W,j as X}from"./chunk-ZBVIIFB4.js";import{n as $}from"./chunk-DGGXLPHI.js";import{b as ie}from"./chunk-TQIZN3GB.js";import{a as B}from"./chunk-FRWORXER.js";import{a as s}from"./chunk-BNVQIMXY.js";import{h as Q}from"./chunk-BJSY53HD.js";import{b as K}from"./chunk-VITB5MIL.js";import{a as z}from"./chunk-DSPLGTQI.js";var U=t=>{if(!Number.isSafeInteger(t)||t<0||t>=Number.MAX_SAFE_INTEGER)throw new s("INVALID_STATE","Installation sequence exhausted");return t+1},Se=async t=>[...new Uint8Array(await crypto.subtle.digest("SHA-256",Uint8Array.from(t,e=>e.charCodeAt(0))))].map(e=>e.toString(16).padStart(2,"0")).join("");function _(t,e){return t.transaction(n=>{if(!Number.isSafeInteger(n.identitySeq)||n.identitySeq<0||!Number.isSafeInteger(n.addressSeq)||n.addressSeq<0||n.detachSeq!==null&&(!Number.isSafeInteger(n.detachSeq)||n.detachSeq<1||n.detachSeq>n.identitySeq))throw new s("INVALID_STATE","Installation journal is invalid");return e({...n})})}function ue(t,e,n){let r=null,o=0,a=0,d=0,y=Promise.resolve(),g=!1;if(t&&(!n||Q.parse(t.scope).projectId!==n.projectId||t.scope.environment!==n.environment))throw new s("SCOPE_MISMATCH","Push installation belongs to another scope");let l=()=>{if(g)throw new s("CLOSED","SDK client was destroyed");if(!t)throw new s("NOT_CONFIGURED","Configure this client's native Push host first");return t},O=i=>{if(i!==o)throw new s("IDENTITY_CHANGED","Identity changed during Push operation")};async function F(i){let c=l();if(!c.sha256&&!globalThis.crypto?.subtle)throw new s("NOT_CONFIGURED","Configure native SHA-256 for this Push host");let u=c.sha256?await c.sha256(Uint8Array.from(i,A=>A.charCodeAt(0))):await Se(i);if(!/^[a-f0-9]{64}$/.test(u))throw new s("INVALID_STATE","Push credential digest is invalid");return u}function p(i){let c=G.parse(i);if(c.installationId.toLowerCase()!==l().installationId.toLowerCase())throw new s("INVALID_RESPONSE","Push response belongs to another installation");return c}async function S(i,c){let u=l(),A={installationId:u.installationId,publicKey:u.publicKey,issuedAt:new Date().toISOString(),...c},w=await u.sign(ne(i,u.scope,A));return{...A,signature:w}}let I=(i,c,u)=>e.requestWithCredential?e.requestWithCredential(i,c,u):e.request(i,c);async function q(){let i=l(),c=o,u=r?await(e.session?.access()??r):null,A=_(i,v=>v),w;if(A.detachSeq!==null){let v=A.detachSeq,V=Z.parse(await S("detach",{sequence:v,platform:i.platform}));try{let k=await e.request("push/installations/detach",{...i.scope,...V},"POST",{installationDetach:!0});if(!k||typeof k!="object"||!("installation"in k))throw new s("INVALID_RESPONSE","Push detach acknowledgement is invalid");let x=p(k.installation);if(x.bound||x.identitySeq!==v)throw new s("INVALID_RESPONSE","Push detach acknowledgement does not match its intent")}catch(k){if(k instanceof s&&k.status===404)w=k;else if(!(k instanceof s)||k.status!==412)throw k}w||_(i,k=>({...k,detachSeq:k.detachSeq===v?null:k.detachSeq}))}if(O(c),!u){if(w)throw w;return null}let C=(await import("./operation-contracts-IAMHNJCL.js")).apiOperations.bindPushInstallation,D=C.request.parse(await S("bind",{sequence:d,platform:i.platform,credentialDigest:await F(u)}));O(c);let R=C.response.parse(await I(C.path,D,u));O(c);let N=p(R.installation);if(!N.bound||N.identitySeq!==d)throw new s("INVALID_RESPONSE","Push binding acknowledgement does not match its intent");return w&&A.detachSeq!==null&&d>A.detachSeq&&_(i,v=>({...v,detachSeq:v.detachSeq===A.detachSeq?null:v.detachSeq})),N}async function h(){l();let i=o,c=r?await(e.session?.access()??r):null;if(!c)throw new s("NOT_IDENTIFIED","Identify before reading this installation");let u=(await import("./operation-contracts-IAMHNJCL.js")).apiOperations.readPushInstallation,A=u.request.parse(await S("read",{credentialDigest:await F(c)}));O(i);let w=u.response.parse(await I(u.path,A,c));return O(i),p(w.installation)}function P(i=q){let c=y.catch(()=>{}).then(i);return y=c,c.catch(u=>{try{t?.onError?.(u instanceof Error?u:new Error("Push synchronization failed"))}catch{}}),c}async function E(i,c,u){let A=l(),w=c.identity,C=c.observation,D=r?await(e.session?.access()??r):null;if(O(w),C!==a)throw new s("INVALID_STATE","Push observation changed during recovery");if(!D)throw new s("NOT_IDENTIFIED","Identify before recovering a Push address");if(!i.connectionId||!i.kind||!i.token||!["granted","provisional"].includes(i.permission))throw new s("INVALID_REQUEST","Recovery needs a provider token and notification permission");return await P(async()=>{if(O(w),await q(),O(w),C!==a)throw new s("INVALID_STATE","Push observation changed during recovery");let R=_(A,x=>u?x:{...x,addressSeq:U(x.addressSeq)}),v=await S(u?"recovery_confirm":"recovery_request",{...i,sequence:R.addressSeq,credentialDigest:await F(D),...u?{challenge:u}:{}}),V=u?te.parse(v):ee.parse(v);if(O(w),C!==a)throw new s("INVALID_STATE","Push observation changed during recovery");let k=await I(`push/installations/recovery/${u?"confirm":"request"}`,V,D);if(O(w),C!==a||_(A,x=>x).addressSeq!==R.addressSeq)throw new s("INVALID_STATE","Push observation changed during recovery");if(u){let{apiOperations:x}=await import("./operation-contracts-IAMHNJCL.js");if(O(w),C!==a||_(A,Oe=>Oe).addressSeq!==R.addressSeq)throw new s("INVALID_STATE","Push observation changed during recovery");let Ae=x.updatePushAddress.response.parse(k),L=p(Ae.installation);if(!L.bound||L.identitySeq!==d||L.addressSeq!==R.addressSeq||L.connectionId!==i.connectionId||L.addressStatus!=="active")throw new s("INVALID_RESPONSE","Push recovery acknowledgement does not match its intent");return L}if(!k||typeof k!="object"||!("recovery"in k))throw new s("INVALID_RESPONSE","Push recovery acknowledgement is invalid");return H.parse(k.recovery)})}return{recoveryObserver(){l();let i={identity:o,observation:++a};return{async request(c){return H.parse(await E(c,i))},async confirm(c,u){return G.parse(await E(u,i,c))}}},identify(i){if(!t)return;d=_(t,u=>({...u,identitySeq:U(u.identitySeq)})).identitySeq,r=i,o++,a++},reset(){if(t)try{_(t,i=>{let c=U(i.identitySeq);return{...i,identitySeq:c,detachSeq:c}})}finally{r=null,o++,a++}},start(){t&&!g&&P()},destroy(){g=!0,r=null,o++,a++},async sync(){return await P()},read:h,async recover(){let i=l(),c=o,u=d;return a++,await P(async()=>{O(c);let A=await h();return O(c),d=_(i,C=>{if(C.identitySeq!==u)throw new s("IDENTITY_CHANGED","A newer installation intent exists");return{...C,identitySeq:U(Math.max(C.identitySeq,A.identitySeq)),addressSeq:Math.max(C.addressSeq,A.addressSeq)}}).identitySeq,await q()})},tokenObserver(){l();let i=++a,c=o;return async u=>{if(i!==a||c!==o)return null;let A=l(),w=r?await(e.session?.access()??r):null;if(!w)throw new s("NOT_IDENTIFIED","Identify before registering a Push token");if(await P(),O(c),i!==a)return null;let C=_(A,v=>({...v,addressSeq:U(v.addressSeq)})),D=(await import("./operation-contracts-IAMHNJCL.js")).apiOperations.updatePushAddress,R=D.request.parse(await S("address",{...u,sequence:C.addressSeq,credentialDigest:await F(w)}));if(O(c),i!==a)return null;let N=await I(D.path,R,w);return O(c),i!==a||_(A,v=>v).addressSeq!==C.addressSeq?null:p(D.response.parse(N).installation)}}}}function de(t,e){let n={async preference(r){let o=await f(t,"readMessagingPreference");return(await m(t,o,{channel:r})).preference},async setPreference(r){r=b(r);let o=await f(t,"setMessagingPreference");return(await m(t,o,r)).preference}};return{messaging:n,push:{sync:e.sync,read:e.read,recover:e.recover,tokenObserver:e.tokenObserver,recoveryObserver:e.recoveryObserver,async preference(){return n.preference("push")},async setPreference(r){return r=b(r),n.setPreference({...r,channel:"push"})}}}}function le(t,e,n={}){let r=!1;function o(){if(r)throw new s("CLOSED","SDK client was destroyed")}let a=new Set,d=g=>{for(let l of a)try{l(g)}catch{}},y=t.session.subscribeIdentity(()=>{d(!!t.session.peek()),n.afterChange?.()},()=>{e()});return{assertActive:o,isIdentified:()=>!r&&!!t.session.peek(),methods:{subscribeIdentity(g){return o(),a.add(g),()=>{a.delete(g)}},identify(g){o();let l=typeof g=="string"?g:g.accessToken;if(!B.test(l))throw new s("INVALID_TOKEN","Browser SDK requires a customer session");n.beforeIdentify?.(l),t.identify(g)},reset(){if(!r)try{n.beforeReset?.()}finally{t.reset()}},destroy(){if(!r){r=!0,y(),a.clear();try{n.beforeDestroy?.(),e()}finally{t.dispose()}}}}}}function pe(t){return{async checkEntitlement(e){e=b(e),T(e);let n=await f(t,"checkEntitlement"),r=n.request.parse(e),o=await m(t,n,r);return oe(r.requirement,o.check,void 0,o.scope),o},async readHoldings(e={}){e=b(e);let n=await f(t,"readHoldings"),r={...n,request:n.request.omit({customerId:!0})};return m(t,r,e)}}}function fe(t){return{async readLedger(e){e=b(e);let n=await f(t,"readLedger");return m(t,n,{query:e})},async readCreditStatement(e){e=b(e),T(e);let n=await f(t,"readCreditStatement");return m(t,n,e)},async quoteBalance(e){e=b(e),T(e);let n=await f(t,"quoteBalance");return m(t,n,{command:e})}}}function me(t){return{async setupPayment(e){e=b(e),T(e);let n=await f(t,"setupPayment");return m(t,n,e)},async readPaymentSetup(e){e=b(e),T(e);let n=await f(t,"readPaymentSetup");return m(t,n,e)},async readBillingInvoice(e){e=b(e),T(e);let n=await f(t,"readBillingInvoice");return m(t,n,e)},async readBillingControls(e={}){e=b(e),T(e);let n=await f(t,"readBillingControls");return m(t,n,e)},async prepareBillingAuthorization(e){e=b(e),T(e);let n=await f(t,"prepareBillingAuthorization");return m(t,n,e)},async confirmBillingAuthorization(e){e=b(e),T(e);let n=await f(t,"confirmBillingAuthorization");return m(t,n,e)},async setBillingCoupons(e){e=b(e),T(e);let n=await f(t,"setBillingCoupons");return m(t,n,e,{request:"Invalid billing coupon list",response:"Invalid billing coupon receipt"})},async revokeBillingAuthorization(e){e=b(e),T(e);let n=await f(t,"revokeBillingAuthorization");return m(t,n,e)},async listBillingInvoices(e={after:null,limit:25}){e=b(e),T(e);let n=await f(t,"listBillingInvoices");return m(t,n,e)},async confirmBillingAdjustment(e){e=b(e),T(e);let n=await f(t,"confirmBillingAdjustment");return m(t,n,e)}}}function ye(t){return{async redeemReward(e){return e=b(e),T(e),(await m(t,await f(t,"redeemReward"),{...e,requestId:e.requestId??crypto.randomUUID()},{request:"Invalid reward redemption",response:"Invalid reward receipt"})).redemption},async claimRewardProduct(e){return e=b(e),T(e),(await m(t,await f(t,"claimRewardProduct"),e,{request:"Invalid reward product claim",response:"Invalid reward product checkout"})).checkout},async createReferralCode(e){return e=b(e),T(e),(await m(t,await f(t,"createReferralCode"),{...e,requestId:e.requestId??crypto.randomUUID()},{request:"Invalid referral program",response:"Invalid referral code"})).referralCode},async redeemCoupon(e,n=crypto.randomUUID()){typeof e=="string"&&(e=e.trim().toUpperCase());let r=await m(t,await f(t,"redeemCoupon"),{code:e,requestId:n},{request:"Invalid coupon code",response:"Invalid Coupon receipt"});return{offer:r.offer,reason:r.reason}},async claimCoupon(e,n=crypto.randomUUID()){let r=await m(t,await f(t,"grantOffer"),{couponId:e,requestId:n},{request:"Invalid Coupon claim",response:"Invalid Coupon receipt"});return{offer:r.offer,reason:r.reason}},async listOffers(){return(await m(t,await f(t,"listOffers"),{},{response:"Invalid offers response"})).offers}}}function Ie(t){return{...pe(t),...fe(t),...me(t),...se(t),...ye(t)}}function he(t){return{async resolveContent(e){e=b(e),T(e);let n=await f(t,"resolveContent");return m(t,n,e)},async resolvePaywall(e){e=b(e),T(e);let n=await f(t,"resolvePaywall"),r=n.request.parse(e),o=await m(t,n,r);return j(r,o.paywall.check,o.scope),o},async resolveOffering(e){e=b(e),T(e);let n=await f(t,"resolveOffering"),r=n.request.parse(e),o=await m(t,n,r);return j(r,o.check,o.scope),o}}}var Y=t=>new TextEncoder().encode(JSON.stringify(t)).length,we=16384,Pe=5e3,Ce=6e4,Re=5;function Te(t){return t instanceof s&&t.status!==void 0&&t.status>=400&&t.status<500&&!t.retryable}function ge(t,e){let n=0,r,o=h=>{r={config:structuredClone(h),until:Date.now()+3e4}},a=[],d=null,y,g=0;function l(){if(!e())throw new s("NOT_IDENTIFIED","Call identify before using Features or events")}function O(){y||!a.length||!e()||(y=setTimeout(()=>{y=void 0,S().catch(()=>{}).finally(O)},Math.min(Pe*2**g,Ce)),typeof y=="object"&&"unref"in y&&y.unref())}function F(h){if(l(),r&&Date.now()<r.until&&!W(r.config,h.kind))return;q();let P=X.parse({events:[{...h,eventUuid:crypto.randomUUID(),timestamp:new Date().toISOString()}]}).events[0];if(Y({events:[P]})>we)throw new s("INVALID_REQUEST","Event exceeds the delivery size limit");if(a.length>=500)throw new s("EVENT_QUEUE_FULL","Flush pending events before tracking more");a.push(structuredClone(P)),O()}function p(h,P={},E={}){F({kind:"custom",name:h,properties:P,...E})}async function S(h=!1){if(l(),d)return d;let P=n,E=(async()=>{let i={inserted:0,duplicates:0,rejected:0,skipped:0,rejections:[]},c=a.length;for(;c&&P===n;){let u=[],A=Y({events:[]});for(let C of a.slice(0,Math.min(c,100))){let D=Y(C)+(u.length?1:0);if(u.length&&A+D>we)break;u.push(C),A+=D}let w;try{let C=await f(t,"trackEvents");if(w=await m(t,C,{events:u},void 0,{keepalive:h}),P!==n)throw new s("IDENTITY_CHANGED","Event identity changed during delivery");if(w.inserted+w.duplicates+w.rejected+w.skipped!==u.length||w.rejections.length!==w.rejected)throw new s("INVALID_RESPONSE","Incomplete event acknowledgement")}catch(C){throw P===n&&(g++,(Te(C)||g>=Re)&&(a.splice(0,u.length),g=0)),C}g=0,o(w.analyticsConfig),a.splice(0,u.length),c-=u.length,i.inserted+=w.inserted,i.duplicates+=w.duplicates,i.rejected+=w.rejected,i.skipped+=w.skipped,i.rejections.push(...w.rejections)}return i})();d=E;try{return await E}finally{d===E&&(d=null)}}let I;function q(){if(I||typeof document>"u")return;let h=()=>{document.visibilityState==="hidden"&&e()&&a.length&&S(!0).catch(()=>{})};document.addEventListener("visibilitychange",h),I=()=>document.removeEventListener("visibilitychange",h)}return{rememberConfiguration:o,track:p,observe:F,flush:S,reset(){n++,r=void 0,clearTimeout(y),y=void 0,a=[],g=0,d=null},detachVisibility(){I?.(),I=void 0}}}function ve(t){let e=t.merchandise;if(typeof t.merchandiseId=="string")return{internalId:t.merchandiseId};if(!(!e||typeof e!="object"||Array.isArray(e))){if(typeof e.internalId=="string")return{internalId:e.internalId};if(typeof e.externalId=="string")return{id:e.externalId};if(typeof e.id=="string")return{id:e.id}}}var qe=new Set([...$,"merchandiseId","merchandise"]);function ke(t){let e=ve(t);return{...Object.fromEntries(Object.entries(t).filter(([r])=>!qe.has(r))),...e?{merchandise:e}:{}}}function Ee(t,e,n,r,o){if(o&&r&&(o.scope.projectId!==r.projectId||o.scope.environment!==r.environment))throw new s("SCOPE_MISMATCH","Configuration belongs to another App/environment");let a=0,d=new Set;function y(){if(!e())throw new s("NOT_IDENTIFIED","Call identify before using Features or events")}async function g(l={}){o||y();let O=a,F=!1,p=async()=>{if(F||O!==a)throw new s("IDENTITY_CHANGED","Feature identity changed");let R=o?{scope:{projectId:o.scope.projectId,environment:o.scope.environment},payload:await o.features()}:await m(t,await f(t,"getFeatures"),{});if(O!==a)throw new s("IDENTITY_CHANGED","Feature identity changed");if(r&&(R.scope.projectId!==r.projectId||R.scope.environment!==r.environment))throw new s("INVALID_RESPONSE","Feature response scope changed");return n.rememberConfiguration(R.payload.analyticsConfig),R},S=await p(),I=!0,q,h=R=>{try{l.onError?.(R)}catch{}},P=(R,N)=>{try{let v=ve(N);n.observe({...R,...v?{merchandise:v}:{}})}catch(v){h(v)}},E=ae({assertUsable:o?.assertFeatures,scope:S.scope,attributes:l.attributes,onError:l.onError,load:async()=>I?(I=!1,S.payload):(await p()).payload,evaluateRemote:async R=>{if(O!==a)throw new s("IDENTITY_CHANGED","Feature identity changed");let N=await f(t,"evaluateFeatures"),v=await m(t,N,{...R,attributes:ke(R.attributes)});if(v.scope.projectId!==S.scope.projectId||v.scope.environment!==S.scope.environment)throw new s("INVALID_RESPONSE","Remote Feature response scope changed");return{generation:v.generation,evaluatedAt:v.evaluatedAt,expiresAt:v.expiresAt,features:v.features,...v.merchandiseContext?{merchandiseContext:v.merchandiseContext}:{}}},onExperimentViewed:(R,N,v,V)=>P({kind:"experiment_exposure",generation:V,experimentId:R.key,variationId:N.key},v),onFeatureUsage:(R,N,v,V)=>P({kind:"feature_usage",generation:V,feature:R,value:N.value??null,source:N.source,ruleId:N.ruleId,...N.experimentResult?{variationId:N.experimentResult.key}:{}},v)}),i=E.refresh;function c(){clearTimeout(q),!o&&(F||O!==a||!E.expiresAt||(q=setTimeout(()=>{u().catch(h)},Math.min(2147483647,Math.max(1e3,Date.parse(E.expiresAt)-Date.now()))),typeof q=="object"&&"unref"in q&&q.unref()))}async function u(){try{return await i()}finally{c()}}let A=()=>{F||u().catch(h)},w=E.subscribe(c),C=o?.subscribe(()=>{!F&&o.fresh&&u().catch(h)});function D(){F||(F=!0,clearTimeout(q),typeof window<"u"&&window.removeEventListener("focus",A),w(),C?.(),E.reset(),d.delete(D))}d.add(D);try{await E.init(),(l.attributes?.merchandise||l.attributes?.merchandiseId)&&await E.refreshRemote()}catch(R){throw D(),R}return c(),!o&&typeof window<"u"&&window.addEventListener("focus",A),Object.assign(E,{refresh:u,destroy:D})}return{features:g,reset(l){a++,l();for(let O of d)O()}}}function be(t,e){let n="source"in e?{funnelId:e.source.id,funnelVersionId:e.source.versionId}:"versionId"in e?{funnelId:e.funnelId,funnelVersionId:e.versionId}:e,r=K.object({funnelId:J.shape.id,funnelVersionId:J.shape.versionId.optional()}).safeParse(n);if(!r.success)throw new s("INVALID_REQUEST","A valid Funnel source is required");let o=Object.freeze(r.data);function a(d){if("customerId"in d)throw new s("INVALID_REQUEST","Customer identity cannot be overridden");if("funnelId"in d&&d.funnelId!==void 0&&d.funnelId!==o.funnelId||"funnelVersionId"in d&&d.funnelVersionId!==void 0&&d.funnelVersionId!==o.funnelVersionId)throw new s("SCOPE_MISMATCH","The original Funnel source cannot change");return{...d,...o}}return{async claimCoupon(d,y=crypto.randomUUID()){let g=await f(t,"grantOffer"),l=await m(t,g,a({couponId:d,requestId:y}));return{offer:l.offer,reason:l.reason}},async resolveOffering(d){d=b(d);let y=await f(t,"resolveOffering"),g=y.request.parse(a(d)),l=await m(t,y,g);return j(g,l.check,l.scope),l},async resolvePaywall(d){d=b(d);let y=await f(t,"resolvePaywall"),g=y.request.parse(a(d)),l=await m(t,y,g);return j(g,l.paywall.check,l.scope),l},async previewAttach(d){d=b(d);let y=await f(t,"previewAttach");return m(t,y,a(d))}}}function xt(t){return Ne(t)}function Ne(t){let e=ie(t),n=e.request,r;try{r=ue(t.push,e,t.scope??t.configuration?.scope)}catch(y){throw e.dispose(),y}let o=le(e,()=>{d.reset(a.reset),a.detachVisibility()},{beforeIdentify:r.identify,beforeReset:r.reset,afterChange:r.start,beforeDestroy:r.destroy}),a=ge(n,o.isIdentified),d=Ee(n,o.isIdentified,a,t.scope,t.configuration);return{session:e.session,...de(n,r),...Ie(n),...he(n),forFunnel(y){return o.assertActive(),be(n,y)},async features(y={}){return o.assertActive(),d.features(y)},track(y,g,l={}){return a.track(y,g,l)},flush(){return a.flush()},...o.methods}}function Mt(t){if(!B.test(t.customerToken))throw new s("INVALID_TOKEN","A customer credential is required");if(!t.scope)throw new s("INVALID_REQUEST","An explicit App and environment scope is required");let e=ce({...t,scope:t.scope,apiKey:t.customerToken});return{async start(n){let r=await e.start(n),o=M({...t,runToken:r.runToken,initialResponse:r});o.identify(t.customerToken);let a=await o.get();return{...r,...a,controller:o}}}}function Kt(t){if(!t.scope)throw new s("INVALID_CONFIGURATION","An explicit process App/environment scope is required");if(t.session!==void 0)throw new s("INVALID_CONFIGURATION","The merchant process adapter owns the session");let e=null,n,r=0,o=new Set,a=new Map,d=new Map;async function y(p){let S,I=new Promise((q,h)=>{S=setTimeout(()=>h(new s("TIMEOUT","Process bridge request timed out")),t.timeoutMs??35e3)});try{return await Promise.race([Promise.resolve().then(p),I])}finally{clearTimeout(S)}}function g(p){throw p instanceof s&&(p.status===401||p.reason==="CUSTOMER_BINDING_CONFLICT")&&(r++,n?.reset(),n=void 0,e=null,a.clear(),d.clear()),p}function l(p,S){if(S!==r)throw new s("IDENTITY_CHANGED","Process was detached during a request");let I=re.parse(p);if(I.scope.projectId!==t.scope.projectId||I.scope.environment!==t.scope.environment)throw new s("SCOPE_MISMATCH","Process response belongs to another App/environment");if(e&&(e.run.id!==I.run.id||e.run.source.versionId!==I.run.source.versionId||e.run.source.id!==I.run.source.id||e.run.runExpiresAt!==I.run.runExpiresAt||e.run.identity.startedAs!==I.run.identity.startedAs||e.run.identity.participantId!==I.run.identity.participantId||e.run.identity.binding&&I.run.identity.binding&&e.run.identity.binding.id!==I.run.identity.binding.id))throw new s("INVALID_RESPONSE","The process changed its Run or Customer binding");if(!e||I.run.revision>=e.run.revision){if(e?.run.identity.binding&&!I.run.identity.binding)throw new s("INVALID_RESPONSE","The process lost its Customer binding");e=I;for(let A of o)z(A,I.run);I.run.instruction?.type==="authentication_required"&&z(t.onAuthenticationRequired,I.run)}I.settlement?.accepted!==void 0&&d.set(I.settlement.requestId,I.settlement.accepted);let{identity:q,instruction:h,...P}=I.run,{contract:E,settlement:i,...c}=I,u=i&&(({accepted:A,...w})=>w)(i);return{...c,run:{...P,authenticated:q.binding!==null,instruction:h?.type==="authentication_required"?null:h},...u?{settlement:u}:{}}}let O=p=>(a.has(p)||a.set(p,e?.run.identity.binding?.id??null),a.get(p));async function F(p){let S=r,I=e?.run.identity.binding?.id??null,q=P=>{if(I!==(e?.run.identity.binding?.id??null))throw P;return g(P)};if(p.operation==="page_experiments"){if(!t.adapter.pageExperiments)throw new s("CAPABILITY_UNAVAILABLE","Process page experiments are unavailable",501);return y(()=>t.adapter.pageExperiments(p.release,p.usedReceiptIds)).catch(q)}let h;if(p.operation==="get"){let{operation:P,customerToken:E,...i}=p;h=await y(()=>t.adapter.get({...i,...i.settlementRequestId?{settlementBindingId:O(i.settlementRequestId)}:{}})).catch(q)}else if(p.operation==="review")h=await y(()=>t.adapter.review(p.receiptId)).catch(q);else{if(p.operation==="start")throw new s("INVALID_REQUEST","Use process.open for entry");{let{customerToken:P,...E}=p;h=await y(()=>t.adapter.command(E,O(E.requestId))).catch(q)}}return l(h,S)}return{get view(){return e?.run??null},get controller(){return n},async open(p){let S=r,I=await y(()=>t.adapter.open(p)).catch(g),q=l(I,S);if(!n){n=M({...t,runToken:I.runToken,initialResponse:q,process:{request:F,binding:O,restore(E){for(let[i,c]of Object.entries(E))a.set(i,c)}}});let h=n,P=h.submit;h.submit=async E=>{try{return await P(E)}catch(i){if(!(i instanceof s)||i.reason!=="IDENTITY_CONTEXT_CHANGED"||E.operation!=="submit"||E.input.type!=="screen"||a.get(E.requestId)!==null)throw i;await h.settle?.(E.requestId),await h.get();let c=h.view;if(d.get(E.requestId)!==!1||!c||c.id!==e?.run.id||c.nodeId!==E.nodeId||c.visit!==E.visit||!e?.run.identity.binding)throw i;return P({...E,requestId:crypto.randomUUID(),revision:c.revision})}}}await n.get();for(let h of n.pendingCommands??[])a.has(h.requestId)&&a.get(h.requestId)!==(e?.run.identity.binding?.id??null)&&await n.settle?.(h.requestId);return{run:e.run,controller:n}},async syncIdentity(){let p=r;l(await y(()=>t.adapter.syncIdentity()).catch(g),p),await n?.get();for(let S of n?.pendingCommands??[])a.has(S.requestId)&&a.get(S.requestId)!==(e?.run.identity.binding?.id??null)&&await n?.settle?.(S.requestId);return e.run},async detach(){r++,n?.reset(),n=void 0,e=null,a.clear(),d.clear(),await y(()=>t.adapter.detach())},forProcess(p){if(!e?.run.identity.binding)throw new s("UNAUTHENTICATED","Sign in before a commercial operation",401);return{runId:e.run.id,bindingId:e.run.identity.binding.id,receiptId:p}},subscribe(p){return o.add(p),()=>{o.delete(p)}},destroy(){r++,n?.reset(),n=void 0,e=null,a.clear(),d.clear(),o.clear()}}}export{xt as a,Ne as b,Mt as c,Kt as d};
|
|
@@ -1 +1 @@
|
|
|
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-FWQO3IKX.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-FRWORXER.js";import{a as P}from"./chunk-BNVQIMXY.js";import{a as BA,c as jA,d as xA,e as MA,f as UA,h as sA}from"./chunk-BJSY53HD.js";import{a as zA}from"./chunk-KHJZA73V.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{b as e}from"./chunk-
|
|
1
|
+
import{b as e}from"./chunk-VITB5MIL.js";var r=e.number().int().min(1).max(Number.MAX_SAFE_INTEGER),m=e.enum(["unknown","denied","provisional","granted"]),d=e.enum(["ios","android"]),i=e.strictObject({installationId:e.uuid(),publicKey:e.string().regex(/^[A-Za-z0-9_-]{80,200}$/),issuedAt:e.iso.datetime({offset:!0}),signature:e.string().regex(/^[A-Za-z0-9_-]{86}$/)}),a=e.string().regex(/^[a-f0-9]{64}$/),p=i.extend({sequence:r,platform:d,credentialDigest:a}),f=i.extend({credentialDigest:a}),x=i.extend({sequence:r,platform:d}),l=i.extend({sequence:r,credentialDigest:a,connectionId:e.uuid().nullable(),kind:e.enum(["fcm_token","apns_token"]).nullable(),token:e.string().regex(/^[\x21-\x7e]{16,4096}$/).nullable(),permission:m}),g=l,b=l.extend({challenge:e.string().regex(/^[A-Za-z0-9_-]{100,3500}$/)}),S=e.strictObject({requested:e.literal(!0),expiresAt:e.iso.datetime({offset:!0})}),A=e.strictObject({installationId:e.uuid(),bound:e.boolean(),identitySeq:r,bindingGeneration:r,addressSeq:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),addressRevision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),connectionId:e.uuid().nullable(),addressStatus:e.enum(["active","invalid"]).nullable(),permission:m}),I=e.strictObject({channel:e.enum(["email","sms","voice","push"]),state:e.enum(["unknown","allowed","denied"]),revision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER),updatedAt:e.iso.datetime({offset:!0}).nullable()}),P=e.strictObject({state:e.enum(["allowed","denied"]),revision:e.number().int().min(0).max(Number.MAX_SAFE_INTEGER-1)});function y(s,c,t){let n=["indiana_push_v1",s,c.projectId,c.environment,t.installationId,t.publicKey,t.issuedAt];s==="bind"?n.push(t.sequence,t.platform,t.credentialDigest):s==="detach"?n.push(t.sequence,t.platform):s==="read"?n.push(t.credentialDigest):n.push(t.sequence,t.credentialDigest,t.connectionId,t.kind,t.token,t.permission),s==="recovery_confirm"&&n.push(t.challenge);let u=JSON.stringify(n);if([...u].some(o=>o.charCodeAt(0)>127))throw new Error("Push proof fields must be ASCII");return Uint8Array.from(u,o=>o.charCodeAt(0))}export{p as a,f as b,x as c,l as d,g as e,b as f,S as g,A as h,I as i,y as j};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as B}from"./chunk-AEQUKR4O.js";import{b as Y}from"./chunk-Y55OBV7D.js";import{c as W,e as X,f as Z,g as $,h as ee,i as te}from"./chunk-MOIVJERE.js";import{K as L}from"./chunk-ME6QTD5Y.js";import{b as J}from"./chunk-6XRQR43F.js";import{B as V}from"./chunk-3532HSBP.js";import{x as H}from"./chunk-67WFVDTV.js";import{t as z}from"./chunk-Y3W5G4BF.js";import{a as u}from"./chunk-UGATOG2T.js";import{a as K}from"./chunk-DSPLGTQI.js";async function ye(r){let{session:f,load:d}=ie(r);try{return await d(),f}catch(h){throw f.destroy(),h}}function ie(r){let f=r.view;if(!f?.paywall)throw new u("INVALID_REQUEST","The current node is not a Paywall");let d=f.paywall.receiptId,h=f.nodeId,E=f.visit,R=f.paywall.resolution,n=f.paywall,N="document"in R?{document:R.document,offering:R.offering,capabilities:R.capabilities}:null;function D(){let e=n.resolution;return"document"in e?e:N&&{...e,document:N.document,offering:N.offering,capabilities:W(e.capabilities,N.capabilities)}}function F(e){if(!X(e,R))throw new u("INVALID_RESPONSE","The pinned Paywall binding changed")}let p=!1,A=new Set,_=null;function G(){let e=D();if(e&&!p)for(let o of A)K(o,structuredClone(e))}async function M(){b();let e=D();if(e)return structuredClone(e);if(!_){let o=(async()=>{if("document"in n.resolution||!r.resolvePaywall)throw new u("INVALID_RESPONSE","Public Paywall reader is unavailable");let s=await B(r,n.resolution);return b(),F(s),N={document:s.document,offering:s.offering,capabilities:s.capabilities},G(),D()})();_=o;let t=()=>{_===o&&(_=null)};o.then(t,t)}return _.then(o=>structuredClone(o))}let q=new AbortController,m=(r.pendingCommands??(r.pendingCommand?[r.pendingCommand]:[])).find(e=>e.operation==="submit"&&e.nodeId===h&&e.visit===E&&e.input.type==="paywall_quote")?.requestId??f.paywall.purchaseRequestId,C=0,g=null,T=new Set,I=null,v=new Map;function U(e){if(e.purchase&&e.purchase.receiptId!==d)throw new u("INVALID_RESPONSE","Purchase receipt changed");let o=e.run.paywall;return e.purchase??(o?.receiptId===d?o:null)}function b(){if(p)throw new u("IDENTITY_CHANGED","Paywall presentation has closed")}function S(e,o,t){if(b(),o!==C||t!==void 0&&n.quote?.operationId!==t)return!1;let s=n.selectionGeneration??0,i=e.run.paywall;if(i?.receiptId===d){if((i.selectionGeneration??0)<(n.selectionGeneration??0))return!1;F(i.resolution)}let a=U(e),c=i?.receiptId===d&&(i.selectionGeneration??0)>s,l=c?a?.quote??null:a?.quote??n.quote,y=a?.operation??(l?.operationId===n.quote?.operationId?n.operation:null);return n.quote&&l&&ee(n.quote,l),l&&y&&Z(y,{operationId:l.operationId,membershipId:V(l)?l.membershipId:null,...V(l)?{featureQuantities:l.featureQuantities??{}}:{}},"Purchase operation changed"),(c||l?.operationId!==n.quote?.operationId)&&(C++,i?.receiptId===d&&(m=i.purchaseRequestId)),i?.canReselect===!0&&i.purchaseRequestId===I&&!(r.pendingCommands??[r.pendingCommand]).some(w=>w?.requestId===I)&&(I=null),n={...n,...i?.receiptId===d?i:{},...t!==void 0&&!c&&a?.canReselect!==void 0?{canReselect:a.canReselect}:{},quote:l,operation:te(n.operation,y,!0)},G(),!0}function O(e,o,t){return new Promise((s,i)=>{let a=!1,c=()=>{clearTimeout(P),q.signal.removeEventListener("abort",w)},l=Q=>{a||(a=!0,c(),s(Q))},y=Q=>{a||(a=!0,c(),i(Q))},w=()=>y(new u("IDENTITY_CHANGED","Paywall presentation has closed")),P=setTimeout(()=>y(new u("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,t)),Math.max(0,o-Date.now()));q.signal.addEventListener("abort",w,{once:!0}),q.signal.aborted&&w(),e.then(l,y)})}function ne(e){return new Promise(o=>{let t=()=>{clearTimeout(s),q.signal.removeEventListener("abort",t),o()},s=setTimeout(t,e);q.signal.addEventListener("abort",t,{once:!0}),q.signal.aborted&&t()})}function j(e,o){b();let t=v.get(e)??r.pendingCommands?.find(a=>a.requestId===e)??r.pendingCommand;if(t?.operation==="submit"&&t.requestId===e&&t.nodeId===h&&t.visit===E){o.type==="paywall_quote"&&t.input.type==="paywall_quote"&&t.input.predecessor&&!o.predecessor&&(o={...o,predecessor:t.input.predecessor});let a=L.parse(t),c=L.parse({...t,input:o});if(a.operation!=="submit"||c.operation!=="submit"||JSON.stringify(a.input)!==JSON.stringify(c.input))throw new u("CONFLICT","A purchase request cannot change its input");return v.set(e,a),a}let s=r.view;if(!s||s.nodeId!==h||s.visit!==E||s.paywall?.receiptId!==d)throw new u("PRECONDITION_FAILED","The Paywall visit has changed");let i=L.parse({operation:"submit",requestId:e,nodeId:h,visit:E,revision:s.revision,input:structuredClone(o)});if(i.operation!=="submit")throw new u("INVALID_REQUEST","A purchase submission is required");return v.set(e,i),i}async function x(e,o){b();let{requestId:t,input:s}=e,i=Date.now()+3e4;T.add(t);try{let a=await O(r.submit(e),i,t);for(;a.run.pendingRequest?.requestId===t&&Date.now()<i&&!p&&(await ne(Math.min(1e3,i-Date.now())),!(p||Date.now()>=i));)a=await O(r.resume(t),i,t);if(p)throw new u("IDENTITY_CHANGED","Paywall presentation has closed");if(a.run.pendingRequest?.requestId===t)throw new u("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,t);if(!S(a,o,s.type==="paywall_confirm"||s.type==="paywall_cancel"?s.operationId:void 0))throw new u("PRECONDITION_FAILED","The purchase selection has changed");I===t&&(I=null)}catch(a){if(I=t,s.type==="paywall_quote"&&r.settle&&!p&&a instanceof u&&a.status!==void 0&&![401,425].includes(a.status)&&!a.retryable&&a.recovery!=="recover_operation")try{if((await O(r.settle(t),i,t)).settlement?.state==="settled"){let l=await O(r.get(),i,t);S(l,o)&&l.run.paywall?.purchaseRequestId===t&&n.canReselect===!0&&v.delete(t)}}catch{}throw a instanceof u&&a.code==="COMMAND_PENDING"&&a.status===void 0&&v.delete(t),a}finally{T.delete(t)}}async function k(e){if(!n.quote)throw new u("INVALID_REQUEST","A quoted purchase is required");let o=e==="confirm"?"paywall_confirm":"paywall_cancel",t=[...v.values(),...r.pendingCommands??(r.pendingCommand?[r.pendingCommand]:[])].find(i=>i.operation==="submit"&&i.input.type===o&&"operationId"in i.input&&i.input.operationId===n.quote.operationId),s=t?.operation==="submit"&&t.input.type===o&&"operationId"in t.input&&t.input.operationId===n.quote.operationId?t.requestId:crypto.randomUUID();if(await x(j(s,{type:e==="confirm"?"paywall_confirm":"paywall_cancel",operationId:n.quote.operationId,...e==="confirm"&&n.quote.merchantTerms?{merchantConfirmation:H(n.quote.merchantTerms)}:{}}),C),!n.operation)throw new u("INVALID_RESPONSE","The accepted purchase result is missing");return structuredClone(n.operation)}let oe={get supportsHostedCheckout(){return!m&&!n.operation&&(n.selectionGeneration??0)===0},get view(){return structuredClone(D())},get quote(){return n.quote?structuredClone(n.quote):null},get operation(){return n.operation?structuredClone(n.operation):null},get webViewUrl(){return r.webViewUrl},get locale(){return r.view?.locale??f.locale},get canReselect(){return n.canReselect===!0&&I===null},get recovery(){let e=r.pendingCommands??(r.pendingCommand?[r.pendingCommand]:[]),o=r.pendingPurchase;if(o&&(o.receiptId!==d||o.operationId!==n.quote?.operationId))return{type:"recover",operationId:o.operationId,requestId:e[0]?.requestId??null};let t=Y({quote:n.quote,operation:n.operation,requestId:e[0]?.requestId??I??m,pending:T.size>0||e.length>0||I!==null,destroyed:p,canReselect:n.canReselect});return t.type==="recover"&&t.requestId===null&&!p&&r.hasDurableJournal===!0&&!n.quote&&!n.operation&&(n.selectionGeneration??0)===0&&!o&&!e.length&&!T.size&&!m?{type:"native",operationId:null}:t},get pendingCancellation(){return!p&&(r.pendingCommands??(r.pendingCommand?[r.pendingCommand]:[])).some(e=>e.operation==="submit"&&e.nodeId===h&&e.visit===E&&e.input.type==="paywall_cancel"&&e.input.operationId===n.quote?.operationId)},subscribe(e){return p?()=>{}:(A.add(e),()=>A.delete(e))},async refresh(){b();let e=C,o=await r.get();if(S(o,e),o.run.paywall?.receiptId!==d)throw new u("PRECONDITION_FAILED","Paywall presentation has changed");return M()},preview(e){let o=D();if(!o)return Promise.reject(new u("PRECONDITION_FAILED","Load the Paywall presentation first"));if(m&&m!==e.requestId&&(g||n.canReselect!==!0))return Promise.reject(new u("COMMAND_PENDING","Retry the original purchase before starting another"));let t=o.document.buttons[e.actionId],s=t?.type==="checkout"?J(t.product,e.selection,o.capabilities):null;if(!s)return Promise.reject(new u("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));let i=z(o.document.screen,s,e.selection,o.capabilities),a=m!==e.requestId&&(n.selectionGeneration??0)>0?{operationId:n.quote?.operationId??null,generation:n.selectionGeneration??0}:void 0,c=r.view?.parameters.commerce;if(c&&typeof c=="object"&&!Array.isArray(c)&&c.intent==="subscription_change"&&!e.subscriptionChange)return Promise.reject(new u("INVALID_REQUEST","Choose the existing membership for this subscription change"));if(e.subscriptionChange&&e.nativeOffer)return Promise.reject(new u("INVALID_REQUEST","A web membership change cannot include a store offer"));if(a&&n.canReselect!==!0)return Promise.reject(new u("COMMAND_PENDING","Original purchase requires authoritative termination"));let l;try{l=j(e.requestId,{type:"paywall_quote",...e.acceptHostedMonthly===void 0?{}:{acceptHostedMonthly:e.acceptHostedMonthly},actionId:e.actionId,productVersionId:s,...Object.keys(i).length?{featureQuantities:i}:{},...a?{predecessor:a}:{},...e.offerId?{offerId:e.offerId}:{},...e.nativeOffer?{nativeOffer:e.nativeOffer}:{},...e.subscriptionChange?{subscriptionChange:e.subscriptionChange}:{}})}catch(P){return Promise.reject(P)}if(m===e.requestId&&g)return g;m!==e.requestId&&C++;let y=C;m=e.requestId;let w=(async()=>{if(await x(l,y),!n.quote)throw new u("INVALID_RESPONSE","The accepted quote is missing");return $(n.quote,{productVersionId:s,featureQuantities:i,subscriptionChange:e.subscriptionChange},"The selected purchase changed"),structuredClone(n.quote)})();return g=w,w.then(()=>{g===w&&(g=null)},P=>{g===w&&(g=null),m===e.requestId&&r.pendingCommand?.requestId!==e.requestId&&P instanceof u&&P.status!==void 0&&P.status<500&&![401,425].includes(P.status)&&(m=null)}),w},confirm:()=>k("confirm"),cancel:()=>k("cancel"),async read(){if(b(),!n.quote)throw new u("INVALID_REQUEST","A quoted purchase is required");let e=n.quote.operationId,o=C,t=r.pendingCommands?.find(l=>l.operation==="submit"&&(l.input.type==="paywall_confirm"||l.input.type==="paywall_cancel")&&l.input.operationId===e)??r.pendingCommand;t?.operation==="submit"&&(t.input.type==="paywall_confirm"||t.input.type==="paywall_cancel")&&t.input.operationId===e&&await r.settle?.(t.requestId);let s=await r.get(void 0,{receiptId:d,operationId:e});b();let i=U(s);if(i?.quote&&i.quote.operationId!==e||i?.operation&&i.operation.operationId!==e)throw new u("INVALID_RESPONSE","Purchase operation changed");let a=S(s,o,e),c=a?n.operation:i?.operation;if(!c)throw new u("INVALID_RESPONSE","The current purchase result is missing");return a&&T.size===0&&!(r.pendingCommands?.length??(r.pendingCommand?1:0))&&(I=null),structuredClone(c)},destroy(){p=!0,re(),A.clear(),q.abort(),v.clear()}},re=r.subscribe(e=>{p||e.nodeId!==h||e.visit!==E||e.paywall?.receiptId!==d||(e.paywall.selectionGeneration??0)<(n.selectionGeneration??0)||(F(e.paywall.resolution),n={...n,resolution:e.paywall.resolution},G())});return{session:oe,load:M}}export{ye as a};
|
|
1
|
+
import{b as B}from"./chunk-AEQUKR4O.js";import{b as Y}from"./chunk-TG7FSNRF.js";import{c as W,e as X,f as Z,g as $,h as ee,i as te}from"./chunk-VJXGTINT.js";import{K as L}from"./chunk-DGGXLPHI.js";import{b as J}from"./chunk-R6NVHYXW.js";import{B as V}from"./chunk-3QRVHAWK.js";import{x as H}from"./chunk-HJLZY2VK.js";import{t as z}from"./chunk-YBDTPMGD.js";import{a as u}from"./chunk-BNVQIMXY.js";import{a as K}from"./chunk-DSPLGTQI.js";async function ye(r){let{session:f,load:d}=ie(r);try{return await d(),f}catch(h){throw f.destroy(),h}}function ie(r){let f=r.view;if(!f?.paywall)throw new u("INVALID_REQUEST","The current node is not a Paywall");let d=f.paywall.receiptId,h=f.nodeId,E=f.visit,R=f.paywall.resolution,n=f.paywall,N="document"in R?{document:R.document,offering:R.offering,capabilities:R.capabilities}:null;function D(){let e=n.resolution;return"document"in e?e:N&&{...e,document:N.document,offering:N.offering,capabilities:W(e.capabilities,N.capabilities)}}function F(e){if(!X(e,R))throw new u("INVALID_RESPONSE","The pinned Paywall binding changed")}let p=!1,A=new Set,_=null;function G(){let e=D();if(e&&!p)for(let o of A)K(o,structuredClone(e))}async function M(){b();let e=D();if(e)return structuredClone(e);if(!_){let o=(async()=>{if("document"in n.resolution||!r.resolvePaywall)throw new u("INVALID_RESPONSE","Public Paywall reader is unavailable");let s=await B(r,n.resolution);return b(),F(s),N={document:s.document,offering:s.offering,capabilities:s.capabilities},G(),D()})();_=o;let t=()=>{_===o&&(_=null)};o.then(t,t)}return _.then(o=>structuredClone(o))}let q=new AbortController,m=(r.pendingCommands??(r.pendingCommand?[r.pendingCommand]:[])).find(e=>e.operation==="submit"&&e.nodeId===h&&e.visit===E&&e.input.type==="paywall_quote")?.requestId??f.paywall.purchaseRequestId,C=0,g=null,T=new Set,I=null,v=new Map;function U(e){if(e.purchase&&e.purchase.receiptId!==d)throw new u("INVALID_RESPONSE","Purchase receipt changed");let o=e.run.paywall;return e.purchase??(o?.receiptId===d?o:null)}function b(){if(p)throw new u("IDENTITY_CHANGED","Paywall presentation has closed")}function S(e,o,t){if(b(),o!==C||t!==void 0&&n.quote?.operationId!==t)return!1;let s=n.selectionGeneration??0,i=e.run.paywall;if(i?.receiptId===d){if((i.selectionGeneration??0)<(n.selectionGeneration??0))return!1;F(i.resolution)}let a=U(e),c=i?.receiptId===d&&(i.selectionGeneration??0)>s,l=c?a?.quote??null:a?.quote??n.quote,y=a?.operation??(l?.operationId===n.quote?.operationId?n.operation:null);return n.quote&&l&&ee(n.quote,l),l&&y&&Z(y,{operationId:l.operationId,membershipId:V(l)?l.membershipId:null,...V(l)?{featureQuantities:l.featureQuantities??{}}:{}},"Purchase operation changed"),(c||l?.operationId!==n.quote?.operationId)&&(C++,i?.receiptId===d&&(m=i.purchaseRequestId)),i?.canReselect===!0&&i.purchaseRequestId===I&&!(r.pendingCommands??[r.pendingCommand]).some(w=>w?.requestId===I)&&(I=null),n={...n,...i?.receiptId===d?i:{},...t!==void 0&&!c&&a?.canReselect!==void 0?{canReselect:a.canReselect}:{},quote:l,operation:te(n.operation,y,!0)},G(),!0}function O(e,o,t){return new Promise((s,i)=>{let a=!1,c=()=>{clearTimeout(P),q.signal.removeEventListener("abort",w)},l=Q=>{a||(a=!0,c(),s(Q))},y=Q=>{a||(a=!0,c(),i(Q))},w=()=>y(new u("IDENTITY_CHANGED","Paywall presentation has closed")),P=setTimeout(()=>y(new u("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,t)),Math.max(0,o-Date.now()));q.signal.addEventListener("abort",w,{once:!0}),q.signal.aborted&&w(),e.then(l,y)})}function ne(e){return new Promise(o=>{let t=()=>{clearTimeout(s),q.signal.removeEventListener("abort",t),o()},s=setTimeout(t,e);q.signal.addEventListener("abort",t,{once:!0}),q.signal.aborted&&t()})}function j(e,o){b();let t=v.get(e)??r.pendingCommands?.find(a=>a.requestId===e)??r.pendingCommand;if(t?.operation==="submit"&&t.requestId===e&&t.nodeId===h&&t.visit===E){o.type==="paywall_quote"&&t.input.type==="paywall_quote"&&t.input.predecessor&&!o.predecessor&&(o={...o,predecessor:t.input.predecessor});let a=L.parse(t),c=L.parse({...t,input:o});if(a.operation!=="submit"||c.operation!=="submit"||JSON.stringify(a.input)!==JSON.stringify(c.input))throw new u("CONFLICT","A purchase request cannot change its input");return v.set(e,a),a}let s=r.view;if(!s||s.nodeId!==h||s.visit!==E||s.paywall?.receiptId!==d)throw new u("PRECONDITION_FAILED","The Paywall visit has changed");let i=L.parse({operation:"submit",requestId:e,nodeId:h,visit:E,revision:s.revision,input:structuredClone(o)});if(i.operation!=="submit")throw new u("INVALID_REQUEST","A purchase submission is required");return v.set(e,i),i}async function x(e,o){b();let{requestId:t,input:s}=e,i=Date.now()+3e4;T.add(t);try{let a=await O(r.submit(e),i,t);for(;a.run.pendingRequest?.requestId===t&&Date.now()<i&&!p&&(await ne(Math.min(1e3,i-Date.now())),!(p||Date.now()>=i));)a=await O(r.resume(t),i,t);if(p)throw new u("IDENTITY_CHANGED","Paywall presentation has closed");if(a.run.pendingRequest?.requestId===t)throw new u("COMMAND_PENDING","The purchase command is still pending; retry the original request",202,t);if(!S(a,o,s.type==="paywall_confirm"||s.type==="paywall_cancel"?s.operationId:void 0))throw new u("PRECONDITION_FAILED","The purchase selection has changed");I===t&&(I=null)}catch(a){if(I=t,s.type==="paywall_quote"&&r.settle&&!p&&a instanceof u&&a.status!==void 0&&![401,425].includes(a.status)&&!a.retryable&&a.recovery!=="recover_operation")try{if((await O(r.settle(t),i,t)).settlement?.state==="settled"){let l=await O(r.get(),i,t);S(l,o)&&l.run.paywall?.purchaseRequestId===t&&n.canReselect===!0&&v.delete(t)}}catch{}throw a instanceof u&&a.code==="COMMAND_PENDING"&&a.status===void 0&&v.delete(t),a}finally{T.delete(t)}}async function k(e){if(!n.quote)throw new u("INVALID_REQUEST","A quoted purchase is required");let o=e==="confirm"?"paywall_confirm":"paywall_cancel",t=[...v.values(),...r.pendingCommands??(r.pendingCommand?[r.pendingCommand]:[])].find(i=>i.operation==="submit"&&i.input.type===o&&"operationId"in i.input&&i.input.operationId===n.quote.operationId),s=t?.operation==="submit"&&t.input.type===o&&"operationId"in t.input&&t.input.operationId===n.quote.operationId?t.requestId:crypto.randomUUID();if(await x(j(s,{type:e==="confirm"?"paywall_confirm":"paywall_cancel",operationId:n.quote.operationId,...e==="confirm"&&n.quote.merchantTerms?{merchantConfirmation:H(n.quote.merchantTerms)}:{}}),C),!n.operation)throw new u("INVALID_RESPONSE","The accepted purchase result is missing");return structuredClone(n.operation)}let oe={get supportsHostedCheckout(){return!m&&!n.operation&&(n.selectionGeneration??0)===0},get view(){return structuredClone(D())},get quote(){return n.quote?structuredClone(n.quote):null},get operation(){return n.operation?structuredClone(n.operation):null},get webViewUrl(){return r.webViewUrl},get locale(){return r.view?.locale??f.locale},get canReselect(){return n.canReselect===!0&&I===null},get recovery(){let e=r.pendingCommands??(r.pendingCommand?[r.pendingCommand]:[]),o=r.pendingPurchase;if(o&&(o.receiptId!==d||o.operationId!==n.quote?.operationId))return{type:"recover",operationId:o.operationId,requestId:e[0]?.requestId??null};let t=Y({quote:n.quote,operation:n.operation,requestId:e[0]?.requestId??I??m,pending:T.size>0||e.length>0||I!==null,destroyed:p,canReselect:n.canReselect});return t.type==="recover"&&t.requestId===null&&!p&&r.hasDurableJournal===!0&&!n.quote&&!n.operation&&(n.selectionGeneration??0)===0&&!o&&!e.length&&!T.size&&!m?{type:"native",operationId:null}:t},get pendingCancellation(){return!p&&(r.pendingCommands??(r.pendingCommand?[r.pendingCommand]:[])).some(e=>e.operation==="submit"&&e.nodeId===h&&e.visit===E&&e.input.type==="paywall_cancel"&&e.input.operationId===n.quote?.operationId)},subscribe(e){return p?()=>{}:(A.add(e),()=>A.delete(e))},async refresh(){b();let e=C,o=await r.get();if(S(o,e),o.run.paywall?.receiptId!==d)throw new u("PRECONDITION_FAILED","Paywall presentation has changed");return M()},preview(e){let o=D();if(!o)return Promise.reject(new u("PRECONDITION_FAILED","Load the Paywall presentation first"));if(m&&m!==e.requestId&&(g||n.canReselect!==!0))return Promise.reject(new u("COMMAND_PENDING","Retry the original purchase before starting another"));let t=o.document.buttons[e.actionId],s=t?.type==="checkout"?J(t.product,e.selection,o.capabilities):null;if(!s)return Promise.reject(new u("PRODUCT_UNAVAILABLE","Choose an available Product in this purchase area"));let i=z(o.document.screen,s,e.selection,o.capabilities),a=m!==e.requestId&&(n.selectionGeneration??0)>0?{operationId:n.quote?.operationId??null,generation:n.selectionGeneration??0}:void 0,c=r.view?.parameters.commerce;if(c&&typeof c=="object"&&!Array.isArray(c)&&c.intent==="subscription_change"&&!e.subscriptionChange)return Promise.reject(new u("INVALID_REQUEST","Choose the existing membership for this subscription change"));if(e.subscriptionChange&&e.nativeOffer)return Promise.reject(new u("INVALID_REQUEST","A web membership change cannot include a store offer"));if(a&&n.canReselect!==!0)return Promise.reject(new u("COMMAND_PENDING","Original purchase requires authoritative termination"));let l;try{l=j(e.requestId,{type:"paywall_quote",...e.acceptHostedMonthly===void 0?{}:{acceptHostedMonthly:e.acceptHostedMonthly},actionId:e.actionId,productVersionId:s,...Object.keys(i).length?{featureQuantities:i}:{},...a?{predecessor:a}:{},...e.offerId?{offerId:e.offerId}:{},...e.nativeOffer?{nativeOffer:e.nativeOffer}:{},...e.subscriptionChange?{subscriptionChange:e.subscriptionChange}:{}})}catch(P){return Promise.reject(P)}if(m===e.requestId&&g)return g;m!==e.requestId&&C++;let y=C;m=e.requestId;let w=(async()=>{if(await x(l,y),!n.quote)throw new u("INVALID_RESPONSE","The accepted quote is missing");return $(n.quote,{productVersionId:s,featureQuantities:i,subscriptionChange:e.subscriptionChange},"The selected purchase changed"),structuredClone(n.quote)})();return g=w,w.then(()=>{g===w&&(g=null)},P=>{g===w&&(g=null),m===e.requestId&&r.pendingCommand?.requestId!==e.requestId&&P instanceof u&&P.status!==void 0&&P.status<500&&![401,425].includes(P.status)&&(m=null)}),w},confirm:()=>k("confirm"),cancel:()=>k("cancel"),async read(){if(b(),!n.quote)throw new u("INVALID_REQUEST","A quoted purchase is required");let e=n.quote.operationId,o=C,t=r.pendingCommands?.find(l=>l.operation==="submit"&&(l.input.type==="paywall_confirm"||l.input.type==="paywall_cancel")&&l.input.operationId===e)??r.pendingCommand;t?.operation==="submit"&&(t.input.type==="paywall_confirm"||t.input.type==="paywall_cancel")&&t.input.operationId===e&&await r.settle?.(t.requestId);let s=await r.get(void 0,{receiptId:d,operationId:e});b();let i=U(s);if(i?.quote&&i.quote.operationId!==e||i?.operation&&i.operation.operationId!==e)throw new u("INVALID_RESPONSE","Purchase operation changed");let a=S(s,o,e),c=a?n.operation:i?.operation;if(!c)throw new u("INVALID_RESPONSE","The current purchase result is missing");return a&&T.size===0&&!(r.pendingCommands?.length??(r.pendingCommand?1:0))&&(I=null),structuredClone(c)},destroy(){p=!0,re(),A.clear(),q.abort(),v.clear()}},re=r.subscribe(e=>{p||e.nodeId!==h||e.visit!==E||e.paywall?.receiptId!==d||(e.paywall.selectionGeneration??0)<(n.selectionGeneration??0)||(F(e.paywall.resolution),n={...n,resolution:e.paywall.resolution},G())});return{session:oe,load:M}}export{ye as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as y}from"./chunk-
|
|
1
|
+
import{e as y}from"./chunk-P6O6ULXW.js";import{c as g}from"./chunk-Q2ZKKRIB.js";import{b as $}from"./chunk-TG7FSNRF.js";import{e as Y,f as X,g as Z,h as ee,i as re}from"./chunk-VJXGTINT.js";import{b as B}from"./chunk-25LM2JXB.js";import{b as F}from"./chunk-Z42LII54.js";import{b as j}from"./chunk-R6NVHYXW.js";import{A as J,B as R,E as H,z as x}from"./chunk-3QRVHAWK.js";import{x as G}from"./chunk-HJLZY2VK.js";import{b as W}from"./chunk-TQIZN3GB.js";import{a as L}from"./chunk-FRWORXER.js";import{t as K}from"./chunk-YBDTPMGD.js";import{a}from"./chunk-BNVQIMXY.js";import{a as z}from"./chunk-DSPLGTQI.js";function ae(I){let t=[...new Set(I.map(({path:s})=>{let c=s.map(String).join(".");return c.startsWith("selector")?"paywallId or paywallVersionId":c||"input"}))],O=t.includes("locale")?` Pass locale, the Customer's language such as "en" or "zh-CN".`:"";return new a("INVALID_REQUEST",`createPaywallSession input is invalid: ${t.join(", ")}.${O}`)}async function Ie(I,t){if(!L.test(t.customerToken))throw new a("INVALID_TOKEN","A verified Customer credential is required");if(I.session&&I.session.peek()!==t.customerToken)throw new a("SCOPE_MISMATCH","Paywall credential does not match the shared session");let O=y.resolvePaywall.request.safeParse({funnelId:t.funnelId,funnelVersionId:t.funnelVersionId,selector:t.paywallVersionId?{type:"version",versionId:t.paywallVersionId}:{type:"paywall",paywallId:t.paywallId},commerce:t.commerce,locale:t.locale,...t.requirement?{requirement:t.requirement}:{}});if(!O.success)throw ae(O.error.issues);let s=O.data,c=W(I);I.session||c.identify(t.customerToken);let n=null,b=!1,k=new AbortController,u=null,d=null,v=null,P=null,T=null,w=null,m=null,A=0,q=null,U="",D=0,C=new Map,E=new Set;function S(){if(b)throw new a("IDENTITY_CHANGED","Paywall is closed")}function M(){let e=JSON.stringify([A,m!==null]);if(!q||e!==U){U=e;let r=te(++D);q=r;let i=()=>{q===r&&(q=null)};r.then(i,i)}return q.then(r=>structuredClone(r))}async function te(e){S();let r=y.resolvePaywall,i=await g(c.request,r,{...s,selector:n?{type:"version",versionId:n.id}:s.selector});B(s,i.paywall.check,i.scope);let l=await F(I,i.paywall);if(S(),t.paywallVersionId?l.id!==t.paywallVersionId:l.paywallId!==t.paywallId)throw new a("INVALID_RESPONSE","The requested Paywall changed");if(n&&(!Y(l,n)||l.paywallId!==n.paywallId))throw new a("INVALID_RESPONSE","The pinned Paywall or Offering Version changed");if(e!==D)return structuredClone(n??l);n=l;for(let h of E)z(h,structuredClone(n));return structuredClone(n)}async function Q(e){if(S(),P&&e!=="read")throw new a("COMMAND_PENDING","Wait for the original quote");if(!u)throw new a("INVALID_REQUEST","A quoted purchase is required");let r=u;if(e!=="read"){if(m){if(w===e)return m;throw new a("COMMAND_PENDING","Wait for the original purchase command")}if(w&&w!==e)throw new a("COMMAND_PENDING","Read the original purchase before changing an uncertain command");w=e,A++,D++}let i=w,l=A,h=e==="read"&&m===null,f=JSON.stringify([r.operationId,l,m!==null]);if(e==="read"&&C.has(f))return C.get(f).then(o=>structuredClone(o));let p=(async()=>{let o={operationId:r.operationId,...e==="read"?{}:{intent:e},...e==="confirm"&&r.merchantTerms?{merchantConfirmation:G(r.merchantTerms)}:{}},V=R(r)?e==="read"?await g(c.request,y.readSubscriptionUpdate,o):await g(c.request,y.update,o):e==="read"?await g(c.request,y.readSubscriptionOperation,o):await g(c.request,y.attach,o),N=J.parse(V.operation);return N.quote&&ee(r,N.quote),X(N,{operationId:r.operationId,currency:s.commerce.currency,membershipId:R(r)?r.membershipId:null,...R(r)?{featureQuantities:r.featureQuantities??{}}:{}},"The purchase operation changed"),S(),u?.operationId!==r.operationId?structuredClone(N):(d=re(d,N),(e!=="read"||h&&m===null)&&A===l&&w===i&&(w=null),structuredClone(d))})();if(e!=="read"){m=p;let o=()=>{m===p&&(m=null)};p.then(o,o)}else{C.set(f,p);let o=()=>{C.get(f)===p&&C.delete(f)};p.then(o,o)}return p.then(o=>structuredClone(o))}let _={signal:k.signal,get view(){return n?structuredClone(n):null},get quote(){return u?structuredClone(u):null},get operation(){return d?structuredClone(d):null},get webViewUrl(){return"bundled"},get locale(){return s.locale},get recovery(){return $({quote:u,operation:d,requestId:T,pending:P!==null||w!==null,destroyed:b})},get pendingCancellation(){return!b&&w==="cancel"},refresh:M,subscribe(e){return b?()=>{}:(E.add(e),()=>E.delete(e))},async preview(e){if(S(),!n)throw new a("INVALID_REQUEST","Load the Paywall first");let r=n.document.buttons[e.actionId];if(r?.type!=="checkout")throw new a("INVALID_REQUEST","Choose an authored purchase action");let i=j(r.product,e.selection,n.capabilities);if(!i)throw new a("PRODUCT_UNAVAILABLE","Choose an available Product");let l=K(n.document.screen,i,e.selection,n.capabilities);if(s.commerce.intent==="subscription_change"&&!e.subscriptionChange)throw new a("INVALID_REQUEST","Choose the existing membership for this subscription change");if(e.subscriptionChange&&e.nativeOffer)throw new a("INVALID_REQUEST","A web membership change cannot include a store offer");let h=e.subscriptionChange?y.previewUpdate.request.parse({requestId:e.requestId,...e.subscriptionChange,change:{type:"plan",productVersionId:i,...Object.keys(l).length?{featureQuantities:l}:{}},...e.offerId?{offerId:e.offerId}:{}}):y.previewAttach.request.parse({funnelId:s.funnelId,funnelVersionId:s.funnelVersionId,requestId:e.requestId,plans:[{productVersionId:i,...Object.keys(l).length?{featureQuantities:l}:{}}],provider:s.commerce.provider,currency:s.commerce.currency,...e.offerId?{offerId:e.offerId}:{},...e.nativeOffer?{nativeOffer:e.nativeOffer}:{}}),f=JSON.stringify(h);if(v&&v!==f&&(P||w||!d||H(d)))throw new a("COMMAND_PENDING","Finish or cancel the original purchase before changing it");if(v===f){if(P)return P;if(u)return structuredClone(u)}v!==f&&(u=null,d=null),v=f,T=h.requestId;let p=(async()=>{let o="membershipId"in h?await g(c.request,y.previewUpdate,h):await g(c.request,y.previewAttach,h),V=x.parse(o.quote);return S(),Z(V,{productVersionId:i,featureQuantities:l,currency:s.commerce.currency,provider:s.commerce.provider,subscriptionChange:e.subscriptionChange},"The purchase quote changed its selected Product or presentment"),u=V,d=null,structuredClone(u)})();P=p;try{return await p}finally{P===p&&(P=null)}},confirm:()=>Q("confirm"),cancel:()=>Q("cancel"),read:()=>Q("read"),destroy(){b||(b=!0,k.abort(),E.clear(),C.clear(),ne?.(),c.dispose(),n=null,u=null,d=null,v=null,T=null)}},ne=I.session?.subscribeIdentity(_.destroy);try{return await M(),_}catch(e){throw _.destroy(),e}}export{Ie as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as p,C as u,D as d,E as f}from"./chunk-
|
|
1
|
+
import{B as p,C as u,D as d,E as f}from"./chunk-3QRVHAWK.js";import{v as y}from"./chunk-W5MSVU2K.js";import{a as s}from"./chunk-BNVQIMXY.js";function Q(e,t,r=new Set){let i={...t};return y(e.document.screen,n=>{if(n.hidden)return!1;if(n.type!=="quantity_picker"||r.has(n.id))return;let a=e.capabilities.quantities?.[n.id],o=a?.available?a.value:i[n.id]??n.defaultQuantity;if(a?.available&&(typeof o!="number"||!Number.isSafeInteger(o)||o<Math.max(n.minimumQuantity,a.minimum)||o>Math.min(n.maximumQuantity,a.maximum)||(o-n.minimumQuantity)%n.step!==0))throw new s("INVALID_RESPONSE","The current subscription quantity is outside this control's bounds");typeof o=="number"&&(i[n.id]=o)}),i}function V(e){let t=Object.create(null);for(let r of e.document.screen.actions){let i=r.properties.couponBinding,n=e.document.buttons[r.id];if(typeof i!="string"||n?.type!=="checkout")continue;let a=Object.hasOwn(e.capabilities.nodes,i)?e.capabilities.nodes[i]:void 0,{product:o}=n,b=o.type==="fixed"?[o.productVersionId]:o.allowedProductVersionIds,I=a?[a.base,...Object.values(a.byPlan??{})]:[],w=Object.fromEntries(I.flatMap(l=>l.planVersionId&&l.couponId&&l.text&&b.includes(l.planVersionId)?[[l.planVersionId,l]]:[]));t[r.id]={products:w,...o.type==="picker"?{picker:o.pickerId}:{}}}return Object.keys(t).length?{...e.capabilities,checkoutCoupons:t}:e.capabilities}function E(e,t){let r=structuredClone(e);for(let[i,n]of Object.entries(r.plans)){let a=t.plans[i];!a||a.versionId!==n.versionId||(a.amountMinor!==void 0&&(n.amountMinor=a.amountMinor),a.interval!==void 0&&(n.interval=a.interval),a.intervalCount!==void 0&&(n.intervalCount=a.intervalCount),a.prepaid!==void 0&&(n.prepaid=structuredClone(a.prepaid)))}return r}var h=class extends s{constructor(r="Plans were updated. Choose again.",i="套餐已更新,请重新选择。"){super("CONFLICT",r);this.zhMessage=i}zhMessage;customerMessage(r){return r?this.zhMessage:this.message}};function N(e,t){let r=i=>"document"in i?i.offering.id:i.content.offeringVersionId;return e.id===t.id&&r(e)===r(t)&&e.content?.artifact.sha256===t.content?.artifact.sha256}function D(e,t,r){if(e.operationId!==t.operationId||t.currency!==void 0&&"currency"in e&&e.currency!==t.currency||t.membershipId!==void 0&&(t.membershipId===null?u(e):!u(e)||e.membershipId!==t.membershipId)||t.featureQuantities!==void 0&&(!u(e)||!c(e.featureQuantities,t.featureQuantities)))throw new s("INVALID_RESPONSE",r)}function c(e,t){return Object.keys(e??{}).length===Object.keys(t??{}).length&&Object.entries(t??{}).every(([r,i])=>e?.[r]===i)}function P(e,t,r){if(p(e)){if(!t.subscriptionChange||e.membershipId!==t.subscriptionChange.membershipId||e.timing!==t.subscriptionChange.timing||e.productVersionId!==t.productVersionId||t.currency!==void 0&&e.currency!==t.currency||!c(e.featureQuantities,t.featureQuantities))throw new s("INVALID_RESPONSE",r);if(e.execution.provider==="merchant"){let n=e.execution.change,a=e.merchantTerms?.request;if(e.execution.membershipId!==e.membershipId||e.execution.timing!==e.timing||n.type!=="plan"||n.productVersionId!==e.productVersionId||!c(n.featureQuantities,e.featureQuantities)||a&&(a.action!=="subscription_change"||a.timing!==e.timing||a.change.type!=="plan"||a.change.productVersionId!==e.productVersionId||!c(a.change.featureQuantities,e.featureQuantities)))throw new s("INVALID_RESPONSE",r)}return}if(t.subscriptionChange)throw new s("INVALID_RESPONSE",r);let i=Object.fromEntries((e.lines[0]?.prepaid??[]).map(n=>[n.internal_feature_id,n.quantity]));if(t.featureQuantities&&(Object.keys(i).length!==Object.keys(t.featureQuantities).length||Object.entries(t.featureQuantities).some(([n,a])=>i[n]!==a)))throw new s("INVALID_RESPONSE","The purchase quote changed its selected quantities");if(e.lines.length!==1||e.lines[0].productVersionId!==t.productVersionId||t.currency!==void 0&&e.currency!==t.currency||t.provider!==void 0&&e.provider!==t.provider&&!(t.provider==="stripe"&&e.provider==="merchant"&&e.execution?.provider==="merchant"))throw new s("INVALID_RESPONSE",r)}function m(e,t){if(e.operationId===t.operationId){if(p(e))P(t,{productVersionId:e.productVersionId,currency:e.currency,subscriptionChange:{membershipId:e.membershipId,timing:e.timing},featureQuantities:e.featureQuantities??{}},"The original membership change selection changed");else if(p(t))throw new s("INVALID_RESPONSE","The commercial operation kind changed")}}function C(e,t,r=!1){if(t&&u(t)&&t.quote&&!c(t.featureQuantities,t.quote.featureQuantities))throw new s("INVALID_RESPONSE","The original membership change quantities changed");if(t&&u(t)&&t.quote&&m(t.quote,t.quote),!e||e.operationId!==t?.operationId)return t;if(e.quote&&t.quote&&m(e.quote,t.quote),u(e)&&u(t)&&!c(e.featureQuantities,t.featureQuantities))throw new s("INVALID_RESPONSE","The original membership change quantities changed");let i=e.merchantExecution,n=t.merchantExecution;if(i&&(!n||Date.parse(n.updatedAt)<Date.parse(i.updatedAt)))return e;if(u(e)!==u(t))throw new s("INVALID_RESPONSE","The commercial operation kind changed");if(d(e)&&!d(t))return e;let a=t.status===e.status&&i?.recordingStatus!=="accepted"&&n?.recordingStatus==="accepted";return!f(e)&&(f(t)||r&&!d(t)&&!a)?e:t}function R(e){return e.screen.actions.some(t=>t.properties.closeControl==="content"&&e.buttons[t.id]?.type==="close")}export{Q as a,V as b,E as c,h as d,N as e,D as f,P as g,m as h,C as i,R as j};
|