@tinkerlandai/longplay-sdk 0.10.29 → 0.10.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/{chunk-VSWKFI3L.js → chunk-23WNEOK4.js} +1 -1
- package/dist/{chunk-S4JIOALC.js → chunk-2QQZSMTB.js} +1 -1
- package/dist/{chunk-PQJJ5BSY.js → chunk-2TPPGW7V.js} +1 -1
- package/dist/{chunk-TNN4S6VO.js → chunk-4ZVVG5LM.js} +1 -1
- package/dist/{chunk-FDCINOOI.js → chunk-5N7QFF5M.js} +1 -1
- package/dist/{chunk-O4KXODTJ.js → chunk-6BTJNSQQ.js} +1 -1
- package/dist/{chunk-JPHYIUIR.js → chunk-7Z7JT4HE.js} +1 -1
- package/dist/{chunk-AZ53RDWO.js → chunk-ACFQLHJR.js} +1 -1
- package/dist/{chunk-KAXKYBSI.js → chunk-B3KFE57L.js} +1 -1
- package/dist/{chunk-EUVKRGMO.js → chunk-BQLT2LDP.js} +1 -1
- package/dist/{chunk-VKDBROTE.js → chunk-D3UU546S.js} +1 -1
- package/dist/{chunk-Q2TQLDEH.js → chunk-EZ5RCVVY.js} +1 -1
- package/dist/{chunk-HZYCK4XJ.js → chunk-FJGJQGYF.js} +1 -1
- package/dist/{chunk-5X6WAPH3.js → chunk-FVGUBIVT.js} +1 -1
- package/dist/{chunk-7EPE2PUN.js → chunk-HJLGRW4A.js} +1 -1
- package/dist/{chunk-2JTMXZ5M.js → chunk-ITVSLSRM.js} +1 -1
- package/dist/{chunk-TLGKBSXC.js → chunk-J4VTKRH7.js} +1 -1
- package/dist/{chunk-MBKZYWPF.js → chunk-JNSU2AP2.js} +1 -1
- package/dist/{chunk-PNHGULO2.js → chunk-LZV4QJ5E.js} +1 -1
- package/dist/chunk-NH5ML5SB.js +1 -0
- package/dist/chunk-PI25NLDV.js +1 -0
- package/dist/{chunk-UWAZDSWO.js → chunk-QPHT6QHE.js} +1 -1
- package/dist/{chunk-GOYKJHDV.js → chunk-RBMOWJGE.js} +1 -1
- package/dist/{chunk-77GCT2VP.js → chunk-S57HRPT2.js} +1 -1
- package/dist/{chunk-SBSLHDBE.js → chunk-S5H3WJVQ.js} +1 -1
- package/dist/chunk-SJSCROSL.js +1 -0
- package/dist/{chunk-4OBCF5H3.js → chunk-TF2OFTYS.js} +1 -1
- package/dist/{chunk-6QJRT23Q.js → chunk-TMZGZAWM.js} +1 -1
- package/dist/{chunk-K72QA2PO.js → chunk-UWYL2QCF.js} +1 -1
- package/dist/{chunk-PKY55SBA.js → chunk-WK4WQZHK.js} +1 -1
- package/dist/{chunk-4WBIACS2.js → chunk-WRUW2UIJ.js} +1 -1
- package/dist/{chunk-VC2H3LFP.js → chunk-XIP32WI7.js} +1 -1
- package/dist/{chunk-YBX2LLRG.js → chunk-XZEGVBAI.js} +1 -1
- package/dist/chunk-YEXRETKV.js +1 -0
- package/dist/{chunk-CGSZBPSX.js → chunk-YXCEZAQL.js} +1 -1
- package/dist/{chunk-QZG2YXM4.js → chunk-ZYTT7ZAB.js} +1 -1
- package/dist/{content-S5MXIR7Y.js → content-OY5MRXF5.js} +1 -1
- package/dist/{funnel-host-purchase-7BRXGIJX.js → funnel-host-purchase-IRFPNIZY.js} +1 -1
- package/dist/{funnel-local-client-DoYVcZ1z.d.ts → funnel-local-client-D7e3rP5-.d.ts} +1 -1
- package/dist/{funnel-process-client-DtXNiFQ-.d.ts → funnel-process-client-BEPv6guV.d.ts} +1 -1
- package/dist/funnel-runtime-host-CJTPLZ4N.js +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/merchant-bridge-contracts-LJKL7PNJ.js +1 -0
- package/dist/native-shell.js +1 -1
- package/dist/openrouter.js +1 -1
- package/dist/operation-contracts-SP2RZUT3.js +1 -0
- package/dist/page.js +1 -1
- package/dist/paywall-DI62MX5L.js +1 -0
- package/dist/paywall-session-AW6R3PJB.js +1 -0
- package/dist/popup.js +1 -1
- package/dist/react-native.d.ts +4 -4
- package/dist/react-native.js +1 -1
- package/dist/screen-renderer-W5MP4KVG.js +1 -0
- package/dist/server.d.ts +2 -2
- package/dist/server.js +1 -1
- package/dist/{visual-dom-5LUN4AHO.js → visual-dom-32PB6MMP.js} +1 -1
- package/dist/visual.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-3GT4A3TA.js +0 -1
- package/dist/chunk-IDMOAV63.js +0 -1
- package/dist/chunk-JAUJZWYJ.js +0 -1
- package/dist/chunk-MMZR4I5X.js +0 -1
- package/dist/funnel-runtime-host-ITKTYBDS.js +0 -1
- package/dist/merchant-bridge-contracts-JCDMP54Z.js +0 -1
- package/dist/operation-contracts-B7I45NS3.js +0 -1
- package/dist/paywall-BEFHTZW7.js +0 -1
- package/dist/paywall-session-YVGZPSFM.js +0 -1
- package/dist/screen-renderer-ITUUNF4E.js +0 -1
- /package/dist/{chunk-CILM5XMH.js → chunk-PWXN3W4Q.js} +0 -0
- /package/dist/{chunk-OJM6ORHE.js → chunk-RFUXSC52.js} +0 -0
- /package/dist/{chunk-7GD2UTBU.js → chunk-ZY4XAKNQ.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as UA}from"./chunk-TLGKBSXC.js";import{a as P}from"./chunk-7EPE2PUN.js";import{a as _A,d as jA,e as xA,f as MA,h as sA}from"./chunk-VC2H3LFP.js";import{a as $A,b as zA}from"./chunk-5X6WAPH3.js";var pA="X-Indiana-Protocol",FA="X-Indiana-SDK-Version";var gA={current:"0.10"};function b(A){return typeof A=="string"?A:String(A)}var De=/[\ud800-\udbff](?![\udc00-\udfff])|(^|[^\ud800-\udbff])[\udc00-\udfff]/g;function Se(A){return A.replace(De,"$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(b);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[b(t.value),b(n.value)]}throw new TypeError("Each query pair must be an iterable [name, value] tuple")}var GA="0123456789ABCDEF",be=/(?:%[0-9A-Fa-f]{2})+/g;function M(A){return`%${GA[A>>4&15]}${GA[15&A]}`}function Ae(A,e,t=!1){return A>=55296&&A<=57343&&(A=65533),A<=127?t&&A===32?"+":e(A)?M(A):String.fromCharCode(A):A<=2047?M(192|A>>6)+M(128|63&A):A<=65535?M(224|A>>12)+M(128|A>>6&63)+M(128|63&A):M(240|A>>18)+M(128|A>>12&63)+M(128|A>>6&63)+M(128|63&A)}function 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 SA(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(be,n=>{try{return decodeURIComponent(n)}catch{return"\uFFFD".repeat(n.length/3)}})}function AA(A){return A<=31||A>126}function Ie(A){switch(A){case 32:case 34:case 60:case 62:case 96:return!0;default:return AA(A)}}function OA(A){switch(A){case 32:case 34:case 35:case 60:case 62:return!0;default:return AA(A)}}function Ce(A){return OA(A)||A===39}function bA(A){switch(A){case 63:case 94:case 96:case 123:case 125:return!0;default:return OA(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 bA(A)}}function KA(A){switch(A){case 33:case 39:case 40:case 41:case 126:return!0;default:return(function(t){switch(t){case 36:case 37:case 38:case 43:case 44:return!0;default:return cA(t)}})(A)}}function ee(A,e){return Ae(A=A||0,e)}function U(A,e,t=!1){let n=0;for(;n<A.length;n++){let u=A.charCodeAt(n);if(u>=128||t&&u===32||e(u))break}if(n===A.length)return A;let r=A.slice(0,n);for(;n<A.length;n++){let u=A.charCodeAt(n),l=u;if(u>=55296&&u<=56319&&n+1<A.length){let a=A.charCodeAt(n+1);a>=56320&&a<=57343&&(l=(u-55296<<10)+a-56320+65536,n++)}r+=Ae(l,e,t)}return r}function qA(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([SA(r.slice(0,u),!0),SA(r.slice(u+1),!0)])}if(t=n+1,n===A.length)break}return e}function IA(A){let e="";for(let t=0;t<A.length;t++){let n=U(A[t][0],KA,!0),r=U(A[t][1],KA,!0);e+=t!==0?`&${n}=${r}`:`${n}=${r}`}return e}var Ee=[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],Te=[7296,7297,7298,7299,7300,7301,7302,7303,7304,42958,42962,42964,42993],ve=["\u0432","\u0434","\u043E","\u0441","\u0442","\u0442","\u044A","\u0463","\uA64B","\uA7CF","\uA7D3","\uA7D5","s"],Oe=[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 qe(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[Re,Ne,ke,YA]=[[[],"0,6,7,8,m,w,10,1b,1d,1f,72,73,7k,8k,dt,2rk","AAAAAAAAAAAAAAAAAAAAAP////8AAAAAAAAAAAAAAAA/AAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAADAAABwfwAAAAAAAMADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//w8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAhAAAAQAAAAAAAAQCAAABAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgACAAAAAAAAAAAAAAAAD//wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAP///////////////wAAAAAAAAAAAAAAAAAAAAA="],[[],"6,7,8,o,4o,7e,7f,7h,7i,7j,dl","AAAAAEF9+P/+BwAAAMAA//8AAPz/////BlADAAAAAJwAAPz///8AAADA//H/5+X8AAAAAAAAAAAA/P///wcAAAAAAAAAAAAAPv0vAD0BAABA/gAA/5/5/f8BAAAAAAAAgAAAAP//////////////AYD/////BQAAAAAAAAAAAAAAAAAAAAAAAP///////wcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD8g+N8B+AAAAAAAAAAAAAAAAAAAAAAAAP//AwAAYAAAAAAAAAAAAAD/////CwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANgAAAAAAAAAAAAAAAAA//8fAB4AAAD//wMAAAAAAH3/HgwAAAAAAAD//////////w8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="],[[],"6,7,8,o,4o,7e,7f,7h,7i,7j,dl","AAAAAP3////+BwAAAMDu//////////////8vAADAAJwAAP3///8AAADg////////AAAAAAAAAAAA/P///wcAAAAAAAAAAAAA////Ab0H//9H/gAA/9////8BAAAAAAAAgAAAAP//////////////AYD/////BQAAAAAAAAAAAAAAAAAAAAAAAP///////wcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAL/G//8T+AAAAAAAAAAAAAAAAAAAAAAAAP//AwAAfgAAAAAAAAAAAAD+////DwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANwAAAAAAAAAAAAAAAAA//8fAB4AAAD//wMAAAAAAH3/Hg4AAAAAAAD//////////w8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="],[[],"0,3,4,5,6,7,8,9,a,b,c,d,e,f,g,j,n,o,p,q,r,s,t,w,18,19,1c,4m,4o,4p,4q,4r,6z,72,73,75,76,77,7e,7h,7i,7j,7k,7l,7m,7n,7o,7p,7q,7r,7s,7t,7u,7v,7w,7x,7y,7z,8k,9t,a2,a3,a7,cc,cv,cx,cy,d6,dc,dd,de,dg,dh,di,dk,dl,2rk,2rl","AAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAD//////////////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD4AwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/v////+/tgAAAAAAAAAAAP8XAAAAAAD4//8AAAEAAAAAAAAAAAAAAMCfnz0AAACAAgAAAP///wcAAAAAAAAAAAAAwP8BAAAAAAAA+A8gAADA++8+AAAAAAAOAAAAAAAAgP8AAAAAAPz///v///8HAAAAAAAAFP4h/gAMAAAAAgAAAAAAABAeIAAADAAAQAYAAAAAAAAQhjkCAAAAIwAGAAAAAAAAEL4hAAAMAAD8AgAAAAAAAJAeIGAADAAAAAQAAAAAAAAAASAAAAAAAAARAAAAAAAA0ME9YAAMAAAAAgAAAAAAAJBAMAAADAAAAAMAAAAAAAAYHiAAAAwAAAACAAAAAAAAAAAEXAAAAAAAAAAAAAAA8geAfwAAAAAAAAAAAAAAAPIfAH8AAAAAAAAAAAADAACgAgAAAAAAAP5/3+D//v///x9AAAAAAAAAAAAAAAAA4P1mAAAAwwEAHgBkIAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAMAAAADAAAAAwAAAAAAAAAsD9A/g8gAAAAAAC4AAAAAAAAAAAAAAAAAABgAAAAAAIAAAAAAAAAAAAAAAAAAIcBBA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAJAAAAAAAAQH/lH/ifAAAAAAAA//////8//w8AAA8AAAAAANAXBAAAAAD4DwADAAAAPDsAAAAAAABAowMAAAAAAADwzwAAAAAAAAAAAAAAAAAAAAAAAAD3//0hEAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////wDIAAAAfAAAAAAAAB/8AAAAAAAAAAAAAAAA/////wEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAwAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAA/////wAAAAAAPAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAID3PwAAAMAAAAAAAAAAAAAAAwBECAAAYBAAAAAAAAAAAAAAAAAAAAAAAAAwAAAA//8DgAAAAADAPwAAgP8DAAAAAAAHAAAAAADIMwAAAAAgAAAAAAAAAAB+ZgAIEAAAAAAAEAAAAAAAAJ3BAgAAAAAwQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAICEAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//8AAP//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAMAHAAAAAAAAAAAAAAAAAAAAAG7wAAAAAACHAAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAAAAAAPAAAAAAAAAAAD4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAA/AAAAAAAAAAAwP8BAAAAAAA8AAAAAAAAAAAAAAAAAAAAAgAAAAAAAP9/AAAAAAAZgAMAAAAAAHgGBAAAAAAAAAAHAAAAgO8fAAAAAAAAAAgAAwAAAAAAwH8AngAAAAAAAAAAAAAAgNNAAgAAAAAAAAAAAAAAAAAAAAAAAID4BwAAAwAAAAAAABgBAAAAwB8fAAAAAAAAAAD4AUAFAAYAAAAAAAAAAAAA/1wAAEAAAAAAAAAAAAAA+IUNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8sAEAADAAAAAAAAAAAAAA+KcBAAAAAAAAAAAAAAAAKL8AAAAAAAAAAAAAAACgvA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgP8GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFgIAAAAAAAAAAAAAAAAAAAAAADwDAEAAAD+BwAAAAD4eYAAfg4AAAAAAPx/AwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAf78AAAAAAAAAAAAA/P///G0AAAAAAAAAAAAAAAAAAAB+tL8AAAAAAAAAAACjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAwAcFAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//4H/PwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMD/4wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHwAAAAAAAAB/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAcAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAPAAAAAAAAAAAAAAD//////z///38AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAD+P/nDwAAADwAAAAAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////9/+P//////HyAAEAAA+P7/AAAAAAAAAAAAAH////nbBwAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAfwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASMAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAfwAAAAAAAAAAAAAAAADwDwAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAA////////////////AAAAAAAAAAAAAAAAAAAAAP///////////////////////////////////////wAA"]].map(function([e,t,n]){return[e,t.split(",").map(r=>parseInt(r,36)),Uint8Array.from(atob(n),r=>r.charCodeAt(0))]});function Le(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 W(A,e){let[t,n,r]=A,u=e>>8;for(let h=0;h<t.length;h+=2)if(u>=t[h]&&u<=t[h+1])return!0;let l=n.indexOf(u);if(l<0)return!1;let a=255&e;return!!(r[32*l+(a>>3)]&1<<(7&a))}function He(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(Oe,e[t-1]))continue;if(n===8205)return!1;let r=t-1;for(;r>=0&&W(YA,e[r]);)r--;let u=t+1;for(;u<e.length&&W(YA,e[u]);)u++;if(!(r>=0&&u<e.length&&W(Ne,e[r])&&W(ke,e[u])))return!1}return!0}var Be=/(?![\p{Mark}\p{Decimal_Number}])[\p{Script=Arabic}\p{Script=Hebrew}]/u,_e=/\p{Script=Latin}/u;function je(A){return!Be.test(A)||!_e.test(A)}var F=36,iA=1,CA=26,xe=38,Me=700,Ue=72,$e=128,ze=2147483647;function VA(A){return String.fromCharCode(A+22+75*+(A<26))}function Fe(A,e,t){let n=0;for(A=t?Math.floor(A/Me):A>>1,A+=Math.floor(A/e);A>(F-iA)*CA>>1;n+=F)A=Math.floor(A/(F-iA));return Math.floor(n+(F-iA+1)*A/(A+xe))}function Qe(A){let e=Array.from(A,h=>h.codePointAt(0)),t="",n=0;for(let h=0;h<e.length;h++){let f=e[h];f<128&&(t+=String.fromCharCode(f),n++)}let r=n;r&&(t+="-");let u=$e,l=0,a=Ue;for(;n<e.length;){let h=ze;for(let f=0;f<e.length;f++){let g=e[f];g>=u&&g<h&&(h=g)}l+=(h-u)*(n+1),u=h;for(let f=0;f<e.length;f++){let g=e[f];if(g<u&&l++,g===u){let p=l;for(let w=F;;w+=F){let y=w<=a?iA:w>=a+CA?CA:w-a;if(p<y)break;t+=VA(y+(p-y)%(F-y)),p=Math.floor((p-y)/(F-y))}t+=VA(p),a=Fe(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 XA(A){switch(A){case".":case"%2e":case"%2E":return!0;default:return!1}}function ne(A,e){return(A>=65&&A<=90||A>=97&&A<=122)&&(e===58||e===124)}function re(A){return A.length===2&&ne(A.codePointAt(0),A.codePointAt(1))}function JA(A){return A.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|\/|:|<|>|\?|@|\[|\\|\]|\^|\|/u)!==-1}function C(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,h=Array.from(n,f=>f.codePointAt(0));if(h[a]===58){if(h[a+1]!==58)return null;a+=2,l++,u=l}for(;a<h.length;){if(l===8)return null;if(h[a]===58){if(u!==null)return null;a++,l++,u=l;continue}let f=0,g=0,p=0;for(;p<4&&(f=DA(h[a]))>=0;)g=(g<<4)+f,a++,p++;if(h[a]===46){if(p===0||l>6)return null;a-=p;let w=0;for(;h[a]!==void 0;){let y=0;if(w>0)if(h[a]===46&&w<4)a++;else return null;if(h[a]==null||h[a]<48||h[a]>57)return null;for(;h[a]>=48&&h[a]<=57;){if(y=10*y+DA(h[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(h[a]===58){if(h[++a]===void 0)return null}else if(h[a]!==void 0)return null;r[l]=g,l++}if(u!==null){let f=l-u;for(l=7;l!==0&&f>0;){let g=r[u+f-1];r[u+f-1]=r[l],r[l]=g,l--,f--}}else if(u===null&&l!==8)return null;return r})(A.substring(1,A.length-1)):null;if(e)return(function(n){return JA(n)?null:U(n,AA)})(A);{let t=(function(r){let u=!1,l=!1;for(let h=0;h<r.length;h++){let f=r.charCodeAt(h);if(f<=32||f===37||f===127)return null;if(f>=128){u=!0;break}f>=65&&f<=90&&(l=!0)}if(!u)return r!==""?l?r.toLowerCase():r:null;if((function(f){for(let g of f){let p=g.codePointAt(0);if(/[\p{Cn}\p{Co}\p{Cs}\p{Noncharacter_Code_Point}]/u.test(g)&&!te(Ee,p)||W(Re,p))return!0}return!1})(r))return null;let a=(r=(function(f){let g="";for(let p of f){let w=p.codePointAt(0);if(w!==8204&&w!==8205&&/\p{Default_Ignorable_Code_Point}/u.test(p))continue;let y=Le(p,w);if(y){g+=y;continue}let R=Te.indexOf(w);g+=R<0?p:ve[R]}return g})(r).normalize("NFKC").replace(/[\u3002\uff0e\uff61]/g,".").toLowerCase()).split(".");for(let h=0;h<a.length;h++){let f=a[h];if(f==="")continue;let g=/[^\0-\x7f]/.test(f);if(qe(f)||g&&(/^\p{Mark}/u.test(f)||!He(f)||!je(f)||f.startsWith("xn--")))return null;g&&(a[h]=`xn--${Qe(f)}`)}return(r=a.join("."))!==""?r:null})(A.indexOf("%")===-1?A:SA(A));return t===null||JA(t)?null:(function(r){let u=r.length,l=r.lastIndexOf(".",u-2)+1;if(r.charCodeAt(u-1)===46&&u--,u<=l)return!1;if(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 f=0;f<l-1;f++){let g=mA(u[f]);if(g<0||g>255)return null;a+=g*(1<<8*(3-f))}let h=mA(u[l-1]);return h<0||h>=256**(5-l)?null:(a+=h,a)})(t):t}}function TA(A){return typeof A=="number"?(function(t){let r="";return r+=`${(t>>>24&255).toString(10)}.`,r+=`${(t>>>16&255).toString(10)}.`,r+=`${(t>>>8&255).toString(10)}.`,r+=(t&255).toString(10),r})(A):Array.isArray(A)?`[${(function(t){let n=(function(a){let h=-1,f=-1,g=1,p=0;for(let w=0;w<a.length;++w)a[w]!==0?(p>g&&(h=f,g=p),f=-1,p=0):(f===-1&&(f=w),++p);return p>g?f:h})(t),r="",u=!1;for(let l=0;l<=7;++l)if(!(u&&t[l]===0)){if(u&&(u=!1),n===l){r+=l===0?"::":":",u=!0;continue}r+=t[l].toString(16),l!==7&&(r+=":")}return r})(A)}]`:A}function oe(A){A.path.length>0&&(A.path.length!==1||A.scheme!=="file"||!(function(t){return/^[A-Za-z]:$/u.test(t)})(A.path[0]))&&A.path.pop()}function ie(A){return A.username!==""||A.password!==""}function wA(A){return A.host===null||A.host===""||A.scheme==="file"}var s=0,o="",m="",D=null,i,lA=!1,uA=!1,G=!1,E;function H(A,e,t,n){e||(A=(function(l){let a=0,h=l.length;for(;a<h&&!(l.charCodeAt(a)>32);++a);for(;h>a&&!(l.charCodeAt(h-1)>32);--h);return l.substring(a,h)})(A)),A=(function(l){let a=0;for(;a<l.length;a++){let f=l.charCodeAt(a);if(f===9||f===10||f===13)break}if(a===l.length)return l;let h=l.slice(0,a);for(;a<l.length;a++){let f=l.charCodeAt(a);f!==9&&f!==10&&f!==13&&(h+=l[a])}return h})(A),s=0,o=A,m="",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=Ge;switch(n){case 3:case 4:r=aA;break;case 5:r=NA;break;case 6:r=K;break;case 7:r=Q;break;case 8:r=$}return r(c(A,s))!==1?i:null}function d(A,e){return s+=s===A?j(e):1,s<=o.length}function c(A,e){return e<A.length?A.codePointAt(e):void 0}function j(A){return A!=null&&A>65535?2:1}function le(A){return A==null?"":A<=65535?String.fromCharCode(A):String.fromCodePoint(A)}var Ge=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 m=o.slice(s,t).toLowerCase(),s=t,Ke(t<o.length?A:void 0)}else return E?1:(--s,d(e,A)?ue(c(o,s)):0)},Ke=A=>{let e=s;if(A===58){if(E){if(C(i.scheme)!==C(m))return 0;if((ie(i)||i.port!==null)&&m==="file")return 0;if(i.scheme==="file"&&i.host==="")return 0}return i.scheme=m,E?(i.port===se(i.scheme)&&(i.port=null),0):(m="",i.scheme==="file"?d(e,A)?kA(c(o,s)):0:C(i.scheme)&&D!==null&&D.scheme===i.scheme?d(e,A)?Ye(c(o,s)):0:C(i.scheme)?d(e,A)?Xe(c(o,s)):0:c(o,s+1)===47?(s++,d(e,A)?Ve(c(o,s)):0):(i.path=[""],i.opaquePath=!0,d(e,A)?ae(c(o,s)):0))}else return E?1:(m="",s=-1,d(e,A)?ue(c(o,s)):0)},ue=A=>{let e=s;return D===null||D.opaquePath&&A!==35?1:D.opaquePath&&A===35?(i.scheme=D.scheme,i.path=D.path.slice(),i.opaquePath=D.opaquePath,i.query=D.query,i.fragment="",d(e,A)?$(c(o,s)):0):D.scheme==="file"?(s--,d(e,A)?kA(c(o,s)):0):(s--,d(e,A)?RA(c(o,s)):0)},Ye=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)?RA(c(o,s)):0)},Ve=A=>{let e=s;return A===47?d(e,A)?J(c(o,s)):0:(s--,d(e,A)?x(c(o,s)):0)},RA=A=>{let e=s;return i.scheme=D.scheme,A===47||C(i.scheme)&&A===92?d(e,A)?WA(c(o,s)):0:(i.username=D.username,i.password=D.password,i.host=D.host,i.port=D.port,i.path=D.path.slice(),i.query=D.query,A===63?(i.query="",d(e,A)?Q(c(o,s)):0):A===35?(i.fragment="",d(e,A)?$(c(o,s)):0):A!=null?(i.query=null,i.path.pop(),s--,d(e,A)?x(c(o,s)):0):d(e,A)?RA(c(o,s)):0)},WA=A=>{let e=s;return C(i.scheme)&&(A===47||A===92)?d(e,A)?hA(c(o,s)):0:A===47?d(e,A)?J(c(o,s)):0:(i.username=D.username,i.password=D.password,i.host=D.host,i.port=D.port,s--,d(e,A)?x(c(o,s)):0)},Xe=A=>{let e=s;return A===47&&c(o,s+1)===47?s++:s--,d(e,A)?hA(c(o,s)):0},hA=A=>{let e=s;return A!==47&&A!==92?(s--,d(e,A)?J(c(o,s)):0):d(e,A)?hA(c(o,s)):0},J=A=>{let e=s;if(A!=null&&A!==64&&A!==35&&A!==47&&A!==63&&(A!==92||!C(i.scheme))){let t=s+j(A);for(;t<o.length;){let n=c(o,t);if(n==null||n===64||n===35||n===47||n===63||n===92&&C(i.scheme))break;t+=j(n)}return m+=o.slice(s,t),s=t-1,d(e,A)?J(c(o,s)):0}if(A===64){lA&&(m=`%40${m}`),lA=!0;for(let t=0;t<m.length;t++){let n=m.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 m="",d(e,A)?J(c(o,s)):0}else return A==null||A===35||A===47||A===63||A===92&&C(i.scheme)?lA&&m===""?1:(s-=m.length+1,m="",d(e,A)?aA(c(o,s)):0):(m+=le(A),d(e,A)?J(c(o,s)):0)},aA=A=>{let e=s;if(E&&i.scheme==="file")return s--,d(e,A)?LA(c(o,s)):0;if(A!=null&&A!==58&&A!==35&&A!==47&&A!==63&&(A!==92||!C(i.scheme))){let t=s+j(A);for(A===91?G=!0:A===93&&(G=!1);t<o.length;){let n=c(o,t);if(n==null||!G&&n===58||n===35||n===47||n===63||n===92&&C(i.scheme))break;n===91?G=!0:n===93&&(G=!1),t+=j(n)}return m+=o.slice(s,t),s=t-1,d(e,A)?aA(c(o,s)):0}else if(A===58&&!G){if(m===""||E===4)return 1;let t=EA(m,!C(i.scheme));return t===null?1:(i.host=TA(t),m="",d(e,A)?NA(c(o,s)):0)}else if(A==null||A===35||A===47||A===63||A===92&&C(i.scheme)){if(s--,C(i.scheme)&&m==="")return 1;if(E&&m===""&&(ie(i)||i.port!==null))return 1;let t=EA(m,!C(i.scheme));return t===null?1:(i.host=TA(t),m="",E?0:d(e,A)?K(c(o,s)):0)}else return m+=le(A),d(e,A)?aA(c(o,s)):0},NA=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 m+=o.slice(s,t),s=t-1,d(e,A)?NA(c(o,s)):0}else if(E||A==null||A===35||A===47||A===63||A===92&&C(i.scheme)){if(m!==""){let t=parseInt(m,10);if(t>65535)return 1;if(i.port=t===se(i.scheme)?null:t,m="",E)return 0}return E?1:(s--,d(e,A)?K(c(o,s)):0)}else return 1};function ce(A,e){let t=A.length-e;if(t<2)return!1;if(ne(c(A,e),c(A,e+1))){if(t===2)return!0;{let n=c(A,e+2);return n===47||n===92||n===63||n===35}}else return!1}var kA=A=>{let e=s;return i.scheme="file",i.host="",A===47||A===92?d(e,A)?Je(c(o,s)):0:D?.scheme==="file"?(i.host=D.host,i.path=D.path.slice(),i.opaquePath=D.opaquePath,i.query=D.query,A===63?(i.query="",d(e,A)?Q(c(o,s)):0):A===35?(i.fragment="",d(e,A)?$(c(o,s)):0):A!=null?(i.query=null,ce(o,s)?i.path=[]:oe(i),s--,d(e,A)?x(c(o,s)):0):d(e,A)?kA(c(o,s)):0):(s--,d(e,A)?x(c(o,s)):0)},Je=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)?x(c(o,s)):0)},LA=A=>{let e=s;if(A!=null&&A!==47&&A!==92&&A!==63&&A!==35){let t=s+j(A);for(;t<o.length;){let n=c(o,t);if(n==null||n===47||n===92||n===63||n===35)break;t+=j(n)}return m+=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(m))return d(e,A)?x(c(o,s)):0;if(m==="")return i.host="",E?0:d(e,A)?K(c(o,s)):0;{let t=EA(m,!C(i.scheme));return t===null?1:(t==="localhost"&&(t=""),i.host=TA(t),m="",E?0:d(e,A)?K(c(o,s)):0)}}return 1},K=A=>{let e=s;return C(i.scheme)?(A!==92&&A!==47&&s--,d(e,A)?x(c(o,s)):0):!E&&A===63?(i.query="",d(e,A)?Q(c(o,s)):0):!E&&A===35?(i.fragment="",d(e,A)?$(c(o,s)):0):A!=null?(A!==47&&s--,d(e,A)?x(c(o,s)):0):(E&&i.host===null&&i.path.push(""),d(e,A)?K(c(o,s)):0)},x=A=>{let e=s;if(A!=null&&A!==47&&(!C(i.scheme)||A!==92)&&(E||A!==63&&A!==35)){let t=s+j(A);for(;t<o.length;){let n=c(o,t);if(n==null||n===47||C(i.scheme)&&n===92||!E&&(n===63||n===35))break;t+=j(n)}m+=U(o.slice(s,t),bA),s=t,A=c(o,t)}if(A==null||A===47||C(i.scheme)&&A===92||!E&&(A===63||A===35)){let t=C(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}})(m)?(oe(i),A!==47&&!t&&i.path.push("")):XA(m)&&A!==47&&!t?i.path.push(""):XA(m)||(i.scheme==="file"&&i.path.length===0&&re(m)&&(m=`${m[0]}:`),i.path.push(m)),m="",A===63?(i.query="",d(e,A)?Q(c(o,s)):0):A===35?(i.fragment="",d(e,A)?$(c(o,s)):0):d(e,A)?x(c(o,s)):0}else return m+=ee(A,bA),d(e,A)?x(c(o,s)):0},ae=A=>{let e=s;if(A===63)return i.query="",d(e,A)?Q(c(o,s)):0;if(A===35)return i.fragment="",d(e,A)?$(c(o,s)):0;if(A!=null){let t=s+j(A);for(;t<o.length;){let r=c(o,t);if(r===63||r===35)break;t+=j(r)}let n=o.slice(s,t);if(t<o.length&&n.charCodeAt(n.length-1)===32?i.path[0]+=U(n.slice(0,-1),AA)+"%20":i.path[0]+=U(n,AA),s=t,(A=c(o,t))===63)return i.query="",d(e,A)?Q(c(o,s)):0;if(A===35)return i.fragment="",d(e,A)?$(c(o,s)):0}return d(e,A)?ae(c(o,s)):0},Q=A=>{let e=s,t=s;if(A!=null){if(E)t=o.length;else{let r=o.indexOf("#",s);t=r===-1?o.length:r}let n=C(i.scheme)?Ce:OA;i.query+=U(o.slice(s,t),n)}return s=t,c(o,t)===35&&!E?(i.fragment="",d(e,A)?$(c(o,s)):0):d(e,A)?Q(c(o,s)):0},$=A=>{let e=s;return A!=null&&(i.fragment+=U(o.slice(s),Ie),s=o.length),d(e,A)?$(c(o,s)):0};function vA(A){if(A.opaquePath)return A.path[0];{let e="";for(let t of A.path)e+=`/${t}`;return e}}function fe(A){switch(A.scheme){case"blob":{let e=H(vA(A),null,null,0);return e===null||e.scheme!=="http"&&e.scheme!=="https"?"null":fe(e)}case"ftp":case"http":case"https":case"ws":case"wss":return(function(t){let n=`${t.scheme}://`;return n+=t.host,t.port!==null&&(n+=`:${t.port}`),n})(A);default:return"null"}}var S=Symbol("URLImpl"),eA=class A{constructor(e,t){if(e===void 0&&t===void 0)throw new TypeError('The "url" argument must be specified.');e=b(e),t!=null&&(t=b(t));let n=null;if(t!=null&&(n=H(t,null,null,0),n==null))throw new TypeError(`Invalid base URL: ${t}`);let r=H(e,null,n,0);if(r==null)throw new TypeError(`Invalid URL: ${e}`);this[S]={url:r,query:null}}static createObjectURL(e){throw new TypeError("URL.createObjetURL is unsupported")}static revokeObjectURL(e){}static parse(e,t){e=b(e),t!==void 0&&(t=b(t));try{return new A(e,t)}catch{return null}}static canParse(e,t){e=b(e),t!==void 0&&(t=b(t));let n=null;return t!=null&&(n=H(t,null,null,0),n==null)?!1:H(e,null,n,0)!=null}get href(){return(function(t){let n=`${t.scheme}:`;return t.host!==null&&(n+="//",(t.username!==""||t.password!=="")&&(n+=t.username,t.password!==""&&(n+=`:${t.password}`),n+="@"),n+=t.host,t.port!==null&&(n+=`:${t.port}`)),t.host===null&&!t.opaquePath&&t.path.length>1&&t.path[0]===""&&(n+="/."),n+=vA(t),t.query!==null&&(n+=`?${t.query}`),t.fragment!==null&&(n+=`#${t.fragment}`),n})(this[S].url)}set href(e){let t=H(e=b(e),null,null,0);if(t==null)throw new TypeError(`Invalid URL: ${e}`);this[S].url=t,this[S].query&&yA(this[S].query,t.query)}get origin(){return fe(this[S].url)}get protocol(){return`${this[S].url.scheme}:`}set protocol(e){H(`${e=b(e)}:`,this[S].url,null,2)}get username(){return this[S].url.username}set username(e){e=b(e),wA(this[S].url)||(function(n,r){n.username=U(r,cA)})(this[S].url,e)}get password(){return this[S].url.password}set password(e){e=b(e),wA(this[S].url)||(function(n,r){n.password=U(r,cA)})(this[S].url,e)}get host(){let{url:e}=this[S];return e.host==null?"":e.port==null?e.host:`${e.host}:${e.port}`}set host(e){e=b(e),this[S].url.opaquePath||H(e,this[S].url,null,3)}get hostname(){let{url:e}=this[S];return e.host!=null?e.host:""}set hostname(e){e=b(e),this[S].url.opaquePath||H(e,this[S].url,null,4)}get port(){let{url:e}=this[S];return e.port!=null?`${e.port}`:""}set port(e){e=b(e);let{url:t}=this[S];wA(t)||(e?H(e,t,null,5):t.port=null)}get pathname(){return vA(this[S].url)}set pathname(e){e=b(e);let{url:t}=this[S];t.opaquePath||(t.path=[],H(e,t,null,6))}get search(){let{url:e}=this[S];return e.query?`?${e.query}`:""}set search(e){e=b(e);let{url:t,query:n}=this[S];if(!e)t.query=null,n&&yA(n,null);else{let r=e[0]==="?"?e.substring(1):e;t.query="",H(r,t,null,7),n&&yA(n,t.query)}}get searchParams(){let e=this[S],t=e.query;return t==null&&(t=e.query=(function(r,u){let l=new fA;return l[I].url=r,l[I].serialized=u==null,u&&(l[I].list=qA(u)),l})(this,e.url.query)),t}get hash(){let{url:e}=this[S];return e.fragment?`#${e.fragment}`:""}set hash(e){e=b(e);let{url:t}=this[S];if(!e)t.fragment=null;else{let n=e[0]==="#"?e.substring(1):e;t.fragment="",H(n,t,null,8)}}toJSON(){return this.href}toString(){return this.href}};Object.defineProperty(eA.prototype,Symbol.toStringTag,{value:"URL",configurable:!0});var I=Symbol("URLSearchParamsImpl"),We=Symbol.dispose||Symbol.for("dispose");function yA(A,e){e?A[I].list=qA(e):A[I].list.length=0,A[I].serialized=e==null}function oA(A){if(A.url){let e=IA(A.list);(function(n,r){n[S].url.query=r})(A.url,e||null),A.serialized=!0}}var Ze=typeof Iterator<"u"?Iterator:Object,Z=class extends Ze{constructor(e,t){super(),this[I]={ptr:e,map:t,index:0}}next(){let e=this[I];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}[We](){}},fA=class{constructor(e){let t=this[I]={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=Se(l),h=b(e[l]),f=t.list.find(g=>g[0]===a);f?f[1]=h:t.list.push([a,h])}}else if(e!==void 0){let r=b(e);r=r[0]==="?"?r.substring(1):r,t.list=qA(r)}}get size(){return this[I].list.length}append(e,t){e=b(e),t=b(t),this[I].list.push([e,t]);let n=this[I];n.url&&n.serialized?(function(u,l){let a=u[S].url;a.query=a.query?`${a.query}&${l}`:l})(n.url,IA([[e,t]])):oA(n)}delete(e,t){e=b(e),t=t!=null?b(t):void 0;let{list:n}=this[I],r=0;for(;r<n.length;)n[r][0]===e&&(t==null||n[r][1]===t)?n.splice(r,1):r++;oA(this[I])}get(e){e=b(e);let{list:t}=this[I];for(let n=0;n<t.length;n++)if(t[n][0]===e)return t[n][1];return null}getAll(e){e=b(e);let t=[],{list:n}=this[I];for(let r=0;r<n.length;r++)n[r][0]===e&&t.push(n[r][1]);return t}has(e,t){e=b(e),t=t!=null?b(t):void 0;let{list:n}=this[I];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=b(e),t=b(t);let{list:n}=this[I],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[I])}sort(){this[I].list.sort((e,t)=>e[0]<t[0]?-1:e[0]>t[0]?1:0),oA(this[I])}forEach(e,t){if(typeof e!="function")throw new TypeError('The "callback" argument must be of type function');let{list:n}=this[I];for(let r=0;r<n.length;r++)e.call(t,n[r][1],n[r][0],this)}entries(){return new Z(this[I],e=>e)}keys(){return new Z(this[I],e=>e[0])}values(){return new Z(this[I],e=>e[1])}toString(){return IA(this[I].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 h=()=>a();function f(p,w=!1){let y=UA.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 g(){if(r)return r;let p=typeof e=="object"?e:void 0,w=n;if(!p||Date.parse(p.refreshExpiresAt)<=Date.now())throw p&&h(),new P("UNAUTHENTICATED","Customer authentication is required",401);let y=(async()=>{try{let R=await A(p.refreshToken);if(w!==n)throw new P("IDENTITY_CHANGED","Customer identity changed during refresh");let Y=f(R,!0);if(Y.customerId!==p.customerId||Y.sessionId!==p.sessionId)throw new P("SCOPE_MISMATCH","Refresh changed the customer session");return e=Y,{...Y}}catch(R){throw w!==n?new P("IDENTITY_CHANGED","Customer identity changed during refresh"):(R instanceof P&&R.status===401&&h(),R)}})();r=y;try{return await y}finally{r===y&&(r=void 0)}}return{identify(p){let w=typeof p=="string"?p:f(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:h,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 g().then(()=>{let R=t();if(y!==n||!R)throw new P("IDENTITY_CHANGED","Customer identity changed during refresh");return R})}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:g}}var de=Symbol("IndianaNoContent");function dt(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??zA);if(l.username||l.password||l.search||l.hash)throw new P("INVALID_URL","baseUrl must not contain credentials, query, or fragment");if(l.protocol!=="https:"&&!(l.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(l.hostname)))throw new P("INVALID_URL","Use HTTPS, or HTTP on localhost during development");let a=A.fetch??globalThis.fetch.bind(globalThis),h=A.timeoutMs??1e4;if(!Number.isFinite(h)||h<1||h>12e4)throw new P("INVALID_TIMEOUT","timeoutMs must be between 1 and 120000");let f=!1,g=0,p=null,w=new Set,y=A.session??he(async v=>{let T=await tA("customer-sessions/refresh",{},"POST",{},v);if(!T||typeof T!="object")throw new P("INVALID_RESPONSE","Invalid refresh response");let{requestId:B,scope:_,...V}=T;return V});function R(){g+=1,p=null;for(let v of w)v.abort();w.clear()}let Y=y.subscribeIdentity(R);function pe(){f||y.reset()}async function tA(v,T={},B="POST",_={},V){let k=_.installationDetach===!0;if(k&&(v!=="push/installations/detach"||B!=="POST"))throw new P("INVALID_REQUEST","Installation authority only detaches this installation");if(!V&&!k)throw new P("NOT_IDENTIFIED","Call identify with a server-issued customer token first");let X=g,L=new AbortController;k||w.add(L);let nA=()=>!k&&X!==g?new P("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):new P("TIMEOUT","The request timed out"),dA,we=new Promise((q,N)=>{dA=()=>N(nA()),L.signal.addEventListener("abort",dA,{once:!0})}),ye=setTimeout(()=>L.abort(),_.timeoutMs??h),Pe=async()=>{let q=await a(`${l.href.replace(/\/$/,"")}/api/v1/${v}`,{method:B,headers:{..._.headers,"Content-Type":"application/json",...k?{}:{Authorization:`Bearer ${V}`},[pA]:gA.current,[FA]:$A.version,...u?{"X-Indiana-Project":u.projectId,"X-Indiana-Environment":u.environment}:{}},body:B==="POST"?JSON.stringify(T):void 0,signal:L.signal,credentials:"omit",cache:B==="POST"&&typeof document<"u"&&v==="funnels"&&T!==null&&typeof T=="object"&&"operation"in T&&(T.operation==="start"||T.operation==="shown")?"default":"no-store",redirect:"error",..._.keepalive?{keepalive:!0}:{}});if(L.signal.aborted)throw nA();let N;try{N=q.status===204?de:await q.json()}catch{throw L.signal.aborted?nA():new P(q.ok?"INVALID_RESPONSE":"HTTP_ERROR","The gateway returned an unreadable response",q.status,q.headers.get("X-Request-Id")??void 0)}if(L.signal.aborted)throw nA();if(!k&&X!==g)throw new P("IDENTITY_CHANGED","Customer identity changed while the request was in flight");if(!q.ok){let O=xA.safeParse(N),z=O.success&&(!_A.safeParse(O.data.error.code).success||jA(O.data.error.code,q.status)),HA=z?O.data.error.code:"HTTP_ERROR",BA=MA(HA,q.status,{retryAfter:q.headers.get("Retry-After"),recovery:z?O.data.error.recovery:void 0,reason:z?O.data.error.reason:void 0});throw new P(HA,z?O.data.error.message:"The request failed",q.status,q.headers.get("X-Request-Id")??(O.success?O.data.requestId:void 0),{...BA,...O.success&&O.data.error.retryable===!1?{retryable:!1}:{},...BA.retryAfterSeconds===void 0&&O.success&&O.data.error.retryAfterSeconds!==void 0?{retryAfterSeconds:O.data.error.retryAfterSeconds}:{}})}if(q.headers.get(pA)!==gA.current)throw new P("PROTOCOL_MISMATCH","Response protocol does not match this SDK");if(u&&N!==de){let O=N&&typeof N=="object"&&"scope"in N?N:N&&typeof N=="object"&&"configuration"in N?N.configuration:null;if(!O||typeof O!="object"||!("scope"in O))throw new P("INVALID_RESPONSE","Response is missing its App/environment scope");let z=sA.safeParse(O.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=q.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 N};try{return await Promise.race([Pe(),we])}catch(q){throw!k&&X!==g?new P("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):q instanceof P?q:new P(L.signal.aborted?"TIMEOUT":"NETWORK_ERROR",L.signal.aborted?"The request timed out":"Unable to read the response")}finally{clearTimeout(ye),L.signal.removeEventListener("abort",dA),w.delete(L)}}function ge(v,T={},B="POST",_={}){if(f)return Promise.reject(new P("CLOSED","SDK client was destroyed"));if(_.installationDetach)return tA(v,T,B,_);let V=g;try{let k=y.access(),X=L=>{if(V!==g)throw new P("IDENTITY_CHANGED","Customer identity changed before dispatch");return tA(v,T,B,_,L)};return typeof k=="string"?X(k):k.then(X)}catch(k){return Promise.reject(k)}}let me=Object.assign(ge,{captureIdentity(){let v=g,T=f,B=!!y.peek();return()=>{if(T)throw new P("CLOSED","SDK client was destroyed");if(!B)throw new P("NOT_IDENTIFIED","Call identify with a server-issued customer token first");if(v!==g)throw new P("IDENTITY_CHANGED","Customer identity changed before dispatch")}}});return{session:y,requestWithCredential(v,T,B,_={}){return f?Promise.reject(new P("CLOSED","SDK client was destroyed")):tA(v,T,"POST",_,B)},subjectKey:()=>p,identify(v){if(f)throw new P("CLOSED","SDK client was destroyed");if(u&&typeof v=="object"&&"scope"in v){let T=sA.safeParse(v.scope);if(!T.success||T.data.projectId!==u.projectId||T.data.environment!==u.environment)throw new P("SCOPE_MISMATCH","Customer session belongs to another App/environment")}y.identify(v)},reset:pe,dispose(){f||(f=!0,Y(),R())},request:me}}export{eA as a,dt as b};
|
|
1
|
+
import{b as UA}from"./chunk-J4VTKRH7.js";import{a as P}from"./chunk-HJLGRW4A.js";import{a as _A,d as jA,e as xA,f as MA,h as sA}from"./chunk-XIP32WI7.js";import{a as $A,b as zA}from"./chunk-FVGUBIVT.js";var pA="X-Indiana-Protocol",FA="X-Indiana-SDK-Version";var gA={current:"0.10"};function b(A){return typeof A=="string"?A:String(A)}var De=/[\ud800-\udbff](?![\udc00-\udfff])|(^|[^\ud800-\udbff])[\udc00-\udfff]/g;function Se(A){return A.replace(De,"$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(b);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[b(t.value),b(n.value)]}throw new TypeError("Each query pair must be an iterable [name, value] tuple")}var GA="0123456789ABCDEF",be=/(?:%[0-9A-Fa-f]{2})+/g;function M(A){return`%${GA[A>>4&15]}${GA[15&A]}`}function Ae(A,e,t=!1){return A>=55296&&A<=57343&&(A=65533),A<=127?t&&A===32?"+":e(A)?M(A):String.fromCharCode(A):A<=2047?M(192|A>>6)+M(128|63&A):A<=65535?M(224|A>>12)+M(128|A>>6&63)+M(128|63&A):M(240|A>>18)+M(128|A>>12&63)+M(128|A>>6&63)+M(128|63&A)}function 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 SA(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(be,n=>{try{return decodeURIComponent(n)}catch{return"\uFFFD".repeat(n.length/3)}})}function AA(A){return A<=31||A>126}function Ie(A){switch(A){case 32:case 34:case 60:case 62:case 96:return!0;default:return AA(A)}}function OA(A){switch(A){case 32:case 34:case 35:case 60:case 62:return!0;default:return AA(A)}}function Ce(A){return OA(A)||A===39}function bA(A){switch(A){case 63:case 94:case 96:case 123:case 125:return!0;default:return OA(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 bA(A)}}function KA(A){switch(A){case 33:case 39:case 40:case 41:case 126:return!0;default:return(function(t){switch(t){case 36:case 37:case 38:case 43:case 44:return!0;default:return cA(t)}})(A)}}function ee(A,e){return Ae(A=A||0,e)}function U(A,e,t=!1){let n=0;for(;n<A.length;n++){let u=A.charCodeAt(n);if(u>=128||t&&u===32||e(u))break}if(n===A.length)return A;let r=A.slice(0,n);for(;n<A.length;n++){let u=A.charCodeAt(n),l=u;if(u>=55296&&u<=56319&&n+1<A.length){let a=A.charCodeAt(n+1);a>=56320&&a<=57343&&(l=(u-55296<<10)+a-56320+65536,n++)}r+=Ae(l,e,t)}return r}function qA(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([SA(r.slice(0,u),!0),SA(r.slice(u+1),!0)])}if(t=n+1,n===A.length)break}return e}function IA(A){let e="";for(let t=0;t<A.length;t++){let n=U(A[t][0],KA,!0),r=U(A[t][1],KA,!0);e+=t!==0?`&${n}=${r}`:`${n}=${r}`}return e}var Ee=[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],Te=[7296,7297,7298,7299,7300,7301,7302,7303,7304,42958,42962,42964,42993],ve=["\u0432","\u0434","\u043E","\u0441","\u0442","\u0442","\u044A","\u0463","\uA64B","\uA7CF","\uA7D3","\uA7D5","s"],Oe=[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 qe(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[Re,Ne,ke,YA]=[[[],"0,6,7,8,m,w,10,1b,1d,1f,72,73,7k,8k,dt,2rk","AAAAAAAAAAAAAAAAAAAAAP////8AAAAAAAAAAAAAAAA/AAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAwAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAADAAABwfwAAAAAAAMADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//w8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAhAAAAQAAAAAAAAQCAAABAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgACAAAAAAAAAAAAAAAAD//wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAP///////////////wAAAAAAAAAAAAAAAAAAAAA="],[[],"6,7,8,o,4o,7e,7f,7h,7i,7j,dl","AAAAAEF9+P/+BwAAAMAA//8AAPz/////BlADAAAAAJwAAPz///8AAADA//H/5+X8AAAAAAAAAAAA/P///wcAAAAAAAAAAAAAPv0vAD0BAABA/gAA/5/5/f8BAAAAAAAAgAAAAP//////////////AYD/////BQAAAAAAAAAAAAAAAAAAAAAAAP///////wcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD8g+N8B+AAAAAAAAAAAAAAAAAAAAAAAAP//AwAAYAAAAAAAAAAAAAD/////CwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANgAAAAAAAAAAAAAAAAA//8fAB4AAAD//wMAAAAAAH3/HgwAAAAAAAD//////////w8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="],[[],"6,7,8,o,4o,7e,7f,7h,7i,7j,dl","AAAAAP3////+BwAAAMDu//////////////8vAADAAJwAAP3///8AAADg////////AAAAAAAAAAAA/P///wcAAAAAAAAAAAAA////Ab0H//9H/gAA/9////8BAAAAAAAAgAAAAP//////////////AYD/////BQAAAAAAAAAAAAAAAAAAAAAAAP///////wcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAL/G//8T+AAAAAAAAAAAAAAAAAAAAAAAAP//AwAAfgAAAAAAAAAAAAD+////DwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAANwAAAAAAAAAAAAAAAAA//8fAB4AAAD//wMAAAAAAH3/Hg4AAAAAAAD//////////w8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="],[[],"0,3,4,5,6,7,8,9,a,b,c,d,e,f,g,j,n,o,p,q,r,s,t,w,18,19,1c,4m,4o,4p,4q,4r,6z,72,73,75,76,77,7e,7h,7i,7j,7k,7l,7m,7n,7o,7p,7q,7r,7s,7t,7u,7v,7w,7x,7y,7z,8k,9t,a2,a3,a7,cc,cv,cx,cy,d6,dc,dd,de,dg,dh,di,dk,dl,2rk,2rl","AAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAD//////////////////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD4AwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/v////+/tgAAAAAAAAAAAP8XAAAAAAD4//8AAAEAAAAAAAAAAAAAAMCfnz0AAACAAgAAAP///wcAAAAAAAAAAAAAwP8BAAAAAAAA+A8gAADA++8+AAAAAAAOAAAAAAAAgP8AAAAAAPz///v///8HAAAAAAAAFP4h/gAMAAAAAgAAAAAAABAeIAAADAAAQAYAAAAAAAAQhjkCAAAAIwAGAAAAAAAAEL4hAAAMAAD8AgAAAAAAAJAeIGAADAAAAAQAAAAAAAAAASAAAAAAAAARAAAAAAAA0ME9YAAMAAAAAgAAAAAAAJBAMAAADAAAAAMAAAAAAAAYHiAAAAwAAAACAAAAAAAAAAAEXAAAAAAAAAAAAAAA8geAfwAAAAAAAAAAAAAAAPIfAH8AAAAAAAAAAAADAACgAgAAAAAAAP5/3+D//v///x9AAAAAAAAAAAAAAAAA4P1mAAAAwwEAHgBkIAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAABwAAAAMAAAADAAAAAwAAAAAAAAAsD9A/g8gAAAAAAC4AAAAAAAAAAAAAAAAAABgAAAAAAIAAAAAAAAAAAAAAAAAAIcBBA4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAJAAAAAAAAQH/lH/ifAAAAAAAA//////8//w8AAA8AAAAAANAXBAAAAAD4DwADAAAAPDsAAAAAAABAowMAAAAAAADwzwAAAAAAAAAAAAAAAAAAAAAAAAD3//0hEAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//////////wDIAAAAfAAAAAAAAB/8AAAAAAAAAAAAAAAA/////wEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAwAAAAAAAAAAAAAAAAAAAACAAAAAAAAAAAAAAAAA/////wAAAAAAPAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAID3PwAAAMAAAAAAAAAAAAAAAwBECAAAYBAAAAAAAAAAAAAAAAAAAAAAAAAwAAAA//8DgAAAAADAPwAAgP8DAAAAAAAHAAAAAADIMwAAAAAgAAAAAAAAAAB+ZgAIEAAAAAAAEAAAAAAAAJ3BAgAAAAAwQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAICEAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA//8AAP//AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAMAHAAAAAAAAAAAAAAAAAAAAAG7wAAAAAACHAAAAAAAAAAAAAAAAAAAAAAAAAABgAAAAAAAAAPAAAAAAAAAAAD4AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAYAAAAAAAAAAAA/AAAAAAAAAAAwP8BAAAAAAA8AAAAAAAAAAAAAAAAAAAAAgAAAAAAAP9/AAAAAAAZgAMAAAAAAHgGBAAAAAAAAAAHAAAAgO8fAAAAAAAAAAgAAwAAAAAAwH8AngAAAAAAAAAAAAAAgNNAAgAAAAAAAAAAAAAAAAAAAAAAAID4BwAAAwAAAAAAABgBAAAAwB8fAAAAAAAAAAD4AUAFAAYAAAAAAAAAAAAA/1wAAEAAAAAAAAAAAAAA+IUNAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8sAEAADAAAAAAAAAAAAAA+KcBAAAAAAAAAAAAAAAAKL8AAAAAAAAAAAAAAACgvA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgP8GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFgIAAAAAAAAAAAAAAAAAAAAAADwDAEAAAD+BwAAAAD4eYAAfg4AAAAAAPx/AwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAF0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAf78AAAAAAAAAAAAA/P///G0AAAAAAAAAAAAAAAAAAAB+tL8AAAAAAAAAAACjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABgAAwAAAAAAwAcFAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD//4H/PwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMD/4wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHwAAAAAAAAB/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAAAAAAAAgAcAAAAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAGAPAAAAAAAAAAAAAAD//////z///38AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAD+P/nDwAAADwAAAAAAAAAAAAAAAAAAAAAAAAcAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///////9/+P//////HyAAEAAA+P7/AAAAAAAAAAAAAH////nbBwAAAAAAAAAAAAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAfwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAASMAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAfwAAAAAAAAAAAAAAAADwDwAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAAA////////////////AAAAAAAAAAAAAAAAAAAAAP///////////////////////////////////////wAA"]].map(function([e,t,n]){return[e,t.split(",").map(r=>parseInt(r,36)),Uint8Array.from(atob(n),r=>r.charCodeAt(0))]});function Le(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 W(A,e){let[t,n,r]=A,u=e>>8;for(let h=0;h<t.length;h+=2)if(u>=t[h]&&u<=t[h+1])return!0;let l=n.indexOf(u);if(l<0)return!1;let a=255&e;return!!(r[32*l+(a>>3)]&1<<(7&a))}function He(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(Oe,e[t-1]))continue;if(n===8205)return!1;let r=t-1;for(;r>=0&&W(YA,e[r]);)r--;let u=t+1;for(;u<e.length&&W(YA,e[u]);)u++;if(!(r>=0&&u<e.length&&W(Ne,e[r])&&W(ke,e[u])))return!1}return!0}var Be=/(?![\p{Mark}\p{Decimal_Number}])[\p{Script=Arabic}\p{Script=Hebrew}]/u,_e=/\p{Script=Latin}/u;function je(A){return!Be.test(A)||!_e.test(A)}var F=36,iA=1,CA=26,xe=38,Me=700,Ue=72,$e=128,ze=2147483647;function VA(A){return String.fromCharCode(A+22+75*+(A<26))}function Fe(A,e,t){let n=0;for(A=t?Math.floor(A/Me):A>>1,A+=Math.floor(A/e);A>(F-iA)*CA>>1;n+=F)A=Math.floor(A/(F-iA));return Math.floor(n+(F-iA+1)*A/(A+xe))}function Qe(A){let e=Array.from(A,h=>h.codePointAt(0)),t="",n=0;for(let h=0;h<e.length;h++){let f=e[h];f<128&&(t+=String.fromCharCode(f),n++)}let r=n;r&&(t+="-");let u=$e,l=0,a=Ue;for(;n<e.length;){let h=ze;for(let f=0;f<e.length;f++){let g=e[f];g>=u&&g<h&&(h=g)}l+=(h-u)*(n+1),u=h;for(let f=0;f<e.length;f++){let g=e[f];if(g<u&&l++,g===u){let p=l;for(let w=F;;w+=F){let y=w<=a?iA:w>=a+CA?CA:w-a;if(p<y)break;t+=VA(y+(p-y)%(F-y)),p=Math.floor((p-y)/(F-y))}t+=VA(p),a=Fe(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 XA(A){switch(A){case".":case"%2e":case"%2E":return!0;default:return!1}}function ne(A,e){return(A>=65&&A<=90||A>=97&&A<=122)&&(e===58||e===124)}function re(A){return A.length===2&&ne(A.codePointAt(0),A.codePointAt(1))}function JA(A){return A.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|\/|:|<|>|\?|@|\[|\\|\]|\^|\|/u)!==-1}function C(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,h=Array.from(n,f=>f.codePointAt(0));if(h[a]===58){if(h[a+1]!==58)return null;a+=2,l++,u=l}for(;a<h.length;){if(l===8)return null;if(h[a]===58){if(u!==null)return null;a++,l++,u=l;continue}let f=0,g=0,p=0;for(;p<4&&(f=DA(h[a]))>=0;)g=(g<<4)+f,a++,p++;if(h[a]===46){if(p===0||l>6)return null;a-=p;let w=0;for(;h[a]!==void 0;){let y=0;if(w>0)if(h[a]===46&&w<4)a++;else return null;if(h[a]==null||h[a]<48||h[a]>57)return null;for(;h[a]>=48&&h[a]<=57;){if(y=10*y+DA(h[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(h[a]===58){if(h[++a]===void 0)return null}else if(h[a]!==void 0)return null;r[l]=g,l++}if(u!==null){let f=l-u;for(l=7;l!==0&&f>0;){let g=r[u+f-1];r[u+f-1]=r[l],r[l]=g,l--,f--}}else if(u===null&&l!==8)return null;return r})(A.substring(1,A.length-1)):null;if(e)return(function(n){return JA(n)?null:U(n,AA)})(A);{let t=(function(r){let u=!1,l=!1;for(let h=0;h<r.length;h++){let f=r.charCodeAt(h);if(f<=32||f===37||f===127)return null;if(f>=128){u=!0;break}f>=65&&f<=90&&(l=!0)}if(!u)return r!==""?l?r.toLowerCase():r:null;if((function(f){for(let g of f){let p=g.codePointAt(0);if(/[\p{Cn}\p{Co}\p{Cs}\p{Noncharacter_Code_Point}]/u.test(g)&&!te(Ee,p)||W(Re,p))return!0}return!1})(r))return null;let a=(r=(function(f){let g="";for(let p of f){let w=p.codePointAt(0);if(w!==8204&&w!==8205&&/\p{Default_Ignorable_Code_Point}/u.test(p))continue;let y=Le(p,w);if(y){g+=y;continue}let R=Te.indexOf(w);g+=R<0?p:ve[R]}return g})(r).normalize("NFKC").replace(/[\u3002\uff0e\uff61]/g,".").toLowerCase()).split(".");for(let h=0;h<a.length;h++){let f=a[h];if(f==="")continue;let g=/[^\0-\x7f]/.test(f);if(qe(f)||g&&(/^\p{Mark}/u.test(f)||!He(f)||!je(f)||f.startsWith("xn--")))return null;g&&(a[h]=`xn--${Qe(f)}`)}return(r=a.join("."))!==""?r:null})(A.indexOf("%")===-1?A:SA(A));return t===null||JA(t)?null:(function(r){let u=r.length,l=r.lastIndexOf(".",u-2)+1;if(r.charCodeAt(u-1)===46&&u--,u<=l)return!1;if(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 f=0;f<l-1;f++){let g=mA(u[f]);if(g<0||g>255)return null;a+=g*(1<<8*(3-f))}let h=mA(u[l-1]);return h<0||h>=256**(5-l)?null:(a+=h,a)})(t):t}}function TA(A){return typeof A=="number"?(function(t){let r="";return r+=`${(t>>>24&255).toString(10)}.`,r+=`${(t>>>16&255).toString(10)}.`,r+=`${(t>>>8&255).toString(10)}.`,r+=(t&255).toString(10),r})(A):Array.isArray(A)?`[${(function(t){let n=(function(a){let h=-1,f=-1,g=1,p=0;for(let w=0;w<a.length;++w)a[w]!==0?(p>g&&(h=f,g=p),f=-1,p=0):(f===-1&&(f=w),++p);return p>g?f:h})(t),r="",u=!1;for(let l=0;l<=7;++l)if(!(u&&t[l]===0)){if(u&&(u=!1),n===l){r+=l===0?"::":":",u=!0;continue}r+=t[l].toString(16),l!==7&&(r+=":")}return r})(A)}]`:A}function oe(A){A.path.length>0&&(A.path.length!==1||A.scheme!=="file"||!(function(t){return/^[A-Za-z]:$/u.test(t)})(A.path[0]))&&A.path.pop()}function ie(A){return A.username!==""||A.password!==""}function wA(A){return A.host===null||A.host===""||A.scheme==="file"}var s=0,o="",m="",D=null,i,lA=!1,uA=!1,G=!1,E;function H(A,e,t,n){e||(A=(function(l){let a=0,h=l.length;for(;a<h&&!(l.charCodeAt(a)>32);++a);for(;h>a&&!(l.charCodeAt(h-1)>32);--h);return l.substring(a,h)})(A)),A=(function(l){let a=0;for(;a<l.length;a++){let f=l.charCodeAt(a);if(f===9||f===10||f===13)break}if(a===l.length)return l;let h=l.slice(0,a);for(;a<l.length;a++){let f=l.charCodeAt(a);f!==9&&f!==10&&f!==13&&(h+=l[a])}return h})(A),s=0,o=A,m="",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=Ge;switch(n){case 3:case 4:r=aA;break;case 5:r=NA;break;case 6:r=K;break;case 7:r=Q;break;case 8:r=$}return r(c(A,s))!==1?i:null}function d(A,e){return s+=s===A?j(e):1,s<=o.length}function c(A,e){return e<A.length?A.codePointAt(e):void 0}function j(A){return A!=null&&A>65535?2:1}function le(A){return A==null?"":A<=65535?String.fromCharCode(A):String.fromCodePoint(A)}var Ge=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 m=o.slice(s,t).toLowerCase(),s=t,Ke(t<o.length?A:void 0)}else return E?1:(--s,d(e,A)?ue(c(o,s)):0)},Ke=A=>{let e=s;if(A===58){if(E){if(C(i.scheme)!==C(m))return 0;if((ie(i)||i.port!==null)&&m==="file")return 0;if(i.scheme==="file"&&i.host==="")return 0}return i.scheme=m,E?(i.port===se(i.scheme)&&(i.port=null),0):(m="",i.scheme==="file"?d(e,A)?kA(c(o,s)):0:C(i.scheme)&&D!==null&&D.scheme===i.scheme?d(e,A)?Ye(c(o,s)):0:C(i.scheme)?d(e,A)?Xe(c(o,s)):0:c(o,s+1)===47?(s++,d(e,A)?Ve(c(o,s)):0):(i.path=[""],i.opaquePath=!0,d(e,A)?ae(c(o,s)):0))}else return E?1:(m="",s=-1,d(e,A)?ue(c(o,s)):0)},ue=A=>{let e=s;return D===null||D.opaquePath&&A!==35?1:D.opaquePath&&A===35?(i.scheme=D.scheme,i.path=D.path.slice(),i.opaquePath=D.opaquePath,i.query=D.query,i.fragment="",d(e,A)?$(c(o,s)):0):D.scheme==="file"?(s--,d(e,A)?kA(c(o,s)):0):(s--,d(e,A)?RA(c(o,s)):0)},Ye=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)?RA(c(o,s)):0)},Ve=A=>{let e=s;return A===47?d(e,A)?J(c(o,s)):0:(s--,d(e,A)?x(c(o,s)):0)},RA=A=>{let e=s;return i.scheme=D.scheme,A===47||C(i.scheme)&&A===92?d(e,A)?WA(c(o,s)):0:(i.username=D.username,i.password=D.password,i.host=D.host,i.port=D.port,i.path=D.path.slice(),i.query=D.query,A===63?(i.query="",d(e,A)?Q(c(o,s)):0):A===35?(i.fragment="",d(e,A)?$(c(o,s)):0):A!=null?(i.query=null,i.path.pop(),s--,d(e,A)?x(c(o,s)):0):d(e,A)?RA(c(o,s)):0)},WA=A=>{let e=s;return C(i.scheme)&&(A===47||A===92)?d(e,A)?hA(c(o,s)):0:A===47?d(e,A)?J(c(o,s)):0:(i.username=D.username,i.password=D.password,i.host=D.host,i.port=D.port,s--,d(e,A)?x(c(o,s)):0)},Xe=A=>{let e=s;return A===47&&c(o,s+1)===47?s++:s--,d(e,A)?hA(c(o,s)):0},hA=A=>{let e=s;return A!==47&&A!==92?(s--,d(e,A)?J(c(o,s)):0):d(e,A)?hA(c(o,s)):0},J=A=>{let e=s;if(A!=null&&A!==64&&A!==35&&A!==47&&A!==63&&(A!==92||!C(i.scheme))){let t=s+j(A);for(;t<o.length;){let n=c(o,t);if(n==null||n===64||n===35||n===47||n===63||n===92&&C(i.scheme))break;t+=j(n)}return m+=o.slice(s,t),s=t-1,d(e,A)?J(c(o,s)):0}if(A===64){lA&&(m=`%40${m}`),lA=!0;for(let t=0;t<m.length;t++){let n=m.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 m="",d(e,A)?J(c(o,s)):0}else return A==null||A===35||A===47||A===63||A===92&&C(i.scheme)?lA&&m===""?1:(s-=m.length+1,m="",d(e,A)?aA(c(o,s)):0):(m+=le(A),d(e,A)?J(c(o,s)):0)},aA=A=>{let e=s;if(E&&i.scheme==="file")return s--,d(e,A)?LA(c(o,s)):0;if(A!=null&&A!==58&&A!==35&&A!==47&&A!==63&&(A!==92||!C(i.scheme))){let t=s+j(A);for(A===91?G=!0:A===93&&(G=!1);t<o.length;){let n=c(o,t);if(n==null||!G&&n===58||n===35||n===47||n===63||n===92&&C(i.scheme))break;n===91?G=!0:n===93&&(G=!1),t+=j(n)}return m+=o.slice(s,t),s=t-1,d(e,A)?aA(c(o,s)):0}else if(A===58&&!G){if(m===""||E===4)return 1;let t=EA(m,!C(i.scheme));return t===null?1:(i.host=TA(t),m="",d(e,A)?NA(c(o,s)):0)}else if(A==null||A===35||A===47||A===63||A===92&&C(i.scheme)){if(s--,C(i.scheme)&&m==="")return 1;if(E&&m===""&&(ie(i)||i.port!==null))return 1;let t=EA(m,!C(i.scheme));return t===null?1:(i.host=TA(t),m="",E?0:d(e,A)?K(c(o,s)):0)}else return m+=le(A),d(e,A)?aA(c(o,s)):0},NA=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 m+=o.slice(s,t),s=t-1,d(e,A)?NA(c(o,s)):0}else if(E||A==null||A===35||A===47||A===63||A===92&&C(i.scheme)){if(m!==""){let t=parseInt(m,10);if(t>65535)return 1;if(i.port=t===se(i.scheme)?null:t,m="",E)return 0}return E?1:(s--,d(e,A)?K(c(o,s)):0)}else return 1};function ce(A,e){let t=A.length-e;if(t<2)return!1;if(ne(c(A,e),c(A,e+1))){if(t===2)return!0;{let n=c(A,e+2);return n===47||n===92||n===63||n===35}}else return!1}var kA=A=>{let e=s;return i.scheme="file",i.host="",A===47||A===92?d(e,A)?Je(c(o,s)):0:D?.scheme==="file"?(i.host=D.host,i.path=D.path.slice(),i.opaquePath=D.opaquePath,i.query=D.query,A===63?(i.query="",d(e,A)?Q(c(o,s)):0):A===35?(i.fragment="",d(e,A)?$(c(o,s)):0):A!=null?(i.query=null,ce(o,s)?i.path=[]:oe(i),s--,d(e,A)?x(c(o,s)):0):d(e,A)?kA(c(o,s)):0):(s--,d(e,A)?x(c(o,s)):0)},Je=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)?x(c(o,s)):0)},LA=A=>{let e=s;if(A!=null&&A!==47&&A!==92&&A!==63&&A!==35){let t=s+j(A);for(;t<o.length;){let n=c(o,t);if(n==null||n===47||n===92||n===63||n===35)break;t+=j(n)}return m+=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(m))return d(e,A)?x(c(o,s)):0;if(m==="")return i.host="",E?0:d(e,A)?K(c(o,s)):0;{let t=EA(m,!C(i.scheme));return t===null?1:(t==="localhost"&&(t=""),i.host=TA(t),m="",E?0:d(e,A)?K(c(o,s)):0)}}return 1},K=A=>{let e=s;return C(i.scheme)?(A!==92&&A!==47&&s--,d(e,A)?x(c(o,s)):0):!E&&A===63?(i.query="",d(e,A)?Q(c(o,s)):0):!E&&A===35?(i.fragment="",d(e,A)?$(c(o,s)):0):A!=null?(A!==47&&s--,d(e,A)?x(c(o,s)):0):(E&&i.host===null&&i.path.push(""),d(e,A)?K(c(o,s)):0)},x=A=>{let e=s;if(A!=null&&A!==47&&(!C(i.scheme)||A!==92)&&(E||A!==63&&A!==35)){let t=s+j(A);for(;t<o.length;){let n=c(o,t);if(n==null||n===47||C(i.scheme)&&n===92||!E&&(n===63||n===35))break;t+=j(n)}m+=U(o.slice(s,t),bA),s=t,A=c(o,t)}if(A==null||A===47||C(i.scheme)&&A===92||!E&&(A===63||A===35)){let t=C(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}})(m)?(oe(i),A!==47&&!t&&i.path.push("")):XA(m)&&A!==47&&!t?i.path.push(""):XA(m)||(i.scheme==="file"&&i.path.length===0&&re(m)&&(m=`${m[0]}:`),i.path.push(m)),m="",A===63?(i.query="",d(e,A)?Q(c(o,s)):0):A===35?(i.fragment="",d(e,A)?$(c(o,s)):0):d(e,A)?x(c(o,s)):0}else return m+=ee(A,bA),d(e,A)?x(c(o,s)):0},ae=A=>{let e=s;if(A===63)return i.query="",d(e,A)?Q(c(o,s)):0;if(A===35)return i.fragment="",d(e,A)?$(c(o,s)):0;if(A!=null){let t=s+j(A);for(;t<o.length;){let r=c(o,t);if(r===63||r===35)break;t+=j(r)}let n=o.slice(s,t);if(t<o.length&&n.charCodeAt(n.length-1)===32?i.path[0]+=U(n.slice(0,-1),AA)+"%20":i.path[0]+=U(n,AA),s=t,(A=c(o,t))===63)return i.query="",d(e,A)?Q(c(o,s)):0;if(A===35)return i.fragment="",d(e,A)?$(c(o,s)):0}return d(e,A)?ae(c(o,s)):0},Q=A=>{let e=s,t=s;if(A!=null){if(E)t=o.length;else{let r=o.indexOf("#",s);t=r===-1?o.length:r}let n=C(i.scheme)?Ce:OA;i.query+=U(o.slice(s,t),n)}return s=t,c(o,t)===35&&!E?(i.fragment="",d(e,A)?$(c(o,s)):0):d(e,A)?Q(c(o,s)):0},$=A=>{let e=s;return A!=null&&(i.fragment+=U(o.slice(s),Ie),s=o.length),d(e,A)?$(c(o,s)):0};function vA(A){if(A.opaquePath)return A.path[0];{let e="";for(let t of A.path)e+=`/${t}`;return e}}function fe(A){switch(A.scheme){case"blob":{let e=H(vA(A),null,null,0);return e===null||e.scheme!=="http"&&e.scheme!=="https"?"null":fe(e)}case"ftp":case"http":case"https":case"ws":case"wss":return(function(t){let n=`${t.scheme}://`;return n+=t.host,t.port!==null&&(n+=`:${t.port}`),n})(A);default:return"null"}}var S=Symbol("URLImpl"),eA=class A{constructor(e,t){if(e===void 0&&t===void 0)throw new TypeError('The "url" argument must be specified.');e=b(e),t!=null&&(t=b(t));let n=null;if(t!=null&&(n=H(t,null,null,0),n==null))throw new TypeError(`Invalid base URL: ${t}`);let r=H(e,null,n,0);if(r==null)throw new TypeError(`Invalid URL: ${e}`);this[S]={url:r,query:null}}static createObjectURL(e){throw new TypeError("URL.createObjetURL is unsupported")}static revokeObjectURL(e){}static parse(e,t){e=b(e),t!==void 0&&(t=b(t));try{return new A(e,t)}catch{return null}}static canParse(e,t){e=b(e),t!==void 0&&(t=b(t));let n=null;return t!=null&&(n=H(t,null,null,0),n==null)?!1:H(e,null,n,0)!=null}get href(){return(function(t){let n=`${t.scheme}:`;return t.host!==null&&(n+="//",(t.username!==""||t.password!=="")&&(n+=t.username,t.password!==""&&(n+=`:${t.password}`),n+="@"),n+=t.host,t.port!==null&&(n+=`:${t.port}`)),t.host===null&&!t.opaquePath&&t.path.length>1&&t.path[0]===""&&(n+="/."),n+=vA(t),t.query!==null&&(n+=`?${t.query}`),t.fragment!==null&&(n+=`#${t.fragment}`),n})(this[S].url)}set href(e){let t=H(e=b(e),null,null,0);if(t==null)throw new TypeError(`Invalid URL: ${e}`);this[S].url=t,this[S].query&&yA(this[S].query,t.query)}get origin(){return fe(this[S].url)}get protocol(){return`${this[S].url.scheme}:`}set protocol(e){H(`${e=b(e)}:`,this[S].url,null,2)}get username(){return this[S].url.username}set username(e){e=b(e),wA(this[S].url)||(function(n,r){n.username=U(r,cA)})(this[S].url,e)}get password(){return this[S].url.password}set password(e){e=b(e),wA(this[S].url)||(function(n,r){n.password=U(r,cA)})(this[S].url,e)}get host(){let{url:e}=this[S];return e.host==null?"":e.port==null?e.host:`${e.host}:${e.port}`}set host(e){e=b(e),this[S].url.opaquePath||H(e,this[S].url,null,3)}get hostname(){let{url:e}=this[S];return e.host!=null?e.host:""}set hostname(e){e=b(e),this[S].url.opaquePath||H(e,this[S].url,null,4)}get port(){let{url:e}=this[S];return e.port!=null?`${e.port}`:""}set port(e){e=b(e);let{url:t}=this[S];wA(t)||(e?H(e,t,null,5):t.port=null)}get pathname(){return vA(this[S].url)}set pathname(e){e=b(e);let{url:t}=this[S];t.opaquePath||(t.path=[],H(e,t,null,6))}get search(){let{url:e}=this[S];return e.query?`?${e.query}`:""}set search(e){e=b(e);let{url:t,query:n}=this[S];if(!e)t.query=null,n&&yA(n,null);else{let r=e[0]==="?"?e.substring(1):e;t.query="",H(r,t,null,7),n&&yA(n,t.query)}}get searchParams(){let e=this[S],t=e.query;return t==null&&(t=e.query=(function(r,u){let l=new fA;return l[I].url=r,l[I].serialized=u==null,u&&(l[I].list=qA(u)),l})(this,e.url.query)),t}get hash(){let{url:e}=this[S];return e.fragment?`#${e.fragment}`:""}set hash(e){e=b(e);let{url:t}=this[S];if(!e)t.fragment=null;else{let n=e[0]==="#"?e.substring(1):e;t.fragment="",H(n,t,null,8)}}toJSON(){return this.href}toString(){return this.href}};Object.defineProperty(eA.prototype,Symbol.toStringTag,{value:"URL",configurable:!0});var I=Symbol("URLSearchParamsImpl"),We=Symbol.dispose||Symbol.for("dispose");function yA(A,e){e?A[I].list=qA(e):A[I].list.length=0,A[I].serialized=e==null}function oA(A){if(A.url){let e=IA(A.list);(function(n,r){n[S].url.query=r})(A.url,e||null),A.serialized=!0}}var Ze=typeof Iterator<"u"?Iterator:Object,Z=class extends Ze{constructor(e,t){super(),this[I]={ptr:e,map:t,index:0}}next(){let e=this[I];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}[We](){}},fA=class{constructor(e){let t=this[I]={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=Se(l),h=b(e[l]),f=t.list.find(g=>g[0]===a);f?f[1]=h:t.list.push([a,h])}}else if(e!==void 0){let r=b(e);r=r[0]==="?"?r.substring(1):r,t.list=qA(r)}}get size(){return this[I].list.length}append(e,t){e=b(e),t=b(t),this[I].list.push([e,t]);let n=this[I];n.url&&n.serialized?(function(u,l){let a=u[S].url;a.query=a.query?`${a.query}&${l}`:l})(n.url,IA([[e,t]])):oA(n)}delete(e,t){e=b(e),t=t!=null?b(t):void 0;let{list:n}=this[I],r=0;for(;r<n.length;)n[r][0]===e&&(t==null||n[r][1]===t)?n.splice(r,1):r++;oA(this[I])}get(e){e=b(e);let{list:t}=this[I];for(let n=0;n<t.length;n++)if(t[n][0]===e)return t[n][1];return null}getAll(e){e=b(e);let t=[],{list:n}=this[I];for(let r=0;r<n.length;r++)n[r][0]===e&&t.push(n[r][1]);return t}has(e,t){e=b(e),t=t!=null?b(t):void 0;let{list:n}=this[I];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=b(e),t=b(t);let{list:n}=this[I],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[I])}sort(){this[I].list.sort((e,t)=>e[0]<t[0]?-1:e[0]>t[0]?1:0),oA(this[I])}forEach(e,t){if(typeof e!="function")throw new TypeError('The "callback" argument must be of type function');let{list:n}=this[I];for(let r=0;r<n.length;r++)e.call(t,n[r][1],n[r][0],this)}entries(){return new Z(this[I],e=>e)}keys(){return new Z(this[I],e=>e[0])}values(){return new Z(this[I],e=>e[1])}toString(){return IA(this[I].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 h=()=>a();function f(p,w=!1){let y=UA.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 g(){if(r)return r;let p=typeof e=="object"?e:void 0,w=n;if(!p||Date.parse(p.refreshExpiresAt)<=Date.now())throw p&&h(),new P("UNAUTHENTICATED","Customer authentication is required",401);let y=(async()=>{try{let R=await A(p.refreshToken);if(w!==n)throw new P("IDENTITY_CHANGED","Customer identity changed during refresh");let Y=f(R,!0);if(Y.customerId!==p.customerId||Y.sessionId!==p.sessionId)throw new P("SCOPE_MISMATCH","Refresh changed the customer session");return e=Y,{...Y}}catch(R){throw w!==n?new P("IDENTITY_CHANGED","Customer identity changed during refresh"):(R instanceof P&&R.status===401&&h(),R)}})();r=y;try{return await y}finally{r===y&&(r=void 0)}}return{identify(p){let w=typeof p=="string"?p:f(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:h,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 g().then(()=>{let R=t();if(y!==n||!R)throw new P("IDENTITY_CHANGED","Customer identity changed during refresh");return R})}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:g}}var de=Symbol("IndianaNoContent");function dt(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??zA);if(l.username||l.password||l.search||l.hash)throw new P("INVALID_URL","baseUrl must not contain credentials, query, or fragment");if(l.protocol!=="https:"&&!(l.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(l.hostname)))throw new P("INVALID_URL","Use HTTPS, or HTTP on localhost during development");let a=A.fetch??globalThis.fetch.bind(globalThis),h=A.timeoutMs??1e4;if(!Number.isFinite(h)||h<1||h>12e4)throw new P("INVALID_TIMEOUT","timeoutMs must be between 1 and 120000");let f=!1,g=0,p=null,w=new Set,y=A.session??he(async v=>{let T=await tA("customer-sessions/refresh",{},"POST",{},v);if(!T||typeof T!="object")throw new P("INVALID_RESPONSE","Invalid refresh response");let{requestId:B,scope:_,...V}=T;return V});function R(){g+=1,p=null;for(let v of w)v.abort();w.clear()}let Y=y.subscribeIdentity(R);function pe(){f||y.reset()}async function tA(v,T={},B="POST",_={},V){let k=_.installationDetach===!0;if(k&&(v!=="push/installations/detach"||B!=="POST"))throw new P("INVALID_REQUEST","Installation authority only detaches this installation");if(!V&&!k)throw new P("NOT_IDENTIFIED","Call identify with a server-issued customer token first");let X=g,L=new AbortController;k||w.add(L);let nA=()=>!k&&X!==g?new P("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):new P("TIMEOUT","The request timed out"),dA,we=new Promise((q,N)=>{dA=()=>N(nA()),L.signal.addEventListener("abort",dA,{once:!0})}),ye=setTimeout(()=>L.abort(),_.timeoutMs??h),Pe=async()=>{let q=await a(`${l.href.replace(/\/$/,"")}/api/v1/${v}`,{method:B,headers:{..._.headers,"Content-Type":"application/json",...k?{}:{Authorization:`Bearer ${V}`},[pA]:gA.current,[FA]:$A.version,...u?{"X-Indiana-Project":u.projectId,"X-Indiana-Environment":u.environment}:{}},body:B==="POST"?JSON.stringify(T):void 0,signal:L.signal,credentials:"omit",cache:B==="POST"&&typeof document<"u"&&v==="funnels"&&T!==null&&typeof T=="object"&&"operation"in T&&(T.operation==="start"||T.operation==="shown")?"default":"no-store",redirect:"error",..._.keepalive?{keepalive:!0}:{}});if(L.signal.aborted)throw nA();let N;try{N=q.status===204?de:await q.json()}catch{throw L.signal.aborted?nA():new P(q.ok?"INVALID_RESPONSE":"HTTP_ERROR","The gateway returned an unreadable response",q.status,q.headers.get("X-Request-Id")??void 0)}if(L.signal.aborted)throw nA();if(!k&&X!==g)throw new P("IDENTITY_CHANGED","Customer identity changed while the request was in flight");if(!q.ok){let O=xA.safeParse(N),z=O.success&&(!_A.safeParse(O.data.error.code).success||jA(O.data.error.code,q.status)),HA=z?O.data.error.code:"HTTP_ERROR",BA=MA(HA,q.status,{retryAfter:q.headers.get("Retry-After"),recovery:z?O.data.error.recovery:void 0,reason:z?O.data.error.reason:void 0});throw new P(HA,z?O.data.error.message:"The request failed",q.status,q.headers.get("X-Request-Id")??(O.success?O.data.requestId:void 0),{...BA,...O.success&&O.data.error.retryable===!1?{retryable:!1}:{},...BA.retryAfterSeconds===void 0&&O.success&&O.data.error.retryAfterSeconds!==void 0?{retryAfterSeconds:O.data.error.retryAfterSeconds}:{}})}if(q.headers.get(pA)!==gA.current)throw new P("PROTOCOL_MISMATCH","Response protocol does not match this SDK");if(u&&N!==de){let O=N&&typeof N=="object"&&"scope"in N?N:N&&typeof N=="object"&&"configuration"in N?N.configuration:null;if(!O||typeof O!="object"||!("scope"in O))throw new P("INVALID_RESPONSE","Response is missing its App/environment scope");let z=sA.safeParse(O.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=q.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 N};try{return await Promise.race([Pe(),we])}catch(q){throw!k&&X!==g?new P("IDENTITY_CHANGED","Customer identity changed while the request was in flight"):q instanceof P?q:new P(L.signal.aborted?"TIMEOUT":"NETWORK_ERROR",L.signal.aborted?"The request timed out":"Unable to read the response")}finally{clearTimeout(ye),L.signal.removeEventListener("abort",dA),w.delete(L)}}function ge(v,T={},B="POST",_={}){if(f)return Promise.reject(new P("CLOSED","SDK client was destroyed"));if(_.installationDetach)return tA(v,T,B,_);let V=g;try{let k=y.access(),X=L=>{if(V!==g)throw new P("IDENTITY_CHANGED","Customer identity changed before dispatch");return tA(v,T,B,_,L)};return typeof k=="string"?X(k):k.then(X)}catch(k){return Promise.reject(k)}}let me=Object.assign(ge,{captureIdentity(){let v=g,T=f,B=!!y.peek();return()=>{if(T)throw new P("CLOSED","SDK client was destroyed");if(!B)throw new P("NOT_IDENTIFIED","Call identify with a server-issued customer token first");if(v!==g)throw new P("IDENTITY_CHANGED","Customer identity changed before dispatch")}}});return{session:y,requestWithCredential(v,T,B,_={}){return f?Promise.reject(new P("CLOSED","SDK client was destroyed")):tA(v,T,"POST",_,B)},subjectKey:()=>p,identify(v){if(f)throw new P("CLOSED","SDK client was destroyed");if(u&&typeof v=="object"&&"scope"in v){let T=sA.safeParse(v.scope);if(!T.success||T.data.projectId!==u.projectId||T.data.environment!==u.environment)throw new P("SCOPE_MISMATCH","Customer session belongs to another App/environment")}y.identify(v)},reset:pe,dispose(){f||(f=!0,Y(),R())},request:me}}export{eA as a,dt as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as we}from"./chunk-2TPPGW7V.js";import{a as Q}from"./chunk-TMZGZAWM.js";import{A as Pe,E as B,G as Re,d as me,f as N,k as fe,v as ge,w as ye,y as Se}from"./chunk-7Z7JT4HE.js";import{$ as k}from"./chunk-ITVSLSRM.js";import{a as U,i as J}from"./chunk-B3KFE57L.js";import{b as Ie}from"./chunk-XZEGVBAI.js";import{a as l}from"./chunk-HJLGRW4A.js";import{h as z}from"./chunk-XIP32WI7.js";import{b as he}from"./chunk-FVGUBIVT.js";import{b as r}from"./chunk-ZY4XAKNQ.js";import{a as ae}from"./chunk-DSPLGTQI.js";var g=k.options,ke=r.discriminatedUnion("operation",[g[1].omit({customerToken:!0}),g[2].omit({customerToken:!0}),g[3].omit({customerToken:!0}),g[4].omit({customerToken:!0}),g[5].omit({customerToken:!0}),g[6].omit({customerToken:!0}),g[7].omit({customerToken:!0}),g[8].omit({customerToken:!0}),fe.omit({customerToken:!0})]),Ne=r.strictObject({receiptId:r.uuid(),operationId:r.uuid()}),Ge=r.discriminatedUnion("operation",[r.strictObject({operation:r.literal("recover_start"),intent:r.enum(["lookup","resume"]),start:r.strictObject({requestId:g[0].shape.requestId,funnelId:g[0].shape.funnelId,locale:g[0].shape.locale,parameters:g[0].shape.parameters})}),r.strictObject({operation:r.literal("recover_run"),runId:r.uuid(),funnelId:r.uuid()}),r.strictObject({operation:r.literal("recover_purchase"),runId:r.uuid(),funnelId:r.uuid(),purchase:Ne}),r.strictObject({operation:r.literal("settle_command"),runId:r.uuid(),funnelId:r.uuid(),requestId:r.uuid(),command:r.discriminatedUnion("operation",[g[3].omit({customerToken:!0}),g[4].omit({customerToken:!0}),g[5].omit({customerToken:!0}),g[6].omit({customerToken:!0}),g[7].omit({customerToken:!0})]).optional()}).refine(o=>!o.command||o.requestId===o.command.requestId),r.strictObject({operation:r.literal("run_command"),runId:r.uuid(),funnelId:r.uuid(),command:ke})]),ie=r.strictObject({runId:r.uuid(),funnelId:r.uuid(),versionId:r.uuid(),startRequestId:r.uuid(),runExpiresAt:r.iso.datetime({offset:!0}),status:N.shape.run.shape.status}),K={scope:z,customerId:r.uuid()},Ce=r.discriminatedUnion("outcome",[r.strictObject({...K,outcome:r.literal("unknown"),target:r.null(),view:r.null(),access:r.null()}),r.strictObject({...K,outcome:r.literal("resolved"),target:ie,view:N.shape.run.nullable(),access:r.discriminatedUnion("type",[r.strictObject({type:r.literal("customer")}),r.strictObject({type:r.literal("operation_only"),cause:r.enum(["run_terminal","run_expired","run_revoked","issuer_unavailable"])})])})]).superRefine((o,d)=>{o.outcome==="resolved"&&(o.access.type==="customer"!=(o.view!==null)||o.view&&(o.view.id!==o.target.runId||o.view.source.id!==o.target.funnelId||o.view.source.versionId!==o.target.versionId||o.view.status!==o.target.status||o.view.runExpiresAt!==o.target.runExpiresAt||o.view.credentialExpiresAt!==null))&&d.addIssue({code:"custom",message:"Recovery view and original Run binding differ"})}),ve=r.strictObject({...K,target:ie,view:N.shape.run.nullable(),settlement:r.strictObject({requestId:r.uuid(),state:r.enum(["pending","unknown","settled"]),acceptance:r.enum(["accepted","not_accepted","unknown"]),receiptPhase:r.enum(["accepted","processing","done"]).nullable(),basis:r.enum(["receipt","run_terminal","position_advanced","none"]),receiptId:r.uuid().nullable(),operationId:r.uuid().nullable()}),purchase:N.shape.purchase.unwrap().nullable()}).superRefine((o,d)=>{let p=o.settlement;(p.acceptance==="accepted"!=(p.receiptPhase!==null)||p.acceptance==="accepted"&&p.basis!=="receipt"||p.acceptance==="unknown"&&(p.state!=="unknown"||p.basis!=="none")||p.acceptance!=="accepted"&&(p.operationId!==null||p.receiptId!==null)||p.acceptance==="not_accepted"&&(p.state!=="settled"||!["run_terminal","position_advanced"].includes(p.basis))||o.purchase&&(o.purchase.receiptId!==p.receiptId||o.purchase.operation&&o.purchase.operation.operationId!==p.operationId||o.purchase.quote&&o.purchase.quote.operationId!==p.operationId)||o.view&&(o.view.id!==o.target.runId||o.view.source.id!==o.target.funnelId||o.view.source.versionId!==o.target.versionId||o.view.status!==o.target.status||o.view.runExpiresAt!==o.target.runExpiresAt||o.view.credentialExpiresAt!==null))&&d.addIssue({code:"custom",message:"Original command settlement binding differs"})}),Ee=r.strictObject({...K,target:ie,purchase:N.shape.purchase.unwrap()}).superRefine((o,d)=>{(!o.purchase.operation||typeof o.purchase.canReselect!="boolean"||o.purchase.quote&&o.purchase.quote.operationId!==o.purchase.operation.operationId)&&d.addIssue({code:"custom",message:"Original purchase proof is incomplete"})});var Te=k.options[0].refine(o=>!o.customer&&!o.customerData),xe=r.strictObject({receiptId:r.uuid(),operationId:r.uuid(),terminal:r.enum(["complete","native"]).nullable()}),be=r.strictObject({schemaVersion:r.literal(1),baseUrl:r.url(),scope:z,customerId:r.uuid(),sessionId:r.uuid(),start:Te,allowed:r.array(r.enum(["merchant","record_only","indiana","native"])),run:r.strictObject({id:r.uuid(),versionId:r.uuid(),status:me.shape.status,revision:r.number().int().nonnegative(),runExpiresAt:r.iso.datetime({offset:!0}).optional()}).optional(),purchases:r.array(xe).max(100),operationCommand:r.strictObject({operationId:r.uuid(),intent:r.literal("confirm")}).optional(),journal:r.strictObject({revision:r.number().int().nonnegative(),entry:ge.nullable()})});function Fe(o){return Se({...o,namespace:"purchases",identity:[o.scope.projectId,o.scope.environment,o.customerId]})}function Oe(o){let d=new URL(o.baseUrl??he).href,p=()=>new l("PURCHASE_STORAGE_INVALID","Purchase recovery storage is unavailable or invalid; native fallback is not authorized");async function v(){o.assertCurrent();try{let y=await o.storage.read();if(o.assertCurrent(),!Number.isSafeInteger(y.revision)||y.revision<0)throw p();let a=y.entry===null?null:be.parse(y.entry);if(a&&(a.baseUrl!==d||a.customerId!==o.customerId||a.scope.projectId!==o.scope.projectId||a.scope.environment!==o.scope.environment))throw new l("SCOPE_MISMATCH","Purchase recovery belongs to another Customer or environment");if(a?.journal.entry&&(a.journal.entry.scope.projectId!==a.scope.projectId||a.journal.entry.scope.environment!==a.scope.environment||a.journal.entry.funnelId!==a.start.funnelId||a.journal.entry.runId!==a.run?.id||a.journal.entry.versionId!==a.run?.versionId)||a?.operationCommand&&!a.purchases.some(P=>P.operationId===a.operationCommand?.operationId))throw p();return{revision:y.revision,entry:a}}catch(y){throw y instanceof l?y:p()}}async function Y(y){for(let a=0;a<8;a++){let P=await v(),b=y(structuredClone(P.entry));if(JSON.stringify(b)===JSON.stringify(P.entry))return b;b&&be.parse(b),o.assertCurrent();let E;try{E=await o.storage.write(P.revision,b)}catch{throw p()}if(o.assertCurrent(),E!==null){if(!Number.isSafeInteger(E)||E<=P.revision)throw p();return b}}throw new l("PURCHASE_STORAGE_CONFLICT","Another consumer changed this purchase; recover the original attempt")}return{read:v,update:Y,baseUrl:d}}function Ue(o){let d=o.purchases.find(p=>p.type==="checkout");if(!o.actions.includes("continue_checkout")||d?.type!=="checkout")throw new l("PURCHASE_PENDING","No single resumable Checkout is confirmed");return d.checkoutUrl}function fn(o){let d={...o,scope:{...o.scope},executionPolicy:structuredClone(o.executionPolicy)},p=d.session.snapshot();if(!p)throw new l("CUSTOMER_SESSION_REQUIRED","Purchase recovery requires a verified Customer session");let{customerId:v,sessionId:Y}=p,y=!1,a=null,P,b=null,E=!1,q,D,H,O={mode:"idle",status:"idle",actions:["start"],purchases:[]},I=new Map,j=new Map,se=new AbortController,L=new Set,W=Ie(d),ue=we(W.request);function M(e){return{code:e instanceof l?e.code:"PURCHASE_RECOVERY_BLOCKED",message:e instanceof Error?e.message:"The original purchase requires server confirmation",...e instanceof l&&e.status!==void 0?{status:e.status}:{}}}function R(){if(y||d.session.snapshot()?.customerId!==v)throw new l("IDENTITY_CHANGED","The original purchase Customer changed")}let w=Oe({...d,customerId:v,assertCurrent:R,storage:d.storage??Fe({baseUrl:d.baseUrl,scope:d.scope,customerId:v})}),qe=d.session.subscribeIdentity(ce);function ce(){y||(y=!0,clearTimeout(H),se.abort(new l("IDENTITY_CHANGED","Purchase consumer was destroyed")),qe(),a?.reset(),a=null,b=null,W.dispose(),L.clear(),I.clear(),j.clear())}function C(e){R();let n=JSON.stringify(e)!==JSON.stringify(O);O=e,clearTimeout(H),(e.mode==="operation"||e.mode==="run"&&!e.actions.includes("close"))&&["waiting_result","fulfillment","recording"].includes(e.status)&&(H=setTimeout(()=>{T().catch(()=>{})},5e3)),n&&ae(d.onRecovery,structuredClone(e));for(let t of n?L:[]){if(y)break;ae(t,structuredClone(e))}return structuredClone(e)}function h(e){if(R(),!e||e.start.requestId!==P)throw new l("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(u=>u.operationId===t.operationId)&&n.push({receiptId:t.receiptId,operationId:t.operationId,terminal:null}),n}function V(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 $(e){if(e.journal.entry?.command||e.journal.entry?.closeCommand||e.operationCommand)return!1;let n=F(e).filter(t=>t.terminal===null);return n.length>0&&n.every(t=>{let u=I.get(t.operationId);return u?.executor==="merchant"&&U({quote:u.quote??null,operation:u,requestId:null,pending:!1,destroyed:!1,canReselect:!1}).type==="checkout"})}function _(e,n){let t=e.journal.entry?.command??e.journal.entry?.closeCommand,u=F(e).map(S=>{let oe=I.get(S.operationId);return S.terminal&&!oe?{type:S.terminal,operationId:S.operationId}:U({quote:oe?.quote??null,operation:oe??null,requestId:t?.requestId??null,pending:!1,destroyed:!1,canReselect:j.get(S.operationId)===!0})}),c=u.filter(S=>!["complete","native"].includes(S.type)),i=c[0],s=c.length===1&&i?.operationId?I.get(i.operationId):void 0;if(s&&(i?.type==="checkout"||i?.type==="cancel"))try{B({allowed:e.allowed.filter(S=>d.executionPolicy.allowed.includes(S))},s.quote)}catch(S){return{mode:n,status:"blocked",actions:["refresh",...n==="run"&&e.run&&["running","waiting"].includes(e.run.status)?["close"]:[]],purchases:u,error:M(S)}}let m;if(n==="operation"&&!t&&i?.type==="cancel"&&s?.quote&&!s.problem&&!s.confirmedAt)try{B({allowed:e.allowed.filter(S=>d.executionPolicy.allowed.includes(S))},s.quote),Date.parse(s.quote.expiresAt)>Date.now()&&(m={operationId:s.operationId,quote:s.quote})}catch{}let f=u.length>0&&c.length===0,x=V(e)||n==="operation"&&f&&!t&&!e.operationCommand?"complete":i?.type==="checkout"?"checkout":i?.type==="fulfillment"?"fulfillment":i?.type==="recording"?"recording":t||e.operationCommand||i&&i.type!=="cancel"||n==="operation"&&!m?"waiting_result":"ready";return{mode:n,status:x,purchases:u,...m?{confirmation:structuredClone(m)}:{},actions:["refresh",...V(e)||$(e)?["start"]:[],...n==="run"&&e.run&&["running","waiting"].includes(e.run.status)?["close"]:[],...e.operationCommand?["retry"]:m?["confirm"]:[],...c.length===1&&i?.type==="checkout"?["continue_checkout"]:[]]}}function X(e){let n=U({quote:e?.quote??null,operation:e??null,requestId:null,pending:!1,destroyed:!1,canReselect:e&&j.get(e.operationId)===!0});return n.type==="complete"||n.type==="native"?n.type:null}function Z(e){if(!e.operation)return;let n={...e.operation,...e.operation.quote?{}:e.quote?{quote:e.quote}:{}};if(n.merchantExecution&&n.merchantExecution.customerId!==v)throw new l("SCOPE_MISMATCH","Purchase execution belongs to another Customer");let t=J(I.get(n.operationId)??null,n);I.set(n.operationId,t),t===n&&j.set(n.operationId,e.canReselect===!0)}async function _e(e){R();for(let t of[e.purchase,e.run.paywall])t&&Z(t);let n=await w.update(t=>{if(h(t),t.run&&(t.run.id!==e.run.id||t.run.versionId!==e.run.source.versionId))throw new l("SCOPE_MISMATCH","The original purchase Run changed");let u=F(t);for(let c of[e.purchase,e.run.paywall]){let i=c?.operation?.operationId??c?.quote?.operationId;if(!c||!i)continue;let s=u.find(f=>f.operationId===i);if(s&&s.receiptId!==c.receiptId)throw new l("INVALID_RESPONSE","The original purchase Receipt changed");let m=X(I.get(i));s?s.terminal??=m:u.push({receiptId:c.receiptId,operationId:i,terminal:m})}return{...t,purchases:u,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}}});h(n),n.run&&!["running","waiting"].includes(n.run.status)&&F(n).some(t=>!t.terminal)&&(n=await ee(n,!n.journal.entry?.command&&!n.journal.entry?.closeCommand,new Set([e.purchase?.operation?.operationId,e.run.paywall?.operation?.operationId].filter(t=>!!t)))),h(n),C(_(n,"run"))}function Ae(){return{async read(){let{entry:e}=await w.read();return h(e),structuredClone(e.journal)},async write(e,n){let t=null;return await w.update(u=>{if(h(u),u.operationCommand&&n?.command&&n.command.operation!=="close")throw new l("PURCHASE_PENDING","Recover the original Operation command before dispatching a Run mutation");return t=null,u.journal.revision!==e?u:(t=e+1,{...u,journal:{revision:t,entry:n}})}),t}}}async function ee(e,n=!1,t=new Set){h(e);let u=F(e);for(let i of u){if(i.terminal)continue;let s=t.has(i.operationId)?I.get(i.operationId):void 0;if(s??=await le(e,i),R(),s.operationId!==i.operationId)throw new l("INVALID_RESPONSE","Original Operation changed");if(s.merchantExecution&&s.merchantExecution.customerId!==v)throw new l("SCOPE_MISMATCH","Purchase execution belongs to another Customer");if(n&&!e.operationCommand&&U({quote:s.quote??null,operation:s,requestId:null,pending:!1,destroyed:!1}).type==="cancel"){if({operation:s}=await ue.attach({operationId:i.operationId,intent:"cancel"}),R(),s.operationId!==i.operationId)throw new l("INVALID_RESPONSE","Original cancellation Operation changed");s=await le(e,i)}I.set(i.operationId,J(I.get(i.operationId)??null,s))}let c=await w.update(i=>{h(i);let s=i.operationCommand&&I.get(i.operationCommand.operationId);return{...i,...s&&(s.confirmedAt||s.merchantExecution||s.status!=="pending")?{operationCommand:void 0}:{},purchases:F(i).map(m=>({...m,terminal:m.terminal??X(I.get(m.operationId))}))}});return h(c),c}async function ne(e){R();let n=await W.request("funnels",e);return R(),n}async function le(e,n){let t=Q(Ee,await ne({operation:"recover_purchase",runId:e.run.id,funnelId:e.start.funnelId,purchase:{receiptId:n.receiptId,operationId:n.operationId}}));if(te(e,t),t.purchase.receiptId!==n.receiptId||t.purchase.operation?.operationId!==n.operationId)throw new l("INVALID_RESPONSE","Original purchase reference changed");return Z(t.purchase),I.get(n.operationId)}async function de(e){for(let n of[e.journal.entry?.command,e.journal.entry?.closeCommand]){if(!n)continue;let t=Q(ve,await ne({operation:"settle_command",runId:e.run.id,funnelId:e.start.funnelId,requestId:n.requestId,...n.operation==="resume"?{}:{command:n}}));if(te(e,t),t.settlement.requestId!==n.requestId)throw new l("INVALID_RESPONSE","Original command settlement changed");t.purchase&&Z(t.purchase);let u=await w.update(c=>{h(c);let i=F(c),{receiptId:s,operationId:m}=t.settlement;if(s&&m){let x=i.find(S=>S.operationId===m);if(x&&x.receiptId!==s)throw new l("INVALID_RESPONSE","Original Receipt changed");x||i.push({receiptId:s,operationId:m,terminal:X(I.get(m))})}let f=t.settlement.state==="settled"?ye(c.journal.entry,n.requestId):c.journal.entry;return{...c,purchases:i,journal:f===c.journal.entry?c.journal:{revision:c.journal.revision+1,entry:f}}});h(u),e=u}return e}function te(e,n){if(n.customerId!==v||n.scope.projectId!==d.scope.projectId||n.scope.environment!==d.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 l("SCOPE_MISMATCH","The original recovery binding changed")}async function re(e,n){if(h(e),e.run&&(e=await de(e)),!F(e).length&&V(e))return C(_(e,"operation"));if(!F(e).length)return C({mode:"blocked",status:"blocked",actions:["refresh"],purchases:[],error:M(n)});E=!0;let t=await ee(e);return C(_(t,"operation"))}async function G(e,n=!1,t=!0){if(P=e.start.requestId,b=structuredClone({requestId:e.start.requestId,funnelId:e.start.funnelId,locale:e.start.locale,parameters:e.start.parameters}),!a){let u=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}},c;try{c=await ne(u)}catch(f){if(!e.run&&f instanceof l&&(f.status===void 0||f.status>=500))return C({mode:"blocked",status:"blocked",actions:["refresh","retry"],purchases:O.purchases,error:M(f)});throw f}let i=Q(Ce,c);if(i.customerId!==v||i.scope.projectId!==d.scope.projectId||i.scope.environment!==d.scope.environment)throw new l("SCOPE_MISMATCH","Recovery Customer or environment changed");if(i.outcome==="unknown")return C({mode:"blocked",status:"blocked",actions:["refresh","retry"],purchases:O.purchases,error:{code:"RESULT_UNKNOWN",message:"The original Start outcome remains unknown; retry only its original input"}});te(e,i);let s=await w.update(f=>(h(f),{...f,run:{id:i.target.runId,versionId:i.target.versionId,status:i.target.status,revision:i.view?.revision??f.run?.revision??0,runExpiresAt:i.target.runExpiresAt}}));if(h(s),e=s,i.access.type==="operation_only")return re(e,new l("RUN_RECONCILIATION_REQUIRED","Only the original command and Operation can be recovered"));e=await de(e);let m=i.view;if(m.locale!==e.start.locale||!Pe(m.parameters,e.start.parameters))throw new l("INVALID_RESPONSE","The original Start input changed");a=Re({...d,customerRun:{runId:i.target.runId,customerId:v,startRequestId:e.start.requestId},funnelId:e.start.funnelId,funnelExecutionPolicy:{allowed:e.allowed.filter(f=>d.executionPolicy.allowed.includes(f))},funnelCommandStorage:Ae(),onAcceptedResponse:_e},{scope:i.scope,run:m})}try{await a.get(),a.view?.pendingRequest?.requestId===e.start.requestId&&!a.pendingCommands?.length&&await a.resume(a.view.pendingRequest.requestId);for(let c of a.pendingCommands??[])c.operation!=="close"&&await a.settle?.(c.requestId);a.pendingCommands?.length&&await a.retry(),R();let u=(await w.read()).entry;return h(u),C(_(u,"run"))}catch(u){if(R(),t&&u instanceof l&&(u.status===401||u.status===409&&u.reason==="STATE_CHANGED")){a.reset(),a=null;let c=(await w.read()).entry;return h(c),G(c,!1,!1)}throw u}}function A(e,n="read"){if(R(),q)return n==="read"||n===D?q:q.then(()=>A(e,n),()=>A(e,n));clearTimeout(H);let t=e().catch(u=>{throw y||C({mode:"blocked",status:"blocked",actions:["refresh"],purchases:O.purchases,error:M(u)}),u});return q=t,D=n,t.then(()=>{q===t&&(q=void 0,D=void 0)},()=>{q===t&&(q=void 0,D=void 0)}),t}function T(){return A(async()=>{let{entry:e}=await w.read();return e?(P&&e.start.requestId!==P&&(a?.reset(),a=null,I.clear(),j.clear()),E&&P===e.start.requestId?re(e,O.error):G(e)):C({mode:"idle",status:"idle",actions:["start"],purchases:[]})})}async function pe(){let e=await T();return e.mode==="operation"&&!e.actions.includes("confirm")&&!e.actions.includes("retry")?e:A(async()=>{let n=(await w.read()).entry;if(h(n),!E){if(!a?.view?.paywall?.quote)throw new l("PURCHASE_PENDING","Read the original quote before confirming");let s=a.view.paywall.operation;if(s?.confirmedAt||s?.merchantExecution||s&&s.status!=="pending")return C(_(n,"run"));if(a.pendingCommands?.length)await a.retry();else{let f=a.view;await a.submit({operation:"submit",requestId:crypto.randomUUID(),nodeId:f.nodeId,visit:f.visit,revision:f.revision,input:{type:"paywall_confirm",operationId:f.paywall.quote.operationId}})}let m=(await w.read()).entry;return h(m),C(_(m,"run"))}let t=n.operationCommand?.operationId??O.confirmation?.operationId,u=t&&I.get(t);if(!t||!u||n.journal.entry?.command||n.journal.entry?.closeCommand)throw new l("PURCHASE_PENDING","The original Run command must be settled before Operation confirmation");B({allowed:n.allowed.filter(s=>d.executionPolicy.allowed.includes(s))},u.quote),await w.update(s=>{if(h(s),s.journal.entry?.command||s.journal.entry?.closeCommand||s.operationCommand&&s.operationCommand.operationId!==t)throw new l("PURCHASE_PENDING","Another original command is pending");return{...s,operationCommand:{operationId:t,intent:"confirm"}}});let c=await ue.attach({operationId:t,intent:"confirm"});if(R(),c.operation.operationId!==t)throw new l("INVALID_RESPONSE","Original confirmation Operation changed");I.set(t,J(u,c.operation));let i=(await w.read()).entry;return h(i),C(_(await ee(i,!1,new Set([t])),"operation"))},"confirm")}async function je(){let e=a?.view;if(!(!a||!e||!["running","waiting"].includes(e.status)))try{await a.submit({operation:"close",requestId:crypto.randomUUID(),nodeId:e.nodeId,visit:e.visit,revision:e.revision})}catch{}}return{get controller(){return a},get recovery(){return structuredClone(O)},get attempt(){return R(),structuredClone(b)},get identitySignal(){return se.signal},start(e){let n=k.parse({...structuredClone(e),operation:"start",requestId:e.requestId??crypto.randomUUID()});if(n.operation!=="start"||n.customer||n.customerData)throw new l("INVALID_REQUEST","A Customer-owned Funnel start is required");return A(async()=>{let t=(await w.read()).entry;t&&t.start.requestId===P&&$(t)&&await je();let u=await w.update(c=>{if(c&&!V(c)&&!$(c)){if(c.start.funnelId!==n.funnelId)throw new l("PURCHASE_PENDING","Recover the original Funnel before starting another purchase");return c}return{schemaVersion:1,baseUrl:w.baseUrl,scope:d.scope,customerId:v,sessionId:Y,start:n,allowed:[...d.executionPolicy.allowed],purchases:[],journal:{revision:0,entry:null}}});if(!u)throw new l("PURCHASE_STORAGE_INVALID","Original start was not retained");return P!==u.start.requestId&&(a?.reset(),a=null,I.clear(),j.clear(),E=!1),E?re(u,O.error):G(u,!0)},`start:${n.funnelId}`)},refresh:T,confirm:pe,retry:()=>E?pe():A(async()=>{let{entry:e}=await w.read();return e?G(e,!0):C({mode:"idle",status:"idle",actions:["start"],purchases:[]})},"retry"),async close(){return a?.view?A(async()=>{if(!a?.view)throw new l("PURCHASE_PENDING","Recover the original Run before closing");if(a.pendingCommands?.find(t=>t.operation==="close"))await a.retry();else if(["running","waiting"].includes(a.view.status)){let t=a.view;await a.submit({operation:"close",requestId:crypto.randomUUID(),nodeId:t.nodeId,visit:t.visit,revision:t.revision})}let n=(await w.read()).entry;return h(n),C(_(n,"run"))},"close"):T()},async continueCheckout(e){let n=await T();R(),await e(Ue(n))},subscribe(e){return L.add(e),()=>{L.delete(e)}},destroy:ce}}export{Fe as a,Ue as b,fn as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{h as p,i as d}from"./chunk-
|
|
1
|
+
import{h as p,i as d}from"./chunk-ITVSLSRM.js";import{I as a,L as u,O as m}from"./chunk-WRUW2UIJ.js";import{b as e}from"./chunk-ZY4XAKNQ.js";var s=e.enum(["page","popup","banner"]),y=3e5,f=e.strictObject({type:e.enum(["string","number","boolean","strings","json"]),nullable:e.boolean()}),h=e.strictObject({inputs:e.record(a,f.extend({required:e.boolean()})).refine(t=>Object.keys(t).length<=40,"Too many content inputs"),outputs:e.record(a,f).refine(t=>Object.keys(t).length<=40,"Too many content outputs")}),g=e.strictObject({kind:s,schemaVersion:e.literal(1),name:e.string().trim().min(1).max(80),screen:u,contract:h}),c=g.superRefine((t,r)=>{let n=(o,b)=>r.addIssue({code:"custom",message:o,path:b});t.screen.surface!==t.kind&&n("Content surface must match its domain",["screen","surface"]),t.screen.name!==t.name&&n("Content has one editable name",["screen","name"]),t.kind==="banner"&&t.screen.presentation.type!=="inline"&&n("Banner requires an inline container",["screen","presentation"]),t.kind!=="banner"&&t.screen.presentation.type==="inline"&&n("Inline presentation belongs to Banner",["screen","presentation"]),t.screen.actions.some(o=>o.type!=="event"&&o.type!=="navigate")&&n("Content actions must emit host intents or navigate locally",["screen","actions"]);let i=new Set(t.screen.actions.filter(o=>o.type==="event").map(o=>o.id));(Object.keys(t.contract.outputs).some(o=>!i.has(o))||[...i].some(o=>!Object.hasOwn(t.contract.outputs,o)))&&n("Every event needs exactly one output declaration",["contract","outputs"]),d(t)>y&&n("Content document exceeds its byte budget",[])});function S(t,r){if(t===null)return r.nullable;switch(r.type){case"json":return!0;case"string":return typeof t=="string";case"number":return typeof t=="number"&&Number.isFinite(t);case"boolean":return typeof t=="boolean";case"strings":return Array.isArray(t)&&t.every(n=>typeof n=="string")}}var x=c.superRefine((t,r)=>{for(let n of p(t.screen))Object.keys(t.contract.inputs).some(i=>n===i||n.startsWith(i+"."))||r.addIssue({code:"custom",path:["contract","inputs"],message:"Declare every reusable input read"});for(let n of t.screen.actions){if(n.type!=="event")continue;let i=t.contract.outputs[n.id],o=Object.hasOwn(n.properties,"value")?n.properties.value:n.properties;i&&!S(o,i)&&r.addIssue({code:"custom",path:["contract","outputs",n.id],message:"Action value differs from its declared type"})}m(t.screen).some(n=>!n.complete)&&r.addIssue({code:"custom",path:["screen","strings"],message:"Content needs complete localized copy"})}),l=e.strictObject({id:e.uuid(),kind:s,projectId:e.uuid(),environmentId:e.uuid(),name:e.string(),revision:e.number().int().nonnegative(),status:e.enum(["draft","published","archived"]),publishedVersionId:e.uuid().nullable(),createdAt:e.iso.datetime({offset:!0}),updatedAt:e.iso.datetime({offset:!0})}),D=l.extend({draft:c}),I=e.strictObject({rows:e.array(l).max(200),nextCursor:e.uuid().nullable()}),v=e.strictObject({id:e.uuid(),kind:s,resourceId:e.uuid(),projectId:e.uuid(),environmentId:e.uuid(),version:e.number().int().positive(),sourceRevision:e.number().int().nonnegative(),document:x,createdAt:e.iso.datetime({offset:!0})}),z=v.omit({document:!0}),V=e.discriminatedUnion("action",[e.strictObject({action:e.literal("create"),kind:s,id:e.uuid(),document:c}),e.strictObject({action:e.literal("save"),kind:s,id:e.uuid(),revision:e.number().int().nonnegative(),document:c}),e.strictObject({action:e.enum(["publish","archive"]),kind:s,id:e.uuid(),revision:e.number().int().nonnegative()})]).superRefine((t,r)=>{"document"in t&&t.document.kind!==t.kind&&r.addIssue({code:"custom",path:["document","kind"],message:"Content cannot change domain"})});export{s as a,v as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as d}from"./chunk-
|
|
1
|
+
import{b as d}from"./chunk-FVGUBIVT.js";import{a as u}from"./chunk-DSPLGTQI.js";function m(e){if(!/^[A-Za-z0-9_-]{1,64}$/.test(e))throw new Error("Invalid device cookie name");let t="";for(let i of document.cookie.split(";"))if(i.trim().startsWith(`${e}=`))try{t=decodeURIComponent(i.trim().slice(e.length+1))}catch{}return/^[A-Za-z0-9_-]{8,128}$/.test(t)||(t=crypto.randomUUID(),document.cookie=`${e}=${encodeURIComponent(t)}; path=/; max-age=${400*24*3600}; SameSite=Lax`),t}function y(){try{let e=sessionStorage.getItem("indiana_sid");return e||(e=crypto.randomUUID(),sessionStorage.setItem("indiana_sid",e)),e}catch{return}}function g(e=d){let t=new URL(e);if(t.protocol!=="https:"&&!(t.protocol==="http:"&&["localhost","127.0.0.1","[::1]"].includes(t.hostname))||t.username||t.password||t.search||t.hash)throw new Error("baseUrl must be an https origin without credentials");return t.origin}var o=new Set,s;function S(e){let t=()=>e();if(o.add(t),!s){let i=!0,a=history.pushState,p=history.replaceState,r=()=>{if(i)for(let n of[...o])o.has(n)&&u(n)},c=function(...n){a.apply(this,n),r()},h=function(...n){p.apply(this,n),r()};history.pushState=c,history.replaceState=h,addEventListener("popstate",r),addEventListener("hashchange",r),s=()=>{i=!1,history.pushState===c&&(history.pushState=a),history.replaceState===h&&(history.replaceState=p),removeEventListener("popstate",r),removeEventListener("hashchange",r)}}return()=>{o.delete(t)&&(o.size||(s?.(),s=void 0))}}export{m as a,y as b,g as c,S as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as ie}from"./chunk-
|
|
1
|
+
import{i as ie}from"./chunk-TF2OFTYS.js";import{a as Z,c as ee,d as te,e as ne,g as re,h as oe,i as se,k as N}from"./chunk-RBMOWJGE.js";import{b as X}from"./chunk-YXCEZAQL.js";import{r as V}from"./chunk-4ZVVG5LM.js";import"./chunk-ITVSLSRM.js";import"./chunk-SJSCROSL.js";import"./chunk-ACFQLHJR.js";import"./chunk-XZEGVBAI.js";import"./chunk-J4VTKRH7.js";import{E as $,P as G,U as R,la as Y,ma as K}from"./chunk-WRUW2UIJ.js";import"./chunk-FJGJQGYF.js";import{a as p}from"./chunk-HJLGRW4A.js";import"./chunk-XIP32WI7.js";import"./chunk-FVGUBIVT.js";import{b as u}from"./chunk-ZY4XAKNQ.js";import{a as h}from"./chunk-DSPLGTQI.js";import"./chunk-6BTJNSQQ.js";import"./chunk-PWXN3W4Q.js";import"./chunk-WOT6VMZA.js";var z=new WeakMap;function ce(s){let t={string:u.string(),number:u.number().finite(),boolean:u.boolean(),strings:u.array(u.string()),json:R}[s.type];return s.nullable?t.nullable():t}function ae(s,t){let f=u.record(u.string(),R).parse(s);if(Object.keys(f).length>40)throw new p("INVALID_REQUEST","Too many content inputs");for(let[m,r]of Object.entries(f))Y.parse({[m]:r});if(Object.keys(f).some(m=>!Object.hasOwn(t.inputs,m)))throw new p("INVALID_REQUEST","Undeclared content input");for(let[m,r]of Object.entries(t.inputs))if(Object.hasOwn(f,m))ce(r).parse(f[m]);else if(r.required)throw new p("INVALID_REQUEST",`Missing content input ${m}`);return f}async function Ae(s,t){return le(s,t,!1)}async function Se(s,t){return le(s,t,!0)}async function le(s,t,f){t.signal?.throwIfAborted();let m=X.parse(t.content),r=m.document;if(t.closeControl==="content"&&!r.screen.actions.some(e=>e.type==="event"&&e.close))throw new p("INVALID_REQUEST","An authored Close control requires a declared Close action");if(z.has(s))throw new p("CONFLICT","Content is already mounted in this container");let y=ae(t.inputs??{},r.contract),T=new Set(u.array(u.string()).max(40).parse(t.mutableInputs??[]));if(T.size!==(t.mutableInputs?.length??0)||[...T].some(e=>!Object.hasOwn(r.contract.inputs,e)))throw new p("INVALID_REQUEST","Mutable content inputs must name unique declared inputs");for(let e of Object.keys(r.contract.outputs))if(typeof t.actions[e]!="function")throw new p("INVALID_REQUEST",`Missing host handler for ${e}`);let M=K.parse(t.bindings??[]),d=s.ownerDocument,ue=s.clientHeight||d.defaultView?.innerHeight||800,P,w,a,_,x=r.kind==="popup",n=x?d.createElement("dialog"):null,c=d.createElement("div");if(c.dataset.indianaContent=r.kind,c.setAttribute("aria-label",r.name),c.style.cssText="width:100%;min-width:0",n){n.setAttribute("aria-label",r.name);let e=r.screen.presentation;n.style.cssText="box-sizing:border-box;padding:0;border:0;max-width:calc(100vw - 32px);max-height:calc(100dvh - 32px);overflow:auto",e.type==="modal"||e.type==="sheet"?(n.style.width=`${$[e.size]}px`,e.type==="sheet"&&(n.style.margin="auto auto 0")):n.style.width="100vw",a=ee(n,r.screen,()=>{w?.resizeViewport(d.defaultView?.innerHeight||800,d.defaultView?.innerWidth||1024)}),n.append(c),s.append(n)}else s.append(c);let i=!1,A=!1,E=!1,S=!1,de=n?oe(n):se(c,s),D=re(s,t,r.kind,()=>{k()&&(b(),h(t.onDismiss))}),q,H,L=new Promise((e,o)=>{q=e,H=o});L.catch(()=>{});let g=null,I=structuredClone(r.screen),W=G(I,[t.locale,...d.defaultView?.navigator.languages??[]]),j=t.capabilities;I.actions=I.actions.map(e=>e.type==="event"?{...e,close:!1}:e);function b(){i||(i=!0,t.signal?.removeEventListener("abort",b),D.finish("dismissed"),H(new Error("Content preparation cancelled")),a?.destroy(),_?.(),w?.destroy(),n?.close(),n?.remove(),c.remove(),z.delete(s),n&&P?.())}let v=()=>{!E||!k()||(b(),h(t.onDismiss))};function k(){try{return t.canDismiss?.()!==!1}catch(e){return h(t.onError,e),!1}}if(n&&t.closeControl!=="content"){let e=d.createElement("button");e.type="button",e.textContent="\xD7",e.setAttribute("aria-label",t.locale?.startsWith("zh")?"\u5173\u95ED":"Close"),ne(e,r.screen.theme),e.addEventListener("click",v),n.prepend(e)}n&&a?.responsive&&(_=Z(n,v,k,t.locale?.startsWith("zh")?"\u5173\u95ED":"Close"),n.addEventListener("click",e=>{if(e.target!==n)return;let o=n.getBoundingClientRect();(e.clientX<o.left||e.clientX>o.right||e.clientY<o.top||e.clientY>o.bottom)&&v()})),n?.addEventListener("cancel",e=>{e.preventDefault(),v()}),n?.addEventListener("keydown",e=>{e.key==="Escape"&&(e.preventDefault(),v())});async function F(){if(i||!E||A||!g)return;let e=g;A=!0,c.setAttribute("aria-busy","true");try{await t.actions[e.actionId](structuredClone(e)),g=null}catch(o){i||h(t.onError,o)}finally{A=!1,i||c.removeAttribute("aria-busy")}}function J(){if(i)throw new p("CONFLICT","Content host has been destroyed");E||!S||(P??=N(d),D.present(e=>{de(),n&&(a?.latch(),n.showModal(),a?.responsive&&n.focus({preventScroll:!0}),!e&&t.loading!=="host"&&te(n,a?.type??r.screen.presentation.type,a?.responsive)),E=!0}))}function U(e){D.finish("error",e),H(e instanceof Error?e:new Error(String(e))),b()}let Q={destroy:b,show:J,get pendingAction(){return g?structuredClone(g):null},retryAction:F,updateInputs(e){if(i)throw new p("CONFLICT","Content host has been destroyed");let o=u.record(u.string(),R).parse(e),C=ae({...y,...o},r.contract);for(let l of Object.keys(o))if(!T.has(l)&&(!Object.hasOwn(y,l)||V(y[l])!==V(C[l])))throw new p("PRECONDITION_FAILED","This content input is frozen; prepare a new presentation");V(y)!==V(C)&&(w?.update(I,W,{capabilities:j,serverInput:{bindings:M,answers:{},values:C}}),y=C)},updateCapabilities(e){if(i)return;let o=structuredClone(e);w?.updateCapabilities(o),j=o}};z.set(s,Q),t.signal?.addEventListener("abort",b,{once:!0});try{if(t.signal?.throwIfAborted(),f||(P=N(d),D.start(x,t.locale??r.screen.strings.defaultLocale),i&&await L),w=ie(c,{mode:"live",rendererUrl:t.rendererUrl,title:r.name,viewportHeight:r.kind==="page"?ue:a?.responsive?d.defaultView?.innerHeight||800:void 0,...a?.responsive?{viewportWidth:d.defaultView?.innerWidth||1024,hostPresentation:()=>a.type}:{},onResize:e=>{i||a?.responsive&&(c.style.height=`${e}px`,c.style.overflow="clip",a.setContentHeight(e))},onRendered:e=>{if(!i&&(e&&n?.setAttribute("aria-label",e),!S))try{S=!0,f||J(),q()}catch(o){U(o),h(t.onError,o)}},onError:e=>{if(i)return;let o=new Error(e);S||U(o),h(t.onError,o)},onEscape:x?v:void 0,onAction:(e,o,C)=>{if(i||!E||A||g)return;let l=r.screen.actions.find(O=>O.id===e),B=r.contract.outputs[e];if(!(l?.type!=="event"||!B)&&!(l.close&&!k()))try{let O=ce(B).parse(Object.hasOwn(l.properties,"value")?l.properties.value:l.properties);g=structuredClone({requestId:crypto.randomUUID(),contentVersionId:m.id,actionId:e,event:l.event,value:O,selection:o??{},answers:C??{},requestedClose:l.close}),F()}catch(O){h(t.onError,O)}}}),w.update(I,W,{capabilities:j,serverInput:{bindings:M,answers:{},values:y}}),await Promise.race([w.ready,L]),f&&await L,i)throw new Error("Content preparation cancelled");return Q}catch(e){throw U(e),e}}export{Ae as mountContent,Se as prepareContent};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as y}from"./chunk-
|
|
1
|
+
import{b as y}from"./chunk-YEXRETKV.js";import{d as A}from"./chunk-PI25NLDV.js";import"./chunk-UWYL2QCF.js";import{f as g,g as I}from"./chunk-RBMOWJGE.js";import"./chunk-2TPPGW7V.js";import"./chunk-TMZGZAWM.js";import"./chunk-7Z7JT4HE.js";import"./chunk-WK4WQZHK.js";import"./chunk-QPHT6QHE.js";import"./chunk-4ZVVG5LM.js";import"./chunk-LZV4QJ5E.js";import"./chunk-ITVSLSRM.js";import"./chunk-SJSCROSL.js";import"./chunk-B3KFE57L.js";import"./chunk-ACFQLHJR.js";import"./chunk-XZEGVBAI.js";import"./chunk-J4VTKRH7.js";import"./chunk-WRUW2UIJ.js";import"./chunk-FJGJQGYF.js";import{a as c}from"./chunk-HJLGRW4A.js";import"./chunk-XIP32WI7.js";import"./chunk-SLUA7ABW.js";import"./chunk-ZYTT7ZAB.js";import"./chunk-3VUPVXAV.js";import"./chunk-FVGUBIVT.js";import"./chunk-ZY4XAKNQ.js";import{a as i}from"./chunk-DSPLGTQI.js";import"./chunk-6BTJNSQQ.js";import"./chunk-PWXN3W4Q.js";import"./chunk-WOT6VMZA.js";var d=new WeakMap;function T(h,e){let P=d.get(e.client);if(P)return P;let m=Promise.resolve().then(async()=>{let n=!1,s,w,E=!1,v=()=>{},r=e.signal?AbortSignal.any([e.signal,e.client.identitySignal]):e.client.identitySignal,u=()=>{d.get(e.client)===m&&d.delete(e.client),r.removeEventListener("abort",f),v()},o=I(h,e,"funnel",f);function f(){n||(n=!0,o.finish("dismissed"),s?s.destroy():(u(),i(e.onDismiss,null)))}r.addEventListener("abort",f,{once:!0});try{let b=function(){!n&&!r.aborted&&!E&&w&&e.client.recovery.status==="complete"&&(E=!0,i(e.onComplete,structuredClone(w)))};var C=b;r.throwIfAborted(),o.start(!0,e.start?.locale);let l=await o.wait(e.start?e.client.start(e.start):e.client.refresh(),g);r.throwIfAborted();let O=e.client.controller;return l.mode!=="run"||l.status==="blocked"||!O?(o.finish("skipped"),u(),null):(r.removeEventListener("abort",f),v=e.client.subscribe(b),s=await A(h,{...e,client:O,signal:r,checkoutNavigation:"after_confirmation",onCheckoutUrl(t){if(r.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");if(y(e.client.recovery)!==t)throw new c("PURCHASE_PENDING","Checkout differs from the original recovery proof");return e.onCheckoutUrl?e.onCheckoutUrl(t):h.ownerDocument.defaultView?.location.assign(t)},async resolveOfferId(t){if(r.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");let a=e.client.attempt;if(!a)throw new c("PURCHASE_PENDING","Read the original Start before selecting an offer");let F=await e.resolveOfferId?.(t,a);if(r.throwIfAborted(),n)throw new DOMException("Presentation dismissed","AbortError");if(e.client.attempt?.requestId!==a.requestId)throw new c("PURCHASE_STORAGE_CONFLICT","The original purchase changed while selecting an offer");return F},onComplete(t){w=t,b()},onError(t){i(e.onError,t),t instanceof c&&t.status===401&&!r.aborted&&e.client.refresh().catch(a=>i(e.onError,a))},onDismiss(t){n=!0,u(),i(e.onDismiss,t)}},o),n||r.aborted?(s.destroy(),null):s)}catch(l){if(n)return null;throw o.finish("error",l),u(),i(e.onError,l),l}});return d.set(e.client,m),m}export{T as showFunnelPurchase};
|
|
@@ -49399,7 +49399,7 @@ declare function createFunnelRunController(options: FunnelRunControllerOptions):
|
|
|
49399
49399
|
runToken?: string | undefined;
|
|
49400
49400
|
customerId?: string | undefined;
|
|
49401
49401
|
}>;
|
|
49402
|
-
retry(): Promise<
|
|
49402
|
+
retry(): Promise<FunnelControllerResponse>;
|
|
49403
49403
|
identify(token: string): void;
|
|
49404
49404
|
readonly identitySignal: AbortSignal;
|
|
49405
49405
|
subscribe: (listener: (run: FunnelRunView) => void) => () => boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as zod from 'zod';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
import { l as FeatureClientOptions, I as IndianaOptions, C as CustomerSession, R as RemoteFeatureResult, G as PushAddressObservation, g as FunnelStartInput, p as FunnelRuntimeResponse, m as FunnelControllerResponse, z as createFunnelRunController, H as FunnelProcessOpenInput, J as FunnelProcessResponse, K as FunnelCommand, M as FunnelProcessMutation, N as FunnelPageExperimentsResponse, i as FunnelProcessRunView, F as FunnelRunController } from './funnel-local-client-
|
|
3
|
+
import { l as FeatureClientOptions, I as IndianaOptions, C as CustomerSession, R as RemoteFeatureResult, G as PushAddressObservation, g as FunnelStartInput, p as FunnelRuntimeResponse, m as FunnelControllerResponse, z as createFunnelRunController, H as FunnelProcessOpenInput, J as FunnelProcessResponse, K as FunnelCommand, M as FunnelProcessMutation, N as FunnelPageExperimentsResponse, i as FunnelProcessRunView, F as FunnelRunController } from './funnel-local-client-D7e3rP5-.js';
|
|
4
4
|
import { A as ApiInput, O as OfferingItem, I as InvoiceModeParams, a as ApiOutput } from './api-BpeJkr6U.js';
|
|
5
5
|
import { O as Offer } from './coupon-kfkIVf9n.js';
|
|
6
6
|
import { S as StackNode } from './screen-CGCJ46b1.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as a,d as b}from"./chunk-PI25NLDV.js";import"./chunk-UWYL2QCF.js";import"./chunk-RBMOWJGE.js";import"./chunk-ITVSLSRM.js";import"./chunk-SJSCROSL.js";import"./chunk-B3KFE57L.js";import"./chunk-ACFQLHJR.js";import"./chunk-XZEGVBAI.js";import"./chunk-J4VTKRH7.js";import"./chunk-WRUW2UIJ.js";import"./chunk-FJGJQGYF.js";import"./chunk-HJLGRW4A.js";import"./chunk-XIP32WI7.js";import"./chunk-SLUA7ABW.js";import"./chunk-ZYTT7ZAB.js";import"./chunk-FVGUBIVT.js";import"./chunk-ZY4XAKNQ.js";import"./chunk-DSPLGTQI.js";import"./chunk-6BTJNSQQ.js";import"./chunk-PWXN3W4Q.js";import"./chunk-WOT6VMZA.js";export{a as showFunnelRun,b as showObservedFunnelRun};
|
package/dist/index.d.ts
CHANGED
|
@@ -3,14 +3,14 @@ import { S as ScreenAnswers, P as PresentationLoadingOptions, s as screenInputBi
|
|
|
3
3
|
export { b as PresentationState } from './presentation-loading-iSaRiDP2.js';
|
|
4
4
|
import { J as JsonValue } from './growth-rules-B4YYy64R.js';
|
|
5
5
|
import { S as StackNode, a as ScreenSelection } from './screen-CGCJ46b1.js';
|
|
6
|
-
import { P as PaywallSession, S as SubscriptionOperation, F as FunnelRunController, a as FunnelRunView, b as PaywallRecovery, c as FunnelCommandStorage, s as scopeSchema, I as IndianaOptions, d as SessionCredentials, e as FunnelExecutionPolicy, f as SubscriptionAttachQuote, g as FunnelStartInput, h as IamFunnelEntryDelivery, i as FunnelProcessRunView, j as createPaywallSession$1 } from './funnel-local-client-
|
|
7
|
-
export { C as CustomerSession, k as FeatureClient, l as FeatureClientOptions, m as FunnelControllerResponse, n as FunnelPendingEntry, o as FunnelPurchaseRecovery, p as FunnelRuntimeResponse, q as FunnelSegmentPrediction, L as LocalFunnelClient, r as LocalFunnelClientOptions, t as LongplayError, u as PaywallPurchaseInput, v as PaywallStartInput, w as PushHost, x as PushJournal, y as createFeatureClient, z as createFunnelRunController, A as createLocalFunnelClient, B as getPaywallRecovery, D as preparePaywallFallback } from './funnel-local-client-
|
|
6
|
+
import { P as PaywallSession, S as SubscriptionOperation, F as FunnelRunController, a as FunnelRunView, b as PaywallRecovery, c as FunnelCommandStorage, s as scopeSchema, I as IndianaOptions, d as SessionCredentials, e as FunnelExecutionPolicy, f as SubscriptionAttachQuote, g as FunnelStartInput, h as IamFunnelEntryDelivery, i as FunnelProcessRunView, j as createPaywallSession$1 } from './funnel-local-client-D7e3rP5-.js';
|
|
7
|
+
export { C as CustomerSession, k as FeatureClient, l as FeatureClientOptions, m as FunnelControllerResponse, n as FunnelPendingEntry, o as FunnelPurchaseRecovery, p as FunnelRuntimeResponse, q as FunnelSegmentPrediction, L as LocalFunnelClient, r as LocalFunnelClientOptions, t as LongplayError, u as PaywallPurchaseInput, v as PaywallStartInput, w as PushHost, x as PushJournal, y as createFeatureClient, z as createFunnelRunController, A as createLocalFunnelClient, B as getPaywallRecovery, D as preparePaywallFallback } from './funnel-local-client-D7e3rP5-.js';
|
|
8
8
|
import { E as EntitlementCheckResult, M as MerchantBridgeManifest } from './funnel-node-evaluation-COxXtZEQ.js';
|
|
9
9
|
export { a as EntitlementCheckInput, b as EntitlementCheckObservation, c as EntitlementRequirement, F as FunnelNodeEvaluationContext, e as evaluateFunnelNode } from './funnel-node-evaluation-COxXtZEQ.js';
|
|
10
10
|
import { C as CouponInput } from './coupon-kfkIVf9n.js';
|
|
11
11
|
export { O as Offer, a as OfferUnavailableReason } from './coupon-kfkIVf9n.js';
|
|
12
|
-
import { c as createFunnelProcess } from './funnel-process-client-
|
|
13
|
-
export { F as FunnelProcessAdapter, a as FunnelProcessOptions, b as FunnelResourceSource, I as LongplayFeatureOptions, d as createFunnelClient, e as createLongplay } from './funnel-process-client-
|
|
12
|
+
import { c as createFunnelProcess } from './funnel-process-client-BEPv6guV.js';
|
|
13
|
+
export { F as FunnelProcessAdapter, a as FunnelProcessOptions, b as FunnelResourceSource, I as LongplayFeatureOptions, d as createFunnelClient, e as createLongplay } from './funnel-process-client-BEPv6guV.js';
|
|
14
14
|
export { C as ConfigurationStorage, a as ConfigurationSync, b as ConfigurationSyncOptions, c as createConfigurationSync } from './configuration-sync-DdTRUv7A.js';
|
|
15
15
|
import './api-BpeJkr6U.js';
|
|
16
16
|
import 'zod/v4';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as cn,c as dn}from"./chunk-MMZR4I5X.js";import{a as Ue,b as fn,c as Ie}from"./chunk-IDMOAV63.js";import{f as pe}from"./chunk-K72QA2PO.js";import"./chunk-GOYKJHDV.js";import{a as en,c as sn,d as un}from"./chunk-VKDBROTE.js";import"./chunk-PQJJ5BSY.js";import{a as an}from"./chunk-JAUJZWYJ.js";import"./chunk-6QJRT23Q.js";import{h as Qe,i as on,k as ln}from"./chunk-S4JIOALC.js";import"./chunk-VSWKFI3L.js";import"./chunk-MBKZYWPF.js";import{F as Re,e as Ve,g as je,h as fe,i as me,j as Ge,x as nn}from"./chunk-JPHYIUIR.js";import{a as qe}from"./chunk-PKY55SBA.js";import"./chunk-UWAZDSWO.js";import"./chunk-TNN4S6VO.js";import{B as Fe,D as Oe,E as xe,G as De,H as Te,I as ke,J as Be,K as Ee,L as He,x as ve,y as Me,z as Ne}from"./chunk-PNHGULO2.js";import{$ as Le,l as Ye,m as Ze,n as We}from"./chunk-2JTMXZ5M.js";import"./chunk-3GT4A3TA.js";import{c as tn,d as rn}from"./chunk-KAXKYBSI.js";import"./chunk-AZ53RDWO.js";import{b as be}from"./chunk-YBX2LLRG.js";import"./chunk-TLGKBSXC.js";import"./chunk-4WBIACS2.js";import"./chunk-HZYCK4XJ.js";import{a as H}from"./chunk-7EPE2PUN.js";import"./chunk-VC2H3LFP.js";import{a as ge,c as ce}from"./chunk-J6KIN4RH.js";import"./chunk-SLUA7ABW.js";import{c as ye,d as he}from"./chunk-QZG2YXM4.js";import"./chunk-3VUPVXAV.js";import"./chunk-5X6WAPH3.js";import{b as K}from"./chunk-7GD2UTBU.js";import{a as Z}from"./chunk-DSPLGTQI.js";import"./chunk-O4KXODTJ.js";import"./chunk-CILM5XMH.js";import"./chunk-WOT6VMZA.js";var y=class extends Error{constructor(m,k=0,_=!1,E="fix_request"){super(m);this.code=m;this.status=k;this.retryable=_;this.recovery=E;this.name="MerchantBridgeError"}code;status;retryable;recovery};async function mn(n,A){if(!n.headers.get("content-type")?.split(";",1)[0].trim().match(/^application\/(?:json|[a-z0-9.+-]+\+json)$/i))throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE");let m=n.body?.getReader();if(!m)throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE");let k=()=>{m.cancel().catch(()=>{})};A.addEventListener("abort",k,{once:!0});let _=0,E="",r=new TextDecoder("utf-8",{fatal:!0});try{for(A.throwIfAborted();;){let i=await m.read();if(A.throwIfAborted(),i.done)break;if(_+=i.value.byteLength,_>262144)throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE");E+=r.decode(i.value,{stream:!0})}return E+=r.decode(),JSON.parse(E)}catch(i){throw A.throwIfAborted(),i instanceof y?i:new y("MERCHANT_BRIDGE_INVALID_RESPONSE")}finally{A.removeEventListener("abort",k),await m.cancel().catch(()=>{}),m.releaseLock()}}function pn(n){let A=Oe.parse(n.origin),m=xe.parse(n.manifest),k={projectId:n.scope.projectId,environmentId:n.scope.environmentId,environment:n.scope.environment};for(let c of["projectId","environmentId","environment"])if(m[c]!==n.scope[c])throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");let _=n.customerId===void 0?null:K.uuid().parse(n.customerId),E=0,r=null,i=null,g=new AbortController,I=n.fetch??globalThis.fetch;async function U(c,s,p,w,h){if(!m.capabilities.includes(c))throw new y("MERCHANT_BRIDGE_CAPABILITY_UNSUPPORTED",501);let d=Fe[c];if(["merchant_catalog_reader","merchant_refund_authority","indiana_server_key"].includes(d.authority))throw new y("MERCHANT_BRIDGE_FORBIDDEN",403);let l=E,o=AbortSignal.any([g.signal,AbortSignal.timeout(Math.min(3e4,Math.max(1e3,n.timeoutMs??1e4))),...n.signal?[n.signal]:[],...w?[w]:[]]);o.throwIfAborted();let N=new Headers(await n.headers?.());if(o.throwIfAborted(),l!==E)throw new DOMException("Merchant identity changed","AbortError");if(/\bgg_(?:sk|ct|rt)_/.test(N.get("authorization")??"")||N.has("X-Indiana-Bridge-Signature")||N.has("X-Indiana-Bridge-Key-Id"))throw new y("MERCHANT_BRIDGE_FORBIDDEN",403);N.set(Ne,String(ve)),N.set("Accept","application/json");let P=crypto.randomUUID();N.set("X-Request-Id",P),N.set("Content-Type","application/json");let b=await I(A+Me,{method:"POST",credentials:"include",redirect:"error",cache:"no-store",headers:N,signal:o,body:JSON.stringify({bridgeVersion:ve,requestId:P,command:d.command,scope:k,data:h??(p===void 0?{}:{operationId:p})})}),V=await mn(b,o);if(o.throwIfAborted(),l!==E)throw new DOMException("Merchant identity changed","AbortError");if(!b.ok){let D=He.safeParse(V);throw!D.success||D.data.scope.projectId!==n.scope.projectId||D.data.scope.environment!==n.scope.environment||D.data.scope.environmentId!==n.scope.environmentId||D.data.requestId!==P||D.data.command!==d.command?new y("MERCHANT_BRIDGE_INVALID_RESPONSE",b.status):new y(D.data.error.code,b.status,D.data.error.retryable,D.data.error.recovery)}let u=De(K.unknown()).safeParse(V);if(!u.success||u.data.scope.projectId!==n.scope.projectId||u.data.scope.environment!==n.scope.environment||u.data.scope.environmentId!==n.scope.environmentId||u.data.requestId!==P||u.data.command!==d.command)throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE",b.status);let j=s.safeParse(u.data.data);if(!j.success)throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE",b.status);return j.data}function M(){if(!_)throw new y("MERCHANT_BRIDGE_UNAUTHENTICATED",401);return _}async function z(c,s,p,w){let h=M();if(w!==void 0&&Ee.parse({operationId:w,customerId:h}),!m.capabilities.includes(c))throw new y("MERCHANT_BRIDGE_CAPABILITY_UNSUPPORTED",501);let d=E,l=AbortSignal.any([g.signal,AbortSignal.timeout(Math.min(3e4,Math.max(1e3,n.timeoutMs??1e4))),...n.signal?[n.signal]:[],...s?[s]:[]]);l.throwIfAborted();let o,N=new Promise((P,b)=>{o=()=>b(l.reason),l.addEventListener("abort",o,{once:!0})});try{let b=p(async()=>{let u=await import("./merchant-bridge-contracts-JCDMP54Z.js");if(l.throwIfAborted(),d!==E||_!==h)throw new DOMException("Merchant identity changed","AbortError");return u},l),V=await Promise.race([b,N]);return l.throwIfAborted(),V}finally{l.removeEventListener("abort",o)}}async function J(c,s,p,w){let h=M(),d=Ee.parse({operationId:p,customerId:h}),l=await U(c,s,d.operationId,w,d);if(l.customerId!==h||l.operationId!==d.operationId)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");return l}return{async readPresentation(c){let s=await U("presentation",ke,void 0,c);if(i!==null&&i!==s.nativeUserId)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(s.presentation&&_!==null&&s.presentation.customerId!==_)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");return i=s.nativeUserId,r=s.presentation,s},async createSession(c){let s=await U("session",Te,void 0,c);if(i!==null&&i!==s.nativeUserId)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(_!==null&&_!==s.session.customerId)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(r&&r.customerId!==s.session.customerId)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");return _=s.session.customerId,i=s.nativeUserId,s.session},async reportPresentation(c,s){let p=M(),w=Be.parse(c);if(!r||r.customerId!==p||r.decisionId!==w.decisionId)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");return U("presentation_events",K.strictObject({queued:K.literal(!0)}),void 0,s,w)},async readCustomerCommerce(c){let s=M(),p=await z("customer_commerce",c,async(w,h)=>{let[d,l]=await Promise.all([w(),U("customer_commerce",K.unknown(),void 0,h)]),o=d.merchantBridgeCommerceSchema.safeParse(l);if(!o.success)throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE");return o.data});if(p.customerId!==s)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");return p},async executePurchase(c,s){let p=await z("purchases",s,async(w,h)=>J("purchases",(await w()).merchantBridgeOperationSchema,c,h),c);if(p.type!=="purchase")throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE");return p},readOperation:(c,s)=>z("operation_status",s,async(p,w)=>J("operation_status",(await p()).merchantOperationLookupSchema,c,w),c),async executeSubscriptionChange(c,s){let p=await z("subscription_changes",s,async(w,h)=>J("subscription_changes",(await w()).merchantBridgeOperationSchema,c,h),c);if(p.type!=="subscription_change")throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE");return p},reset(){E++,g.abort(),g=new AbortController,_=null,r=null,i=null}}}var $e=K.strictObject({command:me,target:je,runId:K.uuid().optional(),expiresAt:K.iso.datetime({offset:!0}).optional()}).refine(n=>n.command.release===n.target.release),Ke=K.strictObject({schemaVersion:K.literal(1),entries:K.array($e).max(4e3)});function ze(n){let A=!1,m=()=>{A||n.unavailable(),A=!0};function k(){return n.storage===!1?void 0:n.storage??globalThis.sessionStorage}function _(r){let i=k()?.getItem(r);if(!i)return[];if(i.length>1048576)throw Error("Entry recovery is too large");return Ke.parse(JSON.parse(i)).entries}function E(r,i){let g=k();if(!g)return;if(!i.length)return g.removeItem(r);let I=JSON.stringify(Ke.parse({schemaVersion:1,entries:i}));if(I.length>1048576)throw Error("Entry recovery is too large");g.setItem(r,I)}return{load(){try{let r=n.binding();if(!r||n.storage===!1)return;let i="indiana.funnel.entries.v1."+JSON.stringify(r);return{key:i,entries:_(i)}}catch{m();return}},retain(r,i){if(r)try{let g=$e.parse(i);E(r,[..._(r).filter(I=>I.command.funnelId!==g.command.funnelId),g])}catch{m()}},forget(r,i){if(r)try{E(r,_(r).filter(g=>g.command.requestId!==i))}catch{m()}}}}var we=n=>["running","waiting"].includes(n.status)&&!n.pendingRequest&&(n.stopped||!n.screen&&!n.paywall&&n.instruction?.type==="wait"&&n.instruction.kind!=="operation");function yn(n){let A=ye(n.baseUrl),m=n.scope,k=be(n),_=n.fetch??globalThis.fetch.bind(globalThis),E,r=!1,i=!1,g=0,I=0,U="",M=0,z=0,J=0,c=!1,s,p=!0,w,h,d,l,o,N=-1,P,b=e=>{P===e&&(P=void 0,q())},V=new Set,u=(e,a)=>Z(n.onStatus,e,a),j=new Set,D=ze({storage:n.recoveryStorage,binding:()=>{let e=n.session.snapshot()?.customerId;return e?[A,m.projectId,m.environment,n.environmentId,n.appManifestRelease,e]:void 0},unavailable:()=>u("recovery_unavailable")}),X=e=>D.forget(e.storageKey,e.command.requestId);function re(e,a){a&&(e.runId=a.id,e.expiresAt=a.runExpiresAt),D.retain(e.storageKey,{command:e.command,target:e.target,...e.runId&&{runId:e.runId},...e.expiresAt&&{expiresAt:e.expiresAt}})}function ee(){let e=o;o=void 0,e?.host.destroy(),e?.slot.remove(),e?.client.reset(),q()}let de=()=>P!==void 0||o!==void 0&&!o.background;function t(e,a){if(o?.client!==e)return;re(o.recovery,a);let f=we(a);o.slot.hidden=f,f!==o.background&&(o.background=f,f?u("run_background",o.entryId):N=I,q())}function R(e,a,f){let S=e.client.view;if(!a||e.background||!S?.screen||S.paywall||S.pendingRequest||S.stopped||S.status!=="waiting")return;let O=Le.parse({operation:"close",requestId:crypto.randomUUID(),nodeId:S.nodeId,visit:S.visit,revision:S.revision,customerToken:a}),$=be({...n,session:void 0});$.requestWithCredential("funnels",O,e.runToken,{keepalive:f}).then(()=>X(e.recovery)).catch(()=>{}).finally(()=>$.dispose())}let F=()=>{o&&R(o,n.session.peek(),!0)},L=()=>Date.now()<z&&performance.now()<J;function G(e){if(e.target.release!==n.appManifestRelease||!L())return!1;try{return ce(e.target.render,document,location.pathname,()=>{})}catch{return u("incompatible",e.id),!1}}function ne(e){if(r||e.epoch!==M||e.visit!==I||document.visibilityState==="hidden")return!1;try{return ce(e.target.render,document,location.pathname,()=>{})}catch{return!1}}async function oe(e){if(de()){u("in_progress",e.id);return}if(!n.session.peek()){u("identity_required",e.id);return}let a=D.load(),f=a?.entries.find(O=>O.command.funnelId===e.funnelId&&(!O.expiresAt||Date.parse(O.expiresAt)>Date.now()));if(f){if(!ae(f)){u("recovery_pending",e.id);return}let O={...f,storageKey:a.key,epoch:M,visit:I};j.add(O.command.requestId),P=O,await te(O);return}let S={freshStart:!0,command:me.parse({operation:"entry_start",entryId:e.id,funnelId:e.funnelId,versionId:e.versionId,release:n.appManifestRelease,requestId:crypto.randomUUID(),locale:document.documentElement.lang||"en"}),epoch:M,visit:I,target:e.target,storageKey:a?.key};j.add(S.command.requestId),P=S,await te(S)}async function te(e){if(e.dispatching)return;e.dispatching=!0;let a=e.freshStart===!0;e.freshStart=!1;let f,S=!1,O=!1;async function $(T){if(e.epoch!==M)return;let v=T.view;if(!(e.storageKey&&v&&(we(v)||v.paywall||v.pendingRequest))&&v&&["running","waiting"].includes(v.status))try{await T.submit({operation:"close",requestId:crypto.randomUUID(),nodeId:v.nodeId,visit:v.visit,revision:v.revision}),X(e)}catch(x){if(!(x instanceof H&&x.code==="FORBIDDEN"))throw x}}try{re(e),u("starting",e.command.entryId);let T=await k.request("funnels",e.command),v=Ge.safeParse(T);if(v.success){if(v.data.scope.projectId!==m.projectId||v.data.scope.environment!==m.environment)throw new H("SCOPE_MISMATCH","Entry scope changed");e.epoch===M&&u(v.data.reason,e.command.entryId),X(e),b(e);return}let x=Ve.parse(T);if(!x.runToken||x.scope.projectId!==m.projectId||x.scope.environment!==m.environment||x.run.source.type!=="funnel"||x.run.source.id!==e.command.funnelId||x.run.source.versionId!==e.command.versionId||e.runId!==void 0&&x.run.id!==e.runId)throw new H("INVALID_RESPONSE","Invalid entry Run");if(e.epoch!==M){b(e),u("identity_changed",e.command.entryId);return}re(e,x.run);let C=Re({...n,runToken:x.runToken,funnelId:e.command.funnelId,initialResponse:a?T:void 0});f=C,O=!0,await C.get(),O=!1;let Y=C.view;if(!Y||Y.id!==x.run.id||Y.source.type!=="funnel"||Y.source.id!==e.command.funnelId||Y.source.versionId!==e.command.versionId)throw new H("INVALID_RESPONSE","Entry Run version changed");if(!["running","waiting"].includes(Y.status)){X(e),b(e),u("run_ended",e.command.entryId);return}if(!ne(e)){await $(C),u("left_screen",e.command.entryId),b(e);return}let se=!1,Ae=!1;if(o&&!o.background){await $(C),u("in_progress",e.command.entryId),b(e);return}o&&ee();let Q=document.createElement("div");Q.hidden=we(Y),n.container.append(Q);let Ce=await Ie(Q,{...n.host,client:C,appManifestRelease:n.appManifestRelease,onState(B){t(C,B),Z(n.host?.onState,B)},onDismiss(B){se=!0,Q.remove(),B&&!["running","waiting"].includes(B.status)&&X(e),o?.client===C&&(o=void 0,C.reset(),q(),B&&B.status!=="completed"&&u("run_ended",e.command.entryId)),Z(n.host?.onDismiss,B)},onComplete(B){Ae=!0,X(e),o?.client===C&&ee(),Z(n.host?.onComplete,B)},onError(B){Z(n.host?.onError,B),o?.client===C&&B instanceof H&&B.code==="FORBIDDEN"&&(X(e),ee(),u("run_ended",e.command.entryId))}}).catch(B=>{throw Q.remove(),B});if(!ne(e)||se||Ae){Ce.destroy(),Q.remove(),ne(e)||await $(C),b(e);return}let le=we(C.view??Y);Q.hidden=le,o={host:Ce,client:C,slot:Q,entryId:e.command.entryId,background:le,runToken:x.runToken,owner:n.session.peek(),recovery:e},le||(N=e.visit),S=!0,b(e),u("started",e.command.entryId),le&&u("run_background",e.command.entryId)}catch(T){T instanceof H&&(!f||O&&T.code==="FORBIDDEN")&&T.status!==void 0&&T.status>=400&&T.status<500&&!T.retryable&&(X(e),b(e)),e.epoch===M&&!r&&(u("start_failed",e.command.entryId),Z(n.host?.onError,T))}finally{S||f?.reset(),e.dispatching=!1}}function ae(e){if(e.command.release!==n.appManifestRelease||e.target.release!==n.appManifestRelease)return!1;try{return ce(e.target.render,document,location.pathname,()=>{})}catch{return!1}}function W(){if(de())return!1;let e=D.load();for(let a of e?.entries??[]){if(a.expiresAt&&Date.parse(a.expiresAt)<=Date.now()){D.forget(e.key,a.command.requestId);continue}if(a.command.requestId===o?.recovery.command.requestId||j.has(a.command.requestId)||!ae(a))continue;j.add(a.command.requestId);let f={...a,storageKey:e.key,epoch:M,visit:I};return P=f,te(f),!0}return!1}function ue(){if(c=!1,r||!i||document.visibilityState==="hidden")return;ie();let e=o!==void 0&&!o.background;if(e&&(N=I),!W()){if(!L()){p=!0;return}p=!1;for(let a of E?.entries??[]){let f=`${a.funnelId}:${a.id}`;if(!(a.event!=="screen_enter"||V.has(f)||!G(a))){if(!n.session.peek()){u("identity_required",a.id);continue}if(N===I){V.add(f),e&&u("in_progress",a.id);continue}if(P){u("in_progress",a.id);return}V.add(f),oe(a);break}}}}let q=()=>{!c&&!r&&(c=!0,queueMicrotask(ue))};function ie(){let e=location.origin+location.pathname;return e===U?!1:(U=e,I++,p=!0,V.clear(),j.clear(),!0)}function Je(){ie()&&q()}function Se(e){if(!e.isTrusted||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||document.visibilityState==="hidden")return;let a=e.target;if(!(a instanceof Element)||a.closest("[data-indiana-funnel]"))return;let f=a.closest("button,a,input");if(!(!f||f.matches(":disabled,[aria-disabled='true']")||f.closest("[hidden],[inert],[aria-hidden='true']")))for(let S of E?.entries??[]){let O=S.target.button;if(!(S.event!=="button_click"||!O||!G(S))){try{let $=ge(document);if(!f.matches(O.selector)||$(O.selector,f)!==1)continue}catch{u("incompatible",S.id);continue}oe(S);break}}}async function _e(){if(r)return;if(s)return s;let e=++g,a=new AbortController;w=a;let f,S=new Promise((T,v)=>{f=()=>v(new H("TIMEOUT","Funnel entry configuration read cancelled or timed out")),a.signal.addEventListener("abort",f,{once:!0})}),O=setTimeout(()=>a.abort(),n.timeoutMs??5e3),$=(async()=>{let T=async()=>{let se=await _(`${A}/api/v1/funnel-entries/${n.environmentId}?iam=${n.appManifestRelease}`,{credentials:"omit",cache:"no-store",redirect:"error",signal:a.signal});if(!se.ok)throw new H("SERVICE_UNAVAILABLE","Funnel entries unavailable",se.status);return fe.parse(await se.json())},v=await Promise.race([T(),S]),x=Date.parse(v.validatedAt),C=Date.parse(v.validUntil);if(v.scope.projectId!==m.projectId||v.scope.environment!==m.environment||v.scope.environmentId!==n.environmentId||v.release!==n.appManifestRelease||C<=Date.now()||x>Date.now()+5e3||C-x>6e4||C<=x)throw new H("INVALID_RESPONSE","Entry configuration scope or deadline changed");if(r||e!==g)return;let Y=E===void 0;E=v,z=C,J=performance.now()+Math.min(C-Date.now(),6e4),(Y||p)&&q()})();s=$;try{await $}finally{clearTimeout(O),a.signal.removeEventListener("abort",f),s===$&&(s=void 0)}}async function Xe(){if(!(!i||r)){try{await _e()}catch{r||u("configuration_unavailable")}q()}}let Pe=pe({document,run:Xe,delay:()=>i&&!r?15e3:void 0});return{async start(){i||r||(i=!0,U=location.origin+location.pathname,h=he(Je),d=n.session.subscribeIdentity(()=>{M++,p=!0,P=void 0,V.clear(),N=-1,j.clear(),o&&R(o,o.owner,!1),ee(),q()}),l=new MutationObserver(q),l.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["hidden","inert","aria-hidden","data-indiana-id","id","style","data-testid","data-test","data-qa"]}),document.addEventListener("click",Se,!0),addEventListener("pagehide",F),await Pe.refresh())},refresh:_e,async retry(){P&&!r&&P.epoch===M&&await te(P)},destroy(){r=!0,g++,Pe.destroy(),w?.abort(),l?.disconnect(),h?.(),d?.(),document.removeEventListener("click",Se,!0),removeEventListener("pagehide",F),F(),ee(),k.dispose(),E=void 0}}}function hn(n){let A=ye(n.baseUrl),m=n.fetch??globalThis.fetch.bind(globalThis),k,_=0,E=0,r=!1,i=!1,g=0,I=0,U=-1,M=!1,z="",J,c,s,p,w=new Set,h,d,l,o=(t,R)=>Z(n.onStatus,t,R),N=()=>Date.now()<_&&performance.now()<E;function P(t){try{return N()&&t.target.release===n.appManifestRelease&&ce(t.target.render,document,location.pathname,()=>{})}catch{return o("incompatible",t.id),!1}}function b(){let t=l;l=void 0,t?.host.destroy(),t?.slot.remove()}async function V(t){if(t.dispatching)return;t.dispatching=!0;let R=g;try{let F=await t.process.open({operation:"entry_start",funnelId:t.entry.funnelId,versionId:t.entry.versionId,entryId:t.entry.id,release:n.appManifestRelease,locale:n.locale??"en"});if(r||R!==g||d!==t)return;let L=document.createElement("div");n.container.append(L),U=I;let G=await Ie(L,{...n.host,client:F.controller,appManifestRelease:n.appManifestRelease,onDismiss(ne){l?.process===t.process&&(l=void 0,L.remove()),Z(n.host?.onDismiss,ne)}});if(r||R!==g||d!==t){G.destroy(),L.remove();return}l={entry:t.entry,process:t.process,host:G,slot:L},d=void 0,o("run_presented",t.entry.id)}catch(F){if(r||R!==g||d!==t)return;F instanceof H&&"result"in F?(d=void 0,t.process.destroy(),o("suppressed",t.entry.id),j()):o("entry_unavailable",t.entry.id)}finally{t.dispatching=!1}}function u(t){if(r||d||l||h||U===I||!P(t))return;let R=`${I}:${t.id}`;if(w.has(R))return;w.add(R);let F={entry:t,process:n.createProcess(t),visit:I};d=F,V(F)}function j(){M||r||(M=!0,queueMicrotask(()=>{if(M=!1,!(r||document.visibilityState==="hidden"||!N()||d||l||h||U===I)){for(let t of k?.entries??[])if(t.event==="screen_enter"&&P(t)){u(t);break}}}))}function D(t){if(!t.isTrusted||t.defaultPrevented||!(t.target instanceof Element)||d||l||h||U===I)return;let R=ge(document,()=>{});for(let F of k?.entries??[]){let L=F.target.button;if(F.event!=="button_click"||!L||!P(F))continue;let G=t.target.closest(L.selector);if(!(!G||G.tagName.toLowerCase()!==L.tag||R(L.selector)!==1||G.matches(":disabled")||G.closest('[inert],[hidden],[aria-hidden="true"]'))){u(F);break}}}let X=()=>{let t=location.origin+location.pathname;t!==z&&(z=t,I++,w.clear(),j())};async function re(){if(r)return;if(c)return c;let t=g,R=new AbortController;J=R;let F,L=new Promise((te,ae)=>{F=ae}),G=()=>F(new H("TIMEOUT","Funnel entry read cancelled"));R.signal.addEventListener("abort",G,{once:!0});let ne=setTimeout(()=>R.abort(),n.timeoutMs??5e3),oe=(async()=>{let te=encodeURIComponent(JSON.stringify(["funnel-process/1"])),ae=async()=>{let ie=await m(`${A}/api/v1/funnel-entries/${n.environmentId}?iam=${n.appManifestRelease}&executionContracts=${te}`,{credentials:"omit",cache:"no-store",redirect:"error",signal:R.signal});if(!ie.ok)throw new H("SERVICE_UNAVAILABLE","Funnel entries unavailable",ie.status);return fe.parse(await ie.json())},W=await Promise.race([ae(),L]),ue=Date.parse(W.validatedAt),q=Date.parse(W.validUntil);if(W.scope.projectId!==n.scope.projectId||W.scope.environment!==n.scope.environment||W.scope.environmentId!==n.environmentId||W.release!==n.appManifestRelease||q<=Date.now()||ue>Date.now()+5e3||q<=ue||q-ue>6e4)throw new H("INVALID_RESPONSE","Entry scope or deadline changed");r||t!==g||(k=W,_=q,E=performance.now()+Math.min(q-Date.now(),6e4),j())})();c=oe;try{await oe}finally{clearTimeout(ne),R.signal.removeEventListener("abort",G),c===oe&&(c=void 0)}}async function ee(){if(!(!i||r))try{await re()}catch{r||o("configuration_unavailable")}}let de=pe({document,run:ee,delay:()=>i&&!r?15e3:void 0});return{async start(){i||r||(i=!0,z=location.origin+location.pathname,s=he(X),p=new MutationObserver(j),p.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["hidden","inert","aria-hidden","data-indiana-id","id","style","data-testid","data-test","data-qa"]}),document.addEventListener("click",D,!0),await de.refresh())},refresh:re,async retry(){d&&!r&&await V(d)},async syncIdentity(){let t=l??d??h;if(t)try{let R=await t.process.syncIdentity();return h===t&&(d={entry:t.entry,process:t.process,visit:I},h=void 0,await V(d)),R}catch(R){throw t.process.view||(h={entry:t.entry,process:t.process,visit:I},d=void 0,b()),R}},async detach(){g++,J?.abort();let t=l??d??h;t&&(h={entry:t.entry,process:t.process,visit:I}),d=void 0,b(),t&&await t.process.detach()},destroy(){r=!0,g++,de.destroy(),J?.abort(),p?.disconnect(),s?.(),document.removeEventListener("click",D,!0);let t=l??d??h;d=void 0,h=void 0,b(),t?.process.destroy(),k=void 0}}}async function zn(n,A){return(await import("./paywall-BEFHTZW7.js")).showPaywall(n,A)}async function Jn(...n){return n[1]=qe(n[1]),(await import("./paywall-session-YVGZPSFM.js")).createPaywallSession(...n)}async function Xn(...n){let A=n[1].signal?.aborted?void 0:Ue(n[1].client);try{let[m]=await Promise.all([import("./funnel-runtime-host-ITKTYBDS.js"),import("./screen-renderer-ITUUNF4E.js"),import("./paywall-BEFHTZW7.js")]);return await m.showFunnelRun(...n)}finally{A?.()}}async function Yn(...n){return(await import("./funnel-host-purchase-7BRXGIJX.js")).showFunnelPurchase(...n)}async function Zn(...n){return(await import("./content-S5MXIR7Y.js")).mountContent(...n)}async function Wn(...n){return(await import("./content-S5MXIR7Y.js")).prepareContent(...n)}export{H as LongplayError,y as MerchantBridgeError,nn as createBrowserFunnelCommandStorage,cn as createBrowserFunnelPurchaseStorage,on as createConfigurationSync,Qe as createFeatureClient,sn as createFunnelClient,fn as createFunnelPageExperiments,un as createFunnelProcess,dn as createFunnelPurchaseClient,Re as createFunnelRunController,yn as createIamFunnelEntries,hn as createIamFunnelProcessEntries,ln as createLocalFunnelClient,en as createLongplay,pn as createMerchantBridge,Jn as createPaywallSession,an as evaluateFunnelNode,Ze as formatCouponDiscount,Ye as formatCouponMoney,We as formatCouponTerms,tn as getPaywallRecovery,Zn as mountContent,Wn as prepareContent,rn as preparePaywallFallback,Yn as showFunnelPurchase,Xn as showFunnelRun,zn as showPaywall};
|
|
1
|
+
import{a as cn,c as dn}from"./chunk-YEXRETKV.js";import{a as Ue,b as fn,c as Ie}from"./chunk-PI25NLDV.js";import{f as pe}from"./chunk-UWYL2QCF.js";import"./chunk-RBMOWJGE.js";import{a as en,c as sn,d as un}from"./chunk-D3UU546S.js";import"./chunk-2TPPGW7V.js";import{a as an}from"./chunk-NH5ML5SB.js";import"./chunk-TMZGZAWM.js";import{h as Qe,i as on,k as ln}from"./chunk-2QQZSMTB.js";import"./chunk-23WNEOK4.js";import"./chunk-JNSU2AP2.js";import{F as Re,e as Ve,g as je,h as fe,i as me,j as Ge,x as nn}from"./chunk-7Z7JT4HE.js";import{a as qe}from"./chunk-WK4WQZHK.js";import"./chunk-QPHT6QHE.js";import"./chunk-4ZVVG5LM.js";import{B as Fe,D as Oe,E as xe,G as De,H as Te,I as ke,J as Be,K as Ee,L as He,x as ve,y as Me,z as Ne}from"./chunk-LZV4QJ5E.js";import{$ as Le,l as Ye,m as Ze,n as We}from"./chunk-ITVSLSRM.js";import"./chunk-SJSCROSL.js";import{c as tn,d as rn}from"./chunk-B3KFE57L.js";import"./chunk-ACFQLHJR.js";import{b as be}from"./chunk-XZEGVBAI.js";import"./chunk-J4VTKRH7.js";import"./chunk-WRUW2UIJ.js";import"./chunk-FJGJQGYF.js";import{a as H}from"./chunk-HJLGRW4A.js";import"./chunk-XIP32WI7.js";import{a as ge,c as ce}from"./chunk-J6KIN4RH.js";import"./chunk-SLUA7ABW.js";import{c as ye,d as he}from"./chunk-ZYTT7ZAB.js";import"./chunk-3VUPVXAV.js";import"./chunk-FVGUBIVT.js";import{b as K}from"./chunk-ZY4XAKNQ.js";import{a as Z}from"./chunk-DSPLGTQI.js";import"./chunk-6BTJNSQQ.js";import"./chunk-PWXN3W4Q.js";import"./chunk-WOT6VMZA.js";var y=class extends Error{constructor(m,k=0,_=!1,E="fix_request"){super(m);this.code=m;this.status=k;this.retryable=_;this.recovery=E;this.name="MerchantBridgeError"}code;status;retryable;recovery};async function mn(n,A){if(!n.headers.get("content-type")?.split(";",1)[0].trim().match(/^application\/(?:json|[a-z0-9.+-]+\+json)$/i))throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE");let m=n.body?.getReader();if(!m)throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE");let k=()=>{m.cancel().catch(()=>{})};A.addEventListener("abort",k,{once:!0});let _=0,E="",r=new TextDecoder("utf-8",{fatal:!0});try{for(A.throwIfAborted();;){let i=await m.read();if(A.throwIfAborted(),i.done)break;if(_+=i.value.byteLength,_>262144)throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE");E+=r.decode(i.value,{stream:!0})}return E+=r.decode(),JSON.parse(E)}catch(i){throw A.throwIfAborted(),i instanceof y?i:new y("MERCHANT_BRIDGE_INVALID_RESPONSE")}finally{A.removeEventListener("abort",k),await m.cancel().catch(()=>{}),m.releaseLock()}}function pn(n){let A=Oe.parse(n.origin),m=xe.parse(n.manifest),k={projectId:n.scope.projectId,environmentId:n.scope.environmentId,environment:n.scope.environment};for(let c of["projectId","environmentId","environment"])if(m[c]!==n.scope[c])throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");let _=n.customerId===void 0?null:K.uuid().parse(n.customerId),E=0,r=null,i=null,g=new AbortController,I=n.fetch??globalThis.fetch;async function U(c,s,p,w,h){if(!m.capabilities.includes(c))throw new y("MERCHANT_BRIDGE_CAPABILITY_UNSUPPORTED",501);let d=Fe[c];if(["merchant_catalog_reader","merchant_refund_authority","indiana_server_key"].includes(d.authority))throw new y("MERCHANT_BRIDGE_FORBIDDEN",403);let l=E,o=AbortSignal.any([g.signal,AbortSignal.timeout(Math.min(3e4,Math.max(1e3,n.timeoutMs??1e4))),...n.signal?[n.signal]:[],...w?[w]:[]]);o.throwIfAborted();let N=new Headers(await n.headers?.());if(o.throwIfAborted(),l!==E)throw new DOMException("Merchant identity changed","AbortError");if(/\bgg_(?:sk|ct|rt)_/.test(N.get("authorization")??"")||N.has("X-Indiana-Bridge-Signature")||N.has("X-Indiana-Bridge-Key-Id"))throw new y("MERCHANT_BRIDGE_FORBIDDEN",403);N.set(Ne,String(ve)),N.set("Accept","application/json");let P=crypto.randomUUID();N.set("X-Request-Id",P),N.set("Content-Type","application/json");let b=await I(A+Me,{method:"POST",credentials:"include",redirect:"error",cache:"no-store",headers:N,signal:o,body:JSON.stringify({bridgeVersion:ve,requestId:P,command:d.command,scope:k,data:h??(p===void 0?{}:{operationId:p})})}),V=await mn(b,o);if(o.throwIfAborted(),l!==E)throw new DOMException("Merchant identity changed","AbortError");if(!b.ok){let D=He.safeParse(V);throw!D.success||D.data.scope.projectId!==n.scope.projectId||D.data.scope.environment!==n.scope.environment||D.data.scope.environmentId!==n.scope.environmentId||D.data.requestId!==P||D.data.command!==d.command?new y("MERCHANT_BRIDGE_INVALID_RESPONSE",b.status):new y(D.data.error.code,b.status,D.data.error.retryable,D.data.error.recovery)}let u=De(K.unknown()).safeParse(V);if(!u.success||u.data.scope.projectId!==n.scope.projectId||u.data.scope.environment!==n.scope.environment||u.data.scope.environmentId!==n.scope.environmentId||u.data.requestId!==P||u.data.command!==d.command)throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE",b.status);let j=s.safeParse(u.data.data);if(!j.success)throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE",b.status);return j.data}function M(){if(!_)throw new y("MERCHANT_BRIDGE_UNAUTHENTICATED",401);return _}async function z(c,s,p,w){let h=M();if(w!==void 0&&Ee.parse({operationId:w,customerId:h}),!m.capabilities.includes(c))throw new y("MERCHANT_BRIDGE_CAPABILITY_UNSUPPORTED",501);let d=E,l=AbortSignal.any([g.signal,AbortSignal.timeout(Math.min(3e4,Math.max(1e3,n.timeoutMs??1e4))),...n.signal?[n.signal]:[],...s?[s]:[]]);l.throwIfAborted();let o,N=new Promise((P,b)=>{o=()=>b(l.reason),l.addEventListener("abort",o,{once:!0})});try{let b=p(async()=>{let u=await import("./merchant-bridge-contracts-LJKL7PNJ.js");if(l.throwIfAborted(),d!==E||_!==h)throw new DOMException("Merchant identity changed","AbortError");return u},l),V=await Promise.race([b,N]);return l.throwIfAborted(),V}finally{l.removeEventListener("abort",o)}}async function J(c,s,p,w){let h=M(),d=Ee.parse({operationId:p,customerId:h}),l=await U(c,s,d.operationId,w,d);if(l.customerId!==h||l.operationId!==d.operationId)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");return l}return{async readPresentation(c){let s=await U("presentation",ke,void 0,c);if(i!==null&&i!==s.nativeUserId)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(s.presentation&&_!==null&&s.presentation.customerId!==_)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");return i=s.nativeUserId,r=s.presentation,s},async createSession(c){let s=await U("session",Te,void 0,c);if(i!==null&&i!==s.nativeUserId)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(_!==null&&_!==s.session.customerId)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");if(r&&r.customerId!==s.session.customerId)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");return _=s.session.customerId,i=s.nativeUserId,s.session},async reportPresentation(c,s){let p=M(),w=Be.parse(c);if(!r||r.customerId!==p||r.decisionId!==w.decisionId)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");return U("presentation_events",K.strictObject({queued:K.literal(!0)}),void 0,s,w)},async readCustomerCommerce(c){let s=M(),p=await z("customer_commerce",c,async(w,h)=>{let[d,l]=await Promise.all([w(),U("customer_commerce",K.unknown(),void 0,h)]),o=d.merchantBridgeCommerceSchema.safeParse(l);if(!o.success)throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE");return o.data});if(p.customerId!==s)throw new y("MERCHANT_BRIDGE_SCOPE_MISMATCH");return p},async executePurchase(c,s){let p=await z("purchases",s,async(w,h)=>J("purchases",(await w()).merchantBridgeOperationSchema,c,h),c);if(p.type!=="purchase")throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE");return p},readOperation:(c,s)=>z("operation_status",s,async(p,w)=>J("operation_status",(await p()).merchantOperationLookupSchema,c,w),c),async executeSubscriptionChange(c,s){let p=await z("subscription_changes",s,async(w,h)=>J("subscription_changes",(await w()).merchantBridgeOperationSchema,c,h),c);if(p.type!=="subscription_change")throw new y("MERCHANT_BRIDGE_INVALID_RESPONSE");return p},reset(){E++,g.abort(),g=new AbortController,_=null,r=null,i=null}}}var $e=K.strictObject({command:me,target:je,runId:K.uuid().optional(),expiresAt:K.iso.datetime({offset:!0}).optional()}).refine(n=>n.command.release===n.target.release),Ke=K.strictObject({schemaVersion:K.literal(1),entries:K.array($e).max(4e3)});function ze(n){let A=!1,m=()=>{A||n.unavailable(),A=!0};function k(){return n.storage===!1?void 0:n.storage??globalThis.sessionStorage}function _(r){let i=k()?.getItem(r);if(!i)return[];if(i.length>1048576)throw Error("Entry recovery is too large");return Ke.parse(JSON.parse(i)).entries}function E(r,i){let g=k();if(!g)return;if(!i.length)return g.removeItem(r);let I=JSON.stringify(Ke.parse({schemaVersion:1,entries:i}));if(I.length>1048576)throw Error("Entry recovery is too large");g.setItem(r,I)}return{load(){try{let r=n.binding();if(!r||n.storage===!1)return;let i="indiana.funnel.entries.v1."+JSON.stringify(r);return{key:i,entries:_(i)}}catch{m();return}},retain(r,i){if(r)try{let g=$e.parse(i);E(r,[..._(r).filter(I=>I.command.funnelId!==g.command.funnelId),g])}catch{m()}},forget(r,i){if(r)try{E(r,_(r).filter(g=>g.command.requestId!==i))}catch{m()}}}}var we=n=>["running","waiting"].includes(n.status)&&!n.pendingRequest&&(n.stopped||!n.screen&&!n.paywall&&n.instruction?.type==="wait"&&n.instruction.kind!=="operation");function yn(n){let A=ye(n.baseUrl),m=n.scope,k=be(n),_=n.fetch??globalThis.fetch.bind(globalThis),E,r=!1,i=!1,g=0,I=0,U="",M=0,z=0,J=0,c=!1,s,p=!0,w,h,d,l,o,N=-1,P,b=e=>{P===e&&(P=void 0,q())},V=new Set,u=(e,a)=>Z(n.onStatus,e,a),j=new Set,D=ze({storage:n.recoveryStorage,binding:()=>{let e=n.session.snapshot()?.customerId;return e?[A,m.projectId,m.environment,n.environmentId,n.appManifestRelease,e]:void 0},unavailable:()=>u("recovery_unavailable")}),X=e=>D.forget(e.storageKey,e.command.requestId);function re(e,a){a&&(e.runId=a.id,e.expiresAt=a.runExpiresAt),D.retain(e.storageKey,{command:e.command,target:e.target,...e.runId&&{runId:e.runId},...e.expiresAt&&{expiresAt:e.expiresAt}})}function ee(){let e=o;o=void 0,e?.host.destroy(),e?.slot.remove(),e?.client.reset(),q()}let de=()=>P!==void 0||o!==void 0&&!o.background;function t(e,a){if(o?.client!==e)return;re(o.recovery,a);let f=we(a);o.slot.hidden=f,f!==o.background&&(o.background=f,f?u("run_background",o.entryId):N=I,q())}function R(e,a,f){let S=e.client.view;if(!a||e.background||!S?.screen||S.paywall||S.pendingRequest||S.stopped||S.status!=="waiting")return;let O=Le.parse({operation:"close",requestId:crypto.randomUUID(),nodeId:S.nodeId,visit:S.visit,revision:S.revision,customerToken:a}),$=be({...n,session:void 0});$.requestWithCredential("funnels",O,e.runToken,{keepalive:f}).then(()=>X(e.recovery)).catch(()=>{}).finally(()=>$.dispose())}let F=()=>{o&&R(o,n.session.peek(),!0)},L=()=>Date.now()<z&&performance.now()<J;function G(e){if(e.target.release!==n.appManifestRelease||!L())return!1;try{return ce(e.target.render,document,location.pathname,()=>{})}catch{return u("incompatible",e.id),!1}}function ne(e){if(r||e.epoch!==M||e.visit!==I||document.visibilityState==="hidden")return!1;try{return ce(e.target.render,document,location.pathname,()=>{})}catch{return!1}}async function oe(e){if(de()){u("in_progress",e.id);return}if(!n.session.peek()){u("identity_required",e.id);return}let a=D.load(),f=a?.entries.find(O=>O.command.funnelId===e.funnelId&&(!O.expiresAt||Date.parse(O.expiresAt)>Date.now()));if(f){if(!ae(f)){u("recovery_pending",e.id);return}let O={...f,storageKey:a.key,epoch:M,visit:I};j.add(O.command.requestId),P=O,await te(O);return}let S={freshStart:!0,command:me.parse({operation:"entry_start",entryId:e.id,funnelId:e.funnelId,versionId:e.versionId,release:n.appManifestRelease,requestId:crypto.randomUUID(),locale:document.documentElement.lang||"en"}),epoch:M,visit:I,target:e.target,storageKey:a?.key};j.add(S.command.requestId),P=S,await te(S)}async function te(e){if(e.dispatching)return;e.dispatching=!0;let a=e.freshStart===!0;e.freshStart=!1;let f,S=!1,O=!1;async function $(T){if(e.epoch!==M)return;let v=T.view;if(!(e.storageKey&&v&&(we(v)||v.paywall||v.pendingRequest))&&v&&["running","waiting"].includes(v.status))try{await T.submit({operation:"close",requestId:crypto.randomUUID(),nodeId:v.nodeId,visit:v.visit,revision:v.revision}),X(e)}catch(x){if(!(x instanceof H&&x.code==="FORBIDDEN"))throw x}}try{re(e),u("starting",e.command.entryId);let T=await k.request("funnels",e.command),v=Ge.safeParse(T);if(v.success){if(v.data.scope.projectId!==m.projectId||v.data.scope.environment!==m.environment)throw new H("SCOPE_MISMATCH","Entry scope changed");e.epoch===M&&u(v.data.reason,e.command.entryId),X(e),b(e);return}let x=Ve.parse(T);if(!x.runToken||x.scope.projectId!==m.projectId||x.scope.environment!==m.environment||x.run.source.type!=="funnel"||x.run.source.id!==e.command.funnelId||x.run.source.versionId!==e.command.versionId||e.runId!==void 0&&x.run.id!==e.runId)throw new H("INVALID_RESPONSE","Invalid entry Run");if(e.epoch!==M){b(e),u("identity_changed",e.command.entryId);return}re(e,x.run);let C=Re({...n,runToken:x.runToken,funnelId:e.command.funnelId,initialResponse:a?T:void 0});f=C,O=!0,await C.get(),O=!1;let Y=C.view;if(!Y||Y.id!==x.run.id||Y.source.type!=="funnel"||Y.source.id!==e.command.funnelId||Y.source.versionId!==e.command.versionId)throw new H("INVALID_RESPONSE","Entry Run version changed");if(!["running","waiting"].includes(Y.status)){X(e),b(e),u("run_ended",e.command.entryId);return}if(!ne(e)){await $(C),u("left_screen",e.command.entryId),b(e);return}let se=!1,Ae=!1;if(o&&!o.background){await $(C),u("in_progress",e.command.entryId),b(e);return}o&&ee();let Q=document.createElement("div");Q.hidden=we(Y),n.container.append(Q);let Ce=await Ie(Q,{...n.host,client:C,appManifestRelease:n.appManifestRelease,onState(B){t(C,B),Z(n.host?.onState,B)},onDismiss(B){se=!0,Q.remove(),B&&!["running","waiting"].includes(B.status)&&X(e),o?.client===C&&(o=void 0,C.reset(),q(),B&&B.status!=="completed"&&u("run_ended",e.command.entryId)),Z(n.host?.onDismiss,B)},onComplete(B){Ae=!0,X(e),o?.client===C&&ee(),Z(n.host?.onComplete,B)},onError(B){Z(n.host?.onError,B),o?.client===C&&B instanceof H&&B.code==="FORBIDDEN"&&(X(e),ee(),u("run_ended",e.command.entryId))}}).catch(B=>{throw Q.remove(),B});if(!ne(e)||se||Ae){Ce.destroy(),Q.remove(),ne(e)||await $(C),b(e);return}let le=we(C.view??Y);Q.hidden=le,o={host:Ce,client:C,slot:Q,entryId:e.command.entryId,background:le,runToken:x.runToken,owner:n.session.peek(),recovery:e},le||(N=e.visit),S=!0,b(e),u("started",e.command.entryId),le&&u("run_background",e.command.entryId)}catch(T){T instanceof H&&(!f||O&&T.code==="FORBIDDEN")&&T.status!==void 0&&T.status>=400&&T.status<500&&!T.retryable&&(X(e),b(e)),e.epoch===M&&!r&&(u("start_failed",e.command.entryId),Z(n.host?.onError,T))}finally{S||f?.reset(),e.dispatching=!1}}function ae(e){if(e.command.release!==n.appManifestRelease||e.target.release!==n.appManifestRelease)return!1;try{return ce(e.target.render,document,location.pathname,()=>{})}catch{return!1}}function W(){if(de())return!1;let e=D.load();for(let a of e?.entries??[]){if(a.expiresAt&&Date.parse(a.expiresAt)<=Date.now()){D.forget(e.key,a.command.requestId);continue}if(a.command.requestId===o?.recovery.command.requestId||j.has(a.command.requestId)||!ae(a))continue;j.add(a.command.requestId);let f={...a,storageKey:e.key,epoch:M,visit:I};return P=f,te(f),!0}return!1}function ue(){if(c=!1,r||!i||document.visibilityState==="hidden")return;ie();let e=o!==void 0&&!o.background;if(e&&(N=I),!W()){if(!L()){p=!0;return}p=!1;for(let a of E?.entries??[]){let f=`${a.funnelId}:${a.id}`;if(!(a.event!=="screen_enter"||V.has(f)||!G(a))){if(!n.session.peek()){u("identity_required",a.id);continue}if(N===I){V.add(f),e&&u("in_progress",a.id);continue}if(P){u("in_progress",a.id);return}V.add(f),oe(a);break}}}}let q=()=>{!c&&!r&&(c=!0,queueMicrotask(ue))};function ie(){let e=location.origin+location.pathname;return e===U?!1:(U=e,I++,p=!0,V.clear(),j.clear(),!0)}function Je(){ie()&&q()}function Se(e){if(!e.isTrusted||e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey||document.visibilityState==="hidden")return;let a=e.target;if(!(a instanceof Element)||a.closest("[data-indiana-funnel]"))return;let f=a.closest("button,a,input");if(!(!f||f.matches(":disabled,[aria-disabled='true']")||f.closest("[hidden],[inert],[aria-hidden='true']")))for(let S of E?.entries??[]){let O=S.target.button;if(!(S.event!=="button_click"||!O||!G(S))){try{let $=ge(document);if(!f.matches(O.selector)||$(O.selector,f)!==1)continue}catch{u("incompatible",S.id);continue}oe(S);break}}}async function _e(){if(r)return;if(s)return s;let e=++g,a=new AbortController;w=a;let f,S=new Promise((T,v)=>{f=()=>v(new H("TIMEOUT","Funnel entry configuration read cancelled or timed out")),a.signal.addEventListener("abort",f,{once:!0})}),O=setTimeout(()=>a.abort(),n.timeoutMs??5e3),$=(async()=>{let T=async()=>{let se=await _(`${A}/api/v1/funnel-entries/${n.environmentId}?iam=${n.appManifestRelease}`,{credentials:"omit",cache:"no-store",redirect:"error",signal:a.signal});if(!se.ok)throw new H("SERVICE_UNAVAILABLE","Funnel entries unavailable",se.status);return fe.parse(await se.json())},v=await Promise.race([T(),S]),x=Date.parse(v.validatedAt),C=Date.parse(v.validUntil);if(v.scope.projectId!==m.projectId||v.scope.environment!==m.environment||v.scope.environmentId!==n.environmentId||v.release!==n.appManifestRelease||C<=Date.now()||x>Date.now()+5e3||C-x>6e4||C<=x)throw new H("INVALID_RESPONSE","Entry configuration scope or deadline changed");if(r||e!==g)return;let Y=E===void 0;E=v,z=C,J=performance.now()+Math.min(C-Date.now(),6e4),(Y||p)&&q()})();s=$;try{await $}finally{clearTimeout(O),a.signal.removeEventListener("abort",f),s===$&&(s=void 0)}}async function Xe(){if(!(!i||r)){try{await _e()}catch{r||u("configuration_unavailable")}q()}}let Pe=pe({document,run:Xe,delay:()=>i&&!r?15e3:void 0});return{async start(){i||r||(i=!0,U=location.origin+location.pathname,h=he(Je),d=n.session.subscribeIdentity(()=>{M++,p=!0,P=void 0,V.clear(),N=-1,j.clear(),o&&R(o,o.owner,!1),ee(),q()}),l=new MutationObserver(q),l.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["hidden","inert","aria-hidden","data-indiana-id","id","style","data-testid","data-test","data-qa"]}),document.addEventListener("click",Se,!0),addEventListener("pagehide",F),await Pe.refresh())},refresh:_e,async retry(){P&&!r&&P.epoch===M&&await te(P)},destroy(){r=!0,g++,Pe.destroy(),w?.abort(),l?.disconnect(),h?.(),d?.(),document.removeEventListener("click",Se,!0),removeEventListener("pagehide",F),F(),ee(),k.dispose(),E=void 0}}}function hn(n){let A=ye(n.baseUrl),m=n.fetch??globalThis.fetch.bind(globalThis),k,_=0,E=0,r=!1,i=!1,g=0,I=0,U=-1,M=!1,z="",J,c,s,p,w=new Set,h,d,l,o=(t,R)=>Z(n.onStatus,t,R),N=()=>Date.now()<_&&performance.now()<E;function P(t){try{return N()&&t.target.release===n.appManifestRelease&&ce(t.target.render,document,location.pathname,()=>{})}catch{return o("incompatible",t.id),!1}}function b(){let t=l;l=void 0,t?.host.destroy(),t?.slot.remove()}async function V(t){if(t.dispatching)return;t.dispatching=!0;let R=g;try{let F=await t.process.open({operation:"entry_start",funnelId:t.entry.funnelId,versionId:t.entry.versionId,entryId:t.entry.id,release:n.appManifestRelease,locale:n.locale??"en"});if(r||R!==g||d!==t)return;let L=document.createElement("div");n.container.append(L),U=I;let G=await Ie(L,{...n.host,client:F.controller,appManifestRelease:n.appManifestRelease,onDismiss(ne){l?.process===t.process&&(l=void 0,L.remove()),Z(n.host?.onDismiss,ne)}});if(r||R!==g||d!==t){G.destroy(),L.remove();return}l={entry:t.entry,process:t.process,host:G,slot:L},d=void 0,o("run_presented",t.entry.id)}catch(F){if(r||R!==g||d!==t)return;F instanceof H&&"result"in F?(d=void 0,t.process.destroy(),o("suppressed",t.entry.id),j()):o("entry_unavailable",t.entry.id)}finally{t.dispatching=!1}}function u(t){if(r||d||l||h||U===I||!P(t))return;let R=`${I}:${t.id}`;if(w.has(R))return;w.add(R);let F={entry:t,process:n.createProcess(t),visit:I};d=F,V(F)}function j(){M||r||(M=!0,queueMicrotask(()=>{if(M=!1,!(r||document.visibilityState==="hidden"||!N()||d||l||h||U===I)){for(let t of k?.entries??[])if(t.event==="screen_enter"&&P(t)){u(t);break}}}))}function D(t){if(!t.isTrusted||t.defaultPrevented||!(t.target instanceof Element)||d||l||h||U===I)return;let R=ge(document,()=>{});for(let F of k?.entries??[]){let L=F.target.button;if(F.event!=="button_click"||!L||!P(F))continue;let G=t.target.closest(L.selector);if(!(!G||G.tagName.toLowerCase()!==L.tag||R(L.selector)!==1||G.matches(":disabled")||G.closest('[inert],[hidden],[aria-hidden="true"]'))){u(F);break}}}let X=()=>{let t=location.origin+location.pathname;t!==z&&(z=t,I++,w.clear(),j())};async function re(){if(r)return;if(c)return c;let t=g,R=new AbortController;J=R;let F,L=new Promise((te,ae)=>{F=ae}),G=()=>F(new H("TIMEOUT","Funnel entry read cancelled"));R.signal.addEventListener("abort",G,{once:!0});let ne=setTimeout(()=>R.abort(),n.timeoutMs??5e3),oe=(async()=>{let te=encodeURIComponent(JSON.stringify(["funnel-process/1"])),ae=async()=>{let ie=await m(`${A}/api/v1/funnel-entries/${n.environmentId}?iam=${n.appManifestRelease}&executionContracts=${te}`,{credentials:"omit",cache:"no-store",redirect:"error",signal:R.signal});if(!ie.ok)throw new H("SERVICE_UNAVAILABLE","Funnel entries unavailable",ie.status);return fe.parse(await ie.json())},W=await Promise.race([ae(),L]),ue=Date.parse(W.validatedAt),q=Date.parse(W.validUntil);if(W.scope.projectId!==n.scope.projectId||W.scope.environment!==n.scope.environment||W.scope.environmentId!==n.environmentId||W.release!==n.appManifestRelease||q<=Date.now()||ue>Date.now()+5e3||q<=ue||q-ue>6e4)throw new H("INVALID_RESPONSE","Entry scope or deadline changed");r||t!==g||(k=W,_=q,E=performance.now()+Math.min(q-Date.now(),6e4),j())})();c=oe;try{await oe}finally{clearTimeout(ne),R.signal.removeEventListener("abort",G),c===oe&&(c=void 0)}}async function ee(){if(!(!i||r))try{await re()}catch{r||o("configuration_unavailable")}}let de=pe({document,run:ee,delay:()=>i&&!r?15e3:void 0});return{async start(){i||r||(i=!0,z=location.origin+location.pathname,s=he(X),p=new MutationObserver(j),p.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["hidden","inert","aria-hidden","data-indiana-id","id","style","data-testid","data-test","data-qa"]}),document.addEventListener("click",D,!0),await de.refresh())},refresh:re,async retry(){d&&!r&&await V(d)},async syncIdentity(){let t=l??d??h;if(t)try{let R=await t.process.syncIdentity();return h===t&&(d={entry:t.entry,process:t.process,visit:I},h=void 0,await V(d)),R}catch(R){throw t.process.view||(h={entry:t.entry,process:t.process,visit:I},d=void 0,b()),R}},async detach(){g++,J?.abort();let t=l??d??h;t&&(h={entry:t.entry,process:t.process,visit:I}),d=void 0,b(),t&&await t.process.detach()},destroy(){r=!0,g++,de.destroy(),J?.abort(),p?.disconnect(),s?.(),document.removeEventListener("click",D,!0);let t=l??d??h;d=void 0,h=void 0,b(),t?.process.destroy(),k=void 0}}}async function zn(n,A){return(await import("./paywall-DI62MX5L.js")).showPaywall(n,A)}async function Jn(...n){return n[1]=qe(n[1]),(await import("./paywall-session-AW6R3PJB.js")).createPaywallSession(...n)}async function Xn(...n){let A=n[1].signal?.aborted?void 0:Ue(n[1].client);try{let[m]=await Promise.all([import("./funnel-runtime-host-CJTPLZ4N.js"),import("./screen-renderer-W5MP4KVG.js"),import("./paywall-DI62MX5L.js")]);return await m.showFunnelRun(...n)}finally{A?.()}}async function Yn(...n){return(await import("./funnel-host-purchase-IRFPNIZY.js")).showFunnelPurchase(...n)}async function Zn(...n){return(await import("./content-OY5MRXF5.js")).mountContent(...n)}async function Wn(...n){return(await import("./content-OY5MRXF5.js")).prepareContent(...n)}export{H as LongplayError,y as MerchantBridgeError,nn as createBrowserFunnelCommandStorage,cn as createBrowserFunnelPurchaseStorage,on as createConfigurationSync,Qe as createFeatureClient,sn as createFunnelClient,fn as createFunnelPageExperiments,un as createFunnelProcess,dn as createFunnelPurchaseClient,Re as createFunnelRunController,yn as createIamFunnelEntries,hn as createIamFunnelProcessEntries,ln as createLocalFunnelClient,en as createLongplay,pn as createMerchantBridge,Jn as createPaywallSession,an as evaluateFunnelNode,Ze as formatCouponDiscount,Ye as formatCouponMoney,We as formatCouponTerms,tn as getPaywallRecovery,Zn as mountContent,Wn as prepareContent,rn as preparePaywallFallback,Yn as showFunnelPurchase,Xn as showFunnelRun,zn as showPaywall};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{N as r,O as m,h as e}from"./chunk-LZV4QJ5E.js";import"./chunk-SJSCROSL.js";import"./chunk-J4VTKRH7.js";import"./chunk-FJGJQGYF.js";import"./chunk-XIP32WI7.js";import"./chunk-ZY4XAKNQ.js";import"./chunk-PWXN3W4Q.js";import"./chunk-WOT6VMZA.js";export{m as merchantBridgeCommerceSchema,r as merchantBridgeOperationSchema,e as merchantOperationLookupSchema};
|