denotify-client 1.1.19 → 1.1.21

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.
@@ -1,6 +1,6 @@
1
- "use strict";var fa=Object.defineProperty;var da=(n,e,t)=>e in n?fa(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var m=(n,e,t)=>(da(n,typeof e!="symbol"?e+"":e,t),t),pn=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var v=(n,e,t)=>(pn(n,e,"read from private field"),t?t.call(n):e.get(n)),L=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},I=(n,e,t,r)=>(pn(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),Is=(n,e,t,r)=>({set _(s){I(n,e,s,t)},get _(){return v(n,e,r)}}),z=(n,e,t)=>(pn(n,e,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function pa(n,e){for(var t=0;t<e.length;t++){const r=e[t];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in n)){const i=Object.getOwnPropertyDescriptor(r,s);i&&Object.defineProperty(n,s,i.get?i:{enumerable:!0,get:()=>r[s]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}var ya=globalThis&&globalThis.__awaiter||function(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(l){try{u(r.next(l))}catch(h){o(h)}}function c(l){try{u(r.throw(l))}catch(h){o(h)}}function u(l){l.done?i(l.value):s(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})};const ma=n=>{let e;return n?e=n:typeof fetch>"u"?e=(...t)=>ya(void 0,void 0,void 0,function*(){return yield(yield Promise.resolve().then(()=>Wr)).fetch(...t)}):e=fetch,(...t)=>e(...t)};class rs extends Error{constructor(e,t="FunctionsError",r){super(e),super.name=t,this.context=r}}class ga extends rs{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class wa extends rs{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class ba extends rs{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var va=globalThis&&globalThis.__awaiter||function(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(l){try{u(r.next(l))}catch(h){o(h)}}function c(l){try{u(r.throw(l))}catch(h){o(h)}}function u(l){l.done?i(l.value):s(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})};class _a{constructor(e,{headers:t={},customFetch:r}={}){this.url=e,this.headers=t,this.fetch=ma(r)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e,t={}){var r;return va(this,void 0,void 0,function*(){try{const{headers:s,method:i,body:o}=t;let a={},c;o&&(s&&!Object.prototype.hasOwnProperty.call(s,"Content-Type")||!s)&&(typeof Blob<"u"&&o instanceof Blob||o instanceof ArrayBuffer?(a["Content-Type"]="application/octet-stream",c=o):typeof o=="string"?(a["Content-Type"]="text/plain",c=o):typeof FormData<"u"&&o instanceof FormData?c=o:(a["Content-Type"]="application/json",c=JSON.stringify(o)));const u=yield this.fetch(`${this.url}/${e}`,{method:i||"POST",headers:Object.assign(Object.assign(Object.assign({},a),this.headers),s),body:c}).catch(f=>{throw new ga(f)}),l=u.headers.get("x-relay-error");if(l&&l==="true")throw new wa(u);if(!u.ok)throw new ba(u);let h=((r=u.headers.get("Content-Type"))!==null&&r!==void 0?r:"text/plain").split(";")[0].trim(),p;return h==="application/json"?p=yield u.json():h==="application/octet-stream"?p=yield u.blob():h==="multipart/form-data"?p=yield u.formData():p=yield u.text(),{data:p,error:null}}catch(s){return{data:null,error:s}}})}}var Ea=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function xa(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Ht={},Oa={get exports(){return Ht},set exports(n){Ht=n}};(function(n,e){var t=typeof self<"u"?self:Ea,r=function(){function i(){this.fetch=!1,this.DOMException=t.DOMException}return i.prototype=t,new i}();(function(i){(function(o){var a={searchParams:"URLSearchParams"in i,iterable:"Symbol"in i&&"iterator"in Symbol,blob:"FileReader"in i&&"Blob"in i&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in i,arrayBuffer:"ArrayBuffer"in i};function c(y){return y&&DataView.prototype.isPrototypeOf(y)}if(a.arrayBuffer)var u=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],l=ArrayBuffer.isView||function(y){return y&&u.indexOf(Object.prototype.toString.call(y))>-1};function h(y){if(typeof y!="string"&&(y=String(y)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(y))throw new TypeError("Invalid character in header field name");return y.toLowerCase()}function p(y){return typeof y!="string"&&(y=String(y)),y}function f(y){var _={next:function(){var S=y.shift();return{done:S===void 0,value:S}}};return a.iterable&&(_[Symbol.iterator]=function(){return _}),_}function d(y){this.map={},y instanceof d?y.forEach(function(_,S){this.append(S,_)},this):Array.isArray(y)?y.forEach(function(_){this.append(_[0],_[1])},this):y&&Object.getOwnPropertyNames(y).forEach(function(_){this.append(_,y[_])},this)}d.prototype.append=function(y,_){y=h(y),_=p(_);var S=this.map[y];this.map[y]=S?S+", "+_:_},d.prototype.delete=function(y){delete this.map[h(y)]},d.prototype.get=function(y){return y=h(y),this.has(y)?this.map[y]:null},d.prototype.has=function(y){return this.map.hasOwnProperty(h(y))},d.prototype.set=function(y,_){this.map[h(y)]=p(_)},d.prototype.forEach=function(y,_){for(var S in this.map)this.map.hasOwnProperty(S)&&y.call(_,this.map[S],S,this)},d.prototype.keys=function(){var y=[];return this.forEach(function(_,S){y.push(S)}),f(y)},d.prototype.values=function(){var y=[];return this.forEach(function(_){y.push(_)}),f(y)},d.prototype.entries=function(){var y=[];return this.forEach(function(_,S){y.push([S,_])}),f(y)},a.iterable&&(d.prototype[Symbol.iterator]=d.prototype.entries);function w(y){if(y.bodyUsed)return Promise.reject(new TypeError("Already read"));y.bodyUsed=!0}function b(y){return new Promise(function(_,S){y.onload=function(){_(y.result)},y.onerror=function(){S(y.error)}})}function O(y){var _=new FileReader,S=b(_);return _.readAsArrayBuffer(y),S}function P(y){var _=new FileReader,S=b(_);return _.readAsText(y),S}function M(y){for(var _=new Uint8Array(y),S=new Array(_.length),Z=0;Z<_.length;Z++)S[Z]=String.fromCharCode(_[Z]);return S.join("")}function U(y){if(y.slice)return y.slice(0);var _=new Uint8Array(y.byteLength);return _.set(new Uint8Array(y)),_.buffer}function Ee(){return this.bodyUsed=!1,this._initBody=function(y){this._bodyInit=y,y?typeof y=="string"?this._bodyText=y:a.blob&&Blob.prototype.isPrototypeOf(y)?this._bodyBlob=y:a.formData&&FormData.prototype.isPrototypeOf(y)?this._bodyFormData=y:a.searchParams&&URLSearchParams.prototype.isPrototypeOf(y)?this._bodyText=y.toString():a.arrayBuffer&&a.blob&&c(y)?(this._bodyArrayBuffer=U(y.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):a.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(y)||l(y))?this._bodyArrayBuffer=U(y):this._bodyText=y=Object.prototype.toString.call(y):this._bodyText="",this.headers.get("content-type")||(typeof y=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):a.searchParams&&URLSearchParams.prototype.isPrototypeOf(y)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},a.blob&&(this.blob=function(){var y=w(this);if(y)return y;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?w(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(O)}),this.text=function(){var y=w(this);if(y)return y;if(this._bodyBlob)return P(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(M(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},a.formData&&(this.formData=function(){return this.text().then(gr)}),this.json=function(){return this.text().then(JSON.parse)},this}var qt=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function mr(y){var _=y.toUpperCase();return qt.indexOf(_)>-1?_:y}function ye(y,_){_=_||{};var S=_.body;if(y instanceof ye){if(y.bodyUsed)throw new TypeError("Already read");this.url=y.url,this.credentials=y.credentials,_.headers||(this.headers=new d(y.headers)),this.method=y.method,this.mode=y.mode,this.signal=y.signal,!S&&y._bodyInit!=null&&(S=y._bodyInit,y.bodyUsed=!0)}else this.url=String(y);if(this.credentials=_.credentials||this.credentials||"same-origin",(_.headers||!this.headers)&&(this.headers=new d(_.headers)),this.method=mr(_.method||this.method||"GET"),this.mode=_.mode||this.mode||null,this.signal=_.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&S)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(S)}ye.prototype.clone=function(){return new ye(this,{body:this._bodyInit})};function gr(y){var _=new FormData;return y.trim().split("&").forEach(function(S){if(S){var Z=S.split("="),G=Z.shift().replace(/\+/g," "),F=Z.join("=").replace(/\+/g," ");_.append(decodeURIComponent(G),decodeURIComponent(F))}}),_}function H(y){var _=new d,S=y.replace(/\r?\n[\t ]+/g," ");return S.split(/\r?\n/).forEach(function(Z){var G=Z.split(":"),F=G.shift().trim();if(F){var br=G.join(":").trim();_.append(F,br)}}),_}Ee.call(ye.prototype);function J(y,_){_||(_={}),this.type="default",this.status=_.status===void 0?200:_.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in _?_.statusText:"OK",this.headers=new d(_.headers),this.url=_.url||"",this._initBody(y)}Ee.call(J.prototype),J.prototype.clone=function(){return new J(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},J.error=function(){var y=new J(null,{status:0,statusText:""});return y.type="error",y};var wr=[301,302,303,307,308];J.redirect=function(y,_){if(wr.indexOf(_)===-1)throw new RangeError("Invalid status code");return new J(null,{status:_,headers:{location:y}})},o.DOMException=i.DOMException;try{new o.DOMException}catch{o.DOMException=function(_,S){this.message=_,this.name=S;var Z=Error(_);this.stack=Z.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function Tt(y,_){return new Promise(function(S,Z){var G=new ye(y,_);if(G.signal&&G.signal.aborted)return Z(new o.DOMException("Aborted","AbortError"));var F=new XMLHttpRequest;function br(){F.abort()}F.onload=function(){var Jt={status:F.status,statusText:F.statusText,headers:H(F.getAllResponseHeaders()||"")};Jt.url="responseURL"in F?F.responseURL:Jt.headers.get("X-Request-URL");var dn="response"in F?F.response:F.responseText;S(new J(dn,Jt))},F.onerror=function(){Z(new TypeError("Network request failed"))},F.ontimeout=function(){Z(new TypeError("Network request failed"))},F.onabort=function(){Z(new o.DOMException("Aborted","AbortError"))},F.open(G.method,G.url,!0),G.credentials==="include"?F.withCredentials=!0:G.credentials==="omit"&&(F.withCredentials=!1),"responseType"in F&&a.blob&&(F.responseType="blob"),G.headers.forEach(function(Jt,dn){F.setRequestHeader(dn,Jt)}),G.signal&&(G.signal.addEventListener("abort",br),F.onreadystatechange=function(){F.readyState===4&&G.signal.removeEventListener("abort",br)}),F.send(typeof G._bodyInit>"u"?null:G._bodyInit)})}return Tt.polyfill=!0,i.fetch||(i.fetch=Tt,i.Headers=d,i.Request=ye,i.Response=J),o.Headers=d,o.Request=ye,o.Response=J,o.fetch=Tt,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(r),r.fetch.ponyfill=!0,delete r.fetch.polyfill;var s=r;e=s.fetch,e.default=s.fetch,e.fetch=s.fetch,e.Headers=s.Headers,e.Request=s.Request,e.Response=s.Response,n.exports=e})(Oa,Ht);const ns=xa(Ht),Wr=pa({__proto__:null,default:ns},[Ht]);class Ta{constructor(e){this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=e.headers,this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=e.shouldThrowOnError,this.signal=e.signal,this.allowEmpty=e.allowEmpty,e.fetch?this.fetch=e.fetch:typeof fetch>"u"?this.fetch=ns:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}then(e,t){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers["Accept-Profile"]=this.schema:this.headers["Content-Profile"]=this.schema),this.method!=="GET"&&this.method!=="HEAD"&&(this.headers["Content-Type"]="application/json");const r=this.fetch;let s=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async i=>{var o,a,c;let u=null,l=null,h=null,p=i.status,f=i.statusText;if(i.ok){if(this.method!=="HEAD"){const O=await i.text();O===""||(this.headers.Accept==="text/csv"||this.headers.Accept&&this.headers.Accept.includes("application/vnd.pgrst.plan+text")?l=O:l=JSON.parse(O))}const w=(o=this.headers.Prefer)===null||o===void 0?void 0:o.match(/count=(exact|planned|estimated)/),b=(a=i.headers.get("content-range"))===null||a===void 0?void 0:a.split("/");w&&b&&b.length>1&&(h=parseInt(b[1]))}else{const w=await i.text();try{u=JSON.parse(w),Array.isArray(u)&&i.status===404&&(l=[],u=null,p=200,f="OK")}catch{i.status===404&&w===""?(p=204,f="No Content"):u={message:w}}if(u&&this.allowEmpty&&(!((c=u==null?void 0:u.details)===null||c===void 0)&&c.includes("Results contain 0 rows"))&&(u=null,p=200,f="OK"),u&&this.shouldThrowOnError)throw u}return{error:u,data:l,count:h,status:p,statusText:f}});return this.shouldThrowOnError||(s=s.catch(i=>({error:{message:`FetchError: ${i.message}`,details:"",hint:"",code:i.code||""},data:null,count:null,status:0,statusText:""}))),s.then(e,t)}}class Sa extends Ta{select(e){let t=!1;const r=(e??"*").split("").map(s=>/\s/.test(s)&&!t?"":(s==='"'&&(t=!t),s)).join("");return this.url.searchParams.set("select",r),this.headers.Prefer&&(this.headers.Prefer+=","),this.headers.Prefer+="return=representation",this}order(e,{ascending:t=!0,nullsFirst:r,foreignTable:s}={}){const i=s?`${s}.order`:"order",o=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${o?`${o},`:""}${e}.${t?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t}={}){const r=typeof t>"u"?"limit":`${t}.limit`;return this.url.searchParams.set(r,`${e}`),this}range(e,t,{foreignTable:r}={}){const s=typeof r>"u"?"offset":`${r}.offset`,i=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(s,`${e}`),this.url.searchParams.set(i,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.Accept="application/vnd.pgrst.object+json",this}maybeSingle(){return this.headers.Accept="application/vnd.pgrst.object+json",this.allowEmpty=!0,this}csv(){return this.headers.Accept="text/csv",this}geojson(){return this.headers.Accept="application/geo+json",this}explain({analyze:e=!1,verbose:t=!1,settings:r=!1,buffers:s=!1,wal:i=!1,format:o="text"}={}){const a=[e?"analyze":null,t?"verbose":null,r?"settings":null,s?"buffers":null,i?"wal":null].filter(Boolean).join("|"),c=this.headers.Accept;return this.headers.Accept=`application/vnd.pgrst.plan+${o}; for="${c}"; options=${a};`,o==="json"?this:this}rollback(){var e;return((e=this.headers.Prefer)!==null&&e!==void 0?e:"").trim().length>0?this.headers.Prefer+=",tx=rollback":this.headers.Prefer="tx=rollback",this}returns(){return this}}class Pt extends Sa{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}in(e,t){const r=t.map(s=>typeof s=="string"&&new RegExp("[,()]").test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(e,`in.(${r})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:r,type:s}={}){let i="";s==="plain"?i="pl":s==="phrase"?i="ph":s==="websearch"&&(i="w");const o=r===void 0?"":`(${r})`;return this.url.searchParams.append(e,`${i}fts${o}.${t}`),this}match(e){return Object.entries(e).forEach(([t,r])=>{this.url.searchParams.append(t,`eq.${r}`)}),this}not(e,t,r){return this.url.searchParams.append(e,`not.${t}.${r}`),this}or(e,{foreignTable:t}={}){const r=t?`${t}.or`:"or";return this.url.searchParams.append(r,`(${e})`),this}filter(e,t,r){return this.url.searchParams.append(e,`${t}.${r}`),this}}class Aa{constructor(e,{headers:t={},schema:r,fetch:s}){this.url=e,this.headers=t,this.schema=r,this.fetch=s}select(e,{head:t=!1,count:r}={}){const s=t?"HEAD":"GET";let i=!1;const o=(e??"*").split("").map(a=>/\s/.test(a)&&!i?"":(a==='"'&&(i=!i),a)).join("");return this.url.searchParams.set("select",o),r&&(this.headers.Prefer=`count=${r}`),new Pt({method:s,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}insert(e,{count:t}={}){const r="POST",s=[],i=e;if(t&&s.push(`count=${t}`),this.headers.Prefer&&s.unshift(this.headers.Prefer),this.headers.Prefer=s.join(","),Array.isArray(e)){const o=e.reduce((a,c)=>a.concat(Object.keys(c)),[]);if(o.length>0){const a=[...new Set(o)].map(c=>`"${c}"`);this.url.searchParams.set("columns",a.join(","))}}return new Pt({method:r,url:this.url,headers:this.headers,schema:this.schema,body:i,fetch:this.fetch,allowEmpty:!1})}upsert(e,{onConflict:t,ignoreDuplicates:r=!1,count:s}={}){const i="POST",o=[`resolution=${r?"ignore":"merge"}-duplicates`];t!==void 0&&this.url.searchParams.set("on_conflict",t);const a=e;return s&&o.push(`count=${s}`),this.headers.Prefer&&o.unshift(this.headers.Prefer),this.headers.Prefer=o.join(","),new Pt({method:i,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:this.fetch,allowEmpty:!1})}update(e,{count:t}={}){const r="PATCH",s=[],i=e;return t&&s.push(`count=${t}`),this.headers.Prefer&&s.unshift(this.headers.Prefer),this.headers.Prefer=s.join(","),new Pt({method:r,url:this.url,headers:this.headers,schema:this.schema,body:i,fetch:this.fetch,allowEmpty:!1})}delete({count:e}={}){const t="DELETE",r=[];return e&&r.push(`count=${e}`),this.headers.Prefer&&r.unshift(this.headers.Prefer),this.headers.Prefer=r.join(","),new Pt({method:t,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}}const ka="1.4.1",Ra={"X-Client-Info":`postgrest-js/${ka}`};class Pa{constructor(e,{headers:t={},schema:r,fetch:s}={}){this.url=e,this.headers=Object.assign(Object.assign({},Ra),t),this.schema=r,this.fetch=s}from(e){const t=new URL(`${this.url}/${e}`);return new Aa(t,{headers:Object.assign({},this.headers),schema:this.schema,fetch:this.fetch})}rpc(e,t={},{head:r=!1,count:s}={}){let i;const o=new URL(`${this.url}/rpc/${e}`);let a;r?(i="HEAD",Object.entries(t).forEach(([u,l])=>{o.searchParams.append(u,`${l}`)})):(i="POST",a=t);const c=Object.assign({},this.headers);return s&&(c.Prefer=`count=${s}`),new Pt({method:i,url:o,headers:c,schema:this.schema,body:a,fetch:this.fetch,allowEmpty:!1})}}var yn,Fs;function Na(){if(Fs)return yn;Fs=1;var n=function(){if(typeof self=="object"&&self)return self;if(typeof window=="object"&&window)return window;throw new Error("Unable to resolve global `this`")};return yn=function(){if(this)return this;if(typeof globalThis=="object"&&globalThis)return globalThis;try{Object.defineProperty(Object.prototype,"__global__",{get:function(){return this},configurable:!0})}catch{return n()}try{return __global__||n()}finally{delete Object.prototype.__global__}}(),yn}const $a="websocket",Ca="Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.",Ia=["websocket","websockets","socket","networking","comet","push","RFC-6455","realtime","server","client"],Fa="Brian McKelvey <theturtle32@gmail.com> (https://github.com/theturtle32)",Da=["Iñaki Baz Castillo <ibc@aliax.net> (http://dev.sipdoc.net)"],Ua="1.0.34",La={type:"git",url:"https://github.com/theturtle32/WebSocket-Node.git"},ja="https://github.com/theturtle32/WebSocket-Node",Ba={node:">=4.0.0"},Ha={bufferutil:"^4.0.1",debug:"^2.2.0","es5-ext":"^0.10.50","typedarray-to-buffer":"^3.1.5","utf-8-validate":"^5.0.2",yaeti:"^0.0.6"},Ma={"buffer-equal":"^1.0.0",gulp:"^4.0.2","gulp-jshint":"^2.0.4","jshint-stylish":"^2.2.1",jshint:"^2.0.0",tape:"^4.9.1"},za={verbose:!1},Va={test:"tape test/unit/*.js",gulp:"gulp"},qa="index",Ja={lib:"./lib"},Ga="lib/browser.js",Wa="Apache-2.0",Ka={name:$a,description:Ca,keywords:Ia,author:Fa,contributors:Da,version:Ua,repository:La,homepage:ja,engines:Ba,dependencies:Ha,devDependencies:Ma,config:za,scripts:Va,main:qa,directories:Ja,browser:Ga,license:Wa};var Xa=Ka.version,at;if(typeof globalThis=="object")at=globalThis;else try{at=Na()}catch{}finally{if(!at&&typeof window<"u"&&(at=window),!at)throw new Error("Could not determine global this")}var er=at.WebSocket||at.MozWebSocket,Za=Xa;function ji(n,e){var t;return e?t=new er(n,e):t=new er(n),t}er&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach(function(n){Object.defineProperty(ji,n,{get:function(){return er[n]}})});var Ya={w3cwebsocket:er?ji:null,version:Za};const Qa="2.6.0",ec={"X-Client-Info":`realtime-js/${Qa}`},tc="1.0.0",Bi=1e4,rc=1e3;var Zt;(function(n){n[n.connecting=0]="connecting",n[n.open=1]="open",n[n.closing=2]="closing",n[n.closed=3]="closed"})(Zt||(Zt={}));var oe;(function(n){n.closed="closed",n.errored="errored",n.joined="joined",n.joining="joining",n.leaving="leaving"})(oe||(oe={}));var we;(function(n){n.close="phx_close",n.error="phx_error",n.join="phx_join",n.reply="phx_reply",n.leave="phx_leave",n.access_token="access_token"})(we||(we={}));var Nn;(function(n){n.websocket="websocket"})(Nn||(Nn={}));var ct;(function(n){n.Connecting="connecting",n.Open="open",n.Closing="closing",n.Closed="closed"})(ct||(ct={}));class Hi{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=void 0,this.tries=0,this.callback=e,this.timerCalc=t}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}}class nc{constructor(){this.HEADER_LENGTH=1}decode(e,t){return e.constructor===ArrayBuffer?t(this._binaryDecode(e)):t(typeof e=="string"?JSON.parse(e):{})}_binaryDecode(e){const t=new DataView(e),r=new TextDecoder;return this._decodeBroadcast(e,t,r)}_decodeBroadcast(e,t,r){const s=t.getUint8(1),i=t.getUint8(2);let o=this.HEADER_LENGTH+2;const a=r.decode(e.slice(o,o+s));o=o+s;const c=r.decode(e.slice(o,o+i));o=o+i;const u=JSON.parse(r.decode(e.slice(o,e.byteLength)));return{ref:null,topic:a,event:c,payload:u}}}class mn{constructor(e,t,r={},s=Bi){this.channel=e,this.event=t,this.payload=r,this.timeout=s,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null,this.rateLimited=!1}resend(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){if(this._hasReceived("timeout"))return;this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()})==="rate limited"&&(this.rateLimited=!0)}updatePayload(e){this.payload=Object.assign(Object.assign({},this.payload),e)}receive(e,t){var r;return this._hasReceived(e)&&t((r=this.receivedResp)===null||r===void 0?void 0:r.response),this.recHooks.push({status:e,callback:t}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);const e=t=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=t,this._matchReceive(t)};this.channel._on(this.refEvent,{},e),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(e,t){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:t})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:e,response:t}){this.recHooks.filter(r=>r.status===e).forEach(r=>r.callback(t))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}}var Ds;(function(n){n.SYNC="sync",n.JOIN="join",n.LEAVE="leave"})(Ds||(Ds={}));class Yt{constructor(e,t){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const r=(t==null?void 0:t.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(r.state,{},s=>{const{onJoin:i,onLeave:o,onSync:a}=this.caller;this.joinRef=this.channel._joinRef(),this.state=Yt.syncState(this.state,s,i,o),this.pendingDiffs.forEach(c=>{this.state=Yt.syncDiff(this.state,c,i,o)}),this.pendingDiffs=[],a()}),this.channel._on(r.diff,{},s=>{const{onJoin:i,onLeave:o,onSync:a}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(s):(this.state=Yt.syncDiff(this.state,s,i,o),a())}),this.onJoin((s,i,o)=>{this.channel._trigger("presence",{event:"join",key:s,currentPresences:i,newPresences:o})}),this.onLeave((s,i,o)=>{this.channel._trigger("presence",{event:"leave",key:s,currentPresences:i,leftPresences:o})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,t,r,s){const i=this.cloneDeep(e),o=this.transformState(t),a={},c={};return this.map(i,(u,l)=>{o[u]||(c[u]=l)}),this.map(o,(u,l)=>{const h=i[u];if(h){const p=l.map(b=>b.presence_ref),f=h.map(b=>b.presence_ref),d=l.filter(b=>f.indexOf(b.presence_ref)<0),w=h.filter(b=>p.indexOf(b.presence_ref)<0);d.length>0&&(a[u]=d),w.length>0&&(c[u]=w)}else a[u]=l}),this.syncDiff(i,{joins:a,leaves:c},r,s)}static syncDiff(e,t,r,s){const{joins:i,leaves:o}={joins:this.transformState(t.joins),leaves:this.transformState(t.leaves)};return r||(r=()=>{}),s||(s=()=>{}),this.map(i,(a,c)=>{var u;const l=(u=e[a])!==null&&u!==void 0?u:[];if(e[a]=this.cloneDeep(c),l.length>0){const h=e[a].map(f=>f.presence_ref),p=l.filter(f=>h.indexOf(f.presence_ref)<0);e[a].unshift(...p)}r(a,l,c)}),this.map(o,(a,c)=>{let u=e[a];if(!u)return;const l=c.map(h=>h.presence_ref);u=u.filter(h=>l.indexOf(h.presence_ref)<0),e[a]=u,s(a,u,c),u.length===0&&delete e[a]}),e}static map(e,t){return Object.getOwnPropertyNames(e).map(r=>t(r,e[r]))}static transformState(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce((t,r)=>{const s=e[r];return"metas"in s?t[r]=s.metas.map(i=>(i.presence_ref=i.phx_ref,delete i.phx_ref,delete i.phx_ref_prev,i)):t[r]=s,t},{})}static cloneDeep(e){return JSON.parse(JSON.stringify(e))}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}var j;(function(n){n.abstime="abstime",n.bool="bool",n.date="date",n.daterange="daterange",n.float4="float4",n.float8="float8",n.int2="int2",n.int4="int4",n.int4range="int4range",n.int8="int8",n.int8range="int8range",n.json="json",n.jsonb="jsonb",n.money="money",n.numeric="numeric",n.oid="oid",n.reltime="reltime",n.text="text",n.time="time",n.timestamp="timestamp",n.timestamptz="timestamptz",n.timetz="timetz",n.tsrange="tsrange",n.tstzrange="tstzrange"})(j||(j={}));const Us=(n,e,t={})=>{var r;const s=(r=t.skipTypes)!==null&&r!==void 0?r:[];return Object.keys(e).reduce((i,o)=>(i[o]=sc(o,n,e,s),i),{})},sc=(n,e,t,r)=>{const s=e.find(a=>a.name===n),i=s==null?void 0:s.type,o=t[n];return i&&!r.includes(i)?Mi(i,o):$n(o)},Mi=(n,e)=>{if(n.charAt(0)==="_"){const t=n.slice(1,n.length);return cc(e,t)}switch(n){case j.bool:return ic(e);case j.float4:case j.float8:case j.int2:case j.int4:case j.int8:case j.numeric:case j.oid:return oc(e);case j.json:case j.jsonb:return ac(e);case j.timestamp:return uc(e);case j.abstime:case j.date:case j.daterange:case j.int4range:case j.int8range:case j.money:case j.reltime:case j.text:case j.time:case j.timestamptz:case j.timetz:case j.tsrange:case j.tstzrange:return $n(e);default:return $n(e)}},$n=n=>n,ic=n=>{switch(n){case"t":return!0;case"f":return!1;default:return n}},oc=n=>{if(typeof n=="string"){const e=parseFloat(n);if(!Number.isNaN(e))return e}return n},ac=n=>{if(typeof n=="string")try{return JSON.parse(n)}catch(e){return console.log(`JSON parse error: ${e}`),n}return n},cc=(n,e)=>{if(typeof n!="string")return n;const t=n.length-1,r=n[t];if(n[0]==="{"&&r==="}"){let i;const o=n.slice(1,t);try{i=JSON.parse("["+o+"]")}catch{i=o?o.split(","):[]}return i.map(a=>Mi(e,a))}return n},uc=n=>typeof n=="string"?n.replace(" ","T"):n;var Ls=globalThis&&globalThis.__awaiter||function(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(l){try{u(r.next(l))}catch(h){o(h)}}function c(l){try{u(r.throw(l))}catch(h){o(h)}}function u(l){l.done?i(l.value):s(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})},js;(function(n){n.ALL="*",n.INSERT="INSERT",n.UPDATE="UPDATE",n.DELETE="DELETE"})(js||(js={}));var Bs;(function(n){n.BROADCAST="broadcast",n.PRESENCE="presence",n.POSTGRES_CHANGES="postgres_changes"})(Bs||(Bs={}));var Hs;(function(n){n.SUBSCRIBED="SUBSCRIBED",n.TIMED_OUT="TIMED_OUT",n.CLOSED="CLOSED",n.CHANNEL_ERROR="CHANNEL_ERROR"})(Hs||(Hs={}));class ss{constructor(e,t={config:{}},r){this.topic=e,this.params=t,this.socket=r,this.bindings={},this.state=oe.closed,this.joinedOnce=!1,this.pushBuffer=[],this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:""}},t.config),this.timeout=this.socket.timeout,this.joinPush=new mn(this,we.join,this.params,this.timeout),this.rejoinTimer=new Hi(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=oe.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=oe.closed,this.socket._remove(this)}),this._onError(s=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,s),this.state=oe.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=oe.errored,this.rejoinTimer.scheduleTimeout())}),this._on(we.reply,{},(s,i)=>{this._trigger(this._replyEventName(i),s)}),this.presence=new Yt(this)}subscribe(e,t=this.timeout){var r,s;if(this.joinedOnce)throw"tried to subscribe multiple times. 'subscribe' can only be called a single time per channel instance";{const{config:{broadcast:i,presence:o}}=this.params;this._onError(u=>e&&e("CHANNEL_ERROR",u)),this._onClose(()=>e&&e("CLOSED"));const a={},c={broadcast:i,presence:o,postgres_changes:(s=(r=this.bindings.postgres_changes)===null||r===void 0?void 0:r.map(u=>u.filter))!==null&&s!==void 0?s:[]};this.socket.accessToken&&(a.access_token=this.socket.accessToken),this.updateJoinPayload(Object.assign({config:c},a)),this.joinedOnce=!0,this._rejoin(t),this.joinPush.receive("ok",({postgres_changes:u})=>{var l;if(this.socket.accessToken&&this.socket.setAuth(this.socket.accessToken),u===void 0){e&&e("SUBSCRIBED");return}else{const h=this.bindings.postgres_changes,p=(l=h==null?void 0:h.length)!==null&&l!==void 0?l:0,f=[];for(let d=0;d<p;d++){const w=h[d],{filter:{event:b,schema:O,table:P,filter:M}}=w,U=u&&u[d];if(U&&U.event===b&&U.schema===O&&U.table===P&&U.filter===M)f.push(Object.assign(Object.assign({},w),{id:U.id}));else{this.unsubscribe(),e&&e("CHANNEL_ERROR",new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=f,e&&e("SUBSCRIBED");return}}).receive("error",u=>{e&&e("CHANNEL_ERROR",new Error(JSON.stringify(Object.values(u).join(", ")||"error")))}).receive("timeout",()=>{e&&e("TIMED_OUT")})}return this}presenceState(){return this.presence.state}track(e,t={}){return Ls(this,void 0,void 0,function*(){return yield this.send({type:"presence",event:"track",payload:e},t.timeout||this.timeout)})}untrack(e={}){return Ls(this,void 0,void 0,function*(){return yield this.send({type:"presence",event:"untrack"},e)})}on(e,t,r){return this._on(e,t,r)}send(e,t={}){return new Promise(r=>{var s,i,o;const a=this._push(e.type,e,t.timeout||this.timeout);a.rateLimited&&r("rate limited"),e.type==="broadcast"&&!(!((o=(i=(s=this.params)===null||s===void 0?void 0:s.config)===null||i===void 0?void 0:i.broadcast)===null||o===void 0)&&o.ack)&&r("ok"),a.receive("ok",()=>r("ok")),a.receive("timeout",()=>r("timed out"))})}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=oe.leaving;const t=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(we.close,"leave",this._joinRef())};return this.rejoinTimer.reset(),this.joinPush.destroy(),new Promise(r=>{const s=new mn(this,we.leave,{},e);s.receive("ok",()=>{t(),r("ok")}).receive("timeout",()=>{t(),r("timed out")}).receive("error",()=>{r("error")}),s.send(),this._canPush()||s.trigger("ok",{})})}_push(e,t,r=this.timeout){if(!this.joinedOnce)throw`tried to push '${e}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let s=new mn(this,e,t,r);return this._canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}_onMessage(e,t,r){return t}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,t,r){var s,i;const o=e.toLocaleLowerCase(),{close:a,error:c,leave:u,join:l}=we;if(r&&[a,c,u,l].indexOf(o)>=0&&r!==this._joinRef())return;let p=this._onMessage(o,t,r);if(t&&!p)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(o)?(s=this.bindings.postgres_changes)===null||s===void 0||s.filter(f=>{var d,w,b;return((d=f.filter)===null||d===void 0?void 0:d.event)==="*"||((b=(w=f.filter)===null||w===void 0?void 0:w.event)===null||b===void 0?void 0:b.toLocaleLowerCase())===o}).map(f=>f.callback(p,r)):(i=this.bindings[o])===null||i===void 0||i.filter(f=>{var d,w,b,O,P,M;if(["broadcast","presence","postgres_changes"].includes(o))if("id"in f){const U=f.id,Ee=(d=f.filter)===null||d===void 0?void 0:d.event;return U&&((w=t.ids)===null||w===void 0?void 0:w.includes(U))&&(Ee==="*"||(Ee==null?void 0:Ee.toLocaleLowerCase())===((b=t.data)===null||b===void 0?void 0:b.type.toLocaleLowerCase()))}else{const U=(P=(O=f==null?void 0:f.filter)===null||O===void 0?void 0:O.event)===null||P===void 0?void 0:P.toLocaleLowerCase();return U==="*"||U===((M=t==null?void 0:t.event)===null||M===void 0?void 0:M.toLocaleLowerCase())}else return f.type.toLocaleLowerCase()===o}).map(f=>{if(typeof p=="object"&&"ids"in p){const d=p.data,{schema:w,table:b,commit_timestamp:O,type:P,errors:M}=d;p=Object.assign(Object.assign({},{schema:w,table:b,commit_timestamp:O,eventType:P,new:{},old:{},errors:M}),this._getPayloadRecords(d))}f.callback(p,r)})}_isClosed(){return this.state===oe.closed}_isJoined(){return this.state===oe.joined}_isJoining(){return this.state===oe.joining}_isLeaving(){return this.state===oe.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,t,r){const s=e.toLocaleLowerCase(),i={type:s,filter:t,callback:r};return this.bindings[s]?this.bindings[s].push(i):this.bindings[s]=[i],this}_off(e,t){const r=e.toLocaleLowerCase();return this.bindings[r]=this.bindings[r].filter(s=>{var i;return!(((i=s.type)===null||i===void 0?void 0:i.toLocaleLowerCase())===r&&ss.isEqual(s.filter,t))}),this}static isEqual(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(e){this._on(we.close,{},e)}_onError(e){this._on(we.error,{},t=>e(t))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=oe.joining,this.joinPush.resend(e))}_getPayloadRecords(e){const t={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(t.new=Us(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(t.old=Us(e.columns,e.old_record)),t}}var lc=globalThis&&globalThis.__awaiter||function(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(l){try{u(r.next(l))}catch(h){o(h)}}function c(l){try{u(r.throw(l))}catch(h){o(h)}}function u(l){l.done?i(l.value):s(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})};const hc=()=>{};class fc{constructor(e,t){var r;this.accessToken=null,this.channels=[],this.endPoint="",this.headers=ec,this.params={},this.timeout=Bi,this.transport=Ya.w3cwebsocket,this.heartbeatIntervalMs=3e4,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.ref=0,this.logger=hc,this.conn=null,this.sendBuffer=[],this.serializer=new nc,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.eventsPerSecondLimitMs=100,this.inThrottle=!1,this.endPoint=`${e}/${Nn.websocket}`,t!=null&&t.params&&(this.params=t.params),t!=null&&t.headers&&(this.headers=Object.assign(Object.assign({},this.headers),t.headers)),t!=null&&t.timeout&&(this.timeout=t.timeout),t!=null&&t.logger&&(this.logger=t.logger),t!=null&&t.transport&&(this.transport=t.transport),t!=null&&t.heartbeatIntervalMs&&(this.heartbeatIntervalMs=t.heartbeatIntervalMs);const s=(r=t==null?void 0:t.params)===null||r===void 0?void 0:r.eventsPerSecond;s&&(this.eventsPerSecondLimitMs=Math.floor(1e3/s)),this.reconnectAfterMs=t!=null&&t.reconnectAfterMs?t.reconnectAfterMs:i=>[1e3,2e3,5e3,1e4][i-1]||1e4,this.encode=t!=null&&t.encode?t.encode:(i,o)=>o(JSON.stringify(i)),this.decode=t!=null&&t.decode?t.decode:this.serializer.decode.bind(this.serializer),this.reconnectTimer=new Hi(()=>lc(this,void 0,void 0,function*(){this.disconnect(),this.connect()}),this.reconnectAfterMs)}connect(){this.conn||(this.conn=new this.transport(this._endPointURL(),[],null,this.headers),this.conn&&(this.conn.binaryType="arraybuffer",this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=e=>this._onConnError(e),this.conn.onmessage=e=>this._onConnMessage(e),this.conn.onclose=e=>this._onConnClose(e)))}disconnect(e,t){this.conn&&(this.conn.onclose=function(){},e?this.conn.close(e,t??""):this.conn.close(),this.conn=null,this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.reset())}getChannels(){return this.channels}removeChannel(e){return e.unsubscribe().then(t=>(this.channels.length===0&&this.disconnect(),t))}removeAllChannels(){return Promise.all(this.channels.map(e=>e.unsubscribe())).then(e=>(this.disconnect(),e))}log(e,t,r){this.logger(e,t,r)}connectionState(){switch(this.conn&&this.conn.readyState){case Zt.connecting:return ct.Connecting;case Zt.open:return ct.Open;case Zt.closing:return ct.Closing;default:return ct.Closed}}isConnected(){return this.connectionState()===ct.Open}channel(e,t={config:{}}){this.isConnected()||this.connect();const r=new ss(`realtime:${e}`,t,this);return this.channels.push(r),r}push(e){const{topic:t,event:r,payload:s,ref:i}=e;let o=()=>{this.encode(e,a=>{var c;(c=this.conn)===null||c===void 0||c.send(a)})};if(this.log("push",`${t} ${r} (${i})`,s),this.isConnected())if(["broadcast","presence","postgres_changes"].includes(r)){if(this._throttle(o)())return"rate limited"}else o();else this.sendBuffer.push(o)}setAuth(e){this.accessToken=e,this.channels.forEach(t=>{e&&t.updateJoinPayload({access_token:e}),t.joinedOnce&&t._isJoined()&&t._push(we.access_token,{access_token:e})})}_makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}_leaveOpenTopic(e){let t=this.channels.find(r=>r.topic===e&&(r._isJoined()||r._isJoining()));t&&(this.log("transport",`leaving duplicate topic "${e}"`),t.unsubscribe())}_remove(e){this.channels=this.channels.filter(t=>t._joinRef()!==e._joinRef())}_endPointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:tc}))}_onConnMessage(e){this.decode(e.data,t=>{let{topic:r,event:s,payload:i,ref:o}=t;(o&&o===this.pendingHeartbeatRef||s===(i==null?void 0:i.type))&&(this.pendingHeartbeatRef=null),this.log("receive",`${i.status||""} ${r} ${s} ${o&&"("+o+")"||""}`,i),this.channels.filter(a=>a._isMember(r)).forEach(a=>a._trigger(s,i,o)),this.stateChangeCallbacks.message.forEach(a=>a(t))})}_onConnOpen(){this.log("transport",`connected to ${this._endPointURL()}`),this._flushSendBuffer(),this.reconnectTimer.reset(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this._sendHeartbeat(),this.heartbeatIntervalMs),this.stateChangeCallbacks.open.forEach(e=>e())}_onConnClose(e){this.log("transport","close",e),this._triggerChanError(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(t=>t(e))}_onConnError(e){this.log("transport",e.message),this._triggerChanError(),this.stateChangeCallbacks.error.forEach(t=>t(e))}_triggerChanError(){this.channels.forEach(e=>e._trigger(we.error))}_appendParams(e,t){if(Object.keys(t).length===0)return e;const r=e.match(/\?/)?"&":"?",s=new URLSearchParams(t);return`${e}${r}${s}`}_flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}_sendHeartbeat(){var e;if(this.isConnected()){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection"),(e=this.conn)===null||e===void 0||e.close(rc,"hearbeat timeout");return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.setAuth(this.accessToken)}}_throttle(e,t=this.eventsPerSecondLimitMs){return()=>this.inThrottle?!0:(e(),t>0&&(this.inThrottle=!0,setTimeout(()=>{this.inThrottle=!1},t)),!1)}}class zi extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}}function re(n){return typeof n=="object"&&n!==null&&"__isStorageError"in n}class dc extends zi{constructor(e,t){super(e),this.name="StorageApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class Ms extends zi{constructor(e,t){super(e),this.name="StorageUnknownError",this.originalError=t}}var Vi=globalThis&&globalThis.__awaiter||function(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(l){try{u(r.next(l))}catch(h){o(h)}}function c(l){try{u(r.throw(l))}catch(h){o(h)}}function u(l){l.done?i(l.value):s(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})};const qi=n=>{let e;return n?e=n:typeof fetch>"u"?e=(...t)=>Vi(void 0,void 0,void 0,function*(){return yield(yield Promise.resolve().then(()=>Wr)).fetch(...t)}):e=fetch,(...t)=>e(...t)},pc=()=>Vi(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield Promise.resolve().then(()=>Wr)).Response:Response});var zt=globalThis&&globalThis.__awaiter||function(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(l){try{u(r.next(l))}catch(h){o(h)}}function c(l){try{u(r.throw(l))}catch(h){o(h)}}function u(l){l.done?i(l.value):s(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})};const gn=n=>n.msg||n.message||n.error_description||n.error||JSON.stringify(n),yc=(n,e)=>zt(void 0,void 0,void 0,function*(){const t=yield pc();n instanceof t?n.json().then(r=>{e(new dc(gn(r),n.status||500))}).catch(r=>{e(new Ms(gn(r),r))}):e(new Ms(gn(n),n))}),mc=(n,e,t,r)=>{const s={method:n,headers:(e==null?void 0:e.headers)||{}};return n==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json"},e==null?void 0:e.headers),s.body=JSON.stringify(r),Object.assign(Object.assign({},s),t))};function Kr(n,e,t,r,s,i){return zt(this,void 0,void 0,function*(){return new Promise((o,a)=>{n(t,mc(e,r,s,i)).then(c=>{if(!c.ok)throw c;return r!=null&&r.noResolveJson?c:c.json()}).then(c=>o(c)).catch(c=>yc(c,a))})})}function Cn(n,e,t,r){return zt(this,void 0,void 0,function*(){return Kr(n,"GET",e,t,r)})}function ut(n,e,t,r,s){return zt(this,void 0,void 0,function*(){return Kr(n,"POST",e,r,s,t)})}function gc(n,e,t,r,s){return zt(this,void 0,void 0,function*(){return Kr(n,"PUT",e,r,s,t)})}function Ji(n,e,t,r,s){return zt(this,void 0,void 0,function*(){return Kr(n,"DELETE",e,r,s,t)})}var xe=globalThis&&globalThis.__awaiter||function(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(l){try{u(r.next(l))}catch(h){o(h)}}function c(l){try{u(r.throw(l))}catch(h){o(h)}}function u(l){l.done?i(l.value):s(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})};const wc={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},bc={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class vc{constructor(e,t={},r,s){this.url=e,this.headers=t,this.bucketId=r,this.fetch=qi(s)}uploadOrUpdate(e,t,r,s){return xe(this,void 0,void 0,function*(){try{let i;const o=Object.assign(Object.assign({},bc),s),a=Object.assign(Object.assign({},this.headers),e==="POST"&&{"x-upsert":String(o.upsert)});typeof Blob<"u"&&r instanceof Blob?(i=new FormData,i.append("cacheControl",o.cacheControl),i.append("",r)):typeof FormData<"u"&&r instanceof FormData?(i=r,i.append("cacheControl",o.cacheControl)):(i=r,a["cache-control"]=`max-age=${o.cacheControl}`,a["content-type"]=o.contentType);const c=this._removeEmptyFolders(t),u=this._getFinalPath(c),l=yield this.fetch(`${this.url}/object/${u}`,{method:e,body:i,headers:a});return l.ok?{data:{path:c},error:null}:{data:null,error:yield l.json()}}catch(i){if(re(i))return{data:null,error:i};throw i}})}upload(e,t,r){return xe(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,t,r)})}update(e,t,r){return xe(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,t,r)})}move(e,t){return xe(this,void 0,void 0,function*(){try{return{data:yield ut(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t},{headers:this.headers}),error:null}}catch(r){if(re(r))return{data:null,error:r};throw r}})}copy(e,t){return xe(this,void 0,void 0,function*(){try{return{data:{path:(yield ut(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t},{headers:this.headers})).Key},error:null}}catch(r){if(re(r))return{data:null,error:r};throw r}})}createSignedUrl(e,t,r){return xe(this,void 0,void 0,function*(){try{let s=this._getFinalPath(e),i=yield ut(this.fetch,`${this.url}/object/sign/${s}`,Object.assign({expiresIn:t},r!=null&&r.transform?{transform:r.transform}:{}),{headers:this.headers});const o=r!=null&&r.download?`&download=${r.download===!0?"":r.download}`:"";return i={signedUrl:encodeURI(`${this.url}${i.signedURL}${o}`)},{data:i,error:null}}catch(s){if(re(s))return{data:null,error:s};throw s}})}createSignedUrls(e,t,r){return xe(this,void 0,void 0,function*(){try{const s=yield ut(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:t,paths:e},{headers:this.headers}),i=r!=null&&r.download?`&download=${r.download===!0?"":r.download}`:"";return{data:s.map(o=>Object.assign(Object.assign({},o),{signedUrl:o.signedURL?encodeURI(`${this.url}${o.signedURL}${i}`):null})),error:null}}catch(s){if(re(s))return{data:null,error:s};throw s}})}download(e,t){return xe(this,void 0,void 0,function*(){const s=typeof(t==null?void 0:t.transform)<"u"?"render/image/authenticated":"object",i=this.transformOptsToQueryString((t==null?void 0:t.transform)||{}),o=i?`?${i}`:"";try{const a=this._getFinalPath(e);return{data:yield(yield Cn(this.fetch,`${this.url}/${s}/${a}${o}`,{headers:this.headers,noResolveJson:!0})).blob(),error:null}}catch(a){if(re(a))return{data:null,error:a};throw a}})}getPublicUrl(e,t){const r=this._getFinalPath(e),s=[],i=t!=null&&t.download?`download=${t.download===!0?"":t.download}`:"";i!==""&&s.push(i);const a=typeof(t==null?void 0:t.transform)<"u"?"render/image":"object",c=this.transformOptsToQueryString((t==null?void 0:t.transform)||{});c!==""&&s.push(c);let u=s.join("&");return u!==""&&(u=`?${u}`),{data:{publicUrl:encodeURI(`${this.url}/${a}/public/${r}${u}`)}}}remove(e){return xe(this,void 0,void 0,function*(){try{return{data:yield Ji(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(t){if(re(t))return{data:null,error:t};throw t}})}list(e,t,r){return xe(this,void 0,void 0,function*(){try{const s=Object.assign(Object.assign(Object.assign({},wc),t),{prefix:e||""});return{data:yield ut(this.fetch,`${this.url}/object/list/${this.bucketId}`,s,{headers:this.headers},r),error:null}}catch(s){if(re(s))return{data:null,error:s};throw s}})}_getFinalPath(e){return`${this.bucketId}/${e}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(e){const t=[];return e.width&&t.push(`width=${e.width}`),e.height&&t.push(`height=${e.height}`),e.resize&&t.push(`resize=${e.resize}`),e.format&&t.push(`format=${e.format}`),e.quality&&t.push(`quality=${e.quality}`),t.join("&")}}const _c="2.3.1",Ec={"X-Client-Info":`storage-js/${_c}`};var St=globalThis&&globalThis.__awaiter||function(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(l){try{u(r.next(l))}catch(h){o(h)}}function c(l){try{u(r.throw(l))}catch(h){o(h)}}function u(l){l.done?i(l.value):s(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})};class xc{constructor(e,t={},r){this.url=e,this.headers=Object.assign(Object.assign({},Ec),t),this.fetch=qi(r)}listBuckets(){return St(this,void 0,void 0,function*(){try{return{data:yield Cn(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if(re(e))return{data:null,error:e};throw e}})}getBucket(e){return St(this,void 0,void 0,function*(){try{return{data:yield Cn(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(t){if(re(t))return{data:null,error:t};throw t}})}createBucket(e,t={public:!1}){return St(this,void 0,void 0,function*(){try{return{data:yield ut(this.fetch,`${this.url}/bucket`,{id:e,name:e,public:t.public},{headers:this.headers}),error:null}}catch(r){if(re(r))return{data:null,error:r};throw r}})}updateBucket(e,t){return St(this,void 0,void 0,function*(){try{return{data:yield gc(this.fetch,`${this.url}/bucket/${e}`,{id:e,name:e,public:t.public},{headers:this.headers}),error:null}}catch(r){if(re(r))return{data:null,error:r};throw r}})}emptyBucket(e){return St(this,void 0,void 0,function*(){try{return{data:yield ut(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(t){if(re(t))return{data:null,error:t};throw t}})}deleteBucket(e){return St(this,void 0,void 0,function*(){try{return{data:yield Ji(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(t){if(re(t))return{data:null,error:t};throw t}})}}class Oc extends xc{constructor(e,t={},r){super(e,t,r)}from(e){return new vc(this.url,this.headers,e,this.fetch)}}const Tc="2.10.0",Sc={"X-Client-Info":`supabase-js/${Tc}`};var Ac=globalThis&&globalThis.__awaiter||function(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(l){try{u(r.next(l))}catch(h){o(h)}}function c(l){try{u(r.throw(l))}catch(h){o(h)}}function u(l){l.done?i(l.value):s(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})};const kc=n=>{let e;return n?e=n:typeof fetch>"u"?e=ns:e=fetch,(...t)=>e(...t)},Rc=()=>typeof Headers>"u"?Ht.Headers:Headers,Pc=(n,e,t)=>{const r=kc(t),s=Rc();return(i,o)=>Ac(void 0,void 0,void 0,function*(){var a;const c=(a=yield e())!==null&&a!==void 0?a:n;let u=new s(o==null?void 0:o.headers);return u.has("apikey")||u.set("apikey",n),u.has("Authorization")||u.set("Authorization",`Bearer ${c}`),r(i,Object.assign(Object.assign({},o),{headers:u}))})};function Nc(n){return n.replace(/\/$/,"")}function $c(n,e){const{db:t,auth:r,realtime:s,global:i}=n,{db:o,auth:a,realtime:c,global:u}=e;return{db:Object.assign(Object.assign({},o),t),auth:Object.assign(Object.assign({},a),r),realtime:Object.assign(Object.assign({},c),s),global:Object.assign(Object.assign({},u),i)}}var hr=globalThis&&globalThis.__awaiter||function(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(l){try{u(r.next(l))}catch(h){o(h)}}function c(l){try{u(r.throw(l))}catch(h){o(h)}}function u(l){l.done?i(l.value):s(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})};function Cc(n){return Math.round(Date.now()/1e3)+n}function Ic(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){const e=Math.random()*16|0;return(n=="x"?e:e&3|8).toString(16)})}const ot=()=>typeof document<"u",st={tested:!1,writable:!1},wn=()=>{if(!ot())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(st.tested)return st.writable;const n=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(n,n),globalThis.localStorage.removeItem(n),st.tested=!0,st.writable=!0}catch{st.tested=!0,st.writable=!1}return st.writable};function le(n,e){var t;e||(e=((t=window==null?void 0:window.location)===null||t===void 0?void 0:t.href)||""),n=n.replace(/[\[\]]/g,"\\$&");const r=new RegExp("[?&#]"+n+"(=([^&#]*)|&|#|$)"),s=r.exec(e);return s?s[2]?decodeURIComponent(s[2].replace(/\+/g," ")):"":null}const Gi=n=>{let e;return n?e=n:typeof fetch>"u"?e=(...t)=>hr(void 0,void 0,void 0,function*(){return yield(yield Promise.resolve().then(()=>Wr)).fetch(...t)}):e=fetch,(...t)=>e(...t)},Fc=n=>typeof n=="object"&&n!==null&&"status"in n&&"ok"in n&&"json"in n&&typeof n.json=="function",Dc=(n,e,t)=>hr(void 0,void 0,void 0,function*(){yield n.setItem(e,JSON.stringify(t))}),zs=(n,e)=>hr(void 0,void 0,void 0,function*(){const t=yield n.getItem(e);if(!t)return null;try{return JSON.parse(t)}catch{return t}}),Uc=(n,e)=>hr(void 0,void 0,void 0,function*(){yield n.removeItem(e)});function Lc(n){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let t="",r,s,i,o,a,c,u,l=0;for(n=n.replace("-","+").replace("_","/");l<n.length;)o=e.indexOf(n.charAt(l++)),a=e.indexOf(n.charAt(l++)),c=e.indexOf(n.charAt(l++)),u=e.indexOf(n.charAt(l++)),r=o<<2|a>>4,s=(a&15)<<4|c>>2,i=(c&3)<<6|u,t=t+String.fromCharCode(r),c!=64&&s!=0&&(t=t+String.fromCharCode(s)),u!=64&&i!=0&&(t=t+String.fromCharCode(i));return t}class Xr{constructor(){this.promise=new Xr.promiseConstructor((e,t)=>{this.resolve=e,this.reject=t})}}Xr.promiseConstructor=Promise;function Vs(n){const e=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}=?$|[a-z0-9_-]{2}(==)?$)$/i,t=n.split(".");if(t.length!==3)throw new Error("JWT is not valid: not a JWT structure");if(!e.test(t[1]))throw new Error("JWT is not valid: payload is not in base64url format");const r=t[1];return JSON.parse(Lc(r))}function jc(n){return new Promise(e=>{setTimeout(()=>e(null),n)})}function Bc(n,e){return new Promise((r,s)=>{hr(this,void 0,void 0,function*(){for(let i=0;i<1/0;i++)try{const o=yield n(i);if(!e(i,null,o)){r(o);return}}catch(o){if(!e(i,o)){s(o);return}}})})}class is extends Error{constructor(e,t){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=t}}function C(n){return typeof n=="object"&&n!==null&&"__isAuthError"in n}class Hc extends is{constructor(e,t){super(e,t),this.name="AuthApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}}function Mc(n){return C(n)&&n.name==="AuthApiError"}class Wi extends is{constructor(e,t){super(e),this.name="AuthUnknownError",this.originalError=t}}class Zr extends is{constructor(e,t,r){super(e),this.name=t,this.status=r}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class Gt extends Zr{constructor(){super("Auth session missing!","AuthSessionMissingError",400)}}class bn extends Zr{constructor(e){super(e,"AuthInvalidCredentialsError",400)}}class Ne extends Zr{constructor(e,t=null){super(e,"AuthImplicitGrantRedirectError",500),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class In extends Zr{constructor(e,t){super(e,"AuthRetryableFetchError",t)}}var os=globalThis&&globalThis.__awaiter||function(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(l){try{u(r.next(l))}catch(h){o(h)}}function c(l){try{u(r.throw(l))}catch(h){o(h)}}function u(l){l.done?i(l.value):s(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})},zc=globalThis&&globalThis.__rest||function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(t[r[s]]=n[r[s]]);return t};const vr=n=>n.msg||n.message||n.error_description||n.error||JSON.stringify(n),Vc=(n,e)=>os(void 0,void 0,void 0,function*(){const t=[502,503,504];Fc(n)?t.includes(n.status)?e(new In(vr(n),n.status)):n.json().then(r=>{e(new Hc(vr(r),n.status||500))}).catch(r=>{e(new Wi(vr(r),r))}):e(new In(vr(n),0))}),qc=(n,e,t,r)=>{const s={method:n,headers:(e==null?void 0:e.headers)||{}};return n==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e==null?void 0:e.headers),s.body=JSON.stringify(r),Object.assign(Object.assign({},s),t))};function D(n,e,t,r){var s;return os(this,void 0,void 0,function*(){const i=Object.assign({},r==null?void 0:r.headers);r!=null&&r.jwt&&(i.Authorization=`Bearer ${r.jwt}`);const o=(s=r==null?void 0:r.query)!==null&&s!==void 0?s:{};r!=null&&r.redirectTo&&(o.redirect_to=r.redirectTo);const a=Object.keys(o).length?"?"+new URLSearchParams(o).toString():"",c=yield Jc(n,e,t+a,{headers:i,noResolveJson:r==null?void 0:r.noResolveJson},{},r==null?void 0:r.body);return r!=null&&r.xform?r==null?void 0:r.xform(c):{data:Object.assign({},c),error:null}})}function Jc(n,e,t,r,s,i){return os(this,void 0,void 0,function*(){return new Promise((o,a)=>{n(t,qc(e,r,s,i)).then(c=>{if(!c.ok)throw c;return r!=null&&r.noResolveJson?c:c.json()}).then(c=>o(c)).catch(c=>Vc(c,a))})})}function it(n){var e;let t=null;Xc(n)&&(t=Object.assign({},n),t.expires_at=Cc(n.expires_in));const r=(e=n.user)!==null&&e!==void 0?e:n;return{data:{session:t,user:r},error:null}}function lt(n){var e;return{data:{user:(e=n.user)!==null&&e!==void 0?e:n},error:null}}function Gc(n){return{data:n,error:null}}function Wc(n){const{action_link:e,email_otp:t,hashed_token:r,redirect_to:s,verification_type:i}=n,o=zc(n,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),a={action_link:e,email_otp:t,hashed_token:r,redirect_to:s,verification_type:i},c=Object.assign({},o);return{data:{properties:a,user:c},error:null}}function Kc(n){return n}function Xc(n){return n.access_token&&n.refresh_token&&n.expires_in}var Oe=globalThis&&globalThis.__awaiter||function(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(l){try{u(r.next(l))}catch(h){o(h)}}function c(l){try{u(r.throw(l))}catch(h){o(h)}}function u(l){l.done?i(l.value):s(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})},Zc=globalThis&&globalThis.__rest||function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(t[r[s]]=n[r[s]]);return t};class Yc{constructor({url:e="",headers:t={},fetch:r}){this.url=e,this.headers=t,this.fetch=Gi(r),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)}}signOut(e){return Oe(this,void 0,void 0,function*(){try{return yield D(this.fetch,"POST",`${this.url}/logout`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(t){if(C(t))return{data:null,error:t};throw t}})}inviteUserByEmail(e,t={}){return Oe(this,void 0,void 0,function*(){try{return yield D(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:t.data},headers:this.headers,redirectTo:t.redirectTo,xform:lt})}catch(r){if(C(r))return{data:{user:null},error:r};throw r}})}generateLink(e){return Oe(this,void 0,void 0,function*(){try{const{options:t}=e,r=Zc(e,["options"]),s=Object.assign(Object.assign({},r),t);return"newEmail"in r&&(s.new_email=r==null?void 0:r.newEmail,delete s.newEmail),yield D(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:s,headers:this.headers,xform:Wc,redirectTo:t==null?void 0:t.redirectTo})}catch(t){if(C(t))return{data:{properties:null,user:null},error:t};throw t}})}createUser(e){return Oe(this,void 0,void 0,function*(){try{return yield D(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:lt})}catch(t){if(C(t))return{data:{user:null},error:t};throw t}})}listUsers(e){var t,r,s,i,o,a,c;return Oe(this,void 0,void 0,function*(){try{const u={nextPage:null,lastPage:0,total:0},l=yield D(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(r=(t=e==null?void 0:e.page)===null||t===void 0?void 0:t.toString())!==null&&r!==void 0?r:"",per_page:(i=(s=e==null?void 0:e.perPage)===null||s===void 0?void 0:s.toString())!==null&&i!==void 0?i:""},xform:Kc});if(l.error)throw l.error;const h=yield l.json(),p=(o=l.headers.get("x-total-count"))!==null&&o!==void 0?o:0,f=(c=(a=l.headers.get("link"))===null||a===void 0?void 0:a.split(","))!==null&&c!==void 0?c:[];return f.length>0&&(f.forEach(d=>{const w=parseInt(d.split(";")[0].split("=")[1].substring(0,1)),b=JSON.parse(d.split(";")[1].split("=")[1]);u[`${b}Page`]=w}),u.total=parseInt(p)),{data:Object.assign(Object.assign({},h),u),error:null}}catch(u){if(C(u))return{data:{users:[]},error:u};throw u}})}getUserById(e){return Oe(this,void 0,void 0,function*(){try{return yield D(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:lt})}catch(t){if(C(t))return{data:{user:null},error:t};throw t}})}updateUserById(e,t){return Oe(this,void 0,void 0,function*(){try{return yield D(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:t,headers:this.headers,xform:lt})}catch(r){if(C(r))return{data:{user:null},error:r};throw r}})}deleteUser(e,t=!1){return Oe(this,void 0,void 0,function*(){try{return yield D(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:t},xform:lt})}catch(r){if(C(r))return{data:{user:null},error:r};throw r}})}_listFactors(e){return Oe(this,void 0,void 0,function*(){try{const{data:t,error:r}=yield D(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:s=>({data:{factors:s},error:null})});return{data:t,error:r}}catch(t){if(C(t))return{data:null,error:t};throw t}})}_deleteFactor(e){return Oe(this,void 0,void 0,function*(){try{return{data:yield D(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(t){if(C(t))return{data:null,error:t};throw t}})}}const Qc="2.13.0",eu="http://localhost:9999",tu="supabase.auth.token",ru={"X-Client-Info":`gotrue-js/${Qc}`},nu=10,su={getItem:n=>wn()?globalThis.localStorage.getItem(n):null,setItem:(n,e)=>{wn()&&globalThis.localStorage.setItem(n,e)},removeItem:n=>{wn()&&globalThis.localStorage.removeItem(n)}};function iu(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}var k=globalThis&&globalThis.__awaiter||function(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(l){try{u(r.next(l))}catch(h){o(h)}}function c(l){try{u(r.throw(l))}catch(h){o(h)}}function u(l){l.done?i(l.value):s(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})};iu();const ou={url:eu,storageKey:tu,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:ru},vn=10*1e3,au=3;class cu{constructor(e){this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.broadcastChannel=null;const t=Object.assign(Object.assign({},ou),e);this.inMemorySession=null,this.storageKey=t.storageKey,this.autoRefreshToken=t.autoRefreshToken,this.persistSession=t.persistSession,this.storage=t.storage||su,this.admin=new Yc({url:t.url,headers:t.headers,fetch:t.fetch}),this.url=t.url,this.headers=t.headers,this.fetch=Gi(t.fetch),this.detectSessionInUrl=t.detectSessionInUrl,this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this)},ot()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey&&(this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey),this.broadcastChannel.addEventListener("message",r=>{this._notifyAllSubscribers(r.data.event,r.data.session,!1)})),this.initialize()}initialize(){return this.initializePromise||(this.initializePromise=this._initialize()),this.initializePromise}_initialize(){return k(this,void 0,void 0,function*(){if(this.initializePromise)return this.initializePromise;try{if(this.detectSessionInUrl&&this._isImplicitGrantFlow()){const{data:e,error:t}=yield this._getSessionFromUrl();if(t)return yield this._removeSession(),{error:t};const{session:r,redirectType:s}=e;return yield this._saveSession(r),setTimeout(()=>{this._notifyAllSubscribers("SIGNED_IN",r),s==="recovery"&&this._notifyAllSubscribers("PASSWORD_RECOVERY",r)},0),{error:null}}return yield this._recoverAndRefresh(),{error:null}}catch(e){return C(e)?{error:e}:{error:new Wi("Unexpected error during initialization",e)}}finally{yield this._handleVisibilityChange()}})}signUp(e){var t,r;return k(this,void 0,void 0,function*(){try{yield this._removeSession();let s;if("email"in e){const{email:u,password:l,options:h}=e;s=yield D(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:h==null?void 0:h.emailRedirectTo,body:{email:u,password:l,data:(t=h==null?void 0:h.data)!==null&&t!==void 0?t:{},gotrue_meta_security:{captcha_token:h==null?void 0:h.captchaToken}},xform:it})}else if("phone"in e){const{phone:u,password:l,options:h}=e;s=yield D(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:u,password:l,data:(r=h==null?void 0:h.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:h==null?void 0:h.captchaToken}},xform:it})}else throw new bn("You must provide either an email or phone number and a password");const{data:i,error:o}=s;if(o||!i)return{data:{user:null,session:null},error:o};const a=i.session,c=i.user;return i.session&&(yield this._saveSession(i.session),this._notifyAllSubscribers("SIGNED_IN",a)),{data:{user:c,session:a},error:null}}catch(s){if(C(s))return{data:{user:null,session:null},error:s};throw s}})}signInWithPassword(e){var t;return k(this,void 0,void 0,function*(){try{yield this._removeSession();let r;if("email"in e){const{email:o,password:a,options:c}=e;r=yield D(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:o,password:a,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken}},xform:it})}else if("phone"in e){const{phone:o,password:a,options:c}=e;r=yield D(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:o,password:a,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken},channel:(t=c==null?void 0:c.channel)!==null&&t!==void 0?t:"sms"},xform:it})}else throw new bn("You must provide either an email or phone number and a password");const{data:s,error:i}=r;return i||!s?{data:{user:null,session:null},error:i}:(s.session&&(yield this._saveSession(s.session),this._notifyAllSubscribers("SIGNED_IN",s.session)),{data:s,error:i})}catch(r){if(C(r))return{data:{user:null,session:null},error:r};throw r}})}signInWithOAuth(e){var t,r,s,i;return k(this,void 0,void 0,function*(){return yield this._removeSession(),this._handleProviderSignIn(e.provider,{redirectTo:(t=e.options)===null||t===void 0?void 0:t.redirectTo,scopes:(r=e.options)===null||r===void 0?void 0:r.scopes,queryParams:(s=e.options)===null||s===void 0?void 0:s.queryParams,skipBrowserRedirect:(i=e.options)===null||i===void 0?void 0:i.skipBrowserRedirect})})}signInWithIdToken(e){return k(this,void 0,void 0,function*(){yield this._removeSession();try{const{options:t,provider:r,token:s,nonce:i}=e,o=yield D(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:r,id_token:s,nonce:i,gotrue_meta_security:{captcha_token:t==null?void 0:t.captchaToken}},xform:it}),{data:a,error:c}=o;return c||!a?{data:{user:null,session:null},error:c}:(a.session&&(yield this._saveSession(a.session),this._notifyAllSubscribers("SIGNED_IN",a.session)),{data:a,error:c})}catch(t){if(C(t))return{data:{user:null,session:null},error:t};throw t}})}signInWithOtp(e){var t,r,s,i,o;return k(this,void 0,void 0,function*(){try{if(yield this._removeSession(),"email"in e){const{email:a,options:c}=e,{error:u}=yield D(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:a,data:(t=c==null?void 0:c.data)!==null&&t!==void 0?t:{},create_user:(r=c==null?void 0:c.shouldCreateUser)!==null&&r!==void 0?r:!0,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken}},redirectTo:c==null?void 0:c.emailRedirectTo});return{data:{user:null,session:null},error:u}}if("phone"in e){const{phone:a,options:c}=e,{error:u}=yield D(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:a,data:(s=c==null?void 0:c.data)!==null&&s!==void 0?s:{},create_user:(i=c==null?void 0:c.shouldCreateUser)!==null&&i!==void 0?i:!0,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken},channel:(o=c==null?void 0:c.channel)!==null&&o!==void 0?o:"sms"}});return{data:{user:null,session:null},error:u}}throw new bn("You must provide either an email or phone number.")}catch(a){if(C(a))return{data:{user:null,session:null},error:a};throw a}})}verifyOtp(e){var t,r;return k(this,void 0,void 0,function*(){try{yield this._removeSession();const{data:s,error:i}=yield D(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:(t=e.options)===null||t===void 0?void 0:t.captchaToken}}),redirectTo:(r=e.options)===null||r===void 0?void 0:r.redirectTo,xform:it});if(i)throw i;if(!s)throw"An error occurred on token verification.";const o=s.session,a=s.user;return o!=null&&o.access_token&&(yield this._saveSession(o),this._notifyAllSubscribers("SIGNED_IN",o)),{data:{user:a,session:o},error:null}}catch(s){if(C(s))return{data:{user:null,session:null},error:s};throw s}})}signInWithSSO(e){var t,r,s;return k(this,void 0,void 0,function*(){try{return yield this._removeSession(),yield D(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:(r=(t=e.options)===null||t===void 0?void 0:t.redirectTo)!==null&&r!==void 0?r:void 0}),!((s=e==null?void 0:e.options)===null||s===void 0)&&s.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0}),headers:this.headers,xform:Gc})}catch(i){if(C(i))return{data:null,error:i};throw i}})}getSession(){return k(this,void 0,void 0,function*(){yield this.initializePromise;let e=null;if(this.persistSession){const i=yield zs(this.storage,this.storageKey);i!==null&&(this._isValidSession(i)?e=i:yield this._removeSession())}else e=this.inMemorySession;if(!e)return{data:{session:null},error:null};if(!(e.expires_at?e.expires_at<=Date.now()/1e3:!1))return{data:{session:e},error:null};const{session:r,error:s}=yield this._callRefreshToken(e.refresh_token);return s?{data:{session:null},error:s}:{data:{session:r},error:null}})}getUser(e){var t,r;return k(this,void 0,void 0,function*(){try{if(!e){const{data:s,error:i}=yield this.getSession();if(i)throw i;e=(r=(t=s.session)===null||t===void 0?void 0:t.access_token)!==null&&r!==void 0?r:void 0}return yield D(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:lt})}catch(s){if(C(s))return{data:{user:null},error:s};throw s}})}updateUser(e,t={}){return k(this,void 0,void 0,function*(){try{const{data:r,error:s}=yield this.getSession();if(s)throw s;if(!r.session)throw new Gt;const i=r.session,{data:o,error:a}=yield D(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:t==null?void 0:t.emailRedirectTo,body:e,jwt:i.access_token,xform:lt});if(a)throw a;return i.user=o.user,yield this._saveSession(i),this._notifyAllSubscribers("USER_UPDATED",i),{data:{user:i.user},error:null}}catch(r){if(C(r))return{data:{user:null},error:r};throw r}})}_decodeJWT(e){return Vs(e)}setSession(e){return k(this,void 0,void 0,function*(){try{if(!e.access_token||!e.refresh_token)throw new Gt;const t=Date.now()/1e3;let r=t,s=!0,i=null;const o=Vs(e.access_token);if(o.exp&&(r=o.exp,s=r<=t),s){const{session:a,error:c}=yield this._callRefreshToken(e.refresh_token);if(c)return{data:{user:null,session:null},error:c};if(!a)return{data:{user:null,session:null},error:null};i=a}else{const{data:a,error:c}=yield this.getUser(e.access_token);if(c)throw c;i={access_token:e.access_token,refresh_token:e.refresh_token,user:a.user,token_type:"bearer",expires_in:r-t,expires_at:r},yield this._saveSession(i),this._notifyAllSubscribers("SIGNED_IN",i)}return{data:{user:i.user,session:i},error:null}}catch(t){if(C(t))return{data:{session:null,user:null},error:t};throw t}})}refreshSession(e){var t;return k(this,void 0,void 0,function*(){try{if(!e){const{data:i,error:o}=yield this.getSession();if(o)throw o;e=(t=i.session)!==null&&t!==void 0?t:void 0}if(!(e!=null&&e.refresh_token))throw new Gt;const{session:r,error:s}=yield this._callRefreshToken(e.refresh_token);return s?{data:{user:null,session:null},error:s}:r?{data:{user:r.user,session:r},error:null}:{data:{user:null,session:null},error:null}}catch(r){if(C(r))return{data:{user:null,session:null},error:r};throw r}})}_getSessionFromUrl(){return k(this,void 0,void 0,function*(){try{if(!ot())throw new Ne("No browser detected.");if(!this._isImplicitGrantFlow())throw new Ne("Not a valid implicit grant flow url.");const e=le("error_description");if(e){const w=le("error_code");if(!w)throw new Ne("No error_code detected.");const b=le("error");throw b?new Ne(e,{error:b,code:w}):new Ne("No error detected.")}const t=le("provider_token"),r=le("provider_refresh_token"),s=le("access_token");if(!s)throw new Ne("No access_token detected.");const i=le("expires_in");if(!i)throw new Ne("No expires_in detected.");const o=le("refresh_token");if(!o)throw new Ne("No refresh_token detected.");const a=le("token_type");if(!a)throw new Ne("No token_type detected.");const u=Math.round(Date.now()/1e3)+parseInt(i),{data:l,error:h}=yield this.getUser(s);if(h)throw h;const p=l.user,f={provider_token:t,provider_refresh_token:r,access_token:s,expires_in:parseInt(i),expires_at:u,refresh_token:o,token_type:a,user:p},d=le("type");return window.location.hash="",{data:{session:f,redirectType:d},error:null}}catch(e){if(C(e))return{data:{session:null,redirectType:null},error:e};throw e}})}_isImplicitGrantFlow(){return ot()&&(Boolean(le("access_token"))||Boolean(le("error_description")))}signOut(){var e;return k(this,void 0,void 0,function*(){const{data:t,error:r}=yield this.getSession();if(r)return{error:r};const s=(e=t.session)===null||e===void 0?void 0:e.access_token;if(s){const{error:i}=yield this.admin.signOut(s);if(i&&!(Mc(i)&&(i.status===404||i.status===401)))return{error:i}}return yield this._removeSession(),this._notifyAllSubscribers("SIGNED_OUT",null),{error:null}})}onAuthStateChange(e){const t=Ic(),r={id:t,callback:e,unsubscribe:()=>{this.stateChangeEmitters.delete(t)}};return this.stateChangeEmitters.set(t,r),{data:{subscription:r}}}resetPasswordForEmail(e,t={}){return k(this,void 0,void 0,function*(){try{return yield D(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,gotrue_meta_security:{captcha_token:t.captchaToken}},headers:this.headers,redirectTo:t.redirectTo})}catch(r){if(C(r))return{data:null,error:r};throw r}})}_refreshAccessToken(e){return k(this,void 0,void 0,function*(){try{const t=Date.now();return yield Bc(r=>k(this,void 0,void 0,function*(){return yield jc(r*200),yield D(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:it})}),(r,s,i)=>i&&i.error&&i.error instanceof In&&Date.now()+(r+1)*200-t<vn)}catch(t){if(C(t))return{data:{session:null,user:null},error:t};throw t}})}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}_handleProviderSignIn(e,t={}){const r=this._getUrlForProvider(e,{redirectTo:t.redirectTo,scopes:t.scopes,queryParams:t.queryParams});return ot()&&!t.skipBrowserRedirect&&window.location.assign(r),{data:{provider:e,url:r},error:null}}_recoverAndRefresh(){var e;return k(this,void 0,void 0,function*(){try{const t=yield zs(this.storage,this.storageKey);if(!this._isValidSession(t)){t!==null&&(yield this._removeSession());return}const r=Math.round(Date.now()/1e3);if(((e=t.expires_at)!==null&&e!==void 0?e:1/0)<r+nu)if(this.autoRefreshToken&&t.refresh_token){const{error:s}=yield this._callRefreshToken(t.refresh_token);s&&(console.log(s.message),yield this._removeSession())}else yield this._removeSession();else this.persistSession&&(yield this._saveSession(t)),this._notifyAllSubscribers("SIGNED_IN",t)}catch(t){console.error(t);return}})}_callRefreshToken(e){var t,r;return k(this,void 0,void 0,function*(){if(this.refreshingDeferred)return this.refreshingDeferred.promise;try{if(this.refreshingDeferred=new Xr,!e)throw new Gt;const{data:s,error:i}=yield this._refreshAccessToken(e);if(i)throw i;if(!s.session)throw new Gt;yield this._saveSession(s.session),this._notifyAllSubscribers("TOKEN_REFRESHED",s.session);const o={session:s.session,error:null};return this.refreshingDeferred.resolve(o),o}catch(s){if(C(s)){const i={session:null,error:s};return(t=this.refreshingDeferred)===null||t===void 0||t.resolve(i),i}throw(r=this.refreshingDeferred)===null||r===void 0||r.reject(s),s}finally{this.refreshingDeferred=null}})}_notifyAllSubscribers(e,t,r=!0){this.broadcastChannel&&r&&this.broadcastChannel.postMessage({event:e,session:t}),this.stateChangeEmitters.forEach(s=>s.callback(e,t))}_saveSession(e){return k(this,void 0,void 0,function*(){this.persistSession||(this.inMemorySession=e),this.persistSession&&e.expires_at&&(yield this._persistSession(e))})}_persistSession(e){return Dc(this.storage,this.storageKey,e)}_removeSession(){return k(this,void 0,void 0,function*(){this.persistSession?yield Uc(this.storage,this.storageKey):this.inMemorySession=null})}_removeVisibilityChangedCallback(){const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&ot()&&(window!=null&&window.removeEventListener)&&window.removeEventListener("visibilitychange",e)}catch(t){console.error("removing visibilitychange callback failed",t)}}_startAutoRefresh(){return k(this,void 0,void 0,function*(){yield this._stopAutoRefresh();const e=setInterval(()=>this._autoRefreshTokenTick(),vn);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"&&e.unref(),yield this._autoRefreshTokenTick()})}_stopAutoRefresh(){return k(this,void 0,void 0,function*(){const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e)})}startAutoRefresh(){return k(this,void 0,void 0,function*(){this._removeVisibilityChangedCallback(),yield this._startAutoRefresh()})}stopAutoRefresh(){return k(this,void 0,void 0,function*(){this._removeVisibilityChangedCallback(),yield this._stopAutoRefresh()})}_autoRefreshTokenTick(){return k(this,void 0,void 0,function*(){const e=Date.now();try{const{data:{session:t}}=yield this.getSession();if(!t||!t.refresh_token||!t.expires_at)return;Math.floor((t.expires_at*1e3-e)/vn)<au&&(yield this._callRefreshToken(t.refresh_token))}catch(t){console.error("Auto refresh tick failed with error. This is likely a transient error.",t)}})}_handleVisibilityChange(){return k(this,void 0,void 0,function*(){if(!ot()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=()=>k(this,void 0,void 0,function*(){return yield this._onVisibilityChanged(!1)}),window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),yield this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}})}_onVisibilityChanged(e){return k(this,void 0,void 0,function*(){document.visibilityState==="visible"?(e||(yield this.initializePromise,yield this._recoverAndRefresh()),this.autoRefreshToken&&this._startAutoRefresh()):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()})}_getUrlForProvider(e,t){const r=[`provider=${encodeURIComponent(e)}`];if(t!=null&&t.redirectTo&&r.push(`redirect_to=${encodeURIComponent(t.redirectTo)}`),t!=null&&t.scopes&&r.push(`scopes=${encodeURIComponent(t.scopes)}`),t!=null&&t.queryParams){const s=new URLSearchParams(t.queryParams);r.push(s.toString())}return`${this.url}/authorize?${r.join("&")}`}_unenroll(e){var t;return k(this,void 0,void 0,function*(){try{const{data:r,error:s}=yield this.getSession();return s?{data:null,error:s}:yield D(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(t=r==null?void 0:r.session)===null||t===void 0?void 0:t.access_token})}catch(r){if(C(r))return{data:null,error:r};throw r}})}_enroll(e){var t,r;return k(this,void 0,void 0,function*(){try{const{data:s,error:i}=yield this.getSession();if(i)return{data:null,error:i};const{data:o,error:a}=yield D(this.fetch,"POST",`${this.url}/factors`,{body:{friendly_name:e.friendlyName,factor_type:e.factorType,issuer:e.issuer},headers:this.headers,jwt:(t=s==null?void 0:s.session)===null||t===void 0?void 0:t.access_token});return a?{data:null,error:a}:(!((r=o==null?void 0:o.totp)===null||r===void 0)&&r.qr_code&&(o.totp.qr_code=`data:image/svg+xml;utf-8,${o.totp.qr_code}`),{data:o,error:null})}catch(s){if(C(s))return{data:null,error:s};throw s}})}_verify(e){var t;return k(this,void 0,void 0,function*(){try{const{data:r,error:s}=yield this.getSession();if(s)return{data:null,error:s};const{data:i,error:o}=yield D(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:{code:e.code,challenge_id:e.challengeId},headers:this.headers,jwt:(t=r==null?void 0:r.session)===null||t===void 0?void 0:t.access_token});return o?{data:null,error:o}:(yield this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+i.expires_in},i)),this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",i),{data:i,error:o})}catch(r){if(C(r))return{data:null,error:r};throw r}})}_challenge(e){var t;return k(this,void 0,void 0,function*(){try{const{data:r,error:s}=yield this.getSession();return s?{data:null,error:s}:yield D(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{headers:this.headers,jwt:(t=r==null?void 0:r.session)===null||t===void 0?void 0:t.access_token})}catch(r){if(C(r))return{data:null,error:r};throw r}})}_challengeAndVerify(e){return k(this,void 0,void 0,function*(){const{data:t,error:r}=yield this._challenge({factorId:e.factorId});return r?{data:null,error:r}:yield this._verify({factorId:e.factorId,challengeId:t.id,code:e.code})})}_listFactors(){return k(this,void 0,void 0,function*(){const{data:{user:e},error:t}=yield this.getUser();if(t)return{data:null,error:t};const r=(e==null?void 0:e.factors)||[],s=r.filter(i=>i.factor_type==="totp"&&i.status==="verified");return{data:{all:r,totp:s},error:null}})}_getAuthenticatorAssuranceLevel(){var e,t;return k(this,void 0,void 0,function*(){const{data:{session:r},error:s}=yield this.getSession();if(s)return{data:null,error:s};if(!r)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const i=this._decodeJWT(r.access_token);let o=null;i.aal&&(o=i.aal);let a=o;((t=(e=r.user.factors)===null||e===void 0?void 0:e.filter(l=>l.status==="verified"))!==null&&t!==void 0?t:[]).length>0&&(a="aal2");const u=i.amr||[];return{data:{currentLevel:o,nextLevel:a,currentAuthenticationMethods:u},error:null}})}}class uu extends cu{constructor(e){super(e)}}var lu=globalThis&&globalThis.__awaiter||function(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(l){try{u(r.next(l))}catch(h){o(h)}}function c(l){try{u(r.throw(l))}catch(h){o(h)}}function u(l){l.done?i(l.value):s(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})};const hu={headers:Sc},fu={schema:"public"},du={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0},pu={};class yu{constructor(e,t,r){var s,i,o,a,c,u,l,h;if(this.supabaseUrl=e,this.supabaseKey=t,!e)throw new Error("supabaseUrl is required.");if(!t)throw new Error("supabaseKey is required.");const p=Nc(e);if(this.realtimeUrl=`${p}/realtime/v1`.replace(/^http/i,"ws"),this.authUrl=`${p}/auth/v1`,this.storageUrl=`${p}/storage/v1`,p.match(/(supabase\.co)|(supabase\.in)/)){const O=p.split(".");this.functionsUrl=`${O[0]}.functions.${O[1]}.${O[2]}`}else this.functionsUrl=`${p}/functions/v1`;const d=`sb-${new URL(this.authUrl).hostname.split(".")[0]}-auth-token`,w={db:fu,realtime:pu,auth:Object.assign(Object.assign({},du),{storageKey:d}),global:hu},b=$c(r??{},w);this.storageKey=(i=(s=b.auth)===null||s===void 0?void 0:s.storageKey)!==null&&i!==void 0?i:"",this.headers=(a=(o=b.global)===null||o===void 0?void 0:o.headers)!==null&&a!==void 0?a:{},this.auth=this._initSupabaseAuthClient((c=b.auth)!==null&&c!==void 0?c:{},this.headers,(u=b.global)===null||u===void 0?void 0:u.fetch),this.fetch=Pc(t,this._getAccessToken.bind(this),(l=b.global)===null||l===void 0?void 0:l.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers},b.realtime)),this.rest=new Pa(`${p}/rest/v1`,{headers:this.headers,schema:(h=b.db)===null||h===void 0?void 0:h.schema,fetch:this.fetch}),this._listenForAuthEvents()}get functions(){return new _a(this.functionsUrl,{headers:this.headers,customFetch:this.fetch})}get storage(){return new Oc(this.storageUrl,this.headers,this.fetch)}from(e){return this.rest.from(e)}rpc(e,t={},r){return this.rest.rpc(e,t,r)}channel(e,t={config:{}}){return this.realtime.channel(e,t)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}_getAccessToken(){var e,t;return lu(this,void 0,void 0,function*(){const{data:r}=yield this.auth.getSession();return(t=(e=r.session)===null||e===void 0?void 0:e.access_token)!==null&&t!==void 0?t:null})}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:s,storageKey:i},o,a){const c={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new uu({url:this.authUrl,headers:Object.assign(Object.assign({},c),o),storageKey:i,autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:s,fetch:a})}_initRealtimeClient(e){return new fc(this.realtimeUrl,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},e==null?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((t,r)=>{this._handleTokenChanged(t,r==null?void 0:r.access_token,"CLIENT")})}_handleTokenChanged(e,t,r){(e==="TOKEN_REFRESHED"||e==="SIGNED_IN")&&this.changedAccessToken!==t?(this.realtime.setAuth(t??null),this.changedAccessToken=t):(e==="SIGNED_OUT"||e==="USER_DELETED")&&(this.realtime.setAuth(this.supabaseKey),r=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}}const mu=(n,e,t)=>new yu(n,e,t);function Ki(n,e){return function(){return n.apply(e,arguments)}}const{toString:Xi}=Object.prototype,{getPrototypeOf:as}=Object,cs=(n=>e=>{const t=Xi.call(e);return n[t]||(n[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),Ve=n=>(n=n.toLowerCase(),e=>cs(e)===n),Yr=n=>e=>typeof e===n,{isArray:Vt}=Array,tr=Yr("undefined");function gu(n){return n!==null&&!tr(n)&&n.constructor!==null&&!tr(n.constructor)&&et(n.constructor.isBuffer)&&n.constructor.isBuffer(n)}const Zi=Ve("ArrayBuffer");function wu(n){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(n):e=n&&n.buffer&&Zi(n.buffer),e}const bu=Yr("string"),et=Yr("function"),Yi=Yr("number"),us=n=>n!==null&&typeof n=="object",vu=n=>n===!0||n===!1,Ar=n=>{if(cs(n)!=="object")return!1;const e=as(n);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in n)&&!(Symbol.iterator in n)},_u=Ve("Date"),Eu=Ve("File"),xu=Ve("Blob"),Ou=Ve("FileList"),Tu=n=>us(n)&&et(n.pipe),Su=n=>{const e="[object FormData]";return n&&(typeof FormData=="function"&&n instanceof FormData||Xi.call(n)===e||et(n.toString)&&n.toString()===e)},Au=Ve("URLSearchParams"),ku=n=>n.trim?n.trim():n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function fr(n,e,{allOwnKeys:t=!1}={}){if(n===null||typeof n>"u")return;let r,s;if(typeof n!="object"&&(n=[n]),Vt(n))for(r=0,s=n.length;r<s;r++)e.call(null,n[r],r,n);else{const i=t?Object.getOwnPropertyNames(n):Object.keys(n),o=i.length;let a;for(r=0;r<o;r++)a=i[r],e.call(null,n[a],a,n)}}function Qi(n,e){e=e.toLowerCase();const t=Object.keys(n);let r=t.length,s;for(;r-- >0;)if(s=t[r],e===s.toLowerCase())return s;return null}const eo=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),to=n=>!tr(n)&&n!==eo;function Fn(){const{caseless:n}=to(this)&&this||{},e={},t=(r,s)=>{const i=n&&Qi(e,s)||s;Ar(e[i])&&Ar(r)?e[i]=Fn(e[i],r):Ar(r)?e[i]=Fn({},r):Vt(r)?e[i]=r.slice():e[i]=r};for(let r=0,s=arguments.length;r<s;r++)arguments[r]&&fr(arguments[r],t);return e}const Ru=(n,e,t,{allOwnKeys:r}={})=>(fr(e,(s,i)=>{t&&et(s)?n[i]=Ki(s,t):n[i]=s},{allOwnKeys:r}),n),Pu=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),Nu=(n,e,t,r)=>{n.prototype=Object.create(e.prototype,r),n.prototype.constructor=n,Object.defineProperty(n,"super",{value:e.prototype}),t&&Object.assign(n.prototype,t)},$u=(n,e,t,r)=>{let s,i,o;const a={};if(e=e||{},n==null)return e;do{for(s=Object.getOwnPropertyNames(n),i=s.length;i-- >0;)o=s[i],(!r||r(o,n,e))&&!a[o]&&(e[o]=n[o],a[o]=!0);n=t!==!1&&as(n)}while(n&&(!t||t(n,e))&&n!==Object.prototype);return e},Cu=(n,e,t)=>{n=String(n),(t===void 0||t>n.length)&&(t=n.length),t-=e.length;const r=n.indexOf(e,t);return r!==-1&&r===t},Iu=n=>{if(!n)return null;if(Vt(n))return n;let e=n.length;if(!Yi(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=n[e];return t},Fu=(n=>e=>n&&e instanceof n)(typeof Uint8Array<"u"&&as(Uint8Array)),Du=(n,e)=>{const r=(n&&n[Symbol.iterator]).call(n);let s;for(;(s=r.next())&&!s.done;){const i=s.value;e.call(n,i[0],i[1])}},Uu=(n,e)=>{let t;const r=[];for(;(t=n.exec(e))!==null;)r.push(t);return r},Lu=Ve("HTMLFormElement"),ju=n=>n.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,r,s){return r.toUpperCase()+s}),qs=(({hasOwnProperty:n})=>(e,t)=>n.call(e,t))(Object.prototype),Bu=Ve("RegExp"),ro=(n,e)=>{const t=Object.getOwnPropertyDescriptors(n),r={};fr(t,(s,i)=>{e(s,i,n)!==!1&&(r[i]=s)}),Object.defineProperties(n,r)},Hu=n=>{ro(n,(e,t)=>{if(et(n)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const r=n[t];if(et(r)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},Mu=(n,e)=>{const t={},r=s=>{s.forEach(i=>{t[i]=!0})};return Vt(n)?r(n):r(String(n).split(e)),t},zu=()=>{},Vu=(n,e)=>(n=+n,Number.isFinite(n)?n:e),_n="abcdefghijklmnopqrstuvwxyz",Js="0123456789",no={DIGIT:Js,ALPHA:_n,ALPHA_DIGIT:_n+_n.toUpperCase()+Js},qu=(n=16,e=no.ALPHA_DIGIT)=>{let t="";const{length:r}=e;for(;n--;)t+=e[Math.random()*r|0];return t};function Ju(n){return!!(n&&et(n.append)&&n[Symbol.toStringTag]==="FormData"&&n[Symbol.iterator])}const Gu=n=>{const e=new Array(10),t=(r,s)=>{if(us(r)){if(e.indexOf(r)>=0)return;if(!("toJSON"in r)){e[s]=r;const i=Vt(r)?[]:{};return fr(r,(o,a)=>{const c=t(o,s+1);!tr(c)&&(i[a]=c)}),e[s]=void 0,i}}return r};return t(n,0)},g={isArray:Vt,isArrayBuffer:Zi,isBuffer:gu,isFormData:Su,isArrayBufferView:wu,isString:bu,isNumber:Yi,isBoolean:vu,isObject:us,isPlainObject:Ar,isUndefined:tr,isDate:_u,isFile:Eu,isBlob:xu,isRegExp:Bu,isFunction:et,isStream:Tu,isURLSearchParams:Au,isTypedArray:Fu,isFileList:Ou,forEach:fr,merge:Fn,extend:Ru,trim:ku,stripBOM:Pu,inherits:Nu,toFlatObject:$u,kindOf:cs,kindOfTest:Ve,endsWith:Cu,toArray:Iu,forEachEntry:Du,matchAll:Uu,isHTMLForm:Lu,hasOwnProperty:qs,hasOwnProp:qs,reduceDescriptors:ro,freezeMethods:Hu,toObjectSet:Mu,toCamelCase:ju,noop:zu,toFiniteNumber:Vu,findKey:Qi,global:eo,isContextDefined:to,ALPHABET:no,generateString:qu,isSpecCompliantForm:Ju,toJSONObject:Gu};function N(n,e,t,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=n,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),r&&(this.request=r),s&&(this.response=s)}g.inherits(N,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:g.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const so=N.prototype,io={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(n=>{io[n]={value:n}});Object.defineProperties(N,io);Object.defineProperty(so,"isAxiosError",{value:!0});N.from=(n,e,t,r,s,i)=>{const o=Object.create(so);return g.toFlatObject(n,o,function(c){return c!==Error.prototype},a=>a!=="isAxiosError"),N.call(o,n.message,e,t,r,s),o.cause=n,o.name=n.name,i&&Object.assign(o,i),o};const Wu=null;function Dn(n){return g.isPlainObject(n)||g.isArray(n)}function oo(n){return g.endsWith(n,"[]")?n.slice(0,-2):n}function Gs(n,e,t){return n?n.concat(e).map(function(s,i){return s=oo(s),!t&&i?"["+s+"]":s}).join(t?".":""):e}function Ku(n){return g.isArray(n)&&!n.some(Dn)}const Xu=g.toFlatObject(g,{},null,function(e){return/^is[A-Z]/.test(e)});function Qr(n,e,t){if(!g.isObject(n))throw new TypeError("target must be an object");e=e||new FormData,t=g.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(w,b){return!g.isUndefined(b[w])});const r=t.metaTokens,s=t.visitor||l,i=t.dots,o=t.indexes,c=(t.Blob||typeof Blob<"u"&&Blob)&&g.isSpecCompliantForm(e);if(!g.isFunction(s))throw new TypeError("visitor must be a function");function u(d){if(d===null)return"";if(g.isDate(d))return d.toISOString();if(!c&&g.isBlob(d))throw new N("Blob is not supported. Use a Buffer instead.");return g.isArrayBuffer(d)||g.isTypedArray(d)?c&&typeof Blob=="function"?new Blob([d]):Buffer.from(d):d}function l(d,w,b){let O=d;if(d&&!b&&typeof d=="object"){if(g.endsWith(w,"{}"))w=r?w:w.slice(0,-2),d=JSON.stringify(d);else if(g.isArray(d)&&Ku(d)||(g.isFileList(d)||g.endsWith(w,"[]"))&&(O=g.toArray(d)))return w=oo(w),O.forEach(function(M,U){!(g.isUndefined(M)||M===null)&&e.append(o===!0?Gs([w],U,i):o===null?w:w+"[]",u(M))}),!1}return Dn(d)?!0:(e.append(Gs(b,w,i),u(d)),!1)}const h=[],p=Object.assign(Xu,{defaultVisitor:l,convertValue:u,isVisitable:Dn});function f(d,w){if(!g.isUndefined(d)){if(h.indexOf(d)!==-1)throw Error("Circular reference detected in "+w.join("."));h.push(d),g.forEach(d,function(O,P){(!(g.isUndefined(O)||O===null)&&s.call(e,O,g.isString(P)?P.trim():P,w,p))===!0&&f(O,w?w.concat(P):[P])}),h.pop()}}if(!g.isObject(n))throw new TypeError("data must be an object");return f(n),e}function Ws(n){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g,function(r){return e[r]})}function ls(n,e){this._pairs=[],n&&Qr(n,this,e)}const ao=ls.prototype;ao.append=function(e,t){this._pairs.push([e,t])};ao.toString=function(e){const t=e?function(r){return e.call(this,r,Ws)}:Ws;return this._pairs.map(function(s){return t(s[0])+"="+t(s[1])},"").join("&")};function Zu(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function co(n,e,t){if(!e)return n;const r=t&&t.encode||Zu,s=t&&t.serialize;let i;if(s?i=s(e,t):i=g.isURLSearchParams(e)?e.toString():new ls(e,t).toString(r),i){const o=n.indexOf("#");o!==-1&&(n=n.slice(0,o)),n+=(n.indexOf("?")===-1?"?":"&")+i}return n}class Yu{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){g.forEach(this.handlers,function(r){r!==null&&e(r)})}}const Ks=Yu,uo={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Qu=typeof URLSearchParams<"u"?URLSearchParams:ls,el=typeof FormData<"u"?FormData:null,tl=typeof Blob<"u"?Blob:null,rl=(()=>{let n;return typeof navigator<"u"&&((n=navigator.product)==="ReactNative"||n==="NativeScript"||n==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),nl=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),Pe={isBrowser:!0,classes:{URLSearchParams:Qu,FormData:el,Blob:tl},isStandardBrowserEnv:rl,isStandardBrowserWebWorkerEnv:nl,protocols:["http","https","file","blob","url","data"]};function sl(n,e){return Qr(n,new Pe.classes.URLSearchParams,Object.assign({visitor:function(t,r,s,i){return Pe.isNode&&g.isBuffer(t)?(this.append(r,t.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},e))}function il(n){return g.matchAll(/\w+|\[(\w*)]/g,n).map(e=>e[0]==="[]"?"":e[1]||e[0])}function ol(n){const e={},t=Object.keys(n);let r;const s=t.length;let i;for(r=0;r<s;r++)i=t[r],e[i]=n[i];return e}function lo(n){function e(t,r,s,i){let o=t[i++];const a=Number.isFinite(+o),c=i>=t.length;return o=!o&&g.isArray(s)?s.length:o,c?(g.hasOwnProp(s,o)?s[o]=[s[o],r]:s[o]=r,!a):((!s[o]||!g.isObject(s[o]))&&(s[o]=[]),e(t,r,s[o],i)&&g.isArray(s[o])&&(s[o]=ol(s[o])),!a)}if(g.isFormData(n)&&g.isFunction(n.entries)){const t={};return g.forEachEntry(n,(r,s)=>{e(il(r),s,t,0)}),t}return null}const al={"Content-Type":void 0};function cl(n,e,t){if(g.isString(n))try{return(e||JSON.parse)(n),g.trim(n)}catch(r){if(r.name!=="SyntaxError")throw r}return(t||JSON.stringify)(n)}const en={transitional:uo,adapter:["xhr","http"],transformRequest:[function(e,t){const r=t.getContentType()||"",s=r.indexOf("application/json")>-1,i=g.isObject(e);if(i&&g.isHTMLForm(e)&&(e=new FormData(e)),g.isFormData(e))return s&&s?JSON.stringify(lo(e)):e;if(g.isArrayBuffer(e)||g.isBuffer(e)||g.isStream(e)||g.isFile(e)||g.isBlob(e))return e;if(g.isArrayBufferView(e))return e.buffer;if(g.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return sl(e,this.formSerializer).toString();if((a=g.isFileList(e))||r.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return Qr(a?{"files[]":e}:e,c&&new c,this.formSerializer)}}return i||s?(t.setContentType("application/json",!1),cl(e)):e}],transformResponse:[function(e){const t=this.transitional||en.transitional,r=t&&t.forcedJSONParsing,s=this.responseType==="json";if(e&&g.isString(e)&&(r&&!this.responseType||s)){const o=!(t&&t.silentJSONParsing)&&s;try{return JSON.parse(e)}catch(a){if(o)throw a.name==="SyntaxError"?N.from(a,N.ERR_BAD_RESPONSE,this,null,this.response):a}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Pe.classes.FormData,Blob:Pe.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};g.forEach(["delete","get","head"],function(e){en.headers[e]={}});g.forEach(["post","put","patch"],function(e){en.headers[e]=g.merge(al)});const hs=en,ul=g.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),ll=n=>{const e={};let t,r,s;return n&&n.split(`
2
- `).forEach(function(o){s=o.indexOf(":"),t=o.substring(0,s).trim().toLowerCase(),r=o.substring(s+1).trim(),!(!t||e[t]&&ul[t])&&(t==="set-cookie"?e[t]?e[t].push(r):e[t]=[r]:e[t]=e[t]?e[t]+", "+r:r)}),e},Xs=Symbol("internals");function Wt(n){return n&&String(n).trim().toLowerCase()}function kr(n){return n===!1||n==null?n:g.isArray(n)?n.map(kr):String(n)}function hl(n){const e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=t.exec(n);)e[r[1]]=r[2];return e}function fl(n){return/^[-_a-zA-Z]+$/.test(n.trim())}function En(n,e,t,r,s){if(g.isFunction(r))return r.call(this,e,t);if(s&&(e=t),!!g.isString(e)){if(g.isString(r))return e.indexOf(r)!==-1;if(g.isRegExp(r))return r.test(e)}}function dl(n){return n.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,r)=>t.toUpperCase()+r)}function pl(n,e){const t=g.toCamelCase(" "+e);["get","set","has"].forEach(r=>{Object.defineProperty(n,r+t,{value:function(s,i,o){return this[r].call(this,e,s,i,o)},configurable:!0})})}class tn{constructor(e){e&&this.set(e)}set(e,t,r){const s=this;function i(a,c,u){const l=Wt(c);if(!l)throw new Error("header name must be a non-empty string");const h=g.findKey(s,l);(!h||s[h]===void 0||u===!0||u===void 0&&s[h]!==!1)&&(s[h||c]=kr(a))}const o=(a,c)=>g.forEach(a,(u,l)=>i(u,l,c));return g.isPlainObject(e)||e instanceof this.constructor?o(e,t):g.isString(e)&&(e=e.trim())&&!fl(e)?o(ll(e),t):e!=null&&i(t,e,r),this}get(e,t){if(e=Wt(e),e){const r=g.findKey(this,e);if(r){const s=this[r];if(!t)return s;if(t===!0)return hl(s);if(g.isFunction(t))return t.call(this,s,r);if(g.isRegExp(t))return t.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Wt(e),e){const r=g.findKey(this,e);return!!(r&&this[r]!==void 0&&(!t||En(this,this[r],r,t)))}return!1}delete(e,t){const r=this;let s=!1;function i(o){if(o=Wt(o),o){const a=g.findKey(r,o);a&&(!t||En(r,r[a],a,t))&&(delete r[a],s=!0)}}return g.isArray(e)?e.forEach(i):i(e),s}clear(e){const t=Object.keys(this);let r=t.length,s=!1;for(;r--;){const i=t[r];(!e||En(this,this[i],i,e,!0))&&(delete this[i],s=!0)}return s}normalize(e){const t=this,r={};return g.forEach(this,(s,i)=>{const o=g.findKey(r,i);if(o){t[o]=kr(s),delete t[i];return}const a=e?dl(i):String(i).trim();a!==i&&delete t[i],t[a]=kr(s),r[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return g.forEach(this,(r,s)=>{r!=null&&r!==!1&&(t[s]=e&&g.isArray(r)?r.join(", "):r)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join(`
3
- `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach(s=>r.set(s)),r}static accessor(e){const r=(this[Xs]=this[Xs]={accessors:{}}).accessors,s=this.prototype;function i(o){const a=Wt(o);r[a]||(pl(s,o),r[a]=!0)}return g.isArray(e)?e.forEach(i):i(e),this}}tn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);g.freezeMethods(tn.prototype);g.freezeMethods(tn);const je=tn;function xn(n,e){const t=this||hs,r=e||t,s=je.from(r.headers);let i=r.data;return g.forEach(n,function(a){i=a.call(t,i,s.normalize(),e?e.status:void 0)}),s.normalize(),i}function ho(n){return!!(n&&n.__CANCEL__)}function dr(n,e,t){N.call(this,n??"canceled",N.ERR_CANCELED,e,t),this.name="CanceledError"}g.inherits(dr,N,{__CANCEL__:!0});function yl(n,e,t){const r=t.config.validateStatus;!t.status||!r||r(t.status)?n(t):e(new N("Request failed with status code "+t.status,[N.ERR_BAD_REQUEST,N.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}const ml=Pe.isStandardBrowserEnv?function(){return{write:function(t,r,s,i,o,a){const c=[];c.push(t+"="+encodeURIComponent(r)),g.isNumber(s)&&c.push("expires="+new Date(s).toGMTString()),g.isString(i)&&c.push("path="+i),g.isString(o)&&c.push("domain="+o),a===!0&&c.push("secure"),document.cookie=c.join("; ")},read:function(t){const r=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function gl(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function wl(n,e){return e?n.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):n}function fo(n,e){return n&&!gl(e)?wl(n,e):e}const bl=Pe.isStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a");let r;function s(i){let o=i;return e&&(t.setAttribute("href",o),o=t.href),t.setAttribute("href",o),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}return r=s(window.location.href),function(o){const a=g.isString(o)?s(o):o;return a.protocol===r.protocol&&a.host===r.host}}():function(){return function(){return!0}}();function vl(n){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return e&&e[1]||""}function _l(n,e){n=n||10;const t=new Array(n),r=new Array(n);let s=0,i=0,o;return e=e!==void 0?e:1e3,function(c){const u=Date.now(),l=r[i];o||(o=u),t[s]=c,r[s]=u;let h=i,p=0;for(;h!==s;)p+=t[h++],h=h%n;if(s=(s+1)%n,s===i&&(i=(i+1)%n),u-o<e)return;const f=l&&u-l;return f?Math.round(p*1e3/f):void 0}}function Zs(n,e){let t=0;const r=_l(50,250);return s=>{const i=s.loaded,o=s.lengthComputable?s.total:void 0,a=i-t,c=r(a),u=i<=o;t=i;const l={loaded:i,total:o,progress:o?i/o:void 0,bytes:a,rate:c||void 0,estimated:c&&o&&u?(o-i)/c:void 0,event:s};l[e?"download":"upload"]=!0,n(l)}}const El=typeof XMLHttpRequest<"u",xl=El&&function(n){return new Promise(function(t,r){let s=n.data;const i=je.from(n.headers).normalize(),o=n.responseType;let a;function c(){n.cancelToken&&n.cancelToken.unsubscribe(a),n.signal&&n.signal.removeEventListener("abort",a)}g.isFormData(s)&&(Pe.isStandardBrowserEnv||Pe.isStandardBrowserWebWorkerEnv)&&i.setContentType(!1);let u=new XMLHttpRequest;if(n.auth){const f=n.auth.username||"",d=n.auth.password?unescape(encodeURIComponent(n.auth.password)):"";i.set("Authorization","Basic "+btoa(f+":"+d))}const l=fo(n.baseURL,n.url);u.open(n.method.toUpperCase(),co(l,n.params,n.paramsSerializer),!0),u.timeout=n.timeout;function h(){if(!u)return;const f=je.from("getAllResponseHeaders"in u&&u.getAllResponseHeaders()),w={data:!o||o==="text"||o==="json"?u.responseText:u.response,status:u.status,statusText:u.statusText,headers:f,config:n,request:u};yl(function(O){t(O),c()},function(O){r(O),c()},w),u=null}if("onloadend"in u?u.onloadend=h:u.onreadystatechange=function(){!u||u.readyState!==4||u.status===0&&!(u.responseURL&&u.responseURL.indexOf("file:")===0)||setTimeout(h)},u.onabort=function(){u&&(r(new N("Request aborted",N.ECONNABORTED,n,u)),u=null)},u.onerror=function(){r(new N("Network Error",N.ERR_NETWORK,n,u)),u=null},u.ontimeout=function(){let d=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const w=n.transitional||uo;n.timeoutErrorMessage&&(d=n.timeoutErrorMessage),r(new N(d,w.clarifyTimeoutError?N.ETIMEDOUT:N.ECONNABORTED,n,u)),u=null},Pe.isStandardBrowserEnv){const f=(n.withCredentials||bl(l))&&n.xsrfCookieName&&ml.read(n.xsrfCookieName);f&&i.set(n.xsrfHeaderName,f)}s===void 0&&i.setContentType(null),"setRequestHeader"in u&&g.forEach(i.toJSON(),function(d,w){u.setRequestHeader(w,d)}),g.isUndefined(n.withCredentials)||(u.withCredentials=!!n.withCredentials),o&&o!=="json"&&(u.responseType=n.responseType),typeof n.onDownloadProgress=="function"&&u.addEventListener("progress",Zs(n.onDownloadProgress,!0)),typeof n.onUploadProgress=="function"&&u.upload&&u.upload.addEventListener("progress",Zs(n.onUploadProgress)),(n.cancelToken||n.signal)&&(a=f=>{u&&(r(!f||f.type?new dr(null,n,u):f),u.abort(),u=null)},n.cancelToken&&n.cancelToken.subscribe(a),n.signal&&(n.signal.aborted?a():n.signal.addEventListener("abort",a)));const p=vl(l);if(p&&Pe.protocols.indexOf(p)===-1){r(new N("Unsupported protocol "+p+":",N.ERR_BAD_REQUEST,n));return}u.send(s||null)})},Rr={http:Wu,xhr:xl};g.forEach(Rr,(n,e)=>{if(n){try{Object.defineProperty(n,"name",{value:e})}catch{}Object.defineProperty(n,"adapterName",{value:e})}});const Ol={getAdapter:n=>{n=g.isArray(n)?n:[n];const{length:e}=n;let t,r;for(let s=0;s<e&&(t=n[s],!(r=g.isString(t)?Rr[t.toLowerCase()]:t));s++);if(!r)throw r===!1?new N(`Adapter ${t} is not supported by the environment`,"ERR_NOT_SUPPORT"):new Error(g.hasOwnProp(Rr,t)?`Adapter '${t}' is not available in the build`:`Unknown adapter '${t}'`);if(!g.isFunction(r))throw new TypeError("adapter is not a function");return r},adapters:Rr};function On(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new dr(null,n)}function Ys(n){return On(n),n.headers=je.from(n.headers),n.data=xn.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),Ol.getAdapter(n.adapter||hs.adapter)(n).then(function(r){return On(n),r.data=xn.call(n,n.transformResponse,r),r.headers=je.from(r.headers),r},function(r){return ho(r)||(On(n),r&&r.response&&(r.response.data=xn.call(n,n.transformResponse,r.response),r.response.headers=je.from(r.response.headers))),Promise.reject(r)})}const Qs=n=>n instanceof je?n.toJSON():n;function Mt(n,e){e=e||{};const t={};function r(u,l,h){return g.isPlainObject(u)&&g.isPlainObject(l)?g.merge.call({caseless:h},u,l):g.isPlainObject(l)?g.merge({},l):g.isArray(l)?l.slice():l}function s(u,l,h){if(g.isUndefined(l)){if(!g.isUndefined(u))return r(void 0,u,h)}else return r(u,l,h)}function i(u,l){if(!g.isUndefined(l))return r(void 0,l)}function o(u,l){if(g.isUndefined(l)){if(!g.isUndefined(u))return r(void 0,u)}else return r(void 0,l)}function a(u,l,h){if(h in e)return r(u,l);if(h in n)return r(void 0,u)}const c={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(u,l)=>s(Qs(u),Qs(l),!0)};return g.forEach(Object.keys(n).concat(Object.keys(e)),function(l){const h=c[l]||s,p=h(n[l],e[l],l);g.isUndefined(p)&&h!==a||(t[l]=p)}),t}const po="1.3.4",fs={};["object","boolean","number","function","string","symbol"].forEach((n,e)=>{fs[n]=function(r){return typeof r===n||"a"+(e<1?"n ":" ")+n}});const ei={};fs.transitional=function(e,t,r){function s(i,o){return"[Axios v"+po+"] Transitional option '"+i+"'"+o+(r?". "+r:"")}return(i,o,a)=>{if(e===!1)throw new N(s(o," has been removed"+(t?" in "+t:"")),N.ERR_DEPRECATED);return t&&!ei[o]&&(ei[o]=!0,console.warn(s(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(i,o,a):!0}};function Tl(n,e,t){if(typeof n!="object")throw new N("options must be an object",N.ERR_BAD_OPTION_VALUE);const r=Object.keys(n);let s=r.length;for(;s-- >0;){const i=r[s],o=e[i];if(o){const a=n[i],c=a===void 0||o(a,i,n);if(c!==!0)throw new N("option "+i+" must be "+c,N.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new N("Unknown option "+i,N.ERR_BAD_OPTION)}}const Un={assertOptions:Tl,validators:fs},Ge=Un.validators;class Dr{constructor(e){this.defaults=e,this.interceptors={request:new Ks,response:new Ks}}request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=Mt(this.defaults,t);const{transitional:r,paramsSerializer:s,headers:i}=t;r!==void 0&&Un.assertOptions(r,{silentJSONParsing:Ge.transitional(Ge.boolean),forcedJSONParsing:Ge.transitional(Ge.boolean),clarifyTimeoutError:Ge.transitional(Ge.boolean)},!1),s!==void 0&&Un.assertOptions(s,{encode:Ge.function,serialize:Ge.function},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o;o=i&&g.merge(i.common,i[t.method]),o&&g.forEach(["delete","get","head","post","put","patch","common"],d=>{delete i[d]}),t.headers=je.concat(o,i);const a=[];let c=!0;this.interceptors.request.forEach(function(w){typeof w.runWhen=="function"&&w.runWhen(t)===!1||(c=c&&w.synchronous,a.unshift(w.fulfilled,w.rejected))});const u=[];this.interceptors.response.forEach(function(w){u.push(w.fulfilled,w.rejected)});let l,h=0,p;if(!c){const d=[Ys.bind(this),void 0];for(d.unshift.apply(d,a),d.push.apply(d,u),p=d.length,l=Promise.resolve(t);h<p;)l=l.then(d[h++],d[h++]);return l}p=a.length;let f=t;for(h=0;h<p;){const d=a[h++],w=a[h++];try{f=d(f)}catch(b){w.call(this,b);break}}try{l=Ys.call(this,f)}catch(d){return Promise.reject(d)}for(h=0,p=u.length;h<p;)l=l.then(u[h++],u[h++]);return l}getUri(e){e=Mt(this.defaults,e);const t=fo(e.baseURL,e.url);return co(t,e.params,e.paramsSerializer)}}g.forEach(["delete","get","head","options"],function(e){Dr.prototype[e]=function(t,r){return this.request(Mt(r||{},{method:e,url:t,data:(r||{}).data}))}});g.forEach(["post","put","patch"],function(e){function t(r){return function(i,o,a){return this.request(Mt(a||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}Dr.prototype[e]=t(),Dr.prototype[e+"Form"]=t(!0)});const Pr=Dr;class ds{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(i){t=i});const r=this;this.promise.then(s=>{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](s);r._listeners=null}),this.promise.then=s=>{let i;const o=new Promise(a=>{r.subscribe(a),i=a}).then(s);return o.cancel=function(){r.unsubscribe(i)},o},e(function(i,o,a){r.reason||(r.reason=new dr(i,o,a),t(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}static source(){let e;return{token:new ds(function(s){e=s}),cancel:e}}}const Sl=ds;function Al(n){return function(t){return n.apply(null,t)}}function kl(n){return g.isObject(n)&&n.isAxiosError===!0}const Ln={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Ln).forEach(([n,e])=>{Ln[e]=n});const Rl=Ln;function yo(n){const e=new Pr(n),t=Ki(Pr.prototype.request,e);return g.extend(t,Pr.prototype,e,{allOwnKeys:!0}),g.extend(t,e,null,{allOwnKeys:!0}),t.create=function(s){return yo(Mt(n,s))},t}const V=yo(hs);V.Axios=Pr;V.CanceledError=dr;V.CancelToken=Sl;V.isCancel=ho;V.VERSION=po;V.toFormData=Qr;V.AxiosError=N;V.Cancel=V.CanceledError;V.all=function(e){return Promise.all(e)};V.spread=Al;V.isAxiosError=kl;V.mergeConfig=Mt;V.AxiosHeaders=je;V.formToJSON=n=>lo(g.isHTMLForm(n)?new FormData(n):n);V.HttpStatusCode=Rl;V.default=V;const Pl=V;function Et(n){this._maxSize=n,this.clear()}Et.prototype.clear=function(){this._size=0,this._values=Object.create(null)};Et.prototype.get=function(n){return this._values[n]};Et.prototype.set=function(n,e){return this._size>=this._maxSize&&this.clear(),n in this._values||this._size++,this._values[n]=e};var Nl=/[^.^\]^[]+|(?=\[\]|\.\.)/g,mo=/^\d+$/,$l=/^\d/,Cl=/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,Il=/^\s*(['"]?)(.*?)(\1)\s*$/,ps=512,ti=new Et(ps),ri=new Et(ps),ni=new Et(ps),pt={Cache:Et,split:jn,normalizePath:Tn,setter:function(n){var e=Tn(n);return ri.get(n)||ri.set(n,function(r,s){for(var i=0,o=e.length,a=r;i<o-1;){var c=e[i];if(c==="__proto__"||c==="constructor"||c==="prototype")return r;a=a[e[i++]]}a[e[i]]=s})},getter:function(n,e){var t=Tn(n);return ni.get(n)||ni.set(n,function(s){for(var i=0,o=t.length;i<o;)if(s!=null||!e)s=s[t[i++]];else return;return s})},join:function(n){return n.reduce(function(e,t){return e+(ys(t)||mo.test(t)?"["+t+"]":(e?".":"")+t)},"")},forEach:function(n,e,t){Fl(Array.isArray(n)?n:jn(n),e,t)}};function Tn(n){return ti.get(n)||ti.set(n,jn(n).map(function(e){return e.replace(Il,"$2")}))}function jn(n){return n.match(Nl)||[""]}function Fl(n,e,t){var r=n.length,s,i,o,a;for(i=0;i<r;i++)s=n[i],s&&(Ll(s)&&(s='"'+s+'"'),a=ys(s),o=!a&&/^\d+$/.test(s),e.call(t,s,a,o,i,n))}function ys(n){return typeof n=="string"&&n&&["'",'"'].indexOf(n.charAt(0))!==-1}function Dl(n){return n.match($l)&&!n.match(mo)}function Ul(n){return Cl.test(n)}function Ll(n){return!ys(n)&&(Dl(n)||Ul(n))}const jl=/[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g,rn=n=>n.match(jl)||[],nn=n=>n[0].toUpperCase()+n.slice(1),ms=(n,e)=>rn(n).join(e).toLowerCase(),go=n=>rn(n).reduce((e,t)=>`${e}${e?t[0].toUpperCase()+t.slice(1).toLowerCase():t.toLowerCase()}`,""),Bl=n=>nn(go(n)),Hl=n=>ms(n,"_"),Ml=n=>ms(n,"-"),zl=n=>nn(ms(n," ")),Vl=n=>rn(n).map(nn).join(" ");var Sn={words:rn,upperFirst:nn,camelCase:go,pascalCase:Bl,snakeCase:Hl,kebabCase:Ml,sentenceCase:zl,titleCase:Vl},Ur={},ql={get exports(){return Ur},set exports(n){Ur=n}};ql.exports=function(n){return wo(Jl(n),n)};Ur.array=wo;function wo(n,e){var t=n.length,r=new Array(t),s={},i=t,o=Gl(e),a=Wl(n);for(e.forEach(function(u){if(!a.has(u[0])||!a.has(u[1]))throw new Error("Unknown node. There is an unknown node in the supplied edges.")});i--;)s[i]||c(n[i],i,new Set);return r;function c(u,l,h){if(h.has(u)){var p;try{p=", node was:"+JSON.stringify(u)}catch{p=""}throw new Error("Cyclic dependency"+p)}if(!a.has(u))throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: "+JSON.stringify(u));if(!s[l]){s[l]=!0;var f=o.get(u)||new Set;if(f=Array.from(f),l=f.length){h.add(u);do{var d=f[--l];c(d,a.get(d),h)}while(l);h.delete(u)}r[--t]=u}}}function Jl(n){for(var e=new Set,t=0,r=n.length;t<r;t++){var s=n[t];e.add(s[0]),e.add(s[1])}return Array.from(e)}function Gl(n){for(var e=new Map,t=0,r=n.length;t<r;t++){var s=n[t];e.has(s[0])||e.set(s[0],new Set),e.has(s[1])||e.set(s[1],new Set),e.get(s[0]).add(s[1])}return e}function Wl(n){for(var e=new Map,t=0,r=n.length;t<r;t++)e.set(n[t],t);return e}const Kl=Object.prototype.toString,Xl=Error.prototype.toString,Zl=RegExp.prototype.toString,Yl=typeof Symbol<"u"?Symbol.prototype.toString:()=>"",Ql=/^Symbol\((.*)\)(.*)$/;function eh(n){return n!=+n?"NaN":n===0&&1/n<0?"-0":""+n}function si(n,e=!1){if(n==null||n===!0||n===!1)return""+n;const t=typeof n;if(t==="number")return eh(n);if(t==="string")return e?`"${n}"`:n;if(t==="function")return"[Function "+(n.name||"anonymous")+"]";if(t==="symbol")return Yl.call(n).replace(Ql,"Symbol($1)");const r=Kl.call(n).slice(8,-1);return r==="Date"?isNaN(n.getTime())?""+n:n.toISOString(n):r==="Error"||n instanceof Error?"["+Xl.call(n)+"]":r==="RegExp"?Zl.call(n):null}function yt(n,e){let t=si(n,e);return t!==null?t:JSON.stringify(n,function(r,s){let i=si(this[r],e);return i!==null?i:s},2)}function bo(n){return n==null?[]:[].concat(n)}let th=/\$\{\s*(\w+)\s*\}/g;class ce extends Error{static formatError(e,t){const r=t.label||t.path||"this";return r!==t.path&&(t=Object.assign({},t,{path:r})),typeof e=="string"?e.replace(th,(s,i)=>yt(t[i])):typeof e=="function"?e(t):e}static isError(e){return e&&e.name==="ValidationError"}constructor(e,t,r,s){super(),this.value=void 0,this.path=void 0,this.type=void 0,this.errors=void 0,this.params=void 0,this.inner=void 0,this.name="ValidationError",this.value=t,this.path=r,this.type=s,this.errors=[],this.inner=[],bo(e).forEach(i=>{ce.isError(i)?(this.errors.push(...i.errors),this.inner=this.inner.concat(i.inner.length?i.inner:i)):this.errors.push(i)}),this.message=this.errors.length>1?`${this.errors.length} errors occurred`:this.errors[0],Error.captureStackTrace&&Error.captureStackTrace(this,ce)}}let $e={default:"${path} is invalid",required:"${path} is a required field",defined:"${path} must be defined",notNull:"${path} cannot be null",oneOf:"${path} must be one of the following values: ${values}",notOneOf:"${path} must not be one of the following values: ${values}",notType:({path:n,type:e,value:t,originalValue:r})=>{const s=r!=null&&r!==t?` (cast from the value \`${yt(r,!0)}\`).`:".";return e!=="mixed"?`${n} must be a \`${e}\` type, but the final value was: \`${yt(t,!0)}\``+s:`${n} must match the configured type. The validated value was: \`${yt(t,!0)}\``+s}},me={length:"${path} must be exactly ${length} characters",min:"${path} must be at least ${min} characters",max:"${path} must be at most ${max} characters",matches:'${path} must match the following: "${regex}"',email:"${path} must be a valid email",url:"${path} must be a valid URL",uuid:"${path} must be a valid UUID",trim:"${path} must be a trimmed string",lowercase:"${path} must be a lowercase string",uppercase:"${path} must be a upper case string"},We={min:"${path} must be greater than or equal to ${min}",max:"${path} must be less than or equal to ${max}",lessThan:"${path} must be less than ${less}",moreThan:"${path} must be greater than ${more}",positive:"${path} must be a positive number",negative:"${path} must be a negative number",integer:"${path} must be an integer"},Bn={min:"${path} field must be later than ${min}",max:"${path} field must be at earlier than ${max}"},Hn={isValue:"${path} field must be ${value}"},Mn={noUnknown:"${path} field has unspecified keys: ${unknown}"},Nr={min:"${path} field must have at least ${min} items",max:"${path} field must have less than or equal to ${max} items",length:"${path} must have ${length} items"};Object.assign(Object.create(null),{mixed:$e,string:me,number:We,date:Bn,object:Mn,array:Nr,boolean:Hn});const sn=n=>n&&n.__isYupSchema__;class Lr{static fromOptions(e,t){if(!t.then&&!t.otherwise)throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");let{is:r,then:s,otherwise:i}=t,o=typeof r=="function"?r:(...a)=>a.every(c=>c===r);return new Lr(e,(a,c)=>{var u;let l=o(...a)?s:i;return(u=l==null?void 0:l(c))!=null?u:c})}constructor(e,t){this.fn=void 0,this.refs=e,this.refs=e,this.fn=t}resolve(e,t){let r=this.refs.map(i=>i.getValue(t==null?void 0:t.value,t==null?void 0:t.parent,t==null?void 0:t.context)),s=this.fn(r,e,t);if(s===void 0||s===e)return e;if(!sn(s))throw new TypeError("conditions must return a schema object");return s.resolve(t)}}const _r={context:"$",value:"."};class xt{constructor(e,t={}){if(this.key=void 0,this.isContext=void 0,this.isValue=void 0,this.isSibling=void 0,this.path=void 0,this.getter=void 0,this.map=void 0,typeof e!="string")throw new TypeError("ref must be a string, got: "+e);if(this.key=e.trim(),e==="")throw new TypeError("ref must be a non-empty string");this.isContext=this.key[0]===_r.context,this.isValue=this.key[0]===_r.value,this.isSibling=!this.isContext&&!this.isValue;let r=this.isContext?_r.context:this.isValue?_r.value:"";this.path=this.key.slice(r.length),this.getter=this.path&&pt.getter(this.path,!0),this.map=t.map}getValue(e,t,r){let s=this.isContext?r:this.isValue?e:t;return this.getter&&(s=this.getter(s||{})),this.map&&(s=this.map(s)),s}cast(e,t){return this.getValue(e,t==null?void 0:t.parent,t==null?void 0:t.context)}resolve(){return this}describe(){return{type:"ref",key:this.key}}toString(){return`Ref(${this.key})`}static isRef(e){return e&&e.__isYupRef}}xt.prototype.__isYupRef=!0;const pe=n=>n==null;function At(n){function e({value:t,path:r="",options:s,originalValue:i,schema:o},a,c){const{name:u,test:l,params:h,message:p,skipAbsent:f}=n;let{parent:d,context:w,abortEarly:b=o.spec.abortEarly}=s;function O(H){return xt.isRef(H)?H.getValue(t,d,w):H}function P(H={}){const J=Object.assign({value:t,originalValue:i,label:o.spec.label,path:H.path||r,spec:o.spec},h,H.params);for(const Tt of Object.keys(J))J[Tt]=O(J[Tt]);const wr=new ce(ce.formatError(H.message||p,J),t,J.path,H.type||u);return wr.params=J,wr}const M=b?a:c;let U={path:r,parent:d,type:u,from:s.from,createError:P,resolve:O,options:s,originalValue:i,schema:o};const Ee=H=>{ce.isError(H)?M(H):H?c(null):M(P())},qt=H=>{ce.isError(H)?M(H):a(H)},mr=f&&pe(t);if(!s.sync){try{Promise.resolve(mr?!0:l.call(U,t,U)).then(Ee,qt)}catch(H){qt(H)}return}let ye;try{var gr;if(ye=mr?!0:l.call(U,t,U),typeof((gr=ye)==null?void 0:gr.then)=="function")throw new Error(`Validation test of type: "${U.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`)}catch(H){qt(H);return}Ee(ye)}return e.OPTIONS=n,e}function rh(n,e,t,r=t){let s,i,o;return e?(pt.forEach(e,(a,c,u)=>{let l=c?a.slice(1,a.length-1):a;n=n.resolve({context:r,parent:s,value:t});let h=n.type==="tuple",p=u?parseInt(l,10):0;if(n.innerType||h){if(h&&!u)throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${o}" must contain an index to the tuple element, e.g. "${o}[0]"`);if(t&&p>=t.length)throw new Error(`Yup.reach cannot resolve an array item at index: ${a}, in the path: ${e}. because there is no value at that index. `);s=t,t=t&&t[p],n=h?n.spec.types[p]:n.innerType}if(!u){if(!n.fields||!n.fields[l])throw new Error(`The schema does not contain the path: ${e}. (failed at: ${o} which is a type: "${n.type}")`);s=t,t=t&&t[l],n=n.fields[l]}i=l,o=c?"["+a+"]":"."+a}),{schema:n,parent:s,parentPath:i}):{parent:s,parentPath:e,schema:n}}class jr extends Set{describe(){const e=[];for(const t of this.values())e.push(xt.isRef(t)?t.describe():t);return e}resolveAll(e){let t=[];for(const r of this.values())t.push(e(r));return t}clone(){return new jr(this.values())}merge(e,t){const r=this.clone();return e.forEach(s=>r.add(s)),t.forEach(s=>r.delete(s)),r}}function $t(n,e=new Map){if(sn(n)||!n||typeof n!="object")return n;if(e.has(n))return e.get(n);let t;if(n instanceof Date)t=new Date(n.getTime()),e.set(n,t);else if(n instanceof RegExp)t=new RegExp(n),e.set(n,t);else if(Array.isArray(n)){t=new Array(n.length),e.set(n,t);for(let r=0;r<n.length;r++)t[r]=$t(n[r],e)}else if(n instanceof Map){t=new Map,e.set(n,t);for(const[r,s]of n.entries())t.set(r,$t(s,e))}else if(n instanceof Set){t=new Set,e.set(n,t);for(const r of n)t.add($t(r,e))}else if(n instanceof Object){t={},e.set(n,t);for(const[r,s]of Object.entries(n))t[r]=$t(s,e)}else throw Error(`Unable to clone ${n}`);return t}class se{constructor(e){this.type=void 0,this.deps=[],this.tests=void 0,this.transforms=void 0,this.conditions=[],this._mutate=void 0,this.internalTests={},this._whitelist=new jr,this._blacklist=new jr,this.exclusiveTests=Object.create(null),this._typeCheck=void 0,this.spec=void 0,this.tests=[],this.transforms=[],this.withMutation(()=>{this.typeError($e.notType)}),this.type=e.type,this._typeCheck=e.check,this.spec=Object.assign({strip:!1,strict:!1,abortEarly:!0,recursive:!0,nullable:!1,optional:!0,coerce:!0},e==null?void 0:e.spec),this.withMutation(t=>{t.nonNullable()})}get _type(){return this.type}clone(e){if(this._mutate)return e&&Object.assign(this.spec,e),this;const t=Object.create(Object.getPrototypeOf(this));return t.type=this.type,t._typeCheck=this._typeCheck,t._whitelist=this._whitelist.clone(),t._blacklist=this._blacklist.clone(),t.internalTests=Object.assign({},this.internalTests),t.exclusiveTests=Object.assign({},this.exclusiveTests),t.deps=[...this.deps],t.conditions=[...this.conditions],t.tests=[...this.tests],t.transforms=[...this.transforms],t.spec=$t(Object.assign({},this.spec,e)),t}label(e){let t=this.clone();return t.spec.label=e,t}meta(...e){if(e.length===0)return this.spec.meta;let t=this.clone();return t.spec.meta=Object.assign(t.spec.meta||{},e[0]),t}withMutation(e){let t=this._mutate;this._mutate=!0;let r=e(this);return this._mutate=t,r}concat(e){if(!e||e===this)return this;if(e.type!==this.type&&this.type!=="mixed")throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${e.type}`);let t=this,r=e.clone();const s=Object.assign({},t.spec,r.spec);return r.spec=s,r.internalTests=Object.assign({},t.internalTests,r.internalTests),r._whitelist=t._whitelist.merge(e._whitelist,e._blacklist),r._blacklist=t._blacklist.merge(e._blacklist,e._whitelist),r.tests=t.tests,r.exclusiveTests=t.exclusiveTests,r.withMutation(i=>{e.tests.forEach(o=>{i.test(o.OPTIONS)})}),r.transforms=[...t.transforms,...r.transforms],r}isType(e){return e==null?!!(this.spec.nullable&&e===null||this.spec.optional&&e===void 0):this._typeCheck(e)}resolve(e){let t=this;if(t.conditions.length){let r=t.conditions;t=t.clone(),t.conditions=[],t=r.reduce((s,i)=>i.resolve(s,e),t),t=t.resolve(e)}return t}resolveOptions(e){var t,r,s;return Object.assign({},e,{from:e.from||[],strict:(t=e.strict)!=null?t:this.spec.strict,abortEarly:(r=e.abortEarly)!=null?r:this.spec.abortEarly,recursive:(s=e.recursive)!=null?s:this.spec.recursive})}cast(e,t={}){let r=this.resolve(Object.assign({value:e},t)),s=t.assert==="ignore-optionality",i=r._cast(e,t);if(t.assert!==!1&&!r.isType(i)){if(s&&pe(i))return i;let o=yt(e),a=yt(i);throw new TypeError(`The value of ${t.path||"field"} could not be cast to a value that satisfies the schema type: "${r.type}".
1
+ "use strict";var da=Object.defineProperty;var pa=(n,e,t)=>e in n?da(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var m=(n,e,t)=>(pa(n,typeof e!="symbol"?e+"":e,t),t),yn=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var v=(n,e,t)=>(yn(n,e,"read from private field"),t?t.call(n):e.get(n)),L=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},F=(n,e,t,r)=>(yn(n,e,"write to private field"),r?r.call(n,t):e.set(n,t),t),Ds=(n,e,t,r)=>({set _(s){F(n,e,s,t)},get _(){return v(n,e,r)}}),z=(n,e,t)=>(yn(n,e,"access private method"),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function ya(n,e){for(var t=0;t<e.length;t++){const r=e[t];if(typeof r!="string"&&!Array.isArray(r)){for(const s in r)if(s!=="default"&&!(s in n)){const i=Object.getOwnPropertyDescriptor(r,s);i&&Object.defineProperty(n,s,i.get?i:{enumerable:!0,get:()=>r[s]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}var ma=globalThis&&globalThis.__awaiter||function(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(l){try{u(r.next(l))}catch(h){o(h)}}function c(l){try{u(r.throw(l))}catch(h){o(h)}}function u(l){l.done?i(l.value):s(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})};const ga=n=>{let e;return n?e=n:typeof fetch>"u"?e=(...t)=>ma(void 0,void 0,void 0,function*(){return yield(yield Promise.resolve().then(()=>Wr)).fetch(...t)}):e=fetch,(...t)=>e(...t)};class is extends Error{constructor(e,t="FunctionsError",r){super(e),super.name=t,this.context=r}}class wa extends is{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class ba extends is{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class va extends is{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}var _a=globalThis&&globalThis.__awaiter||function(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(l){try{u(r.next(l))}catch(h){o(h)}}function c(l){try{u(r.throw(l))}catch(h){o(h)}}function u(l){l.done?i(l.value):s(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})};class Ea{constructor(e,{headers:t={},customFetch:r}={}){this.url=e,this.headers=t,this.fetch=ga(r)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e,t={}){var r;return _a(this,void 0,void 0,function*(){try{const{headers:s,method:i,body:o}=t;let a={},c;o&&(s&&!Object.prototype.hasOwnProperty.call(s,"Content-Type")||!s)&&(typeof Blob<"u"&&o instanceof Blob||o instanceof ArrayBuffer?(a["Content-Type"]="application/octet-stream",c=o):typeof o=="string"?(a["Content-Type"]="text/plain",c=o):typeof FormData<"u"&&o instanceof FormData?c=o:(a["Content-Type"]="application/json",c=JSON.stringify(o)));const u=yield this.fetch(`${this.url}/${e}`,{method:i||"POST",headers:Object.assign(Object.assign(Object.assign({},a),this.headers),s),body:c}).catch(f=>{throw new wa(f)}),l=u.headers.get("x-relay-error");if(l&&l==="true")throw new ba(u);if(!u.ok)throw new va(u);let h=((r=u.headers.get("Content-Type"))!==null&&r!==void 0?r:"text/plain").split(";")[0].trim(),p;return h==="application/json"?p=yield u.json():h==="application/octet-stream"?p=yield u.blob():h==="multipart/form-data"?p=yield u.formData():p=yield u.text(),{data:p,error:null}}catch(s){return{data:null,error:s}}})}}var xa=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ta(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var Mt={},Oa={get exports(){return Mt},set exports(n){Mt=n}};(function(n,e){var t=typeof self<"u"?self:xa,r=function(){function i(){this.fetch=!1,this.DOMException=t.DOMException}return i.prototype=t,new i}();(function(i){(function(o){var a={searchParams:"URLSearchParams"in i,iterable:"Symbol"in i&&"iterator"in Symbol,blob:"FileReader"in i&&"Blob"in i&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in i,arrayBuffer:"ArrayBuffer"in i};function c(y){return y&&DataView.prototype.isPrototypeOf(y)}if(a.arrayBuffer)var u=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],l=ArrayBuffer.isView||function(y){return y&&u.indexOf(Object.prototype.toString.call(y))>-1};function h(y){if(typeof y!="string"&&(y=String(y)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(y))throw new TypeError("Invalid character in header field name");return y.toLowerCase()}function p(y){return typeof y!="string"&&(y=String(y)),y}function f(y){var _={next:function(){var A=y.shift();return{done:A===void 0,value:A}}};return a.iterable&&(_[Symbol.iterator]=function(){return _}),_}function d(y){this.map={},y instanceof d?y.forEach(function(_,A){this.append(A,_)},this):Array.isArray(y)?y.forEach(function(_){this.append(_[0],_[1])},this):y&&Object.getOwnPropertyNames(y).forEach(function(_){this.append(_,y[_])},this)}d.prototype.append=function(y,_){y=h(y),_=p(_);var A=this.map[y];this.map[y]=A?A+", "+_:_},d.prototype.delete=function(y){delete this.map[h(y)]},d.prototype.get=function(y){return y=h(y),this.has(y)?this.map[y]:null},d.prototype.has=function(y){return this.map.hasOwnProperty(h(y))},d.prototype.set=function(y,_){this.map[h(y)]=p(_)},d.prototype.forEach=function(y,_){for(var A in this.map)this.map.hasOwnProperty(A)&&y.call(_,this.map[A],A,this)},d.prototype.keys=function(){var y=[];return this.forEach(function(_,A){y.push(A)}),f(y)},d.prototype.values=function(){var y=[];return this.forEach(function(_){y.push(_)}),f(y)},d.prototype.entries=function(){var y=[];return this.forEach(function(_,A){y.push([A,_])}),f(y)},a.iterable&&(d.prototype[Symbol.iterator]=d.prototype.entries);function w(y){if(y.bodyUsed)return Promise.reject(new TypeError("Already read"));y.bodyUsed=!0}function b(y){return new Promise(function(_,A){y.onload=function(){_(y.result)},y.onerror=function(){A(y.error)}})}function T(y){var _=new FileReader,A=b(_);return _.readAsArrayBuffer(y),A}function P(y){var _=new FileReader,A=b(_);return _.readAsText(y),A}function M(y){for(var _=new Uint8Array(y),A=new Array(_.length),Z=0;Z<_.length;Z++)A[Z]=String.fromCharCode(_[Z]);return A.join("")}function U(y){if(y.slice)return y.slice(0);var _=new Uint8Array(y.byteLength);return _.set(new Uint8Array(y)),_.buffer}function Ee(){return this.bodyUsed=!1,this._initBody=function(y){this._bodyInit=y,y?typeof y=="string"?this._bodyText=y:a.blob&&Blob.prototype.isPrototypeOf(y)?this._bodyBlob=y:a.formData&&FormData.prototype.isPrototypeOf(y)?this._bodyFormData=y:a.searchParams&&URLSearchParams.prototype.isPrototypeOf(y)?this._bodyText=y.toString():a.arrayBuffer&&a.blob&&c(y)?(this._bodyArrayBuffer=U(y.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):a.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(y)||l(y))?this._bodyArrayBuffer=U(y):this._bodyText=y=Object.prototype.toString.call(y):this._bodyText="",this.headers.get("content-type")||(typeof y=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):a.searchParams&&URLSearchParams.prototype.isPrototypeOf(y)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},a.blob&&(this.blob=function(){var y=w(this);if(y)return y;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?w(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(T)}),this.text=function(){var y=w(this);if(y)return y;if(this._bodyBlob)return P(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(M(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},a.formData&&(this.formData=function(){return this.text().then(wr)}),this.json=function(){return this.text().then(JSON.parse)},this}var Jt=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function gr(y){var _=y.toUpperCase();return Jt.indexOf(_)>-1?_:y}function ye(y,_){_=_||{};var A=_.body;if(y instanceof ye){if(y.bodyUsed)throw new TypeError("Already read");this.url=y.url,this.credentials=y.credentials,_.headers||(this.headers=new d(y.headers)),this.method=y.method,this.mode=y.mode,this.signal=y.signal,!A&&y._bodyInit!=null&&(A=y._bodyInit,y.bodyUsed=!0)}else this.url=String(y);if(this.credentials=_.credentials||this.credentials||"same-origin",(_.headers||!this.headers)&&(this.headers=new d(_.headers)),this.method=gr(_.method||this.method||"GET"),this.mode=_.mode||this.mode||null,this.signal=_.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&A)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(A)}ye.prototype.clone=function(){return new ye(this,{body:this._bodyInit})};function wr(y){var _=new FormData;return y.trim().split("&").forEach(function(A){if(A){var Z=A.split("="),G=Z.shift().replace(/\+/g," "),I=Z.join("=").replace(/\+/g," ");_.append(decodeURIComponent(G),decodeURIComponent(I))}}),_}function H(y){var _=new d,A=y.replace(/\r?\n[\t ]+/g," ");return A.split(/\r?\n/).forEach(function(Z){var G=Z.split(":"),I=G.shift().trim();if(I){var vr=G.join(":").trim();_.append(I,vr)}}),_}Ee.call(ye.prototype);function J(y,_){_||(_={}),this.type="default",this.status=_.status===void 0?200:_.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in _?_.statusText:"OK",this.headers=new d(_.headers),this.url=_.url||"",this._initBody(y)}Ee.call(J.prototype),J.prototype.clone=function(){return new J(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})},J.error=function(){var y=new J(null,{status:0,statusText:""});return y.type="error",y};var br=[301,302,303,307,308];J.redirect=function(y,_){if(br.indexOf(_)===-1)throw new RangeError("Invalid status code");return new J(null,{status:_,headers:{location:y}})},o.DOMException=i.DOMException;try{new o.DOMException}catch{o.DOMException=function(_,A){this.message=_,this.name=A;var Z=Error(_);this.stack=Z.stack},o.DOMException.prototype=Object.create(Error.prototype),o.DOMException.prototype.constructor=o.DOMException}function kt(y,_){return new Promise(function(A,Z){var G=new ye(y,_);if(G.signal&&G.signal.aborted)return Z(new o.DOMException("Aborted","AbortError"));var I=new XMLHttpRequest;function vr(){I.abort()}I.onload=function(){var Gt={status:I.status,statusText:I.statusText,headers:H(I.getAllResponseHeaders()||"")};Gt.url="responseURL"in I?I.responseURL:Gt.headers.get("X-Request-URL");var pn="response"in I?I.response:I.responseText;A(new J(pn,Gt))},I.onerror=function(){Z(new TypeError("Network request failed"))},I.ontimeout=function(){Z(new TypeError("Network request failed"))},I.onabort=function(){Z(new o.DOMException("Aborted","AbortError"))},I.open(G.method,G.url,!0),G.credentials==="include"?I.withCredentials=!0:G.credentials==="omit"&&(I.withCredentials=!1),"responseType"in I&&a.blob&&(I.responseType="blob"),G.headers.forEach(function(Gt,pn){I.setRequestHeader(pn,Gt)}),G.signal&&(G.signal.addEventListener("abort",vr),I.onreadystatechange=function(){I.readyState===4&&G.signal.removeEventListener("abort",vr)}),I.send(typeof G._bodyInit>"u"?null:G._bodyInit)})}return kt.polyfill=!0,i.fetch||(i.fetch=kt,i.Headers=d,i.Request=ye,i.Response=J),o.Headers=d,o.Request=ye,o.Response=J,o.fetch=kt,Object.defineProperty(o,"__esModule",{value:!0}),o})({})})(r),r.fetch.ponyfill=!0,delete r.fetch.polyfill;var s=r;e=s.fetch,e.default=s.fetch,e.fetch=s.fetch,e.Headers=s.Headers,e.Request=s.Request,e.Response=s.Response,n.exports=e})(Oa,Mt);const os=Ta(Mt),Wr=ya({__proto__:null,default:os},[Mt]);class ka{constructor(e){this.shouldThrowOnError=!1,this.method=e.method,this.url=e.url,this.headers=e.headers,this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=e.shouldThrowOnError,this.signal=e.signal,this.allowEmpty=e.allowEmpty,e.fetch?this.fetch=e.fetch:typeof fetch>"u"?this.fetch=os:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}then(e,t){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers["Accept-Profile"]=this.schema:this.headers["Content-Profile"]=this.schema),this.method!=="GET"&&this.method!=="HEAD"&&(this.headers["Content-Type"]="application/json");const r=this.fetch;let s=r(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async i=>{var o,a,c;let u=null,l=null,h=null,p=i.status,f=i.statusText;if(i.ok){if(this.method!=="HEAD"){const T=await i.text();T===""||(this.headers.Accept==="text/csv"||this.headers.Accept&&this.headers.Accept.includes("application/vnd.pgrst.plan+text")?l=T:l=JSON.parse(T))}const w=(o=this.headers.Prefer)===null||o===void 0?void 0:o.match(/count=(exact|planned|estimated)/),b=(a=i.headers.get("content-range"))===null||a===void 0?void 0:a.split("/");w&&b&&b.length>1&&(h=parseInt(b[1]))}else{const w=await i.text();try{u=JSON.parse(w),Array.isArray(u)&&i.status===404&&(l=[],u=null,p=200,f="OK")}catch{i.status===404&&w===""?(p=204,f="No Content"):u={message:w}}if(u&&this.allowEmpty&&(!((c=u==null?void 0:u.details)===null||c===void 0)&&c.includes("Results contain 0 rows"))&&(u=null,p=200,f="OK"),u&&this.shouldThrowOnError)throw u}return{error:u,data:l,count:h,status:p,statusText:f}});return this.shouldThrowOnError||(s=s.catch(i=>({error:{message:`FetchError: ${i.message}`,details:"",hint:"",code:i.code||""},data:null,count:null,status:0,statusText:""}))),s.then(e,t)}}class Aa extends ka{select(e){let t=!1;const r=(e??"*").split("").map(s=>/\s/.test(s)&&!t?"":(s==='"'&&(t=!t),s)).join("");return this.url.searchParams.set("select",r),this.headers.Prefer&&(this.headers.Prefer+=","),this.headers.Prefer+="return=representation",this}order(e,{ascending:t=!0,nullsFirst:r,foreignTable:s}={}){const i=s?`${s}.order`:"order",o=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${o?`${o},`:""}${e}.${t?"asc":"desc"}${r===void 0?"":r?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t}={}){const r=typeof t>"u"?"limit":`${t}.limit`;return this.url.searchParams.set(r,`${e}`),this}range(e,t,{foreignTable:r}={}){const s=typeof r>"u"?"offset":`${r}.offset`,i=typeof r>"u"?"limit":`${r}.limit`;return this.url.searchParams.set(s,`${e}`),this.url.searchParams.set(i,`${t-e+1}`),this}abortSignal(e){return this.signal=e,this}single(){return this.headers.Accept="application/vnd.pgrst.object+json",this}maybeSingle(){return this.headers.Accept="application/vnd.pgrst.object+json",this.allowEmpty=!0,this}csv(){return this.headers.Accept="text/csv",this}geojson(){return this.headers.Accept="application/geo+json",this}explain({analyze:e=!1,verbose:t=!1,settings:r=!1,buffers:s=!1,wal:i=!1,format:o="text"}={}){const a=[e?"analyze":null,t?"verbose":null,r?"settings":null,s?"buffers":null,i?"wal":null].filter(Boolean).join("|"),c=this.headers.Accept;return this.headers.Accept=`application/vnd.pgrst.plan+${o}; for="${c}"; options=${a};`,o==="json"?this:this}rollback(){var e;return((e=this.headers.Prefer)!==null&&e!==void 0?e:"").trim().length>0?this.headers.Prefer+=",tx=rollback":this.headers.Prefer="tx=rollback",this}returns(){return this}}class Nt extends Aa{eq(e,t){return this.url.searchParams.append(e,`eq.${t}`),this}neq(e,t){return this.url.searchParams.append(e,`neq.${t}`),this}gt(e,t){return this.url.searchParams.append(e,`gt.${t}`),this}gte(e,t){return this.url.searchParams.append(e,`gte.${t}`),this}lt(e,t){return this.url.searchParams.append(e,`lt.${t}`),this}lte(e,t){return this.url.searchParams.append(e,`lte.${t}`),this}like(e,t){return this.url.searchParams.append(e,`like.${t}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}in(e,t){const r=t.map(s=>typeof s=="string"&&new RegExp("[,()]").test(s)?`"${s}"`:`${s}`).join(",");return this.url.searchParams.append(e,`in.(${r})`),this}contains(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cs.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cs.{${t.join(",")}}`):this.url.searchParams.append(e,`cs.${JSON.stringify(t)}`),this}containedBy(e,t){return typeof t=="string"?this.url.searchParams.append(e,`cd.${t}`):Array.isArray(t)?this.url.searchParams.append(e,`cd.{${t.join(",")}}`):this.url.searchParams.append(e,`cd.${JSON.stringify(t)}`),this}rangeGt(e,t){return this.url.searchParams.append(e,`sr.${t}`),this}rangeGte(e,t){return this.url.searchParams.append(e,`nxl.${t}`),this}rangeLt(e,t){return this.url.searchParams.append(e,`sl.${t}`),this}rangeLte(e,t){return this.url.searchParams.append(e,`nxr.${t}`),this}rangeAdjacent(e,t){return this.url.searchParams.append(e,`adj.${t}`),this}overlaps(e,t){return typeof t=="string"?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:r,type:s}={}){let i="";s==="plain"?i="pl":s==="phrase"?i="ph":s==="websearch"&&(i="w");const o=r===void 0?"":`(${r})`;return this.url.searchParams.append(e,`${i}fts${o}.${t}`),this}match(e){return Object.entries(e).forEach(([t,r])=>{this.url.searchParams.append(t,`eq.${r}`)}),this}not(e,t,r){return this.url.searchParams.append(e,`not.${t}.${r}`),this}or(e,{foreignTable:t}={}){const r=t?`${t}.or`:"or";return this.url.searchParams.append(r,`(${e})`),this}filter(e,t,r){return this.url.searchParams.append(e,`${t}.${r}`),this}}class Sa{constructor(e,{headers:t={},schema:r,fetch:s}){this.url=e,this.headers=t,this.schema=r,this.fetch=s}select(e,{head:t=!1,count:r}={}){const s=t?"HEAD":"GET";let i=!1;const o=(e??"*").split("").map(a=>/\s/.test(a)&&!i?"":(a==='"'&&(i=!i),a)).join("");return this.url.searchParams.set("select",o),r&&(this.headers.Prefer=`count=${r}`),new Nt({method:s,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}insert(e,{count:t}={}){const r="POST",s=[],i=e;if(t&&s.push(`count=${t}`),this.headers.Prefer&&s.unshift(this.headers.Prefer),this.headers.Prefer=s.join(","),Array.isArray(e)){const o=e.reduce((a,c)=>a.concat(Object.keys(c)),[]);if(o.length>0){const a=[...new Set(o)].map(c=>`"${c}"`);this.url.searchParams.set("columns",a.join(","))}}return new Nt({method:r,url:this.url,headers:this.headers,schema:this.schema,body:i,fetch:this.fetch,allowEmpty:!1})}upsert(e,{onConflict:t,ignoreDuplicates:r=!1,count:s}={}){const i="POST",o=[`resolution=${r?"ignore":"merge"}-duplicates`];t!==void 0&&this.url.searchParams.set("on_conflict",t);const a=e;return s&&o.push(`count=${s}`),this.headers.Prefer&&o.unshift(this.headers.Prefer),this.headers.Prefer=o.join(","),new Nt({method:i,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:this.fetch,allowEmpty:!1})}update(e,{count:t}={}){const r="PATCH",s=[],i=e;return t&&s.push(`count=${t}`),this.headers.Prefer&&s.unshift(this.headers.Prefer),this.headers.Prefer=s.join(","),new Nt({method:r,url:this.url,headers:this.headers,schema:this.schema,body:i,fetch:this.fetch,allowEmpty:!1})}delete({count:e}={}){const t="DELETE",r=[];return e&&r.push(`count=${e}`),this.headers.Prefer&&r.unshift(this.headers.Prefer),this.headers.Prefer=r.join(","),new Nt({method:t,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch,allowEmpty:!1})}}const Ra="1.4.1",Pa={"X-Client-Info":`postgrest-js/${Ra}`};class Na{constructor(e,{headers:t={},schema:r,fetch:s}={}){this.url=e,this.headers=Object.assign(Object.assign({},Pa),t),this.schema=r,this.fetch=s}from(e){const t=new URL(`${this.url}/${e}`);return new Sa(t,{headers:Object.assign({},this.headers),schema:this.schema,fetch:this.fetch})}rpc(e,t={},{head:r=!1,count:s}={}){let i;const o=new URL(`${this.url}/rpc/${e}`);let a;r?(i="HEAD",Object.entries(t).forEach(([u,l])=>{o.searchParams.append(u,`${l}`)})):(i="POST",a=t);const c=Object.assign({},this.headers);return s&&(c.Prefer=`count=${s}`),new Nt({method:i,url:o,headers:c,schema:this.schema,body:a,fetch:this.fetch,allowEmpty:!1})}}var mn,Us;function $a(){if(Us)return mn;Us=1;var n=function(){if(typeof self=="object"&&self)return self;if(typeof window=="object"&&window)return window;throw new Error("Unable to resolve global `this`")};return mn=function(){if(this)return this;if(typeof globalThis=="object"&&globalThis)return globalThis;try{Object.defineProperty(Object.prototype,"__global__",{get:function(){return this},configurable:!0})}catch{return n()}try{return __global__||n()}finally{delete Object.prototype.__global__}}(),mn}const Ca="websocket",Fa="Websocket Client & Server Library implementing the WebSocket protocol as specified in RFC 6455.",Ia=["websocket","websockets","socket","networking","comet","push","RFC-6455","realtime","server","client"],Da="Brian McKelvey <theturtle32@gmail.com> (https://github.com/theturtle32)",Ua=["Iñaki Baz Castillo <ibc@aliax.net> (http://dev.sipdoc.net)"],La="1.0.34",ja={type:"git",url:"https://github.com/theturtle32/WebSocket-Node.git"},Ba="https://github.com/theturtle32/WebSocket-Node",Ha={node:">=4.0.0"},Ma={bufferutil:"^4.0.1",debug:"^2.2.0","es5-ext":"^0.10.50","typedarray-to-buffer":"^3.1.5","utf-8-validate":"^5.0.2",yaeti:"^0.0.6"},za={"buffer-equal":"^1.0.0",gulp:"^4.0.2","gulp-jshint":"^2.0.4","jshint-stylish":"^2.2.1",jshint:"^2.0.0",tape:"^4.9.1"},Va={verbose:!1},qa={test:"tape test/unit/*.js",gulp:"gulp"},Ja="index",Ga={lib:"./lib"},Wa="lib/browser.js",Ka="Apache-2.0",Xa={name:Ca,description:Fa,keywords:Ia,author:Da,contributors:Ua,version:La,repository:ja,homepage:Ba,engines:Ha,dependencies:Ma,devDependencies:za,config:Va,scripts:qa,main:Ja,directories:Ga,browser:Wa,license:Ka};var Za=Xa.version,at;if(typeof globalThis=="object")at=globalThis;else try{at=$a()}catch{}finally{if(!at&&typeof window<"u"&&(at=window),!at)throw new Error("Could not determine global this")}var rr=at.WebSocket||at.MozWebSocket,Ya=Za;function ji(n,e){var t;return e?t=new rr(n,e):t=new rr(n),t}rr&&["CONNECTING","OPEN","CLOSING","CLOSED"].forEach(function(n){Object.defineProperty(ji,n,{get:function(){return rr[n]}})});var Qa={w3cwebsocket:rr?ji:null,version:Ya};const ec="2.6.0",tc={"X-Client-Info":`realtime-js/${ec}`},rc="1.0.0",Bi=1e4,nc=1e3;var Qt;(function(n){n[n.connecting=0]="connecting",n[n.open=1]="open",n[n.closing=2]="closing",n[n.closed=3]="closed"})(Qt||(Qt={}));var ae;(function(n){n.closed="closed",n.errored="errored",n.joined="joined",n.joining="joining",n.leaving="leaving"})(ae||(ae={}));var we;(function(n){n.close="phx_close",n.error="phx_error",n.join="phx_join",n.reply="phx_reply",n.leave="phx_leave",n.access_token="access_token"})(we||(we={}));var Fn;(function(n){n.websocket="websocket"})(Fn||(Fn={}));var ct;(function(n){n.Connecting="connecting",n.Open="open",n.Closing="closing",n.Closed="closed"})(ct||(ct={}));class Hi{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=void 0,this.tries=0,this.callback=e,this.timerCalc=t}reset(){this.tries=0,clearTimeout(this.timer)}scheduleTimeout(){clearTimeout(this.timer),this.timer=setTimeout(()=>{this.tries=this.tries+1,this.callback()},this.timerCalc(this.tries+1))}}class sc{constructor(){this.HEADER_LENGTH=1}decode(e,t){return e.constructor===ArrayBuffer?t(this._binaryDecode(e)):t(typeof e=="string"?JSON.parse(e):{})}_binaryDecode(e){const t=new DataView(e),r=new TextDecoder;return this._decodeBroadcast(e,t,r)}_decodeBroadcast(e,t,r){const s=t.getUint8(1),i=t.getUint8(2);let o=this.HEADER_LENGTH+2;const a=r.decode(e.slice(o,o+s));o=o+s;const c=r.decode(e.slice(o,o+i));o=o+i;const u=JSON.parse(r.decode(e.slice(o,e.byteLength)));return{ref:null,topic:a,event:c,payload:u}}}class gn{constructor(e,t,r={},s=Bi){this.channel=e,this.event=t,this.payload=r,this.timeout=s,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null,this.rateLimited=!1}resend(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}send(){if(this._hasReceived("timeout"))return;this.startTimeout(),this.sent=!0,this.channel.socket.push({topic:this.channel.topic,event:this.event,payload:this.payload,ref:this.ref,join_ref:this.channel._joinRef()})==="rate limited"&&(this.rateLimited=!0)}updatePayload(e){this.payload=Object.assign(Object.assign({},this.payload),e)}receive(e,t){var r;return this._hasReceived(e)&&t((r=this.receivedResp)===null||r===void 0?void 0:r.response),this.recHooks.push({status:e,callback:t}),this}startTimeout(){if(this.timeoutTimer)return;this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref);const e=t=>{this._cancelRefEvent(),this._cancelTimeout(),this.receivedResp=t,this._matchReceive(t)};this.channel._on(this.refEvent,{},e),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}trigger(e,t){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:t})}destroy(){this._cancelRefEvent(),this._cancelTimeout()}_cancelRefEvent(){this.refEvent&&this.channel._off(this.refEvent,{})}_cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}_matchReceive({status:e,response:t}){this.recHooks.filter(r=>r.status===e).forEach(r=>r.callback(t))}_hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}}var Ls;(function(n){n.SYNC="sync",n.JOIN="join",n.LEAVE="leave"})(Ls||(Ls={}));class er{constructor(e,t){this.channel=e,this.state={},this.pendingDiffs=[],this.joinRef=null,this.caller={onJoin:()=>{},onLeave:()=>{},onSync:()=>{}};const r=(t==null?void 0:t.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(r.state,{},s=>{const{onJoin:i,onLeave:o,onSync:a}=this.caller;this.joinRef=this.channel._joinRef(),this.state=er.syncState(this.state,s,i,o),this.pendingDiffs.forEach(c=>{this.state=er.syncDiff(this.state,c,i,o)}),this.pendingDiffs=[],a()}),this.channel._on(r.diff,{},s=>{const{onJoin:i,onLeave:o,onSync:a}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(s):(this.state=er.syncDiff(this.state,s,i,o),a())}),this.onJoin((s,i,o)=>{this.channel._trigger("presence",{event:"join",key:s,currentPresences:i,newPresences:o})}),this.onLeave((s,i,o)=>{this.channel._trigger("presence",{event:"leave",key:s,currentPresences:i,leftPresences:o})}),this.onSync(()=>{this.channel._trigger("presence",{event:"sync"})})}static syncState(e,t,r,s){const i=this.cloneDeep(e),o=this.transformState(t),a={},c={};return this.map(i,(u,l)=>{o[u]||(c[u]=l)}),this.map(o,(u,l)=>{const h=i[u];if(h){const p=l.map(b=>b.presence_ref),f=h.map(b=>b.presence_ref),d=l.filter(b=>f.indexOf(b.presence_ref)<0),w=h.filter(b=>p.indexOf(b.presence_ref)<0);d.length>0&&(a[u]=d),w.length>0&&(c[u]=w)}else a[u]=l}),this.syncDiff(i,{joins:a,leaves:c},r,s)}static syncDiff(e,t,r,s){const{joins:i,leaves:o}={joins:this.transformState(t.joins),leaves:this.transformState(t.leaves)};return r||(r=()=>{}),s||(s=()=>{}),this.map(i,(a,c)=>{var u;const l=(u=e[a])!==null&&u!==void 0?u:[];if(e[a]=this.cloneDeep(c),l.length>0){const h=e[a].map(f=>f.presence_ref),p=l.filter(f=>h.indexOf(f.presence_ref)<0);e[a].unshift(...p)}r(a,l,c)}),this.map(o,(a,c)=>{let u=e[a];if(!u)return;const l=c.map(h=>h.presence_ref);u=u.filter(h=>l.indexOf(h.presence_ref)<0),e[a]=u,s(a,u,c),u.length===0&&delete e[a]}),e}static map(e,t){return Object.getOwnPropertyNames(e).map(r=>t(r,e[r]))}static transformState(e){return e=this.cloneDeep(e),Object.getOwnPropertyNames(e).reduce((t,r)=>{const s=e[r];return"metas"in s?t[r]=s.metas.map(i=>(i.presence_ref=i.phx_ref,delete i.phx_ref,delete i.phx_ref_prev,i)):t[r]=s,t},{})}static cloneDeep(e){return JSON.parse(JSON.stringify(e))}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}var j;(function(n){n.abstime="abstime",n.bool="bool",n.date="date",n.daterange="daterange",n.float4="float4",n.float8="float8",n.int2="int2",n.int4="int4",n.int4range="int4range",n.int8="int8",n.int8range="int8range",n.json="json",n.jsonb="jsonb",n.money="money",n.numeric="numeric",n.oid="oid",n.reltime="reltime",n.text="text",n.time="time",n.timestamp="timestamp",n.timestamptz="timestamptz",n.timetz="timetz",n.tsrange="tsrange",n.tstzrange="tstzrange"})(j||(j={}));const js=(n,e,t={})=>{var r;const s=(r=t.skipTypes)!==null&&r!==void 0?r:[];return Object.keys(e).reduce((i,o)=>(i[o]=ic(o,n,e,s),i),{})},ic=(n,e,t,r)=>{const s=e.find(a=>a.name===n),i=s==null?void 0:s.type,o=t[n];return i&&!r.includes(i)?Mi(i,o):In(o)},Mi=(n,e)=>{if(n.charAt(0)==="_"){const t=n.slice(1,n.length);return uc(e,t)}switch(n){case j.bool:return oc(e);case j.float4:case j.float8:case j.int2:case j.int4:case j.int8:case j.numeric:case j.oid:return ac(e);case j.json:case j.jsonb:return cc(e);case j.timestamp:return lc(e);case j.abstime:case j.date:case j.daterange:case j.int4range:case j.int8range:case j.money:case j.reltime:case j.text:case j.time:case j.timestamptz:case j.timetz:case j.tsrange:case j.tstzrange:return In(e);default:return In(e)}},In=n=>n,oc=n=>{switch(n){case"t":return!0;case"f":return!1;default:return n}},ac=n=>{if(typeof n=="string"){const e=parseFloat(n);if(!Number.isNaN(e))return e}return n},cc=n=>{if(typeof n=="string")try{return JSON.parse(n)}catch(e){return console.log(`JSON parse error: ${e}`),n}return n},uc=(n,e)=>{if(typeof n!="string")return n;const t=n.length-1,r=n[t];if(n[0]==="{"&&r==="}"){let i;const o=n.slice(1,t);try{i=JSON.parse("["+o+"]")}catch{i=o?o.split(","):[]}return i.map(a=>Mi(e,a))}return n},lc=n=>typeof n=="string"?n.replace(" ","T"):n;var Bs=globalThis&&globalThis.__awaiter||function(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(l){try{u(r.next(l))}catch(h){o(h)}}function c(l){try{u(r.throw(l))}catch(h){o(h)}}function u(l){l.done?i(l.value):s(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})},Hs;(function(n){n.ALL="*",n.INSERT="INSERT",n.UPDATE="UPDATE",n.DELETE="DELETE"})(Hs||(Hs={}));var Ms;(function(n){n.BROADCAST="broadcast",n.PRESENCE="presence",n.POSTGRES_CHANGES="postgres_changes"})(Ms||(Ms={}));var zs;(function(n){n.SUBSCRIBED="SUBSCRIBED",n.TIMED_OUT="TIMED_OUT",n.CLOSED="CLOSED",n.CHANNEL_ERROR="CHANNEL_ERROR"})(zs||(zs={}));class as{constructor(e,t={config:{}},r){this.topic=e,this.params=t,this.socket=r,this.bindings={},this.state=ae.closed,this.joinedOnce=!1,this.pushBuffer=[],this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:""}},t.config),this.timeout=this.socket.timeout,this.joinPush=new gn(this,we.join,this.params,this.timeout),this.rejoinTimer=new Hi(()=>this._rejoinUntilConnected(),this.socket.reconnectAfterMs),this.joinPush.receive("ok",()=>{this.state=ae.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(s=>s.send()),this.pushBuffer=[]}),this._onClose(()=>{this.rejoinTimer.reset(),this.socket.log("channel",`close ${this.topic} ${this._joinRef()}`),this.state=ae.closed,this.socket._remove(this)}),this._onError(s=>{this._isLeaving()||this._isClosed()||(this.socket.log("channel",`error ${this.topic}`,s),this.state=ae.errored,this.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",()=>{this._isJoining()&&(this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),this.state=ae.errored,this.rejoinTimer.scheduleTimeout())}),this._on(we.reply,{},(s,i)=>{this._trigger(this._replyEventName(i),s)}),this.presence=new er(this)}subscribe(e,t=this.timeout){var r,s;if(this.joinedOnce)throw"tried to subscribe multiple times. 'subscribe' can only be called a single time per channel instance";{const{config:{broadcast:i,presence:o}}=this.params;this._onError(u=>e&&e("CHANNEL_ERROR",u)),this._onClose(()=>e&&e("CLOSED"));const a={},c={broadcast:i,presence:o,postgres_changes:(s=(r=this.bindings.postgres_changes)===null||r===void 0?void 0:r.map(u=>u.filter))!==null&&s!==void 0?s:[]};this.socket.accessToken&&(a.access_token=this.socket.accessToken),this.updateJoinPayload(Object.assign({config:c},a)),this.joinedOnce=!0,this._rejoin(t),this.joinPush.receive("ok",({postgres_changes:u})=>{var l;if(this.socket.accessToken&&this.socket.setAuth(this.socket.accessToken),u===void 0){e&&e("SUBSCRIBED");return}else{const h=this.bindings.postgres_changes,p=(l=h==null?void 0:h.length)!==null&&l!==void 0?l:0,f=[];for(let d=0;d<p;d++){const w=h[d],{filter:{event:b,schema:T,table:P,filter:M}}=w,U=u&&u[d];if(U&&U.event===b&&U.schema===T&&U.table===P&&U.filter===M)f.push(Object.assign(Object.assign({},w),{id:U.id}));else{this.unsubscribe(),e&&e("CHANNEL_ERROR",new Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=f,e&&e("SUBSCRIBED");return}}).receive("error",u=>{e&&e("CHANNEL_ERROR",new Error(JSON.stringify(Object.values(u).join(", ")||"error")))}).receive("timeout",()=>{e&&e("TIMED_OUT")})}return this}presenceState(){return this.presence.state}track(e,t={}){return Bs(this,void 0,void 0,function*(){return yield this.send({type:"presence",event:"track",payload:e},t.timeout||this.timeout)})}untrack(e={}){return Bs(this,void 0,void 0,function*(){return yield this.send({type:"presence",event:"untrack"},e)})}on(e,t,r){return this._on(e,t,r)}send(e,t={}){return new Promise(r=>{var s,i,o;const a=this._push(e.type,e,t.timeout||this.timeout);a.rateLimited&&r("rate limited"),e.type==="broadcast"&&!(!((o=(i=(s=this.params)===null||s===void 0?void 0:s.config)===null||i===void 0?void 0:i.broadcast)===null||o===void 0)&&o.ack)&&r("ok"),a.receive("ok",()=>r("ok")),a.receive("timeout",()=>r("timed out"))})}updateJoinPayload(e){this.joinPush.updatePayload(e)}unsubscribe(e=this.timeout){this.state=ae.leaving;const t=()=>{this.socket.log("channel",`leave ${this.topic}`),this._trigger(we.close,"leave",this._joinRef())};return this.rejoinTimer.reset(),this.joinPush.destroy(),new Promise(r=>{const s=new gn(this,we.leave,{},e);s.receive("ok",()=>{t(),r("ok")}).receive("timeout",()=>{t(),r("timed out")}).receive("error",()=>{r("error")}),s.send(),this._canPush()||s.trigger("ok",{})})}_push(e,t,r=this.timeout){if(!this.joinedOnce)throw`tried to push '${e}' to '${this.topic}' before joining. Use channel.subscribe() before pushing events`;let s=new gn(this,e,t,r);return this._canPush()?s.send():(s.startTimeout(),this.pushBuffer.push(s)),s}_onMessage(e,t,r){return t}_isMember(e){return this.topic===e}_joinRef(){return this.joinPush.ref}_trigger(e,t,r){var s,i;const o=e.toLocaleLowerCase(),{close:a,error:c,leave:u,join:l}=we;if(r&&[a,c,u,l].indexOf(o)>=0&&r!==this._joinRef())return;let p=this._onMessage(o,t,r);if(t&&!p)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(o)?(s=this.bindings.postgres_changes)===null||s===void 0||s.filter(f=>{var d,w,b;return((d=f.filter)===null||d===void 0?void 0:d.event)==="*"||((b=(w=f.filter)===null||w===void 0?void 0:w.event)===null||b===void 0?void 0:b.toLocaleLowerCase())===o}).map(f=>f.callback(p,r)):(i=this.bindings[o])===null||i===void 0||i.filter(f=>{var d,w,b,T,P,M;if(["broadcast","presence","postgres_changes"].includes(o))if("id"in f){const U=f.id,Ee=(d=f.filter)===null||d===void 0?void 0:d.event;return U&&((w=t.ids)===null||w===void 0?void 0:w.includes(U))&&(Ee==="*"||(Ee==null?void 0:Ee.toLocaleLowerCase())===((b=t.data)===null||b===void 0?void 0:b.type.toLocaleLowerCase()))}else{const U=(P=(T=f==null?void 0:f.filter)===null||T===void 0?void 0:T.event)===null||P===void 0?void 0:P.toLocaleLowerCase();return U==="*"||U===((M=t==null?void 0:t.event)===null||M===void 0?void 0:M.toLocaleLowerCase())}else return f.type.toLocaleLowerCase()===o}).map(f=>{if(typeof p=="object"&&"ids"in p){const d=p.data,{schema:w,table:b,commit_timestamp:T,type:P,errors:M}=d;p=Object.assign(Object.assign({},{schema:w,table:b,commit_timestamp:T,eventType:P,new:{},old:{},errors:M}),this._getPayloadRecords(d))}f.callback(p,r)})}_isClosed(){return this.state===ae.closed}_isJoined(){return this.state===ae.joined}_isJoining(){return this.state===ae.joining}_isLeaving(){return this.state===ae.leaving}_replyEventName(e){return`chan_reply_${e}`}_on(e,t,r){const s=e.toLocaleLowerCase(),i={type:s,filter:t,callback:r};return this.bindings[s]?this.bindings[s].push(i):this.bindings[s]=[i],this}_off(e,t){const r=e.toLocaleLowerCase();return this.bindings[r]=this.bindings[r].filter(s=>{var i;return!(((i=s.type)===null||i===void 0?void 0:i.toLocaleLowerCase())===r&&as.isEqual(s.filter,t))}),this}static isEqual(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}_rejoinUntilConnected(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}_onClose(e){this._on(we.close,{},e)}_onError(e){this._on(we.error,{},t=>e(t))}_canPush(){return this.socket.isConnected()&&this._isJoined()}_rejoin(e=this.timeout){this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=ae.joining,this.joinPush.resend(e))}_getPayloadRecords(e){const t={new:{},old:{}};return(e.type==="INSERT"||e.type==="UPDATE")&&(t.new=js(e.columns,e.record)),(e.type==="UPDATE"||e.type==="DELETE")&&(t.old=js(e.columns,e.old_record)),t}}var hc=globalThis&&globalThis.__awaiter||function(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(l){try{u(r.next(l))}catch(h){o(h)}}function c(l){try{u(r.throw(l))}catch(h){o(h)}}function u(l){l.done?i(l.value):s(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})};const fc=()=>{};class dc{constructor(e,t){var r;this.accessToken=null,this.channels=[],this.endPoint="",this.headers=tc,this.params={},this.timeout=Bi,this.transport=Qa.w3cwebsocket,this.heartbeatIntervalMs=3e4,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.ref=0,this.logger=fc,this.conn=null,this.sendBuffer=[],this.serializer=new sc,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.eventsPerSecondLimitMs=100,this.inThrottle=!1,this.endPoint=`${e}/${Fn.websocket}`,t!=null&&t.params&&(this.params=t.params),t!=null&&t.headers&&(this.headers=Object.assign(Object.assign({},this.headers),t.headers)),t!=null&&t.timeout&&(this.timeout=t.timeout),t!=null&&t.logger&&(this.logger=t.logger),t!=null&&t.transport&&(this.transport=t.transport),t!=null&&t.heartbeatIntervalMs&&(this.heartbeatIntervalMs=t.heartbeatIntervalMs);const s=(r=t==null?void 0:t.params)===null||r===void 0?void 0:r.eventsPerSecond;s&&(this.eventsPerSecondLimitMs=Math.floor(1e3/s)),this.reconnectAfterMs=t!=null&&t.reconnectAfterMs?t.reconnectAfterMs:i=>[1e3,2e3,5e3,1e4][i-1]||1e4,this.encode=t!=null&&t.encode?t.encode:(i,o)=>o(JSON.stringify(i)),this.decode=t!=null&&t.decode?t.decode:this.serializer.decode.bind(this.serializer),this.reconnectTimer=new Hi(()=>hc(this,void 0,void 0,function*(){this.disconnect(),this.connect()}),this.reconnectAfterMs)}connect(){this.conn||(this.conn=new this.transport(this._endPointURL(),[],null,this.headers),this.conn&&(this.conn.binaryType="arraybuffer",this.conn.onopen=()=>this._onConnOpen(),this.conn.onerror=e=>this._onConnError(e),this.conn.onmessage=e=>this._onConnMessage(e),this.conn.onclose=e=>this._onConnClose(e)))}disconnect(e,t){this.conn&&(this.conn.onclose=function(){},e?this.conn.close(e,t??""):this.conn.close(),this.conn=null,this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.reset())}getChannels(){return this.channels}removeChannel(e){return e.unsubscribe().then(t=>(this.channels.length===0&&this.disconnect(),t))}removeAllChannels(){return Promise.all(this.channels.map(e=>e.unsubscribe())).then(e=>(this.disconnect(),e))}log(e,t,r){this.logger(e,t,r)}connectionState(){switch(this.conn&&this.conn.readyState){case Qt.connecting:return ct.Connecting;case Qt.open:return ct.Open;case Qt.closing:return ct.Closing;default:return ct.Closed}}isConnected(){return this.connectionState()===ct.Open}channel(e,t={config:{}}){this.isConnected()||this.connect();const r=new as(`realtime:${e}`,t,this);return this.channels.push(r),r}push(e){const{topic:t,event:r,payload:s,ref:i}=e;let o=()=>{this.encode(e,a=>{var c;(c=this.conn)===null||c===void 0||c.send(a)})};if(this.log("push",`${t} ${r} (${i})`,s),this.isConnected())if(["broadcast","presence","postgres_changes"].includes(r)){if(this._throttle(o)())return"rate limited"}else o();else this.sendBuffer.push(o)}setAuth(e){this.accessToken=e,this.channels.forEach(t=>{e&&t.updateJoinPayload({access_token:e}),t.joinedOnce&&t._isJoined()&&t._push(we.access_token,{access_token:e})})}_makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}_leaveOpenTopic(e){let t=this.channels.find(r=>r.topic===e&&(r._isJoined()||r._isJoining()));t&&(this.log("transport",`leaving duplicate topic "${e}"`),t.unsubscribe())}_remove(e){this.channels=this.channels.filter(t=>t._joinRef()!==e._joinRef())}_endPointURL(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:rc}))}_onConnMessage(e){this.decode(e.data,t=>{let{topic:r,event:s,payload:i,ref:o}=t;(o&&o===this.pendingHeartbeatRef||s===(i==null?void 0:i.type))&&(this.pendingHeartbeatRef=null),this.log("receive",`${i.status||""} ${r} ${s} ${o&&"("+o+")"||""}`,i),this.channels.filter(a=>a._isMember(r)).forEach(a=>a._trigger(s,i,o)),this.stateChangeCallbacks.message.forEach(a=>a(t))})}_onConnOpen(){this.log("transport",`connected to ${this._endPointURL()}`),this._flushSendBuffer(),this.reconnectTimer.reset(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(()=>this._sendHeartbeat(),this.heartbeatIntervalMs),this.stateChangeCallbacks.open.forEach(e=>e())}_onConnClose(e){this.log("transport","close",e),this._triggerChanError(),this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.reconnectTimer.scheduleTimeout(),this.stateChangeCallbacks.close.forEach(t=>t(e))}_onConnError(e){this.log("transport",e.message),this._triggerChanError(),this.stateChangeCallbacks.error.forEach(t=>t(e))}_triggerChanError(){this.channels.forEach(e=>e._trigger(we.error))}_appendParams(e,t){if(Object.keys(t).length===0)return e;const r=e.match(/\?/)?"&":"?",s=new URLSearchParams(t);return`${e}${r}${s}`}_flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}_sendHeartbeat(){var e;if(this.isConnected()){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection"),(e=this.conn)===null||e===void 0||e.close(nc,"hearbeat timeout");return}this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef}),this.setAuth(this.accessToken)}}_throttle(e,t=this.eventsPerSecondLimitMs){return()=>this.inThrottle?!0:(e(),t>0&&(this.inThrottle=!0,setTimeout(()=>{this.inThrottle=!1},t)),!1)}}class zi extends Error{constructor(e){super(e),this.__isStorageError=!0,this.name="StorageError"}}function re(n){return typeof n=="object"&&n!==null&&"__isStorageError"in n}class pc extends zi{constructor(e,t){super(e),this.name="StorageApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class Vs extends zi{constructor(e,t){super(e),this.name="StorageUnknownError",this.originalError=t}}var Vi=globalThis&&globalThis.__awaiter||function(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(l){try{u(r.next(l))}catch(h){o(h)}}function c(l){try{u(r.throw(l))}catch(h){o(h)}}function u(l){l.done?i(l.value):s(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})};const qi=n=>{let e;return n?e=n:typeof fetch>"u"?e=(...t)=>Vi(void 0,void 0,void 0,function*(){return yield(yield Promise.resolve().then(()=>Wr)).fetch(...t)}):e=fetch,(...t)=>e(...t)},yc=()=>Vi(void 0,void 0,void 0,function*(){return typeof Response>"u"?(yield Promise.resolve().then(()=>Wr)).Response:Response});var Vt=globalThis&&globalThis.__awaiter||function(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(l){try{u(r.next(l))}catch(h){o(h)}}function c(l){try{u(r.throw(l))}catch(h){o(h)}}function u(l){l.done?i(l.value):s(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})};const wn=n=>n.msg||n.message||n.error_description||n.error||JSON.stringify(n),mc=(n,e)=>Vt(void 0,void 0,void 0,function*(){const t=yield yc();n instanceof t?n.json().then(r=>{e(new pc(wn(r),n.status||500))}).catch(r=>{e(new Vs(wn(r),r))}):e(new Vs(wn(n),n))}),gc=(n,e,t,r)=>{const s={method:n,headers:(e==null?void 0:e.headers)||{}};return n==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json"},e==null?void 0:e.headers),s.body=JSON.stringify(r),Object.assign(Object.assign({},s),t))};function Kr(n,e,t,r,s,i){return Vt(this,void 0,void 0,function*(){return new Promise((o,a)=>{n(t,gc(e,r,s,i)).then(c=>{if(!c.ok)throw c;return r!=null&&r.noResolveJson?c:c.json()}).then(c=>o(c)).catch(c=>mc(c,a))})})}function Dn(n,e,t,r){return Vt(this,void 0,void 0,function*(){return Kr(n,"GET",e,t,r)})}function ut(n,e,t,r,s){return Vt(this,void 0,void 0,function*(){return Kr(n,"POST",e,r,s,t)})}function wc(n,e,t,r,s){return Vt(this,void 0,void 0,function*(){return Kr(n,"PUT",e,r,s,t)})}function Ji(n,e,t,r,s){return Vt(this,void 0,void 0,function*(){return Kr(n,"DELETE",e,r,s,t)})}var xe=globalThis&&globalThis.__awaiter||function(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(l){try{u(r.next(l))}catch(h){o(h)}}function c(l){try{u(r.throw(l))}catch(h){o(h)}}function u(l){l.done?i(l.value):s(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})};const bc={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},vc={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};class _c{constructor(e,t={},r,s){this.url=e,this.headers=t,this.bucketId=r,this.fetch=qi(s)}uploadOrUpdate(e,t,r,s){return xe(this,void 0,void 0,function*(){try{let i;const o=Object.assign(Object.assign({},vc),s),a=Object.assign(Object.assign({},this.headers),e==="POST"&&{"x-upsert":String(o.upsert)});typeof Blob<"u"&&r instanceof Blob?(i=new FormData,i.append("cacheControl",o.cacheControl),i.append("",r)):typeof FormData<"u"&&r instanceof FormData?(i=r,i.append("cacheControl",o.cacheControl)):(i=r,a["cache-control"]=`max-age=${o.cacheControl}`,a["content-type"]=o.contentType);const c=this._removeEmptyFolders(t),u=this._getFinalPath(c),l=yield this.fetch(`${this.url}/object/${u}`,{method:e,body:i,headers:a});return l.ok?{data:{path:c},error:null}:{data:null,error:yield l.json()}}catch(i){if(re(i))return{data:null,error:i};throw i}})}upload(e,t,r){return xe(this,void 0,void 0,function*(){return this.uploadOrUpdate("POST",e,t,r)})}update(e,t,r){return xe(this,void 0,void 0,function*(){return this.uploadOrUpdate("PUT",e,t,r)})}move(e,t){return xe(this,void 0,void 0,function*(){try{return{data:yield ut(this.fetch,`${this.url}/object/move`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t},{headers:this.headers}),error:null}}catch(r){if(re(r))return{data:null,error:r};throw r}})}copy(e,t){return xe(this,void 0,void 0,function*(){try{return{data:{path:(yield ut(this.fetch,`${this.url}/object/copy`,{bucketId:this.bucketId,sourceKey:e,destinationKey:t},{headers:this.headers})).Key},error:null}}catch(r){if(re(r))return{data:null,error:r};throw r}})}createSignedUrl(e,t,r){return xe(this,void 0,void 0,function*(){try{let s=this._getFinalPath(e),i=yield ut(this.fetch,`${this.url}/object/sign/${s}`,Object.assign({expiresIn:t},r!=null&&r.transform?{transform:r.transform}:{}),{headers:this.headers});const o=r!=null&&r.download?`&download=${r.download===!0?"":r.download}`:"";return i={signedUrl:encodeURI(`${this.url}${i.signedURL}${o}`)},{data:i,error:null}}catch(s){if(re(s))return{data:null,error:s};throw s}})}createSignedUrls(e,t,r){return xe(this,void 0,void 0,function*(){try{const s=yield ut(this.fetch,`${this.url}/object/sign/${this.bucketId}`,{expiresIn:t,paths:e},{headers:this.headers}),i=r!=null&&r.download?`&download=${r.download===!0?"":r.download}`:"";return{data:s.map(o=>Object.assign(Object.assign({},o),{signedUrl:o.signedURL?encodeURI(`${this.url}${o.signedURL}${i}`):null})),error:null}}catch(s){if(re(s))return{data:null,error:s};throw s}})}download(e,t){return xe(this,void 0,void 0,function*(){const s=typeof(t==null?void 0:t.transform)<"u"?"render/image/authenticated":"object",i=this.transformOptsToQueryString((t==null?void 0:t.transform)||{}),o=i?`?${i}`:"";try{const a=this._getFinalPath(e);return{data:yield(yield Dn(this.fetch,`${this.url}/${s}/${a}${o}`,{headers:this.headers,noResolveJson:!0})).blob(),error:null}}catch(a){if(re(a))return{data:null,error:a};throw a}})}getPublicUrl(e,t){const r=this._getFinalPath(e),s=[],i=t!=null&&t.download?`download=${t.download===!0?"":t.download}`:"";i!==""&&s.push(i);const a=typeof(t==null?void 0:t.transform)<"u"?"render/image":"object",c=this.transformOptsToQueryString((t==null?void 0:t.transform)||{});c!==""&&s.push(c);let u=s.join("&");return u!==""&&(u=`?${u}`),{data:{publicUrl:encodeURI(`${this.url}/${a}/public/${r}${u}`)}}}remove(e){return xe(this,void 0,void 0,function*(){try{return{data:yield Ji(this.fetch,`${this.url}/object/${this.bucketId}`,{prefixes:e},{headers:this.headers}),error:null}}catch(t){if(re(t))return{data:null,error:t};throw t}})}list(e,t,r){return xe(this,void 0,void 0,function*(){try{const s=Object.assign(Object.assign(Object.assign({},bc),t),{prefix:e||""});return{data:yield ut(this.fetch,`${this.url}/object/list/${this.bucketId}`,s,{headers:this.headers},r),error:null}}catch(s){if(re(s))return{data:null,error:s};throw s}})}_getFinalPath(e){return`${this.bucketId}/${e}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}transformOptsToQueryString(e){const t=[];return e.width&&t.push(`width=${e.width}`),e.height&&t.push(`height=${e.height}`),e.resize&&t.push(`resize=${e.resize}`),e.format&&t.push(`format=${e.format}`),e.quality&&t.push(`quality=${e.quality}`),t.join("&")}}const Ec="2.3.1",xc={"X-Client-Info":`storage-js/${Ec}`};var At=globalThis&&globalThis.__awaiter||function(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(l){try{u(r.next(l))}catch(h){o(h)}}function c(l){try{u(r.throw(l))}catch(h){o(h)}}function u(l){l.done?i(l.value):s(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})};class Tc{constructor(e,t={},r){this.url=e,this.headers=Object.assign(Object.assign({},xc),t),this.fetch=qi(r)}listBuckets(){return At(this,void 0,void 0,function*(){try{return{data:yield Dn(this.fetch,`${this.url}/bucket`,{headers:this.headers}),error:null}}catch(e){if(re(e))return{data:null,error:e};throw e}})}getBucket(e){return At(this,void 0,void 0,function*(){try{return{data:yield Dn(this.fetch,`${this.url}/bucket/${e}`,{headers:this.headers}),error:null}}catch(t){if(re(t))return{data:null,error:t};throw t}})}createBucket(e,t={public:!1}){return At(this,void 0,void 0,function*(){try{return{data:yield ut(this.fetch,`${this.url}/bucket`,{id:e,name:e,public:t.public},{headers:this.headers}),error:null}}catch(r){if(re(r))return{data:null,error:r};throw r}})}updateBucket(e,t){return At(this,void 0,void 0,function*(){try{return{data:yield wc(this.fetch,`${this.url}/bucket/${e}`,{id:e,name:e,public:t.public},{headers:this.headers}),error:null}}catch(r){if(re(r))return{data:null,error:r};throw r}})}emptyBucket(e){return At(this,void 0,void 0,function*(){try{return{data:yield ut(this.fetch,`${this.url}/bucket/${e}/empty`,{},{headers:this.headers}),error:null}}catch(t){if(re(t))return{data:null,error:t};throw t}})}deleteBucket(e){return At(this,void 0,void 0,function*(){try{return{data:yield Ji(this.fetch,`${this.url}/bucket/${e}`,{},{headers:this.headers}),error:null}}catch(t){if(re(t))return{data:null,error:t};throw t}})}}class Oc extends Tc{constructor(e,t={},r){super(e,t,r)}from(e){return new _c(this.url,this.headers,e,this.fetch)}}const kc="2.10.0",Ac={"X-Client-Info":`supabase-js/${kc}`};var Sc=globalThis&&globalThis.__awaiter||function(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(l){try{u(r.next(l))}catch(h){o(h)}}function c(l){try{u(r.throw(l))}catch(h){o(h)}}function u(l){l.done?i(l.value):s(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})};const Rc=n=>{let e;return n?e=n:typeof fetch>"u"?e=os:e=fetch,(...t)=>e(...t)},Pc=()=>typeof Headers>"u"?Mt.Headers:Headers,Nc=(n,e,t)=>{const r=Rc(t),s=Pc();return(i,o)=>Sc(void 0,void 0,void 0,function*(){var a;const c=(a=yield e())!==null&&a!==void 0?a:n;let u=new s(o==null?void 0:o.headers);return u.has("apikey")||u.set("apikey",n),u.has("Authorization")||u.set("Authorization",`Bearer ${c}`),r(i,Object.assign(Object.assign({},o),{headers:u}))})};function $c(n){return n.replace(/\/$/,"")}function Cc(n,e){const{db:t,auth:r,realtime:s,global:i}=n,{db:o,auth:a,realtime:c,global:u}=e;return{db:Object.assign(Object.assign({},o),t),auth:Object.assign(Object.assign({},a),r),realtime:Object.assign(Object.assign({},c),s),global:Object.assign(Object.assign({},u),i)}}var dr=globalThis&&globalThis.__awaiter||function(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(l){try{u(r.next(l))}catch(h){o(h)}}function c(l){try{u(r.throw(l))}catch(h){o(h)}}function u(l){l.done?i(l.value):s(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})};function Fc(n){return Math.round(Date.now()/1e3)+n}function Ic(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){const e=Math.random()*16|0;return(n=="x"?e:e&3|8).toString(16)})}const ot=()=>typeof document<"u",st={tested:!1,writable:!1},bn=()=>{if(!ot())return!1;try{if(typeof globalThis.localStorage!="object")return!1}catch{return!1}if(st.tested)return st.writable;const n=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(n,n),globalThis.localStorage.removeItem(n),st.tested=!0,st.writable=!0}catch{st.tested=!0,st.writable=!1}return st.writable};function le(n,e){var t;e||(e=((t=window==null?void 0:window.location)===null||t===void 0?void 0:t.href)||""),n=n.replace(/[\[\]]/g,"\\$&");const r=new RegExp("[?&#]"+n+"(=([^&#]*)|&|#|$)"),s=r.exec(e);return s?s[2]?decodeURIComponent(s[2].replace(/\+/g," ")):"":null}const Gi=n=>{let e;return n?e=n:typeof fetch>"u"?e=(...t)=>dr(void 0,void 0,void 0,function*(){return yield(yield Promise.resolve().then(()=>Wr)).fetch(...t)}):e=fetch,(...t)=>e(...t)},Dc=n=>typeof n=="object"&&n!==null&&"status"in n&&"ok"in n&&"json"in n&&typeof n.json=="function",Uc=(n,e,t)=>dr(void 0,void 0,void 0,function*(){yield n.setItem(e,JSON.stringify(t))}),qs=(n,e)=>dr(void 0,void 0,void 0,function*(){const t=yield n.getItem(e);if(!t)return null;try{return JSON.parse(t)}catch{return t}}),Lc=(n,e)=>dr(void 0,void 0,void 0,function*(){yield n.removeItem(e)});function jc(n){const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";let t="",r,s,i,o,a,c,u,l=0;for(n=n.replace("-","+").replace("_","/");l<n.length;)o=e.indexOf(n.charAt(l++)),a=e.indexOf(n.charAt(l++)),c=e.indexOf(n.charAt(l++)),u=e.indexOf(n.charAt(l++)),r=o<<2|a>>4,s=(a&15)<<4|c>>2,i=(c&3)<<6|u,t=t+String.fromCharCode(r),c!=64&&s!=0&&(t=t+String.fromCharCode(s)),u!=64&&i!=0&&(t=t+String.fromCharCode(i));return t}class Xr{constructor(){this.promise=new Xr.promiseConstructor((e,t)=>{this.resolve=e,this.reject=t})}}Xr.promiseConstructor=Promise;function Js(n){const e=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}=?$|[a-z0-9_-]{2}(==)?$)$/i,t=n.split(".");if(t.length!==3)throw new Error("JWT is not valid: not a JWT structure");if(!e.test(t[1]))throw new Error("JWT is not valid: payload is not in base64url format");const r=t[1];return JSON.parse(jc(r))}function Bc(n){return new Promise(e=>{setTimeout(()=>e(null),n)})}function Hc(n,e){return new Promise((r,s)=>{dr(this,void 0,void 0,function*(){for(let i=0;i<1/0;i++)try{const o=yield n(i);if(!e(i,null,o)){r(o);return}}catch(o){if(!e(i,o)){s(o);return}}})})}class cs extends Error{constructor(e,t){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=t}}function C(n){return typeof n=="object"&&n!==null&&"__isAuthError"in n}class Mc extends cs{constructor(e,t){super(e,t),this.name="AuthApiError",this.status=t}toJSON(){return{name:this.name,message:this.message,status:this.status}}}function zc(n){return C(n)&&n.name==="AuthApiError"}class Wi extends cs{constructor(e,t){super(e),this.name="AuthUnknownError",this.originalError=t}}class Zr extends cs{constructor(e,t,r){super(e),this.name=t,this.status=r}toJSON(){return{name:this.name,message:this.message,status:this.status}}}class Wt extends Zr{constructor(){super("Auth session missing!","AuthSessionMissingError",400)}}class vn extends Zr{constructor(e){super(e,"AuthInvalidCredentialsError",400)}}class Ne extends Zr{constructor(e,t=null){super(e,"AuthImplicitGrantRedirectError",500),this.details=null,this.details=t}toJSON(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}class Un extends Zr{constructor(e,t){super(e,"AuthRetryableFetchError",t)}}var us=globalThis&&globalThis.__awaiter||function(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(l){try{u(r.next(l))}catch(h){o(h)}}function c(l){try{u(r.throw(l))}catch(h){o(h)}}function u(l){l.done?i(l.value):s(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})},Vc=globalThis&&globalThis.__rest||function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(t[r[s]]=n[r[s]]);return t};const _r=n=>n.msg||n.message||n.error_description||n.error||JSON.stringify(n),qc=(n,e)=>us(void 0,void 0,void 0,function*(){const t=[502,503,504];Dc(n)?t.includes(n.status)?e(new Un(_r(n),n.status)):n.json().then(r=>{e(new Mc(_r(r),n.status||500))}).catch(r=>{e(new Wi(_r(r),r))}):e(new Un(_r(n),0))}),Jc=(n,e,t,r)=>{const s={method:n,headers:(e==null?void 0:e.headers)||{}};return n==="GET"?s:(s.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},e==null?void 0:e.headers),s.body=JSON.stringify(r),Object.assign(Object.assign({},s),t))};function D(n,e,t,r){var s;return us(this,void 0,void 0,function*(){const i=Object.assign({},r==null?void 0:r.headers);r!=null&&r.jwt&&(i.Authorization=`Bearer ${r.jwt}`);const o=(s=r==null?void 0:r.query)!==null&&s!==void 0?s:{};r!=null&&r.redirectTo&&(o.redirect_to=r.redirectTo);const a=Object.keys(o).length?"?"+new URLSearchParams(o).toString():"",c=yield Gc(n,e,t+a,{headers:i,noResolveJson:r==null?void 0:r.noResolveJson},{},r==null?void 0:r.body);return r!=null&&r.xform?r==null?void 0:r.xform(c):{data:Object.assign({},c),error:null}})}function Gc(n,e,t,r,s,i){return us(this,void 0,void 0,function*(){return new Promise((o,a)=>{n(t,Jc(e,r,s,i)).then(c=>{if(!c.ok)throw c;return r!=null&&r.noResolveJson?c:c.json()}).then(c=>o(c)).catch(c=>qc(c,a))})})}function it(n){var e;let t=null;Zc(n)&&(t=Object.assign({},n),t.expires_at=Fc(n.expires_in));const r=(e=n.user)!==null&&e!==void 0?e:n;return{data:{session:t,user:r},error:null}}function lt(n){var e;return{data:{user:(e=n.user)!==null&&e!==void 0?e:n},error:null}}function Wc(n){return{data:n,error:null}}function Kc(n){const{action_link:e,email_otp:t,hashed_token:r,redirect_to:s,verification_type:i}=n,o=Vc(n,["action_link","email_otp","hashed_token","redirect_to","verification_type"]),a={action_link:e,email_otp:t,hashed_token:r,redirect_to:s,verification_type:i},c=Object.assign({},o);return{data:{properties:a,user:c},error:null}}function Xc(n){return n}function Zc(n){return n.access_token&&n.refresh_token&&n.expires_in}var Te=globalThis&&globalThis.__awaiter||function(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(l){try{u(r.next(l))}catch(h){o(h)}}function c(l){try{u(r.throw(l))}catch(h){o(h)}}function u(l){l.done?i(l.value):s(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})},Yc=globalThis&&globalThis.__rest||function(n,e){var t={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(t[r[s]]=n[r[s]]);return t};class Qc{constructor({url:e="",headers:t={},fetch:r}){this.url=e,this.headers=t,this.fetch=Gi(r),this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)}}signOut(e){return Te(this,void 0,void 0,function*(){try{return yield D(this.fetch,"POST",`${this.url}/logout`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(t){if(C(t))return{data:null,error:t};throw t}})}inviteUserByEmail(e,t={}){return Te(this,void 0,void 0,function*(){try{return yield D(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:t.data},headers:this.headers,redirectTo:t.redirectTo,xform:lt})}catch(r){if(C(r))return{data:{user:null},error:r};throw r}})}generateLink(e){return Te(this,void 0,void 0,function*(){try{const{options:t}=e,r=Yc(e,["options"]),s=Object.assign(Object.assign({},r),t);return"newEmail"in r&&(s.new_email=r==null?void 0:r.newEmail,delete s.newEmail),yield D(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:s,headers:this.headers,xform:Kc,redirectTo:t==null?void 0:t.redirectTo})}catch(t){if(C(t))return{data:{properties:null,user:null},error:t};throw t}})}createUser(e){return Te(this,void 0,void 0,function*(){try{return yield D(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:lt})}catch(t){if(C(t))return{data:{user:null},error:t};throw t}})}listUsers(e){var t,r,s,i,o,a,c;return Te(this,void 0,void 0,function*(){try{const u={nextPage:null,lastPage:0,total:0},l=yield D(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:(r=(t=e==null?void 0:e.page)===null||t===void 0?void 0:t.toString())!==null&&r!==void 0?r:"",per_page:(i=(s=e==null?void 0:e.perPage)===null||s===void 0?void 0:s.toString())!==null&&i!==void 0?i:""},xform:Xc});if(l.error)throw l.error;const h=yield l.json(),p=(o=l.headers.get("x-total-count"))!==null&&o!==void 0?o:0,f=(c=(a=l.headers.get("link"))===null||a===void 0?void 0:a.split(","))!==null&&c!==void 0?c:[];return f.length>0&&(f.forEach(d=>{const w=parseInt(d.split(";")[0].split("=")[1].substring(0,1)),b=JSON.parse(d.split(";")[1].split("=")[1]);u[`${b}Page`]=w}),u.total=parseInt(p)),{data:Object.assign(Object.assign({},h),u),error:null}}catch(u){if(C(u))return{data:{users:[]},error:u};throw u}})}getUserById(e){return Te(this,void 0,void 0,function*(){try{return yield D(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:lt})}catch(t){if(C(t))return{data:{user:null},error:t};throw t}})}updateUserById(e,t){return Te(this,void 0,void 0,function*(){try{return yield D(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:t,headers:this.headers,xform:lt})}catch(r){if(C(r))return{data:{user:null},error:r};throw r}})}deleteUser(e,t=!1){return Te(this,void 0,void 0,function*(){try{return yield D(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:t},xform:lt})}catch(r){if(C(r))return{data:{user:null},error:r};throw r}})}_listFactors(e){return Te(this,void 0,void 0,function*(){try{const{data:t,error:r}=yield D(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:s=>({data:{factors:s},error:null})});return{data:t,error:r}}catch(t){if(C(t))return{data:null,error:t};throw t}})}_deleteFactor(e){return Te(this,void 0,void 0,function*(){try{return{data:yield D(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(t){if(C(t))return{data:null,error:t};throw t}})}}const eu="2.13.0",tu="http://localhost:9999",ru="supabase.auth.token",nu={"X-Client-Info":`gotrue-js/${eu}`},su=10,iu={getItem:n=>bn()?globalThis.localStorage.getItem(n):null,setItem:(n,e)=>{bn()&&globalThis.localStorage.setItem(n,e)},removeItem:n=>{bn()&&globalThis.localStorage.removeItem(n)}};function ou(){if(typeof globalThis!="object")try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch{typeof self<"u"&&(self.globalThis=self)}}var S=globalThis&&globalThis.__awaiter||function(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(l){try{u(r.next(l))}catch(h){o(h)}}function c(l){try{u(r.throw(l))}catch(h){o(h)}}function u(l){l.done?i(l.value):s(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})};ou();const au={url:tu,storageKey:ru,autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:nu},_n=10*1e3,cu=3;class uu{constructor(e){this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.broadcastChannel=null;const t=Object.assign(Object.assign({},au),e);this.inMemorySession=null,this.storageKey=t.storageKey,this.autoRefreshToken=t.autoRefreshToken,this.persistSession=t.persistSession,this.storage=t.storage||iu,this.admin=new Qc({url:t.url,headers:t.headers,fetch:t.fetch}),this.url=t.url,this.headers=t.headers,this.fetch=Gi(t.fetch),this.detectSessionInUrl=t.detectSessionInUrl,this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this)},ot()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey&&(this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey),this.broadcastChannel.addEventListener("message",r=>{this._notifyAllSubscribers(r.data.event,r.data.session,!1)})),this.initialize()}initialize(){return this.initializePromise||(this.initializePromise=this._initialize()),this.initializePromise}_initialize(){return S(this,void 0,void 0,function*(){if(this.initializePromise)return this.initializePromise;try{if(this.detectSessionInUrl&&this._isImplicitGrantFlow()){const{data:e,error:t}=yield this._getSessionFromUrl();if(t)return yield this._removeSession(),{error:t};const{session:r,redirectType:s}=e;return yield this._saveSession(r),setTimeout(()=>{this._notifyAllSubscribers("SIGNED_IN",r),s==="recovery"&&this._notifyAllSubscribers("PASSWORD_RECOVERY",r)},0),{error:null}}return yield this._recoverAndRefresh(),{error:null}}catch(e){return C(e)?{error:e}:{error:new Wi("Unexpected error during initialization",e)}}finally{yield this._handleVisibilityChange()}})}signUp(e){var t,r;return S(this,void 0,void 0,function*(){try{yield this._removeSession();let s;if("email"in e){const{email:u,password:l,options:h}=e;s=yield D(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,redirectTo:h==null?void 0:h.emailRedirectTo,body:{email:u,password:l,data:(t=h==null?void 0:h.data)!==null&&t!==void 0?t:{},gotrue_meta_security:{captcha_token:h==null?void 0:h.captchaToken}},xform:it})}else if("phone"in e){const{phone:u,password:l,options:h}=e;s=yield D(this.fetch,"POST",`${this.url}/signup`,{headers:this.headers,body:{phone:u,password:l,data:(r=h==null?void 0:h.data)!==null&&r!==void 0?r:{},gotrue_meta_security:{captcha_token:h==null?void 0:h.captchaToken}},xform:it})}else throw new vn("You must provide either an email or phone number and a password");const{data:i,error:o}=s;if(o||!i)return{data:{user:null,session:null},error:o};const a=i.session,c=i.user;return i.session&&(yield this._saveSession(i.session),this._notifyAllSubscribers("SIGNED_IN",a)),{data:{user:c,session:a},error:null}}catch(s){if(C(s))return{data:{user:null,session:null},error:s};throw s}})}signInWithPassword(e){var t;return S(this,void 0,void 0,function*(){try{yield this._removeSession();let r;if("email"in e){const{email:o,password:a,options:c}=e;r=yield D(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{email:o,password:a,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken}},xform:it})}else if("phone"in e){const{phone:o,password:a,options:c}=e;r=yield D(this.fetch,"POST",`${this.url}/token?grant_type=password`,{headers:this.headers,body:{phone:o,password:a,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken},channel:(t=c==null?void 0:c.channel)!==null&&t!==void 0?t:"sms"},xform:it})}else throw new vn("You must provide either an email or phone number and a password");const{data:s,error:i}=r;return i||!s?{data:{user:null,session:null},error:i}:(s.session&&(yield this._saveSession(s.session),this._notifyAllSubscribers("SIGNED_IN",s.session)),{data:s,error:i})}catch(r){if(C(r))return{data:{user:null,session:null},error:r};throw r}})}signInWithOAuth(e){var t,r,s,i;return S(this,void 0,void 0,function*(){return yield this._removeSession(),this._handleProviderSignIn(e.provider,{redirectTo:(t=e.options)===null||t===void 0?void 0:t.redirectTo,scopes:(r=e.options)===null||r===void 0?void 0:r.scopes,queryParams:(s=e.options)===null||s===void 0?void 0:s.queryParams,skipBrowserRedirect:(i=e.options)===null||i===void 0?void 0:i.skipBrowserRedirect})})}signInWithIdToken(e){return S(this,void 0,void 0,function*(){yield this._removeSession();try{const{options:t,provider:r,token:s,nonce:i}=e,o=yield D(this.fetch,"POST",`${this.url}/token?grant_type=id_token`,{headers:this.headers,body:{provider:r,id_token:s,nonce:i,gotrue_meta_security:{captcha_token:t==null?void 0:t.captchaToken}},xform:it}),{data:a,error:c}=o;return c||!a?{data:{user:null,session:null},error:c}:(a.session&&(yield this._saveSession(a.session),this._notifyAllSubscribers("SIGNED_IN",a.session)),{data:a,error:c})}catch(t){if(C(t))return{data:{user:null,session:null},error:t};throw t}})}signInWithOtp(e){var t,r,s,i,o;return S(this,void 0,void 0,function*(){try{if(yield this._removeSession(),"email"in e){const{email:a,options:c}=e,{error:u}=yield D(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{email:a,data:(t=c==null?void 0:c.data)!==null&&t!==void 0?t:{},create_user:(r=c==null?void 0:c.shouldCreateUser)!==null&&r!==void 0?r:!0,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken}},redirectTo:c==null?void 0:c.emailRedirectTo});return{data:{user:null,session:null},error:u}}if("phone"in e){const{phone:a,options:c}=e,{error:u}=yield D(this.fetch,"POST",`${this.url}/otp`,{headers:this.headers,body:{phone:a,data:(s=c==null?void 0:c.data)!==null&&s!==void 0?s:{},create_user:(i=c==null?void 0:c.shouldCreateUser)!==null&&i!==void 0?i:!0,gotrue_meta_security:{captcha_token:c==null?void 0:c.captchaToken},channel:(o=c==null?void 0:c.channel)!==null&&o!==void 0?o:"sms"}});return{data:{user:null,session:null},error:u}}throw new vn("You must provide either an email or phone number.")}catch(a){if(C(a))return{data:{user:null,session:null},error:a};throw a}})}verifyOtp(e){var t,r;return S(this,void 0,void 0,function*(){try{yield this._removeSession();const{data:s,error:i}=yield D(this.fetch,"POST",`${this.url}/verify`,{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:(t=e.options)===null||t===void 0?void 0:t.captchaToken}}),redirectTo:(r=e.options)===null||r===void 0?void 0:r.redirectTo,xform:it});if(i)throw i;if(!s)throw"An error occurred on token verification.";const o=s.session,a=s.user;return o!=null&&o.access_token&&(yield this._saveSession(o),this._notifyAllSubscribers("SIGNED_IN",o)),{data:{user:a,session:o},error:null}}catch(s){if(C(s))return{data:{user:null,session:null},error:s};throw s}})}signInWithSSO(e){var t,r,s;return S(this,void 0,void 0,function*(){try{return yield this._removeSession(),yield D(this.fetch,"POST",`${this.url}/sso`,{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:(r=(t=e.options)===null||t===void 0?void 0:t.redirectTo)!==null&&r!==void 0?r:void 0}),!((s=e==null?void 0:e.options)===null||s===void 0)&&s.captchaToken?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0}),headers:this.headers,xform:Wc})}catch(i){if(C(i))return{data:null,error:i};throw i}})}getSession(){return S(this,void 0,void 0,function*(){yield this.initializePromise;let e=null;if(this.persistSession){const i=yield qs(this.storage,this.storageKey);i!==null&&(this._isValidSession(i)?e=i:yield this._removeSession())}else e=this.inMemorySession;if(!e)return{data:{session:null},error:null};if(!(e.expires_at?e.expires_at<=Date.now()/1e3:!1))return{data:{session:e},error:null};const{session:r,error:s}=yield this._callRefreshToken(e.refresh_token);return s?{data:{session:null},error:s}:{data:{session:r},error:null}})}getUser(e){var t,r;return S(this,void 0,void 0,function*(){try{if(!e){const{data:s,error:i}=yield this.getSession();if(i)throw i;e=(r=(t=s.session)===null||t===void 0?void 0:t.access_token)!==null&&r!==void 0?r:void 0}return yield D(this.fetch,"GET",`${this.url}/user`,{headers:this.headers,jwt:e,xform:lt})}catch(s){if(C(s))return{data:{user:null},error:s};throw s}})}updateUser(e,t={}){return S(this,void 0,void 0,function*(){try{const{data:r,error:s}=yield this.getSession();if(s)throw s;if(!r.session)throw new Wt;const i=r.session,{data:o,error:a}=yield D(this.fetch,"PUT",`${this.url}/user`,{headers:this.headers,redirectTo:t==null?void 0:t.emailRedirectTo,body:e,jwt:i.access_token,xform:lt});if(a)throw a;return i.user=o.user,yield this._saveSession(i),this._notifyAllSubscribers("USER_UPDATED",i),{data:{user:i.user},error:null}}catch(r){if(C(r))return{data:{user:null},error:r};throw r}})}_decodeJWT(e){return Js(e)}setSession(e){return S(this,void 0,void 0,function*(){try{if(!e.access_token||!e.refresh_token)throw new Wt;const t=Date.now()/1e3;let r=t,s=!0,i=null;const o=Js(e.access_token);if(o.exp&&(r=o.exp,s=r<=t),s){const{session:a,error:c}=yield this._callRefreshToken(e.refresh_token);if(c)return{data:{user:null,session:null},error:c};if(!a)return{data:{user:null,session:null},error:null};i=a}else{const{data:a,error:c}=yield this.getUser(e.access_token);if(c)throw c;i={access_token:e.access_token,refresh_token:e.refresh_token,user:a.user,token_type:"bearer",expires_in:r-t,expires_at:r},yield this._saveSession(i),this._notifyAllSubscribers("SIGNED_IN",i)}return{data:{user:i.user,session:i},error:null}}catch(t){if(C(t))return{data:{session:null,user:null},error:t};throw t}})}refreshSession(e){var t;return S(this,void 0,void 0,function*(){try{if(!e){const{data:i,error:o}=yield this.getSession();if(o)throw o;e=(t=i.session)!==null&&t!==void 0?t:void 0}if(!(e!=null&&e.refresh_token))throw new Wt;const{session:r,error:s}=yield this._callRefreshToken(e.refresh_token);return s?{data:{user:null,session:null},error:s}:r?{data:{user:r.user,session:r},error:null}:{data:{user:null,session:null},error:null}}catch(r){if(C(r))return{data:{user:null,session:null},error:r};throw r}})}_getSessionFromUrl(){return S(this,void 0,void 0,function*(){try{if(!ot())throw new Ne("No browser detected.");if(!this._isImplicitGrantFlow())throw new Ne("Not a valid implicit grant flow url.");const e=le("error_description");if(e){const w=le("error_code");if(!w)throw new Ne("No error_code detected.");const b=le("error");throw b?new Ne(e,{error:b,code:w}):new Ne("No error detected.")}const t=le("provider_token"),r=le("provider_refresh_token"),s=le("access_token");if(!s)throw new Ne("No access_token detected.");const i=le("expires_in");if(!i)throw new Ne("No expires_in detected.");const o=le("refresh_token");if(!o)throw new Ne("No refresh_token detected.");const a=le("token_type");if(!a)throw new Ne("No token_type detected.");const u=Math.round(Date.now()/1e3)+parseInt(i),{data:l,error:h}=yield this.getUser(s);if(h)throw h;const p=l.user,f={provider_token:t,provider_refresh_token:r,access_token:s,expires_in:parseInt(i),expires_at:u,refresh_token:o,token_type:a,user:p},d=le("type");return window.location.hash="",{data:{session:f,redirectType:d},error:null}}catch(e){if(C(e))return{data:{session:null,redirectType:null},error:e};throw e}})}_isImplicitGrantFlow(){return ot()&&(Boolean(le("access_token"))||Boolean(le("error_description")))}signOut(){var e;return S(this,void 0,void 0,function*(){const{data:t,error:r}=yield this.getSession();if(r)return{error:r};const s=(e=t.session)===null||e===void 0?void 0:e.access_token;if(s){const{error:i}=yield this.admin.signOut(s);if(i&&!(zc(i)&&(i.status===404||i.status===401)))return{error:i}}return yield this._removeSession(),this._notifyAllSubscribers("SIGNED_OUT",null),{error:null}})}onAuthStateChange(e){const t=Ic(),r={id:t,callback:e,unsubscribe:()=>{this.stateChangeEmitters.delete(t)}};return this.stateChangeEmitters.set(t,r),{data:{subscription:r}}}resetPasswordForEmail(e,t={}){return S(this,void 0,void 0,function*(){try{return yield D(this.fetch,"POST",`${this.url}/recover`,{body:{email:e,gotrue_meta_security:{captcha_token:t.captchaToken}},headers:this.headers,redirectTo:t.redirectTo})}catch(r){if(C(r))return{data:null,error:r};throw r}})}_refreshAccessToken(e){return S(this,void 0,void 0,function*(){try{const t=Date.now();return yield Hc(r=>S(this,void 0,void 0,function*(){return yield Bc(r*200),yield D(this.fetch,"POST",`${this.url}/token?grant_type=refresh_token`,{body:{refresh_token:e},headers:this.headers,xform:it})}),(r,s,i)=>i&&i.error&&i.error instanceof Un&&Date.now()+(r+1)*200-t<_n)}catch(t){if(C(t))return{data:{session:null,user:null},error:t};throw t}})}_isValidSession(e){return typeof e=="object"&&e!==null&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}_handleProviderSignIn(e,t={}){const r=this._getUrlForProvider(e,{redirectTo:t.redirectTo,scopes:t.scopes,queryParams:t.queryParams});return ot()&&!t.skipBrowserRedirect&&window.location.assign(r),{data:{provider:e,url:r},error:null}}_recoverAndRefresh(){var e;return S(this,void 0,void 0,function*(){try{const t=yield qs(this.storage,this.storageKey);if(!this._isValidSession(t)){t!==null&&(yield this._removeSession());return}const r=Math.round(Date.now()/1e3);if(((e=t.expires_at)!==null&&e!==void 0?e:1/0)<r+su)if(this.autoRefreshToken&&t.refresh_token){const{error:s}=yield this._callRefreshToken(t.refresh_token);s&&(console.log(s.message),yield this._removeSession())}else yield this._removeSession();else this.persistSession&&(yield this._saveSession(t)),this._notifyAllSubscribers("SIGNED_IN",t)}catch(t){console.error(t);return}})}_callRefreshToken(e){var t,r;return S(this,void 0,void 0,function*(){if(this.refreshingDeferred)return this.refreshingDeferred.promise;try{if(this.refreshingDeferred=new Xr,!e)throw new Wt;const{data:s,error:i}=yield this._refreshAccessToken(e);if(i)throw i;if(!s.session)throw new Wt;yield this._saveSession(s.session),this._notifyAllSubscribers("TOKEN_REFRESHED",s.session);const o={session:s.session,error:null};return this.refreshingDeferred.resolve(o),o}catch(s){if(C(s)){const i={session:null,error:s};return(t=this.refreshingDeferred)===null||t===void 0||t.resolve(i),i}throw(r=this.refreshingDeferred)===null||r===void 0||r.reject(s),s}finally{this.refreshingDeferred=null}})}_notifyAllSubscribers(e,t,r=!0){this.broadcastChannel&&r&&this.broadcastChannel.postMessage({event:e,session:t}),this.stateChangeEmitters.forEach(s=>s.callback(e,t))}_saveSession(e){return S(this,void 0,void 0,function*(){this.persistSession||(this.inMemorySession=e),this.persistSession&&e.expires_at&&(yield this._persistSession(e))})}_persistSession(e){return Uc(this.storage,this.storageKey,e)}_removeSession(){return S(this,void 0,void 0,function*(){this.persistSession?yield Lc(this.storage,this.storageKey):this.inMemorySession=null})}_removeVisibilityChangedCallback(){const e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&ot()&&(window!=null&&window.removeEventListener)&&window.removeEventListener("visibilitychange",e)}catch(t){console.error("removing visibilitychange callback failed",t)}}_startAutoRefresh(){return S(this,void 0,void 0,function*(){yield this._stopAutoRefresh();const e=setInterval(()=>this._autoRefreshTokenTick(),_n);this.autoRefreshTicker=e,e&&typeof e=="object"&&typeof e.unref=="function"&&e.unref(),yield this._autoRefreshTokenTick()})}_stopAutoRefresh(){return S(this,void 0,void 0,function*(){const e=this.autoRefreshTicker;this.autoRefreshTicker=null,e&&clearInterval(e)})}startAutoRefresh(){return S(this,void 0,void 0,function*(){this._removeVisibilityChangedCallback(),yield this._startAutoRefresh()})}stopAutoRefresh(){return S(this,void 0,void 0,function*(){this._removeVisibilityChangedCallback(),yield this._stopAutoRefresh()})}_autoRefreshTokenTick(){return S(this,void 0,void 0,function*(){const e=Date.now();try{const{data:{session:t}}=yield this.getSession();if(!t||!t.refresh_token||!t.expires_at)return;Math.floor((t.expires_at*1e3-e)/_n)<cu&&(yield this._callRefreshToken(t.refresh_token))}catch(t){console.error("Auto refresh tick failed with error. This is likely a transient error.",t)}})}_handleVisibilityChange(){return S(this,void 0,void 0,function*(){if(!ot()||!(window!=null&&window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),!1;try{this.visibilityChangedCallback=()=>S(this,void 0,void 0,function*(){return yield this._onVisibilityChanged(!1)}),window==null||window.addEventListener("visibilitychange",this.visibilityChangedCallback),yield this._onVisibilityChanged(!0)}catch(e){console.error("_handleVisibilityChange",e)}})}_onVisibilityChanged(e){return S(this,void 0,void 0,function*(){document.visibilityState==="visible"?(e||(yield this.initializePromise,yield this._recoverAndRefresh()),this.autoRefreshToken&&this._startAutoRefresh()):document.visibilityState==="hidden"&&this.autoRefreshToken&&this._stopAutoRefresh()})}_getUrlForProvider(e,t){const r=[`provider=${encodeURIComponent(e)}`];if(t!=null&&t.redirectTo&&r.push(`redirect_to=${encodeURIComponent(t.redirectTo)}`),t!=null&&t.scopes&&r.push(`scopes=${encodeURIComponent(t.scopes)}`),t!=null&&t.queryParams){const s=new URLSearchParams(t.queryParams);r.push(s.toString())}return`${this.url}/authorize?${r.join("&")}`}_unenroll(e){var t;return S(this,void 0,void 0,function*(){try{const{data:r,error:s}=yield this.getSession();return s?{data:null,error:s}:yield D(this.fetch,"DELETE",`${this.url}/factors/${e.factorId}`,{headers:this.headers,jwt:(t=r==null?void 0:r.session)===null||t===void 0?void 0:t.access_token})}catch(r){if(C(r))return{data:null,error:r};throw r}})}_enroll(e){var t,r;return S(this,void 0,void 0,function*(){try{const{data:s,error:i}=yield this.getSession();if(i)return{data:null,error:i};const{data:o,error:a}=yield D(this.fetch,"POST",`${this.url}/factors`,{body:{friendly_name:e.friendlyName,factor_type:e.factorType,issuer:e.issuer},headers:this.headers,jwt:(t=s==null?void 0:s.session)===null||t===void 0?void 0:t.access_token});return a?{data:null,error:a}:(!((r=o==null?void 0:o.totp)===null||r===void 0)&&r.qr_code&&(o.totp.qr_code=`data:image/svg+xml;utf-8,${o.totp.qr_code}`),{data:o,error:null})}catch(s){if(C(s))return{data:null,error:s};throw s}})}_verify(e){var t;return S(this,void 0,void 0,function*(){try{const{data:r,error:s}=yield this.getSession();if(s)return{data:null,error:s};const{data:i,error:o}=yield D(this.fetch,"POST",`${this.url}/factors/${e.factorId}/verify`,{body:{code:e.code,challenge_id:e.challengeId},headers:this.headers,jwt:(t=r==null?void 0:r.session)===null||t===void 0?void 0:t.access_token});return o?{data:null,error:o}:(yield this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+i.expires_in},i)),this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",i),{data:i,error:o})}catch(r){if(C(r))return{data:null,error:r};throw r}})}_challenge(e){var t;return S(this,void 0,void 0,function*(){try{const{data:r,error:s}=yield this.getSession();return s?{data:null,error:s}:yield D(this.fetch,"POST",`${this.url}/factors/${e.factorId}/challenge`,{headers:this.headers,jwt:(t=r==null?void 0:r.session)===null||t===void 0?void 0:t.access_token})}catch(r){if(C(r))return{data:null,error:r};throw r}})}_challengeAndVerify(e){return S(this,void 0,void 0,function*(){const{data:t,error:r}=yield this._challenge({factorId:e.factorId});return r?{data:null,error:r}:yield this._verify({factorId:e.factorId,challengeId:t.id,code:e.code})})}_listFactors(){return S(this,void 0,void 0,function*(){const{data:{user:e},error:t}=yield this.getUser();if(t)return{data:null,error:t};const r=(e==null?void 0:e.factors)||[],s=r.filter(i=>i.factor_type==="totp"&&i.status==="verified");return{data:{all:r,totp:s},error:null}})}_getAuthenticatorAssuranceLevel(){var e,t;return S(this,void 0,void 0,function*(){const{data:{session:r},error:s}=yield this.getSession();if(s)return{data:null,error:s};if(!r)return{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null};const i=this._decodeJWT(r.access_token);let o=null;i.aal&&(o=i.aal);let a=o;((t=(e=r.user.factors)===null||e===void 0?void 0:e.filter(l=>l.status==="verified"))!==null&&t!==void 0?t:[]).length>0&&(a="aal2");const u=i.amr||[];return{data:{currentLevel:o,nextLevel:a,currentAuthenticationMethods:u},error:null}})}}class lu extends uu{constructor(e){super(e)}}var hu=globalThis&&globalThis.__awaiter||function(n,e,t,r){function s(i){return i instanceof t?i:new t(function(o){o(i)})}return new(t||(t=Promise))(function(i,o){function a(l){try{u(r.next(l))}catch(h){o(h)}}function c(l){try{u(r.throw(l))}catch(h){o(h)}}function u(l){l.done?i(l.value):s(l.value).then(a,c)}u((r=r.apply(n,e||[])).next())})};const fu={headers:Ac},du={schema:"public"},pu={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0},yu={};class mu{constructor(e,t,r){var s,i,o,a,c,u,l,h;if(this.supabaseUrl=e,this.supabaseKey=t,!e)throw new Error("supabaseUrl is required.");if(!t)throw new Error("supabaseKey is required.");const p=$c(e);if(this.realtimeUrl=`${p}/realtime/v1`.replace(/^http/i,"ws"),this.authUrl=`${p}/auth/v1`,this.storageUrl=`${p}/storage/v1`,p.match(/(supabase\.co)|(supabase\.in)/)){const T=p.split(".");this.functionsUrl=`${T[0]}.functions.${T[1]}.${T[2]}`}else this.functionsUrl=`${p}/functions/v1`;const d=`sb-${new URL(this.authUrl).hostname.split(".")[0]}-auth-token`,w={db:du,realtime:yu,auth:Object.assign(Object.assign({},pu),{storageKey:d}),global:fu},b=Cc(r??{},w);this.storageKey=(i=(s=b.auth)===null||s===void 0?void 0:s.storageKey)!==null&&i!==void 0?i:"",this.headers=(a=(o=b.global)===null||o===void 0?void 0:o.headers)!==null&&a!==void 0?a:{},this.auth=this._initSupabaseAuthClient((c=b.auth)!==null&&c!==void 0?c:{},this.headers,(u=b.global)===null||u===void 0?void 0:u.fetch),this.fetch=Nc(t,this._getAccessToken.bind(this),(l=b.global)===null||l===void 0?void 0:l.fetch),this.realtime=this._initRealtimeClient(Object.assign({headers:this.headers},b.realtime)),this.rest=new Na(`${p}/rest/v1`,{headers:this.headers,schema:(h=b.db)===null||h===void 0?void 0:h.schema,fetch:this.fetch}),this._listenForAuthEvents()}get functions(){return new Ea(this.functionsUrl,{headers:this.headers,customFetch:this.fetch})}get storage(){return new Oc(this.storageUrl,this.headers,this.fetch)}from(e){return this.rest.from(e)}rpc(e,t={},r){return this.rest.rpc(e,t,r)}channel(e,t={config:{}}){return this.realtime.channel(e,t)}getChannels(){return this.realtime.getChannels()}removeChannel(e){return this.realtime.removeChannel(e)}removeAllChannels(){return this.realtime.removeAllChannels()}_getAccessToken(){var e,t;return hu(this,void 0,void 0,function*(){const{data:r}=yield this.auth.getSession();return(t=(e=r.session)===null||e===void 0?void 0:e.access_token)!==null&&t!==void 0?t:null})}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:s,storageKey:i},o,a){const c={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new lu({url:this.authUrl,headers:Object.assign(Object.assign({},c),o),storageKey:i,autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:s,fetch:a})}_initRealtimeClient(e){return new dc(this.realtimeUrl,Object.assign(Object.assign({},e),{params:Object.assign({apikey:this.supabaseKey},e==null?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((t,r)=>{this._handleTokenChanged(t,r==null?void 0:r.access_token,"CLIENT")})}_handleTokenChanged(e,t,r){(e==="TOKEN_REFRESHED"||e==="SIGNED_IN")&&this.changedAccessToken!==t?(this.realtime.setAuth(t??null),this.changedAccessToken=t):(e==="SIGNED_OUT"||e==="USER_DELETED")&&(this.realtime.setAuth(this.supabaseKey),r=="STORAGE"&&this.auth.signOut(),this.changedAccessToken=void 0)}}const gu=(n,e,t)=>new mu(n,e,t);function Ki(n,e){return function(){return n.apply(e,arguments)}}const{toString:Xi}=Object.prototype,{getPrototypeOf:ls}=Object,hs=(n=>e=>{const t=Xi.call(e);return n[t]||(n[t]=t.slice(8,-1).toLowerCase())})(Object.create(null)),Ve=n=>(n=n.toLowerCase(),e=>hs(e)===n),Yr=n=>e=>typeof e===n,{isArray:qt}=Array,nr=Yr("undefined");function wu(n){return n!==null&&!nr(n)&&n.constructor!==null&&!nr(n.constructor)&&et(n.constructor.isBuffer)&&n.constructor.isBuffer(n)}const Zi=Ve("ArrayBuffer");function bu(n){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(n):e=n&&n.buffer&&Zi(n.buffer),e}const vu=Yr("string"),et=Yr("function"),Yi=Yr("number"),fs=n=>n!==null&&typeof n=="object",_u=n=>n===!0||n===!1,Sr=n=>{if(hs(n)!=="object")return!1;const e=ls(n);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in n)&&!(Symbol.iterator in n)},Eu=Ve("Date"),xu=Ve("File"),Tu=Ve("Blob"),Ou=Ve("FileList"),ku=n=>fs(n)&&et(n.pipe),Au=n=>{const e="[object FormData]";return n&&(typeof FormData=="function"&&n instanceof FormData||Xi.call(n)===e||et(n.toString)&&n.toString()===e)},Su=Ve("URLSearchParams"),Ru=n=>n.trim?n.trim():n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function pr(n,e,{allOwnKeys:t=!1}={}){if(n===null||typeof n>"u")return;let r,s;if(typeof n!="object"&&(n=[n]),qt(n))for(r=0,s=n.length;r<s;r++)e.call(null,n[r],r,n);else{const i=t?Object.getOwnPropertyNames(n):Object.keys(n),o=i.length;let a;for(r=0;r<o;r++)a=i[r],e.call(null,n[a],a,n)}}function Qi(n,e){e=e.toLowerCase();const t=Object.keys(n);let r=t.length,s;for(;r-- >0;)if(s=t[r],e===s.toLowerCase())return s;return null}const eo=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),to=n=>!nr(n)&&n!==eo;function Ln(){const{caseless:n}=to(this)&&this||{},e={},t=(r,s)=>{const i=n&&Qi(e,s)||s;Sr(e[i])&&Sr(r)?e[i]=Ln(e[i],r):Sr(r)?e[i]=Ln({},r):qt(r)?e[i]=r.slice():e[i]=r};for(let r=0,s=arguments.length;r<s;r++)arguments[r]&&pr(arguments[r],t);return e}const Pu=(n,e,t,{allOwnKeys:r}={})=>(pr(e,(s,i)=>{t&&et(s)?n[i]=Ki(s,t):n[i]=s},{allOwnKeys:r}),n),Nu=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),$u=(n,e,t,r)=>{n.prototype=Object.create(e.prototype,r),n.prototype.constructor=n,Object.defineProperty(n,"super",{value:e.prototype}),t&&Object.assign(n.prototype,t)},Cu=(n,e,t,r)=>{let s,i,o;const a={};if(e=e||{},n==null)return e;do{for(s=Object.getOwnPropertyNames(n),i=s.length;i-- >0;)o=s[i],(!r||r(o,n,e))&&!a[o]&&(e[o]=n[o],a[o]=!0);n=t!==!1&&ls(n)}while(n&&(!t||t(n,e))&&n!==Object.prototype);return e},Fu=(n,e,t)=>{n=String(n),(t===void 0||t>n.length)&&(t=n.length),t-=e.length;const r=n.indexOf(e,t);return r!==-1&&r===t},Iu=n=>{if(!n)return null;if(qt(n))return n;let e=n.length;if(!Yi(e))return null;const t=new Array(e);for(;e-- >0;)t[e]=n[e];return t},Du=(n=>e=>n&&e instanceof n)(typeof Uint8Array<"u"&&ls(Uint8Array)),Uu=(n,e)=>{const r=(n&&n[Symbol.iterator]).call(n);let s;for(;(s=r.next())&&!s.done;){const i=s.value;e.call(n,i[0],i[1])}},Lu=(n,e)=>{let t;const r=[];for(;(t=n.exec(e))!==null;)r.push(t);return r},ju=Ve("HTMLFormElement"),Bu=n=>n.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(t,r,s){return r.toUpperCase()+s}),Gs=(({hasOwnProperty:n})=>(e,t)=>n.call(e,t))(Object.prototype),Hu=Ve("RegExp"),ro=(n,e)=>{const t=Object.getOwnPropertyDescriptors(n),r={};pr(t,(s,i)=>{e(s,i,n)!==!1&&(r[i]=s)}),Object.defineProperties(n,r)},Mu=n=>{ro(n,(e,t)=>{if(et(n)&&["arguments","caller","callee"].indexOf(t)!==-1)return!1;const r=n[t];if(et(r)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+t+"'")})}})},zu=(n,e)=>{const t={},r=s=>{s.forEach(i=>{t[i]=!0})};return qt(n)?r(n):r(String(n).split(e)),t},Vu=()=>{},qu=(n,e)=>(n=+n,Number.isFinite(n)?n:e),En="abcdefghijklmnopqrstuvwxyz",Ws="0123456789",no={DIGIT:Ws,ALPHA:En,ALPHA_DIGIT:En+En.toUpperCase()+Ws},Ju=(n=16,e=no.ALPHA_DIGIT)=>{let t="";const{length:r}=e;for(;n--;)t+=e[Math.random()*r|0];return t};function Gu(n){return!!(n&&et(n.append)&&n[Symbol.toStringTag]==="FormData"&&n[Symbol.iterator])}const Wu=n=>{const e=new Array(10),t=(r,s)=>{if(fs(r)){if(e.indexOf(r)>=0)return;if(!("toJSON"in r)){e[s]=r;const i=qt(r)?[]:{};return pr(r,(o,a)=>{const c=t(o,s+1);!nr(c)&&(i[a]=c)}),e[s]=void 0,i}}return r};return t(n,0)},g={isArray:qt,isArrayBuffer:Zi,isBuffer:wu,isFormData:Au,isArrayBufferView:bu,isString:vu,isNumber:Yi,isBoolean:_u,isObject:fs,isPlainObject:Sr,isUndefined:nr,isDate:Eu,isFile:xu,isBlob:Tu,isRegExp:Hu,isFunction:et,isStream:ku,isURLSearchParams:Su,isTypedArray:Du,isFileList:Ou,forEach:pr,merge:Ln,extend:Pu,trim:Ru,stripBOM:Nu,inherits:$u,toFlatObject:Cu,kindOf:hs,kindOfTest:Ve,endsWith:Fu,toArray:Iu,forEachEntry:Uu,matchAll:Lu,isHTMLForm:ju,hasOwnProperty:Gs,hasOwnProp:Gs,reduceDescriptors:ro,freezeMethods:Mu,toObjectSet:zu,toCamelCase:Bu,noop:Vu,toFiniteNumber:qu,findKey:Qi,global:eo,isContextDefined:to,ALPHABET:no,generateString:Ju,isSpecCompliantForm:Gu,toJSONObject:Wu};function N(n,e,t,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=n,this.name="AxiosError",e&&(this.code=e),t&&(this.config=t),r&&(this.request=r),s&&(this.response=s)}g.inherits(N,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:g.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const so=N.prototype,io={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(n=>{io[n]={value:n}});Object.defineProperties(N,io);Object.defineProperty(so,"isAxiosError",{value:!0});N.from=(n,e,t,r,s,i)=>{const o=Object.create(so);return g.toFlatObject(n,o,function(c){return c!==Error.prototype},a=>a!=="isAxiosError"),N.call(o,n.message,e,t,r,s),o.cause=n,o.name=n.name,i&&Object.assign(o,i),o};const Ku=null;function jn(n){return g.isPlainObject(n)||g.isArray(n)}function oo(n){return g.endsWith(n,"[]")?n.slice(0,-2):n}function Ks(n,e,t){return n?n.concat(e).map(function(s,i){return s=oo(s),!t&&i?"["+s+"]":s}).join(t?".":""):e}function Xu(n){return g.isArray(n)&&!n.some(jn)}const Zu=g.toFlatObject(g,{},null,function(e){return/^is[A-Z]/.test(e)});function Qr(n,e,t){if(!g.isObject(n))throw new TypeError("target must be an object");e=e||new FormData,t=g.toFlatObject(t,{metaTokens:!0,dots:!1,indexes:!1},!1,function(w,b){return!g.isUndefined(b[w])});const r=t.metaTokens,s=t.visitor||l,i=t.dots,o=t.indexes,c=(t.Blob||typeof Blob<"u"&&Blob)&&g.isSpecCompliantForm(e);if(!g.isFunction(s))throw new TypeError("visitor must be a function");function u(d){if(d===null)return"";if(g.isDate(d))return d.toISOString();if(!c&&g.isBlob(d))throw new N("Blob is not supported. Use a Buffer instead.");return g.isArrayBuffer(d)||g.isTypedArray(d)?c&&typeof Blob=="function"?new Blob([d]):Buffer.from(d):d}function l(d,w,b){let T=d;if(d&&!b&&typeof d=="object"){if(g.endsWith(w,"{}"))w=r?w:w.slice(0,-2),d=JSON.stringify(d);else if(g.isArray(d)&&Xu(d)||(g.isFileList(d)||g.endsWith(w,"[]"))&&(T=g.toArray(d)))return w=oo(w),T.forEach(function(M,U){!(g.isUndefined(M)||M===null)&&e.append(o===!0?Ks([w],U,i):o===null?w:w+"[]",u(M))}),!1}return jn(d)?!0:(e.append(Ks(b,w,i),u(d)),!1)}const h=[],p=Object.assign(Zu,{defaultVisitor:l,convertValue:u,isVisitable:jn});function f(d,w){if(!g.isUndefined(d)){if(h.indexOf(d)!==-1)throw Error("Circular reference detected in "+w.join("."));h.push(d),g.forEach(d,function(T,P){(!(g.isUndefined(T)||T===null)&&s.call(e,T,g.isString(P)?P.trim():P,w,p))===!0&&f(T,w?w.concat(P):[P])}),h.pop()}}if(!g.isObject(n))throw new TypeError("data must be an object");return f(n),e}function Xs(n){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g,function(r){return e[r]})}function ds(n,e){this._pairs=[],n&&Qr(n,this,e)}const ao=ds.prototype;ao.append=function(e,t){this._pairs.push([e,t])};ao.toString=function(e){const t=e?function(r){return e.call(this,r,Xs)}:Xs;return this._pairs.map(function(s){return t(s[0])+"="+t(s[1])},"").join("&")};function Yu(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function co(n,e,t){if(!e)return n;const r=t&&t.encode||Yu,s=t&&t.serialize;let i;if(s?i=s(e,t):i=g.isURLSearchParams(e)?e.toString():new ds(e,t).toString(r),i){const o=n.indexOf("#");o!==-1&&(n=n.slice(0,o)),n+=(n.indexOf("?")===-1?"?":"&")+i}return n}class Qu{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){g.forEach(this.handlers,function(r){r!==null&&e(r)})}}const Zs=Qu,uo={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},el=typeof URLSearchParams<"u"?URLSearchParams:ds,tl=typeof FormData<"u"?FormData:null,rl=typeof Blob<"u"?Blob:null,nl=(()=>{let n;return typeof navigator<"u"&&((n=navigator.product)==="ReactNative"||n==="NativeScript"||n==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),sl=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),Pe={isBrowser:!0,classes:{URLSearchParams:el,FormData:tl,Blob:rl},isStandardBrowserEnv:nl,isStandardBrowserWebWorkerEnv:sl,protocols:["http","https","file","blob","url","data"]};function il(n,e){return Qr(n,new Pe.classes.URLSearchParams,Object.assign({visitor:function(t,r,s,i){return Pe.isNode&&g.isBuffer(t)?(this.append(r,t.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},e))}function ol(n){return g.matchAll(/\w+|\[(\w*)]/g,n).map(e=>e[0]==="[]"?"":e[1]||e[0])}function al(n){const e={},t=Object.keys(n);let r;const s=t.length;let i;for(r=0;r<s;r++)i=t[r],e[i]=n[i];return e}function lo(n){function e(t,r,s,i){let o=t[i++];const a=Number.isFinite(+o),c=i>=t.length;return o=!o&&g.isArray(s)?s.length:o,c?(g.hasOwnProp(s,o)?s[o]=[s[o],r]:s[o]=r,!a):((!s[o]||!g.isObject(s[o]))&&(s[o]=[]),e(t,r,s[o],i)&&g.isArray(s[o])&&(s[o]=al(s[o])),!a)}if(g.isFormData(n)&&g.isFunction(n.entries)){const t={};return g.forEachEntry(n,(r,s)=>{e(ol(r),s,t,0)}),t}return null}const cl={"Content-Type":void 0};function ul(n,e,t){if(g.isString(n))try{return(e||JSON.parse)(n),g.trim(n)}catch(r){if(r.name!=="SyntaxError")throw r}return(t||JSON.stringify)(n)}const en={transitional:uo,adapter:["xhr","http"],transformRequest:[function(e,t){const r=t.getContentType()||"",s=r.indexOf("application/json")>-1,i=g.isObject(e);if(i&&g.isHTMLForm(e)&&(e=new FormData(e)),g.isFormData(e))return s&&s?JSON.stringify(lo(e)):e;if(g.isArrayBuffer(e)||g.isBuffer(e)||g.isStream(e)||g.isFile(e)||g.isBlob(e))return e;if(g.isArrayBufferView(e))return e.buffer;if(g.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return il(e,this.formSerializer).toString();if((a=g.isFileList(e))||r.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return Qr(a?{"files[]":e}:e,c&&new c,this.formSerializer)}}return i||s?(t.setContentType("application/json",!1),ul(e)):e}],transformResponse:[function(e){const t=this.transitional||en.transitional,r=t&&t.forcedJSONParsing,s=this.responseType==="json";if(e&&g.isString(e)&&(r&&!this.responseType||s)){const o=!(t&&t.silentJSONParsing)&&s;try{return JSON.parse(e)}catch(a){if(o)throw a.name==="SyntaxError"?N.from(a,N.ERR_BAD_RESPONSE,this,null,this.response):a}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:Pe.classes.FormData,Blob:Pe.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};g.forEach(["delete","get","head"],function(e){en.headers[e]={}});g.forEach(["post","put","patch"],function(e){en.headers[e]=g.merge(cl)});const ps=en,ll=g.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),hl=n=>{const e={};let t,r,s;return n&&n.split(`
2
+ `).forEach(function(o){s=o.indexOf(":"),t=o.substring(0,s).trim().toLowerCase(),r=o.substring(s+1).trim(),!(!t||e[t]&&ll[t])&&(t==="set-cookie"?e[t]?e[t].push(r):e[t]=[r]:e[t]=e[t]?e[t]+", "+r:r)}),e},Ys=Symbol("internals");function Kt(n){return n&&String(n).trim().toLowerCase()}function Rr(n){return n===!1||n==null?n:g.isArray(n)?n.map(Rr):String(n)}function fl(n){const e=Object.create(null),t=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=t.exec(n);)e[r[1]]=r[2];return e}function dl(n){return/^[-_a-zA-Z]+$/.test(n.trim())}function xn(n,e,t,r,s){if(g.isFunction(r))return r.call(this,e,t);if(s&&(e=t),!!g.isString(e)){if(g.isString(r))return e.indexOf(r)!==-1;if(g.isRegExp(r))return r.test(e)}}function pl(n){return n.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,r)=>t.toUpperCase()+r)}function yl(n,e){const t=g.toCamelCase(" "+e);["get","set","has"].forEach(r=>{Object.defineProperty(n,r+t,{value:function(s,i,o){return this[r].call(this,e,s,i,o)},configurable:!0})})}class tn{constructor(e){e&&this.set(e)}set(e,t,r){const s=this;function i(a,c,u){const l=Kt(c);if(!l)throw new Error("header name must be a non-empty string");const h=g.findKey(s,l);(!h||s[h]===void 0||u===!0||u===void 0&&s[h]!==!1)&&(s[h||c]=Rr(a))}const o=(a,c)=>g.forEach(a,(u,l)=>i(u,l,c));return g.isPlainObject(e)||e instanceof this.constructor?o(e,t):g.isString(e)&&(e=e.trim())&&!dl(e)?o(hl(e),t):e!=null&&i(t,e,r),this}get(e,t){if(e=Kt(e),e){const r=g.findKey(this,e);if(r){const s=this[r];if(!t)return s;if(t===!0)return fl(s);if(g.isFunction(t))return t.call(this,s,r);if(g.isRegExp(t))return t.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Kt(e),e){const r=g.findKey(this,e);return!!(r&&this[r]!==void 0&&(!t||xn(this,this[r],r,t)))}return!1}delete(e,t){const r=this;let s=!1;function i(o){if(o=Kt(o),o){const a=g.findKey(r,o);a&&(!t||xn(r,r[a],a,t))&&(delete r[a],s=!0)}}return g.isArray(e)?e.forEach(i):i(e),s}clear(e){const t=Object.keys(this);let r=t.length,s=!1;for(;r--;){const i=t[r];(!e||xn(this,this[i],i,e,!0))&&(delete this[i],s=!0)}return s}normalize(e){const t=this,r={};return g.forEach(this,(s,i)=>{const o=g.findKey(r,i);if(o){t[o]=Rr(s),delete t[i];return}const a=e?pl(i):String(i).trim();a!==i&&delete t[i],t[a]=Rr(s),r[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return g.forEach(this,(r,s)=>{r!=null&&r!==!1&&(t[s]=e&&g.isArray(r)?r.join(", "):r)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join(`
3
+ `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach(s=>r.set(s)),r}static accessor(e){const r=(this[Ys]=this[Ys]={accessors:{}}).accessors,s=this.prototype;function i(o){const a=Kt(o);r[a]||(yl(s,o),r[a]=!0)}return g.isArray(e)?e.forEach(i):i(e),this}}tn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);g.freezeMethods(tn.prototype);g.freezeMethods(tn);const je=tn;function Tn(n,e){const t=this||ps,r=e||t,s=je.from(r.headers);let i=r.data;return g.forEach(n,function(a){i=a.call(t,i,s.normalize(),e?e.status:void 0)}),s.normalize(),i}function ho(n){return!!(n&&n.__CANCEL__)}function yr(n,e,t){N.call(this,n??"canceled",N.ERR_CANCELED,e,t),this.name="CanceledError"}g.inherits(yr,N,{__CANCEL__:!0});function ml(n,e,t){const r=t.config.validateStatus;!t.status||!r||r(t.status)?n(t):e(new N("Request failed with status code "+t.status,[N.ERR_BAD_REQUEST,N.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}const gl=Pe.isStandardBrowserEnv?function(){return{write:function(t,r,s,i,o,a){const c=[];c.push(t+"="+encodeURIComponent(r)),g.isNumber(s)&&c.push("expires="+new Date(s).toGMTString()),g.isString(i)&&c.push("path="+i),g.isString(o)&&c.push("domain="+o),a===!0&&c.push("secure"),document.cookie=c.join("; ")},read:function(t){const r=document.cookie.match(new RegExp("(^|;\\s*)("+t+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(t){this.write(t,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function wl(n){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function bl(n,e){return e?n.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):n}function fo(n,e){return n&&!wl(e)?bl(n,e):e}const vl=Pe.isStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),t=document.createElement("a");let r;function s(i){let o=i;return e&&(t.setAttribute("href",o),o=t.href),t.setAttribute("href",o),{href:t.href,protocol:t.protocol?t.protocol.replace(/:$/,""):"",host:t.host,search:t.search?t.search.replace(/^\?/,""):"",hash:t.hash?t.hash.replace(/^#/,""):"",hostname:t.hostname,port:t.port,pathname:t.pathname.charAt(0)==="/"?t.pathname:"/"+t.pathname}}return r=s(window.location.href),function(o){const a=g.isString(o)?s(o):o;return a.protocol===r.protocol&&a.host===r.host}}():function(){return function(){return!0}}();function _l(n){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return e&&e[1]||""}function El(n,e){n=n||10;const t=new Array(n),r=new Array(n);let s=0,i=0,o;return e=e!==void 0?e:1e3,function(c){const u=Date.now(),l=r[i];o||(o=u),t[s]=c,r[s]=u;let h=i,p=0;for(;h!==s;)p+=t[h++],h=h%n;if(s=(s+1)%n,s===i&&(i=(i+1)%n),u-o<e)return;const f=l&&u-l;return f?Math.round(p*1e3/f):void 0}}function Qs(n,e){let t=0;const r=El(50,250);return s=>{const i=s.loaded,o=s.lengthComputable?s.total:void 0,a=i-t,c=r(a),u=i<=o;t=i;const l={loaded:i,total:o,progress:o?i/o:void 0,bytes:a,rate:c||void 0,estimated:c&&o&&u?(o-i)/c:void 0,event:s};l[e?"download":"upload"]=!0,n(l)}}const xl=typeof XMLHttpRequest<"u",Tl=xl&&function(n){return new Promise(function(t,r){let s=n.data;const i=je.from(n.headers).normalize(),o=n.responseType;let a;function c(){n.cancelToken&&n.cancelToken.unsubscribe(a),n.signal&&n.signal.removeEventListener("abort",a)}g.isFormData(s)&&(Pe.isStandardBrowserEnv||Pe.isStandardBrowserWebWorkerEnv)&&i.setContentType(!1);let u=new XMLHttpRequest;if(n.auth){const f=n.auth.username||"",d=n.auth.password?unescape(encodeURIComponent(n.auth.password)):"";i.set("Authorization","Basic "+btoa(f+":"+d))}const l=fo(n.baseURL,n.url);u.open(n.method.toUpperCase(),co(l,n.params,n.paramsSerializer),!0),u.timeout=n.timeout;function h(){if(!u)return;const f=je.from("getAllResponseHeaders"in u&&u.getAllResponseHeaders()),w={data:!o||o==="text"||o==="json"?u.responseText:u.response,status:u.status,statusText:u.statusText,headers:f,config:n,request:u};ml(function(T){t(T),c()},function(T){r(T),c()},w),u=null}if("onloadend"in u?u.onloadend=h:u.onreadystatechange=function(){!u||u.readyState!==4||u.status===0&&!(u.responseURL&&u.responseURL.indexOf("file:")===0)||setTimeout(h)},u.onabort=function(){u&&(r(new N("Request aborted",N.ECONNABORTED,n,u)),u=null)},u.onerror=function(){r(new N("Network Error",N.ERR_NETWORK,n,u)),u=null},u.ontimeout=function(){let d=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const w=n.transitional||uo;n.timeoutErrorMessage&&(d=n.timeoutErrorMessage),r(new N(d,w.clarifyTimeoutError?N.ETIMEDOUT:N.ECONNABORTED,n,u)),u=null},Pe.isStandardBrowserEnv){const f=(n.withCredentials||vl(l))&&n.xsrfCookieName&&gl.read(n.xsrfCookieName);f&&i.set(n.xsrfHeaderName,f)}s===void 0&&i.setContentType(null),"setRequestHeader"in u&&g.forEach(i.toJSON(),function(d,w){u.setRequestHeader(w,d)}),g.isUndefined(n.withCredentials)||(u.withCredentials=!!n.withCredentials),o&&o!=="json"&&(u.responseType=n.responseType),typeof n.onDownloadProgress=="function"&&u.addEventListener("progress",Qs(n.onDownloadProgress,!0)),typeof n.onUploadProgress=="function"&&u.upload&&u.upload.addEventListener("progress",Qs(n.onUploadProgress)),(n.cancelToken||n.signal)&&(a=f=>{u&&(r(!f||f.type?new yr(null,n,u):f),u.abort(),u=null)},n.cancelToken&&n.cancelToken.subscribe(a),n.signal&&(n.signal.aborted?a():n.signal.addEventListener("abort",a)));const p=_l(l);if(p&&Pe.protocols.indexOf(p)===-1){r(new N("Unsupported protocol "+p+":",N.ERR_BAD_REQUEST,n));return}u.send(s||null)})},Pr={http:Ku,xhr:Tl};g.forEach(Pr,(n,e)=>{if(n){try{Object.defineProperty(n,"name",{value:e})}catch{}Object.defineProperty(n,"adapterName",{value:e})}});const Ol={getAdapter:n=>{n=g.isArray(n)?n:[n];const{length:e}=n;let t,r;for(let s=0;s<e&&(t=n[s],!(r=g.isString(t)?Pr[t.toLowerCase()]:t));s++);if(!r)throw r===!1?new N(`Adapter ${t} is not supported by the environment`,"ERR_NOT_SUPPORT"):new Error(g.hasOwnProp(Pr,t)?`Adapter '${t}' is not available in the build`:`Unknown adapter '${t}'`);if(!g.isFunction(r))throw new TypeError("adapter is not a function");return r},adapters:Pr};function On(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new yr(null,n)}function ei(n){return On(n),n.headers=je.from(n.headers),n.data=Tn.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),Ol.getAdapter(n.adapter||ps.adapter)(n).then(function(r){return On(n),r.data=Tn.call(n,n.transformResponse,r),r.headers=je.from(r.headers),r},function(r){return ho(r)||(On(n),r&&r.response&&(r.response.data=Tn.call(n,n.transformResponse,r.response),r.response.headers=je.from(r.response.headers))),Promise.reject(r)})}const ti=n=>n instanceof je?n.toJSON():n;function zt(n,e){e=e||{};const t={};function r(u,l,h){return g.isPlainObject(u)&&g.isPlainObject(l)?g.merge.call({caseless:h},u,l):g.isPlainObject(l)?g.merge({},l):g.isArray(l)?l.slice():l}function s(u,l,h){if(g.isUndefined(l)){if(!g.isUndefined(u))return r(void 0,u,h)}else return r(u,l,h)}function i(u,l){if(!g.isUndefined(l))return r(void 0,l)}function o(u,l){if(g.isUndefined(l)){if(!g.isUndefined(u))return r(void 0,u)}else return r(void 0,l)}function a(u,l,h){if(h in e)return r(u,l);if(h in n)return r(void 0,u)}const c={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(u,l)=>s(ti(u),ti(l),!0)};return g.forEach(Object.keys(n).concat(Object.keys(e)),function(l){const h=c[l]||s,p=h(n[l],e[l],l);g.isUndefined(p)&&h!==a||(t[l]=p)}),t}const po="1.3.4",ys={};["object","boolean","number","function","string","symbol"].forEach((n,e)=>{ys[n]=function(r){return typeof r===n||"a"+(e<1?"n ":" ")+n}});const ri={};ys.transitional=function(e,t,r){function s(i,o){return"[Axios v"+po+"] Transitional option '"+i+"'"+o+(r?". "+r:"")}return(i,o,a)=>{if(e===!1)throw new N(s(o," has been removed"+(t?" in "+t:"")),N.ERR_DEPRECATED);return t&&!ri[o]&&(ri[o]=!0,console.warn(s(o," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(i,o,a):!0}};function kl(n,e,t){if(typeof n!="object")throw new N("options must be an object",N.ERR_BAD_OPTION_VALUE);const r=Object.keys(n);let s=r.length;for(;s-- >0;){const i=r[s],o=e[i];if(o){const a=n[i],c=a===void 0||o(a,i,n);if(c!==!0)throw new N("option "+i+" must be "+c,N.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new N("Unknown option "+i,N.ERR_BAD_OPTION)}}const Bn={assertOptions:kl,validators:ys},Ge=Bn.validators;class Dr{constructor(e){this.defaults=e,this.interceptors={request:new Zs,response:new Zs}}request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=zt(this.defaults,t);const{transitional:r,paramsSerializer:s,headers:i}=t;r!==void 0&&Bn.assertOptions(r,{silentJSONParsing:Ge.transitional(Ge.boolean),forcedJSONParsing:Ge.transitional(Ge.boolean),clarifyTimeoutError:Ge.transitional(Ge.boolean)},!1),s!==void 0&&Bn.assertOptions(s,{encode:Ge.function,serialize:Ge.function},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let o;o=i&&g.merge(i.common,i[t.method]),o&&g.forEach(["delete","get","head","post","put","patch","common"],d=>{delete i[d]}),t.headers=je.concat(o,i);const a=[];let c=!0;this.interceptors.request.forEach(function(w){typeof w.runWhen=="function"&&w.runWhen(t)===!1||(c=c&&w.synchronous,a.unshift(w.fulfilled,w.rejected))});const u=[];this.interceptors.response.forEach(function(w){u.push(w.fulfilled,w.rejected)});let l,h=0,p;if(!c){const d=[ei.bind(this),void 0];for(d.unshift.apply(d,a),d.push.apply(d,u),p=d.length,l=Promise.resolve(t);h<p;)l=l.then(d[h++],d[h++]);return l}p=a.length;let f=t;for(h=0;h<p;){const d=a[h++],w=a[h++];try{f=d(f)}catch(b){w.call(this,b);break}}try{l=ei.call(this,f)}catch(d){return Promise.reject(d)}for(h=0,p=u.length;h<p;)l=l.then(u[h++],u[h++]);return l}getUri(e){e=zt(this.defaults,e);const t=fo(e.baseURL,e.url);return co(t,e.params,e.paramsSerializer)}}g.forEach(["delete","get","head","options"],function(e){Dr.prototype[e]=function(t,r){return this.request(zt(r||{},{method:e,url:t,data:(r||{}).data}))}});g.forEach(["post","put","patch"],function(e){function t(r){return function(i,o,a){return this.request(zt(a||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}Dr.prototype[e]=t(),Dr.prototype[e+"Form"]=t(!0)});const Nr=Dr;class ms{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(i){t=i});const r=this;this.promise.then(s=>{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](s);r._listeners=null}),this.promise.then=s=>{let i;const o=new Promise(a=>{r.subscribe(a),i=a}).then(s);return o.cancel=function(){r.unsubscribe(i)},o},e(function(i,o,a){r.reason||(r.reason=new yr(i,o,a),t(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}static source(){let e;return{token:new ms(function(s){e=s}),cancel:e}}}const Al=ms;function Sl(n){return function(t){return n.apply(null,t)}}function Rl(n){return g.isObject(n)&&n.isAxiosError===!0}const Hn={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Hn).forEach(([n,e])=>{Hn[e]=n});const Pl=Hn;function yo(n){const e=new Nr(n),t=Ki(Nr.prototype.request,e);return g.extend(t,Nr.prototype,e,{allOwnKeys:!0}),g.extend(t,e,null,{allOwnKeys:!0}),t.create=function(s){return yo(zt(n,s))},t}const V=yo(ps);V.Axios=Nr;V.CanceledError=yr;V.CancelToken=Al;V.isCancel=ho;V.VERSION=po;V.toFormData=Qr;V.AxiosError=N;V.Cancel=V.CanceledError;V.all=function(e){return Promise.all(e)};V.spread=Sl;V.isAxiosError=Rl;V.mergeConfig=zt;V.AxiosHeaders=je;V.formToJSON=n=>lo(g.isHTMLForm(n)?new FormData(n):n);V.HttpStatusCode=Pl;V.default=V;const Nl=V;function Et(n){this._maxSize=n,this.clear()}Et.prototype.clear=function(){this._size=0,this._values=Object.create(null)};Et.prototype.get=function(n){return this._values[n]};Et.prototype.set=function(n,e){return this._size>=this._maxSize&&this.clear(),n in this._values||this._size++,this._values[n]=e};var $l=/[^.^\]^[]+|(?=\[\]|\.\.)/g,mo=/^\d+$/,Cl=/^\d/,Fl=/[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g,Il=/^\s*(['"]?)(.*?)(\1)\s*$/,gs=512,ni=new Et(gs),si=new Et(gs),ii=new Et(gs),pt={Cache:Et,split:Mn,normalizePath:kn,setter:function(n){var e=kn(n);return si.get(n)||si.set(n,function(r,s){for(var i=0,o=e.length,a=r;i<o-1;){var c=e[i];if(c==="__proto__"||c==="constructor"||c==="prototype")return r;a=a[e[i++]]}a[e[i]]=s})},getter:function(n,e){var t=kn(n);return ii.get(n)||ii.set(n,function(s){for(var i=0,o=t.length;i<o;)if(s!=null||!e)s=s[t[i++]];else return;return s})},join:function(n){return n.reduce(function(e,t){return e+(ws(t)||mo.test(t)?"["+t+"]":(e?".":"")+t)},"")},forEach:function(n,e,t){Dl(Array.isArray(n)?n:Mn(n),e,t)}};function kn(n){return ni.get(n)||ni.set(n,Mn(n).map(function(e){return e.replace(Il,"$2")}))}function Mn(n){return n.match($l)||[""]}function Dl(n,e,t){var r=n.length,s,i,o,a;for(i=0;i<r;i++)s=n[i],s&&(jl(s)&&(s='"'+s+'"'),a=ws(s),o=!a&&/^\d+$/.test(s),e.call(t,s,a,o,i,n))}function ws(n){return typeof n=="string"&&n&&["'",'"'].indexOf(n.charAt(0))!==-1}function Ul(n){return n.match(Cl)&&!n.match(mo)}function Ll(n){return Fl.test(n)}function jl(n){return!ws(n)&&(Ul(n)||Ll(n))}const Bl=/[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g,rn=n=>n.match(Bl)||[],nn=n=>n[0].toUpperCase()+n.slice(1),bs=(n,e)=>rn(n).join(e).toLowerCase(),go=n=>rn(n).reduce((e,t)=>`${e}${e?t[0].toUpperCase()+t.slice(1).toLowerCase():t.toLowerCase()}`,""),Hl=n=>nn(go(n)),Ml=n=>bs(n,"_"),zl=n=>bs(n,"-"),Vl=n=>nn(bs(n," ")),ql=n=>rn(n).map(nn).join(" ");var An={words:rn,upperFirst:nn,camelCase:go,pascalCase:Hl,snakeCase:Ml,kebabCase:zl,sentenceCase:Vl,titleCase:ql},Ur={},Jl={get exports(){return Ur},set exports(n){Ur=n}};Jl.exports=function(n){return wo(Gl(n),n)};Ur.array=wo;function wo(n,e){var t=n.length,r=new Array(t),s={},i=t,o=Wl(e),a=Kl(n);for(e.forEach(function(u){if(!a.has(u[0])||!a.has(u[1]))throw new Error("Unknown node. There is an unknown node in the supplied edges.")});i--;)s[i]||c(n[i],i,new Set);return r;function c(u,l,h){if(h.has(u)){var p;try{p=", node was:"+JSON.stringify(u)}catch{p=""}throw new Error("Cyclic dependency"+p)}if(!a.has(u))throw new Error("Found unknown node. Make sure to provided all involved nodes. Unknown node: "+JSON.stringify(u));if(!s[l]){s[l]=!0;var f=o.get(u)||new Set;if(f=Array.from(f),l=f.length){h.add(u);do{var d=f[--l];c(d,a.get(d),h)}while(l);h.delete(u)}r[--t]=u}}}function Gl(n){for(var e=new Set,t=0,r=n.length;t<r;t++){var s=n[t];e.add(s[0]),e.add(s[1])}return Array.from(e)}function Wl(n){for(var e=new Map,t=0,r=n.length;t<r;t++){var s=n[t];e.has(s[0])||e.set(s[0],new Set),e.has(s[1])||e.set(s[1],new Set),e.get(s[0]).add(s[1])}return e}function Kl(n){for(var e=new Map,t=0,r=n.length;t<r;t++)e.set(n[t],t);return e}const Xl=Object.prototype.toString,Zl=Error.prototype.toString,Yl=RegExp.prototype.toString,Ql=typeof Symbol<"u"?Symbol.prototype.toString:()=>"",eh=/^Symbol\((.*)\)(.*)$/;function th(n){return n!=+n?"NaN":n===0&&1/n<0?"-0":""+n}function oi(n,e=!1){if(n==null||n===!0||n===!1)return""+n;const t=typeof n;if(t==="number")return th(n);if(t==="string")return e?`"${n}"`:n;if(t==="function")return"[Function "+(n.name||"anonymous")+"]";if(t==="symbol")return Ql.call(n).replace(eh,"Symbol($1)");const r=Xl.call(n).slice(8,-1);return r==="Date"?isNaN(n.getTime())?""+n:n.toISOString(n):r==="Error"||n instanceof Error?"["+Zl.call(n)+"]":r==="RegExp"?Yl.call(n):null}function yt(n,e){let t=oi(n,e);return t!==null?t:JSON.stringify(n,function(r,s){let i=oi(this[r],e);return i!==null?i:s},2)}function bo(n){return n==null?[]:[].concat(n)}let rh=/\$\{\s*(\w+)\s*\}/g;class ue extends Error{static formatError(e,t){const r=t.label||t.path||"this";return r!==t.path&&(t=Object.assign({},t,{path:r})),typeof e=="string"?e.replace(rh,(s,i)=>yt(t[i])):typeof e=="function"?e(t):e}static isError(e){return e&&e.name==="ValidationError"}constructor(e,t,r,s){super(),this.value=void 0,this.path=void 0,this.type=void 0,this.errors=void 0,this.params=void 0,this.inner=void 0,this.name="ValidationError",this.value=t,this.path=r,this.type=s,this.errors=[],this.inner=[],bo(e).forEach(i=>{ue.isError(i)?(this.errors.push(...i.errors),this.inner=this.inner.concat(i.inner.length?i.inner:i)):this.errors.push(i)}),this.message=this.errors.length>1?`${this.errors.length} errors occurred`:this.errors[0],Error.captureStackTrace&&Error.captureStackTrace(this,ue)}}let $e={default:"${path} is invalid",required:"${path} is a required field",defined:"${path} must be defined",notNull:"${path} cannot be null",oneOf:"${path} must be one of the following values: ${values}",notOneOf:"${path} must not be one of the following values: ${values}",notType:({path:n,type:e,value:t,originalValue:r})=>{const s=r!=null&&r!==t?` (cast from the value \`${yt(r,!0)}\`).`:".";return e!=="mixed"?`${n} must be a \`${e}\` type, but the final value was: \`${yt(t,!0)}\``+s:`${n} must match the configured type. The validated value was: \`${yt(t,!0)}\``+s}},me={length:"${path} must be exactly ${length} characters",min:"${path} must be at least ${min} characters",max:"${path} must be at most ${max} characters",matches:'${path} must match the following: "${regex}"',email:"${path} must be a valid email",url:"${path} must be a valid URL",uuid:"${path} must be a valid UUID",trim:"${path} must be a trimmed string",lowercase:"${path} must be a lowercase string",uppercase:"${path} must be a upper case string"},We={min:"${path} must be greater than or equal to ${min}",max:"${path} must be less than or equal to ${max}",lessThan:"${path} must be less than ${less}",moreThan:"${path} must be greater than ${more}",positive:"${path} must be a positive number",negative:"${path} must be a negative number",integer:"${path} must be an integer"},zn={min:"${path} field must be later than ${min}",max:"${path} field must be at earlier than ${max}"},Vn={isValue:"${path} field must be ${value}"},qn={noUnknown:"${path} field has unspecified keys: ${unknown}"},$r={min:"${path} field must have at least ${min} items",max:"${path} field must have less than or equal to ${max} items",length:"${path} must have ${length} items"};Object.assign(Object.create(null),{mixed:$e,string:me,number:We,date:zn,object:qn,array:$r,boolean:Vn});const sn=n=>n&&n.__isYupSchema__;class Lr{static fromOptions(e,t){if(!t.then&&!t.otherwise)throw new TypeError("either `then:` or `otherwise:` is required for `when()` conditions");let{is:r,then:s,otherwise:i}=t,o=typeof r=="function"?r:(...a)=>a.every(c=>c===r);return new Lr(e,(a,c)=>{var u;let l=o(...a)?s:i;return(u=l==null?void 0:l(c))!=null?u:c})}constructor(e,t){this.fn=void 0,this.refs=e,this.refs=e,this.fn=t}resolve(e,t){let r=this.refs.map(i=>i.getValue(t==null?void 0:t.value,t==null?void 0:t.parent,t==null?void 0:t.context)),s=this.fn(r,e,t);if(s===void 0||s===e)return e;if(!sn(s))throw new TypeError("conditions must return a schema object");return s.resolve(t)}}const Er={context:"$",value:"."};class xt{constructor(e,t={}){if(this.key=void 0,this.isContext=void 0,this.isValue=void 0,this.isSibling=void 0,this.path=void 0,this.getter=void 0,this.map=void 0,typeof e!="string")throw new TypeError("ref must be a string, got: "+e);if(this.key=e.trim(),e==="")throw new TypeError("ref must be a non-empty string");this.isContext=this.key[0]===Er.context,this.isValue=this.key[0]===Er.value,this.isSibling=!this.isContext&&!this.isValue;let r=this.isContext?Er.context:this.isValue?Er.value:"";this.path=this.key.slice(r.length),this.getter=this.path&&pt.getter(this.path,!0),this.map=t.map}getValue(e,t,r){let s=this.isContext?r:this.isValue?e:t;return this.getter&&(s=this.getter(s||{})),this.map&&(s=this.map(s)),s}cast(e,t){return this.getValue(e,t==null?void 0:t.parent,t==null?void 0:t.context)}resolve(){return this}describe(){return{type:"ref",key:this.key}}toString(){return`Ref(${this.key})`}static isRef(e){return e&&e.__isYupRef}}xt.prototype.__isYupRef=!0;const pe=n=>n==null;function St(n){function e({value:t,path:r="",options:s,originalValue:i,schema:o},a,c){const{name:u,test:l,params:h,message:p,skipAbsent:f}=n;let{parent:d,context:w,abortEarly:b=o.spec.abortEarly}=s;function T(H){return xt.isRef(H)?H.getValue(t,d,w):H}function P(H={}){const J=Object.assign({value:t,originalValue:i,label:o.spec.label,path:H.path||r,spec:o.spec},h,H.params);for(const kt of Object.keys(J))J[kt]=T(J[kt]);const br=new ue(ue.formatError(H.message||p,J),t,J.path,H.type||u);return br.params=J,br}const M=b?a:c;let U={path:r,parent:d,type:u,from:s.from,createError:P,resolve:T,options:s,originalValue:i,schema:o};const Ee=H=>{ue.isError(H)?M(H):H?c(null):M(P())},Jt=H=>{ue.isError(H)?M(H):a(H)},gr=f&&pe(t);if(!s.sync){try{Promise.resolve(gr?!0:l.call(U,t,U)).then(Ee,Jt)}catch(H){Jt(H)}return}let ye;try{var wr;if(ye=gr?!0:l.call(U,t,U),typeof((wr=ye)==null?void 0:wr.then)=="function")throw new Error(`Validation test of type: "${U.type}" returned a Promise during a synchronous validate. This test will finish after the validate call has returned`)}catch(H){Jt(H);return}Ee(ye)}return e.OPTIONS=n,e}function nh(n,e,t,r=t){let s,i,o;return e?(pt.forEach(e,(a,c,u)=>{let l=c?a.slice(1,a.length-1):a;n=n.resolve({context:r,parent:s,value:t});let h=n.type==="tuple",p=u?parseInt(l,10):0;if(n.innerType||h){if(h&&!u)throw new Error(`Yup.reach cannot implicitly index into a tuple type. the path part "${o}" must contain an index to the tuple element, e.g. "${o}[0]"`);if(t&&p>=t.length)throw new Error(`Yup.reach cannot resolve an array item at index: ${a}, in the path: ${e}. because there is no value at that index. `);s=t,t=t&&t[p],n=h?n.spec.types[p]:n.innerType}if(!u){if(!n.fields||!n.fields[l])throw new Error(`The schema does not contain the path: ${e}. (failed at: ${o} which is a type: "${n.type}")`);s=t,t=t&&t[l],n=n.fields[l]}i=l,o=c?"["+a+"]":"."+a}),{schema:n,parent:s,parentPath:i}):{parent:s,parentPath:e,schema:n}}class jr extends Set{describe(){const e=[];for(const t of this.values())e.push(xt.isRef(t)?t.describe():t);return e}resolveAll(e){let t=[];for(const r of this.values())t.push(e(r));return t}clone(){return new jr(this.values())}merge(e,t){const r=this.clone();return e.forEach(s=>r.add(s)),t.forEach(s=>r.delete(s)),r}}function Ct(n,e=new Map){if(sn(n)||!n||typeof n!="object")return n;if(e.has(n))return e.get(n);let t;if(n instanceof Date)t=new Date(n.getTime()),e.set(n,t);else if(n instanceof RegExp)t=new RegExp(n),e.set(n,t);else if(Array.isArray(n)){t=new Array(n.length),e.set(n,t);for(let r=0;r<n.length;r++)t[r]=Ct(n[r],e)}else if(n instanceof Map){t=new Map,e.set(n,t);for(const[r,s]of n.entries())t.set(r,Ct(s,e))}else if(n instanceof Set){t=new Set,e.set(n,t);for(const r of n)t.add(Ct(r,e))}else if(n instanceof Object){t={},e.set(n,t);for(const[r,s]of Object.entries(n))t[r]=Ct(s,e)}else throw Error(`Unable to clone ${n}`);return t}class se{constructor(e){this.type=void 0,this.deps=[],this.tests=void 0,this.transforms=void 0,this.conditions=[],this._mutate=void 0,this.internalTests={},this._whitelist=new jr,this._blacklist=new jr,this.exclusiveTests=Object.create(null),this._typeCheck=void 0,this.spec=void 0,this.tests=[],this.transforms=[],this.withMutation(()=>{this.typeError($e.notType)}),this.type=e.type,this._typeCheck=e.check,this.spec=Object.assign({strip:!1,strict:!1,abortEarly:!0,recursive:!0,nullable:!1,optional:!0,coerce:!0},e==null?void 0:e.spec),this.withMutation(t=>{t.nonNullable()})}get _type(){return this.type}clone(e){if(this._mutate)return e&&Object.assign(this.spec,e),this;const t=Object.create(Object.getPrototypeOf(this));return t.type=this.type,t._typeCheck=this._typeCheck,t._whitelist=this._whitelist.clone(),t._blacklist=this._blacklist.clone(),t.internalTests=Object.assign({},this.internalTests),t.exclusiveTests=Object.assign({},this.exclusiveTests),t.deps=[...this.deps],t.conditions=[...this.conditions],t.tests=[...this.tests],t.transforms=[...this.transforms],t.spec=Ct(Object.assign({},this.spec,e)),t}label(e){let t=this.clone();return t.spec.label=e,t}meta(...e){if(e.length===0)return this.spec.meta;let t=this.clone();return t.spec.meta=Object.assign(t.spec.meta||{},e[0]),t}withMutation(e){let t=this._mutate;this._mutate=!0;let r=e(this);return this._mutate=t,r}concat(e){if(!e||e===this)return this;if(e.type!==this.type&&this.type!=="mixed")throw new TypeError(`You cannot \`concat()\` schema's of different types: ${this.type} and ${e.type}`);let t=this,r=e.clone();const s=Object.assign({},t.spec,r.spec);return r.spec=s,r.internalTests=Object.assign({},t.internalTests,r.internalTests),r._whitelist=t._whitelist.merge(e._whitelist,e._blacklist),r._blacklist=t._blacklist.merge(e._blacklist,e._whitelist),r.tests=t.tests,r.exclusiveTests=t.exclusiveTests,r.withMutation(i=>{e.tests.forEach(o=>{i.test(o.OPTIONS)})}),r.transforms=[...t.transforms,...r.transforms],r}isType(e){return e==null?!!(this.spec.nullable&&e===null||this.spec.optional&&e===void 0):this._typeCheck(e)}resolve(e){let t=this;if(t.conditions.length){let r=t.conditions;t=t.clone(),t.conditions=[],t=r.reduce((s,i)=>i.resolve(s,e),t),t=t.resolve(e)}return t}resolveOptions(e){var t,r,s;return Object.assign({},e,{from:e.from||[],strict:(t=e.strict)!=null?t:this.spec.strict,abortEarly:(r=e.abortEarly)!=null?r:this.spec.abortEarly,recursive:(s=e.recursive)!=null?s:this.spec.recursive})}cast(e,t={}){let r=this.resolve(Object.assign({value:e},t)),s=t.assert==="ignore-optionality",i=r._cast(e,t);if(t.assert!==!1&&!r.isType(i)){if(s&&pe(i))return i;let o=yt(e),a=yt(i);throw new TypeError(`The value of ${t.path||"field"} could not be cast to a value that satisfies the schema type: "${r.type}".
4
4
 
5
5
  attempted value: ${o}
6
- `+(a!==o?`result of cast: ${a}`:""))}return i}_cast(e,t){let r=e===void 0?e:this.transforms.reduce((s,i)=>i.call(this,s,e,this),e);return r===void 0&&(r=this.getDefault()),r}_validate(e,t={},r,s){let{path:i,originalValue:o=e,strict:a=this.spec.strict}=t,c=e;a||(c=this._cast(c,Object.assign({assert:!1},t)));let u=[];for(let l of Object.values(this.internalTests))l&&u.push(l);this.runTests({path:i,value:c,originalValue:o,options:t,tests:u},r,l=>{if(l.length)return s(l,c);this.runTests({path:i,value:c,originalValue:o,options:t,tests:this.tests},r,s)})}runTests(e,t,r){let s=!1,{tests:i,value:o,originalValue:a,path:c,options:u}=e,l=w=>{s||(s=!0,t(w,o))},h=w=>{s||(s=!0,r(w,o))},p=i.length,f=[];if(!p)return h([]);let d={value:o,originalValue:a,path:c,options:u,schema:this};for(let w=0;w<i.length;w++){const b=i[w];b(d,l,function(P){P&&(f=f.concat(P)),--p<=0&&h(f)})}}asNestedTest({key:e,index:t,parent:r,parentPath:s,originalParent:i,options:o}){const a=e??t;if(a==null)throw TypeError("Must include `key` or `index` for nested validations");const c=typeof a=="number";let u=r[a];const l=Object.assign({},o,{strict:!0,parent:r,value:u,originalValue:i[a],key:void 0,[c?"index":"key"]:a,path:c||a.includes(".")?`${s||""}[${u?a:`"${a}"`}]`:(s?`${s}.`:"")+e});return(h,p,f)=>this.resolve(l)._validate(u,l,p,f)}validate(e,t){let r=this.resolve(Object.assign({},t,{value:e}));return new Promise((s,i)=>r._validate(e,t,(o,a)=>{ce.isError(o)&&(o.value=a),i(o)},(o,a)=>{o.length?i(new ce(o,a)):s(a)}))}validateSync(e,t){let r=this.resolve(Object.assign({},t,{value:e})),s;return r._validate(e,Object.assign({},t,{sync:!0}),(i,o)=>{throw ce.isError(i)&&(i.value=o),i},(i,o)=>{if(i.length)throw new ce(i,e);s=o}),s}isValid(e,t){return this.validate(e,t).then(()=>!0,r=>{if(ce.isError(r))return!1;throw r})}isValidSync(e,t){try{return this.validateSync(e,t),!0}catch(r){if(ce.isError(r))return!1;throw r}}_getDefault(){let e=this.spec.default;return e==null?e:typeof e=="function"?e.call(this):$t(e)}getDefault(e){return this.resolve(e||{})._getDefault()}default(e){return arguments.length===0?this._getDefault():this.clone({default:e})}strict(e=!0){return this.clone({strict:e})}nullability(e,t){const r=this.clone({nullable:e});return r.internalTests.nullable=At({message:t,name:"nullable",test(s){return s===null?this.schema.spec.nullable:!0}}),r}optionality(e,t){const r=this.clone({optional:e});return r.internalTests.optionality=At({message:t,name:"optionality",test(s){return s===void 0?this.schema.spec.optional:!0}}),r}optional(){return this.optionality(!0)}defined(e=$e.defined){return this.optionality(!1,e)}nullable(){return this.nullability(!0)}nonNullable(e=$e.notNull){return this.nullability(!1,e)}required(e=$e.required){return this.clone().withMutation(t=>t.nonNullable(e).defined(e))}notRequired(){return this.clone().withMutation(e=>e.nullable().optional())}transform(e){let t=this.clone();return t.transforms.push(e),t}test(...e){let t;if(e.length===1?typeof e[0]=="function"?t={test:e[0]}:t=e[0]:e.length===2?t={name:e[0],test:e[1]}:t={name:e[0],message:e[1],test:e[2]},t.message===void 0&&(t.message=$e.default),typeof t.test!="function")throw new TypeError("`test` is a required parameters");let r=this.clone(),s=At(t),i=t.exclusive||t.name&&r.exclusiveTests[t.name]===!0;if(t.exclusive&&!t.name)throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");return t.name&&(r.exclusiveTests[t.name]=!!t.exclusive),r.tests=r.tests.filter(o=>!(o.OPTIONS.name===t.name&&(i||o.OPTIONS.test===s.OPTIONS.test))),r.tests.push(s),r}when(e,t){!Array.isArray(e)&&typeof e!="string"&&(t=e,e=".");let r=this.clone(),s=bo(e).map(i=>new xt(i));return s.forEach(i=>{i.isSibling&&r.deps.push(i.key)}),r.conditions.push(typeof t=="function"?new Lr(s,t):Lr.fromOptions(s,t)),r}typeError(e){let t=this.clone();return t.internalTests.typeError=At({message:e,name:"typeError",test(r){return!pe(r)&&!this.schema._typeCheck(r)?this.createError({params:{type:this.schema.type}}):!0}}),t}oneOf(e,t=$e.oneOf){let r=this.clone();return e.forEach(s=>{r._whitelist.add(s),r._blacklist.delete(s)}),r.internalTests.whiteList=At({message:t,name:"oneOf",skipAbsent:!0,test(s){let i=this.schema._whitelist,o=i.resolveAll(this.resolve);return o.includes(s)?!0:this.createError({params:{values:Array.from(i).join(", "),resolved:o}})}}),r}notOneOf(e,t=$e.notOneOf){let r=this.clone();return e.forEach(s=>{r._blacklist.add(s),r._whitelist.delete(s)}),r.internalTests.blacklist=At({message:t,name:"notOneOf",test(s){let i=this.schema._blacklist,o=i.resolveAll(this.resolve);return o.includes(s)?this.createError({params:{values:Array.from(i).join(", "),resolved:o}}):!0}}),r}strip(e=!0){let t=this.clone();return t.spec.strip=e,t}describe(e){const t=(e?this.resolve(e):this).clone(),{label:r,meta:s,optional:i,nullable:o}=t.spec;return{meta:s,label:r,optional:i,nullable:o,default:t.getDefault(e),type:t.type,oneOf:t._whitelist.describe(),notOneOf:t._blacklist.describe(),tests:t.tests.map(c=>({name:c.OPTIONS.name,params:c.OPTIONS.params})).filter((c,u,l)=>l.findIndex(h=>h.name===c.name)===u)}}}se.prototype.__isYupSchema__=!0;for(const n of["validate","validateSync"])se.prototype[`${n}At`]=function(e,t,r={}){const{parent:s,parentPath:i,schema:o}=rh(this,e,t,r.context);return o[n](s&&s[i],Object.assign({},r,{parent:s,path:e}))};for(const n of["equals","is"])se.prototype[n]=se.prototype.oneOf;for(const n of["not","nope"])se.prototype[n]=se.prototype.notOneOf;const nh=()=>!0;function vo(n){return new _o(n)}class _o extends se{constructor(e){super(typeof e=="function"?{type:"mixed",check:e}:Object.assign({type:"mixed",check:nh},e))}}vo.prototype=_o.prototype;function gs(){return new Eo}class Eo extends se{constructor(){super({type:"boolean",check(e){return e instanceof Boolean&&(e=e.valueOf()),typeof e=="boolean"}}),this.withMutation(()=>{this.transform((e,t,r)=>{if(r.spec.coerce&&!r.isType(e)){if(/^(true|1)$/i.test(String(e)))return!0;if(/^(false|0)$/i.test(String(e)))return!1}return e})})}isTrue(e=Hn.isValue){return this.test({message:e,name:"is-value",exclusive:!0,params:{value:"true"},test(t){return pe(t)||t===!0}})}isFalse(e=Hn.isValue){return this.test({message:e,name:"is-value",exclusive:!0,params:{value:"false"},test(t){return pe(t)||t===!1}})}default(e){return super.default(e)}defined(e){return super.defined(e)}optional(){return super.optional()}required(e){return super.required(e)}notRequired(){return super.notRequired()}nullable(){return super.nullable()}nonNullable(e){return super.nonNullable(e)}strip(e){return super.strip(e)}}gs.prototype=Eo.prototype;let sh=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,ih=/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,oh=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,ah=n=>pe(n)||n===n.trim(),ch={}.toString();function A(){return new xo}class xo extends se{constructor(){super({type:"string",check(e){return e instanceof String&&(e=e.valueOf()),typeof e=="string"}}),this.withMutation(()=>{this.transform((e,t,r)=>{if(!r.spec.coerce||r.isType(e)||Array.isArray(e))return e;const s=e!=null&&e.toString?e.toString():e;return s===ch?e:s})})}required(e){return super.required(e).withMutation(t=>t.test({message:e||$e.required,name:"required",skipAbsent:!0,test:r=>!!r.length}))}notRequired(){return super.notRequired().withMutation(e=>(e.tests=e.tests.filter(t=>t.OPTIONS.name!=="required"),e))}length(e,t=me.length){return this.test({message:t,name:"length",exclusive:!0,params:{length:e},skipAbsent:!0,test(r){return r.length===this.resolve(e)}})}min(e,t=me.min){return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(r){return r.length>=this.resolve(e)}})}max(e,t=me.max){return this.test({name:"max",exclusive:!0,message:t,params:{max:e},skipAbsent:!0,test(r){return r.length<=this.resolve(e)}})}matches(e,t){let r=!1,s,i;return t&&(typeof t=="object"?{excludeEmptyString:r=!1,message:s,name:i}=t:s=t),this.test({name:i||"matches",message:s||me.matches,params:{regex:e},skipAbsent:!0,test:o=>o===""&&r||o.search(e)!==-1})}email(e=me.email){return this.matches(sh,{name:"email",message:e,excludeEmptyString:!0})}url(e=me.url){return this.matches(ih,{name:"url",message:e,excludeEmptyString:!0})}uuid(e=me.uuid){return this.matches(oh,{name:"uuid",message:e,excludeEmptyString:!1})}ensure(){return this.default("").transform(e=>e===null?"":e)}trim(e=me.trim){return this.transform(t=>t!=null?t.trim():t).test({message:e,name:"trim",test:ah})}lowercase(e=me.lowercase){return this.transform(t=>pe(t)?t:t.toLowerCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:t=>pe(t)||t===t.toLowerCase()})}uppercase(e=me.uppercase){return this.transform(t=>pe(t)?t:t.toUpperCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:t=>pe(t)||t===t.toUpperCase()})}}A.prototype=xo.prototype;let uh=n=>n!=+n;function K(){return new Oo}class Oo extends se{constructor(){super({type:"number",check(e){return e instanceof Number&&(e=e.valueOf()),typeof e=="number"&&!uh(e)}}),this.withMutation(()=>{this.transform((e,t,r)=>{if(!r.spec.coerce)return e;let s=e;if(typeof s=="string"){if(s=s.replace(/\s/g,""),s==="")return NaN;s=+s}return r.isType(s)?s:parseFloat(s)})})}min(e,t=We.min){return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(r){return r>=this.resolve(e)}})}max(e,t=We.max){return this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(r){return r<=this.resolve(e)}})}lessThan(e,t=We.lessThan){return this.test({message:t,name:"max",exclusive:!0,params:{less:e},skipAbsent:!0,test(r){return r<this.resolve(e)}})}moreThan(e,t=We.moreThan){return this.test({message:t,name:"min",exclusive:!0,params:{more:e},skipAbsent:!0,test(r){return r>this.resolve(e)}})}positive(e=We.positive){return this.moreThan(0,e)}negative(e=We.negative){return this.lessThan(0,e)}integer(e=We.integer){return this.test({name:"integer",message:e,skipAbsent:!0,test:t=>Number.isInteger(t)})}truncate(){return this.transform(e=>pe(e)?e:e|0)}round(e){var t;let r=["ceil","floor","round","trunc"];if(e=((t=e)==null?void 0:t.toLowerCase())||"round",e==="trunc")return this.truncate();if(r.indexOf(e.toLowerCase())===-1)throw new TypeError("Only valid options for round() are: "+r.join(", "));return this.transform(s=>pe(s)?s:Math[e](s))}}K.prototype=Oo.prototype;var lh=/^(\d{4}|[+\-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,\.](\d{1,}))?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?)?)?$/;function hh(n){var e=[1,4,5,6,7,10,11],t=0,r,s;if(s=lh.exec(n)){for(var i=0,o;o=e[i];++i)s[o]=+s[o]||0;s[2]=(+s[2]||1)-1,s[3]=+s[3]||1,s[7]=s[7]?String(s[7]).substr(0,3):0,(s[8]===void 0||s[8]==="")&&(s[9]===void 0||s[9]==="")?r=+new Date(s[1],s[2],s[3],s[4],s[5],s[6],s[7]):(s[8]!=="Z"&&s[9]!==void 0&&(t=s[10]*60+s[11],s[9]==="+"&&(t=0-t)),r=Date.UTC(s[1],s[2],s[3],s[4],s[5]+t,s[6],s[7]))}else r=Date.parse?Date.parse(n):NaN;return r}let fh=new Date(""),dh=n=>Object.prototype.toString.call(n)==="[object Date]";class on extends se{constructor(){super({type:"date",check(e){return dh(e)&&!isNaN(e.getTime())}}),this.withMutation(()=>{this.transform((e,t,r)=>!r.spec.coerce||r.isType(e)?e:(e=hh(e),isNaN(e)?on.INVALID_DATE:new Date(e)))})}prepareParam(e,t){let r;if(xt.isRef(e))r=e;else{let s=this.cast(e);if(!this._typeCheck(s))throw new TypeError(`\`${t}\` must be a Date or a value that can be \`cast()\` to a Date`);r=s}return r}min(e,t=Bn.min){let r=this.prepareParam(e,"min");return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(s){return s>=this.resolve(r)}})}max(e,t=Bn.max){let r=this.prepareParam(e,"max");return this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(s){return s<=this.resolve(r)}})}}on.INVALID_DATE=fh;on.prototype;function ph(n,e=[]){let t=[],r=new Set,s=new Set(e.map(([o,a])=>`${o}-${a}`));function i(o,a){let c=pt.split(o)[0];r.add(c),s.has(`${a}-${c}`)||t.push([a,c])}for(const o of Object.keys(n)){let a=n[o];r.add(o),xt.isRef(a)&&a.isSibling?i(a.path,o):sn(a)&&"deps"in a&&a.deps.forEach(c=>i(c,o))}return Ur.array(Array.from(r),t).reverse()}function ii(n,e){let t=1/0;return n.some((r,s)=>{var i;if((i=e.path)!=null&&i.includes(r))return t=s,!0}),t}function To(n){return(e,t)=>ii(n,e)-ii(n,t)}const So=(n,e,t)=>{if(typeof n!="string")return n;let r=n;try{r=JSON.parse(n)}catch{}return t.isType(r)?r:n};function $r(n){if("fields"in n){const e={};for(const[t,r]of Object.entries(n.fields))e[t]=$r(r);return n.setFields(e)}if(n.type==="array"){const e=n.optional();return e.innerType&&(e.innerType=$r(e.innerType)),e}return n.type==="tuple"?n.optional().clone({types:n.spec.types.map($r)}):"optional"in n?n.optional():n}const yh=(n,e)=>{const t=[...pt.normalizePath(e)];if(t.length===1)return t[0]in n;let r=t.pop(),s=pt.getter(pt.join(t),!0)(n);return!!(s&&r in s)};let oi=n=>Object.prototype.toString.call(n)==="[object Object]";function mh(n,e){let t=Object.keys(n.fields);return Object.keys(e).filter(r=>t.indexOf(r)===-1)}const gh=To([]);function ue(n){return new Ao(n)}class Ao extends se{constructor(e){super({type:"object",check(t){return oi(t)||typeof t=="function"}}),this.fields=Object.create(null),this._sortErrors=gh,this._nodes=[],this._excludedEdges=[],this.withMutation(()=>{e&&this.shape(e)})}_cast(e,t={}){var r;let s=super._cast(e,t);if(s===void 0)return this.getDefault();if(!this._typeCheck(s))return s;let i=this.fields,o=(r=t.stripUnknown)!=null?r:this.spec.noUnknown,a=[].concat(this._nodes,Object.keys(s).filter(h=>!this._nodes.includes(h))),c={},u=Object.assign({},t,{parent:c,__validating:t.__validating||!1}),l=!1;for(const h of a){let p=i[h],f=h in s;if(p){let d,w=s[h];u.path=(t.path?`${t.path}.`:"")+h,p=p.resolve({value:w,context:t.context,parent:c});let b=p instanceof se?p.spec:void 0,O=b==null?void 0:b.strict;if(b!=null&&b.strip){l=l||h in s;continue}d=!t.__validating||!O?p.cast(s[h],u):s[h],d!==void 0&&(c[h]=d)}else f&&!o&&(c[h]=s[h]);(f!==h in c||c[h]!==s[h])&&(l=!0)}return l?c:s}_validate(e,t={},r,s){let{from:i=[],originalValue:o=e,recursive:a=this.spec.recursive}=t;t.from=[{schema:this,value:o},...i],t.__validating=!0,t.originalValue=o,super._validate(e,t,r,(c,u)=>{if(!a||!oi(u)){s(c,u);return}o=o||u;let l=[];for(let h of this._nodes){let p=this.fields[h];!p||xt.isRef(p)||l.push(p.asNestedTest({options:t,key:h,parent:u,parentPath:t.path,originalParent:o}))}this.runTests({tests:l,value:u,originalValue:o,options:t},r,h=>{s(h.sort(this._sortErrors).concat(c),u)})})}clone(e){const t=super.clone(e);return t.fields=Object.assign({},this.fields),t._nodes=this._nodes,t._excludedEdges=this._excludedEdges,t._sortErrors=this._sortErrors,t}concat(e){let t=super.concat(e),r=t.fields;for(let[s,i]of Object.entries(this.fields)){const o=r[s];r[s]=o===void 0?i:o}return t.withMutation(s=>s.setFields(r,this._excludedEdges))}_getDefault(){if("default"in this.spec)return super._getDefault();if(!this._nodes.length)return;let e={};return this._nodes.forEach(t=>{const r=this.fields[t];e[t]=r&&"getDefault"in r?r.getDefault():void 0}),e}setFields(e,t){let r=this.clone();return r.fields=e,r._nodes=ph(e,t),r._sortErrors=To(Object.keys(e)),t&&(r._excludedEdges=t),r}shape(e,t=[]){return this.clone().withMutation(r=>{let s=r._excludedEdges;return t.length&&(Array.isArray(t[0])||(t=[t]),s=[...r._excludedEdges,...t]),r.setFields(Object.assign(r.fields,e),s)})}partial(){const e={};for(const[t,r]of Object.entries(this.fields))e[t]="optional"in r&&r.optional instanceof Function?r.optional():r;return this.setFields(e)}deepPartial(){return $r(this)}pick(e){const t={};for(const r of e)this.fields[r]&&(t[r]=this.fields[r]);return this.setFields(t)}omit(e){const t=Object.assign({},this.fields);for(const r of e)delete t[r];return this.setFields(t)}from(e,t,r){let s=pt.getter(e,!0);return this.transform(i=>{if(!i)return i;let o=i;return yh(i,e)&&(o=Object.assign({},i),r||delete o[e],o[t]=s(i)),o})}json(){return this.transform(So)}noUnknown(e=!0,t=Mn.noUnknown){typeof e!="boolean"&&(t=e,e=!0);let r=this.test({name:"noUnknown",exclusive:!0,message:t,test(s){if(s==null)return!0;const i=mh(this.schema,s);return!e||i.length===0||this.createError({params:{unknown:i.join(", ")}})}});return r.spec.noUnknown=e,r}unknown(e=!0,t=Mn.noUnknown){return this.noUnknown(!e,t)}transformKeys(e){return this.transform(t=>{if(!t)return t;const r={};for(const s of Object.keys(t))r[e(s)]=t[s];return r})}camelCase(){return this.transformKeys(Sn.camelCase)}snakeCase(){return this.transformKeys(Sn.snakeCase)}constantCase(){return this.transformKeys(e=>Sn.snakeCase(e).toUpperCase())}describe(e){let t=super.describe(e);t.fields={};for(const[s,i]of Object.entries(this.fields)){var r;let o=e;(r=o)!=null&&r.value&&(o=Object.assign({},o,{parent:o.value,value:o.value[s]})),t.fields[s]=i.describe(o)}return t}}ue.prototype=Ao.prototype;function gt(n){return new ko(n)}class ko extends se{constructor(e){super({type:"array",check(t){return Array.isArray(t)}}),this.innerType=void 0,this.innerType=e}_cast(e,t){const r=super._cast(e,t);if(!this._typeCheck(r)||!this.innerType)return r;let s=!1;const i=r.map((o,a)=>{const c=this.innerType.cast(o,Object.assign({},t,{path:`${t.path||""}[${a}]`}));return c!==o&&(s=!0),c});return s?i:r}_validate(e,t={},r,s){var i;let o=this.innerType,a=(i=t.recursive)!=null?i:this.spec.recursive;t.originalValue!=null&&t.originalValue,super._validate(e,t,r,(c,u)=>{var l;if(!a||!o||!this._typeCheck(u)){s(c,u);return}let h=new Array(u.length);for(let f=0;f<u.length;f++){var p;h[f]=o.asNestedTest({options:t,index:f,parent:u,parentPath:t.path,originalParent:(p=t.originalValue)!=null?p:e})}this.runTests({value:u,tests:h,originalValue:(l=t.originalValue)!=null?l:e,options:t},r,f=>s(f.concat(c),u))})}clone(e){const t=super.clone(e);return t.innerType=this.innerType,t}json(){return this.transform(So)}concat(e){let t=super.concat(e);return t.innerType=this.innerType,e.innerType&&(t.innerType=t.innerType?t.innerType.concat(e.innerType):e.innerType),t}of(e){let t=this.clone();if(!sn(e))throw new TypeError("`array.of()` sub-schema must be a valid yup schema not: "+yt(e));return t.innerType=e,t}length(e,t=Nr.length){return this.test({message:t,name:"length",exclusive:!0,params:{length:e},skipAbsent:!0,test(r){return r.length===this.resolve(e)}})}min(e,t){return t=t||Nr.min,this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(r){return r.length>=this.resolve(e)}})}max(e,t){return t=t||Nr.max,this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(r){return r.length<=this.resolve(e)}})}ensure(){return this.default(()=>[]).transform((e,t)=>this._typeCheck(e)?e:t==null?[]:[].concat(t))}compact(e){let t=e?(r,s,i)=>!e(r,s,i):r=>!!r;return this.transform(r=>r!=null?r.filter(t):r)}describe(e){let t=super.describe(e);if(this.innerType){var r;let s=e;(r=s)!=null&&r.value&&(s=Object.assign({},s,{parent:s.value,value:s.value[0]})),t.innerType=this.innerType.describe(e)}return t}}gt.prototype=ko.prototype;const ai=ue({url:A().url(),height:K(),width:K()}),wh=ue({type:A().default("rich"),title:A(),color:K(),thumbnail:ai,image:ai,url:A()}),bh=ue({url:A().url().required(),username:A(),avatar_url:A().url(),message:A().required(),embed:wh}),vh="notify_discord_webhook";class ws{static async SimpleToRaw(e){return{name:"",notify_type:vh,notify:await ws.validateCreate(e)}}static validateCreate(e){return bh.validate(e)}}const _h=ue({email:A().required(),subject:A(),html:A().required()}),Eh="notify_email";class bs{static async SimpleToRaw(e){return{name:"",notify_type:Eh,notify:await bs.validateCreate(e)}}static async validateCreate(e){return _h.validate(e)}}const xh=ue({clientId:K().required(),content:A().required()}),Oh="notify_telegram";class vs{static async SimpleToRaw(e){return{name:"",notify_type:Oh,notify:await vs.validateCreate(e)}}static validateCreate(e){return xh.validate(e)}}class An{static async SimpleToRaw(e,t){switch(e){case"Discord":return ws.SimpleToRaw(t);case"Telegram":return vs.SimpleToRaw(t);case"Email":return bs.SimpleToRaw(t)}}static RawToSimple(e){return{...e.notify,error:e.error,error_message:e.error_message,error_timestamp:e.error_timestamp}}static RawTypeToSimpleType(e){switch(e){case"notify_discord_webhook":return"Discord";case"notify_telegram":return"Telegram";case"notify_email":return"Email"}}static SimpleTypeToRawType(e){switch(e){case"Discord":return"notify_discord_webhook";case"Telegram":return"notify_telegram";case"Email":return"notify_email"}}}const Th="handler_function_call";class ci{static async SimpleToRaw(e,t,r){return{alertType:"event",network:t,nickname:e,type:Th,handler:await this.validate(r)}}static validate(e){const t=([s],i)=>s==="true"?i.notRequired():i.required();return ue({address:A().required(),abi:gt().required(),nBlocks:K().default(100).min(10).required(),function:A().required(),condition:A().default("true").oneOf([">",">=","<","<=","=","true"]).required(),constant:K().min(0).when("condition",t),responseArgIndex:K().min(0).when("condition",t),responseArgDecimals:K().min(0).when("condition",t)}).validateSync(e)}}const Sh="handler_onchain_event";class ui{static async SimpleToRaw(e,t,r){return{alertType:"event",network:t,nickname:e,type:Sh,handler:await this.validate(r)}}static validate(e){const t=([s],i)=>s==="true"?i.notRequired():i.required();return ue({address:A().required(),event:A().required(),abi:gt().required(),condition:A().default("true").oneOf([">",">=","<","<=","=","true"]).required(),constant:K().min(0).when("condition",t),paramsIndex:K().min(0).when("condition",t),paramsDecimals:K().min(0).when("condition",t)}).validateSync(e)}}const Ah="6.1.0";function kh(n,e,t){const r=e.split("|").map(i=>i.trim());for(let i=0;i<r.length;i++)switch(e){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof n===e)return}const s=new Error(`invalid value for type ${e}`);throw s.code="INVALID_ARGUMENT",s.argument=`value.${t}`,s.value=n,s}async function Ro(n){const e=Object.keys(n);return(await Promise.all(e.map(r=>Promise.resolve(n[r])))).reduce((r,s,i)=>(r[e[i]]=s,r),{})}function R(n,e,t){for(let r in e){let s=e[r];const i=t?t[r]:null;i&&kh(s,i,r),Object.defineProperty(n,r,{enumerable:!0,value:s,writable:!1})}}function Ct(n){if(n==null)return"null";if(Array.isArray(n))return"[ "+n.map(Ct).join(", ")+" ]";if(n instanceof Uint8Array){const e="0123456789abcdef";let t="0x";for(let r=0;r<n.length;r++)t+=e[n[r]>>4],t+=e[n[r]&15];return t}if(typeof n=="object"&&typeof n.toJSON=="function")return Ct(n.toJSON());switch(typeof n){case"boolean":case"symbol":return n.toString();case"bigint":return BigInt(n).toString();case"number":return n.toString();case"string":return JSON.stringify(n);case"object":{const e=Object.keys(n);return e.sort(),"{ "+e.map(t=>`${Ct(t)}: ${Ct(n[t])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function Br(n,e){return n&&n.code===e}function Po(n){return Br(n,"CALL_EXCEPTION")}function an(n,e,t){{const s=[];if(t){if("message"in t||"code"in t||"name"in t)throw new Error(`value will overwrite populated values: ${Ct(t)}`);for(const i in t){const o=t[i];s.push(i+"="+Ct(o))}}s.push(`code=${e}`),s.push(`version=${Ah}`),s.length&&(n+=" ("+s.join(", ")+")")}let r;switch(e){case"INVALID_ARGUMENT":r=new TypeError(n);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":r=new RangeError(n);break;default:r=new Error(n)}return R(r,{code:e}),t&&Object.assign(r,t),r}function T(n,e,t,r){if(!n)throw an(e,t,r)}function E(n,e,t,r){T(n,e,"INVALID_ARGUMENT",{argument:t,value:r})}function No(n,e,t){t==null&&(t=""),t&&(t=": "+t),T(n>=e,"missing arguemnt"+t,"MISSING_ARGUMENT",{count:n,expectedCount:e}),T(n<=e,"too many arguemnts"+t,"UNEXPECTED_ARGUMENT",{count:n,expectedCount:e})}const Rh=["NFD","NFC","NFKD","NFKC"].reduce((n,e)=>{try{if("test".normalize(e)!=="test")throw new Error("bad");if(e==="NFD"){const t=String.fromCharCode(233).normalize("NFD"),r=String.fromCharCode(101,769);if(t!==r)throw new Error("broken")}n.push(e)}catch{}return n},[]);function Ph(n){T(Rh.indexOf(n)>=0,"platform missing String.prototype.normalize","UNSUPPORTED_OPERATION",{operation:"String.prototype.normalize",info:{form:n}})}function _s(n,e,t){if(t==null&&(t=""),n!==e){let r=t,s="new";t&&(r+=".",s+=" "+t),T(!1,`private constructor; use ${r}from* methods`,"UNSUPPORTED_OPERATION",{operation:s})}}function $o(n,e,t){if(n instanceof Uint8Array)return t?new Uint8Array(n):n;if(typeof n=="string"&&n.match(/^0x([0-9a-f][0-9a-f])*$/i)){const r=new Uint8Array((n.length-2)/2);let s=2;for(let i=0;i<r.length;i++)r[i]=parseInt(n.substring(s,s+2),16),s+=2;return r}E(!1,"invalid BytesLike value",e||"value",n)}function Me(n,e){return $o(n,e,!1)}function Be(n,e){return $o(n,e,!0)}function Qe(n,e){return!(typeof n!="string"||!n.match(/^0x[0-9A-Fa-f]*$/)||typeof e=="number"&&n.length!==2+2*e||e===!0&&n.length%2!==0)}const li="0123456789abcdef";function q(n){const e=Me(n);let t="0x";for(let r=0;r<e.length;r++){const s=e[r];t+=li[(s&240)>>4]+li[s&15]}return t}function Dt(n){return"0x"+n.map(e=>q(e).substring(2)).join("")}function kt(n,e,t){const r=Me(n);return t!=null&&t>r.length&&T(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:r,length:r.length,offset:t}),q(r.slice(e??0,t??r.length))}function Nh(n,e,t){const r=Me(n);T(e>=r.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(r),length:e,offset:e+1});const s=new Uint8Array(e);return s.fill(0),t?s.set(r,e-r.length):s.set(r,0),q(s)}function $h(n,e){return Nh(n,e,!0)}const cn=BigInt(0),be=BigInt(1),It=9007199254740991;function Ch(n,e){const t=un(n,"value"),r=BigInt(qe(e,"width"));if(T(t>>r===cn,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:n}),t>>r-be){const s=(be<<r)-be;return-((~t&s)+be)}return t}function Ih(n,e){let t=Ot(n,"value");const r=BigInt(qe(e,"width")),s=be<<r-be;if(t<cn){t=-t,T(t<=s,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});const i=(be<<r)-be;return(~t&i)+be}else T(t<s,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});return t}function Er(n,e){const t=un(n,"value"),r=BigInt(qe(e,"bits"));return t&(be<<r)-be}function Ot(n,e){switch(typeof n){case"bigint":return n;case"number":return E(Number.isInteger(n),"underflow",e||"value",n),E(n>=-It&&n<=It,"overflow",e||"value",n),BigInt(n);case"string":try{if(n==="")throw new Error("empty string");return n[0]==="-"&&n[1]!=="-"?-BigInt(n.substring(1)):BigInt(n)}catch(t){E(!1,`invalid BigNumberish string: ${t.message}`,e||"value",n)}}E(!1,"invalid BigNumberish value",e||"value",n)}function un(n,e){const t=Ot(n,e);return T(t>=cn,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:n}),t}const hi="0123456789abcdef";function Co(n){if(n instanceof Uint8Array){let e="0x0";for(const t of n)e+=hi[t>>4],e+=hi[t&15];return BigInt(e)}return Ot(n)}function qe(n,e){switch(typeof n){case"bigint":return E(n>=-It&&n<=It,"overflow",e||"value",n),Number(n);case"number":return E(Number.isInteger(n),"underflow",e||"value",n),E(n>=-It&&n<=It,"overflow",e||"value",n),n;case"string":try{if(n==="")throw new Error("empty string");return qe(BigInt(n),e)}catch(t){E(!1,`invalid numeric string: ${t.message}`,e||"value",n)}}E(!1,"invalid numeric value",e||"value",n)}function Fh(n){return qe(Co(n))}function Io(n,e){let r=un(n,"value").toString(16);if(e==null)r.length%2&&(r="0"+r);else{const s=qe(e,"width");for(T(s*2>=r.length,`value exceeds width (${s} bits)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:n});r.length<s*2;)r="0"+r}return"0x"+r}function Dh(n){const e=un(n,"value");if(e===cn)return new Uint8Array([]);let t=e.toString(16);t.length%2&&(t="0"+t);const r=new Uint8Array(t.length/2);for(let s=0;s<r.length;s++){const i=s*2;r[s]=parseInt(t.substring(i,i+2),16)}return r}var Ut;class Uh{constructor(e,t,r){m(this,"filter");m(this,"emitter");L(this,Ut,void 0);I(this,Ut,t),R(this,{emitter:e,filter:r})}async removeListener(){v(this,Ut)!=null&&await this.emitter.off(this.filter,v(this,Ut))}}Ut=new WeakMap;function Lh(n,e,t,r,s){E(!1,`invalid codepoint at offset ${e}; ${n}`,"bytes",t)}function Fo(n,e,t,r,s){if(n==="BAD_PREFIX"||n==="UNEXPECTED_CONTINUE"){let i=0;for(let o=e+1;o<t.length&&t[o]>>6===2;o++)i++;return i}return n==="OVERRUN"?t.length-e-1:0}function jh(n,e,t,r,s){return n==="OVERLONG"?(E(typeof s=="number","invalid bad code point for replacement","badCodepoint",s),r.push(s),0):(r.push(65533),Fo(n,e,t))}const Bh=Object.freeze({error:Lh,ignore:Fo,replace:jh});function Hh(n,e){e==null&&(e=Bh.error);const t=Me(n,"bytes"),r=[];let s=0;for(;s<t.length;){const i=t[s++];if(!(i>>7)){r.push(i);continue}let o=null,a=null;if((i&224)===192)o=1,a=127;else if((i&240)===224)o=2,a=2047;else if((i&248)===240)o=3,a=65535;else{(i&192)===128?s+=e("UNEXPECTED_CONTINUE",s-1,t,r):s+=e("BAD_PREFIX",s-1,t,r);continue}if(s-1+o>=t.length){s+=e("OVERRUN",s-1,t,r);continue}let c=i&(1<<8-o-1)-1;for(let u=0;u<o;u++){let l=t[s];if((l&192)!=128){s+=e("MISSING_CONTINUE",s,t,r),c=null;break}c=c<<6|l&63,s++}if(c!==null){if(c>1114111){s+=e("OUT_OF_RANGE",s-1-o,t,r,c);continue}if(c>=55296&&c<=57343){s+=e("UTF16_SURROGATE",s-1-o,t,r,c);continue}if(c<=a){s+=e("OVERLONG",s-1-o,t,r,c);continue}r.push(c)}}return r}function Do(n,e){e!=null&&(Ph(e),n=n.normalize(e));let t=[];for(let r=0;r<n.length;r++){const s=n.charCodeAt(r);if(s<128)t.push(s);else if(s<2048)t.push(s>>6|192),t.push(s&63|128);else if((s&64512)==55296){r++;const i=n.charCodeAt(r);E(r<n.length&&(i&64512)===56320,"invalid surrogate pair","str",n);const o=65536+((s&1023)<<10)+(i&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(s>>12|224),t.push(s>>6&63|128),t.push(s&63|128)}return new Uint8Array(t)}function Mh(n){return n.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function zh(n,e){return Mh(Hh(n,e))}const ee=32,zn=new Uint8Array(ee),Vh=["then"],xr={};function Or(n,e){const t=new Error(`deferred error during ABI decoding triggered accessing ${n}`);throw t.error=e,t}var Xe;const Qt=class extends Array{constructor(...t){const r=t[0];let s=t[1],i=(t[2]||[]).slice(),o=!0;r!==xr&&(s=t,i=[],o=!1);super(s.length);L(this,Xe,void 0);s.forEach((c,u)=>{this[u]=c});const a=i.reduce((c,u)=>(typeof u=="string"&&c.set(u,(c.get(u)||0)+1),c),new Map);if(I(this,Xe,Object.freeze(s.map((c,u)=>{const l=i[u];return l!=null&&a.get(l)===1?l:null}))),!!o)return Object.freeze(this),new Proxy(this,{get:(c,u,l)=>{if(typeof u=="string"){if(u.match(/^[0-9]+$/)){const p=qe(u,"%index");if(p<0||p>=this.length)throw new RangeError("out of result range");const f=c[p];return f instanceof Error&&Or(`index ${p}`,f),f}if(Vh.indexOf(u)>=0)return Reflect.get(c,u,l);const h=c[u];if(h instanceof Function)return function(...p){return h.apply(this===l?c:this,p)};if(!(u in c))return c.getValue.apply(this===l?c:this,[u])}return Reflect.get(c,u,l)}})}toArray(){const t=[];return this.forEach((r,s)=>{r instanceof Error&&Or(`index ${s}`,r),t.push(r)}),t}toObject(){return v(this,Xe).reduce((t,r,s)=>(T(r!=null,"value at index ${ index } unnamed","UNSUPPORTED_OPERATION",{operation:"toObject()"}),r in t||(t[r]=this.getValue(r)),t),{})}slice(t,r){t==null&&(t=0),t<0&&(t+=this.length,t<0&&(t=0)),r==null&&(r=this.length),r<0&&(r+=this.length,r<0&&(r=0)),r>this.length&&(r=this.length);const s=[],i=[];for(let o=t;o<r;o++)s.push(this[o]),i.push(v(this,Xe)[o]);return new Qt(xr,s,i)}filter(t,r){const s=[],i=[];for(let o=0;o<this.length;o++){const a=this[o];a instanceof Error&&Or(`index ${o}`,a),t.call(r,a,o,this)&&(s.push(a),i.push(v(this,Xe)[o]))}return new Qt(xr,s,i)}getValue(t){const r=v(this,Xe).indexOf(t);if(r===-1)return;const s=this[r];return s instanceof Error&&Or(`property ${JSON.stringify(t)}`,s.error),s}static fromItems(t,r){return new Qt(xr,t,r)}};let Hr=Qt;Xe=new WeakMap;function fi(n){let e=Dh(n);return T(e.length<=ee,"value out-of-bounds","BUFFER_OVERRUN",{buffer:e,length:ee,offset:e.length}),e.length!==ee&&(e=Be(Dt([zn.slice(e.length%ee),e]))),e}class Je{constructor(e,t,r,s){m(this,"name");m(this,"type");m(this,"localName");m(this,"dynamic");R(this,{name:e,type:t,localName:r,dynamic:s},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(e,t){E(!1,e,this.localName,t)}}var Ue,ft,Lt,Cr;class Vn{constructor(){L(this,Lt);L(this,Ue,void 0);L(this,ft,void 0);I(this,Ue,[]),I(this,ft,0)}get data(){return Dt(v(this,Ue))}get length(){return v(this,ft)}appendWriter(e){return z(this,Lt,Cr).call(this,Be(e.data))}writeBytes(e){let t=Be(e);const r=t.length%ee;return r&&(t=Be(Dt([t,zn.slice(r)]))),z(this,Lt,Cr).call(this,t)}writeValue(e){return z(this,Lt,Cr).call(this,fi(e))}writeUpdatableValue(){const e=v(this,Ue).length;return v(this,Ue).push(zn),I(this,ft,v(this,ft)+ee),t=>{v(this,Ue)[e]=fi(t)}}}Ue=new WeakMap,ft=new WeakMap,Lt=new WeakSet,Cr=function(e){return v(this,Ue).push(e),I(this,ft,v(this,ft)+e.length),e.length};var ae,de,Vr,Uo;const $s=class{constructor(e,t){L(this,Vr);m(this,"allowLoose");L(this,ae,void 0);L(this,de,void 0);R(this,{allowLoose:!!t}),I(this,ae,Be(e)),I(this,de,0)}get data(){return q(v(this,ae))}get dataLength(){return v(this,ae).length}get consumed(){return v(this,de)}get bytes(){return new Uint8Array(v(this,ae))}subReader(e){return new $s(v(this,ae).slice(v(this,de)+e),this.allowLoose)}readBytes(e,t){let r=z(this,Vr,Uo).call(this,0,e,!!t);return I(this,de,v(this,de)+r.length),r.slice(0,e)}readValue(){return Co(this.readBytes(ee))}readIndex(){return Fh(this.readBytes(ee))}};let qn=$s;ae=new WeakMap,de=new WeakMap,Vr=new WeakSet,Uo=function(e,t,r){let s=Math.ceil(t/ee)*ee;return v(this,de)+s>v(this,ae).length&&(this.allowLoose&&r&&v(this,de)+t<=v(this,ae).length?s=t:T(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:Be(v(this,ae)),length:v(this,ae).length,offset:v(this,de)+s})),v(this,ae).slice(v(this,de),v(this,de)+s)};function Jn(n){if(!Number.isSafeInteger(n)||n<0)throw new Error(`Wrong positive integer: ${n}`)}function qh(n){if(typeof n!="boolean")throw new Error(`Expected boolean, not ${n}`)}function Lo(n,...e){if(!(n instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(e.length>0&&!e.includes(n.length))throw new TypeError(`Expected Uint8Array of length ${e}, not of length=${n.length}`)}function Jh(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Jn(n.outputLen),Jn(n.blockLen)}function Gh(n,e=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(e&&n.finished)throw new Error("Hash#digest() has already been called")}function Wh(n,e){Lo(n);const t=e.outputLen;if(n.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}const Rt={number:Jn,bool:qh,bytes:Lo,hash:Jh,exists:Gh,output:Wh};/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Kh=n=>new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)),Xh=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Xh)throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function Zh(n){if(typeof n!="string")throw new TypeError(`utf8ToBytes expected string, got ${typeof n}`);return new TextEncoder().encode(n)}function Es(n){if(typeof n=="string"&&(n=Zh(n)),!(n instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof n})`);return n}class Yh{clone(){return this._cloneInto()}}function Qh(n){const e=r=>n().update(Es(r)).digest(),t=n();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>n(),e}function ef(n){const e=(r,s)=>n(s).update(Es(r)).digest(),t=n({});return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=r=>n(r),e}const Tr=BigInt(2**32-1),Gn=BigInt(32);function jo(n,e=!1){return e?{h:Number(n&Tr),l:Number(n>>Gn&Tr)}:{h:Number(n>>Gn&Tr)|0,l:Number(n&Tr)|0}}function tf(n,e=!1){let t=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let s=0;s<n.length;s++){const{h:i,l:o}=jo(n[s],e);[t[s],r[s]]=[i,o]}return[t,r]}const rf=(n,e)=>BigInt(n>>>0)<<Gn|BigInt(e>>>0),nf=(n,e,t)=>n>>>t,sf=(n,e,t)=>n<<32-t|e>>>t,of=(n,e,t)=>n>>>t|e<<32-t,af=(n,e,t)=>n<<32-t|e>>>t,cf=(n,e,t)=>n<<64-t|e>>>t-32,uf=(n,e,t)=>n>>>t-32|e<<64-t,lf=(n,e)=>e,hf=(n,e)=>n,ff=(n,e,t)=>n<<t|e>>>32-t,df=(n,e,t)=>e<<t|n>>>32-t,pf=(n,e,t)=>e<<t-32|n>>>64-t,yf=(n,e,t)=>n<<t-32|e>>>64-t;function mf(n,e,t,r){const s=(e>>>0)+(r>>>0);return{h:n+t+(s/2**32|0)|0,l:s|0}}const gf=(n,e,t)=>(n>>>0)+(e>>>0)+(t>>>0),wf=(n,e,t,r)=>e+t+r+(n/2**32|0)|0,bf=(n,e,t,r)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0),vf=(n,e,t,r,s)=>e+t+r+s+(n/2**32|0)|0,_f=(n,e,t,r,s)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0),Ef=(n,e,t,r,s,i)=>e+t+r+s+i+(n/2**32|0)|0,rr={fromBig:jo,split:tf,toBig:rf,shrSH:nf,shrSL:sf,rotrSH:of,rotrSL:af,rotrBH:cf,rotrBL:uf,rotr32H:lf,rotr32L:hf,rotlSH:ff,rotlSL:df,rotlBH:pf,rotlBL:yf,add:mf,add3L:gf,add3H:wf,add4L:bf,add4H:vf,add5H:Ef,add5L:_f},[Bo,Ho,Mo]=[[],[],[]],xf=BigInt(0),Kt=BigInt(1),Of=BigInt(2),Tf=BigInt(7),Sf=BigInt(256),Af=BigInt(113);for(let n=0,e=Kt,t=1,r=0;n<24;n++){[t,r]=[r,(2*t+3*r)%5],Bo.push(2*(5*r+t)),Ho.push((n+1)*(n+2)/2%64);let s=xf;for(let i=0;i<7;i++)e=(e<<Kt^(e>>Tf)*Af)%Sf,e&Of&&(s^=Kt<<(Kt<<BigInt(i))-Kt);Mo.push(s)}const[kf,Rf]=rr.split(Mo,!0),di=(n,e,t)=>t>32?rr.rotlBH(n,e,t):rr.rotlSH(n,e,t),pi=(n,e,t)=>t>32?rr.rotlBL(n,e,t):rr.rotlSL(n,e,t);function Pf(n,e=24){const t=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)t[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,u=t[c],l=t[c+1],h=di(u,l,1)^t[a],p=pi(u,l,1)^t[a+1];for(let f=0;f<50;f+=10)n[o+f]^=h,n[o+f+1]^=p}let s=n[2],i=n[3];for(let o=0;o<24;o++){const a=Ho[o],c=di(s,i,a),u=pi(s,i,a),l=Bo[o];s=n[l],i=n[l+1],n[l]=c,n[l+1]=u}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=n[o+a];for(let a=0;a<10;a++)n[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}n[0]^=kf[r],n[1]^=Rf[r]}t.fill(0)}class ln extends Yh{constructor(e,t,r,s=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Rt.number(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Kh(this.state)}keccak(){Pf(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){Rt.exists(this);const{blockLen:t,state:r}=this;e=Es(e);const s=e.length;for(let i=0;i<s;){const o=Math.min(t-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:r,blockLen:s}=this;e[r]^=t,t&128&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Rt.exists(this,!1),Rt.bytes(e),this.finish();const t=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);e.set(t.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Rt.number(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Rt.output(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,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new ln(t,r,s,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}}const rt=(n,e,t)=>Qh(()=>new ln(e,n,t));rt(6,144,224/8);rt(6,136,256/8);rt(6,104,384/8);rt(6,72,512/8);rt(1,144,224/8);const Nf=rt(1,136,256/8);rt(1,104,384/8);rt(1,72,512/8);const zo=(n,e,t)=>ef((r={})=>new ln(e,n,r.dkLen===void 0?t:r.dkLen,!0));zo(31,168,128/8);zo(31,136,256/8);let Vo=!1;const qo=function(n){return Nf(n)};let Jo=qo;function tt(n){const e=Me(n,"data");return q(Jo(e))}tt._=qo;tt.lock=function(){Vo=!0};tt.register=function(n){if(Vo)throw new TypeError("keccak256 is locked");Jo=n};Object.freeze(tt);const $f=BigInt(0),Cf=BigInt(36);function yi(n){n=n.toLowerCase();const e=n.substring(2).split(""),t=new Uint8Array(40);for(let s=0;s<40;s++)t[s]=e[s].charCodeAt(0);const r=Me(tt(t));for(let s=0;s<40;s+=2)r[s>>1]>>4>=8&&(e[s]=e[s].toUpperCase()),(r[s>>1]&15)>=8&&(e[s+1]=e[s+1].toUpperCase());return"0x"+e.join("")}const xs={};for(let n=0;n<10;n++)xs[String(n)]=String(n);for(let n=0;n<26;n++)xs[String.fromCharCode(65+n)]=String(10+n);const mi=15;function If(n){n=n.toUpperCase(),n=n.substring(4)+n.substring(0,2)+"00";let e=n.split("").map(r=>xs[r]).join("");for(;e.length>=mi;){let r=e.substring(0,mi);e=parseInt(r,10)%97+e.substring(r.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}const Ff=function(){const n={};for(let e=0;e<36;e++){const t="0123456789abcdefghijklmnopqrstuvwxyz"[e];n[t]=BigInt(e)}return n}();function Df(n){n=n.toLowerCase();let e=$f;for(let t=0;t<n.length;t++)e=e*Cf+Ff[n[t]];return e}function wt(n){if(E(typeof n=="string","invalid address","address",n),n.match(/^(0x)?[0-9a-fA-F]{40}$/)){n.startsWith("0x")||(n="0x"+n);const e=yi(n);return E(!n.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||e===n,"bad address checksum","address",n),e}if(n.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){E(n.substring(2,4)===If(n),"bad icap checksum","address",n);let e=Df(n.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return yi("0x"+e)}E(!1,"invalid address","address",n)}function Uf(n){return n&&typeof n.getAddress=="function"}async function kn(n,e){const t=await e;return(t==null||t==="0x0000000000000000000000000000000000000000")&&(T(typeof n!="string","unconfigured name","UNCONFIGURED_NAME",{value:n}),E(!1,"invalid AddressLike value; did not resolve to a value address","target",n)),wt(t)}function Os(n,e){if(typeof n=="string")return n.match(/^0x[0-9a-f]{40}$/i)?wt(n):(T(e!=null,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),kn(n,e.resolveName(n)));if(Uf(n))return kn(n,n.getAddress());if(n&&typeof n.then=="function")return kn(n,n);E(!1,"unsupported addressable value","target",n)}const Ce={};function x(n,e){let t=!1;return e<0&&(t=!0,e*=-1),new Q(Ce,`${t?"":"u"}int${e}`,n,{signed:t,width:e})}function $(n,e){return new Q(Ce,`bytes${e||""}`,n,{size:e})}const gi=Symbol.for("_ethers_typed");var dt;const Ie=class{constructor(e,t,r,s){m(this,"type");m(this,"value");L(this,dt,void 0);m(this,"_typedSymbol");s==null&&(s=null),_s(Ce,e,"Typed"),R(this,{_typedSymbol:gi,type:t,value:r}),I(this,dt,s),this.format()}format(){if(this.type==="array")throw new Error("");if(this.type==="dynamicArray")throw new Error("");return this.type==="tuple"?`tuple(${this.value.map(e=>e.format()).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return this.type==="string"}get tupleName(){if(this.type!=="tuple")throw TypeError("not a tuple");return v(this,dt)}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return v(this,dt)===!0?-1:v(this,dt)===!1?this.value.length:null}static from(e,t){return new Ie(Ce,e,t)}static uint8(e){return x(e,8)}static uint16(e){return x(e,16)}static uint24(e){return x(e,24)}static uint32(e){return x(e,32)}static uint40(e){return x(e,40)}static uint48(e){return x(e,48)}static uint56(e){return x(e,56)}static uint64(e){return x(e,64)}static uint72(e){return x(e,72)}static uint80(e){return x(e,80)}static uint88(e){return x(e,88)}static uint96(e){return x(e,96)}static uint104(e){return x(e,104)}static uint112(e){return x(e,112)}static uint120(e){return x(e,120)}static uint128(e){return x(e,128)}static uint136(e){return x(e,136)}static uint144(e){return x(e,144)}static uint152(e){return x(e,152)}static uint160(e){return x(e,160)}static uint168(e){return x(e,168)}static uint176(e){return x(e,176)}static uint184(e){return x(e,184)}static uint192(e){return x(e,192)}static uint200(e){return x(e,200)}static uint208(e){return x(e,208)}static uint216(e){return x(e,216)}static uint224(e){return x(e,224)}static uint232(e){return x(e,232)}static uint240(e){return x(e,240)}static uint248(e){return x(e,248)}static uint256(e){return x(e,256)}static uint(e){return x(e,256)}static int8(e){return x(e,-8)}static int16(e){return x(e,-16)}static int24(e){return x(e,-24)}static int32(e){return x(e,-32)}static int40(e){return x(e,-40)}static int48(e){return x(e,-48)}static int56(e){return x(e,-56)}static int64(e){return x(e,-64)}static int72(e){return x(e,-72)}static int80(e){return x(e,-80)}static int88(e){return x(e,-88)}static int96(e){return x(e,-96)}static int104(e){return x(e,-104)}static int112(e){return x(e,-112)}static int120(e){return x(e,-120)}static int128(e){return x(e,-128)}static int136(e){return x(e,-136)}static int144(e){return x(e,-144)}static int152(e){return x(e,-152)}static int160(e){return x(e,-160)}static int168(e){return x(e,-168)}static int176(e){return x(e,-176)}static int184(e){return x(e,-184)}static int192(e){return x(e,-192)}static int200(e){return x(e,-200)}static int208(e){return x(e,-208)}static int216(e){return x(e,-216)}static int224(e){return x(e,-224)}static int232(e){return x(e,-232)}static int240(e){return x(e,-240)}static int248(e){return x(e,-248)}static int256(e){return x(e,-256)}static int(e){return x(e,-256)}static bytes1(e){return $(e,1)}static bytes2(e){return $(e,2)}static bytes3(e){return $(e,3)}static bytes4(e){return $(e,4)}static bytes5(e){return $(e,5)}static bytes6(e){return $(e,6)}static bytes7(e){return $(e,7)}static bytes8(e){return $(e,8)}static bytes9(e){return $(e,9)}static bytes10(e){return $(e,10)}static bytes11(e){return $(e,11)}static bytes12(e){return $(e,12)}static bytes13(e){return $(e,13)}static bytes14(e){return $(e,14)}static bytes15(e){return $(e,15)}static bytes16(e){return $(e,16)}static bytes17(e){return $(e,17)}static bytes18(e){return $(e,18)}static bytes19(e){return $(e,19)}static bytes20(e){return $(e,20)}static bytes21(e){return $(e,21)}static bytes22(e){return $(e,22)}static bytes23(e){return $(e,23)}static bytes24(e){return $(e,24)}static bytes25(e){return $(e,25)}static bytes26(e){return $(e,26)}static bytes27(e){return $(e,27)}static bytes28(e){return $(e,28)}static bytes29(e){return $(e,29)}static bytes30(e){return $(e,30)}static bytes31(e){return $(e,31)}static bytes32(e){return $(e,32)}static address(e){return new Ie(Ce,"address",e)}static bool(e){return new Ie(Ce,"bool",!!e)}static bytes(e){return new Ie(Ce,"bytes",e)}static string(e){return new Ie(Ce,"string",e)}static array(e,t){throw new Error("not implemented yet")}static tuple(e,t){throw new Error("not implemented yet")}static overrides(e){return new Ie(Ce,"overrides",Object.assign({},e))}static isTyped(e){return e&&e._typedSymbol===gi}static dereference(e,t){if(Ie.isTyped(e)){if(e.type!==t)throw new Error(`invalid type: expecetd ${t}, got ${e.type}`);return e.value}return e}};let Q=Ie;dt=new WeakMap;class Lf extends Je{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){let r=Q.dereference(t,"string");try{r=wt(r)}catch(s){return this._throwError(s.message,t)}return e.writeValue(r)}decode(e){return wt(Io(e.readValue(),20))}}class jf extends Je{constructor(t){super(t.name,t.type,"_",t.dynamic);m(this,"coder");this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,r){return this.coder.encode(t,r)}decode(t){return this.coder.decode(t)}}function Go(n,e,t){let r=[];if(Array.isArray(t))r=t;else if(t&&typeof t=="object"){let c={};r=e.map(u=>{const l=u.localName;return T(l,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:u},value:t}),T(!c[l],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:u},value:t}),c[l]=!0,t[l]})}else E(!1,"invalid tuple value","tuple",t);E(e.length===r.length,"types/value length mismatch","tuple",t);let s=new Vn,i=new Vn,o=[];e.forEach((c,u)=>{let l=r[u];if(c.dynamic){let h=i.length;c.encode(i,l);let p=s.writeUpdatableValue();o.push(f=>{p(f+h)})}else c.encode(s,l)}),o.forEach(c=>{c(s.length)});let a=n.appendWriter(s);return a+=n.appendWriter(i),a}function Wo(n,e){let t=[],r=[],s=n.subReader(0);return e.forEach(i=>{let o=null;if(i.dynamic){let a=n.readIndex(),c=s.subReader(a);try{o=i.decode(c)}catch(u){if(Br(u,"BUFFER_OVERRUN"))throw u;o=u,o.baseType=i.name,o.name=i.localName,o.type=i.type}}else try{o=i.decode(n)}catch(a){if(Br(a,"BUFFER_OVERRUN"))throw a;o=a,o.baseType=i.name,o.name=i.localName,o.type=i.type}if(o==null)throw new Error("investigate");t.push(o),r.push(i.localName||null)}),Hr.fromItems(t,r)}class Bf extends Je{constructor(t,r,s){const i=t.type+"["+(r>=0?r:"")+"]",o=r===-1||t.dynamic;super("array",i,s,o);m(this,"coder");m(this,"length");R(this,{coder:t,length:r})}defaultValue(){const t=this.coder.defaultValue(),r=[];for(let s=0;s<this.length;s++)r.push(t);return r}encode(t,r){const s=Q.dereference(r,"array");Array.isArray(s)||this._throwError("expected array value",s);let i=this.length;i===-1&&(i=s.length,t.writeValue(s.length)),No(s.length,i,"coder array"+(this.localName?" "+this.localName:""));let o=[];for(let a=0;a<s.length;a++)o.push(this.coder);return Go(t,o,s)}decode(t){let r=this.length;r===-1&&(r=t.readIndex(),T(r*ee<=t.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:t.bytes,offset:r*ee,length:t.dataLength}));let s=[];for(let i=0;i<r;i++)s.push(new jf(this.coder));return Wo(t,s)}}class Hf extends Je{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,t){const r=Q.dereference(t,"bool");return e.writeValue(r?1:0)}decode(e){return!!e.readValue()}}class Ko extends Je{constructor(e,t){super(e,e,t,!0)}defaultValue(){return"0x"}encode(e,t){t=Be(t);let r=e.writeValue(t.length);return r+=e.writeBytes(t),r}decode(e){return e.readBytes(e.readIndex(),!0)}}class Mf extends Ko{constructor(e){super("bytes",e)}decode(e){return q(super.decode(e))}}class zf extends Je{constructor(t,r){let s="bytes"+String(t);super(s,s,r,!1);m(this,"size");R(this,{size:t},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(t,r){let s=Be(Q.dereference(r,this.type));return s.length!==this.size&&this._throwError("incorrect data length",r),t.writeBytes(s)}decode(t){return q(t.readBytes(this.size))}}const Vf=new Uint8Array([]);class qf extends Je{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,t){return t!=null&&this._throwError("not null",t),e.writeBytes(Vf)}decode(e){return e.readBytes(0),null}}const Jf=BigInt(0),Gf=BigInt(1),Wf=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class Kf extends Je{constructor(t,r,s){const i=(r?"int":"uint")+t*8;super(i,i,s,!1);m(this,"size");m(this,"signed");R(this,{size:t,signed:r},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(t,r){let s=Ot(Q.dereference(r,this.type)),i=Er(Wf,ee*8);if(this.signed){let o=Er(i,this.size*8-1);(s>o||s<-(o+Gf))&&this._throwError("value out-of-bounds",r),s=Ih(s,8*ee)}else(s<Jf||s>Er(i,this.size*8))&&this._throwError("value out-of-bounds",r);return t.writeValue(s)}decode(t){let r=Er(t.readValue(),this.size*8);return this.signed&&(r=Ch(r,this.size*8)),r}}class Xf extends Ko{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,Do(Q.dereference(t,"string")))}decode(e){return zh(super.decode(e))}}class Sr extends Je{constructor(t,r){let s=!1;const i=[];t.forEach(a=>{a.dynamic&&(s=!0),i.push(a.type)});const o="tuple("+i.join(",")+")";super("tuple",o,r,s);m(this,"coders");R(this,{coders:Object.freeze(t.slice())})}defaultValue(){const t=[];this.coders.forEach(s=>{t.push(s.defaultValue())});const r=this.coders.reduce((s,i)=>{const o=i.localName;return o&&(s[o]||(s[o]=0),s[o]++),s},{});return this.coders.forEach((s,i)=>{let o=s.localName;!o||r[o]!==1||(o==="length"&&(o="_length"),t[o]==null&&(t[o]=t[i]))}),Object.freeze(t)}encode(t,r){const s=Q.dereference(r,"tuple");return Go(t,this.coders,s)}decode(t){return Wo(t,this.coders)}}function nr(n){return tt(Do(n))}function Rn(n,e){return{address:wt(n),storageKeys:e.map((t,r)=>(E(Qe(t,32),"invalid slot",`storageKeys[${r}]`,t),t.toLowerCase()))}}function Zf(n){if(Array.isArray(n))return n.map((t,r)=>Array.isArray(t)?(E(t.length===2,"invalid slot set",`value[${r}]`,t),Rn(t[0],t[1])):(E(t!=null&&typeof t=="object","invalid address-slot set","value",n),Rn(t.address,t.storageKeys)));E(n!=null&&typeof n=="object","invalid access list","value",n);const e=Object.keys(n).map(t=>{const r=n[t].reduce((s,i)=>(s[i]=!0,s),{});return Rn(t,Object.keys(r).sort())});return e.sort((t,r)=>t.address.localeCompare(r.address)),e}function te(n){const e=new Set;return n.forEach(t=>e.add(t)),Object.freeze(e)}const Xo="constant external internal payable private public pure view",Yf=te(Xo.split(" ")),Zo="constructor error event fallback function receive struct",Yo=te(Zo.split(" ")),Qo="calldata memory storage payable indexed",Qf=te(Qo.split(" ")),ed="tuple returns",td=[Zo,Qo,ed,Xo].join(" "),rd=te(td.split(" ")),nd={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},sd=new RegExp("^(\\s*)"),id=new RegExp("^([0-9]+)"),od=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),ea=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),ta=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$");var W,ge,ir,Wn;const qr=class{constructor(e){L(this,ir);L(this,W,void 0);L(this,ge,void 0);I(this,W,0),I(this,ge,e.slice())}get offset(){return v(this,W)}get length(){return v(this,ge).length-v(this,W)}clone(){return new qr(v(this,ge))}reset(){I(this,W,0)}popKeyword(e){const t=this.peek();if(t.type!=="KEYWORD"||!e.has(t.text))throw new Error(`expected keyword ${t.text}`);return this.pop().text}popType(e){if(this.peek().type!==e)throw new Error(`expected ${e}; got ${JSON.stringify(this.peek())}`);return this.pop().text}popParen(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=z(this,ir,Wn).call(this,v(this,W)+1,e.match+1);return I(this,W,e.match+1),t}popParams(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=[];for(;v(this,W)<e.match-1;){const r=this.peek().linkNext;t.push(z(this,ir,Wn).call(this,v(this,W)+1,r)),I(this,W,r)}return I(this,W,e.match+1),t}peek(){if(v(this,W)>=v(this,ge).length)throw new Error("out-of-bounds");return v(this,ge)[v(this,W)]}peekKeyword(e){const t=this.peekType("KEYWORD");return t!=null&&e.has(t)?t:null}peekType(e){if(this.length===0)return null;const t=this.peek();return t.type===e?t.text:null}pop(){const e=this.peek();return Is(this,W)._++,e}toString(){const e=[];for(let t=v(this,W);t<v(this,ge).length;t++){const r=v(this,ge)[t];e.push(`${r.type}:${r.text}`)}return`<TokenString ${e.join(" ")}>`}};let ve=qr;W=new WeakMap,ge=new WeakMap,ir=new WeakSet,Wn=function(e=0,t=0){return new qr(v(this,ge).slice(e,t).map(r=>Object.freeze(Object.assign({},r,{match:r.match-e,linkBack:r.linkBack-e,linkNext:r.linkNext-e}))))};function nt(n){const e=[],t=o=>{const a=i<n.length?JSON.stringify(n[i]):"$EOI";throw new Error(`invalid token ${a} at ${i}: ${o}`)};let r=[],s=[],i=0;for(;i<n.length;){let o=n.substring(i),a=o.match(sd);a&&(i+=a[1].length,o=n.substring(i));const c={depth:r.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:i,value:-1};e.push(c);let u=nd[o[0]]||"";if(u){if(c.type=u,c.text=o[0],i++,u==="OPEN_PAREN")r.push(e.length-1),s.push(e.length-1);else if(u=="CLOSE_PAREN")r.length===0&&t("no matching open bracket"),c.match=r.pop(),e[c.match].match=e.length-1,c.depth--,c.linkBack=s.pop(),e[c.linkBack].linkNext=e.length-1;else if(u==="COMMA")c.linkBack=s.pop(),e[c.linkBack].linkNext=e.length-1,s.push(e.length-1);else if(u==="OPEN_BRACKET")c.type="BRACKET";else if(u==="CLOSE_BRACKET"){let l=e.pop().text;if(e.length>0&&e[e.length-1].type==="NUMBER"){const h=e.pop().text;l=h+l,e[e.length-1].value=qe(h)}if(e.length===0||e[e.length-1].type!=="BRACKET")throw new Error("missing opening bracket");e[e.length-1].text+=l}continue}if(a=o.match(od),a){if(c.text=a[1],i+=c.text.length,rd.has(c.text)){c.type="KEYWORD";continue}if(c.text.match(ta)){c.type="TYPE";continue}c.type="ID";continue}if(a=o.match(id),a){c.text=a[1],c.type="NUMBER",i+=c.text.length;continue}throw new Error(`unexpected token ${JSON.stringify(o[0])} at position ${i}`)}return new ve(e.map(o=>Object.freeze(o)))}function wi(n,e){let t=[];for(const r in e.keys())n.has(r)&&t.push(r);if(t.length>1)throw new Error(`conflicting types: ${t.join(", ")}`)}function hn(n,e){if(e.peekKeyword(Yo)){const t=e.pop().text;if(t!==n)throw new Error(`expected ${n}, got ${t}`)}return e.popType("ID")}function ze(n,e){const t=new Set;for(;;){const r=n.peekType("KEYWORD");if(r==null||e&&!e.has(r))break;if(n.pop(),t.has(r))throw new Error(`duplicate keywords: ${JSON.stringify(r)}`);t.add(r)}return Object.freeze(t)}function ra(n){let e=ze(n,Yf);return wi(e,te("constant payable nonpayable".split(" "))),wi(e,te("pure view payable nonpayable".split(" "))),e.has("view")?"view":e.has("pure")?"pure":e.has("payable")?"payable":e.has("nonpayable")?"nonpayable":e.has("constant")?"view":"nonpayable"}function He(n,e){return n.popParams().map(t=>X.from(t,e))}function na(n){if(n.peekType("AT")){if(n.pop(),n.peekType("NUMBER"))return Ot(n.pop().text);throw new Error("invalid gas")}return null}function bt(n){if(n.length)throw new Error(`unexpected tokens: ${n.toString()}`)}const ad=new RegExp(/^(.*)\[([0-9]*)\]$/);function bi(n){const e=n.match(ta);if(E(e,"invalid type","type",n),n==="uint")return"uint256";if(n==="int")return"int256";if(e[2]){const t=parseInt(e[2]);E(t!==0&&t<=32,"invalid bytes length","type",n)}else if(e[3]){const t=parseInt(e[3]);E(t!==0&&t<=256&&t%8===0,"invalid numeric width","type",n)}return n}const B={},ie=Symbol.for("_ethers_internal"),vi="_ParamTypeInternal",_i="_ErrorInternal",Ei="_EventInternal",xi="_ConstructorInternal",Oi="_FallbackInternal",Ti="_FunctionInternal",Si="_StructInternal";var jt,Ir;const fe=class{constructor(e,t,r,s,i,o,a,c){L(this,jt);m(this,"name");m(this,"type");m(this,"baseType");m(this,"indexed");m(this,"components");m(this,"arrayLength");m(this,"arrayChildren");if(_s(e,B,"ParamType"),Object.defineProperty(this,ie,{value:vi}),o&&(o=Object.freeze(o.slice())),s==="array"){if(a==null||c==null)throw new Error("")}else if(a!=null||c!=null)throw new Error("");if(s==="tuple"){if(o==null)throw new Error("")}else if(o!=null)throw new Error("");R(this,{name:t,type:r,baseType:s,indexed:i,components:o,arrayLength:a,arrayChildren:c})}format(e){if(e==null&&(e="sighash"),e==="json"){let r={type:this.baseType==="tuple"?"tuple":this.type,name:this.name||void 0};return typeof this.indexed=="boolean"&&(r.indexed=this.indexed),this.isTuple()&&(r.components=this.components.map(s=>JSON.parse(s.format(e)))),JSON.stringify(r)}let t="";return this.isArray()?(t+=this.arrayChildren.format(e),t+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?(e!=="sighash"&&(t+=this.type),t+="("+this.components.map(r=>r.format(e)).join(e==="full"?", ":",")+")"):t+=this.type,e!=="sighash"&&(this.indexed===!0&&(t+=" indexed"),e==="full"&&this.name&&(t+=" "+this.name)),t}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(e,t){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw new Error("array is wrong length");const r=this;return e.map(s=>r.arrayChildren.walk(s,t))}if(this.isTuple()){if(!Array.isArray(e))throw new Error("invalid tuple value");if(e.length!==this.components.length)throw new Error("array is wrong length");const r=this;return e.map((s,i)=>r.components[i].walk(s,t))}return t(this.type,e)}async walkAsync(e,t){const r=[],s=[e];return z(this,jt,Ir).call(this,r,e,t,i=>{s[0]=i}),r.length&&await Promise.all(r),s[0]}static from(e,t){if(fe.isParamType(e))return e;if(typeof e=="string")return fe.from(nt(e),t);if(e instanceof ve){let a="",c="",u=null;ze(e,te(["tuple"])).has("tuple")||e.peekType("OPEN_PAREN")?(c="tuple",u=e.popParams().map(w=>fe.from(w)),a=`tuple(${u.map(w=>w.format()).join(",")})`):(a=bi(e.popType("TYPE")),c=a);let l=null,h=null;for(;e.length&&e.peekType("BRACKET");){const w=e.pop();l=new fe(B,"",a,c,null,u,h,l),h=w.value,a+=w.text,c="array",u=null}let p=null;if(ze(e,Qf).has("indexed")){if(!t)throw new Error("");p=!0}const d=e.peekType("ID")?e.pop().text:"";if(e.length)throw new Error("leftover tokens");return new fe(B,d,a,c,p,u,h,l)}const r=e.name;E(!r||typeof r=="string"&&r.match(ea),"invalid name","obj.name",r);let s=e.indexed;s!=null&&(E(t,"parameter cannot be indexed","obj.indexed",e.indexed),s=!!s);let i=e.type,o=i.match(ad);if(o){const a=parseInt(o[2]||"-1"),c=fe.from({type:o[1],components:e.components});return new fe(B,r||"",i,"array",s,null,a,c)}if(i==="tuple"||i.startsWith("tuple(")||i.startsWith("(")){const a=e.components!=null?e.components.map(u=>fe.from(u)):null;return new fe(B,r||"",i,"tuple",s,a,null,null)}return i=bi(e.type),new fe(B,r||"",i,i,s,null,null,null)}static isParamType(e){return e&&e[ie]===vi}};let X=fe;jt=new WeakSet,Ir=function(e,t,r,s){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw new Error("array is wrong length");const o=this.arrayChildren,a=t.slice();a.forEach((c,u)=>{var l;z(l=o,jt,Ir).call(l,e,c,r,h=>{a[u]=h})}),s(a);return}if(this.isTuple()){const o=this.components;let a;if(Array.isArray(t))a=t.slice();else{if(t==null||typeof t!="object")throw new Error("invalid tuple value");a=o.map(c=>{if(!c.name)throw new Error("cannot use object value with unnamed components");if(!(c.name in t))throw new Error(`missing value for component ${c.name}`);return t[c.name]})}if(a.length!==this.components.length)throw new Error("array is wrong length");a.forEach((c,u)=>{var l;z(l=o[u],jt,Ir).call(l,e,c,r,h=>{a[u]=h})}),s(a);return}const i=r(this.type,t);i.then?e.push(async function(){s(await i)}()):s(i)};class vt{constructor(e,t,r){m(this,"type");m(this,"inputs");_s(e,B,"Fragment"),r=Object.freeze(r.slice()),R(this,{type:t,inputs:r})}static from(e){if(typeof e=="string"){try{vt.from(JSON.parse(e))}catch{}return vt.from(nt(e))}if(e instanceof ve)switch(e.peekKeyword(Yo)){case"constructor":return Le.from(e);case"error":return ne.from(e);case"event":return ke.from(e);case"fallback":case"receive":return Fe.from(e);case"function":return Re.from(e);case"struct":return mt.from(e)}else if(typeof e=="object"){switch(e.type){case"constructor":return Le.from(e);case"error":return ne.from(e);case"event":return ke.from(e);case"fallback":case"receive":return Fe.from(e);case"function":return Re.from(e);case"struct":return mt.from(e)}T(!1,`unsupported type: ${e.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}E(!1,"unsupported frgament object","obj",e)}static isConstructor(e){return Le.isFragment(e)}static isError(e){return ne.isFragment(e)}static isEvent(e){return ke.isFragment(e)}static isFunction(e){return Re.isFragment(e)}static isStruct(e){return mt.isFragment(e)}}class fn extends vt{constructor(t,r,s,i){super(t,r,i);m(this,"name");E(typeof s=="string"&&s.match(ea),"invalid identifier","name",s),i=Object.freeze(i.slice()),R(this,{name:s})}}function sr(n,e){return"("+e.map(t=>t.format(n)).join(n==="full"?", ":",")+")"}class ne extends fn{constructor(e,t,r){super(e,"error",t,r),Object.defineProperty(this,ie,{value:_i})}get selector(){return nr(this.format("sighash")).substring(0,10)}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(r=>JSON.parse(r.format(e)))});const t=[];return e!=="sighash"&&t.push("error"),t.push(this.name+sr(e,this.inputs)),t.join(" ")}static from(e){if(ne.isFragment(e))return e;if(typeof e=="string")return ne.from(nt(e));if(e instanceof ve){const t=hn("error",e),r=He(e);return bt(e),new ne(B,t,r)}return new ne(B,e.name,e.inputs?e.inputs.map(X.from):[])}static isFragment(e){return e&&e[ie]===_i}}class ke extends fn{constructor(t,r,s,i){super(t,"event",r,s);m(this,"anonymous");Object.defineProperty(this,ie,{value:Ei}),R(this,{anonymous:i})}get topicHash(){return nr(this.format("sighash"))}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(s=>JSON.parse(s.format(t)))});const r=[];return t!=="sighash"&&r.push("event"),r.push(this.name+sr(t,this.inputs)),t!=="sighash"&&this.anonymous&&r.push("anonymous"),r.join(" ")}static getTopicHash(t,r){return r=(r||[]).map(i=>X.from(i)),new ke(B,t,r,!1).topicHash}static from(t){if(ke.isFragment(t))return t;if(typeof t=="string")return ke.from(nt(t));if(t instanceof ve){const r=hn("event",t),s=He(t,!0),i=!!ze(t,te(["anonymous"])).has("anonymous");return bt(t),new ke(B,r,s,i)}return new ke(B,t.name,t.inputs?t.inputs.map(r=>X.from(r,!0)):[],!!t.anonymous)}static isFragment(t){return t&&t[ie]===Ei}}class Le extends vt{constructor(t,r,s,i,o){super(t,r,s);m(this,"payable");m(this,"gas");Object.defineProperty(this,ie,{value:xi}),R(this,{payable:i,gas:o})}format(t){if(T(t!=null&&t!=="sighash","cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),t==="json")return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(s=>JSON.parse(s.format(t)))});const r=[`constructor${sr(t,this.inputs)}`];return r.push(this.payable?"payable":"nonpayable"),this.gas!=null&&r.push(`@${this.gas.toString()}`),r.join(" ")}static from(t){if(Le.isFragment(t))return t;if(typeof t=="string")return Le.from(nt(t));if(t instanceof ve){ze(t,te(["constructor"]));const r=He(t),s=!!ze(t,te(["payable"])).has("payable"),i=na(t);return bt(t),new Le(B,"constructor",r,s,i)}return new Le(B,"constructor",t.inputs?t.inputs.map(X.from):[],!!t.payable,t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[ie]===xi}}class Fe extends vt{constructor(t,r,s){super(t,"fallback",r);m(this,"payable");Object.defineProperty(this,ie,{value:Oi}),R(this,{payable:s})}format(t){const r=this.inputs.length===0?"receive":"fallback";if(t==="json"){const s=this.payable?"payable":"nonpayable";return JSON.stringify({type:r,stateMutability:s})}return`${r}()${this.payable?" payable":""}`}static from(t){if(Fe.isFragment(t))return t;if(typeof t=="string")return Fe.from(nt(t));if(t instanceof ve){const r=t.toString(),s=t.peekKeyword(te(["fallback","receive"]));if(E(s,"type must be fallback or receive","obj",r),t.popKeyword(te(["fallback","receive"]))==="receive"){const c=He(t);return E(c.length===0,"receive cannot have arguments","obj.inputs",c),ze(t,te(["payable"])),bt(t),new Fe(B,[],!0)}let o=He(t);o.length?E(o.length===1&&o[0].type==="bytes","invalid fallback inputs","obj.inputs",o.map(c=>c.format("minimal")).join(", ")):o=[X.from("bytes")];const a=ra(t);if(E(a==="nonpayable"||a==="payable","fallback cannot be constants","obj.stateMutability",a),ze(t,te(["returns"])).has("returns")){const c=He(t);E(c.length===1&&c[0].type==="bytes","invalid fallback outputs","obj.outputs",c.map(u=>u.format("minimal")).join(", "))}return bt(t),new Fe(B,o,a==="payable")}if(t.type==="receive")return new Fe(B,[],!0);if(t.type==="fallback"){const r=[X.from("bytes")],s=t.stateMutability==="payable";return new Fe(B,r,s)}E(!1,"invalid fallback description","obj",t)}static isFragment(t){return t&&t[ie]===Oi}}class Re extends fn{constructor(t,r,s,i,o,a){super(t,"function",r,i);m(this,"constant");m(this,"outputs");m(this,"stateMutability");m(this,"payable");m(this,"gas");Object.defineProperty(this,ie,{value:Ti}),o=Object.freeze(o.slice()),R(this,{constant:s==="view"||s==="pure",gas:a,outputs:o,payable:s==="payable",stateMutability:s})}get selector(){return nr(this.format("sighash")).substring(0,10)}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(s=>JSON.parse(s.format(t))),outputs:this.outputs.map(s=>JSON.parse(s.format(t)))});const r=[];return t!=="sighash"&&r.push("function"),r.push(this.name+sr(t,this.inputs)),t!=="sighash"&&(this.stateMutability!=="nonpayable"&&r.push(this.stateMutability),this.outputs&&this.outputs.length&&(r.push("returns"),r.push(sr(t,this.outputs))),this.gas!=null&&r.push(`@${this.gas.toString()}`)),r.join(" ")}static getSelector(t,r){return r=(r||[]).map(i=>X.from(i)),new Re(B,t,"view",r,[],null).selector}static from(t){if(Re.isFragment(t))return t;if(typeof t=="string")return Re.from(nt(t));if(t instanceof ve){const r=hn("function",t),s=He(t),i=ra(t);let o=[];ze(t,te(["returns"])).has("returns")&&(o=He(t));const a=na(t);return bt(t),new Re(B,r,i,s,o,a)}return new Re(B,t.name,t.stateMutability,t.inputs?t.inputs.map(X.from):[],t.outputs?t.outputs.map(X.from):[],t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[ie]===Ti}}class mt extends fn{constructor(e,t,r){super(e,"struct",t,r),Object.defineProperty(this,ie,{value:Si})}format(){throw new Error("@TODO")}static from(e){if(typeof e=="string")return mt.from(nt(e));if(e instanceof ve){const t=hn("struct",e),r=He(e);return bt(e),new mt(B,t,r)}return new mt(B,e.name,e.inputs?e.inputs.map(X.from):[])}static isFragment(e){return e&&e[ie]===Si}}const _e=new Map;_e.set(0,"GENERIC_PANIC");_e.set(1,"ASSERT_FALSE");_e.set(17,"OVERFLOW");_e.set(18,"DIVIDE_BY_ZERO");_e.set(33,"ENUM_RANGE_ERROR");_e.set(34,"BAD_STORAGE_DATA");_e.set(49,"STACK_UNDERFLOW");_e.set(50,"ARRAY_RANGE_ERROR");_e.set(65,"OUT_OF_MEMORY");_e.set(81,"UNINITIALIZED_FUNCTION_CALL");const cd=new RegExp(/^bytes([0-9]*)$/),ud=new RegExp(/^(u?int)([0-9]*)$/);let Pn=null;function ld(n,e,t,r){let s="missing revert data",i=null;const o=null;let a=null;if(t){s="execution reverted";const u=Me(t);if(t=q(t),u.length===0)s+=" (no data present; likely require(false) occurred",i="require(false)";else if(u.length%32!==4)s+=" (could not decode reason; invalid data length)";else if(q(u.slice(0,4))==="0x08c379a0")try{i=r.decode(["string"],u.slice(4))[0],a={signature:"Error(string)",name:"Error",args:[i]},s+=`: ${JSON.stringify(i)}`}catch{s+=" (could not decode reason; invalid string data)"}else if(q(u.slice(0,4))==="0x4e487b71")try{const l=Number(r.decode(["uint256"],u.slice(4))[0]);a={signature:"Panic(uint256)",name:"Panic",args:[l]},i=`Panic due to ${_e.get(l)||"UNKNOWN"}(${l})`,s+=`: ${i}`}catch{s+=" (could not decode panic code)"}else s+=" (unknown custom error)"}const c={to:e.to?wt(e.to):null,data:e.data||"0x"};return e.from&&(c.from=wt(e.from)),an(s,"CALL_EXCEPTION",{action:n,data:t,reason:i,transaction:c,invocation:o,revert:a})}var Ze,Nt;const Jr=class{constructor(){L(this,Ze)}getDefaultValue(e){const t=e.map(s=>z(this,Ze,Nt).call(this,X.from(s)));return new Sr(t,"_").defaultValue()}encode(e,t){No(t.length,e.length,"types/values length mismatch");const r=e.map(o=>z(this,Ze,Nt).call(this,X.from(o))),s=new Sr(r,"_"),i=new Vn;return s.encode(i,t),i.data}decode(e,t,r){const s=e.map(o=>z(this,Ze,Nt).call(this,X.from(o)));return new Sr(s,"_").decode(new qn(t,r))}static defaultAbiCoder(){return Pn==null&&(Pn=new Jr),Pn}static getBuiltinCallException(e,t,r){return ld(e,t,r,Jr.defaultAbiCoder())}};let Mr=Jr;Ze=new WeakSet,Nt=function(e){if(e.isArray())return new Bf(z(this,Ze,Nt).call(this,e.arrayChildren),e.arrayLength,e.name);if(e.isTuple())return new Sr(e.components.map(r=>z(this,Ze,Nt).call(this,r)),e.name);switch(e.baseType){case"address":return new Lf(e.name);case"bool":return new Hf(e.name);case"string":return new Xf(e.name);case"bytes":return new Mf(e.name);case"":return new qf(e.name)}let t=e.type.match(ud);if(t){let r=parseInt(t[2]||"256");return E(r!==0&&r<=256&&r%8===0,"invalid "+t[1]+" bit length","param",e),new Kf(r/8,t[1]==="int",e.name)}if(t=e.type.match(cd),t){let r=parseInt(t[1]);return E(r!==0&&r<=32,"invalid bytes length","param",e),new zf(r,e.name)}E(!1,"invalid type","type",e.type)};class hd{constructor(e,t,r){m(this,"fragment");m(this,"name");m(this,"signature");m(this,"topic");m(this,"args");const s=e.name,i=e.format();R(this,{fragment:e,name:s,signature:i,topic:t,args:r})}}class fd{constructor(e,t,r,s){m(this,"fragment");m(this,"name");m(this,"args");m(this,"signature");m(this,"selector");m(this,"value");const i=e.name,o=e.format();R(this,{fragment:e,name:i,args:r,signature:o,selector:t,value:s})}}class dd{constructor(e,t,r){m(this,"fragment");m(this,"name");m(this,"args");m(this,"signature");m(this,"selector");const s=e.name,i=e.format();R(this,{fragment:e,name:s,args:r,signature:i,selector:t})}}class Ai{constructor(e){m(this,"hash");m(this,"_isIndexed");R(this,{hash:e,_isIndexed:!0})}static isIndexed(e){return!!(e&&e._isIndexed)}}const ki={0:"generic panic",1:"assert(false)",17:"arithmetic overflow",18:"division or modulo by zero",33:"enum overflow",34:"invalid encoded storage byte array accessed",49:"out-of-bounds array access; popping on an empty array",50:"out-of-bounds access of an array or bytesN",65:"out of memory",81:"uninitialized function"},Ri={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:n=>`reverted with reason string ${JSON.stringify(n)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:n=>{let e="unknown panic code";return n>=0&&n<=255&&ki[n.toString()]&&(e=ki[n.toString()]),`reverted with panic code 0x${n.toString(16)} (${e})`}}};var Te,Se,Ae,Y,or,Xn,ar,Zn;const Ft=class{constructor(e){L(this,or);L(this,ar);m(this,"fragments");m(this,"deploy");m(this,"fallback");m(this,"receive");L(this,Te,void 0);L(this,Se,void 0);L(this,Ae,void 0);L(this,Y,void 0);let t=[];typeof e=="string"?t=JSON.parse(e):t=e,I(this,Ae,new Map),I(this,Te,new Map),I(this,Se,new Map);const r=[];for(const o of t)try{r.push(vt.from(o))}catch(a){console.log("EE",a)}R(this,{fragments:Object.freeze(r)});let s=null,i=!1;I(this,Y,this.getAbiCoder()),this.fragments.forEach((o,a)=>{let c;switch(o.type){case"constructor":if(this.deploy){console.log("duplicate definition - constructor");return}R(this,{deploy:o});return;case"fallback":o.inputs.length===0?i=!0:(E(!s||o.payable!==s.payable,"conflicting fallback fragments",`fragments[${a}]`,o),s=o,i=s.payable);return;case"function":c=v(this,Ae);break;case"event":c=v(this,Se);break;case"error":c=v(this,Te);break;default:return}const u=o.format();c.has(u)||c.set(u,o)}),this.deploy||R(this,{deploy:Le.from("constructor()")}),R(this,{fallback:s,receive:i})}format(e){const t=e?"minimal":"full";return this.fragments.map(s=>s.format(t))}formatJson(){const e=this.fragments.map(t=>t.format("json"));return JSON.stringify(e.map(t=>JSON.parse(t)))}getAbiCoder(){return Mr.defaultAbiCoder()}getFunctionName(e){const t=z(this,or,Xn).call(this,e,null,!1);return E(t,"no matching function","key",e),t.name}getFunction(e,t){return z(this,or,Xn).call(this,e,t||null,!0)}forEachFunction(e){const t=Array.from(v(this,Ae).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(v(this,Ae).get(s),r)}}getEventName(e){const t=z(this,ar,Zn).call(this,e,null,!1);return E(t,"no matching event","key",e),t.name}getEvent(e,t){return z(this,ar,Zn).call(this,e,t||null,!0)}forEachEvent(e){const t=Array.from(v(this,Se).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(v(this,Se).get(s),r)}}getError(e,t){if(Qe(e)){const s=e.toLowerCase();if(Ri[s])return ne.from(Ri[s].signature);for(const i of v(this,Te).values())if(s===i.selector)return i;return null}if(e.indexOf("(")===-1){const s=[];for(const[i,o]of v(this,Te))i.split("(")[0]===e&&s.push(o);if(s.length===0)return e==="Error"?ne.from("error Error(string)"):e==="Panic"?ne.from("error Panic(uint256)"):null;if(s.length>1){const i=s.map(o=>JSON.stringify(o.format())).join(", ");E(!1,`ambiguous error description (i.e. ${i})`,"name",e)}return s[0]}if(e=ne.from(e).format(),e==="Error(string)")return ne.from("error Error(string)");if(e==="Panic(uint256)")return ne.from("error Panic(uint256)");const r=v(this,Te).get(e);return r||null}forEachError(e){const t=Array.from(v(this,Te).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(v(this,Te).get(s),r)}}_decodeParams(e,t){return v(this,Y).decode(e,t)}_encodeParams(e,t){return v(this,Y).encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){if(typeof e=="string"){const r=this.getError(e);E(r,"unknown error","fragment",e),e=r}return E(kt(t,0,4)===e.selector,`data signature does not match error ${e.name}.`,"data",t),this._decodeParams(e.inputs,kt(t,4))}encodeErrorResult(e,t){if(typeof e=="string"){const r=this.getError(e);E(r,"unknown error","fragment",e),e=r}return Dt([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionData(e,t){if(typeof e=="string"){const r=this.getFunction(e);E(r,"unknown function","fragment",e),e=r}return E(kt(t,0,4)===e.selector,`data signature does not match function ${e.name}.`,"data",t),this._decodeParams(e.inputs,kt(t,4))}encodeFunctionData(e,t){if(typeof e=="string"){const r=this.getFunction(e);E(r,"unknown function","fragment",e),e=r}return Dt([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionResult(e,t){if(typeof e=="string"){const i=this.getFunction(e);E(i,"unknown function","fragment",e),e=i}let r="invalid length for result data";const s=Be(t);if(s.length%32===0)try{return v(this,Y).decode(e.outputs,s)}catch{r="could not decode result data"}T(!1,r,"BAD_DATA",{value:q(s),info:{method:e.name,signature:e.format()}})}makeError(e,t){const r=Me(e,"data"),s=Mr.getBuiltinCallException("call",t,r),i="execution reverted (unknown custom error)";if(s.message.startsWith(i)){const a=q(r.slice(0,4)),c=this.getError(a);if(c)try{const u=v(this,Y).decode(c.inputs,r.slice(4));s.revert={name:c.name,signature:c.format(),args:u},s.reason=s.revert.signature,s.message=`execution reverted: ${s.reason}`}catch{s.message="execution reverted (coult not decode custom error)"}}const o=this.parseTransaction(t);return o&&(s.invocation={method:o.name,signature:o.signature,args:o.args}),s}encodeFunctionResult(e,t){if(typeof e=="string"){const r=this.getFunction(e);E(r,"unknown function","fragment",e),e=r}return q(v(this,Y).encode(e.outputs,t||[]))}encodeFilterTopics(e,t){if(typeof e=="string"){const i=this.getEvent(e);E(i,"unknown event","eventFragment",e),e=i}T(t.length<=e.inputs.length,`too many arguments for ${e.format()}`,"UNEXPECTED_ARGUMENT",{count:t.length,expectedCount:e.inputs.length});const r=[];e.anonymous||r.push(e.topicHash);const s=(i,o)=>i.type==="string"?nr(o):i.type==="bytes"?tt(q(o)):(i.type==="bool"&&typeof o=="boolean"&&(o=o?"0x01":"0x00"),i.type.match(/^u?int/)&&(o=Io(o)),i.type==="address"&&v(this,Y).encode(["address"],[o]),$h(q(o),32));for(t.forEach((i,o)=>{const a=e.inputs[o];if(!a.indexed){E(i==null,"cannot filter non-indexed parameters; must be null","contract."+a.name,i);return}i==null?r.push(null):a.baseType==="array"||a.baseType==="tuple"?E(!1,"filtering with tuples or arrays not supported","contract."+a.name,i):Array.isArray(i)?r.push(i.map(c=>s(a,c))):r.push(s(a,i))});r.length&&r[r.length-1]===null;)r.pop();return r}encodeEventLog(e,t){if(typeof e=="string"){const o=this.getEvent(e);E(o,"unknown event","eventFragment",e),e=o}const r=[],s=[],i=[];return e.anonymous||r.push(e.topicHash),E(t.length===e.inputs.length,"event arguments/values mismatch","values",t),e.inputs.forEach((o,a)=>{const c=t[a];if(o.indexed)if(o.type==="string")r.push(nr(c));else if(o.type==="bytes")r.push(tt(c));else{if(o.baseType==="tuple"||o.baseType==="array")throw new Error("not implemented");r.push(v(this,Y).encode([o.type],[c]))}else s.push(o),i.push(c)}),{data:v(this,Y).encode(s,i),topics:r}}decodeEventLog(e,t,r){if(typeof e=="string"){const f=this.getEvent(e);E(f,"unknown event","eventFragment",e),e=f}if(r!=null&&!e.anonymous){const f=e.topicHash;E(Qe(r[0],32)&&r[0].toLowerCase()===f,"fragment/topic mismatch","topics[0]",r[0]),r=r.slice(1)}const s=[],i=[],o=[];e.inputs.forEach((f,d)=>{f.indexed?f.type==="string"||f.type==="bytes"||f.baseType==="tuple"||f.baseType==="array"?(s.push(X.from({type:"bytes32",name:f.name})),o.push(!0)):(s.push(f),o.push(!1)):(i.push(f),o.push(!1))});const a=r!=null?v(this,Y).decode(s,Dt(r)):null,c=v(this,Y).decode(i,t,!0),u=[],l=[];let h=0,p=0;return e.inputs.forEach((f,d)=>{let w=null;if(f.indexed)if(a==null)w=new Ai(null);else if(o[d])w=new Ai(a[p++]);else try{w=a[p++]}catch(b){w=b}else try{w=c[h++]}catch(b){w=b}u.push(w),l.push(f.name||null)}),Hr.fromItems(u,l)}parseTransaction(e){const t=Me(e.data,"tx.data"),r=Ot(e.value!=null?e.value:0,"tx.value"),s=this.getFunction(q(t.slice(0,4)));if(!s)return null;const i=v(this,Y).decode(s.inputs,t.slice(4));return new fd(s,s.selector,i,r)}parseCallResult(e){throw new Error("@TODO")}parseLog(e){const t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new hd(t,t.topicHash,this.decodeEventLog(t,e.data,e.topics))}parseError(e){const t=q(e),r=this.getError(kt(t,0,4));if(!r)return null;const s=v(this,Y).decode(r.inputs,kt(t,4));return new dd(r,r.selector,s)}static from(e){return e instanceof Ft?e:typeof e=="string"?new Ft(JSON.parse(e)):typeof e.format=="function"?new Ft(e.format("json")):new Ft(e)}};let Kn=Ft;Te=new WeakMap,Se=new WeakMap,Ae=new WeakMap,Y=new WeakMap,or=new WeakSet,Xn=function(e,t,r){if(Qe(e)){const i=e.toLowerCase();for(const o of v(this,Ae).values())if(i===o.selector)return o;return null}if(e.indexOf("(")===-1){const i=[];for(const[o,a]of v(this,Ae))o.split("(")[0]===e&&i.push(a);if(t){const o=t.length>0?t[t.length-1]:null;let a=t.length,c=!0;Q.isTyped(o)&&o.type==="overrides"&&(c=!1,a--);for(let u=i.length-1;u>=0;u--){const l=i[u].inputs.length;l!==a&&(!c||l!==a-1)&&i.splice(u,1)}for(let u=i.length-1;u>=0;u--){const l=i[u].inputs;for(let h=0;h<t.length;h++)if(Q.isTyped(t[h])){if(h>=l.length){if(t[h].type==="overrides")continue;i.splice(u,1);break}if(t[h].type!==l[h].baseType){i.splice(u,1);break}}}}if(i.length===1&&t&&t.length!==i[0].inputs.length){const o=t[t.length-1];(o==null||Array.isArray(o)||typeof o!="object")&&i.splice(0,1)}if(i.length===0)return null;if(i.length>1&&r){const o=i.map(a=>JSON.stringify(a.format())).join(", ");E(!1,`ambiguous function description (i.e. matches ${o})`,"key",e)}return i[0]}const s=v(this,Ae).get(Re.from(e).format());return s||null},ar=new WeakSet,Zn=function(e,t,r){if(Qe(e)){const i=e.toLowerCase();for(const o of v(this,Se).values())if(i===o.topicHash)return o;return null}if(e.indexOf("(")===-1){const i=[];for(const[o,a]of v(this,Se))o.split("(")[0]===e&&i.push(a);if(t){for(let o=i.length-1;o>=0;o--)i[o].inputs.length<t.length&&i.splice(o,1);for(let o=i.length-1;o>=0;o--){const a=i[o].inputs;for(let c=0;c<t.length;c++)if(Q.isTyped(t[c])&&t[c].type!==a[c].baseType){i.splice(o,1);break}}}if(i.length===0)return null;if(i.length>1&&r){const o=i.map(a=>JSON.stringify(a.format())).join(", ");E(!1,`ambiguous event description (i.e. matches ${o})`,"key",e)}return i[0]}const s=v(this,Se).get(ke.from(e).format());return s||null};const pd=BigInt(0);function De(n){return n==null?null:n.toString()}function yd(n){const e={};n.to&&(e.to=n.to),n.from&&(e.from=n.from),n.data&&(e.data=q(n.data));const t="chainId,gasLimit,gasPrice,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const s of t)!(s in n)||n[s]==null||(e[s]=Ot(n[s],`request.${s}`));const r="type,nonce".split(/,/);for(const s of r)!(s in n)||n[s]==null||(e[s]=qe(n[s],`request.${s}`));return n.accessList&&(e.accessList=Zf(n.accessList)),"blockTag"in n&&(e.blockTag=n.blockTag),"enableCcipRead"in n&&(e.enableCcipReadEnabled=!!n.enableCcipRead),"customData"in n&&(e.customData=n.customData),e}class Ts{constructor(e,t){m(this,"provider");m(this,"transactionHash");m(this,"blockHash");m(this,"blockNumber");m(this,"removed");m(this,"address");m(this,"data");m(this,"topics");m(this,"index");m(this,"transactionIndex");this.provider=t;const r=Object.freeze(e.topics.slice());R(this,{transactionHash:e.transactionHash,blockHash:e.blockHash,blockNumber:e.blockNumber,removed:e.removed,address:e.address,data:e.data,topics:r,index:e.index,transactionIndex:e.transactionIndex})}toJSON(){const{address:e,blockHash:t,blockNumber:r,data:s,index:i,removed:o,topics:a,transactionHash:c,transactionIndex:u}=this;return{_type:"log",address:e,blockHash:t,blockNumber:r,data:s,index:i,removed:o,topics:a,transactionHash:c,transactionIndex:u}}async getBlock(){const e=await this.provider.getBlock(this.blockHash);return T(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransaction(){const e=await this.provider.getTransaction(this.transactionHash);return T(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransactionReceipt(){const e=await this.provider.getTransactionReceipt(this.transactionHash);return T(!!e,"failed to find transaction receipt","UNKNOWN_ERROR",{}),e}removedEvent(){return gd(this)}}var cr;class md{constructor(e,t){m(this,"provider");m(this,"to");m(this,"from");m(this,"contractAddress");m(this,"hash");m(this,"index");m(this,"blockHash");m(this,"blockNumber");m(this,"logsBloom");m(this,"gasUsed");m(this,"cumulativeGasUsed");m(this,"gasPrice");m(this,"type");m(this,"status");m(this,"root");L(this,cr,void 0);I(this,cr,Object.freeze(e.logs.map(r=>new Ts(r,t)))),R(this,{provider:t,to:e.to,from:e.from,contractAddress:e.contractAddress,hash:e.hash,index:e.index,blockHash:e.blockHash,blockNumber:e.blockNumber,logsBloom:e.logsBloom,gasUsed:e.gasUsed,cumulativeGasUsed:e.cumulativeGasUsed,gasPrice:e.effectiveGasPrice||e.gasPrice,type:e.type,status:e.status,root:e.root})}get logs(){return v(this,cr)}toJSON(){const{to:e,from:t,contractAddress:r,hash:s,index:i,blockHash:o,blockNumber:a,logsBloom:c,logs:u,status:l,root:h}=this;return{_type:"TransactionReceipt",blockHash:o,blockNumber:a,contractAddress:r,cumulativeGasUsed:De(this.cumulativeGasUsed),from:t,gasPrice:De(this.gasPrice),gasUsed:De(this.gasUsed),hash:s,index:i,logs:u,logsBloom:c,root:h,status:l,to:e}}get length(){return this.logs.length}[Symbol.iterator](){let e=0;return{next:()=>e<this.length?{value:this.logs[e++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const e=await this.provider.getBlock(this.blockHash);if(e==null)throw new Error("TODO");return e}async getTransaction(){const e=await this.provider.getTransaction(this.hash);if(e==null)throw new Error("TODO");return e}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return ia(this)}reorderedEvent(e){return T(!e||e.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),sa(this,e)}}cr=new WeakMap;var Ye;const Cs=class{constructor(e,t){m(this,"provider");m(this,"blockNumber");m(this,"blockHash");m(this,"index");m(this,"hash");m(this,"type");m(this,"to");m(this,"from");m(this,"nonce");m(this,"gasLimit");m(this,"gasPrice");m(this,"maxPriorityFeePerGas");m(this,"maxFeePerGas");m(this,"data");m(this,"value");m(this,"chainId");m(this,"signature");m(this,"accessList");L(this,Ye,void 0);this.provider=t,this.blockNumber=e.blockNumber!=null?e.blockNumber:null,this.blockHash=e.blockHash!=null?e.blockHash:null,this.hash=e.hash,this.index=e.index,this.type=e.type,this.from=e.from,this.to=e.to||null,this.gasLimit=e.gasLimit,this.nonce=e.nonce,this.data=e.data,this.value=e.value,this.gasPrice=e.gasPrice,this.maxPriorityFeePerGas=e.maxPriorityFeePerGas!=null?e.maxPriorityFeePerGas:null,this.maxFeePerGas=e.maxFeePerGas!=null?e.maxFeePerGas:null,this.chainId=e.chainId,this.signature=e.signature,this.accessList=e.accessList!=null?e.accessList:null,I(this,Ye,-1)}toJSON(){const{blockNumber:e,blockHash:t,index:r,hash:s,type:i,to:o,from:a,nonce:c,data:u,signature:l,accessList:h}=this;return{_type:"TransactionReceipt",accessList:h,blockNumber:e,blockHash:t,chainId:De(this.chainId),data:u,from:a,gasLimit:De(this.gasLimit),gasPrice:De(this.gasPrice),hash:s,maxFeePerGas:De(this.maxFeePerGas),maxPriorityFeePerGas:De(this.maxPriorityFeePerGas),nonce:c,signature:l,to:o,index:r,type:i,value:De(this.value)}}async getBlock(){let e=this.blockNumber;if(e==null){const r=await this.getTransaction();r&&(e=r.blockNumber)}if(e==null)return null;const t=this.provider.getBlock(e);if(t==null)throw new Error("TODO");return t}async getTransaction(){return this.provider.getTransaction(this.hash)}async wait(e,t){const r=e??1,s=t??0;let i=v(this,Ye),o=-1,a=i===-1;const c=async()=>{if(a)return null;const{blockNumber:h,nonce:p}=await Ro({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(p<this.nonce){i=h;return}if(a)return null;const f=await this.getTransaction();if(!(f&&f.blockNumber!=null))for(o===-1&&(o=i-3,o<v(this,Ye)&&(o=v(this,Ye)));o<=h;){if(a)return null;const d=await this.provider.getBlock(o,!0);if(d==null)return;for(const w of d)if(w===this.hash)return;for(let w=0;w<d.length;w++){const b=await d.getTransaction(w);if(b.from===this.from&&b.nonce===this.nonce){if(a)return null;const O=await this.provider.getTransactionReceipt(b.hash);if(O==null||h-O.blockNumber+1<r)return;let P="replaced";b.data===this.data&&b.to===this.to&&b.value===this.value?P="repriced":b.data==="0x"&&b.from===b.to&&b.value===pd&&(P="cancelled"),T(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:P==="replaced"||P==="cancelled",reason:P,replacement:b.replaceableTransaction(i),hash:b.hash,receipt:O})}}o++}},u=await this.provider.getTransactionReceipt(this.hash);if(u){if(await u.confirmations()>=r)return u}else if(await c(),r===0)return null;return await new Promise((h,p)=>{const f=[],d=()=>{f.forEach(b=>b())};if(f.push(()=>{a=!0}),s>0){const b=setTimeout(()=>{d(),p(an("wait for transaction timeout","TIMEOUT"))},s);f.push(()=>{clearTimeout(b)})}const w=async b=>{await b.confirmations()>=r&&(d(),h(b))};if(f.push(()=>{this.provider.off(this.hash,w)}),this.provider.on(this.hash,w),i>=0){const b=async()=>{try{await c()}catch(O){if(Br(O,"TRANSACTION_REPLACED")){d(),p(O);return}}a||this.provider.once("block",b)};f.push(()=>{this.provider.off("block",b)}),this.provider.once("block",b)}})}isMined(){return this.blockHash!=null}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}removedEvent(){return T(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),ia(this)}reorderedEvent(e){return T(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),T(!e||e.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),sa(this,e)}replaceableTransaction(e){E(Number.isInteger(e)&&e>=0,"invalid startBlock","startBlock",e);const t=new Cs(this,this.provider);return I(t,Ye,e),t}};let Yn=Cs;Ye=new WeakMap;function sa(n,e){return{orphan:"reorder-transaction",tx:n,other:e}}function ia(n){return{orphan:"drop-transaction",tx:n}}function gd(n){return{orphan:"drop-log",log:{transactionHash:n.transactionHash,blockHash:n.blockHash,blockNumber:n.blockNumber,address:n.address,data:n.data,topics:Object.freeze(n.topics.slice()),index:n.index}}}class Ss extends Ts{constructor(t,r,s){super(t,t.provider);m(this,"interface");m(this,"fragment");m(this,"args");const i=r.decodeEventLog(s,t.data,t.topics);R(this,{args:i,fragment:s,interface:r})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}var Bt;class wd extends md{constructor(t,r,s){super(s,r);L(this,Bt,void 0);I(this,Bt,t)}get logs(){return super.logs.map(t=>{const r=t.topics.length?v(this,Bt).getEvent(t.topics[0]):null;return r?new Ss(t,v(this,Bt),r):t})}}Bt=new WeakMap;var ur;class As extends Yn{constructor(t,r,s){super(s,r);L(this,ur,void 0);I(this,ur,t)}async wait(t){const r=await super.wait();return r==null?null:new wd(v(this,ur),this.provider,r)}}ur=new WeakMap;class oa extends Uh{constructor(t,r,s,i){super(t,r,s);m(this,"log");R(this,{log:i})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}}class bd extends oa{constructor(e,t,r,s,i){super(e,t,r,new Ss(i,e.interface,s));const o=e.interface.decodeEventLog(s,this.log.data,this.log.topics);R(this,{args:o,fragment:s})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const Pi=BigInt(0);function aa(n){return n&&typeof n.call=="function"}function ca(n){return n&&typeof n.estimateGas=="function"}function ks(n){return n&&typeof n.resolveName=="function"}function ua(n){return n&&typeof n.sendTransaction=="function"}var lr;class vd{constructor(e,t,r){L(this,lr,void 0);m(this,"fragment");if(R(this,{fragment:t}),t.inputs.length<r.length)throw new Error("too many arguments");const s=_t(e.runner,"resolveName"),i=ks(s)?s:null;I(this,lr,async function(){const o=await Promise.all(t.inputs.map((a,c)=>r[c]==null?null:a.walkAsync(r[c],(l,h)=>l==="address"?Os(h,i):h)));return e.interface.encodeFilterTopics(t,o)}())}getTopicFilter(){return v(this,lr)}}lr=new WeakMap;function _d(){return Function}function _t(n,e){return n==null?null:typeof n[e]=="function"?n:n.provider&&typeof n.provider[e]=="function"?n.provider:null}function ht(n){return n==null?null:n.provider||null}async function la(n,e){const t=yd(Q.dereference(n,"overrides"));return E(t.to==null||(e||[]).indexOf("to")>=0,"cannot override to","overrides.to",t.to),E(t.data==null||(e||[]).indexOf("data")>=0,"cannot override data","overrides.data",t.data),t.from&&(t.from=await Os(t.from)),t}async function Ed(n,e,t){const r=_t(n,"resolveName"),s=ks(r)?r:null;return await Promise.all(e.map((i,o)=>i.walkAsync(t[o],(a,c)=>(c=Q.dereference(c,a),a==="address"?Os(c,s):c))))}class xd{constructor(e){m(this,"_contract");return R(this,{_contract:e}),new Proxy(this,{apply:async(r,s,i)=>await r.send(...i)})}async populateTransaction(e){const t=await la(e,["data"]);t.to=await this._contract.getAddress();const r=this._contract.interface,s=r.receive||r.fallback&&r.fallback.payable;return E(s||(t.value||Pi)===Pi,"cannot send value to non-payable contract","overrides.value",t.value),E(r.fallback||(t.data||"0x")==="0x","cannot send data to receive-only contract","overrides.data",t.data),t}async staticCall(e){const t=_t(this._contract.runner,"call");T(aa(t),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const r=await this.populateTransaction(e);try{return await t.call(r)}catch(s){throw Po(s)&&s.data?this._contract.interface.makeError(s.data,r):s}}async send(e){const t=this._contract.runner;T(ua(t),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const r=await t.sendTransaction(await this.populateTransaction(e)),s=ht(this._contract.runner);return new As(this._contract.interface,s,r)}async estimateGas(e){const t=_t(this._contract.runner,"estimateGas");return T(ca(t),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await t.estimateGas(await this.populateTransaction(e))}}class Od extends _d(){constructor(t,r){super();m(this,"name","");m(this,"_contract");m(this,"_key");return R(this,{name:t.interface.getFunctionName(r),_contract:t,_key:r}),new Proxy(this,{apply:async(i,o,a)=>i.getFragment(...a).constant?await i.staticCall(...a):await i.send(...a)})}get fragment(){const t=this._contract.interface.getFunction(this._key);return T(t,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment"}),t}getFragment(...t){const r=this._contract.interface.getFunction(this._key,t);return T(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment"}),r}async populateTransaction(...t){const r=this.getFragment(...t);let s={};if(r.inputs.length+1===t.length&&(s=await la(t.pop())),r.inputs.length!==t.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const i=await Ed(this._contract.runner,r.inputs,t);return Object.assign({},s,await Ro({to:this._contract.getAddress(),data:this._contract.interface.encodeFunctionData(r,i)}))}async staticCall(...t){const r=await this.staticCallResult(...t);return r.length===1?r[0]:r}async send(...t){const r=this._contract.runner;T(ua(r),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const s=await r.sendTransaction(await this.populateTransaction(...t)),i=ht(this._contract.runner);return new As(this._contract.interface,i,s)}async estimateGas(...t){const r=_t(this._contract.runner,"estimateGas");return T(ca(r),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await r.estimateGas(await this.populateTransaction(...t))}async staticCallResult(...t){const r=_t(this._contract.runner,"call");T(aa(r),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const s=await this.populateTransaction(...t);let i="0x";try{i=await r.call(s)}catch(a){throw Po(a)&&a.data?this._contract.interface.makeError(a.data,s):a}const o=this.getFragment(...t);return this._contract.interface.decodeFunctionResult(o,i)}}function Td(){return Function}class Sd extends Td(){constructor(t,r){super();m(this,"name","");m(this,"_contract");m(this,"_key");return R(this,{name:t.interface.getEventName(r),_contract:t,_key:r}),new Proxy(this,{apply:(s,i,o)=>new vd(t,s.getFragment(...o),o)})}get fragment(){const t=this._contract.interface.getEvent(this._key);return T(t,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment"}),t}getFragment(...t){const r=this._contract.interface.getEvent(this._key,t);return T(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment"}),r}}const zr=Symbol.for("_ethersInternal_contract"),ha=new WeakMap;function Ad(n,e){ha.set(n[zr],e)}function he(n){return ha.get(n[zr])}function kd(n){return n&&typeof n=="object"&&"getTopicFilter"in n&&typeof n.getTopicFilter=="function"&&n.fragment}async function Rs(n,e){let t,r=null;if(Array.isArray(e)){const i=function(o){if(Qe(o,32))return o;const a=n.interface.getEvent(o);return E(a,"unknown fragment","name",o),a.topicHash};t=e.map(o=>o==null?null:Array.isArray(o)?o.map(i):i(o))}else e==="*"?t=[null]:typeof e=="string"?Qe(e,32)?t=[e]:(r=n.interface.getEvent(e),E(r,"unknown fragment","event",e),t=[r.topicHash]):kd(e)?t=await e.getTopicFilter():"fragment"in e?(r=e.fragment,t=[r.topicHash]):E(!1,"unknown event name","event",e);t=t.map(i=>{if(i==null)return null;if(Array.isArray(i)){const o=Array.from(new Set(i.map(a=>a.toLowerCase())).values());return o.length===1?o[0]:(o.sort(),o)}return i.toLowerCase()});const s=t.map(i=>i==null?"null":Array.isArray(i)?i.join("|"):i).join("&");return{fragment:r,tag:s,topics:t}}async function Xt(n,e){const{subs:t}=he(n);return t.get((await Rs(n,e)).tag)||null}async function Ni(n,e,t){const r=ht(n.runner);T(r,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:e});const{fragment:s,tag:i,topics:o}=await Rs(n,t),{addr:a,subs:c}=he(n);let u=c.get(i);if(!u){const h={address:a||n,topics:o},p=b=>{let O=s;if(O==null)try{O=n.interface.getEvent(b.topics[0])}catch{}if(O){const P=O,M=s?n.interface.decodeEventLog(s,b.data,b.topics):[];es(n,t,M,U=>new bd(n,U,t,P,b))}else es(n,t,[],P=>new oa(n,P,t,b))};let f=[];u={tag:i,listeners:[],start:()=>{f.length||f.push(r.on(h,p))},stop:async()=>{if(f.length==0)return;let b=f;f=[],await Promise.all(b),r.off(h,p)}},c.set(i,u)}return u}let Qn=Promise.resolve();async function Rd(n,e,t,r){await Qn;const s=await Xt(n,e);if(!s)return!1;const i=s.listeners.length;return s.listeners=s.listeners.filter(({listener:o,once:a})=>{const c=Array.from(t);r&&c.push(r(a?null:o));try{o.call(n,...c)}catch{}return!a}),i>0}async function es(n,e,t,r){try{await Qn}catch{}const s=Rd(n,e,t,r);return Qn=s,await s}const $i=["then"];var jd;const Gr=class{constructor(e,t,r,s){m(this,"target");m(this,"interface");m(this,"runner");m(this,"filters");m(this,jd);m(this,"fallback");r==null&&(r=null);const i=Kn.from(t);R(this,{target:e,runner:r,interface:i}),Object.defineProperty(this,zr,{value:{}});let o,a=null,c=null;if(s){const h=ht(r);c=new As(this.interface,h,s)}let u=new Map;if(typeof e=="string")if(Qe(e))a=e,o=Promise.resolve(e);else{const h=_t(r,"resolveName");if(!ks(h))throw an("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});o=h.resolveName(e).then(p=>{if(p==null)throw new Error("TODO");return he(this).addr=p,p})}else o=e.getAddress().then(h=>{if(h==null)throw new Error("TODO");return he(this).addr=h,h});Ad(this,{addrPromise:o,addr:a,deployTx:c,subs:u});const l=new Proxy({},{get:(h,p,f)=>{if($i.indexOf(p)>=0)return Reflect.get(h,p,f);const d=String(p),w=this.getEvent(d);if(w)return w;throw new Error(`unknown contract event: ${d}`)}});return R(this,{filters:l}),R(this,{fallback:i.receive||i.fallback?new xd(this):null}),new Proxy(this,{get:(h,p,f)=>{if(p in h||$i.indexOf(p)>=0)return Reflect.get(h,p,f);const d=String(p),w=h.getFunction(d);if(w)return w;throw new Error(`unknown contract method: ${d}`)}})}connect(e){return new Gr(this.target,this.interface,e)}async getAddress(){return await he(this).addrPromise}async getDeployedCode(){const e=ht(this.runner);T(e,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const t=await e.getCode(await this.getAddress());return t==="0x"?null:t}async waitForDeployment(){const e=this.deploymentTransaction();if(e)return await e.wait(),this;if(await this.getDeployedCode()!=null)return this;const r=ht(this.runner);return T(r!=null,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise((s,i)=>{const o=async()=>{try{if(await this.getDeployedCode()!=null)return s(this);r.once("block",o)}catch(a){i(a)}};o()})}deploymentTransaction(){return he(this).deployTx}getFunction(e){return typeof e!="string"&&(e=e.format()),new Od(this,e)}getEvent(e){return typeof e!="string"&&(e=e.format()),new Sd(this,e)}async queryTransaction(e){throw new Error("@TODO")}async queryFilter(e,t,r){t==null&&(t=0),r==null&&(r="latest");const{addr:s,addrPromise:i}=he(this),o=s||await i,{fragment:a,topics:c}=await Rs(this,e),u={address:o,topics:c,fromBlock:t,toBlock:r},l=ht(this.runner);return T(l,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await l.getLogs(u)).map(h=>{let p=a;if(p==null)try{p=this.interface.getEvent(h.topics[0])}catch{}return p?new Ss(h,this.interface,p):new Ts(h,l)})}async on(e,t){const r=await Ni(this,"on",e);return r.listeners.push({listener:t,once:!1}),r.start(),this}async once(e,t){const r=await Ni(this,"once",e);return r.listeners.push({listener:t,once:!0}),r.start(),this}async emit(e,...t){return await es(this,e,t,null)}async listenerCount(e){if(e){const s=await Xt(this,e);return s?s.listeners.length:0}const{subs:t}=he(this);let r=0;for(const{listeners:s}of t.values())r+=s.length;return r}async listeners(e){if(e){const s=await Xt(this,e);return s?s.listeners.map(({listener:i})=>i):[]}const{subs:t}=he(this);let r=[];for(const{listeners:s}of t.values())r=r.concat(s.map(({listener:i})=>i));return r}async off(e,t){const r=await Xt(this,e);if(!r)return this;if(t){const s=r.listeners.map(({listener:i})=>i).indexOf(t);s>=0&&r.listeners.splice(s,1)}return(t==null||r.listeners.length===0)&&(r.stop(),he(this).subs.delete(r.tag)),this}async removeAllListeners(e){if(e){const t=await Xt(this,e);if(!t)return this;t.stop(),he(this).subs.delete(t.tag)}else{const{subs:t}=he(this);for(const{tag:r,stop:s}of t.values())s(),t.delete(r)}return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return await this.off(e,t)}static buildClass(e){class t extends Gr{constructor(s,i=null){super(s,e,i)}}return t}static from(e,t,r){return r==null&&(r=null),new this(e,t,r)}};let ts=Gr;jd=zr;function Pd(){return ts}class Nd extends Pd(){}class pr{constructor(e){m(this,"data",[]);this.api=e}static create(e){return new pr(e)}getAbiHash(e){if(this.api===void 0)throw new Error("FunctionBuilder must be initialised with api");return this.api.getAbiHash(e)}async addFunction(e,t,r,s,i){const o=new Nd(e,s);return o.interface.encodeFunctionData(t,r),this.data.push({address:e,bytecode:o.interface.encodeFunctionData(t,r),abiHash:i||await this.getAbiHash(s),function:t}),this}get(){return this.data}static schema(){return gt().of(ue({address:A().required(),bytecode:A().matches(/^(0x)?([0-9a-fA-F]{2})*$/).required(),abiHash:A().matches(/^[A-Fa-f0-9]{64}/).required(),function:A().required()}))}}class Ke{static version(){return"v1"}static execute(e,t,r="v1"){const s=JSON.parse(JSON.stringify(t));let i=!0;for(const o of s){const a=Ke.process(e,o.conditions);i=Ke.execLogic(i,o.logic,a)}return i}static process(e,t,r){const s=t.shift();if(!s)return r===void 0?!0:r;const i=Ke.execCondition(e,s);if(r===void 0||s.logic==="WHERE")return Ke.process(e,t,i);if(s.logic===void 0)throw new Error("Invalid filter. FilterCondition must have logic value");const o=Ke.execLogic(r,s.logic,i);return Ke.process(e,t,o)}static execLogic(e,t,r){switch(t){case"AND":return e&&r;case"OR":return e||r;case"XOR":return(e||r)&&!(e&&r);case"NAND":return!(e&&r);case"NOR":return!(e&&r);case"WHERE":return r;default:throw new Error(`Invalid Filter. Bad logic value: ${t}`)}}static execCondition(e,t){const r=e[t.key];if(t.type==="Number"){if(typeof t.constant!="number"||typeof r!="number")throw new Error(`Invalid filter. Type miss-match. Type: ${t.type}, Variable: ${t.constant}, Data: ${r}`);const s=r,i=t.constant;switch(t.operation){case"eq":return s===i;case"!eq":return s!==i;case"gt":return s>i;case"gte":return s>=i;case"lt":return s<i;case"lte":return s<=i;default:throw new Error("Invalid Filter. Operation does not match type")}}if(t.type==="String"){if(typeof t.constant!="string"||typeof r!="string")throw new Error(`Invalid filter. Type miss-match. Type: ${t.type}, Variable: ${t.constant}, Data: ${r}`);const s=r,i=t.constant;switch(t.operation){case"contains":return s.includes(i);case"!contains":return!s.includes(i);case"is":return s===i;case"!is":return s!==i;case"isEmpty":return s==="";case"!isEmpty":return s!=="";default:throw new Error("Invalid Filter. Operation does not match type")}}if(t.type==="Address"){if(typeof t.constant!="string"||typeof r!="string")throw new Error(`Invalid filter. Type miss-match. Type: ${t.type}, Variable: ${t.constant}, Data: ${r}`);const s=r,i=t.constant;switch(t.operation){case"contains":return s.toLowerCase().includes(i.toLowerCase());case"!contains":return!s.toLowerCase().includes(i.toLowerCase());case"is":return s.toLowerCase()===i.toLowerCase();case"!is":return s.toLowerCase()!==i.toLowerCase();case"isEmpty":return s==="";case"!isEmpty":return s!=="";default:throw new Error("Invalid Filter. Operation does not match type")}}throw new Error("Invalid Filter. Unknown Type")}}class yr{constructor(){m(this,"groups",[]);this.newGroup("WHERE")}static version(){return Ke.version()}static new(){return new yr}newGroup(e){if(this.groups.length!==0&&e==="WHERE")throw new Error('Only the first groups can start with "WHERE"');return this.groups.push({logic:"WHERE",conditions:[]}),this}addCondition(e,t,r,s,i){const o=this.groups[this.groups.length-1];if(o.conditions.length===0&&e!=="WHERE")throw new Error('Logic for the first condition of a group must be "WHERE"');if(o.conditions.length>0&&e==="WHERE")throw new Error('Only the first condition of a group can be "WHERE"');return o.conditions.push({logic:e,key:t,type:r,operation:s,constant:i}),this}finalise(){for(const e of this.groups)if(e.conditions.length===0)throw new Error("Bad Filter. All Groups must have atleast one condition");return this.groups}static schema(){const e=A().oneOf(["AND","OR","XOR","NAND","NOR","WHERE"]).required(),t=ue({logic:e,key:A().required(),type:A().oneOf(["String","Address","Number"]).required(),operation:A().when("type",([r],s)=>{switch(r){case"String":return s.oneOf(["contains","!contains","is","!is","isEmpty","!isEmpty"]);case"Address":return s.oneOf(["is","!is","isEmpty","!isEmpty"]);case"Number":return s.oneOf(["eq","!eq","gt","gte","lt","lte"]);default:throw new Error("Invalid Filter Data Type")}}).required(),constant:vo().when("type",([r])=>{switch(r){case"String":return A();case"Address":return A();case"Number":return K();default:throw new Error("Invalid Filter Data Type")}}).required()});return gt().of(ue({logic:e,conditions:gt().of(t).required()}))}}const $d="handler_function_call_v2",Cd=/^(\d+)([SMHD])$/i,Ci=ue({timeBase:A().oneOf(["blocks","time"]).required(),nBlocks:K().min(10).when("timeBase",([n],e)=>n==="blocks"?e.required():e),timePeriod:A().matches(Cd,"timePeriod must be of the format n[s|m|h|d], eg 10s for 10 seconds").when("timeBase",([n],e)=>n==="time"?e.required():e),startTime:K().default(0),debounceCount:K().default(0),functions:pr.schema().required(),triggerOn:A().oneOf(["always","filter"]).default("always"),latch:gs().default(!1),filterVersion:A().when("triggerOn",([n],e)=>n==="filter"?e.default("0"):e.nullable().default(null)).required(),filter:yr.schema().when("triggerOn",([n],e)=>n==="filter"?e.required():e.nullable().default(null)).required()});class Ii{static async SimpleToRaw(e,t,r){return{alertType:"event",network:t,nickname:e,type:$d,handler:await this.validate(r)}}static validate(e){return Ci.validateSync(e)}static async convertFromPartial(e){return Ci.validate(e)}}const Id="handler_onchain_event_v2",Fd=ue({addresses:gt().of(A().required()).required(),abiHash:A().required(),event:A().required(),debounceCount:K().default(0),functions:pr.schema().nullable().default(null),triggerOn:A().oneOf(["always","filter"]).default("always"),latch:gs().default(!1),filterVersion:A().nullable().default(null),filter:yr.schema().when("triggerOn",([n],e)=>n==="filter"?e:e.nullable().default(null)).required()});class Fi{static async SimpleToRaw(e,t,r){return{alertType:"event",network:t,nickname:e,type:Id,handler:await this.validate(r)}}static validate(e){return Fd.validateSync(e)}}class Fr{static SimpleToRaw(e,t,r,s){switch(t){case"PollFunctionV2":return Ii.SimpleToRaw(e,r,s);case"PollFunctionV1":return ci.SimpleToRaw(e,r,s);case"OnchainEventV1":return ui.SimpleToRaw(e,r,s);case"OnchainEventV2":return Fi.SimpleToRaw(e,r,s);default:throw new Error("Invalid Trigger ID")}}static Validate(e,t){switch(e){case"PollFunctionV2":return Ii.validate(t);case"PollFunctionV1":return ci.validate(t);case"OnchainEventV1":return ui.validate(t);case"OnchainEventV2":return Fi.validate(t);default:throw new Error("Invalid Trigger ID")}}static RawToSimple(e){return{...{error:e.error,error_message:e.error_message,error_timestamp:e.error_timestamp},...e.handler}}static SimpleTypeToRawType(e){switch(e){case"PollFunctionV2":return"handler_function_call_v2";case"PollFunctionV1":return"handler_function_call";case"OnchainEventV1":return"handler_onchain_event";case"OnchainEventV2":return"handler_onchain_event_v2";default:throw new Error("Invalid Trigger ID")}}static RawTypeToSimpleType(e){switch(e){case"handler_function_call_v2":return"PollFunctionV2";case"handler_function_call":return"PollFunctionV1";case"handler_onchain_event":return"OnchainEventV1";case"handler_onchain_event_v2":return"OnchainEventV2";default:throw new Error("Invalid Trigger ID")}}}const Di=n=>`https://${n}.functions.supabase.co/`,Ui=n=>`https://${n}.supabase.co/`,Li="fdgtrxmmrtlokhgkvcjz",Dd="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZkZ3RyeG1tcnRsb2toZ2t2Y2p6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2NzMwODcwNzYsImV4cCI6MTk4ODY2MzA3Nn0.sAMxjlcJSSozBGr-LNcsudyxzUEM9e-UspMHHQLqLr4";class Ps{constructor(e,t){m(this,"headers",{});this.url=e,this.headers={Authorization:`Bearer ${t}`,"Content-Type":"application/json"}}static async create(e){var t,r;if(e.key)throw new Error("Auth by key not yet supported");if(e.email&&e.password){const s=e.projectId?Ui(e.projectId):Ui(Li),i=e.projectId?Di(e.projectId):Di(Li),o=e.anonKey?e.anonKey:Dd,a=mu(s,o),{data:c,error:u}=await a.auth.signInWithPassword({email:e.email,password:e.password});if(u)throw u;if(((t=c.session)==null?void 0:t.access_token)===void 0)throw new Error("Access token not found");return new Ps(i,(r=c.session)==null?void 0:r.access_token)}else throw new Error("Authentication Required. DeNotify supports either username/password or API key authentication")}async alertHistory(e,t){const r="alert-history",s=t||{};return e&&(s.id=e),Object.keys(s).length>0?await this.request("get",r,{params:t}):await this.request("get",r)}async getAlert(e){const t=(await this.request("get",`alerts/${e}`))[0];return await this.decode(t)}async getAlerts(){const e=await this.request("get","alerts");return Promise.all(e.map(t=>this.decode(t)))}async createAlert(e){const t=await this.encode(e);return await this.request("post","alerts",{body:t})}async deleteAlert(e){return await this.request("delete",`alerts/${e}`)}async decode(e){return{id:e.alertId,name:e.trigger.nickname,network:e.trigger.network,triggerId:Fr.RawTypeToSimpleType(e.trigger.type),trigger:await Fr.RawToSimple(e.trigger),notificationId:An.RawTypeToSimpleType(e.notification.notify_type),notification:await An.RawToSimple(e.notification)}}async encode(e){return{trigger:await Fr.SimpleToRaw(e.name,e.triggerId,e.network,e.trigger),notification:await An.SimpleToRaw(e.notificationId,e.notification)}}async request(e,t,r={}){const s=new URL(`${this.url}${t}`);if(r.params)for(const a of Object.keys(r.params))s.searchParams.append(a,r.params[a]);const i={method:e,url:s.toString(),headers:this.headers};return r.body&&(i.data=r.body),(await Pl(i)).data}async getAbi(e,t){return await this.request("get",`abi/${e}/${t}`)}async getAbiHash(e){return(await this.request("post","abi",{body:e})).hash}async setAlertName(e,t){throw new Error("Not yet supported - Sorry!")}async enableAlert(e){throw new Error("Not yet supported - Sorry!")}async disableAlert(e){throw new Error("Not yet supported - Sorry!")}async updateNotification(e){throw new Error("Not yet supported - Sorry!")}async updateTrigger(e,t){return await this.request("patch",`alerts/trigger-handler/${e}`,{body:t})}}class Ns{constructor(e){m(this,"network");m(this,"triggerId");m(this,"trigger");m(this,"notificationId");m(this,"notification");this.name=e}static create(e){return new Ns(e)}onNetwork(e){return this.network=e,this}withTrigger(e,t){return this.triggerId=e,this.trigger=Fr.Validate(e,t),this}withNotification(e,t){return this.notificationId=e,this.notification=t,this}async config(){if(this.trigger===void 0||this.triggerId===void 0)throw new Error("Trigger not configured");if(this.notification===void 0||this.notificationId===void 0)throw new Error("Notification not configured");if(this.network===void 0)throw new Error("Network not configured");return{name:this.name,network:this.network,triggerId:this.triggerId,trigger:this.trigger,notificationId:this.notificationId,notification:this.notification}}}const Ud=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Ld=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));exports.AlertBuilder=Ns;exports.DeNotifyClient=Ps;exports.FilterBuilder=yr;exports.FunctionBuilder=pr;exports.Notification=Ld;exports.Trigger=Ud;
6
+ `+(a!==o?`result of cast: ${a}`:""))}return i}_cast(e,t){let r=e===void 0?e:this.transforms.reduce((s,i)=>i.call(this,s,e,this),e);return r===void 0&&(r=this.getDefault()),r}_validate(e,t={},r,s){let{path:i,originalValue:o=e,strict:a=this.spec.strict}=t,c=e;a||(c=this._cast(c,Object.assign({assert:!1},t)));let u=[];for(let l of Object.values(this.internalTests))l&&u.push(l);this.runTests({path:i,value:c,originalValue:o,options:t,tests:u},r,l=>{if(l.length)return s(l,c);this.runTests({path:i,value:c,originalValue:o,options:t,tests:this.tests},r,s)})}runTests(e,t,r){let s=!1,{tests:i,value:o,originalValue:a,path:c,options:u}=e,l=w=>{s||(s=!0,t(w,o))},h=w=>{s||(s=!0,r(w,o))},p=i.length,f=[];if(!p)return h([]);let d={value:o,originalValue:a,path:c,options:u,schema:this};for(let w=0;w<i.length;w++){const b=i[w];b(d,l,function(P){P&&(f=f.concat(P)),--p<=0&&h(f)})}}asNestedTest({key:e,index:t,parent:r,parentPath:s,originalParent:i,options:o}){const a=e??t;if(a==null)throw TypeError("Must include `key` or `index` for nested validations");const c=typeof a=="number";let u=r[a];const l=Object.assign({},o,{strict:!0,parent:r,value:u,originalValue:i[a],key:void 0,[c?"index":"key"]:a,path:c||a.includes(".")?`${s||""}[${u?a:`"${a}"`}]`:(s?`${s}.`:"")+e});return(h,p,f)=>this.resolve(l)._validate(u,l,p,f)}validate(e,t){let r=this.resolve(Object.assign({},t,{value:e}));return new Promise((s,i)=>r._validate(e,t,(o,a)=>{ue.isError(o)&&(o.value=a),i(o)},(o,a)=>{o.length?i(new ue(o,a)):s(a)}))}validateSync(e,t){let r=this.resolve(Object.assign({},t,{value:e})),s;return r._validate(e,Object.assign({},t,{sync:!0}),(i,o)=>{throw ue.isError(i)&&(i.value=o),i},(i,o)=>{if(i.length)throw new ue(i,e);s=o}),s}isValid(e,t){return this.validate(e,t).then(()=>!0,r=>{if(ue.isError(r))return!1;throw r})}isValidSync(e,t){try{return this.validateSync(e,t),!0}catch(r){if(ue.isError(r))return!1;throw r}}_getDefault(){let e=this.spec.default;return e==null?e:typeof e=="function"?e.call(this):Ct(e)}getDefault(e){return this.resolve(e||{})._getDefault()}default(e){return arguments.length===0?this._getDefault():this.clone({default:e})}strict(e=!0){return this.clone({strict:e})}nullability(e,t){const r=this.clone({nullable:e});return r.internalTests.nullable=St({message:t,name:"nullable",test(s){return s===null?this.schema.spec.nullable:!0}}),r}optionality(e,t){const r=this.clone({optional:e});return r.internalTests.optionality=St({message:t,name:"optionality",test(s){return s===void 0?this.schema.spec.optional:!0}}),r}optional(){return this.optionality(!0)}defined(e=$e.defined){return this.optionality(!1,e)}nullable(){return this.nullability(!0)}nonNullable(e=$e.notNull){return this.nullability(!1,e)}required(e=$e.required){return this.clone().withMutation(t=>t.nonNullable(e).defined(e))}notRequired(){return this.clone().withMutation(e=>e.nullable().optional())}transform(e){let t=this.clone();return t.transforms.push(e),t}test(...e){let t;if(e.length===1?typeof e[0]=="function"?t={test:e[0]}:t=e[0]:e.length===2?t={name:e[0],test:e[1]}:t={name:e[0],message:e[1],test:e[2]},t.message===void 0&&(t.message=$e.default),typeof t.test!="function")throw new TypeError("`test` is a required parameters");let r=this.clone(),s=St(t),i=t.exclusive||t.name&&r.exclusiveTests[t.name]===!0;if(t.exclusive&&!t.name)throw new TypeError("Exclusive tests must provide a unique `name` identifying the test");return t.name&&(r.exclusiveTests[t.name]=!!t.exclusive),r.tests=r.tests.filter(o=>!(o.OPTIONS.name===t.name&&(i||o.OPTIONS.test===s.OPTIONS.test))),r.tests.push(s),r}when(e,t){!Array.isArray(e)&&typeof e!="string"&&(t=e,e=".");let r=this.clone(),s=bo(e).map(i=>new xt(i));return s.forEach(i=>{i.isSibling&&r.deps.push(i.key)}),r.conditions.push(typeof t=="function"?new Lr(s,t):Lr.fromOptions(s,t)),r}typeError(e){let t=this.clone();return t.internalTests.typeError=St({message:e,name:"typeError",test(r){return!pe(r)&&!this.schema._typeCheck(r)?this.createError({params:{type:this.schema.type}}):!0}}),t}oneOf(e,t=$e.oneOf){let r=this.clone();return e.forEach(s=>{r._whitelist.add(s),r._blacklist.delete(s)}),r.internalTests.whiteList=St({message:t,name:"oneOf",skipAbsent:!0,test(s){let i=this.schema._whitelist,o=i.resolveAll(this.resolve);return o.includes(s)?!0:this.createError({params:{values:Array.from(i).join(", "),resolved:o}})}}),r}notOneOf(e,t=$e.notOneOf){let r=this.clone();return e.forEach(s=>{r._blacklist.add(s),r._whitelist.delete(s)}),r.internalTests.blacklist=St({message:t,name:"notOneOf",test(s){let i=this.schema._blacklist,o=i.resolveAll(this.resolve);return o.includes(s)?this.createError({params:{values:Array.from(i).join(", "),resolved:o}}):!0}}),r}strip(e=!0){let t=this.clone();return t.spec.strip=e,t}describe(e){const t=(e?this.resolve(e):this).clone(),{label:r,meta:s,optional:i,nullable:o}=t.spec;return{meta:s,label:r,optional:i,nullable:o,default:t.getDefault(e),type:t.type,oneOf:t._whitelist.describe(),notOneOf:t._blacklist.describe(),tests:t.tests.map(c=>({name:c.OPTIONS.name,params:c.OPTIONS.params})).filter((c,u,l)=>l.findIndex(h=>h.name===c.name)===u)}}}se.prototype.__isYupSchema__=!0;for(const n of["validate","validateSync"])se.prototype[`${n}At`]=function(e,t,r={}){const{parent:s,parentPath:i,schema:o}=nh(this,e,t,r.context);return o[n](s&&s[i],Object.assign({},r,{parent:s,path:e}))};for(const n of["equals","is"])se.prototype[n]=se.prototype.oneOf;for(const n of["not","nope"])se.prototype[n]=se.prototype.notOneOf;const sh=()=>!0;function vo(n){return new _o(n)}class _o extends se{constructor(e){super(typeof e=="function"?{type:"mixed",check:e}:Object.assign({type:"mixed",check:sh},e))}}vo.prototype=_o.prototype;function on(){return new Eo}class Eo extends se{constructor(){super({type:"boolean",check(e){return e instanceof Boolean&&(e=e.valueOf()),typeof e=="boolean"}}),this.withMutation(()=>{this.transform((e,t,r)=>{if(r.spec.coerce&&!r.isType(e)){if(/^(true|1)$/i.test(String(e)))return!0;if(/^(false|0)$/i.test(String(e)))return!1}return e})})}isTrue(e=Vn.isValue){return this.test({message:e,name:"is-value",exclusive:!0,params:{value:"true"},test(t){return pe(t)||t===!0}})}isFalse(e=Vn.isValue){return this.test({message:e,name:"is-value",exclusive:!0,params:{value:"false"},test(t){return pe(t)||t===!1}})}default(e){return super.default(e)}defined(e){return super.defined(e)}optional(){return super.optional()}required(e){return super.required(e)}notRequired(){return super.notRequired()}nullable(){return super.nullable()}nonNullable(e){return super.nonNullable(e)}strip(e){return super.strip(e)}}on.prototype=Eo.prototype;let ih=/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,oh=/^((https?|ftp):)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i,ah=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,ch=n=>pe(n)||n===n.trim(),uh={}.toString();function k(){return new xo}class xo extends se{constructor(){super({type:"string",check(e){return e instanceof String&&(e=e.valueOf()),typeof e=="string"}}),this.withMutation(()=>{this.transform((e,t,r)=>{if(!r.spec.coerce||r.isType(e)||Array.isArray(e))return e;const s=e!=null&&e.toString?e.toString():e;return s===uh?e:s})})}required(e){return super.required(e).withMutation(t=>t.test({message:e||$e.required,name:"required",skipAbsent:!0,test:r=>!!r.length}))}notRequired(){return super.notRequired().withMutation(e=>(e.tests=e.tests.filter(t=>t.OPTIONS.name!=="required"),e))}length(e,t=me.length){return this.test({message:t,name:"length",exclusive:!0,params:{length:e},skipAbsent:!0,test(r){return r.length===this.resolve(e)}})}min(e,t=me.min){return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(r){return r.length>=this.resolve(e)}})}max(e,t=me.max){return this.test({name:"max",exclusive:!0,message:t,params:{max:e},skipAbsent:!0,test(r){return r.length<=this.resolve(e)}})}matches(e,t){let r=!1,s,i;return t&&(typeof t=="object"?{excludeEmptyString:r=!1,message:s,name:i}=t:s=t),this.test({name:i||"matches",message:s||me.matches,params:{regex:e},skipAbsent:!0,test:o=>o===""&&r||o.search(e)!==-1})}email(e=me.email){return this.matches(ih,{name:"email",message:e,excludeEmptyString:!0})}url(e=me.url){return this.matches(oh,{name:"url",message:e,excludeEmptyString:!0})}uuid(e=me.uuid){return this.matches(ah,{name:"uuid",message:e,excludeEmptyString:!1})}ensure(){return this.default("").transform(e=>e===null?"":e)}trim(e=me.trim){return this.transform(t=>t!=null?t.trim():t).test({message:e,name:"trim",test:ch})}lowercase(e=me.lowercase){return this.transform(t=>pe(t)?t:t.toLowerCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:t=>pe(t)||t===t.toLowerCase()})}uppercase(e=me.uppercase){return this.transform(t=>pe(t)?t:t.toUpperCase()).test({message:e,name:"string_case",exclusive:!0,skipAbsent:!0,test:t=>pe(t)||t===t.toUpperCase()})}}k.prototype=xo.prototype;let lh=n=>n!=+n;function K(){return new To}class To extends se{constructor(){super({type:"number",check(e){return e instanceof Number&&(e=e.valueOf()),typeof e=="number"&&!lh(e)}}),this.withMutation(()=>{this.transform((e,t,r)=>{if(!r.spec.coerce)return e;let s=e;if(typeof s=="string"){if(s=s.replace(/\s/g,""),s==="")return NaN;s=+s}return r.isType(s)?s:parseFloat(s)})})}min(e,t=We.min){return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(r){return r>=this.resolve(e)}})}max(e,t=We.max){return this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(r){return r<=this.resolve(e)}})}lessThan(e,t=We.lessThan){return this.test({message:t,name:"max",exclusive:!0,params:{less:e},skipAbsent:!0,test(r){return r<this.resolve(e)}})}moreThan(e,t=We.moreThan){return this.test({message:t,name:"min",exclusive:!0,params:{more:e},skipAbsent:!0,test(r){return r>this.resolve(e)}})}positive(e=We.positive){return this.moreThan(0,e)}negative(e=We.negative){return this.lessThan(0,e)}integer(e=We.integer){return this.test({name:"integer",message:e,skipAbsent:!0,test:t=>Number.isInteger(t)})}truncate(){return this.transform(e=>pe(e)?e:e|0)}round(e){var t;let r=["ceil","floor","round","trunc"];if(e=((t=e)==null?void 0:t.toLowerCase())||"round",e==="trunc")return this.truncate();if(r.indexOf(e.toLowerCase())===-1)throw new TypeError("Only valid options for round() are: "+r.join(", "));return this.transform(s=>pe(s)?s:Math[e](s))}}K.prototype=To.prototype;var hh=/^(\d{4}|[+\-]\d{6})(?:-?(\d{2})(?:-?(\d{2}))?)?(?:[ T]?(\d{2}):?(\d{2})(?::?(\d{2})(?:[,\.](\d{1,}))?)?(?:(Z)|([+\-])(\d{2})(?::?(\d{2}))?)?)?$/;function fh(n){var e=[1,4,5,6,7,10,11],t=0,r,s;if(s=hh.exec(n)){for(var i=0,o;o=e[i];++i)s[o]=+s[o]||0;s[2]=(+s[2]||1)-1,s[3]=+s[3]||1,s[7]=s[7]?String(s[7]).substr(0,3):0,(s[8]===void 0||s[8]==="")&&(s[9]===void 0||s[9]==="")?r=+new Date(s[1],s[2],s[3],s[4],s[5],s[6],s[7]):(s[8]!=="Z"&&s[9]!==void 0&&(t=s[10]*60+s[11],s[9]==="+"&&(t=0-t)),r=Date.UTC(s[1],s[2],s[3],s[4],s[5]+t,s[6],s[7]))}else r=Date.parse?Date.parse(n):NaN;return r}let dh=new Date(""),ph=n=>Object.prototype.toString.call(n)==="[object Date]";class an extends se{constructor(){super({type:"date",check(e){return ph(e)&&!isNaN(e.getTime())}}),this.withMutation(()=>{this.transform((e,t,r)=>!r.spec.coerce||r.isType(e)?e:(e=fh(e),isNaN(e)?an.INVALID_DATE:new Date(e)))})}prepareParam(e,t){let r;if(xt.isRef(e))r=e;else{let s=this.cast(e);if(!this._typeCheck(s))throw new TypeError(`\`${t}\` must be a Date or a value that can be \`cast()\` to a Date`);r=s}return r}min(e,t=zn.min){let r=this.prepareParam(e,"min");return this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(s){return s>=this.resolve(r)}})}max(e,t=zn.max){let r=this.prepareParam(e,"max");return this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(s){return s<=this.resolve(r)}})}}an.INVALID_DATE=dh;an.prototype;function yh(n,e=[]){let t=[],r=new Set,s=new Set(e.map(([o,a])=>`${o}-${a}`));function i(o,a){let c=pt.split(o)[0];r.add(c),s.has(`${a}-${c}`)||t.push([a,c])}for(const o of Object.keys(n)){let a=n[o];r.add(o),xt.isRef(a)&&a.isSibling?i(a.path,o):sn(a)&&"deps"in a&&a.deps.forEach(c=>i(c,o))}return Ur.array(Array.from(r),t).reverse()}function ai(n,e){let t=1/0;return n.some((r,s)=>{var i;if((i=e.path)!=null&&i.includes(r))return t=s,!0}),t}function Oo(n){return(e,t)=>ai(n,e)-ai(n,t)}const ko=(n,e,t)=>{if(typeof n!="string")return n;let r=n;try{r=JSON.parse(n)}catch{}return t.isType(r)?r:n};function Cr(n){if("fields"in n){const e={};for(const[t,r]of Object.entries(n.fields))e[t]=Cr(r);return n.setFields(e)}if(n.type==="array"){const e=n.optional();return e.innerType&&(e.innerType=Cr(e.innerType)),e}return n.type==="tuple"?n.optional().clone({types:n.spec.types.map(Cr)}):"optional"in n?n.optional():n}const mh=(n,e)=>{const t=[...pt.normalizePath(e)];if(t.length===1)return t[0]in n;let r=t.pop(),s=pt.getter(pt.join(t),!0)(n);return!!(s&&r in s)};let ci=n=>Object.prototype.toString.call(n)==="[object Object]";function gh(n,e){let t=Object.keys(n.fields);return Object.keys(e).filter(r=>t.indexOf(r)===-1)}const wh=Oo([]);function ie(n){return new Ao(n)}class Ao extends se{constructor(e){super({type:"object",check(t){return ci(t)||typeof t=="function"}}),this.fields=Object.create(null),this._sortErrors=wh,this._nodes=[],this._excludedEdges=[],this.withMutation(()=>{e&&this.shape(e)})}_cast(e,t={}){var r;let s=super._cast(e,t);if(s===void 0)return this.getDefault();if(!this._typeCheck(s))return s;let i=this.fields,o=(r=t.stripUnknown)!=null?r:this.spec.noUnknown,a=[].concat(this._nodes,Object.keys(s).filter(h=>!this._nodes.includes(h))),c={},u=Object.assign({},t,{parent:c,__validating:t.__validating||!1}),l=!1;for(const h of a){let p=i[h],f=h in s;if(p){let d,w=s[h];u.path=(t.path?`${t.path}.`:"")+h,p=p.resolve({value:w,context:t.context,parent:c});let b=p instanceof se?p.spec:void 0,T=b==null?void 0:b.strict;if(b!=null&&b.strip){l=l||h in s;continue}d=!t.__validating||!T?p.cast(s[h],u):s[h],d!==void 0&&(c[h]=d)}else f&&!o&&(c[h]=s[h]);(f!==h in c||c[h]!==s[h])&&(l=!0)}return l?c:s}_validate(e,t={},r,s){let{from:i=[],originalValue:o=e,recursive:a=this.spec.recursive}=t;t.from=[{schema:this,value:o},...i],t.__validating=!0,t.originalValue=o,super._validate(e,t,r,(c,u)=>{if(!a||!ci(u)){s(c,u);return}o=o||u;let l=[];for(let h of this._nodes){let p=this.fields[h];!p||xt.isRef(p)||l.push(p.asNestedTest({options:t,key:h,parent:u,parentPath:t.path,originalParent:o}))}this.runTests({tests:l,value:u,originalValue:o,options:t},r,h=>{s(h.sort(this._sortErrors).concat(c),u)})})}clone(e){const t=super.clone(e);return t.fields=Object.assign({},this.fields),t._nodes=this._nodes,t._excludedEdges=this._excludedEdges,t._sortErrors=this._sortErrors,t}concat(e){let t=super.concat(e),r=t.fields;for(let[s,i]of Object.entries(this.fields)){const o=r[s];r[s]=o===void 0?i:o}return t.withMutation(s=>s.setFields(r,this._excludedEdges))}_getDefault(){if("default"in this.spec)return super._getDefault();if(!this._nodes.length)return;let e={};return this._nodes.forEach(t=>{const r=this.fields[t];e[t]=r&&"getDefault"in r?r.getDefault():void 0}),e}setFields(e,t){let r=this.clone();return r.fields=e,r._nodes=yh(e,t),r._sortErrors=Oo(Object.keys(e)),t&&(r._excludedEdges=t),r}shape(e,t=[]){return this.clone().withMutation(r=>{let s=r._excludedEdges;return t.length&&(Array.isArray(t[0])||(t=[t]),s=[...r._excludedEdges,...t]),r.setFields(Object.assign(r.fields,e),s)})}partial(){const e={};for(const[t,r]of Object.entries(this.fields))e[t]="optional"in r&&r.optional instanceof Function?r.optional():r;return this.setFields(e)}deepPartial(){return Cr(this)}pick(e){const t={};for(const r of e)this.fields[r]&&(t[r]=this.fields[r]);return this.setFields(t)}omit(e){const t=Object.assign({},this.fields);for(const r of e)delete t[r];return this.setFields(t)}from(e,t,r){let s=pt.getter(e,!0);return this.transform(i=>{if(!i)return i;let o=i;return mh(i,e)&&(o=Object.assign({},i),r||delete o[e],o[t]=s(i)),o})}json(){return this.transform(ko)}noUnknown(e=!0,t=qn.noUnknown){typeof e!="boolean"&&(t=e,e=!0);let r=this.test({name:"noUnknown",exclusive:!0,message:t,test(s){if(s==null)return!0;const i=gh(this.schema,s);return!e||i.length===0||this.createError({params:{unknown:i.join(", ")}})}});return r.spec.noUnknown=e,r}unknown(e=!0,t=qn.noUnknown){return this.noUnknown(!e,t)}transformKeys(e){return this.transform(t=>{if(!t)return t;const r={};for(const s of Object.keys(t))r[e(s)]=t[s];return r})}camelCase(){return this.transformKeys(An.camelCase)}snakeCase(){return this.transformKeys(An.snakeCase)}constantCase(){return this.transformKeys(e=>An.snakeCase(e).toUpperCase())}describe(e){let t=super.describe(e);t.fields={};for(const[s,i]of Object.entries(this.fields)){var r;let o=e;(r=o)!=null&&r.value&&(o=Object.assign({},o,{parent:o.value,value:o.value[s]})),t.fields[s]=i.describe(o)}return t}}ie.prototype=Ao.prototype;function gt(n){return new So(n)}class So extends se{constructor(e){super({type:"array",check(t){return Array.isArray(t)}}),this.innerType=void 0,this.innerType=e}_cast(e,t){const r=super._cast(e,t);if(!this._typeCheck(r)||!this.innerType)return r;let s=!1;const i=r.map((o,a)=>{const c=this.innerType.cast(o,Object.assign({},t,{path:`${t.path||""}[${a}]`}));return c!==o&&(s=!0),c});return s?i:r}_validate(e,t={},r,s){var i;let o=this.innerType,a=(i=t.recursive)!=null?i:this.spec.recursive;t.originalValue!=null&&t.originalValue,super._validate(e,t,r,(c,u)=>{var l;if(!a||!o||!this._typeCheck(u)){s(c,u);return}let h=new Array(u.length);for(let f=0;f<u.length;f++){var p;h[f]=o.asNestedTest({options:t,index:f,parent:u,parentPath:t.path,originalParent:(p=t.originalValue)!=null?p:e})}this.runTests({value:u,tests:h,originalValue:(l=t.originalValue)!=null?l:e,options:t},r,f=>s(f.concat(c),u))})}clone(e){const t=super.clone(e);return t.innerType=this.innerType,t}json(){return this.transform(ko)}concat(e){let t=super.concat(e);return t.innerType=this.innerType,e.innerType&&(t.innerType=t.innerType?t.innerType.concat(e.innerType):e.innerType),t}of(e){let t=this.clone();if(!sn(e))throw new TypeError("`array.of()` sub-schema must be a valid yup schema not: "+yt(e));return t.innerType=e,t}length(e,t=$r.length){return this.test({message:t,name:"length",exclusive:!0,params:{length:e},skipAbsent:!0,test(r){return r.length===this.resolve(e)}})}min(e,t){return t=t||$r.min,this.test({message:t,name:"min",exclusive:!0,params:{min:e},skipAbsent:!0,test(r){return r.length>=this.resolve(e)}})}max(e,t){return t=t||$r.max,this.test({message:t,name:"max",exclusive:!0,params:{max:e},skipAbsent:!0,test(r){return r.length<=this.resolve(e)}})}ensure(){return this.default(()=>[]).transform((e,t)=>this._typeCheck(e)?e:t==null?[]:[].concat(t))}compact(e){let t=e?(r,s,i)=>!e(r,s,i):r=>!!r;return this.transform(r=>r!=null?r.filter(t):r)}describe(e){let t=super.describe(e);if(this.innerType){var r;let s=e;(r=s)!=null&&r.value&&(s=Object.assign({},s,{parent:s.value,value:s.value[0]})),t.innerType=this.innerType.describe(e)}return t}}gt.prototype=So.prototype;const ui=ie({url:k(),height:K(),width:K()}),bh=ie({type:k().default("rich"),title:k(),color:K(),thumbnail:ui,image:ui,url:k()}),vh=ie({url:k().url().required(),username:k(),avatar_url:k().url(),message:k().required(),embed:bh}),_h="notify_discord_webhook";class vs{static async SimpleToRaw(e){return{name:"",notify_type:_h,notify:await vs.validateCreate(e)}}static validateCreate(e){return vh.validate(e)}}const Eh=ie({email:k().required(),subject:k(),html:k().required()}),xh="notify_email";class _s{static async SimpleToRaw(e){return{name:"",notify_type:xh,notify:await _s.validateCreate(e)}}static async validateCreate(e){return Eh.validate(e)}}const Th=ie({clientId:K().required(),content:k().required()}),Oh="notify_telegram";class Es{static async SimpleToRaw(e){return{name:"",notify_type:Oh,notify:await Es.validateCreate(e)}}static validateCreate(e){return Th.validate(e)}}class Sn{static async SimpleToRaw(e,t){switch(e){case"Discord":return vs.SimpleToRaw(t);case"Telegram":return Es.SimpleToRaw(t);case"Email":return _s.SimpleToRaw(t)}}static RawToSimple(e){return{...e.notify,error:e.error,error_message:e.error_message,error_timestamp:e.error_timestamp}}static RawTypeToSimpleType(e){switch(e){case"notify_discord_webhook":return"Discord";case"notify_telegram":return"Telegram";case"notify_email":return"Email"}}static SimpleTypeToRawType(e){switch(e){case"Discord":return"notify_discord_webhook";case"Telegram":return"notify_telegram";case"Email":return"notify_email"}}}const kh="handler_function_call";class li{static async SimpleToRaw(e,t,r){return{alertType:"event",network:t,nickname:e,type:kh,handler:await this.validate(r)}}static validate(e){const t=([s],i)=>s==="true"?i.notRequired():i.required();return ie({address:k().required(),abi:gt().required(),nBlocks:K().default(100).min(10).required(),function:k().required(),condition:k().default("true").oneOf([">",">=","<","<=","=","true"]).required(),constant:K().min(0).when("condition",t),responseArgIndex:K().min(0).when("condition",t),responseArgDecimals:K().min(0).when("condition",t)}).validateSync(e)}}const Ah="handler_onchain_event";class hi{static async SimpleToRaw(e,t,r){return{alertType:"event",network:t,nickname:e,type:Ah,handler:await this.validate(r)}}static validate(e){const t=([s],i)=>s==="true"?i.notRequired():i.required();return ie({address:k().required(),event:k().required(),abi:gt().required(),condition:k().default("true").oneOf([">",">=","<","<=","=","true"]).required(),constant:K().min(0).when("condition",t),paramsIndex:K().min(0).when("condition",t),paramsDecimals:K().min(0).when("condition",t)}).validateSync(e)}}const Sh="6.1.0";function Rh(n,e,t){const r=e.split("|").map(i=>i.trim());for(let i=0;i<r.length;i++)switch(e){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof n===e)return}const s=new Error(`invalid value for type ${e}`);throw s.code="INVALID_ARGUMENT",s.argument=`value.${t}`,s.value=n,s}async function Ro(n){const e=Object.keys(n);return(await Promise.all(e.map(r=>Promise.resolve(n[r])))).reduce((r,s,i)=>(r[e[i]]=s,r),{})}function R(n,e,t){for(let r in e){let s=e[r];const i=t?t[r]:null;i&&Rh(s,i,r),Object.defineProperty(n,r,{enumerable:!0,value:s,writable:!1})}}function Ft(n){if(n==null)return"null";if(Array.isArray(n))return"[ "+n.map(Ft).join(", ")+" ]";if(n instanceof Uint8Array){const e="0123456789abcdef";let t="0x";for(let r=0;r<n.length;r++)t+=e[n[r]>>4],t+=e[n[r]&15];return t}if(typeof n=="object"&&typeof n.toJSON=="function")return Ft(n.toJSON());switch(typeof n){case"boolean":case"symbol":return n.toString();case"bigint":return BigInt(n).toString();case"number":return n.toString();case"string":return JSON.stringify(n);case"object":{const e=Object.keys(n);return e.sort(),"{ "+e.map(t=>`${Ft(t)}: ${Ft(n[t])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function Br(n,e){return n&&n.code===e}function Po(n){return Br(n,"CALL_EXCEPTION")}function cn(n,e,t){{const s=[];if(t){if("message"in t||"code"in t||"name"in t)throw new Error(`value will overwrite populated values: ${Ft(t)}`);for(const i in t){const o=t[i];s.push(i+"="+Ft(o))}}s.push(`code=${e}`),s.push(`version=${Sh}`),s.length&&(n+=" ("+s.join(", ")+")")}let r;switch(e){case"INVALID_ARGUMENT":r=new TypeError(n);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":r=new RangeError(n);break;default:r=new Error(n)}return R(r,{code:e}),t&&Object.assign(r,t),r}function O(n,e,t,r){if(!n)throw cn(e,t,r)}function E(n,e,t,r){O(n,e,"INVALID_ARGUMENT",{argument:t,value:r})}function No(n,e,t){t==null&&(t=""),t&&(t=": "+t),O(n>=e,"missing arguemnt"+t,"MISSING_ARGUMENT",{count:n,expectedCount:e}),O(n<=e,"too many arguemnts"+t,"UNEXPECTED_ARGUMENT",{count:n,expectedCount:e})}const Ph=["NFD","NFC","NFKD","NFKC"].reduce((n,e)=>{try{if("test".normalize(e)!=="test")throw new Error("bad");if(e==="NFD"){const t=String.fromCharCode(233).normalize("NFD"),r=String.fromCharCode(101,769);if(t!==r)throw new Error("broken")}n.push(e)}catch{}return n},[]);function Nh(n){O(Ph.indexOf(n)>=0,"platform missing String.prototype.normalize","UNSUPPORTED_OPERATION",{operation:"String.prototype.normalize",info:{form:n}})}function xs(n,e,t){if(t==null&&(t=""),n!==e){let r=t,s="new";t&&(r+=".",s+=" "+t),O(!1,`private constructor; use ${r}from* methods`,"UNSUPPORTED_OPERATION",{operation:s})}}function $o(n,e,t){if(n instanceof Uint8Array)return t?new Uint8Array(n):n;if(typeof n=="string"&&n.match(/^0x([0-9a-f][0-9a-f])*$/i)){const r=new Uint8Array((n.length-2)/2);let s=2;for(let i=0;i<r.length;i++)r[i]=parseInt(n.substring(s,s+2),16),s+=2;return r}E(!1,"invalid BytesLike value",e||"value",n)}function Me(n,e){return $o(n,e,!1)}function Be(n,e){return $o(n,e,!0)}function Qe(n,e){return!(typeof n!="string"||!n.match(/^0x[0-9A-Fa-f]*$/)||typeof e=="number"&&n.length!==2+2*e||e===!0&&n.length%2!==0)}const fi="0123456789abcdef";function q(n){const e=Me(n);let t="0x";for(let r=0;r<e.length;r++){const s=e[r];t+=fi[(s&240)>>4]+fi[s&15]}return t}function Ut(n){return"0x"+n.map(e=>q(e).substring(2)).join("")}function Rt(n,e,t){const r=Me(n);return t!=null&&t>r.length&&O(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:r,length:r.length,offset:t}),q(r.slice(e??0,t??r.length))}function $h(n,e,t){const r=Me(n);O(e>=r.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(r),length:e,offset:e+1});const s=new Uint8Array(e);return s.fill(0),t?s.set(r,e-r.length):s.set(r,0),q(s)}function Ch(n,e){return $h(n,e,!0)}const un=BigInt(0),be=BigInt(1),It=9007199254740991;function Fh(n,e){const t=ln(n,"value"),r=BigInt(qe(e,"width"));if(O(t>>r===un,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:n}),t>>r-be){const s=(be<<r)-be;return-((~t&s)+be)}return t}function Ih(n,e){let t=Tt(n,"value");const r=BigInt(qe(e,"width")),s=be<<r-be;if(t<un){t=-t,O(t<=s,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});const i=(be<<r)-be;return(~t&i)+be}else O(t<s,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});return t}function xr(n,e){const t=ln(n,"value"),r=BigInt(qe(e,"bits"));return t&(be<<r)-be}function Tt(n,e){switch(typeof n){case"bigint":return n;case"number":return E(Number.isInteger(n),"underflow",e||"value",n),E(n>=-It&&n<=It,"overflow",e||"value",n),BigInt(n);case"string":try{if(n==="")throw new Error("empty string");return n[0]==="-"&&n[1]!=="-"?-BigInt(n.substring(1)):BigInt(n)}catch(t){E(!1,`invalid BigNumberish string: ${t.message}`,e||"value",n)}}E(!1,"invalid BigNumberish value",e||"value",n)}function ln(n,e){const t=Tt(n,e);return O(t>=un,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:n}),t}const di="0123456789abcdef";function Co(n){if(n instanceof Uint8Array){let e="0x0";for(const t of n)e+=di[t>>4],e+=di[t&15];return BigInt(e)}return Tt(n)}function qe(n,e){switch(typeof n){case"bigint":return E(n>=-It&&n<=It,"overflow",e||"value",n),Number(n);case"number":return E(Number.isInteger(n),"underflow",e||"value",n),E(n>=-It&&n<=It,"overflow",e||"value",n),n;case"string":try{if(n==="")throw new Error("empty string");return qe(BigInt(n),e)}catch(t){E(!1,`invalid numeric string: ${t.message}`,e||"value",n)}}E(!1,"invalid numeric value",e||"value",n)}function Dh(n){return qe(Co(n))}function Fo(n,e){let r=ln(n,"value").toString(16);if(e==null)r.length%2&&(r="0"+r);else{const s=qe(e,"width");for(O(s*2>=r.length,`value exceeds width (${s} bits)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:n});r.length<s*2;)r="0"+r}return"0x"+r}function Uh(n){const e=ln(n,"value");if(e===un)return new Uint8Array([]);let t=e.toString(16);t.length%2&&(t="0"+t);const r=new Uint8Array(t.length/2);for(let s=0;s<r.length;s++){const i=s*2;r[s]=parseInt(t.substring(i,i+2),16)}return r}var Lt;class Lh{constructor(e,t,r){m(this,"filter");m(this,"emitter");L(this,Lt,void 0);F(this,Lt,t),R(this,{emitter:e,filter:r})}async removeListener(){v(this,Lt)!=null&&await this.emitter.off(this.filter,v(this,Lt))}}Lt=new WeakMap;function jh(n,e,t,r,s){E(!1,`invalid codepoint at offset ${e}; ${n}`,"bytes",t)}function Io(n,e,t,r,s){if(n==="BAD_PREFIX"||n==="UNEXPECTED_CONTINUE"){let i=0;for(let o=e+1;o<t.length&&t[o]>>6===2;o++)i++;return i}return n==="OVERRUN"?t.length-e-1:0}function Bh(n,e,t,r,s){return n==="OVERLONG"?(E(typeof s=="number","invalid bad code point for replacement","badCodepoint",s),r.push(s),0):(r.push(65533),Io(n,e,t))}const Hh=Object.freeze({error:jh,ignore:Io,replace:Bh});function Mh(n,e){e==null&&(e=Hh.error);const t=Me(n,"bytes"),r=[];let s=0;for(;s<t.length;){const i=t[s++];if(!(i>>7)){r.push(i);continue}let o=null,a=null;if((i&224)===192)o=1,a=127;else if((i&240)===224)o=2,a=2047;else if((i&248)===240)o=3,a=65535;else{(i&192)===128?s+=e("UNEXPECTED_CONTINUE",s-1,t,r):s+=e("BAD_PREFIX",s-1,t,r);continue}if(s-1+o>=t.length){s+=e("OVERRUN",s-1,t,r);continue}let c=i&(1<<8-o-1)-1;for(let u=0;u<o;u++){let l=t[s];if((l&192)!=128){s+=e("MISSING_CONTINUE",s,t,r),c=null;break}c=c<<6|l&63,s++}if(c!==null){if(c>1114111){s+=e("OUT_OF_RANGE",s-1-o,t,r,c);continue}if(c>=55296&&c<=57343){s+=e("UTF16_SURROGATE",s-1-o,t,r,c);continue}if(c<=a){s+=e("OVERLONG",s-1-o,t,r,c);continue}r.push(c)}}return r}function Do(n,e){e!=null&&(Nh(e),n=n.normalize(e));let t=[];for(let r=0;r<n.length;r++){const s=n.charCodeAt(r);if(s<128)t.push(s);else if(s<2048)t.push(s>>6|192),t.push(s&63|128);else if((s&64512)==55296){r++;const i=n.charCodeAt(r);E(r<n.length&&(i&64512)===56320,"invalid surrogate pair","str",n);const o=65536+((s&1023)<<10)+(i&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(s>>12|224),t.push(s>>6&63|128),t.push(s&63|128)}return new Uint8Array(t)}function zh(n){return n.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function Vh(n,e){return zh(Mh(n,e))}const ee=32,Jn=new Uint8Array(ee),qh=["then"],Tr={};function Or(n,e){const t=new Error(`deferred error during ABI decoding triggered accessing ${n}`);throw t.error=e,t}var Xe;const tr=class extends Array{constructor(...t){const r=t[0];let s=t[1],i=(t[2]||[]).slice(),o=!0;r!==Tr&&(s=t,i=[],o=!1);super(s.length);L(this,Xe,void 0);s.forEach((c,u)=>{this[u]=c});const a=i.reduce((c,u)=>(typeof u=="string"&&c.set(u,(c.get(u)||0)+1),c),new Map);if(F(this,Xe,Object.freeze(s.map((c,u)=>{const l=i[u];return l!=null&&a.get(l)===1?l:null}))),!!o)return Object.freeze(this),new Proxy(this,{get:(c,u,l)=>{if(typeof u=="string"){if(u.match(/^[0-9]+$/)){const p=qe(u,"%index");if(p<0||p>=this.length)throw new RangeError("out of result range");const f=c[p];return f instanceof Error&&Or(`index ${p}`,f),f}if(qh.indexOf(u)>=0)return Reflect.get(c,u,l);const h=c[u];if(h instanceof Function)return function(...p){return h.apply(this===l?c:this,p)};if(!(u in c))return c.getValue.apply(this===l?c:this,[u])}return Reflect.get(c,u,l)}})}toArray(){const t=[];return this.forEach((r,s)=>{r instanceof Error&&Or(`index ${s}`,r),t.push(r)}),t}toObject(){return v(this,Xe).reduce((t,r,s)=>(O(r!=null,"value at index ${ index } unnamed","UNSUPPORTED_OPERATION",{operation:"toObject()"}),r in t||(t[r]=this.getValue(r)),t),{})}slice(t,r){t==null&&(t=0),t<0&&(t+=this.length,t<0&&(t=0)),r==null&&(r=this.length),r<0&&(r+=this.length,r<0&&(r=0)),r>this.length&&(r=this.length);const s=[],i=[];for(let o=t;o<r;o++)s.push(this[o]),i.push(v(this,Xe)[o]);return new tr(Tr,s,i)}filter(t,r){const s=[],i=[];for(let o=0;o<this.length;o++){const a=this[o];a instanceof Error&&Or(`index ${o}`,a),t.call(r,a,o,this)&&(s.push(a),i.push(v(this,Xe)[o]))}return new tr(Tr,s,i)}getValue(t){const r=v(this,Xe).indexOf(t);if(r===-1)return;const s=this[r];return s instanceof Error&&Or(`property ${JSON.stringify(t)}`,s.error),s}static fromItems(t,r){return new tr(Tr,t,r)}};let Hr=tr;Xe=new WeakMap;function pi(n){let e=Uh(n);return O(e.length<=ee,"value out-of-bounds","BUFFER_OVERRUN",{buffer:e,length:ee,offset:e.length}),e.length!==ee&&(e=Be(Ut([Jn.slice(e.length%ee),e]))),e}class Je{constructor(e,t,r,s){m(this,"name");m(this,"type");m(this,"localName");m(this,"dynamic");R(this,{name:e,type:t,localName:r,dynamic:s},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(e,t){E(!1,e,this.localName,t)}}var Ue,ft,jt,Fr;class Gn{constructor(){L(this,jt);L(this,Ue,void 0);L(this,ft,void 0);F(this,Ue,[]),F(this,ft,0)}get data(){return Ut(v(this,Ue))}get length(){return v(this,ft)}appendWriter(e){return z(this,jt,Fr).call(this,Be(e.data))}writeBytes(e){let t=Be(e);const r=t.length%ee;return r&&(t=Be(Ut([t,Jn.slice(r)]))),z(this,jt,Fr).call(this,t)}writeValue(e){return z(this,jt,Fr).call(this,pi(e))}writeUpdatableValue(){const e=v(this,Ue).length;return v(this,Ue).push(Jn),F(this,ft,v(this,ft)+ee),t=>{v(this,Ue)[e]=pi(t)}}}Ue=new WeakMap,ft=new WeakMap,jt=new WeakSet,Fr=function(e){return v(this,Ue).push(e),F(this,ft,v(this,ft)+e.length),e.length};var ce,de,Vr,Uo;const Fs=class{constructor(e,t){L(this,Vr);m(this,"allowLoose");L(this,ce,void 0);L(this,de,void 0);R(this,{allowLoose:!!t}),F(this,ce,Be(e)),F(this,de,0)}get data(){return q(v(this,ce))}get dataLength(){return v(this,ce).length}get consumed(){return v(this,de)}get bytes(){return new Uint8Array(v(this,ce))}subReader(e){return new Fs(v(this,ce).slice(v(this,de)+e),this.allowLoose)}readBytes(e,t){let r=z(this,Vr,Uo).call(this,0,e,!!t);return F(this,de,v(this,de)+r.length),r.slice(0,e)}readValue(){return Co(this.readBytes(ee))}readIndex(){return Dh(this.readBytes(ee))}};let Wn=Fs;ce=new WeakMap,de=new WeakMap,Vr=new WeakSet,Uo=function(e,t,r){let s=Math.ceil(t/ee)*ee;return v(this,de)+s>v(this,ce).length&&(this.allowLoose&&r&&v(this,de)+t<=v(this,ce).length?s=t:O(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:Be(v(this,ce)),length:v(this,ce).length,offset:v(this,de)+s})),v(this,ce).slice(v(this,de),v(this,de)+s)};function Kn(n){if(!Number.isSafeInteger(n)||n<0)throw new Error(`Wrong positive integer: ${n}`)}function Jh(n){if(typeof n!="boolean")throw new Error(`Expected boolean, not ${n}`)}function Lo(n,...e){if(!(n instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(e.length>0&&!e.includes(n.length))throw new TypeError(`Expected Uint8Array of length ${e}, not of length=${n.length}`)}function Gh(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Kn(n.outputLen),Kn(n.blockLen)}function Wh(n,e=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(e&&n.finished)throw new Error("Hash#digest() has already been called")}function Kh(n,e){Lo(n);const t=e.outputLen;if(n.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}const Pt={number:Kn,bool:Jh,bytes:Lo,hash:Gh,exists:Wh,output:Kh};/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const Xh=n=>new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)),Zh=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!Zh)throw new Error("Non little-endian hardware is not supported");Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function Yh(n){if(typeof n!="string")throw new TypeError(`utf8ToBytes expected string, got ${typeof n}`);return new TextEncoder().encode(n)}function Ts(n){if(typeof n=="string"&&(n=Yh(n)),!(n instanceof Uint8Array))throw new TypeError(`Expected input type is Uint8Array (got ${typeof n})`);return n}class Qh{clone(){return this._cloneInto()}}function ef(n){const e=r=>n().update(Ts(r)).digest(),t=n();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>n(),e}function tf(n){const e=(r,s)=>n(s).update(Ts(r)).digest(),t=n({});return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=r=>n(r),e}const kr=BigInt(2**32-1),Xn=BigInt(32);function jo(n,e=!1){return e?{h:Number(n&kr),l:Number(n>>Xn&kr)}:{h:Number(n>>Xn&kr)|0,l:Number(n&kr)|0}}function rf(n,e=!1){let t=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let s=0;s<n.length;s++){const{h:i,l:o}=jo(n[s],e);[t[s],r[s]]=[i,o]}return[t,r]}const nf=(n,e)=>BigInt(n>>>0)<<Xn|BigInt(e>>>0),sf=(n,e,t)=>n>>>t,of=(n,e,t)=>n<<32-t|e>>>t,af=(n,e,t)=>n>>>t|e<<32-t,cf=(n,e,t)=>n<<32-t|e>>>t,uf=(n,e,t)=>n<<64-t|e>>>t-32,lf=(n,e,t)=>n>>>t-32|e<<64-t,hf=(n,e)=>e,ff=(n,e)=>n,df=(n,e,t)=>n<<t|e>>>32-t,pf=(n,e,t)=>e<<t|n>>>32-t,yf=(n,e,t)=>e<<t-32|n>>>64-t,mf=(n,e,t)=>n<<t-32|e>>>64-t;function gf(n,e,t,r){const s=(e>>>0)+(r>>>0);return{h:n+t+(s/2**32|0)|0,l:s|0}}const wf=(n,e,t)=>(n>>>0)+(e>>>0)+(t>>>0),bf=(n,e,t,r)=>e+t+r+(n/2**32|0)|0,vf=(n,e,t,r)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0),_f=(n,e,t,r,s)=>e+t+r+s+(n/2**32|0)|0,Ef=(n,e,t,r,s)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0),xf=(n,e,t,r,s,i)=>e+t+r+s+i+(n/2**32|0)|0,sr={fromBig:jo,split:rf,toBig:nf,shrSH:sf,shrSL:of,rotrSH:af,rotrSL:cf,rotrBH:uf,rotrBL:lf,rotr32H:hf,rotr32L:ff,rotlSH:df,rotlSL:pf,rotlBH:yf,rotlBL:mf,add:gf,add3L:wf,add3H:bf,add4L:vf,add4H:_f,add5H:xf,add5L:Ef},[Bo,Ho,Mo]=[[],[],[]],Tf=BigInt(0),Xt=BigInt(1),Of=BigInt(2),kf=BigInt(7),Af=BigInt(256),Sf=BigInt(113);for(let n=0,e=Xt,t=1,r=0;n<24;n++){[t,r]=[r,(2*t+3*r)%5],Bo.push(2*(5*r+t)),Ho.push((n+1)*(n+2)/2%64);let s=Tf;for(let i=0;i<7;i++)e=(e<<Xt^(e>>kf)*Sf)%Af,e&Of&&(s^=Xt<<(Xt<<BigInt(i))-Xt);Mo.push(s)}const[Rf,Pf]=sr.split(Mo,!0),yi=(n,e,t)=>t>32?sr.rotlBH(n,e,t):sr.rotlSH(n,e,t),mi=(n,e,t)=>t>32?sr.rotlBL(n,e,t):sr.rotlSL(n,e,t);function Nf(n,e=24){const t=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)t[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,u=t[c],l=t[c+1],h=yi(u,l,1)^t[a],p=mi(u,l,1)^t[a+1];for(let f=0;f<50;f+=10)n[o+f]^=h,n[o+f+1]^=p}let s=n[2],i=n[3];for(let o=0;o<24;o++){const a=Ho[o],c=yi(s,i,a),u=mi(s,i,a),l=Bo[o];s=n[l],i=n[l+1],n[l]=c,n[l+1]=u}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=n[o+a];for(let a=0;a<10;a++)n[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}n[0]^=Rf[r],n[1]^=Pf[r]}t.fill(0)}class hn extends Qh{constructor(e,t,r,s=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Pt.number(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Xh(this.state)}keccak(){Nf(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){Pt.exists(this);const{blockLen:t,state:r}=this;e=Ts(e);const s=e.length;for(let i=0;i<s;){const o=Math.min(t-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:r,blockLen:s}=this;e[r]^=t,t&128&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){Pt.exists(this,!1),Pt.bytes(e),this.finish();const t=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);e.set(t.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Pt.number(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Pt.output(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,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new hn(t,r,s,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=s,e.enableXOF=o,e.destroyed=this.destroyed,e}}const rt=(n,e,t)=>ef(()=>new hn(e,n,t));rt(6,144,224/8);rt(6,136,256/8);rt(6,104,384/8);rt(6,72,512/8);rt(1,144,224/8);const $f=rt(1,136,256/8);rt(1,104,384/8);rt(1,72,512/8);const zo=(n,e,t)=>tf((r={})=>new hn(e,n,r.dkLen===void 0?t:r.dkLen,!0));zo(31,168,128/8);zo(31,136,256/8);let Vo=!1;const qo=function(n){return $f(n)};let Jo=qo;function tt(n){const e=Me(n,"data");return q(Jo(e))}tt._=qo;tt.lock=function(){Vo=!0};tt.register=function(n){if(Vo)throw new TypeError("keccak256 is locked");Jo=n};Object.freeze(tt);const Cf=BigInt(0),Ff=BigInt(36);function gi(n){n=n.toLowerCase();const e=n.substring(2).split(""),t=new Uint8Array(40);for(let s=0;s<40;s++)t[s]=e[s].charCodeAt(0);const r=Me(tt(t));for(let s=0;s<40;s+=2)r[s>>1]>>4>=8&&(e[s]=e[s].toUpperCase()),(r[s>>1]&15)>=8&&(e[s+1]=e[s+1].toUpperCase());return"0x"+e.join("")}const Os={};for(let n=0;n<10;n++)Os[String(n)]=String(n);for(let n=0;n<26;n++)Os[String.fromCharCode(65+n)]=String(10+n);const wi=15;function If(n){n=n.toUpperCase(),n=n.substring(4)+n.substring(0,2)+"00";let e=n.split("").map(r=>Os[r]).join("");for(;e.length>=wi;){let r=e.substring(0,wi);e=parseInt(r,10)%97+e.substring(r.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}const Df=function(){const n={};for(let e=0;e<36;e++){const t="0123456789abcdefghijklmnopqrstuvwxyz"[e];n[t]=BigInt(e)}return n}();function Uf(n){n=n.toLowerCase();let e=Cf;for(let t=0;t<n.length;t++)e=e*Ff+Df[n[t]];return e}function wt(n){if(E(typeof n=="string","invalid address","address",n),n.match(/^(0x)?[0-9a-fA-F]{40}$/)){n.startsWith("0x")||(n="0x"+n);const e=gi(n);return E(!n.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||e===n,"bad address checksum","address",n),e}if(n.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){E(n.substring(2,4)===If(n),"bad icap checksum","address",n);let e=Uf(n.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return gi("0x"+e)}E(!1,"invalid address","address",n)}function Lf(n){return n&&typeof n.getAddress=="function"}async function Rn(n,e){const t=await e;return(t==null||t==="0x0000000000000000000000000000000000000000")&&(O(typeof n!="string","unconfigured name","UNCONFIGURED_NAME",{value:n}),E(!1,"invalid AddressLike value; did not resolve to a value address","target",n)),wt(t)}function ks(n,e){if(typeof n=="string")return n.match(/^0x[0-9a-f]{40}$/i)?wt(n):(O(e!=null,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),Rn(n,e.resolveName(n)));if(Lf(n))return Rn(n,n.getAddress());if(n&&typeof n.then=="function")return Rn(n,n);E(!1,"unsupported addressable value","target",n)}const Ce={};function x(n,e){let t=!1;return e<0&&(t=!0,e*=-1),new Q(Ce,`${t?"":"u"}int${e}`,n,{signed:t,width:e})}function $(n,e){return new Q(Ce,`bytes${e||""}`,n,{size:e})}const bi=Symbol.for("_ethers_typed");var dt;const Fe=class{constructor(e,t,r,s){m(this,"type");m(this,"value");L(this,dt,void 0);m(this,"_typedSymbol");s==null&&(s=null),xs(Ce,e,"Typed"),R(this,{_typedSymbol:bi,type:t,value:r}),F(this,dt,s),this.format()}format(){if(this.type==="array")throw new Error("");if(this.type==="dynamicArray")throw new Error("");return this.type==="tuple"?`tuple(${this.value.map(e=>e.format()).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return this.type==="string"}get tupleName(){if(this.type!=="tuple")throw TypeError("not a tuple");return v(this,dt)}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return v(this,dt)===!0?-1:v(this,dt)===!1?this.value.length:null}static from(e,t){return new Fe(Ce,e,t)}static uint8(e){return x(e,8)}static uint16(e){return x(e,16)}static uint24(e){return x(e,24)}static uint32(e){return x(e,32)}static uint40(e){return x(e,40)}static uint48(e){return x(e,48)}static uint56(e){return x(e,56)}static uint64(e){return x(e,64)}static uint72(e){return x(e,72)}static uint80(e){return x(e,80)}static uint88(e){return x(e,88)}static uint96(e){return x(e,96)}static uint104(e){return x(e,104)}static uint112(e){return x(e,112)}static uint120(e){return x(e,120)}static uint128(e){return x(e,128)}static uint136(e){return x(e,136)}static uint144(e){return x(e,144)}static uint152(e){return x(e,152)}static uint160(e){return x(e,160)}static uint168(e){return x(e,168)}static uint176(e){return x(e,176)}static uint184(e){return x(e,184)}static uint192(e){return x(e,192)}static uint200(e){return x(e,200)}static uint208(e){return x(e,208)}static uint216(e){return x(e,216)}static uint224(e){return x(e,224)}static uint232(e){return x(e,232)}static uint240(e){return x(e,240)}static uint248(e){return x(e,248)}static uint256(e){return x(e,256)}static uint(e){return x(e,256)}static int8(e){return x(e,-8)}static int16(e){return x(e,-16)}static int24(e){return x(e,-24)}static int32(e){return x(e,-32)}static int40(e){return x(e,-40)}static int48(e){return x(e,-48)}static int56(e){return x(e,-56)}static int64(e){return x(e,-64)}static int72(e){return x(e,-72)}static int80(e){return x(e,-80)}static int88(e){return x(e,-88)}static int96(e){return x(e,-96)}static int104(e){return x(e,-104)}static int112(e){return x(e,-112)}static int120(e){return x(e,-120)}static int128(e){return x(e,-128)}static int136(e){return x(e,-136)}static int144(e){return x(e,-144)}static int152(e){return x(e,-152)}static int160(e){return x(e,-160)}static int168(e){return x(e,-168)}static int176(e){return x(e,-176)}static int184(e){return x(e,-184)}static int192(e){return x(e,-192)}static int200(e){return x(e,-200)}static int208(e){return x(e,-208)}static int216(e){return x(e,-216)}static int224(e){return x(e,-224)}static int232(e){return x(e,-232)}static int240(e){return x(e,-240)}static int248(e){return x(e,-248)}static int256(e){return x(e,-256)}static int(e){return x(e,-256)}static bytes1(e){return $(e,1)}static bytes2(e){return $(e,2)}static bytes3(e){return $(e,3)}static bytes4(e){return $(e,4)}static bytes5(e){return $(e,5)}static bytes6(e){return $(e,6)}static bytes7(e){return $(e,7)}static bytes8(e){return $(e,8)}static bytes9(e){return $(e,9)}static bytes10(e){return $(e,10)}static bytes11(e){return $(e,11)}static bytes12(e){return $(e,12)}static bytes13(e){return $(e,13)}static bytes14(e){return $(e,14)}static bytes15(e){return $(e,15)}static bytes16(e){return $(e,16)}static bytes17(e){return $(e,17)}static bytes18(e){return $(e,18)}static bytes19(e){return $(e,19)}static bytes20(e){return $(e,20)}static bytes21(e){return $(e,21)}static bytes22(e){return $(e,22)}static bytes23(e){return $(e,23)}static bytes24(e){return $(e,24)}static bytes25(e){return $(e,25)}static bytes26(e){return $(e,26)}static bytes27(e){return $(e,27)}static bytes28(e){return $(e,28)}static bytes29(e){return $(e,29)}static bytes30(e){return $(e,30)}static bytes31(e){return $(e,31)}static bytes32(e){return $(e,32)}static address(e){return new Fe(Ce,"address",e)}static bool(e){return new Fe(Ce,"bool",!!e)}static bytes(e){return new Fe(Ce,"bytes",e)}static string(e){return new Fe(Ce,"string",e)}static array(e,t){throw new Error("not implemented yet")}static tuple(e,t){throw new Error("not implemented yet")}static overrides(e){return new Fe(Ce,"overrides",Object.assign({},e))}static isTyped(e){return e&&e._typedSymbol===bi}static dereference(e,t){if(Fe.isTyped(e)){if(e.type!==t)throw new Error(`invalid type: expecetd ${t}, got ${e.type}`);return e.value}return e}};let Q=Fe;dt=new WeakMap;class jf extends Je{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){let r=Q.dereference(t,"string");try{r=wt(r)}catch(s){return this._throwError(s.message,t)}return e.writeValue(r)}decode(e){return wt(Fo(e.readValue(),20))}}class Bf extends Je{constructor(t){super(t.name,t.type,"_",t.dynamic);m(this,"coder");this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,r){return this.coder.encode(t,r)}decode(t){return this.coder.decode(t)}}function Go(n,e,t){let r=[];if(Array.isArray(t))r=t;else if(t&&typeof t=="object"){let c={};r=e.map(u=>{const l=u.localName;return O(l,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:u},value:t}),O(!c[l],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:u},value:t}),c[l]=!0,t[l]})}else E(!1,"invalid tuple value","tuple",t);E(e.length===r.length,"types/value length mismatch","tuple",t);let s=new Gn,i=new Gn,o=[];e.forEach((c,u)=>{let l=r[u];if(c.dynamic){let h=i.length;c.encode(i,l);let p=s.writeUpdatableValue();o.push(f=>{p(f+h)})}else c.encode(s,l)}),o.forEach(c=>{c(s.length)});let a=n.appendWriter(s);return a+=n.appendWriter(i),a}function Wo(n,e){let t=[],r=[],s=n.subReader(0);return e.forEach(i=>{let o=null;if(i.dynamic){let a=n.readIndex(),c=s.subReader(a);try{o=i.decode(c)}catch(u){if(Br(u,"BUFFER_OVERRUN"))throw u;o=u,o.baseType=i.name,o.name=i.localName,o.type=i.type}}else try{o=i.decode(n)}catch(a){if(Br(a,"BUFFER_OVERRUN"))throw a;o=a,o.baseType=i.name,o.name=i.localName,o.type=i.type}if(o==null)throw new Error("investigate");t.push(o),r.push(i.localName||null)}),Hr.fromItems(t,r)}class Hf extends Je{constructor(t,r,s){const i=t.type+"["+(r>=0?r:"")+"]",o=r===-1||t.dynamic;super("array",i,s,o);m(this,"coder");m(this,"length");R(this,{coder:t,length:r})}defaultValue(){const t=this.coder.defaultValue(),r=[];for(let s=0;s<this.length;s++)r.push(t);return r}encode(t,r){const s=Q.dereference(r,"array");Array.isArray(s)||this._throwError("expected array value",s);let i=this.length;i===-1&&(i=s.length,t.writeValue(s.length)),No(s.length,i,"coder array"+(this.localName?" "+this.localName:""));let o=[];for(let a=0;a<s.length;a++)o.push(this.coder);return Go(t,o,s)}decode(t){let r=this.length;r===-1&&(r=t.readIndex(),O(r*ee<=t.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:t.bytes,offset:r*ee,length:t.dataLength}));let s=[];for(let i=0;i<r;i++)s.push(new Bf(this.coder));return Wo(t,s)}}class Mf extends Je{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,t){const r=Q.dereference(t,"bool");return e.writeValue(r?1:0)}decode(e){return!!e.readValue()}}class Ko extends Je{constructor(e,t){super(e,e,t,!0)}defaultValue(){return"0x"}encode(e,t){t=Be(t);let r=e.writeValue(t.length);return r+=e.writeBytes(t),r}decode(e){return e.readBytes(e.readIndex(),!0)}}class zf extends Ko{constructor(e){super("bytes",e)}decode(e){return q(super.decode(e))}}class Vf extends Je{constructor(t,r){let s="bytes"+String(t);super(s,s,r,!1);m(this,"size");R(this,{size:t},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(t,r){let s=Be(Q.dereference(r,this.type));return s.length!==this.size&&this._throwError("incorrect data length",r),t.writeBytes(s)}decode(t){return q(t.readBytes(this.size))}}const qf=new Uint8Array([]);class Jf extends Je{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,t){return t!=null&&this._throwError("not null",t),e.writeBytes(qf)}decode(e){return e.readBytes(0),null}}const Gf=BigInt(0),Wf=BigInt(1),Kf=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class Xf extends Je{constructor(t,r,s){const i=(r?"int":"uint")+t*8;super(i,i,s,!1);m(this,"size");m(this,"signed");R(this,{size:t,signed:r},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(t,r){let s=Tt(Q.dereference(r,this.type)),i=xr(Kf,ee*8);if(this.signed){let o=xr(i,this.size*8-1);(s>o||s<-(o+Wf))&&this._throwError("value out-of-bounds",r),s=Ih(s,8*ee)}else(s<Gf||s>xr(i,this.size*8))&&this._throwError("value out-of-bounds",r);return t.writeValue(s)}decode(t){let r=xr(t.readValue(),this.size*8);return this.signed&&(r=Fh(r,this.size*8)),r}}class Zf extends Ko{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,Do(Q.dereference(t,"string")))}decode(e){return Vh(super.decode(e))}}class Ar extends Je{constructor(t,r){let s=!1;const i=[];t.forEach(a=>{a.dynamic&&(s=!0),i.push(a.type)});const o="tuple("+i.join(",")+")";super("tuple",o,r,s);m(this,"coders");R(this,{coders:Object.freeze(t.slice())})}defaultValue(){const t=[];this.coders.forEach(s=>{t.push(s.defaultValue())});const r=this.coders.reduce((s,i)=>{const o=i.localName;return o&&(s[o]||(s[o]=0),s[o]++),s},{});return this.coders.forEach((s,i)=>{let o=s.localName;!o||r[o]!==1||(o==="length"&&(o="_length"),t[o]==null&&(t[o]=t[i]))}),Object.freeze(t)}encode(t,r){const s=Q.dereference(r,"tuple");return Go(t,this.coders,s)}decode(t){return Wo(t,this.coders)}}function ir(n){return tt(Do(n))}function Pn(n,e){return{address:wt(n),storageKeys:e.map((t,r)=>(E(Qe(t,32),"invalid slot",`storageKeys[${r}]`,t),t.toLowerCase()))}}function Yf(n){if(Array.isArray(n))return n.map((t,r)=>Array.isArray(t)?(E(t.length===2,"invalid slot set",`value[${r}]`,t),Pn(t[0],t[1])):(E(t!=null&&typeof t=="object","invalid address-slot set","value",n),Pn(t.address,t.storageKeys)));E(n!=null&&typeof n=="object","invalid access list","value",n);const e=Object.keys(n).map(t=>{const r=n[t].reduce((s,i)=>(s[i]=!0,s),{});return Pn(t,Object.keys(r).sort())});return e.sort((t,r)=>t.address.localeCompare(r.address)),e}function te(n){const e=new Set;return n.forEach(t=>e.add(t)),Object.freeze(e)}const Xo="constant external internal payable private public pure view",Qf=te(Xo.split(" ")),Zo="constructor error event fallback function receive struct",Yo=te(Zo.split(" ")),Qo="calldata memory storage payable indexed",ed=te(Qo.split(" ")),td="tuple returns",rd=[Zo,Qo,td,Xo].join(" "),nd=te(rd.split(" ")),sd={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},id=new RegExp("^(\\s*)"),od=new RegExp("^([0-9]+)"),ad=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),ea=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),ta=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$");var W,ge,ar,Zn;const qr=class{constructor(e){L(this,ar);L(this,W,void 0);L(this,ge,void 0);F(this,W,0),F(this,ge,e.slice())}get offset(){return v(this,W)}get length(){return v(this,ge).length-v(this,W)}clone(){return new qr(v(this,ge))}reset(){F(this,W,0)}popKeyword(e){const t=this.peek();if(t.type!=="KEYWORD"||!e.has(t.text))throw new Error(`expected keyword ${t.text}`);return this.pop().text}popType(e){if(this.peek().type!==e)throw new Error(`expected ${e}; got ${JSON.stringify(this.peek())}`);return this.pop().text}popParen(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=z(this,ar,Zn).call(this,v(this,W)+1,e.match+1);return F(this,W,e.match+1),t}popParams(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=[];for(;v(this,W)<e.match-1;){const r=this.peek().linkNext;t.push(z(this,ar,Zn).call(this,v(this,W)+1,r)),F(this,W,r)}return F(this,W,e.match+1),t}peek(){if(v(this,W)>=v(this,ge).length)throw new Error("out-of-bounds");return v(this,ge)[v(this,W)]}peekKeyword(e){const t=this.peekType("KEYWORD");return t!=null&&e.has(t)?t:null}peekType(e){if(this.length===0)return null;const t=this.peek();return t.type===e?t.text:null}pop(){const e=this.peek();return Ds(this,W)._++,e}toString(){const e=[];for(let t=v(this,W);t<v(this,ge).length;t++){const r=v(this,ge)[t];e.push(`${r.type}:${r.text}`)}return`<TokenString ${e.join(" ")}>`}};let ve=qr;W=new WeakMap,ge=new WeakMap,ar=new WeakSet,Zn=function(e=0,t=0){return new qr(v(this,ge).slice(e,t).map(r=>Object.freeze(Object.assign({},r,{match:r.match-e,linkBack:r.linkBack-e,linkNext:r.linkNext-e}))))};function nt(n){const e=[],t=o=>{const a=i<n.length?JSON.stringify(n[i]):"$EOI";throw new Error(`invalid token ${a} at ${i}: ${o}`)};let r=[],s=[],i=0;for(;i<n.length;){let o=n.substring(i),a=o.match(id);a&&(i+=a[1].length,o=n.substring(i));const c={depth:r.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:i,value:-1};e.push(c);let u=sd[o[0]]||"";if(u){if(c.type=u,c.text=o[0],i++,u==="OPEN_PAREN")r.push(e.length-1),s.push(e.length-1);else if(u=="CLOSE_PAREN")r.length===0&&t("no matching open bracket"),c.match=r.pop(),e[c.match].match=e.length-1,c.depth--,c.linkBack=s.pop(),e[c.linkBack].linkNext=e.length-1;else if(u==="COMMA")c.linkBack=s.pop(),e[c.linkBack].linkNext=e.length-1,s.push(e.length-1);else if(u==="OPEN_BRACKET")c.type="BRACKET";else if(u==="CLOSE_BRACKET"){let l=e.pop().text;if(e.length>0&&e[e.length-1].type==="NUMBER"){const h=e.pop().text;l=h+l,e[e.length-1].value=qe(h)}if(e.length===0||e[e.length-1].type!=="BRACKET")throw new Error("missing opening bracket");e[e.length-1].text+=l}continue}if(a=o.match(ad),a){if(c.text=a[1],i+=c.text.length,nd.has(c.text)){c.type="KEYWORD";continue}if(c.text.match(ta)){c.type="TYPE";continue}c.type="ID";continue}if(a=o.match(od),a){c.text=a[1],c.type="NUMBER",i+=c.text.length;continue}throw new Error(`unexpected token ${JSON.stringify(o[0])} at position ${i}`)}return new ve(e.map(o=>Object.freeze(o)))}function vi(n,e){let t=[];for(const r in e.keys())n.has(r)&&t.push(r);if(t.length>1)throw new Error(`conflicting types: ${t.join(", ")}`)}function fn(n,e){if(e.peekKeyword(Yo)){const t=e.pop().text;if(t!==n)throw new Error(`expected ${n}, got ${t}`)}return e.popType("ID")}function ze(n,e){const t=new Set;for(;;){const r=n.peekType("KEYWORD");if(r==null||e&&!e.has(r))break;if(n.pop(),t.has(r))throw new Error(`duplicate keywords: ${JSON.stringify(r)}`);t.add(r)}return Object.freeze(t)}function ra(n){let e=ze(n,Qf);return vi(e,te("constant payable nonpayable".split(" "))),vi(e,te("pure view payable nonpayable".split(" "))),e.has("view")?"view":e.has("pure")?"pure":e.has("payable")?"payable":e.has("nonpayable")?"nonpayable":e.has("constant")?"view":"nonpayable"}function He(n,e){return n.popParams().map(t=>X.from(t,e))}function na(n){if(n.peekType("AT")){if(n.pop(),n.peekType("NUMBER"))return Tt(n.pop().text);throw new Error("invalid gas")}return null}function bt(n){if(n.length)throw new Error(`unexpected tokens: ${n.toString()}`)}const cd=new RegExp(/^(.*)\[([0-9]*)\]$/);function _i(n){const e=n.match(ta);if(E(e,"invalid type","type",n),n==="uint")return"uint256";if(n==="int")return"int256";if(e[2]){const t=parseInt(e[2]);E(t!==0&&t<=32,"invalid bytes length","type",n)}else if(e[3]){const t=parseInt(e[3]);E(t!==0&&t<=256&&t%8===0,"invalid numeric width","type",n)}return n}const B={},oe=Symbol.for("_ethers_internal"),Ei="_ParamTypeInternal",xi="_ErrorInternal",Ti="_EventInternal",Oi="_ConstructorInternal",ki="_FallbackInternal",Ai="_FunctionInternal",Si="_StructInternal";var Bt,Ir;const fe=class{constructor(e,t,r,s,i,o,a,c){L(this,Bt);m(this,"name");m(this,"type");m(this,"baseType");m(this,"indexed");m(this,"components");m(this,"arrayLength");m(this,"arrayChildren");if(xs(e,B,"ParamType"),Object.defineProperty(this,oe,{value:Ei}),o&&(o=Object.freeze(o.slice())),s==="array"){if(a==null||c==null)throw new Error("")}else if(a!=null||c!=null)throw new Error("");if(s==="tuple"){if(o==null)throw new Error("")}else if(o!=null)throw new Error("");R(this,{name:t,type:r,baseType:s,indexed:i,components:o,arrayLength:a,arrayChildren:c})}format(e){if(e==null&&(e="sighash"),e==="json"){let r={type:this.baseType==="tuple"?"tuple":this.type,name:this.name||void 0};return typeof this.indexed=="boolean"&&(r.indexed=this.indexed),this.isTuple()&&(r.components=this.components.map(s=>JSON.parse(s.format(e)))),JSON.stringify(r)}let t="";return this.isArray()?(t+=this.arrayChildren.format(e),t+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?(e!=="sighash"&&(t+=this.type),t+="("+this.components.map(r=>r.format(e)).join(e==="full"?", ":",")+")"):t+=this.type,e!=="sighash"&&(this.indexed===!0&&(t+=" indexed"),e==="full"&&this.name&&(t+=" "+this.name)),t}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(e,t){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw new Error("array is wrong length");const r=this;return e.map(s=>r.arrayChildren.walk(s,t))}if(this.isTuple()){if(!Array.isArray(e))throw new Error("invalid tuple value");if(e.length!==this.components.length)throw new Error("array is wrong length");const r=this;return e.map((s,i)=>r.components[i].walk(s,t))}return t(this.type,e)}async walkAsync(e,t){const r=[],s=[e];return z(this,Bt,Ir).call(this,r,e,t,i=>{s[0]=i}),r.length&&await Promise.all(r),s[0]}static from(e,t){if(fe.isParamType(e))return e;if(typeof e=="string")return fe.from(nt(e),t);if(e instanceof ve){let a="",c="",u=null;ze(e,te(["tuple"])).has("tuple")||e.peekType("OPEN_PAREN")?(c="tuple",u=e.popParams().map(w=>fe.from(w)),a=`tuple(${u.map(w=>w.format()).join(",")})`):(a=_i(e.popType("TYPE")),c=a);let l=null,h=null;for(;e.length&&e.peekType("BRACKET");){const w=e.pop();l=new fe(B,"",a,c,null,u,h,l),h=w.value,a+=w.text,c="array",u=null}let p=null;if(ze(e,ed).has("indexed")){if(!t)throw new Error("");p=!0}const d=e.peekType("ID")?e.pop().text:"";if(e.length)throw new Error("leftover tokens");return new fe(B,d,a,c,p,u,h,l)}const r=e.name;E(!r||typeof r=="string"&&r.match(ea),"invalid name","obj.name",r);let s=e.indexed;s!=null&&(E(t,"parameter cannot be indexed","obj.indexed",e.indexed),s=!!s);let i=e.type,o=i.match(cd);if(o){const a=parseInt(o[2]||"-1"),c=fe.from({type:o[1],components:e.components});return new fe(B,r||"",i,"array",s,null,a,c)}if(i==="tuple"||i.startsWith("tuple(")||i.startsWith("(")){const a=e.components!=null?e.components.map(u=>fe.from(u)):null;return new fe(B,r||"",i,"tuple",s,a,null,null)}return i=_i(e.type),new fe(B,r||"",i,i,s,null,null,null)}static isParamType(e){return e&&e[oe]===Ei}};let X=fe;Bt=new WeakSet,Ir=function(e,t,r,s){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw new Error("array is wrong length");const o=this.arrayChildren,a=t.slice();a.forEach((c,u)=>{var l;z(l=o,Bt,Ir).call(l,e,c,r,h=>{a[u]=h})}),s(a);return}if(this.isTuple()){const o=this.components;let a;if(Array.isArray(t))a=t.slice();else{if(t==null||typeof t!="object")throw new Error("invalid tuple value");a=o.map(c=>{if(!c.name)throw new Error("cannot use object value with unnamed components");if(!(c.name in t))throw new Error(`missing value for component ${c.name}`);return t[c.name]})}if(a.length!==this.components.length)throw new Error("array is wrong length");a.forEach((c,u)=>{var l;z(l=o[u],Bt,Ir).call(l,e,c,r,h=>{a[u]=h})}),s(a);return}const i=r(this.type,t);i.then?e.push(async function(){s(await i)}()):s(i)};class vt{constructor(e,t,r){m(this,"type");m(this,"inputs");xs(e,B,"Fragment"),r=Object.freeze(r.slice()),R(this,{type:t,inputs:r})}static from(e){if(typeof e=="string"){try{vt.from(JSON.parse(e))}catch{}return vt.from(nt(e))}if(e instanceof ve)switch(e.peekKeyword(Yo)){case"constructor":return Le.from(e);case"error":return ne.from(e);case"event":return Se.from(e);case"fallback":case"receive":return Ie.from(e);case"function":return Re.from(e);case"struct":return mt.from(e)}else if(typeof e=="object"){switch(e.type){case"constructor":return Le.from(e);case"error":return ne.from(e);case"event":return Se.from(e);case"fallback":case"receive":return Ie.from(e);case"function":return Re.from(e);case"struct":return mt.from(e)}O(!1,`unsupported type: ${e.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}E(!1,"unsupported frgament object","obj",e)}static isConstructor(e){return Le.isFragment(e)}static isError(e){return ne.isFragment(e)}static isEvent(e){return Se.isFragment(e)}static isFunction(e){return Re.isFragment(e)}static isStruct(e){return mt.isFragment(e)}}class dn extends vt{constructor(t,r,s,i){super(t,r,i);m(this,"name");E(typeof s=="string"&&s.match(ea),"invalid identifier","name",s),i=Object.freeze(i.slice()),R(this,{name:s})}}function or(n,e){return"("+e.map(t=>t.format(n)).join(n==="full"?", ":",")+")"}class ne extends dn{constructor(e,t,r){super(e,"error",t,r),Object.defineProperty(this,oe,{value:xi})}get selector(){return ir(this.format("sighash")).substring(0,10)}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(r=>JSON.parse(r.format(e)))});const t=[];return e!=="sighash"&&t.push("error"),t.push(this.name+or(e,this.inputs)),t.join(" ")}static from(e){if(ne.isFragment(e))return e;if(typeof e=="string")return ne.from(nt(e));if(e instanceof ve){const t=fn("error",e),r=He(e);return bt(e),new ne(B,t,r)}return new ne(B,e.name,e.inputs?e.inputs.map(X.from):[])}static isFragment(e){return e&&e[oe]===xi}}class Se extends dn{constructor(t,r,s,i){super(t,"event",r,s);m(this,"anonymous");Object.defineProperty(this,oe,{value:Ti}),R(this,{anonymous:i})}get topicHash(){return ir(this.format("sighash"))}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(s=>JSON.parse(s.format(t)))});const r=[];return t!=="sighash"&&r.push("event"),r.push(this.name+or(t,this.inputs)),t!=="sighash"&&this.anonymous&&r.push("anonymous"),r.join(" ")}static getTopicHash(t,r){return r=(r||[]).map(i=>X.from(i)),new Se(B,t,r,!1).topicHash}static from(t){if(Se.isFragment(t))return t;if(typeof t=="string")return Se.from(nt(t));if(t instanceof ve){const r=fn("event",t),s=He(t,!0),i=!!ze(t,te(["anonymous"])).has("anonymous");return bt(t),new Se(B,r,s,i)}return new Se(B,t.name,t.inputs?t.inputs.map(r=>X.from(r,!0)):[],!!t.anonymous)}static isFragment(t){return t&&t[oe]===Ti}}class Le extends vt{constructor(t,r,s,i,o){super(t,r,s);m(this,"payable");m(this,"gas");Object.defineProperty(this,oe,{value:Oi}),R(this,{payable:i,gas:o})}format(t){if(O(t!=null&&t!=="sighash","cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),t==="json")return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(s=>JSON.parse(s.format(t)))});const r=[`constructor${or(t,this.inputs)}`];return r.push(this.payable?"payable":"nonpayable"),this.gas!=null&&r.push(`@${this.gas.toString()}`),r.join(" ")}static from(t){if(Le.isFragment(t))return t;if(typeof t=="string")return Le.from(nt(t));if(t instanceof ve){ze(t,te(["constructor"]));const r=He(t),s=!!ze(t,te(["payable"])).has("payable"),i=na(t);return bt(t),new Le(B,"constructor",r,s,i)}return new Le(B,"constructor",t.inputs?t.inputs.map(X.from):[],!!t.payable,t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[oe]===Oi}}class Ie extends vt{constructor(t,r,s){super(t,"fallback",r);m(this,"payable");Object.defineProperty(this,oe,{value:ki}),R(this,{payable:s})}format(t){const r=this.inputs.length===0?"receive":"fallback";if(t==="json"){const s=this.payable?"payable":"nonpayable";return JSON.stringify({type:r,stateMutability:s})}return`${r}()${this.payable?" payable":""}`}static from(t){if(Ie.isFragment(t))return t;if(typeof t=="string")return Ie.from(nt(t));if(t instanceof ve){const r=t.toString(),s=t.peekKeyword(te(["fallback","receive"]));if(E(s,"type must be fallback or receive","obj",r),t.popKeyword(te(["fallback","receive"]))==="receive"){const c=He(t);return E(c.length===0,"receive cannot have arguments","obj.inputs",c),ze(t,te(["payable"])),bt(t),new Ie(B,[],!0)}let o=He(t);o.length?E(o.length===1&&o[0].type==="bytes","invalid fallback inputs","obj.inputs",o.map(c=>c.format("minimal")).join(", ")):o=[X.from("bytes")];const a=ra(t);if(E(a==="nonpayable"||a==="payable","fallback cannot be constants","obj.stateMutability",a),ze(t,te(["returns"])).has("returns")){const c=He(t);E(c.length===1&&c[0].type==="bytes","invalid fallback outputs","obj.outputs",c.map(u=>u.format("minimal")).join(", "))}return bt(t),new Ie(B,o,a==="payable")}if(t.type==="receive")return new Ie(B,[],!0);if(t.type==="fallback"){const r=[X.from("bytes")],s=t.stateMutability==="payable";return new Ie(B,r,s)}E(!1,"invalid fallback description","obj",t)}static isFragment(t){return t&&t[oe]===ki}}class Re extends dn{constructor(t,r,s,i,o,a){super(t,"function",r,i);m(this,"constant");m(this,"outputs");m(this,"stateMutability");m(this,"payable");m(this,"gas");Object.defineProperty(this,oe,{value:Ai}),o=Object.freeze(o.slice()),R(this,{constant:s==="view"||s==="pure",gas:a,outputs:o,payable:s==="payable",stateMutability:s})}get selector(){return ir(this.format("sighash")).substring(0,10)}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(s=>JSON.parse(s.format(t))),outputs:this.outputs.map(s=>JSON.parse(s.format(t)))});const r=[];return t!=="sighash"&&r.push("function"),r.push(this.name+or(t,this.inputs)),t!=="sighash"&&(this.stateMutability!=="nonpayable"&&r.push(this.stateMutability),this.outputs&&this.outputs.length&&(r.push("returns"),r.push(or(t,this.outputs))),this.gas!=null&&r.push(`@${this.gas.toString()}`)),r.join(" ")}static getSelector(t,r){return r=(r||[]).map(i=>X.from(i)),new Re(B,t,"view",r,[],null).selector}static from(t){if(Re.isFragment(t))return t;if(typeof t=="string")return Re.from(nt(t));if(t instanceof ve){const r=fn("function",t),s=He(t),i=ra(t);let o=[];ze(t,te(["returns"])).has("returns")&&(o=He(t));const a=na(t);return bt(t),new Re(B,r,i,s,o,a)}return new Re(B,t.name,t.stateMutability,t.inputs?t.inputs.map(X.from):[],t.outputs?t.outputs.map(X.from):[],t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[oe]===Ai}}class mt extends dn{constructor(e,t,r){super(e,"struct",t,r),Object.defineProperty(this,oe,{value:Si})}format(){throw new Error("@TODO")}static from(e){if(typeof e=="string")return mt.from(nt(e));if(e instanceof ve){const t=fn("struct",e),r=He(e);return bt(e),new mt(B,t,r)}return new mt(B,e.name,e.inputs?e.inputs.map(X.from):[])}static isFragment(e){return e&&e[oe]===Si}}const _e=new Map;_e.set(0,"GENERIC_PANIC");_e.set(1,"ASSERT_FALSE");_e.set(17,"OVERFLOW");_e.set(18,"DIVIDE_BY_ZERO");_e.set(33,"ENUM_RANGE_ERROR");_e.set(34,"BAD_STORAGE_DATA");_e.set(49,"STACK_UNDERFLOW");_e.set(50,"ARRAY_RANGE_ERROR");_e.set(65,"OUT_OF_MEMORY");_e.set(81,"UNINITIALIZED_FUNCTION_CALL");const ud=new RegExp(/^bytes([0-9]*)$/),ld=new RegExp(/^(u?int)([0-9]*)$/);let Nn=null;function hd(n,e,t,r){let s="missing revert data",i=null;const o=null;let a=null;if(t){s="execution reverted";const u=Me(t);if(t=q(t),u.length===0)s+=" (no data present; likely require(false) occurred",i="require(false)";else if(u.length%32!==4)s+=" (could not decode reason; invalid data length)";else if(q(u.slice(0,4))==="0x08c379a0")try{i=r.decode(["string"],u.slice(4))[0],a={signature:"Error(string)",name:"Error",args:[i]},s+=`: ${JSON.stringify(i)}`}catch{s+=" (could not decode reason; invalid string data)"}else if(q(u.slice(0,4))==="0x4e487b71")try{const l=Number(r.decode(["uint256"],u.slice(4))[0]);a={signature:"Panic(uint256)",name:"Panic",args:[l]},i=`Panic due to ${_e.get(l)||"UNKNOWN"}(${l})`,s+=`: ${i}`}catch{s+=" (could not decode panic code)"}else s+=" (unknown custom error)"}const c={to:e.to?wt(e.to):null,data:e.data||"0x"};return e.from&&(c.from=wt(e.from)),cn(s,"CALL_EXCEPTION",{action:n,data:t,reason:i,transaction:c,invocation:o,revert:a})}var Ze,$t;const Jr=class{constructor(){L(this,Ze)}getDefaultValue(e){const t=e.map(s=>z(this,Ze,$t).call(this,X.from(s)));return new Ar(t,"_").defaultValue()}encode(e,t){No(t.length,e.length,"types/values length mismatch");const r=e.map(o=>z(this,Ze,$t).call(this,X.from(o))),s=new Ar(r,"_"),i=new Gn;return s.encode(i,t),i.data}decode(e,t,r){const s=e.map(o=>z(this,Ze,$t).call(this,X.from(o)));return new Ar(s,"_").decode(new Wn(t,r))}static defaultAbiCoder(){return Nn==null&&(Nn=new Jr),Nn}static getBuiltinCallException(e,t,r){return hd(e,t,r,Jr.defaultAbiCoder())}};let Mr=Jr;Ze=new WeakSet,$t=function(e){if(e.isArray())return new Hf(z(this,Ze,$t).call(this,e.arrayChildren),e.arrayLength,e.name);if(e.isTuple())return new Ar(e.components.map(r=>z(this,Ze,$t).call(this,r)),e.name);switch(e.baseType){case"address":return new jf(e.name);case"bool":return new Mf(e.name);case"string":return new Zf(e.name);case"bytes":return new zf(e.name);case"":return new Jf(e.name)}let t=e.type.match(ld);if(t){let r=parseInt(t[2]||"256");return E(r!==0&&r<=256&&r%8===0,"invalid "+t[1]+" bit length","param",e),new Xf(r/8,t[1]==="int",e.name)}if(t=e.type.match(ud),t){let r=parseInt(t[1]);return E(r!==0&&r<=32,"invalid bytes length","param",e),new Vf(r,e.name)}E(!1,"invalid type","type",e.type)};class fd{constructor(e,t,r){m(this,"fragment");m(this,"name");m(this,"signature");m(this,"topic");m(this,"args");const s=e.name,i=e.format();R(this,{fragment:e,name:s,signature:i,topic:t,args:r})}}class dd{constructor(e,t,r,s){m(this,"fragment");m(this,"name");m(this,"args");m(this,"signature");m(this,"selector");m(this,"value");const i=e.name,o=e.format();R(this,{fragment:e,name:i,args:r,signature:o,selector:t,value:s})}}class pd{constructor(e,t,r){m(this,"fragment");m(this,"name");m(this,"args");m(this,"signature");m(this,"selector");const s=e.name,i=e.format();R(this,{fragment:e,name:s,args:r,signature:i,selector:t})}}class Ri{constructor(e){m(this,"hash");m(this,"_isIndexed");R(this,{hash:e,_isIndexed:!0})}static isIndexed(e){return!!(e&&e._isIndexed)}}const Pi={0:"generic panic",1:"assert(false)",17:"arithmetic overflow",18:"division or modulo by zero",33:"enum overflow",34:"invalid encoded storage byte array accessed",49:"out-of-bounds array access; popping on an empty array",50:"out-of-bounds access of an array or bytesN",65:"out of memory",81:"uninitialized function"},Ni={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:n=>`reverted with reason string ${JSON.stringify(n)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:n=>{let e="unknown panic code";return n>=0&&n<=255&&Pi[n.toString()]&&(e=Pi[n.toString()]),`reverted with panic code 0x${n.toString(16)} (${e})`}}};var Oe,ke,Ae,Y,cr,Qn,ur,es;const Dt=class{constructor(e){L(this,cr);L(this,ur);m(this,"fragments");m(this,"deploy");m(this,"fallback");m(this,"receive");L(this,Oe,void 0);L(this,ke,void 0);L(this,Ae,void 0);L(this,Y,void 0);let t=[];typeof e=="string"?t=JSON.parse(e):t=e,F(this,Ae,new Map),F(this,Oe,new Map),F(this,ke,new Map);const r=[];for(const o of t)try{r.push(vt.from(o))}catch(a){console.log("EE",a)}R(this,{fragments:Object.freeze(r)});let s=null,i=!1;F(this,Y,this.getAbiCoder()),this.fragments.forEach((o,a)=>{let c;switch(o.type){case"constructor":if(this.deploy){console.log("duplicate definition - constructor");return}R(this,{deploy:o});return;case"fallback":o.inputs.length===0?i=!0:(E(!s||o.payable!==s.payable,"conflicting fallback fragments",`fragments[${a}]`,o),s=o,i=s.payable);return;case"function":c=v(this,Ae);break;case"event":c=v(this,ke);break;case"error":c=v(this,Oe);break;default:return}const u=o.format();c.has(u)||c.set(u,o)}),this.deploy||R(this,{deploy:Le.from("constructor()")}),R(this,{fallback:s,receive:i})}format(e){const t=e?"minimal":"full";return this.fragments.map(s=>s.format(t))}formatJson(){const e=this.fragments.map(t=>t.format("json"));return JSON.stringify(e.map(t=>JSON.parse(t)))}getAbiCoder(){return Mr.defaultAbiCoder()}getFunctionName(e){const t=z(this,cr,Qn).call(this,e,null,!1);return E(t,"no matching function","key",e),t.name}getFunction(e,t){return z(this,cr,Qn).call(this,e,t||null,!0)}forEachFunction(e){const t=Array.from(v(this,Ae).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(v(this,Ae).get(s),r)}}getEventName(e){const t=z(this,ur,es).call(this,e,null,!1);return E(t,"no matching event","key",e),t.name}getEvent(e,t){return z(this,ur,es).call(this,e,t||null,!0)}forEachEvent(e){const t=Array.from(v(this,ke).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(v(this,ke).get(s),r)}}getError(e,t){if(Qe(e)){const s=e.toLowerCase();if(Ni[s])return ne.from(Ni[s].signature);for(const i of v(this,Oe).values())if(s===i.selector)return i;return null}if(e.indexOf("(")===-1){const s=[];for(const[i,o]of v(this,Oe))i.split("(")[0]===e&&s.push(o);if(s.length===0)return e==="Error"?ne.from("error Error(string)"):e==="Panic"?ne.from("error Panic(uint256)"):null;if(s.length>1){const i=s.map(o=>JSON.stringify(o.format())).join(", ");E(!1,`ambiguous error description (i.e. ${i})`,"name",e)}return s[0]}if(e=ne.from(e).format(),e==="Error(string)")return ne.from("error Error(string)");if(e==="Panic(uint256)")return ne.from("error Panic(uint256)");const r=v(this,Oe).get(e);return r||null}forEachError(e){const t=Array.from(v(this,Oe).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(v(this,Oe).get(s),r)}}_decodeParams(e,t){return v(this,Y).decode(e,t)}_encodeParams(e,t){return v(this,Y).encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){if(typeof e=="string"){const r=this.getError(e);E(r,"unknown error","fragment",e),e=r}return E(Rt(t,0,4)===e.selector,`data signature does not match error ${e.name}.`,"data",t),this._decodeParams(e.inputs,Rt(t,4))}encodeErrorResult(e,t){if(typeof e=="string"){const r=this.getError(e);E(r,"unknown error","fragment",e),e=r}return Ut([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionData(e,t){if(typeof e=="string"){const r=this.getFunction(e);E(r,"unknown function","fragment",e),e=r}return E(Rt(t,0,4)===e.selector,`data signature does not match function ${e.name}.`,"data",t),this._decodeParams(e.inputs,Rt(t,4))}encodeFunctionData(e,t){if(typeof e=="string"){const r=this.getFunction(e);E(r,"unknown function","fragment",e),e=r}return Ut([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionResult(e,t){if(typeof e=="string"){const i=this.getFunction(e);E(i,"unknown function","fragment",e),e=i}let r="invalid length for result data";const s=Be(t);if(s.length%32===0)try{return v(this,Y).decode(e.outputs,s)}catch{r="could not decode result data"}O(!1,r,"BAD_DATA",{value:q(s),info:{method:e.name,signature:e.format()}})}makeError(e,t){const r=Me(e,"data"),s=Mr.getBuiltinCallException("call",t,r),i="execution reverted (unknown custom error)";if(s.message.startsWith(i)){const a=q(r.slice(0,4)),c=this.getError(a);if(c)try{const u=v(this,Y).decode(c.inputs,r.slice(4));s.revert={name:c.name,signature:c.format(),args:u},s.reason=s.revert.signature,s.message=`execution reverted: ${s.reason}`}catch{s.message="execution reverted (coult not decode custom error)"}}const o=this.parseTransaction(t);return o&&(s.invocation={method:o.name,signature:o.signature,args:o.args}),s}encodeFunctionResult(e,t){if(typeof e=="string"){const r=this.getFunction(e);E(r,"unknown function","fragment",e),e=r}return q(v(this,Y).encode(e.outputs,t||[]))}encodeFilterTopics(e,t){if(typeof e=="string"){const i=this.getEvent(e);E(i,"unknown event","eventFragment",e),e=i}O(t.length<=e.inputs.length,`too many arguments for ${e.format()}`,"UNEXPECTED_ARGUMENT",{count:t.length,expectedCount:e.inputs.length});const r=[];e.anonymous||r.push(e.topicHash);const s=(i,o)=>i.type==="string"?ir(o):i.type==="bytes"?tt(q(o)):(i.type==="bool"&&typeof o=="boolean"&&(o=o?"0x01":"0x00"),i.type.match(/^u?int/)&&(o=Fo(o)),i.type==="address"&&v(this,Y).encode(["address"],[o]),Ch(q(o),32));for(t.forEach((i,o)=>{const a=e.inputs[o];if(!a.indexed){E(i==null,"cannot filter non-indexed parameters; must be null","contract."+a.name,i);return}i==null?r.push(null):a.baseType==="array"||a.baseType==="tuple"?E(!1,"filtering with tuples or arrays not supported","contract."+a.name,i):Array.isArray(i)?r.push(i.map(c=>s(a,c))):r.push(s(a,i))});r.length&&r[r.length-1]===null;)r.pop();return r}encodeEventLog(e,t){if(typeof e=="string"){const o=this.getEvent(e);E(o,"unknown event","eventFragment",e),e=o}const r=[],s=[],i=[];return e.anonymous||r.push(e.topicHash),E(t.length===e.inputs.length,"event arguments/values mismatch","values",t),e.inputs.forEach((o,a)=>{const c=t[a];if(o.indexed)if(o.type==="string")r.push(ir(c));else if(o.type==="bytes")r.push(tt(c));else{if(o.baseType==="tuple"||o.baseType==="array")throw new Error("not implemented");r.push(v(this,Y).encode([o.type],[c]))}else s.push(o),i.push(c)}),{data:v(this,Y).encode(s,i),topics:r}}decodeEventLog(e,t,r){if(typeof e=="string"){const f=this.getEvent(e);E(f,"unknown event","eventFragment",e),e=f}if(r!=null&&!e.anonymous){const f=e.topicHash;E(Qe(r[0],32)&&r[0].toLowerCase()===f,"fragment/topic mismatch","topics[0]",r[0]),r=r.slice(1)}const s=[],i=[],o=[];e.inputs.forEach((f,d)=>{f.indexed?f.type==="string"||f.type==="bytes"||f.baseType==="tuple"||f.baseType==="array"?(s.push(X.from({type:"bytes32",name:f.name})),o.push(!0)):(s.push(f),o.push(!1)):(i.push(f),o.push(!1))});const a=r!=null?v(this,Y).decode(s,Ut(r)):null,c=v(this,Y).decode(i,t,!0),u=[],l=[];let h=0,p=0;return e.inputs.forEach((f,d)=>{let w=null;if(f.indexed)if(a==null)w=new Ri(null);else if(o[d])w=new Ri(a[p++]);else try{w=a[p++]}catch(b){w=b}else try{w=c[h++]}catch(b){w=b}u.push(w),l.push(f.name||null)}),Hr.fromItems(u,l)}parseTransaction(e){const t=Me(e.data,"tx.data"),r=Tt(e.value!=null?e.value:0,"tx.value"),s=this.getFunction(q(t.slice(0,4)));if(!s)return null;const i=v(this,Y).decode(s.inputs,t.slice(4));return new dd(s,s.selector,i,r)}parseCallResult(e){throw new Error("@TODO")}parseLog(e){const t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new fd(t,t.topicHash,this.decodeEventLog(t,e.data,e.topics))}parseError(e){const t=q(e),r=this.getError(Rt(t,0,4));if(!r)return null;const s=v(this,Y).decode(r.inputs,Rt(t,4));return new pd(r,r.selector,s)}static from(e){return e instanceof Dt?e:typeof e=="string"?new Dt(JSON.parse(e)):typeof e.format=="function"?new Dt(e.format("json")):new Dt(e)}};let Yn=Dt;Oe=new WeakMap,ke=new WeakMap,Ae=new WeakMap,Y=new WeakMap,cr=new WeakSet,Qn=function(e,t,r){if(Qe(e)){const i=e.toLowerCase();for(const o of v(this,Ae).values())if(i===o.selector)return o;return null}if(e.indexOf("(")===-1){const i=[];for(const[o,a]of v(this,Ae))o.split("(")[0]===e&&i.push(a);if(t){const o=t.length>0?t[t.length-1]:null;let a=t.length,c=!0;Q.isTyped(o)&&o.type==="overrides"&&(c=!1,a--);for(let u=i.length-1;u>=0;u--){const l=i[u].inputs.length;l!==a&&(!c||l!==a-1)&&i.splice(u,1)}for(let u=i.length-1;u>=0;u--){const l=i[u].inputs;for(let h=0;h<t.length;h++)if(Q.isTyped(t[h])){if(h>=l.length){if(t[h].type==="overrides")continue;i.splice(u,1);break}if(t[h].type!==l[h].baseType){i.splice(u,1);break}}}}if(i.length===1&&t&&t.length!==i[0].inputs.length){const o=t[t.length-1];(o==null||Array.isArray(o)||typeof o!="object")&&i.splice(0,1)}if(i.length===0)return null;if(i.length>1&&r){const o=i.map(a=>JSON.stringify(a.format())).join(", ");E(!1,`ambiguous function description (i.e. matches ${o})`,"key",e)}return i[0]}const s=v(this,Ae).get(Re.from(e).format());return s||null},ur=new WeakSet,es=function(e,t,r){if(Qe(e)){const i=e.toLowerCase();for(const o of v(this,ke).values())if(i===o.topicHash)return o;return null}if(e.indexOf("(")===-1){const i=[];for(const[o,a]of v(this,ke))o.split("(")[0]===e&&i.push(a);if(t){for(let o=i.length-1;o>=0;o--)i[o].inputs.length<t.length&&i.splice(o,1);for(let o=i.length-1;o>=0;o--){const a=i[o].inputs;for(let c=0;c<t.length;c++)if(Q.isTyped(t[c])&&t[c].type!==a[c].baseType){i.splice(o,1);break}}}if(i.length===0)return null;if(i.length>1&&r){const o=i.map(a=>JSON.stringify(a.format())).join(", ");E(!1,`ambiguous event description (i.e. matches ${o})`,"key",e)}return i[0]}const s=v(this,ke).get(Se.from(e).format());return s||null};const yd=BigInt(0);function De(n){return n==null?null:n.toString()}function md(n){const e={};n.to&&(e.to=n.to),n.from&&(e.from=n.from),n.data&&(e.data=q(n.data));const t="chainId,gasLimit,gasPrice,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const s of t)!(s in n)||n[s]==null||(e[s]=Tt(n[s],`request.${s}`));const r="type,nonce".split(/,/);for(const s of r)!(s in n)||n[s]==null||(e[s]=qe(n[s],`request.${s}`));return n.accessList&&(e.accessList=Yf(n.accessList)),"blockTag"in n&&(e.blockTag=n.blockTag),"enableCcipRead"in n&&(e.enableCcipReadEnabled=!!n.enableCcipRead),"customData"in n&&(e.customData=n.customData),e}class As{constructor(e,t){m(this,"provider");m(this,"transactionHash");m(this,"blockHash");m(this,"blockNumber");m(this,"removed");m(this,"address");m(this,"data");m(this,"topics");m(this,"index");m(this,"transactionIndex");this.provider=t;const r=Object.freeze(e.topics.slice());R(this,{transactionHash:e.transactionHash,blockHash:e.blockHash,blockNumber:e.blockNumber,removed:e.removed,address:e.address,data:e.data,topics:r,index:e.index,transactionIndex:e.transactionIndex})}toJSON(){const{address:e,blockHash:t,blockNumber:r,data:s,index:i,removed:o,topics:a,transactionHash:c,transactionIndex:u}=this;return{_type:"log",address:e,blockHash:t,blockNumber:r,data:s,index:i,removed:o,topics:a,transactionHash:c,transactionIndex:u}}async getBlock(){const e=await this.provider.getBlock(this.blockHash);return O(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransaction(){const e=await this.provider.getTransaction(this.transactionHash);return O(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransactionReceipt(){const e=await this.provider.getTransactionReceipt(this.transactionHash);return O(!!e,"failed to find transaction receipt","UNKNOWN_ERROR",{}),e}removedEvent(){return wd(this)}}var lr;class gd{constructor(e,t){m(this,"provider");m(this,"to");m(this,"from");m(this,"contractAddress");m(this,"hash");m(this,"index");m(this,"blockHash");m(this,"blockNumber");m(this,"logsBloom");m(this,"gasUsed");m(this,"cumulativeGasUsed");m(this,"gasPrice");m(this,"type");m(this,"status");m(this,"root");L(this,lr,void 0);F(this,lr,Object.freeze(e.logs.map(r=>new As(r,t)))),R(this,{provider:t,to:e.to,from:e.from,contractAddress:e.contractAddress,hash:e.hash,index:e.index,blockHash:e.blockHash,blockNumber:e.blockNumber,logsBloom:e.logsBloom,gasUsed:e.gasUsed,cumulativeGasUsed:e.cumulativeGasUsed,gasPrice:e.effectiveGasPrice||e.gasPrice,type:e.type,status:e.status,root:e.root})}get logs(){return v(this,lr)}toJSON(){const{to:e,from:t,contractAddress:r,hash:s,index:i,blockHash:o,blockNumber:a,logsBloom:c,logs:u,status:l,root:h}=this;return{_type:"TransactionReceipt",blockHash:o,blockNumber:a,contractAddress:r,cumulativeGasUsed:De(this.cumulativeGasUsed),from:t,gasPrice:De(this.gasPrice),gasUsed:De(this.gasUsed),hash:s,index:i,logs:u,logsBloom:c,root:h,status:l,to:e}}get length(){return this.logs.length}[Symbol.iterator](){let e=0;return{next:()=>e<this.length?{value:this.logs[e++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const e=await this.provider.getBlock(this.blockHash);if(e==null)throw new Error("TODO");return e}async getTransaction(){const e=await this.provider.getTransaction(this.hash);if(e==null)throw new Error("TODO");return e}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return ia(this)}reorderedEvent(e){return O(!e||e.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),sa(this,e)}}lr=new WeakMap;var Ye;const Is=class{constructor(e,t){m(this,"provider");m(this,"blockNumber");m(this,"blockHash");m(this,"index");m(this,"hash");m(this,"type");m(this,"to");m(this,"from");m(this,"nonce");m(this,"gasLimit");m(this,"gasPrice");m(this,"maxPriorityFeePerGas");m(this,"maxFeePerGas");m(this,"data");m(this,"value");m(this,"chainId");m(this,"signature");m(this,"accessList");L(this,Ye,void 0);this.provider=t,this.blockNumber=e.blockNumber!=null?e.blockNumber:null,this.blockHash=e.blockHash!=null?e.blockHash:null,this.hash=e.hash,this.index=e.index,this.type=e.type,this.from=e.from,this.to=e.to||null,this.gasLimit=e.gasLimit,this.nonce=e.nonce,this.data=e.data,this.value=e.value,this.gasPrice=e.gasPrice,this.maxPriorityFeePerGas=e.maxPriorityFeePerGas!=null?e.maxPriorityFeePerGas:null,this.maxFeePerGas=e.maxFeePerGas!=null?e.maxFeePerGas:null,this.chainId=e.chainId,this.signature=e.signature,this.accessList=e.accessList!=null?e.accessList:null,F(this,Ye,-1)}toJSON(){const{blockNumber:e,blockHash:t,index:r,hash:s,type:i,to:o,from:a,nonce:c,data:u,signature:l,accessList:h}=this;return{_type:"TransactionReceipt",accessList:h,blockNumber:e,blockHash:t,chainId:De(this.chainId),data:u,from:a,gasLimit:De(this.gasLimit),gasPrice:De(this.gasPrice),hash:s,maxFeePerGas:De(this.maxFeePerGas),maxPriorityFeePerGas:De(this.maxPriorityFeePerGas),nonce:c,signature:l,to:o,index:r,type:i,value:De(this.value)}}async getBlock(){let e=this.blockNumber;if(e==null){const r=await this.getTransaction();r&&(e=r.blockNumber)}if(e==null)return null;const t=this.provider.getBlock(e);if(t==null)throw new Error("TODO");return t}async getTransaction(){return this.provider.getTransaction(this.hash)}async wait(e,t){const r=e??1,s=t??0;let i=v(this,Ye),o=-1,a=i===-1;const c=async()=>{if(a)return null;const{blockNumber:h,nonce:p}=await Ro({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(p<this.nonce){i=h;return}if(a)return null;const f=await this.getTransaction();if(!(f&&f.blockNumber!=null))for(o===-1&&(o=i-3,o<v(this,Ye)&&(o=v(this,Ye)));o<=h;){if(a)return null;const d=await this.provider.getBlock(o,!0);if(d==null)return;for(const w of d)if(w===this.hash)return;for(let w=0;w<d.length;w++){const b=await d.getTransaction(w);if(b.from===this.from&&b.nonce===this.nonce){if(a)return null;const T=await this.provider.getTransactionReceipt(b.hash);if(T==null||h-T.blockNumber+1<r)return;let P="replaced";b.data===this.data&&b.to===this.to&&b.value===this.value?P="repriced":b.data==="0x"&&b.from===b.to&&b.value===yd&&(P="cancelled"),O(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:P==="replaced"||P==="cancelled",reason:P,replacement:b.replaceableTransaction(i),hash:b.hash,receipt:T})}}o++}},u=await this.provider.getTransactionReceipt(this.hash);if(u){if(await u.confirmations()>=r)return u}else if(await c(),r===0)return null;return await new Promise((h,p)=>{const f=[],d=()=>{f.forEach(b=>b())};if(f.push(()=>{a=!0}),s>0){const b=setTimeout(()=>{d(),p(cn("wait for transaction timeout","TIMEOUT"))},s);f.push(()=>{clearTimeout(b)})}const w=async b=>{await b.confirmations()>=r&&(d(),h(b))};if(f.push(()=>{this.provider.off(this.hash,w)}),this.provider.on(this.hash,w),i>=0){const b=async()=>{try{await c()}catch(T){if(Br(T,"TRANSACTION_REPLACED")){d(),p(T);return}}a||this.provider.once("block",b)};f.push(()=>{this.provider.off("block",b)}),this.provider.once("block",b)}})}isMined(){return this.blockHash!=null}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}removedEvent(){return O(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),ia(this)}reorderedEvent(e){return O(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),O(!e||e.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),sa(this,e)}replaceableTransaction(e){E(Number.isInteger(e)&&e>=0,"invalid startBlock","startBlock",e);const t=new Is(this,this.provider);return F(t,Ye,e),t}};let ts=Is;Ye=new WeakMap;function sa(n,e){return{orphan:"reorder-transaction",tx:n,other:e}}function ia(n){return{orphan:"drop-transaction",tx:n}}function wd(n){return{orphan:"drop-log",log:{transactionHash:n.transactionHash,blockHash:n.blockHash,blockNumber:n.blockNumber,address:n.address,data:n.data,topics:Object.freeze(n.topics.slice()),index:n.index}}}class Ss extends As{constructor(t,r,s){super(t,t.provider);m(this,"interface");m(this,"fragment");m(this,"args");const i=r.decodeEventLog(s,t.data,t.topics);R(this,{args:i,fragment:s,interface:r})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}var Ht;class bd extends gd{constructor(t,r,s){super(s,r);L(this,Ht,void 0);F(this,Ht,t)}get logs(){return super.logs.map(t=>{const r=t.topics.length?v(this,Ht).getEvent(t.topics[0]):null;return r?new Ss(t,v(this,Ht),r):t})}}Ht=new WeakMap;var hr;class Rs extends ts{constructor(t,r,s){super(s,r);L(this,hr,void 0);F(this,hr,t)}async wait(t){const r=await super.wait();return r==null?null:new bd(v(this,hr),this.provider,r)}}hr=new WeakMap;class oa extends Lh{constructor(t,r,s,i){super(t,r,s);m(this,"log");R(this,{log:i})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}}class vd extends oa{constructor(e,t,r,s,i){super(e,t,r,new Ss(i,e.interface,s));const o=e.interface.decodeEventLog(s,this.log.data,this.log.topics);R(this,{args:o,fragment:s})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const $i=BigInt(0);function aa(n){return n&&typeof n.call=="function"}function ca(n){return n&&typeof n.estimateGas=="function"}function Ps(n){return n&&typeof n.resolveName=="function"}function ua(n){return n&&typeof n.sendTransaction=="function"}var fr;class _d{constructor(e,t,r){L(this,fr,void 0);m(this,"fragment");if(R(this,{fragment:t}),t.inputs.length<r.length)throw new Error("too many arguments");const s=_t(e.runner,"resolveName"),i=Ps(s)?s:null;F(this,fr,async function(){const o=await Promise.all(t.inputs.map((a,c)=>r[c]==null?null:a.walkAsync(r[c],(l,h)=>l==="address"?ks(h,i):h)));return e.interface.encodeFilterTopics(t,o)}())}getTopicFilter(){return v(this,fr)}}fr=new WeakMap;function Ed(){return Function}function _t(n,e){return n==null?null:typeof n[e]=="function"?n:n.provider&&typeof n.provider[e]=="function"?n.provider:null}function ht(n){return n==null?null:n.provider||null}async function la(n,e){const t=md(Q.dereference(n,"overrides"));return E(t.to==null||(e||[]).indexOf("to")>=0,"cannot override to","overrides.to",t.to),E(t.data==null||(e||[]).indexOf("data")>=0,"cannot override data","overrides.data",t.data),t.from&&(t.from=await ks(t.from)),t}async function xd(n,e,t){const r=_t(n,"resolveName"),s=Ps(r)?r:null;return await Promise.all(e.map((i,o)=>i.walkAsync(t[o],(a,c)=>(c=Q.dereference(c,a),a==="address"?ks(c,s):c))))}class Td{constructor(e){m(this,"_contract");return R(this,{_contract:e}),new Proxy(this,{apply:async(r,s,i)=>await r.send(...i)})}async populateTransaction(e){const t=await la(e,["data"]);t.to=await this._contract.getAddress();const r=this._contract.interface,s=r.receive||r.fallback&&r.fallback.payable;return E(s||(t.value||$i)===$i,"cannot send value to non-payable contract","overrides.value",t.value),E(r.fallback||(t.data||"0x")==="0x","cannot send data to receive-only contract","overrides.data",t.data),t}async staticCall(e){const t=_t(this._contract.runner,"call");O(aa(t),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const r=await this.populateTransaction(e);try{return await t.call(r)}catch(s){throw Po(s)&&s.data?this._contract.interface.makeError(s.data,r):s}}async send(e){const t=this._contract.runner;O(ua(t),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const r=await t.sendTransaction(await this.populateTransaction(e)),s=ht(this._contract.runner);return new Rs(this._contract.interface,s,r)}async estimateGas(e){const t=_t(this._contract.runner,"estimateGas");return O(ca(t),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await t.estimateGas(await this.populateTransaction(e))}}class Od extends Ed(){constructor(t,r){super();m(this,"name","");m(this,"_contract");m(this,"_key");return R(this,{name:t.interface.getFunctionName(r),_contract:t,_key:r}),new Proxy(this,{apply:async(i,o,a)=>i.getFragment(...a).constant?await i.staticCall(...a):await i.send(...a)})}get fragment(){const t=this._contract.interface.getFunction(this._key);return O(t,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment"}),t}getFragment(...t){const r=this._contract.interface.getFunction(this._key,t);return O(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment"}),r}async populateTransaction(...t){const r=this.getFragment(...t);let s={};if(r.inputs.length+1===t.length&&(s=await la(t.pop())),r.inputs.length!==t.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const i=await xd(this._contract.runner,r.inputs,t);return Object.assign({},s,await Ro({to:this._contract.getAddress(),data:this._contract.interface.encodeFunctionData(r,i)}))}async staticCall(...t){const r=await this.staticCallResult(...t);return r.length===1?r[0]:r}async send(...t){const r=this._contract.runner;O(ua(r),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const s=await r.sendTransaction(await this.populateTransaction(...t)),i=ht(this._contract.runner);return new Rs(this._contract.interface,i,s)}async estimateGas(...t){const r=_t(this._contract.runner,"estimateGas");return O(ca(r),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await r.estimateGas(await this.populateTransaction(...t))}async staticCallResult(...t){const r=_t(this._contract.runner,"call");O(aa(r),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const s=await this.populateTransaction(...t);let i="0x";try{i=await r.call(s)}catch(a){throw Po(a)&&a.data?this._contract.interface.makeError(a.data,s):a}const o=this.getFragment(...t);return this._contract.interface.decodeFunctionResult(o,i)}}function kd(){return Function}class Ad extends kd(){constructor(t,r){super();m(this,"name","");m(this,"_contract");m(this,"_key");return R(this,{name:t.interface.getEventName(r),_contract:t,_key:r}),new Proxy(this,{apply:(s,i,o)=>new _d(t,s.getFragment(...o),o)})}get fragment(){const t=this._contract.interface.getEvent(this._key);return O(t,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment"}),t}getFragment(...t){const r=this._contract.interface.getEvent(this._key,t);return O(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment"}),r}}const zr=Symbol.for("_ethersInternal_contract"),ha=new WeakMap;function Sd(n,e){ha.set(n[zr],e)}function he(n){return ha.get(n[zr])}function Rd(n){return n&&typeof n=="object"&&"getTopicFilter"in n&&typeof n.getTopicFilter=="function"&&n.fragment}async function Ns(n,e){let t,r=null;if(Array.isArray(e)){const i=function(o){if(Qe(o,32))return o;const a=n.interface.getEvent(o);return E(a,"unknown fragment","name",o),a.topicHash};t=e.map(o=>o==null?null:Array.isArray(o)?o.map(i):i(o))}else e==="*"?t=[null]:typeof e=="string"?Qe(e,32)?t=[e]:(r=n.interface.getEvent(e),E(r,"unknown fragment","event",e),t=[r.topicHash]):Rd(e)?t=await e.getTopicFilter():"fragment"in e?(r=e.fragment,t=[r.topicHash]):E(!1,"unknown event name","event",e);t=t.map(i=>{if(i==null)return null;if(Array.isArray(i)){const o=Array.from(new Set(i.map(a=>a.toLowerCase())).values());return o.length===1?o[0]:(o.sort(),o)}return i.toLowerCase()});const s=t.map(i=>i==null?"null":Array.isArray(i)?i.join("|"):i).join("&");return{fragment:r,tag:s,topics:t}}async function Zt(n,e){const{subs:t}=he(n);return t.get((await Ns(n,e)).tag)||null}async function Ci(n,e,t){const r=ht(n.runner);O(r,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:e});const{fragment:s,tag:i,topics:o}=await Ns(n,t),{addr:a,subs:c}=he(n);let u=c.get(i);if(!u){const h={address:a||n,topics:o},p=b=>{let T=s;if(T==null)try{T=n.interface.getEvent(b.topics[0])}catch{}if(T){const P=T,M=s?n.interface.decodeEventLog(s,b.data,b.topics):[];ns(n,t,M,U=>new vd(n,U,t,P,b))}else ns(n,t,[],P=>new oa(n,P,t,b))};let f=[];u={tag:i,listeners:[],start:()=>{f.length||f.push(r.on(h,p))},stop:async()=>{if(f.length==0)return;let b=f;f=[],await Promise.all(b),r.off(h,p)}},c.set(i,u)}return u}let rs=Promise.resolve();async function Pd(n,e,t,r){await rs;const s=await Zt(n,e);if(!s)return!1;const i=s.listeners.length;return s.listeners=s.listeners.filter(({listener:o,once:a})=>{const c=Array.from(t);r&&c.push(r(a?null:o));try{o.call(n,...c)}catch{}return!a}),i>0}async function ns(n,e,t,r){try{await rs}catch{}const s=Pd(n,e,t,r);return rs=s,await s}const Fi=["then"];var Hd;const Gr=class{constructor(e,t,r,s){m(this,"target");m(this,"interface");m(this,"runner");m(this,"filters");m(this,Hd);m(this,"fallback");r==null&&(r=null);const i=Yn.from(t);R(this,{target:e,runner:r,interface:i}),Object.defineProperty(this,zr,{value:{}});let o,a=null,c=null;if(s){const h=ht(r);c=new Rs(this.interface,h,s)}let u=new Map;if(typeof e=="string")if(Qe(e))a=e,o=Promise.resolve(e);else{const h=_t(r,"resolveName");if(!Ps(h))throw cn("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});o=h.resolveName(e).then(p=>{if(p==null)throw new Error("TODO");return he(this).addr=p,p})}else o=e.getAddress().then(h=>{if(h==null)throw new Error("TODO");return he(this).addr=h,h});Sd(this,{addrPromise:o,addr:a,deployTx:c,subs:u});const l=new Proxy({},{get:(h,p,f)=>{if(Fi.indexOf(p)>=0)return Reflect.get(h,p,f);const d=String(p),w=this.getEvent(d);if(w)return w;throw new Error(`unknown contract event: ${d}`)}});return R(this,{filters:l}),R(this,{fallback:i.receive||i.fallback?new Td(this):null}),new Proxy(this,{get:(h,p,f)=>{if(p in h||Fi.indexOf(p)>=0)return Reflect.get(h,p,f);const d=String(p),w=h.getFunction(d);if(w)return w;throw new Error(`unknown contract method: ${d}`)}})}connect(e){return new Gr(this.target,this.interface,e)}async getAddress(){return await he(this).addrPromise}async getDeployedCode(){const e=ht(this.runner);O(e,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const t=await e.getCode(await this.getAddress());return t==="0x"?null:t}async waitForDeployment(){const e=this.deploymentTransaction();if(e)return await e.wait(),this;if(await this.getDeployedCode()!=null)return this;const r=ht(this.runner);return O(r!=null,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise((s,i)=>{const o=async()=>{try{if(await this.getDeployedCode()!=null)return s(this);r.once("block",o)}catch(a){i(a)}};o()})}deploymentTransaction(){return he(this).deployTx}getFunction(e){return typeof e!="string"&&(e=e.format()),new Od(this,e)}getEvent(e){return typeof e!="string"&&(e=e.format()),new Ad(this,e)}async queryTransaction(e){throw new Error("@TODO")}async queryFilter(e,t,r){t==null&&(t=0),r==null&&(r="latest");const{addr:s,addrPromise:i}=he(this),o=s||await i,{fragment:a,topics:c}=await Ns(this,e),u={address:o,topics:c,fromBlock:t,toBlock:r},l=ht(this.runner);return O(l,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await l.getLogs(u)).map(h=>{let p=a;if(p==null)try{p=this.interface.getEvent(h.topics[0])}catch{}return p?new Ss(h,this.interface,p):new As(h,l)})}async on(e,t){const r=await Ci(this,"on",e);return r.listeners.push({listener:t,once:!1}),r.start(),this}async once(e,t){const r=await Ci(this,"once",e);return r.listeners.push({listener:t,once:!0}),r.start(),this}async emit(e,...t){return await ns(this,e,t,null)}async listenerCount(e){if(e){const s=await Zt(this,e);return s?s.listeners.length:0}const{subs:t}=he(this);let r=0;for(const{listeners:s}of t.values())r+=s.length;return r}async listeners(e){if(e){const s=await Zt(this,e);return s?s.listeners.map(({listener:i})=>i):[]}const{subs:t}=he(this);let r=[];for(const{listeners:s}of t.values())r=r.concat(s.map(({listener:i})=>i));return r}async off(e,t){const r=await Zt(this,e);if(!r)return this;if(t){const s=r.listeners.map(({listener:i})=>i).indexOf(t);s>=0&&r.listeners.splice(s,1)}return(t==null||r.listeners.length===0)&&(r.stop(),he(this).subs.delete(r.tag)),this}async removeAllListeners(e){if(e){const t=await Zt(this,e);if(!t)return this;t.stop(),he(this).subs.delete(t.tag)}else{const{subs:t}=he(this);for(const{tag:r,stop:s}of t.values())s(),t.delete(r)}return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return await this.off(e,t)}static buildClass(e){class t extends Gr{constructor(s,i=null){super(s,e,i)}}return t}static from(e,t,r){return r==null&&(r=null),new this(e,t,r)}};let ss=Gr;Hd=zr;function Nd(){return ss}class $d extends Nd(){}class Ot{constructor(e){m(this,"data",[]);this.api=e}static create(e){return new Ot(e)}getAbiHash(e){if(this.api===void 0)throw new Error("FunctionBuilder must be initialised with api");return this.api.getAbiHash(e)}static readFields(e,t){if(e.length===0)return[];const r=(s,i)=>{console.log(t);const o=t[i].find(a=>a.name===s.function);if(!o)throw new Error("function not in ABI");return o.outputs.map((a,c)=>({source:`function:${s.function}:${i}`,name:a.name,type:a.type,key:`func_${i}_ret_${c}`,index:c}))};return e.map((s,i)=>r(s,i))}async addFunction(e,t,r,s,i){console.log(i);const o=new $d(e,s);return o.interface.encodeFunctionData(t,r),i=i||await this.getAbiHash(s),console.log(i),this.data.push({address:e,bytecode:o.interface.encodeFunctionData(t,r),abiHash:i,function:t}),this}get(){return this.data}static schema(){return gt().of(ie({address:k().required(),bytecode:k().matches(/^(0x)?([0-9a-fA-F]{2})*$/).required(),abiHash:k().matches(/^[A-Fa-f0-9]{64}/).required(),function:k().required()}))}}class Ke{static version(){return"v1"}static execute(e,t,r="v1"){const s=JSON.parse(JSON.stringify(t));let i=!0;for(const o of s){const a=Ke.process(e,o.conditions);i=Ke.execLogic(i,o.logic,a)}return i}static process(e,t,r){const s=t.shift();if(!s)return r===void 0?!0:r;const i=Ke.execCondition(e,s);if(r===void 0||s.logic==="WHERE")return Ke.process(e,t,i);if(s.logic===void 0)throw new Error("Invalid filter. FilterCondition must have logic value");const o=Ke.execLogic(r,s.logic,i);return Ke.process(e,t,o)}static execLogic(e,t,r){switch(t){case"AND":return e&&r;case"OR":return e||r;case"XOR":return(e||r)&&!(e&&r);case"NAND":return!(e&&r);case"NOR":return!(e&&r);case"WHERE":return r;default:throw new Error(`Invalid Filter. Bad logic value: ${t}`)}}static execCondition(e,t){const r=e[t.key];if(t.type==="Number"){if(typeof t.constant!="number"||typeof r!="number")throw new Error(`Invalid filter. Type miss-match. Type: ${t.type}, Variable: ${t.constant}, Data: ${r}`);const s=r,i=t.constant;switch(t.operation){case"eq":return s===i;case"!eq":return s!==i;case"gt":return s>i;case"gte":return s>=i;case"lt":return s<i;case"lte":return s<=i;default:throw new Error("Invalid Filter. Operation does not match type")}}if(t.type==="String"){if(typeof t.constant!="string"||typeof r!="string")throw new Error(`Invalid filter. Type miss-match. Type: ${t.type}, Variable: ${t.constant}, Data: ${r}`);const s=r,i=t.constant;switch(t.operation){case"contains":return s.includes(i);case"!contains":return!s.includes(i);case"is":return s===i;case"!is":return s!==i;case"isEmpty":return s==="";case"!isEmpty":return s!=="";default:throw new Error("Invalid Filter. Operation does not match type")}}if(t.type==="Address"){if(typeof t.constant!="string"||typeof r!="string")throw new Error(`Invalid filter. Type miss-match. Type: ${t.type}, Variable: ${t.constant}, Data: ${r}`);const s=r,i=t.constant;switch(t.operation){case"contains":return s.toLowerCase().includes(i.toLowerCase());case"!contains":return!s.toLowerCase().includes(i.toLowerCase());case"is":return s.toLowerCase()===i.toLowerCase();case"!is":return s.toLowerCase()!==i.toLowerCase();case"isEmpty":return s==="";case"!isEmpty":return s!=="";default:throw new Error("Invalid Filter. Operation does not match type")}}throw new Error("Invalid Filter. Unknown Type")}}class mr{constructor(){m(this,"groups",[]);this.newGroup("WHERE")}static version(){return Ke.version()}static new(){return new mr}newGroup(e){if(this.groups.length!==0&&e==="WHERE")throw new Error('Only the first groups can start with "WHERE"');return this.groups.push({logic:"WHERE",conditions:[]}),this}addCondition(e,t,r,s,i){const o=this.groups[this.groups.length-1];if(o.conditions.length===0&&e!=="WHERE")throw new Error('Logic for the first condition of a group must be "WHERE"');if(o.conditions.length>0&&e==="WHERE")throw new Error('Only the first condition of a group can be "WHERE"');return o.conditions.push({logic:e,key:t,type:r,operation:s,constant:i}),this}finalise(){for(const e of this.groups)if(e.conditions.length===0)throw new Error("Bad Filter. All Groups must have atleast one condition");return this.groups}static schema(){const e=k().oneOf(["AND","OR","XOR","NAND","NOR","WHERE"]).required(),t=ie({logic:e,key:k().required(),type:k().oneOf(["String","Address","Number"]).required(),operation:k().when("type",([r],s)=>{switch(r){case"String":return s.oneOf(["contains","!contains","is","!is","isEmpty","!isEmpty"]);case"Address":return s.oneOf(["is","!is","isEmpty","!isEmpty"]);case"Number":return s.oneOf(["eq","!eq","gt","gte","lt","lte"]);default:throw new Error("Invalid Filter Data Type")}}).required(),constant:vo().when("type",([r])=>{switch(r){case"String":return k();case"Address":return k();case"Number":return K();default:throw new Error("Invalid Filter Data Type")}}).required()});return gt().of(ie({logic:e,conditions:gt().of(t).required()}))}}const Cd="handler_function_call_v2",Fd=/^(\d+)([SMHD])$/i,Ii=ie({timeBase:k().oneOf(["blocks","time"]).required(),nBlocks:K().min(10).when("timeBase",([n],e)=>n==="blocks"?e.required():e),timePeriod:k().matches(Fd,"timePeriod must be of the format n[s|m|h|d], eg 10s for 10 seconds").when("timeBase",([n],e)=>n==="time"?e.required():e),startTime:K().default(0),debounceCount:K().default(0),functions:Ot.schema().required(),triggerOn:k().oneOf(["always","filter"]).default("always"),latch:on().default(!1),filterVersion:k().when("triggerOn",([n],e)=>n==="filter"?e.default("0"):e.nullable().default(null)).required(),filter:mr.schema().when("triggerOn",([n],e)=>n==="filter"?e.required():e.nullable().default(null)).required()});class $n{static async SimpleToRaw(e,t,r){return{alertType:"event",network:t,nickname:e,type:Cd,handler:await this.validate(r)}}static validate(e){return Ii.validateSync(e)}static async convertFromPartial(e){return Ii.validate(e)}static readFields(e,t){const r=[{source:"defaults",label:"Network",type:"string",key:"network"},{source:"defaults",label:"Timestamp",type:"number",key:"timestamp"},{source:"defaults",label:"Time GMT",type:"number",key:"timeStringGMT"},{source:"defaults",label:"Block",type:"number",key:"block"},{source:"defaults",label:"Time Period",type:"number",key:"timePeriod"}];if(!e.functions)return r;const s=e.functions.map(i=>t[i.abiHash]);return console.log(s),[...Ot.readFields(e.functions,s),...r]}}const Id="handler_onchain_event_v2",Dd=ie({addresses:gt().of(k().required()).required(),abiHash:k().required(),event:k().required(),debounceCount:K().default(0),functions:Ot.schema().nullable().default(null),triggerOn:k().oneOf(["always","filter"]).default("always"),latch:on().default(!1),filterVersion:k().nullable().default(null),filter:mr.schema().when("triggerOn",([n],e)=>n==="filter"?e:e.nullable().default(null)).required()}),Ud=n=>n,fa=(n,e,t=[],r="",s="")=>(n.forEach((i,o)=>{const a=i.type.includes("["),c=a?"_[]":"";if(i.components){const u=i.name===""?`${o}`:i.name;fa(i.components,e,t,`${r}${o}${c}_`,`${u}${a?"[]":""}.`)}else t.push({source:e,label:`${s}${i.name}`,type:Ud(i.type),key:`${r}${o}${c}`,index:o})}),t);class Cn{static async SimpleToRaw(e,t,r){return{alertType:"event",network:t,nickname:e,type:Id,handler:await this.validate(r)}}static validate(e){return Dd.validateSync(e)}static readFields(e,t){let r=[{source:"defaults",label:"Network",type:"string",key:"network"},{source:"defaults",label:"Timestamp",type:"number",key:"timestamp"},{source:"defaults",label:"Time GMT",type:"string",key:"timeStringGMT"},{source:"defaults",label:"Block",type:"number",key:"block"},{source:"defaults",label:"Time Period",type:"string",key:"timePeriod"},{source:"defaults",label:"Block Hash",type:"string",key:"blockHash"},{source:"defaults",label:"Transaction Hash",type:"string",key:"txHash"},{source:"defaults",label:"Event",type:"string",key:"event"}];const s=t[e.abiHash].find(o=>o.name===e.event);if(r=fa(s.inputs,`${e.event} Event`,r,"param_"),!e.functions)return r;const i=e.functions.map(o=>t[o.abiHash]);return[...Ot.readFields(e.functions,i),...r]}}class Yt{static SimpleToRaw(e,t,r,s){switch(t){case"PollFunctionV2":return $n.SimpleToRaw(e,r,s);case"PollFunctionV1":return li.SimpleToRaw(e,r,s);case"OnchainEventV1":return hi.SimpleToRaw(e,r,s);case"OnchainEventV2":return Cn.SimpleToRaw(e,r,s);default:throw new Error("Invalid Trigger ID")}}static Validate(e,t){switch(e){case"PollFunctionV2":return $n.validate(t);case"PollFunctionV1":return li.validate(t);case"OnchainEventV1":return hi.validate(t);case"OnchainEventV2":return Cn.validate(t);default:throw new Error("Invalid Trigger ID")}}static RawToSimple(e){return{...{error:e.error,error_message:e.error_message,error_timestamp:e.error_timestamp},...e.handler}}static SimpleTypeToRawType(e){switch(e){case"PollFunctionV2":return"handler_function_call_v2";case"PollFunctionV1":return"handler_function_call";case"OnchainEventV1":return"handler_onchain_event";case"OnchainEventV2":return"handler_onchain_event_v2";default:throw new Error("Invalid Trigger ID")}}static RawTypeToSimpleType(e){switch(e){case"handler_function_call_v2":return"PollFunctionV2";case"handler_function_call":return"PollFunctionV1";case"handler_onchain_event":return"OnchainEventV1";case"handler_onchain_event_v2":return"OnchainEventV2";default:throw new Error("Invalid Trigger ID")}}static readFields(e,t,r){switch(e){case"PollFunctionV2":return $n.readFields(t,r);case"OnchainEventV2":return Cn.readFields(t,r);default:throw new Error("Invalid Trigger ID")}}}const Di=n=>`https://${n}.functions.supabase.co/`,Ui=n=>`https://${n}.supabase.co/`,Li="fdgtrxmmrtlokhgkvcjz",Ld="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZkZ3RyeG1tcnRsb2toZ2t2Y2p6Iiwicm9sZSI6ImFub24iLCJpYXQiOjE2NzMwODcwNzYsImV4cCI6MTk4ODY2MzA3Nn0.sAMxjlcJSSozBGr-LNcsudyxzUEM9e-UspMHHQLqLr4";class $s{constructor(e,t){m(this,"headers",{});this.url=e,this.headers={Authorization:`Bearer ${t}`,"Content-Type":"application/json"}}static async create(e){var t,r;if(e.key)throw new Error("Auth by key not yet supported");if(e.email&&e.password){const s=e.projectId?Ui(e.projectId):Ui(Li),i=e.projectId?Di(e.projectId):Di(Li),o=e.anonKey?e.anonKey:Ld,a=gu(s,o),{data:c,error:u}=await a.auth.signInWithPassword({email:e.email,password:e.password});if(u)throw u;if(((t=c.session)==null?void 0:t.access_token)===void 0)throw new Error("Access token not found");return new $s(i,(r=c.session)==null?void 0:r.access_token)}else throw new Error("Authentication Required. DeNotify supports either username/password or API key authentication")}async alertHistory(e,t){const r="alert-history",s=t||{};return e&&(s.id=e),Object.keys(s).length>0?await this.request("get",r,{params:t}):await this.request("get",r)}async getAlert(e){const t=(await this.request("get",`alerts/${e}`))[0];return await this.decode(t)}async getAlerts(){const e=await this.request("get","alerts");return Promise.all(e.map(t=>this.decode(t)))}async createAlert(e){const t=await this.encode(e);return await this.request("post","alerts",{body:t})}async updateRawTrigger(e,t){const r=await ie({name:k().optional(),enabled:on().optional()}).validate(t);await this.request("patch",`alerts/trigger/${e}`,{body:r})}async updateAlert(e,t){const r=[],{trigger:s,notification:i,...o}=t;return(o.name||o.enabled)&&r.push(this.updateRawTrigger(e,o)),s&&r.push(this.updateRawHandler(e,s)),i&&r.push(this.updateRawNotify(e,i)),await Promise.all(r),await this.getAlert(e)}async deleteAlert(e){return await this.request("delete",`alerts/${e}`)}async decode(e){return{id:e.alertId,enabled:e.trigger.enabled,name:e.trigger.nickname,network:e.trigger.network,triggerId:Yt.RawTypeToSimpleType(e.trigger.type),trigger:await Yt.RawToSimple(e.trigger),notificationId:Sn.RawTypeToSimpleType(e.notification.notify_type),notification:await Sn.RawToSimple(e.notification)}}async encode(e){return{trigger:await Yt.SimpleToRaw(e.name,e.triggerId,e.network,e.trigger),notification:await Sn.SimpleToRaw(e.notificationId,e.notification)}}async request(e,t,r={}){const s=new URL(`${this.url}${t}`);if(r.params)for(const a of Object.keys(r.params))s.searchParams.append(a,r.params[a]);const i={method:e,url:s.toString(),headers:this.headers};return r.body&&(i.data=r.body),(await Nl(i)).data}readFields(e,t,r){return Yt.readFields(e,t,r)}async getAbi(e,t){return await this.request("get",`abi/${e}/${t}`)}async getAbiHash(e){return(await this.request("post","abi",{body:e})).hash}async updateRawNotify(e,t){return await this.request("patch",`alerts/notify/${e}`,{body:t})}async updateRawHandler(e,t){return await this.request("patch",`alerts/trigger-handler/${e}`,{body:t})}}class Cs{constructor(e){m(this,"network");m(this,"triggerId");m(this,"trigger");m(this,"notificationId");m(this,"notification");this.name=e}static create(e){return new Cs(e)}onNetwork(e){return this.network=e,this}withTrigger(e,t){return this.triggerId=e,this.trigger=Yt.Validate(e,t),this}withNotification(e,t){return this.notificationId=e,this.notification=t,this}async config(){if(this.trigger===void 0||this.triggerId===void 0)throw new Error("Trigger not configured");if(this.notification===void 0||this.notificationId===void 0)throw new Error("Notification not configured");if(this.network===void 0)throw new Error("Network not configured");return{name:this.name,network:this.network,triggerId:this.triggerId,trigger:this.trigger,notificationId:this.notificationId,notification:this.notification}}}const jd=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Bd=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));exports.AlertBuilder=Cs;exports.DeNotifyClient=$s;exports.FilterBuilder=mr;exports.FunctionBuilder=Ot;exports.Notification=Bd;exports.Trigger=jd;