1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3777],{10725:(e,t,r)=>{"use strict";function n(e={}){return{getItem:t=>e[t]||null,setItem:(t,r)=>{e[t]=r},removeItem:t=>{delete e[t]}}}r.d(t,{r:()=>n})},15376:e=>{!function(){var t={675:function(e,t){"use strict";t.byteLength=function(e){var t=l(e),r=t[0],n=t[1];return(r+n)*3/4-n},t.toByteArray=function(e){var t,r,i=l(e),a=i[0],o=i[1],c=new s((a+o)*3/4-o),u=0,h=o>0?a-4:a;for(r=0;r<h;r+=4)t=n[e.charCodeAt(r)]<<18|n[e.charCodeAt(r+1)]<<12|n[e.charCodeAt(r+2)]<<6|n[e.charCodeAt(r+3)],c[u++]=t>>16&255,c[u++]=t>>8&255,c[u++]=255&t;return 2===o&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,c[u++]=255&t),1===o&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,c[u++]=t>>8&255,c[u++]=255&t),c},t.fromByteArray=function(e){for(var t,n=e.length,s=n%3,i=[],a=0,o=n-s;a<o;a+=16383)i.push(function(e,t,n){for(var s,i=[],a=t;a<n;a+=3)s=(e[a]<<16&0xff0000)+(e[a+1]<<8&65280)+(255&e[a+2]),i.push(r[s>>18&63]+r[s>>12&63]+r[s>>6&63]+r[63&s]);return i.join("")}(e,a,a+16383>o?o:a+16383));return 1===s?i.push(r[(t=e[n-1])>>2]+r[t<<4&63]+"=="):2===s&&i.push(r[(t=(e[n-2]<<8)+e[n-1])>>10]+r[t>>4&63]+r[t<<2&63]+"="),i.join("")};for(var r=[],n=[],s="undefined"!=typeof Uint8Array?Uint8Array:Array,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,o=i.length;a<o;++a)r[a]=i[a],n[i.charCodeAt(a)]=a;function l(e){var t=e.length;if(t%4>0)throw Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");-1===r&&(r=t);var n=r===t?0:4-r%4;return[r,n]}n[45]=62,n[95]=63},72:function(e,t,r){"use strict";var n=r(675),s=r(783),i="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;function a(e){if(e>0x7fffffff)throw RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,o.prototype),t}function o(e,t,r){if("number"==typeof e){if("string"==typeof t)throw TypeError('The "string" argument must be of type string. Received type number');return u(e)}return l(e,t,r)}function l(e,t,r){if("string"==typeof e){var n=e,s=t;if(("string"!=typeof s||""===s)&&(s="utf8"),!o.isEncoding(s))throw TypeError("Unknown encoding: "+s);var i=0|f(n,s),l=a(i),c=l.write(n,s);return c!==i&&(l=l.slice(0,c)),l}if(ArrayBuffer.isView(e))return h(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(C(e,ArrayBuffer)||e&&C(e.buffer,ArrayBuffer)||"undefined"!=typeof SharedArrayBuffer&&(C(e,SharedArrayBuffer)||e&&C(e.buffer,SharedArrayBuffer)))return function(e,t,r){var n;if(t<0||e.byteLength<t)throw RangeError('"offset" is outside of buffer bounds');if(e.byteLength<t+(r||0))throw RangeError('"length" is outside of buffer bounds');return Object.setPrototypeOf(n=void 0===t&&void 0===r?new Uint8Array(e):void 0===r?new Uint8Array(e,t):new Uint8Array(e,t,r),o.prototype),n}(e,t,r);if("number"==typeof e)throw TypeError('The "value" argument must not be of type number. Received type number');var u=e.valueOf&&e.valueOf();if(null!=u&&u!==e)return o.from(u,t,r);var p=function(e){if(o.isBuffer(e)){var t=0|d(e.length),r=a(t);return 0===r.length||e.copy(r,0,0,t),r}return void 0!==e.length?"number"!=typeof e.length||function(e){return e!=e}(e.length)?a(0):h(e):"Buffer"===e.type&&Array.isArray(e.data)?h(e.data):void 0}(e);if(p)return p;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return o.from(e[Symbol.toPrimitive]("string"),t,r);throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}function c(e){if("number"!=typeof e)throw TypeError('"size" argument must be of type number');if(e<0)throw RangeError('The value "'+e+'" is invalid for option "size"')}function u(e){return c(e),a(e<0?0:0|d(e))}function h(e){for(var t=e.length<0?0:0|d(e.length),r=a(t),n=0;n<t;n+=1)r[n]=255&e[n];return r}t.Buffer=o,t.SlowBuffer=function(e){return+e!=e&&(e=0),o.alloc(+e)}
vendor: 16,240 bytes, line 1
1,t.INSPECT_MAX_BYTES=50,t.kMaxLength=0x7fffffff,o.TYPED_ARRAY_SUPPORT=function(){try{var e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),42===e.foo()}catch(e){return!1}}(),o.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(o.prototype,"parent",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.buffer}}),Object.defineProperty(o.prototype,"offset",{enumerable:!0,get:function(){if(o.isBuffer(this))return this.byteOffset}}),o.poolSize=8192,o.from=function(e,t,r){return l(e,t,r)},Object.setPrototypeOf(o.prototype,Uint8Array.prototype),Object.setPrototypeOf(o,Uint8Array),o.alloc=function(e,t,r){return(c(e),e<=0)?a(e):void 0!==t?"string"==typeof r?a(e).fill(t,r):a(e).fill(t):a(e)},o.allocUnsafe=function(e){return u(e)},o.allocUnsafeSlow=function(e){return u(e)};function d(e){if(e>=0x7fffffff)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x7fffffff bytes");return 0|e}function f(e,t){if(o.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||C(e,ArrayBuffer))return e.byteLength;if("string"!=typeof e)throw TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);var r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var s=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return T(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return A(e).length;default:if(s)return n?-1:T(e).length;t=(""+t).toLowerCase(),s=!0}}function p(e,t,r){var s,i,a,o=!1;if((void 0===t||t<0)&&(t=0),t>this.length||((void 0===r||r>this.length)&&(r=this.length),r<=0||(r>>>=0)<=(t>>>=0)))return"";for(e||(e="utf8");;)switch(e){case"hex":return function(e,t,r){var n=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>n)&&(r=n);for(var s="",i=t;i<r;++i)s+=j[e[i]];return s}(this,t,r);case"utf8":case"utf-8":return b(this,t,r);case"ascii":return function(e,t,r){var n="";r=Math.min(e.length,r);for(var s=t;s<r;++s)n+=String.fromCharCode(127&e[s]);return n}(this,t,r);case"latin1":case"binary":return function(e,t,r){var n="";r=Math.min(e.length,r);for(var s=t;s<r;++s)n+=String.fromCharCode(e[s]);return n}(this,t,r);case"base64":return s=this,i=t,a=r,0===i&&a===s.length?n.fromByteArray(s):n.fromByteArray(s.slice(i,a));case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return function(e,t,r){for(var n=e.slice(t,r),s="",i=0;i<n.length;i+=2)s+=String.fromCharCode(n[i]+256*n[i+1]);return s}(this,t,r);default:if(o)throw TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),o=!0}}function m(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function g(e,t,r,n,s){var i;if(0===e.length)return -1;if("string"==typeof r?(n=r,r=0):r>0x7fffffff?r=0x7fffffff:r<-0x80000000&&(r=-0x80000000),(i=r*=1)!=i&&(r=s?0:e.length-1),r<0&&(r=e.length+r),r>=e.length)if(s)return -1;else r=e.length-1;else if(r<0)if(!s)return -1;else r=0;if("string"==typeof t&&(t=o.from(t,n)),o.isBuffer(t))return 0===t.length?-1:y(e,t,r,n,s);if("number"==typeof t){if(t&=255,"function"==typeof Uint8Array.prototype.indexOf)if(s)return Uint8Array.prototype.indexOf.call(e,t,r);else return Uint8Array.prototype.lastIndexOf.call(e,t,r);return y(e,[t],r,n,s)}throw TypeError("val must be string, number or Buffer")}function y(e,t,r,n,s){var i,a=1,o=e.length,l=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return -1;a=2,o/=2,l/=2,r/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(s){var u=-1;for(i=r;i<o;i++)if(c(e,i)===c(t,-1===u?0:i-u)){if(-1===u&&(u=i),i-u+1===l)return u*a}else -1!==u&&(i-=i-u),u=-1}else for(r+l>o&&(r=o-l),i=r;i>=0;i--){for(var h=!0,d=0;d<l;d++)if(c(e,i+d)!==c(t,d)){h=!1;break}if(h)return i}return -1}o.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==o.prototype},o.compare=function(e,t){if(C(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),C(t,Uint8Array)&&(t=o.from(t,t.offset,t.byteLength)),!o.isBuffer(e)||!o.isBuffer(t))throw TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(e===t)return 0;for(var r=e.length,n=t.length,s=0,i=Math.min(r,n);s<i;++s)if(e[s]!==t[s]){r=e[s],n=t[s];break}return r<n?-1:+(n<r)},o.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},o.concat=function(e,t){if(!Array.isArray(e))throw TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return o.alloc(0);if(void 0===t)for(r=0,t=0;r<e.length;++r)t+=e[r].length;var r,n=o.allocUnsafe(t),s=0;for(r=0;r<e.length;++r){var i=e[r];if(C(i,Uint8Array)&&(i=o.from(i)),!o.isBuffer(i))throw TypeError('"list" argument must be an Array of Buffers');i.copy(n,s),s+=i.length}return n},o.byteLength=f,o.prototype._isBuffer=!0,o.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)m(this,t,t+1);return this},o.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)m(this,t,t+3),m(this,t+1,t+2);return this},o.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)m(this,t,t+7),m(this,t+1,t+6),m(this,t+2,t+5),m(this,t+3,t+4);return this},o.prototype.toString=function(){var e=this.length;return 0===e?"":0==arguments.length?b(this,0,e):p.apply(this,arguments)},o.prototype.toLocaleString=o.prototype.toString,o.prototype.equals=function(e){if(!o.isBuffer(e))throw TypeError("Argument must be a Buffer");return this===e||0===o.compare(this,e)},o.prototype.inspect=function(){var e="",r=t.INSPECT_MAX_BYTES;return e=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(e+=" ... "),"<Buffer "+e+">"},i&&(o.prototype[i]=o.prototype.inspect),o.prototype.compare=function(e,t,r,n,s){if(C(e,Uint8Array)&&(e=o.from(e,e.offset,e.byteLength)),!o.isBuffer(e))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof e);if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===s&&(s=this.length),t<0||r>e.length||n<0||s>this.length)throw RangeError("out of range index");if(n>=s&&t>=r)return 0;if(n>=s)return -1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,s>>>=0,this===e)return 0;for(var i=s-n,a=r-t,l=Math.min(i,a),c=this.slice(n,s),u=e.slice(t,r),h=0;h<l;++h)if(c[h]!==u[h]){i=c[h],a=u[h];break}return i<a?-1:+(a<i)},o.prototype.includes=function(e,t,r){return -1!==this.indexOf(e,t,r)},o.prototype.indexOf=function(e,t,r){return g(this,e,t,r,!0)},o.prototype.lastIndexOf=function(e,t,r){return g(this,e,t,r,!1)};function b(e,t,r){r=Math.min(e.length,r);for(var n=[],s=t;s<r;){var i,a,o,l,c=e[s],u=null,h=c>239?4:c>223?3:c>191?2:1;if(s+h<=r)switch(h){case 1:c<128&&(u=c);break;case 2:(192&(i=e[s+1]))==128&&(l=(31&c)<<6|63&i)>127&&(u=l);break;case 3:i=e[s+1],a=e[s+2],(192&i)==128&&(192&a)==128&&(l=(15&c)<<12|(63&i)<<6|63&a)>2047&&(l<55296||l>57343)&&(u=l);break;case 4:i=e[s+1],a=e[s+2],o=e[s+3],(192&i)==128&&(192&a)==128&&(192&o)==128&&(l=(15&c)<<18|(63&i)<<12|(63&a)<<6|63&o)>65535&&l<1114112&&(u=l)}null===u?(u=65533,h=1):u>65535&&(u-=65536,n.push(u>>>10&1023|55296),u=56320|1023&u),n.push(u),s+=h}var d=n,f=d.length;if(f<=4096)return String.fromCharCode.apply(String,d);for(var p="",m=0;m<f;)p+=String.fromCharCode.apply(String,d.slice(m,m+=4096));return p}function v(e,t,r){if(e%1!=0||e<0)throw RangeError("offset is not uint");if(e+t>r)throw RangeError("Trying to access beyond buffer length")}function w(e,t,r,n,s,i){if(!o.isBuffer(e))throw TypeError('"buffer" argument must be a Buffer instance');if(t>s||t<i)throw RangeError('"value" argument is out of bounds');if(r+n>e.length)throw RangeError("Index out of range")}function k(e,t,r,n,s,i){if(r+n>e.length||r<0)throw RangeError("Index out of range")}function _(e,t,r,n,i){return t*=1,r>>>=0,i||k(e,t,r,4,34028234663852886e22,-34028234663852886e22),s.write(e,t,r,n,23,4),r+4}function E(e,t,r,n,i){return t*=1,r>>>=0,i||k(e,t,r,8,17976931348623157e292,-17976931348623157e292),s.write(e,t,r,n,52,8),r+8}o.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else if(isFinite(t))t>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0);else throw Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var s,i,a,o,l,c,u,h,d=this.length-t;if((void 0===r||r>d)&&(r=d),e.length>0&&(r<0||t<0)||t>this.length)throw RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var f=!1;;)switch(n){case"hex":return function(e,t,r,n){r=Number(r)||0;var s=e.length-r;n?(n=Number(n))>s&&(n=s):n=s;var i=t.length;n>i/2&&(n=i/2);for(var a=0;a<n;++a){var o,l=parseInt(t.substr(2*a,2),16);if((o=l)!=o)break;e[r+a]=l}return a}(this,e,t,r);case"utf8":case"utf-8":return s=t,i=r,$(T(e,this.length-s),this,s,i);case"ascii":return a=t,o=r,$(O(e),this,a,o);case"latin1":case"binary":return function(e,t,r,n){return $(O(t),e,r,n)}(this,e,t,r);case"base64":return l=t,c=r,$(A(e),this,l,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return u=t,h=r,$(function(e,t){for(var r,n,s=[],i=0;i<e.length&&!((t-=2)<0);++i)n=(r=e.charCodeAt(i))>>8,s.push(r%256),s.push(n);return s}(e,this.length-u),this,u,h);default:if(f)throw TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),f=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},o.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e);var n=this.subarray(e,t);return Object.setPrototypeOf(n,o.prototype),n},o.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||v(e,t,this.length);for(var n=this[e],s=1,i=0;++i<t&&(s*=256);)n+=this[e+i]*s;return n},o.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||v(e,t,this.length);for(var n=this[e+--t],s=1;t>0&&(s*=256);)n+=this[e+--t]*s;return n},o.prototype.readUInt8=function(e,t){return e>>>=0,t||v(e,1,this.length),this[e]},o.prototype.readUInt16LE=function(e,t){return e>>>=0,t||v(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUInt16BE=function(e,t){return e>>>=0,t||v(e,2,this.length),this[e]<<8|this[e+1]},o.prototype.readUInt32LE=function(e,t){return e>>>=0,t||v(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+0x1000000*this[e+3]},o.prototype.readUInt32BE=function(e,t){return e>>>=0,t||v(e,4,this.length),0x1000000*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},o.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||v(e,t,this.length);for(var n=this[e],s=1,i=0;++i<t&&(s*=256);)n+=this[e+i]*s;return n>=(s*=128)&&(n-=Math.pow(2,8*t)),n},o.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||v(e,t,this.length);for(var n=t,s=1,i=this[e+--n];n>0&&(s*=256);)i+=this[e+--n]*s;return i>=(s*=128)&&(i-=Math.pow(2,8*t)),i},o.prototype.readInt8=function(e,t){return(e>>>=0,t||v(e,1,this.length),128&this[e])?-((255-this[e]+1)*1):this[e]},o.prototype.readInt16LE=function(e,t){e>>>=0,t||v(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?0xffff0000|r:r},o.prototype.readInt16BE=function(e,t){e>>>=0,t||v(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?0xffff0000|r:r},o.prototype.readInt32LE=function(e,t){return e>>>=0,t||v(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},o.prototype.readInt32BE=function(e,t){return e>>>=0,t||v(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},o.prototype.readFloatLE=function(e,t){return e>>>=0,t||v(e,4,this.length),s.read(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return e>>>=0,t||v(e,4,this.length),s.read(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return e>>>=0,t||v(e,8,this.length),s.read(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return e>>>=0,t||v(e,8,this.length),s.read(this,e,!1,52,8)},o.prototype.writeUIntLE=function(e,t,r,n){if(e*=1,t>>>=0,r>>>=0,!n){var s=Math.pow(2,8*r)-1;w(this,e,t,r,s,0)}var i=1,a=0;for(this[t]=255&e;++a<r&&(i*=256);)this[t+a]=e/i&255;return t+r},o.prototype.writeUIntBE=function(e,t,r,n){if(e*=1,t>>>=0,r>>>=0,!n){var s=Math.pow(2,8*r)-1;w(this,e,t,r,s,0)}var i=r-1,a=1;for(this[t+i]=255&e;--i>=0&&(a*=256);)this[t+i]=e/a&255;return t+r},o.prototype.writeUInt8=function(e,t,r){return e*=1,t>>>=0,r||w(this,e,t,1,255,0),this[t]=255&e,t+1},o.prototype.writeUInt16LE=function(e,t,r){return e*=1,t>>>=0,r||w(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},o.prototype.writeUInt16BE=function(e,t,r){return e*=1,t>>>=0,r||w(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},o.prototype.writeUInt32LE=function(e,t,r){return e*=1,t>>>=0,r||w(this,e,t,4,0xffffffff,0),this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e,t+4},o.prototype.writeUInt32BE=function(e,t,r){return e*=1,t>>>=0,r||w(this,e,t,4,0xffffffff,0),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},o.prototype.writeIntLE=function(e,t,r,n){if(e*=1,t>>>=0,!n){var s=Math.pow(2,8*r-1);w(this,e,t,r,s-1,-s)}var i=0,a=1,o=0;for(this[t]=255&e;++i<r&&(a*=256);)e<0&&0===o&&0!==this[t+i-1]&&(o=1),this[t+i]=(e/a|0)-o&255;return t+r},o.prototype.writeIntBE=function(e,t,r,n){if(e*=1,t>>>=0,!n){var s=Math.pow(2,8*r-1);w(this,e,t,r,s-1,-s)}var i=r-1,a=1,o=0;for(this[t+i]=255&e;--i>=0&&(a*=256);)e<0&&0===o&&0!==this[t+i+1]&&(o=1),this[t+i]=(e/a|0)-o&255;return t+r},o.prototype.writeInt8=function(e,t,r){return e*=1,t>>>=0,r||w(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},o.prototype.writeInt16LE=function(e,t,r){return e*=1,t>>>=0,r||w(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},o.prototype.writeInt16BE=function(e,t,r){return e*=1,t>>>=0,r||w(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},o.prototype.writeInt32LE=function(e,t,r){return e*=1,t>>>=0,r||w(this,e,t,4,0x7fffffff,-0x80000000),this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24,t+4},o.prototype.writeInt32BE=function(e,t,r){return e*=1,t>>>=0,r||w(this,e,t,4,0x7fffffff,-0x80000000),e<0&&(e=0xffffffff+e+1),this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e,t+4},o.prototype.writeFloatLE=function(e,t,r){return _(this,e,t,!0,r)},o.prototype.writeFloatBE=function(e,t,r){return _(this,e,t,!1,r)},o.prototype.writeDoubleLE=function(e,t,r){return E(this,e,t,!0,r)},o.prototype.writeDoubleBE=function(e,t,r){return E(this,e,t,!1,r)},o.prototype.copy=function(e,t,r,n){if(!o.isBuffer(e))throw TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r||0===e.length||0===this.length)return 0;if(t<0)throw RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw RangeError("Index out of range");if(n<0)throw RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var s=n-r;if(this===e&&"function"==typeof Uint8Array.prototype.copyWithin)this.copyWithin(t,r,n);else if(this===e&&r<t&&t<n)for(var i=s-1;i>=0;--i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,n),t);return s},o.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw TypeError("encoding must be a string");if("string"==typeof n&&!o.isEncoding(n))throw TypeError("Unknown encoding: "+n);if(1===e.length){var s,i=e.charCodeAt(0);("utf8"===n&&i<128||"latin1"===n)&&(e=i)}}else"number"==typeof e?e&=255:"boolean"==typeof e&&(e=Number(e));if(t<0||this.length<t||this.length<r)throw RangeError("Out of range index");if(r<=t)return this;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(s=t;s<r;++s)this[s]=e;else{var a=o.isBuffer(e)?e:o.from(e,n),l=a.length;
1if(0===l)throw TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<r-t;++s)this[s+t]=a[s%l]}return this};var S=/[^+/0-9A-Za-z-_]/g;function T(e,t){t=t||1/0;for(var r,n=e.length,s=null,i=[],a=0;a<n;++a){if((r=e.charCodeAt(a))>55295&&r<57344){if(!s){if(r>56319||a+1===n){(t-=3)>-1&&i.push(239,191,189);continue}s=r;continue}if(r<56320){(t-=3)>-1&&i.push(239,191,189),s=r;continue}r=(s-55296<<10|r-56320)+65536}else s&&(t-=3)>-1&&i.push(239,191,189);if(s=null,r<128){if((t-=1)<0)break;i.push(r)}else if(r<2048){if((t-=2)<0)break;i.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;i.push(r>>12|224,r>>6&63|128,63&r|128)}else if(r<1114112){if((t-=4)<0)break;i.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}else throw Error("Invalid code point")}return i}function O(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}function A(e){return n.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(S,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function $(e,t,r,n){for(var s=0;s<n&&!(s+r>=t.length)&&!(s>=e.length);++s)t[s+r]=e[s];return s}function C(e,t){return e instanceof t||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}var j=function(){for(var e="0123456789abcdef",t=Array(256),r=0;r<16;++r)for(var n=16*r,s=0;s<16;++s)t[n+s]=e[r]+e[s];return t}()},783:function(e,t){t.read=function(e,t,r,n,s){var i,a,o=8*s-n-1,l=(1<<o)-1,c=l>>1,u=-7,h=r?s-1:0,d=r?-1:1,f=e[t+h];for(h+=d,i=f&(1<<-u)-1,f>>=-u,u+=o;u>0;i=256*i+e[t+h],h+=d,u-=8);for(a=i&(1<<-u)-1,i>>=-u,u+=n;u>0;a=256*a+e[t+h],h+=d,u-=8);if(0===i)i=1-c;else{if(i===l)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,n),i-=c}return(f?-1:1)*a*Math.pow(2,i-n)},t.write=function(e,t,r,n,s,i){var a,o,l,c=8*i-s-1,u=(1<<c)-1,h=u>>1,d=5960464477539062e-23*(23===s),f=n?0:i-1,p=n?1:-1,m=+(t<0||0===t&&1/t<0);for(isNaN(t=Math.abs(t))||t===1/0?(o=+!!isNaN(t),a=u):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),a+h>=1?t+=d/l:t+=d*Math.pow(2,1-h),t*l>=2&&(a++,l/=2),a+h>=u?(o=0,a=u):a+h>=1?(o=(t*l-1)*Math.pow(2,s),a+=h):(o=t*Math.pow(2,h-1)*Math.pow(2,s),a=0));s>=8;e[r+f]=255&o,f+=p,o/=256,s-=8);for(a=a<<s|o,c+=s;c>0;e[r+f]=255&a,f+=p,a/=256,c-=8);e[r+f-p]|=128*m}}},r={};function n(e){var s=r[e];if(void 0!==s)return s.exports;var i=r[e]={exports:{}},a=!0;try{t[e](i,i.exports,n),a=!1}finally{a&&delete r[e]}return i.exports}n.ab="//",e.exports=n(72)}()},24174:(e,t,r)=>{"use strict";r.d(t,{Al:()=>u,no:()=>h,uE:()=>l,xf:()=>c});let n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),s=" \n\r=".split(""),i=(()=>{let e=Array(128);for(let t=0;t<e.length;t+=1)e[t]=-1;for(let t=0;t<s.length;t+=1)e[s[t].charCodeAt(0)]=-2;for(let t=0;t<n.length;t+=1)e[n[t].charCodeAt(0)]=t;return e})();function a(e,t,r){if(null!==e)for(t.queue=t.queue<<8|e,t.queuedBits+=8;t.queuedBits>=6;)r(n[t.queue>>t.queuedBits-6&63]),t.queuedBits-=6;else if(t.queuedBits>0)for(t.queue=t.queue<<6-t.queuedBits,t.queuedBits=6;t.queuedBits>=6;)r(n[t.queue>>t.queuedBits-6&63]),t.queuedBits-=6}function o(e,t,r){let n=i[e];if(n>-1)for(t.queue=t.queue<<6|n,t.queuedBits+=6;t.queuedBits>=8;)r(t.queue>>t.queuedBits-8&255),t.queuedBits-=8;else if(-2===n)return;else throw Error(`Invalid Base64-URL character "${String.fromCharCode(e)}"`)}function l(e){let t=[],r=e=>{t.push(String.fromCodePoint(e))},n={utf8seq:0,codepoint:0},s={queue:0,queuedBits:0},i=e=>{!function(e,t,r){if(0===t.utf8seq){if(e<=127)return r(e);for(let r=1;r<6;r+=1)if((e>>7-r&1)==0){t.utf8seq=r;break}if(2===t.utf8seq)t.codepoint=31&e;else if(3===t.utf8seq)t.codepoint=15&e;else if(4===t.utf8seq)t.codepoint=7&e;else throw Error("Invalid UTF-8 sequence");t.utf8seq-=1}else if(t.utf8seq>0){if(e<=127)throw Error("Invalid UTF-8 sequence");t.codepoint=t.codepoint<<6|63&e,t.utf8seq-=1,0===t.utf8seq&&r(t.codepoint)}}(e,n,r)};for(let t=0;t<e.length;t+=1)o(e.charCodeAt(t),s,i);return t.join("")}function c(e){let t=[],r={queue:0,queuedBits:0},n=e=>{t.push(e)};for(let t=0;t<e.length;t+=1)o(e.charCodeAt(t),r,n);return new Uint8Array(t)}function u(e){let t=[];return!function(e,t){for(let r=0;r<e.length;r+=1){let n=e.charCodeAt(r);if(n>55295&&n<=56319){let t=(n-55296)*1024&65535;n=(e.charCodeAt(r+1)-56320&65535|t)+65536,r+=1}!function(e,t){if(e<=127)return t(e);if(e<=2047){t(192|e>>6),t(128|63&e);return}if(e<=65535){t(224|e>>12),t(128|e>>
16&63),t(128|63&e);return}if(e<=1114111){t(240|e>>18),t(128|e>>12&63),t(128|e>>6&63),t(128|63&e);return}throw Error(`Unrecognized Unicode codepoint: ${e.toString(16)}`)}(n,t)}}(e,e=>t.push(e)),new Uint8Array(t)}function h(e){let t=[],r={queue:0,queuedBits:0},n=e=>{t.push(e)};return e.forEach(e=>a(e,r,n)),a(null,r,n),t.join("")}},24359:(e,t,r)=>{"use strict";let n,s;r.d(t,{k:()=>t$});var i,a,o,l,c,u,h=r(71450);class d extends Error{constructor(e,t="FunctionsError",r){super(e),this.name=t,this.context=r}toJSON(){return{name:this.name,message:this.message,context:this.context}}}class f extends d{constructor(e){super("Failed to send a request to the Edge Function","FunctionsFetchError",e)}}class p extends d{constructor(e){super("Relay Error invoking the Edge Function","FunctionsRelayError",e)}}class m extends d{constructor(e){super("Edge Function returned a non-2xx status code","FunctionsHttpError",e)}}!function(e){e.Any="any",e.ApNortheast1="ap-northeast-1",e.ApNortheast2="ap-northeast-2",e.ApSouth1="ap-south-1",e.ApSoutheast1="ap-southeast-1",e.ApSoutheast2="ap-southeast-2",e.CaCentral1="ca-central-1",e.EuCentral1="eu-central-1",e.EuWest1="eu-west-1",e.EuWest2="eu-west-2",e.EuWest3="eu-west-3",e.SaEast1="sa-east-1",e.UsEast1="us-east-1",e.UsWest1="us-west-1",e.UsWest2="us-west-2"}(i||(i={}));class g{constructor(e,{headers:t={},customFetch:r,region:n=i.Any}={}){this.url=e,this.headers=t,this.region=n,this.fetch=(e=>e?(...t)=>e(...t):(...e)=>fetch(...e))(r)}setAuth(e){this.headers.Authorization=`Bearer ${e}`}invoke(e){return(0,h.sH)(this,arguments,void 0,function*(e,t={}){var r;let n,s;try{let i,{headers:a,method:o,body:l,signal:c,timeout:u}=t,h={},{region:d}=t;d||(d=this.region);let g=new URL(`${this.url}/${e}`);d&&"any"!==d&&(h["x-region"]=d,g.searchParams.set("forceFunctionRegion",d)),l&&(a&&!Object.prototype.hasOwnProperty.call(a,"Content-Type")||!a)?"undefined"!=typeof Blob&&l instanceof Blob||l instanceof ArrayBuffer?(h["Content-Type"]="application/octet-stream",i=l):"string"==typeof l?(h["Content-Type"]="text/plain",i=l):"undefined"!=typeof FormData&&l instanceof FormData?i=l:(h["Content-Type"]="application/json",i=JSON.stringify(l)):i=!l||"string"==typeof l||"undefined"!=typeof Blob&&l instanceof Blob||l instanceof ArrayBuffer||"undefined"!=typeof FormData&&l instanceof FormData?l:JSON.stringify(l);let y=c;u&&(s=new AbortController,n=setTimeout(()=>s.abort(),u),c?(y=s.signal,c.addEventListener("abort",()=>s.abort())):y=s.signal);let b=yield this.fetch(g.toString(),{method:o||"POST",headers:Object.assign(Object.assign(Object.assign({},h),this.headers),a),body:i,signal:y}).catch(e=>{throw new f(e)}),v=b.headers.get("x-relay-error");if(v&&"true"===v)throw new p(b);if(!b.ok)throw new m(b);let w=(null!=(r=b.headers.get("Content-Type"))?r:"text/plain").split(";")[0].trim();return{data:"application/json"===w?yield b.json():"application/octet-stream"===w||"application/pdf"===w?yield b.blob():"text/event-stream"===w?b:"multipart/form-data"===w?yield b.formData():yield b.text(),error:null,response:b}}catch(e){return{data:null,error:e,response:e instanceof m||e instanceof p?e.context:void 0}}finally{n&&clearTimeout(n)}})}}let y=e=>Math.min(1e3*2**e,3e4),b=[520,503],v=["GET","HEAD","OPTIONS"];var w=class extends Error{constructor(e){super(e.message),this.name="PostgrestError",this.details=e.details,this.hint=e.hint,this.co
1de=e.code}toJSON(){return{name:this.name,message:this.message,details:this.details,hint:this.hint,code:this.code}}};function k(e,t){return new Promise(r=>{if(null==t?void 0:t.aborted)return void r();let n=setTimeout(()=>{null==t||t.removeEventListener("abort",s),r()},e);function s(){clearTimeout(n),r()}null==t||t.addEventListener("abort",s)})}var _=class{constructor(e){var t,r,n,s,i;this.shouldThrowOnError=!1,this.retryEnabled=!0,this.method=e.method,this.url=e.url,this.headers=new Headers(e.headers),this.schema=e.schema,this.body=e.body,this.shouldThrowOnError=null!=(t=e.shouldThrowOnError)&&t,this.signal=e.signal,this.isMaybeSingle=null!=(r=e.isMaybeSingle)&&r,this.shouldStripNulls=null!=(n=e.shouldStripNulls)&&n,this.urlLengthLimit=null!=(s=e.urlLengthLimit)?s:8e3,this.retryEnabled=null==(i=e.retry)||i,e.fetch?this.fetch=e.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}stripNulls(){if("text/csv"===this.headers.get("Accept"))throw Error("stripNulls() cannot be used with csv()");return this.shouldStripNulls=!0,this}setHeader(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}retry(e){return this.retryEnabled=e,this}then(e,t){var r=this;if(void 0===this.schema||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),"GET"!==this.method&&"HEAD"!==this.method&&this.headers.set("Content-Type","application/json"),this.shouldStripNulls){let e=this.headers.get("Accept");"application/vnd.pgrst.object+json"===e?this.headers.set("Accept","application/vnd.pgrst.object+json;nulls=stripped"):e&&"application/json"!==e||this.headers.set("Accept","application/vnd.pgrst.array+json;nulls=stripped")}let n=this.fetch,s=(async()=>{let e=0;for(;;){var t,s,i,a,o;let l,c=new Headers(r.headers);e>0&&c.set("X-Retry-Count",String(e));try{l=await n(r.url.toString(),{method:r.method,headers:c,body:JSON.stringify(r.body,(e,t)=>"bigint"==typeof t?t.toString():t),signal:r.signal})}catch(t){if((null==t?void 0:t.name)==="AbortError"||(null==t?void 0:t.code)==="ABORT_ERR"||!v.includes(r.method))throw t;if(r.retryEnabled&&e<3){let t=y(e);e++,await k(t,r.signal);continue}throw t}if(t=r.method,s=l.status,i=e,r.retryEnabled&&!(i>=3)&&v.includes(t)&&b.includes(s)&&1){let t=null!=(a=null==(o=l.headers)?void 0:o.get("Retry-After"))?a:null,n=null!==t?1e3*Math.max(0,parseInt(t,10)||0):y(e);await l.text(),e++,await k(n,r.signal);continue}return await r.processResponse(l)}})();return this.shouldThrowOnError||(s=s.catch(e=>{var t,r,n,s,i,a;let o="",l="",c="",u=null==e?void 0:e.cause;if(u){let t=null!=(r=null==u?void 0:u.message)?r:"",a=null!=(n=null==u?void 0:u.code)?n:"";o=`${null!=(s=null==e?void 0:e.name)?s:"FetchError"}: ${null==e?void 0:e.message} 2 3Caused by: ${null!=(i=null==u?void 0:u.name)?i:"Error"}: ${t}`,a&&(o+=` (${a})`),(null==u?void 0:u.stack)&&(o+=` 4${u.stack}`)}else o=null!=(a=null==e?void 0:e.stack)?a:"";let h=this.url.toString().length;return(null==e?void 0:e.name)==="AbortError"||(null==e?void 0:e.code)==="ABORT_ERR"?(c="",l="Request was aborted (timeout or manual cancellation)",h>this.urlLengthLimit&&(l+=`. Note: Your request URL is ${h} characters, which may exceed server limits. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [many IDs])), consider using an RPC function to pass values server-side.`)):((null==u?void 0:u.name)==="HeadersOverflowError"||(null==u?void 0:u.code)==="UND_ERR_HEADERS_OVERFLOW")&&(c="",l="HTTP headers exceeded server limits (typically 16KB)",h>this.urlLengthLimit&&(l+=`. Your request URL is ${h} characters. If selecting many fields, consider using views. If filtering with large arrays (e.g., .in('id', [200+ IDs])), consider using an RPC function instead.`)),{success:!1,error:{message:`${null!=(t=null==e?void 0:e.name)?t:"FetchError"}: ${null==e?void 0:e.message}`,details:o,hint:l,code:c},data:null,count:null,status:0,statusText:""}})),s.then(e,t)}async processResponse(e){var t,r,n;let s=null,i=null,a=null,o=e.status,l=e.statusText;if(e.ok){if("HEAD"!==this.method){let t=await e.text();""===t||(i="text/csv"===this.headers.get("Accept")||this.headers.get("Accept")&&(null==(n=this.headers.get("Accept"))?void 0:n.includes("application/vnd.pgrst.plan+text"))?t:JSON.parse(t))}let c=null==(t=this.headers.get("Prefer"))?void 0:t.match(/count=(exact|planned|estimated)/),u=null==(r=e.headers.get("content-range"))?void 0:r.split("/");c&&u&&u.length>1&&(a=parseInt(u[1])),this.isMaybeSingle&&Array.isArray(i)&&(i.length>1?(s={code:"PGRST116",details:`Results contain ${i.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},i=null,a=null,o=406,l="Not Acceptable"):i=1===i.length?i[0]:null)}else{let t=await e.text();try{s=JSON.parse(t),Array.isArray(s)&&404===e.status&&(i=[],s=null,o=200,l="OK")}catch(r){404===e.status&&""===t?(o=204,l="No Content"):s={message:t}}if(s&&this.shouldThrowOnError)throw new w(s)}return{success:null===s,error:s,data:i,count:a,status:o,statusText:l}}returns(){return this}overrideTypes(){return this}},E=class extends _{select(e){let t=!1,r=(null!=e?e:"*").split("").map(e=>/\s/.test(e)&&!t?"":('"'===e&&(t=!t),e)).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}order(e,{ascending:t=!0,nullsFirst:r,foreignTable:n,referencedTable:s=n}={}){let i=s?`${s}.order`:"order",a=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${a?`${a},`:""}${e}.${t?"asc":"desc"}${void 0===r?"":r?".nullsfirst":".nullslast"}`),this}limit(e,{foreignTable:t,referencedTable:r=t}={}){let n=void 0===r?"limit":`${r}.limit`;return this.url.searchParams.set(n,`${e}`),this}range(e,t,{foreignTable:r,referencedTable:n=r}={}){let s=void 0===n?"offset":`${n}.offset`,i=void 0===n?"limit":`${n}.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.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}
4explain({analyze:e=!1,verbose:t=!1,settings:r=!1,buffers:n=!1,wal:s=!1,format:i="text"}={}){var a;let o=[e?"analyze":null,t?"verbose":null,r?"settings":null,n?"buffers":null,s?"wal":null].filter(Boolean).join("|"),l=null!=(a=this.headers.get("Accept"))?a:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${l}"; options=${o};`),this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${e}`),this}};let S=RegExp("[,()]");var T=class extends E{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}likeAllOf(e,t){return this.url.searchParams.append(e,`like(all).{${t.join(",")}}`),this}likeAnyOf(e,t){return this.url.searchParams.append(e,`like(any).{${t.join(",")}}`),this}ilike(e,t){return this.url.searchParams.append(e,`ilike.${t}`),this}ilikeAllOf(e,t){return this.url.searchParams.append(e,`ilike(all).{${t.join(",")}}`),this}ilikeAnyOf(e,t){return this.url.searchParams.append(e,`ilike(any).{${t.join(",")}}`),this}regexMatch(e,t){return this.url.searchParams.append(e,`match.${t}`),this}regexIMatch(e,t){return this.url.searchParams.append(e,`imatch.${t}`),this}is(e,t){return this.url.searchParams.append(e,`is.${t}`),this}isDistinct(e,t){return this.url.searchParams.append(e,`isdistinct.${t}`),this}in(e,t){let r=Array.from(new Set(t)).map(e=>"string"==typeof e&&S.test(e)?`"${e}"`:`${e}`).join(",");return this.url.searchParams.append(e,`in.(${r})`),this}notIn(e,t){let r=Array.from(new Set(t)).map(e=>"string"==typeof e&&S.test(e)?`"${e}"`:`${e}`).join(",");return this.url.searchParams.append(e,`not.in.(${r})`),this}contains(e,t){return"string"==typeof t?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"string"==typeof t?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"string"==typeof t?this.url.searchParams.append(e,`ov.${t}`):this.url.searchParams.append(e,`ov.{${t.join(",")}}`),this}textSearch(e,t,{config:r,type:n}={}){let s="";"plain"===n?s="pl":"phrase"===n?s="ph":"websearch"===n&&(s="w");let i=void 0===r?"":`(${r})`;return this.url.searchParams.append(e,`${s}fts${i}.${t}`),this}match(e){return Object.entries(e).filter(([e,t])=>void 0!==t).forEach(([e,t])=>{this.url.searchParams.append(e,`eq.${t}`)}),this}not(e,t,r){return this.url.searchParams.append(e,`not.${t}.${r}`),this}or(e,{foreignTable:t,referencedTable:r=t}={}){let n=r?`${r}.or`:"or";return this.url.searchParams.append(n,`(${e})`),this}filter(e,t,r){return this.url.searchParams.append(e,`${t}.${r}`),this}},O=class{constructor(e,{headers:t={},schema:r,fetch:n,urlLengthLimit:s=8e3,retry:i}){this.url=e,this.headers=new Headers(t),this.schema=r,this.fetch=n,this.urlLengthLimit=s,this.retry=i}cloneRequestState(){return{url:new URL(this.url.toString()),headers:new Headers(this.headers)}}select(e,t){let{head:r=!1,count:n}=null!=t?t:{},s=!1,i=(null!=e?e:"*").split("").map(e=>/\s/.test(e)&&!s?"":('"'===e&&(s=!s),e)).join(""),{url:a,headers:o}=this.cloneRequestState();return a.searchParams.set("select",i),n&&o.append("Prefer",`count=${n}`),new T({method:r?"HEAD":"GET",url:a,headers:o,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}insert(e,{count:t,defaultToNull:r=!0}={}){var n;let{url:s,headers:i}=this.cloneRequestState();if(t&&i.append("Prefer",`count=${t}`),r||i.append("Prefer","missing=default"),Array.isArray(e)){let t=e.reduce((e,t)=>
4e.concat(Object.keys(t)),[]);if(t.length>0){let e=[...new Set(t)].map(e=>`"${e}"`);s.searchParams.set("columns",e.join(","))}}return new T({method:"POST",url:s,headers:i,schema:this.schema,body:e,fetch:null!=(n=this.fetch)?n:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}upsert(e,{onConflict:t,ignoreDuplicates:r=!1,count:n,defaultToNull:s=!0}={}){var i;let{url:a,headers:o}=this.cloneRequestState();if(o.append("Prefer",`resolution=${r?"ignore":"merge"}-duplicates`),void 0!==t&&a.searchParams.set("on_conflict",t),n&&o.append("Prefer",`count=${n}`),s||o.append("Prefer","missing=default"),Array.isArray(e)){let t=e.reduce((e,t)=>e.concat(Object.keys(t)),[]);if(t.length>0){let e=[...new Set(t)].map(e=>`"${e}"`);a.searchParams.set("columns",e.join(","))}}return new T({method:"POST",url:a,headers:o,schema:this.schema,body:e,fetch:null!=(i=this.fetch)?i:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}update(e,{count:t}={}){var r;let{url:n,headers:s}=this.cloneRequestState();return t&&s.append("Prefer",`count=${t}`),new T({method:"PATCH",url:n,headers:s,schema:this.schema,body:e,fetch:null!=(r=this.fetch)?r:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}delete({count:e}={}){var t;let{url:r,headers:n}=this.cloneRequestState();return e&&n.append("Prefer",`count=${e}`),new T({method:"DELETE",url:r,headers:n,schema:this.schema,fetch:null!=(t=this.fetch)?t:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};function A(e){return(A="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function $(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function C(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?$(Object(r),!0).forEach(function(t){!function(e,t,r){var n;(n=function(e,t){if("object"!=A(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=A(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"),(t="symbol"==A(n)?n:n+"")in e)?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):$(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var j=class e{constructor(e,{headers:t={},schema:r,fetch:n,timeout:s,urlLengthLimit:i=8e3,retry:a}={}){this.url=e,this.headers=new Headers(t),this.schemaName=r,this.urlLengthLimit=i;let o=null!=n?n:globalThis.fetch;void 0!==s&&s>0?this.fetch=(e,t)=>{let r=new AbortController,n=setTimeout(()=>r.abort(),s),i=null==t?void 0:t.signal;if(i){if(i.aborted)return clearTimeout(n),o(e,t);let s=()=>{clearTimeout(n),r.abort()};return i.addEventListener("abort",s,{once:!0}),o(e,C(C({},t),{},{signal:r.signal})).finally(()=>{clearTimeout(n),i.removeEventListener("abort",s)})}return o(e,C(C({},t),{},{signal:r.signal})).finally(()=>clearTimeout(n))}:this.fetch=o,this.retry=a}from(e){if(!e||"string"!=typeof e||""===e.trim())throw Error("Invalid relation name: relation must be a non-empty string.");return new O(new URL(`${this.url}/${e}`),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}schema(t){return new e(this.url,{headers:this.headers,schema:t,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}rpc(e,t={},{head:r=!1,get:n=!1,count:s}={}){var i;let a,o,l=new URL(`${this.url}/rpc/${e}`),c=e=>null!==e&&"object"==typeof e&&(!Array.isArray(e)||e.some(c)),u=r&&Object.values(t).some(c);u?(a="POST",o=t):r||n?(a=r?"HEAD":"GET",Object.entries(t).filter(([e,t])=>void 0!==t).map(([e,t])=>[e,Array.isArray(t)?`{${t.join(",")}}`:`${t}
4`]).forEach(([e,t])=>{l.searchParams.append(e,t)})):(a="POST",o=t);let h=new Headers(this.headers);return u?h.set("Prefer",s?`count=${s},return=minimal`:"return=minimal"):s&&h.set("Prefer",`count=${s}`),new T({method:a,url:l,headers:h,schema:this.schemaName,body:o,fetch:null!=(i=this.fetch)?i:fetch,urlLengthLimit:this.urlLengthLimit,retry:this.retry})}};class P{constructor(){}static detectEnvironment(){var e;if("undefined"!=typeof WebSocket)return{type:"native",wsConstructor:WebSocket};let t=globalThis;if("undefined"!=typeof globalThis&&void 0!==t.WebSocket)return{type:"native",wsConstructor:t.WebSocket};let n=void 0!==r.g?r.g:void 0;if(n&&void 0!==n.WebSocket)return{type:"native",wsConstructor:n.WebSocket};if("undefined"!=typeof globalThis&&void 0!==t.WebSocketPair&&void 0===globalThis.WebSocket)return{type:"cloudflare",error:"Cloudflare Workers detected. WebSocket clients are not supported in Cloudflare Workers.",workaround:"Use Cloudflare Workers WebSocket API for server-side WebSocket handling, or deploy to a different runtime."};if("undefined"!=typeof globalThis&&t.EdgeRuntime||"undefined"!=typeof navigator&&(null==(e=navigator.userAgent)?void 0:e.includes("Vercel-Edge")))return{type:"unsupported",error:"Edge runtime detected (Vercel Edge/Netlify Edge). WebSockets are not supported in edge functions.",workaround:"Use serverless functions or a different deployment target for WebSocket functionality."};let s=globalThis.process;if(s){let e=s.versions;if(e&&e.node){let t=parseInt(e.node.replace(/^v/,"").split(".")[0]);return t>=22?void 0!==globalThis.WebSocket?{type:"native",wsConstructor:globalThis.WebSocket}:{type:"unsupported",error:`Node.js ${t} detected but native WebSocket not found.`,workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:`Node.js ${t} detected without native WebSocket support.`,workaround:'For Node.js < 22, install "ws" package and provide it via the transport option:\nimport ws from "ws"\nnew RealtimeClient(url, { transport: ws })'}}}return{type:"unsupported",error:"Unknown JavaScript runtime without WebSocket support.",workaround:"Ensure you're running in a supported environment (browser, Node.js, Deno) or provide a custom WebSocket implementation."}}static getWebSocketConstructor(){let e=this.detectEnvironment();if(e.wsConstructor)return e.wsConstructor;let t=e.error||"WebSocket not supported in this environment.";throw e.workaround&&(t+=` 5 6Suggested solution: ${e.workaround}`),Error(t)}static isWebSocketSupported(){try{let e=this.detectEnvironment();return"native"===e.type||"ws"===e.type}catch(e){return!1}}}let R="2.0.0",x={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},z={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave",access_token:"access_token"},N={connecting:"connecting",closing:"closing",closed:"closed"};class I{constructor(e){this.HEADER_LENGTH=1,this.USER_BROADCAST_PUSH_META_LENGTH=6,this.KINDS={userBroadcastPush:3,userBroadcast:4},this.BINARY_ENCODING=0,this.JSON_ENCODING=1,this.BROADCAST_EVENT="broadcast",this.allowedMetadataKeys=[],this.allowedMetadataKeys=null!=e?e:[]}encode(e,t){return e.event!==this.BROADCAST_EVENT||e.payload instanceof ArrayBuffer||"string"!=typeof e.payload.event?t(JSON.stringify([e.join_ref,e.ref,e.topic,e.event,e.payload])):t(this._binaryEncodeUserBroadcastPush(e))}_binaryEncodeUserBroadcastPush(e){var t;return this._isArrayBuffer(null==(t=e.payload)?void 0:t.payload)?this._encodeBinaryUserBroadcastPush(e):this._encodeJsonUserBroadcastPush(e)}_encodeBinaryUserBroadcastPush(e){var t,r;let n=null!=(r=null==(t=e.payload)?void 0:t.payload)?r:new ArrayBuffer(0);return this._encodeUserBroadcastPush(e,this.BINARY_ENCODING,n)}_encodeJsonUserBroadcastPush(e){var t,r;let n=null!=(r=null==(t=e.payload)?void 0:t.payload)?r:{},s=new TextEncoder().encode(JSON.stringify(n)).buffer;return this._encodeUserBroadcastPush(e,this.JSON_ENCODING,s)}_encodeUserBroadcastPush(e,t,r){let n=e.topic,s=null!=(f=e.ref)?f:"",i=null!=(p=e.join_ref)?p:"",a=e.payload.event,o=this.allowedMetadataKeys?this._pick(e.payload,this.allowedMetadataKeys):{},l=0===Object.keys(o).length?"":JSON.stringify(o);if(i.length>255)throw Error(`joinRef length ${i.length} exceeds maximum of 255`);if(s.length>255)throw Error(`ref length ${s.length} exceeds maximum of 255`);if(n.length>255)throw Error(`topic length ${n.length} exceeds maximum of 255`);if(a.length>255)throw Error(`userEvent length ${a.length} exceeds maximum of 255`);if(l.length>255)throw Error(`metadata length ${l.length} exceeds maximum of 255`);let c=this.USER_BROADCAST_PUSH_META_LENGTH+i.length+s.length+n.length+a.length+l.length,u=new ArrayBuffer(this.HEADER_LENGTH+c),h=new DataView(u),d=0;h.setUint8(d++,this.KINDS.userBroadcastPush),h.setUint8(d++,i.length),h.setUint8(d++,s.length),h.setUint8(d++,n.length),h.setUint8(d++,a.length),h.setUint8(d++,l.length),h.setUint8(d++,t),Array.from(i,e=>h.setUint8(d++,e.charCodeAt(0))),Array.from(s,e=>h.setUint8(d++,e.charCodeAt(0))),Array.from(n,e=>h.setUint8(d++,e.charCodeAt(0))),Array.from(a,e=>h.setUint8(d++,e.charCodeAt(0))),Array.from(l,e=>h.setUint8(d++,e.charCodeAt(0)));var f,p,m=new Uint8Array(u.byteLength+r.byteLength);return m.set(new Uint8Array(u),0),m.set(new Uint8Array(r),u.byteLength),m.buffer}decode(e,t){if(this._isArrayBuffer(e))return t(this._binaryDecode(e));if("string"==typeof e){let[r,n,s,i,a]=JSON.parse(e);return t({join_ref:r,ref:n,topic:s,event:i,payload:a})}return t({})}_binaryDecode(e){let t=new DataView(e),r=t.getUint8(0),n=new TextDecoder;if(r===this.KINDS.userBroadcast)return this._decodeUserBroadcast(e,t,n)}_decodeUserBroadcast(e,t,r){let n=t.getUint8(1),s=t.getUint8(2),i=t.getUint8(3),a=t.getUint8(4),o=this.HEADER_LENGTH+4,l=r.decode(e.slice(o,o+n));o+=n;let c=r.decode(e.slice(o,o+s));o+=s;let u=r.decode(e.slice(o,o+i));o+=i;let h=e.slice(o,e.byteLength),d=a===this.JSON_ENCODING?JSON.parse(r.decode(h)):h,f={type:this.BROADCAST_EVENT,event:c,payload:d};return i>0&&(f.meta=JSON.parse(u)),{join_ref:null,ref:null,topic:l,event:this.BROADCAST_EVENT,payload:f}}_isArrayBuffer(e){var t;return e instanceof ArrayBuffer||(null==(t=null==e?void 0:e.constructor)?void 0:t.name)==="ArrayBuffer"}_pick(e,t){return e&&"object"==typeof e?Object.fromEntries(Object.entries(e).filter(([e])=>t.includes(e))):{}}}!function(e){e.abstime="abstime",e.bool="bool",e.date="date",e.daterange="daterange",e.float4="float4",e.float8="float8",e.int2="int2",e.int4="int4",e.int4range="int4range",e.int8="int8",e.int8range="int8range",e.json="json",e.jsonb="jsonb",e.money="money",e.numeric="numeric",e.oid="oid",e.reltime="reltime",e.text="text",e.time="time",e.timestamp="timestamp",e.timestamptz="timestamptz",e.timetz="timetz",e.tsrange="tsrange",e.tstzrange="tstzrange"}(a||(a={}));let U=(e,t,r={})=>{var n;let s=null!=(n=r.skipTypes)?n:[];return t?Object.keys(t).reduce((r,n)=>(r[n]=L(n,e,t,s),r),{}):{}},L=(e,t,r,n)=>{let s=t.find(t=>t.name===e),i=null==s?void 0:s.type,a=r[e];return i&&!n.includes(i)?B(i,a):D(a)},B=(e,t)=>{if("_"===e.charAt(0))return q(t,e.slice(1,e.length));switch(e){case a.bool:return H(t);case a.float4:case a.float8:case a.int2:case a.int4:case a.int8:case a.numeric:case a.oid:return J(t);case a.json:case a.jsonb:return M(t);case a.timestamp:return F(t);case a.abstime:case a.date:case a.daterange:case a.int4range:case a.int8range:case a.money:case a.reltime:case a.text:case a.time:case a.timestamptz:case a.timetz:case a.tsrange:case a.tstzrange:default:return D(t)}},D=e=>e,H=e=>{switch(e){case"t":return!0;case"f":return!1;default:return e}},J=e=>{if("string"==typeof e){let t=parseFloat(e);
6if(!Number.isNaN(t))return t}return e},M=e=>{if("string"==typeof e)try{return JSON.parse(e)}catch(e){}return e},q=(e,t)=>{if("string"!=typeof e)return e;let r=e.length-1,n=e[r];if("{"===e[0]&&"}"===n){let n,s=e.slice(1,r);try{n=JSON.parse("["+s+"]")}catch(e){n=s?s.split(","):[]}return n.map(e=>B(t,e))}return e},F=e=>"string"==typeof e?e.replace(" ","T"):e,Z=e=>{let t=new URL(e);return t.protocol=t.protocol.replace(/^ws/i,"http"),t.pathname=t.pathname.replace(/\/+$/,"").replace(/\/socket\/websocket$/i,"").replace(/\/socket$/i,"").replace(/\/websocket$/i,""),""===t.pathname||"/"===t.pathname?t.pathname="/api/broadcast":t.pathname=t.pathname+"/api/broadcast",t.href};var W=e=>"function"==typeof e?e:function(){return e},V="undefined"!=typeof window?window:null,K=("undefined"!=typeof self?self:null)||V||globalThis,G={connecting:0,open:1,closing:2,closed:3},Y={closed:"closed",errored:"errored",joined:"joined",joining:"joining",leaving:"leaving"},X={close:"phx_close",error:"phx_error",join:"phx_join",reply:"phx_reply",leave:"phx_leave"},Q={longpoll:"longpoll",websocket:"websocket"},ee={complete:4},et="base64url.bearer.phx.",er=class{constructor(e,t,r,n){this.channel=e,this.event=t,this.payload=r||function(){return{}},this.receivedResp=null,this.timeout=n,this.timeoutTimer=null,this.recHooks=[],this.sent=!1,this.ref=void 0}resend(e){this.timeout=e,this.reset(),this.send()}send(){this.hasReceived("timeout")||(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()}))}receive(e,t){return this.hasReceived(e)&&t(this.receivedResp.response),this.recHooks.push({status:e,callback:t}),this}reset(){this.cancelRefEvent(),this.ref=null,this.refEvent=null,this.receivedResp=null,this.sent=!1}destroy(){this.cancelRefEvent(),this.cancelTimeout()}matchReceive({status:e,response:t,_ref:r}){this.recHooks.filter(t=>t.status===e).forEach(e=>e.callback(t))}cancelRefEvent(){this.refEvent&&this.channel.off(this.refEvent)}cancelTimeout(){clearTimeout(this.timeoutTimer),this.timeoutTimer=null}startTimeout(){this.timeoutTimer&&this.cancelTimeout(),this.ref=this.channel.socket.makeRef(),this.refEvent=this.channel.replyEventName(this.ref),this.channel.on(this.refEvent,e=>{this.cancelRefEvent(),this.cancelTimeout(),this.receivedResp=e,this.matchReceive(e)}),this.timeoutTimer=setTimeout(()=>{this.trigger("timeout",{})},this.timeout)}hasReceived(e){return this.receivedResp&&this.receivedResp.status===e}trigger(e,t){this.channel.trigger(this.refEvent,{status:e,response:t})}},en=class{constructor(e,t){this.callback=e,this.timerCalc=t,this.timer=void 0,this.tries=0}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))}},es=class{constructor(e,t,r){this.state=Y.closed,this.topic=e,this.params=W(t||{}),this.socket=r,this.bindings=[],this.bindingRef=0,this.timeout=this.socket.timeout,this.joinedOnce=!1,this.joinPush=new er(this,X.join,this.params,this.timeout),this.pushBuffer=[],this.stateChangeRefs=[],this.rejoinTimer=new en(()=>{this.socket.isConnected()&&this.rejoin()},this.socket.rejoinAfterMs),this.stateChangeRefs.push(this.socket.onError(()=>this.rejoinTimer.reset())),this.stateChangeRefs.push(this.socket.onOpen(()=>{this.rejoinTimer.reset(),this.isErrored()&&this.rejoin()})),this.joinPush.receive("ok",()=>{this.state=Y.joined,this.rejoinTimer.reset(),this.pushBuffer.forEach(e=>e.send()),this.pushBuffer=[]}),this.joinPush.receive("error",e=>{this.state=Y.errored,this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,e),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.onClose(()=>{this.rejoinTimer.reset(),this.socket.hasLogger()&&this.socket.log("channel",`close ${this.topic}`),this.state=Y.closed,this.socket.remove(this)}),this.onError(e=>{this.socket.hasLogger()&&this.socket.log("channel",`error ${this.topic}`,e),this.isJoining()&&this.joinPush.reset(),this.state=Y.errored,this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.joinPush.receive("timeout",()=>{this.socket.hasLogger()&&this.socket.log("channel",`timeout ${this.topic}`,this.joinPush.timeout),new er(this,X.leave,W({}),this.timeout).send(),this.state=Y.errored,this.joinPush.reset(),this.socket.isConnected()&&this.rejoinTimer.scheduleTimeout()}),this.on(X.reply,(e,t)=>{this.trigger(this.replyEventName(t),e)})}join(e=this.timeout){if(!this.joinedOnce)return this.timeout=e,this.joinedOnce=!0,this.rejoin(),this.joinPush;throw Error("tried to join multiple times. 'join' can only be called a single time per channel instance")}
6teardown(){this.pushBuffer.forEach(e=>e.destroy()),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=Y.closed,this.bindings=[]}onClose(e){this.on(X.close,e)}onError(e){return this.on(X.error,t=>e(t))}on(e,t){let r=this.bindingRef++;return this.bindings.push({event:e,ref:r,callback:t}),r}off(e,t){this.bindings=this.bindings.filter(r=>r.event!==e||void 0!==t&&t!==r.ref)}canPush(){return this.socket.isConnected()&&this.isJoined()}push(e,t,r=this.timeout){if(t=t||{},!this.joinedOnce)throw Error(`tried to push '${e}' to '${this.topic}' before joining. Use channel.join() before pushing events`);let n=new er(this,e,function(){return t},r);return this.canPush()?n.send():(n.startTimeout(),this.pushBuffer.push(n)),n}leave(e=this.timeout){this.rejoinTimer.reset(),this.joinPush.cancelTimeout(),this.state=Y.leaving;let t=()=>{this.socket.hasLogger()&&this.socket.log("channel",`leave ${this.topic}`),this.trigger(X.close,"leave")},r=new er(this,X.leave,W({}),e);return r.receive("ok",()=>t()).receive("timeout",()=>t()),r.send(),this.canPush()||r.trigger("ok",{}),r}onMessage(e,t,r){return t}filterBindings(e,t,r){return!0}isMember(e,t,r,n){return this.topic===e&&(!n||n===this.joinRef()||(this.socket.hasLogger()&&this.socket.log("channel","dropping outdated message",{topic:e,event:t,payload:r,joinRef:n}),!1))}joinRef(){return this.joinPush.ref}rejoin(e=this.timeout){this.isLeaving()||(this.socket.leaveOpenTopic(this.topic),this.state=Y.joining,this.joinPush.resend(e))}trigger(e,t,r,n){let s=this.onMessage(e,t,r,n);if(t&&!s)throw Error("channel onMessage callbacks must return the payload, modified or unmodified");let i=this.bindings.filter(n=>n.event===e&&this.filterBindings(n,t,r));for(let e=0;e<i.length;e++)i[e].callback(s,r,n||this.joinRef())}replyEventName(e){return`chan_reply_${e}`}isClosed(){return this.state===Y.closed}isErrored(){return this.state===Y.errored}isJoined(){return this.state===Y.joined}isJoining(){return this.state===Y.joining}isLeaving(){return this.state===Y.leaving}},ei=class{static request(e,t,r,n,s,i,a){if(K.XDomainRequest){let r=new K.XDomainRequest;return this.xdomainRequest(r,e,t,n,s,i,a)}if(K.XMLHttpRequest){let o=new K.XMLHttpRequest;return this.xhrRequest(o,e,t,r,n,s,i,a)}if(K.fetch&&K.AbortController)return this.fetchRequest(e,t,r,n,s,i,a);throw Error("No suitable XMLHttpRequest implementation found")}static fetchRequest(e,t,r,n,s,i,a){let o={method:e,headers:r,body:n},l=null;return s&&(l=new AbortController,setTimeout(()=>l.abort(),s),o.signal=l.signal),K.fetch(t,o).then(e=>e.text()).then(e=>this.parseJSON(e)).then(e=>a&&a(e)).catch(e=>{"AbortError"===e.name&&i?i():a&&a(null)}),l}static xdomainRequest(e,t,r,n,s,i,a){return e.timeout=s,e.open(t,r),e.onload=()=>{let t=this.parseJSON(e.responseText);a&&a(t)},i&&(e.ontimeout=i),e.onprogress=()=>{},e.send(n),e}static xhrRequest(e,t,r,n,s,i,a,o){for(let[s,a]of(e.open(t,r,!0),e.timeout=i,Object.entries(n)))e.setRequestHeader(s,a);return e.onerror=()=>o&&o(null),e.onreadystatechange=()=>{e.readyState===ee.complete&&o&&o(this.parseJSON(e.responseText))},a&&(e.ontimeout=a),e.send(s),e}static parseJSON(e){if(!e||""===e)return null;try{return JSON.parse(e)}catch{return console&&console.log("failed to parse JSON response",e),null}}static serialize(e,t){let r=[];for(var n in e){if(!Object.prototype.hasOwnProperty.call(e,n))continue;let s=t?`${t}[${n}]`:n,i=e[n];"object"==typeof i?r.push(this.serialize(i,s)):r.push(encodeURIComponent(s)+"="+encodeURIComponent(i))}return r.join("&")}static appendParams(e,t){if(0===Object.keys(t).length)return e;let r=e.match(/\?/)?"&":"?";return`${e}${r}${this.serialize(t)}`}},ea=class{constructor(e,t){t&&2===t.length&&t[1].startsWith(et)&&(this.authToken=atob(t[1].slice(et.length))),this.endPoint=null,this.token=null,this.skipHeartbeat=!0,this.reqs=new Set,this.awaitingBatchAck=!1,this.currentBatch=null,this.currentBatchTimer=null,this.batchBuffer=[],this.onopen=function(){},this.onerror=function(){},this.onmessage=function(){},this.onclose=function(){},this.pollEndpoint=this.normalizeEndpoint(e),this.readyState=G.connecting,setTimeout(()=>this.poll(),0)}normalizeEndpoint(e){return e.replace("ws://","http://").replace("wss://","https://").replace(RegExp("(.*)/"+Q.websocket),"$1/"+Q.longpoll)}endpointURL(){return ei.appendParams(this.pollEndpoint,{token:this.token})}closeAndRetry(e,t,r){this.close(e,t,r),this.readyState=G.connecting}
6ontimeout(){this.onerror("timeout"),this.closeAndRetry(1005,"timeout",!1)}isActive(){return this.readyState===G.open||this.readyState===G.connecting}poll(){let e={Accept:"application/json"};this.authToken&&(e["X-Phoenix-AuthToken"]=this.authToken),this.ajax("GET",e,null,()=>this.ontimeout(),e=>{if(e){var{status:t,token:r,messages:n}=e;if(410===t&&null!==this.token){this.onerror(410),this.closeAndRetry(3410,"session_gone",!1);return}this.token=r}else t=0;switch(t){case 200:n.forEach(e=>{setTimeout(()=>this.onmessage({data:e}),0)}),this.poll();break;case 204:this.poll();break;case 410:this.readyState=G.open,this.onopen({}),this.poll();break;case 403:this.onerror(403),this.close(1008,"forbidden",!1);break;case 0:case 500:this.onerror(500),this.closeAndRetry(1011,"internal server error",500);break;default:throw Error(`unhandled poll status ${t}`)}})}send(e){"string"!=typeof e&&(e=(e=>{let t="",r=new Uint8Array(e),n=r.byteLength;for(let e=0;e<n;e++)t+=String.fromCharCode(r[e]);return btoa(t)})(e)),this.currentBatch?this.currentBatch.push(e):this.awaitingBatchAck?this.batchBuffer.push(e):(this.currentBatch=[e],this.currentBatchTimer=setTimeout(()=>{this.batchSend(this.currentBatch),this.currentBatch=null},0))}batchSend(e){this.awaitingBatchAck=!0,this.ajax("POST",{"Content-Type":"application/x-ndjson"},e.join("\n"),()=>
6this.onerror("timeout"),e=>{this.awaitingBatchAck=!1,e&&200===e.status?this.batchBuffer.length>0&&(this.batchSend(this.batchBuffer),this.batchBuffer=[]):(this.onerror(e&&e.status),this.closeAndRetry(1011,"internal server error",!1))})}close(e,t,r){for(let e of this.reqs)e.abort();this.readyState=G.closed;let n=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:e,reason:t,wasClean:r});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,"undefined"!=typeof CloseEvent?this.onclose(new CloseEvent("close",n)):this.onclose(n)}ajax(e,t,r,n,s){let i,a=()=>{this.reqs.delete(i),n()};i=ei.request(e,this.endpointURL(),t,r,this.timeout,a,e=>{this.reqs.delete(i),this.isActive()&&s(e)}),this.reqs.add(i)}},eo=class e{constructor(t,r={}){let n=r.events||{state:"presence_state",diff:"presence_diff"};this.state={},this.pendingDiffs=[],this.channel=t,this.joinRef=null,this.caller={onJoin:function(){},onLeave:function(){},onSync:function(){}},this.channel.on(n.state,t=>{let{onJoin:r,onLeave:n,onSync:s}=this.caller;this.joinRef=this.channel.joinRef(),this.state=e.syncState(this.state,t,r,n),this.pendingDiffs.forEach(t=>{this.state=e.syncDiff(this.state,t,r,n)}),this.pendingDiffs=[],s()}),this.channel.on(n.diff,t=>{let{onJoin:r,onLeave:n,onSync:s}=this.caller;this.inPendingSyncState()?this.pendingDiffs.push(t):(this.state=e.syncDiff(this.state,t,r,n),s())})}onJoin(e){this.caller.onJoin=e}onLeave(e){this.caller.onLeave=e}onSync(e){this.caller.onSync=e}list(t){return e.list(this.state,t)}inPendingSyncState(){return!this.joinRef||this.joinRef!==this.channel.joinRef()}static syncState(e,t,r,n){let s=this.clone(e),i={},a={};return this.map(s,(e,r)=>{t[e]||(a[e]=r)}),this.map(t,(e,t)=>{let r=s[e];if(r){let n=t.metas.map(e=>e.phx_ref),s=r.metas.map(e=>e.phx_ref),o=t.metas.filter(e=>0>s.indexOf(e.phx_ref)),l=r.metas.filter(e=>0>n.indexOf(e.phx_ref));o.length>0&&(i[e]=t,i[e].metas=o),l.length>0&&(a[e]=this.clone(r),a[e].metas=l)}else i[e]=t}),this.syncDiff(s,{joins:i,leaves:a},r,n)}static syncDiff(e,t,r,n){let{joins:s,leaves:i}=this.clone(t);return r||(r=function(){}),n||(n=function(){}),this.map(s,(t,n)=>{let s=e[t];if(e[t]=this.clone(n),s){let r=e[t].metas.map(e=>e.phx_ref),n=s.metas.filter(e=>0>r.indexOf(e.phx_ref));e[t].metas.unshift(...n)}r(t,s,n)}),this.map(i,(t,r)=>{let s=e[t];if(!s)return;let i=r.metas.map(e=>e.phx_ref);s.metas=s.metas.filter(e=>0>i.indexOf(e.phx_ref)),n(t,s,r),0===s.metas.length&&delete e[t]}),e}static list(e,t){return t||(t=function(e,t){return t}),this.map(e,(e,r)=>t(e,r))}static map(e,t){return Object.getOwnPropertyNames(e).map(r=>t(r,e[r]))}static clone(e){return JSON.parse(JSON.stringify(e))}},el={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(e,t){return e.payload.constructor===ArrayBuffer?t(this.binaryEncode(e)):t(JSON.stringify([e.join_ref,e.ref,e.topic,e.event,e.payload]))},decode(e,t){if(e.constructor===ArrayBuffer)return t(this.binaryDecode(e));{let[r,n,s,i,a]=JSON.parse(e);return t({join_ref:r,ref:n,topic:s,event:i,payload:a})}},binaryEncode(e){let{join_ref:t,ref:r,event:n,topic:s,payload:i}=e,a=this.META_LENGTH+t.length+r.length+s.length+n.length,o=new ArrayBuffer(this.HEADER_LENGTH+a),l=new DataView(o),c=0;l.setUint8(c++,this.KINDS.push),l.setUint8(c++,t.length),l.setUint8(c++,r.length),l.setUint8(c++,s.length),l.setUint8(c++,n.length),Array.from(t,e=>l.setUint8(c++,e.charCodeAt(0))),Array.from(r,e=>l.setUint8(c++,e.charCodeAt(0))),Array.from(s,e=>l.setUint8(c++,e.charCodeAt(0))),Array.from(n,e=>l.setUint8(c++,e.charCodeAt(0)));var u=new Uint8Array(o.byteLength+i.byteLength);return u.set(new Uint8Array(o),0),u.set(new Uint8Array(i),o.byteLength),u.buffer},binaryDecode(e){let t=new DataView(e),r=t.getUint8(0),n=new TextDecoder;switch(r){case this.KINDS.push:return this.decodePush(e,t,n);case this.KINDS.reply:return this.decodeReply(e,t,n);case this.KINDS.broadcast:return this.decodeBroadcast(e,t,n)}},decodePush(e,t,r){let n=t.getUint8(1),s=t.getUint8(2),i=t.getUint8(3),a=this.HEADER_LENGTH+this.META_LENGTH-1,o=r.decode(e.slice(a,a+n));a+=n;let l=r.decode(e.slice(a,a+s));a+=s;let c=r.decode(e.slice(a,a+i));return a+=i,{join_ref:o,ref:null,topic:l,event:c,payload:e.slice(a,e.byteLength)}},decodeReply(e,t,r){let n=t.getUint8(1),s=t.getUint8(2),i=t.getUint8(3),a=t.getUint8(4),o=this.HEADER_LENGTH+this.META_LENGTH,l=r.decode(e.slice(o,o+n));o+=n;let c=r.decode(e.slice(o,o+s));o+=s;let u=r.decode(e.slice(o,o+i));o+=i;let h=r.decode(e.slice(o,o+a));o+=a;let d=e.slice(o,e.byteLength);return{join_ref:l,ref:c,topic:u,event:X.reply,payload:{status:h,response:d}}},decodeBroadcast(e,t,r){let n=t.getUint8(1),s=t.getUint8(2),i=this.HEADER_LENGTH+2,a=r.decode(e.slice(i,i+n));i+=n;let o=r.decode(e.slice(i,i+s));return i+=s,{join_ref:null,ref:null,topic:a,event:o,payload:e.slice(i,e.byteLength)}}},ec=class{constructor(e,t={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.fallbackRef=null,this.timeout=t.timeout||1e4,this.transport=t.transport||K.WebSocket||ea,this.conn=void 0,this.primaryPassedHealthCheck=!1,this.longPollFallbackMs=t.longPollFallbackMs,this.fallbackTimer=null;let r=null;try{r=K&&K.sessionStorage}catch{}this.sessionStore=t.sessionStorage||r,this.establishedConnections=0,this.defaultEncoder=el.encode.bind(el),this.defaultDecoder=el.decode.bind(el),this.closeWasClean=!0,this.disconnecting=!1,this.binaryType=t.binaryType||"arraybuffer",this.connectClock=1,this.pageHidden=!1,this.encode=void 0,this.decode=void 0,this.transport!==ea?(this.encode=t.encode||this.defaultEncoder,this.decode=t.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let n=null;V&&V.addEventListener&&(V.addEventListener("pagehide",e=>{this.conn&&(this.disconnect(),n=this.connectClock)}),V.addEventListener("pageshow",e=>{n===this.connectClock&&(n=null,this.connect())}),V.addEventListener("visibilitychange",()=>{"hidden"===document.visibilityState?this.pageHidden=!0:(this.pageHidden=!1,this.isConnected()||this.closeWasClean||this.teardown(()=>this.connect()))})),this.heartbeatIntervalMs=t.heartbeatIntervalMs||3e4,this.autoSendHeartbeat=t.autoSendHeartbeat??!0,this.heartbeatCallback=t.heartbeatCallback??(()=>{}),this.rejoinAfterMs=e=>t.rejoinAfterMs?t.rejoinAfterMs(e):[1e3,2e3,5e3][e-1]||1e4,this.reconnectAfterMs=e=>t.reconnectAfterMs?t.reconnectAfterMs(e):[10,50,100,150,200,250,500,1e3,2e3][e-1]||5e3,this.logger=t.logger||null,!this.logger&&t.debug&&(this.logger=(e,t,r)=>{console.log(`${e}: ${t}`,r)}),this.longpollerTimeout=t.longpollerTimeout||2e4,this.params=W(t.params||{}),this.endPoint=`${e}/${Q.websocket}`,this.vsn=t.vsn||"2.0.0",this.heartbeatTimeoutTimer=null,this.heartbeatTimer=null,this.heartbeatSentAt=null,this.pendingHeartbeatRef=null,this.reconnectTimer=new en(()=>
6{if(this.pageHidden){this.log("Not reconnecting as page is hidden!"),this.teardown();return}this.teardown(async()=>{t.beforeReconnect&&await t.beforeReconnect(),this.connect()})},this.reconnectAfterMs),this.authToken=t.authToken}getLongPollTransport(){return ea}replaceTransport(e){this.connectClock++,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.conn&&(this.conn.close(),this.conn=null),this.transport=e}protocol(){return location.protocol.match(/^https/)?"wss":"ws"}endPointURL(){let e=ei.appendParams(ei.appendParams(this.endPoint,this.params()),{vsn:this.vsn});return"/"!==e.charAt(0)?e:"/"===e.charAt(1)?`${this.protocol()}:${e}`:`${this.protocol()}://${location.host}${e}`}disconnect(e,t,r){this.connectClock++,this.disconnecting=!0,this.closeWasClean=!0,clearTimeout(this.fallbackTimer),this.reconnectTimer.reset(),this.teardown(()=>{this.disconnecting=!1,e&&e()},t,r)}connect(e){e&&(console&&console.log("passing params to connect is deprecated. Instead pass :params to the Socket constructor"),this.params=W(e)),(!this.conn||this.disconnecting)&&(this.longPollFallbackMs&&this.transport!==ea?this.connectWithF
6allback(ea,this.longPollFallbackMs):this.transportConnect())}log(e,t,r){this.logger&&this.logger(e,t,r)}hasLogger(){return null!==this.logger}onOpen(e){let t=this.makeRef();return this.stateChangeCallbacks.open.push([t,e]),t}onClose(e){let t=this.makeRef();return this.stateChangeCallbacks.close.push([t,e]),t}onError(e){let t=this.makeRef();return this.stateChangeCallbacks.error.push([t,e]),t}onMessage(e){let t=this.makeRef();return this.stateChangeCallbacks.message.push([t,e]),t}onHeartbeat(e){this.heartbeatCallback=e}ping(e){if(!this.isConnected())return!1;let t=this.makeRef(),r=Date.now();this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:t});let n=this.onMessage(s=>{s.ref===t&&(this.off([n]),e(Date.now()-r))});return!0}transportName(e){return e===ea?"LongPoll":e.name}transportConnect(){let e;this.connectClock++,this.closeWasClean=!1,this.authToken&&(e=["phoenix",`${et}${btoa(this.authToken).replace(/=/g,"")}`]),this.conn=new this.transport(this.endPointURL(),e),this.conn.binaryType=this.binaryType,this.conn.timeout=this.longpollerTimeout,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)}getSession(e){return this.sessionStore&&this.sessionStore.getItem(e)}storeSession(e,t){this.sessionStore&&this.sessionStore.setItem(e,t)}connectWithFallback(e,t=2500){let r,n;clearTimeout(this.fallbackTimer);let s=!1,i=!0,a=this.transportName(e),o=t=>{this.log("transport",`falling back to ${a}...`,t),this.off([r,n]),i=!1,this.replaceTransport(e),this.transportConnect()};if(this.getSession(`phx:fallback:${a}`))return o("memorized");this.fallbackTimer=setTimeout(o,t),n=this.onError(e=>{this.log("transport","error",e),i&&!s&&(clearTimeout(this.fallbackTimer),o(e))}),this.fallbackRef&&this.off([this.fallbackRef]),this.fallbackRef=this.onOpen(()=>{if(s=!0,!i){let t=this.transportName(e);return this.primaryPassedHealthCheck||this.storeSession(`phx:fallback:${t}`,"true"),this.log("transport",`established ${t} fallback`)}clearTimeout(this.fallbackTimer),this.fallbackTimer=setTimeout(o,t),this.ping(e=>{this.log("transport","connected to primary after",e),this.primaryPassedHealthCheck=!0,clearTimeout(this.fallbackTimer)})}),this.transportConnect()}clearHeartbeats(){clearTimeout(this.heartbeatTimer),clearTimeout(this.heartbeatTimeoutTimer)}onConnOpen(){this.hasLogger()&&this.log("transport",`connected to ${this.endPointURL()}`),this.closeWasClean=!1,this.disconnecting=!1,this.establishedConnections++,this.flushSendBuffer(),this.reconnectTimer.reset(),this.autoSendHeartbeat&&this.resetHeartbeat(),this.triggerStateCallbacks("open")}heartbeatTimeout(){if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.hasLogger()&&this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(e){this.log("error","error in heartbeat callback",e)}this.triggerChanError(Error("heartbeat timeout")),this.closeWasClean=!1,this.teardown(()=>this.reconnectTimer.scheduleTimeout(),1e3,"heartbeat timeout")}}resetHeartbeat(){this.conn&&this.conn.skipHeartbeat||(this.pendingHeartbeatRef=null,this.clearHeartbeats(),this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}teardown(e,t,r){if(!this.conn)return e&&e();let n=this.conn;this.waitForBufferDone(n,()=>{t?n.close(t,r||""):n.close(),this.waitForSocketClosed(n,()=>{this.conn===n&&(this.conn.onopen=function(){},this.conn.onerror=function(){},this.conn.onmessage=function(){},this.conn.onclose=function(){},this.conn=null),e&&e()})})}waitForBufferDone(e,t,r=1){if(5===r||!e.bufferedAmount)return void t();setTimeout(()=>{this.waitForBufferDone(e,t,r+1)},150*r)}waitForSocketClosed(e,t,r=1){if(5===r||e.readyState===G.closed)return void t();setTimeout(()=>{this.waitForSocketClosed(e,t,r+1)},150*r)}onConnClose(e){this.conn&&(this.conn.onclose=()=>{}),this.hasLogger()&&this.log("transport","close",e),this.triggerChanError(e),this.clearHeartbeats(),this.closeWasClean||this.reconnectTimer.scheduleTimeout(),this.triggerStateCallbacks("close",e)}onConnError(e){this.hasLogger()&&this.log("transport","error",e);let t=this.transport,r=this.establishedConnections;this.triggerStateCallbacks("error",e,t,r),(t===this.transport||r>0)&&this.triggerChanError(e)}
6triggerChanError(e){this.channels.forEach(t=>{t.isErrored()||t.isLeaving()||t.isClosed()||t.trigger(X.error,e)})}connectionState(){switch(this.conn&&this.conn.readyState){case G.connecting:return"connecting";case G.open:return"open";case G.closing:return"closing";default:return"closed"}}isConnected(){return"open"===this.connectionState()}remove(e){this.off(e.stateChangeRefs),this.channels=this.channels.filter(t=>t!==e)}off(e){for(let t in this.stateChangeCallbacks)this.stateChangeCallbacks[t]=this.stateChangeCallbacks[t].filter(([t])=>-1===e.indexOf(t))}channel(e,t={}){let r=new es(e,t,this);return this.channels.push(r),r}push(e){if(this.hasLogger()){let{topic:t,event:r,payload:n,ref:s,join_ref:i}=e;this.log("push",`${t} ${r} (${i}, ${s})`,n)}this.isConnected()?this.encode(e,e=>this.conn.send(e)):this.sendBuffer.push(()=>this.encode(e,e=>this.conn.send(e)))}makeRef(){let e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}sendHeartbeat(){if(!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(e){this.log("error","error in heartbeat callback",e)}return}if(this.pendingHeartbeatRef)return void this.heartbeatTimeout();this.pendingHeartbeatRef=this.makeRef(),this.heartbeatSentAt=Date.now(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(e){this.log("error","error in heartbeat callback",e)}this.heartbeatTimeoutTimer=setTimeout(()=>this.heartbeatTimeout(),this.heartbeatIntervalMs)}flushSendBuffer(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(e=>e()),this.sendBuffer=[])}onConnMessage(e){this.decode(e.data,e=>{let{topic:t,event:r,payload:n,ref:s,join_ref:i}=e;if(s&&s===this.pendingHeartbeatRef){let e=this.heartbeatSentAt?Date.now()-this.heartbeatSentAt:void 0;this.clearHeartbeats();try{this.heartbeatCallback("ok"===n.status?"ok":"error",e)}catch(e){this.log("error","error in heartbeat callback",e)}this.pendingHeartbeatRef=null,this.heartbeatSentAt=null,this.autoSendHeartbeat&&(this.heartbeatTimer=setTimeout(()=>this.sendHeartbeat(),this.heartbeatIntervalMs))}this.hasLogger()&&this.log("receive",`${n.status||""} ${t} ${r} ${s&&"("+s+")"||""}`.trim(),n);for(let e=0;e<this.channels.length;e++){let a=this.channels[e];a.isMember(t,r,n,i)&&a.trigger(r,n,s,i)}this.triggerStateCallbacks("message",e)})}triggerStateCallbacks(e,...t){try{this.stateChangeCallbacks[e].forEach(([r,n])=>{try{n(...t)}catch(t){this.log("error",`error in ${e} callback`,t)}})}catch(t){this.log("error",`error triggering ${e} callbacks`,t)}}leaveOpenTopic(e){let t=this.channels.find(t=>t.topic===e&&(t.isJoined()||t.isJoining()));t&&(this.hasLogger()&&this.log("transport",`leaving duplicate topic "${e}"`),t.leave())}};class eu{constructor(e,t){let r=function(e){return(null==e?void 0:e.events)&&{events:e.events}}(t);this.presence=new eo(e.getChannel(),r),this.presence.onJoin((t,r,n)=>{let s=eu.onJoinPayload(t,r,n);e.getChannel().trigger("presence",s)}),this.presence.onLeave((t,r,n)=>{let s=eu.onLeavePayload(t,r,n);e.getChannel().trigger("presence",s)}),this.presence.onSync(()=>{e.getChannel().trigger("presence",{event:"sync"})})}get state(){return eu.transformState(this.presence.state)}static transformState(e){return Object.getOwnPropertyNames(e=JSON.parse(JSON.stringify(e))).reduce((t,r)=>{let n=e[r];return t[r]=eh(n),t},{})}static onJoinPayload(e,t,r){return{event:"join",key:e,currentPresences:ed(t),newPresences:eh(r)}}static onLeavePayload(e,t,r){return{event:"leave",key:e,currentPresences:ed(t),leftPresences:eh(r)}}}function eh(e){return e.metas.map(e=>(e.presence_ref=e.phx_ref,delete e.phx_ref,delete e.phx_ref_prev,e))}function ed(e){return(null==e?void 0:e.metas)?eh(e):[]}!function(e){e.SYNC="sync",e.JOIN="join",e.LEAVE="leave"}(o||(o={}));class ef{get state(){return this.presenceAdapter.state}constructor(e,t){this.channel=e,this.presenceAdapter=new eu(this.channel.channelAdapter,t)}}class ep{constructor(e,t,r){let n={config:Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},r.config)};this.channel=e.getSocket().channel(t,n),this.socket=e}get state(){return this.channel.state}set state(e){this.channel.state=e}get joinedOnce(){return this.channel.joinedOnce}get joinPush(){return this.channel.joinPush}get rejoinTimer(){return this.channel.rejoinTimer}on(e,t){return this.channel.on(e,t)}off(e,t){this.channel.off(e,t)}subscribe(e){return this.channel.join(e)}unsubscribe(e){return this.channel.leave(e)}teardown(){this.channel.teardown()}onClose(e){this.channel.onClose(e)}onError(e){return this.channel.onError(e)}push(e,t,r){let n;try{n=this.channel.push(e,t,r)}catch(t){throw Error(`tried to push '${e}' to '${this.channel.topic}' before joining. Use channel.subscribe() before pushing events`)}if(this.channel.pushBuffer.length>100){let e=this.channel.pushBuffer.shift();e.cancelTimeout(),this.socket.log("channel",`discarded push due to buffer overflow: ${e.event}`,e.payload())}return n}updateJoinPayload(e){let t=this.channel.joinPush.payload();this.channel.joinPush.payload=()=>Object.assign(Object.assign({},t),e)}canPush(){return this.socket.isConnected()&&this.state===x.joined}isJoined(){return this.state===x.joined}isJoining(){return this.state===x.joining}isClosed(){return this.state===x.closed}isLeaving(){return this.state===x.leaving}updateFilterBindings(e){this.channel.filterBindings=e}updatePayloadTransform(e){this.channel.onMessage=e}getChannel(){return this.channel}}!function(e){e.ALL="*",e.INSERT="INSERT",e.UPDATE="UPDATE",e.DELETE="DELETE"}(l||(l={})),function(e){e.BROADCAST="broadcast",e.PRESENCE="presence",e.POSTGRES_CHANGES="postgres_changes",e.SYSTEM="system"}(c||(c={})),function(e){e.SUBSCRIBED="SUBSCRIBED",e.TIMED_OUT="TIMED_OUT",e.CLOSED="CLOSED",e.CHANNEL_ERROR="CHANNEL_ERROR"}(u||(u={}));class em{get state(){return this.channelAdapter.state}set state(e){this.channelAdapter.state=e}get joinedOnce(){return this.channelAdapter.joinedOnce}get timeout(){return this.socket.timeout}get joinPush(){return this.channelAdapter.joinPush}get rejoinTimer(){return this.channelAdapter.rejoinTimer}constructor(e,t={config:{}},r){var n,s;if(this.topic=e,this.params=t,this.socket=r,this.bindings={},this.subTopic=e.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},t.config),this.channelAdapter=new ep(this.socket.socketAdapter,e,this.params),this.presence=new ef(this),this._onClose(()=>{this.socket._remove(this)}),this._updateFilterTransform(),this.broadcastEndpointURL=Z(this.socket.socketAdapter.endPointURL()),this.private=this.params.config.private||!1,!this.private&&(null==(s=null==(n=this.params.config)?void 0:n.broadcast)?void 0:s.replay))throw Error(`tried to use replay on public channel '${this.topic}'. It must be a private channel.`)}subscribe(e,t=this.timeout){var r,n,s;if(this.socket.isConnected()||this.socket.connect(),this.channelAdapter.isClosed()){let{config:{broadcast:i,presence:a,private:o}}=this.params,l=null!=(n=null==(r=this.bindings.postgres_changes)?void 0:r.map(e=>e.filter))?n:[],h=!!this.bindings[c.PRESENCE]&&this.bindings[c.PRESENCE].length>0||(null==(s=this.params.config.presence)?void 0:s.enabled)===!0,d={},f={broadcast:i,presence:Object.assign(Object.assign({},a),{enabled:h}),postgres_changes:l,private:o};this.socket.accessTokenValue&&(d.access_token=this.socket.accessTokenValue),this._onError(t=>{null==e||e(u.CHANNEL_ERROR,function(e){if(e instanceof Error)return e;if("string"==typeof e)return Error(e);
6if(e&&"object"==typeof e){if("number"==typeof e.code){let t="string"==typeof e.reason&&e.reason?` (${e.reason})`:"";return Error(`socket closed: ${e.code}${t}`,{cause:e})}return Error("channel error: transport failure",{cause:e})}return Error("channel error: connection lost")}(t))}),this._onClose(()=>null==e?void 0:e(u.CLOSED)),this.updateJoinPayload(Object.assign({config:f},d)),this._updateFilterMessage(),this.channelAdapter.subscribe(t).receive("ok",async({postgres_changes:t})=>{if(this.socket._isManualToken()||this.socket.setAuth(),void 0===t){null==e||e(u.SUBSCRIBED);return}this._updatePostgresBindings(t,e)}).receive("error",t=>{this.state=x.errored;let r=Object.values(t).join(", ")||"error";null==e||e(u.CHANNEL_ERROR,Error(r,{cause:t}))}).receive("timeout",()=>{null==e||e(u.TIMED_OUT)})}return this}_updatePostgresBindings(e,t){var r;let n=this.bindings.postgres_changes,s=null!=(r=null==n?void 0:n.length)?r:0,i=[];for(let r=0;r<s;r++){let s=n[r],{filter:{event:a,schema:o,table:l,filter:c}}=s,h=e&&e[r];if(h&&h.event===a&&em.isFilterValueEqual(h.schema,o)&&em.isFilterValueEqual(h.table,l)&&em.isFilterValueEqual(h.filter,c))i.push(Object.assign(Object.assign({},s),{id:h.id}));else{this.unsubscribe(),this.state=x.errored,null==t||t(u.CHANNEL_ERROR,Error("mismatch between server and client bindings for postgres changes"));return}}this.bindings.postgres_changes=i,this.state!=x.errored&&t&&t(u.SUBSCRIBED)}presenceState(){return this.presence.state}async track(e,t={}){return await this.send({type:"presence",event:"track",payload:e},t.timeout||this.timeout)}async untrack(e={}){return await this.send({type:"presence",event:"untrack"},e)}on(e,t,r){let n=this.channelAdapter.isJoined()||this.channelAdapter.isJoining(),s=e===c.PRESENCE||e===c.POSTGRES_CHANGES;if(n&&s)throw this.socket.log("channel",`cannot add \`${e}\` callbacks for ${this.topic} after \`subscribe()\`.`),Error(`cannot add \`${e}\` callbacks for ${this.topic} after \`subscribe()\`.`);return this._on(e,t,r)}async httpSend(e,t,r={}){var n;if(null==t)return Promise.reject(Error("Payload is required for httpSend()"));let s={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(s.Authorization=`Bearer ${this.socket.accessTokenValue}`);let i={method:"POST",headers:s,body:JSON.stringify({messages:[{topic:this.subTopic,event:e,payload:t,private:this.private}]})},a=await this._fetchWithTimeout(this.broadcastEndpointURL,i,null!=(n=r.timeout)?n:this.timeout);if(202===a.status)return{success:!0};let o=a.statusText;try{let e=await a.json();o=e.error||e.message||o}catch(e){}return Promise.reject(Error(o))}async send(e,t={}){var r,n;if(this.channelAdapter.canPush()||"broadcast"!==e.type)return new Promise(r=>{var n,s,i;let a=this.channelAdapter.push(e.type,e,t.timeout||this.timeout);"broadcast"!==e.type||(null==(i=null==(s=null==(n=this.params)?void 0:n.config)?void 0:s.broadcast)?void 0:i.ack)||r("ok"),a.receive("ok",()=>r("ok")),a.receive("error",()=>r("error")),a.receive("timeout",()=>r("timed out"))});{console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated
6in the future. Please use httpSend() explicitly for REST delivery.");let{event:s,payload:i}=e,a={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"};this.socket.accessTokenValue&&(a.Authorization=`Bearer ${this.socket.accessTokenValue}`);let o={method:"POST",headers:a,body:JSON.stringify({messages:[{topic:this.subTopic,event:s,payload:i,private:this.private}]})};try{let e=await this._fetchWithTimeout(this.broadcastEndpointURL,o,null!=(r=t.timeout)?r:this.timeout);return await (null==(n=e.body)?void 0:n.cancel()),e.ok?"ok":"error"}catch(e){if(e instanceof Error&&"AbortError"===e.name)return"timed out";return"error"}}}updateJoinPayload(e){this.channelAdapter.updateJoinPayload(e)}async unsubscribe(e=this.timeout){return new Promise(t=>{this.channelAdapter.unsubscribe(e).receive("ok",()=>t("ok")).receive("timeout",()=>t("timed out")).receive("error",()=>t("error"))})}teardown(){this.channelAdapter.teardown()}async _fetchWithTimeout(e,t,r){let n=new AbortController,s=setTimeout(()=>n.abort(),r),i=await this.socket.fetch(e,Object.assign(Object.assign({},t),{signal:n.signal}));return clearTimeout(s),i}_on(e,t,r){let n=e.toLocaleLowerCase(),s=this.channelAdapter.on(e,r),i={type:n,filter:t,callback:r,ref:s};return this.bindings[n]?this.bindings[n].push(i):this.bindings[n]=[i],this._updateFilterMessage(),this}_onClose(e){this.channelAdapter.onClose(e)}_onError(e){this.channelAdapter.onError(e)}_updateFilterMessage(){this.channelAdapter.updateFilterBindings((e,t,r)=>{var n,s,i,a,o,l,c;let u=e.event.toLocaleLowerCase();if(this._notThisChannelEvent(u,r))return!1;let h=null==(n=this.bindings[u])?void 0:n.find(t=>t.ref===e.ref);if(!h)return!0;if(!["broadcast","presence","postgres_changes"].includes(u))return h.type.toLocaleLowerCase()===u;if("id"in h){let e=h.id,r=null==(s=h.filter)?void 0:s.event;return e&&(null==(i=t.ids)?void 0:i.includes(e))&&("*"===r||(null==r?void 0:r.toLocaleLowerCase())===(null==(a=t.data)?void 0:a.type.toLocaleLowerCase()))}{let e=null==(l=null==(o=null==h?void 0:h.filter)?void 0:o.event)?void 0:l.toLocaleLowerCase();return"*"===e||e===(null==(c=null==t?void 0:t.event)?void 0:c.toLocaleLowerCase())}})}_notThisChannelEvent(e,t){let{close:r,error:n,leave:s,join:i}=z;return t&&[r,n,s,i].includes(e)&&t!==this.joinPush.ref}_updateFilterTransform(){this.channelAdapter.updatePayloadTransform((e,t,r)=>{if("object"==typeof t&&"ids"in t){let e=t.data,{schema:r,table:n,commit_timestamp:s,type:i,errors:a}=e;return Object.assign(Object.assign({},{schema:r,table:n,commit_timestamp:s,eventType:i,new:{},old:{},errors:a}),this._getPayloadRecords(e))}return t})}copyBindings(e){if(this.joinedOnce)throw Error("cannot copy bindings into joined channel");for(let t in e.bindings)for(let r of e.bindings[t])this._on(r.type,r.filter,r.callback)}static isFilterValueEqual(e,t){return(null!=e?e:void 0)===(null!=t?t:void 0)}_getPayloadRecords(e){let t={new:{},old:{}};return("INSERT"===e.type||"UPDATE"===e.type)&&(t.new=U(e.columns,e.record)),("UPDATE"===e.type||"DELETE"===e.type)&&(t.old=U(e.columns,e.old_record)),t}}class eg{constructor(e,t){this.socket=new ec(e,t)}get timeout(){return this.socket.timeout}get endPoint(){return this.socket.endPoint}get transport(){return this.socket.transport}get heartbeatIntervalMs(){return this.socket.heartbeatIntervalMs}get heartbeatCallback(){return this.socket.heartbeatCallback}set heartbeatCallback(e){this.socket.heartbeatCallback=e}get heartbeatTimer(){return this.socket.heartbeatTimer}get pendingHeartbeatRef(){return this.socket.pendingHeartbeatRef}get reconnectTimer(){return this.socket.reconnectTimer}get vsn(){return this.socket.vsn}get encode(){return this.socket.encode}get decode(){return this.socket.decode}get reconnectAfterMs(){return this.socket.reconnectAfterMs}get sendBuffer(){return this.socket.sendBuffer}get stateChangeCallbacks(){return this.socket.stateChangeCallbacks}connect(){this.socket.connect()}disconnect(e,t,r,n=1e4){return new Promise(s=>{setTimeout(()=>s("timeout"),n),this.socket.disconnect(()=>{e(),s("ok")},t,r)})}push(e){this.socket.push(e)}log(e,t,r){this.socket.log(e,t,r)}makeRef(){return this.socket.makeRef()}onOpen(e){this.socket.onOpen(e)}onClose(e){this.socket.onClose(e)}onError(e){this.socket.onError(e)}onMessage(e){this.socket.onMessage(e)}isConnected(){return this.socket.isConnected()}isConnecting(){return this.socket.connectionState()==N.connecting}isDisconnecting(){return this.socket.connectionState()==N.closing}connectionState(){return this.socket.connectionState()}endPointURL(){return this.socket.endPointURL()}sendHeartbeat(){this.socket.sendHeartbeat()}getSocket(){return this.socket}}let ey={HEARTBEAT_INTERVAL:25e3},eb=[1e3,2e3,5e3,1e4],ev=` 7 addEventListener("message", (e) => { 8 if (e.data.event === "start") { 9 setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval); 10 } 11 });`;class ew{get endPoint(){return this.socketAdapter.endPoint}get timeout(){return this.socketAdapter.timeout}get transport(){return this.socketAdapter.transport}get heartbeatCallback(){return this.socketAdapter.heartbeatCallback}get heartbeatIntervalMs(){return this.socketAdapter.heartbeatIntervalMs}get heartbeatTimer(){return this.worker?this._workerHeartbeatTimer:this.socketAdapter.heartbeatTimer}get pendingHeartbeatRef(){return this.worker?this._pendingWorkerHeartbeatRef:this.socketAdapter.pendingHeartbeatRef}get reconnectTimer(){return this.socketAdapter.reconnectTimer}get vsn(){return this.socketAdapter.vsn}get encode(){return this.socketAdapter.encode}get decode(){return this.socketAdapter.decode}get reconnectAfterMs(){return this.socketAdapter.reconnectAfterMs}get sendBuffer(){return this.socketAdapter.sendBuffer}get stateChangeCallbacks(){return this.socketAdapter.stateChangeCallbacks}constructor(e,t){var r;if(this.channels=[],this.accessTokenValue=null,this.accessToken=null,this.apiKey=null,this.httpEndpoint="",this.headers={},this.params={}
11,this.ref=0,this.serializer=new I,this._manuallySetToken=!1,this._authPromise=null,this._workerHeartbeatTimer=void 0,this._pendingWorkerHeartbeatRef=null,this._pendingDisconnectTimer=null,this._disconnectOnEmptyChannelsAfterMs=0,this._resolveFetch=e=>e?(...t)=>e(...t):(...e)=>fetch(...e),!(null==(r=null==t?void 0:t.params)?void 0:r.apikey))throw Error("API key is required to connect to Realtime");this.apiKey=t.params.apikey;let n=this._initializeOptions(t);this.socketAdapter=new eg(e,n),this.httpEndpoint=Z(e),this.fetch=this._resolveFetch(null==t?void 0:t.fetch)}connect(){if(!(this.isConnecting()||this.isDisconnecting()||this.isConnected())){this.accessToken&&!this._authPromise&&this._setAuthSafely("connect"),this._setupConnectionHandlers();try{this.socketAdapter.connect()}catch(t){let e=t.message;if(e.includes("Node.js"))throw Error(`${e} 12 13To use Realtime in Node.js, you need to provide a WebSocket implementation: 14 15Option 1: Use Node.js 22+ which has native WebSocket support 16Option 2: Install and provide the "ws" package: 17 18 npm install ws 19 20 import ws from "ws" 21 const client = new RealtimeClient(url, { 22 ...options, 23 transport: ws 24 })`);throw Error(`WebSocket not available: ${e}`)}this._handleNodeJsRaceCondition()}}endpointURL(){return this.socketAdapter.endPointURL()}async disconnect(e,t){return(this._cancelPendingDisconnect(),this.isDisconnecting())?"ok":await this.socketAdapter.disconnect(()=>{clearInterval(this._workerHeartbeatTimer),this._terminateWorker()},e,t)}getChannels(){return this.channels}async removeChannel(e){let t=await e.unsubscribe();return"ok"===t&&e.teardown(),t}async removeAllChannels(){let e=this.channels.map(async e=>{let t=await e.unsubscribe();return e.teardown(),t}),t=await Promise.all(e);return await this.disconnect(),t}log(e,t,r){this.socketAdapter.log(e,t,r)}connectionState(){return this.socketAdapter.connectionState()||N.closed}isConnected(){return this.socketAdapter.isConnected()}isConnecting(){return this.socketAdapter.isConnecting()}isDisconnecting(){return this.socketAdapter.isDisconnecting()}channel(e,t={config:{}}){let r=`realtime:${e}`,n=this.getChannels().find(e=>e.topic===r);if(n)return n;{let r=new em(`realtime:${e}`,t,this);return this._cancelPendingDisconnect(),this.channels.push(r),r}}push(e){this.socketAdapter.push(e)}async setAuth(e=null){this._authPromise=this._performAuth(e);try{await this._authPromise}finally{this._authPromise=null}}_isManualToken(){return this._manuallySetToken}async sendHeartbeat(){this.socketAdapter.sendHeartbeat()}onHeartbeat(e){this.socketAdapter.heartbeatCallback=this._wrapHeartbeatCallback(e)}_makeRef(){return this.socketAdapter.makeRef()}_remove(e){this.channels=this.channels.filter(t=>t.topic!==e.topic),0===this.channels.length&&(this.log("transport","no channels remaining, scheduling disconnect"),this._schedulePendingDisconnect())}_schedulePendingDisconnect(){if(this._cancelPendingDisconnect(),0===this._disconnectOnEmptyChannelsAfterMs){this.log("transport","disconnecting immediately - no channels"),this.disconnect();return}
24this._pendingDisconnectTimer=setTimeout(()=>{this._pendingDisconnectTimer=null,0===this.channels.length&&(this.log("transport","deferred disconnect fired - no channels, disconnecting"),this.disconnect())},this._disconnectOnEmptyChannelsAfterMs),this.log("transport",`deferred disconnect scheduled in ${this._disconnectOnEmptyChannelsAfterMs}ms`)}_cancelPendingDisconnect(){null!==this._pendingDisconnectTimer&&(this.log("transport","pending disconnect cancelled - channel activity detected"),clearTimeout(this._pendingDisconnectTimer),this._pendingDisconnectTimer=null)}async _performAuth(e=null){let t,r=!1;if(e)t=e,r=!0;else if(this.accessToken)try{t=await this.accessToken()}catch(e){this.log("error","Error fetching access token from callback",e),t=this.accessTokenValue}else t=this.accessTokenValue;r?this._manuallySetToken=!0:this.accessToken&&(this._manuallySetToken=!1),this.accessTokenValue!=t&&(this.accessTokenValue=t,this.channels.forEach(e=>{let r={access_token:t,version:"realtime-js/2.105.4"};t&&e.updateJoinPayload(r),e.joinedOnce&&e.channelAdapter.isJoined()&&e.channelAdapter.push(z.access_token,{access_token:t})}))}async _waitForAuthIfNeeded(){this._authPromise&&await this._authPromise}_setAuthSafely(e="general"){this._isManualToken()||this.setAuth().catch(t=>{this.log("error",`Error setting auth in ${e}`,t)})}_setupConnectionHandlers(){this.socketAdapter.onOpen(()=>{(this._authPromise||(this.accessToken&&!this.accessTokenValue?this.setAuth():Promise.resolve())).catch(e=>{this.log("error","error waiting for auth on connect",e)}),this.worker&&!this.workerRef&&this._startWorkerHeartbeat()}),this.socketAdapter.onClose(()=>{this.worker&&this.workerRef&&this._terminateWorker()}),this.socketAdapter.onMessage(e=>{e.ref&&e.ref===this._pendingWorkerHeartbeatRef&&(this._pendingWorkerHeartbeatRef=null)})}_handleNodeJsRaceCondition(){this.socketAdapter.isConnected()&&this.socketAdapter.getSocket().onConnOpen()}_wrapHeartbeatCallback(e){return(t,r)=>{"sent"==t&&this._setAuthSafely(),e&&e(t,r)}}_startWorkerHeartbeat(){this.workerUrl?this.log("worker",`starting worker for from ${this.workerUrl}`):this.log("worker","starting default worker");let e=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(e),this.workerRef.onerror=e=>{this.log("worker","worker error",e.message),this._terminateWorker(),this.disconnect()},this.workerRef.onmessage=e=>{"keepAlive"===e.data.event&&this.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}_terminateWorker(){this.workerRef&&(this.log("worker","terminating worker"),this.workerRef.terminate(),this.workerRef=void 0)}_workerObjectUrl(e){let t;if(e)t=e;else{let e=new Blob([ev],{type:"application/javascript"});t=URL.createObjectURL(e)}return t}_initializeOptions(e){var t,r,n,s,i,a,o,l,c,u,h,d;let f,p;this.worker=null!=(t=null==e?void 0:e.worker)&&t,this.accessToken=null!=(r=null==e?void 0:e.accessToken)?r:null;let m={};m.timeout=null!=(n=null==e?void 0:e.timeout)?n:1e4,m.heartbeatIntervalMs=null!=(s=null==e?void 0:e.heartbeatIntervalMs)?s:ey.HEARTBEAT_INTERVAL,this._disconnectOnEmptyChannelsAfterMs=null!=(i=null==e?void 0:e.disconnectOnEmptyChannelsAfterMs)?i:2*(null!=(a=null==e?void 0:e.heartbeatIntervalMs)?a:ey.HEARTBEAT_INTERVAL),m.transport=null!=(o=null==e?void 0:e.transport)?o:P.getWebSocketConstructor(),m.params=null==e?void 0:e.params,m.logger=null==e?void 0:e.logger,m.heartbeatCallback=this._wrapHeartbeatCallback(null==e?void 0:e.heartbeatCallback),m.sessionStorage=null!=(l=null==e?void 0:e.sessionStorage)?l:function(){try{if("undefined"!=typeof globalThis&&globalThis.sessionStorage)return globalThis.sessionStorage}catch(e){}let e=new Map;return{get length(){return e.size},clear(){e.clear()},getItem:t=>e.has(t)?e.get(t):null,key(t){var r;return null!=(r=Array.from(e.keys())[t])?r:null},removeItem(t){e.delete(t)},setItem(t,r){e.set(t,String(r))}}}(),m.reconnectAfterMs=null!=(c=null==e?void 0:e.reconnectAfterMs)?c:e=>eb[e-1]||1e4;let g=null!=(u=null==e?void 0:e.vsn)?u:R;switch(g){case"1.0.0":f=(e,t)=>t(JSON.stringify(e)),p=(e,t)=>t(JSON.parse(e));break;case R:f=this.serializer.encode.bind(this.serializer),p=this.serializer.decode.bind(this.serializer);break;default:throw Error(`Unsupported serializer version: ${m.vsn}`)}if(m.vsn=g,m.encode=null!=(h=null==e?void 0:e.encode)?h:f,m.decode=null!=(d=null==e?void 0:e.decode)?d:p,m.beforeReconnect=this._reconnectAuth.bind(this),((null==e?void 0:e.logLevel)||(null==e?void 0:e.log_level))&&(this.logLevel=e.logLevel||e.log_level,m.params=Object.assign(Object.assign({},m.params),{log_level:this.logLevel})),this.worker){if("undefined"!=typeof window&&!window.Worker)throw Error("Web Worker is not supported");this.workerUrl=null==e?void 0:e.workerUrl,m.autoSendHeartbeat=!this.worker}return m}async _reconnectAuth(){await this._waitForAuthIfNeeded(),this.isConnected()||this.connect()}}
24var ek=class extends Error{constructor(e,t){super(e),this.name="IcebergError",this.status=t.status,this.icebergType=t.icebergType,this.icebergCode=t.icebergCode,this.details=t.details,this.isCommitStateUnknown="CommitStateUnknownException"===t.icebergType||[500,502,504].includes(t.status)&&t.icebergType?.includes("CommitState")===!0}isNotFound(){return 404===this.status}isConflict(){return 409===this.status}isAuthenticationTimeout(){return 419===this.status}};async function e_(e){return e&&"none"!==e.type?"bearer"===e.type?{Authorization:`Bearer ${e.token}`}:"header"===e.type?{[e.name]:e.value}:"custom"===e.type?await e.getHeaders():{}:{}}function eE(e){return e.join("\x1f")}var eS=class{constructor(e,t=""){this.client=e,this.prefix=t}async listNamespaces(e){let t=e?{parent:eE(e.namespace)}:void 0;return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces`,query:t})).data.namespaces.map(e=>({namespace:e}))}async createNamespace(e,t){let r={namespace:e.namespace,properties:t?.properties};return(await this.client.request({method:"POST",path:`${this.prefix}/namespaces`,body:r})).data}async dropNamespace(e){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${eE(e.namespace)}`})}async loadNamespaceMetadata(e){return{properties:(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${eE(e.namespace)}`})).data.properties}}async namespaceExists(e){try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${eE(e.namespace)}`}),!0}catch(e){if(e instanceof ek&&404===e.status)return!1;throw e}}async createNamespaceIfNotExists(e,t){try{return await this.createNamespace(e,t)}catch(e){if(e instanceof ek&&409===e.status)return;throw e}}};function eT(e){return e.join("\x1f")}var eO=class{constructor(e,t="",r){this.client=e,this.prefix=t,this.accessDelegation=r}async listTables(e){return(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${eT(e.namespace)}/tables`})).data.identifiers}async createTable(e,t){let r={};return this.accessDelegation&&(r["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${eT(e.namespace)}/tables`,body:t,headers:r})).data.metadata}async updateTable(e,t){let r=await this.client.request({method:"POST",path:`${this.prefix}/namespaces/${eT(e.namespace)}/tables/${e.name}`,body:t});return{"metadata-location":r.data["metadata-location"],metadata:r.data.metadata}}async dropTable(e,t){await this.client.request({method:"DELETE",path:`${this.prefix}/namespaces/${eT(e.namespace)}/tables/${e.name}`,query:{purgeRequested:String(t?.purge??!1)}})}async loadTable(e){let t={};return this.accessDelegation&&(t["X-Iceberg-Access-Delegation"]=this.accessDelegation),(await this.client.request({method:"GET",path:`${this.prefix}/namespaces/${eT(e.namespace)}/tables/${e.name}`,headers:t})).data.metadata}async tableExists(e){let t={};this.accessDelegation&&(t["X-Iceberg-Access-Delegation"]=this.accessDelegation);try{return await this.client.request({method:"HEAD",path:`${this.prefix}/namespaces/${eT(e.namespace)}/tables/${e.name}`,headers:t}),!0}catch(e){if(e instanceof ek&&404===e.status)return!1;throw e}}async createTableIfNotExists(e,t){try{return await this.createTable(e,t)}catch(r){if(r instanceof ek&&409===r.status)return await this.loadTable({namespace:e.namespace,name:t.name});throw r}}},eA=class{constructor(e){let t="v1";e.catalogName&&(t+=`/${e.catalogName}`);let r=e.baseUrl.endsWith("/")?e.baseUrl:`${e.baseUrl}/`;this.client=function(e){let t=e.fetchImpl??globalThis.fetch;return{async request({method:r,path:n,query:s,body:i,headers:a}){let o=function(e,t,r){let n=new URL(t,e);if(r)for(let[e,t]of Object.entries(r))void 0!==t&&n.searchParams.set(e,t);return n.toString()}(e.baseUrl,n,s),l=await e_(e.auth),c=await t(o,{method:r,headers:{...i?{"Content-Type":"application/json"}:{},...l,...a},body:i?JSON.stringify(i):void 0}),u=await c.text(),h=(c.headers.get("content-type")||"").includes("application/json"),d=h&&u?JSON.parse(u):u;if(!c.ok){let e=h?d:void 0,t=e?.error;throw new ek(t?.message??`Request failed with status ${c.status}`,{status:c.status,icebergType:t?.type,icebergCode:t?.code,details:e})}return{status:c.status,headers:c.headers,data:d}}}}({baseUrl:r,auth:e.auth,fetchImpl:e.fetch}),this.accessDelegation=e.accessDelegation?.join(","),this.namespaceOps=new eS(this.client,t),this.tableOps=new eO(this.client,t,this.accessDelegation)}async listNamespaces(e){return this.namespaceOps.listNamespaces(e)}async createNamespace(e,t){return this.namespaceOps.createNamespace(e,t)}async dropNamespace(e){await this.namespaceOps.dropNamespace(e)}async loadNamespaceMetadata(e){return this.namespaceOps.loadNamespaceMetadata(e)}async listTables(e){return this.tableOps.listTables(e)}
24async createTable(e,t){return this.tableOps.createTable(e,t)}async updateTable(e,t){return this.tableOps.updateTable(e,t)}async dropTable(e,t){await this.tableOps.dropTable(e,t)}async loadTable(e){return this.tableOps.loadTable(e)}async namespaceExists(e){return this.namespaceOps.namespaceExists(e)}async tableExists(e){return this.tableOps.tableExists(e)}async createNamespaceIfNotExists(e,t){return this.namespaceOps.createNamespaceIfNotExists(e,t)}async createTableIfNotExists(e,t){return this.tableOps.createTableIfNotExists(e,t)}},e$=r(15376).Buffer;function eC(e){return(eC="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function ej(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function eP(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ej(Object(r),!0).forEach(function(t){!function(e,t,r){var n;(n=function(e,t){if("object"!=eC(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=eC(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"),(t="symbol"==eC(n)?n:n+"")in e)?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ej(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var eR=class extends Error{constructor(e,t="storage",r,n){super(e),this.__isStorageError=!0,this.namespace=t,this.name="vectors"===t?"StorageVectorsError":"StorageError",this.status=r,this.statusCode=n}toJSON(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}};function ex(e){return"object"==typeof e&&null!==e&&"__isStorageError"in e}var ez=class extends eR{constructor(e,t,r,n="storage"){super(e,n,t,r),this.name="vectors"===n?"StorageVectorsApiError":"StorageApiError",this.status=t,this.statusCode=r}toJSON(){return eP({},super.toJSON())}},eN=class extends eR{constructor(e,t,r="storage"){super(e,r),this.name="vectors"===r?"StorageVectorsUnknownError":"StorageUnknownError",this.originalError=t}};function eI(e,t,r){let n=eP({},e),s=t.toLowerCase();for(let e of Object.keys(n))e.toLowerCase()===s&&delete n[e];return n[s]=r,n}let eU=e=>{if(Array.isArray(e))return e.map(e=>eU(e));if("function"==typeof e||e!==Object(e))return e;let t={};return Object.entries(e).forEach(([e,r])=>{t[e.replace(/([-_][a-z])/gi,e=>e.toUpperCase().replace(/[-_]/g,""))]=eU(r)}),t},eL=e=>{if("object"==typeof e&&null!==e){if("string"==typeof e.msg)return e.msg;if("string"==typeof e.message)return e.message;if("string"==typeof e.error_description)return e.error_description;if("string"==typeof e.error)return e.error;if("object"==typeof e.error&&null!==e.error){let t=e.error;if("string"==typeof t.message)return t.message}}return JSON.stringify(e)},eB=async(e,t,r,n)=>{if(null!==e&&"object"==typeof e&&"json"in e&&"function"==typeof e.json){let r=parseInt(String(e.status),10);Number.isFinite(r)||(r=500),e.json().then(e=>{let s=(null==e?void 0:e.statusCode)||(null==e?void 0:e.code)||r+"";t(new ez(eL(e),r,s,n))}).catch(()=>{let s=r+"";t(new ez(e.statusText||`HTTP ${r} error`,r,s,n))})}else t(new eN(eL(e),e,n))};async function eD(e,t,r,n,s,i,a){return new Promise((o,l)=>{e(r,((e,t,r,n)=>{let s={method:e,headers:(null==t?void 0:t.headers)||{}};if("GET"===e||"HEAD"===e||!n)return eP(eP({},s),r);if((e=>{if("object"!=typeof e||null===e)return!1;let t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)})(n)){var i;let e,r=(null==t?void 0:t.headers)||{};for(let[t,n]of Object.entries(r))"content-type"===t.toLowerCase()&&(e=n);s.headers=eI(r,"Content-Type",null!=(i=e)?i:"application/json"),s.body=JSON.stringify(n)}else s.body=n;return(null==t?void 0:t.duplex)&&(s.duplex=t.duplex),eP(eP({},s),r)})(t,n,s,i)).then(e=>{if(!e.ok)throw e;if(null==n?void 0:n.noResolveJson)return e;if("vectors"===a){let t=e.headers.get("content-type");if("0"===e.headers.get("content-length")||204===e.status||!t||!t.includes("application/json"))return{}}return e.json()}).then(e=>o(e)).catch(e=>eB(e,l,n,a))})}function eH(e="storage"){return{get:async(t,r,n,s)=>eD(t,"GET",r,n,s,void 0,e),post:async(t,r,n,s,i)=>eD(t,"POST",r,s,i,n,e),put:async(t,r,n,s,i)=>eD(t,"PUT",r,s,i,n,e),head:async(t,r,n,s)=>eD(t,"HEAD",r,eP(eP({},n),{},{noResolveJson:!0}),s,void 0,e),remove:async(t,r,n,s,i)=>eD(t,"DELETE",r,s,i,n,e)}}let{get:eJ,post:eM,put:eq,head:eF,remove:eZ}=eH("storage"),eW=eH("vectors");var eV=class{constructor(e,t={},r,n="storage"){this.shouldThrowOnError=!1,this.url=e,this.headers=function(e){let t={};for(let[r,n]of Object.entries(e))t[r.toLowerCase()]=n;return t}(t),this.fetch=(e=>e?(...t)=>e(...t):(...e)=>fetch(...e))(r),this.namespace=n}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(e,t){return this.headers=eI(this.headers,e,t),this}async handleOperation(e){try{return{data:await e(),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(ex(e))return{data:null,error:e};throw e}}},eK=class{constructor(e,t){this.downloadFn=e,this.shouldThrowOnError=t}then(e,t){return this.execute().then(e,t)}async execute(){try{return{data:(await this.downloadFn()).body,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(ex(e))return{data:null,error:e};throw e}}};n=Symbol.toStringTag;var eG=class{constructor(e,t){this.downloadFn=e,this.shouldThrowOnError=t,this[n]="BlobDownloadBuilder",this.promise=null}asStream(){return new eK(this.downloadFn,this.shouldThrowOnError)}then(e,t){return this.getPromise().then(e,t)}catch(e){return this.getPromise().catch(e)}finally(e){return this.getPromise().finally(e)}getPromise(){return this.promise||(this.promise=this.execute()),this.promise}async execute(){try{return{data:await (await this.downloadFn()).blob(),error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(ex(e))return{data:null,error:e};throw e}}};let eY={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},eX={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1};var eQ=class extends eV{constructor(e,t={},r,n){super(e,t,n,"storage"),this.bucketId=r}async uploadOrUpdate(e,t,r,n){var s=this;return s.handleOperation(async()=>{let i,a=eP(eP({},eX),n),o=eP(eP({},s.headers),"POST"===e&&{"x-upsert":String(a.upsert)}),l=a.metadata;if("undefined"!=typeof Blob&&r instanceof Blob?((i=new FormData).append("cacheControl",a.cacheControl),l&&i.append("metadata",s.encodeMetadata(l)),i.append("",r)):"undefined"!=typeof FormData&&r instanceof FormData?((i=r).has("cacheControl")||i.append("cacheControl",a.cacheControl),l&&!i.has("metadata")&&i.append("metadata",s.encodeMetadata(l))):(i=r,o["cache-control"]=`max-age=${a.cacheControl}`,o["content-type"]=a.contentType,l&&(o["x-metadata"]=s.toBase64(s.encodeMetadata(l))),("undefined"!=typeof ReadableStream&&i instanceof ReadableStream||i&&"object"==typeof i&&"pipe"in i&&"function"==typeof i.pipe)&&!a.duplex&&(a.duplex="half")),null==n?void 0:n.headers)for(let[e,t]of Object.entries(n.headers))o=eI(o,e,t);let c=s._removeEmptyFolders(t),u=s._getFinalPath(c),h=await ("PUT"==e?eq:eM)(s.fetch,`${s.url}/object/${u}`,i,eP({headers:o},(null==a?void 0:a.duplex)?{duplex:a.duplex}:{}));return{path:c,id:h.Id,fullPath:h.Key}})}async upload(e,t,r){return this.uploadOrUpdate("POST",e,t,r)}async uploadToSignedUrl(e,t,r,n){var s=this;let i=s._removeEmptyFolders(e),a=s._getFinalPath(i),o=new URL(s.url+`/object/upload/sign/${a}`);return o.searchParams.set("token",t),s.handleOperation(async()=>{let e,t=eP(eP({},eX),n),a=eP(eP({},s.headers),{"x-upsert":String(t.upsert)}),l=t.metadata;if("undefined"!=typeof Blob&&r instanceof Blob?((e=new FormData).append("cacheControl",t.cacheControl),l&&e.append("metadata",s.encodeMetadata(l)),e.append("",r)):"undefined"!=typeof FormData&&r instanceof FormData?((e=r).has("cacheControl")||e.append("cacheControl",t.cacheControl),l&&!e.has("metadata")&&e.append("metadata",s.encodeMetadata(l))):(e=r,a["cache-control"]=`max-age=${t.cacheControl}`,a["content-type"]=t.contentType,l&&(a["x-metadata"]=s.toBase64(s.encodeMetadata(l))),("undefined"!=typeof ReadableStream&&e instanceof ReadableStream||e&&"object"==typeof e&&"pipe"in e&&"function"==typeof e.pipe)&&!t.duplex&&(t.duplex="half")),null==n?void 0:n.headers)for(let[e,t]of Object.entries(n.headers))a=eI(a,e,t);return{path:i,fullPath:(await eq(s.fetch,o.toString(),e,eP({headers:a},(null==t?void 0:t.duplex)?{duplex:t.duplex}:{}))).Key}})}async createSignedUploadUrl(e,t){var r=this;return r.handleOperation(async()=>{let n=r._getFinalPath(e),s=eP({},r.headers);(null==t?void 0:t.upsert)&&(s["x-upsert"]="true");let i=await eM(r.fetch,`${r.url}/object/upload/sign/${n}`,{},{headers:s}),a=new URL(r.url+i.url),o=a.searchParams.get("token");if(!o)throw new eR("No token returned by API");return{signedUrl:a.toString(),path:e,token:o}})}async update(e,t,r){return this.uploadOrUpdate("PUT",e,t,r)}async move(e,t,r){var n=this;return n.handleOperation(async()=>await eM(n.fetch,`${n.url}/object/move`,{bucketId:n.bucketId,sourceKey:e,destinationKey:t,de
24stinationBucket:null==r?void 0:r.destinationBucket},{headers:n.headers}))}async copy(e,t,r){var n=this;return n.handleOperation(async()=>({path:(await eM(n.fetch,`${n.url}/object/copy`,{bucketId:n.bucketId,sourceKey:e,destinationKey:t,destinationBucket:null==r?void 0:r.destinationBucket},{headers:n.headers})).Key}))}async createSignedUrl(e,t,r){var n=this;return n.handleOperation(async()=>{let s=n._getFinalPath(e),i="object"==typeof(null==r?void 0:r.transform)&&null!==r.transform&&Object.keys(r.transform).length>0,a=await eM(n.fetch,`${n.url}/object/sign/${s}`,eP({expiresIn:t},i?{transform:r.transform}:{}),{headers:n.headers}),o=new URLSearchParams;(null==r?void 0:r.download)&&o.set("download",!0===r.download?"":r.download),(null==r?void 0:r.cacheNonce)!=null&&o.set("cacheNonce",String(r.cacheNonce));let l=o.toString();return{signedUrl:encodeURI(`${n.url}${a.signedURL}${l?`&${l}`:""}`)}})}async createSignedUrls(e,t,r){var n=this;return n.handleOperation(async()=>{let s=await eM(n.fetch,`${n.url}/object/sign/${n.bucketId}`,{expiresIn:t,paths:e},{headers:n.headers}),i=new URLSearchParams;(null==r?void 0:r.download)&&i.set("download",!0===r.download?"":r.download),(null==r?void 0:r.cacheNonce)!=null&&i.set("cacheNonce",String(r.cacheNonce));let a=i.toString();return s.map(e=>eP(eP({},e),{},{signedUrl:e.signedURL?encodeURI(`${n.url}${e.signedURL}${a?`&${a}`:""}`):null}))})}download(e,t,r){let n="object"==typeof(null==t?void 0:t.transform)&&null!==t.transform&&Object.keys(t.transform).length>0?"render/image/authenticated":"object",s=new URLSearchParams;(null==t?void 0:t.transform)&&this.applyTransformOptsToQuery(s,t.transform),(null==t?void 0:t.cacheNonce)!=null&&s.set("cacheNonce",String(t.cacheNonce));let i=s.toString(),a=this._getFinalPath(e);return new eG(()=>eJ(this.fetch,`${this.url}/${n}/${a}${i?`?${i}`:""}`,{headers:this.headers,noResolveJson:!0},r),this.shouldThrowOnError)}async info(e){var t=this;let r=t._getFinalPath(e);return t.handleOperation(async()=>eU(await eJ(t.fetch,`${t.url}/object/info/${r}`,{headers:t.headers})))}async exists(e){var t;let r=this._getFinalPath(e);try{return await eF(this.fetch,`${this.url}/object/${r}`,{headers:this.headers}),{data:!0,error:null}}catch(e){if(this.shouldThrowOnError)throw e;if(ex(e)){let r=e instanceof ez?e.status:e instanceof eN?null==(t=e.originalError)?void 0:t.status:void 0;if(void 0!==r&&[400,404].includes(r))return{data:!1,error:e}}throw e}}getPublicUrl(e,t){let r=this._getFinalPath(e),n=new URLSearchParams;(null==t?void 0:t.download)&&n.set("download",!0===t.download?"":t.download),(null==t?void 0:t.transform)&&this.applyTransformOptsToQuery(n,t.transform),(null==t?void 0:t.cacheNonce)!=null&&n.set("cacheNonce",String(t.cacheNonce));let s=n.toString(),i="object"==typeof(null==t?void 0:t.transform)&&null!==t.transform&&Object.keys(t.transform).length>0?"render/image":"object";return{data:{publicUrl:encodeURI(`${this.url}/${i}/public/${r}`)+(s?`?${s}`:"")}}}async remove(e){var t=this;return t.handleOperation(async()=>await eZ(t.fetch,`${t.url}/object/${t.bucketId}`,{prefixes:e},{headers:t.headers}))}async list(e,t,r){var n=this;return n.handleOperation(async()=>{let s=eP(eP(eP({},eY),t),{},{prefix:e||""});return await eM(n.fetch,`${n.url}/object/list/${n.bucketId}`,s,{headers:n.headers},r)})}async listV2(e,t){var r=this;return r.handleOperation(async()=>{let n=eP({},e);return await eM(r.fetch,`${r.url}/object/list-v2/${r.bucketId}`,n,{headers:r.headers},t)})}encodeMetadata(e){return JSON.stringify(e)}toBase64(e){return void 0!==e$?e$.from(e).toString("base64"):btoa(e)}_getFinalPath(e){return`${this.bucketId}/${e.replace(/^\/+/,"")}`}_removeEmptyFolders(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}applyTransformOptsToQuery(e,t){return t.width&&e.set("width",t.width.toString()),t.height&&e.set("height",t.height.toString()),t.resize&&e.set("resize",t.resize),t.format&&e.set("format",t.format),t.quality&&e.set("quality",t.quality.toString()),e}};let e0={"X-Client-Info":"storage-js/2.105.4"};var e1=class extends eV{constructor(e,t={},r,n){let s=new URL(e);(null==n?void 0:n.useNewHostname)&&/supabase\.(co|in|red)$/.test(s.hostname)&&!s.hostname.includes("storage.supabase.")&&(s.hostname=s.hostname.replace("supabase.","storage.supabase.")),super(s.href.replace(/\/$/,""),eP(eP({},e0),t),r,"storage")}async listBuckets(e){var t=this;return t.handleOperation(async()=>{let r=t.listBucketOptionsToQueryString(e);return await eJ(t.fetch,`${t.url}/bucket${r}`,{headers:t.headers})})}async getBucket(e){var t=this;return t.handleOperation(async()=>await eJ(t.fetch,`${t.url}/bucket/${e}`,{headers:t.headers}))}async createBucket(e,t={public:!1}){var r=this;return r.handleOperation(async()=>await eM(r.fetch,`${r.url}/bucket`,{id:e,name:e,type:t.type,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:r.headers}))}async updateBucket(e,t){var r=this;return r.handleOperation(async()=>await eq(r.fetch,`${r.url}/bucket/${e}`,{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:r.headers}))}async emptyBucket(e){var t=this;return t.handleOperation(async()=>await eM(t.fetch,`${t.url}/bucket/${e}/empty`,{},{headers:t.headers}))}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await eZ(t.fetch,`${t.url}/bucket/${e}`,{},{headers:t.headers}))}listBucketOptionsToQueryString(e){let t={};return e&&("limit"in e&&(t.limit=String(e.limit)),"offset"in e&&(t.offset=String(e.offset)),e.search&&(t.search=e.search),e.sortColumn&&(t.sortColumn=e.sortColumn),e.sortOrder&&(t.sortOrder=e.sortOrder)),Object.keys(t).length>0?"?"+new URLSearchParams(t).toString():""}},e2=class extends eV{constructor(e,t={},r){super(e.replace(/\/$/,""),eP(eP({},e0),t),r,"storage")}async createBucket(e){var t=this;return t.handleOperation(async()=>await eM(t.fetch,`${t.url}/bucket`,{name:e},{headers:t.headers}))}async listBuckets(e){var t=this;return t.handleOperation(async()=>{let r=new URLSearchParams;(null==e?void 0:e.limit)!==void 0&&r.set("limit",e.limit.toString()),(null==e?void 0:e.offset)!==void 0&&r.set("offset",e.offset.toString()),(null==e?void 0:e.sortColumn)&&r.set("sortColumn",e.sortColumn),(null==e?void 0:e.sortOrder)&&r.set("sortOrder",e.sortOrder),(null==e?void 0:e.search)&&r.set("search",e.search);let n=r.toString(),s=n?`${t.url}/bucket?${n}`:`${t.url}/bucket`;return await eJ(t.fetch,s,{headers:t.headers})})}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await eZ(t.fetch,`${t.url}/bucket/${e}`,{},{headers:t.headers}))}from(e){var t=this;if(!(!(!e||"string"!=typeof e||0===e.length||e.length>100||e.trim()!==e||e.includes("/")||e.includes("\\"))&&/^[\w!.\*'() &$@=;:+,?-]+$/.test(e)))throw new eR("Invalid bucket name: File, folder, and bucket names must follow AWS object key naming guidelines and should avoid the use of any other characters.");let r=new eA({baseUrl:this.url,catalogName:e,auth:{type:"custom",getHeaders:async()=>t.headers},fetch:this.fetch}),n=this.shouldThrowOnError;return new Proxy(r,{get(e,t){let r=e[t];return"function"!=typeof r?r:async(...t)=>{try{return{data:await r.apply(e,t),error:null}}catch(e){if(n)throw e;return{data:null,error:e}}}}})}},e6=class extends eV{constructor(e,t={},r){super(e.replace(/\/$/,""),eP(eP({},e0),{},{"Content-Type":"application/json"},t),r,"vectors")}async createIndex(e){var t=this;return t.handleOperation(async()=>await eW.post(t.fetch,`${t.url}/CreateIndex`,e,{headers:t.headers})||{})}async getIndex(e,t){var r=this;return r.handleOperation(async()=>await eW.post(r.fetch,`${r.url}/GetIndex`,{vectorBucketName:e,indexName:t},{headers:r.headers}))}async listIndexes(e){var t=this;return t.handleOperation(async()=>await eW.post(t.fetch,`${t.url}/ListIndexes`,e,{headers:t.headers}))}async deleteIndex(e,t){var r=this;return r.handleOperation(async()=>await eW.post(r.fetch,`${r.url}/DeleteIndex`,{vectorBucketName:e,indexName:t},{headers:r.headers})||{})}},e5=class extends eV{constructor(e,t={},r){super(e.replace(/\/$/,""),eP(eP({},e0),{},{"Content-Type":"application/json"},t),r,"vectors")}async putVectors(e){var t=this;if(e.vectors.length<1||e.vectors.length>500)throw Error("Vector batch size must be between 1 and 500 items");return t.handleOperation(async()=>await eW.post(t.fetch,`${t.url}/PutVectors`,e,{headers:t.headers})||{})}async getVectors(e){var t=this;return t.handleOperation(async()=>await eW.post(t.fetch,`${t.url}/GetVectors`,e,{headers:t.headers}))}async listVectors(e){var t=this;if(void 0!==e.segmentCount){if(e.segmentCount<1||e.segmentCount>16)throw Error("segmentCount must be between 1 and 16");
24if(void 0!==e.segmentIndex&&(e.segmentIndex<0||e.segmentIndex>=e.segmentCount))throw Error(`segmentIndex must be between 0 and ${e.segmentCount-1}`)}return t.handleOperation(async()=>await eW.post(t.fetch,`${t.url}/ListVectors`,e,{headers:t.headers}))}async queryVectors(e){var t=this;return t.handleOperation(async()=>await eW.post(t.fetch,`${t.url}/QueryVectors`,e,{headers:t.headers}))}async deleteVectors(e){var t=this;if(e.keys.length<1||e.keys.length>500)throw Error("Keys batch size must be between 1 and 500 items");return t.handleOperation(async()=>await eW.post(t.fetch,`${t.url}/DeleteVectors`,e,{headers:t.headers})||{})}},e8=class extends eV{constructor(e,t={},r){super(e.replace(/\/$/,""),eP(eP({},e0),{},{"Content-Type":"application/json"},t),r,"vectors")}async createBucket(e){var t=this;return t.handleOperation(async()=>await eW.post(t.fetch,`${t.url}/CreateVectorBucket`,{vectorBucketName:e},{headers:t.headers})||{})}async getBucket(e){var t=this;return t.handleOperation(async()=>await eW.post(t.fetch,`${t.url}/GetVectorBucket`,{vectorBucketName:e},{headers:t.headers}))}async listBuckets(e={}){var t=this;return t.handleOperation(async()=>await eW.post(t.fetch,`${t.url}/ListVectorBuckets`,e,{headers:t.headers}))}async deleteBucket(e){var t=this;return t.handleOperation(async()=>await eW.post(t.fetch,`${t.url}/DeleteVectorBucket`,{vectorBucketName:e},{headers:t.headers})||{})}},e4=class extends e8{constructor(e,t={}){super(e,t.headers||{},t.fetch)}from(e){return new e3(this.url,this.headers,e,this.fetch)}async createBucket(e){return super.createBucket.call(this,e)}async getBucket(e){return super.getBucket.call(this,e)}async listBuckets(e={}){return super.listBuckets.call(this,e)}async deleteBucket(e){return super.deleteBucket.call(this,e)}},e3=class extends e6{constructor(e,t,r,n){super(e,t,n),this.vectorBucketName=r}async createIndex(e){return super.createIndex.call(this,eP(eP({},e),{},{vectorBucketName:this.vectorBucketName}))}async listIndexes(e={}){return super.listIndexes.call(this,eP(eP({},e),{},{vectorBucketName:this.vectorBucketName}))}async getIndex(e){return super.getIndex.call(this,this.vectorBucketName,e)}async deleteIndex(e){return super.deleteIndex.call(this,this.vectorBucketName,e)}index(e){return new e9(this.url,this.headers,this.vectorBucketName,e,this.fetch)}},e9=class extends e5{constructor(e,t,r,n,s){super(e,t,s),this.vectorBucketName=r,this.indexName=n}async putVectors(e){return super.putVectors.call(this,eP(eP({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}async getVectors(e){return super.getVectors.call(this,eP(eP({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}async listVectors(e={}){return super.listVectors.call(this,eP(eP({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}async queryVectors(e){return super.queryVectors.call(this,eP(eP({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}async deleteVectors(e){return super.deleteVectors.call(this,eP(eP({},e),{},{vectorBucketName:this.vectorBucketName,indexName:this.indexName}))}},e7=class extends e1{constructor(e,t={},r,n){super(e,t,r,n)}from(e){return new eQ(this.url,this.headers,e,this.fetch)}get vectors(){return new e4(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}get analytics(){return new e2(this.url+"/iceberg",this.headers,this.fetch)}};r(36417);let te=r(43995).A;r(61837),r(27378);let tt="";tt="undefined"!=typeof Deno?"deno":"undefined"!=typeof document?"web":"undefined"!=typeof navigator&&"ReactNative"===navigator.product?"react-native":"node";let tr={headers:{"X-Client-Info":`supabase-js-${tt}/2.105.4`}},tn={schema:"public"},ts={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},ti={};function ta(e){return(ta="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function to(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)}return r}function tl(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};
24t%2?to(Object(r),!0).forEach(function(t){!function(e,t,r){var n;(n=function(e,t){if("object"!=ta(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=ta(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"),(t="symbol"==ta(n)?n:n+"")in e)?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):to(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var tc=class extends te{constructor(e){super(e)}},tu=class{constructor(e,t,r){var n,s,i;this.supabaseUrl=e,this.supabaseKey=t;let a=function(e){let t=null==e?void 0:e.trim();if(!t)throw Error("supabaseUrl is required.");if(!t.match(/^https?:\/\//i))throw Error("Invalid supabaseUrl: Must be a valid HTTP or HTTPS URL.");try{return new URL(t.endsWith("/")?t:t+"/")}catch(e){throw Error("Invalid supabaseUrl: Provided URL is malformed.")}}(e);if(!t)throw Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",a),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",a),this.storageUrl=new URL("storage/v1",a),this.functionsUrl=new URL("functions/v1",a);let o=`sb-${a.hostname.split(".")[0]}-auth-token`,l=function(e,t){var r,n;let{db:s,auth:i,realtime:a,global:o}=e,{db:l,auth:c,realtime:u,global:h}=t,d={db:tl(tl({},l),s),auth:tl(tl({},c),i),realtime:tl(tl({},u),a),storage:{},global:tl(tl(tl({},h),o),{},{headers:tl(tl({},null!=(r=null==h?void 0:h.headers)?r:{}),null!=(n=null==o?void 0:o.headers)?n:{})}),accessToken:async()=>""};return e.accessToken?d.accessToken=e.accessToken:delete d.accessToken,d}(null!=r?r:{},{db:tn,realtime:ti,auth:tl(tl({},ts),{},{storageKey:o}),global:tr});this.storageKey=null!=(n=l.auth.storageKey)?n:"",this.headers=null!=(s=l.global.headers)?s:{},l.accessToken?(this.accessToken=l.accessToken,this.auth=new Proxy({},{get:(e,t)=>{throw Error(`@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.${String(t)} is not possible`)}})):this.auth=this._initSupabaseAuthClient(null!=(i=l.auth)?i:{},this.headers,l.global.fetch),this.fetch=((e,t,r)=>{let n=(e=>e?(...t)=>e(...t):(...e)=>fetch(...e))(r),s=Headers;return async(r,i)=>{var a;let o=null!=(a=await t())?a:e,l=new s(null==i?void 0:i.headers);return l.has("apikey")||l.set("apikey",e),l.has("Authorization")||l.set("Authorization",`Bearer ${o}`),n(r,tl(tl({},i),{},{headers:l}))}})(t,this._getAccessToken.bind(this),l.global.fetch),this.realtime=this._initRealtimeClient(tl({headers:this.headers,accessToken:this._getAccessToken.bind(this),fetch:this.fetch},l.realtime)),this.accessToken&&Promise.resolve(this.accessToken()).then(e=>this.realtime.setAuth(e)).catch(e=>console.warn("Failed to set initial Realtime auth token:",e)),this.rest=new j(new URL("rest/v1",a).href,{headers:this.headers,schema:l.db.schema,fetch:this.fetch,timeout:l.db.timeout,urlLengthLimit:l.db.urlLengthLimit}),this.storage=new e7(this.storageUrl.href,this.headers,this.fetch,null==r?void 0:r.storage),l.accessToken||this._listenForAuthEvents()}get functions(){return new g(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}from(e){return this.rest.from(e)}schema(e){return this.rest.schema(e)}rpc(e,t={},r={head:!1,get:!1,count:void 0}){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()}async _getAccessToken(){var e,t;if(this.accessToken)return await this.accessToken();let{data:r}=await this.auth.getSession();return null!=(e=null==(t=r.session)?void 0:t.access_token)?e:this.supabaseKey}_initSupabaseAuthClient({autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:n,userStorage:s,storageKey:i,flowType:a,lock:o,debug:l,throwOnError:c,experimental:u,lockAcquireTimeout:h,skipAutoInitialize:d},f,p){let m={Authorization:`Bearer ${this.supabaseKey}`,apikey:`${this.supabaseKey}`};return new tc({url:this.authUrl.href,headers:tl(tl({},m),f),storageKey:i,autoRefreshToken:e,persistSession:t,detectSessionInUrl:r,storage:n,userStorage:s,flowType:a,lock:o,debug:l,throwOnError:c,experimental:u,fetch:p,lockAcquireTimeout:h,skipAutoInitialize:d,hasCustomAuthorizationHeader:Object.keys(this.headers).some(e=>"authorization"===e.toLowerCase())})}_initRealtimeClient(e){return new ew(this.realtimeUrl.href,tl(tl({},e),{},{params:tl(tl({},{apikey:this.supabaseKey}),null==e?void 0:e.params)}))}_listenForAuthEvents(){return this.auth.onAuthStateChange((e,t)=>{this._handleTokenChanged(e,"CLIENT",null==t?void 0:t.access_token)})}_handleTokenChanged(e,t,r){("TOKEN_REFRESHED"===e||"SIGNED_IN"===e)&&this.changedAccessToken!==r?(this.changedAccessToken=r,this.realtime.setAuth(r)):"SIGNED_OUT"===e&&(this.realtime.setAuth(),"STORAGE"==t&&this.auth.signOut(),this.changedAccessToken=void 0)}};(function(){if("undefined"!=typeof window)return!1;let e=globalThis.process;if(!e)return!1;let t=e.version;if(null==t)return!1;let r=t.match(/^v(\d+)\./);return!!r&&18>=parseInt(r[1],10)})()&&console.warn("â ï¸ Node.js 18 and below are deprecated and will no longer be supported in future versions of @supabase/supabase-js. Please upgrade to N
24ode.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");var th=r(68080);function td(){return"undefined"!=typeof window&&void 0!==window.document}th.qg,th.lK;let tf="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),tp=" \n\r=".split(""),tm=(()=>{let e=Array(128);for(let t=0;t<e.length;t+=1)e[t]=-1;for(let t=0;t<tp.length;t+=1)e[tp[t].charCodeAt(0)]=-2;for(let t=0;t<tf.length;t+=1)e[tf[t].charCodeAt(0)]=t;return e})();function tg(e){let t=[],r=0,n=0;if(function(e,t){for(let r=0;r<e.length;r+=1){let n=e.charCodeAt(r);if(n>55295&&n<=56319){let t=(n-55296)*1024&65535;n=(e.charCodeAt(r+1)-56320&65535|t)+65536,r+=1}!function(e,t){if(e<=127)return t(e);if(e<=2047){t(192|e>>6),t(128|63&e);return}if(e<=65535){t(224|e>>12),t(128|e>>6&63),t(128|63&e);return}if(e<=1114111){t(240|e>>18),t(128|e>>12&63),t(128|e>>6&63),t(128|63&e);return}throw Error(`Unrecognized Unicode codepoint: ${e.toString(16)}`)}(n,t)}}(e,e=>{for(r=r<<8|e,n+=8;n>=6;){let e=r>>n-6&63;t.push(tf[e]),n-=6}}),n>0)for(r<<=6-n,n=6;n>=6;){let e=r>>n-6&63;t.push(tf[e]),n-=6}return t.join("")}let ty=/^(.*)[.](0|[1-9][0-9]*)$/;function tb(e,t){if(e===t)return!0;let r=e.match(ty);return!!r&&r[1]===t}function tv(e,t,r){let n=r??3180,s=encodeURIComponent(t);if(s.length<=n)return[{name:e,value:t}];let i=[];for(;s.length>0;){let e=s.slice(0,n),t=e.lastIndexOf("%");t>n-3&&(e=e.slice(0,t));let r="";for(;e.length>0;)try{r=decodeURIComponent(e);break}catch(t){if(t instanceof URIError&&"%"===e.at(-3)&&e.length>3)e=e.slice(0,e.length-3);else throw t}i.push(r),s=s.slice(e.length)}return i.map((t,r)=>({name:`${e}.${r}`,value:t}))}async function tw(e,t){let r=await t(e);if(r)return r;let n=[];for(let r=0;;r++){let s=`${e}.${r}`,i=await t(s);if(!i)break;n.push(i)}return n.length>0?n.join(""):null}let tk={path:"/",sameSite:"lax",httpOnly:!1,maxAge:3456e4},t_="base64-";function tE(e){let t;if(!e.startsWith(t_))return e;try{t=function(e){let t=[],r=e=>{t.push(String.fromCodePoint(e))},n={utf8seq:0,codepoint:0},s=0,i=0;for(let t=0;t<e.length;t+=1){let a=tm[e.charCodeAt(t)];if(a>-1)for(s=s<<6|a,i+=6;i>=8;)(function(e,t,r){if(0===t.utf8seq){if(e<=127)return r(e);for(let r=1;r<6;r+=1)if((e>>7-r&1)==0){t.utf8seq=r;break}if(2===t.utf8seq)t.codepoint=31&e;else if(3===t.utf8seq)t.codepoint=15&e;else if(4===t.utf8seq)t.codepoint=7&e;else throw Error("Invalid UTF-8 sequence");t.utf8seq-=1}else if(t.utf8seq>0){if(e<=127)throw Error("Invalid UTF-8 sequence");t.codepoint=t.codepoint<<6|63&e,t.utf8seq-=1,0===t.utf8seq&&r(t.codepoint)}})(s>>i-8&255,n,r),i-=8;else if(-2===a)continue;else throw Error(`Invalid Base64-URL character "${e.at(t)}" at position ${t}`)}return t.join("")}(e.substring(t_.length))}catch(e){return console.warn("@supabase/ssr: could not base64url-decode chunked cookie value, treating as absent. Cookie chunks may have been written partially across responses.",e),null}try{JSON.parse(t)}catch{return console.warn("@supabase/ssr: chunked cookie decoded to invalid JSON, treating as absent. This usually indicates that cookie chunks from different writes were combined (e.g. response committed before all Set-Cookie headers were sent)."),null}return t}async function tS({getAll:e,setAll:t,setItems:r,removedItems:n},s){let i=s.cookieEncoding,a=s.cookieOptions??null,o=await e([...r?Object.keys(r):[],...n?Object.keys(n):[]]),l=o?.map(({name:e})=>e)||[],c=Object.keys(n).flatMap(e=>l.filter(t=>tb(t,e))),u=Object.keys(r).flatMap(e=>{let t=new Set(l.filter(t=>tb(t,e))),n=r[e];"base64url"===i&&(n=t_+tg(n));let s=tv(e,n);return s.forEach(e=>{t.delete(e.name)}),c.push(...t),s}),h={...tk,...a,maxAge:0},d={...tk,...a,maxAge:tk.maxAge};delete h.name,delete d.name,await t([...c.map(e=>({name:e,value:"",options:h})),...u.map(({name:e,value:t})=>({name:e,value:t,options:d}))],{"Cache-Control":"private, no-cache, no-store, must-revalidate, max-age=0",Expires:"0",Pragma:"no-cache"})}var tT=r(95704);let tO=!1,tA=["@supabase/auth-helpers-nextjs","@supabase/auth-helpers-react","@supabase/auth-helpers-remix","@supabase/auth-helpers-sveltekit"];function t$(e,t,r){!function(){if(tO||void 0===tT||!tT.env?.npm_package_name)return;let e=tT.env.npm_package_name;tA.includes(e)&&(tO=!0,console.warn(` 25ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 26â â ï¸ IMPORTANT: Package Consolidation Notice â 27â â 28â The ${e.padEnd(35)} package name is deprecated. â 29â â 30â You are now using @supabase/ssr - a unified solution for all frameworks. â 31â â 32â The auth-helpers packages have been consolidated into @supabase/ssr â 33â to provide better maintenance and consistent APIs across frameworks. â 34â â 35â Please update your package.json to use @supabase/ssr directly: â 36â npm uninstall ${e.padEnd(42)} â 37â npm install @supabase/ssr â 38â â 39â For more information, visit: â 40â https://supabase.com/docs/guides/auth/server-side â 41ââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââââ 42 `))}();let n=r?.isSingleton===!0||(!r||!("isSingleton"in r))&&td();if(n&&s)return s;if(!e||!t)throw Error(`@supabase/ssr: Your project's URL and API key are required to create a Supabase client! 43 44Check your Supabase project's API settings to find these values 45 46https://supabase.com/dashboard/project/_/settings/api`);let{storage:i}=function(e,t){let r,n,s=e.cookies??null,i=e.cookieEncoding,a={},o={},l=()=>{let e=(0,th.qg)(document.cookie);return Object.keys(e).map(t=>({name:t,value:e[t]??""}))},c=e=>{e.forEach(({name:e,value:t,options:r})=>{document.cookie=(0,th.lK)(e,t,r)})};if(s)if("get"in s){let e=async e=>{let t=e.flatMap(e=>[e,...Array.from({length:5}).map((t,r)=>`${e}.${r}`)]),r=[];for(let e=0;e<t.length;e+=1){let n=await s.get(t[e]);(n||"string"==typeof n)&&r.push({name:t[e],value:n})}return r};if(r=async t=>await e(t),"set"in s&&"remove"in s)n=async e=>{for(let t=0;t<e.length;t+=1){let{name:r,value:n,options:i}=e[t];n?await s.set(r,n,i):await s.remove(r,i)}};else if(t)n=async()=>{console.warn("@supabase/ssr: createServerClient was configured without set and remove cookie methods, but the client needs to set cookies. This can lead to issues such as random logouts, early session termination or increased token refresh requests. If in NextJS, check your middleware.ts file, route handlers and server actions for c
46orrectness. Consider switching to the getAll and setAll cookie methods instead of get, set and remove which are deprecated and can be difficult to use correctly.")};else throw Error("@supabase/ssr: createBrowserClient requires configuring a getAll and setAll cookie method (deprecated: alternatively both get, set and remove can be used)")}else if("getAll"in s)if(r=async()=>await s.getAll(),"setAll"in s)n=s.setAll;else if(t)n=async()=>{console.warn("@supabase/ssr: createServerClient was configured without the setAll cookie method, but the client needs to set cookies. This can lead to issues such as random logouts, early session termination or increased token refresh requests. If in NextJS, check your middleware.ts file, route handlers and server actions for correctness.")};else throw Error("@supabase/ssr: createBrowserClient requires configuring both getAll and setAll cookie methods (deprecated: alternatively both get, set and remove can be used)");else if(!t&&td())r=()=>l(),n=c;else throw Error(`@supabase/ssr: ${t?"createServerClient":"createBrowserClient"} requires configuring getAll and setAll cookie methods (deprecated: alternatively use get, set and remove).${td()?" As this is called in a browser runtime, consider removing the cookies option object to use the document.cookie API automatically.":""}`);else if(!t&&td())r=()=>l(),n=c;else if(t)throw Error("@supabase/ssr: createServerClient must be initialized with cookie options that specify getAll and setAll functions (deprecated, not recommended: alternatively use get, set and remove)");else r=()=>[],n=()=>{throw Error("@supabase/ssr: createBrowserClient in non-browser runtimes (including Next.js pre-rendering mode) was not initialized cookie options that specify getAll and setAll functions (deprecated: alternatively use get, set and remove), but they were needed")};return t?{getAll:r,setAll:n,setItems:a,removedItems:o,storage:{isServer:!0,getItem:async e=>{if("string"==typeof a[e])return a[e];if(o[e])return null;let t=await r([e]),n=await tw(e,async e=>{let r=t?.find(({name:t})=>t===e)||null;return r?r.value:null});return n?"string"!=typeof n?n:tE(n):null},setItem:async(t,s)=>{t.endsWith("-code-verifier")&&await tS({getAll:r,setAll:n,setItems:{[t]:s},removedItems:{}},{cookieOptions:e?.cookieOptions??null,cookieEncoding:i}),a[t]=s,delete o[t]},removeItem:async e=>{delete a[e],o[e]=!0}}}:{getAll:r,setAll:n,setItems:a,removedItems:o,storage:{isServer:!1,getItem:async e=>{let t=await r([e]),n=await tw(e,async e=>{let r=t?.find(({name:t})=>t===e)||null;return r?r.value:null});return n?tE(n):null},setItem:async(t,s)=>{let a=await r([t]),o=new Set((a?.map(({name:e})=>e)||[]).filter(e=>tb(e,t))),l=s;"base64url"===i&&(l=t_+tg(s));let c=tv(t,l);c.forEach(({name:e})=>{o.delete(e)});let u={...tk,...e?.cookieOptions,maxAge:0},h={...tk,...e?.cookieOptions,maxAge:tk.maxAge};delete u.name,delete h.name;let d=[...[...o].map(e=>({name:e,value:"",options:u})),...c.map(({name:e,value:t})=>({name:e,value:t,options:h}))];d.length>0&&await n(d,{})},removeItem:async t=>{let s=await r([t]),i=(s?.map(({name:e})=>e)||[]).filter(e=>tb(e,t)),a={...tk,...e?.cookieOptions,maxAge:0};delete a.name,i.length>0&&await n(i.map(e=>({name:e,value:"",options:a})),{})}}}}({...r,cookieEncoding:r?.cookieEncoding??"base64url"},!1),a=new tu(e,t,{...r,global:{...r?.global,headers:{...r?.global?.headers,"X-Client-Info":"supabase-ssr/0.10.3 createBrowserClient"}},auth:{...r?.auth,...r?.cookieOptions?.name?{storageKey:r.cookieOptions.name}:null,flowType:"pkce",autoRefreshToken:r?.auth?.autoRefreshToken??td(),detectSessionInUrl:r?.auth?.detectSessionInUrl??td(),persistSession:r?.auth?.persistSession??!0,storage:i,...r?.cookies&&"encode"in r.cookies&&"tokens-only"===r.cookies.encode?{userStorage:r?.auth?.userStorage??window.localStorage}:null}});return n&&(s=a),a}},27378:(e,t,r)=>{"use strict";r.d(t,{JS:()=>o,nb:()=>i});var n=r(66707);let s={debug:!!(globalThis&&(0,n.LJ)()&&globalThis.localStorage&&"true"===globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug"))};class i extends Error{constructor(e){super(e),this.isAcquireTimeout=!0}}class a extends i{}async function o(e,t,r){let n;s.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",e,t);let i=new globalThis.AbortController;t>0&&(n=setTimeout(()=>{i.abort(),s.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",e)},t)),await Promise.resolve();try{return await globalThis.navigator.locks.request(e,0===t?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:i.signal}
46,async i=>{if(i){clearTimeout(n),s.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",e,i.name);try{return await r()}finally{s.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",e,i.name)}}if(0===t)throw s.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",e),new a(`Acquiring an exclusive Navigator LockManager lock "${e}" immediately failed`);if(s.debug)try{let e=await globalThis.navigator.locks.query();console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(e,null," "))}catch(e){console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",e)}return console.warn("@supabase/gotrue-js: Navigator LockManager returned a null lock when using #request without ifAvailable set to true, it appears this browser is not following the LockManager spec https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request"),clearTimeout(n),await r()})}catch(o){if(t>0&&clearTimeout(n),null!==o&&"object"==typeof o&&"name"in o&&"AbortError"===o.name&&t>0)if(i.signal.aborted)return s.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire timeout, recovering by stealing lock",e),console.warn(`@supabase/gotrue-js: Lock "${e}" was not released within ${t}ms. This may indicate an orphaned lock from a component unmount (e.g., React Strict Mode). Forcefully acquiring the lock to recover.`),await Promise.resolve().then(()=>globalThis.navigator.locks.request(e,{mode:"exclusive",steal:!0},async t=>{if(!t)return console.warn("@supabase/gotrue-js: Navigator LockManager returned null lock even with steal: true"),await r();s.debug&&console.log("@supabase/gotrue-js: navigatorLock: recovered (stolen)",e,t.name);try{return await r()}finally{s.debug&&console.log("@supabase/gotrue-js: navigatorLock: released (stolen)",e,t.name)}}));else throw s.debug&&console.log("@supabase/gotrue-js: navigatorLock: lock was stolen by another request",e),new a(`Lock "${e}" was released because another request stole it`);throw o}}},36417:(e,t,r)=>{"use strict";r.d(t,{A:()=>l});var n=r(71450),s=r(71702),i=r(66707);let a=["global","local","others"];var o=r(61837);class l{constructor({url:e="",headers:t={},fetch:r,experimental:n}){this.url=e,this.headers=t,this.fetch=(0,i.lA)(r),this.experimental=null!=n?n:{},this.mfa={listFactors:this._listFactors.bind(this),deleteFactor:this._deleteFactor.bind(this)},this.oauth={listClients:this._listOAuthClients.bind(this),createClient:this._createOAuthClient.bind(this),getClient:this._getOAuthClient.bind(this),updateClient:this._updateOAuthClient.bind(this),deleteClient:this._deleteOAuthClient.bind(this),regenerateClientSecret:this._regenerateOAuthClientSecret.bind(this)},this.customProviders={listProviders:this._listCustomProviders.bind(this),createProvider:this._createCustomProvider.bind(this),getProvider:this._getCustomProvider.bind(this),updateProvider:this._updateCustomProvider.bind(this),deleteProvider:this._deleteCustomProvider.bind(this)},this.passkey={listPasskeys:this._adminListPasskeys.bind(this),deletePasskey:this._adminDeletePasskey.bind(this)}}async signOut(e,t=a[0]){if(0>a.indexOf(t))throw Error(`@supabase/auth-js: Parameter scope must be one of ${a.join(", ")}`);try{return await (0,s.vE)(this.fetch,"POST",`${this.url}/logout?scope=${t}`,{headers:this.headers,jwt:e,noResolveJson:!0}),{data:null,error:null}}catch(e){if((0,o.HY)(e))return{data:null,error:e};throw e}}async inviteUserByEmail(e,t={}){try{return await (0,s.vE)(this.fetch,"POST",`${this.url}/invite`,{body:{email:e,data:t.data},headers:this.headers,redirectTo:t.redirectTo,xform:s.Cl})}catch(e){if((0,o.HY)(e))return{data:{user:null},error:e};throw e}}async generateLink(e){try{let{options:t}=e,r=(0,n.Tt)(e,["options"]),i=Object.assign(Object.assign({},r),t);return"newEmail"in r&&(i.new_email=null==r?void 0:r.newEmail,delete i.newEmail),await (0,s.vE)(this.fetch,"POST",`${this.url}/admin/generate_link`,{body:i,headers:this.headers,xform:s.EY,redirectTo:null==t?void 0:t.redirectTo})}catch(e){if((0,o.HY)(e))return{data:{properties:null,user:null},error:e};throw e}}async createUser(e){try{return await (0,s.vE)(this.fetch,"POST",`${this.url}/admin/users`,{body:e,headers:this.headers,xform:s.Cl})}catch(e){if((0,o.HY)(e))return{data:{user:null},error:e};throw e}}async listUsers(e){var t,r,n,i,a,l,c;try{let o={nextPage:null,lastPage:0,total:0},u=await (0,s.vE)(this.fetch,"GET",`${this.url}/admin/users`,{headers:this.headers,noResolveJson:!0,query:{page:null!=(r=null==(t=null==e?void 0:e.page)?void 0:t.toString())?r:"",per_page:null!=(i=null==(n=null==e?void 0:e.perPage)?void 0:n.toString())?i:""},xform:s.w4});if(u.error)throw u.error;let h=await u.json(),d=null!=(a=u.headers.get("x-total-count"))?a:0,f=null!=(c=null==(l=u.headers.get("link"))?void 0:l.split(","))?c:[];return f.length>
460&&(f.forEach(e=>{let t=parseInt(e.split(";")[0].split("=")[1].substring(0,1)),r=JSON.parse(e.split(";")[1].split("=")[1]);o[`${r}Page`]=t}),o.total=parseInt(d)),{data:Object.assign(Object.assign({},h),o),error:null}}catch(e){if((0,o.HY)(e))return{data:{users:[]},error:e};throw e}}async getUserById(e){(0,i.W0)(e);try{return await (0,s.vE)(this.fetch,"GET",`${this.url}/admin/users/${e}`,{headers:this.headers,xform:s.Cl})}catch(e){if((0,o.HY)(e))return{data:{user:null},error:e};throw e}}async updateUserById(e,t){(0,i.W0)(e);try{return await (0,s.vE)(this.fetch,"PUT",`${this.url}/admin/users/${e}`,{body:t,headers:this.headers,xform:s.Cl})}catch(e){if((0,o.HY)(e))return{data:{user:null},error:e};throw e}}async deleteUser(e,t=!1){(0,i.W0)(e);try{return await (0,s.vE)(this.fetch,"DELETE",`${this.url}/admin/users/${e}`,{headers:this.headers,body:{should_soft_delete:t},xform:s.Cl})}catch(e){if((0,o.HY)(e))return{data:{user:null},error:e};throw e}}async _listFactors(e){(0,i.W0)(e.userId);try{let{data:t,error:r}=await (0,s.vE)(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/factors`,{headers:this.headers,xform:e=>({data:{factors:e},error:null})});return{data:t,error:r}}catch(e){if((0,o.HY)(e))return{data:null,error:e};throw e}}async _deleteFactor(e){(0,i.W0)(e.userId),(0,i.W0)(e.id);try{return{data:await (0,s.vE)(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/factors/${e.id}`,{headers:this.headers}),error:null}}catch(e){if((0,o.HY)(e))return{data:null,error:e};throw e}}async _listOAuthClients(e){var t,r,n,i,a,l,c;try{let o={nextPage:null,lastPage:0,total:0},u=await (0,s.vE)(this.fetch,"GET",`${this.url}/admin/oauth/clients`,{headers:this.headers,noResolveJson:!0,query:{page:null!=(r=null==(t=null==e?void 0:e.page)?void 0:t.toString())?r:"",per_page:null!=(i=null==(n=null==e?void 0:e.perPage)?void 0:n.toString())?i:""},xform:s.w4});if(u.error)throw u.error;let h=await u.json(),d=null!=(a=u.headers.get("x-total-count"))?a:0,f=null!=(c=null==(l=u.headers.get("link"))?void 0:l.split(","))?c:[];return f.length>0&&(f.forEach(e=>{let t=parseInt(e.split(";")[0].split("=")[1].substring(0,1)),r=JSON.parse(e.split(";")[1].split("=")[1]);o[`${r}Page`]=t}),o.total=parseInt(d)),{data:Object.assign(Object.assign({},h),o),error:null}}catch(e){if((0,o.HY)(e))return{data:{clients:[]},error:e};throw e}}async _createOAuthClient(e){try{return await (0,s.vE)(this.fetch,"POST",`${this.url}/admin/oauth/clients`,{body:e,headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if((0,o.HY)(e))return{data:null,error:e};throw e}}async _getOAuthClient(e){try{return await (0,s.vE)(this.fetch,"GET",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if((0,o.HY)(e))return{data:null,error:e};throw e}}async _updateOAuthClient(e,t){try{return await (0,s.vE)(this.fetch,"PUT",`${this.url}/admin/oauth/clients/${e}`,{body:t,headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if((0,o.HY)(e))return{data:null,error:e};throw e}}async _deleteOAuthClient(e){try{return await (0,s.vE)(this.fetch,"DELETE",`${this.url}/admin/oauth/clients/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(e){if((0,o.HY)(e))return{data:null,error:e};throw e}}async _regenerateOAuthClientSecret(e){try{return await (0,s.vE)(this.fetch,"POST",`${this.url}/admin/oauth/clients/${e}/regenerate_secret`,{headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if((0,o.HY)(e))return{data:null,error:e};throw e}}async _listCustomProviders(e){try{let t={};return(null==e?void 0:e.type)&&(t.type=e.type),await (0,s.vE)(this.fetch,"GET",`${this.url}/admin/custom-providers`,{headers:this.headers,query:t,xform:e=>{var t;return{data:{providers:null!=(t=null==e?void 0:e.providers)?t:[]},error:null}}})}catch(e){if((0,o.HY)(e))return{data:{providers:[]},error:e};throw e}}async _createCustomProvider(e){try{return await (0,s.vE)(this.fetch,"POST",`${this.url}/admin/custom-providers`,{body:e,headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if((0,o.HY)(e))return{data:null,error:e};throw e}}async _getCustomProvider(e){try{return await (0,s.vE)(this.fetch,"GET",`${this.url}/admin/custom-providers/${e}`,{headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if((0,o.HY)(e))return{data:null,error:e};throw e}}async _updateCustomProvider(e,t){try{return await (0,s.vE)(this.fetch,"PUT",`${this.url}/admin/custom-providers/${e}`,{body:t,headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if((0,o.HY)(e))return{data:null,error:e};throw e}}async _deleteCustomProvider(e){try{return await (0,s.vE)(this.fetch,"DELET
46E",`${this.url}/admin/custom-providers/${e}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(e){if((0,o.HY)(e))return{data:null,error:e};throw e}}async _adminListPasskeys(e){(0,i.aA)(this.experimental),(0,i.W0)(e.userId);try{return await (0,s.vE)(this.fetch,"GET",`${this.url}/admin/users/${e.userId}/passkeys`,{headers:this.headers,xform:e=>({data:e,error:null})})}catch(e){if((0,o.HY)(e))return{data:null,error:e};throw e}}async _adminDeletePasskey(e){(0,i.aA)(this.experimental),(0,i.W0)(e.userId),(0,i.W0)(e.passkeyId);try{return await (0,s.vE)(this.fetch,"DELETE",`${this.url}/admin/users/${e.userId}/passkeys/${e.passkeyId}`,{headers:this.headers,noResolveJson:!0}),{data:null,error:null}}catch(e){if((0,o.HY)(e))return{data:null,error:e};throw e}}}},39242:(e,t,r)=>{"use strict";r.d(t,{H1:()=>_,zZ:()=>g,GO:()=>y,sC:()=>h,KE:()=>d,w_:()=>b,Ll:()=>m,sy:()=>f,CP:()=>p,uL:()=>u});var n=r(71450),s=r(24174),i=r(61837),a=r(66707);class o extends Error{constructor({message:e,code:t,cause:r,name:n}){var s;super(e,{cause:r}),this.__isWebAuthnError=!0,this.name=null!=(s=null!=n?n:r instanceof Error?r.name:void 0)?s:"Unknown Error",this.code=t}toJSON(){return{name:this.name,message:this.message,code:this.code}}}class l extends o{constructor(e,t){super({code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t,message:e}),this.name="WebAuthnUnknownError",this.originalError=t}}class c{createNewAbortSignal(){if(this.controller){let e=Error("Cancelling existing WebAuthn API call for new one");e.name="AbortError",this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}}let u=new c;function h(e){if(!e)throw Error("Credential creation options are required");if("undefined"!=typeof PublicKeyCredential&&"parseCreationOptionsFromJSON"in PublicKeyCredential&&"function"==typeof PublicKeyCredential.parseCreationOptionsFromJSON)return PublicKeyCredential.parseCreationOptionsFromJSON(e);let{challenge:t,user:r,excludeCredentials:i}=e,a=(0,n.Tt)(e,["challenge","user","excludeCredentials"]),o=(0,s.xf)(t).buffer,l=Object.assign(Object.assign({},r),{id:(0,s.xf)(r.id).buffer}),c=Object.assign(Object.assign({},a),{challenge:o,user:l});if(i&&i.length>0){c.excludeCredentials=Array(i.length);for(let e=0;e<i.length;e++){let t=i[e];c.excludeCredentials[e]=Object.assign(Object.assign({},t),{id:(0,s.xf)(t.id).buffer,type:t.type||"public-key",transports:t.transports})}}return c}function d(e){if(!e)throw Error("Credential request options are required");if("undefined"!=typeof PublicKeyCredential&&"parseRequestOptionsFromJSON"in PublicKeyCredential&&"function"==typeof PublicKeyCredential.parseRequestOptionsFromJSON)return PublicKeyCredential.parseRequestOptionsFromJSON(e);let{challenge:t,allowCredentials:r}=e,i=(0,n.Tt)(e,["challenge","allowCredentials"]),a=(0,s.xf)(t).buffer,o=Object.assign(Object.assign({},i),{challenge:a});if(r&&r.length>0){o.allowCredentials=Array(r.length);for(let e=0;e<r.length;e++){let t=r[e];o.allowCredentials[e]=Object.assign(Object.assign({},t),{id:(0,s.xf)(t.id).buffer,type:t.type||"public-key",transports:t.transports})}}return o}function f(e){var t;return"toJSON"in e&&"function"==typeof e.toJSON?e.toJSON():{id:e.id,rawId:e.id,response:{attestationObject:(0,s.no)(new Uint8Array(e.response.attestationObject)),clientDataJSON:(0,s.no)(new Uint8Array(e.response.clientDataJSON))},type:"public-key",clientExtensionResults:e.getClientExtensionResults(),authenticatorAttachment:null!=(t=e.authenticatorAttachment)?t:void 0}}function p(e){var t;if("toJSON"in e&&"function"==typeof e.toJSON)return e.toJSON();let r=e.getClientExtensionResults(),n=e.response;return{id:e.id,rawId:e.id,response:{authenticatorData:(0,s.no)(new Uint8Array(n.authenticatorData)),clientDataJSON:(0,s.no)(new Uint8Array(n.clientDataJSON)),signature:(0,s.no)(new Uint8Array(n.signature)),userHandle:n.userHandle?(0,s.no)(new Uint8Array(n.userHandle)):void 0},type:"public-key",clientExtensionResults:r,authenticatorAttachment:null!=(t=e.authenticatorAttachment)?t:void 0}}function m(e){return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}function g(){var e,t;return!!((0,a.Bd)()&&"PublicKeyCredential"in window&&window.PublicKeyCredential&&"credentials"in navigator&&"function"==typeof(null==(e=null==navigator?void 0:navigator.credentials)?void 0:e.create)&&"function"==typeof(null==(t=null==navigator?void 0:navigator.credentials)?void 0:t.get))}async function y(e){try{let t=await navigator.credentials.create(e);if(!t)return{data:null,error:new l("Empty credential response",t)};if(!(t instanceof PublicKeyCredential))return{data:null,error:new l("Browser returned unexpected credential type",t)};return{data:t,error:null}}catch(t){return{data:null,error:function({error:e,options:t}){var r,n,s;let{publicKey:i}=t;if(!i)throw Error("options was missing required publicKey property");if("AbortError"===e.name){if(t.signal instanceof AbortSignal)return new o({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else if("ConstraintError"===e.name){if((null==(r=i.authenticatorSelection)?void 0:r.requireResidentKey)===!0)return new o({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:e});else if("conditional"===t.mediation&&(null==(n=i.authenticatorSelection)?void 0:n.userVerification)==="required")return new o({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:e});else if((null==(s=i.authenticatorSelection)?void 0:s.userVerification)==="required")return new o({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:e})}else if("InvalidStateError"===e.name)return new o({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:e});else if("NotAllowedError"===e.name)return new o({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});else if("NotSupportedError"===e.name)return new o(0===i.pubKeyCredParams.filter(e=>"public-key"===e.type).length?{message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:e}:{message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:e});else if("SecurityError"===e.name){let t=window.location.hostname;if(!m(t))return new o({message:`${window.location.hostname}
46 is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e});if(i.rp.id!==t)return new o({message:`The RP ID "${i.rp.id}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else if("TypeError"===e.name){if(i.user.id.byteLength<1||i.user.id.byteLength>64)return new o({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:e})}else if("UnknownError"===e.name)return new o({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e});return new o({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e})}({error:t,options:e})}}}async function b(e){try{let t=await navigator.credentials.get(e);if(!t)return{data:null,error:new l("Empty credential response",t)};if(!(t instanceof PublicKeyCredential))return{data:null,error:new l("Browser returned unexpected credential type",t)};return{data:t,error:null}}catch(t){return{data:null,error:function({error:e,options:t}){let{publicKey:r}=t;if(!r)throw Error("options was missing required publicKey property");if("AbortError"===e.name){if(t.signal instanceof AbortSignal)return new o({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:e})}else if("NotAllowedError"===e.name)return new o({message:e.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e});else if("SecurityError"===e.name){let t=window.location.hostname;if(!m(t))return new o({message:`${window.location.hostname} is an invalid domain`,code:"ERROR_INVALID_DOMAIN",cause:e});if(r.rpId!==t)return new o({message:`The RP ID "${r.rpId}" is invalid for this domain`,code:"ERROR_INVALID_RP_ID",cause:e})}else if("UnknownError"===e.name)return new o({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:e});return new o({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:e})}({error:t,options:e})}}}let v={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},w={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function k(...e){let t=e=>null!==e&&"object"==typeof e&&!Array.isArray(e),r=e=>e instanceof ArrayBuffer||ArrayBuffer.isView(e),n={};for(let s of e)if(s)for(let e in s){let i=s[e];if(void 0!==i)if(Array.isArray(i))n[e]=i;else if(r(i))n[e]=i;else if(t(i)){let r=n[e];t(r)?n[e]=k(r,i):n[e]=k(i)}else n[e]=i}return n}class _{constructor(e){this.client=e,this.enroll=this._enroll.bind(this),this.challenge=this._challenge.bind(this),this.verify=this._verify.bind(this),this.authenticate=this._authenticate.bind(this),this.register=this._register.bind(this)}async _enroll(e){return this.client.mfa.enroll(Object.assign(Object.assign({},e),{factorType:"webauthn"}))}async _challenge({factorId:e,webauthn:t,friendlyName:r,signal:n},s){var a,o,l,c,h;try{let{data:i,error:d}=await this.client.mfa.challenge({factorId:e,webauthn:t});if(!i)return{data:null,error:d};let f=null!=n?n:u.createNewAbortSignal();if("create"===i.webauthn.type){let{user:e}=i.webauthn.credential_options.publicKey;if(!e.name)if(r)e.name=`${e.id}:${r}`;else{let t=(await this.client.getUser()).data.user,r=(null==(a=null==t?void 0:t.user_metadata)?void 0:a.name)||(null==t?void 0:t.email)||(null==t?void 0:t.id)||"User";e.name=`${e.id}:${r}`}e.displayName||(e.displayName=e.name)}switch(i.webauthn.type){case"create":{let t=(o=i.webauthn.credential_options.publicKey,l=null==s?void 0:s.create,k(v,o,l||{})),{data:r,error:n}=await y({publicKey:t,signal:f});if(r)return{data:{factorId:e,challengeId:i.id,webauthn:{type:i.webauthn.type,credential_response:r}},error:null};return{data:null,error:n}}case"request":{let t=(c=i.webauthn.credential_options.publicKey,h=null==s?void 0:s.request,k(w,c,h||{})),{data:r,error:n}=await b(Object.assign(Object.assign({},i.webauthn.credential_options),{publicKey:t,signal:f}));if(r)return{data:{factorId:e,challengeId:i.id,webauthn:{type:i.webauthn.type,credential_response:r}},error:null};return{data:null,error:n}}}}catch(e){if((0,i.HY)(e))return{data:null,error:e};return{data:null,error:new i.HU("Unexpected error in challenge",e)}}}async _verify({challengeId:e,factorId:t,webauthn:r}){return this.client.mfa.verify({factorId:t,challengeId:e,webauthn:r})}async _authenticate({factorId:e,webauthn:{rpId:t="undefined"!=typeof window?window.location.hostname:void 0,rpOrigins:r="undefined"!=typeof window?[window.location.origin]:void 0,signal:n}={}},s){if(!t)return{data:null,error:new i.lR("rpId is required for WebAuthn authentication")};try{if(!g())return{data:null,error:new i.HU("Browser does not support WebAuthn",null)};let{data:a,error:o}=await this.challenge({factorId:e,webauthn:{rpId:t,rpOrigins:r},signal:n},{request:s});if(!a)return{data:null,error:o};let{webauthn:l}=a;return this._verify({factorId:e,challengeId:a.challengeId,webauthn:{type:l.type,rpId:t,rpOrigins:r,credential_response:l.credential_response}})}catch(e){if((0,i.HY)(e))return{data:null,error:e};return{data:null,error:new i.HU("Unexpected error in authenticate",e)}}}async _register({friendlyName:e,webauthn:{rpId:t="undefined"!=typeof window?window.location.hostname:void 0,rpOrigins:r="undefined"!=typeof window?[window.location.origin]:void 0,signal:n}={}},s){if(!t)return{data:null,error:new i.lR("rpId is required for WebAuthn registration")};try{if(!g())return{data:null,error:new i.HU("Browser does not support WebAuthn",null)};let{data:a,error:o}=await this._enroll({friendlyName:e});if(!a)return await this.client.mfa.listFactors().then(t=>{var r;return null==(r=t.data)?void 0:r.all.find(t=>"webauthn"===t.factor_type&&t.friendly_name===e&&"unverified"!==t.status)}).then(e=>e?this.client.mfa.unenroll({factorId:null==e?void 0:e.id}):void 0),{data:null,error:o};let{data:l,error:c}=await this._challenge({factorId:a.id,friendlyName:a.friendly_name,webauthn:{rpId:t,rpOrigins:r},signal:n},{create:s});if(!l)return{data:null,error:c};return this._verify({factorId:a.id,challengeId:l.challengeId,webauthn:{rpId:t,rpOrigins:r,type:l.webauthn.type,credential_response:l.webauthn.credential_response}})}catch(e){if((0,i.HY)(e))return{data:null,error:e};return{data:null,error:new i.HU("Unexpected error in register",e)}}}}},49678:(e,t,r)=>{"use strict";function n(){if("object"!=typeof globalThis)try{Object.defineProperty(Object.prototype,"__magic__",{get:function(){return this},configurable:!0}),__magic__.globalThis=__magic__,delete Object.prototype.__magic__}catch(e){"undefined"!=typeof self&&(self.globalThis=self)}}r.d(t,{V:()=>n})},55653:(e,t,r)=>{"use strict";var n,s;function i(e,t,r){function n(r,n){if(r._zod||Object.defineProperty(r,"_zod",{value:{def:n,constr:a,traits:new Set},enumerable:!1}),r._zod.traits.has(e))return;r._zod.traits.add(e),t(r,n);let s=a.prototype,i=Object.keys(s);for(let e=0;e<i.length;e++){let t=i[e];t in r||(r[t]=s[t].bind(r))}}
46let s=r?.Parent??Object;class i extends s{}function a(e){var t;let s=r?.Parent?new i:this;for(let r of(n(s,e),(t=s._zod).deferred??(t.deferred=[]),s._zod.deferred))r();return s}return Object.defineProperty(i,"name",{value:e}),Object.defineProperty(a,"init",{value:n}),Object.defineProperty(a,Symbol.hasInstance,{value:t=>!!r?.Parent&&t instanceof r.Parent||t?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}r.d(t,{EB:()=>t5,Ik:()=>rw,Yj:()=>t6,OZ:()=>t7}),Symbol("zod_brand");class a extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class o extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}(n=globalThis).__zod_globalConfig??(n.__zod_globalConfig={});let l=globalThis.__zod_globalConfig;function c(e){return e&&Object.assign(l,e),l}let u=/^[cC][0-9a-z]{6,}$/,h=/^[0-9a-z]+$/,d=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,f=/^[0-9a-vA-V]{20}$/,p=/^[A-Za-z0-9]{27}$/,m=/^[a-zA-Z0-9_-]{21}$/,g=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,y=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,b=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,v=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,w=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,k=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,_=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,E=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,S=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,T=/^[A-Za-z0-9_-]*$/,O=/^https?$/,A=/^\+[1-9]\d{6,14}$/,$="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",C=RegExp(`^${$}$`);function j(e){let t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}let P=/^[^A-Z]*$/,R=/^[^a-z]*$/;function x(e){let t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,r])=>-1===t.indexOf(+e)).map(([e,t])=>t)}function z(e,t){return"bigint"==typeof t?t.toString():t}function N(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function I(e){let t=+!!e.startsWith("^"),r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}let U=Symbol("evaluating");function L(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==U)return void 0===n&&(n=U,n=r()),n},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function B(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function D(...e){let t={};for(let r of e)Object.assign(t,Object.getOwnPropertyDescriptors(r));return Object.defineProperties({},t)}function H(e){return JSON.stringify(e)}let J="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function M(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}let q=N(()=>{if(l.jitless||"undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return Function(""),!0}catch(e){return!1}});function F(e){if(!1===M(e))return!1;let t=e.constructor;if(void 0===t||"function"!=typeof t)return!0;let r=t.prototype;return!1!==M(r)&&!1!==Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")}function Z(e){return F(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}let W=new Set(["string","number","symbol"]);function V(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function K(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}function G(e){if(!e)return{};if("string"==typeof e)return{error:()=>e};if(e?.message!==void 0){if(e?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");e.error=e.message}return(delete e.message,"string"==typeof e.error)?{...e,error:()=>e.error}:e}function Y(e,t=0){if(!0===e.aborted)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function X(e,t){return t.map(t=>(t.path??(t.path=[]),t.path.unshift(e),t))}function Q(e){return"string"==typeof e?e:e?.message}function ee(e,t,r){let n=e.message?e.message:Q(e.inst?._zod.def?.error?.(e))??Q(t?.error?.(e))??Q(r.customError?.(e))??Q(r.localeError?.(e))??"Invalid input",{inst:s,continue:i,input:a,...o}=e;return o.path??(o.path=[]),o.message=n,t?.reportInput&&(o.input=a),o}function et(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function er(...e){let[t,r,n]=e;return"string"==typeof t?{message:t,code:"custom",input:r,inst:n}:{...t}}Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,Number.MAX_VALUE,Number.MAX_VALUE;let en=i("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),es=i("$ZodCheckMaxLength",(e,t)=>{var r;en.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return null!=t&&void 0!==t.length}),e._zod.onattach.push(e=>{let r=e._zod.bag.maximum??1/0;t.maximum<r&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=r=>{let n=r.value;if(n.length<=t.maximum)return;let s=et(n);r.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),ei=i("$ZodCheckMinLength",(e,t)=>{var r;en.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return null!=t&&void 0!==t.length}),e._zod.onattach.push(e=>{let r=e._zod.bag.minimum??-1/0;t.minimum>r&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=r=>{let n=r.value;if(n.length>=t.minimum)return;let s=et(n);r.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),ea=i("$ZodCheckLengthEquals",(e,t)=>{var r;en.init(e,t),(r=e._zod.def).when??(r.when=e=>{let t=e.value;return null!=t&&void 0!==t.length}),e._zod.onattach.push(e=>{let r=e._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=r=>{let n=r.value,s=n.length;if(s===t.length)return;let i=et(n),a=s>t.length;r.issues.push({origin:i,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),eo=i("$ZodCheckStringFormat",(e,t)=>{var r,n;en.init(e,t),e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,t.pattern&&(r.patterns??(r.patterns=new Set),r.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),el=i("$ZodCheckRegex",(e,t)=>{eo.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,t.pattern.test(r.value)||r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),ec=i("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=P),eo.init(e,t)}),eu=i("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=R),eo.init(e,t)}),eh=i("$ZodCheckIncludes",(e,t)=>{en.init(e,t);let r=V(t.includes),n=new RegExp("number"==typeof t.position?`^.{${t.position}}${r}`:r);t.pattern=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input
46:r.value,inst:e,continue:!t.abort})}}),ed=i("$ZodCheckStartsWith",(e,t)=>{en.init(e,t);let r=RegExp(`^${V(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),ef=i("$ZodCheckEndsWith",(e,t)=>{en.init(e,t);let r=RegExp(`.*${V(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}}),ep=i("$ZodCheckOverwrite",(e,t)=>{en.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class em{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e){e(this,{execution:"sync"}),e(this,{execution:"async"});return}let t=e.split("\n").filter(e=>e),r=Math.min(...t.map(e=>e.length-e.trimStart().length));for(let e of t.map(e=>e.slice(r)).map(e=>" ".repeat(2*this.indent)+e))this.content.push(e)}compile(){return Function(...this?.args,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}}let eg=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,z,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},ey=i("$ZodError",eg),eb=i("$ZodError",eg,{Parent:Error}),ev=e=>(t,r,n,s)=>{let i=n?{...n,async:!1}:{async:!1},o=t._zod.run({value:r,issues:[]},i);if(o instanceof Promise)throw new a;if(o.issues.length){let t=new(s?.Err??e)(o.issues.map(e=>ee(e,i,c())));throw J(t,s?.callee),t}return o.value},ew=e=>async(t,r,n,s)=>{let i=n?{...n,async:!0}:{async:!0},a=t._zod.run({value:r,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){let t=new(s?.Err??e)(a.issues.map(e=>ee(e,i,c())));throw J(t,s?.callee),t}return a.value},ek=e=>(t,r,n)=>{let s=n?{...n,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},s);if(i instanceof Promise)throw new a;return i.issues.length?{success:!1,error:new(e??ey)(i.issues.map(e=>ee(e,s,c())))}:{success:!0,data:i.value}},e_=ek(eb),eE=e=>async(t,r,n)=>{let s=n?{...n,async:!0}:{async:!0},i=t._zod.run({value:r,issues:[]},s);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(e=>ee(e,s,c())))}:{success:!0,data:i.value}},eS=eE(eb),eT={major:4,minor:4,patch:3},eO=i("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=eT;let n=[...e._zod.def.checks??[]];for(let t of(e._zod.traits.has("$ZodCheck")&&n.unshift(e),n))for(let r of t._zod.onattach)r(e);if(0===n.length)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,r)=>{let n,s=Y(e);for(let i of t){if(i._zod.def.when){if(function(e,t=0){if(!0===e.aborted)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue===!1)return!0;return!1}(e)||!i._zod.def.when(e))continue}else if(s)continue;let t=e.issues.length,o=i._zod.check(e);if(o instanceof Promise&&r?.async===!1)throw new a;if(n||o instanceof Promise)n=(n??Promise.resolve()).then(async()=>{await o,e.issues.length!==t&&(s||(s=Y(e,t)))});else{if(e.issues.length===t)continue;s||(s=Y(e,t))}}return n?n.then(()=>e):e},r=(r,s,i)=>{if(Y(r))return r.aborted=!0,r;let o=t(s,n,i);if(o instanceof Promise){if(!1===i.async)throw new a;return o.then(t=>e._zod.parse(t,i))}return e._zod.parse(o,i)};e._zod.run=(s,i)=>{if(i.skipChecks)return e._zod.parse(s,i);if("backward"===i.direction){let t=e._zod.parse({value:s.value,issues:[]},{...i,skipChecks:!0});return t instanceof Promise?t.then(e=>r(e,s,i)):r(t,s,i)}let o=e._zod.parse(s,i);if(o instanceof Promise){if(!1===i.async)throw new a;return o.then(e=>t(e,n,i))}return t(o,n,i)}}L(e,"~standard",()=>({validate:t=>{try{let r=e_(e,t);return r.success?{value:r.data}:{issues:r.error?.issues}}catch(r){return eS(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}))}),eA=i("$ZodString",(e,t)=>{eO.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return RegExp(`^${t}$`)})(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch(e){}return"string"==typeof r.value||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),e$=i("$ZodStringFormat",(e,t)=>{eo.init(e,t),eA.init(e,t)}
46),eC=i("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=y),e$.init(e,t)}),ej=i("$ZodUUID",(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=b(e))}else t.pattern??(t.pattern=b());e$.init(e,t)}),eP=i("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=v),e$.init(e,t)}),eR=i("$ZodURL",(e,t)=>{e$.init(e,t),e._zod.check=r=>{try{let n=r.value.trim();if(!t.normalize&&t.protocol?.source===O.source&&!/^https?:\/\//i.test(n))return void r.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:r.value,inst:e,continue:!t.abort});let s=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(s.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(s.protocol.endsWith(":")?s.protocol.slice(0,-1):s.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=s.href:r.value=n;return}catch(n){r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),ex=i("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),e$.init(e,t)}),ez=i("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=m),e$.init(e,t)}),eN=i("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=u),e$.init(e,t)}),eI=i("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=h),e$.init(e,t)}),eU=i("$ZodULID",(e,t)=>{t.pattern??(t.pattern=d),e$.init(e,t)}),eL=i("$ZodXID",(e,t)=>{t.pattern??(t.pattern=f),e$.init(e,t)}),eB=i("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=p),e$.init(e,t)}),eD=i("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){let t=j({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let n=`${t}(?:${r.join("|")})`;return RegExp(`^${$}T(?:${n})$`)}(t)),e$.init(e,t)}),eH=i("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=C),e$.init(e,t)}),eJ=i("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=RegExp(`^${j(t)}$`)),e$.init(e,t)}),eM=i("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=g),e$.init(e,t)}),eq=i("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=w),e$.init(e,t),e._zod.bag.format="ipv4"}),eF=i("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=k),e$.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),eZ=i("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=_),e$.init(e,t)}),eW=i("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=E),e$.init(e,t),e._zod.check=r=>{let n=r.value.split("/");try{if(2!==n.length)throw Error();let[e,t]=n;if(!t)throw Error();let r=Number(t);if(`${r}`!==t||r<0||r>128)throw Error();new URL(`http://[${e}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function eV(e){if(""===e)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}let eK=i("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=S),e$.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{eV(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}}),eG=i("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=T),e$.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{!function(e){if(!T.test(e))return!1;let t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return eV(t.padEnd(4*Math.ceil(t.length/4),"="))}(r.value)&&r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),eY=i("$ZodE164",(e,t)=>{t.pattern??(t.pattern=A),e$.init(e,t)}),eX=i("$ZodJWT",(e,t)=>{e$.init(e,t),e._zod.check=r=>{!function(e,t=null){try{let r=e.split(".");if(3!==r.length)return!1;let[n]=r;if(!n)return!1;let s=JSON.parse(atob(n));if("typ"in s&&s?.typ!=="JWT"||!s.alg||t&&(!("alg"in s)||s.alg!==t))return!1;return!0}catch{return!1}}(r.value,t.alg)&&r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),eQ=i("$ZodUnknown",(e,t)=>{eO.init(e,t),e._zod.parse=e=>e}),e0=i("$ZodNever",(e,t)=>{eO.init(e,t),e._zod.parse=(t,r)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function e1(e,t,r){e.issues.length&&t.issues.push(...X(r,e.issues)),t.value[r]=e.value}let e2=i("$ZodArray",(e,t)=>{eO.init(e,t),e._zod.parse=(r,n)=>{let s=r.value;if(!Array.isArray(s))return r.issues.push({expected:"array",code:"invalid_type",input:s,inst:e}),r;r.value=Array(s.length);let i=[];for(let e=0;e<s.length;e++){let a=s[e],o=t.element._zod.run({value:a,issues:[]},n);o instanceof Promise?i.push(o.then(t=>e1(t,r,e))):e1(o,r,e)}return i.length?Promise.all(i).then(()=>r):r}});function e6(e,t,r,n,s,i){let a=r in n;if(e.issues.length){if(s&&i&&!a)return;t.issues.push(...X(r,e.issues))}if(!a&&!s){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[r]});return}void 0===e.value?a&&(t.value[r]=void 0):t.value[r]=e.value}function e5(e){var t;let r=Object.keys(e.shape);for(let t of r)if(!e.shape?.[t]?._zod?.traits?.has("$ZodType"))throw Error(`Invalid element at key "${t}": expected a Zod schema`);let n=Object.keys(t=e.shape).filter(e=>"optional"===t[e]._zod.optin&&"optional"===t[e]._zod.optout);
46return{...e,keys:r,keySet:new Set(r),numKeys:r.length,optionalKeys:new Set(n)}}function e8(e,t,r,n,s,i){let a=[],o=s.keySet,l=s.catchall._zod,c=l.def.type,u="optional"===l.optin,h="optional"===l.optout;for(let s in t){if("__proto__"===s||o.has(s))continue;if("never"===c){a.push(s);continue}let i=l.run({value:t[s],issues:[]},n);i instanceof Promise?e.push(i.then(e=>e6(e,r,s,t,u,h))):e6(i,r,s,t,u,h)}return(a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length)?Promise.all(e).then(()=>r):r}let e4=i("$ZodObject",(e,t)=>{let r;eO.init(e,t);let n=Object.getOwnPropertyDescriptor(t,"shape");if(!n?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let r={...e};return Object.defineProperty(t,"shape",{value:r}),r}})}let s=N(()=>e5(t));L(e._zod,"propValues",()=>{let e=t.shape,r={};for(let t in e){let n=e[t]._zod;if(n.values)for(let e of(r[t]??(r[t]=new Set),n.values))r[t].add(e)}return r});let i=t.catchall;e._zod.parse=(t,n)=>{r??(r=s.value);let a=t.value;if(!M(a))return t.issues.push({expected:"object",code:"invalid_type",input:a,inst:e}),t;t.value={};let o=[],l=r.shape;for(let e of r.keys){let r=l[e],s="optional"===r._zod.optin,i="optional"===r._zod.optout,c=r._zod.run({value:a[e],issues:[]},n);c instanceof Promise?o.push(c.then(r=>e6(r,t,e,a,s,i))):e6(c,t,e,a,s,i)}return i?e8(o,a,t,n,s.value,e):o.length?Promise.all(o).then(()=>t):t}}),e3=i("$ZodObjectJIT",(e,t)=>{let r,n;e4.init(e,t);let s=e._zod.parse,i=N(()=>e5(t)),a=!l.jitless,o=a&&q.value,c=t.catchall;e._zod.parse=(l,u)=>{n??(n=i.value);let h=l.value;return M(h)?a&&o&&u?.async===!1&&!0!==u.jitless?(r||(r=(e=>
46{let t=new em(["shape","payload","ctx"]),r=i.value,n=e=>{let t=H(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");let s=Object.create(null),a=0;for(let e of r.keys)s[e]=`key_${a++}`;for(let i of(t.write("const newResult = {};"),r.keys)){let r=s[i],a=H(i),o=e[i],l=o?._zod?.optin==="optional",c=o?._zod?.optout==="optional";t.write(`const ${r} = ${n(i)};`),l&&c?t.write(` 47 if (${r}.issues.length) { 48 if (${a} in input) { 49 payload.issues = payload.issues.concat(${r}.issues.map(iss => ({ 50 ...iss, 51 path: iss.path ? [${a}, ...iss.path] : [${a}] 52 }))); 53 } 54 } 55 56 if (${r}.value === undefined) { 57 if (${a} in input) { 58 newResult[${a}] = undefined; 59 } 60 } else { 61 newResult[${a}] = ${r}.value; 62 } 63 64 `):l?t.write(` 65 if (${r}.issues.length) { 66 payload.issues = payload.issues.concat(${r}.issues.map(iss => ({ 67 ...iss, 68 path: iss.path ? [${a}, ...iss.path] : [${a}] 69 }))); 70 } 71 72 if (${r}.value === undefined) { 73 if (${a} in input) { 74 newResult[${a}] = undefined; 75 } 76 } else { 77 newResult[${a}] = ${r}.value; 78 } 79 80 `):t.write(` 81 const ${r}_present = ${a} in input; 82 if (${r}.issues.length) { 83 payload.issues = payload.issues.concat(${r}.issues.map(iss => ({ 84 ...iss, 85 path: iss.path ? [${a}, ...iss.path] : [${a}] 86 }))); 87 } 88 if (!${r}_present && !${r}.issues.length) { 89 payload.issues.push({ 90 code: "invalid_type", 91 expected: "nonoptional", 92 input: undefined, 93 path: [${a}] 94 }); 95 } 96 97 if (${r}_present) { 98 if (${r}.value === undefined) { 99 newResult[${a}] = undefined; 100 } else { 101 newResult[${a}] = ${r}.value; 102 } 103 } 104 105 `)}t.write("payload.value = newResult;"),t.write("return payload;");let o=t.compile();return(t,r)=>o(e,t,r)})(t.shape)),l=r(l,u),c)?e8([],h,l,u,n,e):l:s(l,u):(l.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),l)}});function e9(e,t,r,n){for(let r of e)if(0===r.issues.length)return t.value=r.value,t;let s=e.filter(e=>!Y(e));return 1===s.length?(t.value=s[0].value,s[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(e=>e.issues.map(e=>ee(e,n,c())))}),t)}let e7=i("$ZodUnion",(e,t)=>{eO.init(e,t),L(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),L(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),L(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),L(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>I(e.source)).join("|")})$`)}});let r=1===t.options.length?t.options[0]._zod.run:null;e._zod.parse=(n,s)=>{if(r)return r(n,s);let i=!1,a=[];for(let e of t.options){let t=e._zod.run({value:n.value,issues:[]},s);if(t instanceof Promise)a.push(t),i=!0;else{if(0===t.issues.length)return t;a.push(t)}}return i?Promise.all(a).then(t=>e9(t,n,e,s)):e9(a,n,e,s)}}),te=i("$ZodIntersection",(e,t)=>{eO.init(e,t),e._zod.parse=(e,r)=>{let n=e.value,s=t.left._zod.run({value:n,issues:[]},r),i=t.right._zod.run({value:n,issues:[]},r);return s instanceof Promise||i instanceof Promise?Promise.all([s,i]).then(([t,r])=>tt(e,t,r)):tt(e,s,i)}});function tt(e,t,r){let n,s=new Map;for(let r of t.issues)if("unrecognized_keys"===r.code)for(let e of(n??(n=r),r.keys))s.has(e)||s.set(e,{}),s.get(e).l=!0;else e.issues.push(r);for(let t of r.issues)if("unrecognized_keys"===t.code)for(let e of t.keys)s.has(e)||s.set(e,{}),s.get(e).r=!0;else e.issues.push(t);let i=[...s].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(i.length&&n&&e.issues.push({...n,keys:i}),Y(e))return e;let a=function e(t,r){if(t===r||t instanceof Date&&r instanceof Date&&+t==+r)return{valid:!0,data:t};if(F(t)&&F(r)){let n=Object.keys(r),s=Object.keys(t).filter(e=>-1!==n.indexOf(e)),i={...t,...r};for(let n of s){let s=e(t[n],r[n]);if(!s.valid)return{valid:!1,mergeErrorPath:[n,...s.mergeErrorPath]};i[n]=s.data}return{valid:!0,data:i}}if(Array.isArray(t)&&Array.isArray(r)){if(t.length!==r.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let s=0;s<t.length;s++){let i=e(t[s],r[s]);if(!i.valid)return{valid:!1,mergeErrorPath:[s,...i.mergeErrorPath]};n.push(i.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}(t.value,r.value);
105if(!a.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(a.mergeErrorPath)}`);return e.value=a.data,e}let tr=i("$ZodEnum",(e,t)=>{eO.init(e,t);let r=x(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=RegExp(`^(${r.filter(e=>W.has(typeof e)).map(e=>"string"==typeof e?V(e):e.toString()).join("|")})$`),e._zod.parse=(t,s)=>{let i=t.value;return n.has(i)||t.issues.push({code:"invalid_value",values:r,input:i,inst:e}),t}}),tn=i("$ZodTransform",(e,t)=>{eO.init(e,t),e._zod.optin="optional",e._zod.parse=(r,n)=>{if("backward"===n.direction)throw new o(e.constructor.name);let s=t.transform(r.value,r);if(n.async)return(s instanceof Promise?s:Promise.resolve(s)).then(e=>(r.value=e,r.fallback=!0,r));if(s instanceof Promise)throw new a;return r.value=s,r.fallback=!0,r}});function ts(e,t){return void 0===t&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}let ti=i("$ZodOptional",(e,t)=>{eO.init(e,t),e._zod.optin="optional",e._zod.optout="optional",L(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),L(e._zod,"pattern",()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${I(e.source)})?$`):void 0}),e._zod.parse=(e,r)=>{if("optional"===t.innerType._zod.optin){let n=e.value,s=t.innerType._zod.run(e,r);return s instanceof Promise?s.then(e=>ts(e,n)):ts(s,n)}return void 0===e.value?e:t.innerType._zod.run(e,r)}}),ta=i("$ZodExactOptional",(e,t)=>{ti.init(e,t),L(e._zod,"values",()=>t.innerType._zod.values),L(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(e,r)=>t.innerType._zod.run(e,r)}),to=i("$ZodNullable",(e,t)=>{eO.init(e,t),L(e._zod,"optin",()=>t.innerType._zod.optin),L(e._zod,"optout",()=>t.innerType._zod.optout),L(e._zod,"pattern",()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${I(e.source)}|null)$`):void 0}),L(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,r)=>null===e.value?e:t.innerType._zod.run(e,r)}),tl=i("$ZodDefault",(e,t)=>{eO.init(e,t),e._zod.optin="optional",L(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);if(void 0===e.value)return e.value=t.defaultValue,e;let n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(e=>tc(e,t)):tc(n,t)}});function tc(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}let tu=i("$ZodPrefault",(e,t)=>{eO.init(e,t),e._zod.optin="optional",L(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,r)=>("backward"===r.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,r))}),th=i("$ZodNonOptional",(e,t)=>{eO.init(e,t),L(e._zod,"values",()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>void 0!==e)):void 0}),e._zod.parse=(r,n)=>{let s=t.innerType._zod.run(r,n);return s instanceof Promise?s.then(t=>td(t,e)):td(s,e)}});function td(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}let tf=i("$ZodCatch",(e,t)=>{eO.init(e,t),e._zod.optin="optional",L(e._zod,"optout",()=>t.innerType._zod.optout),L(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);let n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(n=>(e.value=n.value,n.issues.length&&(e.value=t.catchValue({...e,error:{issues:n.issues.map(e=>ee(e,r,c()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=n.value,n.issues.length&&(e.value=t.catchValue({...e,error:{issues:n.issues.map(e=>ee(e,r,c()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),tp=i("$ZodPipe",(e,t)=>{eO.init(e,t),L(e._zod,"values",()=>t.in._zod.values),L(e._zod,"optin",()=>t.in._zod.optin),L(e._zod,"optout",()=>t.out._zod.optout),L(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(e,r)=>{if("backward"===r.direction){let n=t.out._zod.run(e,r);return n instanceof Promise?n.then(e=>tm(e,t.in,r)):tm(n,t.in,r)}let n=t.in._zod.run(e,r);return n instanceof Promise?n.then(e=>tm(e,t.out,r)):tm(n,t.out,r)}});function tm(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},r)}let tg=i("$ZodReadonly",(e,t)=>{eO.init(e,t),L(e._zod,"propValues",()=>t.innerType._zod.propValues),L(e._zod,"values",()=>t.innerType._zod.values),L(e._zod,"optin",()=>t.innerType?._zod?.optin),L(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(e,r)=>{if("backward"===r.direction)return t.innerType._zod.run(e,r);let n=t.innerType._zod.run(e,r);return n instanceof Promise?n.then(ty):ty(n)}});function ty(e){return e.value=Object.freeze(e.value),e}let tb=i("$ZodCustom",(e,t)=>{en.init(e,t),eO.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=r=>{let n=r.value,s=t.fn(n);if(s instanceof Promise)return s.then(t=>tv(t,r,n,e));tv(s,r,n,e)}});function tv(e,t,r,n){if(!e){let e={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(e.params=n._zod.def.params),t.issues.push(er(e))}}Symbol("ZodOutput"),Symbol("ZodInput");class tw{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let r=t[0];return this._map.set(e,r),r&&"object"==typeof r&&"id"in r&&this._idmap.set(r.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let r={...this.get(t)??{}};delete r.id;let n={...r,...this._map.get(e)};return Object.keys(n).length?n:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}(s=globalThis).__zod_globalRegistry??(s.__zod_globalRegistry=new tw);let tk=globalThis.__zod_globalRegistry;function t_(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...G(t)})}function tE(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...G(t)})}function tS(e,t){return new es({check:"max_length",...G(t),maximum:e})}function tT(e,t){return new ei({check:"min_length",...G(t),minimum:e})}function tO(e,t){return new ea({check:"length_equals",...G(t),length:e})}function tA(e){return new ep({check:"overwrite",tx:e})}
105function t$(e){let t=e?.target??"draft-2020-12";return"draft-4"===t&&(t="draft-04"),"draft-7"===t&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??tk,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function tC(e,t,r={path:[],schemaPath:[]}){var n;let s=e._zod.def,i=t.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;let a={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,a);let o=e._zod.toJSONSchema?.();if(o)a.schema=o;else{let n={...r,schemaPath:[...r.schemaPath,e],path:r.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,n);else{let r=a.schema,i=t.processors[s.type];if(!i)throw Error(`[toJSONSchema]: Non-representable type encountered: ${s.type}`);i(e,t,r,n)}let i=e._zod.parent;i&&(a.ref||(a.ref=i),tC(i,t,n),t.seen.get(i).isParent=!0)}let l=t.metadataRegistry.get(e);return l&&Object.assign(a.schema,l),"input"===t.io&&function e(t,r){let n=r??{seen:new Set};if(n.seen.has(t))return!1;n.seen.add(t);let s=t._zod.def;if("transform"===s.type)return!0;if("array"===s.type)return e(s.element,n);if("set"===s.type)return e(s.valueType,n);if("lazy"===s.type)return e(s.getter(),n);if("promise"===s.type||"optional"===s.type||"nonoptional"===s.type||"nullable"===s.type||"readonly"===s.type||"default"===s.type||"prefault"===s.type)return e(s.innerType,n);if("intersection"===s.type)return e(s.left,n)||e(s.right,n);if("record"===s.type||"map"===s.type)return e(s.keyType,n)||e(s.valueType,n);if("pipe"===s.type)return!!t._zod.traits.has("$ZodCodec")||e(s.in,n)||e(s.out,n);if("object"===s.type){for(let t in s.shape)if(e(s.shape[t],n))return!0;return!1}if("union"===s.type){for(let t of s.options)if(e(t,n))return!0;return!1}if("tuple"===s.type){for(let t of s.items)if(e(t,n))return!0;if(s.rest&&e(s.rest,n))return!0}return!1}(e)&&(delete a.schema.examples,delete a.schema.default),"input"===t.io&&"_prefault"in a.schema&&((n=a.schema).default??(n.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function tj(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let n=new Map;for(let t of e.seen.entries()){let r=e.metadataRegistry.get(t[0])?.id;if(r){let e=n.get(r);if(e&&e!==t[0])throw Error(`Duplicate schema id "${r}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);n.set(r,t[0])}}let s=t=>{if(t[1].schema.$ref)return;let n=t[1],{ref:s,defId:i}=(t=>{let n="draft-2020-12"===e.target?"$defs":"definitions";if(e.external){let r=e.external.registry.get(t[0])?.id,s=e.external.uri??(e=>e);if(r)return{ref:s(r)};let i=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=i,{defId:i,ref:`${s("__shared")}#/${n}/${i}`}}if(t[1]===r)return{ref:"#"};let s=`#/${n}/`,i=t[1].schema.id??`__schema${e.counter++}`;return{defId:i,ref:s+i}})(t);n.def={...n.schema},i&&(n.defId=i);let a=n.schema;for(let e in a)delete a[e];a.$ref=s};if("throw"===e.cycles)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join("/")}/<root> 106 107Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let r of e.seen.entries()){let n=r[1];if(t===r[0]){s(r);continue}if(e.external){let n=e.external.registry.get(r[0])?.id;if(t!==r[0]&&n){s(r);continue}}if(e.metadataRegistry.get(r[0])?.id||n.cycle||n.count>1&&"ref"===e.reused){s(r);continue}}}function tP(e,t){let r=e.seen.get(t);if(!r)throw Error("Unprocessed schema. This is a bug in Zod.");let n=t=>{let r=e.seen.get(t);if(null===r.ref)return;let s=r.def??r.schema,i={...s},a=r.ref;if(r.ref=null,a){n(a);let r=e.seen.get(a),o=r.schema;if(o.$ref&&("draft-07"===e.target||"draft-04"===e.target||"openapi-3.0"===e.target)?(s.allOf=s.allOf??[],s.allOf.push(o)):Object.assign(s,o),Object.assign(s,i),t._zod.parent===a)for(let e in s)"$ref"!==e&&"allOf"!==e&&(e in i||delete s[e]);if(o.$ref&&r.def)for(let e in s)"$ref"!==e&&"allOf"!==e&&e in r.def&&JSON.stringify(s[e])===JSON.stringify(r.def[e])&&delete s[e]}let o=t._zod.parent;if(o&&o!==a){n(o);let t=e.seen.get(o);if(t?.schema.$ref&&(s.$ref=t.schema.$ref,t.def))for(let e in s)"$ref"!==e&&"allOf"!==e&&e in t.def&&JSON.stringify(s[e])===JSON.stringify(t.def[e])&&delete s[e]}e.override({zodSchema:t,jsonSchema:s,path:r.path??[]})};for(let t of[...e.seen.entries()].reverse())n(t[0]);let s={};
107if("draft-2020-12"===e.target?s.$schema="https://json-schema.org/draft/2020-12/schema":"draft-07"===e.target?s.$schema="http://json-schema.org/draft-07/schema#":"draft-04"===e.target?s.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){let r=e.external.registry.get(t)?.id;if(!r)throw Error("Schema is missing an `id` property");s.$id=e.external.uri(r)}Object.assign(s,r.def??r.schema);let i=e.metadataRegistry.get(t)?.id;void 0!==i&&s.id===i&&delete s.id;let a=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,a[e.defId]=e.def)}e.external||Object.keys(a).length>0&&("draft-2020-12"===e.target?s.$defs=a:s.definitions=a);try{let r=JSON.parse(JSON.stringify(s));return Object.defineProperty(r,"~standard",{value:{...t["~standard"],jsonSchema:{input:tR(t,"input",e.processors),output:tR(t,"output",e.processors)}},enumerable:!1,writable:!1}),r}catch(e){throw Error("Error converting schema to JSON.")}}let tR=(e,t,r={})=>n=>{let{libraryOptions:s,target:i}=n??{},a=t$({...s??{},target:i,io:t,processors:r});return tC(e,a),tj(a,e),tP(a,e)},tx={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},tz=(e,t,r,n)=>{let s=e._zod.def;tC(s.innerType,t,n),t.seen.get(e).ref=s.innerType},tN=i("ZodISODateTime",(e,t)=>{eD.init(e,t),t5.init(e,t)}),tI=i("ZodISODate",(e,t)=>{eH.init(e,t),t5.init(e,t)}),tU=i("ZodISOTime",(e,t)=>{eJ.init(e,t),t5.init(e,t)}),tL=i("ZodISODuration",(e,t)=>{eM.init(e,t),t5.init(e,t)}),tB=i("ZodError",(e,t)=>{ey.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>(function(e,t=e=>e.message){let r={_errors:[]},n=(e,s=[])=>{for(let i of e.issues)if("invalid_union"===i.code&&i.errors.length)i.errors.map(e=>n({issues:e},[...s,...i.path]));else if("invalid_key"===i.code)n({issues:i.issues},[...s,...i.path]);else if("invalid_element"===i.code)n({issues:i.issues},[...s,...i.path]);else{let e=[...s,...i.path];if(0===e.length)r._errors.push(t(i));else{let n=r,s=0;for(;s<e.length;
107){let r=e[s];s===e.length-1?(n[r]=n[r]||{_errors:[]},n[r]._errors.push(t(i))):n[r]=n[r]||{_errors:[]},n=n[r],s++}}}};return n(e),r})(e,t)},flatten:{value:t=>(function(e,t=e=>e.message){let r={},n=[];for(let s of e.issues)s.path.length>0?(r[s.path[0]]=r[s.path[0]]||[],r[s.path[0]].push(t(s))):n.push(t(s));return{formErrors:n,fieldErrors:r}})(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,z,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,z,2)}},isEmpty:{get:()=>0===e.issues.length}})},{Parent:Error}),tD=ev(tB),tH=ew(tB),tJ=ek(tB),tM=eE(tB),tq=(e,t,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return ev(tB)(e,t,n)},tF=(e,t,r)=>ev(tB)(e,t,r),tZ=async(e,t,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return ew(tB)(e,t,n)},tW=async(e,t,r)=>ew(tB)(e,t,r),tV=(e,t,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return ek(tB)(e,t,n)},tK=(e,t,r)=>ek(tB)(e,t,r),tG=async(e,t,r)=>{let n=r?{...r,direction:"backward"}:{direction:"backward"};return eE(tB)(e,t,n)},tY=async(e,t,r)=>eE(tB)(e,t,r),tX=new WeakMap;function tQ(e,t,r){let n=Object.getPrototypeOf(e),s=tX.get(n);if(s||(s=new Set,tX.set(n,s)),!s.has(t))for(let e in s.add(t),r){let t=r[e];Object.defineProperty(n,e,{configurable:!0,enumerable:!1,get(){let r=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:r}),r},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}let t0=i("ZodType",(e,t)=>(eO.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:tR(e,"input"),output:tR(e,"output")}}),e.toJSONSchema=((e,t={})=>r=>{let n=t$({...r,processors:t});return tC(e,n),tj(n,e),tP(n,e)})(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,r)=>tD(e,t,r,{callee:e.parse}),e.safeParse=(t,r)=>tJ(e,t,r),e.parseAsync=async(t,r)=>tH(e,t,r,{callee:e.parseAsync}),e.safeParseAsync=async(t,r)=>tM(e,t,r),e.spa=e.safeParseAsync,e.encode=(t,r)=>tq(e,t,r),e.decode=(t,r)=>tF(e,t,r),e.encodeAsync=async(t,r)=>tZ(e,t,r),e.decodeAsync=async(t,r)=>tW(e,t,r),e.safeEncode=(t,r)=>tV(e,t,r),e.safeDecode=(t,r)=>tK(e,t,r),e.safeEncodeAsync=async(t,r)=>tG(e,t,r),e.safeDecodeAsync=async(t,r)=>tY(e,t,r),tQ(e,"ZodType",{check(...e){let t=this.def;return this.clone(D(t,{checks:[...t.checks??[],...e.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return K(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(function(e,t={}){return new rU({type:"custom",check:"custom",fn:e,...G(t)})}(e,t))},superRefine(e,t){return this.check(function(e,t){let r=function(e,t){let r=new en({check:"custom",...G(t)});return r._zod.check=e,r}(t=>(t.addIssue=e=>{"string"==typeof e?t.issues.push(er(e,t.value,r._zod.def)):(e.fatal&&(e.continue=!1),e.code??(e.code="custom"),e.input??(e.input=t.value),e.inst??(e.inst=r),e.continue??(e.continue=!r._zod.def.abort),t.issues.push(er(e)))},e(t.value,t)),t);return r}(e,t))},overwrite(e){return this.check(tA(e))},optional(){return rO(this)},exactOptional(){var e;return e=this,new rA({type:"optional",innerType:e})},nullable(){return rC(this)},nullish(){return rO(rC(this))},nonoptional(e){var t;return t=this,new rR({type:"nonoptional",innerType:t,...G(e)})},array(){return function(e,t){return new rb({type:"array",element:e,...G(void 0)})}(this)},or(e){return new rk({type:"union",options:[this,e],...G(void 0)})},and(e){var t;return t=this,new r_({type:"intersection",left:t,right:e})},transform(e){return rN(this,new rS({type:"transform",transform:e}))},default(e){var t,r;return t=this,r=e,new rj({type:"default",innerType:t,get defaultValue(){return"function"==typeof r?r():Z(r)}})},prefault(e){var t,r;return t=this,r=e,new rP({type:"prefault",innerType:t,get defaultValue(){return"function"==typeof r?r():Z(r)}})},catch(e){var t,r;return t=this,new rx({type:"catch",innerType:t,catchValue:"function"==typeof(r=e)?r:()=>r})},pipe(e){return rN(this,e)},readonly(){var e;return e=this,new rI({type:"readonly",innerType:e})},describe(e){let t=this.clone();return tk.add(t,{description:e}),t},meta(...e){if(0===e.length)return tk.get(this);let t=this.clone();return tk.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get:()=>tk.get(e)?.description,configurable:!0}),e)),t1=i("_ZodString",(e,t)=>{eA.init(e,t),t0.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{r.type="string";let{minimum:s,maximum:i,format:a,patterns:o,contentEncoding:l}=e._zod.bag;if("number"==typeof s&&(r.minLength=s),"number"==typeof i&&(r.maxLength=i),a&&(r.format=tx[a]??a,""===r.format&&delete r.format,"time"===a&&delete r.format),l&&(r.contentEncoding=l),o&&o.size>0){let e=[...o];1===e.length?r.pattern=e[0].source:e.length>1&&(r.allOf=[...e.map(e=>({..."draft-07"===t.target||"draft-04"===t.target||"openapi-3.0"===t.target?{type:"string"}:{},pattern:e.source}))])}})(e,t,r,0);let r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,tQ(e,"_ZodString",{regex(...e){return this.check(function(e,t){return new el({check:"string_format",format:"regex",...G(t),pattern:e})}(...e))},includes(...e){return this.check(function(e,t){return new eh({check:"string_format",format:"includes",...G(t),includes:e})}(...e))},startsWith(...e){return this.check(function(e,t){return new ed({check:"string_format",format:"starts_with",...G(t),prefix:e})}(...e))},endsWith(...e){return this.check(function(e,t){return new ef({check:"string_format",format:"ends_with",...G(t),suffix:e})}(...e))},min(...e){return this.check(tT(...e))},max(...e){return this.check(tS(...e))},length(...e){return this.check(tO(...e))},nonempty(...e){return this.check(tT(1,...e))},lowercase(e){return this.check(new ec({check:"string_format",format:"lowercase",...G(e)}))},uppercase(e){return this.check(new eu({check:"string_format",format:"up
107percase",...G(e)}))},trim(){return this.check(tA(e=>e.trim()))},normalize(...e){return this.check(function(e){return tA(t=>t.normalize(e))}(...e))},toLowerCase(){return this.check(tA(e=>e.toLowerCase()))},toUpperCase(){return this.check(tA(e=>e.toUpperCase()))},slugify(){return this.check(tA(e=>e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")))}})}),t2=i("ZodString",(e,t)=>{eA.init(e,t),t1.init(e,t),e.email=t=>e.check(new t8({type:"string",format:"email",check:"string_format",abort:!1,...G(t)})),e.url=t=>e.check(tE(t9,t)),e.jwt=t=>e.check(new rp({type:"string",format:"jwt",check:"string_format",abort:!1,...G(t)})),e.emoji=t=>e.check(new re({type:"string",format:"emoji",check:"string_format",abort:!1,...G(t)})),e.guid=t=>e.check(t_(t4,t)),e.uuid=t=>e.check(new t3({type:"string",format:"uuid",check:"string_format",abort:!1,...G(t)})),e.uuidv4=t=>e.check(new t3({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...G(t)})),e.uuidv6=t=>e.check(new t3({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...G(t)})),e.uuidv7=t=>e.check(new t3({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...G(t)})),e.nanoid=t=>e.check(new rt({type:"string",format:"nanoid",check:"string_format",abort:!1,...G(t)})),e.guid=t=>e.check(t_(t4,t)),e.cuid=t=>e.check(new rr({type:"string",format:"cuid",check:"string_format",abort:!1,...G(t)})),e.cuid2=t=>e.check(new rn({type:"string",format:"cuid2",check:"string_format",abort:!1,...G(t)})),e.ulid=t=>e.check(new rs({type:"string",format:"ulid",check:"string_format",abort:!1,...G(t)})),e.base64=t=>e.check(new rh({type:"string",format:"base64",check:"string_format",abort:!1,...G(t)})),e.base64url=t=>e.check(new rd({type:"string",format:"base64url",check:"string_format",abort:!1,...G(t)})),e.xid=t=>e.check(new ri({type:"string",format:"xid",check:"string_format",abort:!1,...G(t)})),e.ksuid=t=>e.check(new ra({type:"string",format:"ksuid",check:"string_format",abort:!1,...G(t)})),e.ipv4=t=>e.check(new ro({type:"string",format:"ipv4",check:"string_format",abort:!1,...G(t)})),e.ipv6=t=>e.check(new rl({type:"string",format:"ipv6",check:"string_format",abort:!1,...G(t)})),e.cidrv4=t=>e.check(new rc({type:"string",format:"cidrv4",check:"string_format",abort:!1,...G(t)})),e.cidrv6=t=>e.check(new ru({type:"string",format:"cidrv6",check:"string_format",abort:!1,...G(t)})),e.e164=t=>e.check(new rf({type:"string",format:"e164",check:"string_format",abort:!1,...G(t)})),e.datetime=t=>e.check(new tN({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...G(t)})),e.date=t=>e.check(new tI({type:"string",format:"date",check:"string_format",...G(t)})),e.time=t=>e.check(new tU({type:"string",format:"time",check:"string_format",precision:null,...G(t)})),e.duration=t=>e.check(new tL({type:"string",format:"duration",check:"string_format",...G(t)}))});function t6(e){return new t2({type:"string",...G(e)})}let t5=i("ZodStringFormat",(e,t)=>{e$.init(e,t),t1.init(e,t)}),t8=i("ZodEmail",(e,t)=>{eP.init(e,t),t5.init(e,t)}),t4=i("ZodGUID",(e,t)=>{eC.init(e,t),t5.init(e,t)}),t3=i("ZodUUID",(e,t)=>{ej.init(e,t),t5.init(e,t)}),t9=i("ZodURL",(e,t)=>{eR.init(e,t),t5.init(e,t)});function t7(e){return tE(t9,e)}let re=i("ZodEmoji",(e,t)=>{ex.init(e,t),t5.init(e,t)}),rt=i("ZodNanoID",(e,t)=>{ez.init(e,t),t5.init(e,t)}),rr=i("ZodCUID",(e,t)=>{eN.init(e,t),t5.init(e,t)}),rn=i("ZodCUID2",(e,t)=>{eI.init(e,t),t5.init(e,t)}),rs=i("ZodULID",(e,t)=>{eU.init(e,t),t5.init(e,t)}),ri=i("ZodXID",(e,t)=>{eL.init(e,t),t5.init(e,t)}),ra=i("ZodKSUID",(e,t)=>{eB.init(e,t),t5.init(e,t)}),ro=i("ZodIPv4",(e,t)=>{eq.init(e,t),t5.init(e,t)}),rl=i("ZodIPv6",(e,t)=>{eF.init(e,t),t5.init(e,t)}),rc=i("ZodCIDRv4",(e,t)=>{eZ.init(e,t),t5.init(e,t)}),ru=i("ZodCIDRv6",(e,t)=>{eW.init(e,t),t5.init(e,t)}),rh=i("ZodBase64",(e,t)=>{eK.init(e,t),t5.init(e,t)}),rd=i("ZodBase64URL",(e,t)=>{eG.init(e,t),t5.init(e,t)}),rf=i("ZodE164",(e,t)=>{eY.init(e,t),t5.init(e,t)}),rp=i("ZodJWT",(e,t)=>{eX.init(e,t),t5.init(e,t)}),rm=i("ZodUnknown",(e,t)=>{eQ.init(e,t),t0.init(e,t),e._zod.processJSONSchema=(e,t,r)=>{}});function rg(){return new rm({type:"unknown"})}let ry=i("ZodNever",(e,t)=>{e0.init(e,t),t0.init(e,t),e._zod.processJSONSchema=(e,t,r)=>{t.not={}}}),rb=i("ZodArray",(e,t)=>{e2.init(e,t),t0.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{let s=e._zod.def,{minimum:i,maximum:a}=e._zod.bag;"number"==typeof i&&(r.minItems=i),"number"==typeof a&&(r.maxItems=a),r.type="array",r.items=tC(s.element,t,{...n,path:[...n.path,"items"]})})(e,t,r,n),e.element=t.element,tQ(e,"ZodArray",{min(e,t){return this.check(tT(e,t))},nonempty(e){return this.check(tT(1,e))},max(e,t){return this.check(tS(e,t))},length(e,t){return this.check(tO(e,t))},unwrap(){return this.element}})}),rv=i("ZodObject",(e,t)=>{e3.init(e,t),t0.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{let s=e._zod.def;r.type="object",r.properties={};let i=s.shape;for(let e in i)r.properties[e]=tC(i[e],t,{...n,path:[...n.path,"properties",e]});let a=new Set([...new Set(Object.keys(i))].filter(e=>{let r=s.shape[e]._zod;return"input"===t.io?void 0===r.optin:void 0===r.optout}));a.size>0&&(r.required=Array.from(a)),s.catchall?._zod.def.type==="never"?r.additionalProperties=!1:s.catchall?s.catchall&&(r.additionalProperties=tC(s.catchall,t,{...n,path:[...n.path,"additionalProperties"]})):"output"===t.io&&(r.additionalProperties=!1)})(e,t,r,n),L(e,"shape",()=>t.shape),tQ(e,"ZodObject",{keyof(){var e;return new rE({type:"enum",entries:Array.isArray(e=Object.keys(this._zod.def.shape))?Object.fromEntries(e.map(e=>[e,e])):e,...G(void 0)})},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:rg()})},loose(){return this.clone({...this._zod.def,catchall:rg()})},strict(){return this.clone({...this._zod.def,catchall:new ry({type:"never",...G(void 0)})})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return function(e,t){if(!F(t))throw Error("Invalid input to extend: expected a plain object");let r=e._zod.def.checks;if(r&&r.length>0){let r=e._zod.def.shape;for(let e in t)if(void 0!==Object.getOwnPropertyDescriptor(r,e))throw Error("Cannot over
107write keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let n=D(e._zod.def,{get shape(){let r={...e._zod.def.shape,...t};return B(this,"shape",r),r}});return K(e,n)}(this,e)},safeExtend(e){var t=this;if(!F(e))throw Error("Invalid input to safeExtend: expected a plain object");let r=D(t._zod.def,{get shape(){let r={...t._zod.def.shape,...e};return B(this,"shape",r),r}});return K(t,r)},merge(e){var t=this;if(t._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let r=D(t._zod.def,{get shape(){let r={...t._zod.def.shape,...e._zod.def.shape};return B(this,"shape",r),r},get catchall(){return e._zod.def.catchall},checks:e._zod.def.checks??[]});return K(t,r)},pick(e){return function(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let s=D(e._zod.def,{get shape(){let e={};for(let n in t){if(!(n in r.shape))throw Error(`Unrecognized key: "${n}"`);t[n]&&(e[n]=r.shape[n])}return B(this,"shape",e),e},checks:[]});return K(e,s)}(this,e)},omit(e){return function(e,t){let r=e._zod.def,n=r.checks;if(n&&n.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let s=D(e._zod.def,{get shape(){let n={...e._zod.def.shape};for(let e in t){if(!(e in r.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete n[e]}return B(this,"shape",n),n},checks:[]});return K(e,s)}(this,e)},partial(...e){return function(e,t,r){let n=t._zod.def.checks;if(n&&n.length>0)throw Error(".partial() cannot be used on object schemas containing refinements");let s=D(t._zod.def,{get shape(){let n=t._zod.def.shape,s={...n};if(r)for(let t in r){if(!(t in n))throw Error(`Unrecognized key: "${t}"`);r[t]&&(s[t]=e?new e({type:"optional",innerType:n[t]}):n[t])}else for(let t in n)s[t]=e?new e({type:"optional",innerType:n[t]}):n[t];return B(this,"shape",s),s},checks:[]});return K(t,s)}(rT,this,e[0])},required(...e){return function(e,t,r){let n=D(t._zod.def,{get shape(){let n=t._zod.def.shape,s={...n};if(r)for(let t in r){if(!(t in s))throw Error(`Unrecognized key: "${t}"`);r[t]&&(s[t]=new e({type:"nonoptional",innerType:n[t]}))}else for(let t in n)s[t]=new e({type:"nonoptional",innerType:n[t]});return B(this,"shape",s),s}});return K(t,n)}(rR,this,e[0])}})});function rw(e,t){return new rv({type:"object",shape:e??{},...G(t)})}let rk=i("ZodUnion",(e,t)=>{e7.init(e,t),t0.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{let s=e._zod.def,i=!1===s.inclusive,a=s.options.map((e,r)=>tC(e,t,{...n,path:[...n.path,i?"oneOf":"anyOf",r]}));i?r.oneOf=a:r.anyOf=a})(e,t,r,n),e.options=t.options}),r_=i("ZodIntersection",(e,t)=>{te.init(e,t),t0.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{let s=e._zod.def,i=tC(s.left,t,{...n,path:[...n.path,"allOf",0]}),a=tC(s.right,t,{...n,path:[...n.path,"allOf",1]}),o=e=>"allOf"in e&&1===Object.keys(e).length;r.allOf=[...o(i)?i.allOf:[i],...o(a)?a.allOf:[a]]})(e,t,r,n)}),rE=i("ZodEnum",(e,t)=>{tr.init(e,t),t0.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{let s=x(e._zod.def.entries);s.every(e=>"number"==typeof e)&&(r.type="number"),s.every(e=>"string"==typeof e)&&(r.type="string"),r.enum=s})(e,0,r,0),e.enum=t.entries,e.options=Object.values(t.entries);let r=new Set(Object.keys(t.entries));e.extract=(e,n)=>{let s={};for(let n of e)if(r.has(n))s[n]=t.entries[n];else throw Error(`Key ${n} not found in enum`);
107return new rE({...t,checks:[],...G(n),entries:s})},e.exclude=(e,n)=>{let s={...t.entries};for(let t of e)if(r.has(t))delete s[t];else throw Error(`Key ${t} not found in enum`);return new rE({...t,checks:[],...G(n),entries:s})}}),rS=i("ZodTransform",(e,t)=>{tn.init(e,t),t0.init(e,t),e._zod.processJSONSchema=(e,t,r)=>((e,t,r,n)=>{if("throw"===t.unrepresentable)throw Error("Transforms cannot be represented in JSON Schema")})(0,e,0,0),e._zod.parse=(r,n)=>{if("backward"===n.direction)throw new o(e.constructor.name);r.addIssue=n=>{"string"==typeof n?r.issues.push(er(n,r.value,t)):(n.fatal&&(n.continue=!1),n.code??(n.code="custom"),n.input??(n.input=r.value),n.inst??(n.inst=e),r.issues.push(er(n)))};let s=t.transform(r.value,r);return s instanceof Promise?s.then(e=>(r.value=e,r.fallback=!0,r)):(r.value=s,r.fallback=!0,r)}}),rT=i("ZodOptional",(e,t)=>{ti.init(e,t),t0.init(e,t),e._zod.processJSONSchema=(t,r,n)=>tz(e,t,r,n),e.unwrap=()=>e._zod.def.innerType});function rO(e){return new rT({type:"optional",innerType:e})}let rA=i("ZodExactOptional",(e,t)=>{ta.init(e,t),t0.init(e,t),e._zod.processJSONSchema=(t,r,n)=>tz(e,t,r,n),e.unwrap=()=>e._zod.def.innerType}),r$=i("ZodNullable",(e,t)=>{to.init(e,t),t0.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{let s=e._zod.def,i=tC(s.innerType,t,n),a=t.seen.get(e);"openapi-3.0"===t.target?(a.ref=s.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]})(e,t,r,n),e.unwrap=()=>e._zod.def.innerType});function rC(e){return new r$({type:"nullable",innerType:e})}let rj=i("ZodDefault",(e,t)=>{tl.init(e,t),t0.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{let s=e._zod.def;tC(s.innerType,t,n),t.seen.get(e).ref=s.innerType,r.default=JSON.parse(JSON.stringify(s.defaultValue))})(e,t,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap}),rP=i("ZodPrefault",(e,t)=>{tu.init(e,t),t0.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{let s=e._zod.def;tC(s.innerType,t,n),t.seen.get(e).ref=s.innerType,"input"===t.io&&(r._prefault=JSON.parse(JSON.stringify(s.defaultValue)))})(e,t,r,n),e.unwrap=()=>e._zod.def.innerType}),rR=i("ZodNonOptional",(e,t)=>{th.init(e,t),t0.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{let s=e._zod.def;tC(s.innerType,t,n),t.seen.get(e).ref=s.innerType})(e,t,0,n),e.unwrap=()=>e._zod.def.innerType}),rx=i("ZodCatch",(e,t)=>{tf.init(e,t),t0.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{let s,i=e._zod.def;tC(i.innerType,t,n),t.seen.get(e).ref=i.innerType;try{s=i.catchValue(void 0)}catch{throw Error("Dynamic catch values are not supported in JSON Schema")}r.default=s})(e,t,r,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap}),rz=i("ZodPipe",(e,t)=>{tp.init(e,t),t0.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{let s=e._zod.def,i=s.in._zod.traits.has("$ZodTransform"),a="input"===t.io?i?s.out:s.in:s.out;tC(a,t,n),t.seen.get(e).ref=a})(e,t,0,n),e.in=t.in,e.out=t.out});function rN(e,t){return new rz({type:"pipe",in:e,out:t})}let rI=i("ZodReadonly",(e,t)=>{tg.init(e,t),t0.init(e,t),e._zod.processJSONSchema=(t,r,n)=>((e,t,r,n)=>{let s=e._zod.def;tC(s.innerType,t,n),t.seen.get(e).ref=s.innerType,r.readOnly=!0})(e,t,r,n),e.unwrap=()=>e._zod.def.innerType}),rU=i("ZodCustom",(e,t)=>{tb.init(e,t),t0.init(e,t),e._zod.processJSONSchema=(e,t,r)=>((e,t,r,n)=>{if("throw"===t.unrepresentable)throw Error("Custom types cannot be represented in JSON Schema")})(0,e,0,0)})},61837:(e,t,r)=>{"use strict";r.d(t,{Fw:()=>b,HU:()=>o,HY:()=>s,MJ:()=>p,MR:()=>f,NA:()=>a,OI:()=>v,Ox:()=>h,RC:()=>i,U_:()=>d,Uw:()=>m,jG:()=>c,lR:()=>n,lh:()=>g,xL:()=>w,zh:()=>y,zq:()=>u});class n extends Error{constructor(e,t,r){super(e),this.__isAuthError=!0,this.name="AuthError",this.status=t,this.code=r}toJSON(){return{name:this.name,message:this.message,status:this.status,code:this.code}}}function s(e){return"object"==typeof e&&null!==e&&"__isAuthError"in e}class i extends n{constructor(e,t,r){super(e,t,r),this.name="AuthApiError",this.status=t,this.code=r}}function a(e){return s(e)&&"AuthApiError"===e.name}class o extends n{constructor(e,t){super(e),this.name="AuthUnknownError",this.originalError=t}}class l extends n{constructor(e,t,r,n){super(e,r,n),this.name=t,this.status=r}}class c extends l{constructor(){super("Auth session missing!","AuthSessionMissingError",400,void 0)}}function u(e){return s(e)&&"AuthSessionMissingError"===e.name}class h extends l{constructor(){super("Auth session or user missing","AuthInvalidToken
107ResponseError",500,void 0)}}class d extends l{constructor(e){super(e,"AuthInvalidCredentialsError",400,void 0)}}class f extends l{constructor(e,t=null){super(e,"AuthImplicitGrantRedirectError",500,void 0),this.details=null,this.details=t}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{details:this.details})}}function p(e){return s(e)&&"AuthImplicitGrantRedirectError"===e.name}class m extends l{constructor(e,t=null){super(e,"AuthPKCEGrantCodeExchangeError",500,void 0),this.details=null,this.details=t}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{details:this.details})}}class g extends l{constructor(){super("PKCE code verifier not found in storage. This can happen if the auth flow was initiated in a different browser or device, or if the storage was cleared. For SSR frameworks (Next.js, SvelteKit, etc.), use @supabase/ssr on both the server and client to store the code verifier in cookies.","AuthPKCECodeVerifierMissingError",400,"pkce_code_verifier_not_found")}}class y extends l{constructor(e,t){super(e,"AuthRetryableFetchError",t,void 0)}}function b(e){return s(e)&&"AuthRetryableFetchError"===e.name}class v extends l{constructor(e,t,r){super(e,"AuthWeakPasswordError",t,"weak_password"),this.reasons=r}toJSON(){return Object.assign(Object.assign({},super.toJSON()),{reasons:this.reasons})}}class w extends l{constructor(e){super(e,"AuthInvalidJwtError",400,"invalid_jwt")}}},66707:(e,t,r)=>{"use strict";r.d(t,{Bd:()=>l,Cq:()=>b,Gb:()=>g,Go:()=>z,K8:()=>$,KY:()=>o,LJ:()=>u,Oi:()=>p,PB:()=>w,QE:()=>R,Rn:()=>O,U9:()=>m,W0:()=>j,WJ:()=>a,XR:()=>h,aA:()=>P,c2:()=>A,cY:()=>y,dS:()=>S,lA:()=>d,pF:()=>f,uO:()=>x,yy:()=>v});var n=r(92647),s=r(61837),i=r(24174);function a(e){return Math.round(Date.now()/1e3)+e}function o(){return Symbol("auth-callback")}let l=()=>"undefined"!=typeof window&&"undefined"!=typeof document,c={tested:!1,writable:!1},u=()=>{if(!l())return!1;try{if("object"!=typeof globalThis.localStorage)return!1}catch(e){return!1}if(c.tested)return c.writable;let e=`lswt-${Math.random()}${Math.random()}`;try{globalThis.localStorage.setItem(e,e),globalThis.localStorage.removeItem(e),c.tested=!0,c.writable=!0}catch(e){c.tested=!0,c.writable=!1}return c.writable};function h(e){let t={},r=new URL(e);if(r.hash&&"#"===r.hash[0])try{new URLSearchParams(r.hash.substring(1)).forEach((e,r)=>{t[r]=e})}catch(e){}return r.searchParams.forEach((e,r)=>{t[r]=e}),t}let d=e=>e?(...t)=>e(...t):(...e)=>fetch(...e),f=e=>"object"==typeof e&&null!==e&&"status"in e&&"ok"in e&&"json"in e&&"function"==typeof e.json,p=async(e,t,r)=>{await e.setItem(t,JSON.stringify(r))},m=async(e,t)=>{let r=await e.getItem(t);if(!r)return null;try{return JSON.parse(r)}catch(e){return null}},g=async(e,t)=>{await e.removeItem(t)};class y{constructor(){this.promise=new y.promiseConstructor((e,t)=>{this.resolve=e,this.reject=t})}}function b(e){let t=e.split(".");if(3!==t.length)throw new s.xL("Invalid JWT structure");for(let e=0;e<t.length;e++)if(!n.Jj.test(t[e]))throw new s.xL("JWT not in base64url format");return{header:JSON.parse((0,i.uE)(t[0])),payload:JSON.parse((0,i.uE)(t[1])),signature:(0,i.xf)(t[2]),raw:{header:t[0],payload:t[1]}}}async function v(e){return await new Promise(t=>{setTimeout(()=>t(null),e)})}function w(e,t){return new Promise((r,n)=>{(async()=>{for(let s=0;s<1/0;s++)try{let n=await e(s);if(!t(s,null,n))return void r(n)}catch(e){if(!t(s,e))return void n(e)}})()})}function k(e){return("0"+e.toString(16)).substr(-2)}async function _(e){let t=new TextEncoder().encode(e);return Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256",t))).map(e=>String.fromCharCode(e)).join("")}async function E(e){return"undefined"==typeof crypto||void 0===crypto.subtle||"undefined"==typeof TextEncoder?(console.warn("WebCrypto API is not supported. Code challenge method will default to use plain instead of sha256."),e):btoa(await _(e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function S(e,t,r=!1){let n=function(){let e=new Uint32Array(56);if("undefined"==typeof crypto){let e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",t=e.length,r="";for(let n=0;n<56;n++)r+=e.charAt(Math.floor(Math.random()*t));return r}return crypto.getRandomValues(e),Array.from(e,k).join("")}(),s=n;r&&(s+="/recovery"),await p(e,`${t}-code-verifier`,s);let i=await E(n),a=n===i?"plain":"s256";return[i,a]}y.promiseConstructor=Promise;let T=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i;function O(e){let t=e.headers.get(n.sk);if(!t||!t.match(T))return null;try{return new Date(`${t}T00:00:00.0Z`)}catch(e){return null}}function A(e){if(!e)throw Error("Missing exp claim");if(e<=Math.floor(Date.now()/1e3))throw Error("JWT has expired")}function $(e){switch(e){case"RS256":return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case"ES256":return{name:"ECDSA",namedCurve:"P-256",hash:{name:"SHA-256"}};default:throw Error("Invalid alg claim")}}let C=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function j(e){if(!C.test(e))throw Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function P(e){if(!e.passkey)throw Error("@supabase/auth-js: the passkey API is experimental and disabled by default. Enable it by passing `auth: { experimental: { passkey: true } }` to createClient (or to the GoTrueClient constructor).")}function R(){return new Proxy({},{get:(e,t)=>{if("__isUserNotAvailableProxy"===t)return!0;
107if("symbol"==typeof t){let e=t.toString();if("Symbol(Symbol.toPrimitive)"===e||"Symbol(Symbol.toStringTag)"===e||"Symbol(util.inspect.custom)"===e)return}throw Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "${t}" property of the session object is not supported. Please use getUser() instead.`)},set:(e,t)=>{throw Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Setting the "${t}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)},deleteProperty:(e,t)=>{throw Error(`@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Deleting the "${t}" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.`)}})}function x(e,t){return new Proxy(e,{get:(e,r,n)=>{if("__isInsecureUserWarningProxy"===r)return!0;if("symbol"==typeof r){let t=r.toString();if("Symbol(Symbol.toPrimitive)"===t||"Symbol(Symbol.toStringTag)"===t||"Symbol(util.inspect.custom)"===t||"Symbol(nodejs.util.inspect.custom)"===t)return Reflect.get(e,r,n)}return t.value||"string"!=typeof r||(console.warn("Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server."),t.value=!0),Reflect.get(e,r,n)}})}function z(e){return JSON.parse(JSON.stringify(e))}},68080:(e,t)=>{"use strict";t.qg=function(e,t){let r=new o,n=e.length;if(n<2)return r;let s=t?.decode||u,i=0;do{let t=function(e,t,r){let n=e.indexOf("=",t);return n<r?n:-1}(e,i,n);if(-1===t)break;let a=function(e,t,r){let n=e.indexOf(";",t);return -1===n?r:n}(e,i,n);if(t>a){i=e.lastIndexOf(";",t-1)+1;continue}let o=c(e,i,t);void 0===r[o]&&(r[o]=s(c(e,t+1,a))),i=a+1}while(i<n);return r},t.lK=l,t.lK=l;let r=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,n=/^[\u0021-\u003A\u003C-\u007E]*$/,s=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,i=/^[\u0020-\u003A\u003D-\u007E]*$/,a=Object.prototype.toString,o=(()=>{let e=function(){};return e.prototype=Object.create(null),e})();function l(e,t,o){let l="object"==typeof e?e:{...o,name:e,value:String(t)},c=("object"==typeof t?t:o)?.encode||encodeURIComponent;if(!r.test(l.name))throw TypeError(`argument name is invalid: ${l.name}`);let u=l.value?c(l.value):"";if(!n.test(u))throw TypeError(`argument val is invalid: ${l.value}`);let h=l.name+"="+u;if(void 0!==l.maxAge){if(!Number.isInteger(l.maxAge))throw TypeError(`option maxAge is invalid: ${l.maxAge}`);h+="; Max-Age="+l.maxAge}if(l.domain){if(!s.test(l.domain))throw TypeError(`option domain is invalid: ${l.domain}`);h+="; Domain="+l.domain}if(l.path){if(!i.test(l.path))throw TypeError(`option path is invalid: ${l.path}`);h+="; Path="+l.path}if(l.expires){var d;if(d=l.expires,"[object Date]"!==a.call(d)||!Number.isFinite(l.expires.valueOf()))throw TypeError(`option expires is invali
107d: ${l.expires}`);h+="; Expires="+l.expires.toUTCString()}if(l.httpOnly&&(h+="; HttpOnly"),l.secure&&(h+="; Secure"),l.partitioned&&(h+="; Partitioned"),l.priority)switch("string"==typeof l.priority?l.priority.toLowerCase():void 0){case"low":h+="; Priority=Low";break;case"medium":h+="; Priority=Medium";break;case"high":h+="; Priority=High";break;default:throw TypeError(`option priority is invalid: ${l.priority}`)}if(l.sameSite)switch("string"==typeof l.sameSite?l.sameSite.toLowerCase():l.sameSite){case!0:case"strict":h+="; SameSite=Strict";break;case"lax":h+="; SameSite=Lax";break;case"none":h+="; SameSite=None";break;default:throw TypeError(`option sameSite is invalid: ${l.sameSite}`)}return h}function c(e,t,r){let n=t,s=r;do{let t=e.charCodeAt(n);if(32!==t&&9!==t)break}while(++n<s);for(;s>n;){let t=e.charCodeAt(s-1);if(32!==t&&9!==t)break;s--}return e.slice(n,s)}function u(e){if(-1===e.indexOf("%"))return e;try{return decodeURIComponent(e)}catch(t){return e}}},71702:(e,t,r)=>{"use strict";r.d(t,{Cl:()=>p,EY:()=>g,GC:()=>f,R_:()=>d,c2:()=>m,vE:()=>u,w4:()=>y});var n=r(71450),s=r(92647),i=r(66707),a=r(61837);let o=e=>{if("object"==typeof e&&null!==e){if("string"==typeof e.msg)return e.msg;if("string"==typeof e.message)return e.message;if("string"==typeof e.error_description)return e.error_description;if("string"==typeof e.error)return e.error}return JSON.stringify(e)},l=[502,503,504,520,521,522,523,524,530];async function c(e){var t;let r,n;if(!(0,i.pF)(e))throw new a.zh(o(e),0);if(l.includes(e.status))throw new a.zh(o(e),e.status);try{r=await e.json()}catch(e){throw new a.HU(o(e),e)}let c=(0,i.Rn)(e);if(c&&c.getTime()>=s.Bo["2024-01-01"].timestamp&&"object"==typeof r&&r&&"string"==typeof r.code?n=r.code:"object"==typeof r&&r&&"string"==typeof r.error_code&&(n=r.error_code),n){if("weak_password"===n)throw new a.OI(o(r),e.status,(null==(t=r.weak_password)?void 0:t.reasons)||[]);else if("session_not_found"===n)throw new a.jG}else if("object"==typeof r&&r&&"object"==typeof r.weak_password&&r.weak_password&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.reasons.reduce((e,t)=>e&&"string"==typeof t,!0))throw new a.OI(o(r),e.status,r.weak_password.reasons);throw new a.RC(o(r),e.status||500,n)}async function u(e,t,r,n){var i;let a=Object.assign({},null==n?void 0:n.headers);a[s.sk]||(a[s.sk]=s.Bo["2024-01-01"].name),(null==n?void 0:n.jwt)&&(a.Authorization=`Bearer ${n.jwt}`);let o=null!=(i=null==n?void 0:n.query)?i:{};(null==n?void 0:n.redirectTo)&&(o.redirect_to=n.redirectTo);let l=Object.keys(o).length?"?"+new URLSearchParams(o).toString():"",c=await h(e,t,r+l,{headers:a,noResolveJson:null==n?void 0:n.noResolveJson},{},null==n?void 0:n.body);return(null==n?void 0:n.xform)?null==n?void 0:n.xform(c):{data:Object.assign({},c),error:null}}async function h(e,t,r,n,s,i){let l,u=((e,t,r,n)=>{let s={method:e,headers:(null==t?void 0:t.headers)||{}};return"GET"===e?s:(s.headers=Object.assign({"Content-Type":"application/json;charset=UTF-8"},null==t?void 0:t.headers),s.body=JSON.stringify(n),Object.assign(Object.assign({},s),r))})(t,n,s,i);try{l=await e(r,Object.assign({},u))}catch(e){throw console.error(e),new a.zh(o(e),0)}if(l.ok||await c(l),null==n?void 0:n.noResolveJson)return l;try{return await l.json()}catch(e){await c(e)}}function d(e){var t,r;let n=null;return(r=e).access_token&&r.refresh_token&&r.expires_in&&(n=Object.assign({},e),e.expires_at||(n.expires_at=(0,i.WJ)(e.expires_in))),{data:{session:n,user:null!=(t=e.user)?t:e},error:null}}function f(e){let t=d(e);return!t.error&&e.weak_password&&"object"==typeof e.weak_password&&Array.isArray(e.weak_password.reasons)&&e.weak_password.reasons.length&&e.weak_password.message&&"string"==typeof e.weak_password.message&&e.weak_password.reasons.reduce((e,t)=>e&&"string"==typeof t,!0)&&(t.data.weak_password=e.weak_password),t}function p(e){var t;return{data:{user:null!=(t=e.user)?t:e},error:null}}function m(e){return{data:e,error:null}}function g(e){let{action_link:t,email_otp:r,hashed_token:s,redirect_to:i,verification_type:a}=e;return{data:{properties:{action_link:t,email_otp:r,hashed_token:s,redirect_to:i,verification_type:a},user:Object.assign({},(0,n.Tt)(e,["action_link","email_otp","hashed_token","redirect_to","verification_type"]))},error:null}}function y(e){return e}},82296:(e,t,r)=>{"use strict";function n(e){if(!/^0x[a-fA-F0-9]{40}$/.test(e))throw Error(`@supabase/auth-js: Address "${e}
107" is invalid.`);return e.toLowerCase()}function s(e){return parseInt(e,16)}function i(e){return"0x"+Array.from(new TextEncoder().encode(e),e=>e.toString(16).padStart(2,"0")).join("")}function a(e){var t;let{chainId:r,domain:s,expirationTime:i,issuedAt:a=new Date,nonce:o,notBefore:l,requestId:c,resources:u,scheme:h,uri:d,version:f}=e;if(!Number.isInteger(r))throw Error(`@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: ${r}`);if(!s)throw Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(o&&o.length<8)throw Error(`@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: ${o}`);if(!d)throw Error('@supabase/auth-js: Invalid SIWE message field "uri". URI must be provided.');if("1"!==f)throw Error(`@supabase/auth-js: Invalid SIWE message field "version". Version must be '1'. Provided value: ${f}`);if(null==(t=e.statement)?void 0:t.includes("\n"))throw Error(`@supabase/auth-js: Invalid SIWE message field "statement". Statement must not include '\\n'. Provided value: ${e.statement}`);let p=n(e.address),m=h?`${h}://${s}`:s,g=e.statement?`${e.statement} 108`:"",y=`${m} wants you to sign in with your Ethereum account: 109${p} 110 111${g}`,b=`URI: ${d} 112Version: ${f} 113Chain ID: ${r}${o?` 114Nonce: ${o}`:""} 115Issued At: ${a.toISOString()}`;if(i&&(b+=` 116Expiration Time: ${i.toISOString()}`),l&&(b+=` 117Not Before: ${l.toISOString()}`),c&&(b+=` 118Request ID: ${c}`),u){let e="\nResources:";for(let t of u){if(!t||"string"!=typeof t)throw Error(`@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: ${t}`);e+=` 119- ${t}`}b+=e}return`${y} 120${b}`}r.d(t,{aD:()=>s,bv:()=>n,nj:()=>i,ob:()=>a})},92647:(e,t,r)=>{"use strict";r.d(t,{$W:()=>f,AQ:()=>l,Bo:()=>h,CT:()=>a,Jj:()=>d,Rn:()=>c,YI:()=>i,a4:()=>s,nf:()=>o,sk:()=>u});var n=r(98914);let s=3e4,i=3,a=9e4,o="http://localhost:9999",l="supabase.auth.token",c={"X-Client-Info":`gotrue-js/${n.r}`},u="X-Supabase-Api-Version",h={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},d=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,f=6e5},98914:(e,t,r)=>{"use strict";r.d(t,{r:()=>n});let n="2.105.4"}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.