@ensofinance/checkout-widget 0.1.5 → 0.1.6

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.
@@ -117,13 +117,13 @@ object-assign
117
117
  @license MIT
118
118
  */var zf,j_;function eB(){if(j_)return zf;j_=1;var t=Object.getOwnPropertySymbols,e=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function r(o){if(o==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(o)}function i(){try{if(!Object.assign)return!1;var o=new String("abc");if(o[5]="de",Object.getOwnPropertyNames(o)[0]==="5")return!1;for(var s={},a=0;a<10;a++)s["_"+String.fromCharCode(a)]=a;var l=Object.getOwnPropertyNames(s).map(function(u){return s[u]});if(l.join("")!=="0123456789")return!1;var c={};return"abcdefghijklmnopqrst".split("").forEach(function(u){c[u]=u}),Object.keys(Object.assign({},c)).join("")==="abcdefghijklmnopqrst"}catch(u){return!1}}return zf=i()?Object.assign:function(o,s){for(var a,l=r(o),c,u=1;u<arguments.length;u++){a=Object(arguments[u]);for(var h in a)e.call(a,h)&&(l[h]=a[h]);if(t){c=t(a);for(var p=0;p<c.length;p++)n.call(a,c[p])&&(l[c[p]]=a[c[p]])}}return l},zf}var Uf,q_;function Wf(){if(q_)return Uf;q_=1;var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Uf=t,Uf}var Hf,G_;function K_(){return G_||(G_=1,Hf=Function.call.bind(Object.prototype.hasOwnProperty)),Hf}var jf,Y_;function tB(){if(Y_)return jf;Y_=1;var t=function(){};if(process.env.NODE_ENV!=="production"){var e=Wf(),n={},r=K_();t=function(o){var s="Warning: "+o;typeof console!="undefined"&&console.error(s);try{throw new Error(s)}catch(a){}}}function i(o,s,a,l,c){if(process.env.NODE_ENV!=="production"){for(var u in o)if(r(o,u)){var h;try{if(typeof o[u]!="function"){var p=Error((l||"React class")+": "+a+" type `"+u+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof o[u]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw p.name="Invariant Violation",p}h=o[u](s,u,l,a,null,e)}catch(b){h=b}if(h&&!(h instanceof Error)&&t((l||"React class")+": type specification of "+a+" `"+u+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof h+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),h instanceof Error&&!(h.message in n)){n[h.message]=!0;var g=c?c():"";t("Failed "+a+" type: "+h.message+(g!=null?g:""))}}}}return i.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},jf=i,jf}var qf,X_;function nB(){if(X_)return qf;X_=1;var t=Qd(),e=eB(),n=Wf(),r=K_(),i=tB(),o=function(){};process.env.NODE_ENV!=="production"&&(o=function(a){var l="Warning: "+a;typeof console!="undefined"&&console.error(l);try{throw new Error(l)}catch(c){}});function s(){return null}return qf=function(a,l){var c=typeof Symbol=="function"&&Symbol.iterator,u="@@iterator";function h(L){var O=L&&(c&&L[c]||L[u]);if(typeof O=="function")return O}var p="<<anonymous>>",g={array:I("array"),bigint:I("bigint"),bool:I("boolean"),func:I("function"),number:I("number"),object:I("object"),string:I("string"),symbol:I("symbol"),any:N(),arrayOf:T,element:$(),elementType:B(),instanceOf:G,node:V(),objectOf:Y,oneOf:Z,oneOfType:F,shape:W,exact:A};function b(L,O){return L===O?L!==0||1/L===1/O:L!==L&&O!==O}function m(L,O){this.message=L,this.data=O&&typeof O=="object"?O:{},this.stack=""}m.prototype=Error.prototype;function x(L){if(process.env.NODE_ENV!=="production")var O={},f=0;function v(M,H,Q,X,j,ee,se){if(X=X||p,ee=ee||Q,se!==n){if(l){var re=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw re.name="Invariant Violation",re}else if(process.env.NODE_ENV!=="production"&&typeof console!="undefined"){var ve=X+":"+Q;!O[ve]&&f<3&&(o("You are manually calling a React.PropTypes validation function for the `"+ee+"` prop on `"+X+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),O[ve]=!0,f++)}}return H[Q]==null?M?H[Q]===null?new m("The "+j+" `"+ee+"` is marked as required "+("in `"+X+"`, but its value is `null`.")):new m("The "+j+" `"+ee+"` is marked as required in "+("`"+X+"`, but its value is `undefined`.")):null:L(H,Q,X,j,ee)}var k=v.bind(null,!1);return k.isRequired=v.bind(null,!0),k}function I(L){function O(f,v,k,M,H,Q){var X=f[v],j=S(X);if(j!==L){var ee=C(X);return new m("Invalid "+M+" `"+H+"` of type "+("`"+ee+"` supplied to `"+k+"`, expected ")+("`"+L+"`."),{expectedType:L})}return null}return x(O)}function N(){return x(s)}function T(L){function O(f,v,k,M,H){if(typeof L!="function")return new m("Property `"+H+"` of component `"+k+"` has invalid PropType notation inside arrayOf.");var Q=f[v];if(!Array.isArray(Q)){var X=S(Q);return new m("Invalid "+M+" `"+H+"` of type "+("`"+X+"` supplied to `"+k+"`, expected an array."))}for(var j=0;j<Q.length;j++){var ee=L(Q,j,k,M,H+"["+j+"]",n);if(ee instanceof Error)return ee}return null}return x(O)}function $(){function L(O,f,v,k,M){var H=O[f];if(!a(H)){var Q=S(H);return new m("Invalid "+k+" `"+M+"` of type "+("`"+Q+"` supplied to `"+v+"`, expected a single ReactElement."))}return null}return x(L)}function B(){function L(O,f,v,k,M){var H=O[f];if(!t.isValidElementType(H)){var Q=S(H);return new m("Invalid "+k+" `"+M+"` of type "+("`"+Q+"` supplied to `"+v+"`, expected a single ReactElement type."))}return null}return x(L)}function G(L){function O(f,v,k,M,H){if(!(f[v]instanceof L)){var Q=L.name||p,X=D(f[v]);return new m("Invalid "+M+" `"+H+"` of type "+("`"+X+"` supplied to `"+k+"`, expected ")+("instance of `"+Q+"`."))}return null}return x(O)}function Z(L){if(!Array.isArray(L))return process.env.NODE_ENV!=="production"&&(arguments.length>1?o("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):o("Invalid argument supplied to oneOf, expected an array.")),s;function O(f,v,k,M,H){for(var Q=f[v],X=0;X<L.length;X++)if(b(Q,L[X]))return null;var j=JSON.stringify(L,function(se,re){var ve=C(re);return ve==="symbol"?String(re):re});return new m("Invalid "+M+" `"+H+"` of value `"+String(Q)+"` "+("supplied to `"+k+"`, expected one of "+j+"."))}return x(O)}function Y(L){function O(f,v,k,M,H){if(typeof L!="function")return new m("Property `"+H+"` of component `"+k+"` has invalid PropType notation inside objectOf.");var Q=f[v],X=S(Q);if(X!=="object")return new m("Invalid "+M+" `"+H+"` of type "+("`"+X+"` supplied to `"+k+"`, expected an object."));for(var j in Q)if(r(Q,j)){var ee=L(Q,j,k,M,H+"."+j,n);if(ee instanceof Error)return ee}return null}return x(O)}function F(L){if(!Array.isArray(L))return process.env.NODE_ENV!=="production"&&o("Invalid argument supplied to oneOfType, expected an instance of array."),s;for(var O=0;O<L.length;O++){var f=L[O];if(typeof f!="function")return o("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+R(f)+" at index "+O+"."),s}function v(k,M,H,Q,X){for(var j=[],ee=0;ee<L.length;ee++){var se=L[ee],re=se(k,M,H,Q,X,n);if(re==null)return null;re.data&&r(re.data,"expectedType")&&j.push(re.data.expectedType)}var ve=j.length>0?", expected one of type ["+j.join(", ")+"]":"";return new m("Invalid "+Q+" `"+X+"` supplied to "+("`"+H+"`"+ve+"."))}return x(v)}function V(){function L(O,f,v,k,M){return d(O[f])?null:new m("Invalid "+k+" `"+M+"` supplied to "+("`"+v+"`, expected a ReactNode."))}return x(L)}function U(L,O,f,v,k){return new m((L||"React class")+": "+O+" type `"+f+"."+v+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+k+"`.")}function W(L){function O(f,v,k,M,H){var Q=f[v],X=S(Q);if(X!=="object")return new m("Invalid "+M+" `"+H+"` of type `"+X+"` "+("supplied to `"+k+"`, expected `object`."));for(var j in L){var ee=L[j];if(typeof ee!="function")return U(k,M,H,j,C(ee));var se=ee(Q,j,k,M,H+"."+j,n);if(se)return se}return null}return x(O)}function A(L){function O(f,v,k,M,H){var Q=f[v],X=S(Q);if(X!=="object")return new m("Invalid "+M+" `"+H+"` of type `"+X+"` "+("supplied to `"+k+"`, expected `object`."));var j=e({},f[v],L);for(var ee in j){var se=L[ee];if(r(L,ee)&&typeof se!="function")return U(k,M,H,ee,C(se));if(!se)return new m("Invalid "+M+" `"+H+"` key `"+ee+"` supplied to `"+k+"`.\nBad object: "+JSON.stringify(f[v],null," ")+`
119
119
  Valid keys: `+JSON.stringify(Object.keys(L),null," "));var re=se(Q,ee,k,M,H+"."+ee,n);if(re)return re}return null}return x(O)}function d(L){switch(typeof L){case"number":case"string":case"undefined":return!0;case"boolean":return!L;case"object":if(Array.isArray(L))return L.every(d);if(L===null||a(L))return!0;var O=h(L);if(O){var f=O.call(L),v;if(O!==L.entries){for(;!(v=f.next()).done;)if(!d(v.value))return!1}else for(;!(v=f.next()).done;){var k=v.value;if(k&&!d(k[1]))return!1}}else return!1;return!0;default:return!1}}function y(L,O){return L==="symbol"?!0:O?O["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&O instanceof Symbol:!1}function S(L){var O=typeof L;return Array.isArray(L)?"array":L instanceof RegExp?"object":y(O,L)?"symbol":O}function C(L){if(typeof L=="undefined"||L===null)return""+L;var O=S(L);if(O==="object"){if(L instanceof Date)return"date";if(L instanceof RegExp)return"regexp"}return O}function R(L){var O=C(L);switch(O){case"array":case"object":return"an "+O;case"boolean":case"date":case"regexp":return"a "+O;default:return O}}function D(L){return!L.constructor||!L.constructor.name?p:L.constructor.name}return g.checkPropTypes=i,g.resetWarningCache=i.resetWarningCache,g.PropTypes=g,g},qf}var Gf,Z_;function rB(){if(Z_)return Gf;Z_=1;var t=Wf();function e(){}function n(){}return n.resetWarningCache=e,Gf=function(){function r(s,a,l,c,u,h){if(h!==t){var p=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw p.name="Invariant Violation",p}}r.isRequired=r;function i(){return r}var o={array:r,bigint:r,bool:r,func:r,number:r,object:r,string:r,symbol:r,any:r,arrayOf:i,element:r,elementType:r,instanceOf:i,node:r,objectOf:i,oneOf:i,oneOfType:i,shape:i,exact:i,checkPropTypes:n,resetWarningCache:e};return o.PropTypes=o,o},Gf}var J_;function iB(){if(J_)return pu.exports;if(J_=1,process.env.NODE_ENV!=="production"){var t=Qd(),e=!0;pu.exports=nB()(t.isElement,e)}else pu.exports=rB()();return pu.exports}var Q_;function oB(){if(Q_)return gu;Q_=1,Object.defineProperty(gu,"__esModule",{value:!0});var t=K,e=J4,n=Q4,r=fa,i=xA,o=iB();function s(d){return d&&typeof d=="object"&&"default"in d?d:{default:d}}var a=s(t),l=s(n),c=s(o),u=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof t0!="undefined"?t0:typeof self!="undefined"?self:{};function h(d,y){return d(y={exports:{}},y.exports),y.exports}var p=h((function(d){(function(y){var S=function(ee,se,re){if(!f(se)||k(se)||M(se)||H(se)||O(se))return se;var ve,xe=0,Pe=0;if(v(se))for(ve=[],Pe=se.length;xe<Pe;xe++)ve.push(S(ee,se[xe],re));else for(var Et in ve={},se)Object.prototype.hasOwnProperty.call(se,Et)&&(ve[ee(Et,re)]=S(ee,se[Et],re));return ve},C=function(ee){return Q(ee)?ee:(ee=ee.replace(/[\-_\s]+(.)?/g,(function(se,re){return re?re.toUpperCase():""}))).substr(0,1).toLowerCase()+ee.substr(1)},R=function(ee){var se=C(ee);return se.substr(0,1).toUpperCase()+se.substr(1)},D=function(ee,se){return(function(re,ve){var xe=(ve=ve||{}).separator||"_",Pe=ve.split||/(?=[A-Z])/;return re.split(Pe).join(xe)})(ee,se).toLowerCase()},L=Object.prototype.toString,O=function(ee){return typeof ee=="function"},f=function(ee){return ee===Object(ee)},v=function(ee){return L.call(ee)=="[object Array]"},k=function(ee){return L.call(ee)=="[object Date]"},M=function(ee){return L.call(ee)=="[object RegExp]"},H=function(ee){return L.call(ee)=="[object Boolean]"},Q=function(ee){return(ee-=0)==ee},X=function(ee,se){var re=se&&"process"in se?se.process:se;return typeof re!="function"?ee:function(ve,xe){return re(ve,ee,xe)}},j={camelize:C,decamelize:D,pascalize:R,depascalize:D,camelizeKeys:function(ee,se){return S(X(C,se),ee)},decamelizeKeys:function(ee,se){return S(X(D,se),ee,se)},pascalizeKeys:function(ee,se){return S(X(R,se),ee)},depascalizeKeys:function(){return this.decamelizeKeys.apply(this,arguments)}};d.exports?d.exports=j:y.humps=j})(u)})).decamelize,g=function(d){if(Array.isArray(d))return d},b=function(d,y){if(typeof Symbol!="undefined"&&Symbol.iterator in Object(d)){var S=[],C=!0,R=!1,D=void 0;try{for(var L,O=d[Symbol.iterator]();!(C=(L=O.next()).done)&&(S.push(L.value),!y||S.length!==y);C=!0);}catch(f){R=!0,D=f}finally{try{C||O.return==null||O.return()}finally{if(R)throw D}}return S}},m=function(d,y){(y==null||y>d.length)&&(y=d.length);for(var S=0,C=new Array(y);S<y;S++)C[S]=d[S];return C},x=function(d,y){if(d){if(typeof d=="string")return m(d,y);var S=Object.prototype.toString.call(d).slice(8,-1);return S==="Object"&&d.constructor&&(S=d.constructor.name),S==="Map"||S==="Set"?Array.from(d):S==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(S)?m(d,y):void 0}},I=function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
120
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)},N=function(d,y){return g(d)||b(d,y)||x(d,y)||I()},T=h((function(d){function y(){return d.exports=y=Object.assign||function(S){for(var C=1;C<arguments.length;C++){var R=arguments[C];for(var D in R)Object.prototype.hasOwnProperty.call(R,D)&&(S[D]=R[D])}return S},y.apply(this,arguments)}d.exports=y})),$=function(d,y){if(d==null)return{};var S,C,R={},D=Object.keys(d);for(C=0;C<D.length;C++)S=D[C],y.indexOf(S)>=0||(R[S]=d[S]);return R},B=function(d,y){if(d==null)return{};var S,C,R=$(d,y);if(Object.getOwnPropertySymbols){var D=Object.getOwnPropertySymbols(d);for(C=0;C<D.length;C++)S=D[C],y.indexOf(S)>=0||Object.prototype.propertyIsEnumerable.call(d,S)&&(R[S]=d[S])}return R},G=t.createContext(null);function Z(d){var y=d.children,S=y===void 0?"":y,C=B(d,["children"]);return typeof S!="string"&&(S=i.renderToString(S)),a.default.createElement("template",T({},C,{dangerouslySetInnerHTML:{__html:S}}))}function Y(d){var y=d.root,S=d.children,C=S===void 0?null:S;return r.createPortal(C,y)}function F(d){var y=t.forwardRef((function(S,C){var R,D,L=S.mode,O=L===void 0?"open":L,f=S.delegatesFocus,v=f!==void 0&&f,k=S.styleSheets,M=k===void 0?[]:k,H=S.ssr,Q=H!==void 0&&H,X=S.children,j=B(S,["mode","delegatesFocus","styleSheets","ssr","children"]),ee=(R=C,D=t.useRef(R&&R.current),t.useEffect((function(){R&&(R.current=D.current)}),[R]),D),se=t.useState(null),re=N(se,2),ve=re[0],xe=re[1],Pe="node_".concat(O).concat(v);return t.useLayoutEffect((function(){if(ee.current)try{if(typeof C=="function"&&C(ee.current),Q){var Et=ee.current.shadowRoot;return void xe(Et)}var He=ee.current.attachShadow({mode:O,delegatesFocus:v});M.length>0&&(He.adoptedStyleSheets=M),xe(He)}catch(ot){(function(ri){var nt=ri.error,Qe=ri.styleSheets,ln=ri.root;switch(nt.name){case"NotSupportedError":Qe.length>0&&(ln.adoptedStyleSheets=Qe);break;default:throw nt}})({error:ot,styleSheets:M,root:ve})}}),[C,ee,M]),a.default.createElement(a.default.Fragment,null,a.default.createElement(d.tag,T({key:Pe,ref:ee},j),(ve||Q)&&a.default.createElement(G.Provider,{value:ve},Q?a.default.createElement(Z,{shadowroot:O,shadowrootmode:O},d.render({root:ve,ssr:Q,children:X})):a.default.createElement(Y,{root:ve},d.render({root:ve,ssr:Q,children:X})))))}));return y.propTypes={mode:c.default.oneOf(["open","closed"]),delegatesFocus:c.default.bool,styleSheets:c.default.arrayOf(c.default.instanceOf(globalThis.CSSStyleSheet)),ssr:c.default.bool,children:c.default.node},y}Z.propTypes={children:c.default.oneOfType([c.default.string,c.default.node])},Y.propTypes={root:c.default.object.isRequired,children:c.default.node};var V=new Map;function U(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"core",S=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(C){return C.children};return new Proxy(d,{get:function(C,R){var D=p(R,{separator:"-"}),L="".concat(y,"-").concat(D);return V.has(L)||V.set(L,F({tag:D,render:S})),V.get(L)}})}U();var W=new WeakMap,A=U({},"emotion",(function(d){var y=d.root,S=d.children,C=W.get(y)||(function(){var R=l.default({container:y,key:"react-shadow"});return W.set(y,R),R})();return a.default.createElement(e.CacheProvider,{value:C},a.default.createElement(a.default.Fragment,null,S))}));return gu.default=A,gu}var sB=oB();const aB=ts(sB),mu=":host",lB=It({base:{display:"flex",width:"100%",justifyContent:"center",alignItems:"center",borderRadius:"md"},variants:{variant:{primary:{bg:"primary",color:"bg"},secondary:{bg:"bg.emphasized",color:"fg"},lightGray:{bg:"bg.subtle",color:"fg"}},size:{mdPlus:{padding:"8px 16px",fontSize:"14px",fontWeight:"medium"}}}}),ex=It({variants:{variant:{text:{border:"none",outline:"none",bg:"transparent",color:"fg",textAlign:"center",fontSize:"48px",fontWeight:600,lineHeight:"120%"}}}}),cB=Se({slots:w_.keys(),base:{trigger:{borderRadius:"6px",boxShadow:"none"},content:{borderRadius:"6px",boxShadow:"none"}},variants:{variant:{filled:{trigger:{bg:"bg.subtle",color:"fg.muted",fontWeight:500},content:{bg:"bg.subtle",color:"fg.muted",fontWeight:400}},customOutline:{trigger:{bg:"bg",color:"fg.muted",fontWeight:400,border:"1px solid",borderColor:"border"},content:{bg:"bg",color:"fg.muted",fontWeight:400,border:"1px solid",borderColor:"border"}}}}}),uB=Se({className:"chakra-table",slots:E_.keys(),base:{root:{fontVariantNumeric:"lining-nums tabular-nums",borderCollapse:"collapse",borderRadius:6,width:"full",textAlign:"start",verticalAlign:"top"},row:{_selected:{bg:"colorPalette.subtle"}},cell:{textAlign:"start",alignItems:"center"},columnHeader:{fontWeight:"medium",textAlign:"start",color:"fg"},caption:{fontWeight:"medium",textStyle:"xs"},footer:{fontWeight:"medium"}},variants:{interactive:{true:{body:{"& tr":{_hover:{bg:"colorPalette.subtle"}}}}},stickyHeader:{true:{header:{"& :where(tr)":{top:"var(--table-sticky-offset, 0)",position:"sticky",zIndex:1}}}},striped:{true:{row:{"&:nth-of-type(odd) td":{bg:"bg.muted"}}}},showColumnBorder:{true:{columnHeader:{"&:not(:last-of-type)":{borderInlineEndWidth:"1px"}},cell:{"&:not(:last-of-type)":{borderInlineEndWidth:"1px"}}}},variant:{line:{columnHeader:{borderBottomWidth:"1px"},cell:{borderBottomWidth:"1px"},row:{bg:"bg"}},outline:{root:{boxShadow:"0 0 0 1px {colors.border}",overflow:"hidden"},columnHeader:{borderBottomWidth:"1px"},header:{bg:"bg.muted"},row:{"&:not(:last-of-type)":{borderBottomWidth:"1px"}},footer:{borderTopWidth:"1px"}}},size:{sm:{root:{textStyle:"sm"},columnHeader:{px:"2",py:"2"},cell:{px:"2",py:"2"}},md:{root:{textStyle:"sm"},columnHeader:{px:"3",py:"3"},cell:{px:"3",py:"3"}},lg:{root:{textStyle:"md"},columnHeader:{px:"4",py:"3"},cell:{px:"4",py:"3"}}}},defaultVariants:{variant:"line",size:"md"}}),dB=Af({theme:{semanticTokens:{colors:{border:{value:"#E4E4E7"},"border.subtle":{value:"#F4F4F5"},"border.emphasized":{value:"#1e171f4d"},primary:{value:"black"},customBlack:{value:"#1E171F"},customWhite:{value:"#FAFAFA"},gray:{50:{value:"#F4F4F5"},100:{value:"#707070"},200:{value:"#F4F4F5"},300:{value:"#E4E4E7"},400:{value:"#433E44"}},pink:{value:"#FF21FF"},green:{value:"#52C86E"}}},recipes:{input:ex,button:lB},slotRecipes:{select:cB,table:uB}}}),hB=({children:t,themeConfig:e})=>{const[n,r]=K.useState(null),[i,o]=K.useState(null);K.useEffect(()=>{if(!(n!=null&&n.shadowRoot)||i)return;const a=Jd({key:"root",container:n.shadowRoot});o(a)},[n,i]);const s=K.useMemo(()=>{var a;return m_(Mf,dB,e,{cssVarsRoot:mu,preflight:{scope:mu},conditions:{light:`${mu} &, .light &`},globalCss:{[mu]:{...(a=Mf.globalCss)==null?void 0:a.html,borderRadius:"xl",shadow:"sm",border:"none"}}})},[e]);return w.jsx(aB.div,{ref:r,children:n&&i&&w.jsx(DP,{value:()=>{var a;return(a=n.shadowRoot)!=null?a:document},children:w.jsx(h0,{value:i,children:w.jsx(DO,{value:s,children:t})})})})},Kf=Ve.forwardRef(function(e,n){const{showArrow:r,children:i,disabled:o,portalled:s=!0,content:a,contentProps:l,portalRef:c,...u}=e;return o?i:w.jsxs(L4,{...u,children:[w.jsx(M4,{asChild:!0,children:i}),w.jsx(hL,{disabled:!s,container:c,children:w.jsx(B4,{children:w.jsxs(F4,{ref:n,...l,children:[r&&w.jsx(D4,{children:w.jsx($_,{})}),a]})})})]})}),Yf=K.forwardRef(({variant:t,...e},n)=>{const r=y0({recipe:ex});if(t==="text"){const i=r({variant:"text"});return w.jsx(We.input,{ref:n,css:i,...e})}return w.jsx(O4,{ref:n,variant:t,...e})}),nr=We(Ff,{base:{display:"flex",width:"100%",justifyContent:"center",alignItems:"center",borderRadius:"md",flexShrink:"initial"},variants:{visual:{solid:{bg:"primary",_hover:{bg:"primary.emphasis"}},grayFilled:{bg:"bg.emphasized",color:"customWhite"},lightGray:{bg:"bg.subtle",color:"fg"}},size:{sm:{padding:"8px 16px",fontSize:"14px",fontWeight:"medium"},md:{padding:"4",fontSize:"16px"},lg:{padding:"8",fontSize:"24px"}}},defaultVariants:{visual:"solid",size:"sm"}});nr.displayName="Button";const gi=K.forwardRef(({variant:t="secondary",children:e,...n},r)=>w.jsx(B_,{ref:r,variant:"ghost",bg:"transparent",border:"none",_active:{bg:"bg.emphasized"},color:"fg.muted",...n,children:e}));gi.displayName="IconButton";const fB=We("div",{base:{p:"10px 12px",h:"32px",display:"flex",justifyContent:"center",alignItems:"center",gap:"8px",borderRadius:"6px",cursor:"pointer",color:"fg.muted",fontSize:"14px",fontWeight:"medium",transition:"all 0.2s ease-in-out",_hover:{bg:"bg.subtle",color:"fg"}}}),gB=({children:t})=>w.jsx(Te,{fontSize:"md",fontWeight:"500",color:"fg",children:t}),pB=({children:t})=>w.jsx(ue,{fontSize:"xs",color:"fg.muted",children:t}),qr=({children:t,padding:e="8px 12px",onClick:n,selected:r=!1,disabled:i=!1})=>w.jsx(ue,{p:e,borderRadius:"md",border:"1px solid",borderColor:r?"primary":"border",bg:"bg",cursor:n&&!i?"pointer":"default",opacity:i?.5:1,_hover:r?void 0:{borderColor:"border.emphasized"},onClick:i?void 0:n,children:t});qr.Title=gB,qr.Description=pB;const tx=We(L_,{base:{display:"flex",padding:"2px 10px",justifyContent:"center",alignItems:"center",lineHeight:"16px",borderRadius:"full",fontSize:"xs",color:"fg.muted",backgroundColor:"bg.subtle",width:"fit-content",fontWeight:600}}),mB=({children:t,type:e="info"})=>{const n=K.useMemo(()=>({info:{bg:"bg.subtle",color:"fg.muted",borderColor:"bg.subtle"},warning:{bg:"warning",color:"bg",borderColor:"warning"},error:{bg:"error",color:"bg",borderColor:"error"},success:{bg:"success",color:"bg",borderColor:"success"}})[e],[e]);return w.jsx(tr,{gap:1,p:3,borderRadius:"md",border:"1px solid",fontSize:"sm",...n,children:t})},nx=We("div",{base:{display:"flex",flexDirection:"row",width:"100%",alignItems:"center",gap:"12px",paddingBottom:"16px",borderBottom:"1px solid",borderColor:"border"}}),Xf=We("div",{base:{display:"flex",flexDirection:"row",width:"100%",justifyContent:"space-between",alignItems:"center",gap:"12px",paddingBottom:"16px",borderBottom:"1px solid",borderColor:"border"}}),Ao=We("h2",{base:{fontWeight:"600",fontSize:"14px",lineHeight:"120%",letterSpacing:"-0.4px",color:"fg"}}),Zf=We("p",{base:{fontWeight:"400",fontSize:"12px",lineHeight:"100%",letterSpacing:"-0.4px",color:"fg.muted"}}),Oo=We("div",{base:{display:"flex",flexDirection:"column",width:"100%",justifyContent:"center",alignItems:"center",gap:4}}),tn=We("div",{base:{display:"flex",flexDirection:"column",width:"100%",justifyContent:"center",alignItems:"center",gap:"12px",paddingTop:"16px"}}),vB=We("hr",{base:{width:"100%",color:"border",backgroundColor:"border",borderColor:"border"}}),rx=t=>{let e;const n=new Set,r=(c,u)=>{const h=typeof c=="function"?c(e):c;if(!Object.is(h,e)){const p=e;e=(u!=null?u:typeof h!="object"||h===null)?h:Object.assign({},e,h),n.forEach(g=>g(e,p))}},i=()=>e,a={setState:r,getState:i,getInitialState:()=>l,subscribe:c=>(n.add(c),()=>n.delete(c))},l=e=t(r,i,a);return a},yB=(t=>t?rx(t):rx),bB=t=>t;function _B(t,e=bB){const n=K.useSyncExternalStore(t.subscribe,K.useCallback(()=>e(t.getState()),[t,e]),K.useCallback(()=>e(t.getInitialState()),[t,e]));return K.useDebugValue(n),n}const ix=t=>{const e=yB(t),n=r=>_B(e,r);return Object.assign(n,e),n},ox=(t=>t?ix(t):ix),Pt="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",xB="0xd8da6bf26964af9d7eed9e03e53415d37aa96045",wB=200,sx={ETH:.02,USDC:20,USDT:20,WBTC:1e-8},ax=5,Gr={address:Pt,name:"Ethereum",symbol:"ETH",decimals:18,logoURI:"https://assets.coingecko.com/coins/images/279/large/ethereum.png"},EB={address:Pt,name:"Binance Coin",symbol:"BNB",decimals:18,logoURI:"https://assets.coingecko.com/coins/images/825/large/binance-coin-logo.png"},SB={address:Pt,name:"Avalanche",symbol:"AVAX",decimals:18,logoURI:"https://assets.coingecko.com/coins/images/12559/large/coin-round-red.png"},IB={address:Pt,name:"Polygon",symbol:"MATIC",decimals:18,logoURI:"https://assets.coingecko.com/coins/images/4713/large/matic___polygon.jpg"},CB={address:Pt,name:"BeraChain",symbol:"BERA",decimals:18,logoURI:"https://assets.coingecko.com/coins/images/25235/large/BERA.png?1738822008"},AB={address:Pt,name:"Gnosis XDAI",symbol:"XDAI",decimals:18,logoURI:"https://assets.coingecko.com/coins/images/11062/large/Identity-Primary-DarkBG.png"},OB={address:Pt,name:"Sonic",symbol:"S",decimals:18,logoURI:"https://assets.coingecko.com/coins/images/38108/standard/200x200_Sonic_Logo.png"},kB={address:Pt,name:"Plume",symbol:"PLUME",decimals:18,logoURI:"https://assets.coingecko.com/coins/images/53623/standard/plume-token.png?1736896935"},TB={address:Pt,name:"Hyperliquid",symbol:"HYPE",decimals:18,logoURI:"https://assets.coingecko.com/asset_platforms/images/243/large/hyperliquid.png"},Is="https://assets.coingecko.com/coins/images/12504/small/uniswap-uni.png";var Cs=(t=>(t[t.MAINNET=1]="MAINNET",t[t.ARBITRUM_ONE=42161]="ARBITRUM_ONE",t[t.OPTIMISM=10]="OPTIMISM",t[t.POLYGON=137]="POLYGON",t[t.BSC=56]="BSC",t[t.BASE=8453]="BASE",t[t.LINEA=59144]="LINEA",t[t.ZKSYNC=324]="ZKSYNC",t[t.GNOSIS=100]="GNOSIS",t[t.AVALANCHE=43114]="AVALANCHE",t[t.BERACHAIN=80094]="BERACHAIN",t[t.SONIC=146]="SONIC",t[t.UNICHAIN=130]="UNICHAIN",t[t.INK=57073]="INK",t[t.SONEIUM=1868]="SONEIUM",t[t.PLUME=98866]="PLUME",t[t.HYPERLIQUID=999]="HYPERLIQUID",t[t.KATANA=747474]="KATANA",t))(Cs||{});const ko={1:"ethereum",8453:"base",137:"polygon",56:"bsc",59144:"linea",324:"zksync",100:"gnosis",43114:"avalanche",80094:"bera",146:"sonic",42161:"arbitrum",10:"optimism",130:"unichain",57073:"ink",1868:"soneium",98866:"plumephoenix",999:"hyperliquid",747474:"katana"},lx={1:"ethereum",42161:"arbitrum-one",10:"optimistic-ethereum",137:"polygon-pos",8453:"base",56:"binance-smart-chain",59144:"linea",324:"zksync",100:"xdai",43114:"avalanche",80094:"berachain",146:"sonic",130:"unichain",57073:"ink",1868:"soneium",98866:"plume",999:"hyperevm",747474:"katana"},cx={1:Gr,42161:Gr,10:Gr,8453:Gr,59144:Gr,324:Gr,1868:Gr,130:Gr,57073:Gr,56:EB,43114:SB,137:IB,80094:CB,100:AB,146:OB,98866:kB,999:TB,747474:Gr},Jf={999:42161},RB=(t,e=Jf)=>{var n;return(n=e[t])!=null?n:null},ux={10:"https://optimistic.etherscan.io",1:"https://etherscan.io",42161:"https://arbiscan.io",137:"https://polygonscan.com",56:"https://bscscan.com",8453:"https://basescan.org",59144:"https://lineascan.build",324:"https://explorer.zksync.io/",100:"https://gnosisscan.io/",43114:"https://cchain.explorer.avax.network",80094:"https://berascan.com",146:"https://sonicscan.io",130:"https://uniscan.xyz",57073:"https://explorer.inkonchain.com",1868:"https://soneium.blockscout.com/",98866:"https://explorer.plume.org/",999:"https://www.hyperscan.com/",747474:"https://explorer-katana.t.conduit.xyz/"},Be=ox(t=>({selectedIntegration:null,setSelectedIntegration:e=>t({selectedIntegration:e}),ensoApiToken:"",setEnsoApiToken:e=>t({ensoApiToken:e}),tokenIn:"",setTokenIn:e=>t({tokenIn:e}),tokenOut:"",setTokenOut:e=>t({tokenOut:e}),chainIdIn:void 0,setChainIdIn:e=>t({chainIdIn:e}),chainIdOut:void 0,setChainIdOut:e=>t({chainIdOut:e}),amountIn:"0",setAmountIn:e=>t({amountIn:e}),slippage:wB,setSlippage:e=>t({slippage:e}),recipient:void 0,setRecipient:e=>t({recipient:e}),meshAccessToken:null,setMeshAccessToken:e=>t({meshAccessToken:e}),sessionId:"",setSessionId:e=>t({sessionId:e}),linkToken:"",setLinkToken:e=>t({linkToken:e})})),ji=()=>{const t=Be(e=>e.ensoApiToken);return async({url:e,method:n,params:r,data:i})=>(await fetch(e+"?"+new URLSearchParams(r),{method:n,headers:{...i==null?void 0:i.headers,Authorization:`Bearer ${t}`},...i?{body:JSON.stringify(i)}:{}})).json()},NB=()=>{const t=ji();return K.useCallback((e,n,r)=>t({url:`https://api.enso.build/api/v1/prices/${e}/${n}`,method:"GET",signal:r}),[t])},PB=(t,e)=>[`https://api.enso.build/api/v1/prices/${t}/${e}`],LB=(t,e,n)=>{var a;const{query:r}={},i=(a=r==null?void 0:r.queryKey)!=null?a:PB(t,e),o=NB();return{queryKey:i,queryFn:({signal:l})=>o(t,e,l),enabled:!!(t&&e),...r}};function MB(t,e,n,r){const i=LB(t,e),o=Kn.useQuery(i,r);return o.queryKey=i.queryKey,o}const BB=()=>{const t=ji();return K.useCallback((e,n)=>t({url:"https://api.enso.build/api/v1/shortcuts/route",method:"GET",params:e,signal:n}),[t])},FB=t=>["https://api.enso.build/api/v1/shortcuts/route",...t?[t]:[]],DB=(t,e)=>{var s;const{query:n}=e!=null?e:{},r=(s=n==null?void 0:n.queryKey)!=null?s:FB(t),i=BB();return{queryKey:r,queryFn:({signal:a})=>i(t,a),...n}};function VB(t,e,n){const r=DB(t,e),i=Kn.useQuery(r,n);return i.queryKey=r.queryKey,i}const $B=()=>{const t=ji();return K.useCallback((e,n)=>t({url:"https://api.enso.build/api/v1/shortcuts/route/nontokenized",method:"GET",params:e,signal:n}),[t])},zB=t=>["https://api.enso.build/api/v1/shortcuts/route/nontokenized",...t?[t]:[]],UB=(t,e)=>{var s;const{query:n}=e!=null?e:{},r=(s=n==null?void 0:n.queryKey)!=null?s:zB(t),i=$B();return{queryKey:r,queryFn:({signal:a})=>i(t,a),...n}};function WB(t,e,n){const r=UB(t,e),i=Kn.useQuery(r,n);return i.queryKey=r.queryKey,i}const HB=()=>{const t=ji();return K.useCallback((e,n)=>t({url:"https://api.enso.build/api/v1/wallet/approve",method:"GET",params:e,signal:n}),[t])},jB=t=>["https://api.enso.build/api/v1/wallet/approve",...t?[t]:[]],qB=(t,e)=>{var s;const{query:n}={},r=(s=n==null?void 0:n.queryKey)!=null?s:jB(t),i=HB();return{queryKey:r,queryFn:({signal:a})=>i(t,a),...n}};function GB(t,e,n){const r=qB(t),i=Kn.useQuery(r,n);return i.queryKey=r.queryKey,i}const KB=()=>{const t=ji();return K.useCallback((e,n)=>t({url:"https://api.enso.build/api/v1/wallet/balances",method:"GET",params:e,signal:n}),[t])},YB=t=>["https://api.enso.build/api/v1/wallet/balances",...t?[t]:[]],XB=(t,e)=>{var s;const{query:n}=e!=null?e:{},r=(s=n==null?void 0:n.queryKey)!=null?s:YB(t),i=KB();return{queryKey:r,queryFn:({signal:a})=>i(t,a),...n}};function dx(t,e,n){const r=XB(t,e),i=Kn.useQuery(r,n);return i.queryKey=r.queryKey,i}const ZB=()=>{const t=ji();return K.useCallback((e,n)=>t({url:"https://api.enso.build/api/v1/tokens",method:"GET",params:e,signal:n}),[t])},JB=t=>["https://api.enso.build/api/v1/tokens",...t?[t]:[]],QB=(t,e)=>{var s;const{query:n}=e!=null?e:{},r=(s=n==null?void 0:n.queryKey)!=null?s:JB(t),i=ZB();return{queryKey:r,queryFn:({signal:a})=>i(t,a),...n}};function e8(t,e,n){const r=QB(t,e),i=Kn.useQuery(r,n);return i.queryKey=r.queryKey,i}const t8=()=>{const t=ji();return K.useCallback((e,n)=>t({url:"https://api.enso.build/api/v1/nontokenized",method:"GET",params:e,signal:n}),[t])},n8=t=>["https://api.enso.build/api/v1/nontokenized",...t?[t]:[]],r8=(t,e)=>{var s;const{query:n}=e!=null?e:{},r=(s=n==null?void 0:n.queryKey)!=null?s:n8(t),i=t8();return{queryKey:r,queryFn:({signal:a})=>i(t,a),...n}};function hx(t,e,n){const r=r8(t,e),i=Kn.useQuery(r,n);return i.queryKey=r.queryKey,i}const i8=()=>{const t=ji();return K.useCallback((e,n)=>t({url:"https://api.enso.build/api/v1/protocols",method:"GET",params:e,signal:n}),[t])},o8=t=>["https://api.enso.build/api/v1/protocols",...t?[t]:[]],s8=(t,e)=>{var s;const{query:n}=e!=null?e:{},r=(s=n==null?void 0:n.queryKey)!=null?s:o8(t),i=i8();return{queryKey:r,queryFn:({signal:a})=>i(t,a),...n}};function a8(t,e,n){const r=s8(t,e),i=Kn.useQuery(r,n);return i.queryKey=r.queryKey,i}const l8="1.0.8";let pi=class zm extends Error{constructor(e,n={}){var s;const r=n.cause instanceof zm?n.cause.details:(s=n.cause)!=null&&s.message?n.cause.message:n.details,i=n.cause instanceof zm&&n.cause.docsPath||n.docsPath,o=[e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...i?[`Docs: https://abitype.dev${i}`]:[],...r?[`Details: ${r}`]:[],`Version: abitype@${l8}`].join(`
120
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)},N=function(d,y){return g(d)||b(d,y)||x(d,y)||I()},T=h((function(d){function y(){return d.exports=y=Object.assign||function(S){for(var C=1;C<arguments.length;C++){var R=arguments[C];for(var D in R)Object.prototype.hasOwnProperty.call(R,D)&&(S[D]=R[D])}return S},y.apply(this,arguments)}d.exports=y})),$=function(d,y){if(d==null)return{};var S,C,R={},D=Object.keys(d);for(C=0;C<D.length;C++)S=D[C],y.indexOf(S)>=0||(R[S]=d[S]);return R},B=function(d,y){if(d==null)return{};var S,C,R=$(d,y);if(Object.getOwnPropertySymbols){var D=Object.getOwnPropertySymbols(d);for(C=0;C<D.length;C++)S=D[C],y.indexOf(S)>=0||Object.prototype.propertyIsEnumerable.call(d,S)&&(R[S]=d[S])}return R},G=t.createContext(null);function Z(d){var y=d.children,S=y===void 0?"":y,C=B(d,["children"]);return typeof S!="string"&&(S=i.renderToString(S)),a.default.createElement("template",T({},C,{dangerouslySetInnerHTML:{__html:S}}))}function Y(d){var y=d.root,S=d.children,C=S===void 0?null:S;return r.createPortal(C,y)}function F(d){var y=t.forwardRef((function(S,C){var R,D,L=S.mode,O=L===void 0?"open":L,f=S.delegatesFocus,v=f!==void 0&&f,k=S.styleSheets,M=k===void 0?[]:k,H=S.ssr,Q=H!==void 0&&H,X=S.children,j=B(S,["mode","delegatesFocus","styleSheets","ssr","children"]),ee=(R=C,D=t.useRef(R&&R.current),t.useEffect((function(){R&&(R.current=D.current)}),[R]),D),se=t.useState(null),re=N(se,2),ve=re[0],xe=re[1],Pe="node_".concat(O).concat(v);return t.useLayoutEffect((function(){if(ee.current)try{if(typeof C=="function"&&C(ee.current),Q){var Et=ee.current.shadowRoot;return void xe(Et)}var He=ee.current.attachShadow({mode:O,delegatesFocus:v});M.length>0&&(He.adoptedStyleSheets=M),xe(He)}catch(ot){(function(ri){var nt=ri.error,Qe=ri.styleSheets,ln=ri.root;switch(nt.name){case"NotSupportedError":Qe.length>0&&(ln.adoptedStyleSheets=Qe);break;default:throw nt}})({error:ot,styleSheets:M,root:ve})}}),[C,ee,M]),a.default.createElement(a.default.Fragment,null,a.default.createElement(d.tag,T({key:Pe,ref:ee},j),(ve||Q)&&a.default.createElement(G.Provider,{value:ve},Q?a.default.createElement(Z,{shadowroot:O,shadowrootmode:O},d.render({root:ve,ssr:Q,children:X})):a.default.createElement(Y,{root:ve},d.render({root:ve,ssr:Q,children:X})))))}));return y.propTypes={mode:c.default.oneOf(["open","closed"]),delegatesFocus:c.default.bool,styleSheets:c.default.arrayOf(c.default.instanceOf(globalThis.CSSStyleSheet)),ssr:c.default.bool,children:c.default.node},y}Z.propTypes={children:c.default.oneOfType([c.default.string,c.default.node])},Y.propTypes={root:c.default.object.isRequired,children:c.default.node};var V=new Map;function U(){var d=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},y=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"core",S=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(C){return C.children};return new Proxy(d,{get:function(C,R){var D=p(R,{separator:"-"}),L="".concat(y,"-").concat(D);return V.has(L)||V.set(L,F({tag:D,render:S})),V.get(L)}})}U();var W=new WeakMap,A=U({},"emotion",(function(d){var y=d.root,S=d.children,C=W.get(y)||(function(){var R=l.default({container:y,key:"react-shadow"});return W.set(y,R),R})();return a.default.createElement(e.CacheProvider,{value:C},a.default.createElement(a.default.Fragment,null,S))}));return gu.default=A,gu}var sB=oB();const aB=ts(sB),mu=":host",lB=It({base:{display:"flex",width:"100%",justifyContent:"center",alignItems:"center",borderRadius:"md"},variants:{variant:{primary:{bg:"primary",color:"bg"},secondary:{bg:"bg.emphasized",color:"fg"},lightGray:{bg:"bg.subtle",color:"fg"}},size:{mdPlus:{padding:"8px 16px",fontSize:"14px",fontWeight:"medium"}}}}),ex=It({variants:{variant:{text:{border:"none",outline:"none",bg:"transparent",color:"fg",textAlign:"center",fontSize:"48px",fontWeight:600,lineHeight:"120%"}}}}),cB=Se({slots:w_.keys(),base:{trigger:{borderRadius:"6px",boxShadow:"none"},content:{borderRadius:"6px",boxShadow:"none"}},variants:{variant:{filled:{trigger:{bg:"bg.subtle",color:"fg.muted",fontWeight:500},content:{bg:"bg.subtle",color:"fg.muted",fontWeight:400}},customOutline:{trigger:{bg:"bg",color:"fg.muted",fontWeight:400,border:"1px solid",borderColor:"border"},content:{bg:"bg",color:"fg.muted",fontWeight:400,border:"1px solid",borderColor:"border"}}}}}),uB=Se({className:"chakra-table",slots:E_.keys(),base:{root:{fontVariantNumeric:"lining-nums tabular-nums",borderCollapse:"collapse",borderRadius:6,width:"full",textAlign:"start",verticalAlign:"top"},row:{_selected:{bg:"colorPalette.subtle"}},cell:{textAlign:"start",alignItems:"center"},columnHeader:{fontWeight:"medium",textAlign:"start",color:"fg"},caption:{fontWeight:"medium",textStyle:"xs"},footer:{fontWeight:"medium"}},variants:{interactive:{true:{body:{"& tr":{_hover:{bg:"colorPalette.subtle"}}}}},stickyHeader:{true:{header:{"& :where(tr)":{top:"var(--table-sticky-offset, 0)",position:"sticky",zIndex:1}}}},striped:{true:{row:{"&:nth-of-type(odd) td":{bg:"bg.muted"}}}},showColumnBorder:{true:{columnHeader:{"&:not(:last-of-type)":{borderInlineEndWidth:"1px"}},cell:{"&:not(:last-of-type)":{borderInlineEndWidth:"1px"}}}},variant:{line:{columnHeader:{borderBottomWidth:"1px"},cell:{borderBottomWidth:"1px"},row:{bg:"bg"}},outline:{root:{boxShadow:"0 0 0 1px {colors.border}",overflow:"hidden"},columnHeader:{borderBottomWidth:"1px"},header:{bg:"bg.muted"},row:{"&:not(:last-of-type)":{borderBottomWidth:"1px"}},footer:{borderTopWidth:"1px"}}},size:{sm:{root:{textStyle:"sm"},columnHeader:{px:"2",py:"2"},cell:{px:"2",py:"2"}},md:{root:{textStyle:"sm"},columnHeader:{px:"3",py:"3"},cell:{px:"3",py:"3"}},lg:{root:{textStyle:"md"},columnHeader:{px:"4",py:"3"},cell:{px:"4",py:"3"}}}},defaultVariants:{variant:"line",size:"md"}}),dB=Af({theme:{semanticTokens:{colors:{border:{value:"#E4E4E7"},"border.subtle":{value:"#F4F4F5"},"border.emphasized":{value:"#1e171f4d"},primary:{value:"black"},customBlack:{value:"#1E171F"},customWhite:{value:"#FAFAFA"},gray:{50:{value:"#F4F4F5"},100:{value:"#707070"},200:{value:"#F4F4F5"},300:{value:"#E4E4E7"},400:{value:"#433E44"}},pink:{value:"#FF21FF"},green:{value:"#52C86E"}}},recipes:{input:ex,button:lB},slotRecipes:{select:cB,table:uB}}}),hB=({children:t,themeConfig:e})=>{const[n,r]=K.useState(null),[i,o]=K.useState(null);K.useEffect(()=>{if(!(n!=null&&n.shadowRoot)||i)return;const a=Jd({key:"root",container:n.shadowRoot});o(a)},[n,i]);const s=K.useMemo(()=>{var a;return m_(Mf,dB,e,{cssVarsRoot:mu,preflight:{scope:mu},conditions:{light:`${mu} &, .light &`},globalCss:{[mu]:{...(a=Mf.globalCss)==null?void 0:a.html,borderRadius:"xl",shadow:"sm",border:"none"}}})},[e]);return w.jsx(aB.div,{ref:r,children:n&&i&&w.jsx(DP,{value:()=>{var a;return(a=n.shadowRoot)!=null?a:document},children:w.jsx(h0,{value:i,children:w.jsx(DO,{value:s,children:t})})})})},Kf=Ve.forwardRef(function(e,n){const{showArrow:r,children:i,disabled:o,portalled:s=!0,content:a,contentProps:l,portalRef:c,...u}=e;return o?i:w.jsxs(L4,{...u,children:[w.jsx(M4,{asChild:!0,children:i}),w.jsx(hL,{disabled:!s,container:c,children:w.jsx(B4,{children:w.jsxs(F4,{ref:n,...l,children:[r&&w.jsx(D4,{children:w.jsx($_,{})}),a]})})})]})}),Yf=K.forwardRef(({variant:t,...e},n)=>{const r=y0({recipe:ex});if(t==="text"){const i=r({variant:"text"});return w.jsx(We.input,{ref:n,css:i,...e})}return w.jsx(O4,{ref:n,variant:t,...e})}),nr=We(Ff,{base:{display:"flex",width:"100%",justifyContent:"center",alignItems:"center",borderRadius:"md",flexShrink:"initial"},variants:{visual:{solid:{bg:"primary",_hover:{bg:"primary.emphasis"}},grayFilled:{bg:"bg.emphasized",color:"customWhite"},lightGray:{bg:"bg.subtle",color:"fg"}},size:{sm:{padding:"8px 16px",fontSize:"14px",fontWeight:"medium"},md:{padding:"4",fontSize:"16px"},lg:{padding:"8",fontSize:"24px"}}},defaultVariants:{visual:"solid",size:"sm"}});nr.displayName="Button";const gi=K.forwardRef(({variant:t="secondary",children:e,...n},r)=>w.jsx(B_,{ref:r,variant:"ghost",bg:"transparent",border:"none",_active:{bg:"bg.emphasized"},color:"fg.muted",...n,children:e}));gi.displayName="IconButton";const fB=We("div",{base:{p:"10px 12px",h:"32px",display:"flex",justifyContent:"center",alignItems:"center",gap:"8px",borderRadius:"6px",cursor:"pointer",color:"fg.muted",fontSize:"14px",fontWeight:"medium",transition:"all 0.2s ease-in-out",_hover:{bg:"bg.subtle",color:"fg"}}}),gB=({children:t})=>w.jsx(Te,{fontSize:"md",fontWeight:"500",color:"fg",children:t}),pB=({children:t})=>w.jsx(ue,{fontSize:"xs",color:"fg.muted",children:t}),qr=({children:t,padding:e="8px 12px",onClick:n,selected:r=!1,disabled:i=!1})=>w.jsx(ue,{p:e,borderRadius:"md",border:"1px solid",borderColor:r?"primary":"border",bg:"bg",cursor:n&&!i?"pointer":"default",opacity:i?.5:1,_hover:r?void 0:{borderColor:"border.emphasized"},onClick:i?void 0:n,children:t});qr.Title=gB,qr.Description=pB;const tx=We(L_,{base:{display:"flex",padding:"2px 10px",justifyContent:"center",alignItems:"center",lineHeight:"16px",borderRadius:"full",fontSize:"xs",color:"fg.muted",backgroundColor:"bg.subtle",width:"fit-content",fontWeight:600}}),mB=({children:t,type:e="info"})=>{const n=K.useMemo(()=>({info:{bg:"bg.subtle",color:"fg.muted",borderColor:"bg.subtle"},warning:{bg:"warning",color:"bg",borderColor:"warning"},error:{bg:"error",color:"bg",borderColor:"error"},success:{bg:"success",color:"bg",borderColor:"success"}})[e],[e]);return w.jsx(tr,{gap:1,p:3,borderRadius:"md",border:"1px solid",fontSize:"sm",...n,children:t})},nx=We("div",{base:{display:"flex",flexDirection:"row",width:"100%",alignItems:"center",gap:"12px",paddingBottom:"16px",borderBottom:"1px solid",borderColor:"border"}}),Xf=We("div",{base:{display:"flex",flexDirection:"row",width:"100%",justifyContent:"space-between",alignItems:"center",gap:"12px",paddingBottom:"16px",borderBottom:"1px solid",borderColor:"border"}}),Ao=We("h2",{base:{fontWeight:"600",fontSize:"14px",lineHeight:"120%",letterSpacing:"-0.4px",color:"fg"}}),Zf=We("p",{base:{fontWeight:"400",fontSize:"12px",lineHeight:"100%",letterSpacing:"-0.4px",color:"fg.muted"}}),Oo=We("div",{base:{display:"flex",flexDirection:"column",width:"100%",justifyContent:"center",alignItems:"center",gap:4}}),tn=We("div",{base:{display:"flex",flexDirection:"column",width:"100%",justifyContent:"center",alignItems:"center",gap:"12px",paddingTop:"16px"}}),vB=We("hr",{base:{width:"100%",color:"border",backgroundColor:"border",borderColor:"border"}}),rx=t=>{let e;const n=new Set,r=(c,u)=>{const h=typeof c=="function"?c(e):c;if(!Object.is(h,e)){const p=e;e=(u!=null?u:typeof h!="object"||h===null)?h:Object.assign({},e,h),n.forEach(g=>g(e,p))}},i=()=>e,a={setState:r,getState:i,getInitialState:()=>l,subscribe:c=>(n.add(c),()=>n.delete(c))},l=e=t(r,i,a);return a},yB=(t=>t?rx(t):rx),bB=t=>t;function _B(t,e=bB){const n=K.useSyncExternalStore(t.subscribe,K.useCallback(()=>e(t.getState()),[t,e]),K.useCallback(()=>e(t.getInitialState()),[t,e]));return K.useDebugValue(n),n}const ix=t=>{const e=yB(t),n=r=>_B(e,r);return Object.assign(n,e),n},ox=(t=>t?ix(t):ix),Pt="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",xB="0xd8da6bf26964af9d7eed9e03e53415d37aa96045",wB=200,sx={ETH:.02,USDC:20,USDT:20,WBTC:1e-8},ax=5,Gr={address:Pt,name:"Ethereum",symbol:"ETH",decimals:18,logoURI:"https://assets.coingecko.com/coins/images/279/large/ethereum.png"},EB={address:Pt,name:"Binance Coin",symbol:"BNB",decimals:18,logoURI:"https://assets.coingecko.com/coins/images/825/large/binance-coin-logo.png"},SB={address:Pt,name:"Avalanche",symbol:"AVAX",decimals:18,logoURI:"https://assets.coingecko.com/coins/images/12559/large/coin-round-red.png"},IB={address:Pt,name:"Polygon",symbol:"MATIC",decimals:18,logoURI:"https://assets.coingecko.com/coins/images/4713/large/matic___polygon.jpg"},CB={address:Pt,name:"BeraChain",symbol:"BERA",decimals:18,logoURI:"https://assets.coingecko.com/coins/images/25235/large/BERA.png?1738822008"},AB={address:Pt,name:"Gnosis XDAI",symbol:"XDAI",decimals:18,logoURI:"https://assets.coingecko.com/coins/images/11062/large/Identity-Primary-DarkBG.png"},OB={address:Pt,name:"Sonic",symbol:"S",decimals:18,logoURI:"https://assets.coingecko.com/coins/images/38108/standard/200x200_Sonic_Logo.png"},kB={address:Pt,name:"Plume",symbol:"PLUME",decimals:18,logoURI:"https://assets.coingecko.com/coins/images/53623/standard/plume-token.png?1736896935"},TB={address:Pt,name:"Hyperliquid",symbol:"HYPE",decimals:18,logoURI:"https://assets.coingecko.com/asset_platforms/images/243/large/hyperliquid.png"},Is="https://assets.coingecko.com/coins/images/12504/small/uniswap-uni.png";var Cs=(t=>(t[t.MAINNET=1]="MAINNET",t[t.ARBITRUM_ONE=42161]="ARBITRUM_ONE",t[t.OPTIMISM=10]="OPTIMISM",t[t.POLYGON=137]="POLYGON",t[t.BSC=56]="BSC",t[t.BASE=8453]="BASE",t[t.LINEA=59144]="LINEA",t[t.ZKSYNC=324]="ZKSYNC",t[t.GNOSIS=100]="GNOSIS",t[t.AVALANCHE=43114]="AVALANCHE",t[t.BERACHAIN=80094]="BERACHAIN",t[t.SONIC=146]="SONIC",t[t.UNICHAIN=130]="UNICHAIN",t[t.INK=57073]="INK",t[t.SONEIUM=1868]="SONEIUM",t[t.PLUME=98866]="PLUME",t[t.HYPERLIQUID=999]="HYPERLIQUID",t[t.KATANA=747474]="KATANA",t))(Cs||{});const ko={1:"ethereum",8453:"base",137:"polygon",56:"bsc",59144:"linea",324:"zksync",100:"gnosis",43114:"avalanche",80094:"bera",146:"sonic",42161:"arbitrum",10:"optimism",130:"unichain",57073:"ink",1868:"soneium",98866:"plumephoenix",999:"hyperliquid",747474:"katana"},lx={1:"ethereum",42161:"arbitrum-one",10:"optimistic-ethereum",137:"polygon-pos",8453:"base",56:"binance-smart-chain",59144:"linea",324:"zksync",100:"xdai",43114:"avalanche",80094:"berachain",146:"sonic",130:"unichain",57073:"ink",1868:"soneium",98866:"plume",999:"hyperevm",747474:"katana"},cx={1:Gr,42161:Gr,10:Gr,8453:Gr,59144:Gr,324:Gr,1868:Gr,130:Gr,57073:Gr,56:EB,43114:SB,137:IB,80094:CB,100:AB,146:OB,98866:kB,999:TB,747474:Gr},Jf={999:42161},RB=(t,e=Jf)=>{var n;return(n=e[t])!=null?n:null},ux={10:"https://optimistic.etherscan.io",1:"https://etherscan.io",42161:"https://arbiscan.io",137:"https://polygonscan.com",56:"https://bscscan.com",8453:"https://basescan.org",59144:"https://lineascan.build",324:"https://explorer.zksync.io/",100:"https://gnosisscan.io/",43114:"https://cchain.explorer.avax.network",80094:"https://berascan.com",146:"https://sonicscan.io",130:"https://uniscan.xyz",57073:"https://explorer.inkonchain.com",1868:"https://soneium.blockscout.com/",98866:"https://explorer.plume.org/",999:"https://www.hyperscan.com/",747474:"https://explorer-katana.t.conduit.xyz/"},Me=ox(t=>({selectedIntegration:null,setSelectedIntegration:e=>t({selectedIntegration:e}),ensoApiToken:"",setEnsoApiToken:e=>t({ensoApiToken:e}),tokenIn:"",setTokenIn:e=>t({tokenIn:e}),tokenOut:"",setTokenOut:e=>t({tokenOut:e}),chainIdIn:void 0,setChainIdIn:e=>t({chainIdIn:e}),chainIdOut:void 0,setChainIdOut:e=>t({chainIdOut:e}),amountIn:"0",setAmountIn:e=>t({amountIn:e}),slippage:wB,setSlippage:e=>t({slippage:e}),recipient:void 0,setRecipient:e=>t({recipient:e}),meshAccessToken:null,setMeshAccessToken:e=>t({meshAccessToken:e}),sessionId:"",setSessionId:e=>t({sessionId:e}),linkToken:"",setLinkToken:e=>t({linkToken:e})})),ji=()=>{const t=Me(e=>e.ensoApiToken);return async({url:e,method:n,params:r,data:i})=>(await fetch(e+"?"+new URLSearchParams(r),{method:n,headers:{...i==null?void 0:i.headers,Authorization:`Bearer ${t}`},...i?{body:JSON.stringify(i)}:{}})).json()},NB=()=>{const t=ji();return K.useCallback((e,n,r)=>t({url:`https://api.enso.build/api/v1/prices/${e}/${n}`,method:"GET",signal:r}),[t])},PB=(t,e)=>[`https://api.enso.build/api/v1/prices/${t}/${e}`],LB=(t,e,n)=>{var a;const{query:r}={},i=(a=r==null?void 0:r.queryKey)!=null?a:PB(t,e),o=NB();return{queryKey:i,queryFn:({signal:l})=>o(t,e,l),enabled:!!(t&&e),...r}};function MB(t,e,n,r){const i=LB(t,e),o=Kn.useQuery(i,r);return o.queryKey=i.queryKey,o}const BB=()=>{const t=ji();return K.useCallback((e,n)=>t({url:"https://api.enso.build/api/v1/shortcuts/route",method:"GET",params:e,signal:n}),[t])},FB=t=>["https://api.enso.build/api/v1/shortcuts/route",...t?[t]:[]],DB=(t,e)=>{var s;const{query:n}=e!=null?e:{},r=(s=n==null?void 0:n.queryKey)!=null?s:FB(t),i=BB();return{queryKey:r,queryFn:({signal:a})=>i(t,a),...n}};function VB(t,e,n){const r=DB(t,e),i=Kn.useQuery(r,n);return i.queryKey=r.queryKey,i}const $B=()=>{const t=ji();return K.useCallback((e,n)=>t({url:"https://api.enso.build/api/v1/shortcuts/route/nontokenized",method:"GET",params:e,signal:n}),[t])},zB=t=>["https://api.enso.build/api/v1/shortcuts/route/nontokenized",...t?[t]:[]],UB=(t,e)=>{var s;const{query:n}=e!=null?e:{},r=(s=n==null?void 0:n.queryKey)!=null?s:zB(t),i=$B();return{queryKey:r,queryFn:({signal:a})=>i(t,a),...n}};function WB(t,e,n){const r=UB(t,e),i=Kn.useQuery(r,n);return i.queryKey=r.queryKey,i}const HB=()=>{const t=ji();return K.useCallback((e,n)=>t({url:"https://api.enso.build/api/v1/wallet/approve",method:"GET",params:e,signal:n}),[t])},jB=t=>["https://api.enso.build/api/v1/wallet/approve",...t?[t]:[]],qB=(t,e)=>{var s;const{query:n}={},r=(s=n==null?void 0:n.queryKey)!=null?s:jB(t),i=HB();return{queryKey:r,queryFn:({signal:a})=>i(t,a),...n}};function GB(t,e,n){const r=qB(t),i=Kn.useQuery(r,n);return i.queryKey=r.queryKey,i}const KB=()=>{const t=ji();return K.useCallback((e,n)=>t({url:"https://api.enso.build/api/v1/wallet/balances",method:"GET",params:e,signal:n}),[t])},YB=t=>["https://api.enso.build/api/v1/wallet/balances",...t?[t]:[]],XB=(t,e)=>{var s;const{query:n}=e!=null?e:{},r=(s=n==null?void 0:n.queryKey)!=null?s:YB(t),i=KB();return{queryKey:r,queryFn:({signal:a})=>i(t,a),...n}};function dx(t,e,n){const r=XB(t,e),i=Kn.useQuery(r,n);return i.queryKey=r.queryKey,i}const ZB=()=>{const t=ji();return K.useCallback((e,n)=>t({url:"https://api.enso.build/api/v1/tokens",method:"GET",params:e,signal:n}),[t])},JB=t=>["https://api.enso.build/api/v1/tokens",...t?[t]:[]],QB=(t,e)=>{var s;const{query:n}=e!=null?e:{},r=(s=n==null?void 0:n.queryKey)!=null?s:JB(t),i=ZB();return{queryKey:r,queryFn:({signal:a})=>i(t,a),...n}};function e8(t,e,n){const r=QB(t,e),i=Kn.useQuery(r,n);return i.queryKey=r.queryKey,i}const t8=()=>{const t=ji();return K.useCallback((e,n)=>t({url:"https://api.enso.build/api/v1/nontokenized",method:"GET",params:e,signal:n}),[t])},n8=t=>["https://api.enso.build/api/v1/nontokenized",...t?[t]:[]],r8=(t,e)=>{var s;const{query:n}=e!=null?e:{},r=(s=n==null?void 0:n.queryKey)!=null?s:n8(t),i=t8();return{queryKey:r,queryFn:({signal:a})=>i(t,a),...n}};function hx(t,e,n){const r=r8(t,e),i=Kn.useQuery(r,n);return i.queryKey=r.queryKey,i}const i8=()=>{const t=ji();return K.useCallback((e,n)=>t({url:"https://api.enso.build/api/v1/protocols",method:"GET",params:e,signal:n}),[t])},o8=t=>["https://api.enso.build/api/v1/protocols",...t?[t]:[]],s8=(t,e)=>{var s;const{query:n}=e!=null?e:{},r=(s=n==null?void 0:n.queryKey)!=null?s:o8(t),i=i8();return{queryKey:r,queryFn:({signal:a})=>i(t,a),...n}};function a8(t,e,n){const r=s8(t,e),i=Kn.useQuery(r,n);return i.queryKey=r.queryKey,i}const l8="1.0.8";let pi=class zm extends Error{constructor(e,n={}){var s;const r=n.cause instanceof zm?n.cause.details:(s=n.cause)!=null&&s.message?n.cause.message:n.details,i=n.cause instanceof zm&&n.cause.docsPath||n.docsPath,o=[e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...i?[`Docs: https://abitype.dev${i}`]:[],...r?[`Details: ${r}`]:[],`Version: abitype@${l8}`].join(`
121
121
  `);super(o),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiTypeError"}),n.cause&&(this.cause=n.cause),this.details=r,this.docsPath=i,this.metaMessages=n.metaMessages,this.shortMessage=e}};function As(t,e){const n=t.exec(e);return n==null?void 0:n.groups}const fx=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,gx=/^u?int(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,c8=/^\(.+?\).*?$/,px=/^error (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;function u8(t){return px.test(t)}function d8(t){return As(px,t)}const mx=/^event (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)$/;function h8(t){return mx.test(t)}function f8(t){return As(mx,t)}const vx=/^function (?<name>[a-zA-Z$_][a-zA-Z0-9$_]*)\((?<parameters>.*?)\)(?: (?<scope>external|public{1}))?(?: (?<stateMutability>pure|view|nonpayable|payable{1}))?(?: returns\s?\((?<returns>.*?)\))?$/;function g8(t){return vx.test(t)}function p8(t){return As(vx,t)}const yx=/^constructor\((?<parameters>.*?)\)(?:\s(?<stateMutability>payable{1}))?$/;function m8(t){return yx.test(t)}function v8(t){return As(yx,t)}const bx=/^fallback\(\) external(?:\s(?<stateMutability>payable{1}))?$/;function y8(t){return bx.test(t)}function b8(t){return As(bx,t)}const _8=/^receive\(\) external payable$/;function x8(t){return _8.test(t)}const w8=new Set(["indexed"]),Qf=new Set(["calldata","memory","storage"]);class E8 extends pi{constructor({signature:e}){super("Failed to parse ABI item.",{details:`parseAbiItem(${JSON.stringify(e,null,2)})`,docsPath:"/api/human#parseabiitem-1"}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidAbiItemError"})}}class S8 extends pi{constructor({type:e}){super("Unknown type.",{metaMessages:[`Type "${e}" is not a valid ABI type.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSolidityTypeError"})}}class I8 extends pi{constructor({param:e}){super("Invalid ABI parameter.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParameterError"})}}class C8 extends pi{constructor({param:e,name:n}){super("Invalid ABI parameter.",{details:e,metaMessages:[`"${n}" is a protected Solidity keyword. More info: https://docs.soliditylang.org/en/latest/cheatsheet.html`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"SolidityProtectedKeywordError"})}}class A8 extends pi{constructor({param:e,type:n,modifier:r}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${r}" not allowed${n?` in "${n}" type`:""}.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidModifierError"})}}class O8 extends pi{constructor({param:e,type:n,modifier:r}){super("Invalid ABI parameter.",{details:e,metaMessages:[`Modifier "${r}" not allowed${n?` in "${n}" type`:""}.`,`Data location can only be specified for array, struct, or mapping types, but "${r}" was given.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidFunctionModifierError"})}}class tl extends pi{constructor({signature:e,type:n}){super(`Invalid ${n} signature.`,{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidSignatureError"})}}class k8 extends pi{constructor({signature:e}){super("Unknown signature.",{details:e}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"UnknownSignatureError"})}}class T8 extends pi{constructor({current:e,depth:n}){super("Unbalanced parentheses.",{metaMessages:[`"${e.trim()}" has too many ${n>0?"opening":"closing"} parentheses.`],details:`Depth "${n}"`}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"InvalidParenthesisError"})}}function R8(t,e,n){let r="";if(n)for(const i of Object.entries(n)){if(!i)continue;let o="";for(const s of i[1])o+=`[${s.type}${s.name?`:${s.name}`:""}]`;r+=`(${i[0]}{${o}})`}return e?`${e}:${t}${r}`:t}const eg=new Map([["address",{type:"address"}],["bool",{type:"bool"}],["bytes",{type:"bytes"}],["bytes32",{type:"bytes32"}],["int",{type:"int256"}],["int256",{type:"int256"}],["string",{type:"string"}],["uint",{type:"uint256"}],["uint8",{type:"uint8"}],["uint16",{type:"uint16"}],["uint24",{type:"uint24"}],["uint32",{type:"uint32"}],["uint64",{type:"uint64"}],["uint96",{type:"uint96"}],["uint112",{type:"uint112"}],["uint160",{type:"uint160"}],["uint192",{type:"uint192"}],["uint256",{type:"uint256"}],["address owner",{type:"address",name:"owner"}],["address to",{type:"address",name:"to"}],["bool approved",{type:"bool",name:"approved"}],["bytes _data",{type:"bytes",name:"_data"}],["bytes data",{type:"bytes",name:"data"}],["bytes signature",{type:"bytes",name:"signature"}],["bytes32 hash",{type:"bytes32",name:"hash"}],["bytes32 r",{type:"bytes32",name:"r"}],["bytes32 root",{type:"bytes32",name:"root"}],["bytes32 s",{type:"bytes32",name:"s"}],["string name",{type:"string",name:"name"}],["string symbol",{type:"string",name:"symbol"}],["string tokenURI",{type:"string",name:"tokenURI"}],["uint tokenId",{type:"uint256",name:"tokenId"}],["uint8 v",{type:"uint8",name:"v"}],["uint256 balance",{type:"uint256",name:"balance"}],["uint256 tokenId",{type:"uint256",name:"tokenId"}],["uint256 value",{type:"uint256",name:"value"}],["event:address indexed from",{type:"address",name:"from",indexed:!0}],["event:address indexed to",{type:"address",name:"to",indexed:!0}],["event:uint indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}],["event:uint256 indexed tokenId",{type:"uint256",name:"tokenId",indexed:!0}]]);function N8(t,e={}){if(g8(t))return P8(t,e);if(h8(t))return L8(t,e);if(u8(t))return M8(t,e);if(m8(t))return B8(t,e);if(y8(t))return F8(t);if(x8(t))return{type:"receive",stateMutability:"payable"};throw new k8({signature:t})}function P8(t,e={}){var a;const n=p8(t);if(!n)throw new tl({signature:t,type:"function"});const r=Ar(n.parameters),i=[],o=r.length;for(let l=0;l<o;l++)i.push(Os(r[l],{modifiers:Qf,structs:e,type:"function"}));const s=[];if(n.returns){const l=Ar(n.returns),c=l.length;for(let u=0;u<c;u++)s.push(Os(l[u],{modifiers:Qf,structs:e,type:"function"}))}return{name:n.name,type:"function",stateMutability:(a=n.stateMutability)!=null?a:"nonpayable",inputs:i,outputs:s}}function L8(t,e={}){const n=f8(t);if(!n)throw new tl({signature:t,type:"event"});const r=Ar(n.parameters),i=[],o=r.length;for(let s=0;s<o;s++)i.push(Os(r[s],{modifiers:w8,structs:e,type:"event"}));return{name:n.name,type:"event",inputs:i}}function M8(t,e={}){const n=d8(t);if(!n)throw new tl({signature:t,type:"error"});const r=Ar(n.parameters),i=[],o=r.length;for(let s=0;s<o;s++)i.push(Os(r[s],{structs:e,type:"error"}));return{name:n.name,type:"error",inputs:i}}function B8(t,e={}){var s;const n=v8(t);if(!n)throw new tl({signature:t,type:"constructor"});const r=Ar(n.parameters),i=[],o=r.length;for(let a=0;a<o;a++)i.push(Os(r[a],{structs:e,type:"constructor"}));return{type:"constructor",stateMutability:(s=n.stateMutability)!=null?s:"nonpayable",inputs:i}}function F8(t){var n;const e=b8(t);if(!e)throw new tl({signature:t,type:"fallback"});return{type:"fallback",stateMutability:(n=e.stateMutability)!=null?n:"nonpayable"}}const D8=/^(?<type>[a-zA-Z$_][a-zA-Z0-9$_]*)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,V8=/^\((?<type>.+?)\)(?<array>(?:\[\d*?\])+?)?(?:\s(?<modifier>calldata|indexed|memory|storage{1}))?(?:\s(?<name>[a-zA-Z$_][a-zA-Z0-9$_]*))?$/,$8=/^u?int$/;function Os(t,e){var h,p,g,b;const n=R8(t,e==null?void 0:e.type,e==null?void 0:e.structs);if(eg.has(n))return eg.get(n);const r=c8.test(t),i=As(r?V8:D8,t);if(!i)throw new I8({param:t});if(i.name&&W8(i.name))throw new C8({param:t,name:i.name});const o=i.name?{name:i.name}:{},s=i.modifier==="indexed"?{indexed:!0}:{},a=(h=e==null?void 0:e.structs)!=null?h:{};let l,c={};if(r){l="tuple";const m=Ar(i.type),x=[],I=m.length;for(let N=0;N<I;N++)x.push(Os(m[N],{structs:a}));c={components:x}}else if(i.type in a)l="tuple",c={components:a[i.type]};else if($8.test(i.type))l=`${i.type}256`;else if(l=i.type,(e==null?void 0:e.type)!=="struct"&&!z8(l))throw new S8({type:l});if(i.modifier){if(!((g=(p=e==null?void 0:e.modifiers)==null?void 0:p.has)!=null&&g.call(p,i.modifier)))throw new A8({param:t,type:e==null?void 0:e.type,modifier:i.modifier});if(Qf.has(i.modifier)&&!H8(l,!!i.array))throw new O8({param:t,type:e==null?void 0:e.type,modifier:i.modifier})}const u={type:`${l}${(b=i.array)!=null?b:""}`,...o,...s,...c};return eg.set(n,u),u}function Ar(t,e=[],n="",r=0){const i=t.trim().length;for(let o=0;o<i;o++){const s=t[o],a=t.slice(o+1);switch(s){case",":return r===0?Ar(a,[...e,n.trim()]):Ar(a,e,`${n}${s}`,r);case"(":return Ar(a,e,`${n}${s}`,r+1);case")":return Ar(a,e,`${n}${s}`,r-1);default:return Ar(a,e,`${n}${s}`,r)}}if(n==="")return e;if(r!==0)throw new T8({current:n,depth:r});return e.push(n.trim()),e}function z8(t){return t==="address"||t==="bool"||t==="function"||t==="string"||fx.test(t)||gx.test(t)}const U8=/^(?:after|alias|anonymous|apply|auto|byte|calldata|case|catch|constant|copyof|default|defined|error|event|external|false|final|function|immutable|implements|in|indexed|inline|internal|let|mapping|match|memory|mutable|null|of|override|partial|private|promise|public|pure|reference|relocatable|return|returns|sizeof|static|storage|struct|super|supports|switch|this|true|try|typedef|typeof|var|view|virtual)$/;function W8(t){return t==="address"||t==="bool"||t==="function"||t==="string"||t==="tuple"||fx.test(t)||gx.test(t)||U8.test(t)}function H8(t,e){return e||t==="bytes"||t==="string"||t==="tuple"}function j8(t){let e;if(e=N8(t),!e)throw new E8({signature:t});return e}function vu(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function mr(t){return vu(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const _x="2.33.2";let nl={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:n})=>e?`${t!=null?t:"https://viem.sh"}${e}${n?`#${n}`:""}`:void 0,version:`viem@${_x}`};class Sn extends Error{constructor(e,n={}){var a,l;const r=(()=>{var c;return n.cause instanceof Sn?n.cause.details:(c=n.cause)!=null&&c.message?n.cause.message:n.details})(),i=n.cause instanceof Sn&&n.cause.docsPath||n.docsPath,o=(a=nl.getDocsUrl)==null?void 0:a.call(nl,{...n,docsPath:i}),s=[e||"An error occurred.","",...n.metaMessages?[...n.metaMessages,""]:[],...o?[`Docs: ${o}`]:[],...r?[`Details: ${r}`]:[],...nl.version?[`Version: ${nl.version}`]:[]].join(`
122
122
  `);super(s,n.cause?{cause:n.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=i,this.metaMessages=n.metaMessages,this.name=(l=n.name)!=null?l:this.name,this.shortMessage=e,this.version=_x}walk(e){return xx(this,e)}}function xx(t,e){return e!=null&&e(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?xx(t.cause,e):e?null:t}class q8 extends Sn{constructor({expectedLength:e,givenLength:n,type:r}){super([`ABI encoding array length mismatch for type ${r}.`,`Expected length: ${e}`,`Given length: ${n}`].join(`
123
123
  `),{name:"AbiEncodingArrayLengthMismatchError"})}}class G8 extends Sn{constructor({expectedSize:e,value:n}){super(`Size of bytes "${n}" (bytes${mr(n)}) does not match expected size (bytes${e}).`,{name:"AbiEncodingBytesSizeMismatchError"})}}class K8 extends Sn{constructor({expectedLength:e,givenLength:n}){super(["ABI encoding params/values length mismatch.",`Expected length (params): ${e}`,`Given length (values): ${n}`].join(`
124
124
  `),{name:"AbiEncodingLengthMismatchError"})}}class Y8 extends Sn{constructor(e,{docsPath:n}){super([`Type "${e}" is not a valid encoding type.`,"Please provide a valid ABI type."].join(`
125
125
  `),{docsPath:n,name:"InvalidAbiEncodingType"})}}class X8 extends Sn{constructor(e){super([`Value "${e}" is not a valid array.`].join(`
126
- `),{name:"InvalidArrayError"})}}class wx extends Sn{constructor({offset:e,position:n,size:r}){super(`Slice ${n==="start"?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${r}).`,{name:"SliceOffsetOutOfBoundsError"})}}class Ex extends Sn{constructor({size:e,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${e}) exceeds padding size (${n}).`,{name:"SizeExceedsPaddingSizeError"})}}function vr(t,{dir:e,size:n=32}={}){return typeof t=="string"?qi(t,{dir:e,size:n}):Z8(t,{dir:e,size:n})}function qi(t,{dir:e,size:n=32}={}){if(n===null)return t;const r=t.replace("0x","");if(r.length>n*2)throw new Ex({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r[e==="right"?"padEnd":"padStart"](n*2,"0")}`}function Z8(t,{dir:e,size:n=32}={}){if(n===null)return t;if(t.length>n)throw new Ex({size:t.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let i=0;i<n;i++){const o=e==="right";r[o?i:n-i-1]=t[o?i:t.length-i-1]}return r}class Sx extends Sn{constructor({max:e,min:n,signed:r,size:i,value:o}){super(`Number "${o}" is not in safe ${i?`${i*8}-bit ${r?"signed":"unsigned"} `:""}integer range ${e?`(${n} to ${e})`:`(above ${n})`}`,{name:"IntegerOutOfRangeError"})}}class J8 extends Sn{constructor({givenSize:e,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function rl(t,{size:e}){if(mr(t)>e)throw new J8({givenSize:mr(t),maxSize:e})}const Q8=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function eF(t,e={}){return typeof t=="number"||typeof t=="bigint"?rr(t,e):typeof t=="string"?Ax(t,e):typeof t=="boolean"?Ix(t,e):Cx(t,e)}function Ix(t,e={}){const n=`0x${Number(t)}`;return typeof e.size=="number"?(rl(n,{size:e.size}),vr(n,{size:e.size})):n}function Cx(t,e={}){let n="";for(let i=0;i<t.length;i++)n+=Q8[t[i]];const r=`0x${n}`;return typeof e.size=="number"?(rl(r,{size:e.size}),vr(r,{dir:"right",size:e.size})):r}function rr(t,e={}){const{signed:n,size:r}=e,i=BigInt(t);let o;r?n?o=(BigInt(1)<<BigInt(r)*BigInt(8)-BigInt(1))-BigInt(1):o=BigInt(2)**(BigInt(r)*BigInt(8))-BigInt(1):typeof t=="number"&&(o=BigInt(Number.MAX_SAFE_INTEGER));const s=typeof o=="bigint"&&n?-o-BigInt(1):0;if(o&&i>o||i<s){const l=typeof t=="bigint"?"n":"";throw new Sx({max:o?`${o}${l}`:void 0,min:`${s}${l}`,signed:n,size:r,value:`${t}${l}`})}const a=`0x${(n&&i<0?(BigInt(1)<<BigInt(r*8))+BigInt(i):i).toString(16)}`;return r?vr(a,{size:r}):a}const tF=new TextEncoder;function Ax(t,e={}){const n=tF.encode(t);return Cx(n,e)}const nF=new TextEncoder;function rF(t,e={}){return typeof t=="number"||typeof t=="bigint"?oF(t,e):typeof t=="boolean"?iF(t,e):vu(t)?kx(t,e):Tx(t,e)}function iF(t,e={}){const n=new Uint8Array(1);return n[0]=Number(t),typeof e.size=="number"?(rl(n,{size:e.size}),vr(n,{size:e.size})):n}const mi={zero:48,nine:57,A:65,F:70,a:97,f:102};function Ox(t){if(t>=mi.zero&&t<=mi.nine)return t-mi.zero;if(t>=mi.A&&t<=mi.F)return t-(mi.A-10);if(t>=mi.a&&t<=mi.f)return t-(mi.a-10)}function kx(t,e={}){let n=t;e.size&&(rl(n,{size:e.size}),n=vr(n,{dir:"right",size:e.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const i=r.length/2,o=new Uint8Array(i);for(let s=0,a=0;s<i;s++){const l=Ox(r.charCodeAt(a++)),c=Ox(r.charCodeAt(a++));if(l===void 0||c===void 0)throw new Sn(`Invalid byte sequence ("${r[a-2]}${r[a-1]}" in "${r}").`);o[s]=l*16+c}return o}function oF(t,e){const n=rr(t,e);return kx(n)}function Tx(t,e={}){const n=nF.encode(t);return typeof e.size=="number"?(rl(n,{size:e.size}),vr(n,{dir:"right",size:e.size})):n}const yu=BigInt(2**32-1),Rx=BigInt(32);function sF(t,e=!1){return e?{h:Number(t&yu),l:Number(t>>Rx&yu)}:{h:Number(t>>Rx&yu)|0,l:Number(t&yu)|0}}function Nx(t,e=!1){const n=t.length;let r=new Uint32Array(n),i=new Uint32Array(n);for(let o=0;o<n;o++){const{h:s,l:a}=sF(t[o],e);[r[o],i[o]]=[s,a]}return[r,i]}const Px=(t,e,n)=>t>>>n,Lx=(t,e,n)=>t<<32-n|e>>>n,ks=(t,e,n)=>t>>>n|e<<32-n,Ts=(t,e,n)=>t<<32-n|e>>>n,bu=(t,e,n)=>t<<64-n|e>>>n-32,_u=(t,e,n)=>t>>>n-32|e<<64-n,aF=(t,e,n)=>t<<n|e>>>32-n,lF=(t,e,n)=>e<<n|t>>>32-n,cF=(t,e,n)=>e<<n-32|t>>>64-n,uF=(t,e,n)=>t<<n-32|e>>>64-n;function vi(t,e,n,r){const i=(e>>>0)+(r>>>0);return{h:t+n+(i/2**32|0)|0,l:i|0}}const dF=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),hF=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,fF=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),gF=(t,e,n,r,i)=>e+n+r+i+(t/2**32|0)|0,pF=(t,e,n,r,i)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(i>>>0),mF=(t,e,n,r,i,o)=>e+n+r+i+o+(t/2**32|0)|0,Rs=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function il(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ol(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function yi(t,...e){if(!il(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Mx(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");ol(t.outputLen),ol(t.blockLen)}function Ns(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Bx(t,e){yi(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function vF(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Gi(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function tg(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Kr(t,e){return t<<32-e|t>>>e}const yF=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function bF(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function _F(t){for(let e=0;e<t.length;e++)t[e]=bF(t[e]);return t}const Fx=yF?t=>t:_F,Dx=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",xF=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function To(t){if(yi(t),Dx)return t.toHex();let e="";for(let n=0;n<t.length;n++)e+=xF[t[n]];return e}const bi={_0:48,_9:57,A:65,F:70,a:97,f:102};function Vx(t){if(t>=bi._0&&t<=bi._9)return t-bi._0;if(t>=bi.A&&t<=bi.F)return t-(bi.A-10);if(t>=bi.a&&t<=bi.f)return t-(bi.a-10)}function xu(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(Dx)return Uint8Array.fromHex(t);const e=t.length,n=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let i=0,o=0;i<n;i++,o+=2){const s=Vx(t.charCodeAt(o)),a=Vx(t.charCodeAt(o+1));if(s===void 0||a===void 0){const l=t[o]+t[o+1];throw new Error('hex string expected, got non-hex character "'+l+'" at index '+o)}r[i]=s*16+a}return r}function wF(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function wu(t){return typeof t=="string"&&(t=wF(t)),yi(t),t}function Yr(...t){let e=0;for(let r=0;r<t.length;r++){const i=t[r];yi(i),e+=i.length}const n=new Uint8Array(e);for(let r=0,i=0;r<t.length;r++){const o=t[r];n.set(o,i),i+=o.length}return n}class ng{}function rg(t){const e=r=>t().update(wu(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function ig(t=32){if(Rs&&typeof Rs.getRandomValues=="function")return Rs.getRandomValues(new Uint8Array(t));if(Rs&&typeof Rs.randomBytes=="function")return Uint8Array.from(Rs.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}const EF=BigInt(0),sl=BigInt(1),SF=BigInt(2),IF=BigInt(7),CF=BigInt(256),AF=BigInt(113),$x=[],zx=[],Ux=[];for(let t=0,e=sl,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],$x.push(2*(5*r+n)),zx.push((t+1)*(t+2)/2%64);let i=EF;for(let o=0;o<7;o++)e=(e<<sl^(e>>IF)*AF)%CF,e&SF&&(i^=sl<<(sl<<BigInt(o))-sl);Ux.push(i)}const Wx=Nx(Ux,!0),OF=Wx[0],kF=Wx[1],Hx=(t,e,n)=>n>32?cF(t,e,n):aF(t,e,n),jx=(t,e,n)=>n>32?uF(t,e,n):lF(t,e,n);function TF(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let s=0;s<10;s++)n[s]=t[s]^t[s+10]^t[s+20]^t[s+30]^t[s+40];for(let s=0;s<10;s+=2){const a=(s+8)%10,l=(s+2)%10,c=n[l],u=n[l+1],h=Hx(c,u,1)^n[a],p=jx(c,u,1)^n[a+1];for(let g=0;g<50;g+=10)t[s+g]^=h,t[s+g+1]^=p}let i=t[2],o=t[3];for(let s=0;s<24;s++){const a=zx[s],l=Hx(i,o,a),c=jx(i,o,a),u=$x[s];i=t[u],o=t[u+1],t[u]=l,t[u+1]=c}for(let s=0;s<50;s+=10){for(let a=0;a<10;a++)n[a]=t[s+a];for(let a=0;a<10;a++)t[s+a]^=~n[(a+2)%10]&n[(a+4)%10]}t[0]^=OF[r],t[1]^=kF[r]}Gi(n)}class og extends ng{constructor(e,n,r,i=!1,o=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=n,this.outputLen=r,this.enableXOF=i,this.rounds=o,ol(r),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=vF(this.state)}clone(){return this._cloneInto()}keccak(){Fx(this.state32),TF(this.state32,this.rounds),Fx(this.state32),this.posOut=0,this.pos=0}update(e){Ns(this),e=wu(e),yi(e);const{blockLen:n,state:r}=this,i=e.length;for(let o=0;o<i;){const s=Math.min(n-this.pos,i-o);for(let a=0;a<s;a++)r[this.pos++]^=e[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:n,pos:r,blockLen:i}=this;e[r]^=n,(n&128)!==0&&r===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){Ns(this,!1),yi(e),this.finish();const n=this.state,{blockLen:r}=this;for(let i=0,o=e.length;i<o;){this.posOut>=r&&this.keccak();const s=Math.min(r-this.posOut,o-i);e.set(n.subarray(this.posOut,this.posOut+s),i),this.posOut+=s,i+=s}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return ol(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Bx(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Gi(this.state)}_cloneInto(e){const{blockLen:n,suffix:r,outputLen:i,rounds:o,enableXOF:s}=this;return e||(e=new og(n,r,i,s,o)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=o,e.suffix=r,e.outputLen=i,e.enableXOF=s,e.destroyed=this.destroyed,e}}const RF=(t,e,n)=>rg(()=>new og(e,t,n)),NF=RF(1,136,256/8);function Ps(t,e){const n=e||"hex",r=NF(vu(t,{strict:!1})?rF(t):t);return n==="bytes"?r:eF(r)}class PF extends Sn{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class qx extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const n=super.get(e);return super.has(e)&&n!==void 0&&(this.delete(e),super.set(e,n)),n}set(e,n){if(super.set(e,n),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}const sg=new qx(8192);function LF(t,e){if(sg.has(`${t}.${e}`))return sg.get(`${t}.${e}`);const n=t.substring(2).toLowerCase(),r=Ps(Tx(n),"bytes"),i=n.split("");for(let s=0;s<40;s+=2)r[s>>1]>>4>=8&&i[s]&&(i[s]=i[s].toUpperCase()),(r[s>>1]&15)>=8&&i[s+1]&&(i[s+1]=i[s+1].toUpperCase());const o=`0x${i.join("")}`;return sg.set(`${t}.${e}`,o),o}const MF=/^0x[a-fA-F0-9]{40}$/,ag=new qx(8192);function al(t,e){const{strict:n=!0}={},r=`${t}.${n}`;if(ag.has(r))return ag.get(r);const i=MF.test(t)?t.toLowerCase()===t?!0:n?LF(t)===t:!0:!1;return ag.set(r,i),i}function Or(t){return typeof t[0]=="string"?FF(t):BF(t)}function BF(t){let e=0;for(const i of t)e+=i.length;const n=new Uint8Array(e);let r=0;for(const i of t)n.set(i,r),r+=i.length;return n}function FF(t){return`0x${t.reduce((e,n)=>e+n.replace("0x",""),"")}`}function DF(t,e,n,{strict:r}={}){return vu(t,{strict:!1})?$F(t,e,n,{strict:r}):VF(t,e,n,{strict:r})}function Gx(t,e){if(typeof e=="number"&&e>0&&e>mr(t)-1)throw new wx({offset:e,position:"start",size:mr(t)})}function Kx(t,e,n){if(typeof e=="number"&&typeof n=="number"&&mr(t)!==n-e)throw new wx({offset:n,position:"end",size:mr(t)})}function VF(t,e,n,{strict:r}={}){Gx(t,e);const i=t.slice(e,n);return r&&Kx(i,e,n),i}function $F(t,e,n,{strict:r}={}){Gx(t,e);const i=`0x${t.replace("0x","").slice((e!=null?e:0)*2,(n!=null?n:t.length)*2)}`;return r&&Kx(i,e,n),i}const zF=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;function Yx(t,e){if(t.length!==e.length)throw new K8({expectedLength:t.length,givenLength:e.length});const n=UF({params:t,values:e}),r=cg(n);return r.length===0?"0x":r}function UF({params:t,values:e}){const n=[];for(let r=0;r<t.length;r++)n.push(lg({param:t[r],value:e[r]}));return n}function lg({param:t,value:e}){var r;const n=XF(t.type);if(n){const[i,o]=n;return HF(e,{length:i,param:{...t,type:o}})}if(t.type==="tuple")return YF(e,{param:t});if(t.type==="address")return WF(e);if(t.type==="bool")return qF(e);if(t.type.startsWith("uint")||t.type.startsWith("int")){const i=t.type.startsWith("int"),[,,o="256"]=(r=zF.exec(t.type))!=null?r:[];return GF(e,{signed:i,size:Number(o)})}if(t.type.startsWith("bytes"))return jF(e,{param:t});if(t.type==="string")return KF(e);throw new Y8(t.type,{docsPath:"/docs/contract/encodeAbiParameters"})}function cg(t){let e=0;for(let o=0;o<t.length;o++){const{dynamic:s,encoded:a}=t[o];s?e+=32:e+=mr(a)}const n=[],r=[];let i=0;for(let o=0;o<t.length;o++){const{dynamic:s,encoded:a}=t[o];s?(n.push(rr(e+i,{size:32})),r.push(a),i+=mr(a)):n.push(a)}return Or([...n,...r])}function WF(t){if(!al(t))throw new PF({address:t});return{dynamic:!1,encoded:qi(t.toLowerCase())}}function HF(t,{length:e,param:n}){const r=e===null;if(!Array.isArray(t))throw new X8(t);if(!r&&t.length!==e)throw new q8({expectedLength:e,givenLength:t.length,type:`${n.type}[${e}]`});let i=!1;const o=[];for(let s=0;s<t.length;s++){const a=lg({param:n,value:t[s]});a.dynamic&&(i=!0),o.push(a)}if(r||i){const s=cg(o);if(r){const a=rr(o.length,{size:32});return{dynamic:!0,encoded:o.length>0?Or([a,s]):a}}if(i)return{dynamic:!0,encoded:s}}return{dynamic:!1,encoded:Or(o.map(({encoded:s})=>s))}}function jF(t,{param:e}){const[,n]=e.type.split("bytes"),r=mr(t);if(!n){let i=t;return r%32!==0&&(i=qi(i,{dir:"right",size:Math.ceil((t.length-2)/2/32)*32})),{dynamic:!0,encoded:Or([qi(rr(r,{size:32})),i])}}if(r!==Number.parseInt(n))throw new G8({expectedSize:Number.parseInt(n),value:t});return{dynamic:!1,encoded:qi(t,{dir:"right"})}}function qF(t){if(typeof t!="boolean")throw new Sn(`Invalid boolean value: "${t}" (type: ${typeof t}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:qi(Ix(t))}}function GF(t,{signed:e,size:n=256}){if(typeof n=="number"){const r=BigInt(2)**(BigInt(n)-(e?BigInt(1):BigInt(0)))-BigInt(1),i=e?-r-BigInt(1):BigInt(0);if(t>r||t<i)throw new Sx({max:r.toString(),min:i.toString(),signed:e,size:n/8,value:t.toString()})}return{dynamic:!1,encoded:rr(t,{size:32,signed:e})}}function KF(t){const e=Ax(t),n=Math.ceil(mr(e)/32),r=[];for(let i=0;i<n;i++)r.push(qi(DF(e,i*32,(i+1)*32),{dir:"right"}));return{dynamic:!0,encoded:Or([qi(rr(mr(e),{size:32})),...r])}}function YF(t,{param:e}){let n=!1;const r=[];for(let i=0;i<e.components.length;i++){const o=e.components[i],s=Array.isArray(t)?i:o.name,a=lg({param:o,value:t[s]});r.push(a),a.dynamic&&(n=!0)}return{dynamic:n,encoded:n?cg(r):Or(r.map(({encoded:i})=>i))}}function XF(t){const e=t.match(/^(.*)\[(\d+)?\]$/);return e?[e[2]?Number(e[2]):null,e[1]]:void 0}function ZF(t,e){let n=t.toString();const r=n.startsWith("-");r&&(n=n.slice(1)),n=n.padStart(e,"0");let[i,o]=[n.slice(0,n.length-e),n.slice(n.length-e)];return o=o.replace(/(0+)$/,""),`${r?"-":""}${i||"0"}${o?`.${o}`:""}`}function JF(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),l=r?4:0,c=r?0:4;t.setUint32(e+l,s,r),t.setUint32(e+c,a,r)}function QF(t,e,n){return t&e^~t&n}function eD(t,e,n){return t&e^t&n^e&n}class Xx extends ng{constructor(e,n,r,i){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=i,this.buffer=new Uint8Array(e),this.view=tg(this.buffer)}update(e){Ns(this),e=wu(e),yi(e);const{view:n,buffer:r,blockLen:i}=this,o=e.length;for(let s=0;s<o;){const a=Math.min(i-this.pos,o-s);if(a===i){const l=tg(e);for(;i<=o-s;s+=i)this.process(l,s);continue}r.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ns(this),Bx(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:i,isLE:o}=this;let{pos:s}=this;n[s++]=128,Gi(this.buffer.subarray(s)),this.padOffset>i-s&&(this.process(r,0),s=0);for(let h=s;h<i;h++)n[h]=0;JF(r,i-8,BigInt(this.length*8),o),this.process(r,0);const a=tg(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=l/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<c;h++)a.setUint32(4*h,u[h],o)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:i,finished:o,destroyed:s,pos:a}=this;return e.destroyed=s,e.finished=o,e.length=i,e.pos=a,i%n&&e.buffer.set(r),e}clone(){return this._cloneInto()}}const Ki=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),In=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),tD=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Yi=new Uint32Array(64);class nD extends Xx{constructor(e=32){super(64,e,8,!1),this.A=Ki[0]|0,this.B=Ki[1]|0,this.C=Ki[2]|0,this.D=Ki[3]|0,this.E=Ki[4]|0,this.F=Ki[5]|0,this.G=Ki[6]|0,this.H=Ki[7]|0}get(){const{A:e,B:n,C:r,D:i,E:o,F:s,G:a,H:l}=this;return[e,n,r,i,o,s,a,l]}set(e,n,r,i,o,s,a,l){this.A=e|0,this.B=n|0,this.C=r|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=l|0}process(e,n){for(let h=0;h<16;h++,n+=4)Yi[h]=e.getUint32(n,!1);for(let h=16;h<64;h++){const p=Yi[h-15],g=Yi[h-2],b=Kr(p,7)^Kr(p,18)^p>>>3,m=Kr(g,17)^Kr(g,19)^g>>>10;Yi[h]=m+Yi[h-7]+b+Yi[h-16]|0}let{A:r,B:i,C:o,D:s,E:a,F:l,G:c,H:u}=this;for(let h=0;h<64;h++){const p=Kr(a,6)^Kr(a,11)^Kr(a,25),g=u+p+QF(a,l,c)+tD[h]+Yi[h]|0,m=(Kr(r,2)^Kr(r,13)^Kr(r,22))+eD(r,i,o)|0;u=c,c=l,l=a,a=s+g|0,s=o,o=i,i=r,r=g+m|0}r=r+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,l=l+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,i,o,s,a,l,c,u)}roundClean(){Gi(Yi)}destroy(){this.set(0,0,0,0,0,0,0,0),Gi(this.buffer)}}const Zx=Nx(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),rD=Zx[0],iD=Zx[1],Xi=new Uint32Array(80),Zi=new Uint32Array(80);class oD extends Xx{constructor(e=64){super(128,e,16,!1),this.Ah=In[0]|0,this.Al=In[1]|0,this.Bh=In[2]|0,this.Bl=In[3]|0,this.Ch=In[4]|0,this.Cl=In[5]|0,this.Dh=In[6]|0,this.Dl=In[7]|0,this.Eh=In[8]|0,this.El=In[9]|0,this.Fh=In[10]|0,this.Fl=In[11]|0,this.Gh=In[12]|0,this.Gl=In[13]|0,this.Hh=In[14]|0,this.Hl=In[15]|0}get(){const{Ah:e,Al:n,Bh:r,Bl:i,Ch:o,Cl:s,Dh:a,Dl:l,Eh:c,El:u,Fh:h,Fl:p,Gh:g,Gl:b,Hh:m,Hl:x}=this;return[e,n,r,i,o,s,a,l,c,u,h,p,g,b,m,x]}set(e,n,r,i,o,s,a,l,c,u,h,p,g,b,m,x){this.Ah=e|0,this.Al=n|0,this.Bh=r|0,this.Bl=i|0,this.Ch=o|0,this.Cl=s|0,this.Dh=a|0,this.Dl=l|0,this.Eh=c|0,this.El=u|0,this.Fh=h|0,this.Fl=p|0,this.Gh=g|0,this.Gl=b|0,this.Hh=m|0,this.Hl=x|0}process(e,n){for(let T=0;T<16;T++,n+=4)Xi[T]=e.getUint32(n),Zi[T]=e.getUint32(n+=4);for(let T=16;T<80;T++){const $=Xi[T-15]|0,B=Zi[T-15]|0,G=ks($,B,1)^ks($,B,8)^Px($,B,7),Z=Ts($,B,1)^Ts($,B,8)^Lx($,B,7),Y=Xi[T-2]|0,F=Zi[T-2]|0,V=ks(Y,F,19)^bu(Y,F,61)^Px(Y,F,6),U=Ts(Y,F,19)^_u(Y,F,61)^Lx(Y,F,6),W=fF(Z,U,Zi[T-7],Zi[T-16]),A=gF(W,G,V,Xi[T-7],Xi[T-16]);Xi[T]=A|0,Zi[T]=W|0}let{Ah:r,Al:i,Bh:o,Bl:s,Ch:a,Cl:l,Dh:c,Dl:u,Eh:h,El:p,Fh:g,Fl:b,Gh:m,Gl:x,Hh:I,Hl:N}=this;for(let T=0;T<80;T++){const $=ks(h,p,14)^ks(h,p,18)^bu(h,p,41),B=Ts(h,p,14)^Ts(h,p,18)^_u(h,p,41),G=h&g^~h&m,Z=p&b^~p&x,Y=pF(N,B,Z,iD[T],Zi[T]),F=mF(Y,I,$,G,rD[T],Xi[T]),V=Y|0,U=ks(r,i,28)^bu(r,i,34)^bu(r,i,39),W=Ts(r,i,28)^_u(r,i,34)^_u(r,i,39),A=r&o^r&a^o&a,d=i&s^i&l^s&l;I=m|0,N=x|0,m=g|0,x=b|0,g=h|0,b=p|0,{h,l:p}=vi(c|0,u|0,F|0,V|0),c=a|0,u=l|0,a=o|0,l=s|0,o=r|0,s=i|0;const y=dF(V,W,d);r=hF(y,F,U,A),i=y|0}({h:r,l:i}=vi(this.Ah|0,this.Al|0,r|0,i|0)),{h:o,l:s}=vi(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l}=vi(this.Ch|0,this.Cl|0,a|0,l|0),{h:c,l:u}=vi(this.Dh|0,this.Dl|0,c|0,u|0),{h,l:p}=vi(this.Eh|0,this.El|0,h|0,p|0),{h:g,l:b}=vi(this.Fh|0,this.Fl|0,g|0,b|0),{h:m,l:x}=vi(this.Gh|0,this.Gl|0,m|0,x|0),{h:I,l:N}=vi(this.Hh|0,this.Hl|0,I|0,N|0),this.set(r,i,o,s,a,l,c,u,h,p,g,b,m,x,I,N)}roundClean(){Gi(Xi,Zi)}destroy(){Gi(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Jx=rg(()=>new nD),sD=rg(()=>new oD),Qx=Jx,e1=[{type:"event",name:"Approval",inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}]},{type:"event",name:"Transfer",inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}]},{type:"function",name:"allowance",stateMutability:"view",inputs:[{name:"owner",type:"address"},{name:"spender",type:"address"}],outputs:[{type:"uint256"}]},{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{type:"uint8"}]},{type:"function",name:"name",stateMutability:"view",inputs:[],outputs:[{type:"string"}]},{type:"function",name:"symbol",stateMutability:"view",inputs:[],outputs:[{type:"string"}]},{type:"function",name:"totalSupply",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"sender",type:"address"},{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}];class aD extends Sn{constructor({value:e}){super(`Number \`${e}\` is not a valid decimal number.`,{name:"InvalidDecimalNumberError"})}}function lD(t,e){if(!/^(-?)([0-9]*)\.?([0-9]*)$/.test(t))throw new aD({value:t});let[n,r="0"]=t.split(".");const i=n.startsWith("-");if(i&&(n=n.slice(1)),r=r.replace(/(0+)$/,""),e===0)Math.round(+`.${r}`)===1&&(n=`${BigInt(n)+BigInt(1)}`),r="";else if(r.length>e){const[o,s,a]=[r.slice(0,e-1),r.slice(e-1,e),r.slice(e)],l=Math.round(+`${s}.${a}`);l>9?r=`${BigInt(o)+BigInt(1)}0`.padStart(o.length+1,"0"):r=`${o}${l}`,r.length>e&&(r=r.slice(1),n=`${BigInt(n)+BigInt(1)}`),r=r.slice(0,e)}else r=r.padEnd(e,"0");return BigInt(`${i?"-":""}${n}${r}`)}const cD="0x0000000000000000000000000000000000000000";class t1 extends ng{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,Mx(e);const r=wu(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,o=new Uint8Array(i);o.set(r.length>i?e.create().update(r).digest():r);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=e.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),Gi(o)}update(e){return Ns(this),this.iHash.update(e),this}digestInto(e){Ns(this),yi(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:i,destroyed:o,blockLen:s,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=o,e.blockLen=s,e.outputLen=a,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const n1=(t,e,n)=>new t1(t,e).update(n).digest();n1.create=(t,e)=>new t1(t,e);const r1=(t,e=0)=>lD(t,e).toString(),ir=(t="0",e=0)=>{try{return ZF(BigInt(t),e)}catch(n){return console.error(n),"0"}},Ro=(t,e)=>!!(t&&e&&(t==null?void 0:t.toLowerCase())===(e==null?void 0:e.toLowerCase())),ug=(t,e=!1)=>`${e?"":t.slice(0,4)}...${t.slice(-4)}`,uD=Intl.NumberFormat("en",{maximumFractionDigits:4}),dD=Intl.NumberFormat("en",{maximumFractionDigits:6}),hD=Intl.NumberFormat("en",{style:"currency",currency:"USD"}),kr=(t,e)=>{const n=e?dD:uD;return isNaN(+t)?"0.0":n.format(+t)},Tr=t=>hD.format(+t),dg=t=>`https://icons-ckg.pages.dev/stargate-light/networks/${ko[t]}.svg`,i1=()=>{const{address:t}=et.useAccount(),e=et.useConfig(),n=Be(l=>l.ensoApiToken),r=K.useMemo(()=>new Set(e.chains.map(l=>l.id)),[e.chains]),{data:i,isLoading:o}=dx({eoaAddress:t,chainId:"all"},{query:{enabled:!!t&&!!n}}),{holdingsList:s,total:a}=K.useMemo(()=>{if(!(i!=null&&i.length))return{holdingsList:[],total:0};const l=i==null?void 0:i.map(u=>({...u,total:+ir(u.amount,u.decimals)*+u.price})).filter(u=>u.total>1&&u.total<1e4&&r.has(u.chainId)).sort((u,h)=>h.total-u.total),c=l==null?void 0:l.reduce((u,{total:h})=>u+h,0);return{holdingsList:l,total:c}},[i,r]);return{holdingsList:s,total:a,isLoading:o}},fD=t=>{const e=et.useConfig(),n=Be(l=>l.ensoApiToken),r=K.useMemo(()=>new Set(e.chains.map(l=>l.id)),[e.chains]),{data:i,isLoading:o}=dx({eoaAddress:t,chainId:"all"},{query:{enabled:!!t&&!!n}}),{holdingsList:s,total:a}=K.useMemo(()=>{if(!(i!=null&&i.length))return{holdingsList:[],total:0};const l=i==null?void 0:i.map(u=>({...u,total:+ir(u.amount,u.decimals)*+u.price})).filter(u=>u.total>1&&u.total<1e4&&r.has(u.chainId)).sort((u,h)=>h.total-u.total),c=l==null?void 0:l.reduce((u,{total:h})=>u+h,0);return{holdingsList:l,total:c}},[i,r]);return{holdingsList:s,total:a,isLoading:o}},o1=t=>{var e,n;return{...t,logoURI:(e=t==null?void 0:t.logosUri)==null?void 0:e[0],underlyingTokens:(n=t==null?void 0:t.underlyingTokens)==null?void 0:n.map(o1)}},gD=[],Ls=(t,e)=>{var i,o;const{data:n,isLoading:r}=e8({address:[t],chainId:e,includeMetadata:!0},{query:{enabled:!!t&&!!e}});return{data:(i=n==null?void 0:n.data)!=null&&i.length?(o=n==null?void 0:n.data)==null?void 0:o.map(o1):gD,isLoading:r}},ll=(t,e)=>{const{data:n,isLoading:r}=MB(t,e);return{data:n==null?void 0:n.price,isLoading:r}},pD=({chainId:t,outChainId:e,fromAddress:n,receiver:r,spender:i,amountIn:o,tokenIn:s,tokenOut:a,slippage:l,referralCode:c,routingStrategy:u="router",enabled:h=!0})=>{const p={referralCode:c,amountIn:[o],tokenIn:[s],tokenOut:[a],slippage:l.toString(),fromAddress:n,receiver:r,spender:i,routingStrategy:u,chainId:t};e!==t&&(p.destinationChainId=e);const{data:[b]}=Ls(a,e),{data:[m]}=Ls(s,t),x=`Purchase ${kr(ir(o,m==null?void 0:m.decimals))} ${m==null?void 0:m.symbol} of ${b==null?void 0:b.symbol}`;return{...VB(p,{query:{retry:2,enabled:!!p.amountIn&&!!m&&!!b&&h}}),title:x}},mD=({address:t,token:e,chainId:n,amount:r})=>{const i=GB({fromAddress:t,tokenAddress:e,chainId:n,amount:r});return{approveData:i.data,approveFetched:i.isFetched}},vD=()=>{const{data:t,isLoading:e}=a8({},{query:{enabled:!0,staleTime:36e5}});return{protocolsMap:K.useMemo(()=>{if(!t)return new Map;const r=new Map;return t.forEach(i=>{r.set(i.slug.toLowerCase(),i)}),r},[t]),isLoading:e}},yD=t=>{const{protocolsMap:e,isLoading:n}=vD();return{protocolData:K.useMemo(()=>{var o;if(!t)return null;const i=e.get(t.toLowerCase());return{logoUri:((o=i==null?void 0:i.logosUri)==null?void 0:o[0])||null,name:(i==null?void 0:i.name)||t}},[t,e]),isLoading:n}},bD=(t,e)=>{var s,a;const{data:n,isLoading:r}=hx({positionId:t?[t]:void 0,chainId:e},{query:{enabled:!!t&&!!e}}),{data:i}=hx({address:t?[t]:void 0,chainId:e},{query:{enabled:!!t&&!!e}}),o=((s=n==null?void 0:n.data)==null?void 0:s[0])||((a=i==null?void 0:i.data)==null?void 0:a[0])||null;return{isNontokenized:!!o,nontokenizedData:o,isLoading:r}},_D=({chainId:t,fromAddress:e,receiver:n,spender:r,amountIn:i,tokenIn:o,positionOut:s,slippage:a,referralCode:l,outChainId:c,routingStrategy:u="router",enabled:h=!0})=>{var N;const p={referralCode:l,amountIn:[i],tokenIn:[o],positionOut:s,slippage:a.toString(),fromAddress:e,receiver:n,spender:r,routingStrategy:u,chainId:t};c!==t&&(p.destinationChainId=c);const{data:[b]}=Ls(o,t),m=`Purchase ${kr(ir(i,b==null?void 0:b.decimals))} ${b==null?void 0:b.symbol} of nontokenized position`,x=WB(p,{query:{retry:2,enabled:!!p.amountIn&&!!b&&h}}),I={...x.data,amountOut:(N=x==null?void 0:x.data)==null?void 0:N.amountDeposited};return{...x,data:I,title:m}},xD=We("div",{base:{position:"sticky",top:"0px",display:"flex",flexDirection:"column",width:"100vw",height:"100vh",justifyContent:"center",alignItems:"center"}}),wD=We("div",{base:{zIndex:1,position:"absolute",top:"0px",left:"0px",width:"100vw",height:"100vh",backgroundColor:"rgba(0, 0, 0, 0.58)"}}),ED=We("div",{base:{zIndex:2,display:"flex",flexDirection:"column",width:"100%",maxWidth:"374px",justifyContent:"center",alignItems:"center",borderRadius:"lg",border:"1px solid",borderColor:"gray.300",padding:"16px",backgroundColor:"white"}}),SD=We("div",{base:{display:"flex",width:"100%",justifyContent:"center",alignItems:"center"}}),ID=We("div",{base:{display:"flex",width:"100%",justifyContent:"center",alignItems:"center"}}),or=({children:t})=>w.jsxs(xD,{children:[w.jsx(ED,{children:t}),w.jsx(wD,{})]}),CD=({children:t})=>w.jsx(SD,{children:t});or.Header=CD;const AD=({children:t})=>w.jsx(ID,{children:t});or.Body=AD;const OD=We("p",{base:{fontWeight:"500",fontSize:"14px",lineHeight:"20px",letterSpacing:"0%",color:"fg.muted"}}),kD=({children:t,isLoading:e})=>e?w.jsxs(ue,{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"1",minWidth:"320px",children:[w.jsxs(ue,{display:"flex",alignItems:"center",gap:"1",children:[w.jsx($f,{size:"8"}),w.jsxs(ue,{display:"flex",flexDirection:"column",gap:"1",children:[w.jsx(Qa,{noOfLines:1,width:"80px"}),w.jsx(Qa,{noOfLines:1,width:"80px"})]})]}),w.jsx(ue,{display:"flex",alignItems:"center",gap:"1",children:w.jsx(Qa,{noOfLines:1,width:"80px"})})]}):t,Eu=({icon:t,title:e,balance:n,usdBalance:r,tag:i,loading:o,selected:s,onClick:a,chainId:l})=>w.jsx(qr,{onClick:a,selected:s,children:w.jsx(kD,{isLoading:o,children:w.jsxs(ue,{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"1",minWidth:"320px",children:[w.jsxs(ue,{display:"flex",alignItems:"center",gap:"1",children:[w.jsxs(ue,{position:"relative",borderRadius:"full",w:"32px",h:"32px",children:[t&&w.jsx(Rn,{borderRadius:"full",w:"32px",src:t}),l&&w.jsx(ue,{position:"absolute",bottom:"0",right:"-2px",width:"16px",height:"16px",borderRadius:"50%",overflow:"hidden",border:"1px solid",borderColor:"bg",zIndex:"1",children:w.jsx("img",{src:dg(l),alt:`Chain ${l}`,width:"100%",height:"100%"})})]}),w.jsxs(ue,{children:[w.jsx(Te,{fontWeight:"medium",color:"fg",whiteSpace:"nowrap",maxWidth:"80px",overflow:"hidden",textOverflow:"ellipsis",children:e}),w.jsx(Te,{fontSize:"xs",color:"fg.muted",children:n})]})]}),w.jsxs(ue,{display:"flex",alignItems:"center",gap:"1",children:[i&&w.jsx(tx,{children:i}),w.jsx(OD,{children:r})]})]})})});var hg=(t=>(t.LOADING="loading",t.CONNECTED="connected",t.NONE="none",t))(hg||{});const TD=({children:t,isLoading:e})=>e?w.jsxs(ue,{display:"flex",alignItems:"center",gap:"1",minWidth:"320px",children:[w.jsx($f,{size:"8"}),w.jsxs(ue,{display:"flex",flexDirection:"column",gap:"1",children:[w.jsx(Qa,{noOfLines:1,width:"80px"}),w.jsx(qr.Description,{children:"Loading wallet..."})]})]}):t,s1=({icon:t,walletHash:e,balance:n,delay:r,status:i,badge:o,onClick:s})=>w.jsx(qr,{onClick:s,children:w.jsx(TD,{isLoading:i==="loading",children:w.jsxs(ue,{display:"flex",alignItems:"center",gap:"1",minWidth:"320px",children:[w.jsxs(ue,{display:"flex",alignItems:"center",gap:"1",marginRight:"auto",children:[t&&(typeof t=="string"?w.jsx(Rn,{src:t}):t),w.jsxs(ue,{children:[w.jsx(qr.Title,{children:e}),n&&r&&w.jsxs(qr.Description,{children:[n," - ",r]})]})]}),o&&w.jsx(tx,{children:o}),i==="connected"&&w.jsx(on,{as:W4,color:"green",width:"16px",height:"16px"})]})})}),RD=({title:t,limit:e,delay:n,icons:r,onClick:i})=>w.jsx(qr,{onClick:i,children:w.jsxs(ue,{display:"flex",alignItems:"center",gap:"1",minWidth:"320px",children:[w.jsx(ue,{display:"flex",alignItems:"center",gap:"1",marginRight:"auto",children:w.jsxs(ue,{children:[w.jsx(qr.Title,{children:t}),e&&w.jsxs(qr.Description,{children:[e,n?` - ${n}`:""]})]})}),w.jsx(ue,{display:"flex",position:"relative",children:r.map((o,s)=>w.jsx(Rn,{w:"32px",h:"32px",borderRadius:"full",position:"relative",zIndex:s,right:`${0-(r.length-1-s)*10}px`,src:o}))}),w.jsx(on,{as:W_,color:"gray",width:"16px",height:"16px"})]})}),a1=t=>fetch(`https://tokens.coingecko.com/${lx[t]}/all.json`).then(e=>e.json()).then(e=>e==null?void 0:e.tokens).then(e=>[cx[t],...e]),ND=()=>fetch("https://mainnet.internal.oogabooga.io/token-list/tokens?chainId=80094&client=SWAP").then(t=>t.json()).then(t=>t.map(e=>({...e,logoURI:e.tokenURI,address:e.address===cD?Pt:e.address.toLowerCase()}))),PD=()=>fetch("https://api.rooster-protocol.xyz/api/tokens").then(t=>t.json()).then(({tokens:t})=>t),LD=t=>({[cx[t].symbol]:5,USDC:4,DAI:4,USDT:4,WBTC:4,WETH:3,LINK:3,UNI:3,SUSHI:3,AAVE:3,USDCE:2}),MD=new Promise(t=>t([{address:"0x6047828dc181963ba44974801ff68e538da5eaf9",name:"Tether USD",symbol:"USDT",decimals:6,logoURI:"https://assets.coingecko.com/coins/images/325/large/Tether.png"}])),BD=new Promise(t=>t([{address:Pt,name:"Plume",symbol:"PLUME",decimals:18,logoURI:"https://assets.coingecko.com/coins/images/53623/standard/plume-token.png?1736896935"},{address:"0x78adD880A697070c1e765Ac44D65323a0DcCE913",name:"USD Coin.e",symbol:"USDC.e",decimals:6,logoURI:"https://assets.coingecko.com/coins/images/6319/large/USD_Coin_icon.png"},{address:"0xEa237441c92CAe6FC17Caaf9a7acB3f953be4bd1",name:"Wrapped Plume",symbol:"wPlume",decimals:18,logoURI:"https://assets.coingecko.com/coins/images/53623/standard/plume-token.png?1736896935"},{address:"0xca59cA09E5602fAe8B629DeE83FfA819741f14be",name:"Wrapped Ether",symbol:"WETH",decimals:18,logoURI:"https://assets.coingecko.com/coins/images/2518/large/weth.png"}])),FD=t=>{let e=[];switch(t){case Cs.BERACHAIN:e=[ND()];break;case Cs.SONIC:e=[a1(t),MD];break;case Cs.PLUME:e=[BD,PD()];break;default:e=[a1(t)]}return Promise.allSettled(e).then(n=>{var a,l,c;const r=n.filter(u=>u.status==="fulfilled").map(u=>u.value),i=r[0];if(r.length>1){const u=new Set((l=(a=r[0])==null?void 0:a.map(p=>p.address))!=null?l:[]),h=r[0];for(let p=1;p<r.length;p++){const g=(c=r[p])==null?void 0:c.filter(b=>!u.has(b.address));g&&(h.push(...g),g.forEach(b=>u.add(b.address)))}}const o=LD(t);return[...i].sort((u,h)=>{var p,g;return(g=(p=o[h.symbol])!=null?p:0-o[u.symbol])!=null?g:0}).map(u=>({...u,address:u.address.toLowerCase()}))})},DD=t=>{const e=Su(t);return Kn.useQuery({queryKey:["tokenList",e],queryFn:()=>FD(e),enabled:!!e})},VD=(t,e)=>t==="USDT"?e===Cs.BSC?"BSC-USD":e===Cs.MAINNET?"USDT":"USDT0":t,$D=(t,e)=>{const{data:n}=DD(e);return(Array.isArray(t)?t:[t]).map(i=>n==null?void 0:n.find(o=>o.symbol==VD(i,e)))},Su=t=>{var r;const e=Be(i=>i.chainIdIn),{chainId:n=1}=et.useAccount();return(r=t!=null?t:e)!=null?r:n},zD=t=>{var e;return((e=t.charAt(0))==null?void 0:e.toUpperCase())+t.slice(1)},l1=t=>{const e=lx[t];return zD(e).split("-")[0]},UD=t=>{const n=et.useConfig().chains.find(r=>r.id===t);return(n==null?void 0:n.name)||l1(t)},Iu=({hash:t,chainId:e,type:n="/tx"})=>{const r=ux[e];if(t)return`${r}${n}/${t}`},Cu=(t,e)=>Number(parseFloat(t.toString()).toFixed(e)).toString(),c1=(t,e)=>{const n=t.replace(/[^\d.]/g,"");if(!n)return"";const r=n.endsWith("."),[i,...o]=n.split(".");let s=o.join("");return e!==void 0&&(s=s.slice(0,e)),r&&s.length===0?i?`${i}.`:".":s.length>0?i?`${i}.${s}`:`.${s}`:i},fg=t=>{if(!t||t===".")return null;const e=Number(t);return Number.isNaN(e)||e<=0?null:e},u1="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAACUUlEQVR4Ae2WA6weQRSFt7bdhrWNqLZtM6riFEFt27aCMqht27at2/3yMun8k52dmi/JyZvcOfd8O8r7vcrda/xS/YfAMXnj1x7RIEXsHxFOlhPYIZ13fU2FDCKdMrT9VpC0y9CKjE7pvTuhQFbmm6RRUk92lk8m0ibdufu1EuX6UhBev+cMvWSQRaYV6BtqYoqAtkwj0iLtHBfM98zCq8MQmWHAKZh06LGqyaOgqFWGdjK2fXZdbJ+ax2vA0BQrkPPDZIN+bJ9VZHQbkREtEWNqYTB0xw0MgF6rElekS2ETSI05G0zIDNvSfpiC5FvlSqcSH00gNeZsfWSGAbPaVrissHWFzFlXSKYViNqm8h60Se4JauGrS6aYcrNuKucZ4sFLj+ony/nwF9cuOGVZ3cKCeLyEKX1sltIEUovw0KP6yXICZXTrowSh9z0rEvhZDWMDihA13UOP6ifLCVRBCvi0dtQNRVfKevK6bz0FY0xNzeOlJ+KDwoDAqmDSAx+1L8Cl4JbyV18BY30Or/ogXVXCgBMNs6hwgs50rUioqjGmxpyqmTA0xQ4c1fouTUFScBOozwWJTCvwSjnvCmdiiquvQs0tVUA8Qb1kWoHXqsQbzOGb0m8g4WwjYqzf5KBeMq1A/p8FNXH1EYANvbtxSRBjVqjmA4FkWoHIbLhaypvxeMWcKbeevBd0+MBJGdC2tSDGqv541bzpeM1+5ztkC5D5ZTcfvc9y+/6r01duPpEtu44IYuzXzjBn7pTKcQDdunD5XstN2/aPRIyjf5f+duAnkHEA02/8X30AAAAASUVORK5CYII=",WD="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAhCAYAAAC4JqlRAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAARKSURBVHgBtVhbbBRVGP7OdrbbC9KikQgxcXnBaCLWxCcftBo1Md6ILzyokb5o2gdbkAQFk91NLMWYavHFglHgxQSf0EQTEq4Jl0C4NRDCvcslhDu9UNi2u3P4/j07e2lnZmdb+iXTOXvOmfN9/3/+888/VagQXb/pKG9Rj+Hkd60qiQqggkyKb9SNkRTa2VyqvcnzIrjqVqWxLogYXwE5a2MkXYopgItv4i3hJ8RTwNpe3W7biHNGI6YDhQHYSKxqUz3uwy7oWq9jWsgfI0gUpycSLv2lWNOrf4FGB2YAIY2eb9vUspK+4h9i+UyRC2yFDsZVrLgv7wEONDPYdgVZSPGpgSFg9ixg5KGxor4O1B4MfPxNbsduaVtF/RsDPo+aaqDzG6Aq5z9N5r//B06eAerqyj+vDdcCaWeXoPVBzncedwaA4fvA2X7gxFnjjSXv87x+bfpVqOwS0U5y5gUQMVSAulqg+0/gYB8QCQMXrgA7D9CdlvHM/KfLbweJv5C76tygm1QGx1ABdG71EDfz4SjwZAPw8gvA4DDw4VtmbPt+4PBJ/0wnsWAhg8UISHp/BHh1EdBEstoIcJtbsX0fcOM2sPcIo9w28xa/A7z9GjCe5had9vYG5zdbtOINrX1V4u4g0PYZ8Nx8cwIczJsLvLTQtGO/Ap+8Cyx63vwO0cfvvW7iZHSs4LVicE6TYgD2+wWgkP+00lgXCvl7SNS6uXzFWuAp94SeDPmRpzPA8haS68nkjrsdy5QHuQx/ucRzG6KuNsliwyPm/sxcE2zFC6bT5rpH74yl4Qt5dCFP/NCw+7jl1inR3LVicr94wqZXMra5IkxIW7cxB3wAX4iXqqo8BFBhMkgSsu0CsYiQ7ZG+2prSeecuMUXXG3FCKgG45T/TZ0/eh6SlFY7Tr9Hi3oYngNXdDJw5wLKWIvKc9c5vcW//tYLAazeBv/4hsfhVG0JJ13K5xYDKBqFGH1xcNqvenAAhHc9Z7IiQ/c/wStG6zz+iiKvcY6bg7j9oeSRHSuvDlglezzwA7JHx3R7jqGfK/f5n4OJloDps3CrisrlAmXtq1BDK+2HlVwzKMQRGuIq1ozS6evUuLtzsNVEmPUgx7fL6YTlw6jzQxww3OFRws2THZ+cB12/RrEMIguSqVrXAnAKNzfzb7CmAChpns7psN20he+VF4PctTMf3zJx9R03AiUvDVnl26k44xmXhlxElKNs+Lfzeexj4dwdfQo3uKTYAstZLo1gr4929IrpFK3/cYIIuxW1oYCU0p2HK5GJ1i9POZ0IpkRy3TES1ZY6Z3KUMmyJvFqy2E045lhNTClYqPexsxwyAwtetblUlRe+kd4FM8PLEtMhp+URygWfBsma97mCxEpv2l5HmlxEq/DJyIN+G9EYcufqtUvDIbqKAqX0bThQiHxUsHj4u9+KS/M543Txeg554ixoot3YgARPF4DH+f+ARXqmiGXvOHE0AAAAASUVORK5CYII=",HD=(t,e)=>{const n=K.useCallback(t,[]);K.useEffect(()=>{const r=setInterval(n,e);return()=>clearInterval(r)},[e,n])},d1=()=>{const[t,e]=K.useState(0);return HD(()=>{e(t+1)},1e4),t},jD=(t,e)=>{const{address:n}=et.useAccount(),r=Su(e);return et.useReadContract({chainId:r,address:t,abi:e1,functionName:"balanceOf",args:[n],query:{enabled:al(n)&&al(t)&&!Ro(t,Pt)}})},qD=(t,e)=>{var h;const{address:n}=et.useAccount(),r=Su(e),i=d1(),o=Kn.useQueryClient(),{data:s,queryKey:a}=jD(t,e),{data:l,queryKey:c}=et.useBalance({address:n,chainId:r,query:{enabled:Ro(t,Pt)}});K.useEffect(()=>{o.invalidateQueries({queryKey:a}),o.invalidateQueries({queryKey:c})},[i,o,a,c]);const u=Ro(t,Pt)?l==null?void 0:l.value:s;return(h=u==null?void 0:u.toString())!=null?h:"0"},GD=(t,e)=>{var u;const{address:n}=et.useAccount(),r=Su(),i=d1(),o=Kn.useQueryClient(),{data:s,queryKey:a,isLoading:l,isFetched:c}=et.useReadContract({chainId:r,address:t,abi:e1,functionName:"allowance",args:[n,e],query:{enabled:al(n)&&al(t)&&!Ro(t,Pt)}});return K.useEffect(()=>{o.invalidateQueries({queryKey:a})},[i,o,a]),{allowance:(u=s==null?void 0:s.toString())!=null?u:"0",allowanceFetched:c,allowanceLoading:l}},KD=(t,e="0xF75584eF6673aD213a685a1B58Cc0330B8eA22Cf",n)=>{const{allowance:r,allowanceFetched:i,allowanceLoading:o}=GD(t,e);return{approveNeeded:!Ro(t,Pt)&&+r<+n,allowanceFetched:i,allowanceLoading:o}},YD=t=>{if(!t)return u1;const e=t.toLowerCase();return e.includes("metamask")?u1:e.includes("rabby")?WD:w.jsx(Z4,{size:20})},XD=t=>{if(!t)return"Wallet";const e=t.toLowerCase();return e.includes("metamask")?"MetaMask":e.includes("rabby")?"Rabby":e.includes("walletconnect")?"WalletConnect":e.includes("injected")?"Browser Wallet":t.charAt(0).toUpperCase()+t.slice(1)};function ZD(t){return"0x1a59347d28f64091079fa04a2cbd03da63dff154"}const JD=j8("function getAddress(address) external view returns (address)"),QD=(t,e)=>{const n=ZD(),{data:r,isLoading:i,error:o}=et.useReadContract({address:n,abi:[JD],functionName:"getAddress",args:t?[t]:void 0,chainId:e,query:{enabled:!!(t&&e)}});return{smartAccountAddress:r,isLoading:i}},h1=(t=1)=>{const{address:e}=et.useAccount(),{smartAccountAddress:n,isLoading:r}=QD(e,t),{holdingsList:i,total:o,isLoading:s}=fD(n);return{smartAccountAddress:n,holdingsList:i,total:o,isLoading:r||s}},yr=()=>{const{address:t=xB}=et.useAccount(),e=Be(T=>T.amountIn),n=Be(T=>T.tokenIn),r=Be(T=>T.tokenOut),i=Be(T=>T.slippage),o=Be(T=>T.chainIdIn),s=Be(T=>T.chainIdOut),a=Be(T=>T.selectedIntegration),l=Be(T=>T.recipient),{data:[c]}=Ls(n,o),{data:[u]}=Ls(r,s),{data:h}=ll(o,n),{data:p}=ll(s,r),{isNontokenized:g,nontokenizedData:b}=bD(r,s),{protocolData:m}=yD(g?b==null?void 0:b.protocol:void 0),x=K.useMemo(()=>{if(g&&(b!=null&&b.underlyingTokens)){const T=b.underlyingTokens.map(B=>{var G;return{...B,logoURI:(G=B.logosUri)==null?void 0:G[0]}}),$=(m==null?void 0:m.name)||b.protocol;return{...T[0],underlyingTokens:T,protocol:b.protocol,protocolName:$,protocolLogo:(m==null?void 0:m.logoUri)||void 0,name:$+" "+T[0].name}}return u},[g,b,u,m]),I=ll(s,x==null?void 0:x.address);return{chainIdIn:o,chainIdOut:s,tokenInData:c,tokenOutData:u,amountIn:e,slippage:i,address:t,tokenInPrice:h,tokenOutPrice:p,tokenIn:n,tokenOut:r,selectedIntegration:a,effectiveTokenOutData:x,effectivePrice:g?I:p,isNontokenized:g,recipient:l}},eV=({address:t,chainId:e,calls:n})=>{const{sendCalls:r}=Um.useSendCalls(),{data:i}=Um.useCapabilities(),o=!1,s=et.useWalletClient();console.log(i,o,s.data);const a=K.useCallback(async(c,u)=>{var h;{console.log("Atomic not supported, sending transactions sequentially");try{for(const p of n){console.log("Sending individual transaction:",p);const g=await((h=s.data)==null?void 0:h.sendTransaction({...p,account:t,chainId:e}));if(console.log("Sequential transaction result:",g),!g)throw new Error(`Transaction failed for call: ${JSON.stringify(p)}`);p===n[n.length-1]&&c(g)}console.log("All sequential transactions completed")}catch(p){throw console.error("Error in sequential transaction:",p),u(p),p}return}},[r,n,o,e,s.data]);return{ready:n.length>0&&s.data,sendTxns:a}},Ms=()=>{const{tokenInData:t,amountIn:e,slippage:n,address:r,chainIdIn:i,chainIdOut:o,tokenInPrice:s,tokenIn:a,tokenOut:l,selectedIntegration:c,isNontokenized:u,recipient:h}=yr(),p=h||r,g=pD({routingStrategy:c!=null&&c.type?"checkout":"router",fromAddress:r,receiver:p,spender:r,amountIn:e,tokenIn:a,tokenOut:l,slippage:n,chainId:i,outChainId:o,enabled:!u}),b=_D({routingStrategy:c!=null&&c.type?"checkout":"router",fromAddress:r,receiver:p,spender:r,amountIn:e,tokenIn:a,positionOut:l,slippage:n,chainId:i,outChainId:o,enabled:u}),{data:m,isLoading:x,error:I,isFetched:N}=u?b:g,T=K.useMemo(()=>Tr(ir((+e*s).toFixed(),t==null?void 0:t.decimals)),[e,s,t==null?void 0:t.decimals]);return{chainIdOut:o,routeData:m,routeFetched:N,routeLoading:x,usdAmountIn:T,routerError:I}},f1=()=>{const{connector:t}=et.useAccount();return{walletIcon:YD(t==null?void 0:t.name),walletDisplayName:XD(t==null?void 0:t.name)}};function tV(t){const{authorization:e,factory:n,factoryData:r}=t;if(n==="0x7702"||n==="0x7702000000000000000000000000000000000000"){if(!e)return"0x7702000000000000000000000000000000000000";const i=e.address;return Or([i,r!=null?r:"0x"])}return n?Or([n,r!=null?r:"0x"]):"0x"}function nV(t){var N,T;const{callGasLimit:e,callData:n,maxPriorityFeePerGas:r,maxFeePerGas:i,paymaster:o,paymasterData:s,paymasterPostOpGasLimit:a,paymasterVerificationGasLimit:l,sender:c,signature:u="0x",verificationGasLimit:h}=t,p=Or([vr(rr(h||BigInt(0)),{size:16}),vr(rr(e||BigInt(0)),{size:16})]),g=tV(t),b=Or([vr(rr(r||BigInt(0)),{size:16}),vr(rr(i||BigInt(0)),{size:16})]),m=(N=t.nonce)!=null?N:BigInt(0),x=o?Or([o,vr(rr(l||BigInt(0)),{size:16}),vr(rr(a||BigInt(0)),{size:16}),s||"0x"]):"0x",I=(T=t.preVerificationGas)!=null?T:BigInt(0);return{accountGasLimits:p,callData:n,initCode:g,gasFees:b,nonce:m,paymasterAndData:x,preVerificationGas:I,sender:c,signature:u}}function rV(t){const{chainId:e,entryPointAddress:n}=t,r=t.userOperation,{authorization:i,callData:o="0x",callGasLimit:s,maxFeePerGas:a,maxPriorityFeePerGas:l,nonce:c,paymasterAndData:u="0x",preVerificationGas:h,sender:p,verificationGasLimit:g}=r,b=(()=>{{const m=nV(r);return Yx([{type:"address"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"},{type:"bytes32"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"}],[m.sender,m.nonce,Ps(m.initCode),Ps(m.callData),m.accountGasLimits,m.preVerificationGas,m.gasFees,Ps(m.paymasterAndData)])}})();return Ps(Yx([{type:"bytes32"},{type:"address"},{type:"uint256"}],[Ps(b),n,BigInt(e)]))}const iV=[{label:"25%",value:25},{label:"50%",value:50},{label:"75%",value:75},{label:"Max",value:100}],g1=({value:t,onChange:e,tokenSymbol:n,tokenPriceUsd:r,tokenBalance:i,roundingPrecision:o=6,usdPrecision:s=2,percentOptions:a=iV,onPercentSelect:l,showPercentTabs:c=!0})=>{const u=B=>{e({...t,...B})},h=B=>{if(t.mode==="usd"){const Z=c1(B.replace("$",""),s);if(!Z||Z==="."){u({usdAmount:Z,tokenAmount:""});return}if(!r||r<=0){u({usdAmount:Z,tokenAmount:""});return}const Y=Cu(parseFloat(Z)/r,o);u({usdAmount:Z,tokenAmount:Y});return}const G=c1(B,o);if(!G||G==="."){u({tokenAmount:G,usdAmount:""});return}if(!r||r<=0){u({tokenAmount:G});return}u({tokenAmount:G,usdAmount:(parseFloat(G)*r).toFixed(s)})},p=()=>{u({mode:t.mode==="usd"?"token":"usd"})},g=B=>{if(l){const Z=l(B);if(!Z)return;u(Z);return}if(!i||!r||r<=0)return;const G=Cu(i*B/100,o);u({tokenAmount:G,usdAmount:(parseFloat(G||"0")*r).toFixed(s)})},b=t.mode==="usd"?"$10.00":"0.00",m=t.mode==="usd"?t.usdAmount?`$${t.usdAmount}`:"":t.tokenAmount,x=!!t.tokenAmount&&t.tokenAmount!==".",I=!!t.usdAmount&&t.usdAmount!==".",N=x?kr(t.tokenAmount):"",T=n?` ${n}`:"",$=t.mode==="usd"?x?`${N}${T}`:"—":I?Tr(t.usdAmount):"—";return w.jsxs(ue,{display:"flex",flexDirection:"column",gap:"8px",children:[w.jsxs(ue,{display:"flex",flexDirection:"column",gap:"8px",alignItems:"center",padding:"25.5px",children:[w.jsx(Yf,{inputMode:"decimal",marginY:"8px",variant:"text",placeholder:b,value:m,onChange:B=>h(B.target.value)}),w.jsxs(ue,{display:"flex",gap:"3",alignItems:"center",onClick:p,_hover:{background:"bg.subtle"},cursor:"pointer",borderRadius:"lg",px:"3",children:[w.jsx(gi,{minWidth:"24px",minHeight:"24px",maxWidth:"24px",background:"transparent",children:w.jsx(on,{as:U4,color:"gray",width:"16px",height:"16px"})}),w.jsx(Te,{fontSize:"sm",color:"fg.muted",children:$})]})]}),c&&a.length>0&&w.jsx(ue,{display:"flex",gap:"4px",justifyContent:"center",paddingBottom:"35px",children:a.map(B=>w.jsx(fB,{onClick:()=>g(B.value),children:B.label},B.label))})]})};var oV=["integrationConnected","integrationConnectionError","integrationMfaRequired","integrationMfaEntered","integrationOAuthStarted","integrationAccountSelectionRequired","transferCompleted","integrationSelected","credentialsEntered","transferStarted","transferPreviewed","transferPreviewError","transferExecutionError","pageLoaded","transferAssetSelected","transferNetworkSelected","transferAmountEntered","transferMfaRequired","transferMfaEntered","transferKycRequired","transferExecuted","transferInitiated","transferNoEligibleAssets","walletMessageSigned","verifyDonePage","verifyWalletRejected","connectionDeclined","transferConfigureError","connectionUnavailable","transferDeclined","done","close","SDKinjectedWalletProviders","legalTermsViewed","seeWhatHappenedClicked","executeFundingStep","fundingOptionsUpdated","fundingOptionsViewed","gasIncreaseWarning","linkTransferQRGenerated","methodSelected"];function sV(t){return oV.includes(t)}function aV(t){try{var e=new URLSearchParams(new URL(t).search),n=e.get("link_style");return n&&JSON.parse(window.atob(n))}catch(r){return}}function gg(t,e){return e!==void 0?e:t}var pg="mesh-link-popup",p1="mesh-link-popup__backdrop",Bs="mesh-link-popup__popup-content",m1="mesh-link-popup__styles",mg="mesh-link-popup__iframe",lV=function(t){return`
126
+ `),{name:"InvalidArrayError"})}}class wx extends Sn{constructor({offset:e,position:n,size:r}){super(`Slice ${n==="start"?"starting":"ending"} at offset "${e}" is out-of-bounds (size: ${r}).`,{name:"SliceOffsetOutOfBoundsError"})}}class Ex extends Sn{constructor({size:e,targetSize:n,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${e}) exceeds padding size (${n}).`,{name:"SizeExceedsPaddingSizeError"})}}function vr(t,{dir:e,size:n=32}={}){return typeof t=="string"?qi(t,{dir:e,size:n}):Z8(t,{dir:e,size:n})}function qi(t,{dir:e,size:n=32}={}){if(n===null)return t;const r=t.replace("0x","");if(r.length>n*2)throw new Ex({size:Math.ceil(r.length/2),targetSize:n,type:"hex"});return`0x${r[e==="right"?"padEnd":"padStart"](n*2,"0")}`}function Z8(t,{dir:e,size:n=32}={}){if(n===null)return t;if(t.length>n)throw new Ex({size:t.length,targetSize:n,type:"bytes"});const r=new Uint8Array(n);for(let i=0;i<n;i++){const o=e==="right";r[o?i:n-i-1]=t[o?i:t.length-i-1]}return r}class Sx extends Sn{constructor({max:e,min:n,signed:r,size:i,value:o}){super(`Number "${o}" is not in safe ${i?`${i*8}-bit ${r?"signed":"unsigned"} `:""}integer range ${e?`(${n} to ${e})`:`(above ${n})`}`,{name:"IntegerOutOfRangeError"})}}class J8 extends Sn{constructor({givenSize:e,maxSize:n}){super(`Size cannot exceed ${n} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function rl(t,{size:e}){if(mr(t)>e)throw new J8({givenSize:mr(t),maxSize:e})}const Q8=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function eF(t,e={}){return typeof t=="number"||typeof t=="bigint"?rr(t,e):typeof t=="string"?Ax(t,e):typeof t=="boolean"?Ix(t,e):Cx(t,e)}function Ix(t,e={}){const n=`0x${Number(t)}`;return typeof e.size=="number"?(rl(n,{size:e.size}),vr(n,{size:e.size})):n}function Cx(t,e={}){let n="";for(let i=0;i<t.length;i++)n+=Q8[t[i]];const r=`0x${n}`;return typeof e.size=="number"?(rl(r,{size:e.size}),vr(r,{dir:"right",size:e.size})):r}function rr(t,e={}){const{signed:n,size:r}=e,i=BigInt(t);let o;r?n?o=(BigInt(1)<<BigInt(r)*BigInt(8)-BigInt(1))-BigInt(1):o=BigInt(2)**(BigInt(r)*BigInt(8))-BigInt(1):typeof t=="number"&&(o=BigInt(Number.MAX_SAFE_INTEGER));const s=typeof o=="bigint"&&n?-o-BigInt(1):0;if(o&&i>o||i<s){const l=typeof t=="bigint"?"n":"";throw new Sx({max:o?`${o}${l}`:void 0,min:`${s}${l}`,signed:n,size:r,value:`${t}${l}`})}const a=`0x${(n&&i<0?(BigInt(1)<<BigInt(r*8))+BigInt(i):i).toString(16)}`;return r?vr(a,{size:r}):a}const tF=new TextEncoder;function Ax(t,e={}){const n=tF.encode(t);return Cx(n,e)}const nF=new TextEncoder;function rF(t,e={}){return typeof t=="number"||typeof t=="bigint"?oF(t,e):typeof t=="boolean"?iF(t,e):vu(t)?kx(t,e):Tx(t,e)}function iF(t,e={}){const n=new Uint8Array(1);return n[0]=Number(t),typeof e.size=="number"?(rl(n,{size:e.size}),vr(n,{size:e.size})):n}const mi={zero:48,nine:57,A:65,F:70,a:97,f:102};function Ox(t){if(t>=mi.zero&&t<=mi.nine)return t-mi.zero;if(t>=mi.A&&t<=mi.F)return t-(mi.A-10);if(t>=mi.a&&t<=mi.f)return t-(mi.a-10)}function kx(t,e={}){let n=t;e.size&&(rl(n,{size:e.size}),n=vr(n,{dir:"right",size:e.size}));let r=n.slice(2);r.length%2&&(r=`0${r}`);const i=r.length/2,o=new Uint8Array(i);for(let s=0,a=0;s<i;s++){const l=Ox(r.charCodeAt(a++)),c=Ox(r.charCodeAt(a++));if(l===void 0||c===void 0)throw new Sn(`Invalid byte sequence ("${r[a-2]}${r[a-1]}" in "${r}").`);o[s]=l*16+c}return o}function oF(t,e){const n=rr(t,e);return kx(n)}function Tx(t,e={}){const n=nF.encode(t);return typeof e.size=="number"?(rl(n,{size:e.size}),vr(n,{dir:"right",size:e.size})):n}const yu=BigInt(2**32-1),Rx=BigInt(32);function sF(t,e=!1){return e?{h:Number(t&yu),l:Number(t>>Rx&yu)}:{h:Number(t>>Rx&yu)|0,l:Number(t&yu)|0}}function Nx(t,e=!1){const n=t.length;let r=new Uint32Array(n),i=new Uint32Array(n);for(let o=0;o<n;o++){const{h:s,l:a}=sF(t[o],e);[r[o],i[o]]=[s,a]}return[r,i]}const Px=(t,e,n)=>t>>>n,Lx=(t,e,n)=>t<<32-n|e>>>n,ks=(t,e,n)=>t>>>n|e<<32-n,Ts=(t,e,n)=>t<<32-n|e>>>n,bu=(t,e,n)=>t<<64-n|e>>>n-32,_u=(t,e,n)=>t>>>n-32|e<<64-n,aF=(t,e,n)=>t<<n|e>>>32-n,lF=(t,e,n)=>e<<n|t>>>32-n,cF=(t,e,n)=>e<<n-32|t>>>64-n,uF=(t,e,n)=>t<<n-32|e>>>64-n;function vi(t,e,n,r){const i=(e>>>0)+(r>>>0);return{h:t+n+(i/2**32|0)|0,l:i|0}}const dF=(t,e,n)=>(t>>>0)+(e>>>0)+(n>>>0),hF=(t,e,n,r)=>e+n+r+(t/2**32|0)|0,fF=(t,e,n,r)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0),gF=(t,e,n,r,i)=>e+n+r+i+(t/2**32|0)|0,pF=(t,e,n,r,i)=>(t>>>0)+(e>>>0)+(n>>>0)+(r>>>0)+(i>>>0),mF=(t,e,n,r,i,o)=>e+n+r+i+o+(t/2**32|0)|0,Rs=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function il(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ol(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function yi(t,...e){if(!il(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function Mx(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");ol(t.outputLen),ol(t.blockLen)}function Ns(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Bx(t,e){yi(t);const n=e.outputLen;if(t.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function vF(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Gi(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function tg(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Kr(t,e){return t<<32-e|t>>>e}const yF=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function bF(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function _F(t){for(let e=0;e<t.length;e++)t[e]=bF(t[e]);return t}const Fx=yF?t=>t:_F,Dx=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",xF=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function To(t){if(yi(t),Dx)return t.toHex();let e="";for(let n=0;n<t.length;n++)e+=xF[t[n]];return e}const bi={_0:48,_9:57,A:65,F:70,a:97,f:102};function Vx(t){if(t>=bi._0&&t<=bi._9)return t-bi._0;if(t>=bi.A&&t<=bi.F)return t-(bi.A-10);if(t>=bi.a&&t<=bi.f)return t-(bi.a-10)}function xu(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(Dx)return Uint8Array.fromHex(t);const e=t.length,n=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const r=new Uint8Array(n);for(let i=0,o=0;i<n;i++,o+=2){const s=Vx(t.charCodeAt(o)),a=Vx(t.charCodeAt(o+1));if(s===void 0||a===void 0){const l=t[o]+t[o+1];throw new Error('hex string expected, got non-hex character "'+l+'" at index '+o)}r[i]=s*16+a}return r}function wF(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function wu(t){return typeof t=="string"&&(t=wF(t)),yi(t),t}function Yr(...t){let e=0;for(let r=0;r<t.length;r++){const i=t[r];yi(i),e+=i.length}const n=new Uint8Array(e);for(let r=0,i=0;r<t.length;r++){const o=t[r];n.set(o,i),i+=o.length}return n}class ng{}function rg(t){const e=r=>t().update(wu(r)).digest(),n=t();return e.outputLen=n.outputLen,e.blockLen=n.blockLen,e.create=()=>t(),e}function ig(t=32){if(Rs&&typeof Rs.getRandomValues=="function")return Rs.getRandomValues(new Uint8Array(t));if(Rs&&typeof Rs.randomBytes=="function")return Uint8Array.from(Rs.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}const EF=BigInt(0),sl=BigInt(1),SF=BigInt(2),IF=BigInt(7),CF=BigInt(256),AF=BigInt(113),$x=[],zx=[],Ux=[];for(let t=0,e=sl,n=1,r=0;t<24;t++){[n,r]=[r,(2*n+3*r)%5],$x.push(2*(5*r+n)),zx.push((t+1)*(t+2)/2%64);let i=EF;for(let o=0;o<7;o++)e=(e<<sl^(e>>IF)*AF)%CF,e&SF&&(i^=sl<<(sl<<BigInt(o))-sl);Ux.push(i)}const Wx=Nx(Ux,!0),OF=Wx[0],kF=Wx[1],Hx=(t,e,n)=>n>32?cF(t,e,n):aF(t,e,n),jx=(t,e,n)=>n>32?uF(t,e,n):lF(t,e,n);function TF(t,e=24){const n=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let s=0;s<10;s++)n[s]=t[s]^t[s+10]^t[s+20]^t[s+30]^t[s+40];for(let s=0;s<10;s+=2){const a=(s+8)%10,l=(s+2)%10,c=n[l],u=n[l+1],h=Hx(c,u,1)^n[a],p=jx(c,u,1)^n[a+1];for(let g=0;g<50;g+=10)t[s+g]^=h,t[s+g+1]^=p}let i=t[2],o=t[3];for(let s=0;s<24;s++){const a=zx[s],l=Hx(i,o,a),c=jx(i,o,a),u=$x[s];i=t[u],o=t[u+1],t[u]=l,t[u+1]=c}for(let s=0;s<50;s+=10){for(let a=0;a<10;a++)n[a]=t[s+a];for(let a=0;a<10;a++)t[s+a]^=~n[(a+2)%10]&n[(a+4)%10]}t[0]^=OF[r],t[1]^=kF[r]}Gi(n)}class og extends ng{constructor(e,n,r,i=!1,o=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=n,this.outputLen=r,this.enableXOF=i,this.rounds=o,ol(r),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=vF(this.state)}clone(){return this._cloneInto()}keccak(){Fx(this.state32),TF(this.state32,this.rounds),Fx(this.state32),this.posOut=0,this.pos=0}update(e){Ns(this),e=wu(e),yi(e);const{blockLen:n,state:r}=this,i=e.length;for(let o=0;o<i;){const s=Math.min(n-this.pos,i-o);for(let a=0;a<s;a++)r[this.pos++]^=e[o++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:n,pos:r,blockLen:i}=this;e[r]^=n,(n&128)!==0&&r===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){Ns(this,!1),yi(e),this.finish();const n=this.state,{blockLen:r}=this;for(let i=0,o=e.length;i<o;){this.posOut>=r&&this.keccak();const s=Math.min(r-this.posOut,o-i);e.set(n.subarray(this.posOut,this.posOut+s),i),this.posOut+=s,i+=s}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return ol(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Bx(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Gi(this.state)}_cloneInto(e){const{blockLen:n,suffix:r,outputLen:i,rounds:o,enableXOF:s}=this;return e||(e=new og(n,r,i,s,o)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=o,e.suffix=r,e.outputLen=i,e.enableXOF=s,e.destroyed=this.destroyed,e}}const RF=(t,e,n)=>rg(()=>new og(e,t,n)),NF=RF(1,136,256/8);function Ps(t,e){const n=e||"hex",r=NF(vu(t,{strict:!1})?rF(t):t);return n==="bytes"?r:eF(r)}class PF extends Sn{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class qx extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const n=super.get(e);return super.has(e)&&n!==void 0&&(this.delete(e),super.set(e,n)),n}set(e,n){if(super.set(e,n),this.maxSize&&this.size>this.maxSize){const r=this.keys().next().value;r&&this.delete(r)}return this}}const sg=new qx(8192);function LF(t,e){if(sg.has(`${t}.${e}`))return sg.get(`${t}.${e}`);const n=t.substring(2).toLowerCase(),r=Ps(Tx(n),"bytes"),i=n.split("");for(let s=0;s<40;s+=2)r[s>>1]>>4>=8&&i[s]&&(i[s]=i[s].toUpperCase()),(r[s>>1]&15)>=8&&i[s+1]&&(i[s+1]=i[s+1].toUpperCase());const o=`0x${i.join("")}`;return sg.set(`${t}.${e}`,o),o}const MF=/^0x[a-fA-F0-9]{40}$/,ag=new qx(8192);function al(t,e){const{strict:n=!0}={},r=`${t}.${n}`;if(ag.has(r))return ag.get(r);const i=MF.test(t)?t.toLowerCase()===t?!0:n?LF(t)===t:!0:!1;return ag.set(r,i),i}function Or(t){return typeof t[0]=="string"?FF(t):BF(t)}function BF(t){let e=0;for(const i of t)e+=i.length;const n=new Uint8Array(e);let r=0;for(const i of t)n.set(i,r),r+=i.length;return n}function FF(t){return`0x${t.reduce((e,n)=>e+n.replace("0x",""),"")}`}function DF(t,e,n,{strict:r}={}){return vu(t,{strict:!1})?$F(t,e,n,{strict:r}):VF(t,e,n,{strict:r})}function Gx(t,e){if(typeof e=="number"&&e>0&&e>mr(t)-1)throw new wx({offset:e,position:"start",size:mr(t)})}function Kx(t,e,n){if(typeof e=="number"&&typeof n=="number"&&mr(t)!==n-e)throw new wx({offset:n,position:"end",size:mr(t)})}function VF(t,e,n,{strict:r}={}){Gx(t,e);const i=t.slice(e,n);return r&&Kx(i,e,n),i}function $F(t,e,n,{strict:r}={}){Gx(t,e);const i=`0x${t.replace("0x","").slice((e!=null?e:0)*2,(n!=null?n:t.length)*2)}`;return r&&Kx(i,e,n),i}const zF=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/;function Yx(t,e){if(t.length!==e.length)throw new K8({expectedLength:t.length,givenLength:e.length});const n=UF({params:t,values:e}),r=cg(n);return r.length===0?"0x":r}function UF({params:t,values:e}){const n=[];for(let r=0;r<t.length;r++)n.push(lg({param:t[r],value:e[r]}));return n}function lg({param:t,value:e}){var r;const n=XF(t.type);if(n){const[i,o]=n;return HF(e,{length:i,param:{...t,type:o}})}if(t.type==="tuple")return YF(e,{param:t});if(t.type==="address")return WF(e);if(t.type==="bool")return qF(e);if(t.type.startsWith("uint")||t.type.startsWith("int")){const i=t.type.startsWith("int"),[,,o="256"]=(r=zF.exec(t.type))!=null?r:[];return GF(e,{signed:i,size:Number(o)})}if(t.type.startsWith("bytes"))return jF(e,{param:t});if(t.type==="string")return KF(e);throw new Y8(t.type,{docsPath:"/docs/contract/encodeAbiParameters"})}function cg(t){let e=0;for(let o=0;o<t.length;o++){const{dynamic:s,encoded:a}=t[o];s?e+=32:e+=mr(a)}const n=[],r=[];let i=0;for(let o=0;o<t.length;o++){const{dynamic:s,encoded:a}=t[o];s?(n.push(rr(e+i,{size:32})),r.push(a),i+=mr(a)):n.push(a)}return Or([...n,...r])}function WF(t){if(!al(t))throw new PF({address:t});return{dynamic:!1,encoded:qi(t.toLowerCase())}}function HF(t,{length:e,param:n}){const r=e===null;if(!Array.isArray(t))throw new X8(t);if(!r&&t.length!==e)throw new q8({expectedLength:e,givenLength:t.length,type:`${n.type}[${e}]`});let i=!1;const o=[];for(let s=0;s<t.length;s++){const a=lg({param:n,value:t[s]});a.dynamic&&(i=!0),o.push(a)}if(r||i){const s=cg(o);if(r){const a=rr(o.length,{size:32});return{dynamic:!0,encoded:o.length>0?Or([a,s]):a}}if(i)return{dynamic:!0,encoded:s}}return{dynamic:!1,encoded:Or(o.map(({encoded:s})=>s))}}function jF(t,{param:e}){const[,n]=e.type.split("bytes"),r=mr(t);if(!n){let i=t;return r%32!==0&&(i=qi(i,{dir:"right",size:Math.ceil((t.length-2)/2/32)*32})),{dynamic:!0,encoded:Or([qi(rr(r,{size:32})),i])}}if(r!==Number.parseInt(n))throw new G8({expectedSize:Number.parseInt(n),value:t});return{dynamic:!1,encoded:qi(t,{dir:"right"})}}function qF(t){if(typeof t!="boolean")throw new Sn(`Invalid boolean value: "${t}" (type: ${typeof t}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:qi(Ix(t))}}function GF(t,{signed:e,size:n=256}){if(typeof n=="number"){const r=BigInt(2)**(BigInt(n)-(e?BigInt(1):BigInt(0)))-BigInt(1),i=e?-r-BigInt(1):BigInt(0);if(t>r||t<i)throw new Sx({max:r.toString(),min:i.toString(),signed:e,size:n/8,value:t.toString()})}return{dynamic:!1,encoded:rr(t,{size:32,signed:e})}}function KF(t){const e=Ax(t),n=Math.ceil(mr(e)/32),r=[];for(let i=0;i<n;i++)r.push(qi(DF(e,i*32,(i+1)*32),{dir:"right"}));return{dynamic:!0,encoded:Or([qi(rr(mr(e),{size:32})),...r])}}function YF(t,{param:e}){let n=!1;const r=[];for(let i=0;i<e.components.length;i++){const o=e.components[i],s=Array.isArray(t)?i:o.name,a=lg({param:o,value:t[s]});r.push(a),a.dynamic&&(n=!0)}return{dynamic:n,encoded:n?cg(r):Or(r.map(({encoded:i})=>i))}}function XF(t){const e=t.match(/^(.*)\[(\d+)?\]$/);return e?[e[2]?Number(e[2]):null,e[1]]:void 0}function ZF(t,e){let n=t.toString();const r=n.startsWith("-");r&&(n=n.slice(1)),n=n.padStart(e,"0");let[i,o]=[n.slice(0,n.length-e),n.slice(n.length-e)];return o=o.replace(/(0+)$/,""),`${r?"-":""}${i||"0"}${o?`.${o}`:""}`}function JF(t,e,n,r){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,n,r);const i=BigInt(32),o=BigInt(4294967295),s=Number(n>>i&o),a=Number(n&o),l=r?4:0,c=r?0:4;t.setUint32(e+l,s,r),t.setUint32(e+c,a,r)}function QF(t,e,n){return t&e^~t&n}function eD(t,e,n){return t&e^t&n^e&n}class Xx extends ng{constructor(e,n,r,i){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=n,this.padOffset=r,this.isLE=i,this.buffer=new Uint8Array(e),this.view=tg(this.buffer)}update(e){Ns(this),e=wu(e),yi(e);const{view:n,buffer:r,blockLen:i}=this,o=e.length;for(let s=0;s<o;){const a=Math.min(i-this.pos,o-s);if(a===i){const l=tg(e);for(;i<=o-s;s+=i)this.process(l,s);continue}r.set(e.subarray(s,s+a),this.pos),this.pos+=a,s+=a,this.pos===i&&(this.process(n,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Ns(this),Bx(e,this),this.finished=!0;const{buffer:n,view:r,blockLen:i,isLE:o}=this;let{pos:s}=this;n[s++]=128,Gi(this.buffer.subarray(s)),this.padOffset>i-s&&(this.process(r,0),s=0);for(let h=s;h<i;h++)n[h]=0;JF(r,i-8,BigInt(this.length*8),o),this.process(r,0);const a=tg(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=l/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let h=0;h<c;h++)a.setUint32(4*h,u[h],o)}digest(){const{buffer:e,outputLen:n}=this;this.digestInto(e);const r=e.slice(0,n);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:n,buffer:r,length:i,finished:o,destroyed:s,pos:a}=this;return e.destroyed=s,e.finished=o,e.length=i,e.pos=a,i%n&&e.buffer.set(r),e}clone(){return this._cloneInto()}}const Ki=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),In=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),tD=Uint32Array.from([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),Yi=new Uint32Array(64);class nD extends Xx{constructor(e=32){super(64,e,8,!1),this.A=Ki[0]|0,this.B=Ki[1]|0,this.C=Ki[2]|0,this.D=Ki[3]|0,this.E=Ki[4]|0,this.F=Ki[5]|0,this.G=Ki[6]|0,this.H=Ki[7]|0}get(){const{A:e,B:n,C:r,D:i,E:o,F:s,G:a,H:l}=this;return[e,n,r,i,o,s,a,l]}set(e,n,r,i,o,s,a,l){this.A=e|0,this.B=n|0,this.C=r|0,this.D=i|0,this.E=o|0,this.F=s|0,this.G=a|0,this.H=l|0}process(e,n){for(let h=0;h<16;h++,n+=4)Yi[h]=e.getUint32(n,!1);for(let h=16;h<64;h++){const p=Yi[h-15],g=Yi[h-2],b=Kr(p,7)^Kr(p,18)^p>>>3,m=Kr(g,17)^Kr(g,19)^g>>>10;Yi[h]=m+Yi[h-7]+b+Yi[h-16]|0}let{A:r,B:i,C:o,D:s,E:a,F:l,G:c,H:u}=this;for(let h=0;h<64;h++){const p=Kr(a,6)^Kr(a,11)^Kr(a,25),g=u+p+QF(a,l,c)+tD[h]+Yi[h]|0,m=(Kr(r,2)^Kr(r,13)^Kr(r,22))+eD(r,i,o)|0;u=c,c=l,l=a,a=s+g|0,s=o,o=i,i=r,r=g+m|0}r=r+this.A|0,i=i+this.B|0,o=o+this.C|0,s=s+this.D|0,a=a+this.E|0,l=l+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,i,o,s,a,l,c,u)}roundClean(){Gi(Yi)}destroy(){this.set(0,0,0,0,0,0,0,0),Gi(this.buffer)}}const Zx=Nx(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),rD=Zx[0],iD=Zx[1],Xi=new Uint32Array(80),Zi=new Uint32Array(80);class oD extends Xx{constructor(e=64){super(128,e,16,!1),this.Ah=In[0]|0,this.Al=In[1]|0,this.Bh=In[2]|0,this.Bl=In[3]|0,this.Ch=In[4]|0,this.Cl=In[5]|0,this.Dh=In[6]|0,this.Dl=In[7]|0,this.Eh=In[8]|0,this.El=In[9]|0,this.Fh=In[10]|0,this.Fl=In[11]|0,this.Gh=In[12]|0,this.Gl=In[13]|0,this.Hh=In[14]|0,this.Hl=In[15]|0}get(){const{Ah:e,Al:n,Bh:r,Bl:i,Ch:o,Cl:s,Dh:a,Dl:l,Eh:c,El:u,Fh:h,Fl:p,Gh:g,Gl:b,Hh:m,Hl:x}=this;return[e,n,r,i,o,s,a,l,c,u,h,p,g,b,m,x]}set(e,n,r,i,o,s,a,l,c,u,h,p,g,b,m,x){this.Ah=e|0,this.Al=n|0,this.Bh=r|0,this.Bl=i|0,this.Ch=o|0,this.Cl=s|0,this.Dh=a|0,this.Dl=l|0,this.Eh=c|0,this.El=u|0,this.Fh=h|0,this.Fl=p|0,this.Gh=g|0,this.Gl=b|0,this.Hh=m|0,this.Hl=x|0}process(e,n){for(let T=0;T<16;T++,n+=4)Xi[T]=e.getUint32(n),Zi[T]=e.getUint32(n+=4);for(let T=16;T<80;T++){const $=Xi[T-15]|0,B=Zi[T-15]|0,G=ks($,B,1)^ks($,B,8)^Px($,B,7),Z=Ts($,B,1)^Ts($,B,8)^Lx($,B,7),Y=Xi[T-2]|0,F=Zi[T-2]|0,V=ks(Y,F,19)^bu(Y,F,61)^Px(Y,F,6),U=Ts(Y,F,19)^_u(Y,F,61)^Lx(Y,F,6),W=fF(Z,U,Zi[T-7],Zi[T-16]),A=gF(W,G,V,Xi[T-7],Xi[T-16]);Xi[T]=A|0,Zi[T]=W|0}let{Ah:r,Al:i,Bh:o,Bl:s,Ch:a,Cl:l,Dh:c,Dl:u,Eh:h,El:p,Fh:g,Fl:b,Gh:m,Gl:x,Hh:I,Hl:N}=this;for(let T=0;T<80;T++){const $=ks(h,p,14)^ks(h,p,18)^bu(h,p,41),B=Ts(h,p,14)^Ts(h,p,18)^_u(h,p,41),G=h&g^~h&m,Z=p&b^~p&x,Y=pF(N,B,Z,iD[T],Zi[T]),F=mF(Y,I,$,G,rD[T],Xi[T]),V=Y|0,U=ks(r,i,28)^bu(r,i,34)^bu(r,i,39),W=Ts(r,i,28)^_u(r,i,34)^_u(r,i,39),A=r&o^r&a^o&a,d=i&s^i&l^s&l;I=m|0,N=x|0,m=g|0,x=b|0,g=h|0,b=p|0,{h,l:p}=vi(c|0,u|0,F|0,V|0),c=a|0,u=l|0,a=o|0,l=s|0,o=r|0,s=i|0;const y=dF(V,W,d);r=hF(y,F,U,A),i=y|0}({h:r,l:i}=vi(this.Ah|0,this.Al|0,r|0,i|0)),{h:o,l:s}=vi(this.Bh|0,this.Bl|0,o|0,s|0),{h:a,l}=vi(this.Ch|0,this.Cl|0,a|0,l|0),{h:c,l:u}=vi(this.Dh|0,this.Dl|0,c|0,u|0),{h,l:p}=vi(this.Eh|0,this.El|0,h|0,p|0),{h:g,l:b}=vi(this.Fh|0,this.Fl|0,g|0,b|0),{h:m,l:x}=vi(this.Gh|0,this.Gl|0,m|0,x|0),{h:I,l:N}=vi(this.Hh|0,this.Hl|0,I|0,N|0),this.set(r,i,o,s,a,l,c,u,h,p,g,b,m,x,I,N)}roundClean(){Gi(Xi,Zi)}destroy(){Gi(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const Jx=rg(()=>new nD),sD=rg(()=>new oD),Qx=Jx,e1=[{type:"event",name:"Approval",inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}]},{type:"event",name:"Transfer",inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}]},{type:"function",name:"allowance",stateMutability:"view",inputs:[{name:"owner",type:"address"},{name:"spender",type:"address"}],outputs:[{type:"uint256"}]},{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]},{type:"function",name:"balanceOf",stateMutability:"view",inputs:[{name:"account",type:"address"}],outputs:[{type:"uint256"}]},{type:"function",name:"decimals",stateMutability:"view",inputs:[],outputs:[{type:"uint8"}]},{type:"function",name:"name",stateMutability:"view",inputs:[],outputs:[{type:"string"}]},{type:"function",name:"symbol",stateMutability:"view",inputs:[],outputs:[{type:"string"}]},{type:"function",name:"totalSupply",stateMutability:"view",inputs:[],outputs:[{type:"uint256"}]},{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"sender",type:"address"},{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}];class aD extends Sn{constructor({value:e}){super(`Number \`${e}\` is not a valid decimal number.`,{name:"InvalidDecimalNumberError"})}}function lD(t,e){if(!/^(-?)([0-9]*)\.?([0-9]*)$/.test(t))throw new aD({value:t});let[n,r="0"]=t.split(".");const i=n.startsWith("-");if(i&&(n=n.slice(1)),r=r.replace(/(0+)$/,""),e===0)Math.round(+`.${r}`)===1&&(n=`${BigInt(n)+BigInt(1)}`),r="";else if(r.length>e){const[o,s,a]=[r.slice(0,e-1),r.slice(e-1,e),r.slice(e)],l=Math.round(+`${s}.${a}`);l>9?r=`${BigInt(o)+BigInt(1)}0`.padStart(o.length+1,"0"):r=`${o}${l}`,r.length>e&&(r=r.slice(1),n=`${BigInt(n)+BigInt(1)}`),r=r.slice(0,e)}else r=r.padEnd(e,"0");return BigInt(`${i?"-":""}${n}${r}`)}const cD="0x0000000000000000000000000000000000000000";class t1 extends ng{constructor(e,n){super(),this.finished=!1,this.destroyed=!1,Mx(e);const r=wu(n);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,o=new Uint8Array(i);o.set(r.length>i?e.create().update(r).digest():r);for(let s=0;s<o.length;s++)o[s]^=54;this.iHash.update(o),this.oHash=e.create();for(let s=0;s<o.length;s++)o[s]^=106;this.oHash.update(o),Gi(o)}update(e){return Ns(this),this.iHash.update(e),this}digestInto(e){Ns(this),yi(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:i,destroyed:o,blockLen:s,outputLen:a}=this;return e=e,e.finished=i,e.destroyed=o,e.blockLen=s,e.outputLen=a,e.oHash=n._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const n1=(t,e,n)=>new t1(t,e).update(n).digest();n1.create=(t,e)=>new t1(t,e);const r1=(t,e=0)=>lD(t,e).toString(),ir=(t="0",e=0)=>{try{return ZF(BigInt(t),e)}catch(n){return console.error(n),"0"}},Ro=(t,e)=>!!(t&&e&&(t==null?void 0:t.toLowerCase())===(e==null?void 0:e.toLowerCase())),ug=(t,e=!1)=>`${e?"":t.slice(0,4)}...${t.slice(-4)}`,uD=Intl.NumberFormat("en",{maximumFractionDigits:4}),dD=Intl.NumberFormat("en",{maximumFractionDigits:6}),hD=Intl.NumberFormat("en",{style:"currency",currency:"USD"}),kr=(t,e)=>{const n=e?dD:uD;return isNaN(+t)?"0.0":n.format(+t)},Tr=t=>hD.format(+t),dg=t=>`https://icons-ckg.pages.dev/stargate-light/networks/${ko[t]}.svg`,i1=()=>{const{address:t}=et.useAccount(),e=et.useConfig(),n=Me(l=>l.ensoApiToken),r=K.useMemo(()=>new Set(e.chains.map(l=>l.id)),[e.chains]),{data:i,isLoading:o}=dx({eoaAddress:t,chainId:"all"},{query:{enabled:!!t&&!!n}}),{holdingsList:s,total:a}=K.useMemo(()=>{if(!(i!=null&&i.length))return{holdingsList:[],total:0};const l=i==null?void 0:i.map(u=>({...u,total:+ir(u.amount,u.decimals)*+u.price})).filter(u=>u.total>1&&u.total<1e4&&r.has(u.chainId)).sort((u,h)=>h.total-u.total),c=l==null?void 0:l.reduce((u,{total:h})=>u+h,0);return{holdingsList:l,total:c}},[i,r]);return{holdingsList:s,total:a,isLoading:o}},fD=t=>{const e=et.useConfig(),n=Me(l=>l.ensoApiToken),r=K.useMemo(()=>new Set(e.chains.map(l=>l.id)),[e.chains]),{data:i,isLoading:o}=dx({eoaAddress:t,chainId:"all"},{query:{enabled:!!t&&!!n}}),{holdingsList:s,total:a}=K.useMemo(()=>{if(!(i!=null&&i.length))return{holdingsList:[],total:0};const l=i==null?void 0:i.map(u=>({...u,total:+ir(u.amount,u.decimals)*+u.price})).filter(u=>u.total>1&&u.total<1e4&&r.has(u.chainId)).sort((u,h)=>h.total-u.total),c=l==null?void 0:l.reduce((u,{total:h})=>u+h,0);return{holdingsList:l,total:c}},[i,r]);return{holdingsList:s,total:a,isLoading:o}},o1=t=>{var e,n;return{...t,logoURI:(e=t==null?void 0:t.logosUri)==null?void 0:e[0],underlyingTokens:(n=t==null?void 0:t.underlyingTokens)==null?void 0:n.map(o1)}},gD=[],Ls=(t,e)=>{var i,o;const{data:n,isLoading:r}=e8({address:[t],chainId:e,includeMetadata:!0},{query:{enabled:!!t&&!!e}});return{data:(i=n==null?void 0:n.data)!=null&&i.length?(o=n==null?void 0:n.data)==null?void 0:o.map(o1):gD,isLoading:r}},ll=(t,e)=>{const{data:n,isLoading:r}=MB(t,e);return{data:n==null?void 0:n.price,isLoading:r}},pD=({chainId:t,outChainId:e,fromAddress:n,receiver:r,spender:i,amountIn:o,tokenIn:s,tokenOut:a,slippage:l,referralCode:c,routingStrategy:u="router",enabled:h=!0})=>{const p={referralCode:c,amountIn:[o],tokenIn:[s],tokenOut:[a],slippage:l.toString(),fromAddress:n,receiver:r,spender:i,routingStrategy:u,chainId:t};e!==t&&(p.destinationChainId=e);const{data:[b]}=Ls(a,e),{data:[m]}=Ls(s,t),x=`Purchase ${kr(ir(o,m==null?void 0:m.decimals))} ${m==null?void 0:m.symbol} of ${b==null?void 0:b.symbol}`;return{...VB(p,{query:{retry:2,enabled:!!p.amountIn&&!!m&&!!b&&h}}),title:x}},mD=({address:t,token:e,chainId:n,amount:r})=>{const i=GB({fromAddress:t,tokenAddress:e,chainId:n,amount:r});return{approveData:i.data,approveFetched:i.isFetched}},vD=()=>{const{data:t,isLoading:e}=a8({},{query:{enabled:!0,staleTime:36e5}});return{protocolsMap:K.useMemo(()=>{if(!t)return new Map;const r=new Map;return t.forEach(i=>{r.set(i.slug.toLowerCase(),i)}),r},[t]),isLoading:e}},yD=t=>{const{protocolsMap:e,isLoading:n}=vD();return{protocolData:K.useMemo(()=>{var o;if(!t)return null;const i=e.get(t.toLowerCase());return{logoUri:((o=i==null?void 0:i.logosUri)==null?void 0:o[0])||null,name:(i==null?void 0:i.name)||t}},[t,e]),isLoading:n}},bD=(t,e)=>{var s,a;const{data:n,isLoading:r}=hx({positionId:t?[t]:void 0,chainId:e},{query:{enabled:!!t&&!!e}}),{data:i}=hx({address:t?[t]:void 0,chainId:e},{query:{enabled:!!t&&!!e}}),o=((s=n==null?void 0:n.data)==null?void 0:s[0])||((a=i==null?void 0:i.data)==null?void 0:a[0])||null;return{isNontokenized:!!o,nontokenizedData:o,isLoading:r}},_D=({chainId:t,fromAddress:e,receiver:n,spender:r,amountIn:i,tokenIn:o,positionOut:s,slippage:a,referralCode:l,outChainId:c,routingStrategy:u="router",enabled:h=!0})=>{var N;const p={referralCode:l,amountIn:[i],tokenIn:[o],positionOut:s,slippage:a.toString(),fromAddress:e,receiver:n,spender:r,routingStrategy:u,chainId:t};c!==t&&(p.destinationChainId=c);const{data:[b]}=Ls(o,t),m=`Purchase ${kr(ir(i,b==null?void 0:b.decimals))} ${b==null?void 0:b.symbol} of nontokenized position`,x=WB(p,{query:{retry:2,enabled:!!p.amountIn&&!!b&&h}}),I={...x.data,amountOut:(N=x==null?void 0:x.data)==null?void 0:N.amountDeposited};return{...x,data:I,title:m}},xD=We("div",{base:{position:"sticky",top:"0px",display:"flex",flexDirection:"column",width:"100vw",height:"100vh",justifyContent:"center",alignItems:"center"}}),wD=We("div",{base:{zIndex:1,position:"absolute",top:"0px",left:"0px",width:"100vw",height:"100vh",backgroundColor:"rgba(0, 0, 0, 0.58)"}}),ED=We("div",{base:{zIndex:2,display:"flex",flexDirection:"column",width:"100%",maxWidth:"374px",justifyContent:"center",alignItems:"center",borderRadius:"lg",border:"1px solid",borderColor:"gray.300",padding:"16px",backgroundColor:"white"}}),SD=We("div",{base:{display:"flex",width:"100%",justifyContent:"center",alignItems:"center"}}),ID=We("div",{base:{display:"flex",width:"100%",justifyContent:"center",alignItems:"center"}}),or=({children:t})=>w.jsxs(xD,{children:[w.jsx(ED,{children:t}),w.jsx(wD,{})]}),CD=({children:t})=>w.jsx(SD,{children:t});or.Header=CD;const AD=({children:t})=>w.jsx(ID,{children:t});or.Body=AD;const OD=We("p",{base:{fontWeight:"500",fontSize:"14px",lineHeight:"20px",letterSpacing:"0%",color:"fg.muted"}}),kD=({children:t,isLoading:e})=>e?w.jsxs(ue,{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"1",minWidth:"320px",children:[w.jsxs(ue,{display:"flex",alignItems:"center",gap:"1",children:[w.jsx($f,{size:"8"}),w.jsxs(ue,{display:"flex",flexDirection:"column",gap:"1",children:[w.jsx(Qa,{noOfLines:1,width:"80px"}),w.jsx(Qa,{noOfLines:1,width:"80px"})]})]}),w.jsx(ue,{display:"flex",alignItems:"center",gap:"1",children:w.jsx(Qa,{noOfLines:1,width:"80px"})})]}):t,Eu=({icon:t,title:e,balance:n,usdBalance:r,tag:i,loading:o,selected:s,onClick:a,chainId:l})=>w.jsx(qr,{onClick:a,selected:s,children:w.jsx(kD,{isLoading:o,children:w.jsxs(ue,{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"1",minWidth:"320px",children:[w.jsxs(ue,{display:"flex",alignItems:"center",gap:"1",children:[w.jsxs(ue,{position:"relative",borderRadius:"full",w:"32px",h:"32px",children:[t&&w.jsx(Rn,{borderRadius:"full",w:"32px",src:t}),l&&w.jsx(ue,{position:"absolute",bottom:"0",right:"-2px",width:"16px",height:"16px",borderRadius:"50%",overflow:"hidden",border:"1px solid",borderColor:"bg",zIndex:"1",children:w.jsx("img",{src:dg(l),alt:`Chain ${l}`,width:"100%",height:"100%"})})]}),w.jsxs(ue,{children:[w.jsx(Te,{fontWeight:"medium",color:"fg",whiteSpace:"nowrap",maxWidth:"80px",overflow:"hidden",textOverflow:"ellipsis",children:e}),w.jsx(Te,{fontSize:"xs",color:"fg.muted",children:n})]})]}),w.jsxs(ue,{display:"flex",alignItems:"center",gap:"1",children:[i&&w.jsx(tx,{children:i}),w.jsx(OD,{children:r})]})]})})});var hg=(t=>(t.LOADING="loading",t.CONNECTED="connected",t.NONE="none",t))(hg||{});const TD=({children:t,isLoading:e})=>e?w.jsxs(ue,{display:"flex",alignItems:"center",gap:"1",minWidth:"320px",children:[w.jsx($f,{size:"8"}),w.jsxs(ue,{display:"flex",flexDirection:"column",gap:"1",children:[w.jsx(Qa,{noOfLines:1,width:"80px"}),w.jsx(qr.Description,{children:"Loading wallet..."})]})]}):t,s1=({icon:t,walletHash:e,balance:n,delay:r,status:i,badge:o,onClick:s})=>w.jsx(qr,{onClick:s,children:w.jsx(TD,{isLoading:i==="loading",children:w.jsxs(ue,{display:"flex",alignItems:"center",gap:"1",minWidth:"320px",children:[w.jsxs(ue,{display:"flex",alignItems:"center",gap:"1",marginRight:"auto",children:[t&&(typeof t=="string"?w.jsx(Rn,{src:t}):t),w.jsxs(ue,{children:[w.jsx(qr.Title,{children:e}),n&&r&&w.jsxs(qr.Description,{children:[n," - ",r]})]})]}),o&&w.jsx(tx,{children:o}),i==="connected"&&w.jsx(on,{as:W4,color:"green",width:"16px",height:"16px"})]})})}),RD=({title:t,limit:e,delay:n,icons:r,onClick:i})=>w.jsx(qr,{onClick:i,children:w.jsxs(ue,{display:"flex",alignItems:"center",gap:"1",minWidth:"320px",children:[w.jsx(ue,{display:"flex",alignItems:"center",gap:"1",marginRight:"auto",children:w.jsxs(ue,{children:[w.jsx(qr.Title,{children:t}),e&&w.jsxs(qr.Description,{children:[e,n?` - ${n}`:""]})]})}),w.jsx(ue,{display:"flex",position:"relative",children:r.map((o,s)=>w.jsx(Rn,{w:"32px",h:"32px",borderRadius:"full",position:"relative",zIndex:s,right:`${0-(r.length-1-s)*10}px`,src:o}))}),w.jsx(on,{as:W_,color:"gray",width:"16px",height:"16px"})]})}),a1=t=>fetch(`https://tokens.coingecko.com/${lx[t]}/all.json`).then(e=>e.json()).then(e=>e==null?void 0:e.tokens).then(e=>[cx[t],...e]),ND=()=>fetch("https://mainnet.internal.oogabooga.io/token-list/tokens?chainId=80094&client=SWAP").then(t=>t.json()).then(t=>t.map(e=>({...e,logoURI:e.tokenURI,address:e.address===cD?Pt:e.address.toLowerCase()}))),PD=()=>fetch("https://api.rooster-protocol.xyz/api/tokens").then(t=>t.json()).then(({tokens:t})=>t),LD=t=>({[cx[t].symbol]:5,USDC:4,DAI:4,USDT:4,WBTC:4,WETH:3,LINK:3,UNI:3,SUSHI:3,AAVE:3,USDCE:2}),MD=new Promise(t=>t([{address:"0x6047828dc181963ba44974801ff68e538da5eaf9",name:"Tether USD",symbol:"USDT",decimals:6,logoURI:"https://assets.coingecko.com/coins/images/325/large/Tether.png"}])),BD=new Promise(t=>t([{address:Pt,name:"Plume",symbol:"PLUME",decimals:18,logoURI:"https://assets.coingecko.com/coins/images/53623/standard/plume-token.png?1736896935"},{address:"0x78adD880A697070c1e765Ac44D65323a0DcCE913",name:"USD Coin.e",symbol:"USDC.e",decimals:6,logoURI:"https://assets.coingecko.com/coins/images/6319/large/USD_Coin_icon.png"},{address:"0xEa237441c92CAe6FC17Caaf9a7acB3f953be4bd1",name:"Wrapped Plume",symbol:"wPlume",decimals:18,logoURI:"https://assets.coingecko.com/coins/images/53623/standard/plume-token.png?1736896935"},{address:"0xca59cA09E5602fAe8B629DeE83FfA819741f14be",name:"Wrapped Ether",symbol:"WETH",decimals:18,logoURI:"https://assets.coingecko.com/coins/images/2518/large/weth.png"}])),FD=t=>{let e=[];switch(t){case Cs.BERACHAIN:e=[ND()];break;case Cs.SONIC:e=[a1(t),MD];break;case Cs.PLUME:e=[BD,PD()];break;default:e=[a1(t)]}return Promise.allSettled(e).then(n=>{var a,l,c;const r=n.filter(u=>u.status==="fulfilled").map(u=>u.value),i=r[0];if(r.length>1){const u=new Set((l=(a=r[0])==null?void 0:a.map(p=>p.address))!=null?l:[]),h=r[0];for(let p=1;p<r.length;p++){const g=(c=r[p])==null?void 0:c.filter(b=>!u.has(b.address));g&&(h.push(...g),g.forEach(b=>u.add(b.address)))}}const o=LD(t);return[...i].sort((u,h)=>{var p,g;return(g=(p=o[h.symbol])!=null?p:0-o[u.symbol])!=null?g:0}).map(u=>({...u,address:u.address.toLowerCase()}))})},DD=t=>{const e=Su(t);return Kn.useQuery({queryKey:["tokenList",e],queryFn:()=>FD(e),enabled:!!e})},VD=(t,e)=>t==="USDT"?e===Cs.BSC?"BSC-USD":e===Cs.MAINNET?"USDT":"USDT0":t,$D=(t,e)=>{const{data:n}=DD(e);return(Array.isArray(t)?t:[t]).map(i=>n==null?void 0:n.find(o=>o.symbol==VD(i,e)))},Su=t=>{var r;const e=Me(i=>i.chainIdIn),{chainId:n=1}=et.useAccount();return(r=t!=null?t:e)!=null?r:n},zD=t=>{var e;return((e=t.charAt(0))==null?void 0:e.toUpperCase())+t.slice(1)},l1=t=>{const e=lx[t];return zD(e).split("-")[0]},UD=t=>{const n=et.useConfig().chains.find(r=>r.id===t);return(n==null?void 0:n.name)||l1(t)},Iu=({hash:t,chainId:e,type:n="/tx"})=>{const r=ux[e];if(t)return`${r}${n}/${t}`},Cu=(t,e)=>Number(parseFloat(t.toString()).toFixed(e)).toString(),c1=(t,e)=>{const n=t.replace(/[^\d.]/g,"");if(!n)return"";const r=n.endsWith("."),[i,...o]=n.split(".");let s=o.join("");return e!==void 0&&(s=s.slice(0,e)),r&&s.length===0?i?`${i}.`:".":s.length>0?i?`${i}.${s}`:`.${s}`:i},fg=t=>{if(!t||t===".")return null;const e=Number(t);return Number.isNaN(e)||e<=0?null:e},u1="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAcCAYAAAByDd+UAAACUUlEQVR4Ae2WA6weQRSFt7bdhrWNqLZtM6riFEFt27aCMqht27at2/3yMun8k52dmi/JyZvcOfd8O8r7vcrda/xS/YfAMXnj1x7RIEXsHxFOlhPYIZ13fU2FDCKdMrT9VpC0y9CKjE7pvTuhQFbmm6RRUk92lk8m0ibdufu1EuX6UhBev+cMvWSQRaYV6BtqYoqAtkwj0iLtHBfM98zCq8MQmWHAKZh06LGqyaOgqFWGdjK2fXZdbJ+ax2vA0BQrkPPDZIN+bJ9VZHQbkREtEWNqYTB0xw0MgF6rElekS2ETSI05G0zIDNvSfpiC5FvlSqcSH00gNeZsfWSGAbPaVrissHWFzFlXSKYViNqm8h60Se4JauGrS6aYcrNuKucZ4sFLj+ony/nwF9cuOGVZ3cKCeLyEKX1sltIEUovw0KP6yXICZXTrowSh9z0rEvhZDWMDihA13UOP6ifLCVRBCvi0dtQNRVfKevK6bz0FY0xNzeOlJ+KDwoDAqmDSAx+1L8Cl4JbyV18BY30Or/ogXVXCgBMNs6hwgs50rUioqjGmxpyqmTA0xQ4c1fouTUFScBOozwWJTCvwSjnvCmdiiquvQs0tVUA8Qb1kWoHXqsQbzOGb0m8g4WwjYqzf5KBeMq1A/p8FNXH1EYANvbtxSRBjVqjmA4FkWoHIbLhaypvxeMWcKbeevBd0+MBJGdC2tSDGqv541bzpeM1+5ztkC5D5ZTcfvc9y+/6r01duPpEtu44IYuzXzjBn7pTKcQDdunD5XstN2/aPRIyjf5f+duAnkHEA02/8X30AAAAASUVORK5CYII=",WD="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAhCAYAAAC4JqlRAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAARKSURBVHgBtVhbbBRVGP7OdrbbC9KikQgxcXnBaCLWxCcftBo1Md6ILzyokb5o2gdbkAQFk91NLMWYavHFglHgxQSf0EQTEq4Jl0C4NRDCvcslhDu9UNi2u3P4/j07e2lnZmdb+iXTOXvOmfN9/3/+888/VagQXb/pKG9Rj+Hkd60qiQqggkyKb9SNkRTa2VyqvcnzIrjqVqWxLogYXwE5a2MkXYopgItv4i3hJ8RTwNpe3W7biHNGI6YDhQHYSKxqUz3uwy7oWq9jWsgfI0gUpycSLv2lWNOrf4FGB2YAIY2eb9vUspK+4h9i+UyRC2yFDsZVrLgv7wEONDPYdgVZSPGpgSFg9ixg5KGxor4O1B4MfPxNbsduaVtF/RsDPo+aaqDzG6Aq5z9N5r//B06eAerqyj+vDdcCaWeXoPVBzncedwaA4fvA2X7gxFnjjSXv87x+bfpVqOwS0U5y5gUQMVSAulqg+0/gYB8QCQMXrgA7D9CdlvHM/KfLbweJv5C76tygm1QGx1ABdG71EDfz4SjwZAPw8gvA4DDw4VtmbPt+4PBJ/0wnsWAhg8UISHp/BHh1EdBEstoIcJtbsX0fcOM2sPcIo9w28xa/A7z9GjCe5had9vYG5zdbtOINrX1V4u4g0PYZ8Nx8cwIczJsLvLTQtGO/Ap+8Cyx63vwO0cfvvW7iZHSs4LVicE6TYgD2+wWgkP+00lgXCvl7SNS6uXzFWuAp94SeDPmRpzPA8haS68nkjrsdy5QHuQx/ucRzG6KuNsliwyPm/sxcE2zFC6bT5rpH74yl4Qt5dCFP/NCw+7jl1inR3LVicr94wqZXMra5IkxIW7cxB3wAX4iXqqo8BFBhMkgSsu0CsYiQ7ZG+2prSeecuMUXXG3FCKgG45T/TZ0/eh6SlFY7Tr9Hi3oYngNXdDJw5wLKWIvKc9c5vcW//tYLAazeBv/4hsfhVG0JJ13K5xYDKBqFGH1xcNqvenAAhHc9Z7IiQ/c/wStG6zz+iiKvcY6bg7j9oeSRHSuvDlglezzwA7JHx3R7jqGfK/f5n4OJloDps3CrisrlAmXtq1BDK+2HlVwzKMQRGuIq1ozS6evUuLtzsNVEmPUgx7fL6YTlw6jzQxww3OFRws2THZ+cB12/RrEMIguSqVrXAnAKNzfzb7CmAChpns7psN20he+VF4PctTMf3zJx9R03AiUvDVnl26k44xmXhlxElKNs+Lfzeexj4dwdfQo3uKTYAstZLo1gr4929IrpFK3/cYIIuxW1oYCU0p2HK5GJ1i9POZ0IpkRy3TES1ZY6Z3KUMmyJvFqy2E045lhNTClYqPexsxwyAwtetblUlRe+kd4FM8PLEtMhp+URygWfBsma97mCxEpv2l5HmlxEq/DJyIN+G9EYcufqtUvDIbqKAqX0bThQiHxUsHj4u9+KS/M543Txeg554ixoot3YgARPF4DH+f+ARXqmiGXvOHE0AAAAASUVORK5CYII=",HD=(t,e)=>{const n=K.useCallback(t,[]);K.useEffect(()=>{const r=setInterval(n,e);return()=>clearInterval(r)},[e,n])},d1=()=>{const[t,e]=K.useState(0);return HD(()=>{e(t+1)},1e4),t},jD=(t,e)=>{const{address:n}=et.useAccount(),r=Su(e);return et.useReadContract({chainId:r,address:t,abi:e1,functionName:"balanceOf",args:[n],query:{enabled:al(n)&&al(t)&&!Ro(t,Pt)}})},qD=(t,e)=>{var h;const{address:n}=et.useAccount(),r=Su(e),i=d1(),o=Kn.useQueryClient(),{data:s,queryKey:a}=jD(t,e),{data:l,queryKey:c}=et.useBalance({address:n,chainId:r,query:{enabled:Ro(t,Pt)}});K.useEffect(()=>{o.invalidateQueries({queryKey:a}),o.invalidateQueries({queryKey:c})},[i,o,a,c]);const u=Ro(t,Pt)?l==null?void 0:l.value:s;return(h=u==null?void 0:u.toString())!=null?h:"0"},GD=(t,e)=>{var u;const{address:n}=et.useAccount(),r=Su(),i=d1(),o=Kn.useQueryClient(),{data:s,queryKey:a,isLoading:l,isFetched:c}=et.useReadContract({chainId:r,address:t,abi:e1,functionName:"allowance",args:[n,e],query:{enabled:al(n)&&al(t)&&!Ro(t,Pt)}});return K.useEffect(()=>{o.invalidateQueries({queryKey:a})},[i,o,a]),{allowance:(u=s==null?void 0:s.toString())!=null?u:"0",allowanceFetched:c,allowanceLoading:l}},KD=(t,e="0xF75584eF6673aD213a685a1B58Cc0330B8eA22Cf",n)=>{const{allowance:r,allowanceFetched:i,allowanceLoading:o}=GD(t,e);return{approveNeeded:!Ro(t,Pt)&&+r<+n,allowanceFetched:i,allowanceLoading:o}},YD=t=>{if(!t)return u1;const e=t.toLowerCase();return e.includes("metamask")?u1:e.includes("rabby")?WD:w.jsx(Z4,{size:20})},XD=t=>{if(!t)return"Wallet";const e=t.toLowerCase();return e.includes("metamask")?"MetaMask":e.includes("rabby")?"Rabby":e.includes("walletconnect")?"WalletConnect":e.includes("injected")?"Browser Wallet":t.charAt(0).toUpperCase()+t.slice(1)};function ZD(t){return"0x1a59347d28f64091079fa04a2cbd03da63dff154"}const JD=j8("function getAddress(address) external view returns (address)"),QD=(t,e)=>{const n=ZD(),{data:r,isLoading:i,error:o}=et.useReadContract({address:n,abi:[JD],functionName:"getAddress",args:t?[t]:void 0,chainId:e,query:{enabled:!!(t&&e)}});return{smartAccountAddress:r,isLoading:i}},h1=(t=1)=>{const{address:e}=et.useAccount(),{smartAccountAddress:n,isLoading:r}=QD(e,t),{holdingsList:i,total:o,isLoading:s}=fD(n);return{smartAccountAddress:n,holdingsList:i,total:o,isLoading:r||s}},yr=()=>{const{address:t=xB}=et.useAccount(),e=Me(T=>T.amountIn),n=Me(T=>T.tokenIn),r=Me(T=>T.tokenOut),i=Me(T=>T.slippage),o=Me(T=>T.chainIdIn),s=Me(T=>T.chainIdOut),a=Me(T=>T.selectedIntegration),l=Me(T=>T.recipient),{data:[c]}=Ls(n,o),{data:[u]}=Ls(r,s),{data:h}=ll(o,n),{data:p}=ll(s,r),{isNontokenized:g,nontokenizedData:b}=bD(r,s),{protocolData:m}=yD(g?b==null?void 0:b.protocol:void 0),x=K.useMemo(()=>{if(g&&(b!=null&&b.underlyingTokens)){const T=b.underlyingTokens.map(B=>{var G;return{...B,logoURI:(G=B.logosUri)==null?void 0:G[0]}}),$=(m==null?void 0:m.name)||b.protocol;return{...T[0],underlyingTokens:T,protocol:b.protocol,protocolName:$,protocolLogo:(m==null?void 0:m.logoUri)||void 0,name:$+" "+T[0].name}}return u},[g,b,u,m]),I=ll(s,x==null?void 0:x.address);return{chainIdIn:o,chainIdOut:s,tokenInData:c,tokenOutData:u,amountIn:e,slippage:i,address:t,tokenInPrice:h,tokenOutPrice:p,tokenIn:n,tokenOut:r,selectedIntegration:a,effectiveTokenOutData:x,effectivePrice:g?I:p,isNontokenized:g,recipient:l}},eV=({address:t,chainId:e,calls:n})=>{const{sendCalls:r}=Um.useSendCalls(),{data:i}=Um.useCapabilities(),o=!1,s=et.useWalletClient();console.log(i,o,s.data);const a=K.useCallback(async(c,u)=>{var h;{console.log("Atomic not supported, sending transactions sequentially");try{for(const p of n){console.log("Sending individual transaction:",p);const g=await((h=s.data)==null?void 0:h.sendTransaction({...p,account:t,chainId:e}));if(console.log("Sequential transaction result:",g),!g)throw new Error(`Transaction failed for call: ${JSON.stringify(p)}`);p===n[n.length-1]&&c(g)}console.log("All sequential transactions completed")}catch(p){throw console.error("Error in sequential transaction:",p),u(p),p}return}},[r,n,o,e,s.data]);return{ready:n.length>0&&s.data,sendTxns:a}},Ms=()=>{const{tokenInData:t,amountIn:e,slippage:n,address:r,chainIdIn:i,chainIdOut:o,tokenInPrice:s,tokenIn:a,tokenOut:l,selectedIntegration:c,isNontokenized:u,recipient:h}=yr(),p=h||r,g=pD({routingStrategy:c!=null&&c.type?"checkout":"router",fromAddress:r,receiver:p,spender:r,amountIn:e,tokenIn:a,tokenOut:l,slippage:n,chainId:i,outChainId:o,enabled:!u}),b=_D({routingStrategy:c!=null&&c.type?"checkout":"router",fromAddress:r,receiver:p,spender:r,amountIn:e,tokenIn:a,positionOut:l,slippage:n,chainId:i,outChainId:o,enabled:u}),{data:m,isLoading:x,error:I,isFetched:N}=u?b:g,T=K.useMemo(()=>Tr(ir((+e*s).toFixed(),t==null?void 0:t.decimals)),[e,s,t==null?void 0:t.decimals]);return{chainIdOut:o,routeData:m,routeFetched:N,routeLoading:x,usdAmountIn:T,routerError:I}},f1=()=>{const{connector:t}=et.useAccount();return{walletIcon:YD(t==null?void 0:t.name),walletDisplayName:XD(t==null?void 0:t.name)}};function tV(t){const{authorization:e,factory:n,factoryData:r}=t;if(n==="0x7702"||n==="0x7702000000000000000000000000000000000000"){if(!e)return"0x7702000000000000000000000000000000000000";const i=e.address;return Or([i,r!=null?r:"0x"])}return n?Or([n,r!=null?r:"0x"]):"0x"}function nV(t){var N,T;const{callGasLimit:e,callData:n,maxPriorityFeePerGas:r,maxFeePerGas:i,paymaster:o,paymasterData:s,paymasterPostOpGasLimit:a,paymasterVerificationGasLimit:l,sender:c,signature:u="0x",verificationGasLimit:h}=t,p=Or([vr(rr(h||BigInt(0)),{size:16}),vr(rr(e||BigInt(0)),{size:16})]),g=tV(t),b=Or([vr(rr(r||BigInt(0)),{size:16}),vr(rr(i||BigInt(0)),{size:16})]),m=(N=t.nonce)!=null?N:BigInt(0),x=o?Or([o,vr(rr(l||BigInt(0)),{size:16}),vr(rr(a||BigInt(0)),{size:16}),s||"0x"]):"0x",I=(T=t.preVerificationGas)!=null?T:BigInt(0);return{accountGasLimits:p,callData:n,initCode:g,gasFees:b,nonce:m,paymasterAndData:x,preVerificationGas:I,sender:c,signature:u}}function rV(t){const{chainId:e,entryPointAddress:n}=t,r=t.userOperation,{authorization:i,callData:o="0x",callGasLimit:s,maxFeePerGas:a,maxPriorityFeePerGas:l,nonce:c,paymasterAndData:u="0x",preVerificationGas:h,sender:p,verificationGasLimit:g}=r,b=(()=>{{const m=nV(r);return Yx([{type:"address"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"},{type:"bytes32"},{type:"uint256"},{type:"bytes32"},{type:"bytes32"}],[m.sender,m.nonce,Ps(m.initCode),Ps(m.callData),m.accountGasLimits,m.preVerificationGas,m.gasFees,Ps(m.paymasterAndData)])}})();return Ps(Yx([{type:"bytes32"},{type:"address"},{type:"uint256"}],[Ps(b),n,BigInt(e)]))}const iV=[{label:"25%",value:25},{label:"50%",value:50},{label:"75%",value:75},{label:"Max",value:100}],g1=({value:t,onChange:e,tokenSymbol:n,tokenPriceUsd:r,tokenBalance:i,roundingPrecision:o=6,usdPrecision:s=2,percentOptions:a=iV,onPercentSelect:l,showPercentTabs:c=!0})=>{const u=B=>{e({...t,...B})},h=B=>{if(t.mode==="usd"){const Z=c1(B.replace("$",""),s);if(!Z||Z==="."){u({usdAmount:Z,tokenAmount:""});return}if(!r||r<=0){u({usdAmount:Z,tokenAmount:""});return}const Y=Cu(parseFloat(Z)/r,o);u({usdAmount:Z,tokenAmount:Y});return}const G=c1(B,o);if(!G||G==="."){u({tokenAmount:G,usdAmount:""});return}if(!r||r<=0){u({tokenAmount:G});return}u({tokenAmount:G,usdAmount:(parseFloat(G)*r).toFixed(s)})},p=()=>{u({mode:t.mode==="usd"?"token":"usd"})},g=B=>{if(l){const Z=l(B);if(!Z)return;u(Z);return}if(!i||!r||r<=0)return;const G=Cu(i*B/100,o);u({tokenAmount:G,usdAmount:(parseFloat(G||"0")*r).toFixed(s)})},b=t.mode==="usd"?"$10.00":"0.00",m=t.mode==="usd"?t.usdAmount?`$${t.usdAmount}`:"":t.tokenAmount,x=!!t.tokenAmount&&t.tokenAmount!==".",I=!!t.usdAmount&&t.usdAmount!==".",N=x?kr(t.tokenAmount):"",T=n?` ${n}`:"",$=t.mode==="usd"?x?`${N}${T}`:"—":I?Tr(t.usdAmount):"—";return w.jsxs(ue,{display:"flex",flexDirection:"column",gap:"8px",children:[w.jsxs(ue,{display:"flex",flexDirection:"column",gap:"8px",alignItems:"center",padding:"25.5px",children:[w.jsx(Yf,{inputMode:"decimal",marginY:"8px",variant:"text",placeholder:b,value:m,onChange:B=>h(B.target.value)}),w.jsxs(ue,{display:"flex",gap:"3",alignItems:"center",onClick:p,_hover:{background:"bg.subtle"},cursor:"pointer",borderRadius:"lg",px:"3",children:[w.jsx(gi,{minWidth:"24px",minHeight:"24px",maxWidth:"24px",background:"transparent",children:w.jsx(on,{as:U4,color:"gray",width:"16px",height:"16px"})}),w.jsx(Te,{fontSize:"sm",color:"fg.muted",children:$})]})]}),c&&a.length>0&&w.jsx(ue,{display:"flex",gap:"4px",justifyContent:"center",paddingBottom:"35px",children:a.map(B=>w.jsx(fB,{onClick:()=>g(B.value),children:B.label},B.label))})]})};var oV=["integrationConnected","integrationConnectionError","integrationMfaRequired","integrationMfaEntered","integrationOAuthStarted","integrationAccountSelectionRequired","transferCompleted","integrationSelected","credentialsEntered","transferStarted","transferPreviewed","transferPreviewError","transferExecutionError","pageLoaded","transferAssetSelected","transferNetworkSelected","transferAmountEntered","transferMfaRequired","transferMfaEntered","transferKycRequired","transferExecuted","transferInitiated","transferNoEligibleAssets","walletMessageSigned","verifyDonePage","verifyWalletRejected","connectionDeclined","transferConfigureError","connectionUnavailable","transferDeclined","done","close","SDKinjectedWalletProviders","legalTermsViewed","seeWhatHappenedClicked","executeFundingStep","fundingOptionsUpdated","fundingOptionsViewed","gasIncreaseWarning","linkTransferQRGenerated","methodSelected"];function sV(t){return oV.includes(t)}function aV(t){try{var e=new URLSearchParams(new URL(t).search),n=e.get("link_style");return n&&JSON.parse(window.atob(n))}catch(r){return}}function gg(t,e){return e!==void 0?e:t}var pg="mesh-link-popup",p1="mesh-link-popup__backdrop",Bs="mesh-link-popup__popup-content",m1="mesh-link-popup__styles",mg="mesh-link-popup__iframe",lV=function(t){return`
127
127
  body {
128
128
  position: fixed;
129
129
  left: 0;
@@ -214,7 +214,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
214
214
  *
215
215
  * @author Feross Aboukhadijeh <https://feross.org>
216
216
  * @license MIT
217
- */var B1;function Ig(){return B1||(B1=1,(function(t){const e=WV(),n=HV(),r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=a,t.SlowBuffer=N,t.INSPECT_MAX_BYTES=50;const i=2147483647;t.kMaxLength=i,a.TYPED_ARRAY_SUPPORT=o(),!a.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function o(){try{const P=new Uint8Array(1),_={foo:function(){return 42}};return Object.setPrototypeOf(_,Uint8Array.prototype),Object.setPrototypeOf(P,_),P.foo()===42}catch(P){return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function s(P){if(P>i)throw new RangeError('The value "'+P+'" is invalid for option "size"');const _=new Uint8Array(P);return Object.setPrototypeOf(_,a.prototype),_}function a(P,_,E){if(typeof P=="number"){if(typeof _=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return h(P)}return l(P,_,E)}a.poolSize=8192;function l(P,_,E){if(typeof P=="string")return p(P,_);if(ArrayBuffer.isView(P))return b(P);if(P==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof P);if(ln(P,ArrayBuffer)||P&&ln(P.buffer,ArrayBuffer)||typeof SharedArrayBuffer!="undefined"&&(ln(P,SharedArrayBuffer)||P&&ln(P.buffer,SharedArrayBuffer)))return m(P,_,E);if(typeof P=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const z=P.valueOf&&P.valueOf();if(z!=null&&z!==P)return a.from(z,_,E);const J=x(P);if(J)return J;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof P[Symbol.toPrimitive]=="function")return a.from(P[Symbol.toPrimitive]("string"),_,E);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof P)}a.from=function(P,_,E){return l(P,_,E)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function c(P){if(typeof P!="number")throw new TypeError('"size" argument must be of type number');if(P<0)throw new RangeError('The value "'+P+'" is invalid for option "size"')}function u(P,_,E){return c(P),P<=0?s(P):_!==void 0?typeof E=="string"?s(P).fill(_,E):s(P).fill(_):s(P)}a.alloc=function(P,_,E){return u(P,_,E)};function h(P){return c(P),s(P<0?0:I(P)|0)}a.allocUnsafe=function(P){return h(P)},a.allocUnsafeSlow=function(P){return h(P)};function p(P,_){if((typeof _!="string"||_==="")&&(_="utf8"),!a.isEncoding(_))throw new TypeError("Unknown encoding: "+_);const E=T(P,_)|0;let z=s(E);const J=z.write(P,_);return J!==E&&(z=z.slice(0,J)),z}function g(P){const _=P.length<0?0:I(P.length)|0,E=s(_);for(let z=0;z<_;z+=1)E[z]=P[z]&255;return E}function b(P){if(ln(P,Uint8Array)){const _=new Uint8Array(P);return m(_.buffer,_.byteOffset,_.byteLength)}return g(P)}function m(P,_,E){if(_<0||P.byteLength<_)throw new RangeError('"offset" is outside of buffer bounds');if(P.byteLength<_+(E||0))throw new RangeError('"length" is outside of buffer bounds');let z;return _===void 0&&E===void 0?z=new Uint8Array(P):E===void 0?z=new Uint8Array(P,_):z=new Uint8Array(P,_,E),Object.setPrototypeOf(z,a.prototype),z}function x(P){if(a.isBuffer(P)){const _=I(P.length)|0,E=s(_);return E.length===0||P.copy(E,0,0,_),E}if(P.length!==void 0)return typeof P.length!="number"||st(P.length)?s(0):g(P);if(P.type==="Buffer"&&Array.isArray(P.data))return g(P.data)}function I(P){if(P>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return P|0}function N(P){return+P!=P&&(P=0),a.alloc(+P)}a.isBuffer=function(_){return _!=null&&_._isBuffer===!0&&_!==a.prototype},a.compare=function(_,E){if(ln(_,Uint8Array)&&(_=a.from(_,_.offset,_.byteLength)),ln(E,Uint8Array)&&(E=a.from(E,E.offset,E.byteLength)),!a.isBuffer(_)||!a.isBuffer(E))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(_===E)return 0;let z=_.length,J=E.length;for(let te=0,ae=Math.min(z,J);te<ae;++te)if(_[te]!==E[te]){z=_[te],J=E[te];break}return z<J?-1:J<z?1:0},a.isEncoding=function(_){switch(String(_).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(_,E){if(!Array.isArray(_))throw new TypeError('"list" argument must be an Array of Buffers');if(_.length===0)return a.alloc(0);let z;if(E===void 0)for(E=0,z=0;z<_.length;++z)E+=_[z].length;const J=a.allocUnsafe(E);let te=0;for(z=0;z<_.length;++z){let ae=_[z];if(ln(ae,Uint8Array))te+ae.length>J.length?(a.isBuffer(ae)||(ae=a.from(ae)),ae.copy(J,te)):Uint8Array.prototype.set.call(J,ae,te);else if(a.isBuffer(ae))ae.copy(J,te);else throw new TypeError('"list" argument must be an Array of Buffers');te+=ae.length}return J};function T(P,_){if(a.isBuffer(P))return P.length;if(ArrayBuffer.isView(P)||ln(P,ArrayBuffer))return P.byteLength;if(typeof P!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof P);const E=P.length,z=arguments.length>2&&arguments[2]===!0;if(!z&&E===0)return 0;let J=!1;for(;;)switch(_){case"ascii":case"latin1":case"binary":return E;case"utf8":case"utf-8":return He(P).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E*2;case"hex":return E>>>1;case"base64":return nt(P).length;default:if(J)return z?-1:He(P).length;_=(""+_).toLowerCase(),J=!0}}a.byteLength=T;function $(P,_,E){let z=!1;if((_===void 0||_<0)&&(_=0),_>this.length||((E===void 0||E>this.length)&&(E=this.length),E<=0)||(E>>>=0,_>>>=0,E<=_))return"";for(P||(P="utf8");;)switch(P){case"hex":return D(this,_,E);case"utf8":case"utf-8":return d(this,_,E);case"ascii":return C(this,_,E);case"latin1":case"binary":return R(this,_,E);case"base64":return A(this,_,E);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,_,E);default:if(z)throw new TypeError("Unknown encoding: "+P);P=(P+"").toLowerCase(),z=!0}}a.prototype._isBuffer=!0;function B(P,_,E){const z=P[_];P[_]=P[E],P[E]=z}a.prototype.swap16=function(){const _=this.length;if(_%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let E=0;E<_;E+=2)B(this,E,E+1);return this},a.prototype.swap32=function(){const _=this.length;if(_%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let E=0;E<_;E+=4)B(this,E,E+3),B(this,E+1,E+2);return this},a.prototype.swap64=function(){const _=this.length;if(_%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let E=0;E<_;E+=8)B(this,E,E+7),B(this,E+1,E+6),B(this,E+2,E+5),B(this,E+3,E+4);return this},a.prototype.toString=function(){const _=this.length;return _===0?"":arguments.length===0?d(this,0,_):$.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(_){if(!a.isBuffer(_))throw new TypeError("Argument must be a Buffer");return this===_?!0:a.compare(this,_)===0},a.prototype.inspect=function(){let _="";const E=t.INSPECT_MAX_BYTES;return _=this.toString("hex",0,E).replace(/(.{2})/g,"$1 ").trim(),this.length>E&&(_+=" ... "),"<Buffer "+_+">"},r&&(a.prototype[r]=a.prototype.inspect),a.prototype.compare=function(_,E,z,J,te){if(ln(_,Uint8Array)&&(_=a.from(_,_.offset,_.byteLength)),!a.isBuffer(_))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof _);if(E===void 0&&(E=0),z===void 0&&(z=_?_.length:0),J===void 0&&(J=0),te===void 0&&(te=this.length),E<0||z>_.length||J<0||te>this.length)throw new RangeError("out of range index");if(J>=te&&E>=z)return 0;if(J>=te)return-1;if(E>=z)return 1;if(E>>>=0,z>>>=0,J>>>=0,te>>>=0,this===_)return 0;let ae=te-J,De=z-E;const Me=Math.min(ae,De),Le=this.slice(J,te),gt=_.slice(E,z);for(let Ne=0;Ne<Me;++Ne)if(Le[Ne]!==gt[Ne]){ae=Le[Ne],De=gt[Ne];break}return ae<De?-1:De<ae?1:0};function G(P,_,E,z,J){if(P.length===0)return-1;if(typeof E=="string"?(z=E,E=0):E>2147483647?E=2147483647:E<-2147483648&&(E=-2147483648),E=+E,st(E)&&(E=J?0:P.length-1),E<0&&(E=P.length+E),E>=P.length){if(J)return-1;E=P.length-1}else if(E<0)if(J)E=0;else return-1;if(typeof _=="string"&&(_=a.from(_,z)),a.isBuffer(_))return _.length===0?-1:Z(P,_,E,z,J);if(typeof _=="number")return _=_&255,typeof Uint8Array.prototype.indexOf=="function"?J?Uint8Array.prototype.indexOf.call(P,_,E):Uint8Array.prototype.lastIndexOf.call(P,_,E):Z(P,[_],E,z,J);throw new TypeError("val must be string, number or Buffer")}function Z(P,_,E,z,J){let te=1,ae=P.length,De=_.length;if(z!==void 0&&(z=String(z).toLowerCase(),z==="ucs2"||z==="ucs-2"||z==="utf16le"||z==="utf-16le")){if(P.length<2||_.length<2)return-1;te=2,ae/=2,De/=2,E/=2}function Me(gt,Ne){return te===1?gt[Ne]:gt.readUInt16BE(Ne*te)}let Le;if(J){let gt=-1;for(Le=E;Le<ae;Le++)if(Me(P,Le)===Me(_,gt===-1?0:Le-gt)){if(gt===-1&&(gt=Le),Le-gt+1===De)return gt*te}else gt!==-1&&(Le-=Le-gt),gt=-1}else for(E+De>ae&&(E=ae-De),Le=E;Le>=0;Le--){let gt=!0;for(let Ne=0;Ne<De;Ne++)if(Me(P,Le+Ne)!==Me(_,Ne)){gt=!1;break}if(gt)return Le}return-1}a.prototype.includes=function(_,E,z){return this.indexOf(_,E,z)!==-1},a.prototype.indexOf=function(_,E,z){return G(this,_,E,z,!0)},a.prototype.lastIndexOf=function(_,E,z){return G(this,_,E,z,!1)};function Y(P,_,E,z){E=Number(E)||0;const J=P.length-E;z?(z=Number(z),z>J&&(z=J)):z=J;const te=_.length;z>te/2&&(z=te/2);let ae;for(ae=0;ae<z;++ae){const De=parseInt(_.substr(ae*2,2),16);if(st(De))return ae;P[E+ae]=De}return ae}function F(P,_,E,z){return Qe(He(_,P.length-E),P,E,z)}function V(P,_,E,z){return Qe(ot(_),P,E,z)}function U(P,_,E,z){return Qe(nt(_),P,E,z)}function W(P,_,E,z){return Qe(ri(_,P.length-E),P,E,z)}a.prototype.write=function(_,E,z,J){if(E===void 0)J="utf8",z=this.length,E=0;else if(z===void 0&&typeof E=="string")J=E,z=this.length,E=0;else if(isFinite(E))E=E>>>0,isFinite(z)?(z=z>>>0,J===void 0&&(J="utf8")):(J=z,z=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const te=this.length-E;if((z===void 0||z>te)&&(z=te),_.length>0&&(z<0||E<0)||E>this.length)throw new RangeError("Attempt to write outside buffer bounds");J||(J="utf8");let ae=!1;for(;;)switch(J){case"hex":return Y(this,_,E,z);case"utf8":case"utf-8":return F(this,_,E,z);case"ascii":case"latin1":case"binary":return V(this,_,E,z);case"base64":return U(this,_,E,z);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return W(this,_,E,z);default:if(ae)throw new TypeError("Unknown encoding: "+J);J=(""+J).toLowerCase(),ae=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function A(P,_,E){return _===0&&E===P.length?e.fromByteArray(P):e.fromByteArray(P.slice(_,E))}function d(P,_,E){E=Math.min(P.length,E);const z=[];let J=_;for(;J<E;){const te=P[J];let ae=null,De=te>239?4:te>223?3:te>191?2:1;if(J+De<=E){let Me,Le,gt,Ne;switch(De){case 1:te<128&&(ae=te);break;case 2:Me=P[J+1],(Me&192)===128&&(Ne=(te&31)<<6|Me&63,Ne>127&&(ae=Ne));break;case 3:Me=P[J+1],Le=P[J+2],(Me&192)===128&&(Le&192)===128&&(Ne=(te&15)<<12|(Me&63)<<6|Le&63,Ne>2047&&(Ne<55296||Ne>57343)&&(ae=Ne));break;case 4:Me=P[J+1],Le=P[J+2],gt=P[J+3],(Me&192)===128&&(Le&192)===128&&(gt&192)===128&&(Ne=(te&15)<<18|(Me&63)<<12|(Le&63)<<6|gt&63,Ne>65535&&Ne<1114112&&(ae=Ne))}}ae===null?(ae=65533,De=1):ae>65535&&(ae-=65536,z.push(ae>>>10&1023|55296),ae=56320|ae&1023),z.push(ae),J+=De}return S(z)}const y=4096;function S(P){const _=P.length;if(_<=y)return String.fromCharCode.apply(String,P);let E="",z=0;for(;z<_;)E+=String.fromCharCode.apply(String,P.slice(z,z+=y));return E}function C(P,_,E){let z="";E=Math.min(P.length,E);for(let J=_;J<E;++J)z+=String.fromCharCode(P[J]&127);return z}function R(P,_,E){let z="";E=Math.min(P.length,E);for(let J=_;J<E;++J)z+=String.fromCharCode(P[J]);return z}function D(P,_,E){const z=P.length;(!_||_<0)&&(_=0),(!E||E<0||E>z)&&(E=z);let J="";for(let te=_;te<E;++te)J+=ht[P[te]];return J}function L(P,_,E){const z=P.slice(_,E);let J="";for(let te=0;te<z.length-1;te+=2)J+=String.fromCharCode(z[te]+z[te+1]*256);return J}a.prototype.slice=function(_,E){const z=this.length;_=~~_,E=E===void 0?z:~~E,_<0?(_+=z,_<0&&(_=0)):_>z&&(_=z),E<0?(E+=z,E<0&&(E=0)):E>z&&(E=z),E<_&&(E=_);const J=this.subarray(_,E);return Object.setPrototypeOf(J,a.prototype),J};function O(P,_,E){if(P%1!==0||P<0)throw new RangeError("offset is not uint");if(P+_>E)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(_,E,z){_=_>>>0,E=E>>>0,z||O(_,E,this.length);let J=this[_],te=1,ae=0;for(;++ae<E&&(te*=256);)J+=this[_+ae]*te;return J},a.prototype.readUintBE=a.prototype.readUIntBE=function(_,E,z){_=_>>>0,E=E>>>0,z||O(_,E,this.length);let J=this[_+--E],te=1;for(;E>0&&(te*=256);)J+=this[_+--E]*te;return J},a.prototype.readUint8=a.prototype.readUInt8=function(_,E){return _=_>>>0,E||O(_,1,this.length),this[_]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(_,E){return _=_>>>0,E||O(_,2,this.length),this[_]|this[_+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(_,E){return _=_>>>0,E||O(_,2,this.length),this[_]<<8|this[_+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(_,E){return _=_>>>0,E||O(_,4,this.length),(this[_]|this[_+1]<<8|this[_+2]<<16)+this[_+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(_,E){return _=_>>>0,E||O(_,4,this.length),this[_]*16777216+(this[_+1]<<16|this[_+2]<<8|this[_+3])},a.prototype.readBigUInt64LE=Mr(function(_){_=_>>>0,ve(_,"offset");const E=this[_],z=this[_+7];(E===void 0||z===void 0)&&xe(_,this.length-8);const J=E+this[++_]*2**8+this[++_]*2**16+this[++_]*2**24,te=this[++_]+this[++_]*2**8+this[++_]*2**16+z*2**24;return BigInt(J)+(BigInt(te)<<BigInt(32))}),a.prototype.readBigUInt64BE=Mr(function(_){_=_>>>0,ve(_,"offset");const E=this[_],z=this[_+7];(E===void 0||z===void 0)&&xe(_,this.length-8);const J=E*2**24+this[++_]*2**16+this[++_]*2**8+this[++_],te=this[++_]*2**24+this[++_]*2**16+this[++_]*2**8+z;return(BigInt(J)<<BigInt(32))+BigInt(te)}),a.prototype.readIntLE=function(_,E,z){_=_>>>0,E=E>>>0,z||O(_,E,this.length);let J=this[_],te=1,ae=0;for(;++ae<E&&(te*=256);)J+=this[_+ae]*te;return te*=128,J>=te&&(J-=Math.pow(2,8*E)),J},a.prototype.readIntBE=function(_,E,z){_=_>>>0,E=E>>>0,z||O(_,E,this.length);let J=E,te=1,ae=this[_+--J];for(;J>0&&(te*=256);)ae+=this[_+--J]*te;return te*=128,ae>=te&&(ae-=Math.pow(2,8*E)),ae},a.prototype.readInt8=function(_,E){return _=_>>>0,E||O(_,1,this.length),this[_]&128?(255-this[_]+1)*-1:this[_]},a.prototype.readInt16LE=function(_,E){_=_>>>0,E||O(_,2,this.length);const z=this[_]|this[_+1]<<8;return z&32768?z|4294901760:z},a.prototype.readInt16BE=function(_,E){_=_>>>0,E||O(_,2,this.length);const z=this[_+1]|this[_]<<8;return z&32768?z|4294901760:z},a.prototype.readInt32LE=function(_,E){return _=_>>>0,E||O(_,4,this.length),this[_]|this[_+1]<<8|this[_+2]<<16|this[_+3]<<24},a.prototype.readInt32BE=function(_,E){return _=_>>>0,E||O(_,4,this.length),this[_]<<24|this[_+1]<<16|this[_+2]<<8|this[_+3]},a.prototype.readBigInt64LE=Mr(function(_){_=_>>>0,ve(_,"offset");const E=this[_],z=this[_+7];(E===void 0||z===void 0)&&xe(_,this.length-8);const J=this[_+4]+this[_+5]*2**8+this[_+6]*2**16+(z<<24);return(BigInt(J)<<BigInt(32))+BigInt(E+this[++_]*2**8+this[++_]*2**16+this[++_]*2**24)}),a.prototype.readBigInt64BE=Mr(function(_){_=_>>>0,ve(_,"offset");const E=this[_],z=this[_+7];(E===void 0||z===void 0)&&xe(_,this.length-8);const J=(E<<24)+this[++_]*2**16+this[++_]*2**8+this[++_];return(BigInt(J)<<BigInt(32))+BigInt(this[++_]*2**24+this[++_]*2**16+this[++_]*2**8+z)}),a.prototype.readFloatLE=function(_,E){return _=_>>>0,E||O(_,4,this.length),n.read(this,_,!0,23,4)},a.prototype.readFloatBE=function(_,E){return _=_>>>0,E||O(_,4,this.length),n.read(this,_,!1,23,4)},a.prototype.readDoubleLE=function(_,E){return _=_>>>0,E||O(_,8,this.length),n.read(this,_,!0,52,8)},a.prototype.readDoubleBE=function(_,E){return _=_>>>0,E||O(_,8,this.length),n.read(this,_,!1,52,8)};function f(P,_,E,z,J,te){if(!a.isBuffer(P))throw new TypeError('"buffer" argument must be a Buffer instance');if(_>J||_<te)throw new RangeError('"value" argument is out of bounds');if(E+z>P.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(_,E,z,J){if(_=+_,E=E>>>0,z=z>>>0,!J){const De=Math.pow(2,8*z)-1;f(this,_,E,z,De,0)}let te=1,ae=0;for(this[E]=_&255;++ae<z&&(te*=256);)this[E+ae]=_/te&255;return E+z},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(_,E,z,J){if(_=+_,E=E>>>0,z=z>>>0,!J){const De=Math.pow(2,8*z)-1;f(this,_,E,z,De,0)}let te=z-1,ae=1;for(this[E+te]=_&255;--te>=0&&(ae*=256);)this[E+te]=_/ae&255;return E+z},a.prototype.writeUint8=a.prototype.writeUInt8=function(_,E,z){return _=+_,E=E>>>0,z||f(this,_,E,1,255,0),this[E]=_&255,E+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(_,E,z){return _=+_,E=E>>>0,z||f(this,_,E,2,65535,0),this[E]=_&255,this[E+1]=_>>>8,E+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(_,E,z){return _=+_,E=E>>>0,z||f(this,_,E,2,65535,0),this[E]=_>>>8,this[E+1]=_&255,E+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(_,E,z){return _=+_,E=E>>>0,z||f(this,_,E,4,4294967295,0),this[E+3]=_>>>24,this[E+2]=_>>>16,this[E+1]=_>>>8,this[E]=_&255,E+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(_,E,z){return _=+_,E=E>>>0,z||f(this,_,E,4,4294967295,0),this[E]=_>>>24,this[E+1]=_>>>16,this[E+2]=_>>>8,this[E+3]=_&255,E+4};function v(P,_,E,z,J){re(_,z,J,P,E,7);let te=Number(_&BigInt(4294967295));P[E++]=te,te=te>>8,P[E++]=te,te=te>>8,P[E++]=te,te=te>>8,P[E++]=te;let ae=Number(_>>BigInt(32)&BigInt(4294967295));return P[E++]=ae,ae=ae>>8,P[E++]=ae,ae=ae>>8,P[E++]=ae,ae=ae>>8,P[E++]=ae,E}function k(P,_,E,z,J){re(_,z,J,P,E,7);let te=Number(_&BigInt(4294967295));P[E+7]=te,te=te>>8,P[E+6]=te,te=te>>8,P[E+5]=te,te=te>>8,P[E+4]=te;let ae=Number(_>>BigInt(32)&BigInt(4294967295));return P[E+3]=ae,ae=ae>>8,P[E+2]=ae,ae=ae>>8,P[E+1]=ae,ae=ae>>8,P[E]=ae,E+8}a.prototype.writeBigUInt64LE=Mr(function(_,E=0){return v(this,_,E,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=Mr(function(_,E=0){return k(this,_,E,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(_,E,z,J){if(_=+_,E=E>>>0,!J){const Me=Math.pow(2,8*z-1);f(this,_,E,z,Me-1,-Me)}let te=0,ae=1,De=0;for(this[E]=_&255;++te<z&&(ae*=256);)_<0&&De===0&&this[E+te-1]!==0&&(De=1),this[E+te]=(_/ae>>0)-De&255;return E+z},a.prototype.writeIntBE=function(_,E,z,J){if(_=+_,E=E>>>0,!J){const Me=Math.pow(2,8*z-1);f(this,_,E,z,Me-1,-Me)}let te=z-1,ae=1,De=0;for(this[E+te]=_&255;--te>=0&&(ae*=256);)_<0&&De===0&&this[E+te+1]!==0&&(De=1),this[E+te]=(_/ae>>0)-De&255;return E+z},a.prototype.writeInt8=function(_,E,z){return _=+_,E=E>>>0,z||f(this,_,E,1,127,-128),_<0&&(_=255+_+1),this[E]=_&255,E+1},a.prototype.writeInt16LE=function(_,E,z){return _=+_,E=E>>>0,z||f(this,_,E,2,32767,-32768),this[E]=_&255,this[E+1]=_>>>8,E+2},a.prototype.writeInt16BE=function(_,E,z){return _=+_,E=E>>>0,z||f(this,_,E,2,32767,-32768),this[E]=_>>>8,this[E+1]=_&255,E+2},a.prototype.writeInt32LE=function(_,E,z){return _=+_,E=E>>>0,z||f(this,_,E,4,2147483647,-2147483648),this[E]=_&255,this[E+1]=_>>>8,this[E+2]=_>>>16,this[E+3]=_>>>24,E+4},a.prototype.writeInt32BE=function(_,E,z){return _=+_,E=E>>>0,z||f(this,_,E,4,2147483647,-2147483648),_<0&&(_=4294967295+_+1),this[E]=_>>>24,this[E+1]=_>>>16,this[E+2]=_>>>8,this[E+3]=_&255,E+4},a.prototype.writeBigInt64LE=Mr(function(_,E=0){return v(this,_,E,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=Mr(function(_,E=0){return k(this,_,E,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function M(P,_,E,z,J,te){if(E+z>P.length)throw new RangeError("Index out of range");if(E<0)throw new RangeError("Index out of range")}function H(P,_,E,z,J){return _=+_,E=E>>>0,J||M(P,_,E,4),n.write(P,_,E,z,23,4),E+4}a.prototype.writeFloatLE=function(_,E,z){return H(this,_,E,!0,z)},a.prototype.writeFloatBE=function(_,E,z){return H(this,_,E,!1,z)};function Q(P,_,E,z,J){return _=+_,E=E>>>0,J||M(P,_,E,8),n.write(P,_,E,z,52,8),E+8}a.prototype.writeDoubleLE=function(_,E,z){return Q(this,_,E,!0,z)},a.prototype.writeDoubleBE=function(_,E,z){return Q(this,_,E,!1,z)},a.prototype.copy=function(_,E,z,J){if(!a.isBuffer(_))throw new TypeError("argument should be a Buffer");if(z||(z=0),!J&&J!==0&&(J=this.length),E>=_.length&&(E=_.length),E||(E=0),J>0&&J<z&&(J=z),J===z||_.length===0||this.length===0)return 0;if(E<0)throw new RangeError("targetStart out of bounds");if(z<0||z>=this.length)throw new RangeError("Index out of range");if(J<0)throw new RangeError("sourceEnd out of bounds");J>this.length&&(J=this.length),_.length-E<J-z&&(J=_.length-E+z);const te=J-z;return this===_&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(E,z,J):Uint8Array.prototype.set.call(_,this.subarray(z,J),E),te},a.prototype.fill=function(_,E,z,J){if(typeof _=="string"){if(typeof E=="string"?(J=E,E=0,z=this.length):typeof z=="string"&&(J=z,z=this.length),J!==void 0&&typeof J!="string")throw new TypeError("encoding must be a string");if(typeof J=="string"&&!a.isEncoding(J))throw new TypeError("Unknown encoding: "+J);if(_.length===1){const ae=_.charCodeAt(0);(J==="utf8"&&ae<128||J==="latin1")&&(_=ae)}}else typeof _=="number"?_=_&255:typeof _=="boolean"&&(_=Number(_));if(E<0||this.length<E||this.length<z)throw new RangeError("Out of range index");if(z<=E)return this;E=E>>>0,z=z===void 0?this.length:z>>>0,_||(_=0);let te;if(typeof _=="number")for(te=E;te<z;++te)this[te]=_;else{const ae=a.isBuffer(_)?_:a.from(_,J),De=ae.length;if(De===0)throw new TypeError('The value "'+_+'" is invalid for argument "value"');for(te=0;te<z-E;++te)this[te+E]=ae[te%De]}return this};const X={};function j(P,_,E){X[P]=class extends E{constructor(){super(),Object.defineProperty(this,"message",{value:_.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${P}]`,this.stack,delete this.name}get code(){return P}set code(J){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:J,writable:!0})}toString(){return`${this.name} [${P}]: ${this.message}`}}}j("ERR_BUFFER_OUT_OF_BOUNDS",function(P){return P?`${P} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),j("ERR_INVALID_ARG_TYPE",function(P,_){return`The "${P}" argument must be of type number. Received type ${typeof _}`},TypeError),j("ERR_OUT_OF_RANGE",function(P,_,E){let z=`The value of "${P}" is out of range.`,J=E;return Number.isInteger(E)&&Math.abs(E)>2**32?J=ee(String(E)):typeof E=="bigint"&&(J=String(E),(E>BigInt(2)**BigInt(32)||E<-(BigInt(2)**BigInt(32)))&&(J=ee(J)),J+="n"),z+=` It must be ${_}. Received ${J}`,z},RangeError);function ee(P){let _="",E=P.length;const z=P[0]==="-"?1:0;for(;E>=z+4;E-=3)_=`_${P.slice(E-3,E)}${_}`;return`${P.slice(0,E)}${_}`}function se(P,_,E){ve(_,"offset"),(P[_]===void 0||P[_+E]===void 0)&&xe(_,P.length-(E+1))}function re(P,_,E,z,J,te){if(P>E||P<_){const ae=typeof _=="bigint"?"n":"";let De;throw _===0||_===BigInt(0)?De=`>= 0${ae} and < 2${ae} ** ${(te+1)*8}${ae}`:De=`>= -(2${ae} ** ${(te+1)*8-1}${ae}) and < 2 ** ${(te+1)*8-1}${ae}`,new X.ERR_OUT_OF_RANGE("value",De,P)}se(z,J,te)}function ve(P,_){if(typeof P!="number")throw new X.ERR_INVALID_ARG_TYPE(_,"number",P)}function xe(P,_,E){throw Math.floor(P)!==P?(ve(P,E),new X.ERR_OUT_OF_RANGE("offset","an integer",P)):_<0?new X.ERR_BUFFER_OUT_OF_BOUNDS:new X.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${_}`,P)}const Pe=/[^+/0-9A-Za-z-_]/g;function Et(P){if(P=P.split("=")[0],P=P.trim().replace(Pe,""),P.length<2)return"";for(;P.length%4!==0;)P=P+"=";return P}function He(P,_){_=_||1/0;let E;const z=P.length;let J=null;const te=[];for(let ae=0;ae<z;++ae){if(E=P.charCodeAt(ae),E>55295&&E<57344){if(!J){if(E>56319){(_-=3)>-1&&te.push(239,191,189);continue}else if(ae+1===z){(_-=3)>-1&&te.push(239,191,189);continue}J=E;continue}if(E<56320){(_-=3)>-1&&te.push(239,191,189),J=E;continue}E=(J-55296<<10|E-56320)+65536}else J&&(_-=3)>-1&&te.push(239,191,189);if(J=null,E<128){if((_-=1)<0)break;te.push(E)}else if(E<2048){if((_-=2)<0)break;te.push(E>>6|192,E&63|128)}else if(E<65536){if((_-=3)<0)break;te.push(E>>12|224,E>>6&63|128,E&63|128)}else if(E<1114112){if((_-=4)<0)break;te.push(E>>18|240,E>>12&63|128,E>>6&63|128,E&63|128)}else throw new Error("Invalid code point")}return te}function ot(P){const _=[];for(let E=0;E<P.length;++E)_.push(P.charCodeAt(E)&255);return _}function ri(P,_){let E,z,J;const te=[];for(let ae=0;ae<P.length&&!((_-=2)<0);++ae)E=P.charCodeAt(ae),z=E>>8,J=E%256,te.push(J),te.push(z);return te}function nt(P){return e.toByteArray(Et(P))}function Qe(P,_,E,z){let J;for(J=0;J<z&&!(J+E>=_.length||J>=P.length);++J)_[J+E]=P[J];return J}function ln(P,_){return P instanceof _||P!=null&&P.constructor!=null&&P.constructor.name!=null&&P.constructor.name===_.name}function st(P){return P!==P}const ht=(function(){const P="0123456789abcdef",_=new Array(256);for(let E=0;E<16;++E){const z=E*16;for(let J=0;J<16;++J)_[z+J]=P[E]+P[J]}return _})();function Mr(P){return typeof BigInt=="undefined"?St:P}function St(){throw new Error("BigInt not supported")}})(Sg)),Sg}var $e=Ig();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Cg=BigInt(0),Ag=BigInt(1);function Po(t,e=""){if(typeof t!="boolean"){const n=e&&`"${e}"`;throw new Error(n+"expected boolean, got type="+typeof t)}return t}function Rr(t,e,n=""){const r=il(t),i=t==null?void 0:t.length,o=e!==void 0;if(!r||o&&i!==e){const s=n&&`"${n}" `,a=o?` of length ${e}`:"",l=r?`length=${i}`:`type=${typeof t}`;throw new Error(s+"expected Uint8Array"+a+", got "+l)}return t}function Mu(t){const e=t.toString(16);return e.length&1?"0"+e:e}function F1(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Cg:BigInt("0x"+t)}function Bu(t){return F1(To(t))}function vl(t){return yi(t),F1(To(Uint8Array.from(t).reverse()))}function Og(t,e){return xu(t.toString(16).padStart(e*2,"0"))}function D1(t,e){return Og(t,e).reverse()}function xt(t,e,n){let r;if(typeof e=="string")try{r=xu(e)}catch(o){throw new Error(t+" must be hex string or Uint8Array, cause: "+o)}else if(il(e))r=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const i=r.length;if(typeof n=="number"&&i!==n)throw new Error(t+" of length "+n+" expected, got "+i);return r}function V1(t){return Uint8Array.from(t)}const kg=t=>typeof t=="bigint"&&Cg<=t;function jV(t,e,n){return kg(t)&&kg(e)&&kg(n)&&e<=t&&t<n}function Tg(t,e,n,r){if(!jV(e,n,r))throw new Error("expected valid "+t+": "+n+" <= n < "+r+", got "+e)}function $1(t){let e;for(e=0;t>Cg;t>>=Ag,e+=1);return e}const yl=t=>(Ag<<BigInt(t))-Ag;function qV(t,e,n){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");const r=g=>new Uint8Array(g),i=g=>Uint8Array.of(g);let o=r(t),s=r(t),a=0;const l=()=>{o.fill(1),s.fill(0),a=0},c=(...g)=>n(s,o,...g),u=(g=r(0))=>{s=c(i(0),g),o=c(),g.length!==0&&(s=c(i(1),g),o=c())},h=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let g=0;const b=[];for(;g<e;){o=c();const m=o.slice();b.push(m),g+=o.length}return Yr(...b)};return(g,b)=>{l(),u(g);let m;for(;!(m=b(h()));)u();return l(),m}}function bl(t,e,n={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function r(i,o,s){const a=t[i];if(s&&a===void 0)return;const l=typeof a;if(l!==o||a===null)throw new Error(`param "${i}" is invalid: expected ${o}, got ${l}`)}Object.entries(e).forEach(([i,o])=>r(i,o,!1)),Object.entries(n).forEach(([i,o])=>r(i,o,!0))}function Fu(t){const e=new WeakMap;return(n,...r)=>{const i=e.get(n);if(i!==void 0)return i;const o=t(n,...r);return e.set(n,o),o}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Wn=BigInt(0),pn=BigInt(1),Lo=BigInt(2),z1=BigInt(3),U1=BigInt(4),W1=BigInt(5),GV=BigInt(7),H1=BigInt(8),KV=BigInt(9),j1=BigInt(16);function Lt(t,e){const n=t%e;return n>=Wn?n:e+n}function wt(t,e,n){let r=t;for(;e-- >Wn;)r*=r,r%=n;return r}function q1(t,e){if(t===Wn)throw new Error("invert: expected non-zero number");if(e<=Wn)throw new Error("invert: expected positive modulus, got "+e);let n=Lt(t,e),r=e,i=Wn,o=pn;for(;n!==Wn;){const a=r/n,l=r%n,c=i-o*a;r=n,n=l,i=o,o=c}if(r!==pn)throw new Error("invert: does not exist");return Lt(i,e)}function Rg(t,e,n){if(!t.eql(t.sqr(e),n))throw new Error("Cannot find square root")}function G1(t,e){const n=(t.ORDER+pn)/U1,r=t.pow(e,n);return Rg(t,r,e),r}function YV(t,e){const n=(t.ORDER-W1)/H1,r=t.mul(e,Lo),i=t.pow(r,n),o=t.mul(e,i),s=t.mul(t.mul(o,Lo),i),a=t.mul(o,t.sub(s,t.ONE));return Rg(t,a,e),a}function XV(t){const e=Mo(t),n=K1(t),r=n(e,e.neg(e.ONE)),i=n(e,r),o=n(e,e.neg(r)),s=(t+GV)/j1;return(a,l)=>{let c=a.pow(l,s),u=a.mul(c,r);const h=a.mul(c,i),p=a.mul(c,o),g=a.eql(a.sqr(u),l),b=a.eql(a.sqr(h),l);c=a.cmov(c,u,g),u=a.cmov(p,h,b);const m=a.eql(a.sqr(u),l),x=a.cmov(c,u,m);return Rg(a,x,l),x}}function K1(t){if(t<z1)throw new Error("sqrt is not defined for small field");let e=t-pn,n=0;for(;e%Lo===Wn;)e/=Lo,n++;let r=Lo;const i=Mo(t);for(;X1(i,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return G1;let o=i.pow(r,e);const s=(e+pn)/Lo;return function(l,c){if(l.is0(c))return c;if(X1(l,c)!==1)throw new Error("Cannot find square root");let u=n,h=l.mul(l.ONE,o),p=l.pow(c,e),g=l.pow(c,s);for(;!l.eql(p,l.ONE);){if(l.is0(p))return l.ZERO;let b=1,m=l.sqr(p);for(;!l.eql(m,l.ONE);)if(b++,m=l.sqr(m),b===u)throw new Error("Cannot find square root");const x=pn<<BigInt(u-b-1),I=l.pow(h,x);u=b,h=l.sqr(I),p=l.mul(p,h),g=l.mul(g,I)}return g}}function ZV(t){return t%U1===z1?G1:t%H1===W1?YV:t%j1===KV?XV(t):K1(t)}const JV=(t,e)=>(Lt(t,e)&pn)===pn,QV=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function e$(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},n=QV.reduce((r,i)=>(r[i]="function",r),e);return bl(t,n),t}function t$(t,e,n){if(n<Wn)throw new Error("invalid exponent, negatives unsupported");if(n===Wn)return t.ONE;if(n===pn)return e;let r=t.ONE,i=e;for(;n>Wn;)n&pn&&(r=t.mul(r,i)),i=t.sqr(i),n>>=pn;return r}function Y1(t,e,n=!1){const r=new Array(e.length).fill(n?t.ZERO:void 0),i=e.reduce((s,a,l)=>t.is0(a)?s:(r[l]=s,t.mul(s,a)),t.ONE),o=t.inv(i);return e.reduceRight((s,a,l)=>t.is0(a)?s:(r[l]=t.mul(s,r[l]),t.mul(s,a)),o),r}function X1(t,e){const n=(t.ORDER-pn)/Lo,r=t.pow(e,n),i=t.eql(r,t.ONE),o=t.eql(r,t.ZERO),s=t.eql(r,t.neg(t.ONE));if(!i&&!o&&!s)throw new Error("invalid Legendre symbol result");return i?1:o?0:-1}function Z1(t,e){e!==void 0&&ol(e);const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Mo(t,e,n=!1,r={}){if(t<=Wn)throw new Error("invalid field: expected ORDER > 0, got "+t);let i,o,s=!1,a;if(typeof e=="object"&&e!=null){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");const p=e;p.BITS&&(i=p.BITS),p.sqrt&&(o=p.sqrt),typeof p.isLE=="boolean"&&(n=p.isLE),typeof p.modFromBytes=="boolean"&&(s=p.modFromBytes),a=p.allowedLengths}else typeof e=="number"&&(i=e),r.sqrt&&(o=r.sqrt);const{nBitLength:l,nByteLength:c}=Z1(t,i);if(c>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let u;const h=Object.freeze({ORDER:t,isLE:n,BITS:l,BYTES:c,MASK:yl(l),ZERO:Wn,ONE:pn,allowedLengths:a,create:p=>Lt(p,t),isValid:p=>{if(typeof p!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof p);return Wn<=p&&p<t},is0:p=>p===Wn,isValidNot0:p=>!h.is0(p)&&h.isValid(p),isOdd:p=>(p&pn)===pn,neg:p=>Lt(-p,t),eql:(p,g)=>p===g,sqr:p=>Lt(p*p,t),add:(p,g)=>Lt(p+g,t),sub:(p,g)=>Lt(p-g,t),mul:(p,g)=>Lt(p*g,t),pow:(p,g)=>t$(h,p,g),div:(p,g)=>Lt(p*q1(g,t),t),sqrN:p=>p*p,addN:(p,g)=>p+g,subN:(p,g)=>p-g,mulN:(p,g)=>p*g,inv:p=>q1(p,t),sqrt:o||(p=>(u||(u=ZV(t)),u(h,p))),toBytes:p=>n?D1(p,c):Og(p,c),fromBytes:(p,g=!0)=>{if(a){if(!a.includes(p.length)||p.length>c)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+p.length);const m=new Uint8Array(c);m.set(p,n?0:m.length-p.length),p=m}if(p.length!==c)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+p.length);let b=n?vl(p):Bu(p);if(s&&(b=Lt(b,t)),!g&&!h.isValid(b))throw new Error("invalid field element: outside of range 0..ORDER");return b},invertBatch:p=>Y1(h,p),cmov:(p,g,b)=>b?g:p});return Object.freeze(h)}function J1(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function Q1(t){const e=J1(t);return e+Math.ceil(e/2)}function n$(t,e,n=!1){const r=t.length,i=J1(e),o=Q1(e);if(r<16||r<o||r>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+r);const s=n?vl(t):Bu(t),a=Lt(s,e-pn)+pn;return n?D1(a,i):Og(a,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const $s=BigInt(0),Bo=BigInt(1);function Du(t,e){const n=e.negate();return t?n:e}function Fo(t,e){const n=Y1(t.Fp,e.map(r=>r.Z));return e.map((r,i)=>t.fromAffine(r.toAffine(n[i])))}function ew(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Ng(t,e){ew(t,e);const n=Math.ceil(e/t)+1,r=2**(t-1),i=2**t,o=yl(t),s=BigInt(t);return{windows:n,windowSize:r,mask:o,maxNumber:i,shiftBy:s}}function tw(t,e,n){const{windowSize:r,mask:i,maxNumber:o,shiftBy:s}=n;let a=Number(t&i),l=t>>s;a>r&&(a-=o,l+=Bo);const c=e*r,u=c+Math.abs(a)-1,h=a===0,p=a<0,g=e%2!==0;return{nextN:l,offset:u,isZero:h,isNeg:p,isNegF:g,offsetF:c}}function r$(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((n,r)=>{if(!(n instanceof e))throw new Error("invalid point at index "+r)})}function i$(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((n,r)=>{if(!e.isValid(n))throw new Error("invalid scalar at index "+r)})}const Pg=new WeakMap,nw=new WeakMap;function Lg(t){return nw.get(t)||1}function rw(t){if(t!==$s)throw new Error("invalid wNAF")}class iw{constructor(e,n){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=n}_unsafeLadder(e,n,r=this.ZERO){let i=e;for(;n>$s;)n&Bo&&(r=r.add(i)),i=i.double(),n>>=Bo;return r}precomputeWindow(e,n){const{windows:r,windowSize:i}=Ng(n,this.bits),o=[];let s=e,a=s;for(let l=0;l<r;l++){a=s,o.push(a);for(let c=1;c<i;c++)a=a.add(s),o.push(a);s=a.double()}return o}wNAF(e,n,r){if(!this.Fn.isValid(r))throw new Error("invalid scalar");let i=this.ZERO,o=this.BASE;const s=Ng(e,this.bits);for(let a=0;a<s.windows;a++){const{nextN:l,offset:c,isZero:u,isNeg:h,isNegF:p,offsetF:g}=tw(r,a,s);r=l,u?o=o.add(Du(p,n[g])):i=i.add(Du(h,n[c]))}return rw(r),{p:i,f:o}}wNAFUnsafe(e,n,r,i=this.ZERO){const o=Ng(e,this.bits);for(let s=0;s<o.windows&&r!==$s;s++){const{nextN:a,offset:l,isZero:c,isNeg:u}=tw(r,s,o);if(r=a,!c){const h=n[l];i=i.add(u?h.negate():h)}}return rw(r),i}getPrecomputes(e,n,r){let i=Pg.get(n);return i||(i=this.precomputeWindow(n,e),e!==1&&(typeof r=="function"&&(i=r(i)),Pg.set(n,i))),i}cached(e,n,r){const i=Lg(e);return this.wNAF(i,this.getPrecomputes(i,e,r),n)}unsafe(e,n,r,i){const o=Lg(e);return o===1?this._unsafeLadder(e,n,i):this.wNAFUnsafe(o,this.getPrecomputes(o,e,r),n,i)}createCache(e,n){ew(n,this.bits),nw.set(e,n),Pg.delete(e)}hasCache(e){return Lg(e)!==1}}function o$(t,e,n,r){let i=e,o=t.ZERO,s=t.ZERO;for(;n>$s||r>$s;)n&Bo&&(o=o.add(i)),r&Bo&&(s=s.add(i)),i=i.double(),n>>=Bo,r>>=Bo;return{p1:o,p2:s}}function ow(t,e,n,r){r$(n,t),i$(r,e);const i=n.length,o=r.length;if(i!==o)throw new Error("arrays of points and scalars must have equal length");const s=t.ZERO,a=$1(BigInt(i));let l=1;a>12?l=a-3:a>4?l=a-2:a>0&&(l=2);const c=yl(l),u=new Array(Number(c)+1).fill(s),h=Math.floor((e.BITS-1)/l)*l;let p=s;for(let g=h;g>=0;g-=l){u.fill(s);for(let m=0;m<o;m++){const x=r[m],I=Number(x>>BigInt(g)&c);u[I]=u[I].add(n[m])}let b=s;for(let m=u.length-1,x=s;m>0;m--)x=x.add(u[m]),b=b.add(x);if(p=p.add(b),g!==0)for(let m=0;m<l;m++)p=p.double()}return p}function sw(t,e,n){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return e$(e),e}else return Mo(t,{isLE:n})}function aw(t,e,n={},r){if(r===void 0&&(r=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);for(const l of["p","n","h"]){const c=e[l];if(!(typeof c=="bigint"&&c>$s))throw new Error(`CURVE.${l} must be positive bigint`)}const i=sw(e.p,n.Fp,r),o=sw(e.n,n.Fn,r),a=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(const l of a)if(!i.isValid(e[l]))throw new Error(`CURVE.${l} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:i,Fn:o}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Qi=BigInt(0),sn=BigInt(1),Mg=BigInt(2),s$=BigInt(8);function a$(t,e,n,r){const i=t.sqr(n),o=t.sqr(r),s=t.add(t.mul(e.a,i),o),a=t.add(t.ONE,t.mul(e.d,t.mul(i,o)));return t.eql(s,a)}function l$(t,e={}){const n=aw("edwards",t,e,e.FpFnLE),{Fp:r,Fn:i}=n;let o=n.CURVE;const{h:s}=o;bl(e,{},{uvRatio:"function"});const a=Mg<<BigInt(i.BYTES*8)-sn,l=x=>r.create(x),c=e.uvRatio||((x,I)=>{try{return{isValid:!0,value:r.sqrt(r.div(x,I))}}catch(N){return{isValid:!1,value:Qi}}});if(!a$(r,o,o.Gx,o.Gy))throw new Error("bad curve params: generator point");function u(x,I,N=!1){const T=N?sn:Qi;return Tg("coordinate "+x,I,T,a),I}function h(x){if(!(x instanceof b))throw new Error("ExtendedPoint expected")}const p=Fu((x,I)=>{const{X:N,Y:T,Z:$}=x,B=x.is0();I==null&&(I=B?s$:r.inv($));const G=l(N*I),Z=l(T*I),Y=r.mul($,I);if(B)return{x:Qi,y:sn};if(Y!==sn)throw new Error("invZ was invalid");return{x:G,y:Z}}),g=Fu(x=>{const{a:I,d:N}=o;if(x.is0())throw new Error("bad point: ZERO");const{X:T,Y:$,Z:B,T:G}=x,Z=l(T*T),Y=l($*$),F=l(B*B),V=l(F*F),U=l(Z*I),W=l(F*l(U+Y)),A=l(V+l(N*l(Z*Y)));if(W!==A)throw new Error("bad point: equation left != right (1)");const d=l(T*$),y=l(B*G);if(d!==y)throw new Error("bad point: equation left != right (2)");return!0});class b{constructor(I,N,T,$){this.X=u("x",I),this.Y=u("y",N),this.Z=u("z",T,!0),this.T=u("t",$),Object.freeze(this)}static CURVE(){return o}static fromAffine(I){if(I instanceof b)throw new Error("extended point not allowed");const{x:N,y:T}=I||{};return u("x",N),u("y",T),new b(N,T,sn,l(N*T))}static fromBytes(I,N=!1){const T=r.BYTES,{a:$,d:B}=o;I=V1(Rr(I,T,"point")),Po(N,"zip215");const G=V1(I),Z=I[T-1];G[T-1]=Z&-129;const Y=vl(G),F=N?a:r.ORDER;Tg("point.y",Y,Qi,F);const V=l(Y*Y),U=l(V-sn),W=l(B*V-$);let{isValid:A,value:d}=c(U,W);if(!A)throw new Error("bad point: invalid y coordinate");const y=(d&sn)===sn,S=(Z&128)!==0;if(!N&&d===Qi&&S)throw new Error("bad point: x=0 and x_0=1");return S!==y&&(d=l(-d)),b.fromAffine({x:d,y:Y})}static fromHex(I,N=!1){return b.fromBytes(xt("point",I),N)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(I=8,N=!0){return m.createCache(this,I),N||this.multiply(Mg),this}assertValidity(){g(this)}equals(I){h(I);const{X:N,Y:T,Z:$}=this,{X:B,Y:G,Z}=I,Y=l(N*Z),F=l(B*$),V=l(T*Z),U=l(G*$);return Y===F&&V===U}is0(){return this.equals(b.ZERO)}negate(){return new b(l(-this.X),this.Y,this.Z,l(-this.T))}double(){const{a:I}=o,{X:N,Y:T,Z:$}=this,B=l(N*N),G=l(T*T),Z=l(Mg*l($*$)),Y=l(I*B),F=N+T,V=l(l(F*F)-B-G),U=Y+G,W=U-Z,A=Y-G,d=l(V*W),y=l(U*A),S=l(V*A),C=l(W*U);return new b(d,y,C,S)}add(I){h(I);const{a:N,d:T}=o,{X:$,Y:B,Z:G,T:Z}=this,{X:Y,Y:F,Z:V,T:U}=I,W=l($*Y),A=l(B*F),d=l(Z*T*U),y=l(G*V),S=l(($+B)*(Y+F)-W-A),C=y-d,R=y+d,D=l(A-N*W),L=l(S*C),O=l(R*D),f=l(S*D),v=l(C*R);return new b(L,O,v,f)}subtract(I){return this.add(I.negate())}multiply(I){if(!i.isValidNot0(I))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:N,f:T}=m.cached(this,I,$=>Fo(b,$));return Fo(b,[N,T])[0]}multiplyUnsafe(I,N=b.ZERO){if(!i.isValid(I))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return I===Qi?b.ZERO:this.is0()||I===sn?this:m.unsafe(this,I,T=>Fo(b,T),N)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}isTorsionFree(){return m.unsafe(this,o.n).is0()}toAffine(I){return p(this,I)}clearCofactor(){return s===sn?this:this.multiplyUnsafe(s)}toBytes(){const{x:I,y:N}=this.toAffine(),T=r.toBytes(N);return T[T.length-1]|=I&sn?128:0,T}toHex(){return To(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(I){return Fo(b,I)}static msm(I,N){return ow(b,i,I,N)}_setWindowSize(I){this.precompute(I)}toRawBytes(){return this.toBytes()}}b.BASE=new b(o.Gx,o.Gy,sn,l(o.Gx*o.Gy)),b.ZERO=new b(Qi,sn,sn,Qi),b.Fp=r,b.Fn=i;const m=new iw(b,i.BITS);return b.BASE.precompute(8),b}function c$(t,e,n={}){if(typeof e!="function")throw new Error('"hash" function param is required');bl(n,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:r}=n,{BASE:i,Fp:o,Fn:s}=t,a=n.randomBytes||ig,l=n.adjustScalarBytes||(F=>F),c=n.domain||((F,V,U)=>{if(Po(U,"phflag"),V.length||U)throw new Error("Contexts/pre-hash are not supported");return F});function u(F){return s.create(vl(F))}function h(F){const V=T.secretKey;F=xt("private key",F,V);const U=xt("hashed private key",e(F),2*V),W=l(U.slice(0,V)),A=U.slice(V,2*V),d=u(W);return{head:W,prefix:A,scalar:d}}function p(F){const{head:V,prefix:U,scalar:W}=h(F),A=i.multiply(W),d=A.toBytes();return{head:V,prefix:U,scalar:W,point:A,pointBytes:d}}function g(F){return p(F).pointBytes}function b(F=Uint8Array.of(),...V){const U=Yr(...V);return u(e(c(U,xt("context",F),!!r)))}function m(F,V,U={}){F=xt("message",F),r&&(F=r(F));const{prefix:W,scalar:A,pointBytes:d}=p(V),y=b(U.context,W,F),S=i.multiply(y).toBytes(),C=b(U.context,S,d,F),R=s.create(y+C*A);if(!s.isValid(R))throw new Error("sign failed: invalid s");const D=Yr(S,s.toBytes(R));return Rr(D,T.signature,"result")}const x={zip215:!0};function I(F,V,U,W=x){const{context:A,zip215:d}=W,y=T.signature;F=xt("signature",F,y),V=xt("message",V),U=xt("publicKey",U,T.publicKey),d!==void 0&&Po(d,"zip215"),r&&(V=r(V));const S=y/2,C=F.subarray(0,S),R=vl(F.subarray(S,y));let D,L,O;try{D=t.fromBytes(U,d),L=t.fromBytes(C,d),O=i.multiplyUnsafe(R)}catch(k){return!1}if(!d&&D.isSmallOrder())return!1;const f=b(A,L.toBytes(),D.toBytes(),V);return L.add(D.multiplyUnsafe(f)).subtract(O).clearCofactor().is0()}const N=o.BYTES,T={secretKey:N,publicKey:N,signature:2*N,seed:N};function $(F=a(T.seed)){return Rr(F,T.seed,"seed")}function B(F){const V=Y.randomSecretKey(F);return{secretKey:V,publicKey:g(V)}}function G(F){return il(F)&&F.length===s.BYTES}function Z(F,V){try{return!!t.fromBytes(F,V)}catch(U){return!1}}const Y={getExtendedPublicKey:p,randomSecretKey:$,isValidSecretKey:G,isValidPublicKey:Z,toMontgomery(F){const{y:V}=t.fromBytes(F),U=T.publicKey,W=U===32;if(!W&&U!==57)throw new Error("only defined for 25519 and 448");const A=W?o.div(sn+V,sn-V):o.div(V-sn,V+sn);return o.toBytes(A)},toMontgomerySecret(F){const V=T.secretKey;Rr(F,V);const U=e(F.subarray(0,V));return l(U).subarray(0,V)},randomPrivateKey:$,precompute(F=8,V=t.BASE){return V.precompute(F,!1)}};return Object.freeze({keygen:B,getPublicKey:g,sign:m,verify:I,utils:Y,Point:t,lengths:T})}function u$(t){const e={a:t.a,d:t.d,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},n=t.Fp,r=Mo(e.n,t.nBitLength,!0),i={Fp:n,Fn:r,uvRatio:t.uvRatio},o={randomBytes:t.randomBytes,adjustScalarBytes:t.adjustScalarBytes,domain:t.domain,prehash:t.prehash,mapToCurve:t.mapToCurve};return{CURVE:e,curveOpts:i,hash:t.hash,eddsaOpts:o}}function d$(t,e){const n=e.Point;return Object.assign({},e,{ExtendedPoint:n,CURVE:t,nBitLength:n.Fn.BITS,nByteLength:n.Fn.BYTES})}function h$(t){const{CURVE:e,curveOpts:n,hash:r,eddsaOpts:i}=u$(t),o=l$(e,n),s=c$(o,r,i);return d$(t,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const f$=BigInt(1),lw=BigInt(2);BigInt(3);const g$=BigInt(5),p$=BigInt(8),Bg=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),cw={p:Bg,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:p$,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function m$(t){const e=BigInt(10),n=BigInt(20),r=BigInt(40),i=BigInt(80),o=Bg,a=t*t%o*t%o,l=wt(a,lw,o)*a%o,c=wt(l,f$,o)*t%o,u=wt(c,g$,o)*c%o,h=wt(u,e,o)*u%o,p=wt(h,n,o)*h%o,g=wt(p,r,o)*p%o,b=wt(g,i,o)*g%o,m=wt(b,i,o)*g%o,x=wt(m,e,o)*u%o;return{pow_p_5_8:wt(x,lw,o)*t%o,b2:a}}function v$(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const uw=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function y$(t,e){const n=Bg,r=Lt(e*e*e,n),i=Lt(r*r*e,n),o=m$(t*i).pow_p_5_8;let s=Lt(t*r*o,n);const a=Lt(e*s*s,n),l=s,c=Lt(s*uw,n),u=a===t,h=a===Lt(-t,n),p=a===Lt(-t*uw,n);return u&&(s=l),(h||p)&&(s=c),JV(s,n)&&(s=Lt(-s,n)),{isValid:u||h,value:s}}const b$=Mo(cw.p,{isLE:!0}),_$={...cw,Fp:b$,hash:sD,adjustScalarBytes:v$,uvRatio:y$},_l=h$(_$);var Vu={exports:{}};const x$=ya(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var w$=Vu.exports,dw;function hw(){return dw||(dw=1,(function(t){(function(e,n){function r(A,d){if(!A)throw new Error(d||"Assertion failed")}function i(A,d){A.super_=d;var y=function(){};y.prototype=d.prototype,A.prototype=new y,A.prototype.constructor=A}function o(A,d,y){if(o.isBN(A))return A;this.negative=0,this.words=null,this.length=0,this.red=null,A!==null&&((d==="le"||d==="be")&&(y=d,d=10),this._init(A||0,d||10,y||"be"))}typeof e=="object"?e.exports=o:n.BN=o,o.BN=o,o.wordSize=26;var s;try{typeof window!="undefined"&&typeof window.Buffer!="undefined"?s=window.Buffer:s=x$.Buffer}catch(A){}o.isBN=function(d){return d instanceof o?!0:d!==null&&typeof d=="object"&&d.constructor.wordSize===o.wordSize&&Array.isArray(d.words)},o.max=function(d,y){return d.cmp(y)>0?d:y},o.min=function(d,y){return d.cmp(y)<0?d:y},o.prototype._init=function(d,y,S){if(typeof d=="number")return this._initNumber(d,y,S);if(typeof d=="object")return this._initArray(d,y,S);y==="hex"&&(y=16),r(y===(y|0)&&y>=2&&y<=36),d=d.toString().replace(/\s+/g,"");var C=0;d[0]==="-"&&(C++,this.negative=1),C<d.length&&(y===16?this._parseHex(d,C,S):(this._parseBase(d,y,C),S==="le"&&this._initArray(this.toArray(),y,S)))},o.prototype._initNumber=function(d,y,S){d<0&&(this.negative=1,d=-d),d<67108864?(this.words=[d&67108863],this.length=1):d<4503599627370496?(this.words=[d&67108863,d/67108864&67108863],this.length=2):(r(d<9007199254740992),this.words=[d&67108863,d/67108864&67108863,1],this.length=3),S==="le"&&this._initArray(this.toArray(),y,S)},o.prototype._initArray=function(d,y,S){if(r(typeof d.length=="number"),d.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(d.length/3),this.words=new Array(this.length);for(var C=0;C<this.length;C++)this.words[C]=0;var R,D,L=0;if(S==="be")for(C=d.length-1,R=0;C>=0;C-=3)D=d[C]|d[C-1]<<8|d[C-2]<<16,this.words[R]|=D<<L&67108863,this.words[R+1]=D>>>26-L&67108863,L+=24,L>=26&&(L-=26,R++);else if(S==="le")for(C=0,R=0;C<d.length;C+=3)D=d[C]|d[C+1]<<8|d[C+2]<<16,this.words[R]|=D<<L&67108863,this.words[R+1]=D>>>26-L&67108863,L+=24,L>=26&&(L-=26,R++);return this._strip()};function a(A,d){var y=A.charCodeAt(d);if(y>=48&&y<=57)return y-48;if(y>=65&&y<=70)return y-55;if(y>=97&&y<=102)return y-87;r(!1,"Invalid character in "+A)}function l(A,d,y){var S=a(A,y);return y-1>=d&&(S|=a(A,y-1)<<4),S}o.prototype._parseHex=function(d,y,S){this.length=Math.ceil((d.length-y)/6),this.words=new Array(this.length);for(var C=0;C<this.length;C++)this.words[C]=0;var R=0,D=0,L;if(S==="be")for(C=d.length-1;C>=y;C-=2)L=l(d,y,C)<<R,this.words[D]|=L&67108863,R>=18?(R-=18,D+=1,this.words[D]|=L>>>26):R+=8;else{var O=d.length-y;for(C=O%2===0?y+1:y;C<d.length;C+=2)L=l(d,y,C)<<R,this.words[D]|=L&67108863,R>=18?(R-=18,D+=1,this.words[D]|=L>>>26):R+=8}this._strip()};function c(A,d,y,S){for(var C=0,R=0,D=Math.min(A.length,y),L=d;L<D;L++){var O=A.charCodeAt(L)-48;C*=S,O>=49?R=O-49+10:O>=17?R=O-17+10:R=O,r(O>=0&&R<S,"Invalid character"),C+=R}return C}o.prototype._parseBase=function(d,y,S){this.words=[0],this.length=1;for(var C=0,R=1;R<=67108863;R*=y)C++;C--,R=R/y|0;for(var D=d.length-S,L=D%C,O=Math.min(D,D-L)+S,f=0,v=S;v<O;v+=C)f=c(d,v,v+C,y),this.imuln(R),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f);if(L!==0){var k=1;for(f=c(d,v,d.length,y),v=0;v<L;v++)k*=y;this.imuln(k),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f)}this._strip()},o.prototype.copy=function(d){d.words=new Array(this.length);for(var y=0;y<this.length;y++)d.words[y]=this.words[y];d.length=this.length,d.negative=this.negative,d.red=this.red};function u(A,d){A.words=d.words,A.length=d.length,A.negative=d.negative,A.red=d.red}if(o.prototype._move=function(d){u(d,this)},o.prototype.clone=function(){var d=new o(null);return this.copy(d),d},o.prototype._expand=function(d){for(;this.length<d;)this.words[this.length++]=0;return this},o.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},o.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol!="undefined"&&typeof Symbol.for=="function")try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=h}catch(A){o.prototype.inspect=h}else o.prototype.inspect=h;function h(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var p=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],g=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],b=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];o.prototype.toString=function(d,y){d=d||10,y=y|0||1;var S;if(d===16||d==="hex"){S="";for(var C=0,R=0,D=0;D<this.length;D++){var L=this.words[D],O=((L<<C|R)&16777215).toString(16);R=L>>>24-C&16777215,C+=2,C>=26&&(C-=26,D--),R!==0||D!==this.length-1?S=p[6-O.length]+O+S:S=O+S}for(R!==0&&(S=R.toString(16)+S);S.length%y!==0;)S="0"+S;return this.negative!==0&&(S="-"+S),S}if(d===(d|0)&&d>=2&&d<=36){var f=g[d],v=b[d];S="";var k=this.clone();for(k.negative=0;!k.isZero();){var M=k.modrn(v).toString(d);k=k.idivn(v),k.isZero()?S=M+S:S=p[f-M.length]+M+S}for(this.isZero()&&(S="0"+S);S.length%y!==0;)S="0"+S;return this.negative!==0&&(S="-"+S),S}r(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var d=this.words[0];return this.length===2?d+=this.words[1]*67108864:this.length===3&&this.words[2]===1?d+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-d:d},o.prototype.toJSON=function(){return this.toString(16,2)},s&&(o.prototype.toBuffer=function(d,y){return this.toArrayLike(s,d,y)}),o.prototype.toArray=function(d,y){return this.toArrayLike(Array,d,y)};var m=function(d,y){return d.allocUnsafe?d.allocUnsafe(y):new d(y)};o.prototype.toArrayLike=function(d,y,S){this._strip();var C=this.byteLength(),R=S||Math.max(1,C);r(C<=R,"byte array longer than desired length"),r(R>0,"Requested array length <= 0");var D=m(d,R),L=y==="le"?"LE":"BE";return this["_toArrayLike"+L](D,C),D},o.prototype._toArrayLikeLE=function(d,y){for(var S=0,C=0,R=0,D=0;R<this.length;R++){var L=this.words[R]<<D|C;d[S++]=L&255,S<d.length&&(d[S++]=L>>8&255),S<d.length&&(d[S++]=L>>16&255),D===6?(S<d.length&&(d[S++]=L>>24&255),C=0,D=0):(C=L>>>24,D+=2)}if(S<d.length)for(d[S++]=C;S<d.length;)d[S++]=0},o.prototype._toArrayLikeBE=function(d,y){for(var S=d.length-1,C=0,R=0,D=0;R<this.length;R++){var L=this.words[R]<<D|C;d[S--]=L&255,S>=0&&(d[S--]=L>>8&255),S>=0&&(d[S--]=L>>16&255),D===6?(S>=0&&(d[S--]=L>>24&255),C=0,D=0):(C=L>>>24,D+=2)}if(S>=0)for(d[S--]=C;S>=0;)d[S--]=0},Math.clz32?o.prototype._countBits=function(d){return 32-Math.clz32(d)}:o.prototype._countBits=function(d){var y=d,S=0;return y>=4096&&(S+=13,y>>>=13),y>=64&&(S+=7,y>>>=7),y>=8&&(S+=4,y>>>=4),y>=2&&(S+=2,y>>>=2),S+y},o.prototype._zeroBits=function(d){if(d===0)return 26;var y=d,S=0;return(y&8191)===0&&(S+=13,y>>>=13),(y&127)===0&&(S+=7,y>>>=7),(y&15)===0&&(S+=4,y>>>=4),(y&3)===0&&(S+=2,y>>>=2),(y&1)===0&&S++,S},o.prototype.bitLength=function(){var d=this.words[this.length-1],y=this._countBits(d);return(this.length-1)*26+y};function x(A){for(var d=new Array(A.bitLength()),y=0;y<d.length;y++){var S=y/26|0,C=y%26;d[y]=A.words[S]>>>C&1}return d}o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var d=0,y=0;y<this.length;y++){var S=this._zeroBits(this.words[y]);if(d+=S,S!==26)break}return d},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(d){return this.negative!==0?this.abs().inotn(d).iaddn(1):this.clone()},o.prototype.fromTwos=function(d){return this.testn(d-1)?this.notn(d).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return this.negative!==0},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(d){for(;this.length<d.length;)this.words[this.length++]=0;for(var y=0;y<d.length;y++)this.words[y]=this.words[y]|d.words[y];return this._strip()},o.prototype.ior=function(d){return r((this.negative|d.negative)===0),this.iuor(d)},o.prototype.or=function(d){return this.length>d.length?this.clone().ior(d):d.clone().ior(this)},o.prototype.uor=function(d){return this.length>d.length?this.clone().iuor(d):d.clone().iuor(this)},o.prototype.iuand=function(d){var y;this.length>d.length?y=d:y=this;for(var S=0;S<y.length;S++)this.words[S]=this.words[S]&d.words[S];return this.length=y.length,this._strip()},o.prototype.iand=function(d){return r((this.negative|d.negative)===0),this.iuand(d)},o.prototype.and=function(d){return this.length>d.length?this.clone().iand(d):d.clone().iand(this)},o.prototype.uand=function(d){return this.length>d.length?this.clone().iuand(d):d.clone().iuand(this)},o.prototype.iuxor=function(d){var y,S;this.length>d.length?(y=this,S=d):(y=d,S=this);for(var C=0;C<S.length;C++)this.words[C]=y.words[C]^S.words[C];if(this!==y)for(;C<y.length;C++)this.words[C]=y.words[C];return this.length=y.length,this._strip()},o.prototype.ixor=function(d){return r((this.negative|d.negative)===0),this.iuxor(d)},o.prototype.xor=function(d){return this.length>d.length?this.clone().ixor(d):d.clone().ixor(this)},o.prototype.uxor=function(d){return this.length>d.length?this.clone().iuxor(d):d.clone().iuxor(this)},o.prototype.inotn=function(d){r(typeof d=="number"&&d>=0);var y=Math.ceil(d/26)|0,S=d%26;this._expand(y),S>0&&y--;for(var C=0;C<y;C++)this.words[C]=~this.words[C]&67108863;return S>0&&(this.words[C]=~this.words[C]&67108863>>26-S),this._strip()},o.prototype.notn=function(d){return this.clone().inotn(d)},o.prototype.setn=function(d,y){r(typeof d=="number"&&d>=0);var S=d/26|0,C=d%26;return this._expand(S+1),y?this.words[S]=this.words[S]|1<<C:this.words[S]=this.words[S]&~(1<<C),this._strip()},o.prototype.iadd=function(d){var y;if(this.negative!==0&&d.negative===0)return this.negative=0,y=this.isub(d),this.negative^=1,this._normSign();if(this.negative===0&&d.negative!==0)return d.negative=0,y=this.isub(d),d.negative=1,y._normSign();var S,C;this.length>d.length?(S=this,C=d):(S=d,C=this);for(var R=0,D=0;D<C.length;D++)y=(S.words[D]|0)+(C.words[D]|0)+R,this.words[D]=y&67108863,R=y>>>26;for(;R!==0&&D<S.length;D++)y=(S.words[D]|0)+R,this.words[D]=y&67108863,R=y>>>26;if(this.length=S.length,R!==0)this.words[this.length]=R,this.length++;else if(S!==this)for(;D<S.length;D++)this.words[D]=S.words[D];return this},o.prototype.add=function(d){var y;return d.negative!==0&&this.negative===0?(d.negative=0,y=this.sub(d),d.negative^=1,y):d.negative===0&&this.negative!==0?(this.negative=0,y=d.sub(this),this.negative=1,y):this.length>d.length?this.clone().iadd(d):d.clone().iadd(this)},o.prototype.isub=function(d){if(d.negative!==0){d.negative=0;var y=this.iadd(d);return d.negative=1,y._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(d),this.negative=1,this._normSign();var S=this.cmp(d);if(S===0)return this.negative=0,this.length=1,this.words[0]=0,this;var C,R;S>0?(C=this,R=d):(C=d,R=this);for(var D=0,L=0;L<R.length;L++)y=(C.words[L]|0)-(R.words[L]|0)+D,D=y>>26,this.words[L]=y&67108863;for(;D!==0&&L<C.length;L++)y=(C.words[L]|0)+D,D=y>>26,this.words[L]=y&67108863;if(D===0&&L<C.length&&C!==this)for(;L<C.length;L++)this.words[L]=C.words[L];return this.length=Math.max(this.length,L),C!==this&&(this.negative=1),this._strip()},o.prototype.sub=function(d){return this.clone().isub(d)};function I(A,d,y){y.negative=d.negative^A.negative;var S=A.length+d.length|0;y.length=S,S=S-1|0;var C=A.words[0]|0,R=d.words[0]|0,D=C*R,L=D&67108863,O=D/67108864|0;y.words[0]=L;for(var f=1;f<S;f++){for(var v=O>>>26,k=O&67108863,M=Math.min(f,d.length-1),H=Math.max(0,f-A.length+1);H<=M;H++){var Q=f-H|0;C=A.words[Q]|0,R=d.words[H]|0,D=C*R+k,v+=D/67108864|0,k=D&67108863}y.words[f]=k|0,O=v|0}return O!==0?y.words[f]=O|0:y.length--,y._strip()}var N=function(d,y,S){var C=d.words,R=y.words,D=S.words,L=0,O,f,v,k=C[0]|0,M=k&8191,H=k>>>13,Q=C[1]|0,X=Q&8191,j=Q>>>13,ee=C[2]|0,se=ee&8191,re=ee>>>13,ve=C[3]|0,xe=ve&8191,Pe=ve>>>13,Et=C[4]|0,He=Et&8191,ot=Et>>>13,ri=C[5]|0,nt=ri&8191,Qe=ri>>>13,ln=C[6]|0,st=ln&8191,ht=ln>>>13,Mr=C[7]|0,St=Mr&8191,P=Mr>>>13,_=C[8]|0,E=_&8191,z=_>>>13,J=C[9]|0,te=J&8191,ae=J>>>13,De=R[0]|0,Me=De&8191,Le=De>>>13,gt=R[1]|0,Ne=gt&8191,Ft=gt>>>13,uA=R[2]|0,Dt=uA&8191,Vt=uA>>>13,dA=R[3]|0,$t=dA&8191,zt=dA>>>13,hA=R[4]|0,Ut=hA&8191,Wt=hA>>>13,fA=R[5]|0,Ht=fA&8191,jt=fA>>>13,gA=R[6]|0,qt=gA&8191,Gt=gA>>>13,pA=R[7]|0,Kt=pA&8191,Yt=pA>>>13,mA=R[8]|0,Xt=mA&8191,Zt=mA>>>13,vA=R[9]|0,Jt=vA&8191,Qt=vA>>>13;S.negative=d.negative^y.negative,S.length=19,O=Math.imul(M,Me),f=Math.imul(M,Le),f=f+Math.imul(H,Me)|0,v=Math.imul(H,Le);var wm=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(wm>>>26)|0,wm&=67108863,O=Math.imul(X,Me),f=Math.imul(X,Le),f=f+Math.imul(j,Me)|0,v=Math.imul(j,Le),O=O+Math.imul(M,Ne)|0,f=f+Math.imul(M,Ft)|0,f=f+Math.imul(H,Ne)|0,v=v+Math.imul(H,Ft)|0;var Em=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Em>>>26)|0,Em&=67108863,O=Math.imul(se,Me),f=Math.imul(se,Le),f=f+Math.imul(re,Me)|0,v=Math.imul(re,Le),O=O+Math.imul(X,Ne)|0,f=f+Math.imul(X,Ft)|0,f=f+Math.imul(j,Ne)|0,v=v+Math.imul(j,Ft)|0,O=O+Math.imul(M,Dt)|0,f=f+Math.imul(M,Vt)|0,f=f+Math.imul(H,Dt)|0,v=v+Math.imul(H,Vt)|0;var Sm=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Sm>>>26)|0,Sm&=67108863,O=Math.imul(xe,Me),f=Math.imul(xe,Le),f=f+Math.imul(Pe,Me)|0,v=Math.imul(Pe,Le),O=O+Math.imul(se,Ne)|0,f=f+Math.imul(se,Ft)|0,f=f+Math.imul(re,Ne)|0,v=v+Math.imul(re,Ft)|0,O=O+Math.imul(X,Dt)|0,f=f+Math.imul(X,Vt)|0,f=f+Math.imul(j,Dt)|0,v=v+Math.imul(j,Vt)|0,O=O+Math.imul(M,$t)|0,f=f+Math.imul(M,zt)|0,f=f+Math.imul(H,$t)|0,v=v+Math.imul(H,zt)|0;var Im=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Im>>>26)|0,Im&=67108863,O=Math.imul(He,Me),f=Math.imul(He,Le),f=f+Math.imul(ot,Me)|0,v=Math.imul(ot,Le),O=O+Math.imul(xe,Ne)|0,f=f+Math.imul(xe,Ft)|0,f=f+Math.imul(Pe,Ne)|0,v=v+Math.imul(Pe,Ft)|0,O=O+Math.imul(se,Dt)|0,f=f+Math.imul(se,Vt)|0,f=f+Math.imul(re,Dt)|0,v=v+Math.imul(re,Vt)|0,O=O+Math.imul(X,$t)|0,f=f+Math.imul(X,zt)|0,f=f+Math.imul(j,$t)|0,v=v+Math.imul(j,zt)|0,O=O+Math.imul(M,Ut)|0,f=f+Math.imul(M,Wt)|0,f=f+Math.imul(H,Ut)|0,v=v+Math.imul(H,Wt)|0;var Cm=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Cm>>>26)|0,Cm&=67108863,O=Math.imul(nt,Me),f=Math.imul(nt,Le),f=f+Math.imul(Qe,Me)|0,v=Math.imul(Qe,Le),O=O+Math.imul(He,Ne)|0,f=f+Math.imul(He,Ft)|0,f=f+Math.imul(ot,Ne)|0,v=v+Math.imul(ot,Ft)|0,O=O+Math.imul(xe,Dt)|0,f=f+Math.imul(xe,Vt)|0,f=f+Math.imul(Pe,Dt)|0,v=v+Math.imul(Pe,Vt)|0,O=O+Math.imul(se,$t)|0,f=f+Math.imul(se,zt)|0,f=f+Math.imul(re,$t)|0,v=v+Math.imul(re,zt)|0,O=O+Math.imul(X,Ut)|0,f=f+Math.imul(X,Wt)|0,f=f+Math.imul(j,Ut)|0,v=v+Math.imul(j,Wt)|0,O=O+Math.imul(M,Ht)|0,f=f+Math.imul(M,jt)|0,f=f+Math.imul(H,Ht)|0,v=v+Math.imul(H,jt)|0;var Am=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Am>>>26)|0,Am&=67108863,O=Math.imul(st,Me),f=Math.imul(st,Le),f=f+Math.imul(ht,Me)|0,v=Math.imul(ht,Le),O=O+Math.imul(nt,Ne)|0,f=f+Math.imul(nt,Ft)|0,f=f+Math.imul(Qe,Ne)|0,v=v+Math.imul(Qe,Ft)|0,O=O+Math.imul(He,Dt)|0,f=f+Math.imul(He,Vt)|0,f=f+Math.imul(ot,Dt)|0,v=v+Math.imul(ot,Vt)|0,O=O+Math.imul(xe,$t)|0,f=f+Math.imul(xe,zt)|0,f=f+Math.imul(Pe,$t)|0,v=v+Math.imul(Pe,zt)|0,O=O+Math.imul(se,Ut)|0,f=f+Math.imul(se,Wt)|0,f=f+Math.imul(re,Ut)|0,v=v+Math.imul(re,Wt)|0,O=O+Math.imul(X,Ht)|0,f=f+Math.imul(X,jt)|0,f=f+Math.imul(j,Ht)|0,v=v+Math.imul(j,jt)|0,O=O+Math.imul(M,qt)|0,f=f+Math.imul(M,Gt)|0,f=f+Math.imul(H,qt)|0,v=v+Math.imul(H,Gt)|0;var Om=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Om>>>26)|0,Om&=67108863,O=Math.imul(St,Me),f=Math.imul(St,Le),f=f+Math.imul(P,Me)|0,v=Math.imul(P,Le),O=O+Math.imul(st,Ne)|0,f=f+Math.imul(st,Ft)|0,f=f+Math.imul(ht,Ne)|0,v=v+Math.imul(ht,Ft)|0,O=O+Math.imul(nt,Dt)|0,f=f+Math.imul(nt,Vt)|0,f=f+Math.imul(Qe,Dt)|0,v=v+Math.imul(Qe,Vt)|0,O=O+Math.imul(He,$t)|0,f=f+Math.imul(He,zt)|0,f=f+Math.imul(ot,$t)|0,v=v+Math.imul(ot,zt)|0,O=O+Math.imul(xe,Ut)|0,f=f+Math.imul(xe,Wt)|0,f=f+Math.imul(Pe,Ut)|0,v=v+Math.imul(Pe,Wt)|0,O=O+Math.imul(se,Ht)|0,f=f+Math.imul(se,jt)|0,f=f+Math.imul(re,Ht)|0,v=v+Math.imul(re,jt)|0,O=O+Math.imul(X,qt)|0,f=f+Math.imul(X,Gt)|0,f=f+Math.imul(j,qt)|0,v=v+Math.imul(j,Gt)|0,O=O+Math.imul(M,Kt)|0,f=f+Math.imul(M,Yt)|0,f=f+Math.imul(H,Kt)|0,v=v+Math.imul(H,Yt)|0;var km=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(km>>>26)|0,km&=67108863,O=Math.imul(E,Me),f=Math.imul(E,Le),f=f+Math.imul(z,Me)|0,v=Math.imul(z,Le),O=O+Math.imul(St,Ne)|0,f=f+Math.imul(St,Ft)|0,f=f+Math.imul(P,Ne)|0,v=v+Math.imul(P,Ft)|0,O=O+Math.imul(st,Dt)|0,f=f+Math.imul(st,Vt)|0,f=f+Math.imul(ht,Dt)|0,v=v+Math.imul(ht,Vt)|0,O=O+Math.imul(nt,$t)|0,f=f+Math.imul(nt,zt)|0,f=f+Math.imul(Qe,$t)|0,v=v+Math.imul(Qe,zt)|0,O=O+Math.imul(He,Ut)|0,f=f+Math.imul(He,Wt)|0,f=f+Math.imul(ot,Ut)|0,v=v+Math.imul(ot,Wt)|0,O=O+Math.imul(xe,Ht)|0,f=f+Math.imul(xe,jt)|0,f=f+Math.imul(Pe,Ht)|0,v=v+Math.imul(Pe,jt)|0,O=O+Math.imul(se,qt)|0,f=f+Math.imul(se,Gt)|0,f=f+Math.imul(re,qt)|0,v=v+Math.imul(re,Gt)|0,O=O+Math.imul(X,Kt)|0,f=f+Math.imul(X,Yt)|0,f=f+Math.imul(j,Kt)|0,v=v+Math.imul(j,Yt)|0,O=O+Math.imul(M,Xt)|0,f=f+Math.imul(M,Zt)|0,f=f+Math.imul(H,Xt)|0,v=v+Math.imul(H,Zt)|0;var Tm=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Tm>>>26)|0,Tm&=67108863,O=Math.imul(te,Me),f=Math.imul(te,Le),f=f+Math.imul(ae,Me)|0,v=Math.imul(ae,Le),O=O+Math.imul(E,Ne)|0,f=f+Math.imul(E,Ft)|0,f=f+Math.imul(z,Ne)|0,v=v+Math.imul(z,Ft)|0,O=O+Math.imul(St,Dt)|0,f=f+Math.imul(St,Vt)|0,f=f+Math.imul(P,Dt)|0,v=v+Math.imul(P,Vt)|0,O=O+Math.imul(st,$t)|0,f=f+Math.imul(st,zt)|0,f=f+Math.imul(ht,$t)|0,v=v+Math.imul(ht,zt)|0,O=O+Math.imul(nt,Ut)|0,f=f+Math.imul(nt,Wt)|0,f=f+Math.imul(Qe,Ut)|0,v=v+Math.imul(Qe,Wt)|0,O=O+Math.imul(He,Ht)|0,f=f+Math.imul(He,jt)|0,f=f+Math.imul(ot,Ht)|0,v=v+Math.imul(ot,jt)|0,O=O+Math.imul(xe,qt)|0,f=f+Math.imul(xe,Gt)|0,f=f+Math.imul(Pe,qt)|0,v=v+Math.imul(Pe,Gt)|0,O=O+Math.imul(se,Kt)|0,f=f+Math.imul(se,Yt)|0,f=f+Math.imul(re,Kt)|0,v=v+Math.imul(re,Yt)|0,O=O+Math.imul(X,Xt)|0,f=f+Math.imul(X,Zt)|0,f=f+Math.imul(j,Xt)|0,v=v+Math.imul(j,Zt)|0,O=O+Math.imul(M,Jt)|0,f=f+Math.imul(M,Qt)|0,f=f+Math.imul(H,Jt)|0,v=v+Math.imul(H,Qt)|0;var Rm=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Rm>>>26)|0,Rm&=67108863,O=Math.imul(te,Ne),f=Math.imul(te,Ft),f=f+Math.imul(ae,Ne)|0,v=Math.imul(ae,Ft),O=O+Math.imul(E,Dt)|0,f=f+Math.imul(E,Vt)|0,f=f+Math.imul(z,Dt)|0,v=v+Math.imul(z,Vt)|0,O=O+Math.imul(St,$t)|0,f=f+Math.imul(St,zt)|0,f=f+Math.imul(P,$t)|0,v=v+Math.imul(P,zt)|0,O=O+Math.imul(st,Ut)|0,f=f+Math.imul(st,Wt)|0,f=f+Math.imul(ht,Ut)|0,v=v+Math.imul(ht,Wt)|0,O=O+Math.imul(nt,Ht)|0,f=f+Math.imul(nt,jt)|0,f=f+Math.imul(Qe,Ht)|0,v=v+Math.imul(Qe,jt)|0,O=O+Math.imul(He,qt)|0,f=f+Math.imul(He,Gt)|0,f=f+Math.imul(ot,qt)|0,v=v+Math.imul(ot,Gt)|0,O=O+Math.imul(xe,Kt)|0,f=f+Math.imul(xe,Yt)|0,f=f+Math.imul(Pe,Kt)|0,v=v+Math.imul(Pe,Yt)|0,O=O+Math.imul(se,Xt)|0,f=f+Math.imul(se,Zt)|0,f=f+Math.imul(re,Xt)|0,v=v+Math.imul(re,Zt)|0,O=O+Math.imul(X,Jt)|0,f=f+Math.imul(X,Qt)|0,f=f+Math.imul(j,Jt)|0,v=v+Math.imul(j,Qt)|0;var Nm=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Nm>>>26)|0,Nm&=67108863,O=Math.imul(te,Dt),f=Math.imul(te,Vt),f=f+Math.imul(ae,Dt)|0,v=Math.imul(ae,Vt),O=O+Math.imul(E,$t)|0,f=f+Math.imul(E,zt)|0,f=f+Math.imul(z,$t)|0,v=v+Math.imul(z,zt)|0,O=O+Math.imul(St,Ut)|0,f=f+Math.imul(St,Wt)|0,f=f+Math.imul(P,Ut)|0,v=v+Math.imul(P,Wt)|0,O=O+Math.imul(st,Ht)|0,f=f+Math.imul(st,jt)|0,f=f+Math.imul(ht,Ht)|0,v=v+Math.imul(ht,jt)|0,O=O+Math.imul(nt,qt)|0,f=f+Math.imul(nt,Gt)|0,f=f+Math.imul(Qe,qt)|0,v=v+Math.imul(Qe,Gt)|0,O=O+Math.imul(He,Kt)|0,f=f+Math.imul(He,Yt)|0,f=f+Math.imul(ot,Kt)|0,v=v+Math.imul(ot,Yt)|0,O=O+Math.imul(xe,Xt)|0,f=f+Math.imul(xe,Zt)|0,f=f+Math.imul(Pe,Xt)|0,v=v+Math.imul(Pe,Zt)|0,O=O+Math.imul(se,Jt)|0,f=f+Math.imul(se,Qt)|0,f=f+Math.imul(re,Jt)|0,v=v+Math.imul(re,Qt)|0;var Pm=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Pm>>>26)|0,Pm&=67108863,O=Math.imul(te,$t),f=Math.imul(te,zt),f=f+Math.imul(ae,$t)|0,v=Math.imul(ae,zt),O=O+Math.imul(E,Ut)|0,f=f+Math.imul(E,Wt)|0,f=f+Math.imul(z,Ut)|0,v=v+Math.imul(z,Wt)|0,O=O+Math.imul(St,Ht)|0,f=f+Math.imul(St,jt)|0,f=f+Math.imul(P,Ht)|0,v=v+Math.imul(P,jt)|0,O=O+Math.imul(st,qt)|0,f=f+Math.imul(st,Gt)|0,f=f+Math.imul(ht,qt)|0,v=v+Math.imul(ht,Gt)|0,O=O+Math.imul(nt,Kt)|0,f=f+Math.imul(nt,Yt)|0,f=f+Math.imul(Qe,Kt)|0,v=v+Math.imul(Qe,Yt)|0,O=O+Math.imul(He,Xt)|0,f=f+Math.imul(He,Zt)|0,f=f+Math.imul(ot,Xt)|0,v=v+Math.imul(ot,Zt)|0,O=O+Math.imul(xe,Jt)|0,f=f+Math.imul(xe,Qt)|0,f=f+Math.imul(Pe,Jt)|0,v=v+Math.imul(Pe,Qt)|0;var Lm=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Lm>>>26)|0,Lm&=67108863,O=Math.imul(te,Ut),f=Math.imul(te,Wt),f=f+Math.imul(ae,Ut)|0,v=Math.imul(ae,Wt),O=O+Math.imul(E,Ht)|0,f=f+Math.imul(E,jt)|0,f=f+Math.imul(z,Ht)|0,v=v+Math.imul(z,jt)|0,O=O+Math.imul(St,qt)|0,f=f+Math.imul(St,Gt)|0,f=f+Math.imul(P,qt)|0,v=v+Math.imul(P,Gt)|0,O=O+Math.imul(st,Kt)|0,f=f+Math.imul(st,Yt)|0,f=f+Math.imul(ht,Kt)|0,v=v+Math.imul(ht,Yt)|0,O=O+Math.imul(nt,Xt)|0,f=f+Math.imul(nt,Zt)|0,f=f+Math.imul(Qe,Xt)|0,v=v+Math.imul(Qe,Zt)|0,O=O+Math.imul(He,Jt)|0,f=f+Math.imul(He,Qt)|0,f=f+Math.imul(ot,Jt)|0,v=v+Math.imul(ot,Qt)|0;var Mm=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Mm>>>26)|0,Mm&=67108863,O=Math.imul(te,Ht),f=Math.imul(te,jt),f=f+Math.imul(ae,Ht)|0,v=Math.imul(ae,jt),O=O+Math.imul(E,qt)|0,f=f+Math.imul(E,Gt)|0,f=f+Math.imul(z,qt)|0,v=v+Math.imul(z,Gt)|0,O=O+Math.imul(St,Kt)|0,f=f+Math.imul(St,Yt)|0,f=f+Math.imul(P,Kt)|0,v=v+Math.imul(P,Yt)|0,O=O+Math.imul(st,Xt)|0,f=f+Math.imul(st,Zt)|0,f=f+Math.imul(ht,Xt)|0,v=v+Math.imul(ht,Zt)|0,O=O+Math.imul(nt,Jt)|0,f=f+Math.imul(nt,Qt)|0,f=f+Math.imul(Qe,Jt)|0,v=v+Math.imul(Qe,Qt)|0;var Bm=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Bm>>>26)|0,Bm&=67108863,O=Math.imul(te,qt),f=Math.imul(te,Gt),f=f+Math.imul(ae,qt)|0,v=Math.imul(ae,Gt),O=O+Math.imul(E,Kt)|0,f=f+Math.imul(E,Yt)|0,f=f+Math.imul(z,Kt)|0,v=v+Math.imul(z,Yt)|0,O=O+Math.imul(St,Xt)|0,f=f+Math.imul(St,Zt)|0,f=f+Math.imul(P,Xt)|0,v=v+Math.imul(P,Zt)|0,O=O+Math.imul(st,Jt)|0,f=f+Math.imul(st,Qt)|0,f=f+Math.imul(ht,Jt)|0,v=v+Math.imul(ht,Qt)|0;var Fm=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Fm>>>26)|0,Fm&=67108863,O=Math.imul(te,Kt),f=Math.imul(te,Yt),f=f+Math.imul(ae,Kt)|0,v=Math.imul(ae,Yt),O=O+Math.imul(E,Xt)|0,f=f+Math.imul(E,Zt)|0,f=f+Math.imul(z,Xt)|0,v=v+Math.imul(z,Zt)|0,O=O+Math.imul(St,Jt)|0,f=f+Math.imul(St,Qt)|0,f=f+Math.imul(P,Jt)|0,v=v+Math.imul(P,Qt)|0;var Dm=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Dm>>>26)|0,Dm&=67108863,O=Math.imul(te,Xt),f=Math.imul(te,Zt),f=f+Math.imul(ae,Xt)|0,v=Math.imul(ae,Zt),O=O+Math.imul(E,Jt)|0,f=f+Math.imul(E,Qt)|0,f=f+Math.imul(z,Jt)|0,v=v+Math.imul(z,Qt)|0;var Vm=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Vm>>>26)|0,Vm&=67108863,O=Math.imul(te,Jt),f=Math.imul(te,Qt),f=f+Math.imul(ae,Jt)|0,v=Math.imul(ae,Qt);var $m=(L+O|0)+((f&8191)<<13)|0;return L=(v+(f>>>13)|0)+($m>>>26)|0,$m&=67108863,D[0]=wm,D[1]=Em,D[2]=Sm,D[3]=Im,D[4]=Cm,D[5]=Am,D[6]=Om,D[7]=km,D[8]=Tm,D[9]=Rm,D[10]=Nm,D[11]=Pm,D[12]=Lm,D[13]=Mm,D[14]=Bm,D[15]=Fm,D[16]=Dm,D[17]=Vm,D[18]=$m,L!==0&&(D[19]=L,S.length++),S};Math.imul||(N=I);function T(A,d,y){y.negative=d.negative^A.negative,y.length=A.length+d.length;for(var S=0,C=0,R=0;R<y.length-1;R++){var D=C;C=0;for(var L=S&67108863,O=Math.min(R,d.length-1),f=Math.max(0,R-A.length+1);f<=O;f++){var v=R-f,k=A.words[v]|0,M=d.words[f]|0,H=k*M,Q=H&67108863;D=D+(H/67108864|0)|0,Q=Q+L|0,L=Q&67108863,D=D+(Q>>>26)|0,C+=D>>>26,D&=67108863}y.words[R]=L,S=D,D=C}return S!==0?y.words[R]=S:y.length--,y._strip()}function $(A,d,y){return T(A,d,y)}o.prototype.mulTo=function(d,y){var S,C=this.length+d.length;return this.length===10&&d.length===10?S=N(this,d,y):C<63?S=I(this,d,y):C<1024?S=T(this,d,y):S=$(this,d,y),S},o.prototype.mul=function(d){var y=new o(null);return y.words=new Array(this.length+d.length),this.mulTo(d,y)},o.prototype.mulf=function(d){var y=new o(null);return y.words=new Array(this.length+d.length),$(this,d,y)},o.prototype.imul=function(d){return this.clone().mulTo(d,this)},o.prototype.imuln=function(d){var y=d<0;y&&(d=-d),r(typeof d=="number"),r(d<67108864);for(var S=0,C=0;C<this.length;C++){var R=(this.words[C]|0)*d,D=(R&67108863)+(S&67108863);S>>=26,S+=R/67108864|0,S+=D>>>26,this.words[C]=D&67108863}return S!==0&&(this.words[C]=S,this.length++),this.length=d===0?1:this.length,y?this.ineg():this},o.prototype.muln=function(d){return this.clone().imuln(d)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(d){var y=x(d);if(y.length===0)return new o(1);for(var S=this,C=0;C<y.length&&y[C]===0;C++,S=S.sqr());if(++C<y.length)for(var R=S.sqr();C<y.length;C++,R=R.sqr())y[C]!==0&&(S=S.mul(R));return S},o.prototype.iushln=function(d){r(typeof d=="number"&&d>=0);var y=d%26,S=(d-y)/26,C=67108863>>>26-y<<26-y,R;if(y!==0){var D=0;for(R=0;R<this.length;R++){var L=this.words[R]&C,O=(this.words[R]|0)-L<<y;this.words[R]=O|D,D=L>>>26-y}D&&(this.words[R]=D,this.length++)}if(S!==0){for(R=this.length-1;R>=0;R--)this.words[R+S]=this.words[R];for(R=0;R<S;R++)this.words[R]=0;this.length+=S}return this._strip()},o.prototype.ishln=function(d){return r(this.negative===0),this.iushln(d)},o.prototype.iushrn=function(d,y,S){r(typeof d=="number"&&d>=0);var C;y?C=(y-y%26)/26:C=0;var R=d%26,D=Math.min((d-R)/26,this.length),L=67108863^67108863>>>R<<R,O=S;if(C-=D,C=Math.max(0,C),O){for(var f=0;f<D;f++)O.words[f]=this.words[f];O.length=D}if(D!==0)if(this.length>D)for(this.length-=D,f=0;f<this.length;f++)this.words[f]=this.words[f+D];else this.words[0]=0,this.length=1;var v=0;for(f=this.length-1;f>=0&&(v!==0||f>=C);f--){var k=this.words[f]|0;this.words[f]=v<<26-R|k>>>R,v=k&L}return O&&v!==0&&(O.words[O.length++]=v),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(d,y,S){return r(this.negative===0),this.iushrn(d,y,S)},o.prototype.shln=function(d){return this.clone().ishln(d)},o.prototype.ushln=function(d){return this.clone().iushln(d)},o.prototype.shrn=function(d){return this.clone().ishrn(d)},o.prototype.ushrn=function(d){return this.clone().iushrn(d)},o.prototype.testn=function(d){r(typeof d=="number"&&d>=0);var y=d%26,S=(d-y)/26,C=1<<y;if(this.length<=S)return!1;var R=this.words[S];return!!(R&C)},o.prototype.imaskn=function(d){r(typeof d=="number"&&d>=0);var y=d%26,S=(d-y)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=S)return this;if(y!==0&&S++,this.length=Math.min(S,this.length),y!==0){var C=67108863^67108863>>>y<<y;this.words[this.length-1]&=C}return this._strip()},o.prototype.maskn=function(d){return this.clone().imaskn(d)},o.prototype.iaddn=function(d){return r(typeof d=="number"),r(d<67108864),d<0?this.isubn(-d):this.negative!==0?this.length===1&&(this.words[0]|0)<=d?(this.words[0]=d-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(d),this.negative=1,this):this._iaddn(d)},o.prototype._iaddn=function(d){this.words[0]+=d;for(var y=0;y<this.length&&this.words[y]>=67108864;y++)this.words[y]-=67108864,y===this.length-1?this.words[y+1]=1:this.words[y+1]++;return this.length=Math.max(this.length,y+1),this},o.prototype.isubn=function(d){if(r(typeof d=="number"),r(d<67108864),d<0)return this.iaddn(-d);if(this.negative!==0)return this.negative=0,this.iaddn(d),this.negative=1,this;if(this.words[0]-=d,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var y=0;y<this.length&&this.words[y]<0;y++)this.words[y]+=67108864,this.words[y+1]-=1;return this._strip()},o.prototype.addn=function(d){return this.clone().iaddn(d)},o.prototype.subn=function(d){return this.clone().isubn(d)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(d,y,S){var C=d.length+S,R;this._expand(C);var D,L=0;for(R=0;R<d.length;R++){D=(this.words[R+S]|0)+L;var O=(d.words[R]|0)*y;D-=O&67108863,L=(D>>26)-(O/67108864|0),this.words[R+S]=D&67108863}for(;R<this.length-S;R++)D=(this.words[R+S]|0)+L,L=D>>26,this.words[R+S]=D&67108863;if(L===0)return this._strip();for(r(L===-1),L=0,R=0;R<this.length;R++)D=-(this.words[R]|0)+L,L=D>>26,this.words[R]=D&67108863;return this.negative=1,this._strip()},o.prototype._wordDiv=function(d,y){var S=this.length-d.length,C=this.clone(),R=d,D=R.words[R.length-1]|0,L=this._countBits(D);S=26-L,S!==0&&(R=R.ushln(S),C.iushln(S),D=R.words[R.length-1]|0);var O=C.length-R.length,f;if(y!=="mod"){f=new o(null),f.length=O+1,f.words=new Array(f.length);for(var v=0;v<f.length;v++)f.words[v]=0}var k=C.clone()._ishlnsubmul(R,1,O);k.negative===0&&(C=k,f&&(f.words[O]=1));for(var M=O-1;M>=0;M--){var H=(C.words[R.length+M]|0)*67108864+(C.words[R.length+M-1]|0);for(H=Math.min(H/D|0,67108863),C._ishlnsubmul(R,H,M);C.negative!==0;)H--,C.negative=0,C._ishlnsubmul(R,1,M),C.isZero()||(C.negative^=1);f&&(f.words[M]=H)}return f&&f._strip(),C._strip(),y!=="div"&&S!==0&&C.iushrn(S),{div:f||null,mod:C}},o.prototype.divmod=function(d,y,S){if(r(!d.isZero()),this.isZero())return{div:new o(0),mod:new o(0)};var C,R,D;return this.negative!==0&&d.negative===0?(D=this.neg().divmod(d,y),y!=="mod"&&(C=D.div.neg()),y!=="div"&&(R=D.mod.neg(),S&&R.negative!==0&&R.iadd(d)),{div:C,mod:R}):this.negative===0&&d.negative!==0?(D=this.divmod(d.neg(),y),y!=="mod"&&(C=D.div.neg()),{div:C,mod:D.mod}):(this.negative&d.negative)!==0?(D=this.neg().divmod(d.neg(),y),y!=="div"&&(R=D.mod.neg(),S&&R.negative!==0&&R.isub(d)),{div:D.div,mod:R}):d.length>this.length||this.cmp(d)<0?{div:new o(0),mod:this}:d.length===1?y==="div"?{div:this.divn(d.words[0]),mod:null}:y==="mod"?{div:null,mod:new o(this.modrn(d.words[0]))}:{div:this.divn(d.words[0]),mod:new o(this.modrn(d.words[0]))}:this._wordDiv(d,y)},o.prototype.div=function(d){return this.divmod(d,"div",!1).div},o.prototype.mod=function(d){return this.divmod(d,"mod",!1).mod},o.prototype.umod=function(d){return this.divmod(d,"mod",!0).mod},o.prototype.divRound=function(d){var y=this.divmod(d);if(y.mod.isZero())return y.div;var S=y.div.negative!==0?y.mod.isub(d):y.mod,C=d.ushrn(1),R=d.andln(1),D=S.cmp(C);return D<0||R===1&&D===0?y.div:y.div.negative!==0?y.div.isubn(1):y.div.iaddn(1)},o.prototype.modrn=function(d){var y=d<0;y&&(d=-d),r(d<=67108863);for(var S=(1<<26)%d,C=0,R=this.length-1;R>=0;R--)C=(S*C+(this.words[R]|0))%d;return y?-C:C},o.prototype.modn=function(d){return this.modrn(d)},o.prototype.idivn=function(d){var y=d<0;y&&(d=-d),r(d<=67108863);for(var S=0,C=this.length-1;C>=0;C--){var R=(this.words[C]|0)+S*67108864;this.words[C]=R/d|0,S=R%d}return this._strip(),y?this.ineg():this},o.prototype.divn=function(d){return this.clone().idivn(d)},o.prototype.egcd=function(d){r(d.negative===0),r(!d.isZero());var y=this,S=d.clone();y.negative!==0?y=y.umod(d):y=y.clone();for(var C=new o(1),R=new o(0),D=new o(0),L=new o(1),O=0;y.isEven()&&S.isEven();)y.iushrn(1),S.iushrn(1),++O;for(var f=S.clone(),v=y.clone();!y.isZero();){for(var k=0,M=1;(y.words[0]&M)===0&&k<26;++k,M<<=1);if(k>0)for(y.iushrn(k);k-- >0;)(C.isOdd()||R.isOdd())&&(C.iadd(f),R.isub(v)),C.iushrn(1),R.iushrn(1);for(var H=0,Q=1;(S.words[0]&Q)===0&&H<26;++H,Q<<=1);if(H>0)for(S.iushrn(H);H-- >0;)(D.isOdd()||L.isOdd())&&(D.iadd(f),L.isub(v)),D.iushrn(1),L.iushrn(1);y.cmp(S)>=0?(y.isub(S),C.isub(D),R.isub(L)):(S.isub(y),D.isub(C),L.isub(R))}return{a:D,b:L,gcd:S.iushln(O)}},o.prototype._invmp=function(d){r(d.negative===0),r(!d.isZero());var y=this,S=d.clone();y.negative!==0?y=y.umod(d):y=y.clone();for(var C=new o(1),R=new o(0),D=S.clone();y.cmpn(1)>0&&S.cmpn(1)>0;){for(var L=0,O=1;(y.words[0]&O)===0&&L<26;++L,O<<=1);if(L>0)for(y.iushrn(L);L-- >0;)C.isOdd()&&C.iadd(D),C.iushrn(1);for(var f=0,v=1;(S.words[0]&v)===0&&f<26;++f,v<<=1);if(f>0)for(S.iushrn(f);f-- >0;)R.isOdd()&&R.iadd(D),R.iushrn(1);y.cmp(S)>=0?(y.isub(S),C.isub(R)):(S.isub(y),R.isub(C))}var k;return y.cmpn(1)===0?k=C:k=R,k.cmpn(0)<0&&k.iadd(d),k},o.prototype.gcd=function(d){if(this.isZero())return d.abs();if(d.isZero())return this.abs();var y=this.clone(),S=d.clone();y.negative=0,S.negative=0;for(var C=0;y.isEven()&&S.isEven();C++)y.iushrn(1),S.iushrn(1);do{for(;y.isEven();)y.iushrn(1);for(;S.isEven();)S.iushrn(1);var R=y.cmp(S);if(R<0){var D=y;y=S,S=D}else if(R===0||S.cmpn(1)===0)break;y.isub(S)}while(!0);return S.iushln(C)},o.prototype.invm=function(d){return this.egcd(d).a.umod(d)},o.prototype.isEven=function(){return(this.words[0]&1)===0},o.prototype.isOdd=function(){return(this.words[0]&1)===1},o.prototype.andln=function(d){return this.words[0]&d},o.prototype.bincn=function(d){r(typeof d=="number");var y=d%26,S=(d-y)/26,C=1<<y;if(this.length<=S)return this._expand(S+1),this.words[S]|=C,this;for(var R=C,D=S;R!==0&&D<this.length;D++){var L=this.words[D]|0;L+=R,R=L>>>26,L&=67108863,this.words[D]=L}return R!==0&&(this.words[D]=R,this.length++),this},o.prototype.isZero=function(){return this.length===1&&this.words[0]===0},o.prototype.cmpn=function(d){var y=d<0;if(this.negative!==0&&!y)return-1;if(this.negative===0&&y)return 1;this._strip();var S;if(this.length>1)S=1;else{y&&(d=-d),r(d<=67108863,"Number is too big");var C=this.words[0]|0;S=C===d?0:C<d?-1:1}return this.negative!==0?-S|0:S},o.prototype.cmp=function(d){if(this.negative!==0&&d.negative===0)return-1;if(this.negative===0&&d.negative!==0)return 1;var y=this.ucmp(d);return this.negative!==0?-y|0:y},o.prototype.ucmp=function(d){if(this.length>d.length)return 1;if(this.length<d.length)return-1;for(var y=0,S=this.length-1;S>=0;S--){var C=this.words[S]|0,R=d.words[S]|0;if(C!==R){C<R?y=-1:C>R&&(y=1);break}}return y},o.prototype.gtn=function(d){return this.cmpn(d)===1},o.prototype.gt=function(d){return this.cmp(d)===1},o.prototype.gten=function(d){return this.cmpn(d)>=0},o.prototype.gte=function(d){return this.cmp(d)>=0},o.prototype.ltn=function(d){return this.cmpn(d)===-1},o.prototype.lt=function(d){return this.cmp(d)===-1},o.prototype.lten=function(d){return this.cmpn(d)<=0},o.prototype.lte=function(d){return this.cmp(d)<=0},o.prototype.eqn=function(d){return this.cmpn(d)===0},o.prototype.eq=function(d){return this.cmp(d)===0},o.red=function(d){return new U(d)},o.prototype.toRed=function(d){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),d.convertTo(this)._forceRed(d)},o.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(d){return this.red=d,this},o.prototype.forceRed=function(d){return r(!this.red,"Already a number in reduction context"),this._forceRed(d)},o.prototype.redAdd=function(d){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,d)},o.prototype.redIAdd=function(d){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,d)},o.prototype.redSub=function(d){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,d)},o.prototype.redISub=function(d){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,d)},o.prototype.redShl=function(d){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,d)},o.prototype.redMul=function(d){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,d),this.red.mul(this,d)},o.prototype.redIMul=function(d){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,d),this.red.imul(this,d)},o.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(d){return r(this.red&&!d.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,d)};var B={k256:null,p224:null,p192:null,p25519:null};function G(A,d){this.name=A,this.p=new o(d,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}G.prototype._tmp=function(){var d=new o(null);return d.words=new Array(Math.ceil(this.n/13)),d},G.prototype.ireduce=function(d){var y=d,S;do this.split(y,this.tmp),y=this.imulK(y),y=y.iadd(this.tmp),S=y.bitLength();while(S>this.n);var C=S<this.n?-1:y.ucmp(this.p);return C===0?(y.words[0]=0,y.length=1):C>0?y.isub(this.p):y.strip!==void 0?y.strip():y._strip(),y},G.prototype.split=function(d,y){d.iushrn(this.n,0,y)},G.prototype.imulK=function(d){return d.imul(this.k)};function Z(){G.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(Z,G),Z.prototype.split=function(d,y){for(var S=4194303,C=Math.min(d.length,9),R=0;R<C;R++)y.words[R]=d.words[R];if(y.length=C,d.length<=9){d.words[0]=0,d.length=1;return}var D=d.words[9];for(y.words[y.length++]=D&S,R=10;R<d.length;R++){var L=d.words[R]|0;d.words[R-10]=(L&S)<<4|D>>>22,D=L}D>>>=22,d.words[R-10]=D,D===0&&d.length>10?d.length-=10:d.length-=9},Z.prototype.imulK=function(d){d.words[d.length]=0,d.words[d.length+1]=0,d.length+=2;for(var y=0,S=0;S<d.length;S++){var C=d.words[S]|0;y+=C*977,d.words[S]=y&67108863,y=C*64+(y/67108864|0)}return d.words[d.length-1]===0&&(d.length--,d.words[d.length-1]===0&&d.length--),d};function Y(){G.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}i(Y,G);function F(){G.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}i(F,G);function V(){G.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}i(V,G),V.prototype.imulK=function(d){for(var y=0,S=0;S<d.length;S++){var C=(d.words[S]|0)*19+y,R=C&67108863;C>>>=26,d.words[S]=R,y=C}return y!==0&&(d.words[d.length++]=y),d},o._prime=function(d){if(B[d])return B[d];var y;if(d==="k256")y=new Z;else if(d==="p224")y=new Y;else if(d==="p192")y=new F;else if(d==="p25519")y=new V;else throw new Error("Unknown prime "+d);return B[d]=y,y};function U(A){if(typeof A=="string"){var d=o._prime(A);this.m=d.p,this.prime=d}else r(A.gtn(1),"modulus must be greater than 1"),this.m=A,this.prime=null}U.prototype._verify1=function(d){r(d.negative===0,"red works only with positives"),r(d.red,"red works only with red numbers")},U.prototype._verify2=function(d,y){r((d.negative|y.negative)===0,"red works only with positives"),r(d.red&&d.red===y.red,"red works only with red numbers")},U.prototype.imod=function(d){return this.prime?this.prime.ireduce(d)._forceRed(this):(u(d,d.umod(this.m)._forceRed(this)),d)},U.prototype.neg=function(d){return d.isZero()?d.clone():this.m.sub(d)._forceRed(this)},U.prototype.add=function(d,y){this._verify2(d,y);var S=d.add(y);return S.cmp(this.m)>=0&&S.isub(this.m),S._forceRed(this)},U.prototype.iadd=function(d,y){this._verify2(d,y);var S=d.iadd(y);return S.cmp(this.m)>=0&&S.isub(this.m),S},U.prototype.sub=function(d,y){this._verify2(d,y);var S=d.sub(y);return S.cmpn(0)<0&&S.iadd(this.m),S._forceRed(this)},U.prototype.isub=function(d,y){this._verify2(d,y);var S=d.isub(y);return S.cmpn(0)<0&&S.iadd(this.m),S},U.prototype.shl=function(d,y){return this._verify1(d),this.imod(d.ushln(y))},U.prototype.imul=function(d,y){return this._verify2(d,y),this.imod(d.imul(y))},U.prototype.mul=function(d,y){return this._verify2(d,y),this.imod(d.mul(y))},U.prototype.isqr=function(d){return this.imul(d,d.clone())},U.prototype.sqr=function(d){return this.mul(d,d)},U.prototype.sqrt=function(d){if(d.isZero())return d.clone();var y=this.m.andln(3);if(r(y%2===1),y===3){var S=this.m.add(new o(1)).iushrn(2);return this.pow(d,S)}for(var C=this.m.subn(1),R=0;!C.isZero()&&C.andln(1)===0;)R++,C.iushrn(1);r(!C.isZero());var D=new o(1).toRed(this),L=D.redNeg(),O=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);this.pow(f,O).cmp(L)!==0;)f.redIAdd(L);for(var v=this.pow(f,C),k=this.pow(d,C.addn(1).iushrn(1)),M=this.pow(d,C),H=R;M.cmp(D)!==0;){for(var Q=M,X=0;Q.cmp(D)!==0;X++)Q=Q.redSqr();r(X<H);var j=this.pow(v,new o(1).iushln(H-X-1));k=k.redMul(j),v=j.redSqr(),M=M.redMul(v),H=X}return k},U.prototype.invm=function(d){var y=d._invmp(this.m);return y.negative!==0?(y.negative=0,this.imod(y).redNeg()):this.imod(y)},U.prototype.pow=function(d,y){if(y.isZero())return new o(1).toRed(this);if(y.cmpn(1)===0)return d.clone();var S=4,C=new Array(1<<S);C[0]=new o(1).toRed(this),C[1]=d;for(var R=2;R<C.length;R++)C[R]=this.mul(C[R-1],d);var D=C[0],L=0,O=0,f=y.bitLength()%26;for(f===0&&(f=26),R=y.length-1;R>=0;R--){for(var v=y.words[R],k=f-1;k>=0;k--){var M=v>>k&1;if(D!==C[0]&&(D=this.sqr(D)),M===0&&L===0){O=0;continue}L<<=1,L|=M,O++,!(O!==S&&(R!==0||k!==0))&&(D=this.mul(D,C[L]),O=0,L=0)}f=26}return D},U.prototype.convertTo=function(d){var y=d.umod(this.m);return y===d?y.clone():y},U.prototype.convertFrom=function(d){var y=d.clone();return y.red=null,y},o.mont=function(d){return new W(d)};function W(A){U.call(this,A),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(W,U),W.prototype.convertTo=function(d){return this.imod(d.ushln(this.shift))},W.prototype.convertFrom=function(d){var y=this.imod(d.mul(this.rinv));return y.red=null,y},W.prototype.imul=function(d,y){if(d.isZero()||y.isZero())return d.words[0]=0,d.length=1,d;var S=d.imul(y),C=S.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),R=S.isub(C).iushrn(this.shift),D=R;return R.cmp(this.m)>=0?D=R.isub(this.m):R.cmpn(0)<0&&(D=R.iadd(this.m)),D._forceRed(this)},W.prototype.mul=function(d,y){if(d.isZero()||y.isZero())return new o(0)._forceRed(this);var S=d.mul(y),C=S.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),R=S.isub(C).iushrn(this.shift),D=R;return R.cmp(this.m)>=0?D=R.isub(this.m):R.cmpn(0)<0&&(D=R.iadd(this.m)),D._forceRed(this)},W.prototype.invm=function(d){var y=this.imod(d._invmp(this.m).mul(this.r2));return y._forceRed(this)}})(t,w$)})(Vu)),Vu.exports}var E$=hw();const fw=ts(E$);var $u={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var gw;function S$(){return gw||(gw=1,(function(t,e){var n=Ig(),r=n.Buffer;function i(s,a){for(var l in s)a[l]=s[l]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?t.exports=n:(i(n,e),e.Buffer=o);function o(s,a,l){return r(s,a,l)}o.prototype=Object.create(r.prototype),i(r,o),o.from=function(s,a,l){if(typeof s=="number")throw new TypeError("Argument must not be a number");return r(s,a,l)},o.alloc=function(s,a,l){if(typeof s!="number")throw new TypeError("Argument must be a number");var c=r(s);return a!==void 0?typeof l=="string"?c.fill(a,l):c.fill(a):c.fill(0),c},o.allocUnsafe=function(s){if(typeof s!="number")throw new TypeError("Argument must be a number");return r(s)},o.allocUnsafeSlow=function(s){if(typeof s!="number")throw new TypeError("Argument must be a number");return n.SlowBuffer(s)}})($u,$u.exports)),$u.exports}var Fg,pw;function I$(){if(pw)return Fg;pw=1;var t=S$().Buffer;function e(n){if(n.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var o=0;o<n.length;o++){var s=n.charAt(o),a=s.charCodeAt(0);if(r[a]!==255)throw new TypeError(s+" is ambiguous");r[a]=o}var l=n.length,c=n.charAt(0),u=Math.log(l)/Math.log(256),h=Math.log(256)/Math.log(l);function p(m){if((Array.isArray(m)||m instanceof Uint8Array)&&(m=t.from(m)),!t.isBuffer(m))throw new TypeError("Expected Buffer");if(m.length===0)return"";for(var x=0,I=0,N=0,T=m.length;N!==T&&m[N]===0;)N++,x++;for(var $=(T-N)*h+1>>>0,B=new Uint8Array($);N!==T;){for(var G=m[N],Z=0,Y=$-1;(G!==0||Z<I)&&Y!==-1;Y--,Z++)G+=256*B[Y]>>>0,B[Y]=G%l>>>0,G=G/l>>>0;if(G!==0)throw new Error("Non-zero carry");I=Z,N++}for(var F=$-I;F!==$&&B[F]===0;)F++;for(var V=c.repeat(x);F<$;++F)V+=n.charAt(B[F]);return V}function g(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return t.alloc(0);for(var x=0,I=0,N=0;m[x]===c;)I++,x++;for(var T=(m.length-x)*u+1>>>0,$=new Uint8Array(T);x<m.length;){var B=m.charCodeAt(x);if(B>255)return;var G=r[B];if(G===255)return;for(var Z=0,Y=T-1;(G!==0||Z<N)&&Y!==-1;Y--,Z++)G+=l*$[Y]>>>0,$[Y]=G%256>>>0,G=G/256>>>0;if(G!==0)throw new Error("Non-zero carry");N=Z,x++}for(var F=T-N;F!==T&&$[F]===0;)F++;var V=t.allocUnsafe(I+(T-F));V.fill(0,0,I);for(var U=I;F!==T;)V[U++]=$[F++];return V}function b(m){var x=g(m);if(x)return x;throw new Error("Non-base"+l+" character")}return{encode:p,decodeUnsafe:g,decode:b}}return Fg=e,Fg}var Dg,mw;function vw(){if(mw)return Dg;mw=1;var t=I$(),e="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";return Dg=t(e),Dg}var C$=vw();const mn=ts(C$);var tt={};function _i(t,e,n){return e<=t&&t<=n}function zu(t){if(t===void 0)return{};if(t===Object(t))return t;throw TypeError("Could not convert argument to dictionary")}function A$(t){for(var e=String(t),n=e.length,r=0,i=[];r<n;){var o=e.charCodeAt(r);if(o<55296||o>57343)i.push(o);else if(56320<=o&&o<=57343)i.push(65533);else if(55296<=o&&o<=56319)if(r===n-1)i.push(65533);else{var s=t.charCodeAt(r+1);if(56320<=s&&s<=57343){var a=o&1023,l=s&1023;i.push(65536+(a<<10)+l),r+=1}else i.push(65533)}r+=1}return i}function O$(t){for(var e="",n=0;n<t.length;++n){var r=t[n];r<=65535?e+=String.fromCharCode(r):(r-=65536,e+=String.fromCharCode((r>>10)+55296,(r&1023)+56320))}return e}var Uu=-1;function Vg(t){this.tokens=[].slice.call(t)}Vg.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():Uu},prepend:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(t)},push:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.push(e.shift());else this.tokens.push(t)}};var zs=-1;function $g(t,e){if(t)throw TypeError("Decoder error");return e||65533}var Wu="utf-8";function Hu(t,e){if(!(this instanceof Hu))return new Hu(t,e);if(t=t!==void 0?String(t).toLowerCase():Wu,t!==Wu)throw new Error("Encoding not supported. Only utf-8 is supported");e=zu(e),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!e.fatal,this._ignoreBOM=!!e.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}Hu.prototype={decode:function(e,n){var r;typeof e=="object"&&e instanceof ArrayBuffer?r=new Uint8Array(e):typeof e=="object"&&"buffer"in e&&e.buffer instanceof ArrayBuffer?r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):r=new Uint8Array(0),n=zu(n),this._streaming||(this._decoder=new k$({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!n.stream;for(var i=new Vg(r),o=[],s;!i.endOfStream()&&(s=this._decoder.handler(i,i.read()),s!==zs);)s!==null&&(Array.isArray(s)?o.push.apply(o,s):o.push(s));if(!this._streaming){do{if(s=this._decoder.handler(i,i.read()),s===zs)break;s!==null&&(Array.isArray(s)?o.push.apply(o,s):o.push(s))}while(!i.endOfStream());this._decoder=null}return o.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(o[0]===65279?(this._BOMseen=!0,o.shift()):this._BOMseen=!0),O$(o)}};function ju(t,e){if(!(this instanceof ju))return new ju(t,e);if(t=t!==void 0?String(t).toLowerCase():Wu,t!==Wu)throw new Error("Encoding not supported. Only utf-8 is supported");e=zu(e),this._streaming=!1,this._encoder=null,this._options={fatal:!!e.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}ju.prototype={encode:function(e,n){e=e?String(e):"",n=zu(n),this._streaming||(this._encoder=new T$(this._options)),this._streaming=!!n.stream;for(var r=[],i=new Vg(A$(e)),o;!i.endOfStream()&&(o=this._encoder.handler(i,i.read()),o!==zs);)Array.isArray(o)?r.push.apply(r,o):r.push(o);if(!this._streaming){for(;o=this._encoder.handler(i,i.read()),o!==zs;)Array.isArray(o)?r.push.apply(r,o):r.push(o);this._encoder=null}return new Uint8Array(r)}};function k$(t){var e=t.fatal,n=0,r=0,i=0,o=128,s=191;this.handler=function(a,l){if(l===Uu&&i!==0)return i=0,$g(e);if(l===Uu)return zs;if(i===0){if(_i(l,0,127))return l;if(_i(l,194,223))i=1,n=l-192;else if(_i(l,224,239))l===224&&(o=160),l===237&&(s=159),i=2,n=l-224;else if(_i(l,240,244))l===240&&(o=144),l===244&&(s=143),i=3,n=l-240;else return $g(e);return n=n<<6*i,null}if(!_i(l,o,s))return n=i=r=0,o=128,s=191,a.prepend(l),$g(e);if(o=128,s=191,r+=1,n+=l-128<<6*(i-r),r!==i)return null;var c=n;return n=i=r=0,c}}function T$(t){t.fatal,this.handler=function(e,n){if(n===Uu)return zs;if(_i(n,0,127))return n;var r,i;_i(n,128,2047)?(r=1,i=192):_i(n,2048,65535)?(r=2,i=224):_i(n,65536,1114111)&&(r=3,i=240);for(var o=[(n>>6*r)+i];r>0;){var s=n>>6*(r-1);o.push(128|s&63),r-=1}return o}}const R$=ya(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:Hu,TextEncoder:ju},Symbol.toStringTag,{value:"Module"})));var yw;function N$(){if(yw)return tt;yw=1;var t=tt&&tt.__createBinding||(Object.create?(function(F,V,U,W){W===void 0&&(W=U),Object.defineProperty(F,W,{enumerable:!0,get:function(){return V[U]}})}):(function(F,V,U,W){W===void 0&&(W=U),F[W]=V[U]})),e=tt&&tt.__setModuleDefault||(Object.create?(function(F,V){Object.defineProperty(F,"default",{enumerable:!0,value:V})}):function(F,V){F.default=V}),n=tt&&tt.__decorate||function(F,V,U,W){var A=arguments.length,d=A<3?V:W===null?W=Object.getOwnPropertyDescriptor(V,U):W,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")d=Reflect.decorate(F,V,U,W);else for(var S=F.length-1;S>=0;S--)(y=F[S])&&(d=(A<3?y(d):A>3?y(V,U,d):y(V,U))||d);return A>3&&d&&Object.defineProperty(V,U,d),d},r=tt&&tt.__importStar||function(F){if(F&&F.__esModule)return F;var V={};if(F!=null)for(var U in F)U!=="default"&&Object.hasOwnProperty.call(F,U)&&t(V,F,U);return e(V,F),V},i=tt&&tt.__importDefault||function(F){return F&&F.__esModule?F:{default:F}};Object.defineProperty(tt,"__esModule",{value:!0}),tt.deserializeUnchecked=tt.deserialize=tt.serialize=tt.BinaryReader=tt.BinaryWriter=tt.BorshError=tt.baseDecode=tt.baseEncode=void 0;const o=i(hw()),s=i(vw()),a=r(R$),l=typeof TextDecoder!="function"?a.TextDecoder:TextDecoder,c=new l("utf-8",{fatal:!0});function u(F){return typeof F=="string"&&(F=Buffer.from(F,"utf8")),s.default.encode(Buffer.from(F))}tt.baseEncode=u;function h(F){return Buffer.from(s.default.decode(F))}tt.baseDecode=h;const p=1024;class g extends Error{constructor(V){super(V),this.fieldPath=[],this.originalMessage=V}addToFieldPath(V){this.fieldPath.splice(0,0,V),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}tt.BorshError=g;class b{constructor(){this.buf=Buffer.alloc(p),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(p)]))}writeU8(V){this.maybeResize(),this.buf.writeUInt8(V,this.length),this.length+=1}writeU16(V){this.maybeResize(),this.buf.writeUInt16LE(V,this.length),this.length+=2}writeU32(V){this.maybeResize(),this.buf.writeUInt32LE(V,this.length),this.length+=4}writeU64(V){this.maybeResize(),this.writeBuffer(Buffer.from(new o.default(V).toArray("le",8)))}writeU128(V){this.maybeResize(),this.writeBuffer(Buffer.from(new o.default(V).toArray("le",16)))}writeU256(V){this.maybeResize(),this.writeBuffer(Buffer.from(new o.default(V).toArray("le",32)))}writeU512(V){this.maybeResize(),this.writeBuffer(Buffer.from(new o.default(V).toArray("le",64)))}writeBuffer(V){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),V,Buffer.alloc(p)]),this.length+=V.length}writeString(V){this.maybeResize();const U=Buffer.from(V,"utf8");this.writeU32(U.length),this.writeBuffer(U)}writeFixedArray(V){this.writeBuffer(Buffer.from(V))}writeArray(V,U){this.maybeResize(),this.writeU32(V.length);for(const W of V)this.maybeResize(),U(W)}toArray(){return this.buf.subarray(0,this.length)}}tt.BinaryWriter=b;function m(F,V,U){const W=U.value;U.value=function(...A){try{return W.apply(this,A)}catch(d){if(d instanceof RangeError){const y=d.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(y)>=0)throw new g("Reached the end of buffer when deserializing")}throw d}}}class x{constructor(V){this.buf=V,this.offset=0}readU8(){const V=this.buf.readUInt8(this.offset);return this.offset+=1,V}readU16(){const V=this.buf.readUInt16LE(this.offset);return this.offset+=2,V}readU32(){const V=this.buf.readUInt32LE(this.offset);return this.offset+=4,V}readU64(){const V=this.readBuffer(8);return new o.default(V,"le")}readU128(){const V=this.readBuffer(16);return new o.default(V,"le")}readU256(){const V=this.readBuffer(32);return new o.default(V,"le")}readU512(){const V=this.readBuffer(64);return new o.default(V,"le")}readBuffer(V){if(this.offset+V>this.buf.length)throw new g(`Expected buffer length ${V} isn't within bounds`);const U=this.buf.slice(this.offset,this.offset+V);return this.offset+=V,U}readString(){const V=this.readU32(),U=this.readBuffer(V);try{return c.decode(U)}catch(W){throw new g(`Error decoding UTF-8 string: ${W}`)}}readFixedArray(V){return new Uint8Array(this.readBuffer(V))}readArray(V){const U=this.readU32(),W=Array();for(let A=0;A<U;++A)W.push(V());return W}}n([m],x.prototype,"readU8",null),n([m],x.prototype,"readU16",null),n([m],x.prototype,"readU32",null),n([m],x.prototype,"readU64",null),n([m],x.prototype,"readU128",null),n([m],x.prototype,"readU256",null),n([m],x.prototype,"readU512",null),n([m],x.prototype,"readString",null),n([m],x.prototype,"readFixedArray",null),n([m],x.prototype,"readArray",null),tt.BinaryReader=x;function I(F){return F.charAt(0).toUpperCase()+F.slice(1)}function N(F,V,U,W,A){try{if(typeof W=="string")A[`write${I(W)}`](U);else if(W instanceof Array)if(typeof W[0]=="number"){if(U.length!==W[0])throw new g(`Expecting byte array of length ${W[0]}, but got ${U.length} bytes`);A.writeFixedArray(U)}else if(W.length===2&&typeof W[1]=="number"){if(U.length!==W[1])throw new g(`Expecting byte array of length ${W[1]}, but got ${U.length} bytes`);for(let d=0;d<W[1];d++)N(F,null,U[d],W[0],A)}else A.writeArray(U,d=>{N(F,V,d,W[0],A)});else if(W.kind!==void 0)switch(W.kind){case"option":{U==null?A.writeU8(0):(A.writeU8(1),N(F,V,U,W.type,A));break}case"map":{A.writeU32(U.size),U.forEach((d,y)=>{N(F,V,y,W.key,A),N(F,V,d,W.value,A)});break}default:throw new g(`FieldType ${W} unrecognized`)}else T(F,U,A)}catch(d){throw d instanceof g&&d.addToFieldPath(V),d}}function T(F,V,U){if(typeof V.borshSerialize=="function"){V.borshSerialize(U);return}const W=F.get(V.constructor);if(!W)throw new g(`Class ${V.constructor.name} is missing in schema`);if(W.kind==="struct")W.fields.map(([A,d])=>{N(F,A,V[A],d,U)});else if(W.kind==="enum"){const A=V[W.field];for(let d=0;d<W.values.length;++d){const[y,S]=W.values[d];if(y===A){U.writeU8(d),N(F,y,V[y],S,U);break}}}else throw new g(`Unexpected schema kind: ${W.kind} for ${V.constructor.name}`)}function $(F,V,U=b){const W=new U;return T(F,V,W),W.toArray()}tt.serialize=$;function B(F,V,U,W){try{if(typeof U=="string")return W[`read${I(U)}`]();if(U instanceof Array){if(typeof U[0]=="number")return W.readFixedArray(U[0]);if(typeof U[1]=="number"){const A=[];for(let d=0;d<U[1];d++)A.push(B(F,null,U[0],W));return A}else return W.readArray(()=>B(F,V,U[0],W))}if(U.kind==="option")return W.readU8()?B(F,V,U.type,W):void 0;if(U.kind==="map"){let A=new Map;const d=W.readU32();for(let y=0;y<d;y++){const S=B(F,V,U.key,W),C=B(F,V,U.value,W);A.set(S,C)}return A}return G(F,U,W)}catch(A){throw A instanceof g&&A.addToFieldPath(V),A}}function G(F,V,U){if(typeof V.borshDeserialize=="function")return V.borshDeserialize(U);const W=F.get(V);if(!W)throw new g(`Class ${V.name} is missing in schema`);if(W.kind==="struct"){const A={};for(const[d,y]of F.get(V).fields)A[d]=B(F,d,y,U);return new V(A)}if(W.kind==="enum"){const A=U.readU8();if(A>=W.values.length)throw new g(`Enum index: ${A} is out of range`);const[d,y]=W.values[A],S=B(F,d,y,U);return new V({[d]:S})}throw new g(`Unexpected schema kind: ${W.kind} for ${V.constructor.name}`)}function Z(F,V,U,W=x){const A=new W(U),d=G(F,V,A);if(A.offset<U.length)throw new g(`Unexpected ${U.length-A.offset} bytes after deserialized data`);return d}tt.deserialize=Z;function Y(F,V,U,W=x){const A=new W(U);return G(F,V,A)}return tt.deserializeUnchecked=Y,tt}var zg=N$(),ie={},bw;function P$(){if(bw)return ie;bw=1,Object.defineProperty(ie,"__esModule",{value:!0}),ie.s16=ie.s8=ie.nu64be=ie.u48be=ie.u40be=ie.u32be=ie.u24be=ie.u16be=ie.nu64=ie.u48=ie.u40=ie.u32=ie.u24=ie.u16=ie.u8=ie.offset=ie.greedy=ie.Constant=ie.UTF8=ie.CString=ie.Blob=ie.Boolean=ie.BitField=ie.BitStructure=ie.VariantLayout=ie.Union=ie.UnionLayoutDiscriminator=ie.UnionDiscriminator=ie.Structure=ie.Sequence=ie.DoubleBE=ie.Double=ie.FloatBE=ie.Float=ie.NearInt64BE=ie.NearInt64=ie.NearUInt64BE=ie.NearUInt64=ie.IntBE=ie.Int=ie.UIntBE=ie.UInt=ie.OffsetLayout=ie.GreedyCount=ie.ExternalLayout=ie.bindConstructorLayout=ie.nameWithProperty=ie.Layout=ie.uint8ArrayToBuffer=ie.checkUint8Array=void 0,ie.constant=ie.utf8=ie.cstr=ie.blob=ie.unionLayoutDiscriminator=ie.union=ie.seq=ie.bits=ie.struct=ie.f64be=ie.f64=ie.f32be=ie.f32=ie.ns64be=ie.s48be=ie.s40be=ie.s32be=ie.s24be=ie.s16be=ie.ns64=ie.s48=ie.s40=ie.s32=ie.s24=void 0;const t=Ig();function e(f){if(!(f instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}ie.checkUint8Array=e;function n(f){return e(f),t.Buffer.from(f.buffer,f.byteOffset,f.length)}ie.uint8ArrayToBuffer=n;let r=class{constructor(v,k){if(!Number.isInteger(v))throw new TypeError("span must be an integer");this.span=v,this.property=k}makeDestinationObject(){return{}}getSpan(v,k){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(v){const k=Object.create(this.constructor.prototype);return Object.assign(k,this),k.property=v,k}fromArray(v){}};ie.Layout=r;function i(f,v){return v.property?f+"["+v.property+"]":f}ie.nameWithProperty=i;function o(f,v){if(typeof f!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(f,"layout_"))throw new Error("Class is already bound to a layout");if(!(v&&v instanceof r))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(v,"boundConstructor_"))throw new Error("layout is already bound to a constructor");f.layout_=v,v.boundConstructor_=f,v.makeDestinationObject=(()=>new f),Object.defineProperty(f.prototype,"encode",{value(k,M){return v.encode(this,k,M)},writable:!0}),Object.defineProperty(f,"decode",{value(k,M){return v.decode(k,M)},writable:!0})}ie.bindConstructorLayout=o;class s extends r{isCount(){throw new Error("ExternalLayout is abstract")}}ie.ExternalLayout=s;class a extends s{constructor(v=1,k){if(!Number.isInteger(v)||0>=v)throw new TypeError("elementSpan must be a (positive) integer");super(-1,k),this.elementSpan=v}isCount(){return!0}decode(v,k=0){e(v);const M=v.length-k;return Math.floor(M/this.elementSpan)}encode(v,k,M){return 0}}ie.GreedyCount=a;class l extends s{constructor(v,k=0,M){if(!(v instanceof r))throw new TypeError("layout must be a Layout");if(!Number.isInteger(k))throw new TypeError("offset must be integer or undefined");super(v.span,M||v.property),this.layout=v,this.offset=k}isCount(){return this.layout instanceof c||this.layout instanceof u}decode(v,k=0){return this.layout.decode(v,k+this.offset)}encode(v,k,M=0){return this.layout.encode(v,k,M+this.offset)}}ie.OffsetLayout=l;class c extends r{constructor(v,k){if(super(v,k),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(v,k=0){return n(v).readUIntLE(k,this.span)}encode(v,k,M=0){return n(k).writeUIntLE(v,M,this.span),this.span}}ie.UInt=c;class u extends r{constructor(v,k){if(super(v,k),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(v,k=0){return n(v).readUIntBE(k,this.span)}encode(v,k,M=0){return n(k).writeUIntBE(v,M,this.span),this.span}}ie.UIntBE=u;class h extends r{constructor(v,k){if(super(v,k),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(v,k=0){return n(v).readIntLE(k,this.span)}encode(v,k,M=0){return n(k).writeIntLE(v,M,this.span),this.span}}ie.Int=h;class p extends r{constructor(v,k){if(super(v,k),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(v,k=0){return n(v).readIntBE(k,this.span)}encode(v,k,M=0){return n(k).writeIntBE(v,M,this.span),this.span}}ie.IntBE=p;const g=Math.pow(2,32);function b(f){const v=Math.floor(f/g),k=f-v*g;return{hi32:v,lo32:k}}function m(f,v){return f*g+v}class x extends r{constructor(v){super(8,v)}decode(v,k=0){const M=n(v),H=M.readUInt32LE(k),Q=M.readUInt32LE(k+4);return m(Q,H)}encode(v,k,M=0){const H=b(v),Q=n(k);return Q.writeUInt32LE(H.lo32,M),Q.writeUInt32LE(H.hi32,M+4),8}}ie.NearUInt64=x;class I extends r{constructor(v){super(8,v)}decode(v,k=0){const M=n(v),H=M.readUInt32BE(k),Q=M.readUInt32BE(k+4);return m(H,Q)}encode(v,k,M=0){const H=b(v),Q=n(k);return Q.writeUInt32BE(H.hi32,M),Q.writeUInt32BE(H.lo32,M+4),8}}ie.NearUInt64BE=I;class N extends r{constructor(v){super(8,v)}decode(v,k=0){const M=n(v),H=M.readUInt32LE(k),Q=M.readInt32LE(k+4);return m(Q,H)}encode(v,k,M=0){const H=b(v),Q=n(k);return Q.writeUInt32LE(H.lo32,M),Q.writeInt32LE(H.hi32,M+4),8}}ie.NearInt64=N;class T extends r{constructor(v){super(8,v)}decode(v,k=0){const M=n(v),H=M.readInt32BE(k),Q=M.readUInt32BE(k+4);return m(H,Q)}encode(v,k,M=0){const H=b(v),Q=n(k);return Q.writeInt32BE(H.hi32,M),Q.writeUInt32BE(H.lo32,M+4),8}}ie.NearInt64BE=T;class $ extends r{constructor(v){super(4,v)}decode(v,k=0){return n(v).readFloatLE(k)}encode(v,k,M=0){return n(k).writeFloatLE(v,M),4}}ie.Float=$;class B extends r{constructor(v){super(4,v)}decode(v,k=0){return n(v).readFloatBE(k)}encode(v,k,M=0){return n(k).writeFloatBE(v,M),4}}ie.FloatBE=B;class G extends r{constructor(v){super(8,v)}decode(v,k=0){return n(v).readDoubleLE(k)}encode(v,k,M=0){return n(k).writeDoubleLE(v,M),8}}ie.Double=G;class Z extends r{constructor(v){super(8,v)}decode(v,k=0){return n(v).readDoubleBE(k)}encode(v,k,M=0){return n(k).writeDoubleBE(v,M),8}}ie.DoubleBE=Z;class Y extends r{constructor(v,k,M){if(!(v instanceof r))throw new TypeError("elementLayout must be a Layout");if(!(k instanceof s&&k.isCount()||Number.isInteger(k)&&0<=k))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let H=-1;!(k instanceof s)&&0<v.span&&(H=k*v.span),super(H,M),this.elementLayout=v,this.count=k}getSpan(v,k=0){if(0<=this.span)return this.span;let M=0,H=this.count;if(H instanceof s&&(H=H.decode(v,k)),0<this.elementLayout.span)M=H*this.elementLayout.span;else{let Q=0;for(;Q<H;)M+=this.elementLayout.getSpan(v,k+M),++Q}return M}decode(v,k=0){const M=[];let H=0,Q=this.count;for(Q instanceof s&&(Q=Q.decode(v,k));H<Q;)M.push(this.elementLayout.decode(v,k)),k+=this.elementLayout.getSpan(v,k),H+=1;return M}encode(v,k,M=0){const H=this.elementLayout,Q=v.reduce((X,j)=>X+H.encode(j,k,M+X),0);return this.count instanceof s&&this.count.encode(v.length,k,M),Q}}ie.Sequence=Y;class F extends r{constructor(v,k,M){if(!(Array.isArray(v)&&v.reduce((Q,X)=>Q&&X instanceof r,!0)))throw new TypeError("fields must be array of Layout instances");typeof k=="boolean"&&M===void 0&&(M=k,k=void 0);for(const Q of v)if(0>Q.span&&Q.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let H=-1;try{H=v.reduce((Q,X)=>Q+X.getSpan(),0)}catch(Q){}super(H,k),this.fields=v,this.decodePrefixes=!!M}getSpan(v,k=0){if(0<=this.span)return this.span;let M=0;try{M=this.fields.reduce((H,Q)=>{const X=Q.getSpan(v,k);return k+=X,H+X},0)}catch(H){throw new RangeError("indeterminate span")}return M}decode(v,k=0){e(v);const M=this.makeDestinationObject();for(const H of this.fields)if(H.property!==void 0&&(M[H.property]=H.decode(v,k)),k+=H.getSpan(v,k),this.decodePrefixes&&v.length===k)break;return M}encode(v,k,M=0){const H=M;let Q=0,X=0;for(const j of this.fields){let ee=j.span;if(X=0<ee?ee:0,j.property!==void 0){const se=v[j.property];se!==void 0&&(X=j.encode(se,k,M),0>ee&&(ee=j.getSpan(k,M)))}Q=M,M+=ee}return Q+X-H}fromArray(v){const k=this.makeDestinationObject();for(const M of this.fields)M.property!==void 0&&0<v.length&&(k[M.property]=v.shift());return k}layoutFor(v){if(typeof v!="string")throw new TypeError("property must be string");for(const k of this.fields)if(k.property===v)return k}offsetOf(v){if(typeof v!="string")throw new TypeError("property must be string");let k=0;for(const M of this.fields){if(M.property===v)return k;0>M.span?k=-1:0<=k&&(k+=M.span)}}}ie.Structure=F;class V{constructor(v){this.property=v}decode(v,k){throw new Error("UnionDiscriminator is abstract")}encode(v,k,M){throw new Error("UnionDiscriminator is abstract")}}ie.UnionDiscriminator=V;class U extends V{constructor(v,k){if(!(v instanceof s&&v.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(k||v.property||"variant"),this.layout=v}decode(v,k){return this.layout.decode(v,k)}encode(v,k,M){return this.layout.encode(v,k,M)}}ie.UnionLayoutDiscriminator=U;class W extends r{constructor(v,k,M){let H;if(v instanceof c||v instanceof u)H=new U(new l(v));else if(v instanceof s&&v.isCount())H=new U(v);else if(v instanceof V)H=v;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(k===void 0&&(k=null),!(k===null||k instanceof r))throw new TypeError("defaultLayout must be null or a Layout");if(k!==null){if(0>k.span)throw new Error("defaultLayout must have constant span");k.property===void 0&&(k=k.replicate("content"))}let Q=-1;k&&(Q=k.span,0<=Q&&(v instanceof c||v instanceof u)&&(Q+=H.layout.span)),super(Q,M),this.discriminator=H,this.usesPrefixDiscriminator=v instanceof c||v instanceof u,this.defaultLayout=k,this.registry={};let X=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(j){return X(j)},this.configGetSourceVariant=function(j){X=j.bind(this)}}getSpan(v,k=0){if(0<=this.span)return this.span;const M=this.getVariant(v,k);if(!M)throw new Error("unable to determine span for unrecognized variant");return M.getSpan(v,k)}defaultGetSourceVariant(v){if(Object.prototype.hasOwnProperty.call(v,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(v,this.defaultLayout.property))return;const k=this.registry[v[this.discriminator.property]];if(k&&(!k.layout||k.property&&Object.prototype.hasOwnProperty.call(v,k.property)))return k}else for(const k in this.registry){const M=this.registry[k];if(M.property&&Object.prototype.hasOwnProperty.call(v,M.property))return M}throw new Error("unable to infer src variant")}decode(v,k=0){let M;const H=this.discriminator,Q=H.decode(v,k),X=this.registry[Q];if(X===void 0){const j=this.defaultLayout;let ee=0;this.usesPrefixDiscriminator&&(ee=H.layout.span),M=this.makeDestinationObject(),M[H.property]=Q,M[j.property]=j.decode(v,k+ee)}else M=X.decode(v,k);return M}encode(v,k,M=0){const H=this.getSourceVariant(v);if(H===void 0){const Q=this.discriminator,X=this.defaultLayout;let j=0;return this.usesPrefixDiscriminator&&(j=Q.layout.span),Q.encode(v[Q.property],k,M),j+X.encode(v[X.property],k,M+j)}return H.encode(v,k,M)}addVariant(v,k,M){const H=new A(this,v,k,M);return this.registry[v]=H,H}getVariant(v,k=0){let M;return v instanceof Uint8Array?M=this.discriminator.decode(v,k):M=v,this.registry[M]}}ie.Union=W;class A extends r{constructor(v,k,M,H){if(!(v instanceof W))throw new TypeError("union must be a Union");if(!Number.isInteger(k)||0>k)throw new TypeError("variant must be a (non-negative) integer");if(typeof M=="string"&&H===void 0&&(H=M,M=null),M){if(!(M instanceof r))throw new TypeError("layout must be a Layout");if(v.defaultLayout!==null&&0<=M.span&&M.span>v.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof H!="string")throw new TypeError("variant must have a String property")}let Q=v.span;0>v.span&&(Q=M?M.span:0,0<=Q&&v.usesPrefixDiscriminator&&(Q+=v.discriminator.layout.span)),super(Q,H),this.union=v,this.variant=k,this.layout=M||null}getSpan(v,k=0){if(0<=this.span)return this.span;let M=0;this.union.usesPrefixDiscriminator&&(M=this.union.discriminator.layout.span);let H=0;return this.layout&&(H=this.layout.getSpan(v,k+M)),M+H}decode(v,k=0){const M=this.makeDestinationObject();if(this!==this.union.getVariant(v,k))throw new Error("variant mismatch");let H=0;return this.union.usesPrefixDiscriminator&&(H=this.union.discriminator.layout.span),this.layout?M[this.property]=this.layout.decode(v,k+H):this.property?M[this.property]=!0:this.union.usesPrefixDiscriminator&&(M[this.union.discriminator.property]=this.variant),M}encode(v,k,M=0){let H=0;if(this.union.usesPrefixDiscriminator&&(H=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(v,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,k,M);let Q=H;if(this.layout&&(this.layout.encode(v[this.property],k,M+H),Q+=this.layout.getSpan(k,M+H),0<=this.union.span&&Q>this.union.span))throw new Error("encoded variant overruns containing union");return Q}fromArray(v){if(this.layout)return this.layout.fromArray(v)}}ie.VariantLayout=A;function d(f){return 0>f&&(f+=4294967296),f}class y extends r{constructor(v,k,M){if(!(v instanceof c||v instanceof u))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof k=="string"&&M===void 0&&(M=k,k=!1),4<v.span)throw new RangeError("word cannot exceed 32 bits");super(v.span,M),this.word=v,this.msb=!!k,this.fields=[];let H=0;this._packedSetValue=function(Q){return H=d(Q),this},this._packedGetValue=function(){return H}}decode(v,k=0){const M=this.makeDestinationObject(),H=this.word.decode(v,k);this._packedSetValue(H);for(const Q of this.fields)Q.property!==void 0&&(M[Q.property]=Q.decode(v));return M}encode(v,k,M=0){const H=this.word.decode(k,M);this._packedSetValue(H);for(const Q of this.fields)if(Q.property!==void 0){const X=v[Q.property];X!==void 0&&Q.encode(X)}return this.word.encode(this._packedGetValue(),k,M)}addField(v,k){const M=new S(this,v,k);return this.fields.push(M),M}addBoolean(v){const k=new C(this,v);return this.fields.push(k),k}fieldFor(v){if(typeof v!="string")throw new TypeError("property must be string");for(const k of this.fields)if(k.property===v)return k}}ie.BitStructure=y;class S{constructor(v,k,M){if(!(v instanceof y))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(k)||0>=k)throw new TypeError("bits must be positive integer");const H=8*v.span,Q=v.fields.reduce((X,j)=>X+j.bits,0);if(k+Q>H)throw new Error("bits too long for span remainder ("+(H-Q)+" of "+H+" remain)");this.container=v,this.bits=k,this.valueMask=(1<<k)-1,k===32&&(this.valueMask=4294967295),this.start=Q,this.container.msb&&(this.start=H-Q-k),this.wordMask=d(this.valueMask<<this.start),this.property=M}decode(v,k){const M=this.container._packedGetValue();return d(M&this.wordMask)>>>this.start}encode(v){if(typeof v!="number"||!Number.isInteger(v)||v!==d(v&this.valueMask))throw new TypeError(i("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const k=this.container._packedGetValue(),M=d(v<<this.start);this.container._packedSetValue(d(k&~this.wordMask)|M)}}ie.BitField=S;class C extends S{constructor(v,k){super(v,1,k)}decode(v,k){return!!super.decode(v,k)}encode(v){typeof v=="boolean"&&(v=+v),super.encode(v)}}ie.Boolean=C;class R extends r{constructor(v,k){if(!(v instanceof s&&v.isCount()||Number.isInteger(v)&&0<=v))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let M=-1;v instanceof s||(M=v),super(M,k),this.length=v}getSpan(v,k){let M=this.span;return 0>M&&(M=this.length.decode(v,k)),M}decode(v,k=0){let M=this.span;return 0>M&&(M=this.length.decode(v,k)),n(v).slice(k,k+M)}encode(v,k,M){let H=this.length;if(this.length instanceof s&&(H=v.length),!(v instanceof Uint8Array&&H===v.length))throw new TypeError(i("Blob.encode",this)+" requires (length "+H+") Uint8Array as src");if(M+H>k.length)throw new RangeError("encoding overruns Uint8Array");const Q=n(v);return n(k).write(Q.toString("hex"),M,H,"hex"),this.length instanceof s&&this.length.encode(H,k,M),H}}ie.Blob=R;class D extends r{constructor(v){super(-1,v)}getSpan(v,k=0){e(v);let M=k;for(;M<v.length&&v[M]!==0;)M+=1;return 1+M-k}decode(v,k=0){const M=this.getSpan(v,k);return n(v).slice(k,k+M-1).toString("utf-8")}encode(v,k,M=0){typeof v!="string"&&(v=String(v));const H=t.Buffer.from(v,"utf8"),Q=H.length;if(M+Q>k.length)throw new RangeError("encoding overruns Buffer");const X=n(k);return H.copy(X,M),X[M+Q]=0,Q+1}}ie.CString=D;class L extends r{constructor(v,k){if(typeof v=="string"&&k===void 0&&(k=v,v=void 0),v===void 0)v=-1;else if(!Number.isInteger(v))throw new TypeError("maxSpan must be an integer");super(-1,k),this.maxSpan=v}getSpan(v,k=0){return e(v),v.length-k}decode(v,k=0){const M=this.getSpan(v,k);if(0<=this.maxSpan&&this.maxSpan<M)throw new RangeError("text length exceeds maxSpan");return n(v).slice(k,k+M).toString("utf-8")}encode(v,k,M=0){typeof v!="string"&&(v=String(v));const H=t.Buffer.from(v,"utf8"),Q=H.length;if(0<=this.maxSpan&&this.maxSpan<Q)throw new RangeError("text length exceeds maxSpan");if(M+Q>k.length)throw new RangeError("encoding overruns Buffer");return H.copy(n(k),M),Q}}ie.UTF8=L;class O extends r{constructor(v,k){super(0,k),this.value=v}decode(v,k){return this.value}encode(v,k,M){return 0}}return ie.Constant=O,ie.greedy=((f,v)=>new a(f,v)),ie.offset=((f,v,k)=>new l(f,v,k)),ie.u8=(f=>new c(1,f)),ie.u16=(f=>new c(2,f)),ie.u24=(f=>new c(3,f)),ie.u32=(f=>new c(4,f)),ie.u40=(f=>new c(5,f)),ie.u48=(f=>new c(6,f)),ie.nu64=(f=>new x(f)),ie.u16be=(f=>new u(2,f)),ie.u24be=(f=>new u(3,f)),ie.u32be=(f=>new u(4,f)),ie.u40be=(f=>new u(5,f)),ie.u48be=(f=>new u(6,f)),ie.nu64be=(f=>new I(f)),ie.s8=(f=>new h(1,f)),ie.s16=(f=>new h(2,f)),ie.s24=(f=>new h(3,f)),ie.s32=(f=>new h(4,f)),ie.s40=(f=>new h(5,f)),ie.s48=(f=>new h(6,f)),ie.ns64=(f=>new N(f)),ie.s16be=(f=>new p(2,f)),ie.s24be=(f=>new p(3,f)),ie.s32be=(f=>new p(4,f)),ie.s40be=(f=>new p(5,f)),ie.s48be=(f=>new p(6,f)),ie.ns64be=(f=>new T(f)),ie.f32=(f=>new $(f)),ie.f32be=(f=>new B(f)),ie.f64=(f=>new G(f)),ie.f64be=(f=>new Z(f)),ie.struct=((f,v,k)=>new F(f,v,k)),ie.bits=((f,v,k)=>new y(f,v,k)),ie.seq=((f,v,k)=>new Y(f,v,k)),ie.union=((f,v,k)=>new W(f,v,k)),ie.unionLayoutDiscriminator=((f,v)=>new U(f,v)),ie.blob=((f,v)=>new R(f,v)),ie.cstr=(f=>new D(f)),ie.utf8=((f,v)=>new L(f,v)),ie.constant=((f,v)=>new O(f,v)),ie}var q=P$(),L$=1,M$=2,B$=3,F$=4,D$=5,V$=6,$$=7,z$=8,U$=9,W$=10,H$=-32700,j$=-32603,q$=-32602,G$=-32601,K$=-32600,Y$=-32016,X$=-32015,Z$=-32014,J$=-32013,Q$=-32012,ez=-32011,tz=-32010,nz=-32009,rz=-32008,iz=-32007,oz=-32006,sz=-32005,az=-32004,lz=-32003,cz=-32002,uz=-32001,dz=28e5,hz=2800001,fz=2800002,gz=2800003,pz=2800004,mz=2800005,vz=2800006,yz=2800007,bz=2800008,_z=2800009,xz=2800010,wz=2800011,Ez=323e4,Sz=32300001,Iz=3230002,Cz=3230003,Az=3230004,Oz=361e4,kz=3610001,Tz=3610002,Rz=3610003,Nz=3610004,Pz=3610005,Lz=3610006,Mz=3610007,Bz=3611e3,Fz=3704e3,Dz=3704001,Vz=3704002,$z=3704003,zz=3704004,Uz=4128e3,Wz=4128001,Hz=4128002,jz=4615e3,qz=4615001,Gz=4615002,Kz=4615003,Yz=4615004,Xz=4615005,Zz=4615006,Jz=4615007,Qz=4615008,eU=4615009,tU=4615010,nU=4615011,rU=4615012,iU=4615013,oU=4615014,sU=4615015,aU=4615016,lU=4615017,cU=4615018,uU=4615019,dU=4615020,hU=4615021,fU=4615022,gU=4615023,pU=4615024,mU=4615025,vU=4615026,yU=4615027,bU=4615028,_U=4615029,xU=4615030,wU=4615031,EU=4615032,SU=4615033,IU=4615034,CU=4615035,AU=4615036,OU=4615037,kU=4615038,TU=4615039,RU=4615040,NU=4615041,PU=4615042,LU=4615043,MU=4615044,BU=4615045,FU=4615046,DU=4615047,VU=4615048,$U=4615049,zU=4615050,UU=4615051,WU=4615052,HU=4615053,jU=4615054,qU=5508e3,GU=5508001,KU=5508002,YU=5508003,XU=5508004,ZU=5508005,JU=5508006,QU=5508007,eW=5508008,tW=5508009,nW=5508010,rW=5508011,iW=5663e3,oW=5663001,sW=5663002,aW=5663003,lW=5663004,cW=5663005,uW=5663006,dW=5663007,hW=5663008,fW=5663009,gW=5663010,pW=5663011,mW=5663012,vW=5663013,yW=5663014,bW=5663015,_W=5663016,xW=5663017,wW=5663018,EW=5663019,SW=5663020,IW=705e4,CW=7050001,AW=7050002,OW=7050003,kW=7050004,TW=7050005,RW=7050006,NW=7050007,PW=7050008,LW=7050009,MW=7050010,BW=7050011,FW=7050012,DW=7050013,VW=7050014,$W=7050015,zW=7050016,UW=7050017,WW=7050018,HW=7050019,jW=7050020,qW=7050021,GW=7050022,KW=7050023,YW=7050024,XW=7050025,ZW=7050026,JW=7050027,QW=7050028,e7=7050029,t7=7050030,n7=7050031,r7=7050032,i7=7050033,o7=7050034,s7=7050035,a7=7050036,_w=8078e3,xw=8078001,l7=8078002,c7=8078003,ww=8078004,Ew=8078005,Sw=8078006,u7=8078007,d7=8078008,h7=8078009,f7=8078010,Iw=8078011,g7=8078012,p7=8078013,m7=8078014,v7=8078015,y7=8078016,b7=8078017,_7=8078018,x7=8078019,w7=8078020,E7=8078021,S7=8078022,I7=81e5,C7=8100001,A7=8100002,O7=8100003,k7=819e4,T7=8190001,R7=8190002,N7=8190003,P7=8190004,L7=99e5,M7=9900001,B7=9900002,F7=9900003,D7=9900004;function Cw(t){return Array.isArray(t)?"%5B"+t.map(Cw).join("%2C%20")+"%5D":typeof t=="bigint"?`${t}n`:encodeURIComponent(String(t!=null&&Object.getPrototypeOf(t)===null?{...t}:t))}function V7([t,e]){return`${t}=${Cw(e)}`}function $7(t){const e=Object.entries(t).map(V7).join("&");return btoa(e)}var z7={[Ez]:"Account not found at address: $address",[Az]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[Cz]:"Expected decoded account at address: $address",[Iz]:"Failed to decode account data at address: $address",[Sz]:"Accounts not found at addresses: $addresses",[_z]:"Unable to find a viable program address bump seed.",[fz]:"$putativeAddress is not a base58-encoded address.",[dz]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[gz]:"The `CryptoKey` must be an `Ed25519` public key.",[wz]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[bz]:"Invalid seeds; point must fall off the Ed25519 curve.",[pz]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[vz]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[yz]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[mz]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[xz]:"Program address cannot end with PDA marker.",[hz]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[F$]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[L$]:"The network has progressed past the last block for which this transaction could have been committed.",[_w]:"Codec [$codecDescription] cannot decode empty byte arrays.",[S7]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[w7]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[Ew]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[Sw]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[ww]:"Encoder and decoder must either both be fixed-size or variable-size.",[d7]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[l7]:"Expected a fixed-size codec, got a variable-size one.",[p7]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[c7]:"Expected a variable-size codec, got a fixed-size one.",[x7]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[xw]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[_7]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[h7]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[f7]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[v7]:"Invalid literal union variant. Expected one of [$variants], got $value.",[u7]:"Expected [$codecDescription] to have $expected items, got $actual.",[g7]:"Invalid value $value for base $base with alphabet $alphabet.",[y7]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[Iw]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[m7]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[E7]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[b7]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[Bz]:"No random values implementation could be found.",[eU]:"instruction requires an uninitialized account",[gU]:"instruction tries to borrow reference for an account which is already borrowed",[pU]:"instruction left account with an outstanding borrowed reference",[hU]:"program other than the account's owner changed the size of the account data",[Xz]:"account data too small for instruction",[fU]:"instruction expected an executable account",[FU]:"An account does not have enough lamports to be rent-exempt",[VU]:"Program arithmetic overflowed",[BU]:"Failed to serialize or deserialize account data: $encodedData",[jU]:"Builtin programs must consume compute units",[EU]:"Cross-program invocation call depth too deep",[kU]:"Computational budget exceeded",[vU]:"custom program error: #$code",[lU]:"instruction contains duplicate accounts",[mU]:"instruction modifications of multiply-passed account differ",[xU]:"executable accounts must be rent exempt",[bU]:"instruction changed executable accounts data",[_U]:"instruction changed the balance of an executable account",[cU]:"instruction changed executable bit of an account",[oU]:"instruction modified data of an account it does not own",[iU]:"instruction spent from the balance of an account it does not own",[qz]:"generic instruction error",[zU]:"Provided owner is not allowed",[LU]:"Account is immutable",[MU]:"Incorrect authority provided",[Jz]:"incorrect program id for instruction",[Zz]:"insufficient funds for instruction",[Yz]:"invalid account data for instruction",[DU]:"Invalid account owner",[Gz]:"invalid program argument",[yU]:"program returned invalid error code",[Kz]:"invalid instruction data",[OU]:"Failed to reallocate account data",[AU]:"Provided seeds do not result in a valid address",[UU]:"Accounts data allocations exceeded the maximum allowed per transaction",[WU]:"Max accounts exceeded",[HU]:"Max instruction trace length exceeded",[CU]:"Length of the seed is too long for address generation",[SU]:"An account required by the instruction is missing",[Qz]:"missing required signature for instruction",[rU]:"instruction illegally modified the program id of an account",[dU]:"insufficient account keys for instruction",[TU]:"Cross-program invocation with unauthorized signer or writable account",[RU]:"Failed to create program execution environment",[PU]:"Program failed to compile",[NU]:"Program failed to complete",[aU]:"instruction modified data of a read-only account",[sU]:"instruction changed the balance of a read-only account",[IU]:"Cross-program invocation reentrancy not allowed for this instruction",[uU]:"instruction modified rent epoch of an account",[nU]:"sum of account balances before and after instruction do not match",[tU]:"instruction requires an initialized account",[jz]:"",[wU]:"Unsupported program id",[$U]:"Unsupported sysvar",[Uz]:"The instruction does not have any accounts.",[Wz]:"The instruction does not have any data.",[Hz]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[D$]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[M$]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[B7]:"Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[D7]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[M7]:"Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[L7]:"Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[F7]:"Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[j$]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[q$]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[K$]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[G$]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[H$]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[Q$]:"$__serverMessage",[uz]:"$__serverMessage",[az]:"$__serverMessage",[Z$]:"$__serverMessage",[tz]:"$__serverMessage",[nz]:"$__serverMessage",[Y$]:"Minimum context slot has not been reached",[sz]:"Node is unhealthy; behind by $numSlotsBehind slots",[rz]:"No snapshot",[cz]:"Transaction simulation failed",[iz]:"$__serverMessage",[ez]:"Transaction history is not available from this node",[oz]:"$__serverMessage",[J$]:"Transaction signature length mismatch",[lz]:"Transaction signature verification failure",[X$]:"$__serverMessage",[Fz]:"Key pair bytes must be of length 64, got $byteLength.",[Dz]:"Expected private key bytes with length 32. Actual length: $actualLength.",[Vz]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[zz]:"The provided private key does not match the provided public key.",[$z]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[V$]:"Lamports value must be in the range [0, 2e64-1]",[$$]:"`$value` cannot be parsed as a `BigInt`",[W$]:"$message",[z$]:"`$value` cannot be parsed as a `Number`",[B$]:"No nonce account could be found at address `$nonceAccountAddress`",[k7]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[R7]:"WebSocket was closed before payload could be added to the send buffer",[N7]:"WebSocket connection closed",[P7]:"WebSocket failed to connect",[T7]:"Failed to obtain a subscription id from the server",[O7]:"Could not find an API plan for RPC method: `$method`",[I7]:"The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",[A7]:"HTTP error ($statusCode): $message",[C7]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[qU]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[GU]:"The provided value does not implement the `KeyPairSigner` interface",[YU]:"The provided value does not implement the `MessageModifyingSigner` interface",[XU]:"The provided value does not implement the `MessagePartialSigner` interface",[KU]:"The provided value does not implement any of the `MessageSigner` interfaces",[JU]:"The provided value does not implement the `TransactionModifyingSigner` interface",[QU]:"The provided value does not implement the `TransactionPartialSigner` interface",[eW]:"The provided value does not implement the `TransactionSendingSigner` interface",[ZU]:"The provided value does not implement any of the `TransactionSigner` interfaces",[tW]:"More than one `TransactionSendingSigner` was identified.",[nW]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[rW]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[Mz]:"Cannot export a non-extractable key.",[kz]:"No digest implementation could be found.",[Oz]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[Tz]:`This runtime does not support the generation of Ed25519 key pairs.
217
+ */var B1;function Ig(){return B1||(B1=1,(function(t){const e=WV(),n=HV(),r=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;t.Buffer=a,t.SlowBuffer=N,t.INSPECT_MAX_BYTES=50;const i=2147483647;t.kMaxLength=i,a.TYPED_ARRAY_SUPPORT=o(),!a.TYPED_ARRAY_SUPPORT&&typeof console!="undefined"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function o(){try{const P=new Uint8Array(1),_={foo:function(){return 42}};return Object.setPrototypeOf(_,Uint8Array.prototype),Object.setPrototypeOf(P,_),P.foo()===42}catch(P){return!1}}Object.defineProperty(a.prototype,"parent",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.buffer}}),Object.defineProperty(a.prototype,"offset",{enumerable:!0,get:function(){if(a.isBuffer(this))return this.byteOffset}});function s(P){if(P>i)throw new RangeError('The value "'+P+'" is invalid for option "size"');const _=new Uint8Array(P);return Object.setPrototypeOf(_,a.prototype),_}function a(P,_,E){if(typeof P=="number"){if(typeof _=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return h(P)}return l(P,_,E)}a.poolSize=8192;function l(P,_,E){if(typeof P=="string")return p(P,_);if(ArrayBuffer.isView(P))return b(P);if(P==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof P);if(ln(P,ArrayBuffer)||P&&ln(P.buffer,ArrayBuffer)||typeof SharedArrayBuffer!="undefined"&&(ln(P,SharedArrayBuffer)||P&&ln(P.buffer,SharedArrayBuffer)))return m(P,_,E);if(typeof P=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const z=P.valueOf&&P.valueOf();if(z!=null&&z!==P)return a.from(z,_,E);const J=x(P);if(J)return J;if(typeof Symbol!="undefined"&&Symbol.toPrimitive!=null&&typeof P[Symbol.toPrimitive]=="function")return a.from(P[Symbol.toPrimitive]("string"),_,E);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof P)}a.from=function(P,_,E){return l(P,_,E)},Object.setPrototypeOf(a.prototype,Uint8Array.prototype),Object.setPrototypeOf(a,Uint8Array);function c(P){if(typeof P!="number")throw new TypeError('"size" argument must be of type number');if(P<0)throw new RangeError('The value "'+P+'" is invalid for option "size"')}function u(P,_,E){return c(P),P<=0?s(P):_!==void 0?typeof E=="string"?s(P).fill(_,E):s(P).fill(_):s(P)}a.alloc=function(P,_,E){return u(P,_,E)};function h(P){return c(P),s(P<0?0:I(P)|0)}a.allocUnsafe=function(P){return h(P)},a.allocUnsafeSlow=function(P){return h(P)};function p(P,_){if((typeof _!="string"||_==="")&&(_="utf8"),!a.isEncoding(_))throw new TypeError("Unknown encoding: "+_);const E=T(P,_)|0;let z=s(E);const J=z.write(P,_);return J!==E&&(z=z.slice(0,J)),z}function g(P){const _=P.length<0?0:I(P.length)|0,E=s(_);for(let z=0;z<_;z+=1)E[z]=P[z]&255;return E}function b(P){if(ln(P,Uint8Array)){const _=new Uint8Array(P);return m(_.buffer,_.byteOffset,_.byteLength)}return g(P)}function m(P,_,E){if(_<0||P.byteLength<_)throw new RangeError('"offset" is outside of buffer bounds');if(P.byteLength<_+(E||0))throw new RangeError('"length" is outside of buffer bounds');let z;return _===void 0&&E===void 0?z=new Uint8Array(P):E===void 0?z=new Uint8Array(P,_):z=new Uint8Array(P,_,E),Object.setPrototypeOf(z,a.prototype),z}function x(P){if(a.isBuffer(P)){const _=I(P.length)|0,E=s(_);return E.length===0||P.copy(E,0,0,_),E}if(P.length!==void 0)return typeof P.length!="number"||st(P.length)?s(0):g(P);if(P.type==="Buffer"&&Array.isArray(P.data))return g(P.data)}function I(P){if(P>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return P|0}function N(P){return+P!=P&&(P=0),a.alloc(+P)}a.isBuffer=function(_){return _!=null&&_._isBuffer===!0&&_!==a.prototype},a.compare=function(_,E){if(ln(_,Uint8Array)&&(_=a.from(_,_.offset,_.byteLength)),ln(E,Uint8Array)&&(E=a.from(E,E.offset,E.byteLength)),!a.isBuffer(_)||!a.isBuffer(E))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(_===E)return 0;let z=_.length,J=E.length;for(let te=0,ae=Math.min(z,J);te<ae;++te)if(_[te]!==E[te]){z=_[te],J=E[te];break}return z<J?-1:J<z?1:0},a.isEncoding=function(_){switch(String(_).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},a.concat=function(_,E){if(!Array.isArray(_))throw new TypeError('"list" argument must be an Array of Buffers');if(_.length===0)return a.alloc(0);let z;if(E===void 0)for(E=0,z=0;z<_.length;++z)E+=_[z].length;const J=a.allocUnsafe(E);let te=0;for(z=0;z<_.length;++z){let ae=_[z];if(ln(ae,Uint8Array))te+ae.length>J.length?(a.isBuffer(ae)||(ae=a.from(ae)),ae.copy(J,te)):Uint8Array.prototype.set.call(J,ae,te);else if(a.isBuffer(ae))ae.copy(J,te);else throw new TypeError('"list" argument must be an Array of Buffers');te+=ae.length}return J};function T(P,_){if(a.isBuffer(P))return P.length;if(ArrayBuffer.isView(P)||ln(P,ArrayBuffer))return P.byteLength;if(typeof P!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof P);const E=P.length,z=arguments.length>2&&arguments[2]===!0;if(!z&&E===0)return 0;let J=!1;for(;;)switch(_){case"ascii":case"latin1":case"binary":return E;case"utf8":case"utf-8":return He(P).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E*2;case"hex":return E>>>1;case"base64":return nt(P).length;default:if(J)return z?-1:He(P).length;_=(""+_).toLowerCase(),J=!0}}a.byteLength=T;function $(P,_,E){let z=!1;if((_===void 0||_<0)&&(_=0),_>this.length||((E===void 0||E>this.length)&&(E=this.length),E<=0)||(E>>>=0,_>>>=0,E<=_))return"";for(P||(P="utf8");;)switch(P){case"hex":return D(this,_,E);case"utf8":case"utf-8":return d(this,_,E);case"ascii":return C(this,_,E);case"latin1":case"binary":return R(this,_,E);case"base64":return A(this,_,E);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,_,E);default:if(z)throw new TypeError("Unknown encoding: "+P);P=(P+"").toLowerCase(),z=!0}}a.prototype._isBuffer=!0;function B(P,_,E){const z=P[_];P[_]=P[E],P[E]=z}a.prototype.swap16=function(){const _=this.length;if(_%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let E=0;E<_;E+=2)B(this,E,E+1);return this},a.prototype.swap32=function(){const _=this.length;if(_%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let E=0;E<_;E+=4)B(this,E,E+3),B(this,E+1,E+2);return this},a.prototype.swap64=function(){const _=this.length;if(_%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let E=0;E<_;E+=8)B(this,E,E+7),B(this,E+1,E+6),B(this,E+2,E+5),B(this,E+3,E+4);return this},a.prototype.toString=function(){const _=this.length;return _===0?"":arguments.length===0?d(this,0,_):$.apply(this,arguments)},a.prototype.toLocaleString=a.prototype.toString,a.prototype.equals=function(_){if(!a.isBuffer(_))throw new TypeError("Argument must be a Buffer");return this===_?!0:a.compare(this,_)===0},a.prototype.inspect=function(){let _="";const E=t.INSPECT_MAX_BYTES;return _=this.toString("hex",0,E).replace(/(.{2})/g,"$1 ").trim(),this.length>E&&(_+=" ... "),"<Buffer "+_+">"},r&&(a.prototype[r]=a.prototype.inspect),a.prototype.compare=function(_,E,z,J,te){if(ln(_,Uint8Array)&&(_=a.from(_,_.offset,_.byteLength)),!a.isBuffer(_))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof _);if(E===void 0&&(E=0),z===void 0&&(z=_?_.length:0),J===void 0&&(J=0),te===void 0&&(te=this.length),E<0||z>_.length||J<0||te>this.length)throw new RangeError("out of range index");if(J>=te&&E>=z)return 0;if(J>=te)return-1;if(E>=z)return 1;if(E>>>=0,z>>>=0,J>>>=0,te>>>=0,this===_)return 0;let ae=te-J,De=z-E;const Be=Math.min(ae,De),Le=this.slice(J,te),gt=_.slice(E,z);for(let Ne=0;Ne<Be;++Ne)if(Le[Ne]!==gt[Ne]){ae=Le[Ne],De=gt[Ne];break}return ae<De?-1:De<ae?1:0};function G(P,_,E,z,J){if(P.length===0)return-1;if(typeof E=="string"?(z=E,E=0):E>2147483647?E=2147483647:E<-2147483648&&(E=-2147483648),E=+E,st(E)&&(E=J?0:P.length-1),E<0&&(E=P.length+E),E>=P.length){if(J)return-1;E=P.length-1}else if(E<0)if(J)E=0;else return-1;if(typeof _=="string"&&(_=a.from(_,z)),a.isBuffer(_))return _.length===0?-1:Z(P,_,E,z,J);if(typeof _=="number")return _=_&255,typeof Uint8Array.prototype.indexOf=="function"?J?Uint8Array.prototype.indexOf.call(P,_,E):Uint8Array.prototype.lastIndexOf.call(P,_,E):Z(P,[_],E,z,J);throw new TypeError("val must be string, number or Buffer")}function Z(P,_,E,z,J){let te=1,ae=P.length,De=_.length;if(z!==void 0&&(z=String(z).toLowerCase(),z==="ucs2"||z==="ucs-2"||z==="utf16le"||z==="utf-16le")){if(P.length<2||_.length<2)return-1;te=2,ae/=2,De/=2,E/=2}function Be(gt,Ne){return te===1?gt[Ne]:gt.readUInt16BE(Ne*te)}let Le;if(J){let gt=-1;for(Le=E;Le<ae;Le++)if(Be(P,Le)===Be(_,gt===-1?0:Le-gt)){if(gt===-1&&(gt=Le),Le-gt+1===De)return gt*te}else gt!==-1&&(Le-=Le-gt),gt=-1}else for(E+De>ae&&(E=ae-De),Le=E;Le>=0;Le--){let gt=!0;for(let Ne=0;Ne<De;Ne++)if(Be(P,Le+Ne)!==Be(_,Ne)){gt=!1;break}if(gt)return Le}return-1}a.prototype.includes=function(_,E,z){return this.indexOf(_,E,z)!==-1},a.prototype.indexOf=function(_,E,z){return G(this,_,E,z,!0)},a.prototype.lastIndexOf=function(_,E,z){return G(this,_,E,z,!1)};function Y(P,_,E,z){E=Number(E)||0;const J=P.length-E;z?(z=Number(z),z>J&&(z=J)):z=J;const te=_.length;z>te/2&&(z=te/2);let ae;for(ae=0;ae<z;++ae){const De=parseInt(_.substr(ae*2,2),16);if(st(De))return ae;P[E+ae]=De}return ae}function F(P,_,E,z){return Qe(He(_,P.length-E),P,E,z)}function V(P,_,E,z){return Qe(ot(_),P,E,z)}function U(P,_,E,z){return Qe(nt(_),P,E,z)}function W(P,_,E,z){return Qe(ri(_,P.length-E),P,E,z)}a.prototype.write=function(_,E,z,J){if(E===void 0)J="utf8",z=this.length,E=0;else if(z===void 0&&typeof E=="string")J=E,z=this.length,E=0;else if(isFinite(E))E=E>>>0,isFinite(z)?(z=z>>>0,J===void 0&&(J="utf8")):(J=z,z=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const te=this.length-E;if((z===void 0||z>te)&&(z=te),_.length>0&&(z<0||E<0)||E>this.length)throw new RangeError("Attempt to write outside buffer bounds");J||(J="utf8");let ae=!1;for(;;)switch(J){case"hex":return Y(this,_,E,z);case"utf8":case"utf-8":return F(this,_,E,z);case"ascii":case"latin1":case"binary":return V(this,_,E,z);case"base64":return U(this,_,E,z);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return W(this,_,E,z);default:if(ae)throw new TypeError("Unknown encoding: "+J);J=(""+J).toLowerCase(),ae=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function A(P,_,E){return _===0&&E===P.length?e.fromByteArray(P):e.fromByteArray(P.slice(_,E))}function d(P,_,E){E=Math.min(P.length,E);const z=[];let J=_;for(;J<E;){const te=P[J];let ae=null,De=te>239?4:te>223?3:te>191?2:1;if(J+De<=E){let Be,Le,gt,Ne;switch(De){case 1:te<128&&(ae=te);break;case 2:Be=P[J+1],(Be&192)===128&&(Ne=(te&31)<<6|Be&63,Ne>127&&(ae=Ne));break;case 3:Be=P[J+1],Le=P[J+2],(Be&192)===128&&(Le&192)===128&&(Ne=(te&15)<<12|(Be&63)<<6|Le&63,Ne>2047&&(Ne<55296||Ne>57343)&&(ae=Ne));break;case 4:Be=P[J+1],Le=P[J+2],gt=P[J+3],(Be&192)===128&&(Le&192)===128&&(gt&192)===128&&(Ne=(te&15)<<18|(Be&63)<<12|(Le&63)<<6|gt&63,Ne>65535&&Ne<1114112&&(ae=Ne))}}ae===null?(ae=65533,De=1):ae>65535&&(ae-=65536,z.push(ae>>>10&1023|55296),ae=56320|ae&1023),z.push(ae),J+=De}return S(z)}const y=4096;function S(P){const _=P.length;if(_<=y)return String.fromCharCode.apply(String,P);let E="",z=0;for(;z<_;)E+=String.fromCharCode.apply(String,P.slice(z,z+=y));return E}function C(P,_,E){let z="";E=Math.min(P.length,E);for(let J=_;J<E;++J)z+=String.fromCharCode(P[J]&127);return z}function R(P,_,E){let z="";E=Math.min(P.length,E);for(let J=_;J<E;++J)z+=String.fromCharCode(P[J]);return z}function D(P,_,E){const z=P.length;(!_||_<0)&&(_=0),(!E||E<0||E>z)&&(E=z);let J="";for(let te=_;te<E;++te)J+=ht[P[te]];return J}function L(P,_,E){const z=P.slice(_,E);let J="";for(let te=0;te<z.length-1;te+=2)J+=String.fromCharCode(z[te]+z[te+1]*256);return J}a.prototype.slice=function(_,E){const z=this.length;_=~~_,E=E===void 0?z:~~E,_<0?(_+=z,_<0&&(_=0)):_>z&&(_=z),E<0?(E+=z,E<0&&(E=0)):E>z&&(E=z),E<_&&(E=_);const J=this.subarray(_,E);return Object.setPrototypeOf(J,a.prototype),J};function O(P,_,E){if(P%1!==0||P<0)throw new RangeError("offset is not uint");if(P+_>E)throw new RangeError("Trying to access beyond buffer length")}a.prototype.readUintLE=a.prototype.readUIntLE=function(_,E,z){_=_>>>0,E=E>>>0,z||O(_,E,this.length);let J=this[_],te=1,ae=0;for(;++ae<E&&(te*=256);)J+=this[_+ae]*te;return J},a.prototype.readUintBE=a.prototype.readUIntBE=function(_,E,z){_=_>>>0,E=E>>>0,z||O(_,E,this.length);let J=this[_+--E],te=1;for(;E>0&&(te*=256);)J+=this[_+--E]*te;return J},a.prototype.readUint8=a.prototype.readUInt8=function(_,E){return _=_>>>0,E||O(_,1,this.length),this[_]},a.prototype.readUint16LE=a.prototype.readUInt16LE=function(_,E){return _=_>>>0,E||O(_,2,this.length),this[_]|this[_+1]<<8},a.prototype.readUint16BE=a.prototype.readUInt16BE=function(_,E){return _=_>>>0,E||O(_,2,this.length),this[_]<<8|this[_+1]},a.prototype.readUint32LE=a.prototype.readUInt32LE=function(_,E){return _=_>>>0,E||O(_,4,this.length),(this[_]|this[_+1]<<8|this[_+2]<<16)+this[_+3]*16777216},a.prototype.readUint32BE=a.prototype.readUInt32BE=function(_,E){return _=_>>>0,E||O(_,4,this.length),this[_]*16777216+(this[_+1]<<16|this[_+2]<<8|this[_+3])},a.prototype.readBigUInt64LE=Mr(function(_){_=_>>>0,ve(_,"offset");const E=this[_],z=this[_+7];(E===void 0||z===void 0)&&xe(_,this.length-8);const J=E+this[++_]*2**8+this[++_]*2**16+this[++_]*2**24,te=this[++_]+this[++_]*2**8+this[++_]*2**16+z*2**24;return BigInt(J)+(BigInt(te)<<BigInt(32))}),a.prototype.readBigUInt64BE=Mr(function(_){_=_>>>0,ve(_,"offset");const E=this[_],z=this[_+7];(E===void 0||z===void 0)&&xe(_,this.length-8);const J=E*2**24+this[++_]*2**16+this[++_]*2**8+this[++_],te=this[++_]*2**24+this[++_]*2**16+this[++_]*2**8+z;return(BigInt(J)<<BigInt(32))+BigInt(te)}),a.prototype.readIntLE=function(_,E,z){_=_>>>0,E=E>>>0,z||O(_,E,this.length);let J=this[_],te=1,ae=0;for(;++ae<E&&(te*=256);)J+=this[_+ae]*te;return te*=128,J>=te&&(J-=Math.pow(2,8*E)),J},a.prototype.readIntBE=function(_,E,z){_=_>>>0,E=E>>>0,z||O(_,E,this.length);let J=E,te=1,ae=this[_+--J];for(;J>0&&(te*=256);)ae+=this[_+--J]*te;return te*=128,ae>=te&&(ae-=Math.pow(2,8*E)),ae},a.prototype.readInt8=function(_,E){return _=_>>>0,E||O(_,1,this.length),this[_]&128?(255-this[_]+1)*-1:this[_]},a.prototype.readInt16LE=function(_,E){_=_>>>0,E||O(_,2,this.length);const z=this[_]|this[_+1]<<8;return z&32768?z|4294901760:z},a.prototype.readInt16BE=function(_,E){_=_>>>0,E||O(_,2,this.length);const z=this[_+1]|this[_]<<8;return z&32768?z|4294901760:z},a.prototype.readInt32LE=function(_,E){return _=_>>>0,E||O(_,4,this.length),this[_]|this[_+1]<<8|this[_+2]<<16|this[_+3]<<24},a.prototype.readInt32BE=function(_,E){return _=_>>>0,E||O(_,4,this.length),this[_]<<24|this[_+1]<<16|this[_+2]<<8|this[_+3]},a.prototype.readBigInt64LE=Mr(function(_){_=_>>>0,ve(_,"offset");const E=this[_],z=this[_+7];(E===void 0||z===void 0)&&xe(_,this.length-8);const J=this[_+4]+this[_+5]*2**8+this[_+6]*2**16+(z<<24);return(BigInt(J)<<BigInt(32))+BigInt(E+this[++_]*2**8+this[++_]*2**16+this[++_]*2**24)}),a.prototype.readBigInt64BE=Mr(function(_){_=_>>>0,ve(_,"offset");const E=this[_],z=this[_+7];(E===void 0||z===void 0)&&xe(_,this.length-8);const J=(E<<24)+this[++_]*2**16+this[++_]*2**8+this[++_];return(BigInt(J)<<BigInt(32))+BigInt(this[++_]*2**24+this[++_]*2**16+this[++_]*2**8+z)}),a.prototype.readFloatLE=function(_,E){return _=_>>>0,E||O(_,4,this.length),n.read(this,_,!0,23,4)},a.prototype.readFloatBE=function(_,E){return _=_>>>0,E||O(_,4,this.length),n.read(this,_,!1,23,4)},a.prototype.readDoubleLE=function(_,E){return _=_>>>0,E||O(_,8,this.length),n.read(this,_,!0,52,8)},a.prototype.readDoubleBE=function(_,E){return _=_>>>0,E||O(_,8,this.length),n.read(this,_,!1,52,8)};function f(P,_,E,z,J,te){if(!a.isBuffer(P))throw new TypeError('"buffer" argument must be a Buffer instance');if(_>J||_<te)throw new RangeError('"value" argument is out of bounds');if(E+z>P.length)throw new RangeError("Index out of range")}a.prototype.writeUintLE=a.prototype.writeUIntLE=function(_,E,z,J){if(_=+_,E=E>>>0,z=z>>>0,!J){const De=Math.pow(2,8*z)-1;f(this,_,E,z,De,0)}let te=1,ae=0;for(this[E]=_&255;++ae<z&&(te*=256);)this[E+ae]=_/te&255;return E+z},a.prototype.writeUintBE=a.prototype.writeUIntBE=function(_,E,z,J){if(_=+_,E=E>>>0,z=z>>>0,!J){const De=Math.pow(2,8*z)-1;f(this,_,E,z,De,0)}let te=z-1,ae=1;for(this[E+te]=_&255;--te>=0&&(ae*=256);)this[E+te]=_/ae&255;return E+z},a.prototype.writeUint8=a.prototype.writeUInt8=function(_,E,z){return _=+_,E=E>>>0,z||f(this,_,E,1,255,0),this[E]=_&255,E+1},a.prototype.writeUint16LE=a.prototype.writeUInt16LE=function(_,E,z){return _=+_,E=E>>>0,z||f(this,_,E,2,65535,0),this[E]=_&255,this[E+1]=_>>>8,E+2},a.prototype.writeUint16BE=a.prototype.writeUInt16BE=function(_,E,z){return _=+_,E=E>>>0,z||f(this,_,E,2,65535,0),this[E]=_>>>8,this[E+1]=_&255,E+2},a.prototype.writeUint32LE=a.prototype.writeUInt32LE=function(_,E,z){return _=+_,E=E>>>0,z||f(this,_,E,4,4294967295,0),this[E+3]=_>>>24,this[E+2]=_>>>16,this[E+1]=_>>>8,this[E]=_&255,E+4},a.prototype.writeUint32BE=a.prototype.writeUInt32BE=function(_,E,z){return _=+_,E=E>>>0,z||f(this,_,E,4,4294967295,0),this[E]=_>>>24,this[E+1]=_>>>16,this[E+2]=_>>>8,this[E+3]=_&255,E+4};function v(P,_,E,z,J){re(_,z,J,P,E,7);let te=Number(_&BigInt(4294967295));P[E++]=te,te=te>>8,P[E++]=te,te=te>>8,P[E++]=te,te=te>>8,P[E++]=te;let ae=Number(_>>BigInt(32)&BigInt(4294967295));return P[E++]=ae,ae=ae>>8,P[E++]=ae,ae=ae>>8,P[E++]=ae,ae=ae>>8,P[E++]=ae,E}function k(P,_,E,z,J){re(_,z,J,P,E,7);let te=Number(_&BigInt(4294967295));P[E+7]=te,te=te>>8,P[E+6]=te,te=te>>8,P[E+5]=te,te=te>>8,P[E+4]=te;let ae=Number(_>>BigInt(32)&BigInt(4294967295));return P[E+3]=ae,ae=ae>>8,P[E+2]=ae,ae=ae>>8,P[E+1]=ae,ae=ae>>8,P[E]=ae,E+8}a.prototype.writeBigUInt64LE=Mr(function(_,E=0){return v(this,_,E,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeBigUInt64BE=Mr(function(_,E=0){return k(this,_,E,BigInt(0),BigInt("0xffffffffffffffff"))}),a.prototype.writeIntLE=function(_,E,z,J){if(_=+_,E=E>>>0,!J){const Be=Math.pow(2,8*z-1);f(this,_,E,z,Be-1,-Be)}let te=0,ae=1,De=0;for(this[E]=_&255;++te<z&&(ae*=256);)_<0&&De===0&&this[E+te-1]!==0&&(De=1),this[E+te]=(_/ae>>0)-De&255;return E+z},a.prototype.writeIntBE=function(_,E,z,J){if(_=+_,E=E>>>0,!J){const Be=Math.pow(2,8*z-1);f(this,_,E,z,Be-1,-Be)}let te=z-1,ae=1,De=0;for(this[E+te]=_&255;--te>=0&&(ae*=256);)_<0&&De===0&&this[E+te+1]!==0&&(De=1),this[E+te]=(_/ae>>0)-De&255;return E+z},a.prototype.writeInt8=function(_,E,z){return _=+_,E=E>>>0,z||f(this,_,E,1,127,-128),_<0&&(_=255+_+1),this[E]=_&255,E+1},a.prototype.writeInt16LE=function(_,E,z){return _=+_,E=E>>>0,z||f(this,_,E,2,32767,-32768),this[E]=_&255,this[E+1]=_>>>8,E+2},a.prototype.writeInt16BE=function(_,E,z){return _=+_,E=E>>>0,z||f(this,_,E,2,32767,-32768),this[E]=_>>>8,this[E+1]=_&255,E+2},a.prototype.writeInt32LE=function(_,E,z){return _=+_,E=E>>>0,z||f(this,_,E,4,2147483647,-2147483648),this[E]=_&255,this[E+1]=_>>>8,this[E+2]=_>>>16,this[E+3]=_>>>24,E+4},a.prototype.writeInt32BE=function(_,E,z){return _=+_,E=E>>>0,z||f(this,_,E,4,2147483647,-2147483648),_<0&&(_=4294967295+_+1),this[E]=_>>>24,this[E+1]=_>>>16,this[E+2]=_>>>8,this[E+3]=_&255,E+4},a.prototype.writeBigInt64LE=Mr(function(_,E=0){return v(this,_,E,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),a.prototype.writeBigInt64BE=Mr(function(_,E=0){return k(this,_,E,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function M(P,_,E,z,J,te){if(E+z>P.length)throw new RangeError("Index out of range");if(E<0)throw new RangeError("Index out of range")}function H(P,_,E,z,J){return _=+_,E=E>>>0,J||M(P,_,E,4),n.write(P,_,E,z,23,4),E+4}a.prototype.writeFloatLE=function(_,E,z){return H(this,_,E,!0,z)},a.prototype.writeFloatBE=function(_,E,z){return H(this,_,E,!1,z)};function Q(P,_,E,z,J){return _=+_,E=E>>>0,J||M(P,_,E,8),n.write(P,_,E,z,52,8),E+8}a.prototype.writeDoubleLE=function(_,E,z){return Q(this,_,E,!0,z)},a.prototype.writeDoubleBE=function(_,E,z){return Q(this,_,E,!1,z)},a.prototype.copy=function(_,E,z,J){if(!a.isBuffer(_))throw new TypeError("argument should be a Buffer");if(z||(z=0),!J&&J!==0&&(J=this.length),E>=_.length&&(E=_.length),E||(E=0),J>0&&J<z&&(J=z),J===z||_.length===0||this.length===0)return 0;if(E<0)throw new RangeError("targetStart out of bounds");if(z<0||z>=this.length)throw new RangeError("Index out of range");if(J<0)throw new RangeError("sourceEnd out of bounds");J>this.length&&(J=this.length),_.length-E<J-z&&(J=_.length-E+z);const te=J-z;return this===_&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(E,z,J):Uint8Array.prototype.set.call(_,this.subarray(z,J),E),te},a.prototype.fill=function(_,E,z,J){if(typeof _=="string"){if(typeof E=="string"?(J=E,E=0,z=this.length):typeof z=="string"&&(J=z,z=this.length),J!==void 0&&typeof J!="string")throw new TypeError("encoding must be a string");if(typeof J=="string"&&!a.isEncoding(J))throw new TypeError("Unknown encoding: "+J);if(_.length===1){const ae=_.charCodeAt(0);(J==="utf8"&&ae<128||J==="latin1")&&(_=ae)}}else typeof _=="number"?_=_&255:typeof _=="boolean"&&(_=Number(_));if(E<0||this.length<E||this.length<z)throw new RangeError("Out of range index");if(z<=E)return this;E=E>>>0,z=z===void 0?this.length:z>>>0,_||(_=0);let te;if(typeof _=="number")for(te=E;te<z;++te)this[te]=_;else{const ae=a.isBuffer(_)?_:a.from(_,J),De=ae.length;if(De===0)throw new TypeError('The value "'+_+'" is invalid for argument "value"');for(te=0;te<z-E;++te)this[te+E]=ae[te%De]}return this};const X={};function j(P,_,E){X[P]=class extends E{constructor(){super(),Object.defineProperty(this,"message",{value:_.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${P}]`,this.stack,delete this.name}get code(){return P}set code(J){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:J,writable:!0})}toString(){return`${this.name} [${P}]: ${this.message}`}}}j("ERR_BUFFER_OUT_OF_BOUNDS",function(P){return P?`${P} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),j("ERR_INVALID_ARG_TYPE",function(P,_){return`The "${P}" argument must be of type number. Received type ${typeof _}`},TypeError),j("ERR_OUT_OF_RANGE",function(P,_,E){let z=`The value of "${P}" is out of range.`,J=E;return Number.isInteger(E)&&Math.abs(E)>2**32?J=ee(String(E)):typeof E=="bigint"&&(J=String(E),(E>BigInt(2)**BigInt(32)||E<-(BigInt(2)**BigInt(32)))&&(J=ee(J)),J+="n"),z+=` It must be ${_}. Received ${J}`,z},RangeError);function ee(P){let _="",E=P.length;const z=P[0]==="-"?1:0;for(;E>=z+4;E-=3)_=`_${P.slice(E-3,E)}${_}`;return`${P.slice(0,E)}${_}`}function se(P,_,E){ve(_,"offset"),(P[_]===void 0||P[_+E]===void 0)&&xe(_,P.length-(E+1))}function re(P,_,E,z,J,te){if(P>E||P<_){const ae=typeof _=="bigint"?"n":"";let De;throw _===0||_===BigInt(0)?De=`>= 0${ae} and < 2${ae} ** ${(te+1)*8}${ae}`:De=`>= -(2${ae} ** ${(te+1)*8-1}${ae}) and < 2 ** ${(te+1)*8-1}${ae}`,new X.ERR_OUT_OF_RANGE("value",De,P)}se(z,J,te)}function ve(P,_){if(typeof P!="number")throw new X.ERR_INVALID_ARG_TYPE(_,"number",P)}function xe(P,_,E){throw Math.floor(P)!==P?(ve(P,E),new X.ERR_OUT_OF_RANGE("offset","an integer",P)):_<0?new X.ERR_BUFFER_OUT_OF_BOUNDS:new X.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${_}`,P)}const Pe=/[^+/0-9A-Za-z-_]/g;function Et(P){if(P=P.split("=")[0],P=P.trim().replace(Pe,""),P.length<2)return"";for(;P.length%4!==0;)P=P+"=";return P}function He(P,_){_=_||1/0;let E;const z=P.length;let J=null;const te=[];for(let ae=0;ae<z;++ae){if(E=P.charCodeAt(ae),E>55295&&E<57344){if(!J){if(E>56319){(_-=3)>-1&&te.push(239,191,189);continue}else if(ae+1===z){(_-=3)>-1&&te.push(239,191,189);continue}J=E;continue}if(E<56320){(_-=3)>-1&&te.push(239,191,189),J=E;continue}E=(J-55296<<10|E-56320)+65536}else J&&(_-=3)>-1&&te.push(239,191,189);if(J=null,E<128){if((_-=1)<0)break;te.push(E)}else if(E<2048){if((_-=2)<0)break;te.push(E>>6|192,E&63|128)}else if(E<65536){if((_-=3)<0)break;te.push(E>>12|224,E>>6&63|128,E&63|128)}else if(E<1114112){if((_-=4)<0)break;te.push(E>>18|240,E>>12&63|128,E>>6&63|128,E&63|128)}else throw new Error("Invalid code point")}return te}function ot(P){const _=[];for(let E=0;E<P.length;++E)_.push(P.charCodeAt(E)&255);return _}function ri(P,_){let E,z,J;const te=[];for(let ae=0;ae<P.length&&!((_-=2)<0);++ae)E=P.charCodeAt(ae),z=E>>8,J=E%256,te.push(J),te.push(z);return te}function nt(P){return e.toByteArray(Et(P))}function Qe(P,_,E,z){let J;for(J=0;J<z&&!(J+E>=_.length||J>=P.length);++J)_[J+E]=P[J];return J}function ln(P,_){return P instanceof _||P!=null&&P.constructor!=null&&P.constructor.name!=null&&P.constructor.name===_.name}function st(P){return P!==P}const ht=(function(){const P="0123456789abcdef",_=new Array(256);for(let E=0;E<16;++E){const z=E*16;for(let J=0;J<16;++J)_[z+J]=P[E]+P[J]}return _})();function Mr(P){return typeof BigInt=="undefined"?St:P}function St(){throw new Error("BigInt not supported")}})(Sg)),Sg}var $e=Ig();/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Cg=BigInt(0),Ag=BigInt(1);function Po(t,e=""){if(typeof t!="boolean"){const n=e&&`"${e}"`;throw new Error(n+"expected boolean, got type="+typeof t)}return t}function Rr(t,e,n=""){const r=il(t),i=t==null?void 0:t.length,o=e!==void 0;if(!r||o&&i!==e){const s=n&&`"${n}" `,a=o?` of length ${e}`:"",l=r?`length=${i}`:`type=${typeof t}`;throw new Error(s+"expected Uint8Array"+a+", got "+l)}return t}function Mu(t){const e=t.toString(16);return e.length&1?"0"+e:e}function F1(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Cg:BigInt("0x"+t)}function Bu(t){return F1(To(t))}function vl(t){return yi(t),F1(To(Uint8Array.from(t).reverse()))}function Og(t,e){return xu(t.toString(16).padStart(e*2,"0"))}function D1(t,e){return Og(t,e).reverse()}function xt(t,e,n){let r;if(typeof e=="string")try{r=xu(e)}catch(o){throw new Error(t+" must be hex string or Uint8Array, cause: "+o)}else if(il(e))r=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const i=r.length;if(typeof n=="number"&&i!==n)throw new Error(t+" of length "+n+" expected, got "+i);return r}function V1(t){return Uint8Array.from(t)}const kg=t=>typeof t=="bigint"&&Cg<=t;function jV(t,e,n){return kg(t)&&kg(e)&&kg(n)&&e<=t&&t<n}function Tg(t,e,n,r){if(!jV(e,n,r))throw new Error("expected valid "+t+": "+n+" <= n < "+r+", got "+e)}function $1(t){let e;for(e=0;t>Cg;t>>=Ag,e+=1);return e}const yl=t=>(Ag<<BigInt(t))-Ag;function qV(t,e,n){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");const r=g=>new Uint8Array(g),i=g=>Uint8Array.of(g);let o=r(t),s=r(t),a=0;const l=()=>{o.fill(1),s.fill(0),a=0},c=(...g)=>n(s,o,...g),u=(g=r(0))=>{s=c(i(0),g),o=c(),g.length!==0&&(s=c(i(1),g),o=c())},h=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let g=0;const b=[];for(;g<e;){o=c();const m=o.slice();b.push(m),g+=o.length}return Yr(...b)};return(g,b)=>{l(),u(g);let m;for(;!(m=b(h()));)u();return l(),m}}function bl(t,e,n={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function r(i,o,s){const a=t[i];if(s&&a===void 0)return;const l=typeof a;if(l!==o||a===null)throw new Error(`param "${i}" is invalid: expected ${o}, got ${l}`)}Object.entries(e).forEach(([i,o])=>r(i,o,!1)),Object.entries(n).forEach(([i,o])=>r(i,o,!0))}function Fu(t){const e=new WeakMap;return(n,...r)=>{const i=e.get(n);if(i!==void 0)return i;const o=t(n,...r);return e.set(n,o),o}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Wn=BigInt(0),pn=BigInt(1),Lo=BigInt(2),z1=BigInt(3),U1=BigInt(4),W1=BigInt(5),GV=BigInt(7),H1=BigInt(8),KV=BigInt(9),j1=BigInt(16);function Lt(t,e){const n=t%e;return n>=Wn?n:e+n}function wt(t,e,n){let r=t;for(;e-- >Wn;)r*=r,r%=n;return r}function q1(t,e){if(t===Wn)throw new Error("invert: expected non-zero number");if(e<=Wn)throw new Error("invert: expected positive modulus, got "+e);let n=Lt(t,e),r=e,i=Wn,o=pn;for(;n!==Wn;){const a=r/n,l=r%n,c=i-o*a;r=n,n=l,i=o,o=c}if(r!==pn)throw new Error("invert: does not exist");return Lt(i,e)}function Rg(t,e,n){if(!t.eql(t.sqr(e),n))throw new Error("Cannot find square root")}function G1(t,e){const n=(t.ORDER+pn)/U1,r=t.pow(e,n);return Rg(t,r,e),r}function YV(t,e){const n=(t.ORDER-W1)/H1,r=t.mul(e,Lo),i=t.pow(r,n),o=t.mul(e,i),s=t.mul(t.mul(o,Lo),i),a=t.mul(o,t.sub(s,t.ONE));return Rg(t,a,e),a}function XV(t){const e=Mo(t),n=K1(t),r=n(e,e.neg(e.ONE)),i=n(e,r),o=n(e,e.neg(r)),s=(t+GV)/j1;return(a,l)=>{let c=a.pow(l,s),u=a.mul(c,r);const h=a.mul(c,i),p=a.mul(c,o),g=a.eql(a.sqr(u),l),b=a.eql(a.sqr(h),l);c=a.cmov(c,u,g),u=a.cmov(p,h,b);const m=a.eql(a.sqr(u),l),x=a.cmov(c,u,m);return Rg(a,x,l),x}}function K1(t){if(t<z1)throw new Error("sqrt is not defined for small field");let e=t-pn,n=0;for(;e%Lo===Wn;)e/=Lo,n++;let r=Lo;const i=Mo(t);for(;X1(i,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return G1;let o=i.pow(r,e);const s=(e+pn)/Lo;return function(l,c){if(l.is0(c))return c;if(X1(l,c)!==1)throw new Error("Cannot find square root");let u=n,h=l.mul(l.ONE,o),p=l.pow(c,e),g=l.pow(c,s);for(;!l.eql(p,l.ONE);){if(l.is0(p))return l.ZERO;let b=1,m=l.sqr(p);for(;!l.eql(m,l.ONE);)if(b++,m=l.sqr(m),b===u)throw new Error("Cannot find square root");const x=pn<<BigInt(u-b-1),I=l.pow(h,x);u=b,h=l.sqr(I),p=l.mul(p,h),g=l.mul(g,I)}return g}}function ZV(t){return t%U1===z1?G1:t%H1===W1?YV:t%j1===KV?XV(t):K1(t)}const JV=(t,e)=>(Lt(t,e)&pn)===pn,QV=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function e$(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},n=QV.reduce((r,i)=>(r[i]="function",r),e);return bl(t,n),t}function t$(t,e,n){if(n<Wn)throw new Error("invalid exponent, negatives unsupported");if(n===Wn)return t.ONE;if(n===pn)return e;let r=t.ONE,i=e;for(;n>Wn;)n&pn&&(r=t.mul(r,i)),i=t.sqr(i),n>>=pn;return r}function Y1(t,e,n=!1){const r=new Array(e.length).fill(n?t.ZERO:void 0),i=e.reduce((s,a,l)=>t.is0(a)?s:(r[l]=s,t.mul(s,a)),t.ONE),o=t.inv(i);return e.reduceRight((s,a,l)=>t.is0(a)?s:(r[l]=t.mul(s,r[l]),t.mul(s,a)),o),r}function X1(t,e){const n=(t.ORDER-pn)/Lo,r=t.pow(e,n),i=t.eql(r,t.ONE),o=t.eql(r,t.ZERO),s=t.eql(r,t.neg(t.ONE));if(!i&&!o&&!s)throw new Error("invalid Legendre symbol result");return i?1:o?0:-1}function Z1(t,e){e!==void 0&&ol(e);const n=e!==void 0?e:t.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function Mo(t,e,n=!1,r={}){if(t<=Wn)throw new Error("invalid field: expected ORDER > 0, got "+t);let i,o,s=!1,a;if(typeof e=="object"&&e!=null){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");const p=e;p.BITS&&(i=p.BITS),p.sqrt&&(o=p.sqrt),typeof p.isLE=="boolean"&&(n=p.isLE),typeof p.modFromBytes=="boolean"&&(s=p.modFromBytes),a=p.allowedLengths}else typeof e=="number"&&(i=e),r.sqrt&&(o=r.sqrt);const{nBitLength:l,nByteLength:c}=Z1(t,i);if(c>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let u;const h=Object.freeze({ORDER:t,isLE:n,BITS:l,BYTES:c,MASK:yl(l),ZERO:Wn,ONE:pn,allowedLengths:a,create:p=>Lt(p,t),isValid:p=>{if(typeof p!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof p);return Wn<=p&&p<t},is0:p=>p===Wn,isValidNot0:p=>!h.is0(p)&&h.isValid(p),isOdd:p=>(p&pn)===pn,neg:p=>Lt(-p,t),eql:(p,g)=>p===g,sqr:p=>Lt(p*p,t),add:(p,g)=>Lt(p+g,t),sub:(p,g)=>Lt(p-g,t),mul:(p,g)=>Lt(p*g,t),pow:(p,g)=>t$(h,p,g),div:(p,g)=>Lt(p*q1(g,t),t),sqrN:p=>p*p,addN:(p,g)=>p+g,subN:(p,g)=>p-g,mulN:(p,g)=>p*g,inv:p=>q1(p,t),sqrt:o||(p=>(u||(u=ZV(t)),u(h,p))),toBytes:p=>n?D1(p,c):Og(p,c),fromBytes:(p,g=!0)=>{if(a){if(!a.includes(p.length)||p.length>c)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+p.length);const m=new Uint8Array(c);m.set(p,n?0:m.length-p.length),p=m}if(p.length!==c)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+p.length);let b=n?vl(p):Bu(p);if(s&&(b=Lt(b,t)),!g&&!h.isValid(b))throw new Error("invalid field element: outside of range 0..ORDER");return b},invertBatch:p=>Y1(h,p),cmov:(p,g,b)=>b?g:p});return Object.freeze(h)}function J1(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function Q1(t){const e=J1(t);return e+Math.ceil(e/2)}function n$(t,e,n=!1){const r=t.length,i=J1(e),o=Q1(e);if(r<16||r<o||r>1024)throw new Error("expected "+o+"-1024 bytes of input, got "+r);const s=n?vl(t):Bu(t),a=Lt(s,e-pn)+pn;return n?D1(a,i):Og(a,i)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const $s=BigInt(0),Bo=BigInt(1);function Du(t,e){const n=e.negate();return t?n:e}function Fo(t,e){const n=Y1(t.Fp,e.map(r=>r.Z));return e.map((r,i)=>t.fromAffine(r.toAffine(n[i])))}function ew(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function Ng(t,e){ew(t,e);const n=Math.ceil(e/t)+1,r=2**(t-1),i=2**t,o=yl(t),s=BigInt(t);return{windows:n,windowSize:r,mask:o,maxNumber:i,shiftBy:s}}function tw(t,e,n){const{windowSize:r,mask:i,maxNumber:o,shiftBy:s}=n;let a=Number(t&i),l=t>>s;a>r&&(a-=o,l+=Bo);const c=e*r,u=c+Math.abs(a)-1,h=a===0,p=a<0,g=e%2!==0;return{nextN:l,offset:u,isZero:h,isNeg:p,isNegF:g,offsetF:c}}function r$(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((n,r)=>{if(!(n instanceof e))throw new Error("invalid point at index "+r)})}function i$(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((n,r)=>{if(!e.isValid(n))throw new Error("invalid scalar at index "+r)})}const Pg=new WeakMap,nw=new WeakMap;function Lg(t){return nw.get(t)||1}function rw(t){if(t!==$s)throw new Error("invalid wNAF")}class iw{constructor(e,n){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=n}_unsafeLadder(e,n,r=this.ZERO){let i=e;for(;n>$s;)n&Bo&&(r=r.add(i)),i=i.double(),n>>=Bo;return r}precomputeWindow(e,n){const{windows:r,windowSize:i}=Ng(n,this.bits),o=[];let s=e,a=s;for(let l=0;l<r;l++){a=s,o.push(a);for(let c=1;c<i;c++)a=a.add(s),o.push(a);s=a.double()}return o}wNAF(e,n,r){if(!this.Fn.isValid(r))throw new Error("invalid scalar");let i=this.ZERO,o=this.BASE;const s=Ng(e,this.bits);for(let a=0;a<s.windows;a++){const{nextN:l,offset:c,isZero:u,isNeg:h,isNegF:p,offsetF:g}=tw(r,a,s);r=l,u?o=o.add(Du(p,n[g])):i=i.add(Du(h,n[c]))}return rw(r),{p:i,f:o}}wNAFUnsafe(e,n,r,i=this.ZERO){const o=Ng(e,this.bits);for(let s=0;s<o.windows&&r!==$s;s++){const{nextN:a,offset:l,isZero:c,isNeg:u}=tw(r,s,o);if(r=a,!c){const h=n[l];i=i.add(u?h.negate():h)}}return rw(r),i}getPrecomputes(e,n,r){let i=Pg.get(n);return i||(i=this.precomputeWindow(n,e),e!==1&&(typeof r=="function"&&(i=r(i)),Pg.set(n,i))),i}cached(e,n,r){const i=Lg(e);return this.wNAF(i,this.getPrecomputes(i,e,r),n)}unsafe(e,n,r,i){const o=Lg(e);return o===1?this._unsafeLadder(e,n,i):this.wNAFUnsafe(o,this.getPrecomputes(o,e,r),n,i)}createCache(e,n){ew(n,this.bits),nw.set(e,n),Pg.delete(e)}hasCache(e){return Lg(e)!==1}}function o$(t,e,n,r){let i=e,o=t.ZERO,s=t.ZERO;for(;n>$s||r>$s;)n&Bo&&(o=o.add(i)),r&Bo&&(s=s.add(i)),i=i.double(),n>>=Bo,r>>=Bo;return{p1:o,p2:s}}function ow(t,e,n,r){r$(n,t),i$(r,e);const i=n.length,o=r.length;if(i!==o)throw new Error("arrays of points and scalars must have equal length");const s=t.ZERO,a=$1(BigInt(i));let l=1;a>12?l=a-3:a>4?l=a-2:a>0&&(l=2);const c=yl(l),u=new Array(Number(c)+1).fill(s),h=Math.floor((e.BITS-1)/l)*l;let p=s;for(let g=h;g>=0;g-=l){u.fill(s);for(let m=0;m<o;m++){const x=r[m],I=Number(x>>BigInt(g)&c);u[I]=u[I].add(n[m])}let b=s;for(let m=u.length-1,x=s;m>0;m--)x=x.add(u[m]),b=b.add(x);if(p=p.add(b),g!==0)for(let m=0;m<l;m++)p=p.double()}return p}function sw(t,e,n){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return e$(e),e}else return Mo(t,{isLE:n})}function aw(t,e,n={},r){if(r===void 0&&(r=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);for(const l of["p","n","h"]){const c=e[l];if(!(typeof c=="bigint"&&c>$s))throw new Error(`CURVE.${l} must be positive bigint`)}const i=sw(e.p,n.Fp,r),o=sw(e.n,n.Fn,r),a=["Gx","Gy","a",t==="weierstrass"?"b":"d"];for(const l of a)if(!i.isValid(e[l]))throw new Error(`CURVE.${l} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:i,Fn:o}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Qi=BigInt(0),sn=BigInt(1),Mg=BigInt(2),s$=BigInt(8);function a$(t,e,n,r){const i=t.sqr(n),o=t.sqr(r),s=t.add(t.mul(e.a,i),o),a=t.add(t.ONE,t.mul(e.d,t.mul(i,o)));return t.eql(s,a)}function l$(t,e={}){const n=aw("edwards",t,e,e.FpFnLE),{Fp:r,Fn:i}=n;let o=n.CURVE;const{h:s}=o;bl(e,{},{uvRatio:"function"});const a=Mg<<BigInt(i.BYTES*8)-sn,l=x=>r.create(x),c=e.uvRatio||((x,I)=>{try{return{isValid:!0,value:r.sqrt(r.div(x,I))}}catch(N){return{isValid:!1,value:Qi}}});if(!a$(r,o,o.Gx,o.Gy))throw new Error("bad curve params: generator point");function u(x,I,N=!1){const T=N?sn:Qi;return Tg("coordinate "+x,I,T,a),I}function h(x){if(!(x instanceof b))throw new Error("ExtendedPoint expected")}const p=Fu((x,I)=>{const{X:N,Y:T,Z:$}=x,B=x.is0();I==null&&(I=B?s$:r.inv($));const G=l(N*I),Z=l(T*I),Y=r.mul($,I);if(B)return{x:Qi,y:sn};if(Y!==sn)throw new Error("invZ was invalid");return{x:G,y:Z}}),g=Fu(x=>{const{a:I,d:N}=o;if(x.is0())throw new Error("bad point: ZERO");const{X:T,Y:$,Z:B,T:G}=x,Z=l(T*T),Y=l($*$),F=l(B*B),V=l(F*F),U=l(Z*I),W=l(F*l(U+Y)),A=l(V+l(N*l(Z*Y)));if(W!==A)throw new Error("bad point: equation left != right (1)");const d=l(T*$),y=l(B*G);if(d!==y)throw new Error("bad point: equation left != right (2)");return!0});class b{constructor(I,N,T,$){this.X=u("x",I),this.Y=u("y",N),this.Z=u("z",T,!0),this.T=u("t",$),Object.freeze(this)}static CURVE(){return o}static fromAffine(I){if(I instanceof b)throw new Error("extended point not allowed");const{x:N,y:T}=I||{};return u("x",N),u("y",T),new b(N,T,sn,l(N*T))}static fromBytes(I,N=!1){const T=r.BYTES,{a:$,d:B}=o;I=V1(Rr(I,T,"point")),Po(N,"zip215");const G=V1(I),Z=I[T-1];G[T-1]=Z&-129;const Y=vl(G),F=N?a:r.ORDER;Tg("point.y",Y,Qi,F);const V=l(Y*Y),U=l(V-sn),W=l(B*V-$);let{isValid:A,value:d}=c(U,W);if(!A)throw new Error("bad point: invalid y coordinate");const y=(d&sn)===sn,S=(Z&128)!==0;if(!N&&d===Qi&&S)throw new Error("bad point: x=0 and x_0=1");return S!==y&&(d=l(-d)),b.fromAffine({x:d,y:Y})}static fromHex(I,N=!1){return b.fromBytes(xt("point",I),N)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(I=8,N=!0){return m.createCache(this,I),N||this.multiply(Mg),this}assertValidity(){g(this)}equals(I){h(I);const{X:N,Y:T,Z:$}=this,{X:B,Y:G,Z}=I,Y=l(N*Z),F=l(B*$),V=l(T*Z),U=l(G*$);return Y===F&&V===U}is0(){return this.equals(b.ZERO)}negate(){return new b(l(-this.X),this.Y,this.Z,l(-this.T))}double(){const{a:I}=o,{X:N,Y:T,Z:$}=this,B=l(N*N),G=l(T*T),Z=l(Mg*l($*$)),Y=l(I*B),F=N+T,V=l(l(F*F)-B-G),U=Y+G,W=U-Z,A=Y-G,d=l(V*W),y=l(U*A),S=l(V*A),C=l(W*U);return new b(d,y,C,S)}add(I){h(I);const{a:N,d:T}=o,{X:$,Y:B,Z:G,T:Z}=this,{X:Y,Y:F,Z:V,T:U}=I,W=l($*Y),A=l(B*F),d=l(Z*T*U),y=l(G*V),S=l(($+B)*(Y+F)-W-A),C=y-d,R=y+d,D=l(A-N*W),L=l(S*C),O=l(R*D),f=l(S*D),v=l(C*R);return new b(L,O,v,f)}subtract(I){return this.add(I.negate())}multiply(I){if(!i.isValidNot0(I))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:N,f:T}=m.cached(this,I,$=>Fo(b,$));return Fo(b,[N,T])[0]}multiplyUnsafe(I,N=b.ZERO){if(!i.isValid(I))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return I===Qi?b.ZERO:this.is0()||I===sn?this:m.unsafe(this,I,T=>Fo(b,T),N)}isSmallOrder(){return this.multiplyUnsafe(s).is0()}isTorsionFree(){return m.unsafe(this,o.n).is0()}toAffine(I){return p(this,I)}clearCofactor(){return s===sn?this:this.multiplyUnsafe(s)}toBytes(){const{x:I,y:N}=this.toAffine(),T=r.toBytes(N);return T[T.length-1]|=I&sn?128:0,T}toHex(){return To(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(I){return Fo(b,I)}static msm(I,N){return ow(b,i,I,N)}_setWindowSize(I){this.precompute(I)}toRawBytes(){return this.toBytes()}}b.BASE=new b(o.Gx,o.Gy,sn,l(o.Gx*o.Gy)),b.ZERO=new b(Qi,sn,sn,Qi),b.Fp=r,b.Fn=i;const m=new iw(b,i.BITS);return b.BASE.precompute(8),b}function c$(t,e,n={}){if(typeof e!="function")throw new Error('"hash" function param is required');bl(n,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:r}=n,{BASE:i,Fp:o,Fn:s}=t,a=n.randomBytes||ig,l=n.adjustScalarBytes||(F=>F),c=n.domain||((F,V,U)=>{if(Po(U,"phflag"),V.length||U)throw new Error("Contexts/pre-hash are not supported");return F});function u(F){return s.create(vl(F))}function h(F){const V=T.secretKey;F=xt("private key",F,V);const U=xt("hashed private key",e(F),2*V),W=l(U.slice(0,V)),A=U.slice(V,2*V),d=u(W);return{head:W,prefix:A,scalar:d}}function p(F){const{head:V,prefix:U,scalar:W}=h(F),A=i.multiply(W),d=A.toBytes();return{head:V,prefix:U,scalar:W,point:A,pointBytes:d}}function g(F){return p(F).pointBytes}function b(F=Uint8Array.of(),...V){const U=Yr(...V);return u(e(c(U,xt("context",F),!!r)))}function m(F,V,U={}){F=xt("message",F),r&&(F=r(F));const{prefix:W,scalar:A,pointBytes:d}=p(V),y=b(U.context,W,F),S=i.multiply(y).toBytes(),C=b(U.context,S,d,F),R=s.create(y+C*A);if(!s.isValid(R))throw new Error("sign failed: invalid s");const D=Yr(S,s.toBytes(R));return Rr(D,T.signature,"result")}const x={zip215:!0};function I(F,V,U,W=x){const{context:A,zip215:d}=W,y=T.signature;F=xt("signature",F,y),V=xt("message",V),U=xt("publicKey",U,T.publicKey),d!==void 0&&Po(d,"zip215"),r&&(V=r(V));const S=y/2,C=F.subarray(0,S),R=vl(F.subarray(S,y));let D,L,O;try{D=t.fromBytes(U,d),L=t.fromBytes(C,d),O=i.multiplyUnsafe(R)}catch(k){return!1}if(!d&&D.isSmallOrder())return!1;const f=b(A,L.toBytes(),D.toBytes(),V);return L.add(D.multiplyUnsafe(f)).subtract(O).clearCofactor().is0()}const N=o.BYTES,T={secretKey:N,publicKey:N,signature:2*N,seed:N};function $(F=a(T.seed)){return Rr(F,T.seed,"seed")}function B(F){const V=Y.randomSecretKey(F);return{secretKey:V,publicKey:g(V)}}function G(F){return il(F)&&F.length===s.BYTES}function Z(F,V){try{return!!t.fromBytes(F,V)}catch(U){return!1}}const Y={getExtendedPublicKey:p,randomSecretKey:$,isValidSecretKey:G,isValidPublicKey:Z,toMontgomery(F){const{y:V}=t.fromBytes(F),U=T.publicKey,W=U===32;if(!W&&U!==57)throw new Error("only defined for 25519 and 448");const A=W?o.div(sn+V,sn-V):o.div(V-sn,V+sn);return o.toBytes(A)},toMontgomerySecret(F){const V=T.secretKey;Rr(F,V);const U=e(F.subarray(0,V));return l(U).subarray(0,V)},randomPrivateKey:$,precompute(F=8,V=t.BASE){return V.precompute(F,!1)}};return Object.freeze({keygen:B,getPublicKey:g,sign:m,verify:I,utils:Y,Point:t,lengths:T})}function u$(t){const e={a:t.a,d:t.d,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},n=t.Fp,r=Mo(e.n,t.nBitLength,!0),i={Fp:n,Fn:r,uvRatio:t.uvRatio},o={randomBytes:t.randomBytes,adjustScalarBytes:t.adjustScalarBytes,domain:t.domain,prehash:t.prehash,mapToCurve:t.mapToCurve};return{CURVE:e,curveOpts:i,hash:t.hash,eddsaOpts:o}}function d$(t,e){const n=e.Point;return Object.assign({},e,{ExtendedPoint:n,CURVE:t,nBitLength:n.Fn.BITS,nByteLength:n.Fn.BYTES})}function h$(t){const{CURVE:e,curveOpts:n,hash:r,eddsaOpts:i}=u$(t),o=l$(e,n),s=c$(o,r,i);return d$(t,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const f$=BigInt(1),lw=BigInt(2);BigInt(3);const g$=BigInt(5),p$=BigInt(8),Bg=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),cw={p:Bg,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:p$,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function m$(t){const e=BigInt(10),n=BigInt(20),r=BigInt(40),i=BigInt(80),o=Bg,a=t*t%o*t%o,l=wt(a,lw,o)*a%o,c=wt(l,f$,o)*t%o,u=wt(c,g$,o)*c%o,h=wt(u,e,o)*u%o,p=wt(h,n,o)*h%o,g=wt(p,r,o)*p%o,b=wt(g,i,o)*g%o,m=wt(b,i,o)*g%o,x=wt(m,e,o)*u%o;return{pow_p_5_8:wt(x,lw,o)*t%o,b2:a}}function v$(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const uw=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function y$(t,e){const n=Bg,r=Lt(e*e*e,n),i=Lt(r*r*e,n),o=m$(t*i).pow_p_5_8;let s=Lt(t*r*o,n);const a=Lt(e*s*s,n),l=s,c=Lt(s*uw,n),u=a===t,h=a===Lt(-t,n),p=a===Lt(-t*uw,n);return u&&(s=l),(h||p)&&(s=c),JV(s,n)&&(s=Lt(-s,n)),{isValid:u||h,value:s}}const b$=Mo(cw.p,{isLE:!0}),_$={...cw,Fp:b$,hash:sD,adjustScalarBytes:v$,uvRatio:y$},_l=h$(_$);var Vu={exports:{}};const x$=ya(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var w$=Vu.exports,dw;function hw(){return dw||(dw=1,(function(t){(function(e,n){function r(A,d){if(!A)throw new Error(d||"Assertion failed")}function i(A,d){A.super_=d;var y=function(){};y.prototype=d.prototype,A.prototype=new y,A.prototype.constructor=A}function o(A,d,y){if(o.isBN(A))return A;this.negative=0,this.words=null,this.length=0,this.red=null,A!==null&&((d==="le"||d==="be")&&(y=d,d=10),this._init(A||0,d||10,y||"be"))}typeof e=="object"?e.exports=o:n.BN=o,o.BN=o,o.wordSize=26;var s;try{typeof window!="undefined"&&typeof window.Buffer!="undefined"?s=window.Buffer:s=x$.Buffer}catch(A){}o.isBN=function(d){return d instanceof o?!0:d!==null&&typeof d=="object"&&d.constructor.wordSize===o.wordSize&&Array.isArray(d.words)},o.max=function(d,y){return d.cmp(y)>0?d:y},o.min=function(d,y){return d.cmp(y)<0?d:y},o.prototype._init=function(d,y,S){if(typeof d=="number")return this._initNumber(d,y,S);if(typeof d=="object")return this._initArray(d,y,S);y==="hex"&&(y=16),r(y===(y|0)&&y>=2&&y<=36),d=d.toString().replace(/\s+/g,"");var C=0;d[0]==="-"&&(C++,this.negative=1),C<d.length&&(y===16?this._parseHex(d,C,S):(this._parseBase(d,y,C),S==="le"&&this._initArray(this.toArray(),y,S)))},o.prototype._initNumber=function(d,y,S){d<0&&(this.negative=1,d=-d),d<67108864?(this.words=[d&67108863],this.length=1):d<4503599627370496?(this.words=[d&67108863,d/67108864&67108863],this.length=2):(r(d<9007199254740992),this.words=[d&67108863,d/67108864&67108863,1],this.length=3),S==="le"&&this._initArray(this.toArray(),y,S)},o.prototype._initArray=function(d,y,S){if(r(typeof d.length=="number"),d.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(d.length/3),this.words=new Array(this.length);for(var C=0;C<this.length;C++)this.words[C]=0;var R,D,L=0;if(S==="be")for(C=d.length-1,R=0;C>=0;C-=3)D=d[C]|d[C-1]<<8|d[C-2]<<16,this.words[R]|=D<<L&67108863,this.words[R+1]=D>>>26-L&67108863,L+=24,L>=26&&(L-=26,R++);else if(S==="le")for(C=0,R=0;C<d.length;C+=3)D=d[C]|d[C+1]<<8|d[C+2]<<16,this.words[R]|=D<<L&67108863,this.words[R+1]=D>>>26-L&67108863,L+=24,L>=26&&(L-=26,R++);return this._strip()};function a(A,d){var y=A.charCodeAt(d);if(y>=48&&y<=57)return y-48;if(y>=65&&y<=70)return y-55;if(y>=97&&y<=102)return y-87;r(!1,"Invalid character in "+A)}function l(A,d,y){var S=a(A,y);return y-1>=d&&(S|=a(A,y-1)<<4),S}o.prototype._parseHex=function(d,y,S){this.length=Math.ceil((d.length-y)/6),this.words=new Array(this.length);for(var C=0;C<this.length;C++)this.words[C]=0;var R=0,D=0,L;if(S==="be")for(C=d.length-1;C>=y;C-=2)L=l(d,y,C)<<R,this.words[D]|=L&67108863,R>=18?(R-=18,D+=1,this.words[D]|=L>>>26):R+=8;else{var O=d.length-y;for(C=O%2===0?y+1:y;C<d.length;C+=2)L=l(d,y,C)<<R,this.words[D]|=L&67108863,R>=18?(R-=18,D+=1,this.words[D]|=L>>>26):R+=8}this._strip()};function c(A,d,y,S){for(var C=0,R=0,D=Math.min(A.length,y),L=d;L<D;L++){var O=A.charCodeAt(L)-48;C*=S,O>=49?R=O-49+10:O>=17?R=O-17+10:R=O,r(O>=0&&R<S,"Invalid character"),C+=R}return C}o.prototype._parseBase=function(d,y,S){this.words=[0],this.length=1;for(var C=0,R=1;R<=67108863;R*=y)C++;C--,R=R/y|0;for(var D=d.length-S,L=D%C,O=Math.min(D,D-L)+S,f=0,v=S;v<O;v+=C)f=c(d,v,v+C,y),this.imuln(R),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f);if(L!==0){var k=1;for(f=c(d,v,d.length,y),v=0;v<L;v++)k*=y;this.imuln(k),this.words[0]+f<67108864?this.words[0]+=f:this._iaddn(f)}this._strip()},o.prototype.copy=function(d){d.words=new Array(this.length);for(var y=0;y<this.length;y++)d.words[y]=this.words[y];d.length=this.length,d.negative=this.negative,d.red=this.red};function u(A,d){A.words=d.words,A.length=d.length,A.negative=d.negative,A.red=d.red}if(o.prototype._move=function(d){u(d,this)},o.prototype.clone=function(){var d=new o(null);return this.copy(d),d},o.prototype._expand=function(d){for(;this.length<d;)this.words[this.length++]=0;return this},o.prototype._strip=function(){for(;this.length>1&&this.words[this.length-1]===0;)this.length--;return this._normSign()},o.prototype._normSign=function(){return this.length===1&&this.words[0]===0&&(this.negative=0),this},typeof Symbol!="undefined"&&typeof Symbol.for=="function")try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=h}catch(A){o.prototype.inspect=h}else o.prototype.inspect=h;function h(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var p=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],g=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],b=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];o.prototype.toString=function(d,y){d=d||10,y=y|0||1;var S;if(d===16||d==="hex"){S="";for(var C=0,R=0,D=0;D<this.length;D++){var L=this.words[D],O=((L<<C|R)&16777215).toString(16);R=L>>>24-C&16777215,C+=2,C>=26&&(C-=26,D--),R!==0||D!==this.length-1?S=p[6-O.length]+O+S:S=O+S}for(R!==0&&(S=R.toString(16)+S);S.length%y!==0;)S="0"+S;return this.negative!==0&&(S="-"+S),S}if(d===(d|0)&&d>=2&&d<=36){var f=g[d],v=b[d];S="";var k=this.clone();for(k.negative=0;!k.isZero();){var M=k.modrn(v).toString(d);k=k.idivn(v),k.isZero()?S=M+S:S=p[f-M.length]+M+S}for(this.isZero()&&(S="0"+S);S.length%y!==0;)S="0"+S;return this.negative!==0&&(S="-"+S),S}r(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var d=this.words[0];return this.length===2?d+=this.words[1]*67108864:this.length===3&&this.words[2]===1?d+=4503599627370496+this.words[1]*67108864:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),this.negative!==0?-d:d},o.prototype.toJSON=function(){return this.toString(16,2)},s&&(o.prototype.toBuffer=function(d,y){return this.toArrayLike(s,d,y)}),o.prototype.toArray=function(d,y){return this.toArrayLike(Array,d,y)};var m=function(d,y){return d.allocUnsafe?d.allocUnsafe(y):new d(y)};o.prototype.toArrayLike=function(d,y,S){this._strip();var C=this.byteLength(),R=S||Math.max(1,C);r(C<=R,"byte array longer than desired length"),r(R>0,"Requested array length <= 0");var D=m(d,R),L=y==="le"?"LE":"BE";return this["_toArrayLike"+L](D,C),D},o.prototype._toArrayLikeLE=function(d,y){for(var S=0,C=0,R=0,D=0;R<this.length;R++){var L=this.words[R]<<D|C;d[S++]=L&255,S<d.length&&(d[S++]=L>>8&255),S<d.length&&(d[S++]=L>>16&255),D===6?(S<d.length&&(d[S++]=L>>24&255),C=0,D=0):(C=L>>>24,D+=2)}if(S<d.length)for(d[S++]=C;S<d.length;)d[S++]=0},o.prototype._toArrayLikeBE=function(d,y){for(var S=d.length-1,C=0,R=0,D=0;R<this.length;R++){var L=this.words[R]<<D|C;d[S--]=L&255,S>=0&&(d[S--]=L>>8&255),S>=0&&(d[S--]=L>>16&255),D===6?(S>=0&&(d[S--]=L>>24&255),C=0,D=0):(C=L>>>24,D+=2)}if(S>=0)for(d[S--]=C;S>=0;)d[S--]=0},Math.clz32?o.prototype._countBits=function(d){return 32-Math.clz32(d)}:o.prototype._countBits=function(d){var y=d,S=0;return y>=4096&&(S+=13,y>>>=13),y>=64&&(S+=7,y>>>=7),y>=8&&(S+=4,y>>>=4),y>=2&&(S+=2,y>>>=2),S+y},o.prototype._zeroBits=function(d){if(d===0)return 26;var y=d,S=0;return(y&8191)===0&&(S+=13,y>>>=13),(y&127)===0&&(S+=7,y>>>=7),(y&15)===0&&(S+=4,y>>>=4),(y&3)===0&&(S+=2,y>>>=2),(y&1)===0&&S++,S},o.prototype.bitLength=function(){var d=this.words[this.length-1],y=this._countBits(d);return(this.length-1)*26+y};function x(A){for(var d=new Array(A.bitLength()),y=0;y<d.length;y++){var S=y/26|0,C=y%26;d[y]=A.words[S]>>>C&1}return d}o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var d=0,y=0;y<this.length;y++){var S=this._zeroBits(this.words[y]);if(d+=S,S!==26)break}return d},o.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},o.prototype.toTwos=function(d){return this.negative!==0?this.abs().inotn(d).iaddn(1):this.clone()},o.prototype.fromTwos=function(d){return this.testn(d-1)?this.notn(d).iaddn(1).ineg():this.clone()},o.prototype.isNeg=function(){return this.negative!==0},o.prototype.neg=function(){return this.clone().ineg()},o.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},o.prototype.iuor=function(d){for(;this.length<d.length;)this.words[this.length++]=0;for(var y=0;y<d.length;y++)this.words[y]=this.words[y]|d.words[y];return this._strip()},o.prototype.ior=function(d){return r((this.negative|d.negative)===0),this.iuor(d)},o.prototype.or=function(d){return this.length>d.length?this.clone().ior(d):d.clone().ior(this)},o.prototype.uor=function(d){return this.length>d.length?this.clone().iuor(d):d.clone().iuor(this)},o.prototype.iuand=function(d){var y;this.length>d.length?y=d:y=this;for(var S=0;S<y.length;S++)this.words[S]=this.words[S]&d.words[S];return this.length=y.length,this._strip()},o.prototype.iand=function(d){return r((this.negative|d.negative)===0),this.iuand(d)},o.prototype.and=function(d){return this.length>d.length?this.clone().iand(d):d.clone().iand(this)},o.prototype.uand=function(d){return this.length>d.length?this.clone().iuand(d):d.clone().iuand(this)},o.prototype.iuxor=function(d){var y,S;this.length>d.length?(y=this,S=d):(y=d,S=this);for(var C=0;C<S.length;C++)this.words[C]=y.words[C]^S.words[C];if(this!==y)for(;C<y.length;C++)this.words[C]=y.words[C];return this.length=y.length,this._strip()},o.prototype.ixor=function(d){return r((this.negative|d.negative)===0),this.iuxor(d)},o.prototype.xor=function(d){return this.length>d.length?this.clone().ixor(d):d.clone().ixor(this)},o.prototype.uxor=function(d){return this.length>d.length?this.clone().iuxor(d):d.clone().iuxor(this)},o.prototype.inotn=function(d){r(typeof d=="number"&&d>=0);var y=Math.ceil(d/26)|0,S=d%26;this._expand(y),S>0&&y--;for(var C=0;C<y;C++)this.words[C]=~this.words[C]&67108863;return S>0&&(this.words[C]=~this.words[C]&67108863>>26-S),this._strip()},o.prototype.notn=function(d){return this.clone().inotn(d)},o.prototype.setn=function(d,y){r(typeof d=="number"&&d>=0);var S=d/26|0,C=d%26;return this._expand(S+1),y?this.words[S]=this.words[S]|1<<C:this.words[S]=this.words[S]&~(1<<C),this._strip()},o.prototype.iadd=function(d){var y;if(this.negative!==0&&d.negative===0)return this.negative=0,y=this.isub(d),this.negative^=1,this._normSign();if(this.negative===0&&d.negative!==0)return d.negative=0,y=this.isub(d),d.negative=1,y._normSign();var S,C;this.length>d.length?(S=this,C=d):(S=d,C=this);for(var R=0,D=0;D<C.length;D++)y=(S.words[D]|0)+(C.words[D]|0)+R,this.words[D]=y&67108863,R=y>>>26;for(;R!==0&&D<S.length;D++)y=(S.words[D]|0)+R,this.words[D]=y&67108863,R=y>>>26;if(this.length=S.length,R!==0)this.words[this.length]=R,this.length++;else if(S!==this)for(;D<S.length;D++)this.words[D]=S.words[D];return this},o.prototype.add=function(d){var y;return d.negative!==0&&this.negative===0?(d.negative=0,y=this.sub(d),d.negative^=1,y):d.negative===0&&this.negative!==0?(this.negative=0,y=d.sub(this),this.negative=1,y):this.length>d.length?this.clone().iadd(d):d.clone().iadd(this)},o.prototype.isub=function(d){if(d.negative!==0){d.negative=0;var y=this.iadd(d);return d.negative=1,y._normSign()}else if(this.negative!==0)return this.negative=0,this.iadd(d),this.negative=1,this._normSign();var S=this.cmp(d);if(S===0)return this.negative=0,this.length=1,this.words[0]=0,this;var C,R;S>0?(C=this,R=d):(C=d,R=this);for(var D=0,L=0;L<R.length;L++)y=(C.words[L]|0)-(R.words[L]|0)+D,D=y>>26,this.words[L]=y&67108863;for(;D!==0&&L<C.length;L++)y=(C.words[L]|0)+D,D=y>>26,this.words[L]=y&67108863;if(D===0&&L<C.length&&C!==this)for(;L<C.length;L++)this.words[L]=C.words[L];return this.length=Math.max(this.length,L),C!==this&&(this.negative=1),this._strip()},o.prototype.sub=function(d){return this.clone().isub(d)};function I(A,d,y){y.negative=d.negative^A.negative;var S=A.length+d.length|0;y.length=S,S=S-1|0;var C=A.words[0]|0,R=d.words[0]|0,D=C*R,L=D&67108863,O=D/67108864|0;y.words[0]=L;for(var f=1;f<S;f++){for(var v=O>>>26,k=O&67108863,M=Math.min(f,d.length-1),H=Math.max(0,f-A.length+1);H<=M;H++){var Q=f-H|0;C=A.words[Q]|0,R=d.words[H]|0,D=C*R+k,v+=D/67108864|0,k=D&67108863}y.words[f]=k|0,O=v|0}return O!==0?y.words[f]=O|0:y.length--,y._strip()}var N=function(d,y,S){var C=d.words,R=y.words,D=S.words,L=0,O,f,v,k=C[0]|0,M=k&8191,H=k>>>13,Q=C[1]|0,X=Q&8191,j=Q>>>13,ee=C[2]|0,se=ee&8191,re=ee>>>13,ve=C[3]|0,xe=ve&8191,Pe=ve>>>13,Et=C[4]|0,He=Et&8191,ot=Et>>>13,ri=C[5]|0,nt=ri&8191,Qe=ri>>>13,ln=C[6]|0,st=ln&8191,ht=ln>>>13,Mr=C[7]|0,St=Mr&8191,P=Mr>>>13,_=C[8]|0,E=_&8191,z=_>>>13,J=C[9]|0,te=J&8191,ae=J>>>13,De=R[0]|0,Be=De&8191,Le=De>>>13,gt=R[1]|0,Ne=gt&8191,Ft=gt>>>13,uA=R[2]|0,Dt=uA&8191,Vt=uA>>>13,dA=R[3]|0,$t=dA&8191,zt=dA>>>13,hA=R[4]|0,Ut=hA&8191,Wt=hA>>>13,fA=R[5]|0,Ht=fA&8191,jt=fA>>>13,gA=R[6]|0,qt=gA&8191,Gt=gA>>>13,pA=R[7]|0,Kt=pA&8191,Yt=pA>>>13,mA=R[8]|0,Xt=mA&8191,Zt=mA>>>13,vA=R[9]|0,Jt=vA&8191,Qt=vA>>>13;S.negative=d.negative^y.negative,S.length=19,O=Math.imul(M,Be),f=Math.imul(M,Le),f=f+Math.imul(H,Be)|0,v=Math.imul(H,Le);var wm=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(wm>>>26)|0,wm&=67108863,O=Math.imul(X,Be),f=Math.imul(X,Le),f=f+Math.imul(j,Be)|0,v=Math.imul(j,Le),O=O+Math.imul(M,Ne)|0,f=f+Math.imul(M,Ft)|0,f=f+Math.imul(H,Ne)|0,v=v+Math.imul(H,Ft)|0;var Em=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Em>>>26)|0,Em&=67108863,O=Math.imul(se,Be),f=Math.imul(se,Le),f=f+Math.imul(re,Be)|0,v=Math.imul(re,Le),O=O+Math.imul(X,Ne)|0,f=f+Math.imul(X,Ft)|0,f=f+Math.imul(j,Ne)|0,v=v+Math.imul(j,Ft)|0,O=O+Math.imul(M,Dt)|0,f=f+Math.imul(M,Vt)|0,f=f+Math.imul(H,Dt)|0,v=v+Math.imul(H,Vt)|0;var Sm=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Sm>>>26)|0,Sm&=67108863,O=Math.imul(xe,Be),f=Math.imul(xe,Le),f=f+Math.imul(Pe,Be)|0,v=Math.imul(Pe,Le),O=O+Math.imul(se,Ne)|0,f=f+Math.imul(se,Ft)|0,f=f+Math.imul(re,Ne)|0,v=v+Math.imul(re,Ft)|0,O=O+Math.imul(X,Dt)|0,f=f+Math.imul(X,Vt)|0,f=f+Math.imul(j,Dt)|0,v=v+Math.imul(j,Vt)|0,O=O+Math.imul(M,$t)|0,f=f+Math.imul(M,zt)|0,f=f+Math.imul(H,$t)|0,v=v+Math.imul(H,zt)|0;var Im=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Im>>>26)|0,Im&=67108863,O=Math.imul(He,Be),f=Math.imul(He,Le),f=f+Math.imul(ot,Be)|0,v=Math.imul(ot,Le),O=O+Math.imul(xe,Ne)|0,f=f+Math.imul(xe,Ft)|0,f=f+Math.imul(Pe,Ne)|0,v=v+Math.imul(Pe,Ft)|0,O=O+Math.imul(se,Dt)|0,f=f+Math.imul(se,Vt)|0,f=f+Math.imul(re,Dt)|0,v=v+Math.imul(re,Vt)|0,O=O+Math.imul(X,$t)|0,f=f+Math.imul(X,zt)|0,f=f+Math.imul(j,$t)|0,v=v+Math.imul(j,zt)|0,O=O+Math.imul(M,Ut)|0,f=f+Math.imul(M,Wt)|0,f=f+Math.imul(H,Ut)|0,v=v+Math.imul(H,Wt)|0;var Cm=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Cm>>>26)|0,Cm&=67108863,O=Math.imul(nt,Be),f=Math.imul(nt,Le),f=f+Math.imul(Qe,Be)|0,v=Math.imul(Qe,Le),O=O+Math.imul(He,Ne)|0,f=f+Math.imul(He,Ft)|0,f=f+Math.imul(ot,Ne)|0,v=v+Math.imul(ot,Ft)|0,O=O+Math.imul(xe,Dt)|0,f=f+Math.imul(xe,Vt)|0,f=f+Math.imul(Pe,Dt)|0,v=v+Math.imul(Pe,Vt)|0,O=O+Math.imul(se,$t)|0,f=f+Math.imul(se,zt)|0,f=f+Math.imul(re,$t)|0,v=v+Math.imul(re,zt)|0,O=O+Math.imul(X,Ut)|0,f=f+Math.imul(X,Wt)|0,f=f+Math.imul(j,Ut)|0,v=v+Math.imul(j,Wt)|0,O=O+Math.imul(M,Ht)|0,f=f+Math.imul(M,jt)|0,f=f+Math.imul(H,Ht)|0,v=v+Math.imul(H,jt)|0;var Am=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Am>>>26)|0,Am&=67108863,O=Math.imul(st,Be),f=Math.imul(st,Le),f=f+Math.imul(ht,Be)|0,v=Math.imul(ht,Le),O=O+Math.imul(nt,Ne)|0,f=f+Math.imul(nt,Ft)|0,f=f+Math.imul(Qe,Ne)|0,v=v+Math.imul(Qe,Ft)|0,O=O+Math.imul(He,Dt)|0,f=f+Math.imul(He,Vt)|0,f=f+Math.imul(ot,Dt)|0,v=v+Math.imul(ot,Vt)|0,O=O+Math.imul(xe,$t)|0,f=f+Math.imul(xe,zt)|0,f=f+Math.imul(Pe,$t)|0,v=v+Math.imul(Pe,zt)|0,O=O+Math.imul(se,Ut)|0,f=f+Math.imul(se,Wt)|0,f=f+Math.imul(re,Ut)|0,v=v+Math.imul(re,Wt)|0,O=O+Math.imul(X,Ht)|0,f=f+Math.imul(X,jt)|0,f=f+Math.imul(j,Ht)|0,v=v+Math.imul(j,jt)|0,O=O+Math.imul(M,qt)|0,f=f+Math.imul(M,Gt)|0,f=f+Math.imul(H,qt)|0,v=v+Math.imul(H,Gt)|0;var Om=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Om>>>26)|0,Om&=67108863,O=Math.imul(St,Be),f=Math.imul(St,Le),f=f+Math.imul(P,Be)|0,v=Math.imul(P,Le),O=O+Math.imul(st,Ne)|0,f=f+Math.imul(st,Ft)|0,f=f+Math.imul(ht,Ne)|0,v=v+Math.imul(ht,Ft)|0,O=O+Math.imul(nt,Dt)|0,f=f+Math.imul(nt,Vt)|0,f=f+Math.imul(Qe,Dt)|0,v=v+Math.imul(Qe,Vt)|0,O=O+Math.imul(He,$t)|0,f=f+Math.imul(He,zt)|0,f=f+Math.imul(ot,$t)|0,v=v+Math.imul(ot,zt)|0,O=O+Math.imul(xe,Ut)|0,f=f+Math.imul(xe,Wt)|0,f=f+Math.imul(Pe,Ut)|0,v=v+Math.imul(Pe,Wt)|0,O=O+Math.imul(se,Ht)|0,f=f+Math.imul(se,jt)|0,f=f+Math.imul(re,Ht)|0,v=v+Math.imul(re,jt)|0,O=O+Math.imul(X,qt)|0,f=f+Math.imul(X,Gt)|0,f=f+Math.imul(j,qt)|0,v=v+Math.imul(j,Gt)|0,O=O+Math.imul(M,Kt)|0,f=f+Math.imul(M,Yt)|0,f=f+Math.imul(H,Kt)|0,v=v+Math.imul(H,Yt)|0;var km=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(km>>>26)|0,km&=67108863,O=Math.imul(E,Be),f=Math.imul(E,Le),f=f+Math.imul(z,Be)|0,v=Math.imul(z,Le),O=O+Math.imul(St,Ne)|0,f=f+Math.imul(St,Ft)|0,f=f+Math.imul(P,Ne)|0,v=v+Math.imul(P,Ft)|0,O=O+Math.imul(st,Dt)|0,f=f+Math.imul(st,Vt)|0,f=f+Math.imul(ht,Dt)|0,v=v+Math.imul(ht,Vt)|0,O=O+Math.imul(nt,$t)|0,f=f+Math.imul(nt,zt)|0,f=f+Math.imul(Qe,$t)|0,v=v+Math.imul(Qe,zt)|0,O=O+Math.imul(He,Ut)|0,f=f+Math.imul(He,Wt)|0,f=f+Math.imul(ot,Ut)|0,v=v+Math.imul(ot,Wt)|0,O=O+Math.imul(xe,Ht)|0,f=f+Math.imul(xe,jt)|0,f=f+Math.imul(Pe,Ht)|0,v=v+Math.imul(Pe,jt)|0,O=O+Math.imul(se,qt)|0,f=f+Math.imul(se,Gt)|0,f=f+Math.imul(re,qt)|0,v=v+Math.imul(re,Gt)|0,O=O+Math.imul(X,Kt)|0,f=f+Math.imul(X,Yt)|0,f=f+Math.imul(j,Kt)|0,v=v+Math.imul(j,Yt)|0,O=O+Math.imul(M,Xt)|0,f=f+Math.imul(M,Zt)|0,f=f+Math.imul(H,Xt)|0,v=v+Math.imul(H,Zt)|0;var Tm=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Tm>>>26)|0,Tm&=67108863,O=Math.imul(te,Be),f=Math.imul(te,Le),f=f+Math.imul(ae,Be)|0,v=Math.imul(ae,Le),O=O+Math.imul(E,Ne)|0,f=f+Math.imul(E,Ft)|0,f=f+Math.imul(z,Ne)|0,v=v+Math.imul(z,Ft)|0,O=O+Math.imul(St,Dt)|0,f=f+Math.imul(St,Vt)|0,f=f+Math.imul(P,Dt)|0,v=v+Math.imul(P,Vt)|0,O=O+Math.imul(st,$t)|0,f=f+Math.imul(st,zt)|0,f=f+Math.imul(ht,$t)|0,v=v+Math.imul(ht,zt)|0,O=O+Math.imul(nt,Ut)|0,f=f+Math.imul(nt,Wt)|0,f=f+Math.imul(Qe,Ut)|0,v=v+Math.imul(Qe,Wt)|0,O=O+Math.imul(He,Ht)|0,f=f+Math.imul(He,jt)|0,f=f+Math.imul(ot,Ht)|0,v=v+Math.imul(ot,jt)|0,O=O+Math.imul(xe,qt)|0,f=f+Math.imul(xe,Gt)|0,f=f+Math.imul(Pe,qt)|0,v=v+Math.imul(Pe,Gt)|0,O=O+Math.imul(se,Kt)|0,f=f+Math.imul(se,Yt)|0,f=f+Math.imul(re,Kt)|0,v=v+Math.imul(re,Yt)|0,O=O+Math.imul(X,Xt)|0,f=f+Math.imul(X,Zt)|0,f=f+Math.imul(j,Xt)|0,v=v+Math.imul(j,Zt)|0,O=O+Math.imul(M,Jt)|0,f=f+Math.imul(M,Qt)|0,f=f+Math.imul(H,Jt)|0,v=v+Math.imul(H,Qt)|0;var Rm=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Rm>>>26)|0,Rm&=67108863,O=Math.imul(te,Ne),f=Math.imul(te,Ft),f=f+Math.imul(ae,Ne)|0,v=Math.imul(ae,Ft),O=O+Math.imul(E,Dt)|0,f=f+Math.imul(E,Vt)|0,f=f+Math.imul(z,Dt)|0,v=v+Math.imul(z,Vt)|0,O=O+Math.imul(St,$t)|0,f=f+Math.imul(St,zt)|0,f=f+Math.imul(P,$t)|0,v=v+Math.imul(P,zt)|0,O=O+Math.imul(st,Ut)|0,f=f+Math.imul(st,Wt)|0,f=f+Math.imul(ht,Ut)|0,v=v+Math.imul(ht,Wt)|0,O=O+Math.imul(nt,Ht)|0,f=f+Math.imul(nt,jt)|0,f=f+Math.imul(Qe,Ht)|0,v=v+Math.imul(Qe,jt)|0,O=O+Math.imul(He,qt)|0,f=f+Math.imul(He,Gt)|0,f=f+Math.imul(ot,qt)|0,v=v+Math.imul(ot,Gt)|0,O=O+Math.imul(xe,Kt)|0,f=f+Math.imul(xe,Yt)|0,f=f+Math.imul(Pe,Kt)|0,v=v+Math.imul(Pe,Yt)|0,O=O+Math.imul(se,Xt)|0,f=f+Math.imul(se,Zt)|0,f=f+Math.imul(re,Xt)|0,v=v+Math.imul(re,Zt)|0,O=O+Math.imul(X,Jt)|0,f=f+Math.imul(X,Qt)|0,f=f+Math.imul(j,Jt)|0,v=v+Math.imul(j,Qt)|0;var Nm=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Nm>>>26)|0,Nm&=67108863,O=Math.imul(te,Dt),f=Math.imul(te,Vt),f=f+Math.imul(ae,Dt)|0,v=Math.imul(ae,Vt),O=O+Math.imul(E,$t)|0,f=f+Math.imul(E,zt)|0,f=f+Math.imul(z,$t)|0,v=v+Math.imul(z,zt)|0,O=O+Math.imul(St,Ut)|0,f=f+Math.imul(St,Wt)|0,f=f+Math.imul(P,Ut)|0,v=v+Math.imul(P,Wt)|0,O=O+Math.imul(st,Ht)|0,f=f+Math.imul(st,jt)|0,f=f+Math.imul(ht,Ht)|0,v=v+Math.imul(ht,jt)|0,O=O+Math.imul(nt,qt)|0,f=f+Math.imul(nt,Gt)|0,f=f+Math.imul(Qe,qt)|0,v=v+Math.imul(Qe,Gt)|0,O=O+Math.imul(He,Kt)|0,f=f+Math.imul(He,Yt)|0,f=f+Math.imul(ot,Kt)|0,v=v+Math.imul(ot,Yt)|0,O=O+Math.imul(xe,Xt)|0,f=f+Math.imul(xe,Zt)|0,f=f+Math.imul(Pe,Xt)|0,v=v+Math.imul(Pe,Zt)|0,O=O+Math.imul(se,Jt)|0,f=f+Math.imul(se,Qt)|0,f=f+Math.imul(re,Jt)|0,v=v+Math.imul(re,Qt)|0;var Pm=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Pm>>>26)|0,Pm&=67108863,O=Math.imul(te,$t),f=Math.imul(te,zt),f=f+Math.imul(ae,$t)|0,v=Math.imul(ae,zt),O=O+Math.imul(E,Ut)|0,f=f+Math.imul(E,Wt)|0,f=f+Math.imul(z,Ut)|0,v=v+Math.imul(z,Wt)|0,O=O+Math.imul(St,Ht)|0,f=f+Math.imul(St,jt)|0,f=f+Math.imul(P,Ht)|0,v=v+Math.imul(P,jt)|0,O=O+Math.imul(st,qt)|0,f=f+Math.imul(st,Gt)|0,f=f+Math.imul(ht,qt)|0,v=v+Math.imul(ht,Gt)|0,O=O+Math.imul(nt,Kt)|0,f=f+Math.imul(nt,Yt)|0,f=f+Math.imul(Qe,Kt)|0,v=v+Math.imul(Qe,Yt)|0,O=O+Math.imul(He,Xt)|0,f=f+Math.imul(He,Zt)|0,f=f+Math.imul(ot,Xt)|0,v=v+Math.imul(ot,Zt)|0,O=O+Math.imul(xe,Jt)|0,f=f+Math.imul(xe,Qt)|0,f=f+Math.imul(Pe,Jt)|0,v=v+Math.imul(Pe,Qt)|0;var Lm=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Lm>>>26)|0,Lm&=67108863,O=Math.imul(te,Ut),f=Math.imul(te,Wt),f=f+Math.imul(ae,Ut)|0,v=Math.imul(ae,Wt),O=O+Math.imul(E,Ht)|0,f=f+Math.imul(E,jt)|0,f=f+Math.imul(z,Ht)|0,v=v+Math.imul(z,jt)|0,O=O+Math.imul(St,qt)|0,f=f+Math.imul(St,Gt)|0,f=f+Math.imul(P,qt)|0,v=v+Math.imul(P,Gt)|0,O=O+Math.imul(st,Kt)|0,f=f+Math.imul(st,Yt)|0,f=f+Math.imul(ht,Kt)|0,v=v+Math.imul(ht,Yt)|0,O=O+Math.imul(nt,Xt)|0,f=f+Math.imul(nt,Zt)|0,f=f+Math.imul(Qe,Xt)|0,v=v+Math.imul(Qe,Zt)|0,O=O+Math.imul(He,Jt)|0,f=f+Math.imul(He,Qt)|0,f=f+Math.imul(ot,Jt)|0,v=v+Math.imul(ot,Qt)|0;var Mm=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Mm>>>26)|0,Mm&=67108863,O=Math.imul(te,Ht),f=Math.imul(te,jt),f=f+Math.imul(ae,Ht)|0,v=Math.imul(ae,jt),O=O+Math.imul(E,qt)|0,f=f+Math.imul(E,Gt)|0,f=f+Math.imul(z,qt)|0,v=v+Math.imul(z,Gt)|0,O=O+Math.imul(St,Kt)|0,f=f+Math.imul(St,Yt)|0,f=f+Math.imul(P,Kt)|0,v=v+Math.imul(P,Yt)|0,O=O+Math.imul(st,Xt)|0,f=f+Math.imul(st,Zt)|0,f=f+Math.imul(ht,Xt)|0,v=v+Math.imul(ht,Zt)|0,O=O+Math.imul(nt,Jt)|0,f=f+Math.imul(nt,Qt)|0,f=f+Math.imul(Qe,Jt)|0,v=v+Math.imul(Qe,Qt)|0;var Bm=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Bm>>>26)|0,Bm&=67108863,O=Math.imul(te,qt),f=Math.imul(te,Gt),f=f+Math.imul(ae,qt)|0,v=Math.imul(ae,Gt),O=O+Math.imul(E,Kt)|0,f=f+Math.imul(E,Yt)|0,f=f+Math.imul(z,Kt)|0,v=v+Math.imul(z,Yt)|0,O=O+Math.imul(St,Xt)|0,f=f+Math.imul(St,Zt)|0,f=f+Math.imul(P,Xt)|0,v=v+Math.imul(P,Zt)|0,O=O+Math.imul(st,Jt)|0,f=f+Math.imul(st,Qt)|0,f=f+Math.imul(ht,Jt)|0,v=v+Math.imul(ht,Qt)|0;var Fm=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Fm>>>26)|0,Fm&=67108863,O=Math.imul(te,Kt),f=Math.imul(te,Yt),f=f+Math.imul(ae,Kt)|0,v=Math.imul(ae,Yt),O=O+Math.imul(E,Xt)|0,f=f+Math.imul(E,Zt)|0,f=f+Math.imul(z,Xt)|0,v=v+Math.imul(z,Zt)|0,O=O+Math.imul(St,Jt)|0,f=f+Math.imul(St,Qt)|0,f=f+Math.imul(P,Jt)|0,v=v+Math.imul(P,Qt)|0;var Dm=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Dm>>>26)|0,Dm&=67108863,O=Math.imul(te,Xt),f=Math.imul(te,Zt),f=f+Math.imul(ae,Xt)|0,v=Math.imul(ae,Zt),O=O+Math.imul(E,Jt)|0,f=f+Math.imul(E,Qt)|0,f=f+Math.imul(z,Jt)|0,v=v+Math.imul(z,Qt)|0;var Vm=(L+O|0)+((f&8191)<<13)|0;L=(v+(f>>>13)|0)+(Vm>>>26)|0,Vm&=67108863,O=Math.imul(te,Jt),f=Math.imul(te,Qt),f=f+Math.imul(ae,Jt)|0,v=Math.imul(ae,Qt);var $m=(L+O|0)+((f&8191)<<13)|0;return L=(v+(f>>>13)|0)+($m>>>26)|0,$m&=67108863,D[0]=wm,D[1]=Em,D[2]=Sm,D[3]=Im,D[4]=Cm,D[5]=Am,D[6]=Om,D[7]=km,D[8]=Tm,D[9]=Rm,D[10]=Nm,D[11]=Pm,D[12]=Lm,D[13]=Mm,D[14]=Bm,D[15]=Fm,D[16]=Dm,D[17]=Vm,D[18]=$m,L!==0&&(D[19]=L,S.length++),S};Math.imul||(N=I);function T(A,d,y){y.negative=d.negative^A.negative,y.length=A.length+d.length;for(var S=0,C=0,R=0;R<y.length-1;R++){var D=C;C=0;for(var L=S&67108863,O=Math.min(R,d.length-1),f=Math.max(0,R-A.length+1);f<=O;f++){var v=R-f,k=A.words[v]|0,M=d.words[f]|0,H=k*M,Q=H&67108863;D=D+(H/67108864|0)|0,Q=Q+L|0,L=Q&67108863,D=D+(Q>>>26)|0,C+=D>>>26,D&=67108863}y.words[R]=L,S=D,D=C}return S!==0?y.words[R]=S:y.length--,y._strip()}function $(A,d,y){return T(A,d,y)}o.prototype.mulTo=function(d,y){var S,C=this.length+d.length;return this.length===10&&d.length===10?S=N(this,d,y):C<63?S=I(this,d,y):C<1024?S=T(this,d,y):S=$(this,d,y),S},o.prototype.mul=function(d){var y=new o(null);return y.words=new Array(this.length+d.length),this.mulTo(d,y)},o.prototype.mulf=function(d){var y=new o(null);return y.words=new Array(this.length+d.length),$(this,d,y)},o.prototype.imul=function(d){return this.clone().mulTo(d,this)},o.prototype.imuln=function(d){var y=d<0;y&&(d=-d),r(typeof d=="number"),r(d<67108864);for(var S=0,C=0;C<this.length;C++){var R=(this.words[C]|0)*d,D=(R&67108863)+(S&67108863);S>>=26,S+=R/67108864|0,S+=D>>>26,this.words[C]=D&67108863}return S!==0&&(this.words[C]=S,this.length++),this.length=d===0?1:this.length,y?this.ineg():this},o.prototype.muln=function(d){return this.clone().imuln(d)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(d){var y=x(d);if(y.length===0)return new o(1);for(var S=this,C=0;C<y.length&&y[C]===0;C++,S=S.sqr());if(++C<y.length)for(var R=S.sqr();C<y.length;C++,R=R.sqr())y[C]!==0&&(S=S.mul(R));return S},o.prototype.iushln=function(d){r(typeof d=="number"&&d>=0);var y=d%26,S=(d-y)/26,C=67108863>>>26-y<<26-y,R;if(y!==0){var D=0;for(R=0;R<this.length;R++){var L=this.words[R]&C,O=(this.words[R]|0)-L<<y;this.words[R]=O|D,D=L>>>26-y}D&&(this.words[R]=D,this.length++)}if(S!==0){for(R=this.length-1;R>=0;R--)this.words[R+S]=this.words[R];for(R=0;R<S;R++)this.words[R]=0;this.length+=S}return this._strip()},o.prototype.ishln=function(d){return r(this.negative===0),this.iushln(d)},o.prototype.iushrn=function(d,y,S){r(typeof d=="number"&&d>=0);var C;y?C=(y-y%26)/26:C=0;var R=d%26,D=Math.min((d-R)/26,this.length),L=67108863^67108863>>>R<<R,O=S;if(C-=D,C=Math.max(0,C),O){for(var f=0;f<D;f++)O.words[f]=this.words[f];O.length=D}if(D!==0)if(this.length>D)for(this.length-=D,f=0;f<this.length;f++)this.words[f]=this.words[f+D];else this.words[0]=0,this.length=1;var v=0;for(f=this.length-1;f>=0&&(v!==0||f>=C);f--){var k=this.words[f]|0;this.words[f]=v<<26-R|k>>>R,v=k&L}return O&&v!==0&&(O.words[O.length++]=v),this.length===0&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(d,y,S){return r(this.negative===0),this.iushrn(d,y,S)},o.prototype.shln=function(d){return this.clone().ishln(d)},o.prototype.ushln=function(d){return this.clone().iushln(d)},o.prototype.shrn=function(d){return this.clone().ishrn(d)},o.prototype.ushrn=function(d){return this.clone().iushrn(d)},o.prototype.testn=function(d){r(typeof d=="number"&&d>=0);var y=d%26,S=(d-y)/26,C=1<<y;if(this.length<=S)return!1;var R=this.words[S];return!!(R&C)},o.prototype.imaskn=function(d){r(typeof d=="number"&&d>=0);var y=d%26,S=(d-y)/26;if(r(this.negative===0,"imaskn works only with positive numbers"),this.length<=S)return this;if(y!==0&&S++,this.length=Math.min(S,this.length),y!==0){var C=67108863^67108863>>>y<<y;this.words[this.length-1]&=C}return this._strip()},o.prototype.maskn=function(d){return this.clone().imaskn(d)},o.prototype.iaddn=function(d){return r(typeof d=="number"),r(d<67108864),d<0?this.isubn(-d):this.negative!==0?this.length===1&&(this.words[0]|0)<=d?(this.words[0]=d-(this.words[0]|0),this.negative=0,this):(this.negative=0,this.isubn(d),this.negative=1,this):this._iaddn(d)},o.prototype._iaddn=function(d){this.words[0]+=d;for(var y=0;y<this.length&&this.words[y]>=67108864;y++)this.words[y]-=67108864,y===this.length-1?this.words[y+1]=1:this.words[y+1]++;return this.length=Math.max(this.length,y+1),this},o.prototype.isubn=function(d){if(r(typeof d=="number"),r(d<67108864),d<0)return this.iaddn(-d);if(this.negative!==0)return this.negative=0,this.iaddn(d),this.negative=1,this;if(this.words[0]-=d,this.length===1&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var y=0;y<this.length&&this.words[y]<0;y++)this.words[y]+=67108864,this.words[y+1]-=1;return this._strip()},o.prototype.addn=function(d){return this.clone().iaddn(d)},o.prototype.subn=function(d){return this.clone().isubn(d)},o.prototype.iabs=function(){return this.negative=0,this},o.prototype.abs=function(){return this.clone().iabs()},o.prototype._ishlnsubmul=function(d,y,S){var C=d.length+S,R;this._expand(C);var D,L=0;for(R=0;R<d.length;R++){D=(this.words[R+S]|0)+L;var O=(d.words[R]|0)*y;D-=O&67108863,L=(D>>26)-(O/67108864|0),this.words[R+S]=D&67108863}for(;R<this.length-S;R++)D=(this.words[R+S]|0)+L,L=D>>26,this.words[R+S]=D&67108863;if(L===0)return this._strip();for(r(L===-1),L=0,R=0;R<this.length;R++)D=-(this.words[R]|0)+L,L=D>>26,this.words[R]=D&67108863;return this.negative=1,this._strip()},o.prototype._wordDiv=function(d,y){var S=this.length-d.length,C=this.clone(),R=d,D=R.words[R.length-1]|0,L=this._countBits(D);S=26-L,S!==0&&(R=R.ushln(S),C.iushln(S),D=R.words[R.length-1]|0);var O=C.length-R.length,f;if(y!=="mod"){f=new o(null),f.length=O+1,f.words=new Array(f.length);for(var v=0;v<f.length;v++)f.words[v]=0}var k=C.clone()._ishlnsubmul(R,1,O);k.negative===0&&(C=k,f&&(f.words[O]=1));for(var M=O-1;M>=0;M--){var H=(C.words[R.length+M]|0)*67108864+(C.words[R.length+M-1]|0);for(H=Math.min(H/D|0,67108863),C._ishlnsubmul(R,H,M);C.negative!==0;)H--,C.negative=0,C._ishlnsubmul(R,1,M),C.isZero()||(C.negative^=1);f&&(f.words[M]=H)}return f&&f._strip(),C._strip(),y!=="div"&&S!==0&&C.iushrn(S),{div:f||null,mod:C}},o.prototype.divmod=function(d,y,S){if(r(!d.isZero()),this.isZero())return{div:new o(0),mod:new o(0)};var C,R,D;return this.negative!==0&&d.negative===0?(D=this.neg().divmod(d,y),y!=="mod"&&(C=D.div.neg()),y!=="div"&&(R=D.mod.neg(),S&&R.negative!==0&&R.iadd(d)),{div:C,mod:R}):this.negative===0&&d.negative!==0?(D=this.divmod(d.neg(),y),y!=="mod"&&(C=D.div.neg()),{div:C,mod:D.mod}):(this.negative&d.negative)!==0?(D=this.neg().divmod(d.neg(),y),y!=="div"&&(R=D.mod.neg(),S&&R.negative!==0&&R.isub(d)),{div:D.div,mod:R}):d.length>this.length||this.cmp(d)<0?{div:new o(0),mod:this}:d.length===1?y==="div"?{div:this.divn(d.words[0]),mod:null}:y==="mod"?{div:null,mod:new o(this.modrn(d.words[0]))}:{div:this.divn(d.words[0]),mod:new o(this.modrn(d.words[0]))}:this._wordDiv(d,y)},o.prototype.div=function(d){return this.divmod(d,"div",!1).div},o.prototype.mod=function(d){return this.divmod(d,"mod",!1).mod},o.prototype.umod=function(d){return this.divmod(d,"mod",!0).mod},o.prototype.divRound=function(d){var y=this.divmod(d);if(y.mod.isZero())return y.div;var S=y.div.negative!==0?y.mod.isub(d):y.mod,C=d.ushrn(1),R=d.andln(1),D=S.cmp(C);return D<0||R===1&&D===0?y.div:y.div.negative!==0?y.div.isubn(1):y.div.iaddn(1)},o.prototype.modrn=function(d){var y=d<0;y&&(d=-d),r(d<=67108863);for(var S=(1<<26)%d,C=0,R=this.length-1;R>=0;R--)C=(S*C+(this.words[R]|0))%d;return y?-C:C},o.prototype.modn=function(d){return this.modrn(d)},o.prototype.idivn=function(d){var y=d<0;y&&(d=-d),r(d<=67108863);for(var S=0,C=this.length-1;C>=0;C--){var R=(this.words[C]|0)+S*67108864;this.words[C]=R/d|0,S=R%d}return this._strip(),y?this.ineg():this},o.prototype.divn=function(d){return this.clone().idivn(d)},o.prototype.egcd=function(d){r(d.negative===0),r(!d.isZero());var y=this,S=d.clone();y.negative!==0?y=y.umod(d):y=y.clone();for(var C=new o(1),R=new o(0),D=new o(0),L=new o(1),O=0;y.isEven()&&S.isEven();)y.iushrn(1),S.iushrn(1),++O;for(var f=S.clone(),v=y.clone();!y.isZero();){for(var k=0,M=1;(y.words[0]&M)===0&&k<26;++k,M<<=1);if(k>0)for(y.iushrn(k);k-- >0;)(C.isOdd()||R.isOdd())&&(C.iadd(f),R.isub(v)),C.iushrn(1),R.iushrn(1);for(var H=0,Q=1;(S.words[0]&Q)===0&&H<26;++H,Q<<=1);if(H>0)for(S.iushrn(H);H-- >0;)(D.isOdd()||L.isOdd())&&(D.iadd(f),L.isub(v)),D.iushrn(1),L.iushrn(1);y.cmp(S)>=0?(y.isub(S),C.isub(D),R.isub(L)):(S.isub(y),D.isub(C),L.isub(R))}return{a:D,b:L,gcd:S.iushln(O)}},o.prototype._invmp=function(d){r(d.negative===0),r(!d.isZero());var y=this,S=d.clone();y.negative!==0?y=y.umod(d):y=y.clone();for(var C=new o(1),R=new o(0),D=S.clone();y.cmpn(1)>0&&S.cmpn(1)>0;){for(var L=0,O=1;(y.words[0]&O)===0&&L<26;++L,O<<=1);if(L>0)for(y.iushrn(L);L-- >0;)C.isOdd()&&C.iadd(D),C.iushrn(1);for(var f=0,v=1;(S.words[0]&v)===0&&f<26;++f,v<<=1);if(f>0)for(S.iushrn(f);f-- >0;)R.isOdd()&&R.iadd(D),R.iushrn(1);y.cmp(S)>=0?(y.isub(S),C.isub(R)):(S.isub(y),R.isub(C))}var k;return y.cmpn(1)===0?k=C:k=R,k.cmpn(0)<0&&k.iadd(d),k},o.prototype.gcd=function(d){if(this.isZero())return d.abs();if(d.isZero())return this.abs();var y=this.clone(),S=d.clone();y.negative=0,S.negative=0;for(var C=0;y.isEven()&&S.isEven();C++)y.iushrn(1),S.iushrn(1);do{for(;y.isEven();)y.iushrn(1);for(;S.isEven();)S.iushrn(1);var R=y.cmp(S);if(R<0){var D=y;y=S,S=D}else if(R===0||S.cmpn(1)===0)break;y.isub(S)}while(!0);return S.iushln(C)},o.prototype.invm=function(d){return this.egcd(d).a.umod(d)},o.prototype.isEven=function(){return(this.words[0]&1)===0},o.prototype.isOdd=function(){return(this.words[0]&1)===1},o.prototype.andln=function(d){return this.words[0]&d},o.prototype.bincn=function(d){r(typeof d=="number");var y=d%26,S=(d-y)/26,C=1<<y;if(this.length<=S)return this._expand(S+1),this.words[S]|=C,this;for(var R=C,D=S;R!==0&&D<this.length;D++){var L=this.words[D]|0;L+=R,R=L>>>26,L&=67108863,this.words[D]=L}return R!==0&&(this.words[D]=R,this.length++),this},o.prototype.isZero=function(){return this.length===1&&this.words[0]===0},o.prototype.cmpn=function(d){var y=d<0;if(this.negative!==0&&!y)return-1;if(this.negative===0&&y)return 1;this._strip();var S;if(this.length>1)S=1;else{y&&(d=-d),r(d<=67108863,"Number is too big");var C=this.words[0]|0;S=C===d?0:C<d?-1:1}return this.negative!==0?-S|0:S},o.prototype.cmp=function(d){if(this.negative!==0&&d.negative===0)return-1;if(this.negative===0&&d.negative!==0)return 1;var y=this.ucmp(d);return this.negative!==0?-y|0:y},o.prototype.ucmp=function(d){if(this.length>d.length)return 1;if(this.length<d.length)return-1;for(var y=0,S=this.length-1;S>=0;S--){var C=this.words[S]|0,R=d.words[S]|0;if(C!==R){C<R?y=-1:C>R&&(y=1);break}}return y},o.prototype.gtn=function(d){return this.cmpn(d)===1},o.prototype.gt=function(d){return this.cmp(d)===1},o.prototype.gten=function(d){return this.cmpn(d)>=0},o.prototype.gte=function(d){return this.cmp(d)>=0},o.prototype.ltn=function(d){return this.cmpn(d)===-1},o.prototype.lt=function(d){return this.cmp(d)===-1},o.prototype.lten=function(d){return this.cmpn(d)<=0},o.prototype.lte=function(d){return this.cmp(d)<=0},o.prototype.eqn=function(d){return this.cmpn(d)===0},o.prototype.eq=function(d){return this.cmp(d)===0},o.red=function(d){return new U(d)},o.prototype.toRed=function(d){return r(!this.red,"Already a number in reduction context"),r(this.negative===0,"red works only with positives"),d.convertTo(this)._forceRed(d)},o.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(d){return this.red=d,this},o.prototype.forceRed=function(d){return r(!this.red,"Already a number in reduction context"),this._forceRed(d)},o.prototype.redAdd=function(d){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,d)},o.prototype.redIAdd=function(d){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,d)},o.prototype.redSub=function(d){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,d)},o.prototype.redISub=function(d){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,d)},o.prototype.redShl=function(d){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,d)},o.prototype.redMul=function(d){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,d),this.red.mul(this,d)},o.prototype.redIMul=function(d){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,d),this.red.imul(this,d)},o.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(d){return r(this.red&&!d.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,d)};var B={k256:null,p224:null,p192:null,p25519:null};function G(A,d){this.name=A,this.p=new o(d,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}G.prototype._tmp=function(){var d=new o(null);return d.words=new Array(Math.ceil(this.n/13)),d},G.prototype.ireduce=function(d){var y=d,S;do this.split(y,this.tmp),y=this.imulK(y),y=y.iadd(this.tmp),S=y.bitLength();while(S>this.n);var C=S<this.n?-1:y.ucmp(this.p);return C===0?(y.words[0]=0,y.length=1):C>0?y.isub(this.p):y.strip!==void 0?y.strip():y._strip(),y},G.prototype.split=function(d,y){d.iushrn(this.n,0,y)},G.prototype.imulK=function(d){return d.imul(this.k)};function Z(){G.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}i(Z,G),Z.prototype.split=function(d,y){for(var S=4194303,C=Math.min(d.length,9),R=0;R<C;R++)y.words[R]=d.words[R];if(y.length=C,d.length<=9){d.words[0]=0,d.length=1;return}var D=d.words[9];for(y.words[y.length++]=D&S,R=10;R<d.length;R++){var L=d.words[R]|0;d.words[R-10]=(L&S)<<4|D>>>22,D=L}D>>>=22,d.words[R-10]=D,D===0&&d.length>10?d.length-=10:d.length-=9},Z.prototype.imulK=function(d){d.words[d.length]=0,d.words[d.length+1]=0,d.length+=2;for(var y=0,S=0;S<d.length;S++){var C=d.words[S]|0;y+=C*977,d.words[S]=y&67108863,y=C*64+(y/67108864|0)}return d.words[d.length-1]===0&&(d.length--,d.words[d.length-1]===0&&d.length--),d};function Y(){G.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}i(Y,G);function F(){G.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}i(F,G);function V(){G.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}i(V,G),V.prototype.imulK=function(d){for(var y=0,S=0;S<d.length;S++){var C=(d.words[S]|0)*19+y,R=C&67108863;C>>>=26,d.words[S]=R,y=C}return y!==0&&(d.words[d.length++]=y),d},o._prime=function(d){if(B[d])return B[d];var y;if(d==="k256")y=new Z;else if(d==="p224")y=new Y;else if(d==="p192")y=new F;else if(d==="p25519")y=new V;else throw new Error("Unknown prime "+d);return B[d]=y,y};function U(A){if(typeof A=="string"){var d=o._prime(A);this.m=d.p,this.prime=d}else r(A.gtn(1),"modulus must be greater than 1"),this.m=A,this.prime=null}U.prototype._verify1=function(d){r(d.negative===0,"red works only with positives"),r(d.red,"red works only with red numbers")},U.prototype._verify2=function(d,y){r((d.negative|y.negative)===0,"red works only with positives"),r(d.red&&d.red===y.red,"red works only with red numbers")},U.prototype.imod=function(d){return this.prime?this.prime.ireduce(d)._forceRed(this):(u(d,d.umod(this.m)._forceRed(this)),d)},U.prototype.neg=function(d){return d.isZero()?d.clone():this.m.sub(d)._forceRed(this)},U.prototype.add=function(d,y){this._verify2(d,y);var S=d.add(y);return S.cmp(this.m)>=0&&S.isub(this.m),S._forceRed(this)},U.prototype.iadd=function(d,y){this._verify2(d,y);var S=d.iadd(y);return S.cmp(this.m)>=0&&S.isub(this.m),S},U.prototype.sub=function(d,y){this._verify2(d,y);var S=d.sub(y);return S.cmpn(0)<0&&S.iadd(this.m),S._forceRed(this)},U.prototype.isub=function(d,y){this._verify2(d,y);var S=d.isub(y);return S.cmpn(0)<0&&S.iadd(this.m),S},U.prototype.shl=function(d,y){return this._verify1(d),this.imod(d.ushln(y))},U.prototype.imul=function(d,y){return this._verify2(d,y),this.imod(d.imul(y))},U.prototype.mul=function(d,y){return this._verify2(d,y),this.imod(d.mul(y))},U.prototype.isqr=function(d){return this.imul(d,d.clone())},U.prototype.sqr=function(d){return this.mul(d,d)},U.prototype.sqrt=function(d){if(d.isZero())return d.clone();var y=this.m.andln(3);if(r(y%2===1),y===3){var S=this.m.add(new o(1)).iushrn(2);return this.pow(d,S)}for(var C=this.m.subn(1),R=0;!C.isZero()&&C.andln(1)===0;)R++,C.iushrn(1);r(!C.isZero());var D=new o(1).toRed(this),L=D.redNeg(),O=this.m.subn(1).iushrn(1),f=this.m.bitLength();for(f=new o(2*f*f).toRed(this);this.pow(f,O).cmp(L)!==0;)f.redIAdd(L);for(var v=this.pow(f,C),k=this.pow(d,C.addn(1).iushrn(1)),M=this.pow(d,C),H=R;M.cmp(D)!==0;){for(var Q=M,X=0;Q.cmp(D)!==0;X++)Q=Q.redSqr();r(X<H);var j=this.pow(v,new o(1).iushln(H-X-1));k=k.redMul(j),v=j.redSqr(),M=M.redMul(v),H=X}return k},U.prototype.invm=function(d){var y=d._invmp(this.m);return y.negative!==0?(y.negative=0,this.imod(y).redNeg()):this.imod(y)},U.prototype.pow=function(d,y){if(y.isZero())return new o(1).toRed(this);if(y.cmpn(1)===0)return d.clone();var S=4,C=new Array(1<<S);C[0]=new o(1).toRed(this),C[1]=d;for(var R=2;R<C.length;R++)C[R]=this.mul(C[R-1],d);var D=C[0],L=0,O=0,f=y.bitLength()%26;for(f===0&&(f=26),R=y.length-1;R>=0;R--){for(var v=y.words[R],k=f-1;k>=0;k--){var M=v>>k&1;if(D!==C[0]&&(D=this.sqr(D)),M===0&&L===0){O=0;continue}L<<=1,L|=M,O++,!(O!==S&&(R!==0||k!==0))&&(D=this.mul(D,C[L]),O=0,L=0)}f=26}return D},U.prototype.convertTo=function(d){var y=d.umod(this.m);return y===d?y.clone():y},U.prototype.convertFrom=function(d){var y=d.clone();return y.red=null,y},o.mont=function(d){return new W(d)};function W(A){U.call(this,A),this.shift=this.m.bitLength(),this.shift%26!==0&&(this.shift+=26-this.shift%26),this.r=new o(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}i(W,U),W.prototype.convertTo=function(d){return this.imod(d.ushln(this.shift))},W.prototype.convertFrom=function(d){var y=this.imod(d.mul(this.rinv));return y.red=null,y},W.prototype.imul=function(d,y){if(d.isZero()||y.isZero())return d.words[0]=0,d.length=1,d;var S=d.imul(y),C=S.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),R=S.isub(C).iushrn(this.shift),D=R;return R.cmp(this.m)>=0?D=R.isub(this.m):R.cmpn(0)<0&&(D=R.iadd(this.m)),D._forceRed(this)},W.prototype.mul=function(d,y){if(d.isZero()||y.isZero())return new o(0)._forceRed(this);var S=d.mul(y),C=S.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),R=S.isub(C).iushrn(this.shift),D=R;return R.cmp(this.m)>=0?D=R.isub(this.m):R.cmpn(0)<0&&(D=R.iadd(this.m)),D._forceRed(this)},W.prototype.invm=function(d){var y=this.imod(d._invmp(this.m).mul(this.r2));return y._forceRed(this)}})(t,w$)})(Vu)),Vu.exports}var E$=hw();const fw=ts(E$);var $u={exports:{}};/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var gw;function S$(){return gw||(gw=1,(function(t,e){var n=Ig(),r=n.Buffer;function i(s,a){for(var l in s)a[l]=s[l]}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?t.exports=n:(i(n,e),e.Buffer=o);function o(s,a,l){return r(s,a,l)}o.prototype=Object.create(r.prototype),i(r,o),o.from=function(s,a,l){if(typeof s=="number")throw new TypeError("Argument must not be a number");return r(s,a,l)},o.alloc=function(s,a,l){if(typeof s!="number")throw new TypeError("Argument must be a number");var c=r(s);return a!==void 0?typeof l=="string"?c.fill(a,l):c.fill(a):c.fill(0),c},o.allocUnsafe=function(s){if(typeof s!="number")throw new TypeError("Argument must be a number");return r(s)},o.allocUnsafeSlow=function(s){if(typeof s!="number")throw new TypeError("Argument must be a number");return n.SlowBuffer(s)}})($u,$u.exports)),$u.exports}var Fg,pw;function I$(){if(pw)return Fg;pw=1;var t=S$().Buffer;function e(n){if(n.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),i=0;i<r.length;i++)r[i]=255;for(var o=0;o<n.length;o++){var s=n.charAt(o),a=s.charCodeAt(0);if(r[a]!==255)throw new TypeError(s+" is ambiguous");r[a]=o}var l=n.length,c=n.charAt(0),u=Math.log(l)/Math.log(256),h=Math.log(256)/Math.log(l);function p(m){if((Array.isArray(m)||m instanceof Uint8Array)&&(m=t.from(m)),!t.isBuffer(m))throw new TypeError("Expected Buffer");if(m.length===0)return"";for(var x=0,I=0,N=0,T=m.length;N!==T&&m[N]===0;)N++,x++;for(var $=(T-N)*h+1>>>0,B=new Uint8Array($);N!==T;){for(var G=m[N],Z=0,Y=$-1;(G!==0||Z<I)&&Y!==-1;Y--,Z++)G+=256*B[Y]>>>0,B[Y]=G%l>>>0,G=G/l>>>0;if(G!==0)throw new Error("Non-zero carry");I=Z,N++}for(var F=$-I;F!==$&&B[F]===0;)F++;for(var V=c.repeat(x);F<$;++F)V+=n.charAt(B[F]);return V}function g(m){if(typeof m!="string")throw new TypeError("Expected String");if(m.length===0)return t.alloc(0);for(var x=0,I=0,N=0;m[x]===c;)I++,x++;for(var T=(m.length-x)*u+1>>>0,$=new Uint8Array(T);x<m.length;){var B=m.charCodeAt(x);if(B>255)return;var G=r[B];if(G===255)return;for(var Z=0,Y=T-1;(G!==0||Z<N)&&Y!==-1;Y--,Z++)G+=l*$[Y]>>>0,$[Y]=G%256>>>0,G=G/256>>>0;if(G!==0)throw new Error("Non-zero carry");N=Z,x++}for(var F=T-N;F!==T&&$[F]===0;)F++;var V=t.allocUnsafe(I+(T-F));V.fill(0,0,I);for(var U=I;F!==T;)V[U++]=$[F++];return V}function b(m){var x=g(m);if(x)return x;throw new Error("Non-base"+l+" character")}return{encode:p,decodeUnsafe:g,decode:b}}return Fg=e,Fg}var Dg,mw;function vw(){if(mw)return Dg;mw=1;var t=I$(),e="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";return Dg=t(e),Dg}var C$=vw();const mn=ts(C$);var tt={};function _i(t,e,n){return e<=t&&t<=n}function zu(t){if(t===void 0)return{};if(t===Object(t))return t;throw TypeError("Could not convert argument to dictionary")}function A$(t){for(var e=String(t),n=e.length,r=0,i=[];r<n;){var o=e.charCodeAt(r);if(o<55296||o>57343)i.push(o);else if(56320<=o&&o<=57343)i.push(65533);else if(55296<=o&&o<=56319)if(r===n-1)i.push(65533);else{var s=t.charCodeAt(r+1);if(56320<=s&&s<=57343){var a=o&1023,l=s&1023;i.push(65536+(a<<10)+l),r+=1}else i.push(65533)}r+=1}return i}function O$(t){for(var e="",n=0;n<t.length;++n){var r=t[n];r<=65535?e+=String.fromCharCode(r):(r-=65536,e+=String.fromCharCode((r>>10)+55296,(r&1023)+56320))}return e}var Uu=-1;function Vg(t){this.tokens=[].slice.call(t)}Vg.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.shift():Uu},prepend:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.unshift(e.pop());else this.tokens.unshift(t)},push:function(t){if(Array.isArray(t))for(var e=t;e.length;)this.tokens.push(e.shift());else this.tokens.push(t)}};var zs=-1;function $g(t,e){if(t)throw TypeError("Decoder error");return e||65533}var Wu="utf-8";function Hu(t,e){if(!(this instanceof Hu))return new Hu(t,e);if(t=t!==void 0?String(t).toLowerCase():Wu,t!==Wu)throw new Error("Encoding not supported. Only utf-8 is supported");e=zu(e),this._streaming=!1,this._BOMseen=!1,this._decoder=null,this._fatal=!!e.fatal,this._ignoreBOM=!!e.ignoreBOM,Object.defineProperty(this,"encoding",{value:"utf-8"}),Object.defineProperty(this,"fatal",{value:this._fatal}),Object.defineProperty(this,"ignoreBOM",{value:this._ignoreBOM})}Hu.prototype={decode:function(e,n){var r;typeof e=="object"&&e instanceof ArrayBuffer?r=new Uint8Array(e):typeof e=="object"&&"buffer"in e&&e.buffer instanceof ArrayBuffer?r=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):r=new Uint8Array(0),n=zu(n),this._streaming||(this._decoder=new k$({fatal:this._fatal}),this._BOMseen=!1),this._streaming=!!n.stream;for(var i=new Vg(r),o=[],s;!i.endOfStream()&&(s=this._decoder.handler(i,i.read()),s!==zs);)s!==null&&(Array.isArray(s)?o.push.apply(o,s):o.push(s));if(!this._streaming){do{if(s=this._decoder.handler(i,i.read()),s===zs)break;s!==null&&(Array.isArray(s)?o.push.apply(o,s):o.push(s))}while(!i.endOfStream());this._decoder=null}return o.length&&["utf-8"].indexOf(this.encoding)!==-1&&!this._ignoreBOM&&!this._BOMseen&&(o[0]===65279?(this._BOMseen=!0,o.shift()):this._BOMseen=!0),O$(o)}};function ju(t,e){if(!(this instanceof ju))return new ju(t,e);if(t=t!==void 0?String(t).toLowerCase():Wu,t!==Wu)throw new Error("Encoding not supported. Only utf-8 is supported");e=zu(e),this._streaming=!1,this._encoder=null,this._options={fatal:!!e.fatal},Object.defineProperty(this,"encoding",{value:"utf-8"})}ju.prototype={encode:function(e,n){e=e?String(e):"",n=zu(n),this._streaming||(this._encoder=new T$(this._options)),this._streaming=!!n.stream;for(var r=[],i=new Vg(A$(e)),o;!i.endOfStream()&&(o=this._encoder.handler(i,i.read()),o!==zs);)Array.isArray(o)?r.push.apply(r,o):r.push(o);if(!this._streaming){for(;o=this._encoder.handler(i,i.read()),o!==zs;)Array.isArray(o)?r.push.apply(r,o):r.push(o);this._encoder=null}return new Uint8Array(r)}};function k$(t){var e=t.fatal,n=0,r=0,i=0,o=128,s=191;this.handler=function(a,l){if(l===Uu&&i!==0)return i=0,$g(e);if(l===Uu)return zs;if(i===0){if(_i(l,0,127))return l;if(_i(l,194,223))i=1,n=l-192;else if(_i(l,224,239))l===224&&(o=160),l===237&&(s=159),i=2,n=l-224;else if(_i(l,240,244))l===240&&(o=144),l===244&&(s=143),i=3,n=l-240;else return $g(e);return n=n<<6*i,null}if(!_i(l,o,s))return n=i=r=0,o=128,s=191,a.prepend(l),$g(e);if(o=128,s=191,r+=1,n+=l-128<<6*(i-r),r!==i)return null;var c=n;return n=i=r=0,c}}function T$(t){t.fatal,this.handler=function(e,n){if(n===Uu)return zs;if(_i(n,0,127))return n;var r,i;_i(n,128,2047)?(r=1,i=192):_i(n,2048,65535)?(r=2,i=224):_i(n,65536,1114111)&&(r=3,i=240);for(var o=[(n>>6*r)+i];r>0;){var s=n>>6*(r-1);o.push(128|s&63),r-=1}return o}}const R$=ya(Object.freeze(Object.defineProperty({__proto__:null,TextDecoder:Hu,TextEncoder:ju},Symbol.toStringTag,{value:"Module"})));var yw;function N$(){if(yw)return tt;yw=1;var t=tt&&tt.__createBinding||(Object.create?(function(F,V,U,W){W===void 0&&(W=U),Object.defineProperty(F,W,{enumerable:!0,get:function(){return V[U]}})}):(function(F,V,U,W){W===void 0&&(W=U),F[W]=V[U]})),e=tt&&tt.__setModuleDefault||(Object.create?(function(F,V){Object.defineProperty(F,"default",{enumerable:!0,value:V})}):function(F,V){F.default=V}),n=tt&&tt.__decorate||function(F,V,U,W){var A=arguments.length,d=A<3?V:W===null?W=Object.getOwnPropertyDescriptor(V,U):W,y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")d=Reflect.decorate(F,V,U,W);else for(var S=F.length-1;S>=0;S--)(y=F[S])&&(d=(A<3?y(d):A>3?y(V,U,d):y(V,U))||d);return A>3&&d&&Object.defineProperty(V,U,d),d},r=tt&&tt.__importStar||function(F){if(F&&F.__esModule)return F;var V={};if(F!=null)for(var U in F)U!=="default"&&Object.hasOwnProperty.call(F,U)&&t(V,F,U);return e(V,F),V},i=tt&&tt.__importDefault||function(F){return F&&F.__esModule?F:{default:F}};Object.defineProperty(tt,"__esModule",{value:!0}),tt.deserializeUnchecked=tt.deserialize=tt.serialize=tt.BinaryReader=tt.BinaryWriter=tt.BorshError=tt.baseDecode=tt.baseEncode=void 0;const o=i(hw()),s=i(vw()),a=r(R$),l=typeof TextDecoder!="function"?a.TextDecoder:TextDecoder,c=new l("utf-8",{fatal:!0});function u(F){return typeof F=="string"&&(F=Buffer.from(F,"utf8")),s.default.encode(Buffer.from(F))}tt.baseEncode=u;function h(F){return Buffer.from(s.default.decode(F))}tt.baseDecode=h;const p=1024;class g extends Error{constructor(V){super(V),this.fieldPath=[],this.originalMessage=V}addToFieldPath(V){this.fieldPath.splice(0,0,V),this.message=this.originalMessage+": "+this.fieldPath.join(".")}}tt.BorshError=g;class b{constructor(){this.buf=Buffer.alloc(p),this.length=0}maybeResize(){this.buf.length<16+this.length&&(this.buf=Buffer.concat([this.buf,Buffer.alloc(p)]))}writeU8(V){this.maybeResize(),this.buf.writeUInt8(V,this.length),this.length+=1}writeU16(V){this.maybeResize(),this.buf.writeUInt16LE(V,this.length),this.length+=2}writeU32(V){this.maybeResize(),this.buf.writeUInt32LE(V,this.length),this.length+=4}writeU64(V){this.maybeResize(),this.writeBuffer(Buffer.from(new o.default(V).toArray("le",8)))}writeU128(V){this.maybeResize(),this.writeBuffer(Buffer.from(new o.default(V).toArray("le",16)))}writeU256(V){this.maybeResize(),this.writeBuffer(Buffer.from(new o.default(V).toArray("le",32)))}writeU512(V){this.maybeResize(),this.writeBuffer(Buffer.from(new o.default(V).toArray("le",64)))}writeBuffer(V){this.buf=Buffer.concat([Buffer.from(this.buf.subarray(0,this.length)),V,Buffer.alloc(p)]),this.length+=V.length}writeString(V){this.maybeResize();const U=Buffer.from(V,"utf8");this.writeU32(U.length),this.writeBuffer(U)}writeFixedArray(V){this.writeBuffer(Buffer.from(V))}writeArray(V,U){this.maybeResize(),this.writeU32(V.length);for(const W of V)this.maybeResize(),U(W)}toArray(){return this.buf.subarray(0,this.length)}}tt.BinaryWriter=b;function m(F,V,U){const W=U.value;U.value=function(...A){try{return W.apply(this,A)}catch(d){if(d instanceof RangeError){const y=d.code;if(["ERR_BUFFER_OUT_OF_BOUNDS","ERR_OUT_OF_RANGE"].indexOf(y)>=0)throw new g("Reached the end of buffer when deserializing")}throw d}}}class x{constructor(V){this.buf=V,this.offset=0}readU8(){const V=this.buf.readUInt8(this.offset);return this.offset+=1,V}readU16(){const V=this.buf.readUInt16LE(this.offset);return this.offset+=2,V}readU32(){const V=this.buf.readUInt32LE(this.offset);return this.offset+=4,V}readU64(){const V=this.readBuffer(8);return new o.default(V,"le")}readU128(){const V=this.readBuffer(16);return new o.default(V,"le")}readU256(){const V=this.readBuffer(32);return new o.default(V,"le")}readU512(){const V=this.readBuffer(64);return new o.default(V,"le")}readBuffer(V){if(this.offset+V>this.buf.length)throw new g(`Expected buffer length ${V} isn't within bounds`);const U=this.buf.slice(this.offset,this.offset+V);return this.offset+=V,U}readString(){const V=this.readU32(),U=this.readBuffer(V);try{return c.decode(U)}catch(W){throw new g(`Error decoding UTF-8 string: ${W}`)}}readFixedArray(V){return new Uint8Array(this.readBuffer(V))}readArray(V){const U=this.readU32(),W=Array();for(let A=0;A<U;++A)W.push(V());return W}}n([m],x.prototype,"readU8",null),n([m],x.prototype,"readU16",null),n([m],x.prototype,"readU32",null),n([m],x.prototype,"readU64",null),n([m],x.prototype,"readU128",null),n([m],x.prototype,"readU256",null),n([m],x.prototype,"readU512",null),n([m],x.prototype,"readString",null),n([m],x.prototype,"readFixedArray",null),n([m],x.prototype,"readArray",null),tt.BinaryReader=x;function I(F){return F.charAt(0).toUpperCase()+F.slice(1)}function N(F,V,U,W,A){try{if(typeof W=="string")A[`write${I(W)}`](U);else if(W instanceof Array)if(typeof W[0]=="number"){if(U.length!==W[0])throw new g(`Expecting byte array of length ${W[0]}, but got ${U.length} bytes`);A.writeFixedArray(U)}else if(W.length===2&&typeof W[1]=="number"){if(U.length!==W[1])throw new g(`Expecting byte array of length ${W[1]}, but got ${U.length} bytes`);for(let d=0;d<W[1];d++)N(F,null,U[d],W[0],A)}else A.writeArray(U,d=>{N(F,V,d,W[0],A)});else if(W.kind!==void 0)switch(W.kind){case"option":{U==null?A.writeU8(0):(A.writeU8(1),N(F,V,U,W.type,A));break}case"map":{A.writeU32(U.size),U.forEach((d,y)=>{N(F,V,y,W.key,A),N(F,V,d,W.value,A)});break}default:throw new g(`FieldType ${W} unrecognized`)}else T(F,U,A)}catch(d){throw d instanceof g&&d.addToFieldPath(V),d}}function T(F,V,U){if(typeof V.borshSerialize=="function"){V.borshSerialize(U);return}const W=F.get(V.constructor);if(!W)throw new g(`Class ${V.constructor.name} is missing in schema`);if(W.kind==="struct")W.fields.map(([A,d])=>{N(F,A,V[A],d,U)});else if(W.kind==="enum"){const A=V[W.field];for(let d=0;d<W.values.length;++d){const[y,S]=W.values[d];if(y===A){U.writeU8(d),N(F,y,V[y],S,U);break}}}else throw new g(`Unexpected schema kind: ${W.kind} for ${V.constructor.name}`)}function $(F,V,U=b){const W=new U;return T(F,V,W),W.toArray()}tt.serialize=$;function B(F,V,U,W){try{if(typeof U=="string")return W[`read${I(U)}`]();if(U instanceof Array){if(typeof U[0]=="number")return W.readFixedArray(U[0]);if(typeof U[1]=="number"){const A=[];for(let d=0;d<U[1];d++)A.push(B(F,null,U[0],W));return A}else return W.readArray(()=>B(F,V,U[0],W))}if(U.kind==="option")return W.readU8()?B(F,V,U.type,W):void 0;if(U.kind==="map"){let A=new Map;const d=W.readU32();for(let y=0;y<d;y++){const S=B(F,V,U.key,W),C=B(F,V,U.value,W);A.set(S,C)}return A}return G(F,U,W)}catch(A){throw A instanceof g&&A.addToFieldPath(V),A}}function G(F,V,U){if(typeof V.borshDeserialize=="function")return V.borshDeserialize(U);const W=F.get(V);if(!W)throw new g(`Class ${V.name} is missing in schema`);if(W.kind==="struct"){const A={};for(const[d,y]of F.get(V).fields)A[d]=B(F,d,y,U);return new V(A)}if(W.kind==="enum"){const A=U.readU8();if(A>=W.values.length)throw new g(`Enum index: ${A} is out of range`);const[d,y]=W.values[A],S=B(F,d,y,U);return new V({[d]:S})}throw new g(`Unexpected schema kind: ${W.kind} for ${V.constructor.name}`)}function Z(F,V,U,W=x){const A=new W(U),d=G(F,V,A);if(A.offset<U.length)throw new g(`Unexpected ${U.length-A.offset} bytes after deserialized data`);return d}tt.deserialize=Z;function Y(F,V,U,W=x){const A=new W(U);return G(F,V,A)}return tt.deserializeUnchecked=Y,tt}var zg=N$(),ie={},bw;function P$(){if(bw)return ie;bw=1,Object.defineProperty(ie,"__esModule",{value:!0}),ie.s16=ie.s8=ie.nu64be=ie.u48be=ie.u40be=ie.u32be=ie.u24be=ie.u16be=ie.nu64=ie.u48=ie.u40=ie.u32=ie.u24=ie.u16=ie.u8=ie.offset=ie.greedy=ie.Constant=ie.UTF8=ie.CString=ie.Blob=ie.Boolean=ie.BitField=ie.BitStructure=ie.VariantLayout=ie.Union=ie.UnionLayoutDiscriminator=ie.UnionDiscriminator=ie.Structure=ie.Sequence=ie.DoubleBE=ie.Double=ie.FloatBE=ie.Float=ie.NearInt64BE=ie.NearInt64=ie.NearUInt64BE=ie.NearUInt64=ie.IntBE=ie.Int=ie.UIntBE=ie.UInt=ie.OffsetLayout=ie.GreedyCount=ie.ExternalLayout=ie.bindConstructorLayout=ie.nameWithProperty=ie.Layout=ie.uint8ArrayToBuffer=ie.checkUint8Array=void 0,ie.constant=ie.utf8=ie.cstr=ie.blob=ie.unionLayoutDiscriminator=ie.union=ie.seq=ie.bits=ie.struct=ie.f64be=ie.f64=ie.f32be=ie.f32=ie.ns64be=ie.s48be=ie.s40be=ie.s32be=ie.s24be=ie.s16be=ie.ns64=ie.s48=ie.s40=ie.s32=ie.s24=void 0;const t=Ig();function e(f){if(!(f instanceof Uint8Array))throw new TypeError("b must be a Uint8Array")}ie.checkUint8Array=e;function n(f){return e(f),t.Buffer.from(f.buffer,f.byteOffset,f.length)}ie.uint8ArrayToBuffer=n;let r=class{constructor(v,k){if(!Number.isInteger(v))throw new TypeError("span must be an integer");this.span=v,this.property=k}makeDestinationObject(){return{}}getSpan(v,k){if(0>this.span)throw new RangeError("indeterminate span");return this.span}replicate(v){const k=Object.create(this.constructor.prototype);return Object.assign(k,this),k.property=v,k}fromArray(v){}};ie.Layout=r;function i(f,v){return v.property?f+"["+v.property+"]":f}ie.nameWithProperty=i;function o(f,v){if(typeof f!="function")throw new TypeError("Class must be constructor");if(Object.prototype.hasOwnProperty.call(f,"layout_"))throw new Error("Class is already bound to a layout");if(!(v&&v instanceof r))throw new TypeError("layout must be a Layout");if(Object.prototype.hasOwnProperty.call(v,"boundConstructor_"))throw new Error("layout is already bound to a constructor");f.layout_=v,v.boundConstructor_=f,v.makeDestinationObject=(()=>new f),Object.defineProperty(f.prototype,"encode",{value(k,M){return v.encode(this,k,M)},writable:!0}),Object.defineProperty(f,"decode",{value(k,M){return v.decode(k,M)},writable:!0})}ie.bindConstructorLayout=o;class s extends r{isCount(){throw new Error("ExternalLayout is abstract")}}ie.ExternalLayout=s;class a extends s{constructor(v=1,k){if(!Number.isInteger(v)||0>=v)throw new TypeError("elementSpan must be a (positive) integer");super(-1,k),this.elementSpan=v}isCount(){return!0}decode(v,k=0){e(v);const M=v.length-k;return Math.floor(M/this.elementSpan)}encode(v,k,M){return 0}}ie.GreedyCount=a;class l extends s{constructor(v,k=0,M){if(!(v instanceof r))throw new TypeError("layout must be a Layout");if(!Number.isInteger(k))throw new TypeError("offset must be integer or undefined");super(v.span,M||v.property),this.layout=v,this.offset=k}isCount(){return this.layout instanceof c||this.layout instanceof u}decode(v,k=0){return this.layout.decode(v,k+this.offset)}encode(v,k,M=0){return this.layout.encode(v,k,M+this.offset)}}ie.OffsetLayout=l;class c extends r{constructor(v,k){if(super(v,k),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(v,k=0){return n(v).readUIntLE(k,this.span)}encode(v,k,M=0){return n(k).writeUIntLE(v,M,this.span),this.span}}ie.UInt=c;class u extends r{constructor(v,k){if(super(v,k),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(v,k=0){return n(v).readUIntBE(k,this.span)}encode(v,k,M=0){return n(k).writeUIntBE(v,M,this.span),this.span}}ie.UIntBE=u;class h extends r{constructor(v,k){if(super(v,k),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(v,k=0){return n(v).readIntLE(k,this.span)}encode(v,k,M=0){return n(k).writeIntLE(v,M,this.span),this.span}}ie.Int=h;class p extends r{constructor(v,k){if(super(v,k),6<this.span)throw new RangeError("span must not exceed 6 bytes")}decode(v,k=0){return n(v).readIntBE(k,this.span)}encode(v,k,M=0){return n(k).writeIntBE(v,M,this.span),this.span}}ie.IntBE=p;const g=Math.pow(2,32);function b(f){const v=Math.floor(f/g),k=f-v*g;return{hi32:v,lo32:k}}function m(f,v){return f*g+v}class x extends r{constructor(v){super(8,v)}decode(v,k=0){const M=n(v),H=M.readUInt32LE(k),Q=M.readUInt32LE(k+4);return m(Q,H)}encode(v,k,M=0){const H=b(v),Q=n(k);return Q.writeUInt32LE(H.lo32,M),Q.writeUInt32LE(H.hi32,M+4),8}}ie.NearUInt64=x;class I extends r{constructor(v){super(8,v)}decode(v,k=0){const M=n(v),H=M.readUInt32BE(k),Q=M.readUInt32BE(k+4);return m(H,Q)}encode(v,k,M=0){const H=b(v),Q=n(k);return Q.writeUInt32BE(H.hi32,M),Q.writeUInt32BE(H.lo32,M+4),8}}ie.NearUInt64BE=I;class N extends r{constructor(v){super(8,v)}decode(v,k=0){const M=n(v),H=M.readUInt32LE(k),Q=M.readInt32LE(k+4);return m(Q,H)}encode(v,k,M=0){const H=b(v),Q=n(k);return Q.writeUInt32LE(H.lo32,M),Q.writeInt32LE(H.hi32,M+4),8}}ie.NearInt64=N;class T extends r{constructor(v){super(8,v)}decode(v,k=0){const M=n(v),H=M.readInt32BE(k),Q=M.readUInt32BE(k+4);return m(H,Q)}encode(v,k,M=0){const H=b(v),Q=n(k);return Q.writeInt32BE(H.hi32,M),Q.writeUInt32BE(H.lo32,M+4),8}}ie.NearInt64BE=T;class $ extends r{constructor(v){super(4,v)}decode(v,k=0){return n(v).readFloatLE(k)}encode(v,k,M=0){return n(k).writeFloatLE(v,M),4}}ie.Float=$;class B extends r{constructor(v){super(4,v)}decode(v,k=0){return n(v).readFloatBE(k)}encode(v,k,M=0){return n(k).writeFloatBE(v,M),4}}ie.FloatBE=B;class G extends r{constructor(v){super(8,v)}decode(v,k=0){return n(v).readDoubleLE(k)}encode(v,k,M=0){return n(k).writeDoubleLE(v,M),8}}ie.Double=G;class Z extends r{constructor(v){super(8,v)}decode(v,k=0){return n(v).readDoubleBE(k)}encode(v,k,M=0){return n(k).writeDoubleBE(v,M),8}}ie.DoubleBE=Z;class Y extends r{constructor(v,k,M){if(!(v instanceof r))throw new TypeError("elementLayout must be a Layout");if(!(k instanceof s&&k.isCount()||Number.isInteger(k)&&0<=k))throw new TypeError("count must be non-negative integer or an unsigned integer ExternalLayout");let H=-1;!(k instanceof s)&&0<v.span&&(H=k*v.span),super(H,M),this.elementLayout=v,this.count=k}getSpan(v,k=0){if(0<=this.span)return this.span;let M=0,H=this.count;if(H instanceof s&&(H=H.decode(v,k)),0<this.elementLayout.span)M=H*this.elementLayout.span;else{let Q=0;for(;Q<H;)M+=this.elementLayout.getSpan(v,k+M),++Q}return M}decode(v,k=0){const M=[];let H=0,Q=this.count;for(Q instanceof s&&(Q=Q.decode(v,k));H<Q;)M.push(this.elementLayout.decode(v,k)),k+=this.elementLayout.getSpan(v,k),H+=1;return M}encode(v,k,M=0){const H=this.elementLayout,Q=v.reduce((X,j)=>X+H.encode(j,k,M+X),0);return this.count instanceof s&&this.count.encode(v.length,k,M),Q}}ie.Sequence=Y;class F extends r{constructor(v,k,M){if(!(Array.isArray(v)&&v.reduce((Q,X)=>Q&&X instanceof r,!0)))throw new TypeError("fields must be array of Layout instances");typeof k=="boolean"&&M===void 0&&(M=k,k=void 0);for(const Q of v)if(0>Q.span&&Q.property===void 0)throw new Error("fields cannot contain unnamed variable-length layout");let H=-1;try{H=v.reduce((Q,X)=>Q+X.getSpan(),0)}catch(Q){}super(H,k),this.fields=v,this.decodePrefixes=!!M}getSpan(v,k=0){if(0<=this.span)return this.span;let M=0;try{M=this.fields.reduce((H,Q)=>{const X=Q.getSpan(v,k);return k+=X,H+X},0)}catch(H){throw new RangeError("indeterminate span")}return M}decode(v,k=0){e(v);const M=this.makeDestinationObject();for(const H of this.fields)if(H.property!==void 0&&(M[H.property]=H.decode(v,k)),k+=H.getSpan(v,k),this.decodePrefixes&&v.length===k)break;return M}encode(v,k,M=0){const H=M;let Q=0,X=0;for(const j of this.fields){let ee=j.span;if(X=0<ee?ee:0,j.property!==void 0){const se=v[j.property];se!==void 0&&(X=j.encode(se,k,M),0>ee&&(ee=j.getSpan(k,M)))}Q=M,M+=ee}return Q+X-H}fromArray(v){const k=this.makeDestinationObject();for(const M of this.fields)M.property!==void 0&&0<v.length&&(k[M.property]=v.shift());return k}layoutFor(v){if(typeof v!="string")throw new TypeError("property must be string");for(const k of this.fields)if(k.property===v)return k}offsetOf(v){if(typeof v!="string")throw new TypeError("property must be string");let k=0;for(const M of this.fields){if(M.property===v)return k;0>M.span?k=-1:0<=k&&(k+=M.span)}}}ie.Structure=F;class V{constructor(v){this.property=v}decode(v,k){throw new Error("UnionDiscriminator is abstract")}encode(v,k,M){throw new Error("UnionDiscriminator is abstract")}}ie.UnionDiscriminator=V;class U extends V{constructor(v,k){if(!(v instanceof s&&v.isCount()))throw new TypeError("layout must be an unsigned integer ExternalLayout");super(k||v.property||"variant"),this.layout=v}decode(v,k){return this.layout.decode(v,k)}encode(v,k,M){return this.layout.encode(v,k,M)}}ie.UnionLayoutDiscriminator=U;class W extends r{constructor(v,k,M){let H;if(v instanceof c||v instanceof u)H=new U(new l(v));else if(v instanceof s&&v.isCount())H=new U(v);else if(v instanceof V)H=v;else throw new TypeError("discr must be a UnionDiscriminator or an unsigned integer layout");if(k===void 0&&(k=null),!(k===null||k instanceof r))throw new TypeError("defaultLayout must be null or a Layout");if(k!==null){if(0>k.span)throw new Error("defaultLayout must have constant span");k.property===void 0&&(k=k.replicate("content"))}let Q=-1;k&&(Q=k.span,0<=Q&&(v instanceof c||v instanceof u)&&(Q+=H.layout.span)),super(Q,M),this.discriminator=H,this.usesPrefixDiscriminator=v instanceof c||v instanceof u,this.defaultLayout=k,this.registry={};let X=this.defaultGetSourceVariant.bind(this);this.getSourceVariant=function(j){return X(j)},this.configGetSourceVariant=function(j){X=j.bind(this)}}getSpan(v,k=0){if(0<=this.span)return this.span;const M=this.getVariant(v,k);if(!M)throw new Error("unable to determine span for unrecognized variant");return M.getSpan(v,k)}defaultGetSourceVariant(v){if(Object.prototype.hasOwnProperty.call(v,this.discriminator.property)){if(this.defaultLayout&&this.defaultLayout.property&&Object.prototype.hasOwnProperty.call(v,this.defaultLayout.property))return;const k=this.registry[v[this.discriminator.property]];if(k&&(!k.layout||k.property&&Object.prototype.hasOwnProperty.call(v,k.property)))return k}else for(const k in this.registry){const M=this.registry[k];if(M.property&&Object.prototype.hasOwnProperty.call(v,M.property))return M}throw new Error("unable to infer src variant")}decode(v,k=0){let M;const H=this.discriminator,Q=H.decode(v,k),X=this.registry[Q];if(X===void 0){const j=this.defaultLayout;let ee=0;this.usesPrefixDiscriminator&&(ee=H.layout.span),M=this.makeDestinationObject(),M[H.property]=Q,M[j.property]=j.decode(v,k+ee)}else M=X.decode(v,k);return M}encode(v,k,M=0){const H=this.getSourceVariant(v);if(H===void 0){const Q=this.discriminator,X=this.defaultLayout;let j=0;return this.usesPrefixDiscriminator&&(j=Q.layout.span),Q.encode(v[Q.property],k,M),j+X.encode(v[X.property],k,M+j)}return H.encode(v,k,M)}addVariant(v,k,M){const H=new A(this,v,k,M);return this.registry[v]=H,H}getVariant(v,k=0){let M;return v instanceof Uint8Array?M=this.discriminator.decode(v,k):M=v,this.registry[M]}}ie.Union=W;class A extends r{constructor(v,k,M,H){if(!(v instanceof W))throw new TypeError("union must be a Union");if(!Number.isInteger(k)||0>k)throw new TypeError("variant must be a (non-negative) integer");if(typeof M=="string"&&H===void 0&&(H=M,M=null),M){if(!(M instanceof r))throw new TypeError("layout must be a Layout");if(v.defaultLayout!==null&&0<=M.span&&M.span>v.defaultLayout.span)throw new Error("variant span exceeds span of containing union");if(typeof H!="string")throw new TypeError("variant must have a String property")}let Q=v.span;0>v.span&&(Q=M?M.span:0,0<=Q&&v.usesPrefixDiscriminator&&(Q+=v.discriminator.layout.span)),super(Q,H),this.union=v,this.variant=k,this.layout=M||null}getSpan(v,k=0){if(0<=this.span)return this.span;let M=0;this.union.usesPrefixDiscriminator&&(M=this.union.discriminator.layout.span);let H=0;return this.layout&&(H=this.layout.getSpan(v,k+M)),M+H}decode(v,k=0){const M=this.makeDestinationObject();if(this!==this.union.getVariant(v,k))throw new Error("variant mismatch");let H=0;return this.union.usesPrefixDiscriminator&&(H=this.union.discriminator.layout.span),this.layout?M[this.property]=this.layout.decode(v,k+H):this.property?M[this.property]=!0:this.union.usesPrefixDiscriminator&&(M[this.union.discriminator.property]=this.variant),M}encode(v,k,M=0){let H=0;if(this.union.usesPrefixDiscriminator&&(H=this.union.discriminator.layout.span),this.layout&&!Object.prototype.hasOwnProperty.call(v,this.property))throw new TypeError("variant lacks property "+this.property);this.union.discriminator.encode(this.variant,k,M);let Q=H;if(this.layout&&(this.layout.encode(v[this.property],k,M+H),Q+=this.layout.getSpan(k,M+H),0<=this.union.span&&Q>this.union.span))throw new Error("encoded variant overruns containing union");return Q}fromArray(v){if(this.layout)return this.layout.fromArray(v)}}ie.VariantLayout=A;function d(f){return 0>f&&(f+=4294967296),f}class y extends r{constructor(v,k,M){if(!(v instanceof c||v instanceof u))throw new TypeError("word must be a UInt or UIntBE layout");if(typeof k=="string"&&M===void 0&&(M=k,k=!1),4<v.span)throw new RangeError("word cannot exceed 32 bits");super(v.span,M),this.word=v,this.msb=!!k,this.fields=[];let H=0;this._packedSetValue=function(Q){return H=d(Q),this},this._packedGetValue=function(){return H}}decode(v,k=0){const M=this.makeDestinationObject(),H=this.word.decode(v,k);this._packedSetValue(H);for(const Q of this.fields)Q.property!==void 0&&(M[Q.property]=Q.decode(v));return M}encode(v,k,M=0){const H=this.word.decode(k,M);this._packedSetValue(H);for(const Q of this.fields)if(Q.property!==void 0){const X=v[Q.property];X!==void 0&&Q.encode(X)}return this.word.encode(this._packedGetValue(),k,M)}addField(v,k){const M=new S(this,v,k);return this.fields.push(M),M}addBoolean(v){const k=new C(this,v);return this.fields.push(k),k}fieldFor(v){if(typeof v!="string")throw new TypeError("property must be string");for(const k of this.fields)if(k.property===v)return k}}ie.BitStructure=y;class S{constructor(v,k,M){if(!(v instanceof y))throw new TypeError("container must be a BitStructure");if(!Number.isInteger(k)||0>=k)throw new TypeError("bits must be positive integer");const H=8*v.span,Q=v.fields.reduce((X,j)=>X+j.bits,0);if(k+Q>H)throw new Error("bits too long for span remainder ("+(H-Q)+" of "+H+" remain)");this.container=v,this.bits=k,this.valueMask=(1<<k)-1,k===32&&(this.valueMask=4294967295),this.start=Q,this.container.msb&&(this.start=H-Q-k),this.wordMask=d(this.valueMask<<this.start),this.property=M}decode(v,k){const M=this.container._packedGetValue();return d(M&this.wordMask)>>>this.start}encode(v){if(typeof v!="number"||!Number.isInteger(v)||v!==d(v&this.valueMask))throw new TypeError(i("BitField.encode",this)+" value must be integer not exceeding "+this.valueMask);const k=this.container._packedGetValue(),M=d(v<<this.start);this.container._packedSetValue(d(k&~this.wordMask)|M)}}ie.BitField=S;class C extends S{constructor(v,k){super(v,1,k)}decode(v,k){return!!super.decode(v,k)}encode(v){typeof v=="boolean"&&(v=+v),super.encode(v)}}ie.Boolean=C;class R extends r{constructor(v,k){if(!(v instanceof s&&v.isCount()||Number.isInteger(v)&&0<=v))throw new TypeError("length must be positive integer or an unsigned integer ExternalLayout");let M=-1;v instanceof s||(M=v),super(M,k),this.length=v}getSpan(v,k){let M=this.span;return 0>M&&(M=this.length.decode(v,k)),M}decode(v,k=0){let M=this.span;return 0>M&&(M=this.length.decode(v,k)),n(v).slice(k,k+M)}encode(v,k,M){let H=this.length;if(this.length instanceof s&&(H=v.length),!(v instanceof Uint8Array&&H===v.length))throw new TypeError(i("Blob.encode",this)+" requires (length "+H+") Uint8Array as src");if(M+H>k.length)throw new RangeError("encoding overruns Uint8Array");const Q=n(v);return n(k).write(Q.toString("hex"),M,H,"hex"),this.length instanceof s&&this.length.encode(H,k,M),H}}ie.Blob=R;class D extends r{constructor(v){super(-1,v)}getSpan(v,k=0){e(v);let M=k;for(;M<v.length&&v[M]!==0;)M+=1;return 1+M-k}decode(v,k=0){const M=this.getSpan(v,k);return n(v).slice(k,k+M-1).toString("utf-8")}encode(v,k,M=0){typeof v!="string"&&(v=String(v));const H=t.Buffer.from(v,"utf8"),Q=H.length;if(M+Q>k.length)throw new RangeError("encoding overruns Buffer");const X=n(k);return H.copy(X,M),X[M+Q]=0,Q+1}}ie.CString=D;class L extends r{constructor(v,k){if(typeof v=="string"&&k===void 0&&(k=v,v=void 0),v===void 0)v=-1;else if(!Number.isInteger(v))throw new TypeError("maxSpan must be an integer");super(-1,k),this.maxSpan=v}getSpan(v,k=0){return e(v),v.length-k}decode(v,k=0){const M=this.getSpan(v,k);if(0<=this.maxSpan&&this.maxSpan<M)throw new RangeError("text length exceeds maxSpan");return n(v).slice(k,k+M).toString("utf-8")}encode(v,k,M=0){typeof v!="string"&&(v=String(v));const H=t.Buffer.from(v,"utf8"),Q=H.length;if(0<=this.maxSpan&&this.maxSpan<Q)throw new RangeError("text length exceeds maxSpan");if(M+Q>k.length)throw new RangeError("encoding overruns Buffer");return H.copy(n(k),M),Q}}ie.UTF8=L;class O extends r{constructor(v,k){super(0,k),this.value=v}decode(v,k){return this.value}encode(v,k,M){return 0}}return ie.Constant=O,ie.greedy=((f,v)=>new a(f,v)),ie.offset=((f,v,k)=>new l(f,v,k)),ie.u8=(f=>new c(1,f)),ie.u16=(f=>new c(2,f)),ie.u24=(f=>new c(3,f)),ie.u32=(f=>new c(4,f)),ie.u40=(f=>new c(5,f)),ie.u48=(f=>new c(6,f)),ie.nu64=(f=>new x(f)),ie.u16be=(f=>new u(2,f)),ie.u24be=(f=>new u(3,f)),ie.u32be=(f=>new u(4,f)),ie.u40be=(f=>new u(5,f)),ie.u48be=(f=>new u(6,f)),ie.nu64be=(f=>new I(f)),ie.s8=(f=>new h(1,f)),ie.s16=(f=>new h(2,f)),ie.s24=(f=>new h(3,f)),ie.s32=(f=>new h(4,f)),ie.s40=(f=>new h(5,f)),ie.s48=(f=>new h(6,f)),ie.ns64=(f=>new N(f)),ie.s16be=(f=>new p(2,f)),ie.s24be=(f=>new p(3,f)),ie.s32be=(f=>new p(4,f)),ie.s40be=(f=>new p(5,f)),ie.s48be=(f=>new p(6,f)),ie.ns64be=(f=>new T(f)),ie.f32=(f=>new $(f)),ie.f32be=(f=>new B(f)),ie.f64=(f=>new G(f)),ie.f64be=(f=>new Z(f)),ie.struct=((f,v,k)=>new F(f,v,k)),ie.bits=((f,v,k)=>new y(f,v,k)),ie.seq=((f,v,k)=>new Y(f,v,k)),ie.union=((f,v,k)=>new W(f,v,k)),ie.unionLayoutDiscriminator=((f,v)=>new U(f,v)),ie.blob=((f,v)=>new R(f,v)),ie.cstr=(f=>new D(f)),ie.utf8=((f,v)=>new L(f,v)),ie.constant=((f,v)=>new O(f,v)),ie}var q=P$(),L$=1,M$=2,B$=3,F$=4,D$=5,V$=6,$$=7,z$=8,U$=9,W$=10,H$=-32700,j$=-32603,q$=-32602,G$=-32601,K$=-32600,Y$=-32016,X$=-32015,Z$=-32014,J$=-32013,Q$=-32012,ez=-32011,tz=-32010,nz=-32009,rz=-32008,iz=-32007,oz=-32006,sz=-32005,az=-32004,lz=-32003,cz=-32002,uz=-32001,dz=28e5,hz=2800001,fz=2800002,gz=2800003,pz=2800004,mz=2800005,vz=2800006,yz=2800007,bz=2800008,_z=2800009,xz=2800010,wz=2800011,Ez=323e4,Sz=32300001,Iz=3230002,Cz=3230003,Az=3230004,Oz=361e4,kz=3610001,Tz=3610002,Rz=3610003,Nz=3610004,Pz=3610005,Lz=3610006,Mz=3610007,Bz=3611e3,Fz=3704e3,Dz=3704001,Vz=3704002,$z=3704003,zz=3704004,Uz=4128e3,Wz=4128001,Hz=4128002,jz=4615e3,qz=4615001,Gz=4615002,Kz=4615003,Yz=4615004,Xz=4615005,Zz=4615006,Jz=4615007,Qz=4615008,eU=4615009,tU=4615010,nU=4615011,rU=4615012,iU=4615013,oU=4615014,sU=4615015,aU=4615016,lU=4615017,cU=4615018,uU=4615019,dU=4615020,hU=4615021,fU=4615022,gU=4615023,pU=4615024,mU=4615025,vU=4615026,yU=4615027,bU=4615028,_U=4615029,xU=4615030,wU=4615031,EU=4615032,SU=4615033,IU=4615034,CU=4615035,AU=4615036,OU=4615037,kU=4615038,TU=4615039,RU=4615040,NU=4615041,PU=4615042,LU=4615043,MU=4615044,BU=4615045,FU=4615046,DU=4615047,VU=4615048,$U=4615049,zU=4615050,UU=4615051,WU=4615052,HU=4615053,jU=4615054,qU=5508e3,GU=5508001,KU=5508002,YU=5508003,XU=5508004,ZU=5508005,JU=5508006,QU=5508007,eW=5508008,tW=5508009,nW=5508010,rW=5508011,iW=5663e3,oW=5663001,sW=5663002,aW=5663003,lW=5663004,cW=5663005,uW=5663006,dW=5663007,hW=5663008,fW=5663009,gW=5663010,pW=5663011,mW=5663012,vW=5663013,yW=5663014,bW=5663015,_W=5663016,xW=5663017,wW=5663018,EW=5663019,SW=5663020,IW=705e4,CW=7050001,AW=7050002,OW=7050003,kW=7050004,TW=7050005,RW=7050006,NW=7050007,PW=7050008,LW=7050009,MW=7050010,BW=7050011,FW=7050012,DW=7050013,VW=7050014,$W=7050015,zW=7050016,UW=7050017,WW=7050018,HW=7050019,jW=7050020,qW=7050021,GW=7050022,KW=7050023,YW=7050024,XW=7050025,ZW=7050026,JW=7050027,QW=7050028,e7=7050029,t7=7050030,n7=7050031,r7=7050032,i7=7050033,o7=7050034,s7=7050035,a7=7050036,_w=8078e3,xw=8078001,l7=8078002,c7=8078003,ww=8078004,Ew=8078005,Sw=8078006,u7=8078007,d7=8078008,h7=8078009,f7=8078010,Iw=8078011,g7=8078012,p7=8078013,m7=8078014,v7=8078015,y7=8078016,b7=8078017,_7=8078018,x7=8078019,w7=8078020,E7=8078021,S7=8078022,I7=81e5,C7=8100001,A7=8100002,O7=8100003,k7=819e4,T7=8190001,R7=8190002,N7=8190003,P7=8190004,L7=99e5,M7=9900001,B7=9900002,F7=9900003,D7=9900004;function Cw(t){return Array.isArray(t)?"%5B"+t.map(Cw).join("%2C%20")+"%5D":typeof t=="bigint"?`${t}n`:encodeURIComponent(String(t!=null&&Object.getPrototypeOf(t)===null?{...t}:t))}function V7([t,e]){return`${t}=${Cw(e)}`}function $7(t){const e=Object.entries(t).map(V7).join("&");return btoa(e)}var z7={[Ez]:"Account not found at address: $address",[Az]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[Cz]:"Expected decoded account at address: $address",[Iz]:"Failed to decode account data at address: $address",[Sz]:"Accounts not found at addresses: $addresses",[_z]:"Unable to find a viable program address bump seed.",[fz]:"$putativeAddress is not a base58-encoded address.",[dz]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[gz]:"The `CryptoKey` must be an `Ed25519` public key.",[wz]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[bz]:"Invalid seeds; point must fall off the Ed25519 curve.",[pz]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[vz]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[yz]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[mz]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[xz]:"Program address cannot end with PDA marker.",[hz]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[F$]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[L$]:"The network has progressed past the last block for which this transaction could have been committed.",[_w]:"Codec [$codecDescription] cannot decode empty byte arrays.",[S7]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[w7]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[Ew]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[Sw]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[ww]:"Encoder and decoder must either both be fixed-size or variable-size.",[d7]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[l7]:"Expected a fixed-size codec, got a variable-size one.",[p7]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[c7]:"Expected a variable-size codec, got a fixed-size one.",[x7]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[xw]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[_7]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[h7]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[f7]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[v7]:"Invalid literal union variant. Expected one of [$variants], got $value.",[u7]:"Expected [$codecDescription] to have $expected items, got $actual.",[g7]:"Invalid value $value for base $base with alphabet $alphabet.",[y7]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[Iw]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[m7]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[E7]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[b7]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[Bz]:"No random values implementation could be found.",[eU]:"instruction requires an uninitialized account",[gU]:"instruction tries to borrow reference for an account which is already borrowed",[pU]:"instruction left account with an outstanding borrowed reference",[hU]:"program other than the account's owner changed the size of the account data",[Xz]:"account data too small for instruction",[fU]:"instruction expected an executable account",[FU]:"An account does not have enough lamports to be rent-exempt",[VU]:"Program arithmetic overflowed",[BU]:"Failed to serialize or deserialize account data: $encodedData",[jU]:"Builtin programs must consume compute units",[EU]:"Cross-program invocation call depth too deep",[kU]:"Computational budget exceeded",[vU]:"custom program error: #$code",[lU]:"instruction contains duplicate accounts",[mU]:"instruction modifications of multiply-passed account differ",[xU]:"executable accounts must be rent exempt",[bU]:"instruction changed executable accounts data",[_U]:"instruction changed the balance of an executable account",[cU]:"instruction changed executable bit of an account",[oU]:"instruction modified data of an account it does not own",[iU]:"instruction spent from the balance of an account it does not own",[qz]:"generic instruction error",[zU]:"Provided owner is not allowed",[LU]:"Account is immutable",[MU]:"Incorrect authority provided",[Jz]:"incorrect program id for instruction",[Zz]:"insufficient funds for instruction",[Yz]:"invalid account data for instruction",[DU]:"Invalid account owner",[Gz]:"invalid program argument",[yU]:"program returned invalid error code",[Kz]:"invalid instruction data",[OU]:"Failed to reallocate account data",[AU]:"Provided seeds do not result in a valid address",[UU]:"Accounts data allocations exceeded the maximum allowed per transaction",[WU]:"Max accounts exceeded",[HU]:"Max instruction trace length exceeded",[CU]:"Length of the seed is too long for address generation",[SU]:"An account required by the instruction is missing",[Qz]:"missing required signature for instruction",[rU]:"instruction illegally modified the program id of an account",[dU]:"insufficient account keys for instruction",[TU]:"Cross-program invocation with unauthorized signer or writable account",[RU]:"Failed to create program execution environment",[PU]:"Program failed to compile",[NU]:"Program failed to complete",[aU]:"instruction modified data of a read-only account",[sU]:"instruction changed the balance of a read-only account",[IU]:"Cross-program invocation reentrancy not allowed for this instruction",[uU]:"instruction modified rent epoch of an account",[nU]:"sum of account balances before and after instruction do not match",[tU]:"instruction requires an initialized account",[jz]:"",[wU]:"Unsupported program id",[$U]:"Unsupported sysvar",[Uz]:"The instruction does not have any accounts.",[Wz]:"The instruction does not have any data.",[Hz]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[D$]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[M$]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[B7]:"Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[D7]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[M7]:"Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[L7]:"Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[F7]:"Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[j$]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[q$]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[K$]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[G$]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[H$]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[Q$]:"$__serverMessage",[uz]:"$__serverMessage",[az]:"$__serverMessage",[Z$]:"$__serverMessage",[tz]:"$__serverMessage",[nz]:"$__serverMessage",[Y$]:"Minimum context slot has not been reached",[sz]:"Node is unhealthy; behind by $numSlotsBehind slots",[rz]:"No snapshot",[cz]:"Transaction simulation failed",[iz]:"$__serverMessage",[ez]:"Transaction history is not available from this node",[oz]:"$__serverMessage",[J$]:"Transaction signature length mismatch",[lz]:"Transaction signature verification failure",[X$]:"$__serverMessage",[Fz]:"Key pair bytes must be of length 64, got $byteLength.",[Dz]:"Expected private key bytes with length 32. Actual length: $actualLength.",[Vz]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[zz]:"The provided private key does not match the provided public key.",[$z]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[V$]:"Lamports value must be in the range [0, 2e64-1]",[$$]:"`$value` cannot be parsed as a `BigInt`",[W$]:"$message",[z$]:"`$value` cannot be parsed as a `Number`",[B$]:"No nonce account could be found at address `$nonceAccountAddress`",[k7]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[R7]:"WebSocket was closed before payload could be added to the send buffer",[N7]:"WebSocket connection closed",[P7]:"WebSocket failed to connect",[T7]:"Failed to obtain a subscription id from the server",[O7]:"Could not find an API plan for RPC method: `$method`",[I7]:"The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",[A7]:"HTTP error ($statusCode): $message",[C7]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[qU]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[GU]:"The provided value does not implement the `KeyPairSigner` interface",[YU]:"The provided value does not implement the `MessageModifyingSigner` interface",[XU]:"The provided value does not implement the `MessagePartialSigner` interface",[KU]:"The provided value does not implement any of the `MessageSigner` interfaces",[JU]:"The provided value does not implement the `TransactionModifyingSigner` interface",[QU]:"The provided value does not implement the `TransactionPartialSigner` interface",[eW]:"The provided value does not implement the `TransactionSendingSigner` interface",[ZU]:"The provided value does not implement any of the `TransactionSigner` interfaces",[tW]:"More than one `TransactionSendingSigner` was identified.",[nW]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[rW]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[Mz]:"Cannot export a non-extractable key.",[kz]:"No digest implementation could be found.",[Oz]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[Tz]:`This runtime does not support the generation of Ed25519 key pairs.
218
218
 
219
219
  Install @solana/webcrypto-ed25519-polyfill and call its \`install\` function before generating keys in environments that do not support Ed25519.
220
220
 
@@ -225,8 +225,8 @@ ${JSON.stringify(i.slice(-10),null,2)}. `:"",s="\nCatch the `SendTransactionErro
225
225
  ${r}. `+o+s;break;case"simulate":a=`Simulation failed.
226
226
  Message: ${r}.
227
227
  `+o+s;break;default:a=`Unknown action '${(l=>l)(e)}'`}super(a),this.signature=void 0,this.transactionMessage=void 0,this.transactionLogs=void 0,this.signature=n,this.transactionMessage=r,this.transactionLogs=i||void 0}get transactionError(){return{message:this.transactionMessage,logs:Array.isArray(this.transactionLogs)?this.transactionLogs:void 0}}get logs(){const e=this.transactionLogs;if(!(e!=null&&typeof e=="object"&&"then"in e))return e}async getLogs(e){return Array.isArray(this.transactionLogs)||(this.transactionLogs=new Promise((n,r)=>{e.getTransaction(this.signature).then(i=>{if(i&&i.meta&&i.meta.logMessages){const o=i.meta.logMessages;this.transactionLogs=o,n(o)}else r(new Error("Log messages not found"))}).catch(r)})),await this.transactionLogs}}class Ee extends Error{constructor({code:e,message:n,data:r},i){super(i!=null?`${i}: ${n}`:n),this.code=void 0,this.data=void 0,this.code=e,this.data=r,this.name="SolanaJSONRPCError"}}function Xs(t){return new Promise(e=>setTimeout(e,t))}const l9=q.nu64("lamportsPerSignature"),eE=q.struct([q.u32("version"),q.u32("state"),ze("authorizedPubkey"),ze("nonce"),q.struct([l9],"feeCalculator")]);eE.span;class rp{constructor(e){this.authorizedPubkey=void 0,this.nonce=void 0,this.feeCalculator=void 0,this.authorizedPubkey=e.authorizedPubkey,this.nonce=e.nonce,this.feeCalculator=e.feeCalculator}static fromAccountData(e){const n=eE.decode(Gs(e),0);return new rp({authorizedPubkey:new Re(n.authorizedPubkey),nonce:new Re(n.nonce).toString(),feeCalculator:n.feeCalculator})}}function Zs(t){const e=q.blob(8,t),n=e.decode.bind(e),r=e.encode.bind(e),i=e,o=nH();return i.decode=(s,a)=>{const l=n(s,a);return o.decode(l)},i.encode=(s,a,l)=>{const c=o.encode(s);return r(c,a,l)},i}Object.freeze({Create:{index:0,layout:q.struct([q.u32("instruction"),q.ns64("lamports"),q.ns64("space"),ze("programId")])},Assign:{index:1,layout:q.struct([q.u32("instruction"),ze("programId")])},Transfer:{index:2,layout:q.struct([q.u32("instruction"),Zs("lamports")])},CreateWithSeed:{index:3,layout:q.struct([q.u32("instruction"),ze("base"),Ys("seed"),q.ns64("lamports"),q.ns64("space"),ze("programId")])},AdvanceNonceAccount:{index:4,layout:q.struct([q.u32("instruction")])},WithdrawNonceAccount:{index:5,layout:q.struct([q.u32("instruction"),q.ns64("lamports")])},InitializeNonceAccount:{index:6,layout:q.struct([q.u32("instruction"),ze("authorized")])},AuthorizeNonceAccount:{index:7,layout:q.struct([q.u32("instruction"),ze("authorized")])},Allocate:{index:8,layout:q.struct([q.u32("instruction"),q.ns64("space")])},AllocateWithSeed:{index:9,layout:q.struct([q.u32("instruction"),ze("base"),Ys("seed"),q.ns64("space"),ze("programId")])},AssignWithSeed:{index:10,layout:q.struct([q.u32("instruction"),ze("base"),Ys("seed"),ze("programId")])},TransferWithSeed:{index:11,layout:q.struct([q.u32("instruction"),Zs("lamports"),Ys("seed"),ze("programId")])},UpgradeNonceAccount:{index:12,layout:q.struct([q.u32("instruction")])}}),new Re("11111111111111111111111111111111"),new Re("BPFLoader2111111111111111111111111111111111");function c9(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ip,tE;function u9(){if(tE)return ip;tE=1;var t=Object.prototype.toString,e=Object.keys||function(r){var i=[];for(var o in r)i.push(o);return i};function n(r,i){var o,s,a,l,c,u,h;if(r===!0)return"true";if(r===!1)return"false";switch(typeof r){case"object":if(r===null)return null;if(r.toJSON&&typeof r.toJSON=="function")return n(r.toJSON(),i);if(h=t.call(r),h==="[object Array]"){for(a="[",s=r.length-1,o=0;o<s;o++)a+=n(r[o],!0)+",";return s>-1&&(a+=n(r[o],!0)),a+"]"}else if(h==="[object Object]"){for(l=e(r).sort(),s=l.length,a="",o=0;o<s;)c=l[o],u=n(r[c],!1),u!==void 0&&(a&&(a+=","),a+=JSON.stringify(c)+":"+u),o++;return"{"+a+"}"}else return JSON.stringify(r);case"function":case"undefined":return i?null:void 0;case"string":return JSON.stringify(r);default:return isFinite(r)?r:null}}return ip=function(r){var i=n(r,!1);if(i!==void 0)return""+i},ip}var d9=u9(),nE=c9(d9);const Cl=32;function op(t){let e=0;for(;t>1;)t/=2,e++;return e}function h9(t){return t===0?1:(t--,t|=t>>1,t|=t>>2,t|=t>>4,t|=t>>8,t|=t>>16,t|=t>>32,t+1)}class f9{constructor(e,n,r,i,o){this.slotsPerEpoch=void 0,this.leaderScheduleSlotOffset=void 0,this.warmup=void 0,this.firstNormalEpoch=void 0,this.firstNormalSlot=void 0,this.slotsPerEpoch=e,this.leaderScheduleSlotOffset=n,this.warmup=r,this.firstNormalEpoch=i,this.firstNormalSlot=o}getEpoch(e){return this.getEpochAndSlotIndex(e)[0]}getEpochAndSlotIndex(e){if(e<this.firstNormalSlot){const n=op(h9(e+Cl+1))-op(Cl)-1,r=this.getSlotsInEpoch(n),i=e-(r-Cl);return[n,i]}else{const n=e-this.firstNormalSlot,r=Math.floor(n/this.slotsPerEpoch),i=this.firstNormalEpoch+r,o=n%this.slotsPerEpoch;return[i,o]}}getFirstSlotInEpoch(e){return e<=this.firstNormalEpoch?(Math.pow(2,e)-1)*Cl:(e-this.firstNormalEpoch)*this.slotsPerEpoch+this.firstNormalSlot}getLastSlotInEpoch(e){return this.getFirstSlotInEpoch(e)+this.getSlotsInEpoch(e)-1}getSlotsInEpoch(e){return e<this.firstNormalEpoch?Math.pow(2,e+op(Cl)):this.slotsPerEpoch}}var g9=globalThis.fetch;class p9 extends BH{constructor(e,n,r){const i=o=>{const s=LH(o,{autoconnect:!0,max_reconnects:5,reconnect:!0,reconnect_interval:1e3,...n});return"socket"in s?this.underlyingSocket=s.socket:this.underlyingSocket=s,s};super(i,e,n,r),this.underlyingSocket=void 0}call(...e){var r;const n=(r=this.underlyingSocket)==null?void 0:r.readyState;return n===1?super.call(...e):Promise.reject(new Error("Tried to call a JSON-RPC method `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+n+")"))}notify(...e){var r;const n=(r=this.underlyingSocket)==null?void 0:r.readyState;return n===1?super.notify(...e):Promise.reject(new Error("Tried to send a JSON-RPC notification `"+e[0]+"` but the socket was not `CONNECTING` or `OPEN` (`readyState` was "+n+")"))}}function m9(t,e){let n;try{n=t.layout.decode(e)}catch(r){throw new Error("invalid instruction; "+r)}if(n.typeIndex!==t.index)throw new Error(`invalid account data; account type mismatch ${n.typeIndex} != ${t.index}`);return n}const rE=56;class iE{constructor(e){this.key=void 0,this.state=void 0,this.key=e.key,this.state=e.state}isActive(){const e=BigInt("0xffffffffffffffff");return this.state.deactivationSlot===e}static deserialize(e){const n=m9(v9,e),r=e.length-rE;pt(r>=0,"lookup table is invalid"),pt(r%32===0,"lookup table is invalid");const i=r/32,{addresses:o}=q.struct([q.seq(ze(),i,"addresses")]).decode(e.slice(rE));return{deactivationSlot:n.deactivationSlot,lastExtendedSlot:n.lastExtendedSlot,lastExtendedSlotStartIndex:n.lastExtendedStartIndex,authority:n.authority.length!==0?new Re(n.authority[0]):void 0,addresses:o.map(s=>new Re(s))}}}const v9={index:1,layout:q.struct([q.u32("typeIndex"),Zs("deactivationSlot"),q.nu64("lastExtendedSlot"),q.u8("lastExtendedStartIndex"),q.u8(),q.seq(ze(),q.offset(q.u8(),-1),"authority")])},y9=/^[^:]+:\/\/([^:[]+|\[[^\]]+\])(:\d+)?(.*)/i;function b9(t){const e=t.match(y9);if(e==null)throw TypeError(`Failed to validate endpoint URL \`${t}\``);const[n,r,i,o]=e,s=t.startsWith("https:")?"wss:":"ws:",a=i==null?null:parseInt(i.slice(1),10),l=a==null?"":`:${a+1}`;return`${s}//${r}${l}${o}`}const yt=El(Wg(Re),de(),t=>new Re(t)),oE=Hg([de(),vt("base64")]),sp=El(Wg($e.Buffer),oE,t=>$e.Buffer.from(t[0],"base64")),_9=30*1e3;function x9(t){if(/^https?:/.test(t)===!1)throw new TypeError("Endpoint URL must start with `http:` or `https:`.");return t}function ct(t){let e,n;if(typeof t=="string")e=t;else if(t){const{commitment:r,...i}=t;e=r,n=i}return{commitment:e,config:n}}function sE(t){return t.map(e=>{var n;return"memcmp"in e?{...e,memcmp:{...e.memcmp,encoding:(n=e.memcmp.encoding)!=null?n:"base58"}}:e})}function aE(t){return Nn([ce({jsonrpc:vt("2.0"),id:de(),result:t}),ce({jsonrpc:vt("2.0"),id:de(),error:ce({code:Hs(),message:de(),data:Ce(cH())})})])}const w9=aE(Hs());function Fe(t){return El(aE(t),w9,e=>"error"in e?e:{...e,result:he(e.result,t)})}function Ct(t){return Fe(ce({context:ce({slot:ne()}),value:t}))}function nd(t){return ce({context:ce({slot:ne()}),value:t})}function ap(t,e){return t===0?new Il({header:e.header,staticAccountKeys:e.accountKeys.map(n=>new Re(n)),recentBlockhash:e.recentBlockhash,compiledInstructions:e.instructions.map(n=>({programIdIndex:n.programIdIndex,accountKeyIndexes:n.accounts,data:mn.decode(n.data)})),addressTableLookups:e.addressTableLookups}):new Ii(e)}const E9=ce({foundation:ne(),foundationTerm:ne(),initial:ne(),taper:ne(),terminal:ne()}),S9=Fe(ge(pe(ce({epoch:ne(),effectiveSlot:ne(),amount:ne(),postBalance:ne(),commission:Ce(pe(ne()))})))),I9=ge(ce({slot:ne(),prioritizationFee:ne()})),C9=ce({total:ne(),validator:ne(),foundation:ne(),epoch:ne()}),A9=ce({epoch:ne(),slotIndex:ne(),slotsInEpoch:ne(),absoluteSlot:ne(),blockHeight:Ce(ne()),transactionCount:Ce(ne())}),O9=ce({slotsPerEpoch:ne(),leaderScheduleSlotOffset:ne(),warmup:Jr(),firstNormalEpoch:ne(),firstNormalSlot:ne()}),k9=Tw(de(),ge(ne())),$o=pe(Nn([ce({}),de()])),T9=ce({err:$o}),R9=vt("receivedSignature"),N9=ce({"solana-core":de(),"feature-set":Ce(ne())}),P9=ce({program:de(),programId:yt,parsed:Hs()}),L9=ce({programId:yt,accounts:ge(yt),data:de()}),lE=Ct(ce({err:pe(Nn([ce({}),de()])),logs:pe(ge(de())),accounts:Ce(pe(ge(pe(ce({executable:Jr(),owner:de(),lamports:ne(),data:ge(de()),rentEpoch:Ce(ne())}))))),unitsConsumed:Ce(ne()),returnData:Ce(pe(ce({programId:de(),data:Hg([de(),vt("base64")])}))),innerInstructions:Ce(pe(ge(ce({index:ne(),instructions:ge(Nn([P9,L9]))}))))})),M9=Ct(ce({byIdentity:Tw(de(),ge(ne())),range:ce({firstSlot:ne(),lastSlot:ne()})}));function B9(t,e,n,r,i,o){const s=n||g9;let a;o!=null&&console.warn("You have supplied an `httpAgent` when creating a `Connection` in a browser environment.It has been ignored; `httpAgent` is only used in Node environments.");let l;return r&&(l=async(u,h)=>{const p=await new Promise((g,b)=>{try{r(u,h,(m,x)=>g([m,x]))}catch(m){b(m)}});return await s(...p)}),new NH(async(u,h)=>{const p={method:"POST",body:u,agent:a,headers:Object.assign({"Content-Type":"application/json"},e||{},Bj)};try{let g=5,b,m=500;for(;l?b=await l(t,p):b=await s(t,p),!(b.status!==429||i===!0||(g-=1,g===0));)console.error(`Server responded with ${b.status} ${b.statusText}. Retrying after ${m}ms delay...`),await Xs(m),m*=2;const x=await b.text();b.ok?h(null,x):h(new Error(`${b.status} ${b.statusText}: ${x}`))}catch(g){g instanceof Error&&h(g)}},{})}function F9(t){return(e,n)=>new Promise((r,i)=>{t.request(e,n,(o,s)=>{if(o){i(o);return}r(s)})})}function D9(t){return e=>new Promise((n,r)=>{e.length===0&&n([]);const i=e.map(o=>t.request(o.methodName,o.args));t.request(i,(o,s)=>{if(o){r(o);return}n(s)})})}const V9=Fe(E9),$9=Fe(C9),z9=Fe(I9),U9=Fe(A9),W9=Fe(O9),H9=Fe(k9),j9=Fe(ne()),q9=Ct(ce({total:ne(),circulating:ne(),nonCirculating:ne(),nonCirculatingAccounts:ge(yt)})),lp=ce({amount:de(),uiAmount:pe(ne()),decimals:ne(),uiAmountString:Ce(de())}),G9=Ct(ge(ce({address:yt,amount:de(),uiAmount:pe(ne()),decimals:ne(),uiAmountString:Ce(de())}))),K9=Ct(ge(ce({pubkey:yt,account:ce({executable:Jr(),owner:yt,lamports:ne(),data:sp,rentEpoch:ne()})}))),cp=ce({program:de(),parsed:Hs(),space:ne()}),Y9=Ct(ge(ce({pubkey:yt,account:ce({executable:Jr(),owner:yt,lamports:ne(),data:cp,rentEpoch:ne()})}))),X9=Ct(ge(ce({lamports:ne(),address:yt}))),Al=ce({executable:Jr(),owner:yt,lamports:ne(),data:sp,rentEpoch:ne()}),Z9=ce({pubkey:yt,account:Al}),J9=El(Nn([Wg($e.Buffer),cp]),Nn([oE,cp]),t=>Array.isArray(t)?he(t,sp):t),up=ce({executable:Jr(),owner:yt,lamports:ne(),data:J9,rentEpoch:ne()}),Q9=ce({pubkey:yt,account:up}),ej=ce({state:Nn([vt("active"),vt("inactive"),vt("activating"),vt("deactivating")]),active:ne(),inactive:ne()}),tj=Fe(ge(ce({signature:de(),slot:ne(),err:$o,memo:pe(de()),blockTime:Ce(pe(ne()))}))),nj=Fe(ge(ce({signature:de(),slot:ne(),err:$o,memo:pe(de()),blockTime:Ce(pe(ne()))}))),rj=ce({subscription:ne(),result:nd(Al)}),ij=ce({pubkey:yt,account:Al}),oj=ce({subscription:ne(),result:nd(ij)}),sj=ce({parent:ne(),slot:ne(),root:ne()}),aj=ce({subscription:ne(),result:sj}),lj=Nn([ce({type:Nn([vt("firstShredReceived"),vt("completed"),vt("optimisticConfirmation"),vt("root")]),slot:ne(),timestamp:ne()}),ce({type:vt("createdBank"),parent:ne(),slot:ne(),timestamp:ne()}),ce({type:vt("frozen"),slot:ne(),timestamp:ne(),stats:ce({numTransactionEntries:ne(),numSuccessfulTransactions:ne(),numFailedTransactions:ne(),maxTransactionsPerEntry:ne()})}),ce({type:vt("dead"),slot:ne(),timestamp:ne(),err:de()})]),cj=ce({subscription:ne(),result:lj}),uj=ce({subscription:ne(),result:nd(Nn([T9,R9]))}),dj=ce({subscription:ne(),result:ne()}),hj=ce({pubkey:de(),gossip:pe(de()),tpu:pe(de()),rpc:pe(de()),version:pe(de())}),cE=ce({votePubkey:de(),nodePubkey:de(),activatedStake:ne(),epochVoteAccount:Jr(),epochCredits:ge(Hg([ne(),ne(),ne()])),commission:ne(),lastVote:ne(),rootSlot:pe(ne())}),fj=Fe(ce({current:ge(cE),delinquent:ge(cE)})),gj=Nn([vt("processed"),vt("confirmed"),vt("finalized")]),pj=ce({slot:ne(),confirmations:pe(ne()),err:$o,confirmationStatus:Ce(gj)}),mj=Ct(ge(pe(pj))),vj=Fe(ne()),uE=ce({accountKey:yt,writableIndexes:ge(ne()),readonlyIndexes:ge(ne())}),dp=ce({signatures:ge(de()),message:ce({accountKeys:ge(de()),header:ce({numRequiredSignatures:ne(),numReadonlySignedAccounts:ne(),numReadonlyUnsignedAccounts:ne()}),instructions:ge(ce({accounts:ge(ne()),data:de(),programIdIndex:ne()})),recentBlockhash:de(),addressTableLookups:Ce(ge(uE))})}),dE=ce({pubkey:yt,signer:Jr(),writable:Jr(),source:Ce(Nn([vt("transaction"),vt("lookupTable")]))}),hE=ce({accountKeys:ge(dE),signatures:ge(de())}),fE=ce({parsed:Hs(),program:de(),programId:yt}),gE=ce({accounts:ge(yt),data:de(),programId:yt}),yj=Nn([gE,fE]),bj=Nn([ce({parsed:Hs(),program:de(),programId:de()}),ce({accounts:ge(de()),data:de(),programId:de()})]),pE=El(yj,bj,t=>"accounts"in t?he(t,gE):he(t,fE)),mE=ce({signatures:ge(de()),message:ce({accountKeys:ge(dE),instructions:ge(pE),recentBlockhash:de(),addressTableLookups:Ce(pe(ge(uE)))})}),rd=ce({accountIndex:ne(),mint:de(),owner:Ce(de()),programId:Ce(de()),uiTokenAmount:lp}),vE=ce({writable:ge(yt),readonly:ge(yt)}),id=ce({err:$o,fee:ne(),innerInstructions:Ce(pe(ge(ce({index:ne(),instructions:ge(ce({accounts:ge(ne()),data:de(),programIdIndex:ne()}))})))),preBalances:ge(ne()),postBalances:ge(ne()),logMessages:Ce(pe(ge(de()))),preTokenBalances:Ce(pe(ge(rd))),postTokenBalances:Ce(pe(ge(rd))),loadedAddresses:Ce(vE),computeUnitsConsumed:Ce(ne()),costUnits:Ce(ne())}),hp=ce({err:$o,fee:ne(),innerInstructions:Ce(pe(ge(ce({index:ne(),instructions:ge(pE)})))),preBalances:ge(ne()),postBalances:ge(ne()),logMessages:Ce(pe(ge(de()))),preTokenBalances:Ce(pe(ge(rd))),postTokenBalances:Ce(pe(ge(rd))),loadedAddresses:Ce(vE),computeUnitsConsumed:Ce(ne()),costUnits:Ce(ne())}),Js=Nn([vt(0),vt("legacy")]),zo=ce({pubkey:de(),lamports:ne(),postBalance:pe(ne()),rewardType:pe(de()),commission:Ce(pe(ne()))}),_j=Fe(pe(ce({blockhash:de(),previousBlockhash:de(),parentSlot:ne(),transactions:ge(ce({transaction:dp,meta:pe(id),version:Ce(Js)})),rewards:Ce(ge(zo)),blockTime:pe(ne()),blockHeight:pe(ne())}))),xj=Fe(pe(ce({blockhash:de(),previousBlockhash:de(),parentSlot:ne(),rewards:Ce(ge(zo)),blockTime:pe(ne()),blockHeight:pe(ne())}))),wj=Fe(pe(ce({blockhash:de(),previousBlockhash:de(),parentSlot:ne(),transactions:ge(ce({transaction:hE,meta:pe(id),version:Ce(Js)})),rewards:Ce(ge(zo)),blockTime:pe(ne()),blockHeight:pe(ne())}))),Ej=Fe(pe(ce({blockhash:de(),previousBlockhash:de(),parentSlot:ne(),transactions:ge(ce({transaction:mE,meta:pe(hp),version:Ce(Js)})),rewards:Ce(ge(zo)),blockTime:pe(ne()),blockHeight:pe(ne())}))),Sj=Fe(pe(ce({blockhash:de(),previousBlockhash:de(),parentSlot:ne(),transactions:ge(ce({transaction:hE,meta:pe(hp),version:Ce(Js)})),rewards:Ce(ge(zo)),blockTime:pe(ne()),blockHeight:pe(ne())}))),Ij=Fe(pe(ce({blockhash:de(),previousBlockhash:de(),parentSlot:ne(),rewards:Ce(ge(zo)),blockTime:pe(ne()),blockHeight:pe(ne())}))),Cj=Fe(pe(ce({blockhash:de(),previousBlockhash:de(),parentSlot:ne(),transactions:ge(ce({transaction:dp,meta:pe(id)})),rewards:Ce(ge(zo)),blockTime:pe(ne())}))),yE=Fe(pe(ce({blockhash:de(),previousBlockhash:de(),parentSlot:ne(),signatures:ge(de()),blockTime:pe(ne())}))),fp=Fe(pe(ce({slot:ne(),meta:pe(id),blockTime:Ce(pe(ne())),transaction:dp,version:Ce(Js)}))),od=Fe(pe(ce({slot:ne(),transaction:mE,meta:pe(hp),blockTime:Ce(pe(ne())),version:Ce(Js)}))),Aj=Ct(ce({blockhash:de(),lastValidBlockHeight:ne()})),Oj=Ct(Jr()),kj=ce({slot:ne(),numTransactions:ne(),numSlots:ne(),samplePeriodSecs:ne()}),Tj=Fe(ge(kj)),Rj=Ct(pe(ce({feeCalculator:ce({lamportsPerSignature:ne()})}))),Nj=Fe(de()),Pj=Fe(de()),Lj=ce({err:$o,logs:ge(de()),signature:de()}),Mj=ce({result:nd(Lj),subscription:ne()}),Bj={"solana-client":"js/1.0.0-maintenance"};class Fj{constructor(e,n){this._commitment=void 0,this._confirmTransactionInitialTimeout=void 0,this._rpcEndpoint=void 0,this._rpcWsEndpoint=void 0,this._rpcClient=void 0,this._rpcRequest=void 0,this._rpcBatchRequest=void 0,this._rpcWebSocket=void 0,this._rpcWebSocketConnected=!1,this._rpcWebSocketHeartbeat=null,this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketGeneration=0,this._disableBlockhashCaching=!1,this._pollingBlockhash=!1,this._blockhashInfo={latestBlockhash:null,lastFetch:0,transactionSignatures:[],simulatedSignatures:[]},this._nextClientSubscriptionId=0,this._subscriptionDisposeFunctionsByClientSubscriptionId={},this._subscriptionHashByClientSubscriptionId={},this._subscriptionStateChangeCallbacksByHash={},this._subscriptionCallbacksByServerSubscriptionId={},this._subscriptionsByHash={},this._subscriptionsAutoDisposedByRpc=new Set,this.getBlockHeight=(()=>{const c={};return async u=>{var m;const{commitment:h,config:p}=ct(u),g=this._buildArgs([],h,void 0,p),b=nE(g);return c[b]=(m=c[b])!=null?m:(async()=>{try{const x=await this._rpcRequest("getBlockHeight",g),I=he(x,Fe(ne()));if("error"in I)throw new Ee(I.error,"failed to get block height information");return I.result}finally{delete c[b]}})(),await c[b]}})();let r,i,o,s,a,l;n&&typeof n=="string"?this._commitment=n:n&&(this._commitment=n.commitment,this._confirmTransactionInitialTimeout=n.confirmTransactionInitialTimeout,r=n.wsEndpoint,i=n.httpHeaders,o=n.fetch,s=n.fetchMiddleware,a=n.disableRetryOnRateLimit,l=n.httpAgent),this._rpcEndpoint=x9(e),this._rpcWsEndpoint=r||b9(e),this._rpcClient=B9(e,i,o,s,a,l),this._rpcRequest=F9(this._rpcClient),this._rpcBatchRequest=D9(this._rpcClient),this._rpcWebSocket=new p9(this._rpcWsEndpoint,{autoconnect:!1,max_reconnects:1/0}),this._rpcWebSocket.on("open",this._wsOnOpen.bind(this)),this._rpcWebSocket.on("error",this._wsOnError.bind(this)),this._rpcWebSocket.on("close",this._wsOnClose.bind(this)),this._rpcWebSocket.on("accountNotification",this._wsOnAccountNotification.bind(this)),this._rpcWebSocket.on("programNotification",this._wsOnProgramAccountNotification.bind(this)),this._rpcWebSocket.on("slotNotification",this._wsOnSlotNotification.bind(this)),this._rpcWebSocket.on("slotsUpdatesNotification",this._wsOnSlotUpdatesNotification.bind(this)),this._rpcWebSocket.on("signatureNotification",this._wsOnSignatureNotification.bind(this)),this._rpcWebSocket.on("rootNotification",this._wsOnRootNotification.bind(this)),this._rpcWebSocket.on("logsNotification",this._wsOnLogsNotification.bind(this))}get commitment(){return this._commitment}get rpcEndpoint(){return this._rpcEndpoint}async getBalanceAndContext(e,n){const{commitment:r,config:i}=ct(n),o=this._buildArgs([e.toBase58()],r,void 0,i),s=await this._rpcRequest("getBalance",o),a=he(s,Ct(ne()));if("error"in a)throw new Ee(a.error,`failed to get balance for ${e.toBase58()}`);return a.result}async getBalance(e,n){return await this.getBalanceAndContext(e,n).then(r=>r.value).catch(r=>{throw new Error("failed to get balance of account "+e.toBase58()+": "+r)})}async getBlockTime(e){const n=await this._rpcRequest("getBlockTime",[e]),r=he(n,Fe(pe(ne())));if("error"in r)throw new Ee(r.error,`failed to get block time for slot ${e}`);return r.result}async getMinimumLedgerSlot(){const e=await this._rpcRequest("minimumLedgerSlot",[]),n=he(e,Fe(ne()));if("error"in n)throw new Ee(n.error,"failed to get minimum ledger slot");return n.result}async getFirstAvailableBlock(){const e=await this._rpcRequest("getFirstAvailableBlock",[]),n=he(e,j9);if("error"in n)throw new Ee(n.error,"failed to get first available block");return n.result}async getSupply(e){let n={};typeof e=="string"?n={commitment:e}:e?n={...e,commitment:e&&e.commitment||this.commitment}:n={commitment:this.commitment};const r=await this._rpcRequest("getSupply",[n]),i=he(r,q9);if("error"in i)throw new Ee(i.error,"failed to get supply");return i.result}async getTokenSupply(e,n){const r=this._buildArgs([e.toBase58()],n),i=await this._rpcRequest("getTokenSupply",r),o=he(i,Ct(lp));if("error"in o)throw new Ee(o.error,"failed to get token supply");return o.result}async getTokenAccountBalance(e,n){const r=this._buildArgs([e.toBase58()],n),i=await this._rpcRequest("getTokenAccountBalance",r),o=he(i,Ct(lp));if("error"in o)throw new Ee(o.error,"failed to get token account balance");return o.result}async getTokenAccountsByOwner(e,n,r){const{commitment:i,config:o}=ct(r);let s=[e.toBase58()];"mint"in n?s.push({mint:n.mint.toBase58()}):s.push({programId:n.programId.toBase58()});const a=this._buildArgs(s,i,"base64",o),l=await this._rpcRequest("getTokenAccountsByOwner",a),c=he(l,K9);if("error"in c)throw new Ee(c.error,`failed to get token accounts owned by account ${e.toBase58()}`);return c.result}async getParsedTokenAccountsByOwner(e,n,r){let i=[e.toBase58()];"mint"in n?i.push({mint:n.mint.toBase58()}):i.push({programId:n.programId.toBase58()});const o=this._buildArgs(i,r,"jsonParsed"),s=await this._rpcRequest("getTokenAccountsByOwner",o),a=he(s,Y9);if("error"in a)throw new Ee(a.error,`failed to get token accounts owned by account ${e.toBase58()}`);return a.result}async getLargestAccounts(e){const n={...e,commitment:e&&e.commitment||this.commitment},r=n.filter||n.commitment?[n]:[],i=await this._rpcRequest("getLargestAccounts",r),o=he(i,X9);if("error"in o)throw new Ee(o.error,"failed to get largest accounts");return o.result}async getTokenLargestAccounts(e,n){const r=this._buildArgs([e.toBase58()],n),i=await this._rpcRequest("getTokenLargestAccounts",r),o=he(i,G9);if("error"in o)throw new Ee(o.error,"failed to get token largest accounts");return o.result}async getAccountInfoAndContext(e,n){const{commitment:r,config:i}=ct(n),o=this._buildArgs([e.toBase58()],r,"base64",i),s=await this._rpcRequest("getAccountInfo",o),a=he(s,Ct(pe(Al)));if("error"in a)throw new Ee(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getParsedAccountInfo(e,n){const{commitment:r,config:i}=ct(n),o=this._buildArgs([e.toBase58()],r,"jsonParsed",i),s=await this._rpcRequest("getAccountInfo",o),a=he(s,Ct(pe(up)));if("error"in a)throw new Ee(a.error,`failed to get info about account ${e.toBase58()}`);return a.result}async getAccountInfo(e,n){try{return(await this.getAccountInfoAndContext(e,n)).value}catch(r){throw new Error("failed to get info about account "+e.toBase58()+": "+r)}}async getMultipleParsedAccounts(e,n){const{commitment:r,config:i}=ct(n),o=e.map(c=>c.toBase58()),s=this._buildArgs([o],r,"jsonParsed",i),a=await this._rpcRequest("getMultipleAccounts",s),l=he(a,Ct(ge(pe(up))));if("error"in l)throw new Ee(l.error,`failed to get info for accounts ${o}`);return l.result}async getMultipleAccountsInfoAndContext(e,n){const{commitment:r,config:i}=ct(n),o=e.map(c=>c.toBase58()),s=this._buildArgs([o],r,"base64",i),a=await this._rpcRequest("getMultipleAccounts",s),l=he(a,Ct(ge(pe(Al))));if("error"in l)throw new Ee(l.error,`failed to get info for accounts ${o}`);return l.result}async getMultipleAccountsInfo(e,n){return(await this.getMultipleAccountsInfoAndContext(e,n)).value}async getStakeActivation(e,n,r){const{commitment:i,config:o}=ct(n),s=this._buildArgs([e.toBase58()],i,void 0,{...o,epoch:r!=null?r:o==null?void 0:o.epoch}),a=await this._rpcRequest("getStakeActivation",s),l=he(a,Fe(ej));if("error"in l)throw new Ee(l.error,`failed to get Stake Activation ${e.toBase58()}`);return l.result}async getProgramAccounts(e,n){const{commitment:r,config:i}=ct(n),{encoding:o,...s}=i||{},a=this._buildArgs([e.toBase58()],r,o||"base64",{...s,...s.filters?{filters:sE(s.filters)}:null}),l=await this._rpcRequest("getProgramAccounts",a),c=ge(Z9),u=s.withContext===!0?he(l,Ct(c)):he(l,Fe(c));if("error"in u)throw new Ee(u.error,`failed to get accounts owned by program ${e.toBase58()}`);return u.result}async getParsedProgramAccounts(e,n){const{commitment:r,config:i}=ct(n),o=this._buildArgs([e.toBase58()],r,"jsonParsed",i),s=await this._rpcRequest("getProgramAccounts",o),a=he(s,Fe(ge(Q9)));if("error"in a)throw new Ee(a.error,`failed to get accounts owned by program ${e.toBase58()}`);return a.result}async confirmTransaction(e,n){var o;let r;if(typeof e=="string")r=e;else{const s=e;if((o=s.abortSignal)!=null&&o.aborted)return Promise.reject(s.abortSignal.reason);r=s.signature}let i;try{i=mn.decode(r)}catch(s){throw new Error("signature must be base58 encoded: "+r)}return pt(i.length===64,"signature has invalid length"),typeof e=="string"?await this.confirmTransactionUsingLegacyTimeoutStrategy({commitment:n||this.commitment,signature:r}):"lastValidBlockHeight"in e?await this.confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:n||this.commitment,strategy:e}):await this.confirmTransactionUsingDurableNonceStrategy({commitment:n||this.commitment,strategy:e})}getCancellationPromise(e){return new Promise((n,r)=>{e!=null&&(e.aborted?r(e.reason):e.addEventListener("abort",()=>{r(e.reason)}))})}getTransactionConfirmationPromise({commitment:e,signature:n}){let r,i,o=!1;const s=new Promise((l,c)=>{try{r=this.onSignature(n,(h,p)=>{r=void 0;const g={context:p,value:h};l({__type:no.PROCESSED,response:g})},e);const u=new Promise(h=>{r==null?h():i=this._onSubscriptionStateChange(r,p=>{p==="subscribed"&&h()})});(async()=>{if(await u,o)return;const h=await this.getSignatureStatus(n);if(o||h==null)return;const{context:p,value:g}=h;if(g!=null)if(g!=null&&g.err)c(g.err);else{switch(e){case"confirmed":case"single":case"singleGossip":{if(g.confirmationStatus==="processed")return;break}case"finalized":case"max":case"root":{if(g.confirmationStatus==="processed"||g.confirmationStatus==="confirmed")return;break}case"processed":case"recent":}o=!0,l({__type:no.PROCESSED,response:{context:p,value:g}})}})()}catch(u){c(u)}});return{abortConfirmation:()=>{i&&(i(),i=void 0),r!=null&&(this.removeSignatureListener(r),r=void 0)},confirmationPromise:s}}async confirmTransactionUsingBlockHeightExceedanceStrategy({commitment:e,strategy:{abortSignal:n,lastValidBlockHeight:r,signature:i}}){let o=!1;const s=new Promise(h=>{const p=async()=>{try{return await this.getBlockHeight(e)}catch(g){return-1}};(async()=>{let g=await p();if(!o){for(;g<=r;)if(await Xs(1e3),o||(g=await p(),o))return;h({__type:no.BLOCKHEIGHT_EXCEEDED})}})()}),{abortConfirmation:a,confirmationPromise:l}=this.getTransactionConfirmationPromise({commitment:e,signature:i}),c=this.getCancellationPromise(n);let u;try{const h=await Promise.race([c,l,s]);if(h.__type===no.PROCESSED)u=h.response;else throw new Kw(i)}finally{o=!0,a()}return u}async confirmTransactionUsingDurableNonceStrategy({commitment:e,strategy:{abortSignal:n,minContextSlot:r,nonceAccountPubkey:i,nonceValue:o,signature:s}}){var g;let a=!1;const l=new Promise(b=>{let m=o,x=null;const I=async()=>{try{const{context:N,value:T}=await this.getNonceAndContext(i,{commitment:e,minContextSlot:r});return x=N.slot,T==null?void 0:T.nonce}catch(N){return m}};(async()=>{if(m=await I(),!a)for(;;){if(o!==m){b({__type:no.NONCE_INVALID,slotInWhichNonceDidAdvance:x});return}if(await Xs(2e3),a||(m=await I(),a))return}})()}),{abortConfirmation:c,confirmationPromise:u}=this.getTransactionConfirmationPromise({commitment:e,signature:s}),h=this.getCancellationPromise(n);let p;try{const b=await Promise.race([h,u,l]);if(b.__type===no.PROCESSED)p=b.response;else{let m;for(;;){const x=await this.getSignatureStatus(s);if(x==null)break;if(x.context.slot<((g=b.slotInWhichNonceDidAdvance)!=null?g:r)){await Xs(400);continue}m=x;break}if(m!=null&&m.value){const x=e||"finalized",{confirmationStatus:I}=m.value;switch(x){case"processed":case"recent":if(I!=="processed"&&I!=="confirmed"&&I!=="finalized")throw new Sl(s);break;case"confirmed":case"single":case"singleGossip":if(I!=="confirmed"&&I!=="finalized")throw new Sl(s);break;case"finalized":case"max":case"root":if(I!=="finalized")throw new Sl(s);break;default:}p={context:m.context,value:{err:m.value.err}}}else throw new Sl(s)}}finally{a=!0,c()}return p}async confirmTransactionUsingLegacyTimeoutStrategy({commitment:e,signature:n}){let r;const i=new Promise(l=>{let c=this._confirmTransactionInitialTimeout||6e4;switch(e){case"processed":case"recent":case"single":case"confirmed":case"singleGossip":{c=this._confirmTransactionInitialTimeout||3e4;break}}r=setTimeout(()=>l({__type:no.TIMED_OUT,timeoutMs:c}),c)}),{abortConfirmation:o,confirmationPromise:s}=this.getTransactionConfirmationPromise({commitment:e,signature:n});let a;try{const l=await Promise.race([s,i]);if(l.__type===no.PROCESSED)a=l.response;else throw new Yw(n,l.timeoutMs/1e3)}finally{clearTimeout(r),o()}return a}async getClusterNodes(){const e=await this._rpcRequest("getClusterNodes",[]),n=he(e,Fe(ge(hj)));if("error"in n)throw new Ee(n.error,"failed to get cluster nodes");return n.result}async getVoteAccounts(e){const n=this._buildArgs([],e),r=await this._rpcRequest("getVoteAccounts",n),i=he(r,fj);if("error"in i)throw new Ee(i.error,"failed to get vote accounts");return i.result}async getSlot(e){const{commitment:n,config:r}=ct(e),i=this._buildArgs([],n,void 0,r),o=await this._rpcRequest("getSlot",i),s=he(o,Fe(ne()));if("error"in s)throw new Ee(s.error,"failed to get slot");return s.result}async getSlotLeader(e){const{commitment:n,config:r}=ct(e),i=this._buildArgs([],n,void 0,r),o=await this._rpcRequest("getSlotLeader",i),s=he(o,Fe(de()));if("error"in s)throw new Ee(s.error,"failed to get slot leader");return s.result}async getSlotLeaders(e,n){const r=[e,n],i=await this._rpcRequest("getSlotLeaders",r),o=he(i,Fe(ge(yt)));if("error"in o)throw new Ee(o.error,"failed to get slot leaders");return o.result}async getSignatureStatus(e,n){const{context:r,value:i}=await this.getSignatureStatuses([e],n);pt(i.length===1);const o=i[0];return{context:r,value:o}}async getSignatureStatuses(e,n){const r=[e];n&&r.push(n);const i=await this._rpcRequest("getSignatureStatuses",r),o=he(i,mj);if("error"in o)throw new Ee(o.error,"failed to get signature status");return o.result}async getTransactionCount(e){const{commitment:n,config:r}=ct(e),i=this._buildArgs([],n,void 0,r),o=await this._rpcRequest("getTransactionCount",i),s=he(o,Fe(ne()));if("error"in s)throw new Ee(s.error,"failed to get transaction count");return s.result}async getTotalSupply(e){return(await this.getSupply({commitment:e,excludeNonCirculatingAccountsList:!0})).value.total}async getInflationGovernor(e){const n=this._buildArgs([],e),r=await this._rpcRequest("getInflationGovernor",n),i=he(r,V9);if("error"in i)throw new Ee(i.error,"failed to get inflation");return i.result}async getInflationReward(e,n,r){const{commitment:i,config:o}=ct(r),s=this._buildArgs([e.map(c=>c.toBase58())],i,void 0,{...o,epoch:n!=null?n:o==null?void 0:o.epoch}),a=await this._rpcRequest("getInflationReward",s),l=he(a,S9);if("error"in l)throw new Ee(l.error,"failed to get inflation reward");return l.result}async getInflationRate(){const e=await this._rpcRequest("getInflationRate",[]),n=he(e,$9);if("error"in n)throw new Ee(n.error,"failed to get inflation rate");return n.result}async getEpochInfo(e){const{commitment:n,config:r}=ct(e),i=this._buildArgs([],n,void 0,r),o=await this._rpcRequest("getEpochInfo",i),s=he(o,U9);if("error"in s)throw new Ee(s.error,"failed to get epoch info");return s.result}async getEpochSchedule(){const e=await this._rpcRequest("getEpochSchedule",[]),n=he(e,W9);if("error"in n)throw new Ee(n.error,"failed to get epoch schedule");const r=n.result;return new f9(r.slotsPerEpoch,r.leaderScheduleSlotOffset,r.warmup,r.firstNormalEpoch,r.firstNormalSlot)}async getLeaderSchedule(){const e=await this._rpcRequest("getLeaderSchedule",[]),n=he(e,H9);if("error"in n)throw new Ee(n.error,"failed to get leader schedule");return n.result}async getMinimumBalanceForRentExemption(e,n){const r=this._buildArgs([e],n),i=await this._rpcRequest("getMinimumBalanceForRentExemption",r),o=he(i,vj);return"error"in o?(console.warn("Unable to fetch minimum balance for rent exemption"),0):o.result}async getRecentBlockhashAndContext(e){const{context:n,value:{blockhash:r}}=await this.getLatestBlockhashAndContext(e);return{context:n,value:{blockhash:r,feeCalculator:{get lamportsPerSignature(){throw new Error("The capability to fetch `lamportsPerSignature` using the `getRecentBlockhash` API is no longer offered by the network. Use the `getFeeForMessage` API to obtain the fee for a given message.")},toJSON(){return{}}}}}}async getRecentPerformanceSamples(e){const n=await this._rpcRequest("getRecentPerformanceSamples",e?[e]:[]),r=he(n,Tj);if("error"in r)throw new Ee(r.error,"failed to get recent performance samples");return r.result}async getFeeCalculatorForBlockhash(e,n){const r=this._buildArgs([e],n),i=await this._rpcRequest("getFeeCalculatorForBlockhash",r),o=he(i,Rj);if("error"in o)throw new Ee(o.error,"failed to get fee calculator");const{context:s,value:a}=o.result;return{context:s,value:a!==null?a.feeCalculator:null}}async getFeeForMessage(e,n){const r=Gs(e.serialize()).toString("base64"),i=this._buildArgs([r],n),o=await this._rpcRequest("getFeeForMessage",i),s=he(o,Ct(pe(ne())));if("error"in s)throw new Ee(s.error,"failed to get fee for message");if(s.result===null)throw new Error("invalid blockhash");return s.result}async getRecentPrioritizationFees(e){var s;const n=(s=e==null?void 0:e.lockedWritableAccounts)==null?void 0:s.map(a=>a.toBase58()),r=n!=null&&n.length?[n]:[],i=await this._rpcRequest("getRecentPrioritizationFees",r),o=he(i,z9);if("error"in o)throw new Ee(o.error,"failed to get recent prioritization fees");return o.result}async getRecentBlockhash(e){try{return(await this.getRecentBlockhashAndContext(e)).value}catch(n){throw new Error("failed to get recent blockhash: "+n)}}async getLatestBlockhash(e){try{return(await this.getLatestBlockhashAndContext(e)).value}catch(n){throw new Error("failed to get recent blockhash: "+n)}}async getLatestBlockhashAndContext(e){const{commitment:n,config:r}=ct(e),i=this._buildArgs([],n,void 0,r),o=await this._rpcRequest("getLatestBlockhash",i),s=he(o,Aj);if("error"in s)throw new Ee(s.error,"failed to get latest blockhash");return s.result}async isBlockhashValid(e,n){const{commitment:r,config:i}=ct(n),o=this._buildArgs([e],r,void 0,i),s=await this._rpcRequest("isBlockhashValid",o),a=he(s,Oj);if("error"in a)throw new Ee(a.error,"failed to determine if the blockhash `"+e+"`is valid");return a.result}async getVersion(){const e=await this._rpcRequest("getVersion",[]),n=he(e,Fe(N9));if("error"in n)throw new Ee(n.error,"failed to get version");return n.result}async getGenesisHash(){const e=await this._rpcRequest("getGenesisHash",[]),n=he(e,Fe(de()));if("error"in n)throw new Ee(n.error,"failed to get genesis hash");return n.result}async getBlock(e,n){const{commitment:r,config:i}=ct(n),o=this._buildArgsAtLeastConfirmed([e],r,void 0,i),s=await this._rpcRequest("getBlock",o);try{switch(i==null?void 0:i.transactionDetails){case"accounts":{const a=he(s,wj);if("error"in a)throw a.error;return a.result}case"none":{const a=he(s,xj);if("error"in a)throw a.error;return a.result}default:{const a=he(s,_j);if("error"in a)throw a.error;const{result:l}=a;return l?{...l,transactions:l.transactions.map(({transaction:c,meta:u,version:h})=>({meta:u,transaction:{...c,message:ap(h,c.message)},version:h}))}:null}}}catch(a){throw new Ee(a,"failed to get confirmed block")}}async getParsedBlock(e,n){const{commitment:r,config:i}=ct(n),o=this._buildArgsAtLeastConfirmed([e],r,"jsonParsed",i),s=await this._rpcRequest("getBlock",o);try{switch(i==null?void 0:i.transactionDetails){case"accounts":{const a=he(s,Sj);if("error"in a)throw a.error;return a.result}case"none":{const a=he(s,Ij);if("error"in a)throw a.error;return a.result}default:{const a=he(s,Ej);if("error"in a)throw a.error;return a.result}}}catch(a){throw new Ee(a,"failed to get block")}}async getBlockProduction(e){let n,r;if(typeof e=="string")r=e;else if(e){const{commitment:a,...l}=e;r=a,n=l}const i=this._buildArgs([],r,"base64",n),o=await this._rpcRequest("getBlockProduction",i),s=he(o,M9);if("error"in s)throw new Ee(s.error,"failed to get block production information");return s.result}async getTransaction(e,n){const{commitment:r,config:i}=ct(n),o=this._buildArgsAtLeastConfirmed([e],r,void 0,i),s=await this._rpcRequest("getTransaction",o),a=he(s,fp);if("error"in a)throw new Ee(a.error,"failed to get transaction");const l=a.result;return l&&{...l,transaction:{...l.transaction,message:ap(l.version,l.transaction.message)}}}async getParsedTransaction(e,n){const{commitment:r,config:i}=ct(n),o=this._buildArgsAtLeastConfirmed([e],r,"jsonParsed",i),s=await this._rpcRequest("getTransaction",o),a=he(s,od);if("error"in a)throw new Ee(a.error,"failed to get transaction");return a.result}async getParsedTransactions(e,n){const{commitment:r,config:i}=ct(n),o=e.map(l=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([l],r,"jsonParsed",i)}));return(await this._rpcBatchRequest(o)).map(l=>{const c=he(l,od);if("error"in c)throw new Ee(c.error,"failed to get transactions");return c.result})}async getTransactions(e,n){const{commitment:r,config:i}=ct(n),o=e.map(l=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([l],r,void 0,i)}));return(await this._rpcBatchRequest(o)).map(l=>{const c=he(l,fp);if("error"in c)throw new Ee(c.error,"failed to get transactions");const u=c.result;return u&&{...u,transaction:{...u.transaction,message:ap(u.version,u.transaction.message)}}})}async getConfirmedBlock(e,n){const r=this._buildArgsAtLeastConfirmed([e],n),i=await this._rpcRequest("getBlock",r),o=he(i,Cj);if("error"in o)throw new Ee(o.error,"failed to get confirmed block");const s=o.result;if(!s)throw new Error("Confirmed block "+e+" not found");const a={...s,transactions:s.transactions.map(({transaction:l,meta:c})=>{const u=new Ii(l.message);return{meta:c,transaction:{...l,message:u}}})};return{...a,transactions:a.transactions.map(({transaction:l,meta:c})=>({meta:c,transaction:cr.populate(l.message,l.signatures)}))}}async getBlocks(e,n,r){const i=this._buildArgsAtLeastConfirmed(n!==void 0?[e,n]:[e],r),o=await this._rpcRequest("getBlocks",i),s=he(o,Fe(ge(ne())));if("error"in s)throw new Ee(s.error,"failed to get blocks");return s.result}async getBlockSignatures(e,n){const r=this._buildArgsAtLeastConfirmed([e],n,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",r),o=he(i,yE);if("error"in o)throw new Ee(o.error,"failed to get block");const s=o.result;if(!s)throw new Error("Block "+e+" not found");return s}async getConfirmedBlockSignatures(e,n){const r=this._buildArgsAtLeastConfirmed([e],n,void 0,{transactionDetails:"signatures",rewards:!1}),i=await this._rpcRequest("getBlock",r),o=he(i,yE);if("error"in o)throw new Ee(o.error,"failed to get confirmed block");const s=o.result;if(!s)throw new Error("Confirmed block "+e+" not found");return s}async getConfirmedTransaction(e,n){const r=this._buildArgsAtLeastConfirmed([e],n),i=await this._rpcRequest("getTransaction",r),o=he(i,fp);if("error"in o)throw new Ee(o.error,"failed to get transaction");const s=o.result;if(!s)return s;const a=new Ii(s.transaction.message),l=s.transaction.signatures;return{...s,transaction:cr.populate(a,l)}}async getParsedConfirmedTransaction(e,n){const r=this._buildArgsAtLeastConfirmed([e],n,"jsonParsed"),i=await this._rpcRequest("getTransaction",r),o=he(i,od);if("error"in o)throw new Ee(o.error,"failed to get confirmed transaction");return o.result}async getParsedConfirmedTransactions(e,n){const r=e.map(s=>({methodName:"getTransaction",args:this._buildArgsAtLeastConfirmed([s],n,"jsonParsed")}));return(await this._rpcBatchRequest(r)).map(s=>{const a=he(s,od);if("error"in a)throw new Ee(a.error,"failed to get confirmed transactions");return a.result})}async getConfirmedSignaturesForAddress(e,n,r){let i={},o=await this.getFirstAvailableBlock();for(;!("until"in i)&&(n--,!(n<=0||n<o));)try{const l=await this.getConfirmedBlockSignatures(n,"finalized");l.signatures.length>0&&(i.until=l.signatures[l.signatures.length-1].toString())}catch(l){if(l instanceof Error&&l.message.includes("skipped"))continue;throw l}let s=await this.getSlot("finalized");for(;!("before"in i)&&(r++,!(r>s));)try{const l=await this.getConfirmedBlockSignatures(r);l.signatures.length>0&&(i.before=l.signatures[l.signatures.length-1].toString())}catch(l){if(l instanceof Error&&l.message.includes("skipped"))continue;throw l}return(await this.getConfirmedSignaturesForAddress2(e,i)).map(l=>l.signature)}async getConfirmedSignaturesForAddress2(e,n,r){const i=this._buildArgsAtLeastConfirmed([e.toBase58()],r,void 0,n),o=await this._rpcRequest("getConfirmedSignaturesForAddress2",i),s=he(o,tj);if("error"in s)throw new Ee(s.error,"failed to get confirmed signatures for address");return s.result}async getSignaturesForAddress(e,n,r){const i=this._buildArgsAtLeastConfirmed([e.toBase58()],r,void 0,n),o=await this._rpcRequest("getSignaturesForAddress",i),s=he(o,nj);if("error"in s)throw new Ee(s.error,"failed to get signatures for address");return s.result}async getAddressLookupTable(e,n){const{context:r,value:i}=await this.getAccountInfoAndContext(e,n);let o=null;return i!==null&&(o=new iE({key:e,state:iE.deserialize(i.data)})),{context:r,value:o}}async getNonceAndContext(e,n){const{context:r,value:i}=await this.getAccountInfoAndContext(e,n);let o=null;return i!==null&&(o=rp.fromAccountData(i.data)),{context:r,value:o}}async getNonce(e,n){return await this.getNonceAndContext(e,n).then(r=>r.value).catch(r=>{throw new Error("failed to get nonce for account "+e.toBase58()+": "+r)})}async requestAirdrop(e,n){const r=await this._rpcRequest("requestAirdrop",[e.toBase58(),n]),i=he(r,Nj);if("error"in i)throw new Ee(i.error,`airdrop to ${e.toBase58()} failed`);return i.result}async _blockhashWithExpiryBlockHeight(e){if(!e){for(;this._pollingBlockhash;)await Xs(100);const r=Date.now()-this._blockhashInfo.lastFetch>=_9;if(this._blockhashInfo.latestBlockhash!==null&&!r)return this._blockhashInfo.latestBlockhash}return await this._pollNewBlockhash()}async _pollNewBlockhash(){this._pollingBlockhash=!0;try{const e=Date.now(),n=this._blockhashInfo.latestBlockhash,r=n?n.blockhash:null;for(let i=0;i<50;i++){const o=await this.getLatestBlockhash("finalized");if(r!==o.blockhash)return this._blockhashInfo={latestBlockhash:o,lastFetch:Date.now(),transactionSignatures:[],simulatedSignatures:[]},o;await Xs(a9/2)}throw new Error(`Unable to obtain a new blockhash after ${Date.now()-e}ms`)}finally{this._pollingBlockhash=!1}}async getStakeMinimumDelegation(e){const{commitment:n,config:r}=ct(e),i=this._buildArgs([],n,"base64",r),o=await this._rpcRequest("getStakeMinimumDelegation",i),s=he(o,Ct(ne()));if("error"in s)throw new Ee(s.error,"failed to get stake minimum delegation");return s.result}async simulateTransaction(e,n,r){if("message"in e){const m=e.serialize(),x=$e.Buffer.from(m).toString("base64");if(Array.isArray(n)||r!==void 0)throw new Error("Invalid arguments");const I=n||{};I.encoding="base64","commitment"in I||(I.commitment=this.commitment),n&&typeof n=="object"&&"innerInstructions"in n&&(I.innerInstructions=n.innerInstructions);const N=[x,I],T=await this._rpcRequest("simulateTransaction",N),$=he(T,lE);if("error"in $)throw new Error("failed to simulate transaction: "+$.error.message);return $.result}let i;if(e instanceof cr){let b=e;i=new cr,i.feePayer=b.feePayer,i.instructions=e.instructions,i.nonceInfo=b.nonceInfo,i.signatures=b.signatures}else i=cr.populate(e),i._message=i._json=void 0;if(n!==void 0&&!Array.isArray(n))throw new Error("Invalid arguments");const o=n;if(i.nonceInfo&&o)i.sign(...o);else{let b=this._disableBlockhashCaching;for(;;){const m=await this._blockhashWithExpiryBlockHeight(b);if(i.lastValidBlockHeight=m.lastValidBlockHeight,i.recentBlockhash=m.blockhash,!o)break;if(i.sign(...o),!i.signature)throw new Error("!signature");const x=i.signature.toString("base64");if(!this._blockhashInfo.simulatedSignatures.includes(x)&&!this._blockhashInfo.transactionSignatures.includes(x)){this._blockhashInfo.simulatedSignatures.push(x);break}else b=!0}}const s=i._compile(),a=s.serialize(),c=i._serialize(a).toString("base64"),u={encoding:"base64",commitment:this.commitment};if(r){const b=(Array.isArray(r)?r:s.nonProgramIds()).map(m=>m.toBase58());u.accounts={encoding:"base64",addresses:b}}o&&(u.sigVerify=!0),n&&typeof n=="object"&&"innerInstructions"in n&&(u.innerInstructions=n.innerInstructions);const h=[c,u],p=await this._rpcRequest("simulateTransaction",h),g=he(p,lE);if("error"in g){let b;if("data"in g.error&&(b=g.error.data.logs,b&&Array.isArray(b))){const m=`
228
- `,x=m+b.join(m);console.error(g.error.message,x)}throw new Qw({action:"simulate",signature:"",transactionMessage:g.error.message,logs:b})}return g.result}async sendTransaction(e,n,r){if("version"in e){if(n&&Array.isArray(n))throw new Error("Invalid arguments");const s=e.serialize();return await this.sendRawTransaction(s,n)}if(n===void 0||!Array.isArray(n))throw new Error("Invalid arguments");const i=n;if(e.nonceInfo)e.sign(...i);else{let s=this._disableBlockhashCaching;for(;;){const a=await this._blockhashWithExpiryBlockHeight(s);if(e.lastValidBlockHeight=a.lastValidBlockHeight,e.recentBlockhash=a.blockhash,e.sign(...i),!e.signature)throw new Error("!signature");const l=e.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(l))s=!0;else{this._blockhashInfo.transactionSignatures.push(l);break}}}const o=e.serialize();return await this.sendRawTransaction(o,r)}async sendRawTransaction(e,n){const r=Gs(e).toString("base64");return await this.sendEncodedTransaction(r,n)}async sendEncodedTransaction(e,n){const r={encoding:"base64"},i=n&&n.skipPreflight,o=i===!0?"processed":n&&n.preflightCommitment||this.commitment;n&&n.maxRetries!=null&&(r.maxRetries=n.maxRetries),n&&n.minContextSlot!=null&&(r.minContextSlot=n.minContextSlot),i&&(r.skipPreflight=i),o&&(r.preflightCommitment=o);const s=[e,r],a=await this._rpcRequest("sendTransaction",s),l=he(a,Pj);if("error"in l){let c;throw"data"in l.error&&(c=l.error.data.logs),new Qw({action:i?"send":"simulate",signature:"",transactionMessage:l.error.message,logs:c})}return l.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch(e){}})()},5e3),this._updateSubscriptions()}_wsOnError(e){this._rpcWebSocketConnected=!1,console.error("ws error:",e.message)}_wsOnClose(e){if(this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%Number.MAX_SAFE_INTEGER,this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null),this._rpcWebSocketHeartbeat&&(clearInterval(this._rpcWebSocketHeartbeat),this._rpcWebSocketHeartbeat=null),e===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([n,r])=>{this._setSubscription(n,{...r,state:"pending"})})}_setSubscription(e,n){var i;const r=(i=this._subscriptionsByHash[e])==null?void 0:i.state;if(this._subscriptionsByHash[e]=n,r!==n.state){const o=this._subscriptionStateChangeCallbacksByHash[e];o&&o.forEach(s=>{try{s(n.state)}catch(a){}})}}_onSubscriptionStateChange(e,n){var o;const r=this._subscriptionHashByClientSubscriptionId[e];if(r==null)return()=>{};const i=(o=this._subscriptionStateChangeCallbacksByHash)[r]||(o[r]=new Set);return i.add(n),()=>{i.delete(n),i.size===0&&delete this._subscriptionStateChangeCallbacksByHash[r]}}async _updateSubscriptions(){if(Object.keys(this._subscriptionsByHash).length===0){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(r){r instanceof Error&&console.log(`Error when closing socket connection: ${r.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}const e=this._rpcWebSocketGeneration,n=()=>e===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async r=>{const i=this._subscriptionsByHash[r];if(i!==void 0)switch(i.state){case"pending":case"unsubscribed":if(i.callbacks.size===0){delete this._subscriptionsByHash[r],i.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[i.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{const{args:o,method:s}=i;try{this._setSubscription(r,{...i,state:"subscribing"});const a=await this._rpcWebSocket.call(s,o);this._setSubscription(r,{...i,serverSubscriptionId:a,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[a]=i.callbacks,await this._updateSubscriptions()}catch(a){if(console.error(`Received ${a instanceof Error?"":"JSON-RPC "}error calling \`${s}\``,{args:o,error:a}),!n())return;this._setSubscription(r,{...i,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":i.callbacks.size===0&&await(async()=>{const{serverSubscriptionId:o,unsubscribeMethod:s}=i;if(this._subscriptionsAutoDisposedByRpc.has(o))this._subscriptionsAutoDisposedByRpc.delete(o);else{this._setSubscription(r,{...i,state:"unsubscribing"}),this._setSubscription(r,{...i,state:"unsubscribing"});try{await this._rpcWebSocket.call(s,[o])}catch(a){if(a instanceof Error&&console.error(`${s} error:`,a.message),!n())return;this._setSubscription(r,{...i,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(r,{...i,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(e,n){const r=this._subscriptionCallbacksByServerSubscriptionId[e];r!==void 0&&r.forEach(i=>{try{i(...n)}catch(o){console.error(o)}})}_wsOnAccountNotification(e){const{result:n,subscription:r}=he(e,rj);this._handleServerNotification(r,[n.value,n.context])}_makeSubscription(e,n){const r=this._nextClientSubscriptionId++,i=nE([e.method,n]),o=this._subscriptionsByHash[i];return o===void 0?this._subscriptionsByHash[i]={...e,args:n,callbacks:new Set([e.callback]),state:"pending"}:o.callbacks.add(e.callback),this._subscriptionHashByClientSubscriptionId[r]=i,this._subscriptionDisposeFunctionsByClientSubscriptionId[r]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[r],delete this._subscriptionHashByClientSubscriptionId[r];const s=this._subscriptionsByHash[i];pt(s!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${r}`),s.callbacks.delete(e.callback),await this._updateSubscriptions()},this._updateSubscriptions(),r}onAccountChange(e,n,r){const{commitment:i,config:o}=ct(r),s=this._buildArgs([e.toBase58()],i||this._commitment||"finalized","base64",o);return this._makeSubscription({callback:n,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},s)}async removeAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"account change")}_wsOnProgramAccountNotification(e){const{result:n,subscription:r}=he(e,oj);this._handleServerNotification(r,[{accountId:n.value.pubkey,accountInfo:n.value.account},n.context])}onProgramAccountChange(e,n,r,i){const{commitment:o,config:s}=ct(r),a=this._buildArgs([e.toBase58()],o||this._commitment||"finalized","base64",s||(i?{filters:sE(i)}:void 0));return this._makeSubscription({callback:n,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},a)}async removeProgramAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"program account change")}onLogs(e,n,r){const i=this._buildArgs([typeof e=="object"?{mentions:[e.toString()]}:e],r||this._commitment||"finalized");return this._makeSubscription({callback:n,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},i)}async removeOnLogsListener(e){await this._unsubscribeClientSubscription(e,"logs")}_wsOnLogsNotification(e){const{result:n,subscription:r}=he(e,Mj);this._handleServerNotification(r,[n.value,n.context])}_wsOnSlotNotification(e){const{result:n,subscription:r}=he(e,aj);this._handleServerNotification(r,[n])}onSlotChange(e){return this._makeSubscription({callback:e,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(e){await this._unsubscribeClientSubscription(e,"slot change")}_wsOnSlotUpdatesNotification(e){const{result:n,subscription:r}=he(e,cj);this._handleServerNotification(r,[n])}onSlotUpdate(e){return this._makeSubscription({callback:e,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(e){await this._unsubscribeClientSubscription(e,"slot update")}async _unsubscribeClientSubscription(e,n){const r=this._subscriptionDisposeFunctionsByClientSubscriptionId[e];r?await r():console.warn(`Ignored unsubscribe request because an active subscription with id \`${e}\` for '${n}' events could not be found.`)}_buildArgs(e,n,r,i){const o=n||this._commitment;if(o||r||i){let s={};r&&(s.encoding=r),o&&(s.commitment=o),i&&(s=Object.assign(s,i)),e.push(s)}return e}_buildArgsAtLeastConfirmed(e,n,r,i){const o=n||this._commitment;if(o&&!["confirmed","finalized"].includes(o))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(e,n,r,i)}_wsOnSignatureNotification(e){const{result:n,subscription:r}=he(e,uj);n.value!=="receivedSignature"&&this._subscriptionsAutoDisposedByRpc.add(r),this._handleServerNotification(r,n.value==="receivedSignature"?[{type:"received"},n.context]:[{type:"status",result:n.value},n.context])}onSignature(e,n,r){const i=this._buildArgs([e],r||this._commitment||"finalized"),o=this._makeSubscription({callback:(s,a)=>{if(s.type==="status"){n(s.result,a);try{this.removeSignatureListener(o)}catch(l){}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},i);return o}onSignatureWithOptions(e,n,r){const{commitment:i,...o}={...r,commitment:r&&r.commitment||this._commitment||"finalized"},s=this._buildArgs([e],i,void 0,o),a=this._makeSubscription({callback:(l,c)=>{n(l,c);try{this.removeSignatureListener(a)}catch(u){}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},s);return a}async removeSignatureListener(e){await this._unsubscribeClientSubscription(e,"signature result")}_wsOnRootNotification(e){const{result:n,subscription:r}=he(e,dj);this._handleServerNotification(r,[n])}onRootChange(e){return this._makeSubscription({callback:e,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(e){await this._unsubscribeClientSubscription(e,"root change")}}Object.freeze({CreateLookupTable:{index:0,layout:q.struct([q.u32("instruction"),Zs("recentSlot"),q.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:q.struct([q.u32("instruction")])},ExtendLookupTable:{index:2,layout:q.struct([q.u32("instruction"),Zs(),q.seq(ze(),q.offset(q.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:q.struct([q.u32("instruction")])},CloseLookupTable:{index:4,layout:q.struct([q.u32("instruction")])}}),new Re("AddressLookupTab1e1111111111111111111111111"),Object.freeze({RequestUnits:{index:0,layout:q.struct([q.u8("instruction"),q.u32("units"),q.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:q.struct([q.u8("instruction"),q.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:q.struct([q.u8("instruction"),q.u32("units")])},SetComputeUnitPrice:{index:3,layout:q.struct([q.u8("instruction"),Zs("microLamports")])}}),new Re("ComputeBudget111111111111111111111111111111"),q.struct([q.u8("numSignatures"),q.u8("padding"),q.u16("signatureOffset"),q.u16("signatureInstructionIndex"),q.u16("publicKeyOffset"),q.u16("publicKeyInstructionIndex"),q.u16("messageDataOffset"),q.u16("messageDataSize"),q.u16("messageInstructionIndex")]),new Re("Ed25519SigVerify111111111111111111111111111"),XH.utils.isValidPrivateKey,q.struct([q.u8("numSignatures"),q.u16("signatureOffset"),q.u8("signatureInstructionIndex"),q.u16("ethAddressOffset"),q.u8("ethAddressInstructionIndex"),q.u16("messageDataOffset"),q.u16("messageDataSize"),q.u8("messageInstructionIndex"),q.blob(20,"ethAddress"),q.blob(64,"signature"),q.u8("recoveryId")]),new Re("KeccakSecp256k11111111111111111111111111111");var bE;new Re("StakeConfig11111111111111111111111111111111");class _E{constructor(e,n,r){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=n,this.custodian=r}}bE=_E,_E.default=new bE(0,0,Re.default),Object.freeze({Initialize:{index:0,layout:q.struct([q.u32("instruction"),n9(),r9()])},Authorize:{index:1,layout:q.struct([q.u32("instruction"),ze("newAuthorized"),q.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:q.struct([q.u32("instruction")])},Split:{index:3,layout:q.struct([q.u32("instruction"),q.ns64("lamports")])},Withdraw:{index:4,layout:q.struct([q.u32("instruction"),q.ns64("lamports")])},Deactivate:{index:5,layout:q.struct([q.u32("instruction")])},Merge:{index:7,layout:q.struct([q.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:q.struct([q.u32("instruction"),ze("newAuthorized"),q.u32("stakeAuthorizationType"),Ys("authoritySeed"),ze("authorityOwner")])}}),new Re("Stake11111111111111111111111111111111111111"),Object.freeze({InitializeAccount:{index:0,layout:q.struct([q.u32("instruction"),i9()])},Authorize:{index:1,layout:q.struct([q.u32("instruction"),ze("newAuthorized"),q.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:q.struct([q.u32("instruction"),q.ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:q.struct([q.u32("instruction")])},AuthorizeWithSeed:{index:10,layout:q.struct([q.u32("instruction"),o9()])}}),new Re("Vote111111111111111111111111111111111111111"),new Re("Va1idator1nfo111111111111111111111111111111"),ce({name:de(),website:Ce(de()),details:Ce(de()),iconUrl:Ce(de()),keybaseUsername:Ce(de())}),new Re("Vote111111111111111111111111111111111111111"),q.struct([ze("nodePubkey"),ze("authorizedWithdrawer"),q.u8("commission"),q.nu64(),q.seq(q.struct([q.nu64("slot"),q.u32("confirmationCount")]),q.offset(q.u32(),-8),"votes"),q.u8("rootSlotValid"),q.nu64("rootSlot"),q.nu64(),q.seq(q.struct([q.nu64("epoch"),ze("authorizedVoter")]),q.offset(q.u32(),-8),"authorizedVoters"),q.struct([q.seq(q.struct([ze("authorizedPubkey"),q.nu64("epochOfLastAuthorizedSwitch"),q.nu64("targetEpoch")]),32,"buf"),q.nu64("idx"),q.u8("isEmpty")],"priorVoters"),q.nu64(),q.seq(q.struct([q.nu64("epoch"),q.nu64("credits"),q.nu64("prevCredits")]),q.offset(q.u32(),-8),"epochCredits"),q.struct([q.nu64("slot"),q.nu64("timestamp")],"lastTimestamp")]);function gp(t){switch(t){case"processed":case"confirmed":case"finalized":case void 0:return t;case"recent":return"processed";case"single":case"singleGossip":return"confirmed";case"max":case"root":return"finalized";default:return}}const xE="solana:mainnet",Dj="solana:devnet",Vj="solana:testnet",$j="solana:localnet",zj="https://api.mainnet-beta.solana.com";function Uj(t){return t.includes(zj)?xE:/\bdevnet\b/i.test(t)?Dj:/\btestnet\b/i.test(t)?Vj:/\blocalhost\b/i.test(t)||/\b127\.0\.0\.1\b/.test(t)?$j:xE}function Wj(t,e){if(t===e)return!0;const n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}function Hj(t){if(t.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let c=0;c<e.length;c++)e[c]=255;for(let c=0;c<t.length;c++){const u=t.charAt(c),h=u.charCodeAt(0);if(e[h]!==255)throw new TypeError(u+" is ambiguous");e[h]=c}const n=t.length,r=t.charAt(0),i=Math.log(n)/Math.log(256),o=Math.log(256)/Math.log(n);function s(c){if(c instanceof Uint8Array||(ArrayBuffer.isView(c)?c=new Uint8Array(c.buffer,c.byteOffset,c.byteLength):Array.isArray(c)&&(c=Uint8Array.from(c))),!(c instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(c.length===0)return"";let u=0,h=0,p=0;const g=c.length;for(;p!==g&&c[p]===0;)p++,u++;const b=(g-p)*o+1>>>0,m=new Uint8Array(b);for(;p!==g;){let N=c[p],T=0;for(let $=b-1;(N!==0||T<h)&&$!==-1;$--,T++)N+=256*m[$]>>>0,m[$]=N%n>>>0,N=N/n>>>0;if(N!==0)throw new Error("Non-zero carry");h=T,p++}let x=b-h;for(;x!==b&&m[x]===0;)x++;let I=r.repeat(u);for(;x<b;++x)I+=t.charAt(m[x]);return I}function a(c){if(typeof c!="string")throw new TypeError("Expected String");if(c.length===0)return new Uint8Array;let u=0,h=0,p=0;for(;c[u]===r;)h++,u++;const g=(c.length-u)*i+1>>>0,b=new Uint8Array(g);for(;u<c.length;){const N=c.charCodeAt(u);if(N>255)return;let T=e[N];if(T===255)return;let $=0;for(let B=g-1;(T!==0||$<p)&&B!==-1;B--,$++)T+=n*b[B]>>>0,b[B]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");p=$,u++}let m=g-p;for(;m!==g&&b[m]===0;)m++;const x=new Uint8Array(h+(g-m));let I=h;for(;m!==g;)x[I++]=b[m++];return x}function l(c){const u=a(c);if(u)return u;throw new Error("Non-base"+n+" character")}return{encode:s,decodeUnsafe:a,decode:l}}var jj="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const qj=Hj(jj);var we=function(t,e,n,r){if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(t):r?r.value:e.get(t)},Mt=function(t,e,n,r,i){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?i.call(t,n):i?i.value=n:e.set(t,n),n},yn,Hn,Uo,Wo,Ho,Ol,sd,qe,ad,pp,ld,mp,kl,vp,wE,EE,SE,IE;class Gj extends zV{get name(){return we(this,qe,"f").name}get url(){return"https://github.com/solana-labs/wallet-standard"}get icon(){return we(this,qe,"f").icon}get readyState(){return we(this,ad,"f")}get publicKey(){return we(this,Uo,"f")}get connecting(){return we(this,Wo,"f")}get supportedTransactionVersions(){return we(this,sd,"f")}get wallet(){return we(this,qe,"f")}get standard(){return!0}constructor({wallet:e}){super(),yn.add(this),Hn.set(this,void 0),Uo.set(this,void 0),Wo.set(this,void 0),Ho.set(this,void 0),Ol.set(this,void 0),sd.set(this,void 0),qe.set(this,void 0),ad.set(this,typeof window=="undefined"||typeof document=="undefined"?fl.Unsupported:fl.Installed),vp.set(this,n=>{if("accounts"in n){const r=we(this,qe,"f").accounts[0];we(this,Hn,"f")&&!we(this,Ho,"f")&&r!==we(this,Hn,"f")&&(r?we(this,yn,"m",ld).call(this,r):(this.emit("error",new FV),we(this,yn,"m",mp).call(this)))}"features"in n&&we(this,yn,"m",kl).call(this)}),Mt(this,qe,e,"f"),Mt(this,Hn,null,"f"),Mt(this,Uo,null,"f"),Mt(this,Wo,!1,"f"),Mt(this,Ho,!1,"f"),Mt(this,Ol,we(this,qe,"f").features[P1].on("change",we(this,vp,"f")),"f"),we(this,yn,"m",kl).call(this)}destroy(){Mt(this,Hn,null,"f"),Mt(this,Uo,null,"f"),Mt(this,Wo,!1,"f"),Mt(this,Ho,!1,"f");const e=we(this,Ol,"f");e&&(Mt(this,Ol,null,"f"),e())}async autoConnect(){return we(this,yn,"m",pp).call(this,{silent:!0})}async connect(){return we(this,yn,"m",pp).call(this)}async disconnect(){if(N1 in we(this,qe,"f").features)try{Mt(this,Ho,!0,"f"),await we(this,qe,"f").features[N1].disconnect()}catch(e){this.emit("error",new DV(e==null?void 0:e.message,e))}finally{Mt(this,Ho,!1,"f")}we(this,yn,"m",mp).call(this)}async sendTransaction(e,n,r={}){try{const i=we(this,Hn,"f");if(!i)throw new hl;let o;if(Ji in we(this,qe,"f").features)if(i.features.includes(Ji))o=Ji;else if(gn in we(this,qe,"f").features&&i.features.includes(gn))o=gn;else throw new Vs;else if(gn in we(this,qe,"f").features){if(!i.features.includes(gn))throw new Vs;o=gn}else throw new dl;const s=Uj(n.rpcEndpoint);if(!i.chains.includes(s))throw new O1;try{const{signers:a,...l}=r;let c;if(gl(e)?(a!=null&&a.length&&e.sign(a),c=e.serialize()):(e=await this.prepareTransaction(e,n,l),a!=null&&a.length&&e.partialSign(...a),c=new Uint8Array(e.serialize({requireAllSignatures:!1,verifySignatures:!1}))),o===Ji){const[u]=await we(this,qe,"f").features[Ji].signAndSendTransaction({account:i,chain:s,transaction:c,options:{preflightCommitment:gp(l.preflightCommitment||n.commitment),skipPreflight:l.skipPreflight,maxRetries:l.maxRetries,minContextSlot:l.minContextSlot}});return qj.encode(u.signature)}else{const[u]=await we(this,qe,"f").features[gn].signTransaction({account:i,chain:s,transaction:c,options:{preflightCommitment:gp(l.preflightCommitment||n.commitment),minContextSlot:l.minContextSlot}});return await n.sendRawTransaction(u.signedTransaction,{...l,preflightCommitment:gp(l.preflightCommitment||n.commitment)})}}catch(a){throw a instanceof Un?a:new O1(a==null?void 0:a.message,a)}}catch(i){throw this.emit("error",i),i}}}Hn=new WeakMap,Uo=new WeakMap,Wo=new WeakMap,Ho=new WeakMap,Ol=new WeakMap,sd=new WeakMap,qe=new WeakMap,ad=new WeakMap,vp=new WeakMap,yn=new WeakSet,pp=async function(e){try{if(this.connected||this.connecting)return;if(we(this,ad,"f")!==fl.Installed)throw new MV;if(Mt(this,Wo,!0,"f"),!we(this,qe,"f").accounts.length)try{await we(this,qe,"f").features[R1].connect(e)}catch(r){throw new BV(r==null?void 0:r.message,r)}const n=we(this,qe,"f").accounts[0];if(!n)throw new Vs;we(this,yn,"m",ld).call(this,n)}catch(n){throw this.emit("error",n),n}finally{Mt(this,Wo,!1,"f")}},ld=function(e){let n;try{n=new Re(e.address)}catch(r){throw new VV(r==null?void 0:r.message,r)}Mt(this,Hn,e,"f"),Mt(this,Uo,n,"f"),we(this,yn,"m",kl).call(this),this.emit("connect",n)},mp=function(){Mt(this,Hn,null,"f"),Mt(this,Uo,null,"f"),we(this,yn,"m",kl).call(this),this.emit("disconnect")},kl=function(){var n,r;const e=Ji in we(this,qe,"f").features?we(this,qe,"f").features[Ji].supportedTransactionVersions:we(this,qe,"f").features[gn].supportedTransactionVersions;Mt(this,sd,Wj(e,["legacy"])?null:new Set(e),"f"),gn in we(this,qe,"f").features&&((n=we(this,Hn,"f"))!=null&&n.features.includes(gn))?(this.signTransaction=we(this,yn,"m",wE),this.signAllTransactions=we(this,yn,"m",EE)):(delete this.signTransaction,delete this.signAllTransactions),pl in we(this,qe,"f").features&&((r=we(this,Hn,"f"))!=null&&r.features.includes(pl))?this.signMessage=we(this,yn,"m",SE):delete this.signMessage,Eg in we(this,qe,"f").features?this.signIn=we(this,yn,"m",IE):delete this.signIn},wE=async function(e){try{const n=we(this,Hn,"f");if(!n)throw new hl;if(!(gn in we(this,qe,"f").features))throw new dl;if(!n.features.includes(gn))throw new Vs;try{const i=(await we(this,qe,"f").features[gn].signTransaction({account:n,transaction:gl(e)?e.serialize():new Uint8Array(e.serialize({requireAllSignatures:!1,verifySignatures:!1}))}))[0].signedTransaction;return gl(e)?Vo.deserialize(i):cr.from(i)}catch(r){throw r instanceof Un?r:new k1(r==null?void 0:r.message,r)}}catch(n){throw this.emit("error",n),n}},EE=async function(e){try{const n=we(this,Hn,"f");if(!n)throw new hl;if(!(gn in we(this,qe,"f").features))throw new dl;if(!n.features.includes(gn))throw new Vs;try{const r=await we(this,qe,"f").features[gn].signTransaction(...e.map(i=>({account:n,transaction:gl(i)?i.serialize():new Uint8Array(i.serialize({requireAllSignatures:!1,verifySignatures:!1}))})));return e.map((i,o)=>{const s=r[o].signedTransaction;return gl(i)?Vo.deserialize(s):cr.from(s)})}catch(r){throw new k1(r==null?void 0:r.message,r)}}catch(n){throw this.emit("error",n),n}},SE=async function(e){try{const n=we(this,Hn,"f");if(!n)throw new hl;if(!(pl in we(this,qe,"f").features))throw new dl;if(!n.features.includes(pl))throw new Vs;try{return(await we(this,qe,"f").features[pl].signMessage({account:n,message:e}))[0].signature}catch(r){throw new $V(r==null?void 0:r.message,r)}}catch(n){throw this.emit("error",n),n}},IE=async function(e={}){try{if(!(Eg in we(this,qe,"f").features))throw new dl;let n;try{[n]=await we(this,qe,"f").features[Eg].signIn(e)}catch(r){throw new T1(r==null?void 0:r.message,r)}if(!n)throw new T1;return we(this,yn,"m",ld).call(this,n.account),n}catch(n){throw this.emit("error",n),n}};class Kj{constructor(e){mt(this,"iframe");mt(this,"handshakeComplete",!1);mt(this,"parentAPI",null);mt(this,"endpoint",null);if(!e)throw new Error("BridgeParent requires an iframe element");this.iframe=e,this.initializeConnection()}async initializeConnection(){if(!this.iframe||!this.iframe.contentWindow)return;const e=await this.discoverWallets(),n=this.getSolanaWallets();this.parentAPI={eip6963Wallets:e,eip6963WalletsReady:!0,walletStandardWallets:n,walletStandardWalletsReady:!0},this.endpoint=EV(this.iframe.contentWindow,window,"*"),bg(this.parentAPI,this.endpoint),this.handshakeComplete=!0}isConnected(){return this.handshakeComplete}async discoverWallets(){return new Promise(e=>{const n=[],i=o=>{const s=o,{info:a,provider:l}=s.detail;n.findIndex(u=>u.uuid===a.uuid)===-1&&n.push({uuid:a.uuid,name:a.name,icon:a.icon,rdns:a.rdns,provider:l})};window.addEventListener("eip6963:announceProvider",i),window.dispatchEvent(new Event("eip6963:requestProvider")),setTimeout(()=>{window.removeEventListener("eip6963:announceProvider",i),e(n)},1e3)})}getSolanaWallets(){const{get:e}=kV(),n=e(),r=[],i=new Set;for(const o of n)if(this.isSolanaWallet(o)){let s;UV(o)&&(s=new Gj({wallet:o})),r.push({uuid:this.generateWalletId(o),name:o.name,chains:o.chains||[],features:Object.keys(o.features),adapter:s?{name:s.name,url:s.url,icon:s.icon,readyState:s.readyState,publicKey:S1({get value(){return s.publicKey},toBase58:async()=>{var a;return(a=s.publicKey)==null?void 0:a.toBase58()},toJSON:async()=>{var a;return(a=s.publicKey)==null?void 0:a.toJSON()},toBytes:async()=>{var a;return(a=s.publicKey)==null?void 0:a.toBytes()},toBuffer:async()=>{var a;return(a=s.publicKey)==null?void 0:a.toBuffer()},toString:async()=>{var a;return(a=s.publicKey)==null?void 0:a.toString()}}),connecting:s.connecting,connected:s.connected,supportedTransactionVersions:s.supportedTransactionVersions,wallet:s.wallet,standard:s.standard,destroy:async()=>await s.destroy(),autoConnect:async()=>await s.autoConnect(),connect:async()=>await s.connect(),disconnect:async()=>await s.disconnect(),sendTransaction:async(a,l,c)=>await s.sendTransaction(a,l,c),signTransaction:async a=>s.signTransaction!==void 0?await s.signTransaction(a):new Error("Adapter does not support signTransaction"),signAllTransactions:async a=>s.signAllTransactions!==void 0?await s.signAllTransactions(a):new Error("Adapter does not support signAllTransactions"),signMessage:async a=>s.signMessage!==void 0?await s.signMessage(a):new Error("Adapter does not support signMessage"),signIn:async a=>s.signIn!==void 0?await s.signIn(a):new Error("Adapter does not support signIn"),customFunctions:["sendSerializedTransaction","signAllSerializedTransactions","signSerializedTransaction"],sendSerializedTransaction:async(a,l)=>{const c=new Fj(l),u=new Uint8Array(a);let h;try{h=Vo.deserialize(u)}catch(p){try{h=cr.from(u)}catch(g){throw new Error("Failed to deserialize transaction as either versioned or legacy format")}}return await s.sendTransaction(h,c)},signSerializedTransaction:async a=>{if(s.signTransaction===void 0)return new Error("Adapter does not support signTransaction");const l=new Uint8Array(a);let c;try{c=Vo.deserialize(l)}catch(u){try{c=cr.from(l)}catch(h){return new Error("Failed to deserialize transaction as either versioned or legacy format")}}return await s.signTransaction(c)},signAllSerializedTransactions:async a=>{if(s.signAllTransactions===void 0)return new Error("Adapter does not support signAllTransactions");const l=[];for(const c of a){const u=new Uint8Array(c);let h;try{h=Vo.deserialize(u)}catch(p){try{h=cr.from(u)}catch(g){return new Error("Failed to deserialize one or more transactions")}}l.push(h)}return await s.signAllTransactions(l)}}:void 0}),i.add(o.name)}return r}isSolanaWallet(e){return(e.chains||[]).some(i=>i.startsWith("solana:"))}generateWalletId(e){var r;const n=((r=e.chains)==null?void 0:r[0])||"unknown";return`${e.name}-${n}`.toLowerCase().replace(/\s+/g,"-")}destroy(){this.handshakeComplete=!1,this.parentAPI&&(this.parentAPI.eip6963Wallets=[],this.parentAPI.walletStandardWallets=[],this.parentAPI=null),this.endpoint=null,this.iframe=null}}var yp=function(){return yp=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){e=arguments[n];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},yp.apply(this,arguments)},CE=function(t,e,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function a(u){try{c(r.next(u))}catch(h){s(h)}}function l(u){try{c(r.throw(u))}catch(h){s(h)}}function c(u){u.done?o(u.value):i(u.value).then(a,l)}c((r=r.apply(t,e||[])).next())})},AE=function(t,e){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(c){return function(u){return l([c,u])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(n=0)),n;)try{if(r=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,i=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){n.label=c[1];break}if(c[0]===6&&n.label<o[1]){n.label=o[1],o=c;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(c);break}o[2]&&n.ops.pop(),n.trys.pop();continue}c=e.call(t,n)}catch(u){c=[6,u],i=0}finally{r=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},Ae,OE,cd,bp=mg,jo=null,kE=function(){return document.getElementById(bp)};function _p(t){var e,n=kE();if(!n){console.warn("Mesh SDK: Failed to deliver ".concat(t.type," message to the iframe - no iframe element found"));return}if(!cd){console.warn("Mesh SDK: Failed to deliver ".concat(t.type," message to the iframe - no link token origin found"));return}try{(e=n.contentWindow)===null||e===void 0||e.postMessage(t,cd)}catch(r){console.error("Mesh SDK: Failed to deliver ".concat(t.type," message to the iframe")),console.error(r)}}function Yj(t){return CE(this,void 0,void 0,function(){var e,e,e,e,n,r,i,o,s,a,l,c,u,h;return AE(this,function(p){switch(t.data.type){case"brokerageAccountAccessToken":{e={accessToken:t.data.payload},(n=Ae==null?void 0:Ae.onEvent)===null||n===void 0||n.call(Ae,{type:"integrationConnected",payload:e}),(r=Ae==null?void 0:Ae.onIntegrationConnected)===null||r===void 0||r.call(Ae,e);break}case"delayedAuthentication":{e={delayedAuth:t.data.payload},(i=Ae==null?void 0:Ae.onEvent)===null||i===void 0||i.call(Ae,{type:"integrationConnected",payload:e}),(o=Ae==null?void 0:Ae.onIntegrationConnected)===null||o===void 0||o.call(Ae,e);break}case"transferFinished":{e=t.data.payload,(s=Ae==null?void 0:Ae.onEvent)===null||s===void 0||s.call(Ae,{type:"transferCompleted",payload:e}),(a=Ae==null?void 0:Ae.onTransferFinished)===null||a===void 0||a.call(Ae,e);break}case"close":case"done":{e=(l=t.data)===null||l===void 0?void 0:l.payload,(c=Ae==null?void 0:Ae.onExit)===null||c===void 0||c.call(Ae,e==null?void 0:e.errorMessage,e),jo==null||jo.destroy(),vg();break}case"loaded":{_p({type:"meshSDKSpecs",payload:yp({},dV)}),Ae!=null&&Ae.accessTokens&&_p({type:"frontAccessTokens",payload:Ae.accessTokens}),Ae!=null&&Ae.transferDestinationTokens&&_p({type:"frontTransferDestinationTokens",payload:Ae.transferDestinationTokens}),(u=Ae==null?void 0:Ae.onEvent)===null||u===void 0||u.call(Ae,{type:"pageLoaded"});break}default:{sV(t.data.type)&&((h=Ae==null?void 0:Ae.onEvent)===null||h===void 0||h.call(Ae,t.data));break}}return[2]})})}function xp(t){return CE(this,void 0,void 0,function(){return AE(this,function(e){switch(e.label){case 0:return t.origin!==OE&&t.origin!==cd?(console.warn("Received message from untrusted origin:",t.origin),[3,3]):[3,1];case 1:return[4,Yj(t)];case 2:e.sent(),e.label=3;case 3:return[2]}})})}var TE=function(t){var e=function(r,i){var o,s;if(!r){(o=t==null?void 0:t.onExit)===null||o===void 0||o.call(t,"Invalid link token!");return}Ae=t;var a=window.atob(r),l=a.startsWith("http://")||a.startsWith("https://");if(!l){(s=t==null?void 0:t.onExit)===null||s===void 0||s.call(t,"Invalid link token!");return}if(a=Xj(a,Ae==null?void 0:Ae.language),a=Zj(a,Ae==null?void 0:Ae.displayFiatCurrency),a=Jj(a,Ae==null?void 0:Ae.theme),cd=new URL(a).origin,window.removeEventListener("message",xp),i){var c=document.getElementById(i);c?(c.allow="clipboard-read *; clipboard-write *",c.src=a,bp=i):console.warn("Mesh SDK: No iframe found with id ".concat(i))}else bp=mg,cV(a);window.addEventListener("message",xp),OE=window.location.origin;var u=kE();u&&(jo=new Kj(u))},n=function(){var r;jo==null||jo.destroy(),vg(),window.removeEventListener("message",xp),(r=t.onExit)===null||r===void 0||r.call(t)};return{openLink:e,closeLink:n}};function Xj(t,e){return e==="system"&&(e=typeof navigator!="undefined"&&navigator.language?encodeURIComponent(navigator.language):void 0),"".concat(t).concat(t.includes("?")?"&":"?","lng=").concat(e||"en")}function Zj(t,e){return e?"".concat(t).concat(t.includes("?")?"&":"?","fiatCur=").concat(e):t}function Jj(t,e){return e?"".concat(t).concat(t.includes("?")?"&":"?","th=").concat(e):t}const Qj="Swap not found for a required underlying of defi route, please make sure your amount is within an acceptable range",eq="coingecko",tq=t=>t.includes(eq)?t.replace("/thumb/","/large/"):t,RE=({token:t,chainId:e,size:n=32})=>w.jsxs(ue,{position:"relative",borderRadius:"50%",minW:`${n}px`,minH:`${n}px`,children:[w.jsx(ue,{borderRadius:"50%",overflow:"hidden",width:`${n}px`,height:`${n}px`,children:w.jsx("img",{src:t!=null&&t.logoURI?tq(t==null?void 0:t.logoURI):Is,title:t==null?void 0:t.symbol,alt:t==null?void 0:t.symbol,width:`${n}px`,height:`${n}px`})}),e&&w.jsx(ue,{position:"absolute",bottom:"0",right:"-2px",width:`${n/2}px`,height:`${n/2}px`,borderRadius:"50%",overflow:"hidden",border:"1px solid",borderColor:"bg",zIndex:"1",children:w.jsx("img",{src:`https://icons-ckg.pages.dev/stargate-light/networks/${ko[e]}.svg`,alt:`Chain ${e}`,width:"100%",height:"100%"})})]}),ud=()=>{const{address:t}=et.useAccount(),{walletIcon:e,walletDisplayName:n}=f1(),{chainIdOut:r,effectiveTokenOutData:i,tokenInData:o,amountIn:s,chainIdIn:a,selectedIntegration:l,isNontokenized:c}=yr(),{routeLoading:u,routeData:h,routeFetched:p,routerError:g}=Ms(),b=u||!p&&!g,m=h!=null&&h.error||(h==null?void 0:h.statusCode)===500?Qj:null,x=Iu({hash:t,chainId:a,type:"/address"}),I=Iu({hash:t,chainId:r,type:"/address"}),N=K.useMemo(()=>{if(l!=null&&l.type){const T=hd[l.type],$=l.name||l.type;return w.jsxs(w.Fragment,{children:[T&&w.jsx(Rn,{src:T,width:"16px",height:"16px",borderRadius:"full"}),w.jsx(Te,{children:$})]})}return w.jsxs(w.Fragment,{children:[typeof e=="string"?w.jsx(Rn,{src:e,width:"16px",height:"16px"}):e,w.jsx(Kf,{content:n,children:w.jsx(Te,{children:t&&n+" "+ug(t,!0)})}),x&&w.jsx(Vf,{href:x,target:"_blank",children:w.jsx(on,{as:H_,color:"fg.muted",width:"16px",height:"16px"})})]})},[l,e,n,t,x]);return w.jsxs(w.Fragment,{children:[w.jsx(hu,{size:"sm",variant:"outline",width:"100%",borderRadius:"sm",children:w.jsxs(fu,{children:[w.jsxs(En,{children:[w.jsx(je,{children:"Source"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:w.jsx(ue,{display:"flex",gap:"8px",alignItems:"center",children:N})})]}),w.jsxs(En,{children:[w.jsx(je,{children:"Destination"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:w.jsx(jr,{loading:b,width:b?"80px":"auto",children:w.jsxs(tr,{gap:"8px",alignItems:"center",children:[w.jsx(Rn,{src:dg(r),width:"16px",height:"16px"}),w.jsx(Te,{children:l1(r)})," - ",w.jsx(Kf,{content:n,children:w.jsx(Te,{children:t&&ug(t)})}),I&&w.jsx(Vf,{href:I,target:"_blank",children:w.jsx(on,{as:H_,color:"fg.muted",width:"16px",height:"16px"})})]})})})]}),w.jsxs(En,{children:[w.jsx(je,{children:"Estimated time"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:w.jsx(jr,{loading:b,width:b?"80px":"auto",children:w.jsx(Te,{children:l!=null&&l.type?"~2min":a!==r?"~1 min":"instant"})})})]})]})},"line"),m?w.jsx(Te,{fontSize:"xs",color:"error",children:m}):w.jsx(hu,{size:"sm",variant:"outline",bg:"bg.subtle",children:w.jsxs(fu,{children:[w.jsxs(En,{children:[w.jsx(je,{children:"You send"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:w.jsxs(ue,{display:"flex",gap:"8px",alignItems:"center",children:[w.jsxs(Te,{children:[kr(ir(s,o==null?void 0:o.decimals))," ",o==null?void 0:o.symbol]}),w.jsx(RE,{token:o,chainId:a,size:24})]})})]}),w.jsxs(En,{children:[w.jsx(je,{children:c&&(i!=null&&i.protocol)?`Deposit into ${i.protocolName||i.protocol}`:"You receive"}),w.jsxs(je,{display:"flex",textAlign:"end",justifyContent:"end",children:[" ",w.jsx(jr,{loading:b,width:b?"156px":"auto",children:w.jsxs(ue,{display:"flex",gap:"8px",alignItems:"center",children:[w.jsxs(Te,{children:[kr(ir(h==null?void 0:h.amountOut,i==null?void 0:i.decimals))," ",i==null?void 0:i.symbol]}),c&&(i!=null&&i.protocol)?w.jsxs(ue,{position:"relative",minW:"24px",minH:"24px",children:[w.jsx(ue,{borderRadius:"50%",overflow:"hidden",width:"24px",height:"24px",children:w.jsx("img",{src:i.protocolLogo||Is,title:i.protocol,alt:i.protocol,width:"24px",height:"24px",onError:T=>{T.currentTarget.src=Is}})}),r&&w.jsx(ue,{position:"absolute",bottom:"0",right:"-2px",width:"12px",height:"12px",borderRadius:"50%",overflow:"hidden",border:"1px solid",borderColor:"bg",zIndex:"1",children:w.jsx("img",{src:`https://icons-ckg.pages.dev/stargate-light/networks/${ko[r]}.svg`,alt:`Chain ${r}`,width:"100%",height:"100%"})})]}):w.jsx(RE,{token:i,chainId:r,size:24})]})})]})]})]})},"line")]})},nq=()=>{var l;const{routeData:t}=Ms(),{tokenIn:e,chainIdIn:n,amountIn:r}=yr(),{data:i}=ll(n,Pt),{data:[o]}=Ls(Pt,n),s=K.useMemo(()=>{var u,h;let c=+((h=(u=t==null?void 0:t.tx)==null?void 0:u.value)!=null?h:0);return Ro(e,Pt)&&(c-=+r),ir(Math.max(0,c).toString(),18)},[(l=t==null?void 0:t.tx)==null?void 0:l.value,e,r]),a=+s*+(i!=null?i:0);return w.jsxs(Te,{title:"Bridging fee",cursor:"default",display:"flex",alignItems:"center",gap:1,color:"fg.subtle",fontSize:"xs",children:[w.jsx(q4,{size:12}),w.jsx(Kf,{content:`${kr(s,!0)} ${o==null?void 0:o.symbol}`,children:w.jsx(Te,{fontSize:"xs",color:"fg.subtle",children:Tr(a)})})]})};We("div",{base:{display:"flex",justifyContent:"space-between",alignItems:"center",h:"36px",p:"8px 12px",borderRadius:"8px",bg:"bg",w:"100%"}});const dd=()=>{const{routeData:t}=Ms(),{chainIdIn:e,chainIdOut:n,selectedIntegration:r}=yr(),i=Be(c=>c.slippage),[o,s]=K.useState(!1),l=[{detail:`${t!=null&&t.priceImpact?(-(t==null?void 0:t.priceImpact)/100).toFixed(2):"0.00"}%`,label:"Est. price impact"},{detail:`${i/100}%`,label:"Max. slippage"},{detail:r!=null&&r.type?"~2min":e!==n?"~1 min":"instant",label:"Est. processing time"}];return w.jsx(x4,{open:o,onOpenChange:c=>s(c.open),w:"full",children:w.jsxs(ue,{width:"100%",bg:"bg.subtle",borderRadius:"md",padding:"12px",transition:"all 0.2s",children:[w.jsx(w4,{asChild:!0,children:w.jsxs(tr,{align:"center",justify:"space-between",width:"100%",cursor:"pointer",children:[w.jsxs(tr,{align:"center",gap:2,children:[w.jsx(Vi,{color:"fg.muted",fontSize:"sm",children:"Transaction details"}),w.jsx(on,{as:H4,width:"14px",height:"14px",color:"fg.muted",transform:o?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease-in-out"})]}),w.jsx(nq,{})]})}),w.jsx(E4,{children:w.jsx(ue,{marginTop:"12px",paddingTop:"12px",borderTop:"1px solid",borderColor:"border",children:l.map((c,u)=>w.jsxs(tr,{justify:"space-between",align:"center",paddingY:"6px",children:[w.jsx(Vi,{fontSize:"sm",color:"fg.muted",children:c.label}),w.jsx(Vi,{fontSize:"sm",color:"fg",fontWeight:"medium",children:c.detail})]},u))})})]})})},rq=We("div",{base:{w:"58px",h:"58px",borderRadius:"full",border:"1px solid",borderColor:"border",display:"flex",alignItems:"center",justifyContent:"center"}}),NE=({onFinish:t,start:e,duration:n=60})=>{const[r,i]=K.useState(n);K.useEffect(()=>{i(n)},[n]),K.useEffect(()=>{if(!e)return;const s=setInterval(()=>{i(a=>a<=1?(clearInterval(s),t==null||t(),0):a-1)},1e3);return()=>clearInterval(s)},[e,t]);const o=s=>{const a=Math.floor(s/60).toString().padStart(2,"0"),l=(s%60).toString().padStart(2,"0");return`${a}:${l}`};return w.jsx(Es,{children:w.jsx(rq,{children:w.jsx(Te,{fontSize:"xs",color:"fg.muted",fontWeight:"medium",children:o(r)})})})},iq="data:image/svg+xml,%3csvg%20width='17'%20height='16'%20viewBox='0%200%2017%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_126_8587)'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M16.3686%2010.6232C16.3715%2010.6146%2016.359%2010.6097%2016.355%2010.6179C14.975%2013.5085%2012.2144%2015.5112%208.66017%2015.5112C4.88611%2015.5112%201.35008%2012.688%201.35008%208.37011C1.35008%204.65011%204.30812%201.56104%207.74213%201.56104C10.6321%201.56104%2012.6382%203.28819%2012.6382%204.51714C12.6382%205.08189%2012.2642%205.48041%2011.6862%205.48041C10.3602%205.48041%209.85022%203.15536%207.33413%203.15536C4.78406%203.15536%202.6081%205.54683%202.6081%208.37011C2.6081%2012.0238%205.56614%2014.4153%208.52417%2014.4153C9.68043%2014.4153%2010.322%2014.1182%2010.5073%2014.0169C10.515%2014.0126%2010.51%2014.0012%2010.5017%2014.0037C10.3174%2014.0604%209.73839%2014.2159%208.93211%2014.2159C5.29405%2014.2159%203.83206%2011.4591%203.83206%209.66544C3.83206%208.30367%204.71606%207.73906%205.43016%207.73906C7.33413%207.73906%207.06219%2011.7248%2011.7542%2011.7248C14.2023%2011.7248%2016.4803%2010.0972%2016.4803%206.87544C16.4803%203.22178%2012.9442%200%208.66017%200C4.17214%200%200.5%203.554%200.5%207.97156C0.5%2012.4223%204.30812%2015.9763%208.66017%2015.9763C12.4804%2015.9763%2015.3429%2013.5242%2016.3686%2010.6232Z'%20fill='%231E171F'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_126_8587'%3e%3crect%20width='16'%20height='16'%20fill='white'%20transform='translate(0.5)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",oq="data:image/svg+xml,%3csvg%20width='32'%20height='33'%20viewBox='0%200%2032%2033'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20y='0.5'%20width='32'%20height='32'%20rx='16'%20fill='%232F2B32'/%3e%3cpath%20d='M22.5582%2020.6133L16.0006%2027.1709L9.4469%2020.6172L9.44397%2020.6133L11.858%2018.2061L16.0006%2022.3496L20.1481%2018.2021L22.5582%2020.6133ZM18.4469%2016.502L16.0006%2018.9521L13.5543%2016.5059V16.498L13.984%2016.0693L14.194%2015.8633L16.0006%2014.0557L18.4469%2016.502ZM26.6666%2016.5029L24.2565%2018.9131L21.8473%2016.5029L24.2565%2014.0928L26.6666%2016.5029ZM10.153%2016.501L7.7428%2018.9111L5.33264%2016.501L7.7428%2014.0908L10.153%2016.501ZM22.5582%2012.3906L20.1481%2014.8018L16.0006%2010.6543L11.858%2014.7979L9.4469%2012.3867L16.0006%205.83301L22.5582%2012.3906Z'%20fill='%23F3BA2F'/%3e%3c/svg%3e",wp=({icon:t,title:e,description:n})=>w.jsxs(ue,{display:"flex",flexDirection:"row",gap:"16px",width:"100%",alignItems:"flex-start",children:[w.jsx(on,{as:t,color:"fg.muted",width:"20px",height:"20px",marginTop:"2px"}),w.jsxs(ue,{display:"flex",flexDirection:"column",gap:"4px",flex:"1",children:[w.jsx(ue,{fontWeight:"600",fontSize:"14px",lineHeight:"120%",color:"fg",children:e}),w.jsx(ue,{fontWeight:"400",fontSize:"12px",lineHeight:"140%",color:"fg.subtle",children:n})]})]}),sq=({onConfirm:t,exchangeName:e="your exchange",exchangeIcon:n})=>w.jsxs(tn,{children:[w.jsx(ue,{display:"flex",justifyContent:"center",width:"100%",children:w.jsx(Rn,{w:"48px",h:"48px",borderRadius:"full",src:n||oq})}),w.jsxs(ue,{fontWeight:"600",fontSize:"16px",lineHeight:"140%",color:"fg",textAlign:"center",children:["Enso Checkout uses a 3rd party to connect your ",e," account."]}),w.jsxs(ue,{display:"flex",flexDirection:"column",gap:"12px",width:"100%",children:[w.jsx(wp,{icon:G4,title:"Your sign-in credentials are never stored",description:"All data is encrypted between enso and Binance"}),w.jsx(wp,{icon:Y4,title:"2fa always required",description:"Transfers cannot be made without your approval."}),w.jsx(wp,{icon:K4,title:"Assets never touch 3rd parties",description:"Your funds are transferred directly to your wallet."}),w.jsxs(mB,{children:[w.jsx(Rn,{src:iq,color:"gray",w:"24px"}),"Enso securely encrypts all user data."]})]}),w.jsx(nr,{onClick:t,children:"Continue to 3rd Party"})]}),PE="data:image/svg+xml,%3csvg%20width='58'%20height='58'%20viewBox='0%200%2058%2058'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='29'%20cy='29'%20r='29'%20fill='%2314AE5C'/%3e%3cpath%20d='M36.2929%2022.2929C36.6834%2021.9024%2037.3164%2021.9024%2037.707%2022.2929C38.0975%2022.6834%2038.0975%2023.3164%2037.707%2023.707L26.707%2034.707C26.3164%2035.0975%2025.6834%2035.0975%2025.2929%2034.707L20.2929%2029.707C19.9024%2029.3164%2019.9024%2028.6834%2020.2929%2028.2929C20.659%2027.9268%2021.238%2027.9042%2021.6308%2028.2245L21.707%2028.2929L25.9999%2032.5859L36.2929%2022.2929Z'%20fill='white'/%3e%3c/svg%3e",LE="data:image/svg+xml,%3csvg%20width='58'%20height='58'%20viewBox='0%200%2058%2058'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='29'%20cy='29'%20r='29'%20fill='%23E84142'/%3e%3cpath%20d='M34.2929%2022.2929C34.6834%2021.9024%2035.3164%2021.9024%2035.707%2022.2929C36.0975%2022.6834%2036.0975%2023.3164%2035.707%2023.707L23.707%2035.707C23.3164%2036.0975%2022.6834%2036.0975%2022.2929%2035.707C21.9024%2035.3164%2021.9024%2034.6834%2022.2929%2034.2929L34.2929%2022.2929Z'%20fill='white'/%3e%3cpath%20d='M22.2929%2022.2929C22.6834%2021.9024%2023.3164%2021.9024%2023.707%2022.2929L35.707%2034.2929L35.7753%2034.3691C36.0957%2034.7618%2036.0731%2035.3408%2035.707%2035.707C35.3408%2036.0731%2034.7618%2036.0957%2034.3691%2035.7753L34.2929%2035.707L22.2929%2023.707C21.9024%2023.3164%2021.9024%2022.6834%2022.2929%2022.2929Z'%20fill='white'/%3e%3c/svg%3e";var Qr=(t=>(t.Binance="binance",t.Kraken="kraken",t.Coinbase="coinbase",t.Bybit="bybit",t))(Qr||{});const Qs=ox(t=>({txs:[],addTx:e=>t(n=>({txs:[...n.txs,e]})),removeTx:e=>t(n=>({txs:n.txs.filter(r=>r.hash!==e)})),updateTx:(e,n)=>t(r=>({txs:r.txs.map(i=>i.hash===e?{...i,...n}:i)}))})),aq=t=>{const{txs:e}=Qs();return e.find(n=>n.hash===t)},lq=()=>{const{addTx:t}=Qs();return{track:K.useCallback(n=>{n.hash&&t(n)},[])}},cq=(t,e=!0)=>{var l,c;const{data:n,isLoading:r}=Kn.useQuery({queryKey:["layerZeroStatus",t||"none"],queryFn:async()=>t?fetch(`https://scan.layerzero-api.com/v1/messages/tx/${t}`).then(u=>u.json()).then(u=>{var h,p;return(p=(h=u.data)==null?void 0:h[0])!=null?p:null}):null,refetchInterval:2e3,enabled:e&&!!t}),i=(l=n==null?void 0:n.status)==null?void 0:l.name,o=(c=n==null?void 0:n.source)==null?void 0:c.status;let s=0,a="Waiting for bridge transaction...";return o&&o!=="SUCCEEDED"?(s=1,a="Waiting for funds to be sent on destination"):i==="INFLIGHT"?(s=2,a="Waiting for funds to be delivered on destination"):i==="CONFIRMING"?(s=3,a="Waiting for destination execution"):i==="DELIVERED"&&(s=4,a="Bridging is complete"),{data:n,isLoading:r,status:i,sourceStatus:o,step:s,message:a,isComplete:i==="DELIVERED",isFailed:i==="FAILED"}},uq=(t,e)=>{const n=Qs(i=>i.updateTx),{data:r}=Kn.useQuery({queryKey:["layerZeroUrl",t||"none",!!e],queryFn:async()=>t?fetch(`https://scan.layerzero-api.com/v1/messages/tx/${t}`).then(i=>i.json()).then(i=>i.data[0]):null,refetchInterval:2e3,enabled:!!(e&&t)});K.useEffect(()=>{var i,o,s,a;t&&((i=r==null?void 0:r.source)!=null&&i.status&&r.source.status!=="SUCCEEDED"?n(t,{status:"(1/4) Waiting for funds to be sent on destination"}):((o=r==null?void 0:r.status)==null?void 0:o.name)==="DELIVERED"?(e==null||e(),n(t,{status:"(4/4) Bridging is complete",isActive:!1})):((s=r==null?void 0:r.status)==null?void 0:s.name)==="CONFIRMING"?n(t,{status:"(3/4) Waiting for destination execution"}):((a=r==null?void 0:r.status)==null?void 0:a.name)==="INFLIGHT"&&n(t,{status:"(2/4) Waiting for funds to be delivered on destination"}))},[r,t])},dq=(t,e,n,r,i)=>{const o=Iu({hash:t,chainId:e}),s=Qs(a=>a.updateTx);K.useEffect(()=>{i&&(r.error?s(t,{status:"Transaction Failed",isActive:!1}):r.data&&(i==null||i(),s(t,{status:"Transaction Confirmed",isActive:!1})))},[r.data,r.error,r.isLoading,n,o,i])},hq=({hash:t,chainId:e,message:n="Transaction confirmed",onConfirmed:r})=>{const{removeTx:i}=Qs(),o=et.useWaitForTransactionReceipt({hash:t,chainId:e});return K.useEffect(()=>{o.data&&(r==null||r(o.data))},[o.data,r]),dq(t,e,n,o,()=>i(t)),null},fq=({hash:t,chainId:e,onConfirmed:n})=>{const r=et.useWaitForTransactionReceipt({hash:t,chainId:e});return uq(r.data?t:void 0,()=>n==null?void 0:n(r.data)),null},gq=t=>t.crosschain?w.jsx(fq,{...t}):w.jsx(hq,{...t}),pq=()=>{const{txs:t}=Qs();return w.jsx(w.Fragment,{children:t.filter(e=>e.isActive).map(e=>w.jsx(gq,{...e},e.hash))})},mq="0x0000000071727de22e5e9d8baf0edac6f37da032",ea={[Qr.Binance]:"binanceInternationalDirect",[Qr.Kraken]:"krakenDirect",[Qr.Coinbase]:"coinbase",[Qr.Bybit]:"bybitDirect"},hd={[ea[Qr.Binance]]:"https://assets.coingecko.com/markets/images/52/large/binance.jpg",[ea[Qr.Kraken]]:"https://assets.coingecko.com/markets/images/29/large/kraken.jpg",[ea[Qr.Coinbase]]:"https://assets.coingecko.com/markets/images/23/large/Coinbase_Coin_Primary.png",[ea[Qr.Bybit]]:"https://assets.coingecko.com/markets/images/698/large/bybit_spot.png"},vq=t=>t==="delayed",Tl="https://mesh-bff.enso-checkout.workers.dev";var fd=(t=>(t[t.CheckSessionKey=0]="CheckSessionKey",t[t.ChooseExchange=1]="ChooseExchange",t[t.ChooseExchangeAsset=2]="ChooseExchangeAsset",t[t.ChooseBalanceAsset=3]="ChooseBalanceAsset",t[t.ChooseAmount=4]="ChooseAmount",t[t.SignUserOp=5]="SignUserOp",t[t.InitiateWithdrawal=6]="InitiateWithdrawal",t[t.TrackUserOp=7]="TrackUserOp",t))(fd||{});const ME=[1,2,4,5,6],yq=[3,4,5],Ep={1:"e3c7fdd8-b1fc-4e51-85ae-bb276e075611",8453:"aa883b03-120d-477c-a588-37c2afd3ca71",42161:"a34f2431-0ddd-4de4-bc22-4a8143287aeb",137:"7436e9d0-ba42-4d2b-b4c0-8e4e606b2c12",10:"18fa36b0-88a8-43ca-83db-9a874e0a2288",43114:"bad16371-c22a-4bf4-a311-274d046cd760",56:"ed0ebeec-b166-4c8b-8574-cb078f7af8cf",146:"385f0b3a-8471-4b8f-884f-c4f4496f1603"},BE=Object.keys(Ep).map(Number),bq=t=>Ep[t]||Ep[8453],FE=()=>{const{setMeshAccessToken:t}=Be(),e=gd(),n=Be(r=>r.selectedIntegration);return K.useCallback((r,i)=>{t(r),sessionStorage.setItem(`${e}:${n==null?void 0:n.type}`,JSON.stringify({accessTokenPayload:r,sessionId:i,timestamp:Date.now()}))},[e,n==null?void 0:n.type])},_q=({setStep:t})=>{var b;const{chainIdOut:e,setChainIdIn:n}=Be(),[r,i]=K.useState([]),[o,s]=K.useState(!0),[a,l]=K.useState(null),c=Be(m=>m.setSelectedIntegration),{enableExchange:u,cexBridgeChainMapping:h}=K.useContext(ic),p=h!=null?h:Jf,g=(b=RB(e,p))!=null?b:e;return K.useEffect(()=>{g&&n(g)},[g,n]),K.useEffect(()=>{(async()=>{try{const I=await(await fetch(`${Tl}/integrations`)).json(),N=u.map($=>ea[$]).filter(Boolean),T=I==null?void 0:I.filter($=>$.networks.some(B=>+B.chainId===g)&&N.includes($.type));i(T)}catch(x){console.error("Failed to fetch integrations",x),l("Failed to load exchanges")}finally{s(!1)}})()},[g]),o?w.jsx(Es,{children:w.jsx(Co,{m:5})}):a?w.jsx(tn,{children:w.jsx(ue,{p:5,color:"red.500",children:a})}):w.jsx(tn,{children:(r==null?void 0:r.length)>0?w.jsx(Oo,{children:r.map(m=>w.jsx(Eu,{icon:hd[m.type],title:m.name,balance:"",usdBalance:"",tag:"",loading:!1,selected:!1,onClick:()=>{c({id:m.id,type:m.type,name:m.name}),t(0)}},m.id))}):w.jsx(ue,{textAlign:"center",fontSize:"sm",color:"fg.subtle",py:3,children:"No exchanges available for specified target chain"})})},xq=({setStep:t})=>{const{chainIdIn:e,chainIdOut:n,setMeshAccessToken:r,setSessionId:i}=Be(),{address:o}=et.useAccount(),s=gd(),[a,l]=K.useState(!1),c=Be(b=>b.selectedIntegration),u=e!==n,h=n&&!BE.includes(n)&&!u,p=FE();K.useEffect(()=>{if(!c){t(1);return}if(h)return;const b=sessionStorage.getItem(`${s}:${c.type}`);if(b)try{const m=JSON.parse(b);if(m!=null&&m.accessTokenPayload&&(m!=null&&m.sessionId)){r(m.accessTokenPayload),i(m.sessionId),t(2);return}}catch(m){console.error("Failed to parse saved Mesh connection",m)}l(!0)},[s,h,c]);const g=()=>{const b=c==null?void 0:c.type;fetch(`${Tl}/linktoken?brokerType=${encodeURIComponent(b)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:s,integrationId:c==null?void 0:c.id,address:o})}).then(m=>m.json()).then(m=>{i(m.content.sessionId);const x=TE({clientId:o,onIntegrationConnected:I=>{console.log("onIntegrationConnected",I),x.closeLink(),t(2),p(I.accessToken,m.content.sessionId)},onExit:I=>{console.log("onExit",I)},onTransferFinished:I=>{console.log("onTransferFinished",I)},onEvent:I=>{console.log(I)}});x.openLink(m.content.linkToken)}).catch(m=>console.error(m))};return h?w.jsx(tn,{children:w.jsxs(ue,{textAlign:"center",py:8,children:[w.jsx(Te,{fontSize:"lg",fontWeight:"bold",color:"red.500",mb:4,children:"Unsupported Network"}),w.jsxs(Te,{color:"fg.muted",mb:6,children:["The selected network (Chain ID: ",n,") is not supported for exchange transactions. Please switch to a supported network such as: ",BE.join(", ")]})]})}):a?w.jsx(sq,{onConfirm:g,exchangeName:c==null?void 0:c.name,exchangeIcon:c!=null&&c.type?hd[c.type]:void 0}):w.jsx(Co,{m:5})},DE="meshDeviceId",gd=()=>K.useMemo(()=>{let t=localStorage.getItem(DE);return t||(t=`device_${Date.now()}_${Math.random().toString(36).substring(2,15)}`,localStorage.setItem(DE,t)),t},[]),wq=({setStep:t,onTokenSelect:e})=>{const[n,r]=K.useState([]),[i,o]=K.useState(null),[s,a]=K.useState(!0),[l,c]=K.useState(null),{address:u}=et.useAccount(),{meshAccessToken:h,sessionId:p,setMeshAccessToken:g,setSessionId:b,setTokenIn:m,chainIdIn:x}=Be(),I=gd(),N=Be($=>$.selectedIntegration);K.useEffect(()=>{h&&p&&x&&N&&(async()=>{var B,G,Z,Y;try{const V=await(await fetch(`${Tl}/holdings`,{method:"POST",headers:{"Content-Type":"application/json","x-session-id":p},body:JSON.stringify({authToken:(G=(B=h==null?void 0:h.accountTokens)==null?void 0:B[0])==null?void 0:G.accessToken,brokerType:N==null?void 0:N.type})})).json();if(console.log("Holdings data:",V),V.status!=="ok"||!((Z=V.content)!=null&&Z.cryptocurrencyPositions))throw V.errorType==="invalidIntegrationToken"&&(console.log("Invalid integration token"),t(0),g(null),b(null),sessionStorage.removeItem(`${I}:${N==null?void 0:N.type}`)),new Error(V.message||"Failed to fetch holdings");const W=await(await fetch(`${Tl}/tokens?chainId=${x}&brokerType=${encodeURIComponent((N==null?void 0:N.type)||"")}`)).json();if(W.status==="success"&&((Y=W.content)!=null&&Y.tokens)){const A=W.content.tokens.map(d=>{const y=V.content.cryptocurrencyPositions.find(S=>S.symbol===d.symbol);return y?{...d,balance:y.amount,marketValue:y.marketValue,holding:y}:null}).filter(d=>d!==null&&d.marketValue>5).sort((d,y)=>y.marketValue-d.marketValue);console.log("Matched tokens with balances:",A),r(A)}else throw new Error(W.message||"Failed to fetch supported tokens")}catch(F){debugger;console.error("Error fetching data:",F),c(F instanceof Error?F.message:"Failed to fetch data")}finally{a(!1)}})()},[u,x,h,p,N]);const T=$D(n.map($=>$.symbol),x);return s?w.jsx(Es,{children:w.jsx(Co,{m:5})}):l?w.jsxs(ue,{p:5,color:"red.500",children:["Error: ",l]}):w.jsxs(tn,{children:[w.jsxs(ue,{mb:4,width:"100%",textAlign:"left",children:[w.jsx(Ao,{children:"Your Holdings"}),w.jsxs(Zf,{children:["Found ",n.length," token balances above $5"]})]}),w.jsx(ue,{overflowY:"scroll",maxH:"400px",children:w.jsx(Oo,{children:n.map(($,B)=>{var G,Z;return w.jsx(Eu,{chainId:x,icon:(Z=(G=T==null?void 0:T[B])==null?void 0:G.logoURI)==null?void 0:Z.replace("/thumb/","/large/"),title:$.name,balance:`${kr($.balance)} ${$.symbol}`,usdBalance:Tr($.marketValue||0),tag:"",loading:!1,selected:i===$.symbol,onClick:()=>{var Y;o($.symbol),e($),m((Y=T==null?void 0:T[B])==null?void 0:Y.address)}},`${$.symbol}-${B}`)})})}),n.length===0&&w.jsx(ue,{textAlign:"center",color:"fg.subtle",py:8,children:"No tokens with balances found for this chain"}),w.jsx(nr,{disabled:!i,onClick:()=>{t(4)},children:"Continue"})]})},Eq=({setStep:t,onTokenSelect:e})=>{const{chainIdIn:n,setTokenIn:r,setChainIdIn:i}=Be(),[o,s]=K.useState(null),{holdingsList:a,total:l,isLoading:c}=h1(1),u=Be(h=>h.setSelectedIntegration);return K.useEffect(()=>{u({type:"delayed",name:"Smart account",id:""})},[]),c?w.jsx(Es,{children:w.jsx(Co,{m:5})}):w.jsxs(tn,{children:[w.jsx(ue,{mb:4,width:"100%",textAlign:"left",children:w.jsxs(Zf,{children:["Smart Account Balance: ",Tr(l)]})}),w.jsx(ue,{overflowY:"scroll",maxH:"400px",children:w.jsx(Oo,{children:a==null?void 0:a.map(h=>w.jsx(Eu,{chainId:h.chainId,icon:h.logoUri,title:h.name,balance:`${kr(ir(h.amount,h.decimals))} ${h.symbol}`,usdBalance:Tr(h.total),tag:"",loading:!1,selected:o===h.token&&n===h.chainId,onClick:()=>{s(h.token),r(h.token),i(h.chainId);const p={symbol:h.symbol,name:h.name,networkId:h.chainId.toString(),chainId:h.chainId,integrationNetworks:[],balance:Number(ir(h.amount,h.decimals)),marketValue:h.total};e(p)}},`${h.token}-${h.chainId}`))})}),(a==null?void 0:a.length)===0&&w.jsx(ue,{textAlign:"center",color:"fg.subtle",py:8,children:"No tokens found in smart account"}),w.jsx(nr,{disabled:!o,onClick:()=>{t(4)},children:"Continue"})]})},Sq=({setStep:t,selectedToken:e})=>{var Y;const[n,r]=K.useState({tokenAmount:"",usdAmount:"",mode:"usd"}),i=Be(F=>F.setAmountIn),{tokenInData:o,selectedIntegration:s}=yr(),l=(e==null?void 0:e.symbol.toLowerCase().includes("USD"))?2:6,c=n.tokenAmount,u=n.usdAmount,h=!vq(s.type),p=e?h?(e.marketValue-ax).toFixed(2):e.marketValue.toFixed(2):0,g=K.useMemo(()=>{if(!(!e||!e.balance))return e.marketValue/e.balance},[e]),b=K.useCallback(F=>{if(!e)return;const V=e.marketValue*F/100;let U,W;if(h){const A=sx[e.symbol]||0;U=Math.max(A,Math.min(V,+p));const d=e.marketValue/e.balance;W=Math.min(U/d,e.balance)}else U=V,W=e.balance*F/100;return{tokenAmount:Cu(W,l),usdAmount:U.toFixed(2)}},[e,h,p,l]);K.useEffect(()=>{if(e){const F=b(100);if(!F)return;r(V=>({...V,...F}))}},[e,b]),K.useEffect(()=>{if(!(o!=null&&o.decimals))return;const F=c.endsWith(".")?c.slice(0,-1):c;if(!F||F==="."){i("0");return}try{i(r1(F,o.decimals))}catch(V){i("0")}},[c,o==null?void 0:o.decimals,i]);const m=fg(c),x=m!==null,I=!!u&&u!==".",N=e?x&&m!==null&&m>e.balance:!0,T=I&&(Y=fg(u))!=null?Y:0,$=h&&e?sx[e.symbol]:0,B=h&&e&&x&&T>0&&$&&m!==null&&m<$,G=h&&e&&x&&T>0&&T>+p,Z=!x||B||G||N;return e?w.jsxs(tn,{children:[w.jsxs(ue,{mb:4,width:"100%",textAlign:"left",children:[w.jsx(Ao,{children:"Enter Amount"}),w.jsxs(Zf,{children:["Available: ",kr(e.balance)," ",e.symbol," (",Tr(e.marketValue),")"]})]}),w.jsx(ue,{display:"flex",flexDirection:"column",gap:"8px",width:"100%",children:w.jsx(g1,{value:n,onChange:r,tokenSymbol:e.symbol,tokenPriceUsd:g,roundingPrecision:l,onPercentSelect:b})}),w.jsx(ue,{textAlign:"center",color:"fg.subtle",fontSize:"xs",h:3,m:-1,visibility:Z?"visible":"hidden",children:x?B?`Minimum amount is ${kr($)} ${e.symbol}`:G?`Maximum amount is ${Tr(p)} (balance - $${ax})`:N?"Amount exceeds available balance":"":"Please enter an amount"}),w.jsx(nr,{onClick:()=>Z?void 0:t(5),disabled:Z,children:"Continue"})]}):w.jsx(tn,{children:w.jsx(ue,{textAlign:"center",color:"fg.subtle",py:8,children:"No token selected"})})},Iq=({setStep:t,setUserOp:e,nextStep:n})=>{const{chainIdIn:r}=yr(),{routeLoading:i,usdAmountIn:o,routeData:s}=Ms(),{signMessageAsync:a}=et.useSignMessage(),{address:l}=et.useAccount(),[c,u]=K.useState(!1),h=async()=>{if(!s||s!=null&&s.error){console.error("No valid router data available");return}try{u(!0);const p=s==null?void 0:s.userOp;if(!p){console.error("No userOperation found in routeData");return}console.log("Signing userOperation:",p);const g=rV({userOperation:p,entryPointAddress:mq,entryPointVersion:"0.7",chainId:r}),b=await a({account:l,message:{raw:g}}),m={...p,signature:b};console.log("signedUserOp",JSON.stringify(m)),e(m),t(n)}catch(p){console.error("Failed to sign userOperation:",p)}finally{u(!1)}};return w.jsxs(tn,{children:[w.jsxs(tr,{flexDirection:"column",gap:"16px",alignItems:"center",width:"100%",children:[w.jsx(jr,{loading:i,width:i?"156px":"auto",children:w.jsx(Yf,{readOnly:!0,marginY:"8px",variant:"text",placeholder:"$10.00",value:o})}),w.jsx(ud,{})]}),w.jsx(dd,{}),w.jsx(nr,{disabled:!!(s!=null&&s.message)||i||c,loading:i||c,onClick:h,children:i?"Loading quote":c?"Signing...":"Sign Transaction"})]})},Cq=({selectedToken:t,userOp:e,setStep:n})=>{const{meshAccessToken:r,amountIn:i,chainIdIn:o}=Be(),{address:s}=et.useAccount(),{tokenInData:a}=yr(),l=Be(x=>x.sessionId),[c,u]=K.useState(!0),[h,p]=K.useState(null),g=Be(x=>x.selectedIntegration),b=FE(),m=gd();return K.useEffect(()=>{if(!t||!e||!r){console.error("Missing required data for withdrawal initiation");return}const x=a!=null&&a.decimals?ir(i,a.decimals):0;console.log("transferAmount",x),(async()=>{try{const N=[{networkId:bq(o),symbol:t.symbol,address:e.sender,amount:x}],T={restrictMultipleAccounts:!0,userId:m,integrationId:g==null?void 0:g.id,transferOptions:{toAddresses:N}};console.log("link request body",T);const B=await(await fetch(`${Tl}/linktoken?brokerType=${encodeURIComponent((g==null?void 0:g.type)||"")}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({restrictMultipleAccounts:!0,userId:m,integrationId:g==null?void 0:g.id,transferOptions:{toAddresses:N}})})).json();console.log("Link token response:",B);const G=r.accountTokens.map(F=>({...F,accountId:F.account.accountId,accountName:F.account.accountName,brokerName:g==null?void 0:g.name,brokerType:g==null?void 0:g.type}));console.log("accessTokens",G);let Z=!1;const Y=TE({clientId:s,accessTokens:G,onIntegrationConnected:F=>{b(F.accessToken,l),console.log("Integration connected",F)},onTransferFinished:F=>{console.log("Transfer finished:",F),u(!1)},onExit:F=>{console.log("Mesh link exited:",F),!Z&&(u(!1),n(2))},onEvent:F=>{var V;if(console.log("Mesh event:",F),F.type==="transferExecuted")console.log("Transfer executed, closing mesh link and moving to TrackUserOp step"),Z=!0,Y.closeLink(),n(7);else if(F.type==="transferExecutionError"){const U=((V=F.payload)==null?void 0:V.errorMessage)||"Transfer failed. Please try again.";console.error("Mesh transfer error:",U),Z=!0,Y.closeLink(),p(U),u(!1)}}});Y.openLink(B.content.linkToken)}catch(N){console.error("Failed to fetch link token:",N),u(!1)}})()},[t,e]),h?w.jsx(tn,{children:w.jsxs(tr,{direction:"column",align:"center",justify:"center",flex:1,p:6,gap:4,children:[w.jsx(tr,{align:"center",justify:"center",w:12,h:12,borderRadius:"full",bg:"orange.100",children:w.jsx(on,{as:X4,boxSize:6,color:"orange.500"})}),w.jsx(Te,{fontSize:"md",textAlign:"center",color:"gray.700",children:h})]})}):w.jsx(tn,{children:w.jsx(Es,{children:w.jsx(Te,{mt:4,children:c?w.jsxs(tr,{alignItems:"center",gap:2,children:[w.jsx(Co,{m:5}),w.jsx(Te,{children:"Intiating Mesh"})]}):"Transfer completed"})})})},Aq=({currentPhase:t,phases:e})=>w.jsx(ue,{display:"flex",gap:4,justifyContent:"center",mb:4,children:e.map((n,r)=>w.jsxs(ue,{display:"flex",alignItems:"center",gap:2,children:[w.jsx(ue,{w:6,h:6,borderRadius:"full",bg:r<t?"green.500":r===t?"blue.500":"gray.300",display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontSize:"xs",fontWeight:"bold",children:r<t?"✓":r+1}),w.jsx(Te,{fontSize:"sm",color:r===t?"fg":"fg.muted",fontWeight:r===t?"semibold":"normal",children:n})]},n))}),Oq=({selectedToken:t,userOp:e,setStep:n})=>{const{chainIdIn:r,chainIdOut:i,tokenInData:o}=yr(),{amountIn:s}=Be(),a=r!==i,[l,c]=K.useState("cex"),[u,h]=K.useState(null),[p,g]=K.useState("sending"),[b,m]=K.useState("Sending operation to tracker..."),[x,I]=K.useState(null),[N,T]=K.useState(!1),[$,B]=K.useState(null),[G,Z]=K.useState(!1),[Y,F]=K.useState(null),[V,U]=K.useState(null),[W,A]=K.useState(null),d=cq(x!=null?x:void 0,a&&l==="bridge");K.useEffect(()=>{(async()=>{if(!t||!e||!o){console.error("Missing required data for tracking"),g("failed"),m("Missing required data"),c("failed");return}try{const M=await(await fetch("https://alpha-scanners-dev-054573dc8549.herokuapp.com/operations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userOperationData:{sender:e.sender,nonce:e.nonce,factory:e.factory,factoryData:e.factoryData,callData:e.callData,callGasLimit:e.callGasLimit,verificationGasLimit:e.verificationGasLimit,preVerificationGas:e.preVerificationGas,maxFeePerGas:e.maxFeePerGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,paymaster:e.paymaster,paymasterData:e.paymasterData,paymasterVerificationGasLimit:e.paymasterVerificationGasLimit,paymasterPostOpGasLimit:e.paymasterPostOpGasLimit,signature:e.signature},chainId:r,expectedBalance:s,tokenAddress:o.address})})).json();if(console.log("Operation tracking response:",M),M.success&&M.operationId)h(M.operationId),g("tracking"),m(a?"Funds forwarding in progress...":"Tracking operation progress...");else throw new Error(M.message||"Failed to send operation to tracker")}catch(k){console.error("Failed to send operation to tracker:",k),g("failed"),m("Failed to send operation to tracker"),c("failed")}})()},[]),K.useEffect(()=>{if(!u||p!=="tracking")return;const k=setInterval(async()=>{var M,H,Q;try{const j=await(await fetch(`https://alpha-scanners-dev-054573dc8549.herokuapp.com/operations/${u}/status`)).json();console.log("Operation status:",j),((M=j.operation)==null?void 0:M.status)==="completed"?(g("completed"),a?(m("Funds forwarding completed!"),(H=j.operation)!=null&&H.bundleTxHash?(I(j.operation.bundleTxHash),c("bridge")):(console.warn("No bundleTxHash returned from indexer, cannot track bridge"),c("completed"))):(m("Operation completed successfully!"),c("completed")),$&&(clearInterval($),B(null))):["failed","failed_permanent"].includes((Q=j.operation)==null?void 0:Q.status)&&(g("failed"),m(a?"Bridging failed. Please select Smart-account balance as a source to use withdrawn funds":"Operation failed"),c("failed"),$&&(clearInterval($),B(null)))}catch(X){console.error("Failed to fetch operation status:",X)}},3e3);return B(k),()=>{k&&clearInterval(k)}},[u,p,a]),K.useEffect(()=>{if(!(!a||l!=="bridge")){if(d.isFailed){c("failed");return}d.isComplete&&!G&&x&&r&&(async()=>{var k;try{const M=await fetch(`https://api.enso.build/api/v1/layerzero/bridge/check?chainId=${r}&txHash=${x}`);if(!M.ok){Z(!0),F(!0),c("completed");return}const H=await M.json();Z(!0),A(H.destinationTxHash||null),H.status==="success"?(F(!0),c("completed")):H.status==="failed"?(F(!1),U(((k=H.ensoDestinationEvent)==null?void 0:k.refundDetails)||null),c("failed")):(F(!0),c("completed"))}catch(M){console.error("Failed to verify destination:",M),Z(!0),F(!0),c("completed")}})()}},[l,d.isComplete,d.isFailed,a,G,x,r]);const y=()=>{T(!0)},S=()=>l==="failed"?"failed":l==="completed"?"completed":"processing",C=()=>{switch(S()){case"completed":return"#14AE5C";case"failed":return"#E84142";default:return"#1E171F"}},R=()=>{switch(S()){case"completed":return"Success";case"failed":return"Failed";default:return"Processing"}},D=()=>a?l==="cex"?`(1/2) ${b}`:l==="bridge"?`(2/2) ${d.message}`:l==="completed"?"Transfer completed successfully!":V?"Destination execution failed. Funds refunded to smart account.":"Transfer failed":l==="completed"?"Operation completed successfully!":l==="failed"?"Operation failed":b,L=()=>l==="cex"||l==="bridge"?w.jsx(NE,{start:p==="tracking"||l==="bridge",onFinish:y,duration:a?180:120}):l==="completed"?w.jsx(ue,{display:"flex",flexDirection:"column",alignItems:"center",children:w.jsx(Rn,{src:PE,boxShadow:"0px 0px 20px #14AE5C",borderRadius:"90%",width:"58px",height:"58px"})}):w.jsx(ue,{display:"flex",flexDirection:"column",alignItems:"center",children:w.jsx(Rn,{src:LE,boxShadow:"0px 0px 20px #E84142",borderRadius:"90%",width:"58px",height:"58px"})}),O=r?ko[r]:"Unknown",f=i?ko[i]:"Unknown";return w.jsxs(tn,{children:[a&&w.jsx(Aq,{currentPhase:l==="cex"?0:l==="bridge"?1:2,phases:["Forward funds","Bridge"]}),w.jsxs(ue,{display:"flex",flexDirection:"column",paddingBottom:"16px",alignItems:"center",width:"100%",children:[L(),w.jsxs(ue,{display:"flex",flexDirection:"column",alignItems:"center",marginTop:"16px",textAlign:"center",children:[w.jsx(Te,{fontSize:"lg",fontWeight:"semibold",color:"fg",marginBottom:"8px",children:D()}),(l==="cex"||l==="bridge")&&N&&w.jsx(Te,{fontSize:"sm",color:"fg.muted",maxWidth:"280px",children:"Your operation is being processed – no action is required from you."})]})]}),w.jsx(hu,{size:"sm",variant:"outline",width:"100%",children:w.jsxs(fu,{children:[w.jsxs(En,{children:[w.jsx(je,{children:"Status"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:w.jsx(Te,{color:C(),children:R()})})]}),a&&w.jsxs(w.Fragment,{children:[w.jsxs(En,{children:[w.jsx(je,{children:"Current Phase"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:w.jsx(Te,{children:l==="cex"?"Awaiting funds":l==="bridge"?"Bridging":l==="completed"?"Complete":"Failed"})})]}),w.jsxs(En,{children:[w.jsx(je,{children:"Intermediate Chain"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:w.jsx(Te,{textTransform:"capitalize",children:O})})]}),w.jsxs(En,{children:[w.jsx(je,{children:"Final Destination"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:w.jsx(Te,{textTransform:"capitalize",children:f})})]})]}),u&&w.jsxs(En,{children:[w.jsx(je,{children:"Operation ID"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:w.jsx(Te,{fontSize:"sm",color:"fg.muted",children:u})})]}),a&&x&&w.jsxs(En,{children:[w.jsx(je,{children:"Bridge TX"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:w.jsx(Te,{fontSize:"sm",color:"blue.500",cursor:"pointer",onClick:()=>window.open(`https://layerzeroscan.com/tx/${x}`,"_blank"),children:"View on LayerZero"})})]}),a&&W&&w.jsxs(En,{children:[w.jsx(je,{children:"Destination TX"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:w.jsx(Te,{fontSize:"sm",color:"blue.500",cursor:"pointer",onClick:()=>{const v=ux[i]||"https://etherscan.io";window.open(`${v}/tx/${W}`,"_blank")},children:"View on Explorer"})})]}),a&&l==="bridge"&&w.jsxs(En,{children:[w.jsx(je,{children:"Bridge Progress"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:w.jsxs(Te,{children:["(",d.step,"/4)"]})})]}),a&&V&&w.jsxs(En,{children:[w.jsx(je,{children:"Refund"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:w.jsx(Te,{fontSize:"sm",color:"orange.500",children:"Funds refunded to smart account"})})]})]})},"status"),w.jsx(ud,{}),w.jsx(dd,{}),(l==="completed"||l==="failed")&&w.jsx(nr,{onClick:()=>n(0),visual:"solid",children:l==="completed"?"New Deposit":"Retry Deposit"})]})},kq=({setFlow:t,initialStep:e=1})=>{const{handleClose:n,enforceFlow:r}=K.useContext(ic),[i,o]=K.useState(e),[s,a]=K.useState(null),[l,c]=K.useState(null),u=Be(g=>g.setSelectedIntegration),h=Be(g=>g.selectedIntegration);K.useEffect(()=>()=>u(null),[]);const p=(()=>{switch(i){case 1:return w.jsx(_q,{setStep:o});case 0:return w.jsx(xq,{setStep:o});case 2:return w.jsx(wq,{setStep:o,onTokenSelect:a});case 3:return w.jsx(Eq,{setStep:o,onTokenSelect:a});case 4:return w.jsx(Sq,{setStep:o,selectedToken:s});case 5:return w.jsx(Iq,{nextStep:s.holding?6:7,setStep:o,setUserOp:c});case 6:return w.jsx(Cq,{selectedToken:s,userOp:l,setStep:o});case 7:return w.jsx(Oq,{selectedToken:s,userOp:l,setStep:o});default:return null}})();return w.jsxs(w.Fragment,{children:[w.jsx(or.Header,{children:w.jsxs(nx,{children:[!(r&&(i===1||i===3))&&w.jsx(gi,{minWidth:"16px",minHeight:"16px",maxWidth:"16px",onClick:()=>{const g=((h==null?void 0:h.type)==="delayed"?yq:ME).findIndex(b=>b===i)-1;g>=0?o(ME[g]):t("")},children:w.jsx(on,{as:U_,color:"gray",width:"16px",height:"16px"})}),w.jsx(ue,{display:"flex",flexDirection:"column",gap:"4px",alignItems:"center",width:"100%",children:w.jsxs(Ao,{children:["Deposit from ",h==null?void 0:h.name]})}),n&&w.jsx(gi,{onClick:n,minWidth:"16px",minHeight:"16px",maxWidth:"16px",marginLeft:"auto",children:w.jsx(on,{as:Ss,color:"gray",width:"16px",height:"16px"})})]})}),w.jsx(or.Body,{children:p})]})},VE=({setStep:t})=>{const e=Be(l=>l.setSelectedIntegration),n=Be(l=>l.setTokenIn),r=Be(l=>l.tokenIn),i=Be(l=>l.setChainIdIn),o=Be(l=>l.chainIdIn),{holdingsList:s,isLoading:a}=i1();return K.useEffect(()=>{e(null)},[]),w.jsxs(tn,{children:[w.jsx(ue,{overflowY:"scroll",maxH:"400px",children:w.jsx(Oo,{children:a?Array.from({length:10}).map((l,c)=>w.jsx(jr,{height:"40px",width:"300px"},c)):s==null?void 0:s.map(l=>w.jsx(Eu,{chainId:l.chainId,icon:l.logoUri,title:l.name,balance:`${kr(ir(l.amount,l.decimals))} ${l.symbol}`,usdBalance:Tr(l.total),tag:"",loading:!1,selected:l.token===r&&l.chainId===o,onClick:()=>{n(l.token),i(l.chainId)}},`${l.token}-${l.chainId}`))})}),w.jsx(nr,{onClick:()=>{t("selectAmount")},disabled:!r,children:"Continue"})]})},Tq="coingecko",Rq=We("div",{base:{display:"flex",gap:"8px",alignItems:"center",justifyContent:"center",p:"8px 12px",borderRadius:"114px",bg:"bg.subtle",w:"fit-content"}}),Nq=t=>t.includes(Tq)?t.replace("/thumb/","/large/"):t,Pq=({token:t,chainId:e,size:n=32})=>w.jsxs(ue,{position:"relative",borderRadius:"50%",minW:`${n}px`,minH:`${n}px`,children:[w.jsx(ue,{borderRadius:"50%",overflow:"hidden",width:`${n}px`,height:`${n}px`,children:w.jsx("img",{src:t!=null&&t.logoURI?Nq(t==null?void 0:t.logoURI):Is,title:t==null?void 0:t.symbol,alt:t==null?void 0:t.symbol,width:`${n}px`,height:`${n}px`})}),e&&w.jsx(ue,{position:"absolute",bottom:"0",right:"-2px",width:`${n/2}px`,height:`${n/2}px`,borderRadius:"50%",overflow:"hidden",border:"1px solid white",zIndex:"1",children:w.jsx("img",{src:`https://icons-ckg.pages.dev/stargate-light/networks/${ko[e]}.svg`,alt:`Chain ${e}`,width:"100%",height:"100%"})})]}),$E=({token:t,chainId:e,size:n=32,title:r,subTitle:i})=>w.jsxs(tr,{align:"center",gap:2,children:[w.jsx(Pq,{token:t,chainId:e,size:n}),w.jsxs(ue,{children:[w.jsx(Te,{fontWeight:"medium",fontSize:"xs",color:"fg.muted",children:r}),w.jsx(Te,{fontSize:"xs",color:"fg",children:i})]})]}),Lq=({token:t,chainId:e,size:n=32})=>{const r=(t==null?void 0:t.protocolName)||(t==null?void 0:t.protocol),i=t==null?void 0:t.protocolLogo;return w.jsxs(tr,{align:"center",gap:2,children:[w.jsxs(ue,{position:"relative",minW:`${n}px`,minH:`${n}px`,children:[w.jsx(ue,{borderRadius:"50%",overflow:"hidden",width:`${n}px`,height:`${n}px`,children:w.jsx("img",{src:i||Is,title:r,alt:r,width:`${n}px`,height:`${n}px`,onError:o=>{o.currentTarget.src=Is}})}),e&&w.jsx(ue,{position:"absolute",bottom:"0",right:"-2px",width:`${n/2}px`,height:`${n/2}px`,borderRadius:"50%",overflow:"hidden",border:"1px solid white",zIndex:"1",children:w.jsx("img",{src:`https://icons-ckg.pages.dev/stargate-light/networks/${ko[e]}.svg`,alt:`Chain ${e}`,width:"100%",height:"100%"})})]}),w.jsxs(ue,{children:[w.jsxs(Te,{fontWeight:"medium",fontSize:"xs",color:"fg.muted",children:["Deposit"," ",w.jsx(Te,{as:"span",fontSize:"xs",color:"fg",children:t==null?void 0:t.symbol})]}),w.jsxs(Te,{fontWeight:"medium",fontSize:"xs",color:"fg.muted",children:["into"," ",w.jsx(Te,{as:"span",fontSize:"xs",color:"fg",children:r})]})]})]})},Mq=({tokenIn:t,tokenOut:e,chainIdIn:n,chainIdOut:r,isNontokenized:i=!1,size:o=24})=>w.jsxs(Rq,{children:[w.jsx($E,{token:t,chainId:n,title:"You send",subTitle:t==null?void 0:t.symbol,size:o}),w.jsx(W_,{color:"#707070",width:"16px",height:"16px"}),i&&(e!=null&&e.protocol)?w.jsx(Lq,{token:e,chainId:r,size:o}):w.jsx($E,{token:e,chainId:r,title:"You receive",subTitle:e==null?void 0:e.symbol,size:o})]}),Bq=({setStep:t})=>{const[e,n]=K.useState({tokenAmount:"",usdAmount:"10.10",mode:"usd"}),r=Be(B=>B.setAmountIn),i=Be(B=>B.amountIn),[o,s]=K.useState(!0),{tokenInData:a,effectiveTokenOutData:l,tokenIn:c,chainIdOut:u,chainIdIn:h,isNontokenized:p}=yr(),{data:g}=ll(h,c),b=a!=null&&a.decimals?Math.min(a.decimals,6):6,m=e.tokenAmount,x=qD(c,h),I=K.useCallback(B=>{if(!x||!g||!(a!=null&&a.decimals))return null;const G=(BigInt(x)*BigInt(B)/BigInt(100)).toString(),Z=ir(G,a.decimals),Y=Cu(Z,b);return{tokenAmount:Y,usdAmount:(+parseFloat(Y||"0")*g).toFixed(2)}},[x,g,a==null?void 0:a.decimals,b]);K.useEffect(()=>{if(o&&g&&a&&+x>0){s(!1);const B=I(100);if(!B)return;n(G=>({...G,...B}))}},[x,o,g,a,I]),K.useEffect(()=>{if(!(a!=null&&a.decimals))return;const B=m.endsWith(".")?m.slice(0,-1):m;if(!B||B==="."){r("0");return}try{r(r1(B,a.decimals))}catch(G){r("0")}},[m,a==null?void 0:a.decimals,r]);const N=fg(m)!==null,T=N?+x<+i:!1,$=!N||T;return w.jsxs(tn,{children:[w.jsx(g1,{value:e,onChange:n,tokenSymbol:a==null?void 0:a.symbol,tokenPriceUsd:g,roundingPrecision:b,onPercentSelect:I}),w.jsx(Mq,{tokenOut:l,tokenIn:a,chainIdIn:h,chainIdOut:u,isNontokenized:p}),w.jsx(nr,{onClick:()=>t("quote"),disabled:$,children:"Continue"})]})},Fq=({setStep:t})=>{const{chainIdIn:e}=yr(),{routeLoading:n,usdAmountIn:r,routeData:i}=Ms(),o=et.useChainId(),{switchChain:s}=et.useSwitchChain(),a=UD(e),l=o!==e;return w.jsxs(tn,{children:[w.jsxs(tr,{flexDirection:"column",gap:"16px",alignItems:"center",width:"100%",children:[w.jsx(jr,{loading:n,width:n?"156px":"auto",children:w.jsx(Yf,{readOnly:!0,marginY:"8px",variant:"text",placeholder:"$10.00",value:r})}),w.jsx(ud,{})]}),w.jsx(dd,{}),l?w.jsxs(nr,{onClick:()=>{s({chainId:e})},children:["Switch to ",a]}):w.jsx(nr,{disabled:!!(i!=null&&i.error),visual:n?"lightGray":"solid",onClick:n?()=>{}:()=>{t("confirmTransfer")},children:n?"Loading quote":"Continue"})]})},Dq="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20x='1'%20y='1'%20width='18'%20height='18'%20rx='9'%20stroke='white'%20stroke-width='2'/%3e%3cpath%20d='M17.7589%2011.9352C16.6904%2016.221%2012.3496%2018.8292%208.06336%2017.7605C3.77889%2016.692%201.17066%2012.351%202.23959%208.06558C3.30758%203.77935%207.64835%201.17093%2011.9333%202.23939C16.2192%203.30785%2018.8273%207.64936%2017.7587%2011.9353L17.7588%2011.9352H17.7589Z'%20fill='%2314AE5C'/%3e%3cpath%20d='M11.9997%204.66675C12.3679%204.66675%2012.6663%204.96522%2012.6663%205.33341C12.6663%205.7016%2012.3679%206.00008%2011.9997%206.00008H7.99967C7.63148%206.00008%207.33301%205.7016%207.33301%205.33341C7.33301%204.96522%207.63148%204.66675%207.99967%204.66675H11.9997Z'%20fill='white'/%3e%3cpath%20d='M12.0003%207.33325C12.3685%207.33325%2012.667%207.63173%2012.667%207.99992V9.33325H14.667C14.9366%209.33325%2015.1797%209.49564%2015.2829%209.74471C15.386%209.99383%2015.329%2010.2806%2015.1383%2010.4713L10.4717%2015.1379C10.2113%2015.3983%209.7893%2015.3983%209.52895%2015.1379L4.86229%2010.4713C4.67162%2010.2806%204.61457%209.99383%204.71775%209.74471C4.82096%209.49564%205.06403%209.33325%205.33364%209.33325H7.33364V7.99992C7.33364%207.63173%207.63212%207.33325%208.00031%207.33325H12.0003ZM8.66697%209.99992C8.66697%2010.3681%208.3685%2010.6666%208.00031%2010.6666H6.94301L10.0003%2013.7239L13.0576%2010.6666H12.0003C11.6321%2010.6666%2011.3336%2010.3681%2011.3336%209.99992V8.66659H8.66697V9.99992Z'%20fill='white'/%3e%3c/svg%3e",Vq=We(Rn,{base:{boxSize:"36px",borderRadius:"full",objectFit:"contain"}}),$q=We(Rn,{base:{boxSize:"16px",position:"absolute",bottom:"-2px",right:"-2px",borderRadius:"full",border:"1px solid",borderColor:"bg",objectFit:"contain"}}),zq=({onClose:t,currencyIcon:e})=>{const n=()=>{const r=new Date,i=r.toLocaleString("en-US",{month:"short"}),o=r.toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"});return`${i} - ${o}`};return w.jsxs(ue,{border:"1px solid",borderColor:"border.subtle",borderRadius:"12px",width:"100%",bg:"bg",children:[w.jsxs(ue,{display:"flex",alignItems:"center",gap:"12px",borderBottom:"1px solid",borderColor:"border.subtle",padding:"10px 16px",children:[w.jsxs(ue,{position:"relative",children:[w.jsx(Vq,{src:e,alt:"Currency icon"}),w.jsx($q,{src:Dq,alt:"deposit icon"})]}),w.jsxs(ue,{flex:"1",children:[w.jsx(Te,{fontSize:"lg",fontWeight:"semibold",color:"fg",marginBottom:"4px",children:"Deposit processing"}),w.jsx(Te,{fontSize:"sm",color:"fg.muted",lineHeight:"1.4",children:"Your deposit will be added to your account soon."})]}),t&&w.jsx(on,{as:Ss,width:"16px",height:"16px",color:"fg.subtle",cursor:"pointer",_hover:{color:"fg.muted"},onClick:t})]}),w.jsxs(ue,{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"10px 16px",children:[w.jsx(Te,{fontSize:"sm",color:"fg.muted",children:"Order started"}),w.jsx(Te,{fontSize:"sm",color:"fg",fontWeight:"medium",children:n()})]})]})},Uq=()=>{var h;const{chainIdIn:t,tokenIn:e,amountIn:n}=yr(),{address:r}=et.useAccount(),{approveData:i,approveFetched:o}=mD({address:r,token:e,chainId:t,amount:n}),{routeData:s,routeFetched:a}=Ms(),{approveNeeded:l,allowanceFetched:c}=KD(e,(h=i==null?void 0:i.tx)==null?void 0:h.to,n);return{calls:K.useMemo(()=>!Ro(e,Pt)&&!c||!a||!o?[]:l?[i==null?void 0:i.tx,s==null?void 0:s.tx]:[s==null?void 0:s.tx],[l,c,a,i,s,o]),approveNeeded:l}},Wq=({setStep:t})=>{const[e,n]=K.useState("idle"),[r,i]=K.useState(!1),{address:o}=et.useAccount(),[s,a]=K.useState(""),[l,c]=K.useState(!1),{chainIdIn:u,chainIdOut:h}=yr(),{calls:p}=Uq(),{sendTxns:g,ready:b}=eV({calls:p,address:o,chainId:u}),{track:m}=lq(),x=u!==h,I=K.useCallback(W=>{n("processing"),a(W),m({hash:W,isActive:!0,chainId:u,crosschain:x,status:x?"(0/4) Waiting for source transaction completion":"Transaction in progess",message:"Transaction confirmed",onConfirmed:()=>{n("success")}})},[u,h]),N=K.useCallback(W=>{console.error(W),n("failed")},[]);K.useEffect(()=>{console.log(l,b),!l&&b&&(g(I,N),c(!0))},[l,b,g,I]);const T=()=>{i(!0)},$=()=>{t("selectToken")},B=()=>{t("quote")},G=aq(s),Z=x?`https://layerzeroscan.com/tx/${s}`:Iu({hash:s,chainId:u}),Y=()=>{switch(e){case"success":return"#14AE5C";case"failed":return"#E84142";default:return"#1E171F"}},F=()=>{switch(e){case"success":return"Success";case"failed":return"Failed";case"idle":return"Awaiting wallet approval";default:return G==null?void 0:G.status}},V=()=>{switch(e){case"processing":case"idle":return w.jsx(NE,{start:e==="processing",onFinish:T});case"success":return w.jsx(ue,{display:"flex",flexDirection:"column",alignItems:"center",children:w.jsx(Rn,{src:PE,boxShadow:"0px 0px 20px #14AE5C",borderRadius:"90%",width:"58px",height:"58px"})});case"failed":return w.jsx(ue,{display:"flex",flexDirection:"column",alignItems:"center",children:w.jsx(Rn,{src:LE,boxShadow:"0px 0px 20px #E84142",borderRadius:"90%",width:"58px",height:"58px"})})}},U=()=>e==="processing"&&r?w.jsxs(ue,{display:"flex",flexDirection:"column",alignItems:"center",marginTop:"16px",textAlign:"center",children:[w.jsx(Te,{fontSize:"lg",fontWeight:"semibold",color:"fg",marginBottom:"8px",children:"Deposit pending"}),w.jsx(Te,{fontSize:"sm",color:"fg.muted",maxWidth:"280px",children:"Your deposit is still in progress – no action is required from you."})]}):null;return w.jsxs(tn,{children:[w.jsxs(ue,{display:"flex",flexDirection:"column",paddingBottom:"16px",alignItems:"center",width:"100%",children:[V(),U()]}),w.jsx(hu,{size:"sm",variant:"outline",width:"100%",children:w.jsxs(fu,{children:[w.jsxs(En,{children:[w.jsx(je,{children:"Status"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:w.jsx(Te,{color:Y(),children:F()})})]}),["success","processing"].includes(e)&&w.jsxs(En,{children:[w.jsx(je,{children:"Transaction"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:Z?w.jsx("a",{href:Z,target:"_blank",rel:"noreferrer",children:w.jsxs(Te,{color:"blue.500",children:["View on"," ",x?"LayerZero":"Etherscan"]})}):w.jsx(Te,{children:"-"})})]})]})},"status"),w.jsx(ud,{}),e==="processing"?w.jsx(zq,{currencyIcon:dg(h)}):w.jsx(dd,{}),e==="success"&&w.jsx(nr,{visual:"solid",onClick:$,width:"100%",children:"New Deposit"}),e==="failed"&&w.jsx(nr,{visual:"solid",onClick:B,width:"100%",children:"Retry Deposit"})]})};var zE=(t=>(t.SelectToken="selectToken",t.SelectAmount="selectAmount",t.Quote="quote",t.ConfirmTransfer="confirmTransfer",t))(zE||{});const UE=["selectToken","selectAmount","quote","confirmTransfer"],Hq={exchange:kq,wallet:({initialStep:t="selectToken",setFlow:e})=>{const[n,r]=K.useState(t),{handleClose:i,enforceFlow:o}=K.useContext(ic),s=c=>{r(c)},a=()=>{const c=UE.findIndex(u=>u===n)-1;c>=0?r(UE[c]):e&&e("")},l=(()=>{switch(n){case"selectToken":return w.jsx(VE,{setStep:s});case"selectAmount":return w.jsx(Bq,{setStep:s});case"quote":return w.jsx(Fq,{setStep:s});case"confirmTransfer":return w.jsx(Wq,{setStep:s});default:return w.jsx(VE,{setStep:s})}})();return w.jsxs(w.Fragment,{children:[w.jsx(or.Header,{children:w.jsxs(nx,{children:[!(o&&n==="selectToken")&&w.jsx(gi,{minWidth:"16px",minHeight:"16px",maxWidth:"16px",onClick:a,children:w.jsx(on,{as:U_,color:"gray",width:"16px",height:"16px"})}),w.jsx(ue,{display:"flex",flexDirection:"column",gap:"4px",alignItems:"center",width:"100%",children:w.jsx(Ao,{children:"Wallet Deposit"})}),i&&w.jsx(gi,{onClick:i,minWidth:"16px",minHeight:"16px",maxWidth:"16px",marginLeft:"auto",children:w.jsx(on,{as:Ss,color:"gray",width:"16px",height:"16px"})})]})}),w.jsx(or.Body,{children:l})]})}},jq=()=>{const{handleClose:t,enableExchange:e,enforceFlow:n}=K.useContext(ic),[r,i]=K.useState(""),[o,s]=K.useState(""),[a,l]=K.useState(null),{total:c,isLoading:u}=i1(),{address:h}=et.useAccount(),{walletIcon:p,walletDisplayName:g}=f1(),{total:b,isLoading:m}=h1(1);K.useEffect(()=>{if(n)if(n==="exchange"){if(!Array.isArray(e)||e.length===0){l("No exchanges configured. Please enable at least one exchange in the widget configuration.");return}i("exchange"),s(fd.ChooseExchange)}else n==="wallet"&&h&&(i("wallet"),s(zE.SelectToken))},[n,e,h]);const x=K.useMemo(()=>u?w.jsx(jr,{display:"inline-block",height:"10px",width:"60px"}):typeof c=="number"?Tr(c):c||"$0.00",[c,u]),I=K.useMemo(()=>h?ug(h):"",[h]),N=K.useMemo(()=>{const $=[];return!m&&b>20&&$.push({id:"smart-balance",title:"Smart Account Balance",limit:Tr(b),delay:"2 min",icons:[],flow:"exchange",firstStep:fd.ChooseBalanceAsset}),Array.isArray(e)&&e.length>0&&$.unshift({id:"exchange",title:"Connect Exchange",limit:"No Limit",delay:"2 min",icons:e.map(B=>hd[ea[B]]).filter(Boolean),flow:"exchange",firstStep:fd.ChooseExchange}),$},[h,e,b,m]),T=r&&Hq[r];return T?w.jsx(T,{setFlow:i,initialStep:o}):a?w.jsxs(w.Fragment,{children:[w.jsx(or.Header,{children:w.jsxs(Xf,{children:[w.jsx(ue,{display:"flex",flexDirection:"column",gap:"4px",children:w.jsx(Ao,{children:"Configuration Error"})}),t&&w.jsx(gi,{onClick:t,width:"40px",children:w.jsx(on,{as:Ss,color:"fg.muted",width:"16px",height:"16px"})})]})}),w.jsx(or.Body,{children:w.jsx(tn,{children:w.jsxs(ue,{display:"flex",flexDirection:"column",alignItems:"center",gap:"4",p:"6",textAlign:"center",children:[w.jsx(on,{as:j4,color:"red.500",width:"48px",height:"48px"}),w.jsx(Te,{color:"fg.muted",children:a})]})})})]}):n==="wallet"&&!h?w.jsxs(w.Fragment,{children:[w.jsx(or.Header,{children:w.jsxs(Xf,{children:[w.jsx(ue,{display:"flex",flexDirection:"column",gap:"4px",children:w.jsx(Ao,{children:"Connect Wallet"})}),t&&w.jsx(gi,{onClick:t,width:"40px",children:w.jsx(on,{as:Ss,color:"fg.muted",width:"16px",height:"16px"})})]})}),w.jsx(or.Body,{children:w.jsx(tn,{children:w.jsx(Oo,{children:w.jsx(s1,{icon:p,walletHash:"Not Connected",balance:"Connect your wallet to continue",delay:"",status:hg.NONE})})})})]}):w.jsxs(w.Fragment,{children:[w.jsx(or.Header,{children:w.jsxs(Xf,{children:[w.jsx(ue,{display:"flex",flexDirection:"column",gap:"4px",children:w.jsx(Ao,{children:"Deposit"})}),t&&w.jsx(gi,{onClick:t,width:"40px",children:w.jsx(on,{as:Ss,color:"fg.muted",width:"16px",height:"16px"})})]})}),w.jsx(or.Body,{children:w.jsxs(tn,{children:[h&&w.jsx(Oo,{children:w.jsx(s1,{icon:p,walletHash:I,balance:x,delay:"Instant",status:hg.CONNECTED,badge:g,onClick:()=>{i("wallet")}},h)}),N.length>0&&w.jsxs(w.Fragment,{children:[w.jsx(vB,{}),w.jsx(Oo,{children:N.map($=>w.jsx(RD,{title:$.title,limit:$.limit,delay:$.delay,icons:$.icons,onClick:()=>{$.disabled||(i($.flow),s($.firstStep))}},$.id))})]})]})})]})};var oe=typeof window!="undefined"?window:void 0,bn=typeof globalThis!="undefined"?globalThis:oe;typeof self=="undefined"&&(bn.self=bn),typeof File=="undefined"&&(bn.File=function(){});var WE=Array.prototype,HE=WE.forEach,jE=WE.indexOf,ur=bn==null?void 0:bn.navigator,me=bn==null?void 0:bn.document,jn=bn==null?void 0:bn.location,Sp=bn==null?void 0:bn.fetch,Ip=bn!=null&&bn.XMLHttpRequest&&"withCredentials"in new bn.XMLHttpRequest?bn.XMLHttpRequest:void 0,qE=bn==null?void 0:bn.AbortController,qn=ur==null?void 0:ur.userAgent,ke=oe!=null?oe:{},Ci={DEBUG:!1,LIB_VERSION:"1.310.1"};function GE(t,e,n,r,i,o,s){try{var a=t[o](s),l=a.value}catch(c){return void n(c)}a.done?e(l):Promise.resolve(l).then(r,i)}function KE(t){return function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function s(l){GE(o,r,i,s,a,"next",l)}function a(l){GE(o,r,i,s,a,"throw",l)}s(void 0)}))}}function be(){return be=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},be.apply(null,arguments)}function YE(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var qq=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],XE=function(t,e){if(e===void 0&&(e=[]),!t)return!1;var n=t.toLowerCase();return qq.concat(e).some((r=>{var i=r.toLowerCase();return n.indexOf(i)!==-1}))},Gq=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"];function Ue(t,e){return t.indexOf(e)!==-1}var pd=function(t){return t.trim()},Cp=function(t){return t.replace(/^\$/,"")},Kq=Array.isArray,ZE=Object.prototype,JE=ZE.hasOwnProperty,md=ZE.toString,Ze=Kq||function(t){return md.call(t)==="[object Array]"},ro=t=>typeof t=="function",an=t=>t===Object(t)&&!Ze(t),ta=t=>{if(an(t)){for(var e in t)if(JE.call(t,e))return!1;return!0}return!1},fe=t=>t===void 0,nn=t=>md.call(t)=="[object String]",Ap=t=>nn(t)&&t.trim().length===0,Pr=t=>t===null,Je=t=>fe(t)||Pr(t),ei=t=>md.call(t)=="[object Number]",Ai=t=>md.call(t)==="[object Boolean]",Yq=t=>t instanceof FormData,Xq=t=>Ue(Gq,t);function Op(t){return t===null||typeof t!="object"}function vd(t,e){return Object.prototype.toString.call(t)==="[object "+e+"]"}function QE(t){return!fe(Event)&&(function(e,n){try{return e instanceof n}catch(r){return!1}})(t,Event)}var Zq=[!0,"true",1,"1","yes"],kp=t=>Ue(Zq,t),Jq=[!1,"false",0,"0","no"];function ti(t,e,n,r,i){return e>n&&(r.warn("min cannot be greater than max."),e=n),ei(t)?t>n?(r.warn(" cannot be greater than max: "+n+". Using max value instead."),n):t<e?(r.warn(" cannot be less than min: "+e+". Using min value instead."),e):t:(r.warn(" must be a number. using max or fallback. max: "+n+", fallback: "+i),ti(i||n,e,n,r))}class Qq{constructor(e){this.t={},this.i=e.i,this.o=ti(e.bucketSize,0,100,e.h),this.m=ti(e.refillRate,0,this.o,e.h),this.$=ti(e.refillInterval,0,864e5,e.h)}S(e,n){var r=n-e.lastAccess,i=Math.floor(r/this.$);if(i>0){var o=i*this.m;e.tokens=Math.min(e.tokens+o,this.o),e.lastAccess=e.lastAccess+i*this.$}}consumeRateLimit(e){var n,r=Date.now(),i=String(e),o=this.t[i];return o?this.S(o,r):(o={tokens:this.o,lastAccess:r},this.t[i]=o),o.tokens===0||(o.tokens--,o.tokens===0&&((n=this.i)==null||n.call(this,e)),o.tokens===0)}stop(){this.t={}}}var br="Mobile",yd="iOS",Oi="Android",Rl="Tablet",eS=Oi+" "+Rl,tS="iPad",nS="Apple",rS=nS+" Watch",Nl="Safari",na="BlackBerry",iS="Samsung",oS=iS+"Browser",sS=iS+" Internet",qo="Chrome",eG=qo+" OS",aS=qo+" "+yd,Tp="Internet Explorer",lS=Tp+" "+br,Rp="Opera",tG=Rp+" Mini",Np="Edge",cS="Microsoft "+Np,ra="Firefox",uS=ra+" "+yd,Pl="Nintendo",Ll="PlayStation",ia="Xbox",dS=Oi+" "+br,hS=br+" "+Nl,Ml="Windows",Pp=Ml+" Phone",fS="Nokia",Lp="Ouya",gS="Generic",nG=gS+" "+br.toLowerCase(),pS=gS+" "+Rl.toLowerCase(),Mp="Konqueror",Pn="(\\d+(\\.\\d+)?)",Bp=new RegExp("Version/"+Pn),rG=new RegExp(ia,"i"),iG=new RegExp(Ll+" \\w+","i"),oG=new RegExp(Pl+" \\w+","i"),Fp=new RegExp(na+"|PlayBook|BB10","i"),sG={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"},bd,mS,Dp,aG=(t,e)=>e&&Ue(e,nS)||(function(n){return Ue(n,Nl)&&!Ue(n,qo)&&!Ue(n,Oi)})(t),vS=function(t,e){return e=e||"",Ue(t," OPR/")&&Ue(t,"Mini")?tG:Ue(t," OPR/")?Rp:Fp.test(t)?na:Ue(t,"IE"+br)||Ue(t,"WPDesktop")?lS:Ue(t,oS)?sS:Ue(t,Np)||Ue(t,"Edg/")?cS:Ue(t,"FBIOS")?"Facebook "+br:Ue(t,"UCWEB")||Ue(t,"UCBrowser")?"UC Browser":Ue(t,"CriOS")?aS:Ue(t,"CrMo")||Ue(t,qo)?qo:Ue(t,Oi)&&Ue(t,Nl)?dS:Ue(t,"FxiOS")?uS:Ue(t.toLowerCase(),Mp.toLowerCase())?Mp:aG(t,e)?Ue(t,br)?hS:Nl:Ue(t,ra)?ra:Ue(t,"MSIE")||Ue(t,"Trident/")?Tp:Ue(t,"Gecko")?ra:""},lG={[lS]:[new RegExp("rv:"+Pn)],[cS]:[new RegExp(Np+"?\\/"+Pn)],[qo]:[new RegExp("("+qo+"|CrMo)\\/"+Pn)],[aS]:[new RegExp("CriOS\\/"+Pn)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Pn)],[Nl]:[Bp],[hS]:[Bp],[Rp]:[new RegExp("(Opera|OPR)\\/"+Pn)],[ra]:[new RegExp(ra+"\\/"+Pn)],[uS]:[new RegExp("FxiOS\\/"+Pn)],[Mp]:[new RegExp("Konqueror[:/]?"+Pn,"i")],[na]:[new RegExp(na+" "+Pn),Bp],[dS]:[new RegExp("android\\s"+Pn,"i")],[sS]:[new RegExp(oS+"\\/"+Pn)],[Tp]:[new RegExp("(rv:|MSIE )"+Pn)],Mozilla:[new RegExp("rv:"+Pn)]},cG=function(t,e){var n=vS(t,e),r=lG[n];if(fe(r))return null;for(var i=0;i<r.length;i++){var o=r[i],s=t.match(o);if(s)return parseFloat(s[s.length-2])}return null},yS=[[new RegExp(ia+"; "+ia+" (.*?)[);]","i"),t=>[ia,t&&t[1]||""]],[new RegExp(Pl,"i"),[Pl,""]],[new RegExp(Ll,"i"),[Ll,""]],[Fp,[na,""]],[new RegExp(Ml,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[Pp,""];if(new RegExp(br).test(e)&&!/IEMobile\b/.test(e))return[Ml+" "+br,""];var n=/Windows NT ([0-9.]+)/i.exec(e);if(n&&n[1]){var r=n[1],i=sG[r]||"";return/arm/i.test(e)&&(i="RT"),[Ml,i]}return[Ml,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>{if(t&&t[3]){var e=[t[3],t[4],t[5]||"0"];return[yd,e.join(".")]}return[yd,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var e="";return t&&t.length>=3&&(e=fe(t[2])?t[3]:t[2]),["watchOS",e]}],[new RegExp("("+Oi+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Oi+")","i"),t=>{if(t&&t[2]){var e=[t[2],t[3],t[4]||"0"];return[Oi,e.join(".")]}return[Oi,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var e=["Mac OS X",""];if(t&&t[1]){var n=[t[1],t[2],t[3]||"0"];e[1]=n.join(".")}return e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[eG,""]],[/Linux|debian/i,["Linux",""]]],bS=function(t){return oG.test(t)?Pl:iG.test(t)?Ll:rG.test(t)?ia:new RegExp(Lp,"i").test(t)?Lp:new RegExp("("+Pp+"|WPDesktop)","i").test(t)?Pp:/iPad/.test(t)?tS:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?rS:Fp.test(t)?na:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(fS,"i").test(t)?fS:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?new RegExp(br).test(t)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)||/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?Oi:eS:new RegExp("(pda|"+br+")","i").test(t)?nG:new RegExp(Rl,"i").test(t)&&!new RegExp(Rl+" pc","i").test(t)?pS:""},uG=t=>t instanceof Error;function dG(t){var e=globalThis._posthogChunkIds;if(e){var n=Object.keys(e);return Dp&&n.length===mS||(mS=n.length,Dp=n.reduce(((r,i)=>{bd||(bd={});var o=bd[i];if(o)r[o[0]]=o[1];else for(var s=t(i),a=s.length-1;a>=0;a--){var l=s[a],c=l==null?void 0:l.filename,u=e[i];if(c&&u){r[c]=u,bd[i]=[c,u];break}}return r}),{})),Dp}}class hG{constructor(e,n,r){r===void 0&&(r=[]),this.coercers=e,this.stackParser=n,this.modifiers=r}buildFromUnknown(e,n){n===void 0&&(n={});var r=n&&n.mechanism||{handled:!0,type:"generic"},i=this.buildCoercingContext(r,n,0).apply(e),o=this.buildParsingContext(),s=this.parseStacktrace(i,o);return{$exception_list:this.convertToExceptionList(s,r),$exception_level:"error"}}modifyFrames(e){var n=this;return KE((function*(){for(var r of e)r.stacktrace&&r.stacktrace.frames&&Ze(r.stacktrace.frames)&&(r.stacktrace.frames=yield n.applyModifiers(r.stacktrace.frames));return e}))()}coerceFallback(e){var n;return{type:"Error",value:"Unknown error",stack:(n=e.syntheticException)==null?void 0:n.stack,synthetic:!0}}parseStacktrace(e,n){var r,i;return e.cause!=null&&(r=this.parseStacktrace(e.cause,n)),e.stack!=""&&e.stack!=null&&(i=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?1:0),n.chunkIdMap)),be({},e,{cause:r,stack:i})}applyChunkIds(e,n){return e.map((r=>(r.filename&&n&&(r.chunk_id=n[r.filename]),r)))}applyCoercers(e,n){for(var r of this.coercers)if(r.match(e))return r.coerce(e,n);return this.coerceFallback(n)}applyModifiers(e){var n=this;return KE((function*(){var r=e;for(var i of n.modifiers)r=yield i(r);return r}))()}convertToExceptionList(e,n){var r,i,o,s={type:e.type,value:e.value,mechanism:{type:(r=n.type)!==null&&r!==void 0?r:"generic",handled:(i=n.handled)===null||i===void 0||i,synthetic:(o=e.synthetic)!==null&&o!==void 0&&o}};e.stack&&(s.stacktrace={type:"raw",frames:e.stack});var a=[s];return e.cause!=null&&a.push(...this.convertToExceptionList(e.cause,be({},n,{handled:!0}))),a}buildParsingContext(){return{chunkIdMap:dG(this.stackParser)}}buildCoercingContext(e,n,r){r===void 0&&(r=0);var i=(o,s)=>{if(s<=4){var a=this.buildCoercingContext(e,n,s);return this.applyCoercers(o,a)}};return be({},n,{syntheticException:r==0?n.syntheticException:void 0,mechanism:e,apply:o=>i(o,r),next:o=>i(o,r+1)})}}var oa="?";function Vp(t,e,n,r,i){var o={platform:t,filename:e,function:n==="<anonymous>"?oa:n,in_app:!0};return fe(r)||(o.lineno=r),fe(i)||(o.colno=i),o}var _S=(t,e)=>{var n=t.indexOf("safari-extension")!==-1,r=t.indexOf("safari-web-extension")!==-1;return n||r?[t.indexOf("@")!==-1?t.split("@")[0]:oa,n?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},fG=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,gG=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,pG=/\((\S*)(?::(\d+))(?::(\d+))\)/,mG=(t,e)=>{var n=fG.exec(t);if(n){var[,r,i,o]=n;return Vp(e,r,oa,+i,+o)}var s=gG.exec(t);if(s){if(s[2]&&s[2].indexOf("eval")===0){var a=pG.exec(s[2]);a&&(s[2]=a[1],s[3]=a[2],s[4]=a[3])}var[l,c]=_S(s[1]||oa,s[2]);return Vp(e,c,l,s[3]?+s[3]:void 0,s[4]?+s[4]:void 0)}},vG=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,yG=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,bG=(t,e)=>{var n=vG.exec(t);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){var r=yG.exec(n[3]);r&&(n[1]=n[1]||"eval",n[3]=r[1],n[4]=r[2],n[5]="")}var i=n[3],o=n[1]||oa;return[o,i]=_S(o,i),Vp(e,i,o,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},xS=/\(error: (.*)\)/,wS=50;function _G(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return function(i,o){o===void 0&&(o=0);for(var s=[],a=i.split(`
228
+ `,x=m+b.join(m);console.error(g.error.message,x)}throw new Qw({action:"simulate",signature:"",transactionMessage:g.error.message,logs:b})}return g.result}async sendTransaction(e,n,r){if("version"in e){if(n&&Array.isArray(n))throw new Error("Invalid arguments");const s=e.serialize();return await this.sendRawTransaction(s,n)}if(n===void 0||!Array.isArray(n))throw new Error("Invalid arguments");const i=n;if(e.nonceInfo)e.sign(...i);else{let s=this._disableBlockhashCaching;for(;;){const a=await this._blockhashWithExpiryBlockHeight(s);if(e.lastValidBlockHeight=a.lastValidBlockHeight,e.recentBlockhash=a.blockhash,e.sign(...i),!e.signature)throw new Error("!signature");const l=e.signature.toString("base64");if(this._blockhashInfo.transactionSignatures.includes(l))s=!0;else{this._blockhashInfo.transactionSignatures.push(l);break}}}const o=e.serialize();return await this.sendRawTransaction(o,r)}async sendRawTransaction(e,n){const r=Gs(e).toString("base64");return await this.sendEncodedTransaction(r,n)}async sendEncodedTransaction(e,n){const r={encoding:"base64"},i=n&&n.skipPreflight,o=i===!0?"processed":n&&n.preflightCommitment||this.commitment;n&&n.maxRetries!=null&&(r.maxRetries=n.maxRetries),n&&n.minContextSlot!=null&&(r.minContextSlot=n.minContextSlot),i&&(r.skipPreflight=i),o&&(r.preflightCommitment=o);const s=[e,r],a=await this._rpcRequest("sendTransaction",s),l=he(a,Pj);if("error"in l){let c;throw"data"in l.error&&(c=l.error.data.logs),new Qw({action:i?"send":"simulate",signature:"",transactionMessage:l.error.message,logs:c})}return l.result}_wsOnOpen(){this._rpcWebSocketConnected=!0,this._rpcWebSocketHeartbeat=setInterval(()=>{(async()=>{try{await this._rpcWebSocket.notify("ping")}catch(e){}})()},5e3),this._updateSubscriptions()}_wsOnError(e){this._rpcWebSocketConnected=!1,console.error("ws error:",e.message)}_wsOnClose(e){if(this._rpcWebSocketConnected=!1,this._rpcWebSocketGeneration=(this._rpcWebSocketGeneration+1)%Number.MAX_SAFE_INTEGER,this._rpcWebSocketIdleTimeout&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null),this._rpcWebSocketHeartbeat&&(clearInterval(this._rpcWebSocketHeartbeat),this._rpcWebSocketHeartbeat=null),e===1e3){this._updateSubscriptions();return}this._subscriptionCallbacksByServerSubscriptionId={},Object.entries(this._subscriptionsByHash).forEach(([n,r])=>{this._setSubscription(n,{...r,state:"pending"})})}_setSubscription(e,n){var i;const r=(i=this._subscriptionsByHash[e])==null?void 0:i.state;if(this._subscriptionsByHash[e]=n,r!==n.state){const o=this._subscriptionStateChangeCallbacksByHash[e];o&&o.forEach(s=>{try{s(n.state)}catch(a){}})}}_onSubscriptionStateChange(e,n){var o;const r=this._subscriptionHashByClientSubscriptionId[e];if(r==null)return()=>{};const i=(o=this._subscriptionStateChangeCallbacksByHash)[r]||(o[r]=new Set);return i.add(n),()=>{i.delete(n),i.size===0&&delete this._subscriptionStateChangeCallbacksByHash[r]}}async _updateSubscriptions(){if(Object.keys(this._subscriptionsByHash).length===0){this._rpcWebSocketConnected&&(this._rpcWebSocketConnected=!1,this._rpcWebSocketIdleTimeout=setTimeout(()=>{this._rpcWebSocketIdleTimeout=null;try{this._rpcWebSocket.close()}catch(r){r instanceof Error&&console.log(`Error when closing socket connection: ${r.message}`)}},500));return}if(this._rpcWebSocketIdleTimeout!==null&&(clearTimeout(this._rpcWebSocketIdleTimeout),this._rpcWebSocketIdleTimeout=null,this._rpcWebSocketConnected=!0),!this._rpcWebSocketConnected){this._rpcWebSocket.connect();return}const e=this._rpcWebSocketGeneration,n=()=>e===this._rpcWebSocketGeneration;await Promise.all(Object.keys(this._subscriptionsByHash).map(async r=>{const i=this._subscriptionsByHash[r];if(i!==void 0)switch(i.state){case"pending":case"unsubscribed":if(i.callbacks.size===0){delete this._subscriptionsByHash[r],i.state==="unsubscribed"&&delete this._subscriptionCallbacksByServerSubscriptionId[i.serverSubscriptionId],await this._updateSubscriptions();return}await(async()=>{const{args:o,method:s}=i;try{this._setSubscription(r,{...i,state:"subscribing"});const a=await this._rpcWebSocket.call(s,o);this._setSubscription(r,{...i,serverSubscriptionId:a,state:"subscribed"}),this._subscriptionCallbacksByServerSubscriptionId[a]=i.callbacks,await this._updateSubscriptions()}catch(a){if(console.error(`Received ${a instanceof Error?"":"JSON-RPC "}error calling \`${s}\``,{args:o,error:a}),!n())return;this._setSubscription(r,{...i,state:"pending"}),await this._updateSubscriptions()}})();break;case"subscribed":i.callbacks.size===0&&await(async()=>{const{serverSubscriptionId:o,unsubscribeMethod:s}=i;if(this._subscriptionsAutoDisposedByRpc.has(o))this._subscriptionsAutoDisposedByRpc.delete(o);else{this._setSubscription(r,{...i,state:"unsubscribing"}),this._setSubscription(r,{...i,state:"unsubscribing"});try{await this._rpcWebSocket.call(s,[o])}catch(a){if(a instanceof Error&&console.error(`${s} error:`,a.message),!n())return;this._setSubscription(r,{...i,state:"subscribed"}),await this._updateSubscriptions();return}}this._setSubscription(r,{...i,state:"unsubscribed"}),await this._updateSubscriptions()})();break}}))}_handleServerNotification(e,n){const r=this._subscriptionCallbacksByServerSubscriptionId[e];r!==void 0&&r.forEach(i=>{try{i(...n)}catch(o){console.error(o)}})}_wsOnAccountNotification(e){const{result:n,subscription:r}=he(e,rj);this._handleServerNotification(r,[n.value,n.context])}_makeSubscription(e,n){const r=this._nextClientSubscriptionId++,i=nE([e.method,n]),o=this._subscriptionsByHash[i];return o===void 0?this._subscriptionsByHash[i]={...e,args:n,callbacks:new Set([e.callback]),state:"pending"}:o.callbacks.add(e.callback),this._subscriptionHashByClientSubscriptionId[r]=i,this._subscriptionDisposeFunctionsByClientSubscriptionId[r]=async()=>{delete this._subscriptionDisposeFunctionsByClientSubscriptionId[r],delete this._subscriptionHashByClientSubscriptionId[r];const s=this._subscriptionsByHash[i];pt(s!==void 0,`Could not find a \`Subscription\` when tearing down client subscription #${r}`),s.callbacks.delete(e.callback),await this._updateSubscriptions()},this._updateSubscriptions(),r}onAccountChange(e,n,r){const{commitment:i,config:o}=ct(r),s=this._buildArgs([e.toBase58()],i||this._commitment||"finalized","base64",o);return this._makeSubscription({callback:n,method:"accountSubscribe",unsubscribeMethod:"accountUnsubscribe"},s)}async removeAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"account change")}_wsOnProgramAccountNotification(e){const{result:n,subscription:r}=he(e,oj);this._handleServerNotification(r,[{accountId:n.value.pubkey,accountInfo:n.value.account},n.context])}onProgramAccountChange(e,n,r,i){const{commitment:o,config:s}=ct(r),a=this._buildArgs([e.toBase58()],o||this._commitment||"finalized","base64",s||(i?{filters:sE(i)}:void 0));return this._makeSubscription({callback:n,method:"programSubscribe",unsubscribeMethod:"programUnsubscribe"},a)}async removeProgramAccountChangeListener(e){await this._unsubscribeClientSubscription(e,"program account change")}onLogs(e,n,r){const i=this._buildArgs([typeof e=="object"?{mentions:[e.toString()]}:e],r||this._commitment||"finalized");return this._makeSubscription({callback:n,method:"logsSubscribe",unsubscribeMethod:"logsUnsubscribe"},i)}async removeOnLogsListener(e){await this._unsubscribeClientSubscription(e,"logs")}_wsOnLogsNotification(e){const{result:n,subscription:r}=he(e,Mj);this._handleServerNotification(r,[n.value,n.context])}_wsOnSlotNotification(e){const{result:n,subscription:r}=he(e,aj);this._handleServerNotification(r,[n])}onSlotChange(e){return this._makeSubscription({callback:e,method:"slotSubscribe",unsubscribeMethod:"slotUnsubscribe"},[])}async removeSlotChangeListener(e){await this._unsubscribeClientSubscription(e,"slot change")}_wsOnSlotUpdatesNotification(e){const{result:n,subscription:r}=he(e,cj);this._handleServerNotification(r,[n])}onSlotUpdate(e){return this._makeSubscription({callback:e,method:"slotsUpdatesSubscribe",unsubscribeMethod:"slotsUpdatesUnsubscribe"},[])}async removeSlotUpdateListener(e){await this._unsubscribeClientSubscription(e,"slot update")}async _unsubscribeClientSubscription(e,n){const r=this._subscriptionDisposeFunctionsByClientSubscriptionId[e];r?await r():console.warn(`Ignored unsubscribe request because an active subscription with id \`${e}\` for '${n}' events could not be found.`)}_buildArgs(e,n,r,i){const o=n||this._commitment;if(o||r||i){let s={};r&&(s.encoding=r),o&&(s.commitment=o),i&&(s=Object.assign(s,i)),e.push(s)}return e}_buildArgsAtLeastConfirmed(e,n,r,i){const o=n||this._commitment;if(o&&!["confirmed","finalized"].includes(o))throw new Error("Using Connection with default commitment: `"+this._commitment+"`, but method requires at least `confirmed`");return this._buildArgs(e,n,r,i)}_wsOnSignatureNotification(e){const{result:n,subscription:r}=he(e,uj);n.value!=="receivedSignature"&&this._subscriptionsAutoDisposedByRpc.add(r),this._handleServerNotification(r,n.value==="receivedSignature"?[{type:"received"},n.context]:[{type:"status",result:n.value},n.context])}onSignature(e,n,r){const i=this._buildArgs([e],r||this._commitment||"finalized"),o=this._makeSubscription({callback:(s,a)=>{if(s.type==="status"){n(s.result,a);try{this.removeSignatureListener(o)}catch(l){}}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},i);return o}onSignatureWithOptions(e,n,r){const{commitment:i,...o}={...r,commitment:r&&r.commitment||this._commitment||"finalized"},s=this._buildArgs([e],i,void 0,o),a=this._makeSubscription({callback:(l,c)=>{n(l,c);try{this.removeSignatureListener(a)}catch(u){}},method:"signatureSubscribe",unsubscribeMethod:"signatureUnsubscribe"},s);return a}async removeSignatureListener(e){await this._unsubscribeClientSubscription(e,"signature result")}_wsOnRootNotification(e){const{result:n,subscription:r}=he(e,dj);this._handleServerNotification(r,[n])}onRootChange(e){return this._makeSubscription({callback:e,method:"rootSubscribe",unsubscribeMethod:"rootUnsubscribe"},[])}async removeRootChangeListener(e){await this._unsubscribeClientSubscription(e,"root change")}}Object.freeze({CreateLookupTable:{index:0,layout:q.struct([q.u32("instruction"),Zs("recentSlot"),q.u8("bumpSeed")])},FreezeLookupTable:{index:1,layout:q.struct([q.u32("instruction")])},ExtendLookupTable:{index:2,layout:q.struct([q.u32("instruction"),Zs(),q.seq(ze(),q.offset(q.u32(),-8),"addresses")])},DeactivateLookupTable:{index:3,layout:q.struct([q.u32("instruction")])},CloseLookupTable:{index:4,layout:q.struct([q.u32("instruction")])}}),new Re("AddressLookupTab1e1111111111111111111111111"),Object.freeze({RequestUnits:{index:0,layout:q.struct([q.u8("instruction"),q.u32("units"),q.u32("additionalFee")])},RequestHeapFrame:{index:1,layout:q.struct([q.u8("instruction"),q.u32("bytes")])},SetComputeUnitLimit:{index:2,layout:q.struct([q.u8("instruction"),q.u32("units")])},SetComputeUnitPrice:{index:3,layout:q.struct([q.u8("instruction"),Zs("microLamports")])}}),new Re("ComputeBudget111111111111111111111111111111"),q.struct([q.u8("numSignatures"),q.u8("padding"),q.u16("signatureOffset"),q.u16("signatureInstructionIndex"),q.u16("publicKeyOffset"),q.u16("publicKeyInstructionIndex"),q.u16("messageDataOffset"),q.u16("messageDataSize"),q.u16("messageInstructionIndex")]),new Re("Ed25519SigVerify111111111111111111111111111"),XH.utils.isValidPrivateKey,q.struct([q.u8("numSignatures"),q.u16("signatureOffset"),q.u8("signatureInstructionIndex"),q.u16("ethAddressOffset"),q.u8("ethAddressInstructionIndex"),q.u16("messageDataOffset"),q.u16("messageDataSize"),q.u8("messageInstructionIndex"),q.blob(20,"ethAddress"),q.blob(64,"signature"),q.u8("recoveryId")]),new Re("KeccakSecp256k11111111111111111111111111111");var bE;new Re("StakeConfig11111111111111111111111111111111");class _E{constructor(e,n,r){this.unixTimestamp=void 0,this.epoch=void 0,this.custodian=void 0,this.unixTimestamp=e,this.epoch=n,this.custodian=r}}bE=_E,_E.default=new bE(0,0,Re.default),Object.freeze({Initialize:{index:0,layout:q.struct([q.u32("instruction"),n9(),r9()])},Authorize:{index:1,layout:q.struct([q.u32("instruction"),ze("newAuthorized"),q.u32("stakeAuthorizationType")])},Delegate:{index:2,layout:q.struct([q.u32("instruction")])},Split:{index:3,layout:q.struct([q.u32("instruction"),q.ns64("lamports")])},Withdraw:{index:4,layout:q.struct([q.u32("instruction"),q.ns64("lamports")])},Deactivate:{index:5,layout:q.struct([q.u32("instruction")])},Merge:{index:7,layout:q.struct([q.u32("instruction")])},AuthorizeWithSeed:{index:8,layout:q.struct([q.u32("instruction"),ze("newAuthorized"),q.u32("stakeAuthorizationType"),Ys("authoritySeed"),ze("authorityOwner")])}}),new Re("Stake11111111111111111111111111111111111111"),Object.freeze({InitializeAccount:{index:0,layout:q.struct([q.u32("instruction"),i9()])},Authorize:{index:1,layout:q.struct([q.u32("instruction"),ze("newAuthorized"),q.u32("voteAuthorizationType")])},Withdraw:{index:3,layout:q.struct([q.u32("instruction"),q.ns64("lamports")])},UpdateValidatorIdentity:{index:4,layout:q.struct([q.u32("instruction")])},AuthorizeWithSeed:{index:10,layout:q.struct([q.u32("instruction"),o9()])}}),new Re("Vote111111111111111111111111111111111111111"),new Re("Va1idator1nfo111111111111111111111111111111"),ce({name:de(),website:Ce(de()),details:Ce(de()),iconUrl:Ce(de()),keybaseUsername:Ce(de())}),new Re("Vote111111111111111111111111111111111111111"),q.struct([ze("nodePubkey"),ze("authorizedWithdrawer"),q.u8("commission"),q.nu64(),q.seq(q.struct([q.nu64("slot"),q.u32("confirmationCount")]),q.offset(q.u32(),-8),"votes"),q.u8("rootSlotValid"),q.nu64("rootSlot"),q.nu64(),q.seq(q.struct([q.nu64("epoch"),ze("authorizedVoter")]),q.offset(q.u32(),-8),"authorizedVoters"),q.struct([q.seq(q.struct([ze("authorizedPubkey"),q.nu64("epochOfLastAuthorizedSwitch"),q.nu64("targetEpoch")]),32,"buf"),q.nu64("idx"),q.u8("isEmpty")],"priorVoters"),q.nu64(),q.seq(q.struct([q.nu64("epoch"),q.nu64("credits"),q.nu64("prevCredits")]),q.offset(q.u32(),-8),"epochCredits"),q.struct([q.nu64("slot"),q.nu64("timestamp")],"lastTimestamp")]);function gp(t){switch(t){case"processed":case"confirmed":case"finalized":case void 0:return t;case"recent":return"processed";case"single":case"singleGossip":return"confirmed";case"max":case"root":return"finalized";default:return}}const xE="solana:mainnet",Dj="solana:devnet",Vj="solana:testnet",$j="solana:localnet",zj="https://api.mainnet-beta.solana.com";function Uj(t){return t.includes(zj)?xE:/\bdevnet\b/i.test(t)?Dj:/\btestnet\b/i.test(t)?Vj:/\blocalhost\b/i.test(t)||/\b127\.0\.0\.1\b/.test(t)?$j:xE}function Wj(t,e){if(t===e)return!0;const n=t.length;if(n!==e.length)return!1;for(let r=0;r<n;r++)if(t[r]!==e[r])return!1;return!0}function Hj(t){if(t.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let c=0;c<e.length;c++)e[c]=255;for(let c=0;c<t.length;c++){const u=t.charAt(c),h=u.charCodeAt(0);if(e[h]!==255)throw new TypeError(u+" is ambiguous");e[h]=c}const n=t.length,r=t.charAt(0),i=Math.log(n)/Math.log(256),o=Math.log(256)/Math.log(n);function s(c){if(c instanceof Uint8Array||(ArrayBuffer.isView(c)?c=new Uint8Array(c.buffer,c.byteOffset,c.byteLength):Array.isArray(c)&&(c=Uint8Array.from(c))),!(c instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(c.length===0)return"";let u=0,h=0,p=0;const g=c.length;for(;p!==g&&c[p]===0;)p++,u++;const b=(g-p)*o+1>>>0,m=new Uint8Array(b);for(;p!==g;){let N=c[p],T=0;for(let $=b-1;(N!==0||T<h)&&$!==-1;$--,T++)N+=256*m[$]>>>0,m[$]=N%n>>>0,N=N/n>>>0;if(N!==0)throw new Error("Non-zero carry");h=T,p++}let x=b-h;for(;x!==b&&m[x]===0;)x++;let I=r.repeat(u);for(;x<b;++x)I+=t.charAt(m[x]);return I}function a(c){if(typeof c!="string")throw new TypeError("Expected String");if(c.length===0)return new Uint8Array;let u=0,h=0,p=0;for(;c[u]===r;)h++,u++;const g=(c.length-u)*i+1>>>0,b=new Uint8Array(g);for(;u<c.length;){const N=c.charCodeAt(u);if(N>255)return;let T=e[N];if(T===255)return;let $=0;for(let B=g-1;(T!==0||$<p)&&B!==-1;B--,$++)T+=n*b[B]>>>0,b[B]=T%256>>>0,T=T/256>>>0;if(T!==0)throw new Error("Non-zero carry");p=$,u++}let m=g-p;for(;m!==g&&b[m]===0;)m++;const x=new Uint8Array(h+(g-m));let I=h;for(;m!==g;)x[I++]=b[m++];return x}function l(c){const u=a(c);if(u)return u;throw new Error("Non-base"+n+" character")}return{encode:s,decodeUnsafe:a,decode:l}}var jj="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const qj=Hj(jj);var we=function(t,e,n,r){if(n==="a"&&!r)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!r:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(t):r?r.value:e.get(t)},Mt=function(t,e,n,r,i){if(r==="m")throw new TypeError("Private method is not writable");if(r==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?i.call(t,n):i?i.value=n:e.set(t,n),n},yn,Hn,Uo,Wo,Ho,Ol,sd,qe,ad,pp,ld,mp,kl,vp,wE,EE,SE,IE;class Gj extends zV{get name(){return we(this,qe,"f").name}get url(){return"https://github.com/solana-labs/wallet-standard"}get icon(){return we(this,qe,"f").icon}get readyState(){return we(this,ad,"f")}get publicKey(){return we(this,Uo,"f")}get connecting(){return we(this,Wo,"f")}get supportedTransactionVersions(){return we(this,sd,"f")}get wallet(){return we(this,qe,"f")}get standard(){return!0}constructor({wallet:e}){super(),yn.add(this),Hn.set(this,void 0),Uo.set(this,void 0),Wo.set(this,void 0),Ho.set(this,void 0),Ol.set(this,void 0),sd.set(this,void 0),qe.set(this,void 0),ad.set(this,typeof window=="undefined"||typeof document=="undefined"?fl.Unsupported:fl.Installed),vp.set(this,n=>{if("accounts"in n){const r=we(this,qe,"f").accounts[0];we(this,Hn,"f")&&!we(this,Ho,"f")&&r!==we(this,Hn,"f")&&(r?we(this,yn,"m",ld).call(this,r):(this.emit("error",new FV),we(this,yn,"m",mp).call(this)))}"features"in n&&we(this,yn,"m",kl).call(this)}),Mt(this,qe,e,"f"),Mt(this,Hn,null,"f"),Mt(this,Uo,null,"f"),Mt(this,Wo,!1,"f"),Mt(this,Ho,!1,"f"),Mt(this,Ol,we(this,qe,"f").features[P1].on("change",we(this,vp,"f")),"f"),we(this,yn,"m",kl).call(this)}destroy(){Mt(this,Hn,null,"f"),Mt(this,Uo,null,"f"),Mt(this,Wo,!1,"f"),Mt(this,Ho,!1,"f");const e=we(this,Ol,"f");e&&(Mt(this,Ol,null,"f"),e())}async autoConnect(){return we(this,yn,"m",pp).call(this,{silent:!0})}async connect(){return we(this,yn,"m",pp).call(this)}async disconnect(){if(N1 in we(this,qe,"f").features)try{Mt(this,Ho,!0,"f"),await we(this,qe,"f").features[N1].disconnect()}catch(e){this.emit("error",new DV(e==null?void 0:e.message,e))}finally{Mt(this,Ho,!1,"f")}we(this,yn,"m",mp).call(this)}async sendTransaction(e,n,r={}){try{const i=we(this,Hn,"f");if(!i)throw new hl;let o;if(Ji in we(this,qe,"f").features)if(i.features.includes(Ji))o=Ji;else if(gn in we(this,qe,"f").features&&i.features.includes(gn))o=gn;else throw new Vs;else if(gn in we(this,qe,"f").features){if(!i.features.includes(gn))throw new Vs;o=gn}else throw new dl;const s=Uj(n.rpcEndpoint);if(!i.chains.includes(s))throw new O1;try{const{signers:a,...l}=r;let c;if(gl(e)?(a!=null&&a.length&&e.sign(a),c=e.serialize()):(e=await this.prepareTransaction(e,n,l),a!=null&&a.length&&e.partialSign(...a),c=new Uint8Array(e.serialize({requireAllSignatures:!1,verifySignatures:!1}))),o===Ji){const[u]=await we(this,qe,"f").features[Ji].signAndSendTransaction({account:i,chain:s,transaction:c,options:{preflightCommitment:gp(l.preflightCommitment||n.commitment),skipPreflight:l.skipPreflight,maxRetries:l.maxRetries,minContextSlot:l.minContextSlot}});return qj.encode(u.signature)}else{const[u]=await we(this,qe,"f").features[gn].signTransaction({account:i,chain:s,transaction:c,options:{preflightCommitment:gp(l.preflightCommitment||n.commitment),minContextSlot:l.minContextSlot}});return await n.sendRawTransaction(u.signedTransaction,{...l,preflightCommitment:gp(l.preflightCommitment||n.commitment)})}}catch(a){throw a instanceof Un?a:new O1(a==null?void 0:a.message,a)}}catch(i){throw this.emit("error",i),i}}}Hn=new WeakMap,Uo=new WeakMap,Wo=new WeakMap,Ho=new WeakMap,Ol=new WeakMap,sd=new WeakMap,qe=new WeakMap,ad=new WeakMap,vp=new WeakMap,yn=new WeakSet,pp=async function(e){try{if(this.connected||this.connecting)return;if(we(this,ad,"f")!==fl.Installed)throw new MV;if(Mt(this,Wo,!0,"f"),!we(this,qe,"f").accounts.length)try{await we(this,qe,"f").features[R1].connect(e)}catch(r){throw new BV(r==null?void 0:r.message,r)}const n=we(this,qe,"f").accounts[0];if(!n)throw new Vs;we(this,yn,"m",ld).call(this,n)}catch(n){throw this.emit("error",n),n}finally{Mt(this,Wo,!1,"f")}},ld=function(e){let n;try{n=new Re(e.address)}catch(r){throw new VV(r==null?void 0:r.message,r)}Mt(this,Hn,e,"f"),Mt(this,Uo,n,"f"),we(this,yn,"m",kl).call(this),this.emit("connect",n)},mp=function(){Mt(this,Hn,null,"f"),Mt(this,Uo,null,"f"),we(this,yn,"m",kl).call(this),this.emit("disconnect")},kl=function(){var n,r;const e=Ji in we(this,qe,"f").features?we(this,qe,"f").features[Ji].supportedTransactionVersions:we(this,qe,"f").features[gn].supportedTransactionVersions;Mt(this,sd,Wj(e,["legacy"])?null:new Set(e),"f"),gn in we(this,qe,"f").features&&((n=we(this,Hn,"f"))!=null&&n.features.includes(gn))?(this.signTransaction=we(this,yn,"m",wE),this.signAllTransactions=we(this,yn,"m",EE)):(delete this.signTransaction,delete this.signAllTransactions),pl in we(this,qe,"f").features&&((r=we(this,Hn,"f"))!=null&&r.features.includes(pl))?this.signMessage=we(this,yn,"m",SE):delete this.signMessage,Eg in we(this,qe,"f").features?this.signIn=we(this,yn,"m",IE):delete this.signIn},wE=async function(e){try{const n=we(this,Hn,"f");if(!n)throw new hl;if(!(gn in we(this,qe,"f").features))throw new dl;if(!n.features.includes(gn))throw new Vs;try{const i=(await we(this,qe,"f").features[gn].signTransaction({account:n,transaction:gl(e)?e.serialize():new Uint8Array(e.serialize({requireAllSignatures:!1,verifySignatures:!1}))}))[0].signedTransaction;return gl(e)?Vo.deserialize(i):cr.from(i)}catch(r){throw r instanceof Un?r:new k1(r==null?void 0:r.message,r)}}catch(n){throw this.emit("error",n),n}},EE=async function(e){try{const n=we(this,Hn,"f");if(!n)throw new hl;if(!(gn in we(this,qe,"f").features))throw new dl;if(!n.features.includes(gn))throw new Vs;try{const r=await we(this,qe,"f").features[gn].signTransaction(...e.map(i=>({account:n,transaction:gl(i)?i.serialize():new Uint8Array(i.serialize({requireAllSignatures:!1,verifySignatures:!1}))})));return e.map((i,o)=>{const s=r[o].signedTransaction;return gl(i)?Vo.deserialize(s):cr.from(s)})}catch(r){throw new k1(r==null?void 0:r.message,r)}}catch(n){throw this.emit("error",n),n}},SE=async function(e){try{const n=we(this,Hn,"f");if(!n)throw new hl;if(!(pl in we(this,qe,"f").features))throw new dl;if(!n.features.includes(pl))throw new Vs;try{return(await we(this,qe,"f").features[pl].signMessage({account:n,message:e}))[0].signature}catch(r){throw new $V(r==null?void 0:r.message,r)}}catch(n){throw this.emit("error",n),n}},IE=async function(e={}){try{if(!(Eg in we(this,qe,"f").features))throw new dl;let n;try{[n]=await we(this,qe,"f").features[Eg].signIn(e)}catch(r){throw new T1(r==null?void 0:r.message,r)}if(!n)throw new T1;return we(this,yn,"m",ld).call(this,n.account),n}catch(n){throw this.emit("error",n),n}};class Kj{constructor(e){mt(this,"iframe");mt(this,"handshakeComplete",!1);mt(this,"parentAPI",null);mt(this,"endpoint",null);if(!e)throw new Error("BridgeParent requires an iframe element");this.iframe=e,this.initializeConnection()}async initializeConnection(){if(!this.iframe||!this.iframe.contentWindow)return;const e=await this.discoverWallets(),n=this.getSolanaWallets();this.parentAPI={eip6963Wallets:e,eip6963WalletsReady:!0,walletStandardWallets:n,walletStandardWalletsReady:!0},this.endpoint=EV(this.iframe.contentWindow,window,"*"),bg(this.parentAPI,this.endpoint),this.handshakeComplete=!0}isConnected(){return this.handshakeComplete}async discoverWallets(){return new Promise(e=>{const n=[],i=o=>{const s=o,{info:a,provider:l}=s.detail;n.findIndex(u=>u.uuid===a.uuid)===-1&&n.push({uuid:a.uuid,name:a.name,icon:a.icon,rdns:a.rdns,provider:l})};window.addEventListener("eip6963:announceProvider",i),window.dispatchEvent(new Event("eip6963:requestProvider")),setTimeout(()=>{window.removeEventListener("eip6963:announceProvider",i),e(n)},1e3)})}getSolanaWallets(){const{get:e}=kV(),n=e(),r=[],i=new Set;for(const o of n)if(this.isSolanaWallet(o)){let s;UV(o)&&(s=new Gj({wallet:o})),r.push({uuid:this.generateWalletId(o),name:o.name,chains:o.chains||[],features:Object.keys(o.features),adapter:s?{name:s.name,url:s.url,icon:s.icon,readyState:s.readyState,publicKey:S1({get value(){return s.publicKey},toBase58:async()=>{var a;return(a=s.publicKey)==null?void 0:a.toBase58()},toJSON:async()=>{var a;return(a=s.publicKey)==null?void 0:a.toJSON()},toBytes:async()=>{var a;return(a=s.publicKey)==null?void 0:a.toBytes()},toBuffer:async()=>{var a;return(a=s.publicKey)==null?void 0:a.toBuffer()},toString:async()=>{var a;return(a=s.publicKey)==null?void 0:a.toString()}}),connecting:s.connecting,connected:s.connected,supportedTransactionVersions:s.supportedTransactionVersions,wallet:s.wallet,standard:s.standard,destroy:async()=>await s.destroy(),autoConnect:async()=>await s.autoConnect(),connect:async()=>await s.connect(),disconnect:async()=>await s.disconnect(),sendTransaction:async(a,l,c)=>await s.sendTransaction(a,l,c),signTransaction:async a=>s.signTransaction!==void 0?await s.signTransaction(a):new Error("Adapter does not support signTransaction"),signAllTransactions:async a=>s.signAllTransactions!==void 0?await s.signAllTransactions(a):new Error("Adapter does not support signAllTransactions"),signMessage:async a=>s.signMessage!==void 0?await s.signMessage(a):new Error("Adapter does not support signMessage"),signIn:async a=>s.signIn!==void 0?await s.signIn(a):new Error("Adapter does not support signIn"),customFunctions:["sendSerializedTransaction","signAllSerializedTransactions","signSerializedTransaction"],sendSerializedTransaction:async(a,l)=>{const c=new Fj(l),u=new Uint8Array(a);let h;try{h=Vo.deserialize(u)}catch(p){try{h=cr.from(u)}catch(g){throw new Error("Failed to deserialize transaction as either versioned or legacy format")}}return await s.sendTransaction(h,c)},signSerializedTransaction:async a=>{if(s.signTransaction===void 0)return new Error("Adapter does not support signTransaction");const l=new Uint8Array(a);let c;try{c=Vo.deserialize(l)}catch(u){try{c=cr.from(l)}catch(h){return new Error("Failed to deserialize transaction as either versioned or legacy format")}}return await s.signTransaction(c)},signAllSerializedTransactions:async a=>{if(s.signAllTransactions===void 0)return new Error("Adapter does not support signAllTransactions");const l=[];for(const c of a){const u=new Uint8Array(c);let h;try{h=Vo.deserialize(u)}catch(p){try{h=cr.from(u)}catch(g){return new Error("Failed to deserialize one or more transactions")}}l.push(h)}return await s.signAllTransactions(l)}}:void 0}),i.add(o.name)}return r}isSolanaWallet(e){return(e.chains||[]).some(i=>i.startsWith("solana:"))}generateWalletId(e){var r;const n=((r=e.chains)==null?void 0:r[0])||"unknown";return`${e.name}-${n}`.toLowerCase().replace(/\s+/g,"-")}destroy(){this.handshakeComplete=!1,this.parentAPI&&(this.parentAPI.eip6963Wallets=[],this.parentAPI.walletStandardWallets=[],this.parentAPI=null),this.endpoint=null,this.iframe=null}}var yp=function(){return yp=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++){e=arguments[n];for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])}return t},yp.apply(this,arguments)},CE=function(t,e,n,r){function i(o){return o instanceof n?o:new n(function(s){s(o)})}return new(n||(n=Promise))(function(o,s){function a(u){try{c(r.next(u))}catch(h){s(h)}}function l(u){try{c(r.throw(u))}catch(h){s(h)}}function c(u){u.done?o(u.value):i(u.value).then(a,l)}c((r=r.apply(t,e||[])).next())})},AE=function(t,e){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,s=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),typeof Symbol=="function"&&(s[Symbol.iterator]=function(){return this}),s;function a(c){return function(u){return l([c,u])}}function l(c){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,c[0]&&(n=0)),n;)try{if(r=1,i&&(o=c[0]&2?i.return:c[0]?i.throw||((o=i.return)&&o.call(i),0):i.next)&&!(o=o.call(i,c[1])).done)return o;switch(i=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return n.label++,{value:c[1],done:!1};case 5:n.label++,i=c[1],c=[0];continue;case 7:c=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){n=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){n.label=c[1];break}if(c[0]===6&&n.label<o[1]){n.label=o[1],o=c;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(c);break}o[2]&&n.ops.pop(),n.trys.pop();continue}c=e.call(t,n)}catch(u){c=[6,u],i=0}finally{r=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},Ae,OE,cd,bp=mg,jo=null,kE=function(){return document.getElementById(bp)};function _p(t){var e,n=kE();if(!n){console.warn("Mesh SDK: Failed to deliver ".concat(t.type," message to the iframe - no iframe element found"));return}if(!cd){console.warn("Mesh SDK: Failed to deliver ".concat(t.type," message to the iframe - no link token origin found"));return}try{(e=n.contentWindow)===null||e===void 0||e.postMessage(t,cd)}catch(r){console.error("Mesh SDK: Failed to deliver ".concat(t.type," message to the iframe")),console.error(r)}}function Yj(t){return CE(this,void 0,void 0,function(){var e,e,e,e,n,r,i,o,s,a,l,c,u,h;return AE(this,function(p){switch(t.data.type){case"brokerageAccountAccessToken":{e={accessToken:t.data.payload},(n=Ae==null?void 0:Ae.onEvent)===null||n===void 0||n.call(Ae,{type:"integrationConnected",payload:e}),(r=Ae==null?void 0:Ae.onIntegrationConnected)===null||r===void 0||r.call(Ae,e);break}case"delayedAuthentication":{e={delayedAuth:t.data.payload},(i=Ae==null?void 0:Ae.onEvent)===null||i===void 0||i.call(Ae,{type:"integrationConnected",payload:e}),(o=Ae==null?void 0:Ae.onIntegrationConnected)===null||o===void 0||o.call(Ae,e);break}case"transferFinished":{e=t.data.payload,(s=Ae==null?void 0:Ae.onEvent)===null||s===void 0||s.call(Ae,{type:"transferCompleted",payload:e}),(a=Ae==null?void 0:Ae.onTransferFinished)===null||a===void 0||a.call(Ae,e);break}case"close":case"done":{e=(l=t.data)===null||l===void 0?void 0:l.payload,(c=Ae==null?void 0:Ae.onExit)===null||c===void 0||c.call(Ae,e==null?void 0:e.errorMessage,e),jo==null||jo.destroy(),vg();break}case"loaded":{_p({type:"meshSDKSpecs",payload:yp({},dV)}),Ae!=null&&Ae.accessTokens&&_p({type:"frontAccessTokens",payload:Ae.accessTokens}),Ae!=null&&Ae.transferDestinationTokens&&_p({type:"frontTransferDestinationTokens",payload:Ae.transferDestinationTokens}),(u=Ae==null?void 0:Ae.onEvent)===null||u===void 0||u.call(Ae,{type:"pageLoaded"});break}default:{sV(t.data.type)&&((h=Ae==null?void 0:Ae.onEvent)===null||h===void 0||h.call(Ae,t.data));break}}return[2]})})}function xp(t){return CE(this,void 0,void 0,function(){return AE(this,function(e){switch(e.label){case 0:return t.origin!==OE&&t.origin!==cd?(console.warn("Received message from untrusted origin:",t.origin),[3,3]):[3,1];case 1:return[4,Yj(t)];case 2:e.sent(),e.label=3;case 3:return[2]}})})}var TE=function(t){var e=function(r,i){var o,s;if(!r){(o=t==null?void 0:t.onExit)===null||o===void 0||o.call(t,"Invalid link token!");return}Ae=t;var a=window.atob(r),l=a.startsWith("http://")||a.startsWith("https://");if(!l){(s=t==null?void 0:t.onExit)===null||s===void 0||s.call(t,"Invalid link token!");return}if(a=Xj(a,Ae==null?void 0:Ae.language),a=Zj(a,Ae==null?void 0:Ae.displayFiatCurrency),a=Jj(a,Ae==null?void 0:Ae.theme),cd=new URL(a).origin,window.removeEventListener("message",xp),i){var c=document.getElementById(i);c?(c.allow="clipboard-read *; clipboard-write *",c.src=a,bp=i):console.warn("Mesh SDK: No iframe found with id ".concat(i))}else bp=mg,cV(a);window.addEventListener("message",xp),OE=window.location.origin;var u=kE();u&&(jo=new Kj(u))},n=function(){var r;jo==null||jo.destroy(),vg(),window.removeEventListener("message",xp),(r=t.onExit)===null||r===void 0||r.call(t)};return{openLink:e,closeLink:n}};function Xj(t,e){return e==="system"&&(e=typeof navigator!="undefined"&&navigator.language?encodeURIComponent(navigator.language):void 0),"".concat(t).concat(t.includes("?")?"&":"?","lng=").concat(e||"en")}function Zj(t,e){return e?"".concat(t).concat(t.includes("?")?"&":"?","fiatCur=").concat(e):t}function Jj(t,e){return e?"".concat(t).concat(t.includes("?")?"&":"?","th=").concat(e):t}const Qj="Swap not found for a required underlying of defi route, please make sure your amount is within an acceptable range",eq="coingecko",tq=t=>t.includes(eq)?t.replace("/thumb/","/large/"):t,RE=({token:t,chainId:e,size:n=32})=>w.jsxs(ue,{position:"relative",borderRadius:"50%",minW:`${n}px`,minH:`${n}px`,children:[w.jsx(ue,{borderRadius:"50%",overflow:"hidden",width:`${n}px`,height:`${n}px`,children:w.jsx("img",{src:t!=null&&t.logoURI?tq(t==null?void 0:t.logoURI):Is,title:t==null?void 0:t.symbol,alt:t==null?void 0:t.symbol,width:`${n}px`,height:`${n}px`})}),e&&w.jsx(ue,{position:"absolute",bottom:"0",right:"-2px",width:`${n/2}px`,height:`${n/2}px`,borderRadius:"50%",overflow:"hidden",border:"1px solid",borderColor:"bg",zIndex:"1",children:w.jsx("img",{src:`https://icons-ckg.pages.dev/stargate-light/networks/${ko[e]}.svg`,alt:`Chain ${e}`,width:"100%",height:"100%"})})]}),ud=()=>{const{address:t}=et.useAccount(),{walletIcon:e,walletDisplayName:n}=f1(),{chainIdOut:r,effectiveTokenOutData:i,tokenInData:o,amountIn:s,chainIdIn:a,selectedIntegration:l,isNontokenized:c}=yr(),{routeLoading:u,routeData:h,routeFetched:p,routerError:g}=Ms(),b=u||!p&&!g,m=h!=null&&h.error||(h==null?void 0:h.statusCode)===500?Qj:null,x=Iu({hash:t,chainId:a,type:"/address"}),I=Iu({hash:t,chainId:r,type:"/address"}),N=K.useMemo(()=>{if(l!=null&&l.type){const T=hd[l.type],$=l.name||l.type;return w.jsxs(w.Fragment,{children:[T&&w.jsx(Rn,{src:T,width:"16px",height:"16px",borderRadius:"full"}),w.jsx(Te,{children:$})]})}return w.jsxs(w.Fragment,{children:[typeof e=="string"?w.jsx(Rn,{src:e,width:"16px",height:"16px"}):e,w.jsx(Kf,{content:n,children:w.jsx(Te,{children:t&&n+" "+ug(t,!0)})}),x&&w.jsx(Vf,{href:x,target:"_blank",children:w.jsx(on,{as:H_,color:"fg.muted",width:"16px",height:"16px"})})]})},[l,e,n,t,x]);return w.jsxs(w.Fragment,{children:[w.jsx(hu,{size:"sm",variant:"outline",width:"100%",borderRadius:"sm",children:w.jsxs(fu,{children:[w.jsxs(En,{children:[w.jsx(je,{children:"Source"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:w.jsx(ue,{display:"flex",gap:"8px",alignItems:"center",children:N})})]}),w.jsxs(En,{children:[w.jsx(je,{children:"Destination"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:w.jsx(jr,{loading:b,width:b?"80px":"auto",children:w.jsxs(tr,{gap:"8px",alignItems:"center",children:[w.jsx(Rn,{src:dg(r),width:"16px",height:"16px"}),w.jsx(Te,{children:l1(r)})," - ",w.jsx(Kf,{content:n,children:w.jsx(Te,{children:t&&ug(t)})}),I&&w.jsx(Vf,{href:I,target:"_blank",children:w.jsx(on,{as:H_,color:"fg.muted",width:"16px",height:"16px"})})]})})})]}),w.jsxs(En,{children:[w.jsx(je,{children:"Estimated time"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:w.jsx(jr,{loading:b,width:b?"80px":"auto",children:w.jsx(Te,{children:l!=null&&l.type?"~2min":a!==r?"~1 min":"instant"})})})]})]})},"line"),m?w.jsx(Te,{fontSize:"xs",color:"error",children:m}):w.jsx(hu,{size:"sm",variant:"outline",bg:"bg.subtle",children:w.jsxs(fu,{children:[w.jsxs(En,{children:[w.jsx(je,{children:"You send"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:w.jsxs(ue,{display:"flex",gap:"8px",alignItems:"center",children:[w.jsxs(Te,{children:[kr(ir(s,o==null?void 0:o.decimals))," ",o==null?void 0:o.symbol]}),w.jsx(RE,{token:o,chainId:a,size:24})]})})]}),w.jsxs(En,{children:[w.jsx(je,{children:c&&(i!=null&&i.protocol)?`Deposit into ${i.protocolName||i.protocol}`:"You receive"}),w.jsxs(je,{display:"flex",textAlign:"end",justifyContent:"end",children:[" ",w.jsx(jr,{loading:b,width:b?"156px":"auto",children:w.jsxs(ue,{display:"flex",gap:"8px",alignItems:"center",children:[w.jsxs(Te,{children:[kr(ir(h==null?void 0:h.amountOut,i==null?void 0:i.decimals))," ",i==null?void 0:i.symbol]}),c&&(i!=null&&i.protocol)?w.jsxs(ue,{position:"relative",minW:"24px",minH:"24px",children:[w.jsx(ue,{borderRadius:"50%",overflow:"hidden",width:"24px",height:"24px",children:w.jsx("img",{src:i.protocolLogo||Is,title:i.protocol,alt:i.protocol,width:"24px",height:"24px",onError:T=>{T.currentTarget.src=Is}})}),r&&w.jsx(ue,{position:"absolute",bottom:"0",right:"-2px",width:"12px",height:"12px",borderRadius:"50%",overflow:"hidden",border:"1px solid",borderColor:"bg",zIndex:"1",children:w.jsx("img",{src:`https://icons-ckg.pages.dev/stargate-light/networks/${ko[r]}.svg`,alt:`Chain ${r}`,width:"100%",height:"100%"})})]}):w.jsx(RE,{token:i,chainId:r,size:24})]})})]})]})]})},"line")]})},nq=()=>{var l;const{routeData:t}=Ms(),{tokenIn:e,chainIdIn:n,amountIn:r}=yr(),{data:i}=ll(n,Pt),{data:[o]}=Ls(Pt,n),s=K.useMemo(()=>{var u,h;let c=+((h=(u=t==null?void 0:t.tx)==null?void 0:u.value)!=null?h:0);return Ro(e,Pt)&&(c-=+r),ir(Math.max(0,c).toString(),18)},[(l=t==null?void 0:t.tx)==null?void 0:l.value,e,r]),a=+s*+(i!=null?i:0);return w.jsxs(Te,{title:"Bridging fee",cursor:"default",display:"flex",alignItems:"center",gap:1,color:"fg.subtle",fontSize:"xs",children:[w.jsx(q4,{size:12}),w.jsx(Kf,{content:`${kr(s,!0)} ${o==null?void 0:o.symbol}`,children:w.jsx(Te,{fontSize:"xs",color:"fg.subtle",children:Tr(a)})})]})};We("div",{base:{display:"flex",justifyContent:"space-between",alignItems:"center",h:"36px",p:"8px 12px",borderRadius:"8px",bg:"bg",w:"100%"}});const dd=()=>{const{routeData:t}=Ms(),{chainIdIn:e,chainIdOut:n,selectedIntegration:r}=yr(),i=Me(c=>c.slippage),[o,s]=K.useState(!1),l=[{detail:`${t!=null&&t.priceImpact?(-(t==null?void 0:t.priceImpact)/100).toFixed(2):"0.00"}%`,label:"Est. price impact"},{detail:`${i/100}%`,label:"Max. slippage"},{detail:r!=null&&r.type?"~2min":e!==n?"~1 min":"instant",label:"Est. processing time"}];return w.jsx(x4,{open:o,onOpenChange:c=>s(c.open),w:"full",children:w.jsxs(ue,{width:"100%",bg:"bg.subtle",borderRadius:"md",padding:"12px",transition:"all 0.2s",children:[w.jsx(w4,{asChild:!0,children:w.jsxs(tr,{align:"center",justify:"space-between",width:"100%",cursor:"pointer",children:[w.jsxs(tr,{align:"center",gap:2,children:[w.jsx(Vi,{color:"fg.muted",fontSize:"sm",children:"Transaction details"}),w.jsx(on,{as:H4,width:"14px",height:"14px",color:"fg.muted",transform:o?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease-in-out"})]}),w.jsx(nq,{})]})}),w.jsx(E4,{children:w.jsx(ue,{marginTop:"12px",paddingTop:"12px",borderTop:"1px solid",borderColor:"border",children:l.map((c,u)=>w.jsxs(tr,{justify:"space-between",align:"center",paddingY:"6px",children:[w.jsx(Vi,{fontSize:"sm",color:"fg.muted",children:c.label}),w.jsx(Vi,{fontSize:"sm",color:"fg",fontWeight:"medium",children:c.detail})]},u))})})]})})},rq=We("div",{base:{w:"58px",h:"58px",borderRadius:"full",border:"1px solid",borderColor:"border",display:"flex",alignItems:"center",justifyContent:"center"}}),NE=({onFinish:t,start:e,duration:n=60})=>{const[r,i]=K.useState(n);K.useEffect(()=>{i(n)},[n]),K.useEffect(()=>{if(!e)return;const s=setInterval(()=>{i(a=>a<=1?(clearInterval(s),t==null||t(),0):a-1)},1e3);return()=>clearInterval(s)},[e,t]);const o=s=>{const a=Math.floor(s/60).toString().padStart(2,"0"),l=(s%60).toString().padStart(2,"0");return`${a}:${l}`};return w.jsx(Es,{children:w.jsx(rq,{children:w.jsx(Te,{fontSize:"xs",color:"fg.muted",fontWeight:"medium",children:o(r)})})})},iq="data:image/svg+xml,%3csvg%20width='17'%20height='16'%20viewBox='0%200%2017%2016'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20clip-path='url(%23clip0_126_8587)'%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M16.3686%2010.6232C16.3715%2010.6146%2016.359%2010.6097%2016.355%2010.6179C14.975%2013.5085%2012.2144%2015.5112%208.66017%2015.5112C4.88611%2015.5112%201.35008%2012.688%201.35008%208.37011C1.35008%204.65011%204.30812%201.56104%207.74213%201.56104C10.6321%201.56104%2012.6382%203.28819%2012.6382%204.51714C12.6382%205.08189%2012.2642%205.48041%2011.6862%205.48041C10.3602%205.48041%209.85022%203.15536%207.33413%203.15536C4.78406%203.15536%202.6081%205.54683%202.6081%208.37011C2.6081%2012.0238%205.56614%2014.4153%208.52417%2014.4153C9.68043%2014.4153%2010.322%2014.1182%2010.5073%2014.0169C10.515%2014.0126%2010.51%2014.0012%2010.5017%2014.0037C10.3174%2014.0604%209.73839%2014.2159%208.93211%2014.2159C5.29405%2014.2159%203.83206%2011.4591%203.83206%209.66544C3.83206%208.30367%204.71606%207.73906%205.43016%207.73906C7.33413%207.73906%207.06219%2011.7248%2011.7542%2011.7248C14.2023%2011.7248%2016.4803%2010.0972%2016.4803%206.87544C16.4803%203.22178%2012.9442%200%208.66017%200C4.17214%200%200.5%203.554%200.5%207.97156C0.5%2012.4223%204.30812%2015.9763%208.66017%2015.9763C12.4804%2015.9763%2015.3429%2013.5242%2016.3686%2010.6232Z'%20fill='%231E171F'/%3e%3c/g%3e%3cdefs%3e%3cclipPath%20id='clip0_126_8587'%3e%3crect%20width='16'%20height='16'%20fill='white'%20transform='translate(0.5)'/%3e%3c/clipPath%3e%3c/defs%3e%3c/svg%3e",oq="data:image/svg+xml,%3csvg%20width='32'%20height='33'%20viewBox='0%200%2032%2033'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20y='0.5'%20width='32'%20height='32'%20rx='16'%20fill='%232F2B32'/%3e%3cpath%20d='M22.5582%2020.6133L16.0006%2027.1709L9.4469%2020.6172L9.44397%2020.6133L11.858%2018.2061L16.0006%2022.3496L20.1481%2018.2021L22.5582%2020.6133ZM18.4469%2016.502L16.0006%2018.9521L13.5543%2016.5059V16.498L13.984%2016.0693L14.194%2015.8633L16.0006%2014.0557L18.4469%2016.502ZM26.6666%2016.5029L24.2565%2018.9131L21.8473%2016.5029L24.2565%2014.0928L26.6666%2016.5029ZM10.153%2016.501L7.7428%2018.9111L5.33264%2016.501L7.7428%2014.0908L10.153%2016.501ZM22.5582%2012.3906L20.1481%2014.8018L16.0006%2010.6543L11.858%2014.7979L9.4469%2012.3867L16.0006%205.83301L22.5582%2012.3906Z'%20fill='%23F3BA2F'/%3e%3c/svg%3e",wp=({icon:t,title:e,description:n})=>w.jsxs(ue,{display:"flex",flexDirection:"row",gap:"16px",width:"100%",alignItems:"flex-start",children:[w.jsx(on,{as:t,color:"fg.muted",width:"20px",height:"20px",marginTop:"2px"}),w.jsxs(ue,{display:"flex",flexDirection:"column",gap:"4px",flex:"1",children:[w.jsx(ue,{fontWeight:"600",fontSize:"14px",lineHeight:"120%",color:"fg",children:e}),w.jsx(ue,{fontWeight:"400",fontSize:"12px",lineHeight:"140%",color:"fg.subtle",children:n})]})]}),sq=({onConfirm:t,exchangeName:e="your exchange",exchangeIcon:n})=>w.jsxs(tn,{children:[w.jsx(ue,{display:"flex",justifyContent:"center",width:"100%",children:w.jsx(Rn,{w:"48px",h:"48px",borderRadius:"full",src:n||oq})}),w.jsxs(ue,{fontWeight:"600",fontSize:"16px",lineHeight:"140%",color:"fg",textAlign:"center",children:["Enso Checkout uses a 3rd party to connect your ",e," account."]}),w.jsxs(ue,{display:"flex",flexDirection:"column",gap:"12px",width:"100%",children:[w.jsx(wp,{icon:G4,title:"Your sign-in credentials are never stored",description:"All data is encrypted between enso and Binance"}),w.jsx(wp,{icon:Y4,title:"2fa always required",description:"Transfers cannot be made without your approval."}),w.jsx(wp,{icon:K4,title:"Assets never touch 3rd parties",description:"Your funds are transferred directly to your wallet."}),w.jsxs(mB,{children:[w.jsx(Rn,{src:iq,color:"gray",w:"24px"}),"Enso securely encrypts all user data."]})]}),w.jsx(nr,{onClick:t,children:"Continue to 3rd Party"})]}),PE="data:image/svg+xml,%3csvg%20width='58'%20height='58'%20viewBox='0%200%2058%2058'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='29'%20cy='29'%20r='29'%20fill='%2314AE5C'/%3e%3cpath%20d='M36.2929%2022.2929C36.6834%2021.9024%2037.3164%2021.9024%2037.707%2022.2929C38.0975%2022.6834%2038.0975%2023.3164%2037.707%2023.707L26.707%2034.707C26.3164%2035.0975%2025.6834%2035.0975%2025.2929%2034.707L20.2929%2029.707C19.9024%2029.3164%2019.9024%2028.6834%2020.2929%2028.2929C20.659%2027.9268%2021.238%2027.9042%2021.6308%2028.2245L21.707%2028.2929L25.9999%2032.5859L36.2929%2022.2929Z'%20fill='white'/%3e%3c/svg%3e",LE="data:image/svg+xml,%3csvg%20width='58'%20height='58'%20viewBox='0%200%2058%2058'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3ccircle%20cx='29'%20cy='29'%20r='29'%20fill='%23E84142'/%3e%3cpath%20d='M34.2929%2022.2929C34.6834%2021.9024%2035.3164%2021.9024%2035.707%2022.2929C36.0975%2022.6834%2036.0975%2023.3164%2035.707%2023.707L23.707%2035.707C23.3164%2036.0975%2022.6834%2036.0975%2022.2929%2035.707C21.9024%2035.3164%2021.9024%2034.6834%2022.2929%2034.2929L34.2929%2022.2929Z'%20fill='white'/%3e%3cpath%20d='M22.2929%2022.2929C22.6834%2021.9024%2023.3164%2021.9024%2023.707%2022.2929L35.707%2034.2929L35.7753%2034.3691C36.0957%2034.7618%2036.0731%2035.3408%2035.707%2035.707C35.3408%2036.0731%2034.7618%2036.0957%2034.3691%2035.7753L34.2929%2035.707L22.2929%2023.707C21.9024%2023.3164%2021.9024%2022.6834%2022.2929%2022.2929Z'%20fill='white'/%3e%3c/svg%3e";var Qr=(t=>(t.Binance="binance",t.Kraken="kraken",t.Coinbase="coinbase",t.Bybit="bybit",t))(Qr||{});const Qs=ox(t=>({txs:[],addTx:e=>t(n=>({txs:[...n.txs,e]})),removeTx:e=>t(n=>({txs:n.txs.filter(r=>r.hash!==e)})),updateTx:(e,n)=>t(r=>({txs:r.txs.map(i=>i.hash===e?{...i,...n}:i)}))})),aq=t=>{const{txs:e}=Qs();return e.find(n=>n.hash===t)},lq=()=>{const{addTx:t}=Qs();return{track:K.useCallback(n=>{n.hash&&t(n)},[])}},cq=(t,e=!0)=>{var l,c;const{data:n,isLoading:r}=Kn.useQuery({queryKey:["layerZeroStatus",t||"none"],queryFn:async()=>t?fetch(`https://scan.layerzero-api.com/v1/messages/tx/${t}`).then(u=>u.json()).then(u=>{var h,p;return(p=(h=u.data)==null?void 0:h[0])!=null?p:null}):null,refetchInterval:2e3,enabled:e&&!!t}),i=(l=n==null?void 0:n.status)==null?void 0:l.name,o=(c=n==null?void 0:n.source)==null?void 0:c.status;let s=0,a="Waiting for bridge transaction...";return o&&o!=="SUCCEEDED"?(s=1,a="Waiting for funds to be sent on destination"):i==="INFLIGHT"?(s=2,a="Waiting for funds to be delivered on destination"):i==="CONFIRMING"?(s=3,a="Waiting for destination execution"):i==="DELIVERED"&&(s=4,a="Bridging is complete"),{data:n,isLoading:r,status:i,sourceStatus:o,step:s,message:a,isComplete:i==="DELIVERED",isFailed:i==="FAILED"}},uq=(t,e)=>{const n=Qs(i=>i.updateTx),{data:r}=Kn.useQuery({queryKey:["layerZeroUrl",t||"none",!!e],queryFn:async()=>t?fetch(`https://scan.layerzero-api.com/v1/messages/tx/${t}`).then(i=>i.json()).then(i=>i.data[0]):null,refetchInterval:2e3,enabled:!!(e&&t)});K.useEffect(()=>{var i,o,s,a;t&&((i=r==null?void 0:r.source)!=null&&i.status&&r.source.status!=="SUCCEEDED"?n(t,{status:"(1/4) Waiting for funds to be sent on destination"}):((o=r==null?void 0:r.status)==null?void 0:o.name)==="DELIVERED"?(e==null||e(),n(t,{status:"(4/4) Bridging is complete",isActive:!1})):((s=r==null?void 0:r.status)==null?void 0:s.name)==="CONFIRMING"?n(t,{status:"(3/4) Waiting for destination execution"}):((a=r==null?void 0:r.status)==null?void 0:a.name)==="INFLIGHT"&&n(t,{status:"(2/4) Waiting for funds to be delivered on destination"}))},[r,t])},dq=(t,e,n,r,i)=>{const o=Iu({hash:t,chainId:e}),s=Qs(a=>a.updateTx);K.useEffect(()=>{i&&(r.error?s(t,{status:"Transaction Failed",isActive:!1}):r.data&&(i==null||i(),s(t,{status:"Transaction Confirmed",isActive:!1})))},[r.data,r.error,r.isLoading,n,o,i])},hq=({hash:t,chainId:e,message:n="Transaction confirmed",onConfirmed:r})=>{const{removeTx:i}=Qs(),o=et.useWaitForTransactionReceipt({hash:t,chainId:e});return K.useEffect(()=>{o.data&&(r==null||r(o.data))},[o.data,r]),dq(t,e,n,o,()=>i(t)),null},fq=({hash:t,chainId:e,onConfirmed:n})=>{const r=et.useWaitForTransactionReceipt({hash:t,chainId:e});return uq(r.data?t:void 0,()=>n==null?void 0:n(r.data)),null},gq=t=>t.crosschain?w.jsx(fq,{...t}):w.jsx(hq,{...t}),pq=()=>{const{txs:t}=Qs();return w.jsx(w.Fragment,{children:t.filter(e=>e.isActive).map(e=>w.jsx(gq,{...e},e.hash))})},mq="0x0000000071727de22e5e9d8baf0edac6f37da032",ea={[Qr.Binance]:"binanceInternationalDirect",[Qr.Kraken]:"krakenDirect",[Qr.Coinbase]:"coinbase",[Qr.Bybit]:"bybitDirect"},hd={[ea[Qr.Binance]]:"https://assets.coingecko.com/markets/images/52/large/binance.jpg",[ea[Qr.Kraken]]:"https://assets.coingecko.com/markets/images/29/large/kraken.jpg",[ea[Qr.Coinbase]]:"https://assets.coingecko.com/markets/images/23/large/Coinbase_Coin_Primary.png",[ea[Qr.Bybit]]:"https://assets.coingecko.com/markets/images/698/large/bybit_spot.png"},vq=t=>t==="delayed",Tl="https://mesh-bff.enso-checkout.workers.dev";var fd=(t=>(t[t.CheckSessionKey=0]="CheckSessionKey",t[t.ChooseExchange=1]="ChooseExchange",t[t.ChooseExchangeAsset=2]="ChooseExchangeAsset",t[t.ChooseBalanceAsset=3]="ChooseBalanceAsset",t[t.ChooseAmount=4]="ChooseAmount",t[t.SignUserOp=5]="SignUserOp",t[t.InitiateWithdrawal=6]="InitiateWithdrawal",t[t.TrackUserOp=7]="TrackUserOp",t))(fd||{});const ME=[1,2,4,5,6],yq=[3,4,5],Ep={1:"e3c7fdd8-b1fc-4e51-85ae-bb276e075611",8453:"aa883b03-120d-477c-a588-37c2afd3ca71",42161:"a34f2431-0ddd-4de4-bc22-4a8143287aeb",137:"7436e9d0-ba42-4d2b-b4c0-8e4e606b2c12",10:"18fa36b0-88a8-43ca-83db-9a874e0a2288",43114:"bad16371-c22a-4bf4-a311-274d046cd760",56:"ed0ebeec-b166-4c8b-8574-cb078f7af8cf",146:"385f0b3a-8471-4b8f-884f-c4f4496f1603"},BE=Object.keys(Ep).map(Number),bq=t=>Ep[t]||Ep[8453],FE=()=>{const{setMeshAccessToken:t}=Me(),e=gd(),n=Me(r=>r.selectedIntegration);return K.useCallback((r,i)=>{t(r),sessionStorage.setItem(`${e}:${n==null?void 0:n.type}`,JSON.stringify({accessTokenPayload:r,sessionId:i,timestamp:Date.now()}))},[e,n==null?void 0:n.type])},_q=({setStep:t})=>{var b;const{chainIdOut:e,setChainIdIn:n}=Me(),[r,i]=K.useState([]),[o,s]=K.useState(!0),[a,l]=K.useState(null),c=Me(m=>m.setSelectedIntegration),{enableExchange:u,cexBridgeChainMapping:h}=K.useContext(ic),p=h!=null?h:Jf,g=(b=RB(e,p))!=null?b:e;return K.useEffect(()=>{g&&n(g)},[g,n]),K.useEffect(()=>{(async()=>{try{const I=await(await fetch(`${Tl}/integrations`)).json(),N=u.map($=>ea[$]).filter(Boolean),T=I==null?void 0:I.filter($=>$.networks.some(B=>+B.chainId===g)&&N.includes($.type));i(T)}catch(x){console.error("Failed to fetch integrations",x),l("Failed to load exchanges")}finally{s(!1)}})()},[g]),o?w.jsx(Es,{children:w.jsx(Co,{m:5})}):a?w.jsx(tn,{children:w.jsx(ue,{p:5,color:"red.500",children:a})}):w.jsx(tn,{children:(r==null?void 0:r.length)>0?w.jsx(Oo,{children:r.map(m=>w.jsx(Eu,{icon:hd[m.type],title:m.name,balance:"",usdBalance:"",tag:"",loading:!1,selected:!1,onClick:()=>{c({id:m.id,type:m.type,name:m.name}),t(0)}},m.id))}):w.jsx(ue,{textAlign:"center",fontSize:"sm",color:"fg.subtle",py:3,children:"No exchanges available for specified target chain"})})},xq=({setStep:t})=>{const{chainIdIn:e,chainIdOut:n,setMeshAccessToken:r,setSessionId:i}=Me(),{address:o}=et.useAccount(),s=gd(),[a,l]=K.useState(!1),c=Me(b=>b.selectedIntegration),u=e!==n,h=n&&!BE.includes(n)&&!u,p=FE();K.useEffect(()=>{if(!c){t(1);return}if(h)return;const b=sessionStorage.getItem(`${s}:${c.type}`);if(b)try{const m=JSON.parse(b);if(m!=null&&m.accessTokenPayload&&(m!=null&&m.sessionId)){r(m.accessTokenPayload),i(m.sessionId),t(2);return}}catch(m){console.error("Failed to parse saved Mesh connection",m)}l(!0)},[s,h,c]);const g=()=>{const b=c==null?void 0:c.type;fetch(`${Tl}/linktoken?brokerType=${encodeURIComponent(b)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userId:s,integrationId:c==null?void 0:c.id,address:o})}).then(m=>m.json()).then(m=>{i(m.content.sessionId);const x=TE({clientId:o,onIntegrationConnected:I=>{console.log("onIntegrationConnected",I),x.closeLink(),t(2),p(I.accessToken,m.content.sessionId)},onExit:I=>{console.log("onExit",I)},onTransferFinished:I=>{console.log("onTransferFinished",I)},onEvent:I=>{console.log(I)}});x.openLink(m.content.linkToken)}).catch(m=>console.error(m))};return h?w.jsx(tn,{children:w.jsxs(ue,{textAlign:"center",py:8,children:[w.jsx(Te,{fontSize:"lg",fontWeight:"bold",color:"red.500",mb:4,children:"Unsupported Network"}),w.jsxs(Te,{color:"fg.muted",mb:6,children:["The selected network (Chain ID: ",n,") is not supported for exchange transactions. Please switch to a supported network such as: ",BE.join(", ")]})]})}):a?w.jsx(sq,{onConfirm:g,exchangeName:c==null?void 0:c.name,exchangeIcon:c!=null&&c.type?hd[c.type]:void 0}):w.jsx(Co,{m:5})},DE="meshDeviceId",gd=()=>K.useMemo(()=>{let t=localStorage.getItem(DE);return t||(t=`device_${Date.now()}_${Math.random().toString(36).substring(2,15)}`,localStorage.setItem(DE,t)),t},[]),wq=({setStep:t,onTokenSelect:e})=>{const[n,r]=K.useState([]),[i,o]=K.useState(null),[s,a]=K.useState(!0),[l,c]=K.useState(null),{address:u}=et.useAccount(),{meshAccessToken:h,sessionId:p,setMeshAccessToken:g,setSessionId:b,setTokenIn:m,chainIdIn:x}=Me(),I=gd(),N=Me($=>$.selectedIntegration);K.useEffect(()=>{h&&p&&x&&N&&(async()=>{var B,G,Z,Y;try{const V=await(await fetch(`${Tl}/holdings`,{method:"POST",headers:{"Content-Type":"application/json","x-session-id":p},body:JSON.stringify({authToken:(G=(B=h==null?void 0:h.accountTokens)==null?void 0:B[0])==null?void 0:G.accessToken,brokerType:N==null?void 0:N.type})})).json();if(console.log("Holdings data:",V),V.status!=="ok"||!((Z=V.content)!=null&&Z.cryptocurrencyPositions))throw V.errorType==="invalidIntegrationToken"&&(console.log("Invalid integration token"),t(0),g(null),b(null),sessionStorage.removeItem(`${I}:${N==null?void 0:N.type}`)),new Error(V.message||"Failed to fetch holdings");const W=await(await fetch(`${Tl}/tokens?chainId=${x}&brokerType=${encodeURIComponent((N==null?void 0:N.type)||"")}`)).json();if(W.status==="success"&&((Y=W.content)!=null&&Y.tokens)){const A=W.content.tokens.map(d=>{const y=V.content.cryptocurrencyPositions.find(S=>S.symbol===d.symbol);return y?{...d,balance:y.amount,marketValue:y.marketValue,holding:y}:null}).filter(d=>d!==null&&d.marketValue>5).sort((d,y)=>y.marketValue-d.marketValue);console.log("Matched tokens with balances:",A),r(A)}else throw new Error(W.message||"Failed to fetch supported tokens")}catch(F){debugger;console.error("Error fetching data:",F),c(F instanceof Error?F.message:"Failed to fetch data")}finally{a(!1)}})()},[u,x,h,p,N]);const T=$D(n.map($=>$.symbol),x);return s?w.jsx(Es,{children:w.jsx(Co,{m:5})}):l?w.jsxs(ue,{p:5,color:"red.500",children:["Error: ",l]}):w.jsxs(tn,{children:[w.jsxs(ue,{mb:4,width:"100%",textAlign:"left",children:[w.jsx(Ao,{children:"Your Holdings"}),w.jsxs(Zf,{children:["Found ",n.length," token balances above $5"]})]}),w.jsx(ue,{overflowY:"scroll",maxH:"400px",children:w.jsx(Oo,{children:n.map(($,B)=>{var G,Z;return w.jsx(Eu,{chainId:x,icon:(Z=(G=T==null?void 0:T[B])==null?void 0:G.logoURI)==null?void 0:Z.replace("/thumb/","/large/"),title:$.name,balance:`${kr($.balance)} ${$.symbol}`,usdBalance:Tr($.marketValue||0),tag:"",loading:!1,selected:i===$.symbol,onClick:()=>{var Y;o($.symbol),e($),m((Y=T==null?void 0:T[B])==null?void 0:Y.address)}},`${$.symbol}-${B}`)})})}),n.length===0&&w.jsx(ue,{textAlign:"center",color:"fg.subtle",py:8,children:"No tokens with balances found for this chain"}),w.jsx(nr,{disabled:!i,onClick:()=>{t(4)},children:"Continue"})]})},Eq=({setStep:t,onTokenSelect:e})=>{const{chainIdIn:n,setTokenIn:r,setChainIdIn:i}=Me(),[o,s]=K.useState(null),{holdingsList:a,total:l,isLoading:c}=h1(1),u=Me(h=>h.setSelectedIntegration);return K.useEffect(()=>{u({type:"delayed",name:"Smart account",id:""})},[]),c?w.jsx(Es,{children:w.jsx(Co,{m:5})}):w.jsxs(tn,{children:[w.jsx(ue,{mb:4,width:"100%",textAlign:"left",children:w.jsxs(Zf,{children:["Smart Account Balance: ",Tr(l)]})}),w.jsx(ue,{overflowY:"scroll",maxH:"400px",children:w.jsx(Oo,{children:a==null?void 0:a.map(h=>w.jsx(Eu,{chainId:h.chainId,icon:h.logoUri,title:h.name,balance:`${kr(ir(h.amount,h.decimals))} ${h.symbol}`,usdBalance:Tr(h.total),tag:"",loading:!1,selected:o===h.token&&n===h.chainId,onClick:()=>{s(h.token),r(h.token),i(h.chainId);const p={symbol:h.symbol,name:h.name,networkId:h.chainId.toString(),chainId:h.chainId,integrationNetworks:[],balance:Number(ir(h.amount,h.decimals)),marketValue:h.total};e(p)}},`${h.token}-${h.chainId}`))})}),(a==null?void 0:a.length)===0&&w.jsx(ue,{textAlign:"center",color:"fg.subtle",py:8,children:"No tokens found in smart account"}),w.jsx(nr,{disabled:!o,onClick:()=>{t(4)},children:"Continue"})]})},Sq=({setStep:t,selectedToken:e})=>{var Y;const[n,r]=K.useState({tokenAmount:"",usdAmount:"",mode:"usd"}),i=Me(F=>F.setAmountIn),{tokenInData:o,selectedIntegration:s}=yr(),l=(e==null?void 0:e.symbol.toLowerCase().includes("USD"))?2:6,c=n.tokenAmount,u=n.usdAmount,h=!vq(s.type),p=e?h?(e.marketValue-ax).toFixed(2):e.marketValue.toFixed(2):0,g=K.useMemo(()=>{if(!(!e||!e.balance))return e.marketValue/e.balance},[e]),b=K.useCallback(F=>{if(!e)return;const V=e.marketValue*F/100;let U,W;if(h){const A=sx[e.symbol]||0;U=Math.max(A,Math.min(V,+p));const d=e.marketValue/e.balance;W=Math.min(U/d,e.balance)}else U=V,W=e.balance*F/100;return{tokenAmount:Cu(W,l),usdAmount:U.toFixed(2)}},[e,h,p,l]);K.useEffect(()=>{if(e){const F=b(100);if(!F)return;r(V=>({...V,...F}))}},[e,b]),K.useEffect(()=>{if(!(o!=null&&o.decimals))return;const F=c.endsWith(".")?c.slice(0,-1):c;if(!F||F==="."){i("0");return}try{i(r1(F,o.decimals))}catch(V){i("0")}},[c,o==null?void 0:o.decimals,i]);const m=fg(c),x=m!==null,I=!!u&&u!==".",N=e?x&&m!==null&&m>e.balance:!0,T=I&&(Y=fg(u))!=null?Y:0,$=h&&e?sx[e.symbol]:0,B=h&&e&&x&&T>0&&$&&m!==null&&m<$,G=h&&e&&x&&T>0&&T>+p,Z=!x||B||G||N;return e?w.jsxs(tn,{children:[w.jsxs(ue,{mb:4,width:"100%",textAlign:"left",children:[w.jsx(Ao,{children:"Enter Amount"}),w.jsxs(Zf,{children:["Available: ",kr(e.balance)," ",e.symbol," (",Tr(e.marketValue),")"]})]}),w.jsx(ue,{display:"flex",flexDirection:"column",gap:"8px",width:"100%",children:w.jsx(g1,{value:n,onChange:r,tokenSymbol:e.symbol,tokenPriceUsd:g,roundingPrecision:l,onPercentSelect:b})}),w.jsx(ue,{textAlign:"center",color:"fg.subtle",fontSize:"xs",h:3,m:-1,visibility:Z?"visible":"hidden",children:x?B?`Minimum amount is ${kr($)} ${e.symbol}`:G?`Maximum amount is ${Tr(p)} (balance - $${ax})`:N?"Amount exceeds available balance":"":"Please enter an amount"}),w.jsx(nr,{onClick:()=>Z?void 0:t(5),disabled:Z,children:"Continue"})]}):w.jsx(tn,{children:w.jsx(ue,{textAlign:"center",color:"fg.subtle",py:8,children:"No token selected"})})},Iq=({setStep:t,setUserOp:e,nextStep:n})=>{const{chainIdIn:r}=yr(),{routeLoading:i,usdAmountIn:o,routeData:s}=Ms(),{signMessageAsync:a}=et.useSignMessage(),{address:l}=et.useAccount(),[c,u]=K.useState(!1),h=async()=>{if(!s||s!=null&&s.error){console.error("No valid router data available");return}try{u(!0);const p=s==null?void 0:s.userOp;if(!p){console.error("No userOperation found in routeData");return}console.log("Signing userOperation:",p);const g=rV({userOperation:p,entryPointAddress:mq,entryPointVersion:"0.7",chainId:r}),b=await a({account:l,message:{raw:g}}),m={...p,signature:b};console.log("signedUserOp",JSON.stringify(m)),e(m),t(n)}catch(p){console.error("Failed to sign userOperation:",p)}finally{u(!1)}};return w.jsxs(tn,{children:[w.jsxs(tr,{flexDirection:"column",gap:"16px",alignItems:"center",width:"100%",children:[w.jsx(jr,{loading:i,width:i?"156px":"auto",children:w.jsx(Yf,{readOnly:!0,marginY:"8px",variant:"text",placeholder:"$10.00",value:o})}),w.jsx(ud,{})]}),w.jsx(dd,{}),w.jsx(nr,{disabled:!!(s!=null&&s.message)||i||c,loading:i||c,onClick:h,children:i?"Loading quote":c?"Signing...":"Sign Transaction"})]})},Cq=({selectedToken:t,userOp:e,setStep:n})=>{const{meshAccessToken:r,amountIn:i,chainIdIn:o}=Me(),{address:s}=et.useAccount(),{tokenInData:a}=yr(),l=Me(x=>x.sessionId),[c,u]=K.useState(!0),[h,p]=K.useState(null),g=Me(x=>x.selectedIntegration),b=FE(),m=gd();return K.useEffect(()=>{if(!t||!e||!r){console.error("Missing required data for withdrawal initiation");return}const x=a!=null&&a.decimals?ir(i,a.decimals):0;console.log("transferAmount",x),(async()=>{try{const N=[{networkId:bq(o),symbol:t.symbol,address:e.sender,amount:x}],T={restrictMultipleAccounts:!0,userId:m,integrationId:g==null?void 0:g.id,transferOptions:{toAddresses:N}};console.log("link request body",T);const B=await(await fetch(`${Tl}/linktoken?brokerType=${encodeURIComponent((g==null?void 0:g.type)||"")}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({restrictMultipleAccounts:!0,userId:m,integrationId:g==null?void 0:g.id,transferOptions:{toAddresses:N}})})).json();console.log("Link token response:",B);const G=r.accountTokens.map(F=>({...F,accountId:F.account.accountId,accountName:F.account.accountName,brokerName:g==null?void 0:g.name,brokerType:g==null?void 0:g.type}));console.log("accessTokens",G);let Z=!1;const Y=TE({clientId:s,accessTokens:G,onIntegrationConnected:F=>{b(F.accessToken,l),console.log("Integration connected",F)},onTransferFinished:F=>{console.log("Transfer finished:",F),u(!1)},onExit:F=>{console.log("Mesh link exited:",F),!Z&&(u(!1),n(2))},onEvent:F=>{var V;if(console.log("Mesh event:",F),F.type==="transferExecuted")console.log("Transfer executed, closing mesh link and moving to TrackUserOp step"),Z=!0,Y.closeLink(),n(7);else if(F.type==="transferExecutionError"){const U=((V=F.payload)==null?void 0:V.errorMessage)||"Transfer failed. Please try again.";console.error("Mesh transfer error:",U),Z=!0,Y.closeLink(),p(U),u(!1)}}});Y.openLink(B.content.linkToken)}catch(N){console.error("Failed to fetch link token:",N),u(!1)}})()},[t,e]),h?w.jsx(tn,{children:w.jsxs(tr,{direction:"column",align:"center",justify:"center",flex:1,p:6,gap:4,children:[w.jsx(tr,{align:"center",justify:"center",w:12,h:12,borderRadius:"full",bg:"orange.100",children:w.jsx(on,{as:X4,boxSize:6,color:"orange.500"})}),w.jsx(Te,{fontSize:"md",textAlign:"center",color:"gray.700",children:h})]})}):w.jsx(tn,{children:w.jsx(Es,{children:w.jsx(Te,{mt:4,children:c?w.jsxs(tr,{alignItems:"center",gap:2,children:[w.jsx(Co,{m:5}),w.jsx(Te,{children:"Intiating Mesh"})]}):"Transfer completed"})})})},Aq=({currentPhase:t,phases:e})=>w.jsx(ue,{display:"flex",gap:4,justifyContent:"center",mb:4,children:e.map((n,r)=>w.jsxs(ue,{display:"flex",alignItems:"center",gap:2,children:[w.jsx(ue,{w:6,h:6,borderRadius:"full",bg:r<t?"green.500":r===t?"blue.500":"gray.300",display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontSize:"xs",fontWeight:"bold",children:r<t?"✓":r+1}),w.jsx(Te,{fontSize:"sm",color:r===t?"fg":"fg.muted",fontWeight:r===t?"semibold":"normal",children:n})]},n))}),Oq=({selectedToken:t,userOp:e,setStep:n})=>{const{chainIdIn:r,chainIdOut:i,tokenInData:o}=yr(),{amountIn:s}=Me(),a=r!==i,[l,c]=K.useState("cex"),[u,h]=K.useState(null),[p,g]=K.useState("sending"),[b,m]=K.useState("Sending operation to tracker..."),[x,I]=K.useState(null),[N,T]=K.useState(!1),[$,B]=K.useState(null),[G,Z]=K.useState(!1),[Y,F]=K.useState(null),[V,U]=K.useState(null),[W,A]=K.useState(null),d=cq(x!=null?x:void 0,a&&l==="bridge");K.useEffect(()=>{(async()=>{if(!t||!e||!o){console.error("Missing required data for tracking"),g("failed"),m("Missing required data"),c("failed");return}try{const M=await(await fetch("https://alpha-scanners-dev-054573dc8549.herokuapp.com/operations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userOperationData:{sender:e.sender,nonce:e.nonce,factory:e.factory,factoryData:e.factoryData,callData:e.callData,callGasLimit:e.callGasLimit,verificationGasLimit:e.verificationGasLimit,preVerificationGas:e.preVerificationGas,maxFeePerGas:e.maxFeePerGas,maxPriorityFeePerGas:e.maxPriorityFeePerGas,paymaster:e.paymaster,paymasterData:e.paymasterData,paymasterVerificationGasLimit:e.paymasterVerificationGasLimit,paymasterPostOpGasLimit:e.paymasterPostOpGasLimit,signature:e.signature},chainId:r,expectedBalance:s,tokenAddress:o.address})})).json();if(console.log("Operation tracking response:",M),M.success&&M.operationId)h(M.operationId),g("tracking"),m(a?"Funds forwarding in progress...":"Tracking operation progress...");else throw new Error(M.message||"Failed to send operation to tracker")}catch(k){console.error("Failed to send operation to tracker:",k),g("failed"),m("Failed to send operation to tracker"),c("failed")}})()},[]),K.useEffect(()=>{if(!u||p!=="tracking")return;const k=setInterval(async()=>{var M,H,Q;try{const j=await(await fetch(`https://alpha-scanners-dev-054573dc8549.herokuapp.com/operations/${u}/status`)).json();console.log("Operation status:",j),((M=j.operation)==null?void 0:M.status)==="completed"?(g("completed"),a?(m("Funds forwarding completed!"),(H=j.operation)!=null&&H.bundleTxHash?(I(j.operation.bundleTxHash),c("bridge")):(console.warn("No bundleTxHash returned from indexer, cannot track bridge"),c("completed"))):(m("Operation completed successfully!"),c("completed")),$&&(clearInterval($),B(null))):["failed","failed_permanent"].includes((Q=j.operation)==null?void 0:Q.status)&&(g("failed"),m(a?"Bridging failed. Please select Smart-account balance as a source to use withdrawn funds":"Operation failed"),c("failed"),$&&(clearInterval($),B(null)))}catch(X){console.error("Failed to fetch operation status:",X)}},3e3);return B(k),()=>{k&&clearInterval(k)}},[u,p,a]),K.useEffect(()=>{if(!(!a||l!=="bridge")){if(d.isFailed){c("failed");return}d.isComplete&&!G&&x&&r&&(async()=>{var k;try{const M=await fetch(`https://api.enso.build/api/v1/layerzero/bridge/check?chainId=${r}&txHash=${x}`);if(!M.ok){Z(!0),F(!0),c("completed");return}const H=await M.json();Z(!0),A(H.destinationTxHash||null),H.status==="success"?(F(!0),c("completed")):H.status==="failed"?(F(!1),U(((k=H.ensoDestinationEvent)==null?void 0:k.refundDetails)||null),c("failed")):(F(!0),c("completed"))}catch(M){console.error("Failed to verify destination:",M),Z(!0),F(!0),c("completed")}})()}},[l,d.isComplete,d.isFailed,a,G,x,r]);const y=()=>{T(!0)},S=()=>l==="failed"?"failed":l==="completed"?"completed":"processing",C=()=>{switch(S()){case"completed":return"#14AE5C";case"failed":return"#E84142";default:return"#1E171F"}},R=()=>{switch(S()){case"completed":return"Success";case"failed":return"Failed";default:return"Processing"}},D=()=>a?l==="cex"?`(1/2) ${b}`:l==="bridge"?`(2/2) ${d.message}`:l==="completed"?"Transfer completed successfully!":V?"Destination execution failed. Funds refunded to smart account.":"Transfer failed":l==="completed"?"Operation completed successfully!":l==="failed"?"Operation failed":b,L=()=>l==="cex"||l==="bridge"?w.jsx(NE,{start:p==="tracking"||l==="bridge",onFinish:y,duration:a?180:120}):l==="completed"?w.jsx(ue,{display:"flex",flexDirection:"column",alignItems:"center",children:w.jsx(Rn,{src:PE,boxShadow:"0px 0px 20px #14AE5C",borderRadius:"90%",width:"58px",height:"58px"})}):w.jsx(ue,{display:"flex",flexDirection:"column",alignItems:"center",children:w.jsx(Rn,{src:LE,boxShadow:"0px 0px 20px #E84142",borderRadius:"90%",width:"58px",height:"58px"})}),O=r?ko[r]:"Unknown",f=i?ko[i]:"Unknown";return w.jsxs(tn,{children:[a&&w.jsx(Aq,{currentPhase:l==="cex"?0:l==="bridge"?1:2,phases:["Forward funds","Bridge"]}),w.jsxs(ue,{display:"flex",flexDirection:"column",paddingBottom:"16px",alignItems:"center",width:"100%",children:[L(),w.jsxs(ue,{display:"flex",flexDirection:"column",alignItems:"center",marginTop:"16px",textAlign:"center",children:[w.jsx(Te,{fontSize:"lg",fontWeight:"semibold",color:"fg",marginBottom:"8px",children:D()}),(l==="cex"||l==="bridge")&&N&&w.jsx(Te,{fontSize:"sm",color:"fg.muted",maxWidth:"280px",children:"Your operation is being processed – no action is required from you."})]})]}),w.jsx(hu,{size:"sm",variant:"outline",width:"100%",children:w.jsxs(fu,{children:[w.jsxs(En,{children:[w.jsx(je,{children:"Status"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:w.jsx(Te,{color:C(),children:R()})})]}),a&&w.jsxs(w.Fragment,{children:[w.jsxs(En,{children:[w.jsx(je,{children:"Current Phase"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:w.jsx(Te,{children:l==="cex"?"Awaiting funds":l==="bridge"?"Bridging":l==="completed"?"Complete":"Failed"})})]}),w.jsxs(En,{children:[w.jsx(je,{children:"Intermediate Chain"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:w.jsx(Te,{textTransform:"capitalize",children:O})})]}),w.jsxs(En,{children:[w.jsx(je,{children:"Final Destination"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:w.jsx(Te,{textTransform:"capitalize",children:f})})]})]}),u&&w.jsxs(En,{children:[w.jsx(je,{children:"Operation ID"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:w.jsx(Te,{fontSize:"sm",color:"fg.muted",children:u})})]}),a&&x&&w.jsxs(En,{children:[w.jsx(je,{children:"Bridge TX"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:w.jsx(Te,{fontSize:"sm",color:"blue.500",cursor:"pointer",onClick:()=>window.open(`https://layerzeroscan.com/tx/${x}`,"_blank"),children:"View on LayerZero"})})]}),a&&W&&w.jsxs(En,{children:[w.jsx(je,{children:"Destination TX"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:w.jsx(Te,{fontSize:"sm",color:"blue.500",cursor:"pointer",onClick:()=>{const v=ux[i]||"https://etherscan.io";window.open(`${v}/tx/${W}`,"_blank")},children:"View on Explorer"})})]}),a&&l==="bridge"&&w.jsxs(En,{children:[w.jsx(je,{children:"Bridge Progress"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:w.jsxs(Te,{children:["(",d.step,"/4)"]})})]}),a&&V&&w.jsxs(En,{children:[w.jsx(je,{children:"Refund"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:w.jsx(Te,{fontSize:"sm",color:"orange.500",children:"Funds refunded to smart account"})})]})]})},"status"),w.jsx(ud,{}),w.jsx(dd,{}),(l==="completed"||l==="failed")&&w.jsx(nr,{onClick:()=>n(0),visual:"solid",children:l==="completed"?"New Deposit":"Retry Deposit"})]})},kq=({setFlow:t,initialStep:e=1})=>{const{handleClose:n,enforceFlow:r}=K.useContext(ic),[i,o]=K.useState(e),[s,a]=K.useState(null),[l,c]=K.useState(null),u=Me(g=>g.setSelectedIntegration),h=Me(g=>g.selectedIntegration);K.useEffect(()=>()=>u(null),[]);const p=(()=>{switch(i){case 1:return w.jsx(_q,{setStep:o});case 0:return w.jsx(xq,{setStep:o});case 2:return w.jsx(wq,{setStep:o,onTokenSelect:a});case 3:return w.jsx(Eq,{setStep:o,onTokenSelect:a});case 4:return w.jsx(Sq,{setStep:o,selectedToken:s});case 5:return w.jsx(Iq,{nextStep:s.holding?6:7,setStep:o,setUserOp:c});case 6:return w.jsx(Cq,{selectedToken:s,userOp:l,setStep:o});case 7:return w.jsx(Oq,{selectedToken:s,userOp:l,setStep:o});default:return null}})();return w.jsxs(w.Fragment,{children:[w.jsx(or.Header,{children:w.jsxs(nx,{children:[!(r&&(i===1||i===3))&&w.jsx(gi,{minWidth:"16px",minHeight:"16px",maxWidth:"16px",onClick:()=>{const g=((h==null?void 0:h.type)==="delayed"?yq:ME).findIndex(b=>b===i)-1;g>=0?o(ME[g]):t("")},children:w.jsx(on,{as:U_,color:"gray",width:"16px",height:"16px"})}),w.jsx(ue,{display:"flex",flexDirection:"column",gap:"4px",alignItems:"center",width:"100%",children:w.jsxs(Ao,{children:["Deposit from ",h==null?void 0:h.name]})}),n&&w.jsx(gi,{onClick:n,minWidth:"16px",minHeight:"16px",maxWidth:"16px",marginLeft:"auto",children:w.jsx(on,{as:Ss,color:"gray",width:"16px",height:"16px"})})]})}),w.jsx(or.Body,{children:p})]})},VE=({setStep:t})=>{const e=Me(h=>h.setSelectedIntegration),n=Me(h=>h.setTokenIn),r=Me(h=>h.tokenIn),i=Me(h=>h.setChainIdIn),o=Me(h=>h.chainIdIn),s=Me(h=>h.tokenOut),a=Me(h=>h.chainIdOut),{holdingsList:l,isLoading:c}=i1(),u=l==null?void 0:l.filter(h=>!(h.token.toLowerCase()===s.toLowerCase()&&h.chainId===a));return K.useEffect(()=>{e(null)},[]),w.jsxs(tn,{children:[w.jsx(ue,{overflowY:"scroll",maxH:"400px",children:w.jsx(Oo,{children:c?Array.from({length:10}).map((h,p)=>w.jsx(jr,{height:"40px",width:"300px"},p)):u==null?void 0:u.map(h=>w.jsx(Eu,{chainId:h.chainId,icon:h.logoUri,title:h.name,balance:`${kr(ir(h.amount,h.decimals))} ${h.symbol}`,usdBalance:Tr(h.total),tag:"",loading:!1,selected:h.token===r&&h.chainId===o,onClick:()=>{n(h.token),i(h.chainId)}},`${h.token}-${h.chainId}`))})}),w.jsx(nr,{onClick:()=>{t("selectAmount")},disabled:!r,children:"Continue"})]})},Tq="coingecko",Rq=We("div",{base:{display:"flex",gap:"8px",alignItems:"center",justifyContent:"center",p:"8px 12px",borderRadius:"114px",bg:"bg.subtle",w:"fit-content"}}),Nq=t=>t.includes(Tq)?t.replace("/thumb/","/large/"):t,Pq=({token:t,chainId:e,size:n=32})=>w.jsxs(ue,{position:"relative",borderRadius:"50%",minW:`${n}px`,minH:`${n}px`,children:[w.jsx(ue,{borderRadius:"50%",overflow:"hidden",width:`${n}px`,height:`${n}px`,children:w.jsx("img",{src:t!=null&&t.logoURI?Nq(t==null?void 0:t.logoURI):Is,title:t==null?void 0:t.symbol,alt:t==null?void 0:t.symbol,width:`${n}px`,height:`${n}px`})}),e&&w.jsx(ue,{position:"absolute",bottom:"0",right:"-2px",width:`${n/2}px`,height:`${n/2}px`,borderRadius:"50%",overflow:"hidden",border:"1px solid white",zIndex:"1",children:w.jsx("img",{src:`https://icons-ckg.pages.dev/stargate-light/networks/${ko[e]}.svg`,alt:`Chain ${e}`,width:"100%",height:"100%"})})]}),$E=({token:t,chainId:e,size:n=32,title:r,subTitle:i})=>w.jsxs(tr,{align:"center",gap:2,children:[w.jsx(Pq,{token:t,chainId:e,size:n}),w.jsxs(ue,{children:[w.jsx(Te,{fontWeight:"medium",fontSize:"xs",color:"fg.muted",children:r}),w.jsx(Te,{fontSize:"xs",color:"fg",children:i})]})]}),Lq=({token:t,chainId:e,size:n=32})=>{const r=(t==null?void 0:t.protocolName)||(t==null?void 0:t.protocol),i=t==null?void 0:t.protocolLogo;return w.jsxs(tr,{align:"center",gap:2,children:[w.jsxs(ue,{position:"relative",minW:`${n}px`,minH:`${n}px`,children:[w.jsx(ue,{borderRadius:"50%",overflow:"hidden",width:`${n}px`,height:`${n}px`,children:w.jsx("img",{src:i||Is,title:r,alt:r,width:`${n}px`,height:`${n}px`,onError:o=>{o.currentTarget.src=Is}})}),e&&w.jsx(ue,{position:"absolute",bottom:"0",right:"-2px",width:`${n/2}px`,height:`${n/2}px`,borderRadius:"50%",overflow:"hidden",border:"1px solid white",zIndex:"1",children:w.jsx("img",{src:`https://icons-ckg.pages.dev/stargate-light/networks/${ko[e]}.svg`,alt:`Chain ${e}`,width:"100%",height:"100%"})})]}),w.jsxs(ue,{children:[w.jsxs(Te,{fontWeight:"medium",fontSize:"xs",color:"fg.muted",children:["Deposit"," ",w.jsx(Te,{as:"span",fontSize:"xs",color:"fg",children:t==null?void 0:t.symbol})]}),w.jsxs(Te,{fontWeight:"medium",fontSize:"xs",color:"fg.muted",children:["into"," ",w.jsx(Te,{as:"span",fontSize:"xs",color:"fg",children:r})]})]})]})},Mq=({tokenIn:t,tokenOut:e,chainIdIn:n,chainIdOut:r,isNontokenized:i=!1,size:o=24})=>w.jsxs(Rq,{children:[w.jsx($E,{token:t,chainId:n,title:"You send",subTitle:t==null?void 0:t.symbol,size:o}),w.jsx(W_,{color:"#707070",width:"16px",height:"16px"}),i&&(e!=null&&e.protocol)?w.jsx(Lq,{token:e,chainId:r,size:o}):w.jsx($E,{token:e,chainId:r,title:"You receive",subTitle:e==null?void 0:e.symbol,size:o})]}),Bq=({setStep:t})=>{const[e,n]=K.useState({tokenAmount:"",usdAmount:"10.10",mode:"usd"}),r=Me(B=>B.setAmountIn),i=Me(B=>B.amountIn),[o,s]=K.useState(!0),{tokenInData:a,effectiveTokenOutData:l,tokenIn:c,chainIdOut:u,chainIdIn:h,isNontokenized:p}=yr(),{data:g}=ll(h,c),b=a!=null&&a.decimals?Math.min(a.decimals,6):6,m=e.tokenAmount,x=qD(c,h),I=K.useCallback(B=>{if(!x||!g||!(a!=null&&a.decimals))return null;const G=(BigInt(x)*BigInt(B)/BigInt(100)).toString(),Z=ir(G,a.decimals),Y=Cu(Z,b);return{tokenAmount:Y,usdAmount:(+parseFloat(Y||"0")*g).toFixed(2)}},[x,g,a==null?void 0:a.decimals,b]);K.useEffect(()=>{if(o&&g&&a&&+x>0){s(!1);const B=I(100);if(!B)return;n(G=>({...G,...B}))}},[x,o,g,a,I]),K.useEffect(()=>{if(!(a!=null&&a.decimals))return;const B=m.endsWith(".")?m.slice(0,-1):m;if(!B||B==="."){r("0");return}try{r(r1(B,a.decimals))}catch(G){r("0")}},[m,a==null?void 0:a.decimals,r]);const N=fg(m)!==null,T=N?+x<+i:!1,$=!N||T;return w.jsxs(tn,{children:[w.jsx(g1,{value:e,onChange:n,tokenSymbol:a==null?void 0:a.symbol,tokenPriceUsd:g,roundingPrecision:b,onPercentSelect:I}),w.jsx(Mq,{tokenOut:l,tokenIn:a,chainIdIn:h,chainIdOut:u,isNontokenized:p}),w.jsx(nr,{onClick:()=>t("quote"),disabled:$,children:"Continue"})]})},Fq=({setStep:t})=>{const{chainIdIn:e}=yr(),{routeLoading:n,usdAmountIn:r,routeData:i}=Ms(),o=et.useChainId(),{switchChain:s}=et.useSwitchChain(),a=UD(e),l=o!==e;return w.jsxs(tn,{children:[w.jsxs(tr,{flexDirection:"column",gap:"16px",alignItems:"center",width:"100%",children:[w.jsx(jr,{loading:n,width:n?"156px":"auto",children:w.jsx(Yf,{readOnly:!0,marginY:"8px",variant:"text",placeholder:"$10.00",value:r})}),w.jsx(ud,{})]}),w.jsx(dd,{}),l?w.jsxs(nr,{onClick:()=>{s({chainId:e})},children:["Switch to ",a]}):w.jsx(nr,{disabled:!!(i!=null&&i.error),visual:n?"lightGray":"solid",onClick:n?()=>{}:()=>{t("confirmTransfer")},children:n?"Loading quote":"Continue"})]})},Dq="data:image/svg+xml,%3csvg%20width='20'%20height='20'%20viewBox='0%200%2020%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20x='1'%20y='1'%20width='18'%20height='18'%20rx='9'%20stroke='white'%20stroke-width='2'/%3e%3cpath%20d='M17.7589%2011.9352C16.6904%2016.221%2012.3496%2018.8292%208.06336%2017.7605C3.77889%2016.692%201.17066%2012.351%202.23959%208.06558C3.30758%203.77935%207.64835%201.17093%2011.9333%202.23939C16.2192%203.30785%2018.8273%207.64936%2017.7587%2011.9353L17.7588%2011.9352H17.7589Z'%20fill='%2314AE5C'/%3e%3cpath%20d='M11.9997%204.66675C12.3679%204.66675%2012.6663%204.96522%2012.6663%205.33341C12.6663%205.7016%2012.3679%206.00008%2011.9997%206.00008H7.99967C7.63148%206.00008%207.33301%205.7016%207.33301%205.33341C7.33301%204.96522%207.63148%204.66675%207.99967%204.66675H11.9997Z'%20fill='white'/%3e%3cpath%20d='M12.0003%207.33325C12.3685%207.33325%2012.667%207.63173%2012.667%207.99992V9.33325H14.667C14.9366%209.33325%2015.1797%209.49564%2015.2829%209.74471C15.386%209.99383%2015.329%2010.2806%2015.1383%2010.4713L10.4717%2015.1379C10.2113%2015.3983%209.7893%2015.3983%209.52895%2015.1379L4.86229%2010.4713C4.67162%2010.2806%204.61457%209.99383%204.71775%209.74471C4.82096%209.49564%205.06403%209.33325%205.33364%209.33325H7.33364V7.99992C7.33364%207.63173%207.63212%207.33325%208.00031%207.33325H12.0003ZM8.66697%209.99992C8.66697%2010.3681%208.3685%2010.6666%208.00031%2010.6666H6.94301L10.0003%2013.7239L13.0576%2010.6666H12.0003C11.6321%2010.6666%2011.3336%2010.3681%2011.3336%209.99992V8.66659H8.66697V9.99992Z'%20fill='white'/%3e%3c/svg%3e",Vq=We(Rn,{base:{boxSize:"36px",borderRadius:"full",objectFit:"contain"}}),$q=We(Rn,{base:{boxSize:"16px",position:"absolute",bottom:"-2px",right:"-2px",borderRadius:"full",border:"1px solid",borderColor:"bg",objectFit:"contain"}}),zq=({onClose:t,currencyIcon:e})=>{const n=()=>{const r=new Date,i=r.toLocaleString("en-US",{month:"short"}),o=r.toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"});return`${i} - ${o}`};return w.jsxs(ue,{border:"1px solid",borderColor:"border.subtle",borderRadius:"12px",width:"100%",bg:"bg",children:[w.jsxs(ue,{display:"flex",alignItems:"center",gap:"12px",borderBottom:"1px solid",borderColor:"border.subtle",padding:"10px 16px",children:[w.jsxs(ue,{position:"relative",children:[w.jsx(Vq,{src:e,alt:"Currency icon"}),w.jsx($q,{src:Dq,alt:"deposit icon"})]}),w.jsxs(ue,{flex:"1",children:[w.jsx(Te,{fontSize:"lg",fontWeight:"semibold",color:"fg",marginBottom:"4px",children:"Deposit processing"}),w.jsx(Te,{fontSize:"sm",color:"fg.muted",lineHeight:"1.4",children:"Your deposit will be added to your account soon."})]}),t&&w.jsx(on,{as:Ss,width:"16px",height:"16px",color:"fg.subtle",cursor:"pointer",_hover:{color:"fg.muted"},onClick:t})]}),w.jsxs(ue,{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"10px 16px",children:[w.jsx(Te,{fontSize:"sm",color:"fg.muted",children:"Order started"}),w.jsx(Te,{fontSize:"sm",color:"fg",fontWeight:"medium",children:n()})]})]})},Uq=()=>{var h;const{chainIdIn:t,tokenIn:e,amountIn:n}=yr(),{address:r}=et.useAccount(),{approveData:i,approveFetched:o}=mD({address:r,token:e,chainId:t,amount:n}),{routeData:s,routeFetched:a}=Ms(),{approveNeeded:l,allowanceFetched:c}=KD(e,(h=i==null?void 0:i.tx)==null?void 0:h.to,n);return{calls:K.useMemo(()=>!Ro(e,Pt)&&!c||!a||!o?[]:l?[i==null?void 0:i.tx,s==null?void 0:s.tx]:[s==null?void 0:s.tx],[l,c,a,i,s,o]),approveNeeded:l}},Wq=({setStep:t})=>{const[e,n]=K.useState("idle"),[r,i]=K.useState(!1),{address:o}=et.useAccount(),[s,a]=K.useState(""),[l,c]=K.useState(!1),{chainIdIn:u,chainIdOut:h}=yr(),{calls:p}=Uq(),{sendTxns:g,ready:b}=eV({calls:p,address:o,chainId:u}),{track:m}=lq(),x=u!==h,I=K.useCallback(W=>{n("processing"),a(W),m({hash:W,isActive:!0,chainId:u,crosschain:x,status:x?"(0/4) Waiting for source transaction completion":"Transaction in progess",message:"Transaction confirmed",onConfirmed:()=>{n("success")}})},[u,h]),N=K.useCallback(W=>{console.error(W),n("failed")},[]);K.useEffect(()=>{console.log(l,b),!l&&b&&(g(I,N),c(!0))},[l,b,g,I]);const T=()=>{i(!0)},$=()=>{t("selectToken")},B=()=>{t("quote")},G=aq(s),Z=x?`https://layerzeroscan.com/tx/${s}`:Iu({hash:s,chainId:u}),Y=()=>{switch(e){case"success":return"#14AE5C";case"failed":return"#E84142";default:return"#1E171F"}},F=()=>{switch(e){case"success":return"Success";case"failed":return"Failed";case"idle":return"Awaiting wallet approval";default:return G==null?void 0:G.status}},V=()=>{switch(e){case"processing":case"idle":return w.jsx(NE,{start:e==="processing",onFinish:T});case"success":return w.jsx(ue,{display:"flex",flexDirection:"column",alignItems:"center",children:w.jsx(Rn,{src:PE,boxShadow:"0px 0px 20px #14AE5C",borderRadius:"90%",width:"58px",height:"58px"})});case"failed":return w.jsx(ue,{display:"flex",flexDirection:"column",alignItems:"center",children:w.jsx(Rn,{src:LE,boxShadow:"0px 0px 20px #E84142",borderRadius:"90%",width:"58px",height:"58px"})})}},U=()=>e==="processing"&&r?w.jsxs(ue,{display:"flex",flexDirection:"column",alignItems:"center",marginTop:"16px",textAlign:"center",children:[w.jsx(Te,{fontSize:"lg",fontWeight:"semibold",color:"fg",marginBottom:"8px",children:"Deposit pending"}),w.jsx(Te,{fontSize:"sm",color:"fg.muted",maxWidth:"280px",children:"Your deposit is still in progress – no action is required from you."})]}):null;return w.jsxs(tn,{children:[w.jsxs(ue,{display:"flex",flexDirection:"column",paddingBottom:"16px",alignItems:"center",width:"100%",children:[V(),U()]}),w.jsx(hu,{size:"sm",variant:"outline",width:"100%",children:w.jsxs(fu,{children:[w.jsxs(En,{children:[w.jsx(je,{children:"Status"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:w.jsx(Te,{color:Y(),children:F()})})]}),["success","processing"].includes(e)&&w.jsxs(En,{children:[w.jsx(je,{children:"Transaction"}),w.jsx(je,{display:"flex",textAlign:"end",justifyContent:"end",children:Z?w.jsx("a",{href:Z,target:"_blank",rel:"noreferrer",children:w.jsxs(Te,{color:"blue.500",children:["View on"," ",x?"LayerZero":"Etherscan"]})}):w.jsx(Te,{children:"-"})})]})]})},"status"),w.jsx(ud,{}),e==="processing"?w.jsx(zq,{currencyIcon:dg(h)}):w.jsx(dd,{}),e==="success"&&w.jsx(nr,{visual:"solid",onClick:$,width:"100%",children:"New Deposit"}),e==="failed"&&w.jsx(nr,{visual:"solid",onClick:B,width:"100%",children:"Retry Deposit"})]})};var zE=(t=>(t.SelectToken="selectToken",t.SelectAmount="selectAmount",t.Quote="quote",t.ConfirmTransfer="confirmTransfer",t))(zE||{});const UE=["selectToken","selectAmount","quote","confirmTransfer"],Hq={exchange:kq,wallet:({initialStep:t="selectToken",setFlow:e})=>{const[n,r]=K.useState(t),{handleClose:i,enforceFlow:o}=K.useContext(ic),s=c=>{r(c)},a=()=>{const c=UE.findIndex(u=>u===n)-1;c>=0?r(UE[c]):e&&e("")},l=(()=>{switch(n){case"selectToken":return w.jsx(VE,{setStep:s});case"selectAmount":return w.jsx(Bq,{setStep:s});case"quote":return w.jsx(Fq,{setStep:s});case"confirmTransfer":return w.jsx(Wq,{setStep:s});default:return w.jsx(VE,{setStep:s})}})();return w.jsxs(w.Fragment,{children:[w.jsx(or.Header,{children:w.jsxs(nx,{children:[!(o&&n==="selectToken")&&w.jsx(gi,{minWidth:"16px",minHeight:"16px",maxWidth:"16px",onClick:a,children:w.jsx(on,{as:U_,color:"gray",width:"16px",height:"16px"})}),w.jsx(ue,{display:"flex",flexDirection:"column",gap:"4px",alignItems:"center",width:"100%",children:w.jsx(Ao,{children:"Wallet Deposit"})}),i&&w.jsx(gi,{onClick:i,minWidth:"16px",minHeight:"16px",maxWidth:"16px",marginLeft:"auto",children:w.jsx(on,{as:Ss,color:"gray",width:"16px",height:"16px"})})]})}),w.jsx(or.Body,{children:l})]})}},jq=()=>{const{handleClose:t,enableExchange:e,enforceFlow:n}=K.useContext(ic),[r,i]=K.useState(""),[o,s]=K.useState(""),[a,l]=K.useState(null),{total:c,isLoading:u}=i1(),{address:h}=et.useAccount(),{walletIcon:p,walletDisplayName:g}=f1(),{total:b,isLoading:m}=h1(1);K.useEffect(()=>{if(n)if(n==="exchange"){if(!Array.isArray(e)||e.length===0){l("No exchanges configured. Please enable at least one exchange in the widget configuration.");return}i("exchange"),s(fd.ChooseExchange)}else n==="wallet"&&h&&(i("wallet"),s(zE.SelectToken))},[n,e,h]);const x=K.useMemo(()=>u?w.jsx(jr,{display:"inline-block",height:"10px",width:"60px"}):typeof c=="number"?Tr(c):c||"$0.00",[c,u]),I=K.useMemo(()=>h?ug(h):"",[h]),N=K.useMemo(()=>{const $=[];return!m&&b>20&&$.push({id:"smart-balance",title:"Smart Account Balance",limit:Tr(b),delay:"2 min",icons:[],flow:"exchange",firstStep:fd.ChooseBalanceAsset}),Array.isArray(e)&&e.length>0&&$.unshift({id:"exchange",title:"Connect Exchange",limit:"No Limit",delay:"2 min",icons:e.map(B=>hd[ea[B]]).filter(Boolean),flow:"exchange",firstStep:fd.ChooseExchange}),$},[h,e,b,m]),T=r&&Hq[r];return T?w.jsx(T,{setFlow:i,initialStep:o}):a?w.jsxs(w.Fragment,{children:[w.jsx(or.Header,{children:w.jsxs(Xf,{children:[w.jsx(ue,{display:"flex",flexDirection:"column",gap:"4px",children:w.jsx(Ao,{children:"Configuration Error"})}),t&&w.jsx(gi,{onClick:t,width:"40px",children:w.jsx(on,{as:Ss,color:"fg.muted",width:"16px",height:"16px"})})]})}),w.jsx(or.Body,{children:w.jsx(tn,{children:w.jsxs(ue,{display:"flex",flexDirection:"column",alignItems:"center",gap:"4",p:"6",textAlign:"center",children:[w.jsx(on,{as:j4,color:"red.500",width:"48px",height:"48px"}),w.jsx(Te,{color:"fg.muted",children:a})]})})})]}):n==="wallet"&&!h?w.jsxs(w.Fragment,{children:[w.jsx(or.Header,{children:w.jsxs(Xf,{children:[w.jsx(ue,{display:"flex",flexDirection:"column",gap:"4px",children:w.jsx(Ao,{children:"Connect Wallet"})}),t&&w.jsx(gi,{onClick:t,width:"40px",children:w.jsx(on,{as:Ss,color:"fg.muted",width:"16px",height:"16px"})})]})}),w.jsx(or.Body,{children:w.jsx(tn,{children:w.jsx(Oo,{children:w.jsx(s1,{icon:p,walletHash:"Not Connected",balance:"Connect your wallet to continue",delay:"",status:hg.NONE})})})})]}):w.jsxs(w.Fragment,{children:[w.jsx(or.Header,{children:w.jsxs(Xf,{children:[w.jsx(ue,{display:"flex",flexDirection:"column",gap:"4px",children:w.jsx(Ao,{children:"Deposit"})}),t&&w.jsx(gi,{onClick:t,width:"40px",children:w.jsx(on,{as:Ss,color:"fg.muted",width:"16px",height:"16px"})})]})}),w.jsx(or.Body,{children:w.jsxs(tn,{children:[h&&w.jsx(Oo,{children:w.jsx(s1,{icon:p,walletHash:I,balance:x,delay:"Instant",status:hg.CONNECTED,badge:g,onClick:()=>{i("wallet")}},h)}),N.length>0&&w.jsxs(w.Fragment,{children:[w.jsx(vB,{}),w.jsx(Oo,{children:N.map($=>w.jsx(RD,{title:$.title,limit:$.limit,delay:$.delay,icons:$.icons,onClick:()=>{$.disabled||(i($.flow),s($.firstStep))}},$.id))})]})]})})]})};var oe=typeof window!="undefined"?window:void 0,bn=typeof globalThis!="undefined"?globalThis:oe;typeof self=="undefined"&&(bn.self=bn),typeof File=="undefined"&&(bn.File=function(){});var WE=Array.prototype,HE=WE.forEach,jE=WE.indexOf,ur=bn==null?void 0:bn.navigator,me=bn==null?void 0:bn.document,jn=bn==null?void 0:bn.location,Sp=bn==null?void 0:bn.fetch,Ip=bn!=null&&bn.XMLHttpRequest&&"withCredentials"in new bn.XMLHttpRequest?bn.XMLHttpRequest:void 0,qE=bn==null?void 0:bn.AbortController,qn=ur==null?void 0:ur.userAgent,ke=oe!=null?oe:{},Ci={DEBUG:!1,LIB_VERSION:"1.310.1"};function GE(t,e,n,r,i,o,s){try{var a=t[o](s),l=a.value}catch(c){return void n(c)}a.done?e(l):Promise.resolve(l).then(r,i)}function KE(t){return function(){var e=this,n=arguments;return new Promise((function(r,i){var o=t.apply(e,n);function s(l){GE(o,r,i,s,a,"next",l)}function a(l){GE(o,r,i,s,a,"throw",l)}s(void 0)}))}}function be(){return be=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},be.apply(null,arguments)}function YE(t,e){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(e.indexOf(r)!==-1)continue;n[r]=t[r]}return n}var qq=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],XE=function(t,e){if(e===void 0&&(e=[]),!t)return!1;var n=t.toLowerCase();return qq.concat(e).some((r=>{var i=r.toLowerCase();return n.indexOf(i)!==-1}))},Gq=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"];function Ue(t,e){return t.indexOf(e)!==-1}var pd=function(t){return t.trim()},Cp=function(t){return t.replace(/^\$/,"")},Kq=Array.isArray,ZE=Object.prototype,JE=ZE.hasOwnProperty,md=ZE.toString,Ze=Kq||function(t){return md.call(t)==="[object Array]"},ro=t=>typeof t=="function",an=t=>t===Object(t)&&!Ze(t),ta=t=>{if(an(t)){for(var e in t)if(JE.call(t,e))return!1;return!0}return!1},fe=t=>t===void 0,nn=t=>md.call(t)=="[object String]",Ap=t=>nn(t)&&t.trim().length===0,Pr=t=>t===null,Je=t=>fe(t)||Pr(t),ei=t=>md.call(t)=="[object Number]",Ai=t=>md.call(t)==="[object Boolean]",Yq=t=>t instanceof FormData,Xq=t=>Ue(Gq,t);function Op(t){return t===null||typeof t!="object"}function vd(t,e){return Object.prototype.toString.call(t)==="[object "+e+"]"}function QE(t){return!fe(Event)&&(function(e,n){try{return e instanceof n}catch(r){return!1}})(t,Event)}var Zq=[!0,"true",1,"1","yes"],kp=t=>Ue(Zq,t),Jq=[!1,"false",0,"0","no"];function ti(t,e,n,r,i){return e>n&&(r.warn("min cannot be greater than max."),e=n),ei(t)?t>n?(r.warn(" cannot be greater than max: "+n+". Using max value instead."),n):t<e?(r.warn(" cannot be less than min: "+e+". Using min value instead."),e):t:(r.warn(" must be a number. using max or fallback. max: "+n+", fallback: "+i),ti(i||n,e,n,r))}class Qq{constructor(e){this.t={},this.i=e.i,this.o=ti(e.bucketSize,0,100,e.h),this.m=ti(e.refillRate,0,this.o,e.h),this.$=ti(e.refillInterval,0,864e5,e.h)}S(e,n){var r=n-e.lastAccess,i=Math.floor(r/this.$);if(i>0){var o=i*this.m;e.tokens=Math.min(e.tokens+o,this.o),e.lastAccess=e.lastAccess+i*this.$}}consumeRateLimit(e){var n,r=Date.now(),i=String(e),o=this.t[i];return o?this.S(o,r):(o={tokens:this.o,lastAccess:r},this.t[i]=o),o.tokens===0||(o.tokens--,o.tokens===0&&((n=this.i)==null||n.call(this,e)),o.tokens===0)}stop(){this.t={}}}var br="Mobile",yd="iOS",Oi="Android",Rl="Tablet",eS=Oi+" "+Rl,tS="iPad",nS="Apple",rS=nS+" Watch",Nl="Safari",na="BlackBerry",iS="Samsung",oS=iS+"Browser",sS=iS+" Internet",qo="Chrome",eG=qo+" OS",aS=qo+" "+yd,Tp="Internet Explorer",lS=Tp+" "+br,Rp="Opera",tG=Rp+" Mini",Np="Edge",cS="Microsoft "+Np,ra="Firefox",uS=ra+" "+yd,Pl="Nintendo",Ll="PlayStation",ia="Xbox",dS=Oi+" "+br,hS=br+" "+Nl,Ml="Windows",Pp=Ml+" Phone",fS="Nokia",Lp="Ouya",gS="Generic",nG=gS+" "+br.toLowerCase(),pS=gS+" "+Rl.toLowerCase(),Mp="Konqueror",Pn="(\\d+(\\.\\d+)?)",Bp=new RegExp("Version/"+Pn),rG=new RegExp(ia,"i"),iG=new RegExp(Ll+" \\w+","i"),oG=new RegExp(Pl+" \\w+","i"),Fp=new RegExp(na+"|PlayBook|BB10","i"),sG={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"},bd,mS,Dp,aG=(t,e)=>e&&Ue(e,nS)||(function(n){return Ue(n,Nl)&&!Ue(n,qo)&&!Ue(n,Oi)})(t),vS=function(t,e){return e=e||"",Ue(t," OPR/")&&Ue(t,"Mini")?tG:Ue(t," OPR/")?Rp:Fp.test(t)?na:Ue(t,"IE"+br)||Ue(t,"WPDesktop")?lS:Ue(t,oS)?sS:Ue(t,Np)||Ue(t,"Edg/")?cS:Ue(t,"FBIOS")?"Facebook "+br:Ue(t,"UCWEB")||Ue(t,"UCBrowser")?"UC Browser":Ue(t,"CriOS")?aS:Ue(t,"CrMo")||Ue(t,qo)?qo:Ue(t,Oi)&&Ue(t,Nl)?dS:Ue(t,"FxiOS")?uS:Ue(t.toLowerCase(),Mp.toLowerCase())?Mp:aG(t,e)?Ue(t,br)?hS:Nl:Ue(t,ra)?ra:Ue(t,"MSIE")||Ue(t,"Trident/")?Tp:Ue(t,"Gecko")?ra:""},lG={[lS]:[new RegExp("rv:"+Pn)],[cS]:[new RegExp(Np+"?\\/"+Pn)],[qo]:[new RegExp("("+qo+"|CrMo)\\/"+Pn)],[aS]:[new RegExp("CriOS\\/"+Pn)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Pn)],[Nl]:[Bp],[hS]:[Bp],[Rp]:[new RegExp("(Opera|OPR)\\/"+Pn)],[ra]:[new RegExp(ra+"\\/"+Pn)],[uS]:[new RegExp("FxiOS\\/"+Pn)],[Mp]:[new RegExp("Konqueror[:/]?"+Pn,"i")],[na]:[new RegExp(na+" "+Pn),Bp],[dS]:[new RegExp("android\\s"+Pn,"i")],[sS]:[new RegExp(oS+"\\/"+Pn)],[Tp]:[new RegExp("(rv:|MSIE )"+Pn)],Mozilla:[new RegExp("rv:"+Pn)]},cG=function(t,e){var n=vS(t,e),r=lG[n];if(fe(r))return null;for(var i=0;i<r.length;i++){var o=r[i],s=t.match(o);if(s)return parseFloat(s[s.length-2])}return null},yS=[[new RegExp(ia+"; "+ia+" (.*?)[);]","i"),t=>[ia,t&&t[1]||""]],[new RegExp(Pl,"i"),[Pl,""]],[new RegExp(Ll,"i"),[Ll,""]],[Fp,[na,""]],[new RegExp(Ml,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[Pp,""];if(new RegExp(br).test(e)&&!/IEMobile\b/.test(e))return[Ml+" "+br,""];var n=/Windows NT ([0-9.]+)/i.exec(e);if(n&&n[1]){var r=n[1],i=sG[r]||"";return/arm/i.test(e)&&(i="RT"),[Ml,i]}return[Ml,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>{if(t&&t[3]){var e=[t[3],t[4],t[5]||"0"];return[yd,e.join(".")]}return[yd,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var e="";return t&&t.length>=3&&(e=fe(t[2])?t[3]:t[2]),["watchOS",e]}],[new RegExp("("+Oi+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Oi+")","i"),t=>{if(t&&t[2]){var e=[t[2],t[3],t[4]||"0"];return[Oi,e.join(".")]}return[Oi,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var e=["Mac OS X",""];if(t&&t[1]){var n=[t[1],t[2],t[3]||"0"];e[1]=n.join(".")}return e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[eG,""]],[/Linux|debian/i,["Linux",""]]],bS=function(t){return oG.test(t)?Pl:iG.test(t)?Ll:rG.test(t)?ia:new RegExp(Lp,"i").test(t)?Lp:new RegExp("("+Pp+"|WPDesktop)","i").test(t)?Pp:/iPad/.test(t)?tS:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?rS:Fp.test(t)?na:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(fS,"i").test(t)?fS:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?new RegExp(br).test(t)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)||/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?Oi:eS:new RegExp("(pda|"+br+")","i").test(t)?nG:new RegExp(Rl,"i").test(t)&&!new RegExp(Rl+" pc","i").test(t)?pS:""},uG=t=>t instanceof Error;function dG(t){var e=globalThis._posthogChunkIds;if(e){var n=Object.keys(e);return Dp&&n.length===mS||(mS=n.length,Dp=n.reduce(((r,i)=>{bd||(bd={});var o=bd[i];if(o)r[o[0]]=o[1];else for(var s=t(i),a=s.length-1;a>=0;a--){var l=s[a],c=l==null?void 0:l.filename,u=e[i];if(c&&u){r[c]=u,bd[i]=[c,u];break}}return r}),{})),Dp}}class hG{constructor(e,n,r){r===void 0&&(r=[]),this.coercers=e,this.stackParser=n,this.modifiers=r}buildFromUnknown(e,n){n===void 0&&(n={});var r=n&&n.mechanism||{handled:!0,type:"generic"},i=this.buildCoercingContext(r,n,0).apply(e),o=this.buildParsingContext(),s=this.parseStacktrace(i,o);return{$exception_list:this.convertToExceptionList(s,r),$exception_level:"error"}}modifyFrames(e){var n=this;return KE((function*(){for(var r of e)r.stacktrace&&r.stacktrace.frames&&Ze(r.stacktrace.frames)&&(r.stacktrace.frames=yield n.applyModifiers(r.stacktrace.frames));return e}))()}coerceFallback(e){var n;return{type:"Error",value:"Unknown error",stack:(n=e.syntheticException)==null?void 0:n.stack,synthetic:!0}}parseStacktrace(e,n){var r,i;return e.cause!=null&&(r=this.parseStacktrace(e.cause,n)),e.stack!=""&&e.stack!=null&&(i=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?1:0),n.chunkIdMap)),be({},e,{cause:r,stack:i})}applyChunkIds(e,n){return e.map((r=>(r.filename&&n&&(r.chunk_id=n[r.filename]),r)))}applyCoercers(e,n){for(var r of this.coercers)if(r.match(e))return r.coerce(e,n);return this.coerceFallback(n)}applyModifiers(e){var n=this;return KE((function*(){var r=e;for(var i of n.modifiers)r=yield i(r);return r}))()}convertToExceptionList(e,n){var r,i,o,s={type:e.type,value:e.value,mechanism:{type:(r=n.type)!==null&&r!==void 0?r:"generic",handled:(i=n.handled)===null||i===void 0||i,synthetic:(o=e.synthetic)!==null&&o!==void 0&&o}};e.stack&&(s.stacktrace={type:"raw",frames:e.stack});var a=[s];return e.cause!=null&&a.push(...this.convertToExceptionList(e.cause,be({},n,{handled:!0}))),a}buildParsingContext(){return{chunkIdMap:dG(this.stackParser)}}buildCoercingContext(e,n,r){r===void 0&&(r=0);var i=(o,s)=>{if(s<=4){var a=this.buildCoercingContext(e,n,s);return this.applyCoercers(o,a)}};return be({},n,{syntheticException:r==0?n.syntheticException:void 0,mechanism:e,apply:o=>i(o,r),next:o=>i(o,r+1)})}}var oa="?";function Vp(t,e,n,r,i){var o={platform:t,filename:e,function:n==="<anonymous>"?oa:n,in_app:!0};return fe(r)||(o.lineno=r),fe(i)||(o.colno=i),o}var _S=(t,e)=>{var n=t.indexOf("safari-extension")!==-1,r=t.indexOf("safari-web-extension")!==-1;return n||r?[t.indexOf("@")!==-1?t.split("@")[0]:oa,n?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},fG=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,gG=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,pG=/\((\S*)(?::(\d+))(?::(\d+))\)/,mG=(t,e)=>{var n=fG.exec(t);if(n){var[,r,i,o]=n;return Vp(e,r,oa,+i,+o)}var s=gG.exec(t);if(s){if(s[2]&&s[2].indexOf("eval")===0){var a=pG.exec(s[2]);a&&(s[2]=a[1],s[3]=a[2],s[4]=a[3])}var[l,c]=_S(s[1]||oa,s[2]);return Vp(e,c,l,s[3]?+s[3]:void 0,s[4]?+s[4]:void 0)}},vG=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,yG=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,bG=(t,e)=>{var n=vG.exec(t);if(n){if(n[3]&&n[3].indexOf(" > eval")>-1){var r=yG.exec(n[3]);r&&(n[1]=n[1]||"eval",n[3]=r[1],n[4]=r[2],n[5]="")}var i=n[3],o=n[1]||oa;return[o,i]=_S(o,i),Vp(e,i,o,n[4]?+n[4]:void 0,n[5]?+n[5]:void 0)}},xS=/\(error: (.*)\)/,wS=50;function _G(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return function(i,o){o===void 0&&(o=0);for(var s=[],a=i.split(`
229
229
  `),l=o;l<a.length;l++){var c=a[l];if(!(c.length>1024)){var u=xS.test(c)?c.replace(xS,"$1"):c;if(!u.match(/\S*Error: /)){for(var h of n){var p=h(u,t);if(p){s.push(p);break}}if(s.length>=wS)break}}}return(function(g){if(!g.length)return[];var b=Array.from(g);return b.reverse(),b.slice(0,wS).map((m=>{return be({},m,{filename:m.filename||(x=b,x[x.length-1]||{}).filename,function:m.function||oa});var x}))})(s)}}class xG{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,n){var r=nn(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:r?e.stack:void 0,cause:e.cause?n.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var n=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?n+": "+e.message:n}isDOMException(e){return vd(e,"DOMException")}isDOMError(e){return vd(e,"DOMError")}}class wG{match(e){return(n=>n instanceof Error)(e)}coerce(e,n){return{type:this.getType(e),value:this.getMessage(e,n),stack:this.getStack(e),cause:e.cause?n.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,n){var r=e.message;return r.error&&typeof r.error.message=="string"?String(r.error.message):String(r)}getStack(e){return e.stacktrace||e.stack||void 0}}class EG{constructor(){}match(e){return vd(e,"ErrorEvent")&&e.error!=null}coerce(e,n){var r,i=n.apply(e.error);return i||{type:"ErrorEvent",value:e.message,stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}}var SG=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;class IG{match(e){return typeof e=="string"}coerce(e,n){var r,[i,o]=this.getInfos(e);return{type:i!=null?i:"Error",value:o!=null?o:e,stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}getInfos(e){var n="Error",r=e,i=e.match(SG);return i&&(n=i[1],r=i[2]),[n,r]}}var CG=["fatal","error","warning","log","info","debug"];function ES(t,e){e===void 0&&(e=40);var n=Object.keys(t);if(n.sort(),!n.length)return"[object has no keys]";for(var r=n.length;r>0;r--){var i=n.slice(0,r).join(", ");if(!(i.length>e))return r===n.length||i.length<=e?i:i.slice(0,e)+"..."}return""}class AG{match(e){return typeof e=="object"&&e!==null}coerce(e,n){var r,i=this.getErrorPropertyFromObject(e);return i?n.apply(i):{type:this.getType(e),value:this.getValue(e),stack:(r=n.syntheticException)==null?void 0:r.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return QE(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){var n="'"+e.name+"' captured as exception";return"message"in e&&typeof e.message=="string"&&(n+=" with message: '"+e.message+"'"),n}if("message"in e&&typeof e.message=="string")return e.message;var r=this.getObjectClassName(e);return(r&&r!=="Object"?"'"+r+"'":"Object")+" captured as exception with keys: "+ES(e)}isSeverityLevel(e){return nn(e)&&!Ap(e)&&CG.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var r=e[n];if(uG(r))return r}}getObjectClassName(e){try{var n=Object.getPrototypeOf(e);return n?n.constructor.name:void 0}catch(r){return}}}class OG{match(e){return QE(e)}coerce(e,n){var r,i=e.constructor.name;return{type:i,value:i+" captured as exception with keys: "+ES(e),stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}}class kG{match(e){return Op(e)}coerce(e,n){var r;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}}}class TG{match(e){return vd(e,"PromiseRejectionEvent")}coerce(e,n){var r,i=this.getUnhandledRejectionReason(e);return Op(i)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(i),stack:(r=n.syntheticException)==null?void 0:r.stack,synthetic:!0}:n.apply(i)}getUnhandledRejectionReason(e){if(Op(e))return e;try{if("reason"in e)return e.reason;if("detail"in e&&"reason"in e.detail)return e.detail.reason}catch(n){}return e}}var SS=function(t,e){var{debugEnabled:n}=e===void 0?{}:e,r={k:function(i){if(oe&&(Ci.DEBUG||ke.POSTHOG_DEBUG||n)&&!fe(oe.console)&&oe.console){for(var o=("__rrweb_original__"in oe.console[i])?oe.console[i].__rrweb_original__:oe.console[i],s=arguments.length,a=new Array(s>1?s-1:0),l=1;l<s;l++)a[l-1]=arguments[l];o(t,...a)}},info:function(){for(var i=arguments.length,o=new Array(i),s=0;s<i;s++)o[s]=arguments[s];r.k("log",...o)},warn:function(){for(var i=arguments.length,o=new Array(i),s=0;s<i;s++)o[s]=arguments[s];r.k("warn",...o)},error:function(){for(var i=arguments.length,o=new Array(i),s=0;s<i;s++)o[s]=arguments[s];r.k("error",...o)},critical:function(){for(var i=arguments.length,o=new Array(i),s=0;s<i;s++)o[s]=arguments[s];console.error(t,...o)},uninitializedWarning:i=>{r.error("You must initialize PostHog before calling "+i)},createLogger:(i,o)=>SS(t+" "+i,o)};return r},ye=SS("[PostHog.js]"),At=ye.createLogger,RG=At("[ExternalScriptsLoader]"),IS=(t,e,n)=>{if(t.config.disable_external_dependency_loading)return RG.warn(e+" was requested but loading of external scripts is disabled."),n("Loading of external scripts is disabled");var r=me==null?void 0:me.querySelectorAll("script");if(r){for(var i,o=function(){if(r[s].src===e){var l=r[s];return l.__posthog_loading_callback_fired?{v:n()}:(l.addEventListener("load",(c=>{l.__posthog_loading_callback_fired=!0,n(void 0,c)})),l.onerror=c=>n(c),{v:void 0})}},s=0;s<r.length;s++)if(i=o())return i.v}var a=()=>{if(!me)return n("document not found");var l=me.createElement("script");if(l.type="text/javascript",l.crossOrigin="anonymous",l.src=e,l.onload=h=>{l.__posthog_loading_callback_fired=!0,n(void 0,h)},l.onerror=h=>n(h),t.config.prepare_external_dependency_script&&(l=t.config.prepare_external_dependency_script(l)),!l)return n("prepare_external_dependency_script returned null");var c,u=me.querySelectorAll("body > script");u.length>0?(c=u[0].parentNode)==null||c.insertBefore(l,u[0]):me.body.appendChild(l)};me!=null&&me.body?a():me==null||me.addEventListener("DOMContentLoaded",a)};ke.__PosthogExtensions__=ke.__PosthogExtensions__||{},ke.__PosthogExtensions__.loadExternalDependency=(t,e,n)=>{var r="/static/"+e+".js?v="+t.version;if(e==="remote-config"&&(r="/array/"+t.config.token+"/config.js"),e==="toolbar"){var i=3e5;r=r+"&t="+Math.floor(Date.now()/i)*i}var o=t.requestRouter.endpointFor("assets",r);IS(t,o,n)},ke.__PosthogExtensions__.loadSiteApp=(t,e,n)=>{var r=t.requestRouter.endpointFor("api",e);IS(t,r,n)};var _d={};function io(t,e,n){if(Ze(t)){if(HE&&t.forEach===HE)t.forEach(e,n);else if("length"in t&&t.length===+t.length){for(var r=0,i=t.length;r<i;r++)if(r in t&&e.call(n,t[r],r)===_d)return}}}function ut(t,e,n){if(!Je(t)){if(Ze(t))return io(t,e,n);if(Yq(t)){for(var r of t.entries())if(e.call(n,r[1],r[0])===_d)return}else for(var i in t)if(JE.call(t,i)&&e.call(n,t[i],i)===_d)return}}var Ot=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return io(n,(function(i){for(var o in i)i[o]!==void 0&&(t[o]=i[o])})),t},sa=function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return io(n,(function(i){io(i,(function(o){t.push(o)}))})),t};function xd(t){for(var e=Object.keys(t),n=e.length,r=new Array(n);n--;)r[n]=[e[n],t[e[n]]];return r}var CS=function(t){try{return t()}catch(e){return}},NG=function(t){return function(){try{for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];return t.apply(this,n)}catch(i){ye.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),ye.critical(i)}}},$p=function(t){var e={};return ut(t,(function(n,r){(nn(n)&&n.length>0||ei(n))&&(e[r]=n)})),e};function PG(t,e){return n=t,r=o=>nn(o)&&!Pr(e)?o.slice(0,e):o,i=new Set,(function o(s,a){return s!==Object(s)?r?r(s,a):s:i.has(s)?void 0:(i.add(s),Ze(s)?(l=[],io(s,(c=>{l.push(o(c))}))):(l={},ut(s,((c,u)=>{i.has(c)||(l[u]=o(c,u))}))),l);var l})(n);var n,r,i}var LG=["herokuapp.com","vercel.app","netlify.app"];function MG(t){var e=t==null?void 0:t.hostname;if(!nn(e))return!1;var n=e.split(".").slice(-2).join(".");for(var r of LG)if(n===r)return!1;return!0}function AS(t,e){for(var n=0;n<t.length;n++)if(e(t[n]))return t[n]}function Bt(t,e,n,r){var{capture:i=!1,passive:o=!0}=r!=null?r:{};t==null||t.addEventListener(e,n,{capture:i,passive:o})}var OS="$people_distinct_id",Bl="__alias",Fl="__timers",kS="$autocapture_disabled_server_side",zp="$heatmaps_enabled_server_side",TS="$exception_capture_enabled_server_side",Up="$error_tracking_suppression_rules",RS="$error_tracking_capture_extension_exceptions",NS="$web_vitals_enabled_server_side",PS="$dead_clicks_enabled_server_side",LS="$product_tours_enabled_server_side",MS="$web_vitals_allowed_metrics",Wp="$session_recording_remote_config",wd="$sesid",BS="$session_is_sampled",aa="$enabled_feature_flags",Dl="$early_access_features",Hp="$feature_flag_details",Vl="$stored_person_properties",Go="$stored_group_properties",jp="$surveys",Ed="$flag_call_reported",ki="$user_state",qp="$client_session_props",Gp="$capture_rate_limit",Kp="$initial_campaign_params",Yp="$initial_referrer_info",Sd="$initial_person_info",Id="$epp",FS="__POSTHOG_TOOLBAR__",$l="$posthog_cookieless",BG=[OS,Bl,"__cmpns",Fl,"$session_recording_enabled_server_side",zp,wd,aa,Up,ki,Dl,Hp,Go,Vl,jp,Ed,qp,Gp,Kp,Yp,Id,Sd,"$conversations_widget_session_id","$conversations_ticket_id","$conversations_widget_state","$conversations_user_traits"];function DS(t){return t instanceof Element&&(t.id===FS||!(t.closest==null||!t.closest(".toolbar-global-fade-container")))}function Cd(t){return!!t&&t.nodeType===1}function oo(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function VS(t){return!!t&&t.nodeType===3}function $S(t){return!!t&&t.nodeType===11}function Xp(t){return t?pd(t).split(/\s+/):[]}function zS(t){var e=oe==null?void 0:oe.location.href;return!!(e&&t&&t.some((n=>e.match(n))))}function Ad(t){var e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return Xp(e)}function US(t){return Je(t)?null:pd(t).split(/(\s+)/).filter((e=>Ul(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function zl(t){var e="";return Qp(t)&&!YS(t)&&t.childNodes&&t.childNodes.length&&ut(t.childNodes,(function(n){var r;VS(n)&&n.textContent&&(e+=(r=US(n.textContent))!==null&&r!==void 0?r:"")})),pd(e)}function WS(t){return fe(t.target)?t.srcElement||null:(e=t.target)!=null&&e.shadowRoot?t.composedPath()[0]||null:t.target||null;var e}var Zp=["a","button","form","input","select","textarea","label"];function HS(t,e){if(fe(e))return!0;var n,r=function(o){if(e.some((s=>o.matches(s))))return{v:!0}};for(var i of t)if(n=r(i))return n.v;return!1}function jS(t){var e=t.parentNode;return!(!e||!Cd(e))&&e}var FG=["next","previous","prev",">","<"],qS=10,GS=[".ph-no-rageclick",".ph-no-capture"];function DG(t,e){if(!oe||Jp(t))return!1;var n,r,i;if(Ai(e)?(n=!!e&&GS,r=void 0):(n=(i=e==null?void 0:e.css_selector_ignorelist)!==null&&i!==void 0?i:GS,r=e==null?void 0:e.content_ignorelist),n===!1)return!1;var{targetElementList:o}=KS(t,!1);return!(function(s,a){if(s===!1||fe(s))return!1;var l;if(s===!0)l=FG;else{if(!Ze(s))return!1;if(s.length>qS)return ye.error("[PostHog] content_ignorelist array cannot exceed "+qS+" items. Use css_selector_ignorelist for more complex matching."),!1;l=s.map((c=>c.toLowerCase()))}return a.some((c=>{var{safeText:u,ariaLabel:h}=c;return l.some((p=>u.includes(p)||h.includes(p)))}))})(r,o.map((s=>{var a;return{safeText:zl(s).toLowerCase(),ariaLabel:((a=s.getAttribute("aria-label"))==null?void 0:a.toLowerCase().trim())||""}})))&&!HS(o,n)}var Jp=t=>!t||oo(t,"html")||!Cd(t),KS=(t,e)=>{if(!oe||Jp(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var n=!1,r=[t],i=t;i.parentNode&&!oo(i,"body");)if($S(i.parentNode))r.push(i.parentNode.host),i=i.parentNode.host;else{var o=jS(i);if(!o)break;if(e||Zp.indexOf(o.tagName.toLowerCase())>-1)n=!0;else{var s=oe.getComputedStyle(o);s&&s.getPropertyValue("cursor")==="pointer"&&(n=!0)}r.push(o),i=o}return{parentIsUsefulElement:n,targetElementList:r}};function VG(t,e,n,r,i){var o,s,a,l;if(n===void 0&&(n=void 0),!oe||Jp(t)||(o=n)!=null&&o.url_allowlist&&!zS(n.url_allowlist)||(s=n)!=null&&s.url_ignorelist&&zS(n.url_ignorelist))return!1;if((a=n)!=null&&a.dom_event_allowlist){var c=n.dom_event_allowlist;if(c&&!c.some((b=>e.type===b)))return!1}var{parentIsUsefulElement:u,targetElementList:h}=KS(t,r);if(!(function(b,m){var x=m==null?void 0:m.element_allowlist;if(fe(x))return!0;var I,N=function($){if(x.some((B=>$.tagName.toLowerCase()===B)))return{v:!0}};for(var T of b)if(I=N(T))return I.v;return!1})(h,n)||!HS(h,(l=n)==null?void 0:l.css_selector_allowlist))return!1;var p=oe.getComputedStyle(t);if(p&&p.getPropertyValue("cursor")==="pointer"&&e.type==="click")return!0;var g=t.tagName.toLowerCase();switch(g){case"html":return!1;case"form":return(i||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(i||["change","click"]).indexOf(e.type)>=0;default:return u?(i||["click"]).indexOf(e.type)>=0:(i||["click"]).indexOf(e.type)>=0&&(Zp.indexOf(g)>-1||t.getAttribute("contenteditable")==="true")}}function Qp(t){for(var e=t;e.parentNode&&!oo(e,"body");e=e.parentNode){var n=Ad(e);if(Ue(n,"ph-sensitive")||Ue(n,"ph-no-capture"))return!1}if(Ue(Ad(t),"ph-include"))return!0;var r=t.type||"";if(nn(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var i=t.name||t.id||"";return!(nn(i)&&/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.replace(/[^a-zA-Z0-9]/g,"")))}function YS(t){return!!(oo(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||oo(t,"select")||oo(t,"textarea")||t.getAttribute("contenteditable")==="true")}var XS="(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11})",$G=new RegExp("^(?:"+XS+")$"),zG=new RegExp(XS),ZS="\\d{3}-?\\d{2}-?\\d{4}",UG=new RegExp("^("+ZS+")$"),WG=new RegExp("("+ZS+")");function Ul(t,e){return e===void 0&&(e=!0),!(Je(t)||nn(t)&&(t=pd(t),(e?$G:zG).test((t||"").replace(/[- ]/g,""))||(e?UG:WG).test(t)))}function JS(t){var e=zl(t);return Ul(e=(e+" "+QS(t)).trim())?e:""}function QS(t){var e="";return t&&t.childNodes&&t.childNodes.length&&ut(t.childNodes,(function(n){var r;if(n&&((r=n.tagName)==null?void 0:r.toLowerCase())==="span")try{var i=zl(n);e=(e+" "+i).trim(),n.childNodes&&n.childNodes.length&&(e=(e+" "+QS(n)).trim())}catch(o){ye.error("[AutoCapture]",o)}})),e}function HG(t){return(function(e){var n=e.map((r=>{var i,o,s="";if(r.tag_name&&(s+=r.tag_name),r.attr_class)for(var a of(r.attr_class.sort(),r.attr_class))s+="."+a.replace(/"/g,"");var l=be({},r.text?{text:r.text}:{},{"nth-child":(i=r.nth_child)!==null&&i!==void 0?i:0,"nth-of-type":(o=r.nth_of_type)!==null&&o!==void 0?o:0},r.href?{href:r.href}:{},r.attr_id?{attr_id:r.attr_id}:{},r.attributes),c={};return xd(l).sort(((u,h)=>{var[p]=u,[g]=h;return p.localeCompare(g)})).forEach((u=>{var[h,p]=u;return c[eI(h.toString())]=eI(p.toString())})),s+=":",s+=xd(c).map((u=>{var[h,p]=u;return h+'="'+p+'"'})).join("")}));return n.join(";")})((function(e){return e.map((n=>{var r,i,o={text:(r=n.$el_text)==null?void 0:r.slice(0,400),tag_name:n.tag_name,href:(i=n.attr__href)==null?void 0:i.slice(0,2048),attr_class:jG(n),attr_id:n.attr__id,nth_child:n.nth_child,nth_of_type:n.nth_of_type,attributes:{}};return xd(n).filter((s=>{var[a]=s;return a.indexOf("attr__")===0})).forEach((s=>{var[a,l]=s;return o.attributes[a]=l})),o}))})(t))}function eI(t){return t.replace(/"|\\"/g,'\\"')}function jG(t){var e=t.attr__class;return e?Ze(e)?e:Xp(e):void 0}class tI{constructor(e){this.disabled=e===!1;var n=an(e)?e:{};this.thresholdPx=n.threshold_px||30,this.timeoutMs=n.timeout_ms||1e3,this.clickCount=n.click_count||3,this.clicks=[]}isRageClick(e,n,r){if(this.disabled)return!1;var i=this.clicks[this.clicks.length-1];if(i&&Math.abs(e-i.x)+Math.abs(n-i.y)<this.thresholdPx&&r-i.timestamp<this.timeoutMs){if(this.clicks.push({x:e,y:n,timestamp:r}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:n,timestamp:r}];return!1}}var em="$copy_autocapture",Ti=(function(t){return t.GZipJS="gzip-js",t.Base64="base64",t})({}),Od=t=>{var e=me==null?void 0:me.createElement("a");return fe(e)?null:(e.href=t,e)},qG=function(t,e){var n,r;e===void 0&&(e="&");var i=[];return ut(t,(function(o,s){fe(o)||fe(s)||s==="undefined"||(n=encodeURIComponent((a=>a instanceof File)(o)?o.name:o.toString()),r=encodeURIComponent(s),i[i.length]=r+"="+n)})),i.join(e)},kd=function(t,e){for(var n,r=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),i=0;i<r.length;i++){var o=r[i].split("=");if(o[0]===e){n=o;break}}if(!Ze(n)||n.length<2)return"";var s=n[1];try{s=decodeURIComponent(s)}catch(a){ye.error("Skipping decoding for malformed query param: "+s)}return s.replace(/\+/g," ")},Wl=function(t,e,n){if(!t||!e||!e.length)return t;for(var r=t.split("#"),i=r[0]||"",o=r[1],s=i.split("?"),a=s[1],l=s[0],c=(a||"").split("&"),u=[],h=0;h<c.length;h++){var p=c[h].split("=");Ze(p)&&(e.includes(p[0])?u.push(p[0]+"="+n):u.push(c[h]))}var g=l;return a!=null&&(g+="?"+u.join("&")),o!=null&&(g+="#"+o),g},Td=function(t,e){var n=t.match(new RegExp(e+"=([^&]*)"));return n?n[1]:null},nI=At("[AutoCapture]");function tm(t,e){return e.length>t?e.slice(0,t)+"...":e}function GG(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do e=e.previousSibling;while(e&&!Cd(e));return e}function KG(t,e,n,r){var i=t.tagName.toLowerCase(),o={tag_name:i};Zp.indexOf(i)>-1&&!n&&(i.toLowerCase()==="a"||i.toLowerCase()==="button"?o.$el_text=tm(1024,JS(t)):o.$el_text=tm(1024,zl(t)));var s=Ad(t);s.length>0&&(o.classes=s.filter((function(u){return u!==""}))),ut(t.attributes,(function(u){var h;if((!YS(t)||["name","id","class","aria-label"].indexOf(u.name)!==-1)&&(r==null||!r.includes(u.name))&&!e&&Ul(u.value)&&(h=u.name,!nn(h)||h.substring(0,10)!=="_ngcontent"&&h.substring(0,7)!=="_nghost")){var p=u.value;u.name==="class"&&(p=Xp(p).join(" ")),o["attr__"+u.name]=tm(1024,p)}}));for(var a=1,l=1,c=t;c=GG(c);)a++,c.tagName===t.tagName&&l++;return o.nth_child=a,o.nth_of_type=l,o}function YG(t,e){for(var n,r,{e:i,maskAllElementAttributes:o,maskAllText:s,elementAttributeIgnoreList:a,elementsChainAsString:l}=e,c=[t],u=t;u.parentNode&&!oo(u,"body");)$S(u.parentNode)?(c.push(u.parentNode.host),u=u.parentNode.host):(c.push(u.parentNode),u=u.parentNode);var h,p=[],g={},b=!1,m=!1;if(ut(c,($=>{var B=Qp($);$.tagName.toLowerCase()==="a"&&(b=$.getAttribute("href"),b=B&&b&&Ul(b)&&b),Ue(Ad($),"ph-no-capture")&&(m=!0),p.push(KG($,o,s,a));var G=(function(Z){if(!Qp(Z))return{};var Y={};return ut(Z.attributes,(function(F){if(F.name&&F.name.indexOf("data-ph-capture-attribute")===0){var V=F.name.replace("data-ph-capture-attribute-",""),U=F.value;V&&U&&Ul(U)&&(Y[V]=U)}})),Y})($);Ot(g,G)})),m)return{props:{},explicitNoCapture:m};if(s||(t.tagName.toLowerCase()==="a"||t.tagName.toLowerCase()==="button"?p[0].$el_text=JS(t):p[0].$el_text=zl(t)),b){var x,I;p[0].attr__href=b;var N=(x=Od(b))==null?void 0:x.host,T=oe==null||(I=oe.location)==null?void 0:I.host;N&&T&&N!==T&&(h=b)}return{props:Ot({$event_type:i.type,$ce_version:1},l?{}:{$elements:p},{$elements_chain:HG(p)},(n=p[0])!=null&&n.$el_text?{$el_text:(r=p[0])==null?void 0:r.$el_text}:{},h&&i.type==="click"?{$external_click_url:h}:{},g)}}class XG{constructor(e){this.P=!1,this.T=null,this.I=!1,this.instance=e,this.rageclicks=new tI(e.config.rageclick),this.C=null}get R(){var e,n,r=an(this.instance.config.autocapture)?this.instance.config.autocapture:{};return r.url_allowlist=(e=r.url_allowlist)==null?void 0:e.map((i=>new RegExp(i))),r.url_ignorelist=(n=r.url_ignorelist)==null?void 0:n.map((i=>new RegExp(i))),r}F(){if(this.isBrowserSupported()){if(oe&&me){var e=r=>{r=r||(oe==null?void 0:oe.event);try{this.M(r)}catch(i){nI.error("Failed to capture event",i)}};if(Bt(me,"submit",e,{capture:!0}),Bt(me,"change",e,{capture:!0}),Bt(me,"click",e,{capture:!0}),this.R.capture_copied_text){var n=r=>{r=r||(oe==null?void 0:oe.event),this.M(r,em)};Bt(me,"copy",n,{capture:!0}),Bt(me,"cut",n,{capture:!0})}}}else nI.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.P&&(this.F(),this.P=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this.I=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[kS]:!!e.autocapture_opt_out}),this.T=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this.C=e}getElementSelectors(e){var n,r=[];return(n=this.C)==null||n.forEach((i=>{var o=me==null?void 0:me.querySelectorAll(i);o==null||o.forEach((s=>{e===s&&r.push(i)}))})),r}get isEnabled(){var e,n,r=(e=this.instance.persistence)==null?void 0:e.props[kS],i=this.T;if(Pr(i)&&!Ai(r)&&!this.instance.O())return!1;var o=(n=this.T)!==null&&n!==void 0?n:!!r;return!!this.instance.config.autocapture&&!o}M(e,n){if(n===void 0&&(n="$autocapture"),this.isEnabled){var r,i=WS(e);VS(i)&&(i=i.parentNode||null),n==="$autocapture"&&e.type==="click"&&e instanceof MouseEvent&&this.instance.config.rageclick&&(r=this.rageclicks)!=null&&r.isRageClick(e.clientX,e.clientY,e.timeStamp||new Date().getTime())&&DG(i,this.instance.config.rageclick)&&this.M(e,"$rageclick");var o=n===em;if(i&&VG(i,e,this.R,o,o?["copy","cut"]:void 0)){var{props:s,explicitNoCapture:a}=YG(i,{e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.R.element_attribute_ignorelist,elementsChainAsString:this.I});if(a)return!1;var l=this.getElementSelectors(i);if(l&&l.length>0&&(s.$element_selectors=l),n===em){var c,u=US(oe==null||(c=oe.getSelection())==null?void 0:c.toString()),h=e.type||"clipboard";if(!u)return!1;s.$selected_content=u,s.$copy_type=h}return this.instance.capture(n,s),!0}}}isBrowserSupported(){return ro(me==null?void 0:me.querySelectorAll)}}Math.trunc||(Math.trunc=function(t){return t<0?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return ei(t)&&isFinite(t)&&Math.floor(t)===t});var rI="0123456789abcdef";class Rd{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,n,r,i){if(!Number.isInteger(e)||!Number.isInteger(n)||!Number.isInteger(r)||!Number.isInteger(i)||e<0||n<0||r<0||i<0||e>0xffffffffffff||n>4095||r>1073741823||i>4294967295)throw new RangeError("invalid field value");var o=new Uint8Array(16);return o[0]=e/Math.pow(2,40),o[1]=e/Math.pow(2,32),o[2]=e/Math.pow(2,24),o[3]=e/Math.pow(2,16),o[4]=e/Math.pow(2,8),o[5]=e,o[6]=112|n>>>8,o[7]=n,o[8]=128|r>>>24,o[9]=r>>>16,o[10]=r>>>8,o[11]=r,o[12]=i>>>24,o[13]=i>>>16,o[14]=i>>>8,o[15]=i,new Rd(o)}toString(){for(var e="",n=0;n<this.bytes.length;n++)e=e+rI.charAt(this.bytes[n]>>>4)+rI.charAt(15&this.bytes[n]),n!==3&&n!==5&&n!==7&&n!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new Rd(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var n=0;n<16;n++){var r=this.bytes[n]-e.bytes[n];if(r!==0)return Math.sign(r)}return 0}}class ZG{constructor(){this.A=0,this.D=0,this.j=new JG}generate(){var e=this.generateOrAbort();if(fe(e)){this.A=0;var n=this.generateOrAbort();if(fe(n))throw new Error("Could not generate UUID after timestamp reset");return n}return e}generateOrAbort(){var e=Date.now();if(e>this.A)this.A=e,this.L();else{if(!(e+1e4>this.A))return;this.D++,this.D>4398046511103&&(this.A++,this.L())}return Rd.fromFieldsV7(this.A,Math.trunc(this.D/Math.pow(2,30)),this.D&Math.pow(2,30)-1,this.j.nextUint32())}L(){this.D=1024*this.j.nextUint32()+(1023&this.j.nextUint32())}}var iI,oI=t=>{if(typeof UUIDV7_DENY_WEAK_RNG!="undefined"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;e<t.length;e++)t[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};oe&&!fe(oe.crypto)&&crypto.getRandomValues&&(oI=t=>crypto.getRandomValues(t));class JG{constructor(){this.N=new Uint32Array(8),this.U=1/0}nextUint32(){return this.U>=this.N.length&&(oI(this.N),this.U=0),this.N[this.U++]}}var so=()=>QG().toString(),QG=()=>(iI||(iI=new ZG)).generate(),Hl="",eK=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function tK(t,e){if(e){var n=(function(i,o){if(o===void 0&&(o=me),Hl)return Hl;if(!o||["localhost","127.0.0.1"].includes(i))return"";for(var s=i.split("."),a=Math.min(s.length,8),l="dmn_chk_"+so();!Hl&&a--;){var c=s.slice(a).join("."),u=l+"=1;domain=."+c+";path=/";o.cookie=u+";max-age=3",o.cookie.includes(l)&&(o.cookie=u+";max-age=0",Hl=c)}return Hl})(t);if(!n){var r=(i=>{var o=i.match(eK);return o?o[0]:""})(t);r!==n&&ye.info("Warning: cookie subdomain discovery mismatch",r,n),n=r}return n?"; domain=."+n:""}return""}var ni={H:()=>!!me,B:function(t){ye.error("cookieStore error: "+t)},q:function(t){if(me){try{for(var e=t+"=",n=me.cookie.split(";").filter((o=>o.length)),r=0;r<n.length;r++){for(var i=n[r];i.charAt(0)==" ";)i=i.substring(1,i.length);if(i.indexOf(e)===0)return decodeURIComponent(i.substring(e.length,i.length))}}catch(o){}return null}},W:function(t){var e;try{e=JSON.parse(ni.q(t))||{}}catch(n){}return e},G:function(t,e,n,r,i){if(me)try{var o="",s="",a=tK(me.location.hostname,r);if(n){var l=new Date;l.setTime(l.getTime()+24*n*60*60*1e3),o="; expires="+l.toUTCString()}i&&(s="; secure");var c=t+"="+encodeURIComponent(JSON.stringify(e))+o+"; SameSite=Lax; path=/"+a+s;return c.length>3686.4&&ye.warn("cookieStore warning: large cookie, len="+c.length),me.cookie=c,c}catch(u){return}},V:function(t,e){if(me!=null&&me.cookie)try{ni.G(t,"",-1,e)}catch(n){return}}},nm=null,bt={H:function(){if(!Pr(nm))return nm;var t=!0;if(fe(oe))t=!1;else try{var e="__mplssupport__";bt.G(e,"xyz"),bt.q(e)!=='"xyz"'&&(t=!1),bt.V(e)}catch(n){t=!1}return t||ye.error("localStorage unsupported; falling back to cookie store"),nm=t,t},B:function(t){ye.error("localStorage error: "+t)},q:function(t){try{return oe==null?void 0:oe.localStorage.getItem(t)}catch(e){bt.B(e)}return null},W:function(t){try{return JSON.parse(bt.q(t))||{}}catch(e){}return null},G:function(t,e){try{oe==null||oe.localStorage.setItem(t,JSON.stringify(e))}catch(n){bt.B(n)}},V:function(t){try{oe==null||oe.localStorage.removeItem(t)}catch(e){bt.B(e)}}},nK=["distinct_id",wd,BS,Id,Sd],Nd=be({},bt,{W:function(t){try{var e={};try{e=ni.W(t)||{}}catch(r){}var n=Ot(e,JSON.parse(bt.q(t)||"{}"));return bt.G(t,n),n}catch(r){}return null},G:function(t,e,n,r,i,o){try{bt.G(t,e,void 0,void 0,o);var s={};nK.forEach((a=>{e[a]&&(s[a]=e[a])})),Object.keys(s).length&&ni.G(t,s,n,r,i,o)}catch(a){bt.B(a)}},V:function(t,e){try{oe==null||oe.localStorage.removeItem(t),ni.V(t,e)}catch(n){bt.B(n)}}}),Pd={},rK={H:function(){return!0},B:function(t){ye.error("memoryStorage error: "+t)},q:function(t){return Pd[t]||null},W:function(t){return Pd[t]||null},G:function(t,e){Pd[t]=e},V:function(t){delete Pd[t]}},Ko=null,_n={H:function(){if(!Pr(Ko))return Ko;if(Ko=!0,fe(oe))Ko=!1;else try{var t="__support__";_n.G(t,"xyz"),_n.q(t)!=='"xyz"'&&(Ko=!1),_n.V(t)}catch(e){Ko=!1}return Ko},B:function(t){ye.error("sessionStorage error: ",t)},q:function(t){try{return oe==null?void 0:oe.sessionStorage.getItem(t)}catch(e){_n.B(e)}return null},W:function(t){try{return JSON.parse(_n.q(t))||null}catch(e){}return null},G:function(t,e){try{oe==null||oe.sessionStorage.setItem(t,JSON.stringify(e))}catch(n){_n.B(n)}},V:function(t){try{oe==null||oe.sessionStorage.removeItem(t)}catch(e){_n.B(e)}}},Ri=(function(t){return t[t.PENDING=-1]="PENDING",t[t.DENIED=0]="DENIED",t[t.GRANTED=1]="GRANTED",t})({});class iK{constructor(e){this._instance=e}get R(){return this._instance.config}get consent(){return this.J()?Ri.DENIED:this.K}isOptedOut(){return this.R.cookieless_mode==="always"||this.consent===Ri.DENIED||this.consent===Ri.PENDING&&(this.R.opt_out_capturing_by_default||this.R.cookieless_mode==="on_reject")}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===Ri.DENIED}optInOut(e){this.Y.G(this.X,e?1:0,this.R.cookie_expiration,this.R.cross_subdomain_cookie,this.R.secure_cookie)}reset(){this.Y.V(this.X,this.R.cross_subdomain_cookie)}get X(){var{token:e,opt_out_capturing_cookie_prefix:n,consent_persistence_name:r}=this._instance.config;return r||(n?n+e:"__ph_opt_in_out_"+e)}get K(){var e=this.Y.q(this.X);return kp(e)?Ri.GRANTED:Ue(Jq,e)?Ri.DENIED:Ri.PENDING}get Y(){if(!this.Z){var e=this.R.opt_out_capturing_persistence_type;this.Z=e==="localStorage"?bt:ni;var n=e==="localStorage"?ni:bt;n.q(this.X)&&(this.Z.q(this.X)||this.optInOut(kp(n.q(this.X))),n.V(this.X,this.R.cross_subdomain_cookie))}return this.Z}J(){return!!this.R.respect_dnt&&!!AS([ur==null?void 0:ur.doNotTrack,ur==null?void 0:ur.msDoNotTrack,ke.doNotTrack],(e=>kp(e)))}}var Ld=At("[Dead Clicks]"),oK=()=>!0,sK=t=>{var e,n=!((e=t.instance.persistence)==null||!e.get_property(PS)),r=t.instance.config.capture_dead_clicks;return Ai(r)?r:!!an(r)||n};class sI{get lazyLoadedDeadClicksAutocapture(){return this.tt}constructor(e,n,r){this.instance=e,this.isEnabled=n,this.onCapture=r,this.startIfEnabled()}onRemoteConfig(e){this.instance.persistence&&this.instance.persistence.register({[PS]:e==null?void 0:e.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.it((()=>{this.et()}))}it(e){var n,r;(n=ke.__PosthogExtensions__)!=null&&n.initDeadClicksAutocapture&&e(),(r=ke.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"dead-clicks-autocapture",(i=>{i?Ld.error("failed to load script",i):e()}))}et(){var e;if(me){if(!this.tt&&(e=ke.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var n=an(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};n.__onCapture=this.onCapture,this.tt=ke.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,n),this.tt.start(me),Ld.info("starting...")}}else Ld.error("`document` not found. Cannot start.")}stop(){this.tt&&(this.tt.stop(),this.tt=void 0,Ld.info("stopping..."))}}var jl=At("[ExceptionAutocapture]");class aK{constructor(e){var n,r,i;this.rt=()=>{var o;if(oe&&this.isEnabled&&(o=ke.__PosthogExtensions__)!=null&&o.errorWrappingFunctions){var s=ke.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,a=ke.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,l=ke.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.st&&this.R.capture_unhandled_errors&&(this.st=s(this.captureException.bind(this))),!this.nt&&this.R.capture_unhandled_rejections&&(this.nt=a(this.captureException.bind(this))),!this.ot&&this.R.capture_console_errors&&(this.ot=l(this.captureException.bind(this)))}catch(c){jl.error("failed to start",c),this.ut()}}},this._instance=e,this.ht=!((n=this._instance.persistence)==null||!n.props[TS]),this.dt=new Qq({refillRate:(r=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)!==null&&r!==void 0?r:1,bucketSize:(i=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)!==null&&i!==void 0?i:10,refillInterval:1e4,h:jl}),this.R=this.vt(),this.startIfEnabledOrStop()}vt(){var e=this._instance.config.capture_exceptions,n={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return an(e)?n=be({},n,e):(fe(e)?this.ht:e)&&(n=be({},n,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),n}get isEnabled(){return this.R.capture_console_errors||this.R.capture_unhandled_errors||this.R.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(jl.info("enabled"),this.ut(),this.it(this.rt)):this.ut()}it(e){var n,r;(n=ke.__PosthogExtensions__)!=null&&n.errorWrappingFunctions&&e(),(r=ke.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"exception-autocapture",(i=>{if(i)return jl.error("failed to load script",i);e()}))}ut(){var e,n,r;(e=this.st)==null||e.call(this),this.st=void 0,(n=this.nt)==null||n.call(this),this.nt=void 0,(r=this.ot)==null||r.call(this),this.ot=void 0}onRemoteConfig(e){var n=e.autocaptureExceptions;this.ht=!!n||!1,this._instance.persistence&&this._instance.persistence.register({[TS]:this.ht}),this.R=this.vt(),this.startIfEnabledOrStop()}onConfigChange(){this.R=this.vt()}captureException(e){var n,r,i=(n=e==null||(r=e.$exception_list)==null||(r=r[0])==null?void 0:r.type)!==null&&n!==void 0?n:"Exception";this.dt.consumeRateLimit(i)?jl.info("Skipping exception capture because of client rate limiting.",{exception:i}):this._instance.exceptions.sendExceptionEvent(e)}}function aI(t,e,n){try{if(!(e in t))return()=>{};var r=t[e],i=n(r);return ro(i)&&(i.prototype=i.prototype||{},Object.defineProperties(i,{__posthog_wrapped__:{enumerable:!1,value:!0}})),t[e]=i,()=>{t[e]=r}}catch(o){return()=>{}}}class lK{constructor(e){var n;this._instance=e,this.ct=(oe==null||(n=oe.location)==null?void 0:n.pathname)||""}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(ye.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.ft&&this.ft(),this.ft=void 0,ye.info("History API monitoring stopped")}monitorHistoryChanges(){var e,n;if(oe&&oe.history){var r=this;(e=oe.history.pushState)!=null&&e.__posthog_wrapped__||aI(oe.history,"pushState",(i=>function(o,s,a){i.call(this,o,s,a),r._t("pushState")})),(n=oe.history.replaceState)!=null&&n.__posthog_wrapped__||aI(oe.history,"replaceState",(i=>function(o,s,a){i.call(this,o,s,a),r._t("replaceState")})),this.bt()}}_t(e){try{var n,r=oe==null||(n=oe.location)==null?void 0:n.pathname;if(!r)return;r!==this.ct&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:e}),this.ct=r}catch(i){ye.error("Error capturing "+e+" pageview",i)}}bt(){if(!this.ft){var e=()=>{this._t("popstate")};Bt(oe,"popstate",e),this.ft=()=>{oe&&oe.removeEventListener("popstate",e)}}}}var rm=At("[SegmentIntegration]");function cK(t,e){var n=t.config.segment;if(!n)return e();(function(r,i){var o=r.config.segment;if(!o)return i();var s=l=>{var c=()=>l.anonymousId()||so();r.config.get_device_id=c,l.id()&&(r.register({distinct_id:l.id(),$device_id:c()}),r.persistence.set_property(ki,"identified")),i()},a=o.user();"then"in a&&ro(a.then)?a.then((l=>s(l))):s(a)})(t,(()=>{n.register((r=>{Promise&&Promise.resolve||rm.warn("This browser does not have Promise support, and can not use the segment integration");var i=(o,s)=>{if(!s)return o;o.event.userId||o.event.anonymousId===r.get_distinct_id()||(rm.info("No userId set, resetting PostHog"),r.reset()),o.event.userId&&o.event.userId!==r.get_distinct_id()&&(rm.info("UserId set, identifying with PostHog"),r.identify(o.event.userId));var a=r.calculateEventProperties(s,o.event.properties);return o.event.properties=Object.assign({},a,o.event.properties),o};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:o=>i(o,o.event.event),page:o=>i(o,"$pageview"),identify:o=>i(o,"$identify"),screen:o=>i(o,"$screen")}})(t)).then((()=>{e()}))}))}var lI="posthog-js";function cI(t,e){var{organization:n,projectId:r,prefix:i,severityAllowList:o=["error"],sendExceptionsToPostHog:s=!0}=e===void 0?{}:e;return a=>{var l,c,u,h,p;if(!(o==="*"||o.includes(a.level))||!t.__loaded)return a;a.tags||(a.tags={});var g=t.requestRouter.endpointFor("ui","/project/"+t.config.token+"/person/"+t.get_distinct_id());a.tags["PostHog Person URL"]=g,t.sessionRecordingStarted()&&(a.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));var b=((l=a.exception)==null?void 0:l.values)||[],m=b.map((I=>be({},I,{stacktrace:I.stacktrace?be({},I.stacktrace,{type:"raw",frames:(I.stacktrace.frames||[]).map((N=>be({},N,{platform:"web:javascript"})))}):void 0}))),x={$exception_message:((c=b[0])==null?void 0:c.value)||a.message,$exception_type:(u=b[0])==null?void 0:u.type,$exception_level:a.level,$exception_list:m,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:((h=b[0])==null?void 0:h.value)||a.message,$sentry_exception_type:(p=b[0])==null?void 0:p.type,$sentry_tags:a.tags};return n&&r&&(x.$sentry_url=(i||"https://sentry.io/organizations/")+n+"/issues/?project="+r+"&query="+a.event_id),s&&t.exceptions.sendExceptionEvent(x),a}}class uK{constructor(e,n,r,i,o,s){this.name=lI,this.setupOnce=function(a){a(cI(e,{organization:n,projectId:r,prefix:i,severityAllowList:o,sendExceptionsToPostHog:s==null||s}))}}}var dK=oe!=null&&oe.location?Td(oe.location.hash,"__posthog")||Td(location.hash,"state"):null,uI="_postHogToolbarParams",dI=At("[Toolbar]"),ao=(function(t){return t[t.UNINITIALIZED=0]="UNINITIALIZED",t[t.LOADING=1]="LOADING",t[t.LOADED=2]="LOADED",t})(ao||{});class hK{constructor(e){this.instance=e}yt(e){ke.ph_toolbar_state=e}wt(){var e;return(e=ke.ph_toolbar_state)!==null&&e!==void 0?e:ao.UNINITIALIZED}maybeLoadToolbar(e,n,r){if(e===void 0&&(e=void 0),n===void 0&&(n=void 0),r===void 0&&(r=void 0),!oe||!me)return!1;e=e!=null?e:oe.location,r=r!=null?r:oe.history;try{if(!n){try{oe.localStorage.setItem("test","test"),oe.localStorage.removeItem("test")}catch(a){return!1}n=oe==null?void 0:oe.localStorage}var i,o=dK||Td(e.hash,"__posthog")||Td(e.hash,"state"),s=o?CS((()=>JSON.parse(atob(decodeURIComponent(o)))))||CS((()=>JSON.parse(decodeURIComponent(o)))):null;return s&&s.action==="ph_authorize"?((i=s).source="url",i&&Object.keys(i).length>0&&(s.desiredHash?e.hash=s.desiredHash:r?r.replaceState(r.state,"",e.pathname+e.search):e.hash="")):((i=JSON.parse(n.getItem(uI)||"{}")).source="localstorage",delete i.userIntent),!(!i.token||this.instance.config.token!==i.token)&&(this.loadToolbar(i),!0)}catch(a){return!1}}xt(e){var n=ke.ph_load_toolbar||ke.ph_load_editor;!Je(n)&&ro(n)?n(e,this.instance):dI.warn("No toolbar load function found")}loadToolbar(e){var n=!(me==null||!me.getElementById(FS));if(!oe||n)return!1;var r=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,i=be({token:this.instance.config.token},e,{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(oe.localStorage.setItem(uI,JSON.stringify(be({},i,{source:void 0}))),this.wt()===ao.LOADED)this.xt(i);else if(this.wt()===ao.UNINITIALIZED){var o;this.yt(ao.LOADING),(o=ke.__PosthogExtensions__)==null||o.loadExternalDependency==null||o.loadExternalDependency(this.instance,"toolbar",(s=>{if(s)return dI.error("[Toolbar] Failed to load",s),void this.yt(ao.UNINITIALIZED);this.yt(ao.LOADED),this.xt(i)})),Bt(oe,"turbolinks:load",(()=>{this.yt(ao.UNINITIALIZED),this.loadToolbar(i)}))}return!0}Et(e){return this.loadToolbar(e)}maybeLoadEditor(e,n,r){return e===void 0&&(e=void 0),n===void 0&&(n=void 0),r===void 0&&(r=void 0),this.maybeLoadToolbar(e,n,r)}}var fK=At("[TracingHeaders]");class gK{constructor(e){this.$t=void 0,this.St=void 0,this.rt=()=>{var n,r;fe(this.$t)&&((n=ke.__PosthogExtensions__)==null||(n=n.tracingHeadersPatchFns)==null||n._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),fe(this.St)&&((r=ke.__PosthogExtensions__)==null||(r=r.tracingHeadersPatchFns)==null||r._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=e}it(e){var n,r;(n=ke.__PosthogExtensions__)!=null&&n.tracingHeadersPatchFns&&e(),(r=ke.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"tracing-headers",(i=>{if(i)return fK.error("failed to load script",i);e()}))}startIfEnabledOrStop(){var e,n;this._instance.config.__add_tracing_headers?this.it(this.rt):((e=this.$t)==null||e.call(this),(n=this.St)==null||n.call(this),this.$t=void 0,this.St=void 0)}}var Md="https?://(.*)",la=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],pK=sa(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],la),ql="<masked>",mK=["li_fat_id"];function hI(t,e,n){if(!me)return{};var r,i=e?sa([],la,n||[]):[],o=fI(Wl(me.URL,i,ql),t),s=(r={},ut(mK,(function(a){var l=ni.q(a);r[a]=l||null})),r);return Ot(s,o)}function fI(t,e){var n=pK.concat(e||[]),r={};return ut(n,(function(i){var o=kd(t,i);r[i]=o||null})),r}function gI(t){var e=(function(o){return o?o.search(Md+"google.([^/?]*)")===0?"google":o.search(Md+"bing.com")===0?"bing":o.search(Md+"yahoo.com")===0?"yahoo":o.search(Md+"duckduckgo.com")===0?"duckduckgo":null:null})(t),n=e!="yahoo"?"q":"p",r={};if(!Pr(e)){r.$search_engine=e;var i=me?kd(me.referrer,n):"";i.length&&(r.ph_keyword=i)}return r}function pI(){return navigator.language||navigator.userLanguage}function mI(){return(me==null?void 0:me.referrer)||"$direct"}function vI(t,e){var n=t?sa([],la,e||[]):[],r=jn==null?void 0:jn.href.substring(0,1e3);return{r:mI().substring(0,1e3),u:r?Wl(r,n,ql):void 0}}function yI(t){var e,{r:n,u:r}=t,i={$referrer:n,$referring_domain:n==null?void 0:n=="$direct"?"$direct":(e=Od(n))==null?void 0:e.host};if(r){i.$current_url=r;var o=Od(r);i.$host=o==null?void 0:o.host,i.$pathname=o==null?void 0:o.pathname;var s=fI(r);Ot(i,s)}if(n){var a=gI(n);Ot(i,a)}return i}function bI(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(t){return}}function vK(){try{return new Date().getTimezoneOffset()}catch(t){return}}function yK(t,e){if(!qn)return{};var n,r,i,o=t?sa([],la,e||[]):[],[s,a]=(function(l){for(var c=0;c<yS.length;c++){var[u,h]=yS[c],p=u.exec(l),g=p&&(ro(h)?h(p,l):h);if(g)return g}return["",""]})(qn);return Ot($p({$os:s,$os_version:a,$browser:vS(qn,navigator.vendor),$device:bS(qn),$device_type:(r=qn,i=bS(r),i===tS||i===eS||i==="Kobo"||i==="Kindle Fire"||i===pS?Rl:i===Pl||i===ia||i===Ll||i===Lp?"Console":i===rS?"Wearable":i?br:"Desktop"),$timezone:bI(),$timezone_offset:vK()}),{$current_url:Wl(jn==null?void 0:jn.href,o,ql),$host:jn==null?void 0:jn.host,$pathname:jn==null?void 0:jn.pathname,$raw_user_agent:qn.length>1e3?qn.substring(0,997)+"...":qn,$browser_version:cG(qn,navigator.vendor),$browser_language:pI(),$browser_language_prefix:(n=pI(),typeof n=="string"?n.split("-")[0]:void 0),$screen_height:oe==null?void 0:oe.screen.height,$screen_width:oe==null?void 0:oe.screen.width,$viewport_height:oe==null?void 0:oe.innerHeight,$viewport_width:oe==null?void 0:oe.innerWidth,$lib:"web",$lib_version:Ci.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var lo=At("[Web Vitals]"),_I=9e5;class bK{constructor(e){var n;this.kt=!1,this.P=!1,this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Pt=()=>{clearTimeout(this.Tt),this.N.metrics.length!==0&&(this._instance.capture("$web_vitals",this.N.metrics.reduce(((r,i)=>be({},r,{["$web_vitals_"+i.name+"_event"]:be({},i),["$web_vitals_"+i.name+"_value"]:i.value})),{})),this.N={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.It=r=>{var i,o=(i=this._instance.sessionManager)==null?void 0:i.checkAndGetSessionAndWindowId(!0);if(fe(o))lo.error("Could not read session ID. Dropping metrics!");else{this.N=this.N||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var s=this.Ct();fe(s)||(Je(r==null?void 0:r.name)||Je(r==null?void 0:r.value)?lo.error("Invalid metric received",r):this.Rt&&r.value>=this.Rt?lo.error("Ignoring metric with value >= "+this.Rt,r):(this.N.url!==s&&(this.Pt(),this.Tt=setTimeout(this.Pt,this.flushToCaptureTimeoutMs)),fe(this.N.url)&&(this.N.url=s),this.N.firstMetricTimestamp=fe(this.N.firstMetricTimestamp)?Date.now():this.N.firstMetricTimestamp,r.attribution&&r.attribution.interactionTargetElement&&(r.attribution.interactionTargetElement=void 0),this.N.metrics.push(be({},r,{$current_url:s,$session_id:o.sessionId,$window_id:o.windowId,timestamp:Date.now()})),this.N.metrics.length===this.allowedMetrics.length&&this.Pt()))}},this.rt=()=>{var r,i,o,s,a=ke.__PosthogExtensions__;fe(a)||fe(a.postHogWebVitalsCallbacks)||({onLCP:r,onCLS:i,onFCP:o,onINP:s}=a.postHogWebVitalsCallbacks),r&&i&&o&&s?(this.allowedMetrics.indexOf("LCP")>-1&&r(this.It.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&i(this.It.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&o(this.It.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&s(this.It.bind(this)),this.P=!0):lo.error("web vitals callbacks not loaded - not starting")},this._instance=e,this.kt=!((n=this._instance.persistence)==null||!n.props[NS]),this.startIfEnabled()}get allowedMetrics(){var e,n,r=an(this._instance.config.capture_performance)?(e=this._instance.config.capture_performance)==null?void 0:e.web_vitals_allowed_metrics:void 0;return fe(r)?((n=this._instance.persistence)==null?void 0:n.props[MS])||["CLS","FCP","INP","LCP"]:r}get flushToCaptureTimeoutMs(){return(an(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get Rt(){var e=an(this._instance.config.capture_performance)&&ei(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:_I;return 0<e&&e<=6e4?_I:e}get isEnabled(){var e=jn==null?void 0:jn.protocol;if(e!=="http:"&&e!=="https:")return lo.info("Web Vitals are disabled on non-http/https protocols"),!1;var n=an(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals:Ai(this._instance.config.capture_performance)?this._instance.config.capture_performance:void 0;return Ai(n)?n:this.kt}startIfEnabled(){this.isEnabled&&!this.P&&(lo.info("enabled, starting..."),this.it(this.rt))}onRemoteConfig(e){var n=an(e.capturePerformance)&&!!e.capturePerformance.web_vitals,r=an(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[NS]:n}),this._instance.persistence.register({[MS]:r})),this.kt=n,this.startIfEnabled()}it(e){var n,r;(n=ke.__PosthogExtensions__)!=null&&n.postHogWebVitalsCallbacks&&e(),(r=ke.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"web-vitals",(i=>{i?lo.error("failed to load script",i):e()}))}Ct(){var e=oe?oe.location.href:void 0;if(e){var n=this._instance.config.mask_personal_data_properties,r=this._instance.config.custom_personal_data_properties,i=n?sa([],la,r||[]):[];return Wl(e,i,ql)}lo.error("Could not determine current URL")}}var _K=At("[Heatmaps]");function xI(t){return an(t)&&"clientX"in t&&"clientY"in t&&ei(t.clientX)&&ei(t.clientY)}class xK{constructor(e){var n;this.kt=!1,this.P=!1,this.Ft=null,this.instance=e,this.kt=!((n=this.instance.persistence)==null||!n.props[zp]),this.rageclicks=new tI(e.config.rageclick)}get flushIntervalMilliseconds(){var e=5e3;return an(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(e=this.instance.config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return fe(this.instance.config.capture_heatmaps)?fe(this.instance.config.enable_heatmaps)?this.kt:this.instance.config.enable_heatmaps:this.instance.config.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.P)return;_K.info("starting..."),this.Mt(),this.Ot()}else{var e;clearInterval((e=this.Ft)!==null&&e!==void 0?e:void 0),this.At(),this.getAndClearBuffer()}}onRemoteConfig(e){var n=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[zp]:n}),this.kt=n,this.startIfEnabled()}getAndClearBuffer(){var e=this.N;return this.N=void 0,e}Dt(e){this.jt(e.originalEvent,"deadclick")}Ot(){this.Ft&&clearInterval(this.Ft),this.Ft=(function(e){return(e==null?void 0:e.visibilityState)==="visible"})(me)?setInterval(this.Lt.bind(this),this.flushIntervalMilliseconds):null}Mt(){oe&&me&&(this.Nt=this.Lt.bind(this),Bt(oe,"beforeunload",this.Nt),this.Ut=e=>this.jt(e||(oe==null?void 0:oe.event)),Bt(me,"click",this.Ut,{capture:!0}),this.zt=e=>this.Ht(e||(oe==null?void 0:oe.event)),Bt(me,"mousemove",this.zt,{capture:!0}),this.Bt=new sI(this.instance,oK,this.Dt.bind(this)),this.Bt.startIfEnabled(),this.qt=this.Ot.bind(this),Bt(me,"visibilitychange",this.qt),this.P=!0)}At(){var e;oe&&me&&(this.Nt&&oe.removeEventListener("beforeunload",this.Nt),this.Ut&&me.removeEventListener("click",this.Ut,{capture:!0}),this.zt&&me.removeEventListener("mousemove",this.zt,{capture:!0}),this.qt&&me.removeEventListener("visibilitychange",this.qt),clearTimeout(this.Wt),(e=this.Bt)==null||e.stop(),this.P=!1)}Gt(e,n){var r=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),o=this.instance.scrollManager.scrollElement(),s=(function(a,l,c){for(var u=a;u&&Cd(u)&&!oo(u,"body");){if(u===c)return!1;if(Ue(l,oe==null?void 0:oe.getComputedStyle(u).position))return!0;u=jS(u)}return!1})(WS(e),["fixed","sticky"],o);return{x:e.clientX+(s?0:i),y:e.clientY+(s?0:r),target_fixed:s,type:n}}jt(e,n){var r;if(n===void 0&&(n="click"),!DS(e.target)&&xI(e)){var i=this.Gt(e,n);(r=this.rageclicks)!=null&&r.isRageClick(e.clientX,e.clientY,new Date().getTime())&&this.Vt(be({},i,{type:"rageclick"})),this.Vt(i)}}Ht(e){!DS(e.target)&&xI(e)&&(clearTimeout(this.Wt),this.Wt=setTimeout((()=>{this.Vt(this.Gt(e,"mousemove"))}),500))}Vt(e){if(oe){var n=oe.location.href,r=this.instance.config.mask_personal_data_properties,i=this.instance.config.custom_personal_data_properties,o=r?sa([],la,i||[]):[],s=Wl(n,o,ql);this.N=this.N||{},this.N[s]||(this.N[s]=[]),this.N[s].push(e)}}Lt(){this.N&&!ta(this.N)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class wK{constructor(e){this._instance=e}doPageView(e,n){var r,i=this.Jt(e,n);return this.Kt={pathname:(r=oe==null?void 0:oe.location.pathname)!==null&&r!==void 0?r:"",pageViewId:n,timestamp:e},this._instance.scrollManager.resetContext(),i}doPageLeave(e){var n;return this.Jt(e,(n=this.Kt)==null?void 0:n.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.Kt)==null?void 0:e.pageViewId}}Jt(e,n){var r=this.Kt;if(!r)return{$pageview_id:n};var i={$pageview_id:n,$prev_pageview_id:r.pageViewId},o=this._instance.scrollManager.getContext();if(o&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:s,lastScrollY:a,maxScrollY:l,maxContentHeight:c,lastContentY:u,maxContentY:h}=o;if(!(fe(s)||fe(a)||fe(l)||fe(c)||fe(u)||fe(h))){s=Math.ceil(s),a=Math.ceil(a),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u),h=Math.ceil(h);var p=s<=1?1:ti(a/s,0,1,ye),g=s<=1?1:ti(l/s,0,1,ye),b=c<=1?1:ti(u/c,0,1,ye),m=c<=1?1:ti(h/c,0,1,ye);i=Ot(i,{$prev_pageview_last_scroll:a,$prev_pageview_last_scroll_percentage:p,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:g,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:b,$prev_pageview_max_content:h,$prev_pageview_max_content_percentage:m})}}return r.pathname&&(i.$prev_pageview_pathname=r.pathname),r.timestamp&&(i.$prev_pageview_duration=(e.getTime()-r.timestamp.getTime())/1e3),i}}var _r=Uint8Array,Gn=Uint16Array,ca=Uint32Array,im=new _r([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),om=new _r([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),wI=new _r([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),EI=function(t,e){for(var n=new Gn(31),r=0;r<31;++r)n[r]=e+=1<<t[r-1];var i=new ca(n[30]);for(r=1;r<30;++r)for(var o=n[r];o<n[r+1];++o)i[o]=o-n[r]<<5|r;return[n,i]},SI=EI(im,2),EK=SI[0],sm=SI[1];EK[28]=258,sm[258]=28;for(var II=EI(om,0)[1],CI=new Gn(32768),ft=0;ft<32768;++ft){var Yo=(43690&ft)>>>1|(21845&ft)<<1;Yo=(61680&(Yo=(52428&Yo)>>>2|(13107&Yo)<<2))>>>4|(3855&Yo)<<4,CI[ft]=((65280&Yo)>>>8|(255&Yo)<<8)>>>1}var Gl=function(t,e,n){for(var r=t.length,i=0,o=new Gn(e);i<r;++i)++o[t[i]-1];var s,a=new Gn(e);for(i=0;i<e;++i)a[i]=a[i-1]+o[i-1]<<1;for(s=new Gn(r),i=0;i<r;++i)s[i]=CI[a[t[i]-1]++]>>>15-t[i];return s},Xo=new _r(288);for(ft=0;ft<144;++ft)Xo[ft]=8;for(ft=144;ft<256;++ft)Xo[ft]=9;for(ft=256;ft<280;++ft)Xo[ft]=7;for(ft=280;ft<288;++ft)Xo[ft]=8;var Bd=new _r(32);for(ft=0;ft<32;++ft)Bd[ft]=5;var SK=Gl(Xo,9),IK=Gl(Bd,5),AI=function(t){return(t/8>>0)+(7&t&&1)},OI=function(t,e,n){(n==null||n>t.length)&&(n=t.length);var r=new(t instanceof Gn?Gn:t instanceof ca?ca:_r)(n-e);return r.set(t.subarray(e,n)),r},Ni=function(t,e,n){n<<=7&e;var r=e/8>>0;t[r]|=n,t[r+1]|=n>>>8},Kl=function(t,e,n){n<<=7&e;var r=e/8>>0;t[r]|=n,t[r+1]|=n>>>8,t[r+2]|=n>>>16},am=function(t,e){for(var n=[],r=0;r<t.length;++r)t[r]&&n.push({s:r,f:t[r]});var i=n.length,o=n.slice();if(!i)return[new _r(0),0];if(i==1){var s=new _r(n[0].s+1);return s[n[0].s]=1,[s,1]}n.sort((function(B,G){return B.f-G.f})),n.push({s:-1,f:25001});var a=n[0],l=n[1],c=0,u=1,h=2;for(n[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=i-1;)a=n[n[c].f<n[h].f?c++:h++],l=n[c!=u&&n[c].f<n[h].f?c++:h++],n[u++]={s:-1,f:a.f+l.f,l:a,r:l};var p=o[0].s;for(r=1;r<i;++r)o[r].s>p&&(p=o[r].s);var g=new Gn(p+1),b=lm(n[u-1],g,0);if(b>e){r=0;var m=0,x=b-e,I=1<<x;for(o.sort((function(B,G){return g[G.s]-g[B.s]||B.f-G.f}));r<i;++r){var N=o[r].s;if(!(g[N]>e))break;m+=I-(1<<b-g[N]),g[N]=e}for(m>>>=x;m>0;){var T=o[r].s;g[T]<e?m-=1<<e-g[T]++-1:++r}for(;r>=0&&m;--r){var $=o[r].s;g[$]==e&&(--g[$],++m)}b=e}return[new _r(g),b]},lm=function(t,e,n){return t.s==-1?Math.max(lm(t.l,e,n+1),lm(t.r,e,n+1)):e[t.s]=n},kI=function(t){for(var e=t.length;e&&!t[--e];);for(var n=new Gn(++e),r=0,i=t[0],o=1,s=function(l){n[r++]=l},a=1;a<=e;++a)if(t[a]==i&&a!=e)++o;else{if(!i&&o>2){for(;o>138;o-=138)s(32754);o>2&&(s(o>10?o-11<<5|28690:o-3<<5|12305),o=0)}else if(o>3){for(s(i),--o;o>6;o-=6)s(8304);o>2&&(s(o-3<<5|8208),o=0)}for(;o--;)s(i);o=1,i=t[a]}return[n.subarray(0,r),e]},Yl=function(t,e){for(var n=0,r=0;r<e.length;++r)n+=t[r]*e[r];return n},cm=function(t,e,n){var r=n.length,i=AI(e+2);t[i]=255&r,t[i+1]=r>>>8,t[i+2]=255^t[i],t[i+3]=255^t[i+1];for(var o=0;o<r;++o)t[i+o+4]=n[o];return 8*(i+4+r)},TI=function(t,e,n,r,i,o,s,a,l,c,u){Ni(e,u++,n),++i[256];for(var h=am(i,15),p=h[0],g=h[1],b=am(o,15),m=b[0],x=b[1],I=kI(p),N=I[0],T=I[1],$=kI(m),B=$[0],G=$[1],Z=new Gn(19),Y=0;Y<N.length;++Y)Z[31&N[Y]]++;for(Y=0;Y<B.length;++Y)Z[31&B[Y]]++;for(var F=am(Z,7),V=F[0],U=F[1],W=19;W>4&&!V[wI[W-1]];--W);var A,d,y,S,C=c+5<<3,R=Yl(i,Xo)+Yl(o,Bd)+s,D=Yl(i,p)+Yl(o,m)+s+14+3*W+Yl(Z,V)+(2*Z[16]+3*Z[17]+7*Z[18]);if(C<=R&&C<=D)return cm(e,u,t.subarray(l,l+c));if(Ni(e,u,1+(D<R)),u+=2,D<R){A=Gl(p,g),d=p,y=Gl(m,x),S=m;var L=Gl(V,U);for(Ni(e,u,T-257),Ni(e,u+5,G-1),Ni(e,u+10,W-4),u+=14,Y=0;Y<W;++Y)Ni(e,u+3*Y,V[wI[Y]]);u+=3*W;for(var O=[N,B],f=0;f<2;++f){var v=O[f];for(Y=0;Y<v.length;++Y){var k=31&v[Y];Ni(e,u,L[k]),u+=V[k],k>15&&(Ni(e,u,v[Y]>>>5&127),u+=v[Y]>>>12)}}}else A=SK,d=Xo,y=IK,S=Bd;for(Y=0;Y<a;++Y)if(r[Y]>255){k=r[Y]>>>18&31,Kl(e,u,A[k+257]),u+=d[k+257],k>7&&(Ni(e,u,r[Y]>>>23&31),u+=im[k]);var M=31&r[Y];Kl(e,u,y[M]),u+=S[M],M>3&&(Kl(e,u,r[Y]>>>5&8191),u+=om[M])}else Kl(e,u,A[r[Y]]),u+=d[r[Y]];return Kl(e,u,A[256]),u+d[256]},CK=new ca([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),AK=(function(){for(var t=new ca(256),e=0;e<256;++e){for(var n=e,r=9;--r;)n=(1&n&&3988292384)^n>>>1;t[e]=n}return t})(),OK=function(t,e,n,r,i){return(function(o,s,a,l,c,u){var h=o.length,p=new _r(l+h+5*(1+Math.floor(h/7e3))+c),g=p.subarray(l,p.length-c),b=0;if(!s||h<8)for(var m=0;m<=h;m+=65535){var x=m+65535;x<h?b=cm(g,b,o.subarray(m,x)):(g[m]=u,b=cm(g,b,o.subarray(m,h)))}else{for(var I=CK[s-1],N=I>>>13,T=8191&I,$=(1<<a)-1,B=new Gn(32768),G=new Gn($+1),Z=Math.ceil(a/3),Y=2*Z,F=function(He){return(o[He]^o[He+1]<<Z^o[He+2]<<Y)&$},V=new ca(25e3),U=new Gn(288),W=new Gn(32),A=0,d=0,y=(m=0,0),S=0,C=0;m<h;++m){var R=F(m),D=32767&m,L=G[R];if(B[D]=L,G[R]=D,S<=m){var O=h-m;if((A>7e3||y>24576)&&O>423){b=TI(o,g,0,V,U,W,d,y,C,m-C,b),y=A=d=0,C=m;for(var f=0;f<286;++f)U[f]=0;for(f=0;f<30;++f)W[f]=0}var v=2,k=0,M=T,H=D-L&32767;if(O>2&&R==F(m-H))for(var Q=Math.min(N,O)-1,X=Math.min(32767,m),j=Math.min(258,O);H<=X&&--M&&D!=L;){if(o[m+v]==o[m+v-H]){for(var ee=0;ee<j&&o[m+ee]==o[m+ee-H];++ee);if(ee>v){if(v=ee,k=H,ee>Q)break;var se=Math.min(H,ee-2),re=0;for(f=0;f<se;++f){var ve=m-H+f+32768&32767,xe=ve-B[ve]+32768&32767;xe>re&&(re=xe,L=ve)}}}H+=(D=L)-(L=B[D])+32768&32767}if(k){V[y++]=268435456|sm[v]<<18|II[k];var Pe=31&sm[v],Et=31&II[k];d+=im[Pe]+om[Et],++U[257+Pe],++W[Et],S=m+v,++A}else V[y++]=o[m],++U[o[m]]}}b=TI(o,g,u,V,U,W,d,y,C,m-C,b)}return OI(p,0,l+AI(b)+c)})(t,e.level==null?6:e.level,e.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(t.length)))):12+e.mem,n,r,!0)},um=function(t,e,n){for(;n;++e)t[e]=n,n>>>=8};function kK(t,e){e===void 0&&(e={});var n=(function(){var a=4294967295;return{p:function(l){for(var c=a,u=0;u<l.length;++u)c=AK[255&c^l[u]]^c>>>8;a=c},d:function(){return 4294967295^a}}})(),r=t.length;n.p(t);var i,o=OK(t,e,10+((i=e).filename&&i.filename.length+1||0),8),s=o.length;return(function(a,l){var c=l.filename;if(a[0]=31,a[1]=139,a[2]=8,a[8]=l.level<2?4:l.level==9?2:0,a[9]=3,l.mtime!=0&&um(a,4,Math.floor(new Date(l.mtime||Date.now())/1e3)),c){a[3]=8;for(var u=0;u<=c.length;++u)a[u+10]=c.charCodeAt(u)}})(o,e),um(o,s-8,n.d()),um(o,s-4,r),o}var TK=function(t){var e,n,r,i,o="";for(e=n=0,r=(t=(t+"").replace(/\r\n/g,`
230
230
  `).replace(/\r/g,`
231
- `)).length,i=0;i<r;i++){var s=t.charCodeAt(i),a=null;s<128?n++:a=s>127&&s<2048?String.fromCharCode(s>>6|192,63&s|128):String.fromCharCode(s>>12|224,s>>6&63|128,63&s|128),Pr(a)||(n>e&&(o+=t.substring(e,n)),o+=a,e=n=i+1)}return n>e&&(o+=t.substring(e,t.length)),o},RK=!!Ip||!!Sp,RI="text/plain",Fd=function(t,e,n){var r;n===void 0&&(n=!0);var[i,o]=t.split("?"),s=be({},e),a=(r=o==null?void 0:o.split("&").map((c=>{var u,[h,p]=c.split("="),g=n&&(u=s[h])!==null&&u!==void 0?u:p;return delete s[h],h+"="+g})))!==null&&r!==void 0?r:[],l=qG(s);return l&&a.push(l),i+"?"+a.join("&")},Xl=(t,e)=>JSON.stringify(t,((n,r)=>typeof r=="bigint"?r.toString():r),e),dm=t=>{var{data:e,compression:n}=t;if(e){if(n===Ti.GZipJS){var r=kK((function(l,c){var u=l.length;if(typeof TextEncoder!="undefined")return new TextEncoder().encode(l);for(var h=new _r(l.length+(l.length>>>1)),p=0,g=function(I){h[p++]=I},b=0;b<u;++b){if(p+5>h.length){var m=new _r(p+8+(u-b<<1));m.set(h),h=m}var x=l.charCodeAt(b);x<128||c?g(x):x<2048?(g(192|x>>>6),g(128|63&x)):x>55295&&x<57344?(g(240|(x=65536+(1047552&x)|1023&l.charCodeAt(++b))>>>18),g(128|x>>>12&63),g(128|x>>>6&63),g(128|63&x)):(g(224|x>>>12),g(128|x>>>6&63),g(128|63&x))}return OI(h,0,p)})(Xl(e)),{mtime:0}),i=new Blob([r],{type:RI});return{contentType:RI,body:i,estimatedSize:i.size}}if(n===Ti.Base64){var o=(function(l){var c,u,h,p,g,b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",m=0,x=0,I="",N=[];if(!l)return l;l=TK(l);do c=(g=l.charCodeAt(m++)<<16|l.charCodeAt(m++)<<8|l.charCodeAt(m++))>>18&63,u=g>>12&63,h=g>>6&63,p=63&g,N[x++]=b.charAt(c)+b.charAt(u)+b.charAt(h)+b.charAt(p);while(m<l.length);switch(I=N.join(""),l.length%3){case 1:I=I.slice(0,-2)+"==";break;case 2:I=I.slice(0,-1)+"="}return I})(Xl(e)),s=(l=>"data="+encodeURIComponent(typeof l=="string"?l:Xl(l)))(o);return{contentType:"application/x-www-form-urlencoded",body:s,estimatedSize:new Blob([s]).size}}var a=Xl(e);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},Dd=[];Sp&&Dd.push({transport:"fetch",method:t=>{var e,n,{contentType:r,body:i,estimatedSize:o}=(e=dm(t))!==null&&e!==void 0?e:{},s=new Headers;ut(t.headers,(function(u,h){s.append(h,u)})),r&&s.append("Content-Type",r);var a=t.url,l=null;if(qE){var c=new qE;l={signal:c.signal,timeout:setTimeout((()=>c.abort()),t.timeout)}}Sp(a,be({method:(t==null?void 0:t.method)||"GET",headers:s,keepalive:t.method==="POST"&&(o||0)<52428.8,body:i,signal:(n=l)==null?void 0:n.signal},t.fetchOptions)).then((u=>u.text().then((h=>{var p={statusCode:u.status,text:h};if(u.status===200)try{p.json=JSON.parse(h)}catch(g){ye.error(g)}t.callback==null||t.callback(p)})))).catch((u=>{ye.error(u),t.callback==null||t.callback({statusCode:0,text:u})})).finally((()=>l?clearTimeout(l.timeout):null))}}),Ip&&Dd.push({transport:"XHR",method:t=>{var e,n=new Ip;n.open(t.method||"GET",t.url,!0);var{contentType:r,body:i}=(e=dm(t))!==null&&e!==void 0?e:{};ut(t.headers,(function(o,s){n.setRequestHeader(s,o)})),r&&n.setRequestHeader("Content-Type",r),t.timeout&&(n.timeout=t.timeout),t.disableXHRCredentials||(n.withCredentials=!0),n.onreadystatechange=()=>{if(n.readyState===4){var o={statusCode:n.status,text:n.responseText};if(n.status===200)try{o.json=JSON.parse(n.responseText)}catch(s){}t.callback==null||t.callback(o)}},n.send(i)}}),ur!=null&&ur.sendBeacon&&Dd.push({transport:"sendBeacon",method:t=>{var e=Fd(t.url,{beacon:"1"});try{var n,{contentType:r,body:i}=(n=dm(t))!==null&&n!==void 0?n:{},o=typeof i=="string"?new Blob([i],{type:r}):i;ur.sendBeacon(e,o)}catch(s){}}});var Vd=function(t,e){if(!(function(n){try{new RegExp(n)}catch(r){return!1}return!0})(e))return!1;try{return new RegExp(e).test(t)}catch(n){return!1}};function NI(t,e,n){return Xl({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:n})}var PI={exact:(t,e)=>e.some((n=>t.some((r=>n===r)))),is_not:(t,e)=>e.every((n=>t.every((r=>n!==r)))),regex:(t,e)=>e.some((n=>t.some((r=>Vd(n,r))))),not_regex:(t,e)=>e.every((n=>t.every((r=>!Vd(n,r))))),icontains:(t,e)=>e.map($d).some((n=>t.map($d).some((r=>n.includes(r))))),not_icontains:(t,e)=>e.map($d).every((n=>t.map($d).every((r=>!n.includes(r))))),gt:(t,e)=>e.some((n=>{var r=parseFloat(n);return!isNaN(r)&&t.some((i=>r>parseFloat(i)))})),lt:(t,e)=>e.some((n=>{var r=parseFloat(n);return!isNaN(r)&&t.some((i=>r<parseFloat(i)))}))},$d=t=>t.toLowerCase();function LI(t,e){return!t||Object.entries(t).every((n=>{var[r,i]=n,o=e==null?void 0:e[r];if(fe(o)||Pr(o))return!1;var s=[String(o)],a=PI[i.operator];return!!a&&a(i.values,s)}))}var hm=At("[Error tracking]");class NK{constructor(e){var n,r;this.Yt=[],this.Xt=new hG([new xG,new TG,new EG,new wG,new OG,new AG,new IG,new kG],_G("web:javascript",mG,bG)),this._instance=e,this.Yt=(n=(r=this._instance.persistence)==null?void 0:r.get_property(Up))!==null&&n!==void 0?n:[]}onRemoteConfig(e){var n,r,i,o=(n=(r=e.errorTracking)==null?void 0:r.suppressionRules)!==null&&n!==void 0?n:[],s=(i=e.errorTracking)==null?void 0:i.captureExtensionExceptions;this.Yt=o,this._instance.persistence&&this._instance.persistence.register({[Up]:this.Yt,[RS]:s})}get Qt(){var e,n=!!this._instance.get_property(RS),r=this._instance.config.error_tracking.captureExtensionExceptions;return(e=r!=null?r:n)!==null&&e!==void 0&&e}buildProperties(e,n){return this.Xt.buildFromUnknown(e,{syntheticException:n==null?void 0:n.syntheticException,mechanism:{handled:n==null?void 0:n.handled}})}sendExceptionEvent(e){var n=e.$exception_list;if(this.Zt(n)){if(this.ti(n))return void hm.info("Skipping exception capture because a suppression rule matched");if(!this.Qt&&this.ii(n))return void hm.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ei(n))return void hm.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"})}ti(e){if(e.length===0)return!1;var n=e.reduce(((r,i)=>{var{type:o,value:s}=i;return nn(o)&&o.length>0&&r.$exception_types.push(o),nn(s)&&s.length>0&&r.$exception_values.push(s),r}),{$exception_types:[],$exception_values:[]});return this.Yt.some((r=>{var i=r.values.map((o=>{var s,a=PI[o.operator],l=Ze(o.value)?o.value:[o.value],c=(s=n[o.key])!==null&&s!==void 0?s:[];return l.length>0&&a(l,c)}));return r.type==="OR"?i.some(Boolean):i.every(Boolean)}))}ii(e){return e.flatMap((n=>{var r,i;return(r=(i=n.stacktrace)==null?void 0:i.frames)!==null&&r!==void 0?r:[]})).some((n=>n.filename&&n.filename.startsWith("chrome-extension://")))}ei(e){if(e.length>0){var n,r,i,o,s=(n=(r=e[0].stacktrace)==null?void 0:r.frames)!==null&&n!==void 0?n:[],a=s[s.length-1];return(i=a==null||(o=a.filename)==null?void 0:o.includes("posthog.com/static"))!==null&&i!==void 0&&i}return!1}Zt(e){return!Je(e)&&Ze(e)}}var Lr=At("[FeatureFlags]"),Zl=At("[FeatureFlags]",{debugEnabled:!0}),fm="$active_feature_flags",ua="$override_feature_flags",MI="$feature_flag_payloads",Jl="$override_feature_flag_payloads",BI="$feature_flag_request_id",FI="$feature_flag_evaluated_at",DI=t=>{var e={};for(var[n,r]of xd(t||{}))r&&(e[n]=r);return e},PK=t=>{var e=t.flags;return e?(t.featureFlags=Object.fromEntries(Object.keys(e).map((n=>{var r;return[n,(r=e[n].variant)!==null&&r!==void 0?r:e[n].enabled]}))),t.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter((n=>e[n].enabled)).filter((n=>{var r;return(r=e[n].metadata)==null?void 0:r.payload})).map((n=>{var r;return[n,(r=e[n].metadata)==null?void 0:r.payload]})))):Lr.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t},LK=(function(t){return t.FeatureFlags="feature_flags",t.Recordings="recordings",t})({});class MK{constructor(e){this.ri=!1,this.si=!1,this.ni=!1,this.oi=!1,this.ai=!1,this.li=!1,this.ui=!1,this._instance=e,this.featureFlagEventHandlers=[]}hi(){var e=this._instance.config.evaluation_environments;return e!=null&&e.length?e.filter((n=>{var r=n&&typeof n=="string"&&n.trim().length>0;return r||Lr.error("Invalid evaluation environment found:",n,"Expected non-empty string"),r})):[]}di(){return this.hi().length>0}flags(){if(this._instance.config.__preview_remote_config)this.li=!0;else{var e=!this.vi&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this.ci({disableFlags:e})}}get hasLoadedFlags(){return this.si}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(Hp),n=this._instance.get_property(ua),r=this._instance.get_property(Jl);if(!r&&!n)return e||{};var i=Ot({},e||{}),o=[...new Set([...Object.keys(r||{}),...Object.keys(n||{})])];for(var s of o){var a,l,c=i[s],u=n==null?void 0:n[s],h=fe(u)?(a=c==null?void 0:c.enabled)!==null&&a!==void 0&&a:!!u,p=fe(u)?c.variant:typeof u=="string"?u:void 0,g=r==null?void 0:r[s],b=be({},c,{enabled:h,variant:h?p!=null?p:c==null?void 0:c.variant:void 0});h!==(c==null?void 0:c.enabled)&&(b.original_enabled=c==null?void 0:c.enabled),p!==(c==null?void 0:c.variant)&&(b.original_variant=c==null?void 0:c.variant),g&&(b.metadata=be({},c==null?void 0:c.metadata,{payload:g,original_payload:c==null||(l=c.metadata)==null?void 0:l.payload})),i[s]=b}return this.ri||(Lr.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:i}),this.ri=!0),i}getFlagVariants(){var e=this._instance.get_property(aa),n=this._instance.get_property(ua);if(!n)return e||{};for(var r=Ot({},e),i=Object.keys(n),o=0;o<i.length;o++)r[i[o]]=n[i[o]];return this.ri||(Lr.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:n,finalFlags:r}),this.ri=!0),r}getFlagPayloads(){var e=this._instance.get_property(MI),n=this._instance.get_property(Jl);if(!n)return e||{};for(var r=Ot({},e||{}),i=Object.keys(n),o=0;o<i.length;o++)r[i[o]]=n[i[o]];return this.ri||(Lr.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:n,finalPayloads:r}),this.ri=!0),r}reloadFeatureFlags(){this.oi||this._instance.config.advanced_disable_feature_flags||this.vi||(this.vi=setTimeout((()=>{this.ci()}),5))}fi(){clearTimeout(this.vi),this.vi=void 0}ensureFlagsLoaded(){this.si||this.ni||this.vi||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.oi=e}ci(e){var n;if(this.fi(),!this._instance.O())if(this.ni)this.ai=!0;else{var r=this._instance.config.token,i=this._instance.get_property("$device_id"),o={token:r,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:be({},((n=this._instance.persistence)==null?void 0:n.get_initial_props())||{},this._instance.get_property(Vl)||{}),group_properties:this._instance.get_property(Go)};Pr(i)||fe(i)||(o.$device_id=i),(e!=null&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(o.disable_flags=!0),this.di()&&(o.evaluation_environments=this.hi());var s=this._instance.config.__preview_remote_config,a=s?"/flags/?v=2":"/flags/?v=2&config=true",l=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",c=this._instance.requestRouter.endpointFor("flags",a+l);s&&(o.timezone=bI()),this.ni=!0,this._instance._send_request({method:"POST",url:c,data:o,compression:this._instance.config.disable_compression?void 0:Ti.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:u=>{var h,p,g=!0;if(u.statusCode===200&&(this.ai||(this.$anon_distinct_id=void 0),g=!1),this.ni=!1,this.li||(this.li=!0,this._instance.pi((p=u.json)!==null&&p!==void 0?p:{})),!o.disable_flags||this.ai)if(this.ui=!g,u.json&&(h=u.json.quotaLimited)!=null&&h.includes(LK.FeatureFlags))Lr.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more.");else{var b;o.disable_flags||this.receivedFeatureFlags((b=u.json)!==null&&b!==void 0?b:{},g),this.ai&&(this.ai=!1,this.ci())}}})}}getFeatureFlag(e,n){if(n===void 0&&(n={}),this.si||this.getFlags()&&this.getFlags().length>0){var r=this.getFlagVariants()[e],i=""+r,o=this._instance.get_property(BI)||void 0,s=this._instance.get_property(FI)||void 0,a=this._instance.get_property(Ed)||{};if((n.send_event||!("send_event"in n))&&(!(e in a)||!a[e].includes(i))){var l,c,u,h,p,g,b,m,x;Ze(a[e])?a[e].push(i):a[e]=[i],(l=this._instance.persistence)==null||l.register({[Ed]:a});var I=this.getFeatureFlagDetails(e),N={$feature_flag:e,$feature_flag_response:r,$feature_flag_payload:this.getFeatureFlagPayload(e)||null,$feature_flag_request_id:o,$feature_flag_evaluated_at:s,$feature_flag_bootstrapped_response:((c=this._instance.config.bootstrap)==null||(c=c.featureFlags)==null?void 0:c[e])||null,$feature_flag_bootstrapped_payload:((u=this._instance.config.bootstrap)==null||(u=u.featureFlagPayloads)==null?void 0:u[e])||null,$used_bootstrap_value:!this.ui};fe(I==null||(h=I.metadata)==null?void 0:h.version)||(N.$feature_flag_version=I.metadata.version);var T,$=(p=I==null||(g=I.reason)==null?void 0:g.description)!==null&&p!==void 0?p:I==null||(b=I.reason)==null?void 0:b.code;$&&(N.$feature_flag_reason=$),I!=null&&(m=I.metadata)!=null&&m.id&&(N.$feature_flag_id=I.metadata.id),fe(I==null?void 0:I.original_variant)&&fe(I==null?void 0:I.original_enabled)||(N.$feature_flag_original_response=fe(I.original_variant)?I.original_enabled:I.original_variant),I!=null&&(x=I.metadata)!=null&&x.original_payload&&(N.$feature_flag_original_payload=I==null||(T=I.metadata)==null?void 0:T.original_payload),this._instance.capture("$feature_flag_called",N)}return r}Lr.warn('getFeatureFlag for key "'+e+`" failed. Feature flags didn't load in time.`)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){return this.getFlagPayloads()[e]}getRemoteConfigPayload(e,n){var r=this._instance.config.token,i={distinct_id:this._instance.get_distinct_id(),token:r};this.di()&&(i.evaluation_environments=this.hi()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2&config=true"),data:i,compression:this._instance.config.disable_compression?void 0:Ti.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:o=>{var s,a=(s=o.json)==null?void 0:s.featureFlagPayloads;n((a==null?void 0:a[e])||void 0)}})}isFeatureEnabled(e,n){if(n===void 0&&(n={}),this.si||this.getFlags()&&this.getFlags().length>0){var r=this.getFeatureFlag(e,n);return fe(r)?void 0:!!r}Lr.warn('isFeatureEnabled for key "'+e+`" failed. Feature flags didn't load in time.`)}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((n=>n!==e))}receivedFeatureFlags(e,n){if(this._instance.persistence){this.si=!0;var r=this.getFlagVariants(),i=this.getFlagPayloads(),o=this.getFlagsWithDetails();(function(s,a,l,c,u){l===void 0&&(l={}),c===void 0&&(c={}),u===void 0&&(u={});var h=PK(s),p=h.flags,g=h.featureFlags,b=h.featureFlagPayloads;if(g){var m=s.requestId,x=s.evaluatedAt;if(Ze(g)){Lr.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var I={};if(g)for(var N=0;N<g.length;N++)I[g[N]]=!0;a&&a.register({[fm]:g,[aa]:I})}else{var T=g,$=b,B=p;s.errorsWhileComputingFlags&&(T=be({},l,T),$=be({},c,$),B=be({},u,B)),a&&a.register(be({[fm]:Object.keys(DI(T)),[aa]:T||{},[MI]:$||{},[Hp]:B||{}},m?{[BI]:m}:{},x?{[FI]:x}:{}))}}})(e,this._instance.persistence,r,i,o),this.gi(n)}}override(e,n){n===void 0&&(n=!1),Lr.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:n})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return Lr.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this._instance.persistence.unregister(ua),this._instance.persistence.unregister(Jl),this.gi(),Zl.info("All overrides cleared");if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var n,r=e;if(this.ri=!!((n=r.suppressWarning)!==null&&n!==void 0&&n),"flags"in r){if(r.flags===!1)this._instance.persistence.unregister(ua),Zl.info("Flag overrides cleared");else if(r.flags){if(Ze(r.flags)){for(var i={},o=0;o<r.flags.length;o++)i[r.flags[o]]=!0;this._instance.persistence.register({[ua]:i})}else this._instance.persistence.register({[ua]:r.flags});Zl.info("Flag overrides set",{flags:r.flags})}}return"payloads"in r&&(r.payloads===!1?(this._instance.persistence.unregister(Jl),Zl.info("Payload overrides cleared")):r.payloads&&(this._instance.persistence.register({[Jl]:r.payloads}),Zl.info("Payload overrides set",{payloads:r.payloads}))),void this.gi()}this.gi()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.si){var{flags:n,flagVariants:r}=this.mi();e(n,r)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,n,r){var i,o=(this._instance.get_property(Dl)||[]).find((c=>c.flagKey===e)),s={["$feature_enrollment/"+e]:n},a={$feature_flag:e,$feature_enrollment:n,$set:s};o&&(a.$early_access_feature_name=o.name),r&&(a.$feature_enrollment_stage=r),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(s,!1);var l=be({},this.getFlagVariants(),{[e]:n});(i=this._instance.persistence)==null||i.register({[fm]:Object.keys(DI(l)),[aa]:l}),this.gi()}getEarlyAccessFeatures(e,n,r){n===void 0&&(n=!1);var i=this._instance.get_property(Dl),o=r?"&"+r.map((s=>"stage="+s)).join("&"):"";if(i&&!n)return e(i);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+o),method:"GET",callback:s=>{var a,l;if(s.json){var c=s.json.earlyAccessFeatures;return(a=this._instance.persistence)==null||a.unregister(Dl),(l=this._instance.persistence)==null||l.register({[Dl]:c}),e(c)}}})}mi(){var e=this.getFlags(),n=this.getFlagVariants();return{flags:e.filter((r=>n[r])),flagVariants:Object.keys(n).filter((r=>n[r])).reduce(((r,i)=>(r[i]=n[i],r)),{})}}gi(e){var{flags:n,flagVariants:r}=this.mi();this.featureFlagEventHandlers.forEach((i=>i(n,r,{errorsLoading:e})))}setPersonPropertiesForFlags(e,n){n===void 0&&(n=!0);var r=this._instance.get_property(Vl)||{};this._instance.register({[Vl]:be({},r,e)}),n&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(Vl)}setGroupPropertiesForFlags(e,n){n===void 0&&(n=!0);var r=this._instance.get_property(Go)||{};Object.keys(r).length!==0&&Object.keys(r).forEach((i=>{r[i]=be({},r[i],e[i]),delete e[i]})),this._instance.register({[Go]:be({},r,e)}),n&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var n=this._instance.get_property(Go)||{};this._instance.register({[Go]:be({},n,{[e]:{}})})}else this._instance.unregister(Go)}reset(){this.si=!1,this.ni=!1,this.oi=!1,this.ai=!1,this.li=!1,this.ui=!1,this.$anon_distinct_id=void 0,this.fi(),this.ri=!1}}var BK=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class gm{constructor(e,n){this.R=e,this.props={},this.bi=!1,this.yi=(r=>{var i="";return r.token&&(i=r.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),r.persistence_name?"ph_"+r.persistence_name:"ph_"+i+"_posthog"})(e),this.Y=this.wi(e),this.load(),e.debug&&ye.info("Persistence loaded",e.persistence,be({},this.props)),this.update_config(e,e,n),this.save()}isDisabled(){return!!this.xi}wi(e){BK.indexOf(e.persistence.toLowerCase())===-1&&(ye.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var n=e.persistence.toLowerCase();return n==="localstorage"&&bt.H()?bt:n==="localstorage+cookie"&&Nd.H()?Nd:n==="sessionstorage"&&_n.H()?_n:n==="memory"?rK:n==="cookie"?ni:Nd.H()?Nd:ni}properties(){var e={};return ut(this.props,(function(n,r){if(r===aa&&an(n))for(var i=Object.keys(n),o=0;o<i.length;o++)e["$feature/"+i[o]]=n[i[o]];else a=r,l=!1,(Pr(s=BG)?l:jE&&s.indexOf===jE?s.indexOf(a)!=-1:(ut(s,(function(c){if(l||(l=c===a))return _d})),l))||(e[r]=n);var s,a,l})),e}load(){if(!this.xi){var e=this.Y.W(this.yi);e&&(this.props=Ot({},e))}}save(){this.xi||this.Y.G(this.yi,this.props,this.Ei,this.$i,this.Si,this.R.debug)}remove(){this.Y.V(this.yi,!1),this.Y.V(this.yi,!0)}clear(){this.remove(),this.props={}}register_once(e,n,r){if(an(e)){fe(n)&&(n="None"),this.Ei=fe(r)?this.ki:r;var i=!1;if(ut(e,((o,s)=>{this.props.hasOwnProperty(s)&&this.props[s]!==n||(this.props[s]=o,i=!0)})),i)return this.save(),!0}return!1}register(e,n){if(an(e)){this.Ei=fe(n)?this.ki:n;var r=!1;if(ut(e,((i,o)=>{e.hasOwnProperty(o)&&this.props[o]!==i&&(this.props[o]=i,r=!0)})),r)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.bi){var e=hI(this.R.custom_campaign_params,this.R.mask_personal_data_properties,this.R.custom_personal_data_properties);ta($p(e))||this.register(e),this.bi=!0}}update_search_keyword(){var e;this.register((e=me==null?void 0:me.referrer)?gI(e):{})}update_referrer_info(){var e;this.register_once({$referrer:mI(),$referring_domain:me!=null&&me.referrer&&((e=Od(me.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[Kp]||this.props[Yp]||this.register_once({[Sd]:vI(this.R.mask_personal_data_properties,this.R.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};ut([Yp,Kp],(s=>{var a=this.props[s];a&&ut(a,(function(l,c){e["$initial_"+Cp(c)]=l}))}));var n,r,i=this.props[Sd];if(i){var o=(n=yI(i),r={},ut(n,(function(s,a){r["$initial_"+Cp(a)]=s})),r);Ot(e,o)}return e}safe_merge(e){return ut(this.props,(function(n,r){r in e||(e[r]=n)})),e}update_config(e,n,r){if(this.ki=this.Ei=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!r),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==n.persistence){var i=this.wi(e),o=this.props;this.clear(),this.Y=i,this.props=o,this.save()}}set_disabled(e){this.xi=e,this.xi?this.remove():this.save()}set_cross_subdomain(e){e!==this.$i&&(this.$i=e,this.remove(),this.save())}set_secure(e){e!==this.Si&&(this.Si=e,this.remove(),this.save())}set_event_timer(e,n){var r=this.props[Fl]||{};r[e]=n,this.props[Fl]=r,this.save()}remove_event_timer(e){var n=(this.props[Fl]||{})[e];return fe(n)||(delete this.props[Fl][e],this.save()),n}get_property(e){return this.props[e]}set_property(e,n){this.props[e]=n,this.save()}}var VI=At("[Product Tours]"),pm="ph_product_tours";class FK{constructor(e){this.Pi=null,this.Ti=null,this._instance=e}onRemoteConfig(e){this._instance.persistence&&this._instance.persistence.register({[LS]:!(e==null||!e.productTours)}),this.loadIfEnabled()}loadIfEnabled(){var e,n;this.Pi||(e=this._instance).config.disable_product_tours||(n=e.persistence)==null||!n.get_property(LS)||this.it((()=>this.Ii()))}it(e){var n,r;(n=ke.__PosthogExtensions__)!=null&&n.generateProductTours?e():(r=ke.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"product-tours",(i=>{i?VI.error("Could not load product tours script",i):e()}))}Ii(){var e;!this.Pi&&(e=ke.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.Pi=ke.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,n){if(n===void 0&&(n=!1),!Ze(this.Ti)||n){var r=this._instance.persistence;if(r){var i=r.props[pm];if(Ze(i)&&!n)return this.Ti=i,void e(i,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:o=>{var s=o.statusCode;if(s!==200||!o.json){var a="Product Tours API could not be loaded, status: "+s;return VI.error(a),void e([],{isLoaded:!1,error:a})}var l=Ze(o.json.product_tours)?o.json.product_tours:[];this.Ti=l,r&&r.register({[pm]:l}),e(l,{isLoaded:!0})}})}else e(this.Ti,{isLoaded:!0})}getActiveProductTours(e){Je(this.Pi)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this.Pi.getActiveProductTours(e)}showProductTour(e){var n;(n=this.Pi)==null||n.showTourById(e)}previewTour(e){this.Pi?this.Pi.previewTour(e):this.it((()=>{var n;this.Ii(),(n=this.Pi)==null||n.previewTour(e)}))}dismissProductTour(){var e;(e=this.Pi)==null||e.dismissTour("user_clicked_skip")}nextStep(){var e;(e=this.Pi)==null||e.nextStep()}previousStep(){var e;(e=this.Pi)==null||e.previousStep()}clearCache(){var e;this.Ti=null,(e=this._instance.persistence)==null||e.unregister(pm)}resetTour(e){var n;(n=this.Pi)==null||n.resetTour(e)}resetAllTours(){var e;(e=this.Pi)==null||e.resetAllTours()}cancelPendingTour(e){var n;(n=this.Pi)==null||n.cancelPendingTour(e)}}var Ql=(function(t){return t.Activation="events",t.Cancellation="cancelEvents",t})({});(function(t){return t.Button="button",t.Tab="tab",t.Selector="selector",t})({}),(function(t){return t.TopLeft="top_left",t.TopRight="top_right",t.TopCenter="top_center",t.MiddleLeft="middle_left",t.MiddleRight="middle_right",t.MiddleCenter="middle_center",t.Left="left",t.Center="center",t.Right="right",t.NextToTrigger="next_to_trigger",t})({}),(function(t){return t.Top="top",t.Left="left",t.Right="right",t.Bottom="bottom",t})({});var mm=(function(t){return t.Popover="popover",t.API="api",t.Widget="widget",t.ExternalSurvey="external_survey",t})({});(function(t){return t.Open="open",t.MultipleChoice="multiple_choice",t.SingleChoice="single_choice",t.Rating="rating",t.Link="link",t})({}),(function(t){return t.NextQuestion="next_question",t.End="end",t.ResponseBased="response_based",t.SpecificQuestion="specific_question",t})({}),(function(t){return t.Once="once",t.Recurring="recurring",t.Always="always",t})({});var zd=(function(t){return t.SHOWN="survey shown",t.DISMISSED="survey dismissed",t.SENT="survey sent",t.ABANDONED="survey abandoned",t})({}),$I=(function(t){return t.SURVEY_ID="$survey_id",t.SURVEY_NAME="$survey_name",t.SURVEY_RESPONSE="$survey_response",t.SURVEY_ITERATION="$survey_iteration",t.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",t.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",t.SURVEY_SUBMISSION_ID="$survey_submission_id",t.SURVEY_QUESTIONS="$survey_questions",t.SURVEY_COMPLETED="$survey_completed",t.PRODUCT_TOUR_ID="$product_tour_id",t})({}),zI=(function(t){return t.Popover="popover",t.Inline="inline",t})({}),dt=At("[Surveys]"),UI="seenSurvey_",DK=(t,e)=>{var n="$survey_"+e+"/"+t.id;return t.current_iteration&&t.current_iteration>0&&(n="$survey_"+e+"/"+t.id+"/"+t.current_iteration),n},WI=t=>((e,n)=>{var r=""+e+n.id;return n.current_iteration&&n.current_iteration>0&&(r=""+e+n.id+"_"+n.current_iteration),r})(UI,t),VK=[mm.Popover,mm.Widget,mm.API],$K={ignoreConditions:!1,ignoreDelay:!1,displayType:zI.Popover};class vm{constructor(){this.Ci={},this.Ci={}}on(e,n){return this.Ci[e]||(this.Ci[e]=[]),this.Ci[e].push(n),()=>{this.Ci[e]=this.Ci[e].filter((r=>r!==n))}}emit(e,n){for(var r of this.Ci[e]||[])r(n);for(var i of this.Ci["*"]||[])i(e,n)}}function da(t,e,n){if(Je(t))return!1;switch(n){case"exact":return t===e;case"contains":var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(t);case"regex":try{return new RegExp(e).test(t)}catch(i){return!1}default:return!1}}class zK{constructor(e){this.Ri=new vm,this.Fi=(n,r)=>this.Mi(n,r)&&this.Oi(n,r)&&this.Ai(n,r)&&this.Di(n,r),this.Mi=(n,r)=>r==null||!r.event||(n==null?void 0:n.event)===(r==null?void 0:r.event),this._instance=e,this.ji=new Set,this.Li=new Set}init(){var e;if(!fe((e=this._instance)==null?void 0:e.Ni)){var n;(n=this._instance)==null||n.Ni(((r,i)=>{this.on(r,i)}))}}register(e){var n,r;if(!fe((n=this._instance)==null?void 0:n.Ni)&&(e.forEach((s=>{var a,l;(a=this.Li)==null||a.add(s),(l=s.steps)==null||l.forEach((c=>{var u;(u=this.ji)==null||u.add((c==null?void 0:c.event)||"")}))})),(r=this._instance)!=null&&r.autocapture)){var i,o=new Set;e.forEach((s=>{var a;(a=s.steps)==null||a.forEach((l=>{l!=null&&l.selector&&o.add(l==null?void 0:l.selector)}))})),(i=this._instance)==null||i.autocapture.setElementSelectors(o)}}on(e,n){var r;n!=null&&e.length!=0&&(this.ji.has(e)||this.ji.has(n==null?void 0:n.event))&&this.Li&&((r=this.Li)==null?void 0:r.size)>0&&this.Li.forEach((i=>{this.Ui(n,i)&&this.Ri.emit("actionCaptured",i.name)}))}zi(e){this.onAction("actionCaptured",(n=>e(n)))}Ui(e,n){if((n==null?void 0:n.steps)==null)return!1;for(var r of n.steps)if(this.Fi(e,r))return!0;return!1}onAction(e,n){return this.Ri.on(e,n)}Oi(e,n){if(n!=null&&n.url){var r,i=e==null||(r=e.properties)==null?void 0:r.$current_url;if(!i||typeof i!="string"||!da(i,n.url,n.url_matching||"contains"))return!1}return!0}Ai(e,n){return!!this.Hi(e,n)&&!!this.Bi(e,n)&&!!this.qi(e,n)}Hi(e,n){var r;if(n==null||!n.href)return!0;var i=this.Wi(e);if(i.length>0)return i.some((a=>da(a.href,n.href,n.href_matching||"exact")));var o,s=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!s&&da((o=s.match(/(?::|")href="(.*?)"/))?o[1]:"",n.href,n.href_matching||"exact")}Bi(e,n){var r;if(n==null||!n.text)return!0;var i=this.Wi(e);if(i.length>0)return i.some((c=>da(c.text,n.text,n.text_matching||"exact")||da(c.$el_text,n.text,n.text_matching||"exact")));var o,s,a,l=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!l&&(o=(function(c){for(var u,h=[],p=/(?::|")text="(.*?)"/g;!Je(u=p.exec(c));)h.includes(u[1])||h.push(u[1]);return h})(l),s=n.text,a=n.text_matching||"exact",o.some((c=>da(c,s,a))))}qi(e,n){var r,i;if(n==null||!n.selector)return!0;var o=e==null||(r=e.properties)==null?void 0:r.$element_selectors;if(o!=null&&o.includes(n.selector))return!0;var s=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";if(n.selector_regex&&s)try{return new RegExp(n.selector_regex).test(s)}catch(a){return!1}return!1}Wi(e){var n;return(e==null||(n=e.properties)==null?void 0:n.$elements)==null?[]:e==null?void 0:e.properties.$elements}Di(e,n){return n==null||!n.properties||n.properties.length===0||LI(n.properties.reduce(((r,i)=>{var o=Ze(i.value)?i.value.map(String):i.value!=null?[String(i.value)]:[];return r[i.key]={values:o,operator:i.operator||"exact"},r}),{}),e==null?void 0:e.properties)}}class UK{constructor(e){this._instance=e,this.Gi=new Map,this.Vi=new Map,this.Ji=new Map}Ki(e,n){return!!e&&LI(e.propertyFilters,n==null?void 0:n.properties)}Yi(e,n){var r=new Map;return e.forEach((i=>{var o;(o=i.conditions)==null||(o=o[n])==null||(o=o.values)==null||o.forEach((s=>{if(s!=null&&s.name){var a=r.get(s.name)||[];a.push(i.id),r.set(s.name,a)}}))})),r}Xi(e,n,r){var i=(r===Ql.Activation?this.Gi:this.Vi).get(e),o=[];return this.Qi((s=>{o=s.filter((a=>i==null?void 0:i.includes(a.id)))})),o.filter((s=>{var a,l=(a=s.conditions)==null||(a=a[r])==null||(a=a.values)==null?void 0:a.find((c=>c.name===e));return this.Ki(l,n)}))}register(e){var n;fe((n=this._instance)==null?void 0:n.Ni)||(this.Zi(e),this.te(e))}te(e){var n=e.filter((r=>{var i,o;return((i=r.conditions)==null?void 0:i.actions)&&((o=r.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0}));n.length!==0&&(this.ie==null&&(this.ie=new zK(this._instance),this.ie.init(),this.ie.zi((r=>{this.onAction(r)}))),n.forEach((r=>{var i,o,s,a,l;r.conditions&&(i=r.conditions)!=null&&i.actions&&(o=r.conditions)!=null&&(o=o.actions)!=null&&o.values&&((s=r.conditions)==null||(s=s.actions)==null||(s=s.values)==null?void 0:s.length)>0&&((a=this.ie)==null||a.register(r.conditions.actions.values),(l=r.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach((c=>{if(c&&c.name){var u=this.Ji.get(c.name);u&&u.push(r.id),this.Ji.set(c.name,u||[r.id])}})))})))}Zi(e){var n,r=e.filter((o=>{var s,a;return((s=o.conditions)==null?void 0:s.events)&&((a=o.conditions)==null||(a=a.events)==null||(a=a.values)==null?void 0:a.length)>0})),i=e.filter((o=>{var s,a;return((s=o.conditions)==null?void 0:s.cancelEvents)&&((a=o.conditions)==null||(a=a.cancelEvents)==null||(a=a.values)==null?void 0:a.length)>0}));(r.length!==0||i.length!==0)&&((n=this._instance)==null||n.Ni(((o,s)=>{this.onEvent(o,s)})),this.Gi=this.Yi(e,Ql.Activation),this.Vi=this.Yi(e,Ql.Cancellation))}onEvent(e,n){var r,i=this.ee(),o=this.re(),s=this.se(),a=((r=this._instance)==null||(r=r.persistence)==null?void 0:r.props[o])||[];if(s===e&&n&&a.length>0){var l,c;i.info("event matched, removing item from activated items",{event:e,eventPayload:n,existingActivatedItems:a});var u=(n==null||(l=n.properties)==null?void 0:l.$survey_id)||(n==null||(c=n.properties)==null?void 0:c.$product_tour_id);if(u){var h=a.indexOf(u);h>=0&&(a.splice(h,1),this.ne(a))}}else{if(this.Vi.has(e)){var p=this.Xi(e,n,Ql.Cancellation);p.length>0&&(i.info("cancel event matched, cancelling items",{event:e,itemsToCancel:p.map((b=>b.id))}),p.forEach((b=>{var m=a.indexOf(b.id);m>=0&&a.splice(m,1),this.oe(b.id)})),this.ne(a))}if(this.Gi.has(e)){i.info("event name matched",{event:e,eventPayload:n,items:this.Gi.get(e)});var g=this.Xi(e,n,Ql.Activation);this.ne(a.concat(g.map((b=>b.id))||[]))}}}onAction(e){var n,r=this.re(),i=((n=this._instance)==null||(n=n.persistence)==null?void 0:n.props[r])||[];this.Ji.has(e)&&this.ne(i.concat(this.Ji.get(e)||[]))}ne(e){var n,r=this.ee(),i=this.re(),o=[...new Set(e)].filter((s=>!this.ae(s)));r.info("updating activated items",{activatedItems:o}),(n=this._instance)==null||(n=n.persistence)==null||n.register({[i]:o})}getActivatedIds(){var e,n=this.re(),r=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[n];return r||[]}getEventToItemsMap(){return this.Gi}le(){return this.ie}}class WK extends UK{constructor(e){super(e)}re(){return"$surveys_activated"}se(){return zd.SHOWN}Qi(e){var n;(n=this._instance)==null||n.getSurveys(e)}oe(e){var n;(n=this._instance)==null||n.cancelPendingSurvey(e)}ee(){return dt}ae(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}class HK{constructor(e){this.ue=void 0,this._surveyManager=null,this.he=!1,this.de=!1,this.ve=[],this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){if(!this._instance.config.disable_surveys){var n=e.surveys;if(Je(n))return dt.warn("Flags not loaded yet. Not loading surveys.");var r=Ze(n);this.ue=r?n.length>0:n,dt.info("flags response received, isSurveysEnabled: "+this.ue),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],n=0;n<localStorage.length;n++){var r=localStorage.key(n);(r!=null&&r.startsWith(UI)||r!=null&&r.startsWith("inProgressSurvey_"))&&e.push(r)}e.forEach((i=>localStorage.removeItem(i)))}loadIfEnabled(){if(!this._surveyManager)if(this.de)dt.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)dt.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())dt.info("Not loading surveys in cookieless mode without consent.");else{var e=ke==null?void 0:ke.__PosthogExtensions__;if(e){if(!fe(this.ue)||this._instance.config.advanced_enable_surveys){var n=this.ue||this._instance.config.advanced_enable_surveys;this.de=!0;try{var r=e.generateSurveys;if(r)return void this.ce(r,n);var i=e.loadExternalDependency;if(!i)return void this.fe("PostHog loadExternalDependency extension not found.");i(this._instance,"surveys",(o=>{o||!e.generateSurveys?this.fe("Could not load surveys script",o):this.ce(e.generateSurveys,n)}))}catch(o){throw this.fe("Error initializing surveys",o),o}finally{this.de=!1}}}else dt.error("PostHog Extensions not found.")}}ce(e,n){this._surveyManager=e(this._instance,n),this._surveyEventReceiver=new WK(this._instance),dt.info("Surveys loaded successfully"),this.pe({isLoaded:!0})}fe(e,n){dt.error(e,n),this.pe({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.ve.push(e),this._surveyManager&&this.pe({isLoaded:!0}),()=>{this.ve=this.ve.filter((n=>n!==e))}}getSurveys(e,n){if(n===void 0&&(n=!1),this._instance.config.disable_surveys)return dt.info("Disabled. Not loading surveys."),e([]);var r=this._instance.get_property(jp);if(r&&!n)return e(r,{isLoaded:!0});if(this.he)return e([],{isLoaded:!1,error:"Surveys are already being loaded"});try{this.he=!0,this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._instance.config.token),method:"GET",timeout:this._instance.config.surveys_request_timeout_ms,callback:i=>{var o;this.he=!1;var s=i.statusCode;if(s!==200||!i.json){var a="Surveys API could not be loaded, status: "+s;return dt.error(a),e([],{isLoaded:!1,error:a})}var l,c=i.json.surveys||[],u=c.filter((h=>(function(p){return!(!p.start_date||p.end_date)})(h)&&((function(p){var g;return!((g=p.conditions)==null||(g=g.events)==null||(g=g.values)==null||!g.length)})(h)||(function(p){var g;return!((g=p.conditions)==null||(g=g.actions)==null||(g=g.values)==null||!g.length)})(h))));return u.length>0&&((l=this._surveyEventReceiver)==null||l.register(u)),(o=this._instance.persistence)==null||o.register({[jp]:c}),e(c,{isLoaded:!0})}})}catch(i){throw this.he=!1,i}}pe(e){for(var n of this.ve)try{if(!e.isLoaded)return n([],e);this.getSurveys(n)}catch(r){dt.error("Error in survey callback",r)}}getActiveMatchingSurveys(e,n){if(n===void 0&&(n=!1),!Je(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,n);dt.warn("init was not called")}ge(e){var n=null;return this.getSurveys((r=>{var i;n=(i=r.find((o=>o.id===e)))!==null&&i!==void 0?i:null})),n}_e(e){if(Je(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var n=typeof e=="string"?this.ge(e):e;return n?this._surveyManager.checkSurveyEligibility(n):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(Je(this._surveyManager))return dt.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var n=this._e(e);return{visible:n.eligible,disabledReason:n.reason}}canRenderSurveyAsync(e,n){return Je(this._surveyManager)?(dt.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"})):new Promise((r=>{this.getSurveys((i=>{var o,s=(o=i.find((l=>l.id===e)))!==null&&o!==void 0?o:null;if(s){var a=this._e(s);r({visible:a.eligible,disabledReason:a.reason})}else r({visible:!1,disabledReason:"Survey not found"})}),n)}))}renderSurvey(e,n){var r;if(Je(this._surveyManager))dt.warn("init was not called");else{var i=typeof e=="string"?this.ge(e):e;if(i!=null&&i.id)if(VK.includes(i.type)){var o=me==null?void 0:me.querySelector(n);if(o)return(r=i.appearance)!=null&&r.surveyPopupDelaySeconds?(dt.info("Rendering survey "+i.id+" with delay of "+i.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var s,a;dt.info("Rendering survey "+i.id+" with delay of "+((s=i.appearance)==null?void 0:s.surveyPopupDelaySeconds)+" seconds"),(a=this._surveyManager)==null||a.renderSurvey(i,o),dt.info("Survey "+i.id+" rendered")}),1e3*i.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(i,o);dt.warn("Survey element not found")}else dt.warn("Surveys of type "+i.type+" cannot be rendered in the app");else dt.warn("Survey not found")}}displaySurvey(e,n){var r;if(Je(this._surveyManager))dt.warn("init was not called");else{var i=this.ge(e);if(i){var o=i;if((r=i.appearance)!=null&&r.surveyPopupDelaySeconds&&n.ignoreDelay&&(o=be({},i,{appearance:be({},i.appearance,{surveyPopupDelaySeconds:0})})),n.ignoreConditions===!1){var s=this.canRenderSurvey(i);if(!s.visible)return void dt.warn("Survey is not eligible to be displayed: ",s.disabledReason)}n.displayType!==zI.Inline?this._surveyManager.handlePopoverSurvey(o):this.renderSurvey(o,n.selector)}else dt.warn("Survey not found")}}cancelPendingSurvey(e){Je(this._surveyManager)?dt.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload()}}var ec=At("[Conversations]");class jK{constructor(e){this.me=void 0,this._conversationsManager=null,this.be=!1,this.ye=null,this._instance=e}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var n=e.conversations;Je(n)||(Ai(n)?this.me=n:(this.me=n.enabled,this.ye=n),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.me=void 0,this.ye=null}loadIfEnabled(){if(!this._conversationsManager&&!this.be&&!(this._instance.config.disable_conversations||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=ke==null?void 0:ke.__PosthogExtensions__;if(e&&!fe(this.me)&&this.me)if(this.ye&&this.ye.token){if((function(i){var o;if(!i||i.length===0)return!0;var s=oe==null||(o=oe.location)==null?void 0:o.hostname;return!s||i.some((a=>{var l=(function(u){var h=u.replace(/^https?:\/\//,"");return(h=h.split("/")[0].split("?")[0].split(":")[0])||null})(a);if(!l)return!1;if(l.startsWith("*.")){var c=l.slice(2);return s.endsWith("."+c)||s===c}return s===l}))})(this.ye.domains)){this.be=!0;try{var n=e.initConversations;if(n)return this.we(n),void(this.be=!1);var r=e.loadExternalDependency;if(!r)return void this.xe("PostHog loadExternalDependency extension not found.");r(this._instance,"conversations",(i=>{i||!e.initConversations?this.xe("Could not load conversations script",i):this.we(e.initConversations),this.be=!1}))}catch(i){this.xe("Error initializing conversations",i),this.be=!1}}}else ec.error("Conversations enabled but missing token in remote config.")}}we(e){if(this.ye)try{this._conversationsManager=e(this.ye,this._instance),ec.info("Conversations loaded successfully")}catch(n){this.xe("Error completing conversations initialization",n)}else ec.error("Cannot complete initialization: remote config is null")}xe(e,n){ec.error(e,n),this._conversationsManager=null,this.be=!1}enable(){this._conversationsManager?this._conversationsManager.enable():ec.warn("Conversations not loaded yet.")}disable(){this._conversationsManager&&this._conversationsManager.disable()}isLoaded(){return!Pr(this._conversationsManager)}isEnabled(){return this.me===!0}}var HI=At("[RateLimiter]");class qK{constructor(e){var n,r;this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=i=>{var o=i.text;if(o&&o.length)try{(JSON.parse(o).quota_limited||[]).forEach((s=>{HI.info((s||"events")+" is quota limited."),this.serverLimits[s]=new Date().getTime()+6e4}))}catch(s){return void HI.warn('could not rate limit - continuing. Error: "'+(s==null?void 0:s.message)+'"',{text:o})}},this.instance=e,this.captureEventsPerSecond=((n=e.config.rate_limiting)==null?void 0:n.events_per_second)||10,this.captureEventsBurstLimit=Math.max(((r=e.config.rate_limiting)==null?void 0:r.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}clientRateLimitContext(e){var n,r,i;e===void 0&&(e=!1);var o=new Date().getTime(),s=(n=(r=this.instance.persistence)==null?void 0:r.get_property(Gp))!==null&&n!==void 0?n:{tokens:this.captureEventsBurstLimit,last:o};s.tokens+=(o-s.last)/1e3*this.captureEventsPerSecond,s.last=o,s.tokens>this.captureEventsBurstLimit&&(s.tokens=this.captureEventsBurstLimit);var a=s.tokens<1;return a||e||(s.tokens=Math.max(0,s.tokens-1)),!a||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+this.captureEventsPerSecond+" events per second and "+this.captureEventsBurstLimit+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=a,(i=this.instance.persistence)==null||i.set_property(Gp,s),{isRateLimited:a,remainingTokens:s.tokens}}isServerRateLimited(e){var n=this.serverLimits[e||"events"]||!1;return n!==!1&&new Date().getTime()<n}}var Zo=At("[RemoteConfig]");class GK{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=ke._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Ee(e){var n,r;(n=ke.__PosthogExtensions__)!=null&&n.loadExternalDependency?(r=ke.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):(Zo.error("PostHog Extensions not found. Cannot load remote config."),e())}$e(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:n=>{e(n.json)}})}load(){try{if(this.remoteConfig)return Zo.info("Using preloaded remote config",this.remoteConfig),void this.pi(this.remoteConfig);if(this._instance.O())return void Zo.warn("Remote config is disabled. Falling back to local config.");this.Ee((e=>{if(!e)return Zo.info("No config found after loading remote JS config. Falling back to JSON."),void this.$e((n=>{this.pi(n)}));this.pi(e)}))}catch(e){Zo.error("Error loading remote config",e)}}pi(e){e?this._instance.config.__preview_remote_config?(this._instance.pi(e),e.hasFeatureFlags!==!1&&this._instance.featureFlags.ensureFlagsLoaded()):Zo.info("__preview_remote_config is disabled. Logging config instead",e):Zo.error("Failed to fetch remote config from PostHog.")}}var ym=3e3;class KK{constructor(e,n){this.Se=!0,this.ke=[],this.Pe=ti((n==null?void 0:n.flush_interval_ms)||ym,250,5e3,ye.createLogger("flush interval"),ym),this.Te=e}enqueue(e){this.ke.push(e),this.Ie||this.Ce()}unload(){this.Re();var e=this.ke.length>0?this.Fe():{},n=Object.values(e);[...n.filter((r=>r.url.indexOf("/e")===0)),...n.filter((r=>r.url.indexOf("/e")!==0))].map((r=>{this.Te(be({},r,{transport:"sendBeacon"}))}))}enable(){this.Se=!1,this.Ce()}Ce(){var e=this;this.Se||(this.Ie=setTimeout((()=>{if(this.Re(),this.ke.length>0){var n=this.Fe(),r=function(){var o=n[i],s=new Date().getTime();o.data&&Ze(o.data)&&ut(o.data,(a=>{a.offset=Math.abs(a.timestamp-s),delete a.timestamp})),e.Te(o)};for(var i in n)r()}}),this.Pe))}Re(){clearTimeout(this.Ie),this.Ie=void 0}Fe(){var e={};return ut(this.ke,(n=>{var r,i=n,o=(i?i.batchKey:null)||i.url;fe(e[o])&&(e[o]=be({},i,{data:[]})),(r=e[o].data)==null||r.push(i.data)})),this.ke=[],e}}var YK=["retriesPerformedSoFar"];class XK{constructor(e){this.Me=!1,this.Oe=3e3,this.ke=[],this._instance=e,this.ke=[],this.Ae=!0,!fe(oe)&&"onLine"in oe.navigator&&(this.Ae=oe.navigator.onLine,this.De=()=>{this.Ae=!0,this.Lt()},this.je=()=>{this.Ae=!1},Bt(oe,"online",this.De),Bt(oe,"offline",this.je))}get length(){return this.ke.length}retriableRequest(e){var{retriesPerformedSoFar:n}=e,r=YE(e,YK);ei(n)&&n>0&&(r.url=Fd(r.url,{retry_count:n})),this._instance._send_request(be({},r,{callback:i=>{i.statusCode!==200&&(i.statusCode<400||i.statusCode>=500)&&(n!=null?n:0)<10?this.Le(be({retriesPerformedSoFar:n},r)):r.callback==null||r.callback(i)}}))}Le(e){var n=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=n+1;var r=(function(s){var a=3e3*Math.pow(2,s),l=a/2,c=Math.min(18e5,a),u=(Math.random()-.5)*(c-l);return Math.ceil(c+u)})(n),i=Date.now()+r;this.ke.push({retryAt:i,requestOptions:e});var o="Enqueued failed request for retry in "+r;navigator.onLine||(o+=" (Browser is offline)"),ye.warn(o),this.Me||(this.Me=!0,this.Ne())}Ne(){if(this.Ue&&clearTimeout(this.Ue),this.ke.length===0)return this.Me=!1,void(this.Ue=void 0);this.Ue=setTimeout((()=>{this.Ae&&this.ke.length>0&&this.Lt(),this.Ne()}),this.Oe)}Lt(){var e=Date.now(),n=[],r=this.ke.filter((o=>o.retryAt<e||(n.push(o),!1)));if(this.ke=n,r.length>0)for(var{requestOptions:i}of r)this.retriableRequest(i)}unload(){for(var{requestOptions:e}of(this.Ue&&(clearTimeout(this.Ue),this.Ue=void 0),this.Me=!1,fe(oe)||(this.De&&(oe.removeEventListener("online",this.De),this.De=void 0),this.je&&(oe.removeEventListener("offline",this.je),this.je=void 0)),this.ke))try{this._instance._send_request(be({},e,{transport:"sendBeacon"}))}catch(n){ye.error(n)}this.ke=[]}}class ZK{constructor(e){this.ze=()=>{var n,r,i,o;this.He||(this.He={});var s=this.scrollElement(),a=this.scrollY(),l=s?Math.max(0,s.scrollHeight-s.clientHeight):0,c=a+((s==null?void 0:s.clientHeight)||0),u=(s==null?void 0:s.scrollHeight)||0;this.He.lastScrollY=Math.ceil(a),this.He.maxScrollY=Math.max(a,(n=this.He.maxScrollY)!==null&&n!==void 0?n:0),this.He.maxScrollHeight=Math.max(l,(r=this.He.maxScrollHeight)!==null&&r!==void 0?r:0),this.He.lastContentY=c,this.He.maxContentY=Math.max(c,(i=this.He.maxContentY)!==null&&i!==void 0?i:0),this.He.maxContentHeight=Math.max(u,(o=this.He.maxContentHeight)!==null&&o!==void 0?o:0)},this._instance=e}getContext(){return this.He}resetContext(){var e=this.He;return setTimeout(this.ze,0),e}startMeasuringScrollPosition(){Bt(oe,"scroll",this.ze,{capture:!0}),Bt(oe,"scrollend",this.ze,{capture:!0}),Bt(oe,"resize",this.ze)}scrollElement(){if(!this._instance.config.scroll_root_selector)return oe==null?void 0:oe.document.documentElement;var e=Ze(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var n of e){var r=oe==null?void 0:oe.document.querySelector(n);if(r)return r}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return oe&&(oe.scrollY||oe.pageYOffset||oe.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return oe&&(oe.scrollX||oe.pageXOffset||oe.document.documentElement.scrollLeft)||0}}var JK=t=>vI(t==null?void 0:t.config.mask_personal_data_properties,t==null?void 0:t.config.custom_personal_data_properties);class jI{constructor(e,n,r,i){this.Be=o=>{var s=this.qe();if(!s||s.sessionId!==o){var a={sessionId:o,props:this.We(this._instance)};this.Ge.register({[qp]:a})}},this._instance=e,this.Ve=n,this.Ge=r,this.We=i||JK,this.Ve.onSessionId(this.Be)}qe(){return this.Ge.props[qp]}getSetOnceProps(){var e,n=(e=this.qe())==null?void 0:e.props;return n?"r"in n?yI(n):{$referring_domain:n.referringDomain,$pathname:n.initialPathName,utm_source:n.utm_source,utm_campaign:n.utm_campaign,utm_medium:n.utm_medium,utm_content:n.utm_content,utm_term:n.utm_term}:{}}getSessionProps(){var e={};return ut($p(this.getSetOnceProps()),((n,r)=>{r==="$current_url"&&(r="url"),e["$session_entry_"+Cp(r)]=n})),e}}var bm=At("[SessionId]");class qI{on(e,n){return this.Je.on(e,n)}constructor(e,n,r){var i;if(this.Ke=[],this.Ye=void 0,this.Je=new vm,this.Xe=(u,h)=>Math.abs(u-h)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode==="always")throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.R=e.config,this.Ge=e.persistence,this.Qe=void 0,this.Ze=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.tr=n||so,this.ir=r||so;var o=this.R.persistence_name||this.R.token,s=this.R.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*ti(s,60,36e3,bm.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.er(),this.rr="ph_"+o+"_window_id",this.sr="ph_"+o+"_primary_window_exists",this.nr()){var a=_n.W(this.rr),l=_n.W(this.sr);a&&!l?this.Qe=a:_n.V(this.rr),_n.G(this.sr,!0)}if((i=this.R.bootstrap)!=null&&i.sessionID)try{var c=(u=>{var h=u.replace(/-/g,"");if(h.length!==32)throw new Error("Not a valid UUID");if(h[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(h.substring(0,12),16)})(this.R.bootstrap.sessionID);this.ar(this.R.bootstrap.sessionID,new Date().getTime(),c)}catch(u){bm.error("Invalid sessionID in bootstrap",u)}this.lr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return fe(this.Ke)&&(this.Ke=[]),this.Ke.push(e),this.Ze&&e(this.Ze,this.Qe),()=>{this.Ke=this.Ke.filter((n=>n!==e))}}nr(){return this.R.persistence!=="memory"&&!this.Ge.xi&&_n.H()}ur(e){e!==this.Qe&&(this.Qe=e,this.nr()&&_n.G(this.rr,e))}hr(){return this.Qe?this.Qe:this.nr()?_n.W(this.rr):null}ar(e,n,r){e===this.Ze&&n===this._sessionActivityTimestamp&&r===this._sessionStartTimestamp||(this._sessionStartTimestamp=r,this._sessionActivityTimestamp=n,this.Ze=e,this.Ge.register({[wd]:[n,e,r]}))}dr(){var e=this.Ge.props[wd];return Ze(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.ar(null,null,null)}destroy(){clearTimeout(this.vr),this.vr=void 0,this.Ye&&oe&&(oe.removeEventListener("beforeunload",this.Ye,{capture:!1}),this.Ye=void 0),this.Ke=[]}lr(){this.Ye=()=>{this.nr()&&_n.V(this.sr)},Bt(oe,"beforeunload",this.Ye,{capture:!1})}checkAndGetSessionAndWindowId(e,n){if(e===void 0&&(e=!1),n===void 0&&(n=null),this.R.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var r=n||new Date().getTime(),[i,o,s]=this.dr(),a=this.hr(),l=ei(s)&&s>0&&Math.abs(r-s)>864e5,c=!1,u=!o,h=!u&&!e&&this.Xe(r,i);u||h||l?(o=this.tr(),a=this.ir(),bm.info("new session ID generated",{sessionId:o,windowId:a,changeReason:{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:l}}),s=r,c=!0):a||(a=this.ir(),c=!0);var p=i===0||!e||l?r:i,g=s===0?new Date().getTime():s;return this.ur(a),this.ar(o,p,g),e||this.er(),c&&this.Ke.forEach((b=>b(o,a,c?{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:l}:void 0))),{sessionId:o,windowId:a,sessionStartTimestamp:g,changeReason:c?{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:i}}er(){clearTimeout(this.vr),this.vr=setTimeout((()=>{var[e]=this.dr();if(this.Xe(new Date().getTime(),e)){var n=this.Ze;this.resetSessionId(),this.Je.emit("forcedIdleReset",{idleSessionId:n})}}),1.1*this.sessionTimeoutMs)}}var QK=["$set_once","$set"],co=At("[SiteApps]");class eY{constructor(e){this._instance=e,this.cr=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}pr(e,n){if(n){var r=this.globalsForEvent(n);this.cr.push(r),this.cr.length>1e3&&(this.cr=this.cr.slice(10))}}get siteAppLoaders(){var e;return(e=ke._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance.Ni(this.pr.bind(this));this.gr=()=>{e(),this.cr=[],this.gr=void 0}}}globalsForEvent(e){var n,r,i,o,s,a,l;if(!e)throw new Error("Event payload is required");var c={},u=this._instance.get_property("$groups")||[],h=this._instance.get_property("$stored_group_properties")||{};for(var[p,g]of Object.entries(h))c[p]={id:u[p],type:p,properties:g};var{$set_once:b,$set:m}=e;return{event:be({},YE(e,QK),{properties:be({},e.properties,m?{$set:be({},(n=(r=e.properties)==null?void 0:r.$set)!==null&&n!==void 0?n:{},m)}:{},b?{$set_once:be({},(i=(o=e.properties)==null?void 0:o.$set_once)!==null&&i!==void 0?i:{},b)}:{}),elements_chain:(s=(a=e.properties)==null?void 0:a.$elements_chain)!==null&&s!==void 0?s:"",distinct_id:(l=e.properties)==null?void 0:l.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:c}}setupSiteApp(e){var n=this.apps[e.id],r=()=>{var a;!n.errored&&this.cr.length&&(co.info("Processing "+this.cr.length+" events for site app with id "+e.id),this.cr.forEach((l=>n.processEvent==null?void 0:n.processEvent(l))),n.processedBuffer=!0),Object.values(this.apps).every((l=>l.processedBuffer||l.errored))&&((a=this.gr)==null||a.call(this))},i=!1,o=a=>{n.errored=!a,n.loaded=!0,co.info("Site app with id "+e.id+" "+(a?"loaded":"errored")),i&&r()};try{var{processEvent:s}=e.init({posthog:this._instance,callback:a=>{o(a)}});s&&(n.processEvent=s),i=!0}catch(a){co.error("Error while initializing PostHog app with config id "+e.id,a),o(!1)}if(i&&n.loaded)try{r()}catch(a){co.error("Error while processing buffered events PostHog app with config id "+e.id,a),n.errored=!0}}_r(){var e=this.siteAppLoaders||[];for(var n of e)this.apps[n.id]={id:n.id,loaded:!1,errored:!1,processedBuffer:!1};for(var r of e)this.setupSiteApp(r)}mr(e){if(Object.keys(this.apps).length!==0){var n=this.globalsForEvent(e);for(var r of Object.values(this.apps))try{r.processEvent==null||r.processEvent(n)}catch(i){co.error("Error while processing event "+e.event+" for site app "+r.id,i)}}}onRemoteConfig(e){var n,r,i,o=this;if((n=this.siteAppLoaders)!=null&&n.length)return this.isEnabled?(this._r(),void this._instance.on("eventCaptured",(c=>this.mr(c)))):void co.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((r=this.gr)==null||r.call(this),(i=e.siteApps)!=null&&i.length)if(this.isEnabled){var s=function(c){var u;ke["__$$ph_site_app_"+c]=o._instance,(u=ke.__PosthogExtensions__)==null||u.loadSiteApp==null||u.loadSiteApp(o._instance,l,(h=>{if(h)return co.error("Error while initializing PostHog app with config id "+c,h)}))};for(var{id:a,url:l}of e.siteApps)s(a)}else co.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var GI=function(t,e){if(!t)return!1;var n=t.userAgent;if(n&&XE(n,e))return!0;try{var r=t==null?void 0:t.userAgentData;if(r!=null&&r.brands&&r.brands.some((i=>XE(i==null?void 0:i.brand,e))))return!0}catch(i){}return!!t.webdriver},tc=(function(t){return t.US="us",t.EU="eu",t.CUSTOM="custom",t})({}),KI="i.posthog.com";class tY{constructor(e){this.br={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,n=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return n||(n=this.apiHost.replace("."+KI,".posthog.com")),n==="https://app.posthog.com"?"https://us.posthog.com":n}get region(){return this.br[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.br[this.apiHost]=tc.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.br[this.apiHost]=tc.EU:this.br[this.apiHost]=tc.CUSTOM),this.br[this.apiHost]}endpointFor(e,n){if(n===void 0&&(n=""),n&&(n=n[0]==="/"?n:"/"+n),e==="ui")return this.uiHost+n;if(e==="flags")return this.flagsApiHost+n;if(this.region===tc.CUSTOM)return this.apiHost+n;var r=KI+n;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}}var nY={icontains:(t,e)=>!!oe&&e.href.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>!!oe&&e.href.toLowerCase().indexOf(t.toLowerCase())===-1,regex:(t,e)=>!!oe&&Vd(e.href,t),not_regex:(t,e)=>!!oe&&!Vd(e.href,t),exact:(t,e)=>e.href===t,is_not:(t,e)=>e.href!==t};class Tn{constructor(e){var n=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(r){r===void 0&&(r=!1),n.getWebExperiments((i=>{Tn.yr("retrieved web experiments from the server"),n.wr=new Map,i.forEach((o=>{if(o.feature_flag_key){var s;n.wr&&(Tn.yr("setting flag key ",o.feature_flag_key," to web experiment ",o),(s=n.wr)==null||s.set(o.feature_flag_key,o));var a=n._instance.getFeatureFlag(o.feature_flag_key);nn(a)&&o.variants[a]&&n.Er(o.name,a,o.variants[a].transforms)}else if(o.variants)for(var l in o.variants){var c=o.variants[l];Tn.$r(c)&&n.Er(o.name,l,c.transforms)}}))}),r)},this._instance=e,this._instance.onFeatureFlags((r=>{this.onFeatureFlags(r)}))}onFeatureFlags(e){if(this._is_bot())Tn.yr("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(Je(this.wr))return this.wr=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Tn.yr("applying feature flags",e),e.forEach((n=>{var r;if(this.wr&&(r=this.wr)!=null&&r.has(n)){var i,o=this._instance.getFeatureFlag(n),s=(i=this.wr)==null?void 0:i.get(n);o&&s!=null&&s.variants[o]&&this.Er(s.name,o,s.variants[o].transforms)}}))}}previewWebExperiment(){var e=Tn.getWindowLocation();if(e!=null&&e.search){var n=kd(e==null?void 0:e.search,"__experiment_id"),r=kd(e==null?void 0:e.search,"__experiment_variant");n&&r&&(Tn.yr("previewing web experiments "+n+" && "+r),this.getWebExperiments((i=>{this.Sr(parseInt(n),r,i)}),!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,n,r){if(this._instance.config.disable_web_experiments&&!r)return e([]);var i=this._instance.get_property("$web_experiments");if(i&&!n)return e(i);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._instance.config.token),method:"GET",callback:o=>{if(o.statusCode!==200||!o.json)return e([]);var s=o.json.experiments||[];return e(s)}})}Sr(e,n,r){var i=r.filter((o=>o.id===e));i&&i.length>0&&(Tn.yr("Previewing web experiment ["+i[0].name+"] with variant ["+n+"]"),this.Er(i[0].name,n,i[0].variants[n].transforms))}static $r(e){return!Je(e.conditions)&&Tn.kr(e)&&Tn.Pr(e)}static kr(e){var n;if(Je(e.conditions)||Je((n=e.conditions)==null?void 0:n.url))return!0;var r,i,o,s=Tn.getWindowLocation();return!!s&&((r=e.conditions)==null||!r.url||nY[(i=(o=e.conditions)==null?void 0:o.urlMatchType)!==null&&i!==void 0?i:"icontains"](e.conditions.url,s))}static getWindowLocation(){return oe==null?void 0:oe.location}static Pr(e){var n;if(Je(e.conditions)||Je((n=e.conditions)==null?void 0:n.utm))return!0;var r=hI();if(r.utm_source){var i,o,s,a,l,c,u,h,p=(i=e.conditions)==null||(i=i.utm)==null||!i.utm_campaign||((o=e.conditions)==null||(o=o.utm)==null?void 0:o.utm_campaign)==r.utm_campaign,g=(s=e.conditions)==null||(s=s.utm)==null||!s.utm_source||((a=e.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==r.utm_source,b=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_medium)==r.utm_medium,m=(u=e.conditions)==null||(u=u.utm)==null||!u.utm_term||((h=e.conditions)==null||(h=h.utm)==null?void 0:h.utm_term)==r.utm_term;return p&&b&&m&&g}return!1}static yr(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];ye.info("[WebExperiments] "+e,r)}Er(e,n,r){this._is_bot()?Tn.yr("Refusing to render web experiment since the viewer is a likely bot"):n!=="control"?r.forEach((i=>{if(i.selector){var o;Tn.yr("applying transform of variant "+n+" for experiment "+e+" ",i);var s=(o=document)==null?void 0:o.querySelectorAll(i.selector);s==null||s.forEach((a=>{var l=a;i.html&&(l.innerHTML=i.html),i.css&&l.setAttribute("style",i.css)}))}})):Tn.yr("Control variants leave the page unmodified.")}_is_bot(){return ur&&this._instance?GI(ur,this._instance.config.custom_blocked_useragents):void 0}}var rY=At("[PostHog ExternalIntegrations]"),iY={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class oY{constructor(e){this._instance=e}it(e,n){var r;(r=ke.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,e,(i=>{if(i)return rY.error("failed to load script",i);n()}))}startIfEnabledOrStop(){var e=this,n=function(s){var a,l,c;!i||(a=ke.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[s]||e.it(iY[s],(()=>{var u;(u=ke.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[s])==null||u.start(e._instance)})),!i&&(l=ke.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[s]&&((c=ke.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[s])==null||c.stop())};for(var[r,i]of Object.entries((o=this._instance.config.integrations)!==null&&o!==void 0?o:{})){var o;n(r)}}}var _m="[SessionRecording]",nc=At(_m);class YI{get started(){var e;return!((e=this.Tr)==null||!e.isStarted)}get status(){return this.Tr?this.Tr.status:this.Ir&&!this.Cr?"disabled":"lazy_loading"}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.Ir=!1,this.Rr=void 0,this._instance=e,!this._instance.sessionManager)throw nc.error("started without valid sessionManager"),new Error(_m+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(_m+' cannot be used with cookieless_mode="always"')}get Cr(){var e,n=!((e=this._instance.get_property(Wp))==null||!e.enabled),r=!this._instance.config.disable_session_recording,i=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return oe&&n&&r&&!i}startIfEnabledOrStop(e){var n;if(!this.Cr||(n=this.Tr)==null||!n.isStarted){var r=!fe(Object.assign)&&!fe(Array.from);this.Cr&&r?(this.Fr(e),nc.info("starting")):this.stopRecording()}}Fr(e){var n,r,i;this.Cr&&(ke!=null&&(n=ke.__PosthogExtensions__)!=null&&(n=n.rrweb)!=null&&n.record&&(r=ke.__PosthogExtensions__)!=null&&r.initSessionRecording?this.Mr(e):(i=ke.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,this.Or,(o=>{if(o)return nc.error("could not load recorder",o);this.Mr(e)})))}stopRecording(){var e,n;(e=this.Rr)==null||e.call(this),this.Rr=void 0,(n=this.Tr)==null||n.stop()}Ar(){var e;(e=this._instance.persistence)==null||e.unregister(BS)}Dr(e){if(this._instance.persistence){var n,r,i=this._instance.persistence,o=()=>{var s=e.sessionRecording===!1?void 0:e.sessionRecording,a=s==null?void 0:s.sampleRate,l=Je(a)?null:parseFloat(a);Je(l)&&this.Ar();var c=s==null?void 0:s.minimumDurationMilliseconds;i.register({[Wp]:be({enabled:!!s},s,{networkPayloadCapture:be({capturePerformance:e.capturePerformance},s==null?void 0:s.networkPayloadCapture),canvasRecording:{enabled:s==null?void 0:s.recordCanvas,fps:s==null?void 0:s.canvasFps,quality:s==null?void 0:s.canvasQuality},sampleRate:l,minimumDurationMilliseconds:fe(c)?null:c,endpoint:s==null?void 0:s.endpoint,triggerMatchType:s==null?void 0:s.triggerMatchType,masking:s==null?void 0:s.masking,urlTriggers:s==null?void 0:s.urlTriggers})})};o(),(n=this.Rr)==null||n.call(this),this.Rr=(r=this._instance.sessionManager)==null?void 0:r.onSessionId(o)}}onRemoteConfig(e){"sessionRecording"in e?e.sessionRecording!==!1?(this.Dr(e),this.Ir=!0,this.startIfEnabledOrStop()):this.Ir=!0:nc.info("skipping remote config with no sessionRecording",e)}log(e,n){var r;n===void 0&&(n="log"),(r=this.Tr)!=null&&r.log?this.Tr.log(e,n):nc.warn("log called before recorder was ready")}get Or(){var e,n,r=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(Wp);return(r==null||(n=r.scriptConfig)==null?void 0:n.script)||"lazy-recorder"}Mr(e){var n,r;if((n=ke.__PosthogExtensions__)==null||!n.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.Tr||(this.Tr=(r=ke.__PosthogExtensions__)==null?void 0:r.initSessionRecording(this._instance),this.Tr._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.Tr.start(e)}onRRwebEmit(e){var n;(n=this.Tr)==null||n.onRRwebEmit==null||n.onRRwebEmit(e)}overrideLinkedFlag(){var e,n;this.Tr||(n=this._instance.persistence)==null||n.register({$replay_override_linked_flag:!0}),(e=this.Tr)==null||e.overrideLinkedFlag()}overrideSampling(){var e,n;this.Tr||(n=this._instance.persistence)==null||n.register({$replay_override_sampling:!0}),(e=this.Tr)==null||e.overrideSampling()}overrideTrigger(e){var n,r;this.Tr||(r=this._instance.persistence)==null||r.register({[e==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(n=this.Tr)==null||n.overrideTrigger(e)}get sdkDebugProperties(){var e;return((e=this.Tr)==null?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,n){var r;return!((r=this.Tr)==null||!r.tryAddCustomEvent(e,n))}}var rc={},xm=()=>{},ha="posthog",XI=!RK&&(qn==null?void 0:qn.indexOf("MSIE"))===-1&&(qn==null?void 0:qn.indexOf("Mozilla"))===-1,ZI=t=>{var e;return be({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:MG(me==null?void 0:me.location),persistence:"localStorage+cookie",persistence_name:"",loaded:xm,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:t!=null?t:"unset",__preview_deferred_init_extensions:!1,debug:jn&&nn(jn==null?void 0:jn.search)&&jn.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!0,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(oe==null||(e=oe.location)==null?void 0:e.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:n=>{var r="Bad HTTP status: "+n.statusCode+" "+n.text;ye.error(r)},get_device_id:n=>n,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:ym},error_tracking:{},_onCapture:xm,__preview_eager_load_replay:!1},(n=>({rageclick:!(n&&n>="2025-11-30")||{content_ignorelist:!0},capture_pageview:!(n&&n>="2025-05-24")||"history_change",session_recording:n&&n>="2025-11-30"?{strictMinimumDuration:!0}:{}}))(t))},JI=t=>{var e={};fe(t.process_person)||(e.person_profiles=t.process_person),fe(t.xhr_headers)||(e.request_headers=t.xhr_headers),fe(t.cookie_name)||(e.persistence_name=t.cookie_name),fe(t.disable_cookie)||(e.disable_persistence=t.disable_cookie),fe(t.store_google)||(e.save_campaign_params=t.store_google),fe(t.verbose)||(e.debug=t.verbose);var n=Ot({},e,t);return Ze(t.property_blacklist)&&(fe(t.property_denylist)?n.property_denylist=t.property_blacklist:Ze(t.property_denylist)?n.property_denylist=[...t.property_blacklist,...t.property_denylist]:ye.error("Invalid value for property_denylist config: "+t.property_denylist)),n};class sY{constructor(){this.__forceAllowLocalhost=!1}get jr(){return this.__forceAllowLocalhost}set jr(e){ye.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class Ud{get decideEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){this.webPerformance=new sY,this.Lr=!1,this.version=Ci.LIB_VERSION,this.Nr=new vm,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=ZI(),this.SentryIntegration=uK,this.sentryIntegration=e=>(function(n,r){var i=cI(n,r);return{name:lI,processEvent:o=>i(o)}})(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Ur=!1,this.zr=null,this.Hr=null,this.Br=null,this.featureFlags=new MK(this),this.toolbar=new hK(this),this.scrollManager=new ZK(this),this.pageViewManager=new wK(this),this.surveys=new HK(this),this.conversations=new jK(this),this.experiments=new Tn(this),this.exceptions=new NK(this),this.rateLimiter=new qK(this),this.requestRouter=new tY(this),this.consent=new iK(this),this.externalIntegrations=new oY(this),this.people={set:(e,n,r)=>{var i=nn(e)?{[e]:n}:e;this.setPersonProperties(i),r==null||r({})},set_once:(e,n,r)=>{var i=nn(e)?{[e]:n}:e;this.setPersonProperties(void 0,i),r==null||r({})}},this.on("eventCaptured",(e=>ye.info('send "'+(e==null?void 0:e.event)+'"',e)))}init(e,n,r){if(r&&r!==ha){var i,o=(i=rc[r])!==null&&i!==void 0?i:new Ud;return o._init(e,n,r),rc[r]=o,rc[ha][r]=o,o}return this._init(e,n,r)}_init(e,n,r){var i;if(n===void 0&&(n={}),fe(e)||Ap(e))return ye.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},n.debug=this.qr(n.debug),this.Wr=n,this.Gr=[],n.person_profiles&&(this.Hr=n.person_profiles),this.set_config(Ot({},ZI(n.defaults),JI(n),{name:r,token:e})),this.config.on_xhr_error&&ye.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=n.disable_compression?void 0:Ti.GZipJS;var o=this.Vr();this.persistence=new gm(this.config,o),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new gm(be({},this.config,{persistence:"sessionStorage"}),o);var s=be({},this.persistence.props),a=be({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Jr=new KK((N=>this.Kr(N)),this.config.request_queue_config),this.Yr=new XK(this),this.__request_queue=[];var l=this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut();if(l||(this.sessionManager=new qI(this),this.sessionPropsManager=new jI(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(ye.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.Xr(l)}),0)):(ye.info("Initializing extensions synchronously"),this.Xr(l)),Ci.DEBUG=Ci.DEBUG||this.config.debug,Ci.DEBUG&&ye.info("Starting in debug mode",{this:this,config:n,thisC:be({},this.config),p:s,s:a}),((i=n.bootstrap)==null?void 0:i.distinctID)!==void 0){var c,u,h=this.config.get_device_id(so()),p=(c=n.bootstrap)!=null&&c.isIdentifiedID?h:n.bootstrap.distinctID;this.persistence.set_property(ki,(u=n.bootstrap)!=null&&u.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:n.bootstrap.distinctID,$device_id:p})}if(this.Qr()){var g,b,m=Object.keys(((g=n.bootstrap)==null?void 0:g.featureFlags)||{}).filter((N=>{var T;return!((T=n.bootstrap)==null||(T=T.featureFlags)==null||!T[N])})).reduce(((N,T)=>{var $;return N[T]=(($=n.bootstrap)==null||($=$.featureFlags)==null?void 0:$[T])||!1,N}),{}),x=Object.keys(((b=n.bootstrap)==null?void 0:b.featureFlagPayloads)||{}).filter((N=>m[N])).reduce(((N,T)=>{var $,B;return($=n.bootstrap)!=null&&($=$.featureFlagPayloads)!=null&&$[T]&&(N[T]=(B=n.bootstrap)==null||(B=B.featureFlagPayloads)==null?void 0:B[T]),N}),{});this.featureFlags.receivedFeatureFlags({featureFlags:m,featureFlagPayloads:x})}if(l)this.register_once({distinct_id:$l,$device_id:null},"");else if(!this.get_distinct_id()){var I=this.config.get_device_id(so());this.register_once({distinct_id:I,$device_id:I},""),this.persistence.set_property(ki,"anonymous")}return Bt(oe,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),n.segment?cK(this,(()=>this.Zr())):this.Zr(),ro(this.config._onCapture)&&this.config._onCapture!==xm&&(ye.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(N=>this.config._onCapture(N.event,N)))),this.config.ip&&ye.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this}Xr(e){var n=performance.now();this.historyAutocapture=new lK(this),this.historyAutocapture.startIfEnabled();var r=[];r.push((()=>{new gK(this).startIfEnabledOrStop()})),r.push((()=>{var i;this.siteApps=new eY(this),(i=this.siteApps)==null||i.init()})),e||r.push((()=>{this.sessionRecording=new YI(this),this.sessionRecording.startIfEnabledOrStop()})),this.config.disable_scroll_properties||r.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),r.push((()=>{this.autocapture=new XG(this),this.autocapture.startIfEnabled()})),r.push((()=>{this.surveys.loadIfEnabled()})),r.push((()=>{this.conversations.loadIfEnabled()})),r.push((()=>{this.productTours=new FK(this),this.productTours.loadIfEnabled()})),r.push((()=>{this.heatmaps=new xK(this),this.heatmaps.startIfEnabled()})),r.push((()=>{this.webVitalsAutocapture=new bK(this)})),r.push((()=>{this.exceptionObserver=new aK(this),this.exceptionObserver.startIfEnabledOrStop()})),r.push((()=>{this.deadClicksAutocapture=new sI(this,sK),this.deadClicksAutocapture.startIfEnabled()})),r.push((()=>{if(this.ts){var i=this.ts;this.ts=void 0,this.pi(i)}})),this.es(r,n)}es(e,n){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-n>=30&&e.length>0)return void setTimeout((()=>{this.es(e,n)}),0);var r=e.shift();if(r)try{r()}catch(o){ye.error("Error initializing extension:",o)}}var i=Math.round(performance.now()-n);this.register_for_session({$sdk_debug_extensions_init_method:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",$sdk_debug_extensions_init_time_ms:i}),this.config.__preview_deferred_init_extensions&&ye.info("PostHog extensions initialized ("+i+"ms)")}pi(e){var n,r,i,o,s,a,l,c,u;if(!me||!me.body)return ye.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.pi(e)}),500);this.config.__preview_deferred_init_extensions&&(this.ts=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=Ue(e.supportedCompression,Ti.GZipJS)?Ti.GZipJS:Ue(e.supportedCompression,Ti.Base64)?Ti.Base64:void 0),(n=e.analytics)!=null&&n.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Hr?this.Hr:"identified_only"}),(r=this.siteApps)==null||r.onRemoteConfig(e),(i=this.sessionRecording)==null||i.onRemoteConfig(e),(o=this.autocapture)==null||o.onRemoteConfig(e),(s=this.heatmaps)==null||s.onRemoteConfig(e),this.surveys.onRemoteConfig(e),this.conversations.onRemoteConfig(e),(a=this.productTours)==null||a.onRemoteConfig(e),(l=this.webVitalsAutocapture)==null||l.onRemoteConfig(e),(c=this.exceptionObserver)==null||c.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),(u=this.deadClicksAutocapture)==null||u.onRemoteConfig(e)}Zr(){try{this.config.loaded(this)}catch(e){ye.critical("`loaded` function failed",e)}this.rs(),this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.config.cookieless_mode==="always")&&this.ss()}),1),new GK(this).load(),this.featureFlags.flags()}rs(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Jr)==null||e.enable())}_dom_loaded(){this.is_capturing()&&io(this.__request_queue,(e=>this.Kr(e))),this.__request_queue=[],this.rs()}_handle_unload(){var e,n;this.surveys.handlePageUnload(),this.config.request_batching?(this.ns()&&this.capture("$pageleave"),(e=this.Jr)==null||e.unload(),(n=this.Yr)==null||n.unload()):this.ns()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(XI?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Fd(e.url,{ip:this.config.ip?1:0}),e.headers=be({},this.config.request_headers,e.headers),e.compression=e.compression==="best-available"?this.compression:e.compression,e.disableXHRCredentials=this.config.__preview_disable_xhr_credentials,this.config.__preview_disable_beacon&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(n=>{var r,i,o,s=be({},n);s.timeout=s.timeout||6e4,s.url=Fd(s.url,{_:new Date().getTime().toString(),ver:Ci.LIB_VERSION,compression:s.compression});var a=(r=s.transport)!==null&&r!==void 0?r:"fetch",l=Dd.filter((u=>!s.disableTransport||!u.transport||!s.disableTransport.includes(u.transport))),c=(i=(o=AS(l,(u=>u.transport===a)))==null?void 0:o.method)!==null&&i!==void 0?i:l[0].method;if(!c)throw new Error("No available transport method");c(s)})(be({},e,{callback:n=>{var r,i;this.rateLimiter.checkForLimiting(n),n.statusCode>=400&&((r=(i=this.config).on_request_error)==null||r.call(i,n)),e.callback==null||e.callback(n)}}))))}Kr(e){this.Yr?this.Yr.retriableRequest(e):this._send_request(e)}_execute_array(e){var n,r=[],i=[],o=[];io(e,(a=>{a&&(n=a[0],Ze(n)?o.push(a):ro(a)?a.call(this):Ze(a)&&n==="alias"?r.push(a):Ze(a)&&n.indexOf("capture")!==-1&&ro(this[n])?o.push(a):i.push(a))}));var s=function(a,l){io(a,(function(c){if(Ze(c[0])){var u=l;ut(c,(function(h){u=u[h[0]].apply(u,h.slice(1))}))}else this[c[0]].apply(this,c.slice(1))}),l)};s(r,this),s(i,this),s(o,this)}Qr(){var e,n;return((e=this.config.bootstrap)==null?void 0:e.featureFlags)&&Object.keys((n=this.config.bootstrap)==null?void 0:n.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,n,r){var i;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Jr){if(this.is_capturing())if(!fe(e)&&nn(e)){var o=!this.config.opt_out_useragent_filter&&this._is_bot();if(!(o&&!this.config.__preview_capture_bot_pageviews)){var s=r!=null&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(s==null||!s.isRateLimited){n!=null&&n.$current_url&&!nn(n==null?void 0:n.$current_url)&&(ye.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),n==null||delete n.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var a=new Date,l=(r==null?void 0:r.timestamp)||a,c=so(),u={uuid:c,event:e,properties:this.calculateEventProperties(e,n||{},l,c)};e==="$pageview"&&this.config.__preview_capture_bot_pageviews&&o&&(u.event="$bot_pageview",u.properties.$browser_type="bot"),s&&(u.properties.$lib_rate_limit_remaining_tokens=s.remainingTokens),r!=null&&r.$set&&(u.$set=r==null?void 0:r.$set);var h,p=e!=="$groupidentify",g=this.os(r==null?void 0:r.$set_once,p);if(g&&(u.$set_once=g),(u=PG(u,r!=null&&r._noTruncate?null:this.config.properties_string_max_length)).timestamp=l,fe(r==null?void 0:r.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=a),e===zd.DISMISSED||e===zd.SENT){var b=n==null?void 0:n[$I.SURVEY_ID],m=n==null?void 0:n[$I.SURVEY_ITERATION];h={id:b,current_iteration:m},localStorage.getItem(WI(h))||localStorage.setItem(WI(h),"true"),u.$set=be({},u.$set,{[DK({id:b,current_iteration:m},e===zd.SENT?"responded":"dismissed")]:!0})}var x=be({},u.properties.$set,u.$set);if(ta(x)||this.setPersonPropertiesForFlags(x),!Je(this.config.before_send)){var I=this.ls(u);if(!I)return;u=I}this.Nr.emit("eventCaptured",u);var N={method:"POST",url:(i=r==null?void 0:r._url)!==null&&i!==void 0?i:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:u,compression:"best-available",batchKey:r==null?void 0:r._batchKey};return!this.config.request_batching||r&&(r==null||!r._batchKey)||r!=null&&r.send_instantly?this.Kr(N):this.Jr.enqueue(N),u}ye.critical("This capture call is ignored due to client rate limiting.")}}else ye.error("No event name provided to posthog.capture")}else ye.uninitializedWarning("posthog.capture")}Ni(e){return this.on("eventCaptured",(n=>e(n.event,n)))}calculateEventProperties(e,n,r,i,o){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return n;var s=o?void 0:this.persistence.remove_event_timer(e),a=be({},n);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,(this.config.cookieless_mode=="always"||this.config.cookieless_mode=="on_reject"&&this.consent.isExplicitlyOptedOut())&&(a.$cookieless_mode=!0),e==="$snapshot"){var l=be({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!nn(a.distinct_id)&&!ei(a.distinct_id)||Ap(a.distinct_id))&&ye.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,u=yK(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:h,windowId:p}=this.sessionManager.checkAndGetSessionAndWindowId(o,r.getTime());a.$session_id=h,a.$window_id=p}this.sessionPropsManager&&Ot(a,this.sessionPropsManager.getSessionProps());try{var g;this.sessionRecording&&Ot(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(g=this.Yr)==null?void 0:g.length}catch(I){a.$sdk_debug_error_capturing_properties=String(I)}if(this.requestRouter.region===tc.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),c=e!=="$pageview"||o?e!=="$pageleave"||o?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,i),a=Ot(a,c),e==="$pageview"&&me&&(a.title=me.title),!fe(s)){var b=r.getTime()-s;a.$duration=parseFloat((b/1e3).toFixed(3))}qn&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=Ot({},u,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),Ze(this.config.property_denylist)?ut(this.config.property_denylist,(function(I){delete a[I]})):ye.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var m=this.config.sanitize_properties;m&&(ye.error("sanitize_properties is deprecated. Use before_send instead"),a=m(a,e));var x=this.us();return a.$process_person_profile=x,x&&!o&&this.hs("_calculate_event_properties"),a}os(e,n){var r;if(n===void 0&&(n=!0),!this.persistence||!this.us()||this.Lr)return e;var i=this.persistence.get_initial_props(),o=(r=this.sessionPropsManager)==null?void 0:r.getSetOnceProps(),s=Ot({},i,o||{},e||{}),a=this.config.sanitize_properties;return a&&(ye.error("sanitize_properties is deprecated. Use before_send instead"),s=a(s,"$set_once")),n&&(this.Lr=!0),ta(s)?void 0:s}register(e,n){var r;(r=this.persistence)==null||r.register(e,n)}register_once(e,n,r){var i;(i=this.persistence)==null||i.register_once(e,n,r)}register_for_session(e){var n;(n=this.sessionPersistence)==null||n.register(e)}unregister(e){var n;(n=this.persistence)==null||n.unregister(e)}unregister_for_session(e){var n;(n=this.sessionPersistence)==null||n.unregister(e)}ds(e,n){this.register({[e]:n})}getFeatureFlag(e,n){return this.featureFlags.getFeatureFlag(e,n)}getFeatureFlagPayload(e){var n=this.featureFlags.getFeatureFlagPayload(e);try{return JSON.parse(n)}catch(r){return n}}isFeatureEnabled(e,n){return this.featureFlags.isFeatureEnabled(e,n)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateEarlyAccessFeatureEnrollment(e,n,r){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,n,r)}getEarlyAccessFeatures(e,n,r){return n===void 0&&(n=!1),this.featureFlags.getEarlyAccessFeatures(e,n,r)}on(e,n){return this.Nr.on(e,n)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var n,r;return(n=(r=this.sessionManager)==null?void 0:r.onSessionId(e))!==null&&n!==void 0?n:()=>{}}getSurveys(e,n){n===void 0&&(n=!1),this.surveys.getSurveys(e,n)}getActiveMatchingSurveys(e,n){n===void 0&&(n=!1),this.surveys.getActiveMatchingSurveys(e,n)}renderSurvey(e,n){this.surveys.renderSurvey(e,n)}displaySurvey(e,n){n===void 0&&(n=$K),this.surveys.displaySurvey(e,n)}cancelPendingSurvey(e){this.surveys.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,n){return n===void 0&&(n=!1),this.surveys.canRenderSurveyAsync(e,n)}identify(e,n,r){if(!this.__loaded||!this.persistence)return ye.uninitializedWarning("posthog.identify");if(ei(e)&&(e=e.toString(),ye.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),e)if(["distinct_id","distinctid"].includes(e.toLowerCase()))ye.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.');else if(e!==$l){if(this.hs("posthog.identify")){var i=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var o=i;this.register_once({$had_persisted_distinct_id:!0,$device_id:o},"")}e!==i&&e!==this.get_property(Bl)&&(this.unregister(Bl),this.register({distinct_id:e}));var s=(this.persistence.get_property(ki)||"anonymous")==="anonymous";e!==i&&s?(this.persistence.set_property(ki,"identified"),this.setPersonPropertiesForFlags(be({},r||{},n||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:i},{$set:n||{},$set_once:r||{}}),this.Br=NI(e,n,r),this.featureFlags.setAnonymousDistinctId(i)):(n||r)&&this.setPersonProperties(n,r),e!==i&&(this.reloadFeatureFlags(),this.unregister(Ed))}}else ye.critical('The string "'+$l+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else ye.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,n){if((e||n)&&this.hs("posthog.setPersonProperties")){var r=NI(this.get_distinct_id(),e,n);this.Br!==r?(this.setPersonPropertiesForFlags(be({},n||{},e||{})),this.capture("$set",{$set:e||{},$set_once:n||{}}),this.Br=r):ye.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,n,r){if(e&&n){var i=this.getGroups();i[e]!==n&&this.resetGroupPropertiesForFlags(e),this.register({$groups:be({},i,{[e]:n})}),r&&(this.capture("$groupidentify",{$group_type:e,$group_key:n,$group_set:r}),this.setGroupPropertiesForFlags({[e]:r})),i[e]===n||r||this.reloadFeatureFlags()}else ye.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,n){n===void 0&&(n=!0),this.featureFlags.setPersonPropertiesForFlags(e,n)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,n){n===void 0&&(n=!0),this.hs("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,n)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var n,r,i,o;if(ye.info("reset"),!this.__loaded)return ye.uninitializedWarning("posthog.reset");var s=this.get_property("$device_id");if(this.consent.reset(),(n=this.persistence)==null||n.clear(),(r=this.sessionPersistence)==null||r.clear(),this.surveys.reset(),this.featureFlags.reset(),(i=this.persistence)==null||i.set_property(ki,"anonymous"),(o=this.sessionManager)==null||o.resetSessionId(),this.Br=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:$l,$device_id:null},"");else{var a=this.config.get_device_id(so());this.register_once({distinct_id:a,$device_id:e?a:s},"")}this.register({$last_posthog_reset:new Date().toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,n;return(e=(n=this.sessionManager)==null?void 0:n.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:n,sessionStartTimestamp:r}=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+n);if(e!=null&&e.withTimestamp&&r){var o,s=(o=e.timestampLookBack)!==null&&o!==void 0?o:10;if(!r)return i;i+="?t="+Math.max(Math.floor((new Date().getTime()-r)/1e3)-s,0)}return i}alias(e,n){return e===this.get_property(OS)?(ye.critical("Attempting to create alias for existing People user - aborting."),-2):this.hs("posthog.alias")?(fe(n)&&(n=this.get_distinct_id()),e!==n?(this.ds(Bl,e),this.capture("$create_alias",{alias:e,distinct_id:n})):(ye.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var n=be({},this.config);if(an(e)){var r,i,o,s,a,l,c;Ot(this.config,JI(e));var u=this.Vr();(r=this.persistence)==null||r.update_config(this.config,n,u),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new gm(be({},this.config,{persistence:"sessionStorage"}),u);var h=this.qr(this.config.debug);Ai(h)&&(this.config.debug=h),Ai(this.config.debug)&&(this.config.debug?(Ci.DEBUG=!0,bt.H()&&bt.G("ph_debug","true"),ye.info("set_config",{config:e,oldConfig:n,newConfig:be({},this.config)})):(Ci.DEBUG=!1,bt.H()&&bt.V("ph_debug"))),(i=this.exceptionObserver)==null||i.onConfigChange(),(o=this.sessionRecording)==null||o.startIfEnabledOrStop(),(s=this.autocapture)==null||s.startIfEnabled(),(a=this.heatmaps)==null||a.startIfEnabled(),(l=this.exceptionObserver)==null||l.startIfEnabledOrStop(),this.surveys.loadIfEnabled(),this.vs(),(c=this.externalIntegrations)==null||c.startIfEnabledOrStop()}}startSessionRecording(e){var n=e===!0,r={sampling:n||!(e==null||!e.sampling),linked_flag:n||!(e==null||!e.linked_flag),url_trigger:n||!(e==null||!e.url_trigger),event_trigger:n||!(e==null||!e.event_trigger)};if(Object.values(r).some(Boolean)){var i,o,s,a,l;(i=this.sessionManager)==null||i.checkAndGetSessionAndWindowId(),r.sampling&&((o=this.sessionRecording)==null||o.overrideSampling()),r.linked_flag&&((s=this.sessionRecording)==null||s.overrideLinkedFlag()),r.url_trigger&&((a=this.sessionRecording)==null||a.overrideTrigger("url")),r.event_trigger&&((l=this.sessionRecording)==null||l.overrideTrigger("event"))}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,n){var r=new Error("PostHog syntheticException"),i=this.exceptions.buildProperties(e,{handled:!0,syntheticException:r});return this.exceptions.sendExceptionEvent(be({},i,n))}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var n;return(n=this.persistence)==null?void 0:n.props[e]}getSessionProperty(e){var n;return(n=this.sessionPersistence)==null?void 0:n.props[e]}toString(){var e,n=(e=this.config.name)!==null&&e!==void 0?e:ha;return n!==ha&&(n=ha+"."+n),n}_isIdentified(){var e,n;return((e=this.persistence)==null?void 0:e.get_property(ki))==="identified"||((n=this.sessionPersistence)==null?void 0:n.get_property(ki))==="identified"}us(){var e,n;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&ta(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[Bl])&&((n=this.persistence)==null||(n=n.props)==null||!n[Id]))}ns(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&(this.config.capture_pageview===!0||this.config.capture_pageview==="history_change")}createPersonProfile(){this.us()||this.hs("posthog.createPersonProfile")&&this.setPersonProperties({},{})}hs(e){return this.config.person_profiles==="never"?(ye.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.ds(Id,!0),!0)}Vr(){if(this.config.cookieless_mode==="always")return!0;var e=this.consent.isOptedOut(),n=this.config.opt_out_persistence_by_default||this.config.cookieless_mode==="on_reject";return this.config.disable_persistence||e&&!!n}vs(){var e,n,r,i,o=this.Vr();return((e=this.persistence)==null?void 0:e.xi)!==o&&((r=this.persistence)==null||r.set_disabled(o)),((n=this.sessionPersistence)==null?void 0:n.xi)!==o&&((i=this.sessionPersistence)==null||i.set_disabled(o)),o}opt_in_capturing(e){var n;if(this.config.cookieless_mode!=="always"){var r,i;this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut()&&(this.reset(!0),(r=this.sessionManager)==null||r.destroy(),this.sessionManager=new qI(this),this.persistence&&(this.sessionPropsManager=new jI(this,this.sessionManager,this.persistence)),this.sessionRecording=new YI(this),this.sessionRecording.startIfEnabledOrStop()),this.consent.optInOut(!0),this.vs(),this.rs(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&this.surveys.loadIfEnabled(),(fe(e==null?void 0:e.captureEventName)||e!=null&&e.captureEventName)&&this.capture((i=e==null?void 0:e.captureEventName)!==null&&i!==void 0?i:"$opt_in",e==null?void 0:e.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.ss()}else ye.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e,n;this.config.cookieless_mode!=="always"?(this.config.cookieless_mode==="on_reject"&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.vs(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:$l,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(n=this.sessionRecording)==null||n.stopRecording(),this.sessionRecording=void 0,this.ss())):ye.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===Ri.GRANTED?"granted":e===Ri.DENIED?"denied":"pending"}is_capturing(){return this.config.cookieless_mode==="always"||(this.config.cookieless_mode==="on_reject"?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.vs()}_is_bot(){return ur?GI(ur,this.config.custom_blocked_useragents):void 0}ss(){me&&(me.visibilityState==="visible"?this.Ur||(this.Ur=!0,this.capture("$pageview",{title:me.title},{send_instantly:!0}),this.zr&&(me.removeEventListener("visibilitychange",this.zr),this.zr=null)):this.zr||(this.zr=this.ss.bind(this),Bt(me,"visibilitychange",this.zr)))}debug(e){e===!1?(oe==null||oe.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(oe==null||oe.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}O(){var e,n,r,i,o,s,a,l=this.Wr||{};return"advanced_disable_flags"in l?!!l.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(ye.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(r="advanced_disable_decide",i=!1,o=ye,s=(n="advanced_disable_flags")in(e=l)&&!fe(e[n]),a=r in e&&!fe(e[r]),s?e[n]:a?(o&&o.warn("Config field '"+r+"' is deprecated. Please use '"+n+"' instead. The old field will be removed in a future major version."),e[r]):i)}ls(e){if(Je(this.config.before_send))return e;var n=Ze(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(var i of n){if(r=i(r),Je(r)){var o="Event '"+e.event+"' was rejected in beforeSend function";return Xq(e.event)?ye.warn(o+". This can cause unexpected behavior."):ye.info(o),null}r.properties&&!ta(r.properties)||ye.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return r}getPageViewId(){var e;return(e=this.pageViewManager.Kt)==null?void 0:e.pageViewId}captureTraceFeedback(e,n){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:n})}captureTraceMetric(e,n,r){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:n,$ai_metric_value:String(r)})}qr(e){var n=Ai(e)&&!e,r=bt.H()&&bt.q("ph_debug")==="true";return!n&&(!!r||e)}}(function(t,e){for(var n=0;n<e.length;n++)t.prototype[e[n]]=NG(t.prototype[e[n]])})(Ud,["identify"]);var QI,aY=(QI=rc[ha]=new Ud,(function(){function t(){t.done||(t.done=!0,XI=!1,ut(rc,(function(e){e._dom_loaded()})))}me!=null&&me.addEventListener?me.readyState==="complete"?t():Bt(me,"DOMContentLoaded",t,{capture:!1}):oe&&ye.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),QI);const ic=K.createContext({}),eC=({config:{apiKey:t,tokenOut:e,chainIdOut:n,theme:r,enableExchange:i,cexBridgeChainMapping:o,recipient:s,enforceFlow:a},onClose:l,wrapper:c})=>{const u=Be(x=>x.setEnsoApiToken),h=Be(x=>x.setTokenOut),p=Be(x=>x.setChainIdOut),g=Be(x=>x.setRecipient),b=K.useMemo(()=>l?()=>{l&&l()}:void 0,[l]);K.useEffect(()=>{h(e),p(n),g(s)},[e,n,s]),K.useEffect(()=>{aY.init("phc_capPDVae4W7y6QIqVTugTtx5geVthX4YVswtXa6DrjM",{api_host:"https://eu.i.posthog.com",person_profiles:"always"}),t||alert("Please provide an API key"),u(t)},[t]);const m=K.useMemo(()=>c!=null?c:(({children:x,...I})=>w.jsx(ue,{p:4,w:"374px",...I,children:x})),[c]);return w.jsx(ic.Provider,{value:{handleClose:b,enableExchange:i,cexBridgeChainMapping:o,enforceFlow:a},children:w.jsx(hB,{themeConfig:r,children:w.jsxs(m,{children:[w.jsx(pq,{}),w.jsx(jq,{})]})})})},lY=({config:t,setIsActive:e,isActive:n,onClose:r})=>{const i=K.useCallback(()=>{e(!1),r==null||r()},[e,r]);return n?w.jsx(eC,{wrapper:or,config:t,onClose:i}):null};_t.Checkout=eC,_t.CheckoutModal=lY,_t.DEFAULT_CEX_BRIDGE_CHAIN_MAPPING=Jf,_t.SupportedExchanges=Qr,Object.defineProperty(_t,Symbol.toStringTag,{value:"Module"})}));
231
+ `)).length,i=0;i<r;i++){var s=t.charCodeAt(i),a=null;s<128?n++:a=s>127&&s<2048?String.fromCharCode(s>>6|192,63&s|128):String.fromCharCode(s>>12|224,s>>6&63|128,63&s|128),Pr(a)||(n>e&&(o+=t.substring(e,n)),o+=a,e=n=i+1)}return n>e&&(o+=t.substring(e,t.length)),o},RK=!!Ip||!!Sp,RI="text/plain",Fd=function(t,e,n){var r;n===void 0&&(n=!0);var[i,o]=t.split("?"),s=be({},e),a=(r=o==null?void 0:o.split("&").map((c=>{var u,[h,p]=c.split("="),g=n&&(u=s[h])!==null&&u!==void 0?u:p;return delete s[h],h+"="+g})))!==null&&r!==void 0?r:[],l=qG(s);return l&&a.push(l),i+"?"+a.join("&")},Xl=(t,e)=>JSON.stringify(t,((n,r)=>typeof r=="bigint"?r.toString():r),e),dm=t=>{var{data:e,compression:n}=t;if(e){if(n===Ti.GZipJS){var r=kK((function(l,c){var u=l.length;if(typeof TextEncoder!="undefined")return new TextEncoder().encode(l);for(var h=new _r(l.length+(l.length>>>1)),p=0,g=function(I){h[p++]=I},b=0;b<u;++b){if(p+5>h.length){var m=new _r(p+8+(u-b<<1));m.set(h),h=m}var x=l.charCodeAt(b);x<128||c?g(x):x<2048?(g(192|x>>>6),g(128|63&x)):x>55295&&x<57344?(g(240|(x=65536+(1047552&x)|1023&l.charCodeAt(++b))>>>18),g(128|x>>>12&63),g(128|x>>>6&63),g(128|63&x)):(g(224|x>>>12),g(128|x>>>6&63),g(128|63&x))}return OI(h,0,p)})(Xl(e)),{mtime:0}),i=new Blob([r],{type:RI});return{contentType:RI,body:i,estimatedSize:i.size}}if(n===Ti.Base64){var o=(function(l){var c,u,h,p,g,b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",m=0,x=0,I="",N=[];if(!l)return l;l=TK(l);do c=(g=l.charCodeAt(m++)<<16|l.charCodeAt(m++)<<8|l.charCodeAt(m++))>>18&63,u=g>>12&63,h=g>>6&63,p=63&g,N[x++]=b.charAt(c)+b.charAt(u)+b.charAt(h)+b.charAt(p);while(m<l.length);switch(I=N.join(""),l.length%3){case 1:I=I.slice(0,-2)+"==";break;case 2:I=I.slice(0,-1)+"="}return I})(Xl(e)),s=(l=>"data="+encodeURIComponent(typeof l=="string"?l:Xl(l)))(o);return{contentType:"application/x-www-form-urlencoded",body:s,estimatedSize:new Blob([s]).size}}var a=Xl(e);return{contentType:"application/json",body:a,estimatedSize:new Blob([a]).size}}},Dd=[];Sp&&Dd.push({transport:"fetch",method:t=>{var e,n,{contentType:r,body:i,estimatedSize:o}=(e=dm(t))!==null&&e!==void 0?e:{},s=new Headers;ut(t.headers,(function(u,h){s.append(h,u)})),r&&s.append("Content-Type",r);var a=t.url,l=null;if(qE){var c=new qE;l={signal:c.signal,timeout:setTimeout((()=>c.abort()),t.timeout)}}Sp(a,be({method:(t==null?void 0:t.method)||"GET",headers:s,keepalive:t.method==="POST"&&(o||0)<52428.8,body:i,signal:(n=l)==null?void 0:n.signal},t.fetchOptions)).then((u=>u.text().then((h=>{var p={statusCode:u.status,text:h};if(u.status===200)try{p.json=JSON.parse(h)}catch(g){ye.error(g)}t.callback==null||t.callback(p)})))).catch((u=>{ye.error(u),t.callback==null||t.callback({statusCode:0,text:u})})).finally((()=>l?clearTimeout(l.timeout):null))}}),Ip&&Dd.push({transport:"XHR",method:t=>{var e,n=new Ip;n.open(t.method||"GET",t.url,!0);var{contentType:r,body:i}=(e=dm(t))!==null&&e!==void 0?e:{};ut(t.headers,(function(o,s){n.setRequestHeader(s,o)})),r&&n.setRequestHeader("Content-Type",r),t.timeout&&(n.timeout=t.timeout),t.disableXHRCredentials||(n.withCredentials=!0),n.onreadystatechange=()=>{if(n.readyState===4){var o={statusCode:n.status,text:n.responseText};if(n.status===200)try{o.json=JSON.parse(n.responseText)}catch(s){}t.callback==null||t.callback(o)}},n.send(i)}}),ur!=null&&ur.sendBeacon&&Dd.push({transport:"sendBeacon",method:t=>{var e=Fd(t.url,{beacon:"1"});try{var n,{contentType:r,body:i}=(n=dm(t))!==null&&n!==void 0?n:{},o=typeof i=="string"?new Blob([i],{type:r}):i;ur.sendBeacon(e,o)}catch(s){}}});var Vd=function(t,e){if(!(function(n){try{new RegExp(n)}catch(r){return!1}return!0})(e))return!1;try{return new RegExp(e).test(t)}catch(n){return!1}};function NI(t,e,n){return Xl({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:n})}var PI={exact:(t,e)=>e.some((n=>t.some((r=>n===r)))),is_not:(t,e)=>e.every((n=>t.every((r=>n!==r)))),regex:(t,e)=>e.some((n=>t.some((r=>Vd(n,r))))),not_regex:(t,e)=>e.every((n=>t.every((r=>!Vd(n,r))))),icontains:(t,e)=>e.map($d).some((n=>t.map($d).some((r=>n.includes(r))))),not_icontains:(t,e)=>e.map($d).every((n=>t.map($d).every((r=>!n.includes(r))))),gt:(t,e)=>e.some((n=>{var r=parseFloat(n);return!isNaN(r)&&t.some((i=>r>parseFloat(i)))})),lt:(t,e)=>e.some((n=>{var r=parseFloat(n);return!isNaN(r)&&t.some((i=>r<parseFloat(i)))}))},$d=t=>t.toLowerCase();function LI(t,e){return!t||Object.entries(t).every((n=>{var[r,i]=n,o=e==null?void 0:e[r];if(fe(o)||Pr(o))return!1;var s=[String(o)],a=PI[i.operator];return!!a&&a(i.values,s)}))}var hm=At("[Error tracking]");class NK{constructor(e){var n,r;this.Yt=[],this.Xt=new hG([new xG,new TG,new EG,new wG,new OG,new AG,new IG,new kG],_G("web:javascript",mG,bG)),this._instance=e,this.Yt=(n=(r=this._instance.persistence)==null?void 0:r.get_property(Up))!==null&&n!==void 0?n:[]}onRemoteConfig(e){var n,r,i,o=(n=(r=e.errorTracking)==null?void 0:r.suppressionRules)!==null&&n!==void 0?n:[],s=(i=e.errorTracking)==null?void 0:i.captureExtensionExceptions;this.Yt=o,this._instance.persistence&&this._instance.persistence.register({[Up]:this.Yt,[RS]:s})}get Qt(){var e,n=!!this._instance.get_property(RS),r=this._instance.config.error_tracking.captureExtensionExceptions;return(e=r!=null?r:n)!==null&&e!==void 0&&e}buildProperties(e,n){return this.Xt.buildFromUnknown(e,{syntheticException:n==null?void 0:n.syntheticException,mechanism:{handled:n==null?void 0:n.handled}})}sendExceptionEvent(e){var n=e.$exception_list;if(this.Zt(n)){if(this.ti(n))return void hm.info("Skipping exception capture because a suppression rule matched");if(!this.Qt&&this.ii(n))return void hm.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ei(n))return void hm.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"})}ti(e){if(e.length===0)return!1;var n=e.reduce(((r,i)=>{var{type:o,value:s}=i;return nn(o)&&o.length>0&&r.$exception_types.push(o),nn(s)&&s.length>0&&r.$exception_values.push(s),r}),{$exception_types:[],$exception_values:[]});return this.Yt.some((r=>{var i=r.values.map((o=>{var s,a=PI[o.operator],l=Ze(o.value)?o.value:[o.value],c=(s=n[o.key])!==null&&s!==void 0?s:[];return l.length>0&&a(l,c)}));return r.type==="OR"?i.some(Boolean):i.every(Boolean)}))}ii(e){return e.flatMap((n=>{var r,i;return(r=(i=n.stacktrace)==null?void 0:i.frames)!==null&&r!==void 0?r:[]})).some((n=>n.filename&&n.filename.startsWith("chrome-extension://")))}ei(e){if(e.length>0){var n,r,i,o,s=(n=(r=e[0].stacktrace)==null?void 0:r.frames)!==null&&n!==void 0?n:[],a=s[s.length-1];return(i=a==null||(o=a.filename)==null?void 0:o.includes("posthog.com/static"))!==null&&i!==void 0&&i}return!1}Zt(e){return!Je(e)&&Ze(e)}}var Lr=At("[FeatureFlags]"),Zl=At("[FeatureFlags]",{debugEnabled:!0}),fm="$active_feature_flags",ua="$override_feature_flags",MI="$feature_flag_payloads",Jl="$override_feature_flag_payloads",BI="$feature_flag_request_id",FI="$feature_flag_evaluated_at",DI=t=>{var e={};for(var[n,r]of xd(t||{}))r&&(e[n]=r);return e},PK=t=>{var e=t.flags;return e?(t.featureFlags=Object.fromEntries(Object.keys(e).map((n=>{var r;return[n,(r=e[n].variant)!==null&&r!==void 0?r:e[n].enabled]}))),t.featureFlagPayloads=Object.fromEntries(Object.keys(e).filter((n=>e[n].enabled)).filter((n=>{var r;return(r=e[n].metadata)==null?void 0:r.payload})).map((n=>{var r;return[n,(r=e[n].metadata)==null?void 0:r.payload]})))):Lr.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),t},LK=(function(t){return t.FeatureFlags="feature_flags",t.Recordings="recordings",t})({});class MK{constructor(e){this.ri=!1,this.si=!1,this.ni=!1,this.oi=!1,this.ai=!1,this.li=!1,this.ui=!1,this._instance=e,this.featureFlagEventHandlers=[]}hi(){var e=this._instance.config.evaluation_environments;return e!=null&&e.length?e.filter((n=>{var r=n&&typeof n=="string"&&n.trim().length>0;return r||Lr.error("Invalid evaluation environment found:",n,"Expected non-empty string"),r})):[]}di(){return this.hi().length>0}flags(){if(this._instance.config.__preview_remote_config)this.li=!0;else{var e=!this.vi&&(this._instance.config.advanced_disable_feature_flags||this._instance.config.advanced_disable_feature_flags_on_first_load);this.ci({disableFlags:e})}}get hasLoadedFlags(){return this.si}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var e=this._instance.get_property(Hp),n=this._instance.get_property(ua),r=this._instance.get_property(Jl);if(!r&&!n)return e||{};var i=Ot({},e||{}),o=[...new Set([...Object.keys(r||{}),...Object.keys(n||{})])];for(var s of o){var a,l,c=i[s],u=n==null?void 0:n[s],h=fe(u)?(a=c==null?void 0:c.enabled)!==null&&a!==void 0&&a:!!u,p=fe(u)?c.variant:typeof u=="string"?u:void 0,g=r==null?void 0:r[s],b=be({},c,{enabled:h,variant:h?p!=null?p:c==null?void 0:c.variant:void 0});h!==(c==null?void 0:c.enabled)&&(b.original_enabled=c==null?void 0:c.enabled),p!==(c==null?void 0:c.variant)&&(b.original_variant=c==null?void 0:c.variant),g&&(b.metadata=be({},c==null?void 0:c.metadata,{payload:g,original_payload:c==null||(l=c.metadata)==null?void 0:l.payload})),i[s]=b}return this.ri||(Lr.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:r,finalDetails:i}),this.ri=!0),i}getFlagVariants(){var e=this._instance.get_property(aa),n=this._instance.get_property(ua);if(!n)return e||{};for(var r=Ot({},e),i=Object.keys(n),o=0;o<i.length;o++)r[i[o]]=n[i[o]];return this.ri||(Lr.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:n,finalFlags:r}),this.ri=!0),r}getFlagPayloads(){var e=this._instance.get_property(MI),n=this._instance.get_property(Jl);if(!n)return e||{};for(var r=Ot({},e||{}),i=Object.keys(n),o=0;o<i.length;o++)r[i[o]]=n[i[o]];return this.ri||(Lr.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:n,finalPayloads:r}),this.ri=!0),r}reloadFeatureFlags(){this.oi||this._instance.config.advanced_disable_feature_flags||this.vi||(this.vi=setTimeout((()=>{this.ci()}),5))}fi(){clearTimeout(this.vi),this.vi=void 0}ensureFlagsLoaded(){this.si||this.ni||this.vi||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this.oi=e}ci(e){var n;if(this.fi(),!this._instance.O())if(this.ni)this.ai=!0;else{var r=this._instance.config.token,i=this._instance.get_property("$device_id"),o={token:r,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:be({},((n=this._instance.persistence)==null?void 0:n.get_initial_props())||{},this._instance.get_property(Vl)||{}),group_properties:this._instance.get_property(Go)};Pr(i)||fe(i)||(o.$device_id=i),(e!=null&&e.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(o.disable_flags=!0),this.di()&&(o.evaluation_environments=this.hi());var s=this._instance.config.__preview_remote_config,a=s?"/flags/?v=2":"/flags/?v=2&config=true",l=this._instance.config.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":"",c=this._instance.requestRouter.endpointFor("flags",a+l);s&&(o.timezone=bI()),this.ni=!0,this._instance._send_request({method:"POST",url:c,data:o,compression:this._instance.config.disable_compression?void 0:Ti.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:u=>{var h,p,g=!0;if(u.statusCode===200&&(this.ai||(this.$anon_distinct_id=void 0),g=!1),this.ni=!1,this.li||(this.li=!0,this._instance.pi((p=u.json)!==null&&p!==void 0?p:{})),!o.disable_flags||this.ai)if(this.ui=!g,u.json&&(h=u.json.quotaLimited)!=null&&h.includes(LK.FeatureFlags))Lr.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more.");else{var b;o.disable_flags||this.receivedFeatureFlags((b=u.json)!==null&&b!==void 0?b:{},g),this.ai&&(this.ai=!1,this.ci())}}})}}getFeatureFlag(e,n){if(n===void 0&&(n={}),this.si||this.getFlags()&&this.getFlags().length>0){var r=this.getFlagVariants()[e],i=""+r,o=this._instance.get_property(BI)||void 0,s=this._instance.get_property(FI)||void 0,a=this._instance.get_property(Ed)||{};if((n.send_event||!("send_event"in n))&&(!(e in a)||!a[e].includes(i))){var l,c,u,h,p,g,b,m,x;Ze(a[e])?a[e].push(i):a[e]=[i],(l=this._instance.persistence)==null||l.register({[Ed]:a});var I=this.getFeatureFlagDetails(e),N={$feature_flag:e,$feature_flag_response:r,$feature_flag_payload:this.getFeatureFlagPayload(e)||null,$feature_flag_request_id:o,$feature_flag_evaluated_at:s,$feature_flag_bootstrapped_response:((c=this._instance.config.bootstrap)==null||(c=c.featureFlags)==null?void 0:c[e])||null,$feature_flag_bootstrapped_payload:((u=this._instance.config.bootstrap)==null||(u=u.featureFlagPayloads)==null?void 0:u[e])||null,$used_bootstrap_value:!this.ui};fe(I==null||(h=I.metadata)==null?void 0:h.version)||(N.$feature_flag_version=I.metadata.version);var T,$=(p=I==null||(g=I.reason)==null?void 0:g.description)!==null&&p!==void 0?p:I==null||(b=I.reason)==null?void 0:b.code;$&&(N.$feature_flag_reason=$),I!=null&&(m=I.metadata)!=null&&m.id&&(N.$feature_flag_id=I.metadata.id),fe(I==null?void 0:I.original_variant)&&fe(I==null?void 0:I.original_enabled)||(N.$feature_flag_original_response=fe(I.original_variant)?I.original_enabled:I.original_variant),I!=null&&(x=I.metadata)!=null&&x.original_payload&&(N.$feature_flag_original_payload=I==null||(T=I.metadata)==null?void 0:T.original_payload),this._instance.capture("$feature_flag_called",N)}return r}Lr.warn('getFeatureFlag for key "'+e+`" failed. Feature flags didn't load in time.`)}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){return this.getFlagPayloads()[e]}getRemoteConfigPayload(e,n){var r=this._instance.config.token,i={distinct_id:this._instance.get_distinct_id(),token:r};this.di()&&(i.evaluation_environments=this.hi()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2&config=true"),data:i,compression:this._instance.config.disable_compression?void 0:Ti.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:o=>{var s,a=(s=o.json)==null?void 0:s.featureFlagPayloads;n((a==null?void 0:a[e])||void 0)}})}isFeatureEnabled(e,n){if(n===void 0&&(n={}),this.si||this.getFlags()&&this.getFlags().length>0){var r=this.getFeatureFlag(e,n);return fe(r)?void 0:!!r}Lr.warn('isFeatureEnabled for key "'+e+`" failed. Feature flags didn't load in time.`)}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((n=>n!==e))}receivedFeatureFlags(e,n){if(this._instance.persistence){this.si=!0;var r=this.getFlagVariants(),i=this.getFlagPayloads(),o=this.getFlagsWithDetails();(function(s,a,l,c,u){l===void 0&&(l={}),c===void 0&&(c={}),u===void 0&&(u={});var h=PK(s),p=h.flags,g=h.featureFlags,b=h.featureFlagPayloads;if(g){var m=s.requestId,x=s.evaluatedAt;if(Ze(g)){Lr.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var I={};if(g)for(var N=0;N<g.length;N++)I[g[N]]=!0;a&&a.register({[fm]:g,[aa]:I})}else{var T=g,$=b,B=p;s.errorsWhileComputingFlags&&(T=be({},l,T),$=be({},c,$),B=be({},u,B)),a&&a.register(be({[fm]:Object.keys(DI(T)),[aa]:T||{},[MI]:$||{},[Hp]:B||{}},m?{[BI]:m}:{},x?{[FI]:x}:{}))}}})(e,this._instance.persistence,r,i,o),this.gi(n)}}override(e,n){n===void 0&&(n=!1),Lr.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:n})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return Lr.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(e===!1)return this._instance.persistence.unregister(ua),this._instance.persistence.unregister(Jl),this.gi(),Zl.info("All overrides cleared");if(e&&typeof e=="object"&&("flags"in e||"payloads"in e)){var n,r=e;if(this.ri=!!((n=r.suppressWarning)!==null&&n!==void 0&&n),"flags"in r){if(r.flags===!1)this._instance.persistence.unregister(ua),Zl.info("Flag overrides cleared");else if(r.flags){if(Ze(r.flags)){for(var i={},o=0;o<r.flags.length;o++)i[r.flags[o]]=!0;this._instance.persistence.register({[ua]:i})}else this._instance.persistence.register({[ua]:r.flags});Zl.info("Flag overrides set",{flags:r.flags})}}return"payloads"in r&&(r.payloads===!1?(this._instance.persistence.unregister(Jl),Zl.info("Payload overrides cleared")):r.payloads&&(this._instance.persistence.register({[Jl]:r.payloads}),Zl.info("Payload overrides set",{payloads:r.payloads}))),void this.gi()}this.gi()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this.si){var{flags:n,flagVariants:r}=this.mi();e(n,r)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,n,r){var i,o=(this._instance.get_property(Dl)||[]).find((c=>c.flagKey===e)),s={["$feature_enrollment/"+e]:n},a={$feature_flag:e,$feature_enrollment:n,$set:s};o&&(a.$early_access_feature_name=o.name),r&&(a.$feature_enrollment_stage=r),this._instance.capture("$feature_enrollment_update",a),this.setPersonPropertiesForFlags(s,!1);var l=be({},this.getFlagVariants(),{[e]:n});(i=this._instance.persistence)==null||i.register({[fm]:Object.keys(DI(l)),[aa]:l}),this.gi()}getEarlyAccessFeatures(e,n,r){n===void 0&&(n=!1);var i=this._instance.get_property(Dl),o=r?"&"+r.map((s=>"stage="+s)).join("&"):"";if(i&&!n)return e(i);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this._instance.config.token+o),method:"GET",callback:s=>{var a,l;if(s.json){var c=s.json.earlyAccessFeatures;return(a=this._instance.persistence)==null||a.unregister(Dl),(l=this._instance.persistence)==null||l.register({[Dl]:c}),e(c)}}})}mi(){var e=this.getFlags(),n=this.getFlagVariants();return{flags:e.filter((r=>n[r])),flagVariants:Object.keys(n).filter((r=>n[r])).reduce(((r,i)=>(r[i]=n[i],r)),{})}}gi(e){var{flags:n,flagVariants:r}=this.mi();this.featureFlagEventHandlers.forEach((i=>i(n,r,{errorsLoading:e})))}setPersonPropertiesForFlags(e,n){n===void 0&&(n=!0);var r=this._instance.get_property(Vl)||{};this._instance.register({[Vl]:be({},r,e)}),n&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(Vl)}setGroupPropertiesForFlags(e,n){n===void 0&&(n=!0);var r=this._instance.get_property(Go)||{};Object.keys(r).length!==0&&Object.keys(r).forEach((i=>{r[i]=be({},r[i],e[i]),delete e[i]})),this._instance.register({[Go]:be({},r,e)}),n&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var n=this._instance.get_property(Go)||{};this._instance.register({[Go]:be({},n,{[e]:{}})})}else this._instance.unregister(Go)}reset(){this.si=!1,this.ni=!1,this.oi=!1,this.ai=!1,this.li=!1,this.ui=!1,this.$anon_distinct_id=void 0,this.fi(),this.ri=!1}}var BK=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class gm{constructor(e,n){this.R=e,this.props={},this.bi=!1,this.yi=(r=>{var i="";return r.token&&(i=r.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),r.persistence_name?"ph_"+r.persistence_name:"ph_"+i+"_posthog"})(e),this.Y=this.wi(e),this.load(),e.debug&&ye.info("Persistence loaded",e.persistence,be({},this.props)),this.update_config(e,e,n),this.save()}isDisabled(){return!!this.xi}wi(e){BK.indexOf(e.persistence.toLowerCase())===-1&&(ye.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var n=e.persistence.toLowerCase();return n==="localstorage"&&bt.H()?bt:n==="localstorage+cookie"&&Nd.H()?Nd:n==="sessionstorage"&&_n.H()?_n:n==="memory"?rK:n==="cookie"?ni:Nd.H()?Nd:ni}properties(){var e={};return ut(this.props,(function(n,r){if(r===aa&&an(n))for(var i=Object.keys(n),o=0;o<i.length;o++)e["$feature/"+i[o]]=n[i[o]];else a=r,l=!1,(Pr(s=BG)?l:jE&&s.indexOf===jE?s.indexOf(a)!=-1:(ut(s,(function(c){if(l||(l=c===a))return _d})),l))||(e[r]=n);var s,a,l})),e}load(){if(!this.xi){var e=this.Y.W(this.yi);e&&(this.props=Ot({},e))}}save(){this.xi||this.Y.G(this.yi,this.props,this.Ei,this.$i,this.Si,this.R.debug)}remove(){this.Y.V(this.yi,!1),this.Y.V(this.yi,!0)}clear(){this.remove(),this.props={}}register_once(e,n,r){if(an(e)){fe(n)&&(n="None"),this.Ei=fe(r)?this.ki:r;var i=!1;if(ut(e,((o,s)=>{this.props.hasOwnProperty(s)&&this.props[s]!==n||(this.props[s]=o,i=!0)})),i)return this.save(),!0}return!1}register(e,n){if(an(e)){this.Ei=fe(n)?this.ki:n;var r=!1;if(ut(e,((i,o)=>{e.hasOwnProperty(o)&&this.props[o]!==i&&(this.props[o]=i,r=!0)})),r)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.bi){var e=hI(this.R.custom_campaign_params,this.R.mask_personal_data_properties,this.R.custom_personal_data_properties);ta($p(e))||this.register(e),this.bi=!0}}update_search_keyword(){var e;this.register((e=me==null?void 0:me.referrer)?gI(e):{})}update_referrer_info(){var e;this.register_once({$referrer:mI(),$referring_domain:me!=null&&me.referrer&&((e=Od(me.referrer))==null?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[Kp]||this.props[Yp]||this.register_once({[Sd]:vI(this.R.mask_personal_data_properties,this.R.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};ut([Yp,Kp],(s=>{var a=this.props[s];a&&ut(a,(function(l,c){e["$initial_"+Cp(c)]=l}))}));var n,r,i=this.props[Sd];if(i){var o=(n=yI(i),r={},ut(n,(function(s,a){r["$initial_"+Cp(a)]=s})),r);Ot(e,o)}return e}safe_merge(e){return ut(this.props,(function(n,r){r in e||(e[r]=n)})),e}update_config(e,n,r){if(this.ki=this.Ei=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!r),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==n.persistence){var i=this.wi(e),o=this.props;this.clear(),this.Y=i,this.props=o,this.save()}}set_disabled(e){this.xi=e,this.xi?this.remove():this.save()}set_cross_subdomain(e){e!==this.$i&&(this.$i=e,this.remove(),this.save())}set_secure(e){e!==this.Si&&(this.Si=e,this.remove(),this.save())}set_event_timer(e,n){var r=this.props[Fl]||{};r[e]=n,this.props[Fl]=r,this.save()}remove_event_timer(e){var n=(this.props[Fl]||{})[e];return fe(n)||(delete this.props[Fl][e],this.save()),n}get_property(e){return this.props[e]}set_property(e,n){this.props[e]=n,this.save()}}var VI=At("[Product Tours]"),pm="ph_product_tours";class FK{constructor(e){this.Pi=null,this.Ti=null,this._instance=e}onRemoteConfig(e){this._instance.persistence&&this._instance.persistence.register({[LS]:!(e==null||!e.productTours)}),this.loadIfEnabled()}loadIfEnabled(){var e,n;this.Pi||(e=this._instance).config.disable_product_tours||(n=e.persistence)==null||!n.get_property(LS)||this.it((()=>this.Ii()))}it(e){var n,r;(n=ke.__PosthogExtensions__)!=null&&n.generateProductTours?e():(r=ke.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"product-tours",(i=>{i?VI.error("Could not load product tours script",i):e()}))}Ii(){var e;!this.Pi&&(e=ke.__PosthogExtensions__)!=null&&e.generateProductTours&&(this.Pi=ke.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(e,n){if(n===void 0&&(n=!1),!Ze(this.Ti)||n){var r=this._instance.persistence;if(r){var i=r.props[pm];if(Ze(i)&&!n)return this.Ti=i,void e(i,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:o=>{var s=o.statusCode;if(s!==200||!o.json){var a="Product Tours API could not be loaded, status: "+s;return VI.error(a),void e([],{isLoaded:!1,error:a})}var l=Ze(o.json.product_tours)?o.json.product_tours:[];this.Ti=l,r&&r.register({[pm]:l}),e(l,{isLoaded:!0})}})}else e(this.Ti,{isLoaded:!0})}getActiveProductTours(e){Je(this.Pi)?e([],{isLoaded:!1,error:"Product tours not loaded"}):this.Pi.getActiveProductTours(e)}showProductTour(e){var n;(n=this.Pi)==null||n.showTourById(e)}previewTour(e){this.Pi?this.Pi.previewTour(e):this.it((()=>{var n;this.Ii(),(n=this.Pi)==null||n.previewTour(e)}))}dismissProductTour(){var e;(e=this.Pi)==null||e.dismissTour("user_clicked_skip")}nextStep(){var e;(e=this.Pi)==null||e.nextStep()}previousStep(){var e;(e=this.Pi)==null||e.previousStep()}clearCache(){var e;this.Ti=null,(e=this._instance.persistence)==null||e.unregister(pm)}resetTour(e){var n;(n=this.Pi)==null||n.resetTour(e)}resetAllTours(){var e;(e=this.Pi)==null||e.resetAllTours()}cancelPendingTour(e){var n;(n=this.Pi)==null||n.cancelPendingTour(e)}}var Ql=(function(t){return t.Activation="events",t.Cancellation="cancelEvents",t})({});(function(t){return t.Button="button",t.Tab="tab",t.Selector="selector",t})({}),(function(t){return t.TopLeft="top_left",t.TopRight="top_right",t.TopCenter="top_center",t.MiddleLeft="middle_left",t.MiddleRight="middle_right",t.MiddleCenter="middle_center",t.Left="left",t.Center="center",t.Right="right",t.NextToTrigger="next_to_trigger",t})({}),(function(t){return t.Top="top",t.Left="left",t.Right="right",t.Bottom="bottom",t})({});var mm=(function(t){return t.Popover="popover",t.API="api",t.Widget="widget",t.ExternalSurvey="external_survey",t})({});(function(t){return t.Open="open",t.MultipleChoice="multiple_choice",t.SingleChoice="single_choice",t.Rating="rating",t.Link="link",t})({}),(function(t){return t.NextQuestion="next_question",t.End="end",t.ResponseBased="response_based",t.SpecificQuestion="specific_question",t})({}),(function(t){return t.Once="once",t.Recurring="recurring",t.Always="always",t})({});var zd=(function(t){return t.SHOWN="survey shown",t.DISMISSED="survey dismissed",t.SENT="survey sent",t.ABANDONED="survey abandoned",t})({}),$I=(function(t){return t.SURVEY_ID="$survey_id",t.SURVEY_NAME="$survey_name",t.SURVEY_RESPONSE="$survey_response",t.SURVEY_ITERATION="$survey_iteration",t.SURVEY_ITERATION_START_DATE="$survey_iteration_start_date",t.SURVEY_PARTIALLY_COMPLETED="$survey_partially_completed",t.SURVEY_SUBMISSION_ID="$survey_submission_id",t.SURVEY_QUESTIONS="$survey_questions",t.SURVEY_COMPLETED="$survey_completed",t.PRODUCT_TOUR_ID="$product_tour_id",t})({}),zI=(function(t){return t.Popover="popover",t.Inline="inline",t})({}),dt=At("[Surveys]"),UI="seenSurvey_",DK=(t,e)=>{var n="$survey_"+e+"/"+t.id;return t.current_iteration&&t.current_iteration>0&&(n="$survey_"+e+"/"+t.id+"/"+t.current_iteration),n},WI=t=>((e,n)=>{var r=""+e+n.id;return n.current_iteration&&n.current_iteration>0&&(r=""+e+n.id+"_"+n.current_iteration),r})(UI,t),VK=[mm.Popover,mm.Widget,mm.API],$K={ignoreConditions:!1,ignoreDelay:!1,displayType:zI.Popover};class vm{constructor(){this.Ci={},this.Ci={}}on(e,n){return this.Ci[e]||(this.Ci[e]=[]),this.Ci[e].push(n),()=>{this.Ci[e]=this.Ci[e].filter((r=>r!==n))}}emit(e,n){for(var r of this.Ci[e]||[])r(n);for(var i of this.Ci["*"]||[])i(e,n)}}function da(t,e,n){if(Je(t))return!1;switch(n){case"exact":return t===e;case"contains":var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(r,"i").test(t);case"regex":try{return new RegExp(e).test(t)}catch(i){return!1}default:return!1}}class zK{constructor(e){this.Ri=new vm,this.Fi=(n,r)=>this.Mi(n,r)&&this.Oi(n,r)&&this.Ai(n,r)&&this.Di(n,r),this.Mi=(n,r)=>r==null||!r.event||(n==null?void 0:n.event)===(r==null?void 0:r.event),this._instance=e,this.ji=new Set,this.Li=new Set}init(){var e;if(!fe((e=this._instance)==null?void 0:e.Ni)){var n;(n=this._instance)==null||n.Ni(((r,i)=>{this.on(r,i)}))}}register(e){var n,r;if(!fe((n=this._instance)==null?void 0:n.Ni)&&(e.forEach((s=>{var a,l;(a=this.Li)==null||a.add(s),(l=s.steps)==null||l.forEach((c=>{var u;(u=this.ji)==null||u.add((c==null?void 0:c.event)||"")}))})),(r=this._instance)!=null&&r.autocapture)){var i,o=new Set;e.forEach((s=>{var a;(a=s.steps)==null||a.forEach((l=>{l!=null&&l.selector&&o.add(l==null?void 0:l.selector)}))})),(i=this._instance)==null||i.autocapture.setElementSelectors(o)}}on(e,n){var r;n!=null&&e.length!=0&&(this.ji.has(e)||this.ji.has(n==null?void 0:n.event))&&this.Li&&((r=this.Li)==null?void 0:r.size)>0&&this.Li.forEach((i=>{this.Ui(n,i)&&this.Ri.emit("actionCaptured",i.name)}))}zi(e){this.onAction("actionCaptured",(n=>e(n)))}Ui(e,n){if((n==null?void 0:n.steps)==null)return!1;for(var r of n.steps)if(this.Fi(e,r))return!0;return!1}onAction(e,n){return this.Ri.on(e,n)}Oi(e,n){if(n!=null&&n.url){var r,i=e==null||(r=e.properties)==null?void 0:r.$current_url;if(!i||typeof i!="string"||!da(i,n.url,n.url_matching||"contains"))return!1}return!0}Ai(e,n){return!!this.Hi(e,n)&&!!this.Bi(e,n)&&!!this.qi(e,n)}Hi(e,n){var r;if(n==null||!n.href)return!0;var i=this.Wi(e);if(i.length>0)return i.some((a=>da(a.href,n.href,n.href_matching||"exact")));var o,s=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!s&&da((o=s.match(/(?::|")href="(.*?)"/))?o[1]:"",n.href,n.href_matching||"exact")}Bi(e,n){var r;if(n==null||!n.text)return!0;var i=this.Wi(e);if(i.length>0)return i.some((c=>da(c.text,n.text,n.text_matching||"exact")||da(c.$el_text,n.text,n.text_matching||"exact")));var o,s,a,l=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";return!!l&&(o=(function(c){for(var u,h=[],p=/(?::|")text="(.*?)"/g;!Je(u=p.exec(c));)h.includes(u[1])||h.push(u[1]);return h})(l),s=n.text,a=n.text_matching||"exact",o.some((c=>da(c,s,a))))}qi(e,n){var r,i;if(n==null||!n.selector)return!0;var o=e==null||(r=e.properties)==null?void 0:r.$element_selectors;if(o!=null&&o.includes(n.selector))return!0;var s=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";if(n.selector_regex&&s)try{return new RegExp(n.selector_regex).test(s)}catch(a){return!1}return!1}Wi(e){var n;return(e==null||(n=e.properties)==null?void 0:n.$elements)==null?[]:e==null?void 0:e.properties.$elements}Di(e,n){return n==null||!n.properties||n.properties.length===0||LI(n.properties.reduce(((r,i)=>{var o=Ze(i.value)?i.value.map(String):i.value!=null?[String(i.value)]:[];return r[i.key]={values:o,operator:i.operator||"exact"},r}),{}),e==null?void 0:e.properties)}}class UK{constructor(e){this._instance=e,this.Gi=new Map,this.Vi=new Map,this.Ji=new Map}Ki(e,n){return!!e&&LI(e.propertyFilters,n==null?void 0:n.properties)}Yi(e,n){var r=new Map;return e.forEach((i=>{var o;(o=i.conditions)==null||(o=o[n])==null||(o=o.values)==null||o.forEach((s=>{if(s!=null&&s.name){var a=r.get(s.name)||[];a.push(i.id),r.set(s.name,a)}}))})),r}Xi(e,n,r){var i=(r===Ql.Activation?this.Gi:this.Vi).get(e),o=[];return this.Qi((s=>{o=s.filter((a=>i==null?void 0:i.includes(a.id)))})),o.filter((s=>{var a,l=(a=s.conditions)==null||(a=a[r])==null||(a=a.values)==null?void 0:a.find((c=>c.name===e));return this.Ki(l,n)}))}register(e){var n;fe((n=this._instance)==null?void 0:n.Ni)||(this.Zi(e),this.te(e))}te(e){var n=e.filter((r=>{var i,o;return((i=r.conditions)==null?void 0:i.actions)&&((o=r.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0}));n.length!==0&&(this.ie==null&&(this.ie=new zK(this._instance),this.ie.init(),this.ie.zi((r=>{this.onAction(r)}))),n.forEach((r=>{var i,o,s,a,l;r.conditions&&(i=r.conditions)!=null&&i.actions&&(o=r.conditions)!=null&&(o=o.actions)!=null&&o.values&&((s=r.conditions)==null||(s=s.actions)==null||(s=s.values)==null?void 0:s.length)>0&&((a=this.ie)==null||a.register(r.conditions.actions.values),(l=r.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach((c=>{if(c&&c.name){var u=this.Ji.get(c.name);u&&u.push(r.id),this.Ji.set(c.name,u||[r.id])}})))})))}Zi(e){var n,r=e.filter((o=>{var s,a;return((s=o.conditions)==null?void 0:s.events)&&((a=o.conditions)==null||(a=a.events)==null||(a=a.values)==null?void 0:a.length)>0})),i=e.filter((o=>{var s,a;return((s=o.conditions)==null?void 0:s.cancelEvents)&&((a=o.conditions)==null||(a=a.cancelEvents)==null||(a=a.values)==null?void 0:a.length)>0}));(r.length!==0||i.length!==0)&&((n=this._instance)==null||n.Ni(((o,s)=>{this.onEvent(o,s)})),this.Gi=this.Yi(e,Ql.Activation),this.Vi=this.Yi(e,Ql.Cancellation))}onEvent(e,n){var r,i=this.ee(),o=this.re(),s=this.se(),a=((r=this._instance)==null||(r=r.persistence)==null?void 0:r.props[o])||[];if(s===e&&n&&a.length>0){var l,c;i.info("event matched, removing item from activated items",{event:e,eventPayload:n,existingActivatedItems:a});var u=(n==null||(l=n.properties)==null?void 0:l.$survey_id)||(n==null||(c=n.properties)==null?void 0:c.$product_tour_id);if(u){var h=a.indexOf(u);h>=0&&(a.splice(h,1),this.ne(a))}}else{if(this.Vi.has(e)){var p=this.Xi(e,n,Ql.Cancellation);p.length>0&&(i.info("cancel event matched, cancelling items",{event:e,itemsToCancel:p.map((b=>b.id))}),p.forEach((b=>{var m=a.indexOf(b.id);m>=0&&a.splice(m,1),this.oe(b.id)})),this.ne(a))}if(this.Gi.has(e)){i.info("event name matched",{event:e,eventPayload:n,items:this.Gi.get(e)});var g=this.Xi(e,n,Ql.Activation);this.ne(a.concat(g.map((b=>b.id))||[]))}}}onAction(e){var n,r=this.re(),i=((n=this._instance)==null||(n=n.persistence)==null?void 0:n.props[r])||[];this.Ji.has(e)&&this.ne(i.concat(this.Ji.get(e)||[]))}ne(e){var n,r=this.ee(),i=this.re(),o=[...new Set(e)].filter((s=>!this.ae(s)));r.info("updating activated items",{activatedItems:o}),(n=this._instance)==null||(n=n.persistence)==null||n.register({[i]:o})}getActivatedIds(){var e,n=this.re(),r=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[n];return r||[]}getEventToItemsMap(){return this.Gi}le(){return this.ie}}class WK extends UK{constructor(e){super(e)}re(){return"$surveys_activated"}se(){return zd.SHOWN}Qi(e){var n;(n=this._instance)==null||n.getSurveys(e)}oe(e){var n;(n=this._instance)==null||n.cancelPendingSurvey(e)}ee(){return dt}ae(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}}class HK{constructor(e){this.ue=void 0,this._surveyManager=null,this.he=!1,this.de=!1,this.ve=[],this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){if(!this._instance.config.disable_surveys){var n=e.surveys;if(Je(n))return dt.warn("Flags not loaded yet. Not loading surveys.");var r=Ze(n);this.ue=r?n.length>0:n,dt.info("flags response received, isSurveysEnabled: "+this.ue),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var e=[],n=0;n<localStorage.length;n++){var r=localStorage.key(n);(r!=null&&r.startsWith(UI)||r!=null&&r.startsWith("inProgressSurvey_"))&&e.push(r)}e.forEach((i=>localStorage.removeItem(i)))}loadIfEnabled(){if(!this._surveyManager)if(this.de)dt.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)dt.info("Disabled. Not loading surveys.");else if(this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())dt.info("Not loading surveys in cookieless mode without consent.");else{var e=ke==null?void 0:ke.__PosthogExtensions__;if(e){if(!fe(this.ue)||this._instance.config.advanced_enable_surveys){var n=this.ue||this._instance.config.advanced_enable_surveys;this.de=!0;try{var r=e.generateSurveys;if(r)return void this.ce(r,n);var i=e.loadExternalDependency;if(!i)return void this.fe("PostHog loadExternalDependency extension not found.");i(this._instance,"surveys",(o=>{o||!e.generateSurveys?this.fe("Could not load surveys script",o):this.ce(e.generateSurveys,n)}))}catch(o){throw this.fe("Error initializing surveys",o),o}finally{this.de=!1}}}else dt.error("PostHog Extensions not found.")}}ce(e,n){this._surveyManager=e(this._instance,n),this._surveyEventReceiver=new WK(this._instance),dt.info("Surveys loaded successfully"),this.pe({isLoaded:!0})}fe(e,n){dt.error(e,n),this.pe({isLoaded:!1,error:e})}onSurveysLoaded(e){return this.ve.push(e),this._surveyManager&&this.pe({isLoaded:!0}),()=>{this.ve=this.ve.filter((n=>n!==e))}}getSurveys(e,n){if(n===void 0&&(n=!1),this._instance.config.disable_surveys)return dt.info("Disabled. Not loading surveys."),e([]);var r=this._instance.get_property(jp);if(r&&!n)return e(r,{isLoaded:!0});if(this.he)return e([],{isLoaded:!1,error:"Surveys are already being loaded"});try{this.he=!0,this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this._instance.config.token),method:"GET",timeout:this._instance.config.surveys_request_timeout_ms,callback:i=>{var o;this.he=!1;var s=i.statusCode;if(s!==200||!i.json){var a="Surveys API could not be loaded, status: "+s;return dt.error(a),e([],{isLoaded:!1,error:a})}var l,c=i.json.surveys||[],u=c.filter((h=>(function(p){return!(!p.start_date||p.end_date)})(h)&&((function(p){var g;return!((g=p.conditions)==null||(g=g.events)==null||(g=g.values)==null||!g.length)})(h)||(function(p){var g;return!((g=p.conditions)==null||(g=g.actions)==null||(g=g.values)==null||!g.length)})(h))));return u.length>0&&((l=this._surveyEventReceiver)==null||l.register(u)),(o=this._instance.persistence)==null||o.register({[jp]:c}),e(c,{isLoaded:!0})}})}catch(i){throw this.he=!1,i}}pe(e){for(var n of this.ve)try{if(!e.isLoaded)return n([],e);this.getSurveys(n)}catch(r){dt.error("Error in survey callback",r)}}getActiveMatchingSurveys(e,n){if(n===void 0&&(n=!1),!Je(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(e,n);dt.warn("init was not called")}ge(e){var n=null;return this.getSurveys((r=>{var i;n=(i=r.find((o=>o.id===e)))!==null&&i!==void 0?i:null})),n}_e(e){if(Je(this._surveyManager))return{eligible:!1,reason:"SDK is not enabled or survey functionality is not yet loaded"};var n=typeof e=="string"?this.ge(e):e;return n?this._surveyManager.checkSurveyEligibility(n):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(e){if(Je(this._surveyManager))return dt.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var n=this._e(e);return{visible:n.eligible,disabledReason:n.reason}}canRenderSurveyAsync(e,n){return Je(this._surveyManager)?(dt.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"})):new Promise((r=>{this.getSurveys((i=>{var o,s=(o=i.find((l=>l.id===e)))!==null&&o!==void 0?o:null;if(s){var a=this._e(s);r({visible:a.eligible,disabledReason:a.reason})}else r({visible:!1,disabledReason:"Survey not found"})}),n)}))}renderSurvey(e,n){var r;if(Je(this._surveyManager))dt.warn("init was not called");else{var i=typeof e=="string"?this.ge(e):e;if(i!=null&&i.id)if(VK.includes(i.type)){var o=me==null?void 0:me.querySelector(n);if(o)return(r=i.appearance)!=null&&r.surveyPopupDelaySeconds?(dt.info("Rendering survey "+i.id+" with delay of "+i.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var s,a;dt.info("Rendering survey "+i.id+" with delay of "+((s=i.appearance)==null?void 0:s.surveyPopupDelaySeconds)+" seconds"),(a=this._surveyManager)==null||a.renderSurvey(i,o),dt.info("Survey "+i.id+" rendered")}),1e3*i.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(i,o);dt.warn("Survey element not found")}else dt.warn("Surveys of type "+i.type+" cannot be rendered in the app");else dt.warn("Survey not found")}}displaySurvey(e,n){var r;if(Je(this._surveyManager))dt.warn("init was not called");else{var i=this.ge(e);if(i){var o=i;if((r=i.appearance)!=null&&r.surveyPopupDelaySeconds&&n.ignoreDelay&&(o=be({},i,{appearance:be({},i.appearance,{surveyPopupDelaySeconds:0})})),n.ignoreConditions===!1){var s=this.canRenderSurvey(i);if(!s.visible)return void dt.warn("Survey is not eligible to be displayed: ",s.disabledReason)}n.displayType!==zI.Inline?this._surveyManager.handlePopoverSurvey(o):this.renderSurvey(o,n.selector)}else dt.warn("Survey not found")}}cancelPendingSurvey(e){Je(this._surveyManager)?dt.warn("init was not called"):this._surveyManager.cancelSurvey(e)}handlePageUnload(){var e;(e=this._surveyManager)==null||e.handlePageUnload()}}var ec=At("[Conversations]");class jK{constructor(e){this.me=void 0,this._conversationsManager=null,this.be=!1,this.ye=null,this._instance=e}onRemoteConfig(e){if(!this._instance.config.disable_conversations){var n=e.conversations;Je(n)||(Ai(n)?this.me=n:(this.me=n.enabled,this.ye=n),this.loadIfEnabled())}}reset(){var e;(e=this._conversationsManager)==null||e.reset(),this._conversationsManager=null,this.me=void 0,this.ye=null}loadIfEnabled(){if(!this._conversationsManager&&!this.be&&!(this._instance.config.disable_conversations||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var e=ke==null?void 0:ke.__PosthogExtensions__;if(e&&!fe(this.me)&&this.me)if(this.ye&&this.ye.token){if((function(i){var o;if(!i||i.length===0)return!0;var s=oe==null||(o=oe.location)==null?void 0:o.hostname;return!s||i.some((a=>{var l=(function(u){var h=u.replace(/^https?:\/\//,"");return(h=h.split("/")[0].split("?")[0].split(":")[0])||null})(a);if(!l)return!1;if(l.startsWith("*.")){var c=l.slice(2);return s.endsWith("."+c)||s===c}return s===l}))})(this.ye.domains)){this.be=!0;try{var n=e.initConversations;if(n)return this.we(n),void(this.be=!1);var r=e.loadExternalDependency;if(!r)return void this.xe("PostHog loadExternalDependency extension not found.");r(this._instance,"conversations",(i=>{i||!e.initConversations?this.xe("Could not load conversations script",i):this.we(e.initConversations),this.be=!1}))}catch(i){this.xe("Error initializing conversations",i),this.be=!1}}}else ec.error("Conversations enabled but missing token in remote config.")}}we(e){if(this.ye)try{this._conversationsManager=e(this.ye,this._instance),ec.info("Conversations loaded successfully")}catch(n){this.xe("Error completing conversations initialization",n)}else ec.error("Cannot complete initialization: remote config is null")}xe(e,n){ec.error(e,n),this._conversationsManager=null,this.be=!1}enable(){this._conversationsManager?this._conversationsManager.enable():ec.warn("Conversations not loaded yet.")}disable(){this._conversationsManager&&this._conversationsManager.disable()}isLoaded(){return!Pr(this._conversationsManager)}isEnabled(){return this.me===!0}}var HI=At("[RateLimiter]");class qK{constructor(e){var n,r;this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=i=>{var o=i.text;if(o&&o.length)try{(JSON.parse(o).quota_limited||[]).forEach((s=>{HI.info((s||"events")+" is quota limited."),this.serverLimits[s]=new Date().getTime()+6e4}))}catch(s){return void HI.warn('could not rate limit - continuing. Error: "'+(s==null?void 0:s.message)+'"',{text:o})}},this.instance=e,this.captureEventsPerSecond=((n=e.config.rate_limiting)==null?void 0:n.events_per_second)||10,this.captureEventsBurstLimit=Math.max(((r=e.config.rate_limiting)==null?void 0:r.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}clientRateLimitContext(e){var n,r,i;e===void 0&&(e=!1);var o=new Date().getTime(),s=(n=(r=this.instance.persistence)==null?void 0:r.get_property(Gp))!==null&&n!==void 0?n:{tokens:this.captureEventsBurstLimit,last:o};s.tokens+=(o-s.last)/1e3*this.captureEventsPerSecond,s.last=o,s.tokens>this.captureEventsBurstLimit&&(s.tokens=this.captureEventsBurstLimit);var a=s.tokens<1;return a||e||(s.tokens=Math.max(0,s.tokens-1)),!a||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+this.captureEventsPerSecond+" events per second and "+this.captureEventsBurstLimit+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=a,(i=this.instance.persistence)==null||i.set_property(Gp,s),{isRateLimited:a,remainingTokens:s.tokens}}isServerRateLimited(e){var n=this.serverLimits[e||"events"]||!1;return n!==!1&&new Date().getTime()<n}}var Zo=At("[RemoteConfig]");class GK{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=ke._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Ee(e){var n,r;(n=ke.__PosthogExtensions__)!=null&&n.loadExternalDependency?(r=ke.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):(Zo.error("PostHog Extensions not found. Cannot load remote config."),e())}$e(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:n=>{e(n.json)}})}load(){try{if(this.remoteConfig)return Zo.info("Using preloaded remote config",this.remoteConfig),void this.pi(this.remoteConfig);if(this._instance.O())return void Zo.warn("Remote config is disabled. Falling back to local config.");this.Ee((e=>{if(!e)return Zo.info("No config found after loading remote JS config. Falling back to JSON."),void this.$e((n=>{this.pi(n)}));this.pi(e)}))}catch(e){Zo.error("Error loading remote config",e)}}pi(e){e?this._instance.config.__preview_remote_config?(this._instance.pi(e),e.hasFeatureFlags!==!1&&this._instance.featureFlags.ensureFlagsLoaded()):Zo.info("__preview_remote_config is disabled. Logging config instead",e):Zo.error("Failed to fetch remote config from PostHog.")}}var ym=3e3;class KK{constructor(e,n){this.Se=!0,this.ke=[],this.Pe=ti((n==null?void 0:n.flush_interval_ms)||ym,250,5e3,ye.createLogger("flush interval"),ym),this.Te=e}enqueue(e){this.ke.push(e),this.Ie||this.Ce()}unload(){this.Re();var e=this.ke.length>0?this.Fe():{},n=Object.values(e);[...n.filter((r=>r.url.indexOf("/e")===0)),...n.filter((r=>r.url.indexOf("/e")!==0))].map((r=>{this.Te(be({},r,{transport:"sendBeacon"}))}))}enable(){this.Se=!1,this.Ce()}Ce(){var e=this;this.Se||(this.Ie=setTimeout((()=>{if(this.Re(),this.ke.length>0){var n=this.Fe(),r=function(){var o=n[i],s=new Date().getTime();o.data&&Ze(o.data)&&ut(o.data,(a=>{a.offset=Math.abs(a.timestamp-s),delete a.timestamp})),e.Te(o)};for(var i in n)r()}}),this.Pe))}Re(){clearTimeout(this.Ie),this.Ie=void 0}Fe(){var e={};return ut(this.ke,(n=>{var r,i=n,o=(i?i.batchKey:null)||i.url;fe(e[o])&&(e[o]=be({},i,{data:[]})),(r=e[o].data)==null||r.push(i.data)})),this.ke=[],e}}var YK=["retriesPerformedSoFar"];class XK{constructor(e){this.Me=!1,this.Oe=3e3,this.ke=[],this._instance=e,this.ke=[],this.Ae=!0,!fe(oe)&&"onLine"in oe.navigator&&(this.Ae=oe.navigator.onLine,this.De=()=>{this.Ae=!0,this.Lt()},this.je=()=>{this.Ae=!1},Bt(oe,"online",this.De),Bt(oe,"offline",this.je))}get length(){return this.ke.length}retriableRequest(e){var{retriesPerformedSoFar:n}=e,r=YE(e,YK);ei(n)&&n>0&&(r.url=Fd(r.url,{retry_count:n})),this._instance._send_request(be({},r,{callback:i=>{i.statusCode!==200&&(i.statusCode<400||i.statusCode>=500)&&(n!=null?n:0)<10?this.Le(be({retriesPerformedSoFar:n},r)):r.callback==null||r.callback(i)}}))}Le(e){var n=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=n+1;var r=(function(s){var a=3e3*Math.pow(2,s),l=a/2,c=Math.min(18e5,a),u=(Math.random()-.5)*(c-l);return Math.ceil(c+u)})(n),i=Date.now()+r;this.ke.push({retryAt:i,requestOptions:e});var o="Enqueued failed request for retry in "+r;navigator.onLine||(o+=" (Browser is offline)"),ye.warn(o),this.Me||(this.Me=!0,this.Ne())}Ne(){if(this.Ue&&clearTimeout(this.Ue),this.ke.length===0)return this.Me=!1,void(this.Ue=void 0);this.Ue=setTimeout((()=>{this.Ae&&this.ke.length>0&&this.Lt(),this.Ne()}),this.Oe)}Lt(){var e=Date.now(),n=[],r=this.ke.filter((o=>o.retryAt<e||(n.push(o),!1)));if(this.ke=n,r.length>0)for(var{requestOptions:i}of r)this.retriableRequest(i)}unload(){for(var{requestOptions:e}of(this.Ue&&(clearTimeout(this.Ue),this.Ue=void 0),this.Me=!1,fe(oe)||(this.De&&(oe.removeEventListener("online",this.De),this.De=void 0),this.je&&(oe.removeEventListener("offline",this.je),this.je=void 0)),this.ke))try{this._instance._send_request(be({},e,{transport:"sendBeacon"}))}catch(n){ye.error(n)}this.ke=[]}}class ZK{constructor(e){this.ze=()=>{var n,r,i,o;this.He||(this.He={});var s=this.scrollElement(),a=this.scrollY(),l=s?Math.max(0,s.scrollHeight-s.clientHeight):0,c=a+((s==null?void 0:s.clientHeight)||0),u=(s==null?void 0:s.scrollHeight)||0;this.He.lastScrollY=Math.ceil(a),this.He.maxScrollY=Math.max(a,(n=this.He.maxScrollY)!==null&&n!==void 0?n:0),this.He.maxScrollHeight=Math.max(l,(r=this.He.maxScrollHeight)!==null&&r!==void 0?r:0),this.He.lastContentY=c,this.He.maxContentY=Math.max(c,(i=this.He.maxContentY)!==null&&i!==void 0?i:0),this.He.maxContentHeight=Math.max(u,(o=this.He.maxContentHeight)!==null&&o!==void 0?o:0)},this._instance=e}getContext(){return this.He}resetContext(){var e=this.He;return setTimeout(this.ze,0),e}startMeasuringScrollPosition(){Bt(oe,"scroll",this.ze,{capture:!0}),Bt(oe,"scrollend",this.ze,{capture:!0}),Bt(oe,"resize",this.ze)}scrollElement(){if(!this._instance.config.scroll_root_selector)return oe==null?void 0:oe.document.documentElement;var e=Ze(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var n of e){var r=oe==null?void 0:oe.document.querySelector(n);if(r)return r}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return oe&&(oe.scrollY||oe.pageYOffset||oe.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return oe&&(oe.scrollX||oe.pageXOffset||oe.document.documentElement.scrollLeft)||0}}var JK=t=>vI(t==null?void 0:t.config.mask_personal_data_properties,t==null?void 0:t.config.custom_personal_data_properties);class jI{constructor(e,n,r,i){this.Be=o=>{var s=this.qe();if(!s||s.sessionId!==o){var a={sessionId:o,props:this.We(this._instance)};this.Ge.register({[qp]:a})}},this._instance=e,this.Ve=n,this.Ge=r,this.We=i||JK,this.Ve.onSessionId(this.Be)}qe(){return this.Ge.props[qp]}getSetOnceProps(){var e,n=(e=this.qe())==null?void 0:e.props;return n?"r"in n?yI(n):{$referring_domain:n.referringDomain,$pathname:n.initialPathName,utm_source:n.utm_source,utm_campaign:n.utm_campaign,utm_medium:n.utm_medium,utm_content:n.utm_content,utm_term:n.utm_term}:{}}getSessionProps(){var e={};return ut($p(this.getSetOnceProps()),((n,r)=>{r==="$current_url"&&(r="url"),e["$session_entry_"+Cp(r)]=n})),e}}var bm=At("[SessionId]");class qI{on(e,n){return this.Je.on(e,n)}constructor(e,n,r){var i;if(this.Ke=[],this.Ye=void 0,this.Je=new vm,this.Xe=(u,h)=>Math.abs(u-h)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode==="always")throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.R=e.config,this.Ge=e.persistence,this.Qe=void 0,this.Ze=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.tr=n||so,this.ir=r||so;var o=this.R.persistence_name||this.R.token,s=this.R.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*ti(s,60,36e3,bm.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.er(),this.rr="ph_"+o+"_window_id",this.sr="ph_"+o+"_primary_window_exists",this.nr()){var a=_n.W(this.rr),l=_n.W(this.sr);a&&!l?this.Qe=a:_n.V(this.rr),_n.G(this.sr,!0)}if((i=this.R.bootstrap)!=null&&i.sessionID)try{var c=(u=>{var h=u.replace(/-/g,"");if(h.length!==32)throw new Error("Not a valid UUID");if(h[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(h.substring(0,12),16)})(this.R.bootstrap.sessionID);this.ar(this.R.bootstrap.sessionID,new Date().getTime(),c)}catch(u){bm.error("Invalid sessionID in bootstrap",u)}this.lr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return fe(this.Ke)&&(this.Ke=[]),this.Ke.push(e),this.Ze&&e(this.Ze,this.Qe),()=>{this.Ke=this.Ke.filter((n=>n!==e))}}nr(){return this.R.persistence!=="memory"&&!this.Ge.xi&&_n.H()}ur(e){e!==this.Qe&&(this.Qe=e,this.nr()&&_n.G(this.rr,e))}hr(){return this.Qe?this.Qe:this.nr()?_n.W(this.rr):null}ar(e,n,r){e===this.Ze&&n===this._sessionActivityTimestamp&&r===this._sessionStartTimestamp||(this._sessionStartTimestamp=r,this._sessionActivityTimestamp=n,this.Ze=e,this.Ge.register({[wd]:[n,e,r]}))}dr(){var e=this.Ge.props[wd];return Ze(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.ar(null,null,null)}destroy(){clearTimeout(this.vr),this.vr=void 0,this.Ye&&oe&&(oe.removeEventListener("beforeunload",this.Ye,{capture:!1}),this.Ye=void 0),this.Ke=[]}lr(){this.Ye=()=>{this.nr()&&_n.V(this.sr)},Bt(oe,"beforeunload",this.Ye,{capture:!1})}checkAndGetSessionAndWindowId(e,n){if(e===void 0&&(e=!1),n===void 0&&(n=null),this.R.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var r=n||new Date().getTime(),[i,o,s]=this.dr(),a=this.hr(),l=ei(s)&&s>0&&Math.abs(r-s)>864e5,c=!1,u=!o,h=!u&&!e&&this.Xe(r,i);u||h||l?(o=this.tr(),a=this.ir(),bm.info("new session ID generated",{sessionId:o,windowId:a,changeReason:{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:l}}),s=r,c=!0):a||(a=this.ir(),c=!0);var p=i===0||!e||l?r:i,g=s===0?new Date().getTime():s;return this.ur(a),this.ar(o,p,g),e||this.er(),c&&this.Ke.forEach((b=>b(o,a,c?{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:l}:void 0))),{sessionId:o,windowId:a,sessionStartTimestamp:g,changeReason:c?{noSessionId:u,activityTimeout:h,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:i}}er(){clearTimeout(this.vr),this.vr=setTimeout((()=>{var[e]=this.dr();if(this.Xe(new Date().getTime(),e)){var n=this.Ze;this.resetSessionId(),this.Je.emit("forcedIdleReset",{idleSessionId:n})}}),1.1*this.sessionTimeoutMs)}}var QK=["$set_once","$set"],co=At("[SiteApps]");class eY{constructor(e){this._instance=e,this.cr=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}pr(e,n){if(n){var r=this.globalsForEvent(n);this.cr.push(r),this.cr.length>1e3&&(this.cr=this.cr.slice(10))}}get siteAppLoaders(){var e;return(e=ke._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.siteApps}init(){if(this.isEnabled){var e=this._instance.Ni(this.pr.bind(this));this.gr=()=>{e(),this.cr=[],this.gr=void 0}}}globalsForEvent(e){var n,r,i,o,s,a,l;if(!e)throw new Error("Event payload is required");var c={},u=this._instance.get_property("$groups")||[],h=this._instance.get_property("$stored_group_properties")||{};for(var[p,g]of Object.entries(h))c[p]={id:u[p],type:p,properties:g};var{$set_once:b,$set:m}=e;return{event:be({},YE(e,QK),{properties:be({},e.properties,m?{$set:be({},(n=(r=e.properties)==null?void 0:r.$set)!==null&&n!==void 0?n:{},m)}:{},b?{$set_once:be({},(i=(o=e.properties)==null?void 0:o.$set_once)!==null&&i!==void 0?i:{},b)}:{}),elements_chain:(s=(a=e.properties)==null?void 0:a.$elements_chain)!==null&&s!==void 0?s:"",distinct_id:(l=e.properties)==null?void 0:l.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:c}}setupSiteApp(e){var n=this.apps[e.id],r=()=>{var a;!n.errored&&this.cr.length&&(co.info("Processing "+this.cr.length+" events for site app with id "+e.id),this.cr.forEach((l=>n.processEvent==null?void 0:n.processEvent(l))),n.processedBuffer=!0),Object.values(this.apps).every((l=>l.processedBuffer||l.errored))&&((a=this.gr)==null||a.call(this))},i=!1,o=a=>{n.errored=!a,n.loaded=!0,co.info("Site app with id "+e.id+" "+(a?"loaded":"errored")),i&&r()};try{var{processEvent:s}=e.init({posthog:this._instance,callback:a=>{o(a)}});s&&(n.processEvent=s),i=!0}catch(a){co.error("Error while initializing PostHog app with config id "+e.id,a),o(!1)}if(i&&n.loaded)try{r()}catch(a){co.error("Error while processing buffered events PostHog app with config id "+e.id,a),n.errored=!0}}_r(){var e=this.siteAppLoaders||[];for(var n of e)this.apps[n.id]={id:n.id,loaded:!1,errored:!1,processedBuffer:!1};for(var r of e)this.setupSiteApp(r)}mr(e){if(Object.keys(this.apps).length!==0){var n=this.globalsForEvent(e);for(var r of Object.values(this.apps))try{r.processEvent==null||r.processEvent(n)}catch(i){co.error("Error while processing event "+e.event+" for site app "+r.id,i)}}}onRemoteConfig(e){var n,r,i,o=this;if((n=this.siteAppLoaders)!=null&&n.length)return this.isEnabled?(this._r(),void this._instance.on("eventCaptured",(c=>this.mr(c)))):void co.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((r=this.gr)==null||r.call(this),(i=e.siteApps)!=null&&i.length)if(this.isEnabled){var s=function(c){var u;ke["__$$ph_site_app_"+c]=o._instance,(u=ke.__PosthogExtensions__)==null||u.loadSiteApp==null||u.loadSiteApp(o._instance,l,(h=>{if(h)return co.error("Error while initializing PostHog app with config id "+c,h)}))};for(var{id:a,url:l}of e.siteApps)s(a)}else co.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var GI=function(t,e){if(!t)return!1;var n=t.userAgent;if(n&&XE(n,e))return!0;try{var r=t==null?void 0:t.userAgentData;if(r!=null&&r.brands&&r.brands.some((i=>XE(i==null?void 0:i.brand,e))))return!0}catch(i){}return!!t.webdriver},tc=(function(t){return t.US="us",t.EU="eu",t.CUSTOM="custom",t})({}),KI="i.posthog.com";class tY{constructor(e){this.br={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,n=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return n||(n=this.apiHost.replace("."+KI,".posthog.com")),n==="https://app.posthog.com"?"https://us.posthog.com":n}get region(){return this.br[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.br[this.apiHost]=tc.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this.br[this.apiHost]=tc.EU:this.br[this.apiHost]=tc.CUSTOM),this.br[this.apiHost]}endpointFor(e,n){if(n===void 0&&(n=""),n&&(n=n[0]==="/"?n:"/"+n),e==="ui")return this.uiHost+n;if(e==="flags")return this.flagsApiHost+n;if(this.region===tc.CUSTOM)return this.apiHost+n;var r=KI+n;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}}var nY={icontains:(t,e)=>!!oe&&e.href.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>!!oe&&e.href.toLowerCase().indexOf(t.toLowerCase())===-1,regex:(t,e)=>!!oe&&Vd(e.href,t),not_regex:(t,e)=>!!oe&&!Vd(e.href,t),exact:(t,e)=>e.href===t,is_not:(t,e)=>e.href!==t};class Tn{constructor(e){var n=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(r){r===void 0&&(r=!1),n.getWebExperiments((i=>{Tn.yr("retrieved web experiments from the server"),n.wr=new Map,i.forEach((o=>{if(o.feature_flag_key){var s;n.wr&&(Tn.yr("setting flag key ",o.feature_flag_key," to web experiment ",o),(s=n.wr)==null||s.set(o.feature_flag_key,o));var a=n._instance.getFeatureFlag(o.feature_flag_key);nn(a)&&o.variants[a]&&n.Er(o.name,a,o.variants[a].transforms)}else if(o.variants)for(var l in o.variants){var c=o.variants[l];Tn.$r(c)&&n.Er(o.name,l,c.transforms)}}))}),r)},this._instance=e,this._instance.onFeatureFlags((r=>{this.onFeatureFlags(r)}))}onFeatureFlags(e){if(this._is_bot())Tn.yr("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(Je(this.wr))return this.wr=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Tn.yr("applying feature flags",e),e.forEach((n=>{var r;if(this.wr&&(r=this.wr)!=null&&r.has(n)){var i,o=this._instance.getFeatureFlag(n),s=(i=this.wr)==null?void 0:i.get(n);o&&s!=null&&s.variants[o]&&this.Er(s.name,o,s.variants[o].transforms)}}))}}previewWebExperiment(){var e=Tn.getWindowLocation();if(e!=null&&e.search){var n=kd(e==null?void 0:e.search,"__experiment_id"),r=kd(e==null?void 0:e.search,"__experiment_variant");n&&r&&(Tn.yr("previewing web experiments "+n+" && "+r),this.getWebExperiments((i=>{this.Sr(parseInt(n),r,i)}),!1,!0))}}loadIfEnabled(){this._instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,n,r){if(this._instance.config.disable_web_experiments&&!r)return e([]);var i=this._instance.get_property("$web_experiments");if(i&&!n)return e(i);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this._instance.config.token),method:"GET",callback:o=>{if(o.statusCode!==200||!o.json)return e([]);var s=o.json.experiments||[];return e(s)}})}Sr(e,n,r){var i=r.filter((o=>o.id===e));i&&i.length>0&&(Tn.yr("Previewing web experiment ["+i[0].name+"] with variant ["+n+"]"),this.Er(i[0].name,n,i[0].variants[n].transforms))}static $r(e){return!Je(e.conditions)&&Tn.kr(e)&&Tn.Pr(e)}static kr(e){var n;if(Je(e.conditions)||Je((n=e.conditions)==null?void 0:n.url))return!0;var r,i,o,s=Tn.getWindowLocation();return!!s&&((r=e.conditions)==null||!r.url||nY[(i=(o=e.conditions)==null?void 0:o.urlMatchType)!==null&&i!==void 0?i:"icontains"](e.conditions.url,s))}static getWindowLocation(){return oe==null?void 0:oe.location}static Pr(e){var n;if(Je(e.conditions)||Je((n=e.conditions)==null?void 0:n.utm))return!0;var r=hI();if(r.utm_source){var i,o,s,a,l,c,u,h,p=(i=e.conditions)==null||(i=i.utm)==null||!i.utm_campaign||((o=e.conditions)==null||(o=o.utm)==null?void 0:o.utm_campaign)==r.utm_campaign,g=(s=e.conditions)==null||(s=s.utm)==null||!s.utm_source||((a=e.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==r.utm_source,b=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((c=e.conditions)==null||(c=c.utm)==null?void 0:c.utm_medium)==r.utm_medium,m=(u=e.conditions)==null||(u=u.utm)==null||!u.utm_term||((h=e.conditions)==null||(h=h.utm)==null?void 0:h.utm_term)==r.utm_term;return p&&b&&m&&g}return!1}static yr(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];ye.info("[WebExperiments] "+e,r)}Er(e,n,r){this._is_bot()?Tn.yr("Refusing to render web experiment since the viewer is a likely bot"):n!=="control"?r.forEach((i=>{if(i.selector){var o;Tn.yr("applying transform of variant "+n+" for experiment "+e+" ",i);var s=(o=document)==null?void 0:o.querySelectorAll(i.selector);s==null||s.forEach((a=>{var l=a;i.html&&(l.innerHTML=i.html),i.css&&l.setAttribute("style",i.css)}))}})):Tn.yr("Control variants leave the page unmodified.")}_is_bot(){return ur&&this._instance?GI(ur,this._instance.config.custom_blocked_useragents):void 0}}var rY=At("[PostHog ExternalIntegrations]"),iY={intercom:"intercom-integration",crispChat:"crisp-chat-integration"};class oY{constructor(e){this._instance=e}it(e,n){var r;(r=ke.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this._instance,e,(i=>{if(i)return rY.error("failed to load script",i);n()}))}startIfEnabledOrStop(){var e=this,n=function(s){var a,l,c;!i||(a=ke.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[s]||e.it(iY[s],(()=>{var u;(u=ke.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[s])==null||u.start(e._instance)})),!i&&(l=ke.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[s]&&((c=ke.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[s])==null||c.stop())};for(var[r,i]of Object.entries((o=this._instance.config.integrations)!==null&&o!==void 0?o:{})){var o;n(r)}}}var _m="[SessionRecording]",nc=At(_m);class YI{get started(){var e;return!((e=this.Tr)==null||!e.isStarted)}get status(){return this.Tr?this.Tr.status:this.Ir&&!this.Cr?"disabled":"lazy_loading"}constructor(e){if(this._forceAllowLocalhostNetworkCapture=!1,this.Ir=!1,this.Rr=void 0,this._instance=e,!this._instance.sessionManager)throw nc.error("started without valid sessionManager"),new Error(_m+" started without valid sessionManager. This is a bug.");if(this._instance.config.cookieless_mode==="always")throw new Error(_m+' cannot be used with cookieless_mode="always"')}get Cr(){var e,n=!((e=this._instance.get_property(Wp))==null||!e.enabled),r=!this._instance.config.disable_session_recording,i=this._instance.config.disable_session_recording||this._instance.consent.isOptedOut();return oe&&n&&r&&!i}startIfEnabledOrStop(e){var n;if(!this.Cr||(n=this.Tr)==null||!n.isStarted){var r=!fe(Object.assign)&&!fe(Array.from);this.Cr&&r?(this.Fr(e),nc.info("starting")):this.stopRecording()}}Fr(e){var n,r,i;this.Cr&&(ke!=null&&(n=ke.__PosthogExtensions__)!=null&&(n=n.rrweb)!=null&&n.record&&(r=ke.__PosthogExtensions__)!=null&&r.initSessionRecording?this.Mr(e):(i=ke.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,this.Or,(o=>{if(o)return nc.error("could not load recorder",o);this.Mr(e)})))}stopRecording(){var e,n;(e=this.Rr)==null||e.call(this),this.Rr=void 0,(n=this.Tr)==null||n.stop()}Ar(){var e;(e=this._instance.persistence)==null||e.unregister(BS)}Dr(e){if(this._instance.persistence){var n,r,i=this._instance.persistence,o=()=>{var s=e.sessionRecording===!1?void 0:e.sessionRecording,a=s==null?void 0:s.sampleRate,l=Je(a)?null:parseFloat(a);Je(l)&&this.Ar();var c=s==null?void 0:s.minimumDurationMilliseconds;i.register({[Wp]:be({enabled:!!s},s,{networkPayloadCapture:be({capturePerformance:e.capturePerformance},s==null?void 0:s.networkPayloadCapture),canvasRecording:{enabled:s==null?void 0:s.recordCanvas,fps:s==null?void 0:s.canvasFps,quality:s==null?void 0:s.canvasQuality},sampleRate:l,minimumDurationMilliseconds:fe(c)?null:c,endpoint:s==null?void 0:s.endpoint,triggerMatchType:s==null?void 0:s.triggerMatchType,masking:s==null?void 0:s.masking,urlTriggers:s==null?void 0:s.urlTriggers})})};o(),(n=this.Rr)==null||n.call(this),this.Rr=(r=this._instance.sessionManager)==null?void 0:r.onSessionId(o)}}onRemoteConfig(e){"sessionRecording"in e?e.sessionRecording!==!1?(this.Dr(e),this.Ir=!0,this.startIfEnabledOrStop()):this.Ir=!0:nc.info("skipping remote config with no sessionRecording",e)}log(e,n){var r;n===void 0&&(n="log"),(r=this.Tr)!=null&&r.log?this.Tr.log(e,n):nc.warn("log called before recorder was ready")}get Or(){var e,n,r=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.get_property(Wp);return(r==null||(n=r.scriptConfig)==null?void 0:n.script)||"lazy-recorder"}Mr(e){var n,r;if((n=ke.__PosthogExtensions__)==null||!n.initSessionRecording)throw Error("Called on script loaded before session recording is available");this.Tr||(this.Tr=(r=ke.__PosthogExtensions__)==null?void 0:r.initSessionRecording(this._instance),this.Tr._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),this.Tr.start(e)}onRRwebEmit(e){var n;(n=this.Tr)==null||n.onRRwebEmit==null||n.onRRwebEmit(e)}overrideLinkedFlag(){var e,n;this.Tr||(n=this._instance.persistence)==null||n.register({$replay_override_linked_flag:!0}),(e=this.Tr)==null||e.overrideLinkedFlag()}overrideSampling(){var e,n;this.Tr||(n=this._instance.persistence)==null||n.register({$replay_override_sampling:!0}),(e=this.Tr)==null||e.overrideSampling()}overrideTrigger(e){var n,r;this.Tr||(r=this._instance.persistence)==null||r.register({[e==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(n=this.Tr)==null||n.overrideTrigger(e)}get sdkDebugProperties(){var e;return((e=this.Tr)==null?void 0:e.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(e,n){var r;return!((r=this.Tr)==null||!r.tryAddCustomEvent(e,n))}}var rc={},xm=()=>{},ha="posthog",XI=!RK&&(qn==null?void 0:qn.indexOf("MSIE"))===-1&&(qn==null?void 0:qn.indexOf("Mozilla"))===-1,ZI=t=>{var e;return be({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:MG(me==null?void 0:me.location),persistence:"localStorage+cookie",persistence_name:"",loaded:xm,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:t!=null?t:"unset",__preview_deferred_init_extensions:!1,debug:jn&&nn(jn==null?void 0:jn.search)&&jn.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!0,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(oe==null||(e=oe.location)==null?void 0:e.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:n=>{var r="Bad HTTP status: "+n.statusCode+" "+n.text;ye.error(r)},get_device_id:n=>n,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:ym},error_tracking:{},_onCapture:xm,__preview_eager_load_replay:!1},(n=>({rageclick:!(n&&n>="2025-11-30")||{content_ignorelist:!0},capture_pageview:!(n&&n>="2025-05-24")||"history_change",session_recording:n&&n>="2025-11-30"?{strictMinimumDuration:!0}:{}}))(t))},JI=t=>{var e={};fe(t.process_person)||(e.person_profiles=t.process_person),fe(t.xhr_headers)||(e.request_headers=t.xhr_headers),fe(t.cookie_name)||(e.persistence_name=t.cookie_name),fe(t.disable_cookie)||(e.disable_persistence=t.disable_cookie),fe(t.store_google)||(e.save_campaign_params=t.store_google),fe(t.verbose)||(e.debug=t.verbose);var n=Ot({},e,t);return Ze(t.property_blacklist)&&(fe(t.property_denylist)?n.property_denylist=t.property_blacklist:Ze(t.property_denylist)?n.property_denylist=[...t.property_blacklist,...t.property_denylist]:ye.error("Invalid value for property_denylist config: "+t.property_denylist)),n};class sY{constructor(){this.__forceAllowLocalhost=!1}get jr(){return this.__forceAllowLocalhost}set jr(e){ye.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class Ud{get decideEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,n;return(e=(n=this.featureFlags)==null?void 0:n.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){this.webPerformance=new sY,this.Lr=!1,this.version=Ci.LIB_VERSION,this.Nr=new vm,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=ZI(),this.SentryIntegration=uK,this.sentryIntegration=e=>(function(n,r){var i=cI(n,r);return{name:lI,processEvent:o=>i(o)}})(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Ur=!1,this.zr=null,this.Hr=null,this.Br=null,this.featureFlags=new MK(this),this.toolbar=new hK(this),this.scrollManager=new ZK(this),this.pageViewManager=new wK(this),this.surveys=new HK(this),this.conversations=new jK(this),this.experiments=new Tn(this),this.exceptions=new NK(this),this.rateLimiter=new qK(this),this.requestRouter=new tY(this),this.consent=new iK(this),this.externalIntegrations=new oY(this),this.people={set:(e,n,r)=>{var i=nn(e)?{[e]:n}:e;this.setPersonProperties(i),r==null||r({})},set_once:(e,n,r)=>{var i=nn(e)?{[e]:n}:e;this.setPersonProperties(void 0,i),r==null||r({})}},this.on("eventCaptured",(e=>ye.info('send "'+(e==null?void 0:e.event)+'"',e)))}init(e,n,r){if(r&&r!==ha){var i,o=(i=rc[r])!==null&&i!==void 0?i:new Ud;return o._init(e,n,r),rc[r]=o,rc[ha][r]=o,o}return this._init(e,n,r)}_init(e,n,r){var i;if(n===void 0&&(n={}),fe(e)||Ap(e))return ye.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},n.debug=this.qr(n.debug),this.Wr=n,this.Gr=[],n.person_profiles&&(this.Hr=n.person_profiles),this.set_config(Ot({},ZI(n.defaults),JI(n),{name:r,token:e})),this.config.on_xhr_error&&ye.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=n.disable_compression?void 0:Ti.GZipJS;var o=this.Vr();this.persistence=new gm(this.config,o),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new gm(be({},this.config,{persistence:"sessionStorage"}),o);var s=be({},this.persistence.props),a=be({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Jr=new KK((N=>this.Kr(N)),this.config.request_queue_config),this.Yr=new XK(this),this.__request_queue=[];var l=this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut();if(l||(this.sessionManager=new qI(this),this.sessionPropsManager=new jI(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(ye.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.Xr(l)}),0)):(ye.info("Initializing extensions synchronously"),this.Xr(l)),Ci.DEBUG=Ci.DEBUG||this.config.debug,Ci.DEBUG&&ye.info("Starting in debug mode",{this:this,config:n,thisC:be({},this.config),p:s,s:a}),((i=n.bootstrap)==null?void 0:i.distinctID)!==void 0){var c,u,h=this.config.get_device_id(so()),p=(c=n.bootstrap)!=null&&c.isIdentifiedID?h:n.bootstrap.distinctID;this.persistence.set_property(ki,(u=n.bootstrap)!=null&&u.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:n.bootstrap.distinctID,$device_id:p})}if(this.Qr()){var g,b,m=Object.keys(((g=n.bootstrap)==null?void 0:g.featureFlags)||{}).filter((N=>{var T;return!((T=n.bootstrap)==null||(T=T.featureFlags)==null||!T[N])})).reduce(((N,T)=>{var $;return N[T]=(($=n.bootstrap)==null||($=$.featureFlags)==null?void 0:$[T])||!1,N}),{}),x=Object.keys(((b=n.bootstrap)==null?void 0:b.featureFlagPayloads)||{}).filter((N=>m[N])).reduce(((N,T)=>{var $,B;return($=n.bootstrap)!=null&&($=$.featureFlagPayloads)!=null&&$[T]&&(N[T]=(B=n.bootstrap)==null||(B=B.featureFlagPayloads)==null?void 0:B[T]),N}),{});this.featureFlags.receivedFeatureFlags({featureFlags:m,featureFlagPayloads:x})}if(l)this.register_once({distinct_id:$l,$device_id:null},"");else if(!this.get_distinct_id()){var I=this.config.get_device_id(so());this.register_once({distinct_id:I,$device_id:I},""),this.persistence.set_property(ki,"anonymous")}return Bt(oe,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),n.segment?cK(this,(()=>this.Zr())):this.Zr(),ro(this.config._onCapture)&&this.config._onCapture!==xm&&(ye.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(N=>this.config._onCapture(N.event,N)))),this.config.ip&&ye.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this}Xr(e){var n=performance.now();this.historyAutocapture=new lK(this),this.historyAutocapture.startIfEnabled();var r=[];r.push((()=>{new gK(this).startIfEnabledOrStop()})),r.push((()=>{var i;this.siteApps=new eY(this),(i=this.siteApps)==null||i.init()})),e||r.push((()=>{this.sessionRecording=new YI(this),this.sessionRecording.startIfEnabledOrStop()})),this.config.disable_scroll_properties||r.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),r.push((()=>{this.autocapture=new XG(this),this.autocapture.startIfEnabled()})),r.push((()=>{this.surveys.loadIfEnabled()})),r.push((()=>{this.conversations.loadIfEnabled()})),r.push((()=>{this.productTours=new FK(this),this.productTours.loadIfEnabled()})),r.push((()=>{this.heatmaps=new xK(this),this.heatmaps.startIfEnabled()})),r.push((()=>{this.webVitalsAutocapture=new bK(this)})),r.push((()=>{this.exceptionObserver=new aK(this),this.exceptionObserver.startIfEnabledOrStop()})),r.push((()=>{this.deadClicksAutocapture=new sI(this,sK),this.deadClicksAutocapture.startIfEnabled()})),r.push((()=>{if(this.ts){var i=this.ts;this.ts=void 0,this.pi(i)}})),this.es(r,n)}es(e,n){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-n>=30&&e.length>0)return void setTimeout((()=>{this.es(e,n)}),0);var r=e.shift();if(r)try{r()}catch(o){ye.error("Error initializing extension:",o)}}var i=Math.round(performance.now()-n);this.register_for_session({$sdk_debug_extensions_init_method:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",$sdk_debug_extensions_init_time_ms:i}),this.config.__preview_deferred_init_extensions&&ye.info("PostHog extensions initialized ("+i+"ms)")}pi(e){var n,r,i,o,s,a,l,c,u;if(!me||!me.body)return ye.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.pi(e)}),500);this.config.__preview_deferred_init_extensions&&(this.ts=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=Ue(e.supportedCompression,Ti.GZipJS)?Ti.GZipJS:Ue(e.supportedCompression,Ti.Base64)?Ti.Base64:void 0),(n=e.analytics)!=null&&n.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Hr?this.Hr:"identified_only"}),(r=this.siteApps)==null||r.onRemoteConfig(e),(i=this.sessionRecording)==null||i.onRemoteConfig(e),(o=this.autocapture)==null||o.onRemoteConfig(e),(s=this.heatmaps)==null||s.onRemoteConfig(e),this.surveys.onRemoteConfig(e),this.conversations.onRemoteConfig(e),(a=this.productTours)==null||a.onRemoteConfig(e),(l=this.webVitalsAutocapture)==null||l.onRemoteConfig(e),(c=this.exceptionObserver)==null||c.onRemoteConfig(e),this.exceptions.onRemoteConfig(e),(u=this.deadClicksAutocapture)==null||u.onRemoteConfig(e)}Zr(){try{this.config.loaded(this)}catch(e){ye.critical("`loaded` function failed",e)}this.rs(),this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.config.cookieless_mode==="always")&&this.ss()}),1),new GK(this).load(),this.featureFlags.flags()}rs(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Jr)==null||e.enable())}_dom_loaded(){this.is_capturing()&&io(this.__request_queue,(e=>this.Kr(e))),this.__request_queue=[],this.rs()}_handle_unload(){var e,n;this.surveys.handlePageUnload(),this.config.request_batching?(this.ns()&&this.capture("$pageleave"),(e=this.Jr)==null||e.unload(),(n=this.Yr)==null||n.unload()):this.ns()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(XI?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Fd(e.url,{ip:this.config.ip?1:0}),e.headers=be({},this.config.request_headers,e.headers),e.compression=e.compression==="best-available"?this.compression:e.compression,e.disableXHRCredentials=this.config.__preview_disable_xhr_credentials,this.config.__preview_disable_beacon&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(n=>{var r,i,o,s=be({},n);s.timeout=s.timeout||6e4,s.url=Fd(s.url,{_:new Date().getTime().toString(),ver:Ci.LIB_VERSION,compression:s.compression});var a=(r=s.transport)!==null&&r!==void 0?r:"fetch",l=Dd.filter((u=>!s.disableTransport||!u.transport||!s.disableTransport.includes(u.transport))),c=(i=(o=AS(l,(u=>u.transport===a)))==null?void 0:o.method)!==null&&i!==void 0?i:l[0].method;if(!c)throw new Error("No available transport method");c(s)})(be({},e,{callback:n=>{var r,i;this.rateLimiter.checkForLimiting(n),n.statusCode>=400&&((r=(i=this.config).on_request_error)==null||r.call(i,n)),e.callback==null||e.callback(n)}}))))}Kr(e){this.Yr?this.Yr.retriableRequest(e):this._send_request(e)}_execute_array(e){var n,r=[],i=[],o=[];io(e,(a=>{a&&(n=a[0],Ze(n)?o.push(a):ro(a)?a.call(this):Ze(a)&&n==="alias"?r.push(a):Ze(a)&&n.indexOf("capture")!==-1&&ro(this[n])?o.push(a):i.push(a))}));var s=function(a,l){io(a,(function(c){if(Ze(c[0])){var u=l;ut(c,(function(h){u=u[h[0]].apply(u,h.slice(1))}))}else this[c[0]].apply(this,c.slice(1))}),l)};s(r,this),s(i,this),s(o,this)}Qr(){var e,n;return((e=this.config.bootstrap)==null?void 0:e.featureFlags)&&Object.keys((n=this.config.bootstrap)==null?void 0:n.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,n,r){var i;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Jr){if(this.is_capturing())if(!fe(e)&&nn(e)){var o=!this.config.opt_out_useragent_filter&&this._is_bot();if(!(o&&!this.config.__preview_capture_bot_pageviews)){var s=r!=null&&r.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(s==null||!s.isRateLimited){n!=null&&n.$current_url&&!nn(n==null?void 0:n.$current_url)&&(ye.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),n==null||delete n.$current_url),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var a=new Date,l=(r==null?void 0:r.timestamp)||a,c=so(),u={uuid:c,event:e,properties:this.calculateEventProperties(e,n||{},l,c)};e==="$pageview"&&this.config.__preview_capture_bot_pageviews&&o&&(u.event="$bot_pageview",u.properties.$browser_type="bot"),s&&(u.properties.$lib_rate_limit_remaining_tokens=s.remainingTokens),r!=null&&r.$set&&(u.$set=r==null?void 0:r.$set);var h,p=e!=="$groupidentify",g=this.os(r==null?void 0:r.$set_once,p);if(g&&(u.$set_once=g),(u=PG(u,r!=null&&r._noTruncate?null:this.config.properties_string_max_length)).timestamp=l,fe(r==null?void 0:r.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=a),e===zd.DISMISSED||e===zd.SENT){var b=n==null?void 0:n[$I.SURVEY_ID],m=n==null?void 0:n[$I.SURVEY_ITERATION];h={id:b,current_iteration:m},localStorage.getItem(WI(h))||localStorage.setItem(WI(h),"true"),u.$set=be({},u.$set,{[DK({id:b,current_iteration:m},e===zd.SENT?"responded":"dismissed")]:!0})}var x=be({},u.properties.$set,u.$set);if(ta(x)||this.setPersonPropertiesForFlags(x),!Je(this.config.before_send)){var I=this.ls(u);if(!I)return;u=I}this.Nr.emit("eventCaptured",u);var N={method:"POST",url:(i=r==null?void 0:r._url)!==null&&i!==void 0?i:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:u,compression:"best-available",batchKey:r==null?void 0:r._batchKey};return!this.config.request_batching||r&&(r==null||!r._batchKey)||r!=null&&r.send_instantly?this.Kr(N):this.Jr.enqueue(N),u}ye.critical("This capture call is ignored due to client rate limiting.")}}else ye.error("No event name provided to posthog.capture")}else ye.uninitializedWarning("posthog.capture")}Ni(e){return this.on("eventCaptured",(n=>e(n.event,n)))}calculateEventProperties(e,n,r,i,o){if(r=r||new Date,!this.persistence||!this.sessionPersistence)return n;var s=o?void 0:this.persistence.remove_event_timer(e),a=be({},n);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,(this.config.cookieless_mode=="always"||this.config.cookieless_mode=="on_reject"&&this.consent.isExplicitlyOptedOut())&&(a.$cookieless_mode=!0),e==="$snapshot"){var l=be({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!nn(a.distinct_id)&&!ei(a.distinct_id)||Ap(a.distinct_id))&&ye.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var c,u=yK(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:h,windowId:p}=this.sessionManager.checkAndGetSessionAndWindowId(o,r.getTime());a.$session_id=h,a.$window_id=p}this.sessionPropsManager&&Ot(a,this.sessionPropsManager.getSessionProps());try{var g;this.sessionRecording&&Ot(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(g=this.Yr)==null?void 0:g.length}catch(I){a.$sdk_debug_error_capturing_properties=String(I)}if(this.requestRouter.region===tc.CUSTOM&&(a.$lib_custom_api_host=this.config.api_host),c=e!=="$pageview"||o?e!=="$pageleave"||o?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(r):this.pageViewManager.doPageView(r,i),a=Ot(a,c),e==="$pageview"&&me&&(a.title=me.title),!fe(s)){var b=r.getTime()-s;a.$duration=parseFloat((b/1e3).toFixed(3))}qn&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=Ot({},u,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),Ze(this.config.property_denylist)?ut(this.config.property_denylist,(function(I){delete a[I]})):ye.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var m=this.config.sanitize_properties;m&&(ye.error("sanitize_properties is deprecated. Use before_send instead"),a=m(a,e));var x=this.us();return a.$process_person_profile=x,x&&!o&&this.hs("_calculate_event_properties"),a}os(e,n){var r;if(n===void 0&&(n=!0),!this.persistence||!this.us()||this.Lr)return e;var i=this.persistence.get_initial_props(),o=(r=this.sessionPropsManager)==null?void 0:r.getSetOnceProps(),s=Ot({},i,o||{},e||{}),a=this.config.sanitize_properties;return a&&(ye.error("sanitize_properties is deprecated. Use before_send instead"),s=a(s,"$set_once")),n&&(this.Lr=!0),ta(s)?void 0:s}register(e,n){var r;(r=this.persistence)==null||r.register(e,n)}register_once(e,n,r){var i;(i=this.persistence)==null||i.register_once(e,n,r)}register_for_session(e){var n;(n=this.sessionPersistence)==null||n.register(e)}unregister(e){var n;(n=this.persistence)==null||n.unregister(e)}unregister_for_session(e){var n;(n=this.sessionPersistence)==null||n.unregister(e)}ds(e,n){this.register({[e]:n})}getFeatureFlag(e,n){return this.featureFlags.getFeatureFlag(e,n)}getFeatureFlagPayload(e){var n=this.featureFlags.getFeatureFlagPayload(e);try{return JSON.parse(n)}catch(r){return n}}isFeatureEnabled(e,n){return this.featureFlags.isFeatureEnabled(e,n)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateEarlyAccessFeatureEnrollment(e,n,r){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,n,r)}getEarlyAccessFeatures(e,n,r){return n===void 0&&(n=!1),this.featureFlags.getEarlyAccessFeatures(e,n,r)}on(e,n){return this.Nr.on(e,n)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(e)}onSessionId(e){var n,r;return(n=(r=this.sessionManager)==null?void 0:r.onSessionId(e))!==null&&n!==void 0?n:()=>{}}getSurveys(e,n){n===void 0&&(n=!1),this.surveys.getSurveys(e,n)}getActiveMatchingSurveys(e,n){n===void 0&&(n=!1),this.surveys.getActiveMatchingSurveys(e,n)}renderSurvey(e,n){this.surveys.renderSurvey(e,n)}displaySurvey(e,n){n===void 0&&(n=$K),this.surveys.displaySurvey(e,n)}cancelPendingSurvey(e){this.surveys.cancelPendingSurvey(e)}canRenderSurvey(e){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e,n){return n===void 0&&(n=!1),this.surveys.canRenderSurveyAsync(e,n)}identify(e,n,r){if(!this.__loaded||!this.persistence)return ye.uninitializedWarning("posthog.identify");if(ei(e)&&(e=e.toString(),ye.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),e)if(["distinct_id","distinctid"].includes(e.toLowerCase()))ye.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.');else if(e!==$l){if(this.hs("posthog.identify")){var i=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var o=i;this.register_once({$had_persisted_distinct_id:!0,$device_id:o},"")}e!==i&&e!==this.get_property(Bl)&&(this.unregister(Bl),this.register({distinct_id:e}));var s=(this.persistence.get_property(ki)||"anonymous")==="anonymous";e!==i&&s?(this.persistence.set_property(ki,"identified"),this.setPersonPropertiesForFlags(be({},r||{},n||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:i},{$set:n||{},$set_once:r||{}}),this.Br=NI(e,n,r),this.featureFlags.setAnonymousDistinctId(i)):(n||r)&&this.setPersonProperties(n,r),e!==i&&(this.reloadFeatureFlags(),this.unregister(Ed))}}else ye.critical('The string "'+$l+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.');else ye.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,n){if((e||n)&&this.hs("posthog.setPersonProperties")){var r=NI(this.get_distinct_id(),e,n);this.Br!==r?(this.setPersonPropertiesForFlags(be({},n||{},e||{})),this.capture("$set",{$set:e||{},$set_once:n||{}}),this.Br=r):ye.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,n,r){if(e&&n){var i=this.getGroups();i[e]!==n&&this.resetGroupPropertiesForFlags(e),this.register({$groups:be({},i,{[e]:n})}),r&&(this.capture("$groupidentify",{$group_type:e,$group_key:n,$group_set:r}),this.setGroupPropertiesForFlags({[e]:r})),i[e]===n||r||this.reloadFeatureFlags()}else ye.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,n){n===void 0&&(n=!0),this.featureFlags.setPersonPropertiesForFlags(e,n)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,n){n===void 0&&(n=!0),this.hs("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,n)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var n,r,i,o;if(ye.info("reset"),!this.__loaded)return ye.uninitializedWarning("posthog.reset");var s=this.get_property("$device_id");if(this.consent.reset(),(n=this.persistence)==null||n.clear(),(r=this.sessionPersistence)==null||r.clear(),this.surveys.reset(),this.featureFlags.reset(),(i=this.persistence)==null||i.set_property(ki,"anonymous"),(o=this.sessionManager)==null||o.resetSessionId(),this.Br=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:$l,$device_id:null},"");else{var a=this.config.get_device_id(so());this.register_once({distinct_id:a,$device_id:e?a:s},"")}this.register({$last_posthog_reset:new Date().toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,n;return(e=(n=this.sessionManager)==null?void 0:n.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:n,sessionStartTimestamp:r}=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+n);if(e!=null&&e.withTimestamp&&r){var o,s=(o=e.timestampLookBack)!==null&&o!==void 0?o:10;if(!r)return i;i+="?t="+Math.max(Math.floor((new Date().getTime()-r)/1e3)-s,0)}return i}alias(e,n){return e===this.get_property(OS)?(ye.critical("Attempting to create alias for existing People user - aborting."),-2):this.hs("posthog.alias")?(fe(n)&&(n=this.get_distinct_id()),e!==n?(this.ds(Bl,e),this.capture("$create_alias",{alias:e,distinct_id:n})):(ye.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var n=be({},this.config);if(an(e)){var r,i,o,s,a,l,c;Ot(this.config,JI(e));var u=this.Vr();(r=this.persistence)==null||r.update_config(this.config,n,u),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new gm(be({},this.config,{persistence:"sessionStorage"}),u);var h=this.qr(this.config.debug);Ai(h)&&(this.config.debug=h),Ai(this.config.debug)&&(this.config.debug?(Ci.DEBUG=!0,bt.H()&&bt.G("ph_debug","true"),ye.info("set_config",{config:e,oldConfig:n,newConfig:be({},this.config)})):(Ci.DEBUG=!1,bt.H()&&bt.V("ph_debug"))),(i=this.exceptionObserver)==null||i.onConfigChange(),(o=this.sessionRecording)==null||o.startIfEnabledOrStop(),(s=this.autocapture)==null||s.startIfEnabled(),(a=this.heatmaps)==null||a.startIfEnabled(),(l=this.exceptionObserver)==null||l.startIfEnabledOrStop(),this.surveys.loadIfEnabled(),this.vs(),(c=this.externalIntegrations)==null||c.startIfEnabledOrStop()}}startSessionRecording(e){var n=e===!0,r={sampling:n||!(e==null||!e.sampling),linked_flag:n||!(e==null||!e.linked_flag),url_trigger:n||!(e==null||!e.url_trigger),event_trigger:n||!(e==null||!e.event_trigger)};if(Object.values(r).some(Boolean)){var i,o,s,a,l;(i=this.sessionManager)==null||i.checkAndGetSessionAndWindowId(),r.sampling&&((o=this.sessionRecording)==null||o.overrideSampling()),r.linked_flag&&((s=this.sessionRecording)==null||s.overrideLinkedFlag()),r.url_trigger&&((a=this.sessionRecording)==null||a.overrideTrigger("url")),r.event_trigger&&((l=this.sessionRecording)==null||l.overrideTrigger("event"))}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,n){var r=new Error("PostHog syntheticException"),i=this.exceptions.buildProperties(e,{handled:!0,syntheticException:r});return this.exceptions.sendExceptionEvent(be({},i,n))}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var n;return(n=this.persistence)==null?void 0:n.props[e]}getSessionProperty(e){var n;return(n=this.sessionPersistence)==null?void 0:n.props[e]}toString(){var e,n=(e=this.config.name)!==null&&e!==void 0?e:ha;return n!==ha&&(n=ha+"."+n),n}_isIdentified(){var e,n;return((e=this.persistence)==null?void 0:e.get_property(ki))==="identified"||((n=this.sessionPersistence)==null?void 0:n.get_property(ki))==="identified"}us(){var e,n;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&ta(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[Bl])&&((n=this.persistence)==null||(n=n.props)==null||!n[Id]))}ns(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&(this.config.capture_pageview===!0||this.config.capture_pageview==="history_change")}createPersonProfile(){this.us()||this.hs("posthog.createPersonProfile")&&this.setPersonProperties({},{})}hs(e){return this.config.person_profiles==="never"?(ye.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.ds(Id,!0),!0)}Vr(){if(this.config.cookieless_mode==="always")return!0;var e=this.consent.isOptedOut(),n=this.config.opt_out_persistence_by_default||this.config.cookieless_mode==="on_reject";return this.config.disable_persistence||e&&!!n}vs(){var e,n,r,i,o=this.Vr();return((e=this.persistence)==null?void 0:e.xi)!==o&&((r=this.persistence)==null||r.set_disabled(o)),((n=this.sessionPersistence)==null?void 0:n.xi)!==o&&((i=this.sessionPersistence)==null||i.set_disabled(o)),o}opt_in_capturing(e){var n;if(this.config.cookieless_mode!=="always"){var r,i;this.config.cookieless_mode==="on_reject"&&this.consent.isExplicitlyOptedOut()&&(this.reset(!0),(r=this.sessionManager)==null||r.destroy(),this.sessionManager=new qI(this),this.persistence&&(this.sessionPropsManager=new jI(this,this.sessionManager,this.persistence)),this.sessionRecording=new YI(this),this.sessionRecording.startIfEnabledOrStop()),this.consent.optInOut(!0),this.vs(),this.rs(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&this.surveys.loadIfEnabled(),(fe(e==null?void 0:e.captureEventName)||e!=null&&e.captureEventName)&&this.capture((i=e==null?void 0:e.captureEventName)!==null&&i!==void 0?i:"$opt_in",e==null?void 0:e.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.ss()}else ye.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}opt_out_capturing(){var e,n;this.config.cookieless_mode!=="always"?(this.config.cookieless_mode==="on_reject"&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.vs(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:$l,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(n=this.sessionRecording)==null||n.stopRecording(),this.sessionRecording=void 0,this.ss())):ye.warn('Consent opt in/out is not valid with cookieless_mode="always" and will be ignored')}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===Ri.GRANTED?"granted":e===Ri.DENIED?"denied":"pending"}is_capturing(){return this.config.cookieless_mode==="always"||(this.config.cookieless_mode==="on_reject"?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.vs()}_is_bot(){return ur?GI(ur,this.config.custom_blocked_useragents):void 0}ss(){me&&(me.visibilityState==="visible"?this.Ur||(this.Ur=!0,this.capture("$pageview",{title:me.title},{send_instantly:!0}),this.zr&&(me.removeEventListener("visibilitychange",this.zr),this.zr=null)):this.zr||(this.zr=this.ss.bind(this),Bt(me,"visibilitychange",this.zr)))}debug(e){e===!1?(oe==null||oe.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(oe==null||oe.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),this.set_config({debug:!0}))}O(){var e,n,r,i,o,s,a,l=this.Wr||{};return"advanced_disable_flags"in l?!!l.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(ye.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(r="advanced_disable_decide",i=!1,o=ye,s=(n="advanced_disable_flags")in(e=l)&&!fe(e[n]),a=r in e&&!fe(e[r]),s?e[n]:a?(o&&o.warn("Config field '"+r+"' is deprecated. Please use '"+n+"' instead. The old field will be removed in a future major version."),e[r]):i)}ls(e){if(Je(this.config.before_send))return e;var n=Ze(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(var i of n){if(r=i(r),Je(r)){var o="Event '"+e.event+"' was rejected in beforeSend function";return Xq(e.event)?ye.warn(o+". This can cause unexpected behavior."):ye.info(o),null}r.properties&&!ta(r.properties)||ye.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return r}getPageViewId(){var e;return(e=this.pageViewManager.Kt)==null?void 0:e.pageViewId}captureTraceFeedback(e,n){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:n})}captureTraceMetric(e,n,r){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:n,$ai_metric_value:String(r)})}qr(e){var n=Ai(e)&&!e,r=bt.H()&&bt.q("ph_debug")==="true";return!n&&(!!r||e)}}(function(t,e){for(var n=0;n<e.length;n++)t.prototype[e[n]]=NG(t.prototype[e[n]])})(Ud,["identify"]);var QI,aY=(QI=rc[ha]=new Ud,(function(){function t(){t.done||(t.done=!0,XI=!1,ut(rc,(function(e){e._dom_loaded()})))}me!=null&&me.addEventListener?me.readyState==="complete"?t():Bt(me,"DOMContentLoaded",t,{capture:!1}):oe&&ye.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),QI);const ic=K.createContext({}),eC=({config:{apiKey:t,tokenOut:e,chainIdOut:n,theme:r,enableExchange:i,cexBridgeChainMapping:o,recipient:s,enforceFlow:a},onClose:l,wrapper:c})=>{const u=Me(x=>x.setEnsoApiToken),h=Me(x=>x.setTokenOut),p=Me(x=>x.setChainIdOut),g=Me(x=>x.setRecipient),b=K.useMemo(()=>l?()=>{l&&l()}:void 0,[l]);K.useEffect(()=>{h(e),p(n),g(s)},[e,n,s]),K.useEffect(()=>{aY.init("phc_capPDVae4W7y6QIqVTugTtx5geVthX4YVswtXa6DrjM",{api_host:"https://eu.i.posthog.com",person_profiles:"always"}),t||alert("Please provide an API key"),u(t)},[t]);const m=K.useMemo(()=>c!=null?c:(({children:x,...I})=>w.jsx(ue,{p:4,w:"374px",...I,children:x})),[c]);return w.jsx(ic.Provider,{value:{handleClose:b,enableExchange:i,cexBridgeChainMapping:o,enforceFlow:a},children:w.jsx(hB,{themeConfig:r,children:w.jsxs(m,{children:[w.jsx(pq,{}),w.jsx(jq,{})]})})})},lY=({config:t,setIsActive:e,isActive:n,onClose:r})=>{const i=K.useCallback(()=>{e(!1),r==null||r()},[e,r]);return n?w.jsx(eC,{wrapper:or,config:t,onClose:i}):null};_t.Checkout=eC,_t.CheckoutModal=lY,_t.DEFAULT_CEX_BRIDGE_CHAIN_MAPPING=Jf,_t.SupportedExchanges=Qr,Object.defineProperty(_t,Symbol.toStringTag,{value:"Module"})}));
232
232
  //# sourceMappingURL=checkout-widget.umd.js.map