@tinkerlandai/longplay-sdk 0.10.25-rc.1 → 0.10.25
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/dist/{chunk-LLS7GT4C.js → chunk-2ZJ5CS5Q.js} +1 -1
- package/dist/{chunk-NHQBONYJ.js → chunk-5HJMAZ7A.js} +1 -1
- package/dist/{chunk-GYHN5L6I.js → chunk-7AXCG6NU.js} +1 -1
- package/dist/{chunk-ZRAKYJZB.js → chunk-BB5P5HPS.js} +1 -1
- package/dist/chunk-C2BODHNY.js +1 -0
- package/dist/{chunk-KFU36IHL.js → chunk-EIYWDWXP.js} +1 -1
- package/dist/{chunk-EEHL2BP6.js → chunk-LFFBNGXP.js} +1 -1
- package/dist/{chunk-T52ZHJ5D.js → chunk-ML3BIPM6.js} +1 -1
- package/dist/{chunk-ASQ6USAC.js → chunk-O3LZPMS4.js} +1 -1
- package/dist/{chunk-BYLU5UY5.js → chunk-O4535GJR.js} +1 -1
- package/dist/{chunk-ZGXRFGOK.js → chunk-OEH47Y2L.js} +1 -1
- package/dist/{chunk-FSQ75ZCZ.js → chunk-THGLNE4K.js} +1 -1
- package/dist/{chunk-RN3WAJ36.js → chunk-TUYBXAAK.js} +1 -1
- package/dist/{content-H7TUH23I.js → content-FD2Q6XD6.js} +1 -1
- package/dist/{funnel-host-purchase-4SH4YYZ5.js → funnel-host-purchase-XW7IF52Y.js} +1 -1
- package/dist/funnel-runtime-host-I6PJXVRC.js +1 -0
- package/dist/index.js +1 -1
- package/dist/openrouter.js +1 -1
- package/dist/page.js +1 -1
- package/dist/{paywall-ENKCZXDE.js → paywall-CGBFHFRU.js} +1 -1
- package/dist/react-native.js +1 -1
- package/dist/server.js +1 -1
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-M5XMYNVW.js +0 -1
- package/dist/funnel-runtime-host-E3GKPRXF.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{sa as g}from"./chunk-
|
|
1
|
+
import{sa as g}from"./chunk-O4535GJR.js";async function u(t,r,e){if(Number(t.headers.get("content-length"))>r)throw t.body?.cancel().catch(()=>{}),e.error("limit");let o=t.body?.getReader();if(!o)throw e.error("missing");let i=[],s=0,c=!1,a=()=>{},b=new Promise((n,f)=>{a=()=>f(e.signal?.reason),e.signal?.addEventListener("abort",a,{once:!0}),e.signal?.aborted&&a()});try{for(;;){let n=await Promise.race([o.read(),b]);if(n.done){c=!0;break}if(s+=n.value.length,s>r)throw e.error("limit");i.push(n.value)}}finally{e.signal?.removeEventListener("abort",a),c||o.cancel().catch(()=>{}),o.releaseLock()}e.signal?.throwIfAborted();let l=new Uint8Array(s),d=0;for(let n of i)l.set(n,d),d+=n.length;return l}async function m(t,r,e){return new TextDecoder("utf-8",{fatal:!0}).decode(await u(t,r,e))}function y(t,r){let e=typeof t=="string"?new TextEncoder().encode(t):t;return e.byteLength===r.byteLength&&g(e)===r.sha256}export{u as a,m as b,y as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as P}from"./chunk-SJNF6JDJ.js";import{g as pA,h as xA,i as gA,ob as zA,pb as FA,r as $A}from"./chunk-BYLU5UY5.js";import{a as sA,b as MA,e as jA,f as UA,g as _A}from"./chunk-MHEYMXGZ.js";function S(A){return typeof A=="string"?A:String(A)}var ye=/[\ud800-\udbff](?![\udc00-\udfff])|(^|[^\ud800-\udbff])[\udc00-\udfff]/g;function Pe(A){return A.replace(ye,"$1\uFFFD")}function PA(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(S);if(t.length===2)return t}else if((e=ZA(A))!=null){let t=PA(e.next()),n=PA(e.next());if(!t.done&&!n.done)return[S(t.value),S(n.value)]}throw new TypeError("Each query pair must be an iterable [name, value] tuple")}var GA="0123456789ABCDEF",De=/(?:%[0-9A-Fa-f]{2})+/g;function U(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)?U(A):String.fromCharCode(A):A<=2047?U(192|A>>6)+U(128|63&A):A<=65535?U(224|A>>12)+U(128|A>>6&63)+U(128|63&A):U(240|A>>18)+U(128|A>>12&63)+U(128|A>>6&63)+U(128|63&A)}function DA(A){return A>=48&&A<=57?A-48:A>=65&&A<=70?A-65+10:A>=97&&A<=102?A-97+10:-1}function bA(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(De,n=>{try{return decodeURIComponent(n)}catch{return"\uFFFD".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 qA(A){switch(A){case 32:case 34:case 35:case 60:case 62:return!0;default:return AA(A)}}function Se(A){return qA(A)||A===39}function SA(A){switch(A){case 63:case 94:case 96:case 123:case 125:return!0;default:return qA(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 SA(A)}}function YA(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 _(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 NA(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([bA(r.slice(0,u),!0),bA(r.slice(u+1),!0)])}if(t=n+1,n===A.length)break}return e}function CA(A){let e="";for(let t=0;t<A.length;t++){let n=_(A[t][0],YA,!0),r=_(A[t][1],YA,!0);e+=t!==0?`&${n}=${r}`:`${n}=${r}`}return e}var Ce=[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],Ie=[7296,7297,7298,7299,7300,7301,7302,7303,7304,42958,42962,42964,42993],Ee=["\u0432","\u0434","\u043E","\u0441","\u0442","\u0442","\u044A","\u0463","\uA64B","\uA7CF","\uA7D3","\uA7D5","s"],ve=[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 Te(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,Oe,VA]=[[[],"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 Re(A,e){return e===931||e===1010||e===120531||e===120589||e===120647||e===120705||e===120763?"\u03C3":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,"\u03B9").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 X(A,e){let[t,n,r]=A,u=e>>8;for(let f=0;f<t.length;f+=2)if(u>=t[f]&&u<=t[f+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 ke(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(ve,e[t-1]))continue;if(n===8205)return!1;let r=t-1;for(;r>=0&&X(VA,e[r]);)r--;let u=t+1;for(;u<e.length&&X(VA,e[u]);)u++;if(!(r>=0&&u<e.length&&X(Ne,e[r])&&X(Oe,e[u])))return!1}return!0}var Le=/(?![\p{Mark}\p{Decimal_Number}])[\p{Script=Arabic}\p{Script=Hebrew}]/u,Be=/\p{Script=Latin}/u;function He(A){return!Le.test(A)||!Be.test(A)}var F=36,iA=1,IA=26,Me=38,je=700,Ue=72,_e=128,xe=2147483647;function KA(A){return String.fromCharCode(A+22+75*+(A<26))}function $e(A,e,t){let n=0;for(A=t?Math.floor(A/je):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 ze(A){let e=Array.from(A,f=>f.codePointAt(0)),t="",n=0;for(let f=0;f<e.length;f++){let h=e[f];h<128&&(t+=String.fromCharCode(h),n++)}let r=n;r&&(t+="-");let u=_e,l=0,a=Ue;for(;n<e.length;){let f=xe;for(let h=0;h<e.length;h++){let m=e[h];m>=u&&m<f&&(f=m)}l+=(f-u)*(n+1),u=f;for(let h=0;h<e.length;h++){let m=e[h];if(m<u&&l++,m===u){let p=l;for(let w=F;;w+=F){let y=w<=a?iA:w>=a+IA?IA:w-a;if(p<y)break;t+=KA(y+(p-y)%(F-y)),p=Math.floor((p-y)/(F-y))}t+=KA(p),a=$e(l,n+1,n===r),l=0,n++}}l++,u++}return t}function mA(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=DA(A.charCodeAt(n));if(r>=e||r<0)return-1;t=t*e+r}return t}function JA(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 WA(A){return A.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|\/|:|<|>|\?|@|\[|\\|\]|\^|\|/u)!==-1}function I(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 EA(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,f=Array.from(n,h=>h.codePointAt(0));if(f[a]===58){if(f[a+1]!==58)return null;a+=2,l++,u=l}for(;a<f.length;){if(l===8)return null;if(f[a]===58){if(u!==null)return null;a++,l++,u=l;continue}let h=0,m=0,p=0;for(;p<4&&(h=DA(f[a]))>=0;)m=(m<<4)+h,a++,p++;if(f[a]===46){if(p===0||l>6)return null;a-=p;let w=0;for(;f[a]!==void 0;){let y=0;if(w>0)if(f[a]===46&&w<4)a++;else return null;if(f[a]==null||f[a]<48||f[a]>57)return null;for(;f[a]>=48&&f[a]<=57;){if(y=10*y+DA(f[a]),y>255)return null;a++}r[l]=256*r[l]+y,w++,w%2==0&&l++}if(w!==4)return null;break}else if(f[a]===58){if(f[++a]===void 0)return null}else if(f[a]!==void 0)return null;r[l]=m,l++}if(u!==null){let h=l-u;for(l=7;l!==0&&h>0;){let m=r[u+h-1];r[u+h-1]=r[l],r[l]=m,l--,h--}}else if(u===null&&l!==8)return null;return r})(A.substring(1,A.length-1)):null;if(e)return(function(n){return WA(n)?null:_(n,AA)})(A);{let t=(function(r){let u=!1,l=!1;for(let f=0;f<r.length;f++){let h=r.charCodeAt(f);if(h<=32||h===37||h===127)return null;if(h>=128){u=!0;break}h>=65&&h<=90&&(l=!0)}if(!u)return r!==""?l?r.toLowerCase():r:null;if((function(h){for(let m of h){let p=m.codePointAt(0);if(/[\p{Cn}\p{Co}\p{Cs}\p{Noncharacter_Code_Point}]/u.test(m)&&!te(Ce,p)||X(qe,p))return!0}return!1})(r))return null;let a=(r=(function(h){let m="";for(let p of h){let w=p.codePointAt(0);if(w!==8204&&w!==8205&&/\p{Default_Ignorable_Code_Point}/u.test(p))continue;let y=Re(p,w);if(y){m+=y;continue}let N=Ie.indexOf(w);m+=N<0?p:Ee[N]}return m})(r).normalize("NFKC").replace(/[\u3002\uff0e\uff61]/g,".").toLowerCase()).split(".");for(let f=0;f<a.length;f++){let h=a[f];if(h==="")continue;let m=/[^\0-\x7f]/.test(h);if(Te(h)||m&&(/^\p{Mark}/u.test(h)||!ke(h)||!He(h)||h.startsWith("xn--")))return null;m&&(a[f]=`xn--${ze(h)}`)}return(r=a.join("."))!==""?r:null})(A.indexOf("%")===-1?A:bA(A));return t===null||WA(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(mA(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 h=0;h<l-1;h++){let m=mA(u[h]);if(m<0||m>255)return null;a+=m*(1<<8*(3-h))}let f=mA(u[l-1]);return f<0||f>=256**(5-l)?null:(a+=f,a)})(t):t}}function vA(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 f=-1,h=-1,m=1,p=0;for(let w=0;w<a.length;++w)a[w]!==0?(p>m&&(f=h,m=p),h=-1,p=0):(h===-1&&(h=w),++p);return p>m?h:f})(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 wA(A){return A.host===null||A.host===""||A.scheme==="file"}var s=0,o="",g="",D=null,i,lA=!1,uA=!1,G=!1,E;function B(A,e,t,n){e||(A=(function(l){let a=0,f=l.length;for(;a<f&&!(l.charCodeAt(a)>32);++a);for(;f>a&&!(l.charCodeAt(f-1)>32);--f);return l.substring(a,f)})(A)),A=(function(l){let a=0;for(;a<l.length;a++){let h=l.charCodeAt(a);if(h===9||h===10||h===13)break}if(a===l.length)return l;let f=l.slice(0,a);for(;a<l.length;a++){let h=l.charCodeAt(a);h!==9&&h!==10&&h!==13&&(f+=l[a])}return f})(A),s=0,o=A,g="",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=Fe;switch(n){case 3:case 4:r=aA;break;case 5:r=RA;break;case 6:r=Y;break;case 7:r=Q;break;case 8:r=x}return r(c(A,s))!==1?i:null}function d(A,e){return s+=s===A?M(e):1,s<=o.length}function c(A,e){return e<A.length?A.codePointAt(e):void 0}function M(A){return A!=null&&A>65535?2:1}function le(A){return A==null?"":A<=65535?String.fromCharCode(A):String.fromCodePoint(A)}var Fe=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 g=o.slice(s,t).toLowerCase(),s=t,Qe(t<o.length?A:void 0)}else return E?1:(--s,d(e,A)?ue(c(o,s)):0)},Qe=A=>{let e=s;if(A===58){if(E){if(I(i.scheme)!==I(g))return 0;if((ie(i)||i.port!==null)&&g==="file")return 0;if(i.scheme==="file"&&i.host==="")return 0}return i.scheme=g,E?(i.port===se(i.scheme)&&(i.port=null),0):(g="",i.scheme==="file"?d(e,A)?kA(c(o,s)):0:I(i.scheme)&&D!==null&&D.scheme===i.scheme?d(e,A)?Ge(c(o,s)):0:I(i.scheme)?d(e,A)?Ve(c(o,s)):0:c(o,s+1)===47?(s++,d(e,A)?Ye(c(o,s)):0):(i.path=[""],i.opaquePath=!0,d(e,A)?ae(c(o,s)):0))}else return E?1:(g="",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)?x(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)},Ge=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)},Ye=A=>{let e=s;return A===47?d(e,A)?W(c(o,s)):0:(s--,d(e,A)?j(c(o,s)):0)},OA=A=>{let e=s;return i.scheme=D.scheme,A===47||I(i.scheme)&&A===92?d(e,A)?XA(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)?x(c(o,s)):0):A!=null?(i.query=null,i.path.pop(),s--,d(e,A)?j(c(o,s)):0):d(e,A)?OA(c(o,s)):0)},XA=A=>{let e=s;return I(i.scheme)&&(A===47||A===92)?d(e,A)?hA(c(o,s)):0:A===47?d(e,A)?W(c(o,s)):0:(i.username=D.username,i.password=D.password,i.host=D.host,i.port=D.port,s--,d(e,A)?j(c(o,s)):0)},Ve=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)?W(c(o,s)):0):d(e,A)?hA(c(o,s)):0},W=A=>{let e=s;if(A!=null&&A!==64&&A!==35&&A!==47&&A!==63&&(A!==92||!I(i.scheme))){let t=s+M(A);for(;t<o.length;){let n=c(o,t);if(n==null||n===64||n===35||n===47||n===63||n===92&&I(i.scheme))break;t+=M(n)}return g+=o.slice(s,t),s=t-1,d(e,A)?W(c(o,s)):0}if(A===64){lA&&(g=`%40${g}`),lA=!0;for(let t=0;t<g.length;t++){let n=g.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 g="",d(e,A)?W(c(o,s)):0}else return A==null||A===35||A===47||A===63||A===92&&I(i.scheme)?lA&&g===""?1:(s-=g.length+1,g="",d(e,A)?aA(c(o,s)):0):(g+=le(A),d(e,A)?W(c(o,s)):0)},aA=A=>{let e=s;if(E&&i.scheme==="file")return s--,d(e,A)?LA(c(o,s)):0;if(A!=null&&A!==58&&A!==35&&A!==47&&A!==63&&(A!==92||!I(i.scheme))){let t=s+M(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&&I(i.scheme))break;n===91?G=!0:n===93&&(G=!1),t+=M(n)}return g+=o.slice(s,t),s=t-1,d(e,A)?aA(c(o,s)):0}else if(A===58&&!G){if(g===""||E===4)return 1;let t=EA(g,!I(i.scheme));return t===null?1:(i.host=vA(t),g="",d(e,A)?RA(c(o,s)):0)}else if(A==null||A===35||A===47||A===63||A===92&&I(i.scheme)){if(s--,I(i.scheme)&&g==="")return 1;if(E&&g===""&&(ie(i)||i.port!==null))return 1;let t=EA(g,!I(i.scheme));return t===null?1:(i.host=vA(t),g="",E?0:d(e,A)?Y(c(o,s)):0)}else return g+=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 g+=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&&I(i.scheme)){if(g!==""){let t=parseInt(g,10);if(t>65535)return 1;if(i.port=t===se(i.scheme)?null:t,g="",E)return 0}return E?1:(s--,d(e,A)?Y(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)?Ke(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)?x(c(o,s)):0):A!=null?(i.query=null,ce(o,s)?i.path=[]:oe(i),s--,d(e,A)?j(c(o,s)):0):d(e,A)?kA(c(o,s)):0):(s--,d(e,A)?j(c(o,s)):0)},Ke=A=>{let e=s;return A===47||A===92?d(e,A)?LA(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)?j(c(o,s)):0)},LA=A=>{let e=s;if(A!=null&&A!==47&&A!==92&&A!==63&&A!==35){let t=s+M(A);for(;t<o.length;){let n=c(o,t);if(n==null||n===47||n===92||n===63||n===35)break;t+=M(n)}return g+=o.slice(s,t),s=t-1,d(e,A)?LA(c(o,s)):0}else if(A==null||A===47||A===92||A===63||A===35){if(s--,!E&&re(g))return d(e,A)?j(c(o,s)):0;if(g==="")return i.host="",E?0:d(e,A)?Y(c(o,s)):0;{let t=EA(g,!I(i.scheme));return t===null?1:(t==="localhost"&&(t=""),i.host=vA(t),g="",E?0:d(e,A)?Y(c(o,s)):0)}}return 1},Y=A=>{let e=s;return I(i.scheme)?(A!==92&&A!==47&&s--,d(e,A)?j(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)?x(c(o,s)):0):A!=null?(A!==47&&s--,d(e,A)?j(c(o,s)):0):(E&&i.host===null&&i.path.push(""),d(e,A)?Y(c(o,s)):0)},j=A=>{let e=s;if(A!=null&&A!==47&&(!I(i.scheme)||A!==92)&&(E||A!==63&&A!==35)){let t=s+M(A);for(;t<o.length;){let n=c(o,t);if(n==null||n===47||I(i.scheme)&&n===92||!E&&(n===63||n===35))break;t+=M(n)}g+=_(o.slice(s,t),SA),s=t,A=c(o,t)}if(A==null||A===47||I(i.scheme)&&A===92||!E&&(A===63||A===35)){let t=I(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}})(g)?(oe(i),A!==47&&!t&&i.path.push("")):JA(g)&&A!==47&&!t?i.path.push(""):JA(g)||(i.scheme==="file"&&i.path.length===0&&re(g)&&(g=`${g[0]}:`),i.path.push(g)),g="",A===63?(i.query="",d(e,A)?Q(c(o,s)):0):A===35?(i.fragment="",d(e,A)?x(c(o,s)):0):d(e,A)?j(c(o,s)):0}else return g+=ee(A,SA),d(e,A)?j(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)?x(c(o,s)):0;if(A!=null){let t=s+M(A);for(;t<o.length;){let r=c(o,t);if(r===63||r===35)break;t+=M(r)}let n=o.slice(s,t);if(t<o.length&&n.charCodeAt(n.length-1)===32?i.path[0]+=_(n.slice(0,-1),AA)+"%20":i.path[0]+=_(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)?x(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=I(i.scheme)?Se:qA;i.query+=_(o.slice(s,t),n)}return s=t,c(o,t)===35&&!E?(i.fragment="",d(e,A)?x(c(o,s)):0):d(e,A)?Q(c(o,s)):0},x=A=>{let e=s;return A!=null&&(i.fragment+=_(o.slice(s),be),s=o.length),d(e,A)?x(c(o,s)):0};function TA(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=B(TA(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 b=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=S(e),t!=null&&(t=S(t));let n=null;if(t!=null&&(n=B(t,null,null,0),n==null))throw new TypeError(`Invalid base URL: ${t}`);let r=B(e,null,n,0);if(r==null)throw new TypeError(`Invalid URL: ${e}`);this[b]={url:r,query:null}}static createObjectURL(e){throw new TypeError("URL.createObjetURL is unsupported")}static revokeObjectURL(e){}static parse(e,t){e=S(e),t!==void 0&&(t=S(t));try{return new A(e,t)}catch{return null}}static canParse(e,t){e=S(e),t!==void 0&&(t=S(t));let n=null;return t!=null&&(n=B(t,null,null,0),n==null)?!1:B(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+=TA(t),t.query!==null&&(n+=`?${t.query}`),t.fragment!==null&&(n+=`#${t.fragment}`),n})(this[b].url)}set href(e){let t=B(e=S(e),null,null,0);if(t==null)throw new TypeError(`Invalid URL: ${e}`);this[b].url=t,this[b].query&&yA(this[b].query,t.query)}get origin(){return fe(this[b].url)}get protocol(){return`${this[b].url.scheme}:`}set protocol(e){B(`${e=S(e)}:`,this[b].url,null,2)}get username(){return this[b].url.username}set username(e){e=S(e),wA(this[b].url)||(function(n,r){n.username=_(r,cA)})(this[b].url,e)}get password(){return this[b].url.password}set password(e){e=S(e),wA(this[b].url)||(function(n,r){n.password=_(r,cA)})(this[b].url,e)}get host(){let{url:e}=this[b];return e.host==null?"":e.port==null?e.host:`${e.host}:${e.port}`}set host(e){e=S(e),this[b].url.opaquePath||B(e,this[b].url,null,3)}get hostname(){let{url:e}=this[b];return e.host!=null?e.host:""}set hostname(e){e=S(e),this[b].url.opaquePath||B(e,this[b].url,null,4)}get port(){let{url:e}=this[b];return e.port!=null?`${e.port}`:""}set port(e){e=S(e);let{url:t}=this[b];wA(t)||(e?B(e,t,null,5):t.port=null)}get pathname(){return TA(this[b].url)}set pathname(e){e=S(e);let{url:t}=this[b];t.opaquePath||(t.path=[],B(e,t,null,6))}get search(){let{url:e}=this[b];return e.query?`?${e.query}`:""}set search(e){e=S(e);let{url:t,query:n}=this[b];if(!e)t.query=null,n&&yA(n,null);else{let r=e[0]==="?"?e.substring(1):e;t.query="",B(r,t,null,7),n&&yA(n,t.query)}}get searchParams(){let e=this[b],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=NA(u)),l})(this,e.url.query)),t}get hash(){let{url:e}=this[b];return e.fragment?`#${e.fragment}`:""}set hash(e){e=S(e);let{url:t}=this[b];if(!e)t.fragment=null;else{let n=e[0]==="#"?e.substring(1):e;t.fragment="",B(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"),Je=Symbol.dispose||Symbol.for("dispose");function yA(A,e){e?A[C].list=NA(e):A[C].list.length=0,A[C].serialized=e==null}function oA(A){if(A.url){let e=CA(A.list);(function(n,r){n[b].url.query=r})(A.url,e||null),A.serialized=!0}}var We=typeof Iterator<"u"?Iterator:Object,Z=class extends We{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}[Je](){}},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=PA(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=Pe(l),f=S(e[l]),h=t.list.find(m=>m[0]===a);h?h[1]=f:t.list.push([a,f])}}else if(e!==void 0){let r=S(e);r=r[0]==="?"?r.substring(1):r,t.list=NA(r)}}get size(){return this[C].list.length}append(e,t){e=S(e),t=S(t),this[C].list.push([e,t]);let n=this[C];n.url&&n.serialized?(function(u,l){let a=u[b].url;a.query=a.query?`${a.query}&${l}`:l})(n.url,CA([[e,t]])):oA(n)}delete(e,t){e=S(e),t=t!=null?S(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=S(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=S(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=S(e),t=t!=null?S(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=S(e),t=S(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 CA(this[C].list)}[Symbol.iterator](){return this.entries()}};Object.defineProperty(fA.prototype,Symbol.toStringTag,{value:"URLSearchParams",configurable:!0});function he(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 w=++n;r=void 0,e=void 0;for(let y of[...u.values()])try{y?.()}catch{}w===n&&(e=p,l())}let f=()=>a();function h(p,w=!1){let y=$A.safeParse(p);if(!y.success||w&&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 m(){if(r)return r;let p=typeof e=="object"?e:void 0,w=n;if(!p||Date.parse(p.refreshExpiresAt)<=Date.now())throw p&&f(),new P("UNAUTHENTICATED","Customer authentication is required",401);let y=(async()=>{try{let N=await A(p.refreshToken);if(w!==n)throw new P("IDENTITY_CHANGED","Customer identity changed during refresh");let V=h(N,!0);if(V.customerId!==p.customerId||V.sessionId!==p.sessionId)throw new P("SCOPE_MISMATCH","Refresh changed the customer session");return e=V,{...V}}catch(N){throw w!==n?new P("IDENTITY_CHANGED","Customer identity changed during refresh"):(N instanceof P&&N.status===401&&f(),N)}})();r=y;try{return await y}finally{r===y&&(r=void 0)}}return{identify(p){let w=typeof p=="string"?p:h(p),y=typeof w=="string"?w:w.accessToken;if(!y.trim()||/\s/.test(y)||y.length>4096)throw new P("INVALID_TOKEN","A server-issued token is required");a(w)},reset:f,subscribeIdentity(p,w){return u.set(p,w),()=>{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 m().then(()=>{let N=t();if(y!==n||!N)throw new P("IDENTITY_CHANGED","Customer identity changed during refresh");return N})}let w=t();if(!w)throw new P("NOT_IDENTIFIED","Identify a customer session before making a request");return w},peek:t,snapshot:()=>typeof e=="object"?{...e}:void 0,refresh:m}}var de=Symbol("IndianaNoContent");function ut(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),f=A.timeoutMs??1e4;if(!Number.isFinite(f)||f<1||f>12e4)throw new P("INVALID_TIMEOUT","timeoutMs must be between 1 and 120000");let h=!1,m=0,p=null,w=new Set,y=A.session??he(async q=>{let O=await tA("customer-sessions/refresh",{},"POST",{},q);if(!O||typeof O!="object")throw new P("INVALID_RESPONSE","Invalid refresh response");let{requestId:$,scope:H,...K}=O;return K});function N(){m+=1,p=null;for(let q of w)q.abort();w.clear()}let V=y.subscribeIdentity(N);function pe(){h||y.reset()}async function tA(q,O={},$="POST",H={},K){let k=H.installationDetach===!0;if(k&&(q!=="push/installations/detach"||$!=="POST"))throw new P("INVALID_REQUEST","Installation authority only detaches this installation");if(!K&&!k)throw new P("NOT_IDENTIFIED","Call identify with a server-issued customer token first");let J=m,L=new AbortController;k||w.add(L);let nA=()=>!k&&J!==m?new P("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):new P("TIMEOUT","Longplay request timed out"),dA,ge=new Promise((T,R)=>{dA=()=>R(nA()),L.signal.addEventListener("abort",dA,{once:!0})}),me=setTimeout(()=>L.abort(),H.timeoutMs??f),we=async()=>{let T=await a(`${l.href.replace(/\/$/,"")}/api/v1/${q}`,{method:$,headers:{...H.headers,"Content-Type":"application/json",...k?{}:{Authorization:`Bearer ${K}`},[pA]:gA.current,[xA]:zA.version,...u?{"X-Indiana-Project":u.projectId,"X-Indiana-Environment":u.environment}:{}},body:$==="POST"?JSON.stringify(O):void 0,signal:L.signal,credentials:"omit",cache:"no-store",redirect:"error",...H.keepalive?{keepalive:!0}:{}});if(L.signal.aborted)throw nA();let R;try{R=T.status===204?de:await T.json()}catch{throw L.signal.aborted?nA():new P(T.ok?"INVALID_RESPONSE":"HTTP_ERROR","The gateway returned an unreadable response",T.status,T.headers.get("X-Request-Id")??void 0)}if(L.signal.aborted)throw nA();if(!k&&J!==m)throw new P("IDENTITY_CHANGED","Customer identity changed while the request was in flight");if(!T.ok){let v=UA.safeParse(R),z=v.success&&(!MA.safeParse(v.data.error.code).success||jA(v.data.error.code,T.status)),BA=z?v.data.error.code:"HTTP_ERROR",HA=_A(BA,T.status,{retryAfter:T.headers.get("Retry-After"),recovery:z?v.data.error.recovery:void 0,reason:z?v.data.error.reason:void 0});throw new P(BA,z?v.data.error.message:"Longplay request failed",T.status,T.headers.get("X-Request-Id")??(v.success?v.data.requestId:void 0),{...HA,...v.success&&v.data.error.retryable===!1?{retryable:!1}:{},...HA.retryAfterSeconds===void 0&&v.success&&v.data.error.retryAfterSeconds!==void 0?{retryAfterSeconds:v.data.error.retryAfterSeconds}:{}})}if(T.headers.get(pA)!==gA.current)throw new P("PROTOCOL_MISMATCH","Response protocol does not match this SDK");if(u&&R!==de){let v=R&&typeof R=="object"&&"scope"in R?R:R&&typeof R=="object"&&"configuration"in R?R.configuration:null;if(!v||typeof v!="object"||!("scope"in v))throw new P("INVALID_RESPONSE","Response is missing its App/environment scope");let z=sA.safeParse(v.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=T.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 R};try{return await Promise.race([we(),ge])}catch(T){throw!k&&J!==m?new P("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):T instanceof P?T:new P(L.signal.aborted?"TIMEOUT":"NETWORK_ERROR",L.signal.aborted?"Longplay request timed out":"Unable to read the Longplay response")}finally{clearTimeout(me),L.signal.removeEventListener("abort",dA),w.delete(L)}}return{session:y,requestWithCredential(q,O,$,H={}){return h?Promise.reject(new P("CLOSED","SDK client was destroyed")):tA(q,O,"POST",H,$)},subjectKey:()=>p,identify(q){if(h)throw new P("CLOSED","SDK client was destroyed");if(u&&typeof q=="object"&&"scope"in q){let O=sA.safeParse(q.scope);if(!O.success||O.data.projectId!==u.projectId||O.data.environment!==u.environment)throw new P("SCOPE_MISMATCH","Customer session belongs to another App/environment")}y.identify(q)},reset:pe,dispose(){h||(h=!0,V(),N())},request(q,O={},$="POST",H={}){if(h)return Promise.reject(new P("CLOSED","SDK client was destroyed"));if(H.installationDetach)return tA(q,O,$,H);let K=m;try{let k=y.access(),J=L=>{if(K!==m)throw new P("IDENTITY_CHANGED","Customer identity changed before dispatch");return tA(q,O,$,H,L)};return typeof k=="string"?J(k):k.then(J)}catch(k){return Promise.reject(k)}}}}export{eA as a,ut as b};
|
|
1
|
+
import{a as P}from"./chunk-SJNF6JDJ.js";import{g as pA,h as xA,i as gA,ob as zA,pb as FA,r as $A}from"./chunk-O4535GJR.js";import{a as sA,b as MA,e as jA,f as UA,g as _A}from"./chunk-MHEYMXGZ.js";function S(A){return typeof A=="string"?A:String(A)}var ye=/[\ud800-\udbff](?![\udc00-\udfff])|(^|[^\ud800-\udbff])[\udc00-\udfff]/g;function Pe(A){return A.replace(ye,"$1\uFFFD")}function PA(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(S);if(t.length===2)return t}else if((e=ZA(A))!=null){let t=PA(e.next()),n=PA(e.next());if(!t.done&&!n.done)return[S(t.value),S(n.value)]}throw new TypeError("Each query pair must be an iterable [name, value] tuple")}var GA="0123456789ABCDEF",De=/(?:%[0-9A-Fa-f]{2})+/g;function U(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)?U(A):String.fromCharCode(A):A<=2047?U(192|A>>6)+U(128|63&A):A<=65535?U(224|A>>12)+U(128|A>>6&63)+U(128|63&A):U(240|A>>18)+U(128|A>>12&63)+U(128|A>>6&63)+U(128|63&A)}function DA(A){return A>=48&&A<=57?A-48:A>=65&&A<=70?A-65+10:A>=97&&A<=102?A-97+10:-1}function bA(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(De,n=>{try{return decodeURIComponent(n)}catch{return"\uFFFD".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 qA(A){switch(A){case 32:case 34:case 35:case 60:case 62:return!0;default:return AA(A)}}function Se(A){return qA(A)||A===39}function SA(A){switch(A){case 63:case 94:case 96:case 123:case 125:return!0;default:return qA(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 SA(A)}}function YA(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 _(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 NA(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([bA(r.slice(0,u),!0),bA(r.slice(u+1),!0)])}if(t=n+1,n===A.length)break}return e}function CA(A){let e="";for(let t=0;t<A.length;t++){let n=_(A[t][0],YA,!0),r=_(A[t][1],YA,!0);e+=t!==0?`&${n}=${r}`:`${n}=${r}`}return e}var Ce=[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],Ie=[7296,7297,7298,7299,7300,7301,7302,7303,7304,42958,42962,42964,42993],Ee=["\u0432","\u0434","\u043E","\u0441","\u0442","\u0442","\u044A","\u0463","\uA64B","\uA7CF","\uA7D3","\uA7D5","s"],ve=[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 Te(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,Oe,VA]=[[[],"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 Re(A,e){return e===931||e===1010||e===120531||e===120589||e===120647||e===120705||e===120763?"\u03C3":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,"\u03B9").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 X(A,e){let[t,n,r]=A,u=e>>8;for(let f=0;f<t.length;f+=2)if(u>=t[f]&&u<=t[f+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 ke(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(ve,e[t-1]))continue;if(n===8205)return!1;let r=t-1;for(;r>=0&&X(VA,e[r]);)r--;let u=t+1;for(;u<e.length&&X(VA,e[u]);)u++;if(!(r>=0&&u<e.length&&X(Ne,e[r])&&X(Oe,e[u])))return!1}return!0}var Le=/(?![\p{Mark}\p{Decimal_Number}])[\p{Script=Arabic}\p{Script=Hebrew}]/u,Be=/\p{Script=Latin}/u;function He(A){return!Le.test(A)||!Be.test(A)}var F=36,iA=1,IA=26,Me=38,je=700,Ue=72,_e=128,xe=2147483647;function KA(A){return String.fromCharCode(A+22+75*+(A<26))}function $e(A,e,t){let n=0;for(A=t?Math.floor(A/je):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 ze(A){let e=Array.from(A,f=>f.codePointAt(0)),t="",n=0;for(let f=0;f<e.length;f++){let h=e[f];h<128&&(t+=String.fromCharCode(h),n++)}let r=n;r&&(t+="-");let u=_e,l=0,a=Ue;for(;n<e.length;){let f=xe;for(let h=0;h<e.length;h++){let m=e[h];m>=u&&m<f&&(f=m)}l+=(f-u)*(n+1),u=f;for(let h=0;h<e.length;h++){let m=e[h];if(m<u&&l++,m===u){let p=l;for(let w=F;;w+=F){let y=w<=a?iA:w>=a+IA?IA:w-a;if(p<y)break;t+=KA(y+(p-y)%(F-y)),p=Math.floor((p-y)/(F-y))}t+=KA(p),a=$e(l,n+1,n===r),l=0,n++}}l++,u++}return t}function mA(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=DA(A.charCodeAt(n));if(r>=e||r<0)return-1;t=t*e+r}return t}function JA(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 WA(A){return A.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|\/|:|<|>|\?|@|\[|\\|\]|\^|\|/u)!==-1}function I(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 EA(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,f=Array.from(n,h=>h.codePointAt(0));if(f[a]===58){if(f[a+1]!==58)return null;a+=2,l++,u=l}for(;a<f.length;){if(l===8)return null;if(f[a]===58){if(u!==null)return null;a++,l++,u=l;continue}let h=0,m=0,p=0;for(;p<4&&(h=DA(f[a]))>=0;)m=(m<<4)+h,a++,p++;if(f[a]===46){if(p===0||l>6)return null;a-=p;let w=0;for(;f[a]!==void 0;){let y=0;if(w>0)if(f[a]===46&&w<4)a++;else return null;if(f[a]==null||f[a]<48||f[a]>57)return null;for(;f[a]>=48&&f[a]<=57;){if(y=10*y+DA(f[a]),y>255)return null;a++}r[l]=256*r[l]+y,w++,w%2==0&&l++}if(w!==4)return null;break}else if(f[a]===58){if(f[++a]===void 0)return null}else if(f[a]!==void 0)return null;r[l]=m,l++}if(u!==null){let h=l-u;for(l=7;l!==0&&h>0;){let m=r[u+h-1];r[u+h-1]=r[l],r[l]=m,l--,h--}}else if(u===null&&l!==8)return null;return r})(A.substring(1,A.length-1)):null;if(e)return(function(n){return WA(n)?null:_(n,AA)})(A);{let t=(function(r){let u=!1,l=!1;for(let f=0;f<r.length;f++){let h=r.charCodeAt(f);if(h<=32||h===37||h===127)return null;if(h>=128){u=!0;break}h>=65&&h<=90&&(l=!0)}if(!u)return r!==""?l?r.toLowerCase():r:null;if((function(h){for(let m of h){let p=m.codePointAt(0);if(/[\p{Cn}\p{Co}\p{Cs}\p{Noncharacter_Code_Point}]/u.test(m)&&!te(Ce,p)||X(qe,p))return!0}return!1})(r))return null;let a=(r=(function(h){let m="";for(let p of h){let w=p.codePointAt(0);if(w!==8204&&w!==8205&&/\p{Default_Ignorable_Code_Point}/u.test(p))continue;let y=Re(p,w);if(y){m+=y;continue}let N=Ie.indexOf(w);m+=N<0?p:Ee[N]}return m})(r).normalize("NFKC").replace(/[\u3002\uff0e\uff61]/g,".").toLowerCase()).split(".");for(let f=0;f<a.length;f++){let h=a[f];if(h==="")continue;let m=/[^\0-\x7f]/.test(h);if(Te(h)||m&&(/^\p{Mark}/u.test(h)||!ke(h)||!He(h)||h.startsWith("xn--")))return null;m&&(a[f]=`xn--${ze(h)}`)}return(r=a.join("."))!==""?r:null})(A.indexOf("%")===-1?A:bA(A));return t===null||WA(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(mA(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 h=0;h<l-1;h++){let m=mA(u[h]);if(m<0||m>255)return null;a+=m*(1<<8*(3-h))}let f=mA(u[l-1]);return f<0||f>=256**(5-l)?null:(a+=f,a)})(t):t}}function vA(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 f=-1,h=-1,m=1,p=0;for(let w=0;w<a.length;++w)a[w]!==0?(p>m&&(f=h,m=p),h=-1,p=0):(h===-1&&(h=w),++p);return p>m?h:f})(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 wA(A){return A.host===null||A.host===""||A.scheme==="file"}var s=0,o="",g="",D=null,i,lA=!1,uA=!1,G=!1,E;function B(A,e,t,n){e||(A=(function(l){let a=0,f=l.length;for(;a<f&&!(l.charCodeAt(a)>32);++a);for(;f>a&&!(l.charCodeAt(f-1)>32);--f);return l.substring(a,f)})(A)),A=(function(l){let a=0;for(;a<l.length;a++){let h=l.charCodeAt(a);if(h===9||h===10||h===13)break}if(a===l.length)return l;let f=l.slice(0,a);for(;a<l.length;a++){let h=l.charCodeAt(a);h!==9&&h!==10&&h!==13&&(f+=l[a])}return f})(A),s=0,o=A,g="",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=Fe;switch(n){case 3:case 4:r=aA;break;case 5:r=RA;break;case 6:r=Y;break;case 7:r=Q;break;case 8:r=x}return r(c(A,s))!==1?i:null}function d(A,e){return s+=s===A?M(e):1,s<=o.length}function c(A,e){return e<A.length?A.codePointAt(e):void 0}function M(A){return A!=null&&A>65535?2:1}function le(A){return A==null?"":A<=65535?String.fromCharCode(A):String.fromCodePoint(A)}var Fe=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 g=o.slice(s,t).toLowerCase(),s=t,Qe(t<o.length?A:void 0)}else return E?1:(--s,d(e,A)?ue(c(o,s)):0)},Qe=A=>{let e=s;if(A===58){if(E){if(I(i.scheme)!==I(g))return 0;if((ie(i)||i.port!==null)&&g==="file")return 0;if(i.scheme==="file"&&i.host==="")return 0}return i.scheme=g,E?(i.port===se(i.scheme)&&(i.port=null),0):(g="",i.scheme==="file"?d(e,A)?kA(c(o,s)):0:I(i.scheme)&&D!==null&&D.scheme===i.scheme?d(e,A)?Ge(c(o,s)):0:I(i.scheme)?d(e,A)?Ve(c(o,s)):0:c(o,s+1)===47?(s++,d(e,A)?Ye(c(o,s)):0):(i.path=[""],i.opaquePath=!0,d(e,A)?ae(c(o,s)):0))}else return E?1:(g="",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)?x(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)},Ge=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)},Ye=A=>{let e=s;return A===47?d(e,A)?W(c(o,s)):0:(s--,d(e,A)?j(c(o,s)):0)},OA=A=>{let e=s;return i.scheme=D.scheme,A===47||I(i.scheme)&&A===92?d(e,A)?XA(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)?x(c(o,s)):0):A!=null?(i.query=null,i.path.pop(),s--,d(e,A)?j(c(o,s)):0):d(e,A)?OA(c(o,s)):0)},XA=A=>{let e=s;return I(i.scheme)&&(A===47||A===92)?d(e,A)?hA(c(o,s)):0:A===47?d(e,A)?W(c(o,s)):0:(i.username=D.username,i.password=D.password,i.host=D.host,i.port=D.port,s--,d(e,A)?j(c(o,s)):0)},Ve=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)?W(c(o,s)):0):d(e,A)?hA(c(o,s)):0},W=A=>{let e=s;if(A!=null&&A!==64&&A!==35&&A!==47&&A!==63&&(A!==92||!I(i.scheme))){let t=s+M(A);for(;t<o.length;){let n=c(o,t);if(n==null||n===64||n===35||n===47||n===63||n===92&&I(i.scheme))break;t+=M(n)}return g+=o.slice(s,t),s=t-1,d(e,A)?W(c(o,s)):0}if(A===64){lA&&(g=`%40${g}`),lA=!0;for(let t=0;t<g.length;t++){let n=g.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 g="",d(e,A)?W(c(o,s)):0}else return A==null||A===35||A===47||A===63||A===92&&I(i.scheme)?lA&&g===""?1:(s-=g.length+1,g="",d(e,A)?aA(c(o,s)):0):(g+=le(A),d(e,A)?W(c(o,s)):0)},aA=A=>{let e=s;if(E&&i.scheme==="file")return s--,d(e,A)?LA(c(o,s)):0;if(A!=null&&A!==58&&A!==35&&A!==47&&A!==63&&(A!==92||!I(i.scheme))){let t=s+M(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&&I(i.scheme))break;n===91?G=!0:n===93&&(G=!1),t+=M(n)}return g+=o.slice(s,t),s=t-1,d(e,A)?aA(c(o,s)):0}else if(A===58&&!G){if(g===""||E===4)return 1;let t=EA(g,!I(i.scheme));return t===null?1:(i.host=vA(t),g="",d(e,A)?RA(c(o,s)):0)}else if(A==null||A===35||A===47||A===63||A===92&&I(i.scheme)){if(s--,I(i.scheme)&&g==="")return 1;if(E&&g===""&&(ie(i)||i.port!==null))return 1;let t=EA(g,!I(i.scheme));return t===null?1:(i.host=vA(t),g="",E?0:d(e,A)?Y(c(o,s)):0)}else return g+=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 g+=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&&I(i.scheme)){if(g!==""){let t=parseInt(g,10);if(t>65535)return 1;if(i.port=t===se(i.scheme)?null:t,g="",E)return 0}return E?1:(s--,d(e,A)?Y(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)?Ke(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)?x(c(o,s)):0):A!=null?(i.query=null,ce(o,s)?i.path=[]:oe(i),s--,d(e,A)?j(c(o,s)):0):d(e,A)?kA(c(o,s)):0):(s--,d(e,A)?j(c(o,s)):0)},Ke=A=>{let e=s;return A===47||A===92?d(e,A)?LA(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)?j(c(o,s)):0)},LA=A=>{let e=s;if(A!=null&&A!==47&&A!==92&&A!==63&&A!==35){let t=s+M(A);for(;t<o.length;){let n=c(o,t);if(n==null||n===47||n===92||n===63||n===35)break;t+=M(n)}return g+=o.slice(s,t),s=t-1,d(e,A)?LA(c(o,s)):0}else if(A==null||A===47||A===92||A===63||A===35){if(s--,!E&&re(g))return d(e,A)?j(c(o,s)):0;if(g==="")return i.host="",E?0:d(e,A)?Y(c(o,s)):0;{let t=EA(g,!I(i.scheme));return t===null?1:(t==="localhost"&&(t=""),i.host=vA(t),g="",E?0:d(e,A)?Y(c(o,s)):0)}}return 1},Y=A=>{let e=s;return I(i.scheme)?(A!==92&&A!==47&&s--,d(e,A)?j(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)?x(c(o,s)):0):A!=null?(A!==47&&s--,d(e,A)?j(c(o,s)):0):(E&&i.host===null&&i.path.push(""),d(e,A)?Y(c(o,s)):0)},j=A=>{let e=s;if(A!=null&&A!==47&&(!I(i.scheme)||A!==92)&&(E||A!==63&&A!==35)){let t=s+M(A);for(;t<o.length;){let n=c(o,t);if(n==null||n===47||I(i.scheme)&&n===92||!E&&(n===63||n===35))break;t+=M(n)}g+=_(o.slice(s,t),SA),s=t,A=c(o,t)}if(A==null||A===47||I(i.scheme)&&A===92||!E&&(A===63||A===35)){let t=I(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}})(g)?(oe(i),A!==47&&!t&&i.path.push("")):JA(g)&&A!==47&&!t?i.path.push(""):JA(g)||(i.scheme==="file"&&i.path.length===0&&re(g)&&(g=`${g[0]}:`),i.path.push(g)),g="",A===63?(i.query="",d(e,A)?Q(c(o,s)):0):A===35?(i.fragment="",d(e,A)?x(c(o,s)):0):d(e,A)?j(c(o,s)):0}else return g+=ee(A,SA),d(e,A)?j(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)?x(c(o,s)):0;if(A!=null){let t=s+M(A);for(;t<o.length;){let r=c(o,t);if(r===63||r===35)break;t+=M(r)}let n=o.slice(s,t);if(t<o.length&&n.charCodeAt(n.length-1)===32?i.path[0]+=_(n.slice(0,-1),AA)+"%20":i.path[0]+=_(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)?x(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=I(i.scheme)?Se:qA;i.query+=_(o.slice(s,t),n)}return s=t,c(o,t)===35&&!E?(i.fragment="",d(e,A)?x(c(o,s)):0):d(e,A)?Q(c(o,s)):0},x=A=>{let e=s;return A!=null&&(i.fragment+=_(o.slice(s),be),s=o.length),d(e,A)?x(c(o,s)):0};function TA(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=B(TA(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 b=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=S(e),t!=null&&(t=S(t));let n=null;if(t!=null&&(n=B(t,null,null,0),n==null))throw new TypeError(`Invalid base URL: ${t}`);let r=B(e,null,n,0);if(r==null)throw new TypeError(`Invalid URL: ${e}`);this[b]={url:r,query:null}}static createObjectURL(e){throw new TypeError("URL.createObjetURL is unsupported")}static revokeObjectURL(e){}static parse(e,t){e=S(e),t!==void 0&&(t=S(t));try{return new A(e,t)}catch{return null}}static canParse(e,t){e=S(e),t!==void 0&&(t=S(t));let n=null;return t!=null&&(n=B(t,null,null,0),n==null)?!1:B(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+=TA(t),t.query!==null&&(n+=`?${t.query}`),t.fragment!==null&&(n+=`#${t.fragment}`),n})(this[b].url)}set href(e){let t=B(e=S(e),null,null,0);if(t==null)throw new TypeError(`Invalid URL: ${e}`);this[b].url=t,this[b].query&&yA(this[b].query,t.query)}get origin(){return fe(this[b].url)}get protocol(){return`${this[b].url.scheme}:`}set protocol(e){B(`${e=S(e)}:`,this[b].url,null,2)}get username(){return this[b].url.username}set username(e){e=S(e),wA(this[b].url)||(function(n,r){n.username=_(r,cA)})(this[b].url,e)}get password(){return this[b].url.password}set password(e){e=S(e),wA(this[b].url)||(function(n,r){n.password=_(r,cA)})(this[b].url,e)}get host(){let{url:e}=this[b];return e.host==null?"":e.port==null?e.host:`${e.host}:${e.port}`}set host(e){e=S(e),this[b].url.opaquePath||B(e,this[b].url,null,3)}get hostname(){let{url:e}=this[b];return e.host!=null?e.host:""}set hostname(e){e=S(e),this[b].url.opaquePath||B(e,this[b].url,null,4)}get port(){let{url:e}=this[b];return e.port!=null?`${e.port}`:""}set port(e){e=S(e);let{url:t}=this[b];wA(t)||(e?B(e,t,null,5):t.port=null)}get pathname(){return TA(this[b].url)}set pathname(e){e=S(e);let{url:t}=this[b];t.opaquePath||(t.path=[],B(e,t,null,6))}get search(){let{url:e}=this[b];return e.query?`?${e.query}`:""}set search(e){e=S(e);let{url:t,query:n}=this[b];if(!e)t.query=null,n&&yA(n,null);else{let r=e[0]==="?"?e.substring(1):e;t.query="",B(r,t,null,7),n&&yA(n,t.query)}}get searchParams(){let e=this[b],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=NA(u)),l})(this,e.url.query)),t}get hash(){let{url:e}=this[b];return e.fragment?`#${e.fragment}`:""}set hash(e){e=S(e);let{url:t}=this[b];if(!e)t.fragment=null;else{let n=e[0]==="#"?e.substring(1):e;t.fragment="",B(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"),Je=Symbol.dispose||Symbol.for("dispose");function yA(A,e){e?A[C].list=NA(e):A[C].list.length=0,A[C].serialized=e==null}function oA(A){if(A.url){let e=CA(A.list);(function(n,r){n[b].url.query=r})(A.url,e||null),A.serialized=!0}}var We=typeof Iterator<"u"?Iterator:Object,Z=class extends We{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}[Je](){}},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=PA(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=Pe(l),f=S(e[l]),h=t.list.find(m=>m[0]===a);h?h[1]=f:t.list.push([a,f])}}else if(e!==void 0){let r=S(e);r=r[0]==="?"?r.substring(1):r,t.list=NA(r)}}get size(){return this[C].list.length}append(e,t){e=S(e),t=S(t),this[C].list.push([e,t]);let n=this[C];n.url&&n.serialized?(function(u,l){let a=u[b].url;a.query=a.query?`${a.query}&${l}`:l})(n.url,CA([[e,t]])):oA(n)}delete(e,t){e=S(e),t=t!=null?S(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=S(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=S(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=S(e),t=t!=null?S(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=S(e),t=S(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 CA(this[C].list)}[Symbol.iterator](){return this.entries()}};Object.defineProperty(fA.prototype,Symbol.toStringTag,{value:"URLSearchParams",configurable:!0});function he(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 w=++n;r=void 0,e=void 0;for(let y of[...u.values()])try{y?.()}catch{}w===n&&(e=p,l())}let f=()=>a();function h(p,w=!1){let y=$A.safeParse(p);if(!y.success||w&&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 m(){if(r)return r;let p=typeof e=="object"?e:void 0,w=n;if(!p||Date.parse(p.refreshExpiresAt)<=Date.now())throw p&&f(),new P("UNAUTHENTICATED","Customer authentication is required",401);let y=(async()=>{try{let N=await A(p.refreshToken);if(w!==n)throw new P("IDENTITY_CHANGED","Customer identity changed during refresh");let V=h(N,!0);if(V.customerId!==p.customerId||V.sessionId!==p.sessionId)throw new P("SCOPE_MISMATCH","Refresh changed the customer session");return e=V,{...V}}catch(N){throw w!==n?new P("IDENTITY_CHANGED","Customer identity changed during refresh"):(N instanceof P&&N.status===401&&f(),N)}})();r=y;try{return await y}finally{r===y&&(r=void 0)}}return{identify(p){let w=typeof p=="string"?p:h(p),y=typeof w=="string"?w:w.accessToken;if(!y.trim()||/\s/.test(y)||y.length>4096)throw new P("INVALID_TOKEN","A server-issued token is required");a(w)},reset:f,subscribeIdentity(p,w){return u.set(p,w),()=>{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 m().then(()=>{let N=t();if(y!==n||!N)throw new P("IDENTITY_CHANGED","Customer identity changed during refresh");return N})}let w=t();if(!w)throw new P("NOT_IDENTIFIED","Identify a customer session before making a request");return w},peek:t,snapshot:()=>typeof e=="object"?{...e}:void 0,refresh:m}}var de=Symbol("IndianaNoContent");function ut(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),f=A.timeoutMs??1e4;if(!Number.isFinite(f)||f<1||f>12e4)throw new P("INVALID_TIMEOUT","timeoutMs must be between 1 and 120000");let h=!1,m=0,p=null,w=new Set,y=A.session??he(async q=>{let O=await tA("customer-sessions/refresh",{},"POST",{},q);if(!O||typeof O!="object")throw new P("INVALID_RESPONSE","Invalid refresh response");let{requestId:$,scope:H,...K}=O;return K});function N(){m+=1,p=null;for(let q of w)q.abort();w.clear()}let V=y.subscribeIdentity(N);function pe(){h||y.reset()}async function tA(q,O={},$="POST",H={},K){let k=H.installationDetach===!0;if(k&&(q!=="push/installations/detach"||$!=="POST"))throw new P("INVALID_REQUEST","Installation authority only detaches this installation");if(!K&&!k)throw new P("NOT_IDENTIFIED","Call identify with a server-issued customer token first");let J=m,L=new AbortController;k||w.add(L);let nA=()=>!k&&J!==m?new P("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):new P("TIMEOUT","Longplay request timed out"),dA,ge=new Promise((T,R)=>{dA=()=>R(nA()),L.signal.addEventListener("abort",dA,{once:!0})}),me=setTimeout(()=>L.abort(),H.timeoutMs??f),we=async()=>{let T=await a(`${l.href.replace(/\/$/,"")}/api/v1/${q}`,{method:$,headers:{...H.headers,"Content-Type":"application/json",...k?{}:{Authorization:`Bearer ${K}`},[pA]:gA.current,[xA]:zA.version,...u?{"X-Indiana-Project":u.projectId,"X-Indiana-Environment":u.environment}:{}},body:$==="POST"?JSON.stringify(O):void 0,signal:L.signal,credentials:"omit",cache:"no-store",redirect:"error",...H.keepalive?{keepalive:!0}:{}});if(L.signal.aborted)throw nA();let R;try{R=T.status===204?de:await T.json()}catch{throw L.signal.aborted?nA():new P(T.ok?"INVALID_RESPONSE":"HTTP_ERROR","The gateway returned an unreadable response",T.status,T.headers.get("X-Request-Id")??void 0)}if(L.signal.aborted)throw nA();if(!k&&J!==m)throw new P("IDENTITY_CHANGED","Customer identity changed while the request was in flight");if(!T.ok){let v=UA.safeParse(R),z=v.success&&(!MA.safeParse(v.data.error.code).success||jA(v.data.error.code,T.status)),BA=z?v.data.error.code:"HTTP_ERROR",HA=_A(BA,T.status,{retryAfter:T.headers.get("Retry-After"),recovery:z?v.data.error.recovery:void 0,reason:z?v.data.error.reason:void 0});throw new P(BA,z?v.data.error.message:"Longplay request failed",T.status,T.headers.get("X-Request-Id")??(v.success?v.data.requestId:void 0),{...HA,...v.success&&v.data.error.retryable===!1?{retryable:!1}:{},...HA.retryAfterSeconds===void 0&&v.success&&v.data.error.retryAfterSeconds!==void 0?{retryAfterSeconds:v.data.error.retryAfterSeconds}:{}})}if(T.headers.get(pA)!==gA.current)throw new P("PROTOCOL_MISMATCH","Response protocol does not match this SDK");if(u&&R!==de){let v=R&&typeof R=="object"&&"scope"in R?R:R&&typeof R=="object"&&"configuration"in R?R.configuration:null;if(!v||typeof v!="object"||!("scope"in v))throw new P("INVALID_RESPONSE","Response is missing its App/environment scope");let z=sA.safeParse(v.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=T.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 R};try{return await Promise.race([we(),ge])}catch(T){throw!k&&J!==m?new P("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):T instanceof P?T:new P(L.signal.aborted?"TIMEOUT":"NETWORK_ERROR",L.signal.aborted?"Longplay request timed out":"Unable to read the Longplay response")}finally{clearTimeout(me),L.signal.removeEventListener("abort",dA),w.delete(L)}}return{session:y,requestWithCredential(q,O,$,H={}){return h?Promise.reject(new P("CLOSED","SDK client was destroyed")):tA(q,O,"POST",H,$)},subjectKey:()=>p,identify(q){if(h)throw new P("CLOSED","SDK client was destroyed");if(u&&typeof q=="object"&&"scope"in q){let O=sA.safeParse(q.scope);if(!O.success||O.data.projectId!==u.projectId||O.data.environment!==u.environment)throw new P("SCOPE_MISMATCH","Customer session belongs to another App/environment")}y.identify(q)},reset:pe,dispose(){h||(h=!0,V(),N())},request(q,O={},$="POST",H={}){if(h)return Promise.reject(new P("CLOSED","SDK client was destroyed"));if(H.installationDetach)return tA(q,O,$,H);let K=m;try{let k=y.access(),J=L=>{if(K!==m)throw new P("IDENTITY_CHANGED","Customer identity changed before dispatch");return tA(q,O,$,H,L)};return typeof k=="string"?J(k):k.then(J)}catch(k){return Promise.reject(k)}}}}export{eA as a,ut as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as fe}from"./chunk-FSQ75ZCZ.js";import{a as B}from"./chunk-34I23EKZ.js";import{g as he,h as Ie,j as we,l as ge,p as M,r as ye}from"./chunk-EEHL2BP6.js";import{a as V,i as G}from"./chunk-RKREEPCT.js";import{b as me}from"./chunk-NHQBONYJ.js";import{a as s}from"./chunk-SJNF6JDJ.js";import{Ga as ue,db as ce,eb as le,fb as de,ma as L,pb as pe}from"./chunk-BYLU5UY5.js";import{a as ee}from"./chunk-DSPLGTQI.js";import{a as se}from"./chunk-MHEYMXGZ.js";import{z as m}from"zod";var be=L.options[0].refine(l=>!l.customer&&!l.customerData),Fe=m.strictObject({receiptId:m.uuid(),operationId:m.uuid(),terminal:m.enum(["complete","native"]).nullable()}),Se=m.strictObject({schemaVersion:m.literal(1),baseUrl:m.url(),scope:se,customerId:m.uuid(),sessionId:m.uuid(),start:be,allowed:m.array(m.enum(["merchant","record_only","indiana","native"])),run:m.strictObject({id:m.uuid(),versionId:m.uuid(),status:ue.shape.status,revision:m.number().int().nonnegative(),runExpiresAt:m.iso.datetime({offset:!0}).optional()}).optional(),purchases:m.array(Fe).max(100),operationCommand:m.strictObject({operationId:m.uuid(),intent:m.literal("confirm")}).optional(),journal:m.strictObject({revision:m.number().int().nonnegative(),entry:he.nullable()})});function Pe(l){return we({...l,namespace:"purchases",identity:[l.scope.projectId,l.scope.environment,l.customerId]})}function Ce(l){let c=new URL(l.baseUrl??pe).href,E=()=>new s("PURCHASE_STORAGE_INVALID","Purchase recovery storage is unavailable or invalid; native fallback is not authorized");async function C(){l.assertCurrent();try{let w=await l.storage.read();if(l.assertCurrent(),!Number.isSafeInteger(w.revision)||w.revision<0)throw E();let r=w.entry===null?null:Se.parse(w.entry);if(r&&(r.baseUrl!==c||r.customerId!==l.customerId||r.scope.projectId!==l.scope.projectId||r.scope.environment!==l.scope.environment))throw new s("SCOPE_MISMATCH","Purchase recovery belongs to another Customer or environment");if(r?.journal.entry&&(r.journal.entry.scope.projectId!==r.scope.projectId||r.journal.entry.scope.environment!==r.scope.environment||r.journal.entry.funnelId!==r.start.funnelId||r.journal.entry.runId!==r.run?.id||r.journal.entry.versionId!==r.run?.versionId)||r?.operationCommand&&!r.purchases.some(P=>P.operationId===r.operationCommand?.operationId))throw E();return{revision:w.revision,entry:r}}catch(w){throw w instanceof s?w:E()}}async function z(w){for(let r=0;r<8;r++){let P=await C(),R=w(structuredClone(P.entry));if(JSON.stringify(R)===JSON.stringify(P.entry))return R;R&&Se.parse(R),l.assertCurrent();let v;try{v=await l.storage.write(P.revision,R)}catch{throw E()}if(l.assertCurrent(),v!==null){if(!Number.isSafeInteger(v)||v<=P.revision)throw E();return R}}throw new s("PURCHASE_STORAGE_CONFLICT","Another consumer changed this purchase; recover the original attempt")}return{read:C,update:z,baseUrl:c}}function Oe(l){let c=l.purchases.find(E=>E.type==="checkout");if(!l.actions.includes("continue_checkout")||c?.type!=="checkout")throw new s("PURCHASE_PENDING","No single resumable Checkout is confirmed");return c.checkoutUrl}function Ke(l){let c={...l,scope:{...l.scope},executionPolicy:structuredClone(l.executionPolicy)},E=c.session.snapshot();if(!E)throw new s("CUSTOMER_SESSION_REQUIRED","Purchase recovery requires a verified Customer session");let{customerId:C,sessionId:z}=E,w=!1,r=null,P,R=null,v=!1,O,T,U,b={mode:"idle",status:"idle",actions:["start"],purchases:[]},h=new Map,A=new Map,ne=new AbortController,k=new Set,Q=me(c),te=fe(Q.request);function D(e){return{code:e instanceof s?e.code:"PURCHASE_RECOVERY_BLOCKED",message:e instanceof Error?e.message:"The original purchase requires server confirmation",...e instanceof s&&e.status!==void 0?{status:e.status}:{}}}function y(){if(w||c.session.snapshot()?.customerId!==C)throw new s("IDENTITY_CHANGED","The original purchase Customer changed")}let I=Ce({...c,customerId:C,assertCurrent:y,storage:c.storage??Pe({baseUrl:c.baseUrl,scope:c.scope,customerId:C})}),Ee=c.session.subscribeIdentity(re);function re(){w||(w=!0,clearTimeout(U),ne.abort(new s("IDENTITY_CHANGED","Purchase consumer was destroyed")),Ee(),r?.reset(),r=null,R=null,Q.dispose(),k.clear(),h.clear(),A.clear())}function S(e){y();let n=JSON.stringify(e)!==JSON.stringify(b);b=e,clearTimeout(U),(e.mode==="operation"||e.mode==="run"&&!e.actions.includes("close"))&&["waiting_result","fulfillment","recording"].includes(e.status)&&(U=setTimeout(()=>{_().catch(()=>{})},5e3)),n&&ee(c.onRecovery,structuredClone(e));for(let t of n?k:[]){if(w)break;ee(t,structuredClone(e))}return structuredClone(e)}function f(e){if(y(),!e||e.start.requestId!==P)throw new s("PURCHASE_STORAGE_CONFLICT","This purchase was superseded; the old consumer cannot dispatch")}function F(e){let n=[...e.purchases],t=e.journal.entry?.purchase;return t&&!n.some(i=>i.operationId===t.operationId)&&n.push({receiptId:t.receiptId,operationId:t.operationId,terminal:null}),n}function x(e){return e.run&&!["running","waiting"].includes(e.run.status)&&!e.journal.entry?.command&&!e.journal.entry?.closeCommand&&!e.operationCommand&&F(e).every(n=>n.terminal!==null)}function q(e,n){let t=e.journal.entry?.command??e.journal.entry?.closeCommand,i=F(e).map(g=>{let Z=h.get(g.operationId);return g.terminal&&!Z?{type:g.terminal,operationId:g.operationId}:V({quote:Z?.quote??null,operation:Z??null,requestId:t?.requestId??null,pending:!1,destroyed:!1,canReselect:A.get(g.operationId)===!0})}),u=i.filter(g=>!["complete","native"].includes(g.type)),o=u[0],a=u.length===1&&o?.operationId?h.get(o.operationId):void 0;if(a&&(o?.type==="checkout"||o?.type==="cancel"))try{M({allowed:e.allowed.filter(g=>c.executionPolicy.allowed.includes(g))},a.quote)}catch(g){return{mode:n,status:"blocked",actions:["refresh",...n==="run"&&e.run&&["running","waiting"].includes(e.run.status)?["close"]:[]],purchases:i,error:D(g)}}let d;if(n==="operation"&&!t&&o?.type==="cancel"&&a?.quote&&!a.problem&&!a.confirmedAt)try{M({allowed:e.allowed.filter(g=>c.executionPolicy.allowed.includes(g))},a.quote),Date.parse(a.quote.expiresAt)>Date.now()&&(d={operationId:a.operationId,quote:a.quote})}catch{}let p=i.length>0&&u.length===0,j=x(e)||n==="operation"&&p&&!t&&!e.operationCommand?"complete":o?.type==="checkout"?"checkout":o?.type==="fulfillment"?"fulfillment":o?.type==="recording"?"recording":t||e.operationCommand||o&&o.type!=="cancel"||n==="operation"&&!d?"waiting_result":"ready";return{mode:n,status:j,purchases:i,...d?{confirmation:structuredClone(d)}:{},actions:["refresh",...x(e)?["start"]:[],...n==="run"&&e.run&&["running","waiting"].includes(e.run.status)?["close"]:[],...e.operationCommand?["retry"]:d?["confirm"]:[],...u.length===1&&o?.type==="checkout"?["continue_checkout"]:[]]}}function J(e){let n=V({quote:e?.quote??null,operation:e??null,requestId:null,pending:!1,destroyed:!1,canReselect:e&&A.get(e.operationId)===!0});return n.type==="complete"||n.type==="native"?n.type:null}function K(e){if(!e.operation)return;let n={...e.operation,...e.operation.quote?{}:e.quote?{quote:e.quote}:{}};if(n.merchantExecution&&n.merchantExecution.customerId!==C)throw new s("SCOPE_MISMATCH","Purchase execution belongs to another Customer");let t=G(h.get(n.operationId)??null,n);h.set(n.operationId,t),t===n&&A.set(n.operationId,e.canReselect===!0)}async function ve(e){y();for(let t of[e.purchase,e.run.paywall])t&&K(t);let n=await I.update(t=>{if(f(t),t.run&&(t.run.id!==e.run.id||t.run.versionId!==e.run.source.versionId))throw new s("SCOPE_MISMATCH","The original purchase Run changed");let i=F(t);for(let u of[e.purchase,e.run.paywall]){let o=u?.operation?.operationId??u?.quote?.operationId;if(!u||!o)continue;let a=i.find(p=>p.operationId===o);if(a&&a.receiptId!==u.receiptId)throw new s("INVALID_RESPONSE","The original purchase Receipt changed");let d=J(h.get(o));a?a.terminal??=d:i.push({receiptId:u.receiptId,operationId:o,terminal:d})}return{...t,purchases:i,run:t.run&&(t.run.revision>e.run.revision||!["running","waiting"].includes(t.run.status)&&["running","waiting"].includes(e.run.status))?t.run:{id:e.run.id,versionId:e.run.source.versionId,status:e.run.status,revision:e.run.revision,runExpiresAt:e.run.runExpiresAt}}});f(n),n.run&&!["running","waiting"].includes(n.run.status)&&F(n).some(t=>!t.terminal)&&(n=await Y(n,!n.journal.entry?.command&&!n.journal.entry?.closeCommand,new Set([e.purchase?.operation?.operationId,e.run.paywall?.operation?.operationId].filter(t=>!!t)))),f(n),S(q(n,"run"))}function Re(){return{async read(){let{entry:e}=await I.read();return f(e),structuredClone(e.journal)},async write(e,n){let t=null;return await I.update(i=>{if(f(i),i.operationCommand&&n?.command&&n.command.operation!=="close")throw new s("PURCHASE_PENDING","Recover the original Operation command before dispatching a Run mutation");return t=null,i.journal.revision!==e?i:(t=e+1,{...i,journal:{revision:t,entry:n}})}),t}}}async function Y(e,n=!1,t=new Set){f(e);let i=F(e);for(let o of i){if(o.terminal)continue;let a=t.has(o.operationId)?h.get(o.operationId):void 0;if(a??=await oe(e,o),y(),a.operationId!==o.operationId)throw new s("INVALID_RESPONSE","Original Operation changed");if(a.merchantExecution&&a.merchantExecution.customerId!==C)throw new s("SCOPE_MISMATCH","Purchase execution belongs to another Customer");if(n&&!e.operationCommand&&V({quote:a.quote??null,operation:a,requestId:null,pending:!1,destroyed:!1}).type==="cancel"){if({operation:a}=await te.attach({operationId:o.operationId,intent:"cancel"}),y(),a.operationId!==o.operationId)throw new s("INVALID_RESPONSE","Original cancellation Operation changed");a=await oe(e,o)}h.set(o.operationId,G(h.get(o.operationId)??null,a))}let u=await I.update(o=>{f(o);let a=o.operationCommand&&h.get(o.operationCommand.operationId);return{...o,...a&&(a.confirmedAt||a.merchantExecution||a.status!=="pending")?{operationCommand:void 0}:{},purchases:F(o).map(d=>({...d,terminal:d.terminal??J(h.get(d.operationId))}))}});return f(u),u}async function W(e){y();let n=await Q.request("funnels",e);return y(),n}async function oe(e,n){let t=B(de,await W({operation:"recover_purchase",runId:e.run.id,funnelId:e.start.funnelId,purchase:{receiptId:n.receiptId,operationId:n.operationId}}));if($(e,t),t.purchase.receiptId!==n.receiptId||t.purchase.operation?.operationId!==n.operationId)throw new s("INVALID_RESPONSE","Original purchase reference changed");return K(t.purchase),h.get(n.operationId)}async function ae(e){for(let n of[e.journal.entry?.command,e.journal.entry?.closeCommand]){if(!n)continue;let t=B(le,await W({operation:"settle_command",runId:e.run.id,funnelId:e.start.funnelId,requestId:n.requestId,...n.operation==="resume"?{}:{command:n}}));if($(e,t),t.settlement.requestId!==n.requestId)throw new s("INVALID_RESPONSE","Original command settlement changed");t.purchase&&K(t.purchase);let i=await I.update(u=>{f(u);let o=F(u),{receiptId:a,operationId:d}=t.settlement;if(a&&d){let j=o.find(g=>g.operationId===d);if(j&&j.receiptId!==a)throw new s("INVALID_RESPONSE","Original Receipt changed");j||o.push({receiptId:a,operationId:d,terminal:J(h.get(d))})}let p=t.settlement.state==="settled"?Ie(u.journal.entry,n.requestId):u.journal.entry;return{...u,purchases:o,journal:p===u.journal.entry?u.journal:{revision:u.journal.revision+1,entry:p}}});f(i),e=i}return e}function $(e,n){if(n.customerId!==C||n.scope.projectId!==c.scope.projectId||n.scope.environment!==c.scope.environment||n.target.funnelId!==e.start.funnelId||n.target.startRequestId!==e.start.requestId||e.run&&(n.target.runId!==e.run.id||n.target.versionId!==e.run.versionId))throw new s("SCOPE_MISMATCH","The original recovery binding changed")}async function X(e,n){if(f(e),e.run&&(e=await ae(e)),!F(e).length&&x(e))return S(q(e,"operation"));if(!F(e).length)return S({mode:"blocked",status:"blocked",actions:["refresh"],purchases:[],error:D(n)});v=!0;let t=await Y(e);return S(q(t,"operation"))}async function H(e,n=!1,t=!0){if(P=e.start.requestId,R=structuredClone({requestId:e.start.requestId,funnelId:e.start.funnelId,locale:e.start.locale,parameters:e.start.parameters}),!r){let i=e.run?{operation:"recover_run",runId:e.run.id,funnelId:e.start.funnelId}:{operation:"recover_start",intent:n?"resume":"lookup",start:{requestId:e.start.requestId,funnelId:e.start.funnelId,locale:e.start.locale,parameters:e.start.parameters}},u;try{u=await W(i)}catch(p){if(!e.run&&p instanceof s&&(p.status===void 0||p.status>=500))return S({mode:"blocked",status:"blocked",actions:["refresh","retry"],purchases:b.purchases,error:D(p)});throw p}let o=B(ce,u);if(o.customerId!==C||o.scope.projectId!==c.scope.projectId||o.scope.environment!==c.scope.environment)throw new s("SCOPE_MISMATCH","Recovery Customer or environment changed");if(o.outcome==="unknown")return S({mode:"blocked",status:"blocked",actions:["refresh","retry"],purchases:b.purchases,error:{code:"RESULT_UNKNOWN",message:"The original Start outcome remains unknown; retry only its original input"}});$(e,o);let a=await I.update(p=>(f(p),{...p,run:{id:o.target.runId,versionId:o.target.versionId,status:o.target.status,revision:o.view?.revision??p.run?.revision??0,runExpiresAt:o.target.runExpiresAt}}));if(f(a),e=a,o.access.type==="operation_only")return X(e,new s("RUN_RECONCILIATION_REQUIRED","Only the original command and Operation can be recovered"));e=await ae(e);let d=o.view;if(d.locale!==e.start.locale||!ge(d.parameters,e.start.parameters))throw new s("INVALID_RESPONSE","The original Start input changed");r=ye({...c,customerRun:{runId:o.target.runId,customerId:C,startRequestId:e.start.requestId},funnelId:e.start.funnelId,funnelExecutionPolicy:{allowed:e.allowed.filter(p=>c.executionPolicy.allowed.includes(p))},funnelCommandStorage:Re(),onAcceptedResponse:ve},{scope:o.scope,run:d})}try{await r.get(),r.view?.pendingRequest?.requestId===e.start.requestId&&!r.pendingCommands?.length&&await r.resume(r.view.pendingRequest.requestId);for(let u of r.pendingCommands??[])u.operation!=="close"&&await r.settle?.(u.requestId);r.pendingCommands?.length&&await r.retry(),y();let i=(await I.read()).entry;return f(i),S(q(i,"run"))}catch(i){if(y(),t&&i instanceof s&&(i.status===401||i.status===409&&i.reason==="STATE_CHANGED")){r.reset(),r=null;let u=(await I.read()).entry;return f(u),H(u,!1,!1)}throw i}}function N(e,n="read"){if(y(),O)return n==="read"||n===T?O:O.then(()=>N(e,n),()=>N(e,n));clearTimeout(U);let t=e().catch(i=>{throw w||S({mode:"blocked",status:"blocked",actions:["refresh"],purchases:b.purchases,error:D(i)}),i});return O=t,T=n,t.then(()=>{O===t&&(O=void 0,T=void 0)},()=>{O===t&&(O=void 0,T=void 0)}),t}function _(){return N(async()=>{let{entry:e}=await I.read();return e?(P&&e.start.requestId!==P&&(r?.reset(),r=null,h.clear(),A.clear()),v&&P===e.start.requestId?X(e,b.error):H(e)):S({mode:"idle",status:"idle",actions:["start"],purchases:[]})})}async function ie(){let e=await _();return e.mode==="operation"&&!e.actions.includes("confirm")&&!e.actions.includes("retry")?e:N(async()=>{let n=(await I.read()).entry;if(f(n),!v){if(!r?.view?.paywall?.quote)throw new s("PURCHASE_PENDING","Read the original quote before confirming");let a=r.view.paywall.operation;if(a?.confirmedAt||a?.merchantExecution||a&&a.status!=="pending")return S(q(n,"run"));if(r.pendingCommands?.length)await r.retry();else{let p=r.view;await r.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:p.nodeId,visit:p.visit,revision:p.revision,input:{type:"paywall_confirm",operationId:p.paywall.quote.operationId}})}let d=(await I.read()).entry;return f(d),S(q(d,"run"))}let t=n.operationCommand?.operationId??b.confirmation?.operationId,i=t&&h.get(t);if(!t||!i||n.journal.entry?.command||n.journal.entry?.closeCommand)throw new s("PURCHASE_PENDING","The original Run command must be settled before Operation confirmation");M({allowed:n.allowed.filter(a=>c.executionPolicy.allowed.includes(a))},i.quote),await I.update(a=>{if(f(a),a.journal.entry?.command||a.journal.entry?.closeCommand||a.operationCommand&&a.operationCommand.operationId!==t)throw new s("PURCHASE_PENDING","Another original command is pending");return{...a,operationCommand:{operationId:t,intent:"confirm"}}});let u=await te.attach({operationId:t,intent:"confirm"});if(y(),u.operation.operationId!==t)throw new s("INVALID_RESPONSE","Original confirmation Operation changed");h.set(t,G(i,u.operation));let o=(await I.read()).entry;return f(o),S(q(await Y(o,!1,new Set([t])),"operation"))},"confirm")}return{get controller(){return r},get recovery(){return structuredClone(b)},get attempt(){return y(),structuredClone(R)},get identitySignal(){return ne.signal},start(e){let n=L.parse({...structuredClone(e),operation:"start",requestId:e.requestId??crypto.randomUUID()});if(n.operation!=="start"||n.customer||n.customerData)throw new s("INVALID_REQUEST","A Customer-owned Funnel start is required");return N(async()=>{let t=await I.update(i=>{if(i&&!x(i)){if(i.start.funnelId!==n.funnelId)throw new s("PURCHASE_PENDING","Recover the original Funnel before starting another purchase");return i}return{schemaVersion:1,baseUrl:I.baseUrl,scope:c.scope,customerId:C,sessionId:z,start:n,allowed:[...c.executionPolicy.allowed],purchases:[],journal:{revision:0,entry:null}}});if(!t)throw new s("PURCHASE_STORAGE_INVALID","Original start was not retained");return P!==t.start.requestId&&(r?.reset(),r=null,h.clear(),A.clear(),v=!1),v?X(t,b.error):H(t,!0)},`start:${n.funnelId}`)},refresh:_,confirm:ie,retry:()=>v?ie():N(async()=>{let{entry:e}=await I.read();return e?H(e,!0):S({mode:"idle",status:"idle",actions:["start"],purchases:[]})},"retry"),async close(){return r?.view?N(async()=>{if(!r?.view)throw new s("PURCHASE_PENDING","Recover the original Run before closing");if(r.pendingCommands?.find(t=>t.operation==="close"))await r.retry();else if(["running","waiting"].includes(r.view.status)){let t=r.view;await r.submit({operation:"close",requestId:crypto.randomUUID(),nodeId:t.nodeId,visit:t.visit,revision:t.revision})}let n=(await I.read()).entry;return f(n),S(q(n,"run"))},"close"):_()},async continueCheckout(e){let n=await _();y(),await e(Oe(n))},subscribe(e){return k.add(e),()=>{k.delete(e)}},destroy:re}}export{Pe as a,Oe as b,Ke as c};
|
|
1
|
+
import{b as fe}from"./chunk-THGLNE4K.js";import{a as B}from"./chunk-34I23EKZ.js";import{g as he,h as Ie,j as we,l as ge,p as M,r as ye}from"./chunk-LFFBNGXP.js";import{a as V,i as G}from"./chunk-RKREEPCT.js";import{b as me}from"./chunk-5HJMAZ7A.js";import{a as s}from"./chunk-SJNF6JDJ.js";import{Ga as ue,db as ce,eb as le,fb as de,ma as L,pb as pe}from"./chunk-O4535GJR.js";import{a as ee}from"./chunk-DSPLGTQI.js";import{a as se}from"./chunk-MHEYMXGZ.js";import{z as m}from"zod";var be=L.options[0].refine(l=>!l.customer&&!l.customerData),Fe=m.strictObject({receiptId:m.uuid(),operationId:m.uuid(),terminal:m.enum(["complete","native"]).nullable()}),Se=m.strictObject({schemaVersion:m.literal(1),baseUrl:m.url(),scope:se,customerId:m.uuid(),sessionId:m.uuid(),start:be,allowed:m.array(m.enum(["merchant","record_only","indiana","native"])),run:m.strictObject({id:m.uuid(),versionId:m.uuid(),status:ue.shape.status,revision:m.number().int().nonnegative(),runExpiresAt:m.iso.datetime({offset:!0}).optional()}).optional(),purchases:m.array(Fe).max(100),operationCommand:m.strictObject({operationId:m.uuid(),intent:m.literal("confirm")}).optional(),journal:m.strictObject({revision:m.number().int().nonnegative(),entry:he.nullable()})});function Pe(l){return we({...l,namespace:"purchases",identity:[l.scope.projectId,l.scope.environment,l.customerId]})}function Ce(l){let c=new URL(l.baseUrl??pe).href,E=()=>new s("PURCHASE_STORAGE_INVALID","Purchase recovery storage is unavailable or invalid; native fallback is not authorized");async function C(){l.assertCurrent();try{let w=await l.storage.read();if(l.assertCurrent(),!Number.isSafeInteger(w.revision)||w.revision<0)throw E();let r=w.entry===null?null:Se.parse(w.entry);if(r&&(r.baseUrl!==c||r.customerId!==l.customerId||r.scope.projectId!==l.scope.projectId||r.scope.environment!==l.scope.environment))throw new s("SCOPE_MISMATCH","Purchase recovery belongs to another Customer or environment");if(r?.journal.entry&&(r.journal.entry.scope.projectId!==r.scope.projectId||r.journal.entry.scope.environment!==r.scope.environment||r.journal.entry.funnelId!==r.start.funnelId||r.journal.entry.runId!==r.run?.id||r.journal.entry.versionId!==r.run?.versionId)||r?.operationCommand&&!r.purchases.some(P=>P.operationId===r.operationCommand?.operationId))throw E();return{revision:w.revision,entry:r}}catch(w){throw w instanceof s?w:E()}}async function z(w){for(let r=0;r<8;r++){let P=await C(),R=w(structuredClone(P.entry));if(JSON.stringify(R)===JSON.stringify(P.entry))return R;R&&Se.parse(R),l.assertCurrent();let v;try{v=await l.storage.write(P.revision,R)}catch{throw E()}if(l.assertCurrent(),v!==null){if(!Number.isSafeInteger(v)||v<=P.revision)throw E();return R}}throw new s("PURCHASE_STORAGE_CONFLICT","Another consumer changed this purchase; recover the original attempt")}return{read:C,update:z,baseUrl:c}}function Oe(l){let c=l.purchases.find(E=>E.type==="checkout");if(!l.actions.includes("continue_checkout")||c?.type!=="checkout")throw new s("PURCHASE_PENDING","No single resumable Checkout is confirmed");return c.checkoutUrl}function Ke(l){let c={...l,scope:{...l.scope},executionPolicy:structuredClone(l.executionPolicy)},E=c.session.snapshot();if(!E)throw new s("CUSTOMER_SESSION_REQUIRED","Purchase recovery requires a verified Customer session");let{customerId:C,sessionId:z}=E,w=!1,r=null,P,R=null,v=!1,O,T,U,b={mode:"idle",status:"idle",actions:["start"],purchases:[]},h=new Map,A=new Map,ne=new AbortController,k=new Set,Q=me(c),te=fe(Q.request);function D(e){return{code:e instanceof s?e.code:"PURCHASE_RECOVERY_BLOCKED",message:e instanceof Error?e.message:"The original purchase requires server confirmation",...e instanceof s&&e.status!==void 0?{status:e.status}:{}}}function y(){if(w||c.session.snapshot()?.customerId!==C)throw new s("IDENTITY_CHANGED","The original purchase Customer changed")}let I=Ce({...c,customerId:C,assertCurrent:y,storage:c.storage??Pe({baseUrl:c.baseUrl,scope:c.scope,customerId:C})}),Ee=c.session.subscribeIdentity(re);function re(){w||(w=!0,clearTimeout(U),ne.abort(new s("IDENTITY_CHANGED","Purchase consumer was destroyed")),Ee(),r?.reset(),r=null,R=null,Q.dispose(),k.clear(),h.clear(),A.clear())}function S(e){y();let n=JSON.stringify(e)!==JSON.stringify(b);b=e,clearTimeout(U),(e.mode==="operation"||e.mode==="run"&&!e.actions.includes("close"))&&["waiting_result","fulfillment","recording"].includes(e.status)&&(U=setTimeout(()=>{_().catch(()=>{})},5e3)),n&&ee(c.onRecovery,structuredClone(e));for(let t of n?k:[]){if(w)break;ee(t,structuredClone(e))}return structuredClone(e)}function f(e){if(y(),!e||e.start.requestId!==P)throw new s("PURCHASE_STORAGE_CONFLICT","This purchase was superseded; the old consumer cannot dispatch")}function F(e){let n=[...e.purchases],t=e.journal.entry?.purchase;return t&&!n.some(i=>i.operationId===t.operationId)&&n.push({receiptId:t.receiptId,operationId:t.operationId,terminal:null}),n}function x(e){return e.run&&!["running","waiting"].includes(e.run.status)&&!e.journal.entry?.command&&!e.journal.entry?.closeCommand&&!e.operationCommand&&F(e).every(n=>n.terminal!==null)}function q(e,n){let t=e.journal.entry?.command??e.journal.entry?.closeCommand,i=F(e).map(g=>{let Z=h.get(g.operationId);return g.terminal&&!Z?{type:g.terminal,operationId:g.operationId}:V({quote:Z?.quote??null,operation:Z??null,requestId:t?.requestId??null,pending:!1,destroyed:!1,canReselect:A.get(g.operationId)===!0})}),u=i.filter(g=>!["complete","native"].includes(g.type)),o=u[0],a=u.length===1&&o?.operationId?h.get(o.operationId):void 0;if(a&&(o?.type==="checkout"||o?.type==="cancel"))try{M({allowed:e.allowed.filter(g=>c.executionPolicy.allowed.includes(g))},a.quote)}catch(g){return{mode:n,status:"blocked",actions:["refresh",...n==="run"&&e.run&&["running","waiting"].includes(e.run.status)?["close"]:[]],purchases:i,error:D(g)}}let d;if(n==="operation"&&!t&&o?.type==="cancel"&&a?.quote&&!a.problem&&!a.confirmedAt)try{M({allowed:e.allowed.filter(g=>c.executionPolicy.allowed.includes(g))},a.quote),Date.parse(a.quote.expiresAt)>Date.now()&&(d={operationId:a.operationId,quote:a.quote})}catch{}let p=i.length>0&&u.length===0,j=x(e)||n==="operation"&&p&&!t&&!e.operationCommand?"complete":o?.type==="checkout"?"checkout":o?.type==="fulfillment"?"fulfillment":o?.type==="recording"?"recording":t||e.operationCommand||o&&o.type!=="cancel"||n==="operation"&&!d?"waiting_result":"ready";return{mode:n,status:j,purchases:i,...d?{confirmation:structuredClone(d)}:{},actions:["refresh",...x(e)?["start"]:[],...n==="run"&&e.run&&["running","waiting"].includes(e.run.status)?["close"]:[],...e.operationCommand?["retry"]:d?["confirm"]:[],...u.length===1&&o?.type==="checkout"?["continue_checkout"]:[]]}}function J(e){let n=V({quote:e?.quote??null,operation:e??null,requestId:null,pending:!1,destroyed:!1,canReselect:e&&A.get(e.operationId)===!0});return n.type==="complete"||n.type==="native"?n.type:null}function K(e){if(!e.operation)return;let n={...e.operation,...e.operation.quote?{}:e.quote?{quote:e.quote}:{}};if(n.merchantExecution&&n.merchantExecution.customerId!==C)throw new s("SCOPE_MISMATCH","Purchase execution belongs to another Customer");let t=G(h.get(n.operationId)??null,n);h.set(n.operationId,t),t===n&&A.set(n.operationId,e.canReselect===!0)}async function ve(e){y();for(let t of[e.purchase,e.run.paywall])t&&K(t);let n=await I.update(t=>{if(f(t),t.run&&(t.run.id!==e.run.id||t.run.versionId!==e.run.source.versionId))throw new s("SCOPE_MISMATCH","The original purchase Run changed");let i=F(t);for(let u of[e.purchase,e.run.paywall]){let o=u?.operation?.operationId??u?.quote?.operationId;if(!u||!o)continue;let a=i.find(p=>p.operationId===o);if(a&&a.receiptId!==u.receiptId)throw new s("INVALID_RESPONSE","The original purchase Receipt changed");let d=J(h.get(o));a?a.terminal??=d:i.push({receiptId:u.receiptId,operationId:o,terminal:d})}return{...t,purchases:i,run:t.run&&(t.run.revision>e.run.revision||!["running","waiting"].includes(t.run.status)&&["running","waiting"].includes(e.run.status))?t.run:{id:e.run.id,versionId:e.run.source.versionId,status:e.run.status,revision:e.run.revision,runExpiresAt:e.run.runExpiresAt}}});f(n),n.run&&!["running","waiting"].includes(n.run.status)&&F(n).some(t=>!t.terminal)&&(n=await Y(n,!n.journal.entry?.command&&!n.journal.entry?.closeCommand,new Set([e.purchase?.operation?.operationId,e.run.paywall?.operation?.operationId].filter(t=>!!t)))),f(n),S(q(n,"run"))}function Re(){return{async read(){let{entry:e}=await I.read();return f(e),structuredClone(e.journal)},async write(e,n){let t=null;return await I.update(i=>{if(f(i),i.operationCommand&&n?.command&&n.command.operation!=="close")throw new s("PURCHASE_PENDING","Recover the original Operation command before dispatching a Run mutation");return t=null,i.journal.revision!==e?i:(t=e+1,{...i,journal:{revision:t,entry:n}})}),t}}}async function Y(e,n=!1,t=new Set){f(e);let i=F(e);for(let o of i){if(o.terminal)continue;let a=t.has(o.operationId)?h.get(o.operationId):void 0;if(a??=await oe(e,o),y(),a.operationId!==o.operationId)throw new s("INVALID_RESPONSE","Original Operation changed");if(a.merchantExecution&&a.merchantExecution.customerId!==C)throw new s("SCOPE_MISMATCH","Purchase execution belongs to another Customer");if(n&&!e.operationCommand&&V({quote:a.quote??null,operation:a,requestId:null,pending:!1,destroyed:!1}).type==="cancel"){if({operation:a}=await te.attach({operationId:o.operationId,intent:"cancel"}),y(),a.operationId!==o.operationId)throw new s("INVALID_RESPONSE","Original cancellation Operation changed");a=await oe(e,o)}h.set(o.operationId,G(h.get(o.operationId)??null,a))}let u=await I.update(o=>{f(o);let a=o.operationCommand&&h.get(o.operationCommand.operationId);return{...o,...a&&(a.confirmedAt||a.merchantExecution||a.status!=="pending")?{operationCommand:void 0}:{},purchases:F(o).map(d=>({...d,terminal:d.terminal??J(h.get(d.operationId))}))}});return f(u),u}async function W(e){y();let n=await Q.request("funnels",e);return y(),n}async function oe(e,n){let t=B(de,await W({operation:"recover_purchase",runId:e.run.id,funnelId:e.start.funnelId,purchase:{receiptId:n.receiptId,operationId:n.operationId}}));if($(e,t),t.purchase.receiptId!==n.receiptId||t.purchase.operation?.operationId!==n.operationId)throw new s("INVALID_RESPONSE","Original purchase reference changed");return K(t.purchase),h.get(n.operationId)}async function ae(e){for(let n of[e.journal.entry?.command,e.journal.entry?.closeCommand]){if(!n)continue;let t=B(le,await W({operation:"settle_command",runId:e.run.id,funnelId:e.start.funnelId,requestId:n.requestId,...n.operation==="resume"?{}:{command:n}}));if($(e,t),t.settlement.requestId!==n.requestId)throw new s("INVALID_RESPONSE","Original command settlement changed");t.purchase&&K(t.purchase);let i=await I.update(u=>{f(u);let o=F(u),{receiptId:a,operationId:d}=t.settlement;if(a&&d){let j=o.find(g=>g.operationId===d);if(j&&j.receiptId!==a)throw new s("INVALID_RESPONSE","Original Receipt changed");j||o.push({receiptId:a,operationId:d,terminal:J(h.get(d))})}let p=t.settlement.state==="settled"?Ie(u.journal.entry,n.requestId):u.journal.entry;return{...u,purchases:o,journal:p===u.journal.entry?u.journal:{revision:u.journal.revision+1,entry:p}}});f(i),e=i}return e}function $(e,n){if(n.customerId!==C||n.scope.projectId!==c.scope.projectId||n.scope.environment!==c.scope.environment||n.target.funnelId!==e.start.funnelId||n.target.startRequestId!==e.start.requestId||e.run&&(n.target.runId!==e.run.id||n.target.versionId!==e.run.versionId))throw new s("SCOPE_MISMATCH","The original recovery binding changed")}async function X(e,n){if(f(e),e.run&&(e=await ae(e)),!F(e).length&&x(e))return S(q(e,"operation"));if(!F(e).length)return S({mode:"blocked",status:"blocked",actions:["refresh"],purchases:[],error:D(n)});v=!0;let t=await Y(e);return S(q(t,"operation"))}async function H(e,n=!1,t=!0){if(P=e.start.requestId,R=structuredClone({requestId:e.start.requestId,funnelId:e.start.funnelId,locale:e.start.locale,parameters:e.start.parameters}),!r){let i=e.run?{operation:"recover_run",runId:e.run.id,funnelId:e.start.funnelId}:{operation:"recover_start",intent:n?"resume":"lookup",start:{requestId:e.start.requestId,funnelId:e.start.funnelId,locale:e.start.locale,parameters:e.start.parameters}},u;try{u=await W(i)}catch(p){if(!e.run&&p instanceof s&&(p.status===void 0||p.status>=500))return S({mode:"blocked",status:"blocked",actions:["refresh","retry"],purchases:b.purchases,error:D(p)});throw p}let o=B(ce,u);if(o.customerId!==C||o.scope.projectId!==c.scope.projectId||o.scope.environment!==c.scope.environment)throw new s("SCOPE_MISMATCH","Recovery Customer or environment changed");if(o.outcome==="unknown")return S({mode:"blocked",status:"blocked",actions:["refresh","retry"],purchases:b.purchases,error:{code:"RESULT_UNKNOWN",message:"The original Start outcome remains unknown; retry only its original input"}});$(e,o);let a=await I.update(p=>(f(p),{...p,run:{id:o.target.runId,versionId:o.target.versionId,status:o.target.status,revision:o.view?.revision??p.run?.revision??0,runExpiresAt:o.target.runExpiresAt}}));if(f(a),e=a,o.access.type==="operation_only")return X(e,new s("RUN_RECONCILIATION_REQUIRED","Only the original command and Operation can be recovered"));e=await ae(e);let d=o.view;if(d.locale!==e.start.locale||!ge(d.parameters,e.start.parameters))throw new s("INVALID_RESPONSE","The original Start input changed");r=ye({...c,customerRun:{runId:o.target.runId,customerId:C,startRequestId:e.start.requestId},funnelId:e.start.funnelId,funnelExecutionPolicy:{allowed:e.allowed.filter(p=>c.executionPolicy.allowed.includes(p))},funnelCommandStorage:Re(),onAcceptedResponse:ve},{scope:o.scope,run:d})}try{await r.get(),r.view?.pendingRequest?.requestId===e.start.requestId&&!r.pendingCommands?.length&&await r.resume(r.view.pendingRequest.requestId);for(let u of r.pendingCommands??[])u.operation!=="close"&&await r.settle?.(u.requestId);r.pendingCommands?.length&&await r.retry(),y();let i=(await I.read()).entry;return f(i),S(q(i,"run"))}catch(i){if(y(),t&&i instanceof s&&(i.status===401||i.status===409&&i.reason==="STATE_CHANGED")){r.reset(),r=null;let u=(await I.read()).entry;return f(u),H(u,!1,!1)}throw i}}function N(e,n="read"){if(y(),O)return n==="read"||n===T?O:O.then(()=>N(e,n),()=>N(e,n));clearTimeout(U);let t=e().catch(i=>{throw w||S({mode:"blocked",status:"blocked",actions:["refresh"],purchases:b.purchases,error:D(i)}),i});return O=t,T=n,t.then(()=>{O===t&&(O=void 0,T=void 0)},()=>{O===t&&(O=void 0,T=void 0)}),t}function _(){return N(async()=>{let{entry:e}=await I.read();return e?(P&&e.start.requestId!==P&&(r?.reset(),r=null,h.clear(),A.clear()),v&&P===e.start.requestId?X(e,b.error):H(e)):S({mode:"idle",status:"idle",actions:["start"],purchases:[]})})}async function ie(){let e=await _();return e.mode==="operation"&&!e.actions.includes("confirm")&&!e.actions.includes("retry")?e:N(async()=>{let n=(await I.read()).entry;if(f(n),!v){if(!r?.view?.paywall?.quote)throw new s("PURCHASE_PENDING","Read the original quote before confirming");let a=r.view.paywall.operation;if(a?.confirmedAt||a?.merchantExecution||a&&a.status!=="pending")return S(q(n,"run"));if(r.pendingCommands?.length)await r.retry();else{let p=r.view;await r.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:p.nodeId,visit:p.visit,revision:p.revision,input:{type:"paywall_confirm",operationId:p.paywall.quote.operationId}})}let d=(await I.read()).entry;return f(d),S(q(d,"run"))}let t=n.operationCommand?.operationId??b.confirmation?.operationId,i=t&&h.get(t);if(!t||!i||n.journal.entry?.command||n.journal.entry?.closeCommand)throw new s("PURCHASE_PENDING","The original Run command must be settled before Operation confirmation");M({allowed:n.allowed.filter(a=>c.executionPolicy.allowed.includes(a))},i.quote),await I.update(a=>{if(f(a),a.journal.entry?.command||a.journal.entry?.closeCommand||a.operationCommand&&a.operationCommand.operationId!==t)throw new s("PURCHASE_PENDING","Another original command is pending");return{...a,operationCommand:{operationId:t,intent:"confirm"}}});let u=await te.attach({operationId:t,intent:"confirm"});if(y(),u.operation.operationId!==t)throw new s("INVALID_RESPONSE","Original confirmation Operation changed");h.set(t,G(i,u.operation));let o=(await I.read()).entry;return f(o),S(q(await Y(o,!1,new Set([t])),"operation"))},"confirm")}return{get controller(){return r},get recovery(){return structuredClone(b)},get attempt(){return y(),structuredClone(R)},get identitySignal(){return ne.signal},start(e){let n=L.parse({...structuredClone(e),operation:"start",requestId:e.requestId??crypto.randomUUID()});if(n.operation!=="start"||n.customer||n.customerData)throw new s("INVALID_REQUEST","A Customer-owned Funnel start is required");return N(async()=>{let t=await I.update(i=>{if(i&&!x(i)){if(i.start.funnelId!==n.funnelId)throw new s("PURCHASE_PENDING","Recover the original Funnel before starting another purchase");return i}return{schemaVersion:1,baseUrl:I.baseUrl,scope:c.scope,customerId:C,sessionId:z,start:n,allowed:[...c.executionPolicy.allowed],purchases:[],journal:{revision:0,entry:null}}});if(!t)throw new s("PURCHASE_STORAGE_INVALID","Original start was not retained");return P!==t.start.requestId&&(r?.reset(),r=null,h.clear(),A.clear(),v=!1),v?X(t,b.error):H(t,!0)},`start:${n.funnelId}`)},refresh:_,confirm:ie,retry:()=>v?ie():N(async()=>{let{entry:e}=await I.read();return e?H(e,!0):S({mode:"idle",status:"idle",actions:["start"],purchases:[]})},"retry"),async close(){return r?.view?N(async()=>{if(!r?.view)throw new s("PURCHASE_PENDING","Recover the original Run before closing");if(r.pendingCommands?.find(t=>t.operation==="close"))await r.retry();else if(["running","waiting"].includes(r.view.status)){let t=r.view;await r.submit({operation:"close",requestId:crypto.randomUUID(),nodeId:t.nodeId,visit:t.visit,revision:t.revision})}let n=(await I.read()).entry;return f(n),S(q(n,"run"))},"close"):_()},async continueCheckout(e){let n=await _();y(),await e(Oe(n))},subscribe(e){return k.add(e),()=>{k.delete(e)}},destroy:re}}export{Pe as a,Oe as b,Ke as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as R,b as re}from"./chunk-FSQ75ZCZ.js";import{a as ne,b as j,c as ie,f as se}from"./chunk-RN3WAJ36.js";import{a as m,q as U}from"./chunk-EEHL2BP6.js";import{b as te}from"./chunk-NHQBONYJ.js";import{a as o}from"./chunk-SJNF6JDJ.js";import{Da as d,Fa as G,Ra as ee,_ as $,a as K,b as Q,c as W,d as M,e as H,f as X,ia as Z,q as B}from"./chunk-BYLU5UY5.js";import{a as J}from"./chunk-DSPLGTQI.js";import{a as Y}from"./chunk-MHEYMXGZ.js";var L=t=>{if(!Number.isSafeInteger(t)||t<0||t>=Number.MAX_SAFE_INTEGER)throw new o("INVALID_STATE","Installation sequence exhausted");return t+1},ve=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 o("INVALID_STATE","Installation journal is invalid");return e({...n})})}function oe(t,e,n){let r=null,s=0,a=0,l=0,y=Promise.resolve(),g=!1;if(t&&(!n||Y.parse(t.scope).projectId!==n.projectId||t.scope.environment!==n.environment))throw new o("SCOPE_MISMATCH","Push installation belongs to another scope");let p=()=>{if(g)throw new o("CLOSED","SDK client was destroyed");if(!t)throw new o("NOT_CONFIGURED","Configure this client's native Push host first");return t},A=i=>{if(i!==s)throw new o("IDENTITY_CHANGED","Identity changed during Push operation")};async function D(i){let c=p();if(!c.sha256&&!globalThis.crypto?.subtle)throw new o("NOT_CONFIGURED","Configure native SHA-256 for this Push host");let u=c.sha256?await c.sha256(Uint8Array.from(i,b=>b.charCodeAt(0))):await ve(i);if(!/^[a-f0-9]{64}$/.test(u))throw new o("INVALID_STATE","Push credential digest is invalid");return u}function f(i){let c=H.parse(i);if(c.installationId.toLowerCase()!==p().installationId.toLowerCase())throw new o("INVALID_RESPONSE","Push response belongs to another installation");return c}async function S(i,c){let u=p(),b={installationId:u.installationId,publicKey:u.publicKey,issuedAt:new Date().toISOString(),...c},P=await u.sign(X(i,u.scope,b));return{...b,signature:P}}let I=(i,c,u)=>e.requestWithCredential?e.requestWithCredential(i,c,u):e.request(i,c);async function q(){let i=p(),c=s,u=r?await(e.session?.access()??r):null,b=_(i,w=>w),P;if(b.detachSeq!==null){let w=b.detachSeq,x=K.parse(await S("detach",{sequence:w,platform:i.platform}));try{let k=await e.request("push/installations/detach",{...i.scope,...x},"POST",{installationDetach:!0});if(!k||typeof k!="object"||!("installation"in k))throw new o("INVALID_RESPONSE","Push detach acknowledgement is invalid");let F=f(k.installation);if(F.bound||F.identitySeq!==w)throw new o("INVALID_RESPONSE","Push detach acknowledgement does not match its intent")}catch(k){if(k instanceof o&&k.status===404)P=k;else if(!(k instanceof o)||k.status!==412)throw k}P||_(i,k=>({...k,detachSeq:k.detachSeq===w?null:k.detachSeq}))}if(A(c),!u){if(P)throw P;return null}let E=d.bindPushInstallation,N=E.request.parse(await S("bind",{sequence:l,platform:i.platform,credentialDigest:await D(u)}));A(c);let C=E.response.parse(await I(E.path,N,u));A(c);let T=f(C.installation);if(!T.bound||T.identitySeq!==l)throw new o("INVALID_RESPONSE","Push binding acknowledgement does not match its intent");return P&&b.detachSeq!==null&&l>b.detachSeq&&_(i,w=>({...w,detachSeq:w.detachSeq===b.detachSeq?null:w.detachSeq})),T}async function h(){p();let i=s,c=r?await(e.session?.access()??r):null;if(!c)throw new o("NOT_IDENTIFIED","Identify before reading this installation");let u=d.readPushInstallation,b=u.request.parse(await S("read",{credentialDigest:await D(c)}));A(i);let P=u.response.parse(await I(u.path,b,c));return A(i),f(P.installation)}function O(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 v(i,c,u){let b=p(),P=c.identity,E=c.observation,N=r?await(e.session?.access()??r):null;if(A(P),E!==a)throw new o("INVALID_STATE","Push observation changed during recovery");if(!N)throw new o("NOT_IDENTIFIED","Identify before recovering a Push address");if(!i.connectionId||!i.kind||!i.token||!["granted","provisional"].includes(i.permission))throw new o("INVALID_REQUEST","Recovery needs a provider token and notification permission");return await O(async()=>{if(A(P),await q(),A(P),E!==a)throw new o("INVALID_STATE","Push observation changed during recovery");let C=_(b,F=>u?F:{...F,addressSeq:L(F.addressSeq)}),w=await S(u?"recovery_confirm":"recovery_request",{...i,sequence:C.addressSeq,credentialDigest:await D(N),...u?{challenge:u}:{}}),x=u?W.parse(w):Q.parse(w);if(A(P),E!==a)throw new o("INVALID_STATE","Push observation changed during recovery");let k=await I(`push/installations/recovery/${u?"confirm":"request"}`,x,N);if(A(P),E!==a||_(b,F=>F).addressSeq!==C.addressSeq)throw new o("INVALID_STATE","Push observation changed during recovery");if(u){let F=d.updatePushAddress.response.parse(k),V=f(F.installation);if(!V.bound||V.identitySeq!==l||V.addressSeq!==C.addressSeq||V.connectionId!==i.connectionId||V.addressStatus!=="active")throw new o("INVALID_RESPONSE","Push recovery acknowledgement does not match its intent");return V}if(!k||typeof k!="object"||!("recovery"in k))throw new o("INVALID_RESPONSE","Push recovery acknowledgement is invalid");return M.parse(k.recovery)})}return{recoveryObserver(){p();let i={identity:s,observation:++a};return{async request(c){return M.parse(await v(c,i))},async confirm(c,u){return H.parse(await v(u,i,c))}}},identify(i){if(!t)return;l=_(t,u=>({...u,identitySeq:L(u.identitySeq)})).identitySeq,r=i,s++,a++},reset(){if(t)try{_(t,i=>{let c=L(i.identitySeq);return{...i,identitySeq:c,detachSeq:c}})}finally{r=null,s++,a++}},start(){t&&!g&&O()},destroy(){g=!0,r=null,s++,a++},async sync(){return await O()},read:h,async recover(){let i=p(),c=s,u=l;return a++,await O(async()=>{A(c);let b=await h();return A(c),l=_(i,E=>{if(E.identitySeq!==u)throw new o("IDENTITY_CHANGED","A newer installation intent exists");return{...E,identitySeq:L(Math.max(E.identitySeq,b.identitySeq)),addressSeq:Math.max(E.addressSeq,b.addressSeq)}}).identitySeq,await q()})},tokenObserver(){p();let i=++a,c=s;return async u=>{if(i!==a||c!==s)return null;let b=p(),P=r?await(e.session?.access()??r):null;if(!P)throw new o("NOT_IDENTIFIED","Identify before registering a Push token");if(await O(),A(c),i!==a)return null;let E=_(b,w=>({...w,addressSeq:L(w.addressSeq)})),N=d.updatePushAddress,C=N.request.parse(await S("address",{...u,sequence:E.addressSeq,credentialDigest:await D(P)}));if(A(c),i!==a)return null;let T=await I(N.path,C,P);return A(c),i!==a||_(b,w=>w).addressSeq!==E.addressSeq?null:f(N.response.parse(T).installation)}}}}function ae(t,e){let n={async preference(r){let s=d.readMessagingPreference;return(await m(t,s,{channel:r})).preference},async setPreference(r){let s=d.setMessagingPreference;return(await m(t,s,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 n.setPreference({...r,channel:"push"})}}}}function ce(t,e,n={}){let r=!1;function s(){if(r)throw new o("CLOSED","SDK client was destroyed")}let a=new Set,l=g=>{for(let p of a)try{p(g)}catch{}},y=t.session.subscribeIdentity(()=>{l(!!t.session.peek()),n.afterChange?.()},()=>{e()});return{assertActive:s,isIdentified:()=>!r&&!!t.session.peek(),methods:{subscribeIdentity(g){return s(),a.add(g),()=>{a.delete(g)}},identify(g){s();let p=typeof g=="string"?g:g.accessToken;if(!B.test(p))throw new o("INVALID_TOKEN","Browser SDK requires a customer session");n.beforeIdentify?.(p),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()}}}}}}var Ee={...d.readHoldings,request:d.readHoldings.request.omit({customerId:!0})};function ue(t){return{async checkEntitlement(e){R(e);let n=d.checkEntitlement,r=n.request.parse(e),s=await m(t,n,r);return ne(r.requirement,s.check,void 0,s.scope),s},async readHoldings(e={}){return m(t,Ee,e)}}}function de(t){return{async readLedger(e){let n=d.readLedger;return m(t,n,{query:e})},async readCreditStatement(e){R(e);let n=d.readCreditStatement;return m(t,n,e)},async quoteBalance(e){R(e);let n=d.quoteBalance;return m(t,n,{command:e})}}}function le(t){return{async setupPayment(e){R(e);let n=d.setupPayment;return m(t,n,e)},async readPaymentSetup(e){R(e);let n=d.readPaymentSetup;return m(t,n,e)},async readBillingInvoice(e){R(e);let n=d.readBillingInvoice;return m(t,n,e)},async readBillingControls(e={}){R(e);let n=d.readBillingControls;return m(t,n,e)},async prepareBillingAuthorization(e){R(e);let n=d.prepareBillingAuthorization;return m(t,n,e)},async confirmBillingAuthorization(e){R(e);let n=d.confirmBillingAuthorization;return m(t,n,e)},async setBillingCoupons(e){R(e);let n=d.setBillingCoupons;return m(t,n,e,{request:"Invalid billing coupon list",response:"Invalid billing coupon receipt"})},async revokeBillingAuthorization(e){R(e);let n=d.revokeBillingAuthorization;return m(t,n,e)},async listBillingInvoices(e={after:null,limit:25}){R(e);let n=d.listBillingInvoices;return m(t,n,e)},async confirmBillingAdjustment(e){R(e);let n=d.confirmBillingAdjustment;return m(t,n,e)}}}function pe(t){return{async redeemReward(e){return R(e),(await m(t,d.redeemReward,{...e,requestId:e.requestId??crypto.randomUUID()},{request:"Invalid reward redemption",response:"Invalid reward receipt"})).redemption},async claimRewardProduct(e){return R(e),(await m(t,d.claimRewardProduct,e,{request:"Invalid reward product claim",response:"Invalid reward product checkout"})).checkout},async createReferralCode(e){return R(e),(await m(t,d.createReferralCode,{...e,requestId:e.requestId??crypto.randomUUID()},{request:"Invalid referral program",response:"Invalid referral code"})).referralCode},async redeemCoupon(e,n=crypto.randomUUID()){let r=await m(t,d.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,d.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,d.listOffers,{},{response:"Invalid offers response"})).offers}}}function fe(t){return{...ue(t),...de(t),...le(t),...re(t),...pe(t)}}function me(t){return{async resolveContent(e){R(e);let n=d.resolveContent;return m(t,n,e)},async resolvePaywall(e){R(e);let n=d.resolvePaywall,r=n.request.parse(e),s=await m(t,n,r);return j(r,s.paywall.check,s.scope),s},async resolveOffering(e){R(e);let n=d.resolveOffering,r=n.request.parse(e),s=await m(t,n,r);return j(r,s.check,s.scope),s}}}var z=t=>new TextEncoder().encode(JSON.stringify(t)).length,ye=16384,be=5e3,Ae=6e4,Se=5;function Oe(t){return t instanceof o&&t.status!==void 0&&t.status>=400&&t.status<500&&!t.retryable}function Ie(t,e){let n=0,r,s=h=>{r={config:structuredClone(h),until:Date.now()+3e4}},a=[],l=null,y,g=0;function p(){if(!e())throw new o("NOT_IDENTIFIED","Call identify before using Features or events")}function A(){y||!a.length||!e()||(y=setTimeout(()=>{y=void 0,S().catch(()=>{}).finally(A)},Math.min(be*2**g,Ae)),typeof y=="object"&&"unref"in y&&y.unref())}function D(h){if(p(),r&&Date.now()<r.until&&!$(r.config,h.kind))return;q();let O=d.trackEvents.request.parse({events:[{...h,eventUuid:crypto.randomUUID(),timestamp:new Date().toISOString()}]}).events[0];if(z({events:[O]})>ye)throw new o("INVALID_REQUEST","Event exceeds the delivery size limit");if(a.length>=500)throw new o("EVENT_QUEUE_FULL","Flush pending events before tracking more");a.push(structuredClone(O)),A()}function f(h,O={},v={}){D({kind:"custom",name:h,properties:O,...v})}async function S(h=!1){if(p(),l)return l;let O=n,v=(async()=>{let i={inserted:0,duplicates:0,rejected:0,skipped:0,rejections:[]},c=a.length;for(;c&&O===n;){let u=[],b=z({events:[]});for(let N of a.slice(0,Math.min(c,100))){let C=z(N)+(u.length?1:0);if(u.length&&b+C>ye)break;u.push(N),b+=C}let P=d.trackEvents,E;try{if(E=await m(t,P,{events:u},void 0,{keepalive:h}),O!==n)throw new o("IDENTITY_CHANGED","Event identity changed during delivery");if(E.inserted+E.duplicates+E.rejected+E.skipped!==u.length||E.rejections.length!==E.rejected)throw new o("INVALID_RESPONSE","Incomplete event acknowledgement")}catch(N){throw O===n&&(g++,(Oe(N)||g>=Se)&&(a.splice(0,u.length),g=0)),N}g=0,s(E.analyticsConfig),a.splice(0,u.length),c-=u.length,i.inserted+=E.inserted,i.duplicates+=E.duplicates,i.rejected+=E.rejected,i.skipped+=E.skipped,i.rejections.push(...E.rejections)}return i})();l=v;try{return await v}finally{l===v&&(l=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:s,track:f,observe:D,flush:S,reset(){n++,r=void 0,clearTimeout(y),y=void 0,a=[],g=0,l=null},detachVisibility(){I?.(),I=void 0}}}function he(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 Pe=new Set([...Z,"merchandiseId","merchandise"]);function Ce(t){let e=he(t);return{...Object.fromEntries(Object.entries(t).filter(([r])=>!Pe.has(r))),...e?{merchandise:e}:{}}}function ge(t,e,n,r,s){if(s&&r&&(s.scope.projectId!==r.projectId||s.scope.environment!==r.environment))throw new o("SCOPE_MISMATCH","Configuration belongs to another App/environment");let a=0,l=new Set;function y(){if(!e())throw new o("NOT_IDENTIFIED","Call identify before using Features or events")}async function g(p={}){s||y();let A=a,D=!1,f=async()=>{if(D||A!==a)throw new o("IDENTITY_CHANGED","Feature identity changed");let C=d.getFeatures,T=s?{scope:{projectId:s.scope.projectId,environment:s.scope.environment},payload:await s.features()}:await m(t,C,{});if(A!==a)throw new o("IDENTITY_CHANGED","Feature identity changed");if(r&&(T.scope.projectId!==r.projectId||T.scope.environment!==r.environment))throw new o("INVALID_RESPONSE","Feature response scope changed");return n.rememberConfiguration(T.payload.analyticsConfig),T},S=await f(),I=!0,q,h=C=>{try{p.onError?.(C)}catch{}},O=(C,T)=>{try{let w=he(T);n.observe({...C,...w?{merchandise:w}:{}})}catch(w){h(w)}},v=ie({assertUsable:s?.assertFeatures,scope:S.scope,attributes:p.attributes,onError:p.onError,load:async()=>I?(I=!1,S.payload):(await f()).payload,evaluateRemote:async C=>{if(A!==a)throw new o("IDENTITY_CHANGED","Feature identity changed");let T=d.evaluateFeatures,w=await m(t,T,{...C,attributes:Ce(C.attributes)});if(w.scope.projectId!==S.scope.projectId||w.scope.environment!==S.scope.environment)throw new o("INVALID_RESPONSE","Remote Feature response scope changed");return{generation:w.generation,evaluatedAt:w.evaluatedAt,expiresAt:w.expiresAt,features:w.features,...w.merchandiseContext?{merchandiseContext:w.merchandiseContext}:{}}},onExperimentViewed:(C,T,w,x)=>O({kind:"experiment_exposure",generation:x,experimentId:C.key,variationId:T.key},w),onFeatureUsage:(C,T,w,x)=>O({kind:"feature_usage",generation:x,feature:C,value:T.value??null,source:T.source,ruleId:T.ruleId,...T.experimentResult?{variationId:T.experimentResult.key}:{}},w)}),i=v.refresh;function c(){clearTimeout(q),!s&&(D||A!==a||!v.expiresAt||(q=setTimeout(()=>{u().catch(h)},Math.min(2147483647,Math.max(1e3,Date.parse(v.expiresAt)-Date.now()))),typeof q=="object"&&"unref"in q&&q.unref()))}async function u(){try{return await i()}finally{c()}}let b=()=>{D||u().catch(h)},P=v.subscribe(c),E=s?.subscribe(()=>{!D&&s.fresh&&u().catch(h)});function N(){D||(D=!0,clearTimeout(q),typeof window<"u"&&window.removeEventListener("focus",b),P(),E?.(),v.reset(),l.delete(N))}l.add(N);try{await v.init(),(p.attributes?.merchandise||p.attributes?.merchandiseId)&&await v.refreshRemote()}catch(C){throw N(),C}return c(),!s&&typeof window<"u"&&window.addEventListener("focus",b),Object.assign(v,{refresh:u,destroy:N})}return{features:g,reset(p){a++,p();for(let A of l)A()}}}import{z as Re}from"zod";function we(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=Re.object({funnelId:G.shape.id,funnelVersionId:G.shape.versionId.optional()}).safeParse(n);if(!r.success)throw new o("INVALID_REQUEST","A valid Funnel source is required");let s=Object.freeze(r.data);function a(l){if("customerId"in l)throw new o("INVALID_REQUEST","Customer identity cannot be overridden");if("funnelId"in l&&l.funnelId!==void 0&&l.funnelId!==s.funnelId||"funnelVersionId"in l&&l.funnelVersionId!==void 0&&l.funnelVersionId!==s.funnelVersionId)throw new o("SCOPE_MISMATCH","The original Funnel source cannot change");return{...l,...s}}return{async claimCoupon(l,y=crypto.randomUUID()){let g=d.grantOffer,p=await m(t,g,a({couponId:l,requestId:y}));return{offer:p.offer,reason:p.reason}},async resolveOffering(l){let y=d.resolveOffering,g=y.request.parse(a(l)),p=await m(t,y,g);return j(g,p.check,p.scope),p},async resolvePaywall(l){let y=d.resolvePaywall,g=y.request.parse(a(l)),p=await m(t,y,g);return j(g,p.paywall.check,p.scope),p},async previewAttach(l){let y=d.previewAttach;return m(t,y,a(l))}}}function Vt(t){return Te(t)}function Te(t){let e=te(t),n=e.request,r;try{r=oe(t.push,e,t.scope??t.configuration?.scope)}catch(y){throw e.dispose(),y}let s=ce(e,()=>{l.reset(a.reset),a.detachVisibility()},{beforeIdentify:r.identify,beforeReset:r.reset,afterChange:r.start,beforeDestroy:r.destroy}),a=Ie(n,s.isIdentified),l=ge(n,s.isIdentified,a,t.scope,t.configuration);return{session:e.session,...ae(n,r),...fe(n),...me(n),forFunnel(y){return s.assertActive(),we(n,y)},async features(y={}){return s.assertActive(),l.features(y)},track(y,g,p={}){return a.track(y,g,p)},flush(){return a.flush()},...s.methods}}function Ht(t){if(!B.test(t.customerToken))throw new o("INVALID_TOKEN","A customer credential is required");if(!t.scope)throw new o("INVALID_REQUEST","An explicit App and environment scope is required");let e=se({...t,scope:t.scope,apiKey:t.customerToken});return{async start(n){let r=await e.start(n),s=U({...t,runToken:r.runToken,initialResponse:r});s.identify(t.customerToken);let a=await s.get();return{...r,...a,controller:s}}}}function Qt(t){if(!t.scope)throw new o("INVALID_CONFIGURATION","An explicit process App/environment scope is required");if(t.session!==void 0)throw new o("INVALID_CONFIGURATION","The merchant process adapter owns the session");let e=null,n,r=0,s=new Set,a=new Map,l=new Map;async function y(f){let S,I=new Promise((q,h)=>{S=setTimeout(()=>h(new o("TIMEOUT","Process bridge request timed out")),t.timeoutMs??35e3)});try{return await Promise.race([Promise.resolve().then(f),I])}finally{clearTimeout(S)}}function g(f){throw f instanceof o&&(f.status===401||f.reason==="CUSTOMER_BINDING_CONFLICT")&&(r++,n?.reset(),n=void 0,e=null,a.clear(),l.clear()),f}function p(f,S){if(S!==r)throw new o("IDENTITY_CHANGED","Process was detached during a request");let I=ee.parse(f);if(I.scope.projectId!==t.scope.projectId||I.scope.environment!==t.scope.environment)throw new o("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 o("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 o("INVALID_RESPONSE","The process lost its Customer binding");e=I;for(let b of s)J(b,I.run);I.run.instruction?.type==="authentication_required"&&J(t.onAuthenticationRequired,I.run)}I.settlement?.accepted!==void 0&&l.set(I.settlement.requestId,I.settlement.accepted);let{identity:q,instruction:h,...O}=I.run,{contract:v,settlement:i,...c}=I,u=i&&(({accepted:b,...P})=>P)(i);return{...c,run:{...O,authenticated:q.binding!==null,instruction:h?.type==="authentication_required"?null:h},...u?{settlement:u}:{}}}let A=f=>(a.has(f)||a.set(f,e?.run.identity.binding?.id??null),a.get(f));async function D(f){let S=r,I=e?.run.identity.binding?.id??null,q=O=>{if(I!==(e?.run.identity.binding?.id??null))throw O;return g(O)};if(f.operation==="page_experiments"){if(!t.adapter.pageExperiments)throw new o("CAPABILITY_UNAVAILABLE","Process page experiments are unavailable",501);return y(()=>t.adapter.pageExperiments(f.release,f.usedReceiptIds)).catch(q)}let h;if(f.operation==="get"){let{operation:O,customerToken:v,...i}=f;h=await y(()=>t.adapter.get({...i,...i.settlementRequestId?{settlementBindingId:A(i.settlementRequestId)}:{}})).catch(q)}else if(f.operation==="review")h=await y(()=>t.adapter.review(f.receiptId)).catch(q);else{if(f.operation==="start")throw new o("INVALID_REQUEST","Use process.open for entry");{let{customerToken:O,...v}=f;h=await y(()=>t.adapter.command(v,A(v.requestId))).catch(q)}}return p(h,S)}return{get view(){return e?.run??null},get controller(){return n},async open(f){let S=r,I=await y(()=>t.adapter.open(f)).catch(g),q=p(I,S);if(!n){n=U({...t,runToken:I.runToken,initialResponse:q,process:{request:D,binding:A,restore(v){for(let[i,c]of Object.entries(v))a.set(i,c)}}});let h=n,O=h.submit;h.submit=async v=>{try{return await O(v)}catch(i){if(!(i instanceof o)||i.reason!=="IDENTITY_CONTEXT_CHANGED"||v.operation!=="submit"||v.input.type!=="screen"||a.get(v.requestId)!==null)throw i;await h.settle?.(v.requestId),await h.get();let c=h.view;if(l.get(v.requestId)!==!1||!c||c.id!==e?.run.id||c.nodeId!==v.nodeId||c.visit!==v.visit||!e?.run.identity.binding)throw i;return O({...v,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 f=r;p(await y(()=>t.adapter.syncIdentity()).catch(g),f),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(),l.clear(),await y(()=>t.adapter.detach())},forProcess(f){if(!e?.run.identity.binding)throw new o("UNAUTHENTICATED","Sign in before a commercial operation",401);return{runId:e.run.id,bindingId:e.run.identity.binding.id,receiptId:f}},subscribe(f){return s.add(f),()=>{s.delete(f)}},destroy(){r++,n?.reset(),n=void 0,e=null,a.clear(),l.clear(),s.clear()}}}export{Vt as a,Te as b,Ht as c,Qt as d};
|
|
1
|
+
import{a as R,b as re}from"./chunk-THGLNE4K.js";import{a as ne,b as j,c as ie,f as se}from"./chunk-TUYBXAAK.js";import{a as m,q as U}from"./chunk-LFFBNGXP.js";import{b as te}from"./chunk-5HJMAZ7A.js";import{a as o}from"./chunk-SJNF6JDJ.js";import{Da as d,Fa as G,Ra as ee,_ as $,a as K,b as Q,c as W,d as M,e as H,f as X,ia as Z,q as B}from"./chunk-O4535GJR.js";import{a as J}from"./chunk-DSPLGTQI.js";import{a as Y}from"./chunk-MHEYMXGZ.js";var L=t=>{if(!Number.isSafeInteger(t)||t<0||t>=Number.MAX_SAFE_INTEGER)throw new o("INVALID_STATE","Installation sequence exhausted");return t+1},ve=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 o("INVALID_STATE","Installation journal is invalid");return e({...n})})}function oe(t,e,n){let r=null,s=0,a=0,l=0,y=Promise.resolve(),g=!1;if(t&&(!n||Y.parse(t.scope).projectId!==n.projectId||t.scope.environment!==n.environment))throw new o("SCOPE_MISMATCH","Push installation belongs to another scope");let p=()=>{if(g)throw new o("CLOSED","SDK client was destroyed");if(!t)throw new o("NOT_CONFIGURED","Configure this client's native Push host first");return t},A=i=>{if(i!==s)throw new o("IDENTITY_CHANGED","Identity changed during Push operation")};async function D(i){let c=p();if(!c.sha256&&!globalThis.crypto?.subtle)throw new o("NOT_CONFIGURED","Configure native SHA-256 for this Push host");let u=c.sha256?await c.sha256(Uint8Array.from(i,b=>b.charCodeAt(0))):await ve(i);if(!/^[a-f0-9]{64}$/.test(u))throw new o("INVALID_STATE","Push credential digest is invalid");return u}function f(i){let c=H.parse(i);if(c.installationId.toLowerCase()!==p().installationId.toLowerCase())throw new o("INVALID_RESPONSE","Push response belongs to another installation");return c}async function S(i,c){let u=p(),b={installationId:u.installationId,publicKey:u.publicKey,issuedAt:new Date().toISOString(),...c},P=await u.sign(X(i,u.scope,b));return{...b,signature:P}}let I=(i,c,u)=>e.requestWithCredential?e.requestWithCredential(i,c,u):e.request(i,c);async function q(){let i=p(),c=s,u=r?await(e.session?.access()??r):null,b=_(i,w=>w),P;if(b.detachSeq!==null){let w=b.detachSeq,x=K.parse(await S("detach",{sequence:w,platform:i.platform}));try{let k=await e.request("push/installations/detach",{...i.scope,...x},"POST",{installationDetach:!0});if(!k||typeof k!="object"||!("installation"in k))throw new o("INVALID_RESPONSE","Push detach acknowledgement is invalid");let F=f(k.installation);if(F.bound||F.identitySeq!==w)throw new o("INVALID_RESPONSE","Push detach acknowledgement does not match its intent")}catch(k){if(k instanceof o&&k.status===404)P=k;else if(!(k instanceof o)||k.status!==412)throw k}P||_(i,k=>({...k,detachSeq:k.detachSeq===w?null:k.detachSeq}))}if(A(c),!u){if(P)throw P;return null}let E=d.bindPushInstallation,N=E.request.parse(await S("bind",{sequence:l,platform:i.platform,credentialDigest:await D(u)}));A(c);let C=E.response.parse(await I(E.path,N,u));A(c);let T=f(C.installation);if(!T.bound||T.identitySeq!==l)throw new o("INVALID_RESPONSE","Push binding acknowledgement does not match its intent");return P&&b.detachSeq!==null&&l>b.detachSeq&&_(i,w=>({...w,detachSeq:w.detachSeq===b.detachSeq?null:w.detachSeq})),T}async function h(){p();let i=s,c=r?await(e.session?.access()??r):null;if(!c)throw new o("NOT_IDENTIFIED","Identify before reading this installation");let u=d.readPushInstallation,b=u.request.parse(await S("read",{credentialDigest:await D(c)}));A(i);let P=u.response.parse(await I(u.path,b,c));return A(i),f(P.installation)}function O(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 v(i,c,u){let b=p(),P=c.identity,E=c.observation,N=r?await(e.session?.access()??r):null;if(A(P),E!==a)throw new o("INVALID_STATE","Push observation changed during recovery");if(!N)throw new o("NOT_IDENTIFIED","Identify before recovering a Push address");if(!i.connectionId||!i.kind||!i.token||!["granted","provisional"].includes(i.permission))throw new o("INVALID_REQUEST","Recovery needs a provider token and notification permission");return await O(async()=>{if(A(P),await q(),A(P),E!==a)throw new o("INVALID_STATE","Push observation changed during recovery");let C=_(b,F=>u?F:{...F,addressSeq:L(F.addressSeq)}),w=await S(u?"recovery_confirm":"recovery_request",{...i,sequence:C.addressSeq,credentialDigest:await D(N),...u?{challenge:u}:{}}),x=u?W.parse(w):Q.parse(w);if(A(P),E!==a)throw new o("INVALID_STATE","Push observation changed during recovery");let k=await I(`push/installations/recovery/${u?"confirm":"request"}`,x,N);if(A(P),E!==a||_(b,F=>F).addressSeq!==C.addressSeq)throw new o("INVALID_STATE","Push observation changed during recovery");if(u){let F=d.updatePushAddress.response.parse(k),V=f(F.installation);if(!V.bound||V.identitySeq!==l||V.addressSeq!==C.addressSeq||V.connectionId!==i.connectionId||V.addressStatus!=="active")throw new o("INVALID_RESPONSE","Push recovery acknowledgement does not match its intent");return V}if(!k||typeof k!="object"||!("recovery"in k))throw new o("INVALID_RESPONSE","Push recovery acknowledgement is invalid");return M.parse(k.recovery)})}return{recoveryObserver(){p();let i={identity:s,observation:++a};return{async request(c){return M.parse(await v(c,i))},async confirm(c,u){return H.parse(await v(u,i,c))}}},identify(i){if(!t)return;l=_(t,u=>({...u,identitySeq:L(u.identitySeq)})).identitySeq,r=i,s++,a++},reset(){if(t)try{_(t,i=>{let c=L(i.identitySeq);return{...i,identitySeq:c,detachSeq:c}})}finally{r=null,s++,a++}},start(){t&&!g&&O()},destroy(){g=!0,r=null,s++,a++},async sync(){return await O()},read:h,async recover(){let i=p(),c=s,u=l;return a++,await O(async()=>{A(c);let b=await h();return A(c),l=_(i,E=>{if(E.identitySeq!==u)throw new o("IDENTITY_CHANGED","A newer installation intent exists");return{...E,identitySeq:L(Math.max(E.identitySeq,b.identitySeq)),addressSeq:Math.max(E.addressSeq,b.addressSeq)}}).identitySeq,await q()})},tokenObserver(){p();let i=++a,c=s;return async u=>{if(i!==a||c!==s)return null;let b=p(),P=r?await(e.session?.access()??r):null;if(!P)throw new o("NOT_IDENTIFIED","Identify before registering a Push token");if(await O(),A(c),i!==a)return null;let E=_(b,w=>({...w,addressSeq:L(w.addressSeq)})),N=d.updatePushAddress,C=N.request.parse(await S("address",{...u,sequence:E.addressSeq,credentialDigest:await D(P)}));if(A(c),i!==a)return null;let T=await I(N.path,C,P);return A(c),i!==a||_(b,w=>w).addressSeq!==E.addressSeq?null:f(N.response.parse(T).installation)}}}}function ae(t,e){let n={async preference(r){let s=d.readMessagingPreference;return(await m(t,s,{channel:r})).preference},async setPreference(r){let s=d.setMessagingPreference;return(await m(t,s,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 n.setPreference({...r,channel:"push"})}}}}function ce(t,e,n={}){let r=!1;function s(){if(r)throw new o("CLOSED","SDK client was destroyed")}let a=new Set,l=g=>{for(let p of a)try{p(g)}catch{}},y=t.session.subscribeIdentity(()=>{l(!!t.session.peek()),n.afterChange?.()},()=>{e()});return{assertActive:s,isIdentified:()=>!r&&!!t.session.peek(),methods:{subscribeIdentity(g){return s(),a.add(g),()=>{a.delete(g)}},identify(g){s();let p=typeof g=="string"?g:g.accessToken;if(!B.test(p))throw new o("INVALID_TOKEN","Browser SDK requires a customer session");n.beforeIdentify?.(p),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()}}}}}}var Ee={...d.readHoldings,request:d.readHoldings.request.omit({customerId:!0})};function ue(t){return{async checkEntitlement(e){R(e);let n=d.checkEntitlement,r=n.request.parse(e),s=await m(t,n,r);return ne(r.requirement,s.check,void 0,s.scope),s},async readHoldings(e={}){return m(t,Ee,e)}}}function de(t){return{async readLedger(e){let n=d.readLedger;return m(t,n,{query:e})},async readCreditStatement(e){R(e);let n=d.readCreditStatement;return m(t,n,e)},async quoteBalance(e){R(e);let n=d.quoteBalance;return m(t,n,{command:e})}}}function le(t){return{async setupPayment(e){R(e);let n=d.setupPayment;return m(t,n,e)},async readPaymentSetup(e){R(e);let n=d.readPaymentSetup;return m(t,n,e)},async readBillingInvoice(e){R(e);let n=d.readBillingInvoice;return m(t,n,e)},async readBillingControls(e={}){R(e);let n=d.readBillingControls;return m(t,n,e)},async prepareBillingAuthorization(e){R(e);let n=d.prepareBillingAuthorization;return m(t,n,e)},async confirmBillingAuthorization(e){R(e);let n=d.confirmBillingAuthorization;return m(t,n,e)},async setBillingCoupons(e){R(e);let n=d.setBillingCoupons;return m(t,n,e,{request:"Invalid billing coupon list",response:"Invalid billing coupon receipt"})},async revokeBillingAuthorization(e){R(e);let n=d.revokeBillingAuthorization;return m(t,n,e)},async listBillingInvoices(e={after:null,limit:25}){R(e);let n=d.listBillingInvoices;return m(t,n,e)},async confirmBillingAdjustment(e){R(e);let n=d.confirmBillingAdjustment;return m(t,n,e)}}}function pe(t){return{async redeemReward(e){return R(e),(await m(t,d.redeemReward,{...e,requestId:e.requestId??crypto.randomUUID()},{request:"Invalid reward redemption",response:"Invalid reward receipt"})).redemption},async claimRewardProduct(e){return R(e),(await m(t,d.claimRewardProduct,e,{request:"Invalid reward product claim",response:"Invalid reward product checkout"})).checkout},async createReferralCode(e){return R(e),(await m(t,d.createReferralCode,{...e,requestId:e.requestId??crypto.randomUUID()},{request:"Invalid referral program",response:"Invalid referral code"})).referralCode},async redeemCoupon(e,n=crypto.randomUUID()){let r=await m(t,d.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,d.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,d.listOffers,{},{response:"Invalid offers response"})).offers}}}function fe(t){return{...ue(t),...de(t),...le(t),...re(t),...pe(t)}}function me(t){return{async resolveContent(e){R(e);let n=d.resolveContent;return m(t,n,e)},async resolvePaywall(e){R(e);let n=d.resolvePaywall,r=n.request.parse(e),s=await m(t,n,r);return j(r,s.paywall.check,s.scope),s},async resolveOffering(e){R(e);let n=d.resolveOffering,r=n.request.parse(e),s=await m(t,n,r);return j(r,s.check,s.scope),s}}}var z=t=>new TextEncoder().encode(JSON.stringify(t)).length,ye=16384,be=5e3,Ae=6e4,Se=5;function Oe(t){return t instanceof o&&t.status!==void 0&&t.status>=400&&t.status<500&&!t.retryable}function Ie(t,e){let n=0,r,s=h=>{r={config:structuredClone(h),until:Date.now()+3e4}},a=[],l=null,y,g=0;function p(){if(!e())throw new o("NOT_IDENTIFIED","Call identify before using Features or events")}function A(){y||!a.length||!e()||(y=setTimeout(()=>{y=void 0,S().catch(()=>{}).finally(A)},Math.min(be*2**g,Ae)),typeof y=="object"&&"unref"in y&&y.unref())}function D(h){if(p(),r&&Date.now()<r.until&&!$(r.config,h.kind))return;q();let O=d.trackEvents.request.parse({events:[{...h,eventUuid:crypto.randomUUID(),timestamp:new Date().toISOString()}]}).events[0];if(z({events:[O]})>ye)throw new o("INVALID_REQUEST","Event exceeds the delivery size limit");if(a.length>=500)throw new o("EVENT_QUEUE_FULL","Flush pending events before tracking more");a.push(structuredClone(O)),A()}function f(h,O={},v={}){D({kind:"custom",name:h,properties:O,...v})}async function S(h=!1){if(p(),l)return l;let O=n,v=(async()=>{let i={inserted:0,duplicates:0,rejected:0,skipped:0,rejections:[]},c=a.length;for(;c&&O===n;){let u=[],b=z({events:[]});for(let N of a.slice(0,Math.min(c,100))){let C=z(N)+(u.length?1:0);if(u.length&&b+C>ye)break;u.push(N),b+=C}let P=d.trackEvents,E;try{if(E=await m(t,P,{events:u},void 0,{keepalive:h}),O!==n)throw new o("IDENTITY_CHANGED","Event identity changed during delivery");if(E.inserted+E.duplicates+E.rejected+E.skipped!==u.length||E.rejections.length!==E.rejected)throw new o("INVALID_RESPONSE","Incomplete event acknowledgement")}catch(N){throw O===n&&(g++,(Oe(N)||g>=Se)&&(a.splice(0,u.length),g=0)),N}g=0,s(E.analyticsConfig),a.splice(0,u.length),c-=u.length,i.inserted+=E.inserted,i.duplicates+=E.duplicates,i.rejected+=E.rejected,i.skipped+=E.skipped,i.rejections.push(...E.rejections)}return i})();l=v;try{return await v}finally{l===v&&(l=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:s,track:f,observe:D,flush:S,reset(){n++,r=void 0,clearTimeout(y),y=void 0,a=[],g=0,l=null},detachVisibility(){I?.(),I=void 0}}}function he(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 Pe=new Set([...Z,"merchandiseId","merchandise"]);function Ce(t){let e=he(t);return{...Object.fromEntries(Object.entries(t).filter(([r])=>!Pe.has(r))),...e?{merchandise:e}:{}}}function ge(t,e,n,r,s){if(s&&r&&(s.scope.projectId!==r.projectId||s.scope.environment!==r.environment))throw new o("SCOPE_MISMATCH","Configuration belongs to another App/environment");let a=0,l=new Set;function y(){if(!e())throw new o("NOT_IDENTIFIED","Call identify before using Features or events")}async function g(p={}){s||y();let A=a,D=!1,f=async()=>{if(D||A!==a)throw new o("IDENTITY_CHANGED","Feature identity changed");let C=d.getFeatures,T=s?{scope:{projectId:s.scope.projectId,environment:s.scope.environment},payload:await s.features()}:await m(t,C,{});if(A!==a)throw new o("IDENTITY_CHANGED","Feature identity changed");if(r&&(T.scope.projectId!==r.projectId||T.scope.environment!==r.environment))throw new o("INVALID_RESPONSE","Feature response scope changed");return n.rememberConfiguration(T.payload.analyticsConfig),T},S=await f(),I=!0,q,h=C=>{try{p.onError?.(C)}catch{}},O=(C,T)=>{try{let w=he(T);n.observe({...C,...w?{merchandise:w}:{}})}catch(w){h(w)}},v=ie({assertUsable:s?.assertFeatures,scope:S.scope,attributes:p.attributes,onError:p.onError,load:async()=>I?(I=!1,S.payload):(await f()).payload,evaluateRemote:async C=>{if(A!==a)throw new o("IDENTITY_CHANGED","Feature identity changed");let T=d.evaluateFeatures,w=await m(t,T,{...C,attributes:Ce(C.attributes)});if(w.scope.projectId!==S.scope.projectId||w.scope.environment!==S.scope.environment)throw new o("INVALID_RESPONSE","Remote Feature response scope changed");return{generation:w.generation,evaluatedAt:w.evaluatedAt,expiresAt:w.expiresAt,features:w.features,...w.merchandiseContext?{merchandiseContext:w.merchandiseContext}:{}}},onExperimentViewed:(C,T,w,x)=>O({kind:"experiment_exposure",generation:x,experimentId:C.key,variationId:T.key},w),onFeatureUsage:(C,T,w,x)=>O({kind:"feature_usage",generation:x,feature:C,value:T.value??null,source:T.source,ruleId:T.ruleId,...T.experimentResult?{variationId:T.experimentResult.key}:{}},w)}),i=v.refresh;function c(){clearTimeout(q),!s&&(D||A!==a||!v.expiresAt||(q=setTimeout(()=>{u().catch(h)},Math.min(2147483647,Math.max(1e3,Date.parse(v.expiresAt)-Date.now()))),typeof q=="object"&&"unref"in q&&q.unref()))}async function u(){try{return await i()}finally{c()}}let b=()=>{D||u().catch(h)},P=v.subscribe(c),E=s?.subscribe(()=>{!D&&s.fresh&&u().catch(h)});function N(){D||(D=!0,clearTimeout(q),typeof window<"u"&&window.removeEventListener("focus",b),P(),E?.(),v.reset(),l.delete(N))}l.add(N);try{await v.init(),(p.attributes?.merchandise||p.attributes?.merchandiseId)&&await v.refreshRemote()}catch(C){throw N(),C}return c(),!s&&typeof window<"u"&&window.addEventListener("focus",b),Object.assign(v,{refresh:u,destroy:N})}return{features:g,reset(p){a++,p();for(let A of l)A()}}}import{z as Re}from"zod";function we(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=Re.object({funnelId:G.shape.id,funnelVersionId:G.shape.versionId.optional()}).safeParse(n);if(!r.success)throw new o("INVALID_REQUEST","A valid Funnel source is required");let s=Object.freeze(r.data);function a(l){if("customerId"in l)throw new o("INVALID_REQUEST","Customer identity cannot be overridden");if("funnelId"in l&&l.funnelId!==void 0&&l.funnelId!==s.funnelId||"funnelVersionId"in l&&l.funnelVersionId!==void 0&&l.funnelVersionId!==s.funnelVersionId)throw new o("SCOPE_MISMATCH","The original Funnel source cannot change");return{...l,...s}}return{async claimCoupon(l,y=crypto.randomUUID()){let g=d.grantOffer,p=await m(t,g,a({couponId:l,requestId:y}));return{offer:p.offer,reason:p.reason}},async resolveOffering(l){let y=d.resolveOffering,g=y.request.parse(a(l)),p=await m(t,y,g);return j(g,p.check,p.scope),p},async resolvePaywall(l){let y=d.resolvePaywall,g=y.request.parse(a(l)),p=await m(t,y,g);return j(g,p.paywall.check,p.scope),p},async previewAttach(l){let y=d.previewAttach;return m(t,y,a(l))}}}function Vt(t){return Te(t)}function Te(t){let e=te(t),n=e.request,r;try{r=oe(t.push,e,t.scope??t.configuration?.scope)}catch(y){throw e.dispose(),y}let s=ce(e,()=>{l.reset(a.reset),a.detachVisibility()},{beforeIdentify:r.identify,beforeReset:r.reset,afterChange:r.start,beforeDestroy:r.destroy}),a=Ie(n,s.isIdentified),l=ge(n,s.isIdentified,a,t.scope,t.configuration);return{session:e.session,...ae(n,r),...fe(n),...me(n),forFunnel(y){return s.assertActive(),we(n,y)},async features(y={}){return s.assertActive(),l.features(y)},track(y,g,p={}){return a.track(y,g,p)},flush(){return a.flush()},...s.methods}}function Ht(t){if(!B.test(t.customerToken))throw new o("INVALID_TOKEN","A customer credential is required");if(!t.scope)throw new o("INVALID_REQUEST","An explicit App and environment scope is required");let e=se({...t,scope:t.scope,apiKey:t.customerToken});return{async start(n){let r=await e.start(n),s=U({...t,runToken:r.runToken,initialResponse:r});s.identify(t.customerToken);let a=await s.get();return{...r,...a,controller:s}}}}function Qt(t){if(!t.scope)throw new o("INVALID_CONFIGURATION","An explicit process App/environment scope is required");if(t.session!==void 0)throw new o("INVALID_CONFIGURATION","The merchant process adapter owns the session");let e=null,n,r=0,s=new Set,a=new Map,l=new Map;async function y(f){let S,I=new Promise((q,h)=>{S=setTimeout(()=>h(new o("TIMEOUT","Process bridge request timed out")),t.timeoutMs??35e3)});try{return await Promise.race([Promise.resolve().then(f),I])}finally{clearTimeout(S)}}function g(f){throw f instanceof o&&(f.status===401||f.reason==="CUSTOMER_BINDING_CONFLICT")&&(r++,n?.reset(),n=void 0,e=null,a.clear(),l.clear()),f}function p(f,S){if(S!==r)throw new o("IDENTITY_CHANGED","Process was detached during a request");let I=ee.parse(f);if(I.scope.projectId!==t.scope.projectId||I.scope.environment!==t.scope.environment)throw new o("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 o("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 o("INVALID_RESPONSE","The process lost its Customer binding");e=I;for(let b of s)J(b,I.run);I.run.instruction?.type==="authentication_required"&&J(t.onAuthenticationRequired,I.run)}I.settlement?.accepted!==void 0&&l.set(I.settlement.requestId,I.settlement.accepted);let{identity:q,instruction:h,...O}=I.run,{contract:v,settlement:i,...c}=I,u=i&&(({accepted:b,...P})=>P)(i);return{...c,run:{...O,authenticated:q.binding!==null,instruction:h?.type==="authentication_required"?null:h},...u?{settlement:u}:{}}}let A=f=>(a.has(f)||a.set(f,e?.run.identity.binding?.id??null),a.get(f));async function D(f){let S=r,I=e?.run.identity.binding?.id??null,q=O=>{if(I!==(e?.run.identity.binding?.id??null))throw O;return g(O)};if(f.operation==="page_experiments"){if(!t.adapter.pageExperiments)throw new o("CAPABILITY_UNAVAILABLE","Process page experiments are unavailable",501);return y(()=>t.adapter.pageExperiments(f.release,f.usedReceiptIds)).catch(q)}let h;if(f.operation==="get"){let{operation:O,customerToken:v,...i}=f;h=await y(()=>t.adapter.get({...i,...i.settlementRequestId?{settlementBindingId:A(i.settlementRequestId)}:{}})).catch(q)}else if(f.operation==="review")h=await y(()=>t.adapter.review(f.receiptId)).catch(q);else{if(f.operation==="start")throw new o("INVALID_REQUEST","Use process.open for entry");{let{customerToken:O,...v}=f;h=await y(()=>t.adapter.command(v,A(v.requestId))).catch(q)}}return p(h,S)}return{get view(){return e?.run??null},get controller(){return n},async open(f){let S=r,I=await y(()=>t.adapter.open(f)).catch(g),q=p(I,S);if(!n){n=U({...t,runToken:I.runToken,initialResponse:q,process:{request:D,binding:A,restore(v){for(let[i,c]of Object.entries(v))a.set(i,c)}}});let h=n,O=h.submit;h.submit=async v=>{try{return await O(v)}catch(i){if(!(i instanceof o)||i.reason!=="IDENTITY_CONTEXT_CHANGED"||v.operation!=="submit"||v.input.type!=="screen"||a.get(v.requestId)!==null)throw i;await h.settle?.(v.requestId),await h.get();let c=h.view;if(l.get(v.requestId)!==!1||!c||c.id!==e?.run.id||c.nodeId!==v.nodeId||c.visit!==v.visit||!e?.run.identity.binding)throw i;return O({...v,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 f=r;p(await y(()=>t.adapter.syncIdentity()).catch(g),f),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(),l.clear(),await y(()=>t.adapter.detach())},forProcess(f){if(!e?.run.identity.binding)throw new o("UNAUTHENTICATED","Sign in before a commercial operation",401);return{runId:e.run.id,bindingId:e.run.identity.binding.id,receiptId:f}},subscribe(f){return s.add(f),()=>{s.delete(f)}},destroy(){r++,n?.reset(),n=void 0,e=null,a.clear(),l.clear(),s.clear()}}}export{Vt as a,Te as b,Ht as c,Qt as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{d as t}from"./chunk-LFFBNGXP.js";import{kb as n}from"./chunk-O4535GJR.js";function r(e,o,a){return n(e,o,a,t)}export{r as a};
|