PageSourceSearch

https://repedge.ai/_next/static/chunks/17500ed3c77afa36.js?dpl=dpl_8CunUEp7bT4r9s1jCsnfjZdbZDG9

js repedge.ai collected 2026-10-05 12:29:39 UTC 266,112 bytes, 1 lines download raw bytes

1(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,467034,(e,t,r)=>{var n=e.r(115240),s=e.r(368996),i={675:function(e,t){"use strict";t.byteLength=function(e){var t=u(e),r=t[0],n=t[1];return(r+n)*3/4-n},t.toByteArray=function(e){var t,r,i=u(e),a=i[0],o=i[1],c=new s((a+o)*3/4-o),l=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[l++]=t>>16&255,c[l++]=t>>8&255,c[l++]=255&t;return 2===o&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,c[l++]=255&t),1===o&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,c[l++]=t>>8&255,c[l++]=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 u(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 i=r(675),a=r(783),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;function u(e){if(e>0x7fffffff)throw RangeError('The value "'+e+'" is invalid for option "size"');var t=new Uint8Array(e);return Object.setPrototypeOf(t,c.prototype),t}function c(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 f(e)}return l(e,t,r)}function l(e,t,r){if("string"==typeof e){var n=e,i=t;if(("string"!=typeof i||""===i)&&(i="utf8"),!c.isEncoding(i))throw TypeError("Unknown encoding: "+i);var a=0|v(n,i),o=u(a),l=o.write(n,i);return l!==a&&(o=o.slice(0,l)),o}if(ArrayBuffer.isView(e))return d(e);if(null==e)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+(void 0===e?"undefined":s._(e)));if(P(e,ArrayBuffer)||e&&P(e.buffer,ArrayBuffer)||"undefined"!=typeof SharedArrayBuffer&&(P(e,SharedArrayBuffer)||e&&P(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),c.prototype),n}(e,t,r);if("number"==typeof e)throw TypeError('The "value" argument must not be of type number. Received type number');var h=e.valueOf&&e.valueOf();if(null!=h&&h!==e)return c.from(h,t,r);var f=function(e){if(c.isBuffer(e)){var t=0|p(e.length),r=u(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)?u(0):d(e):"Buffer"===e.type&&Array.isArray(e.data)?d(e.data):void 0}(e);if(f)return f;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof e[Symbol.toPrimitive])return c.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 "+(void 0===e?"undefined":s._(e)))}function h(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 f(e){return h(e),u(e<0?0:0|p(e))}function d(e){for(var t=e.length<0?0:0|p(e.length),r=u(t),n=0;n<t;n+=1)r[n]=255&e[n];return r}t.Buffer=c,t.SlowBuffer=function(e){return+e!=e&&(e=0),c.alloc(+e)},t.INSPECT_MAX_BYTES=50,t.kMaxLength=0x7fffffff,c.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}}(),c.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(c.prototype,"parent",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.buffer}}),Object.defineProperty(c.prototype,"offset",{enumerable:!0,get:function(){if(c.isBuffer(this))return this.byteOffset}}),c.poolSize=8192,c.from=function(e,t,r){return l(e,t,r)},Object.setPrototypeOf(c.prototype,Uint8Array.prototype),Object.setPrototypeOf(c,Uint8Array),c.alloc=function(e,t,r){return(
vendor: 15,374 bytes, line 1
1h(e),e<=0)?u(e):void 0!==t?"string"==typeof r?u(e).fill(t,r):u(e).fill(t):u(e)},c.allocUnsafe=function(e){return f(e)},c.allocUnsafeSlow=function(e){return f(e)};function p(e){if(e>=0x7fffffff)throw RangeError("Attempt to allocate Buffer larger than maximum size: 0x7fffffff bytes");return 0|e}function v(e,t){if(c.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||P(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 '+(void 0===e?"undefined":s._(e)));var r=e.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return A(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return I(e).length;default:if(i)return n?-1:A(e).length;t=(""+t).toLowerCase(),i=!0}}function _(e,t,r){var n,s,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+=C[e[i]];return s}(this,t,r);case"utf8":case"utf-8":return m(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 n=this,s=t,a=r,0===s&&a===n.length?i.fromByteArray(n):i.fromByteArray(n.slice(s,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 g(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function y(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=c.from(t,n)),c.isBuffer(t))return 0===t.length?-1:b(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 b(e,[t],r,n,s)}throw TypeError("val must be string, number or Buffer")}function b(e,t,r,n,s){var i,a=1,o=e.length,u=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,u/=2,r/=2}function c(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(s){var l=-1;for(i=r;i<o;i++)if(c(e,i)===c(t,-1===l?0:i-l)){if(-1===l&&(l=i),i-l+1===u)return l*a}else -1!==l&&(i-=i-l),l=-1}else for(r+u>o&&(r=o-u),i=r;i>=0;i--){for(var h=!0,f=0;f<u;f++)if(c(e,i+f)!==c(t,f)){h=!1;break}if(h)return i}return -1}c.isBuffer=function(e){return null!=e&&!0===e._isBuffer&&e!==c.prototype},c.compare=function(e,t){if(P(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),P(t,Uint8Array)&&(t=c.from(t,t.offset,t.byteLength)),!c.isBuffer(e)||!c.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)},c.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}},c.concat=function(e,t){if(!Array.isArray(e))throw TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return c.alloc(0);if(void 0===t)for(r=0,t=0;r<e.length;++r)t+=e[r].length;var r,n=c.allocUnsafe(t),s=0;for(r=0;r<e.length;++r){var i=e[r];if(P(i,Uint8Array)&&(i=c.from(i)),!c.isBuffer(i))throw TypeError('"list" argument must be an Array of Buffers');i.copy(n,s),s+=i.length}return n},c.byteLength=v,c.prototype._isBuffer=!0,c.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)g(this,t,t+1);return this},c.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)g(this,t,t+3),g(this,t+1,t+2);return this},c.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)g(this,t,t+7),g(this,t+1,t+6),g(this,t+2,t+5),g(this,t+3,t+4);return this},c.prototype.toString=function(){var e=this.length;return 0===e?"":0==arguments.length?m(this,0,e):_.apply(this,arguments)},c.prototype.toLocaleString=c.prototype.toString,c.prototype.equals=function(e){if(!c.isBuffer(e))throw TypeError("Argument must be a Buffer");return this===e||0===c.compare(this,e)},c.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+">"},o&&(c.prototype[o]=c.prototype.inspect),c.prototype.compare=function(e,t,r,n,i){if(P(e,Uint8Array)&&(e=c.from(e,e.offset,e.byteLength)),!c.isBuffer(e))throw TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+(void 0===e?"undefined":s._(e)));if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return -1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,i>>>=0,this===e)return 0;for(var a=i-n,o=r-t,u=Math.min(a,o),l=this.slice(n,i),h=e.slice(t,r),f=0;f<u;++f)if(l[f]!==h[f]){a=l[f],o=h[f];break}return a<o?-1:+(o<a)},c.prototype.includes=function(e,t,r){return -1!==this.indexOf(e,t,r)},c.prototype.indexOf=function(e,t,r){return y(this,e,t,r,!0)},c.prototype.lastIndexOf=function(e,t,r){return y(this,e,t,r,!1)};function m(e,t,r){r=Math.min(e.length,r);for(var n=[],s=t;s<r;){var i,a,o,u,c=e[s],l=null,h=c>239?4:c>223?3:c>191?2:1;if(s+h<=r)switch(h){case 1:c<128&&(l=c);break;case 2:(192&(i=e[s+1]))==128&&(u=(31&c)<<6|63&i)>127&&(l=u);break;case 3:i=e[s+1],a=e[s+2],(192&i)==128&&(192&a)==128&&(u=(15&c)<<12|(63&i)<<6|63&a)>2047&&(u<55296||u>57343)&&(l=u);break;case 4:i=e[s+1],a=e[s+2],o=e[s+3],(192&i)==128&&(192&a)==128&&(192&o)==128&&(u=(15&c)<<18|(63&i)<<12|(63&a)<<6|63&o)>65535&&u<1114112&&(l=u)}null===l?(l=65533,h=1):l>65535&&(l-=65536,n.push(l>>>10&1023|55296),l=56320|1023&l),n.push(l),s+=h}var f=n,d=f.length;if(d<=4096)return String.fromCharCode.apply(String,f);for(var p="",v=0;v<d;)p+=String.fromCharCode.apply(String,f.slice(v,v+=4096));return p}function w(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 k(e,t,r,n,s,i){if(!c.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 S(e,t,r,n,s,i){if(r+n>e.length||r<0)throw RangeError("Index out of range")}function E(e,t,r,n,s){return t*=1,r>>>=0,s||S(e,t,r,4,34028234663852886e22,-34028234663852886e22),a.write(e,t,r,n,23,4),r+4}function T(e,t,r,n,s){return t*=1,r>>>=0,s||S(e,t,r,8,17976931348623157e292,-17976931348623157e292),a.write(e,t,r,n,52,8),r+8}c.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,u,c,l,h,f=this.length-t;if((void 0===r||r>f)&&(r=f),e.length>0&&(r<0||t<0)||t>this.length)throw RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var d=!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,u=parseInt(t.substr(2*a,2),16);if((o=u)!=o)break;e[r+a]=u}return a}(this,e,t,r);case"utf8":case"utf-8":return s=t,i=r,j(A(e,this.length-s),this,s,i);case"ascii":return a=t,o=r,j(R(e),this,a,o);case"latin1":case"binary":return function(e,t,r,n){return j(R(t),e,r,n)}(this,e,t,r);case"base64":return u=t,c=r,j(I(e),this,u,c);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return l=t,h=r,j(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-l),this,l,h);default:if(d)throw TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),d=!0}},c.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},c.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,c.prototype),n},c.prototype.readUIntLE=function(e,t,r){e>>>=0,t>>>=0,r||w(e,t,this.length);for(var n=this[e],s=1,i=0;++i<t&&(s*=256);)n+=this[e+i]*s;return n},c.prototype.readUIntBE=function(e,t,r){e>>>=0,t>>>=0,r||w(e,t,this.length);for(var n=this[e+--t],s=1;t>0&&(s*=256);)n+=this[e+--t]*s;return n},c.prototype.readUInt8=function(e,t){return e>>>=0,t||w(e,1,this.length),this[e]},c.prototype.readUInt16LE=function(e,t){return e>>>=0,t||w(e,2,this.length),this[e]|this[e+1]<<8},c.prototype.readUInt16BE=function(e,t){return e>>>=0,t||w(e,2,this.length),this[e]<<8|this[e+1]},c.prototype.readUInt32LE=function(e,t){return e>>>=0,t||w(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+0x1000000*this[e+3]},c.prototype.readUInt32BE=function(e,t){return e>>>=0,t||w(e,4,this.length),0x1000000*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},c.prototype.readIntLE=function(e,t,r){e>>>=0,t>>>=0,r||w(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},c.prototype.readIntBE=function(e,t,r){e>>>=0,t>>>=0,r||w(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},c.prototype.readInt8=function(e,t){return(e>>>=0,t||w(e,1,this.length),128&this[e])?-((255-this[e]+1)*1):this[e]},c.prototype.readInt16LE=function(e,t){e>>>=0,t||w(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?0xffff0000|r:r},c.prototype.readInt16BE=function(e,t){e>>>=0,t||w(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?0xffff0000|r:r},c.prototype.readInt32LE=function(e,t){return e>>>=0,t||w(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},c.prototype.readInt32BE=function(e,t){return e>>>=0,t||w(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},c.prototype.readFloatLE=function(e,t){return e>>>=0,t||w(e,4,this.length),a.read(this,e,!0,23,4)},c.prototype.readFloatBE=function(e,t){return e>>>=0,t||w(e,4,this.length),a.read(this,e,!1,23,4)},c.prototype.readDoubleLE=function(e,t){return e>>>=0,t||w(e,8,this.length),a.read(this,e,!0,52,8)},c.prototype.readDoubleBE=function(e,t){return e>>>=0,t||w(e,8,this.length),a.read(this,e,!1,52,8)},c.prototype.writeUIntLE=function(e,t,r,n){if(e*=1,t>>>=0,r>>>=0,!n){var s=Math.pow(2,8*r)-1;k(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},c.prototype.writeUIntBE=function(e,t,r,n){if(e*=1,t>>>=0,r>>>=0,!n){var s=Math.pow(2,8*r)-1;k(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},c.prototype.writeUInt8=function(e,t,r){return e*=1,t>>>=0,r||k(this,e,t,1,255,0),this[t]=255&e,t+1},c.prototype.writeUInt16LE=function(e,t,r){return e*=1,t>>>=0,r||k(this,e,t,2,65535,0),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeUInt16BE=function(e,t,r){return e*=1,t>>>=0,r||k(this,e,t,2,65535,0),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeUInt32LE=function(e,t,r){return e*=1,t>>>=0,r||k(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},c.prototype.writeUInt32BE=function(e,t,r){return e*=1,t>>>=0,r||k(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},c.prototype.writeIntLE=function(e,t,r,n){if(e*=1,t>>>=0,!n){var s=Math.pow(2,8*r-1);k(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},c.prototype.writeIntBE=function(e,t,r,n){if(e*=1,t>>>=0,!n){var s=Math.pow(2,8*r-1);k(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},c.prototype.writeInt8=function(e,t,r){return e*=1,t>>>=0,r||k(this,e,t,1,127,-128),e<0&&(e=255+e+1),this[t]=255&e,t+1},c.prototype.writeInt16LE=function(e,t,r){return e*=1,t>>>=0,r||k(this,e,t,2,32767,-32768),this[t]=255&e,this[t+1]=e>>>8,t+2},c.prototype.writeInt16BE=function(e,t,r){return e*=1,t>>>=0,r||k(this,e,t,2,32767,-32768),this[t]=e>>>8,this[t+1]=255&e,t+2},c.prototype.writeInt32LE=function(e,t,r){return e*=1,t>>>=0,r||k(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},c.prototype.writeInt32BE=function(e,t,r){return e*=1,t>>>=0,r||k(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},c.prototype.writeFloatLE=function(e,t,r){return E(this,e,t,!0,r)},c.prototype.writeFloatBE=function(e,t,r){return E(this,e,t,!1,r)},c.prototype.writeDoubleLE=function(e,t,r){return T(this,e,t,!0,r)},c.prototype.writeDoubleBE=function(e,t,r){return T(this,e,t,!1,r)},c.prototype.copy=function(e,t,r,n){if(!c.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},c.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&&!c.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=c.isBuffer(e)?e:c.from(e,n),o=a.length;
1if(0===o)throw TypeError('The value "'+e+'" is invalid for argument "value"');for(s=0;s<r-t;++s)this[s+t]=a[s%o]}return this};var O=/[^+/0-9A-Za-z-_]/g;function A(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 R(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}function I(e){return i.toByteArray(function(e){if((e=(e=e.split("=")[0]).trim().replace(O,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function j(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 P(e,t){return n._(e,t)||null!=e&&null!=e.constructor&&null!=e.constructor.name&&e.constructor.name===t.name}var C=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,u=(1<<o)-1,c=u>>1,l=-7,h=r?s-1:0,f=r?-1:1,d=e[t+h];for(h+=f,i=d&(1<<-l)-1,d>>=-l,l+=o;l>0;i=256*i+e[t+h],h+=f,l-=8);for(a=i&(1<<-l)-1,i>>=-l,l+=n;l>0;a=256*a+e[t+h],h+=f,l-=8);if(0===i)i=1-c;else{if(i===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),i-=c}return(d?-1:1)*a*Math.pow(2,i-n)},t.write=function(e,t,r,n,s,i){var a,o,u,c=8*i-s-1,l=(1<<c)-1,h=l>>1,f=5960464477539062e-23*(23===s),d=n?0:i-1,p=n?1:-1,v=+(t<0||0===t&&1/t<0);for(isNaN(t=Math.abs(t))||t===1/0?(o=+!!isNaN(t),a=l):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),a+h>=1?t+=f/u:t+=f*Math.pow(2,1-h),t*u>=2&&(a++,u/=2),a+h>=l?(o=0,a=l):a+h>=1?(o=(t*u-1)*Math.pow(2,s),a+=h):(o=t*Math.pow(2,h-1)*Math.pow(2,s),a=0));s>=8;e[r+d]=255&o,d+=p,o/=256,s-=8);for(a=a<<s|o,c+=s;c>0;e[r+d]=255&a,d+=p,a/=256,c-=8);e[r+d-p]|=128*v}}},a={};function o(e){var t=a[e];if(void 0!==t)return t.exports;var r=a[e]={exports:{}},n=!0;try{i[e](r,r.exports,o),n=!1}finally{n&&delete a[e]}return r.exports}o.ab="/ROOT/node_modules/next/dist/compiled/buffer/",t.exports=o(72)},922459,e=>{"use strict";e.i(247167);var t,r,n,s,i,a,o,u,c,l,h,f,d,p,v,_,g,y,b,m,w,k,S=e.i(991865),E=e.i(38981),T=e.i(292955),O=e.i(780646),A=e.i(64217),R=e.i(540316),I=e.i(296137),j=e.i(302393),P=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"FunctionsError",s=arguments.length>2?arguments[2]:void 0;return(0,T._)(this,t),(r=(0,E._)(this,t,[e])).name=n,r.context=s,r}return(0,A._)(t,e),t}((0,j._)(Error)),C=function(e){function t(e){return(0,T._)(this,t),(0,E._)(this,t,["Failed to send a request to the Edge Function","FunctionsFetchError",e])}return(0,A._)(t,e),t}(P),U=function(e){function t(e){return(0,T._)(this,t),(0,E._)(this,t,["Relay Error invoking the Edge Function","FunctionsRelayError",e])}return(0,A._)(t,e),t}(P),x=function(e){function t(e){return(0,T._)(this,t),(0,E._)(this,t,["Edge Function returned a non-2xx status code","FunctionsHttpError",e])}return(0,A._)(t,e),t}(P);(t=h||(h={})).Any="any",t.ApNortheast1="ap-northeast-1",t.ApNortheast2="ap-northeast-2",t.ApSouth1="ap-south-1",t.ApSoutheast1="ap-southeast-1",t.ApSoutheast2="ap-southeast-2",t.CaCentral1="ca-central-1",t.EuCentral1="eu-central-1",t.EuWest1="eu-west-1",t.EuWest2="eu-west-2",t.EuWest3="eu-west-3",t.SaEast1="sa-east-1",t.UsEast1="us-east-1",t.UsWest1="us-west-1",t.UsWest2="us-west-2";var N=e.i(108487),L=e.i(290571),B=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.headers,s=r.customFetch,i=r.region,a=void 0===i?h.Any:i;(0,T._)(this,e),this.url=t,this.headers=void 0===n?{}:n,this.region=a,this.fetch=s?function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return s.apply(void 0,(0,R._)(t))}:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return fetch.apply(void 0,(0,R._)(t))}}return(0,O._)(e,[{key:"setAuth",value:function(e){this.headers.Authorization="Bearer ".concat(e)}},{key:"invoke",value:function(e){return(0,L.__awaiter)(this,arguments,void 0,function(e){var t,r,n,s,i,a,o,u,c,l,h,f,d,p,v,_,g,y,b,m=arguments;return(0,I._)(this,function(w){switch(w.label){case 0:t=m.length>1&&void 0!==m[1]?m[1]:{},w.label=1;case 1:return w.trys.push([1,12,13,14]),i=t.headers,a=t.method,o=t.body,u=t.signal,c=t.t
1imeout,l={},(h=t.region)||(h=this.region),f=new URL("".concat(this.url,"/").concat(e)),h&&"any"!==h&&(l["x-region"]=h,f.searchParams.set("forceFunctionRegion",h)),o&&(i&&!Object.prototype.hasOwnProperty.call(i,"Content-Type")||!i)?"undefined"!=typeof Blob&&(0,N._)(o,Blob)||(0,N._)(o,ArrayBuffer)?(l["Content-Type"]="application/octet-stream",d=o):"string"==typeof o?(l["Content-Type"]="text/plain",d=o):"undefined"!=typeof FormData&&(0,N._)(o,FormData)?d=o:(l["Content-Type"]="application/json",d=JSON.stringify(o)):d=!o||"string"==typeof o||"undefined"!=typeof Blob&&(0,N._)(o,Blob)||(0,N._)(o,ArrayBuffer)||"undefined"!=typeof FormData&&(0,N._)(o,FormData)?o:JSON.stringify(o),p=u,c&&(s=new AbortController,n=setTimeout(function(){return s.abort()},c),u?(p=s.signal,u.addEventListener("abort",function(){return s.abort()})):p=s.signal),[4,this.fetch(f.toString(),{method:a||"POST",headers:Object.assign(Object.assign(Object.assign({},l),this.headers),i),body:d,signal:p}).catch(function(e){throw new C(e)})];case 2:if((_=(v=w.sent()).headers.get("x-relay-error"))&&"true"===_)throw new U(v);if(!v.ok)throw new x(v);if("application/json"!==(g=(null!=(r=v.headers.get("Content-Type"))?r:"text/plain").split(";")[0].trim()))return[3,4];return[4,v.json()];case 3:case 5:case 8:return y=w.sent(),[3,11];case 4:if("application/octet-stream"!==g&&"application/pdf"!==g)return[3,6];return[4,v.blob()];case 6:if("text/event-stream"!==g)return[3,7];return y=v,[3,11];case 7:if("multipart/form-data"!==g)return[3,9];return[4,v.formData()];case 9:return[4,v.text()];case 10:y=w.sent(),w.label=11;case 11:return[2,{data:y,error:null,response:v}];case 12:return[2,{data:null,error:b=w.sent(),response:(0,N._)(b,x)||(0,N._)(b,U)?b.context:void 0}];case 13:return n&&clearTimeout(n),[7];case 14:return[2]}})})}}]),e}(),D=e.i(651682),q=e.i(500075),M=function(e){function t(e){var r;return(0,T._)(this,t),(r=(0,E._)(this,t,[e.message])).name="PostgrestError",r.details=e.details,r.hint=e.hint,r.code=e.code,r}return(0,A._)(t,e),t}((0,j._)(Error)),K=function(e){function t(){return(0,T._)(this,t),(0,E._)(this,t,arguments)}return(0,A._)(t,e),(0,O._)(t,[{key:"select",value:function(e){var t=!1,r=(null!=e?e:"*").split("").map(function(e){return/\s/.test(e)&&!t?"":('"'===e&&(t=!t),e)}).join("");return this.url.searchParams.set("select",r),this.headers.append("Prefer","return=representation"),this}},{key:"order",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.ascending,n=t.nullsFirst,s=t.foreignTable,i=t.referencedTable,a=void 0===i?s:i,o=a?"".concat(a,".order"):"order",u=this.url.searchParams.get(o);return this.url.searchParams.set(o,"".concat(u?"".concat(u,","):"").concat(e,".").concat(void 0===r||r?"asc":"desc").concat(void 0===n?"":n?".nullsfirst":".nullslast")),this}},{key:"limit",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.foreignTable,n=t.referencedTable,s=void 0===n?r:n;return this.url.searchParams.set(void 0===s?"limit":"".concat(s,".limit"),"".concat(e)),this}},{key:"range",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.foreignTable,s=r.referencedTable,i=void 0===s?n:s,a=void 0===i?"offset":"".concat(i,".offset"),o=void 0===i?"limit":"".concat(i,".limit");return this.url.searchParams.set(a,"".concat(e)),this.url.searchParams.set(o,"".concat(t-e+1)),this}},{key:"abortSignal",value:function(e){return this.signal=e,this}},{key:"single",value:function(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}},{key:"maybeSingle",value:function(){return"GET"===this.method?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}},{key:"csv",value:function(){return this.headers.set("Accept","text/csv"),this}},{key:"geojson",value:function(){return this.headers.set("Accept","application/geo+json"),this}},{key:"explain",value:function(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=t.analyze,n=t.verbose,s=t.settings,i=t.buffers,a=t.wal,o=t.format,u=void 0===o?"text":o,c=[void 0!==r&&r?"analyze":null,void 0!==n&&n?"verbose":null,void 0!==s&&s?"settings":null,void 0!==i&&i?"buffers":null,void 0!==a&&a?"wal":null].filter(
1Boolean).join("|"),l=null!=(e=this.headers.get("Accept"))?e:"application/json";return this.headers.set("Accept","application/vnd.pgrst.plan+".concat(u,'; for="').concat(l,'"; options=').concat(c,";")),this}},{key:"rollback",value:function(){return this.headers.append("Prefer","tx=rollback"),this}},{key:"returns",value:function(){return this}},{key:"maxAffected",value:function(e){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer","max-affected=".concat(e)),this}}]),t}(function(){function e(t){var r,n,s;(0,T._)(this,e),this.shouldThrowOnError=!1,this.method=t.method,this.url=t.url,this.headers=new Headers(t.headers),this.schema=t.schema,this.body=t.body,this.shouldThrowOnError=null!=(r=t.shouldThrowOnError)&&r,this.signal=t.signal,this.isMaybeSingle=null!=(n=t.isMaybeSingle)&&n,this.urlLengthLimit=null!=(s=t.urlLengthLimit)?s:8e3,t.fetch?this.fetch=t.fetch:this.fetch=fetch}return(0,O._)(e,[{key:"throwOnError",value:function(){return this.shouldThrowOnError=!0,this}},{key:"setHeader",value:function(e,t){return this.headers=new Headers(this.headers),this.headers.set(e,t),this}},{key:"then",value:function(e,t){var r=this,n=this;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");var s=(0,this.fetch)(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(function(e){return(0,S._)(function(){var t,r,s,i,a,o,u,c,l,h,f,d,p;return(0,I._)(this,function(v){switch(v.label){case 0:if(t=null,r=null,s=null,i=e.status,a=e.statusText,!e.ok)return[3,3];if("HEAD"===n.method)return[3,2];return[4,e.text()];case 1:""===(l=v.sent())||(r="text/csv"===n.headers.get("Accept")||n.headers.get("Accept")&&(null==(c=n.headers.get("Accept"))?void 0:c.includes("application/vnd.pgrst.plan+text"))?l:JSON.parse(l)),v.label=2;case 2:return h=null==(o=n.headers.get("Prefer"))?void 0:o.match(/count=(exact|planned|estimated)/),f=null==(u=e.headers.get("content-range"))?void 0:u.split("/"),h&&f&&f.length>1&&(s=parseInt(f[1])),n.isMaybeSingle&&"GET"===n.method&&Array.isArray(r)&&(r.length>1?(t={code:"PGRST116",details:"Results contain ".concat(r.length," rows, application/vnd.pgrst.object+json requires 1 row"),hint:null,message:"JSON object requested, multiple (or no) rows returned"},r=null,s=null,i=406,a="Not Acceptable"):r=1===r.length?r[0]:null),[3,5];case 3:return[4,e.text()];case 4:p=v.sent();try{t=JSON.parse(p),Array.isArray(t)&&404===e.status&&(r=[],t=null,i=200,a="OK")}catch(r){404===e.status&&""===p?(i=204,a="No Content"):t={message:p}}if(t&&n.isMaybeSingle&&(null==t||null==(d=t.details)?void 0:d.includes("0 rows"))&&(t=null,i=200,a="OK"),t&&n.shouldThrowOnError)throw new M(t);v.label=5;case 5:return[2,{error:t,data:r,count:s,status:i,statusText:a}]}})})()});return this.shouldThrowOnError||(s=s.catch(function(e){var t,n="",s="",i="",a=null==e?void 0:e.cause;if(a){var o,u,c,l,h,f=null!=(u=null==a?void 0:a.message)?u:"",d=null!=(c=null==a?void 0:a.code)?c:"";n="".concat(null!=(l=null==e?void 0:e.name)?l:"FetchError",": ").concat(null==e?void 0:e.message)+"\n\nCaused by: ".concat(null!=(h=null==a?void 0:a.name)?h:"Error",": ").concat(f),d&&(n+=" (".concat(d,")")),(null==a?void 0:a.stack)&&(n+="\n".concat(a.stack))}else n=null!=(t=null==e?void 0:e.stack)?t:"";var p=r.url.toString().length;return(null==e?void 0:e.name)==="AbortError"||(null==e?void 0:e.code)==="ABORT_ERR"?(i="",s="Request was aborted (timeout or manual cancellation)",p>r.urlLengthLimit&&(s+=". Note: Your request URL is ".concat(p," 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==a?void 0:a.name)==="HeadersOverflowError"||(null==a?void 0:a.code)==="UND_ERR_HEADERS_OVERFLOW")&&(i="",s="HTTP headers exceeded server limits (typically 16KB)",p>r.urlLengthLimit&&(s+=". Your request URL is ".concat(p," 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."))),{error:{message:"".concat(null!=(o=null==e?void 0:e.name)?o:"FetchError",": ").concat(null==e?void 0:e.message),details:n,hint:s,code:i},data:null,count:null,status:0,statusText:""}}
1)),s.then(e,t)}},{key:"returns",value:function(){return this}},{key:"overrideTypes",value:function(){return this}}]),e}()),W=RegExp("[,()]"),F=function(e){function t(){return(0,T._)(this,t),(0,E._)(this,t,arguments)}return(0,A._)(t,e),(0,O._)(t,[{key:"eq",value:function(e,t){return this.url.searchParams.append(e,"eq.".concat(t)),this}},{key:"neq",value:function(e,t){return this.url.searchParams.append(e,"neq.".concat(t)),this}},{key:"gt",value:function(e,t){return this.url.searchParams.append(e,"gt.".concat(t)),this}},{key:"gte",value:function(e,t){return this.url.searchParams.append(e,"gte.".concat(t)),this}},{key:"lt",value:function(e,t){return this.url.searchParams.append(e,"lt.".concat(t)),this}},{key:"lte",value:function(e,t){return this.url.searchParams.append(e,"lte.".concat(t)),this}},{key:"like",value:function(e,t){return this.url.searchParams.append(e,"like.".concat(t)),this}},{key:"likeAllOf",value:function(e,t){return this.url.searchParams.append(e,"like(all).{".concat(t.join(","),"}")),this}},{key:"likeAnyOf",value:function(e,t){return this.url.searchParams.append(e,"like(any).{".concat(t.join(","),"}")),this}},{key:"ilike",value:function(e,t){return this.url.searchParams.append(e,"ilike.".concat(t)),this}},{key:"ilikeAllOf",value:function(e,t){return this.url.searchParams.append(e,"ilike(all).{".concat(t.join(","),"}")),this}},{key:"ilikeAnyOf",value:function(e,t){return this.url.searchParams.append(e,"ilike(any).{".concat(t.join(","),"}")),this}},{key:"regexMatch",value:function(e,t){return this.url.searchParams.append(e,"match.".concat(t)),this}},{key:"regexIMatch",value:function(e,t){return this.url.searchParams.append(e,"imatch.".concat(t)),this}},{key:"is",value:function(e,t){return this.url.searchParams.append(e,"is.".concat(t)),this}},{key:"isDistinct",value:function(e,t){return this.url.searchParams.append(e,"isdistinct.".concat(t)),this}},{key:"in",value:function(e,t){var r=Array.from(new Set(t)).map(function(e){return"string"==typeof e&&W.test(e)?'"'.concat(e,'"'):"".concat(e)}).join(",");return this.url.searchParams.append(e,"in.(".concat(r,")")),this}},{key:"notIn",value:function(e,t){var r=Array.from(new Set(t)).map(function(e){return"string"==typeof e&&W.test(e)?'"'.concat(e,'"'):"".concat(e)}).join(",");return this.url.searchParams.append(e,"not.in.(".concat(r,")")),this}},{key:"contains",value:function(e,t){return"string"==typeof t?this.url.searchParams.append(e,"cs.".concat(t)):Array.isArray(t)?this.url.searchParams.append(e,"cs.{".concat(t.join(","),"}")):this.url.searchParams.append(e,"cs.".concat(JSON.stringify(t))),this}},{key:"containedBy",value:function(e,t){return"string"==typeof t?this.url.searchParams.append(e,"cd.".concat(t)):Array.isArray(t)?this.url.searchParams.append(e,"cd.{".concat(t.join(","),"}")):this.url.searchParams.append(e,"cd.".concat(JSON.stringify(t))),this}},{key:"rangeGt",value:function(e,t){return this.url.searchParams.append(e,"sr.".concat(t)),this}},{key:"rangeGte",value:function(e,t){return this.url.searchParams.append(e,"nxl.".concat(t)),this}},{key:"rangeLt",value:function(e,t){return this.url.searchParams.append(e,"sl.".concat(t)),this}},{key:"rangeLte",value:function(e,t){return this.url.searchParams.append(e,"nxr.".concat(t)),this}},{key:"rangeAdjacent",value:function(e,t){return this.url.searchParams.append(e,"adj.".concat(t)),this}},{key:"overlaps",value:function(e,t){return"string"==typeof t?this.url.searchParams.append(e,"ov.".concat(t)):this.url.searchParams.append(e,"ov.{".concat(t.join(","),"}")),this}},{key:"textSearch",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.config,s=r.type,i="";return"plain"===s?i="pl":"phrase"===s?i="ph":"websearch"===s&&(i="w"),this.url.searchParams.append(e,"".concat(i,"fts").concat(void 0===n?"":"(".concat(n,")"),".").concat(t)),this}},{key:"match",value:function(e){var t=this;return Object.entries(e).forEach(function(e){var r=(0,D._)(e,2),n=r[0],s=r[1];t.url.searchParams.append(n,"eq.".concat(s))}),this}},{key:"not",value:function(e,t,r){return this.url.searchParams.append(e,"not.".concat(t,".").concat(r)),this}},{key:"or",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.foreignTable,n=t.referencedTable,s=void 0===n?r:n;return this.url.searchParams.append(s?"".concat(s,".or"):"or","(".concat(e,")")),this}},{key:"filter",value:function(e,t,r){return this.url.searchParams.append(e,"".concat(t,".").concat(r)),this}}]),t}(K),z=function(){function e(t,r){var n=r.headers,s=r.schema,i=r.fetch,a=r.urlLengthLimit;(0,T._)(this,e),this.url=t,this.headers=new Headers(void 0===n?{}:n),this.schema=s,this.fetch=i,this.urlLengthLimit=void 0===a?8e3:a}return(0,O._)(e,[{key:"cloneRequestState",value:function(){return{url:ne
1w URL(this.url.toString()),headers:new Headers(this.headers)}}},{key:"select",value:function(e,t){var r=null!=t?t:{},n=r.head,s=r.count,i=!1,a=(null!=e?e:"*").split("").map(function(e){return/\s/.test(e)&&!i?"":('"'===e&&(i=!i),e)}).join(""),o=this.cloneRequestState(),u=o.url,c=o.headers;return u.searchParams.set("select",a),s&&c.append("Prefer","count=".concat(s)),new F({method:void 0!==n&&n?"HEAD":"GET",url:u,headers:c,schema:this.schema,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}},{key:"insert",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.count,s=r.defaultToNull,i=this.cloneRequestState(),a=i.url,o=i.headers;if(n&&o.append("Prefer","count=".concat(n)),void 0===s||s||o.append("Prefer","missing=default"),Array.isArray(e)){var u=e.reduce(function(e,t){return e.concat(Object.keys(t))},[]);if(u.length>0){var c=(0,R._)(new Set(u)).map(function(e){return'"'.concat(e,'"')});a.searchParams.set("columns",c.join(","))}}return new F({method:"POST",url:a,headers:o,schema:this.schema,body:e,fetch:null!=(t=this.fetch)?t:fetch,urlLengthLimit:this.urlLengthLimit})}},{key:"upsert",value:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.onConflict,s=r.ignoreDuplicates,i=r.count,a=r.defaultToNull,o=this.cloneRequestState(),u=o.url,c=o.headers;if(c.append("Prefer","resolution=".concat(void 0!==s&&s?"ignore":"merge","-duplicates")),void 0!==n&&u.searchParams.set("on_conflict",n),i&&c.append("Prefer","count=".concat(i)),void 0===a||a||c.append("Prefer","missing=default"),Array.isArray(e)){var l=e.reduce(function(e,t){return e.concat(Object.keys(t))},[]);if(l.length>0){var h=(0,R._)(new Set(l)).map(function(e){return'"'.concat(e,'"')});u.searchParams.set("columns",h.join(","))}}return new F({method:"POST",url:u,headers:c,schema:this.schema,body:e,fetch:null!=(t=this.fetch)?t:fetch,urlLengthLimit:this.urlLengthLimit})}},{key:"update",value:function(e){var t,r=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).count,n=this.cloneRequestState(),s=n.url,i=n.headers;return r&&i.append("Prefer","count=".concat(r)),new F({method:"PATCH",url:s,headers:i,schema:this.schema,body:e,fetch:null!=(t=this.fetch)?t:fetch,urlLengthLimit:this.urlLengthLimit})}},{key:"delete",value:function(){var e,t=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}).count,r=this.cloneRequestState(),n=r.url,s=r.headers;return t&&s.append("Prefer","count=".concat(t)),new F({method:"DELETE",url:n,headers:s,schema:this.schema,fetch:null!=(e=this.fetch)?e:fetch,urlLengthLimit:this.urlLengthLimit})}}]),e}();function J(e){return(J="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 V(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 H(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?V(Object(r),!0).forEach(function(t){!function(e,t,r){var n;(n=function(e,t){if("object"!=J(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=J(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"),(t="symbol"==J(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)):V(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var G=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=r.headers,s=r.schema,i=r.fetch,a=r.timeout,o=r.urlLengthLimit;(0,T._)(this,e),this.url=t,this.headers=new Headers(void 0===n?{}:n),this.schemaName=s,this.urlLengthLimit=void 0===o?8e3:o;var u=null!=i?i:globalThis.fetch;void 0!==a&&a>0?this.fetch=function(e,t){var r=new AbortController,n=setTimeout(function(){return r.abort()},a),s=null==t?void 0:t.signal;if(s){if(s.aborted)return clearTimeout(n),u(e,t);var i=function(){clearTimeout(n),r.abort()};return s.addEventListener("abort",i,{once:!0}),u(e,H(H({},t),{},{signal:r.signal})).finally(function(){clearTimeout(n),s.removeEventListener("abort",i)})}return u(e,H(H({},t),{},{signal:r.signal})).finally(function(){return clearTimeout(n)})}:this.fetch=u}return(0,O._)(e,[{key:"from",value:function(e){if(!e||"string"!=typeof e||""===e.trim())throw Error("Invalid relation name: relation must be a non-empty string.");return new z(new URL("".concat(this.url,"/").concat(e)),{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}},{key:"schema",value:function(t){return new e(this.url,{headers:this.headers,schema:t,fetch:this.fetch,urlLengthLimit:this.urlLengthLimit})}},{key:"rpc",value:function(e){var t,r,n,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}
1,a=i.head,o=void 0!==a&&a,u=i.get,c=i.count,l=new URL("".concat(this.url,"/rpc/").concat(e)),h=function(e){return null!==e&&(void 0===e?"undefined":(0,q._)(e))==="object"&&(!Array.isArray(e)||e.some(h))},f=o&&Object.values(s).some(h);f?(r="POST",n=s):o||void 0!==u&&u?(r=o?"HEAD":"GET",Object.entries(s).filter(function(e){var t=(0,D._)(e,2);return void 0!==(t[0],t[1])}).map(function(e){var t=(0,D._)(e,2),r=t[0],n=t[1];return[r,Array.isArray(n)?"{".concat(n.join(","),"}"):"".concat(n)]}).forEach(function(e){var t=(0,D._)(e,2),r=t[0],n=t[1];l.searchParams.append(r,n)})):(r="POST",n=s);var d=new Headers(this.headers);return f?d.set("Prefer",c?"count=".concat(c,",return=minimal"):"return=minimal"):c&&d.set("Prefer","count=".concat(c)),new F({method:r,url:l,headers:d,schema:this.schemaName,body:n,fetch:null!=(t=this.fetch)?t:fetch,urlLengthLimit:this.urlLengthLimit})}}]),e}(),Y=function(){function t(){(0,T._)(this,t)}return(0,O._)(t,null,[{key:"detectEnvironment",value:function(){if("undefined"!=typeof WebSocket)return{type:"native",constructor:WebSocket};if("undefined"!=typeof globalThis&&void 0!==globalThis.WebSocket)return{type:"native",constructor:globalThis.WebSocket};if(void 0!==e.g.WebSocket)return{type:"native",constructor:e.g.WebSocket};if("undefined"!=typeof globalThis&&void 0!==globalThis.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&&globalThis.EdgeRuntime||"undefined"!=typeof navigator&&(null==(t=navigator.userAgent)?void 0:t.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."};var t,r=globalThis.process;if(r){var n=r.versions;if(n&&n.node){var s=parseInt(n.node.replace(/^v/,"").split(".")[0]);return s>=22?void 0!==globalThis.WebSocket?{type:"native",constructor:globalThis.WebSocket}:{type:"unsupported",error:"Node.js ".concat(s," detected but native WebSocket not found."),workaround:"Provide a WebSocket implementation via the transport option."}:{type:"unsupported",error:"Node.js ".concat(s," 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."}}},{key:"getWebSocketConstructor",value:function(){var e=this.detectEnvironment();if(e.constructor)return e.constructor;var t=e.error||"WebSocket not supported in this environment.";throw e.workaround&&(t+="\n\nSuggested solution: ".concat(e.workaround)),Error(t)}},{key:"createWebSocket",value:function(e,t){return new(this.getWebSocketConstructor())(e,t)}},{key:"isWebSocketSupported",value:function(){try{var e=this.detectEnvironment();return"native"===e.type||"ws"===e.type}catch(e){return!1}}}]),t}(),$="realtime-js/".concat("2.99.1"),X="2.0.0";(r=f||(f={}))[r.connecting=0]="connecting",r[r.open=1]="open",r[r.closing=2]="closing",r[r.closed=3]="closed",(n=d||(d={})).closed="closed",n.errored="errored",n.joined="joined",n.joining="joining",n.leaving="leaving",(s=p||(p={})).close="phx_close",s.error="phx_error",s.join="phx_join",s.reply="phx_reply",s.leave="phx_leave",s.access_token="access_token",(v||(v={})).websocket="websocket",(i=_||(_={})).Connecting="connecting",i.Open="open",i.Closing="closing",i.Closed="closed";var Q=function(){function e(t){(0,T._)(this,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!=t?t:[]}return(0,O._)(e,[{key:"encode",value:function(e,t){return t(e.event!==this.BROADCAST_EVENT||(0,N._)(e.payload,ArrayBuffer)||"string"!=typeof e.payload.event?JSON.stringify([e.join_ref,e.ref,e.topic,e.event,e.payload]):this._binaryEncodeUserBroadcastPush(e))}},{key:"_binaryEncodeUserBroadcastPush",value:function(e){var t;return this._isArrayBuffer(null==(t=e.payload)?void 0:t.payload)?this._encodeBinaryUserBroadcastPush(e):this._encodeJsonUserBroadcastPush(e)}},{key:"_encodeBinaryUserBroadcastPush",value:function(e){var t,r,n=null!=(r=null==(t=e.payload)?void 0:t.payload)?r:new ArrayBuffer(0);return this._encodeUserBroadcastPush(e,this.BINARY_ENCODING,n)}},{key:"_encodeJsonUserBroadcastPush",value:function(e){var t,r,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)}},{key:"_encodeUserBroadcastPush",value:function(e,t,r){var n,s,i=e.topic,a=null!=(n=e.ref)?n:"",o=null!=(s=e.join_ref)?s:"",u=e.payload.event,c=this.allowedMetadataKeys?this._pick(e.payload,this.allowedMetadataKeys):{},l=0===Object.keys(c).length?"":JSON.stringify(c);if(o.length>255)throw Error("joinRef length ".concat(o.length," exceeds maximum of 255"));if(a.length>255)throw Error("ref length ".concat(a.length," exceeds maximum of 255"));if(i.length>255)throw Error("topic length ".concat(i.length," exceeds maximum of 255"));if(u.length>255)throw Error("userEvent length ".concat(u.length," exceeds maximum of 255"));if(l.length>255)throw Error("metadata length ".concat(l.length," exceeds maximum of 255"));var h=this.USER_BROADCAST_PUSH_META_LENGTH+o.length+a.length+i.length+u.length+l.length,f=new ArrayBuffer(this.HEADER_LENGTH+h),d=new DataView(f),p=0;d.setUint8(p++,this.KINDS.userBroadcastPush),d.setUint8(p++,o.length),d.setUint8(p++,a.length),d.setUint8(p++,i.length),d.setUint8(p++,u.length),d.setUint8(p++,l.length),d.setUint8(p++,t),Array.from(o,function(e){return d.setUint8(p++,e.charCodeAt(0))}),Array.from(a,function(e){return d.setUint8(p++,e.charCodeAt(0))}),Array.from(i,function(e){return d.setUint8(p++,e.charCodeAt(0))}),Array.from(u,function(e){return d.setUint8(p++,e.charCodeAt(0))}),Array.from(l,function(e){return d.setUint8(p++,e.charCodeAt(0))});var v=new Uint8Array(f.byteLength+r.byteLength);return v.set(new Uint8Array(f),0),v.set(new Uint8Array(r),f.byteLength),v.buffer}},{key:"decode",value:function(e,t){if(this._isArrayBuffer(e))return t(this._binaryDecode(e));if("string"==typeof e){var r=JSON.parse(e),n=(0,D._)(r,5);return t({join_ref:n[0],ref:n[1],topic:n[2],event:n[3],payload:n[4]})}return t({})}},{key:"_binaryDecode",value:function(e){var t=new DataView(e),r=t.getUint8(0),n=new TextDecoder;if(r===this.KINDS.userBroadcast)return this._decodeUserBroadcast(e,t,n)}},{key:"_decodeUserBroadcast",value:function(e,t,r){var n=t.getUint8(1),s=t.getUint8(2),i=t.getUint8(3),a=t.getUint8(4),o=this.HEADER_LENGTH+4,u=r.decode(e.slice(o,o+n));o+=n;var c=r.decode(e.slice(o,o+s));o+=s;var l=r.decode(e.slice(o,o+i));o+=i;var h=e.slice(o,e.byteLength),f=a===this.JSON_ENCODING?JSON.parse(r.decode(h)):h,d={type:this.BROADCAST_EVENT,event:c,payload:f};return i>0&&(d.meta=JSON.parse(l)),{join_ref:null,ref:null,topic:u,event:this.BROADCAST_EVENT,payload:d}}},{key:"_isArrayBuffer",value:function(e){var t;return(0,N._)(e,ArrayBuffer)||(null==(t=null==e?void 0:e.constructor)?void 0:t.name)==="ArrayBuffer"}},{key:"_pick",value:function(e,t){return e&&(void 0===e?"undefined":(0,q._)(e))==="object"?Object.fromEntries(Object.entries(e).filter(function(e){var r=(0,D._)(e,1)[0];return t.includes(r)})):{}}}]),e}(),Z=function(){function e(t,r){(0,T._)(this,e),this.callback=t,this.timerCalc=r,this.timer=void 0,this.tries=0,this.callback=t,this.timerCalc=r}return(0,O._)(e,[{key:"reset",value:function(){this.tries=0,clearTimeout(this.timer),this.timer=void 0}},{key:"scheduleTimeout",value:function(){var e=this;clearTimeout(this.timer),this.timer=setTimeout(function(){e.tries=e.tries+1,e.callback()},this.timerCalc(this.tries+1))}}]),e}();(a=g||(g={})).abstime="abstime",a.bool="bool",a.date="date",a.daterange="daterange",a.float4="float4",a.float8="float8",a.int2="int2",a.int4="int4",a.int4range="int4range",a.int8="int8",a.int8range="int8range",a.json="json",a.jsonb="jsonb",a.money="money",a.numeric="numeric",a.oid="oid",a.reltime="reltime",a.text="text",a.time="time",a.timestamp="timestamp",a.timestamptz="timestamptz",a.timetz="timetz",a.tsrange="tsrange",a.tstzrange="tstzrange";var ee=function(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=null!=(r=n.skipTypes)?r:[];return t?Object.keys(t).reduce(function(r,n){return r[n]=et(n,e,t,s),r},{}):{}},et=function(e,t,r,n){var s=t.find(function(t){return t.name===e}),i=null==s?void 0:s.type,a=r[e];return i&&!n.includes(i)?er(i,a):en(a)},er=function(e,t){if("_"===e.charAt(0))return eo(t,e.slice(1,e.length));switch(e){case g.bool:return es(t);case g.float4:case g.float8:case g.int2:case g.int4:case g.int8:case g.numeric:case g.oid:return ei(t);case g.json:case g.jsonb:return ea(t);case g.timestamp:return eu(t);case g.abstime:case g.date:case g.daterange:case g.int4range:case g.int8range:case g.money:case g.reltime:case g.text:case g.time:case g.timestamptz:case g.timetz:case g.tsrange:case g.tstzrange:default:return en(t)}},en=function(e){return e},es=function(e){switch(e){case"t":return!0;case"f":return!1;default:return e}},ei=function(e){if("string"==typeof e){var t=parseFloat(e);
1if(!Number.isNaN(t))return t}return e},ea=function(e){if("string"==typeof e)try{return JSON.parse(e)}catch(e){}return e},eo=function(e,t){if("string"!=typeof e)return e;var r=e.length-1,n=e[r];if("{"===e[0]&&"}"===n){var s,i=e.slice(1,r);try{s=JSON.parse("["+i+"]")}catch(e){s=i?i.split(","):[]}return s.map(function(e){return er(t,e)})}return e},eu=function(e){return"string"==typeof e?e.replace(" ","T"):e},ec=function(e){var 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},el=function(){function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1e4;(0,T._)(this,e),this.channel=t,this.event=r,this.payload=n,this.timeout=s,this.sent=!1,this.timeoutTimer=void 0,this.ref="",this.receivedResp=null,this.recHooks=[],this.refEvent=null}return(0,O._)(e,[{key:"resend",value:function(e){this.timeout=e,this._cancelRefEvent(),this.ref="",this.refEvent=null,this.receivedResp=null,this.sent=!1,this.send()}},{key:"send",value:function(){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()}))}},{key:"updatePayload",value:function(e){this.payload=Object.assign(Object.assign({},this.payload),e)}},{key:"receive",value:function(e,t){var r;return this._hasReceived(e)&&t(null==(r=this.receivedResp)?void 0:r.response),this.recHooks.push({status:e,callback:t}),this}},{key:"startTimeout",value:function(){var e=this;this.timeoutTimer||(this.ref=this.channel.socket._makeRef(),this.refEvent=this.channel._replyEventName(this.ref),this.channel._on(this.refEvent,{},function(t){e._cancelRefEvent(),e._cancelTimeout(),e.receivedResp=t,e._matchReceive(t)}),this.timeoutTimer=setTimeout(function(){e.trigger("timeout",{})},this.timeout))}},{key:"trigger",value:function(e,t){this.refEvent&&this.channel._trigger(this.refEvent,{status:e,response:t})}},{key:"destroy",value:function(){this._cancelRefEvent(),this._cancelTimeout()}},{key:"_cancelRefEvent",value:function(){this.refEvent&&this.channel._off(this.refEvent,{})}},{key:"_cancelTimeout",value:function(){clearTimeout(this.timeoutTimer),this.timeoutTimer=void 0}},{key:"_matchReceive",value:function(e){var t=e.status,r=e.response;this.recHooks.filter(function(e){return e.status===t}).forEach(function(e){return e.callback(r)})}},{key:"_hasReceived",value:function(e){return this.receivedResp&&this.receivedResp.status===e}}]),e}();(o=y||(y={})).SYNC="sync",o.JOIN="join",o.LEAVE="leave";var eh=function(){function e(t,r){var n=this;(0,T._)(this,e),this.channel=t,this.state={},this.pendingDiffs=[],this.joinRef=null,this.enabled=!1,this.caller={onJoin:function(){},onLeave:function(){},onSync:function(){}};var s=(null==r?void 0:r.events)||{state:"presence_state",diff:"presence_diff"};this.channel._on(s.state,{},function(t){var r=n.caller,s=r.onJoin,i=r.onLeave,a=r.onSync;n.joinRef=n.channel._joinRef(),n.state=e.syncState(n.state,t,s,i),n.pendingDiffs.forEach(function(t){n.state=e.syncDiff(n.state,t,s,i)}),n.pendingDiffs=[],a()}),this.channel._on(s.diff,{},function(t){var r=n.caller,s=r.onJoin,i=r.onLeave,a=r.onSync;n.inPendingSyncState()?n.pendingDiffs.push(t):(n.state=e.syncDiff(n.state,t,s,i),a())}),this.onJoin(function(e,t,r){n.channel._trigger("presence",{event:"join",key:e,currentPresences:t,newPresences:r})}),this.onLeave(function(e,t,r){n.channel._trigger("presence",{event:"leave",key:e,currentPresences:t,leftPresences:r})}),this.onSync(function(){n.channel._trigger("presence",{event:"sync"})})}return(0,O._)(e,[{key:"onJoin",value:function(e){this.caller.onJoin=e}},{key:"onLeave",value:function(e){this.caller.onLeave=e}},{key:"onSync",value:function(e){this.caller.onSync=e}},{key:"inPendingSyncState",value:function(){return!this.joinRef||this.joinRef!==this.channel._joinRef()}}],[{key:"syncState",value:function(e,t,r,n){var s=this.cloneDeep(e),i=this.transformState(t),a={},o={};return this.map(s,function(e,t){i[e]||(o[e]=t)}),this.map(i,function(e,t){var r=s[e];if(r){var n=t.map(function(e){return e.presence_ref}),i=r.map(function(e){return e.presence_ref}),u=t.filter(function(e){return 0>i.indexOf(e.presence_ref)}),c=r.filter(function(e){return 0>n.indexOf(e.presence_ref)});u.length>0&&(a[e]=u),c.length>0&&(o[e]=c)}else a[e]=t}),this.syncDiff(s,{joins:a,leaves:o}
1,r,n)}},{key:"syncDiff",value:function(e,t,r,n){var s=this,i={joins:this.transformState(t.joins),leaves:this.transformState(t.leaves)},a=i.joins,o=i.leaves;return r||(r=function(){}),n||(n=function(){}),this.map(a,function(t,n){var i=null!=(a=e[t])?a:[];if(e[t]=s.cloneDeep(n),i.length>0){var a,o,u=e[t].map(function(e){return e.presence_ref}),c=i.filter(function(e){return 0>u.indexOf(e.presence_ref)});(o=e[t]).unshift.apply(o,(0,R._)(c))}r(t,i,n)}),this.map(o,function(t,r){var s=e[t];if(s){var i=r.map(function(e){return e.presence_ref});s=s.filter(function(e){return 0>i.indexOf(e.presence_ref)}),e[t]=s,n(t,s,r),0===s.length&&delete e[t]}}),e}},{key:"map",value:function(e,t){return Object.getOwnPropertyNames(e).map(function(r){return t(r,e[r])})}},{key:"transformState",value:function(e){return Object.getOwnPropertyNames(e=this.cloneDeep(e)).reduce(function(t,r){var n=e[r];return"metas"in n?t[r]=n.metas.map(function(e){return e.presence_ref=e.phx_ref,delete e.phx_ref,delete e.phx_ref_prev,e}):t[r]=n,t},{})}},{key:"cloneDeep",value:function(e){return JSON.parse(JSON.stringify(e))}}]),e}();(u=b||(b={})).ALL="*",u.INSERT="INSERT",u.UPDATE="UPDATE",u.DELETE="DELETE",(c=m||(m={})).BROADCAST="broadcast",c.PRESENCE="presence",c.POSTGRES_CHANGES="postgres_changes",c.SYSTEM="system",(l=w||(w={})).SUBSCRIBED="SUBSCRIBED",l.TIMED_OUT="TIMED_OUT",l.CLOSED="CLOSED",l.CHANNEL_ERROR="CHANNEL_ERROR";var ef=function(){function e(t){var r,n,s=this,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{config:{}},a=arguments.length>2?arguments[2]:void 0;if((0,T._)(this,e),this.topic=t,this.params=i,this.socket=a,this.bindings={},this.state=d.closed,this.joinedOnce=!1,this.pushBuffer=[],this.subTopic=t.replace(/^realtime:/i,""),this.params.config=Object.assign({broadcast:{ack:!1,self:!1},presence:{key:"",enabled:!1},private:!1},i.config),this.timeout=this.socket.timeout,this.joinPush=new el(this,p.join,this.params,this.timeout),this.rejoinTimer=new Z(function(){return s._rejoinUntilConnected()},this.socket.reconnectAfterMs),this.joinPush.receive("ok",function(){s.state=d.joined,s.rejoinTimer.reset(),s.pushBuffer.forEach(function(e){return e.send()}),s.pushBuffer=[]}),this._onClose(function(){s.rejoinTimer.reset(),s.socket.log("channel","close ".concat(s.topic," ").concat(s._joinRef())),s.state=d.closed,s.socket._remove(s)}),this._onError(function(e){s._isLeaving()||s._isClosed()||(s.socket.log("channel","error ".concat(s.topic),e),s.state=d.errored,s.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("timeout",function(){s._isJoining()&&(s.socket.log("channel","timeout ".concat(s.topic),s.joinPush.timeout),s.state=d.errored,s.rejoinTimer.scheduleTimeout())}),this.joinPush.receive("error",function(e){s._isLeaving()||s._isClosed()||(s.socket.log("channel","error ".concat(s.topic),e),s.state=d.errored,s.rejoinTimer.scheduleTimeout())}),this._on(p.reply,{},function(e,t){s._trigger(s._replyEventName(t),e)}),this.presence=new eh(this),this.broadcastEndpointURL=ec(this.socket.endPoint),this.private=this.params.config.private||!1,!this.private&&(null==(n=null==(r=this.params.config)?void 0:r.broadcast)?void 0:n.replay))throw"tried to use replay on public channel '".concat(this.topic,"'. It must be a private channel.")}return(0,O._)(e,[{key:"subscribe",value:function(t){var r,n,s,i=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.timeout;if(this.socket.isConnected()||this.socket.connect(),this.state==d.closed){var o=this.params.config,u=o.broadcast,c=o.presence,l=o.private,h=null!=(n=null==(r=this.bindings.postgres_changes)?void 0:r.map(function(e){return e.filter}))?n:[],f=!!this.bindings[m.PRESENCE]&&this.bindings[m.PRESENCE].length>0||(null==(s=this.params.config.presence)?void 0:s.enabled)===!0,p={},v={broadcast:u,presence:Object.assign(Object.assign({},c),{enabled:f}),postgres_changes:h,private:l};this.socket.accessTokenValue&&(p.access_token=this.socket.accessTokenValue),this._onError(function(e){return null==t?void 0:t(w.CHANNEL_ERROR,e)}),this._onClose(function(){return null==t?void 0:t(w.CLOSED)}),this.updateJoinPayload(Object.assign({config:v},p)),this.joinedOnce=!0,this._rejoin(a),this.joinPush.receive("ok",function(r){var n=r.postgres_changes;return(0,S._)(function(){var r,s,i,a,o,u,c,l,h,f,p,v;return(0,I._)(this,function(_){if(this.socket._isManualToken()||this.socket.setAuth(),void 0===n)return null==t||t(w.SUBSCRIBED),[2];for(o=0,i=null!=(r=null==(s=this.bindings.postgres_changes)?void 0:s.length)?r:0,a=[];o<i;o++){if(l=(c=(u=s[o]).filter).event,h=c.schema,f=c.table,p=c.filter,!((v=n&&n[o])&&v.event===l&&e.isFilterValueEqual(v.schema,h)&&e.isFilterValueEqual(v.table,f)&&e.isFilterValueEqual(v.filter,p)))return this.unsubscribe(),this.state=d.errored,null==t||t(w.CHANNEL_ERROR,Error("mismatch between server and client bindings for postgres changes")),[2];a.push(Object.assign(Object.assign({},u),{id:v.id}))}return this.bindings.postgres_changes=a,t&&t(w.SUBSCRIBED),[2]})}).call(i)}).receive("error",function(e){i.state=d.errored,null==t||t(w.CHANNEL_ERROR,Error(JSON.stringify(Object.values(e).join(", ")||"error")))}).receive("timeout",function(){null==t||t(w.TIMED_OUT)})}return this}},{key:"presenceState",value:function(){return this.presence.state}},{key:"track",value:function(e){return(0,S._)(function(e){var t,r=arguments;return(0,I._)(this,function(n){switch(n.label){case 0:return t=r.length>1&&void 0!==r[1]?r[1]:{},[4,this.send({type:"presence",event:"track",payload:e},t.timeout||this.timeout)];case 1:return[2,n.sent()]}})}).apply(this,arguments)}},{key:"untrack",value:function(){return(0,S._)(function(){var e,t=arguments;return(0,I._)(this,function(r){switch(r.label){case 0:return e=t.length>0&&void 0!==t[0]?t[0]:{},[4,this.send({type:"presence",event:"untrack"},e)];case 1:return[2,r.sent()]}})}).apply(this,arguments)}},{key:"on",value:function(e,t,r){var n=this;return this.state===d.joined&&e===m.PRESENCE&&(this.socket.log("channel","resubscribe to ".concat(this.topic," due to change in presence callbacks on joined channel")),this.unsubscribe().then(function(){return(0,S._)(function(){return(0,I._)(this,function(e){switch(e.label){case 0:return[4,this.subscribe()];case 1:return[2,e.sent()]}})}).call(n)})),this._on(e,t,r)}},{key:"httpSend",value:function(e,t){return(0,S._)(function(e,t){var r,n,s,i,a,o,u,c=arguments;return(0,I._)(this,function(l){switch(l.label){case 0:if(r=c.length>2&&void 0!==c[2]?c[2]:{},null==t)return[2,Promise.reject("Payload is required for httpSend()")];return s={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},this.socket.accessTokenValue&&(s.Authorization="Bearer ".concat(this.socket.accessTokenValue)),i={method:"POST",headers:s,body:JSON.stringify({messages:[{topic:this.subTopic,event:e,payload:t,private:this.private}]})},[4,this._fetchWithTimeout(this.broadcastEndpointURL,i,null!=(n=r.timeout)?n:this.timeout)];case 1:if(202===(a=l.sent()).status)return[2,{success:!0}];o=a.statusText,l.label=2;case 2:return l.trys.push([2,4,,5]),[4,a.json()];case 3:return o=(u=l.sent()).error||u.message||o,[3,5];case 4:return l.sent(),[3,5];case 5:return[2,Promise.reject(Error(o))]}})}).apply(this,arguments)}},{key:"send",value:function(e){return(0,S._)(function(e){var t,r,n,s,i,a,o,u,c,l=arguments;return(0,I._)(this,function(h){switch(h.label){case 0:if(t=this,r=l.length>1&&void 0!==l[1]?l[1]:{},!(!this._canPush()&&"broadcast"===e.type))return[3,6];console.warn("Realtime send() is automatically falling back to REST API. This behavior will be deprecated 
1in the future. Please use httpSend() explicitly for REST delivery."),i=e.event,a=e.payload,o={apikey:this.socket.apiKey?this.socket.apiKey:"","Content-Type":"application/json"},this.socket.accessTokenValue&&(o.Authorization="Bearer ".concat(this.socket.accessTokenValue)),u={method:"POST",headers:o,body:JSON.stringify({messages:[{topic:this.subTopic,event:i,payload:a,private:this.private}]})},h.label=1;case 1:return h.trys.push([1,4,,5]),[4,this._fetchWithTimeout(this.broadcastEndpointURL,u,null!=(n=r.timeout)?n:this.timeout)];case 2:return[4,null==(s=(c=h.sent()).body)?void 0:s.cancel()];case 3:return h.sent(),[2,c.ok?"ok":"error"];case 4:if("AbortError"===h.sent().name)return[2,"timed out"];return[2,"error"];case 5:return[3,7];case 6:return[2,new Promise(function(n){var s,i,a,o=t._push(e.type,e,r.timeout||t.timeout);"broadcast"!==e.type||(null==(a=null==(i=null==(s=t.params)?void 0:s.config)?void 0:i.broadcast)?void 0:a.ack)||n("ok"),o.receive("ok",function(){return n("ok")}),o.receive("error",function(){return n("error")}),o.receive("timeout",function(){return n("timed out")})})];case 7:return[2]}})}).apply(this,arguments)}},{key:"updateJoinPayload",value:function(e){this.joinPush.updatePayload(e)}},{key:"unsubscribe",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.timeout;this.state=d.leaving;var r=function(){e.socket.log("channel","leave ".concat(e.topic)),e._trigger(p.close,"leave",e._joinRef())};this.joinPush.destroy();var n=null;return new Promise(function(s){(n=new el(e,p.leave,{},t)).receive("ok",function(){r(),s("ok")}).receive("timeout",function(){r(),s("timed out")}).receive("error",function(){s("error")}),n.send(),e._canPush()||n.trigger("ok",{})}).finally(function(){null==n||n.destroy()})}},{key:"teardown",value:function(){this.pushBuffer.forEach(function(e){return e.destroy()}),this.pushBuffer=[],this.rejoinTimer.reset(),this.joinPush.destroy(),this.state=d.closed,this.bindings={}}},{key:"_fetchWithTimeout",value:function(e,t,r){return(0,S._)(function(){var n,s,i;return(0,I._)(this,function(a){switch(a.label){case 0:return n=new AbortController,s=setTimeout(function(){return n.abort()},r),[4,this.socket.fetch(e,Object.assign(Object.assign({},t),{signal:n.signal}))];case 1:return i=a.sent(),clearTimeout(s),[2,i]}})}).call(this)}},{key:"_push",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.timeout;if(!this.joinedOnce)throw"tried to push '".concat(e,"' to '").concat(this.topic,"' before joining. Use channel.subscribe() before pushing events");var n=new el(this,e,t,r);return this._canPush()?n.send():this._addToPushBuffer(n),n}},{key:"_addToPushBuffer",value:function(e){if(e.startTimeout(),this.pushBuffer.push(e),this.pushBuffer.length>100){var t=this.pushBuffer.shift();t&&(t.destroy(),this.socket.log("channel","discarded push due to buffer overflow: ".concat(t.event),t.payload))}}},{key:"_onMessage",value:function(e,t,r){return t}},{key:"_isMember",value:function(e){return this.topic===e}},{key:"_joinRef",value:function(){return this.joinPush.ref}},{key:"_trigger",value:function(e,t,r){var n,s,i=this,a=e.toLocaleLowerCase(),o=p.close,u=p.error,c=p.leave,l=p.join;if(!(r&&[o,u,c,l].indexOf(a)>=0)||r===this._joinRef()){var h=this._onMessage(a,t,r);if(t&&!h)throw"channel onMessage callbacks must return the payload, modified or unmodified";["insert","update","delete"].includes(a)?null==(n=this.bindings.postgres_changes)||n.filter(function(e){var t,r,n;return(null==(t=e.filter)?void 0:t.event)==="*"||(null==(n=null==(r=e.filter)?void 0:r.event)?void 0:n.toLocaleLowerCase())===a}).map(function(e){return e.callback(h,r)}):null==(s=this.bindings[a])||s.filter(function(e){if(!["broadcast","presence","postgres_changes"].includes(a))return e.type.toLocaleLowerCase()===a;if("id"in e){var r,n,s,i,o,u,c=e.id,l=null==(r=e.filter)?void 0:r.event;return c&&(null==(n=t.ids)?void 0:n.includes(c))&&("*"===l||(null==l?void 0:l.toLocaleLowerCase())===(null==(s=t.data)?void 0:s.type.toLocaleLowerCase()))}var h=null==(o=null==(i=null==e?void 0:e.filter)?void 0:i.event)?void 0:o.toLocaleLowerCase();return"*"===h||h===(null==(u=null==t?void 0:t.event)?void 0:u.toLocaleLowerCase())}).map(function(e){if((void 0===h?"undefined":(0,q._)(h))==="object"&&"ids"in h){var t=h.data;h=Object.assign(Object.assign({},{schema:t.schema,table:t.table,commit_timestamp:t.commit_timestamp,eventType:t.type,new:{},old:{},errors:t.errors}),i._getPayloadRecords(t))}e.callback(h,r)})}}},{key:"_isClosed",value:function(){return this.state===d.closed}},{key:"_isJoined",value:function(){return this.state===d.joined}},{key:"_isJoining",value:function(){return this.state===d.joining}},{key:"_isLeaving",value:function(){return this.state===d.leaving}},{key:"_replyEventName",value:function(e){return"chan_reply_".concat(e)}},{key:"_on",value:function(e,t,r){var n=e.toLocaleLowerCase(),s={type:n,filter:t,callback:r};return this.bindings[n]?this.bindings[n].push(s):this.bindings[n]=[s],this}},{key:"_off",value:function(t,r){var n=t.toLocaleLowerCase();return this.bindings[n]&&(this.bindings[n]=this.bindings[n].filter(function(t){var s;return!((null==(s=t.type)?void 0:s.toLocaleLowerCase())===n&&e.isEqual(t.filter,r))})),this}},{key:"_rejoinUntilConnected",value:function(){this.rejoinTimer.scheduleTimeout(),this.socket.isConnected()&&this._rejoin()}},{key:"_onClose",value:function(e){this._on(p.close,{},e)}},{key:"_onError",value:function(e){this._on(p.error,{},function(t){return e(t)})}},{key:"_canPush",value:function(){return this.socket.isConnected()&&this._isJoined()}},{key:"_rejoin",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.timeout;this._isLeaving()||(this.socket._leaveOpenTopic(this.topic),this.state=d.joining,this.joinPush.resend(e))}},{key:"_getPayloadRecords",value:function(e){var t={new:{},old:{}};return("INSERT"===e.type||"UPDATE"===e.type)&&(t.new=ee(e.columns,e.record)),("UPDATE"===e.type||"DELET
1E"===e.type)&&(t.old=ee(e.columns,e.old_record)),t}}],[{key:"isEqual",value:function(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(var r in e)if(e[r]!==t[r])return!1;return!0}},{key:"isFilterValueEqual",value:function(e,t){return(null!=e?e:void 0)===(null!=t?t:void 0)}}]),e}(),ed=function(){},ep=[1e3,2e3,5e3,1e4],ev=function(){function e(t,r){var n;if((0,T._)(this,e),this.accessTokenValue=null,this.apiKey=null,this._manuallySetToken=!1,this.channels=[],this.endPoint="",this.httpEndpoint="",this.headers={},this.params={},this.timeout=1e4,this.transport=null,this.heartbeatIntervalMs=25e3,this.heartbeatTimer=void 0,this.pendingHeartbeatRef=null,this.heartbeatCallback=ed,this.ref=0,this.reconnectTimer=null,this.vsn=X,this.logger=ed,this.conn=null,this.sendBuffer=[],this.serializer=new Q,this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.accessToken=null,this._connectionState="disconnected",this._wasManualDisconnect=!1,this._authPromise=null,this._heartbeatSentAt=null,this._resolveFetch=function(e){return e?function(){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];return e.apply(void 0,(0,R._)(r))}:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return fetch.apply(void 0,(0,R._)(t))}},!(null==(n=null==r?void 0:r.params)?void 0:n.apikey))throw Error("API key is required to connect to Realtime");this.apiKey=r.params.apikey,this.endPoint="".concat(t,"/").concat(v.websocket),this.httpEndpoint=ec(t),this._initializeOptions(r),this._setupReconnectionTimer(),this.fetch=this._resolveFetch(null==r?void 0:r.fetch)}return(0,O._)(e,[{key:"connect",value:function(){if(!(this.isConnecting()||this.isDisconnecting()||null!==this.conn&&this.isConnected())){if(this._setConnectionState("connecting"),this.accessToken&&!this._authPromise&&this._setAuthSafely("connect"),this.transport)this.conn=new this.transport(this.endpointURL());else try{this.conn=Y.createWebSocket(this.endpointURL())}catch(t){this._setConnectionState("disconnected");var e=t.message;if(e.includes("Node.js"))throw Error("".concat(e,"\n\n")+'To use Realtime in Node.js, you need to provide a WebSocket implementation:\n\nOption 1: Use Node.js 22+ which has native WebSocket support\nOption 2: Install and provide the "ws" package:\n\n  npm install ws\n\n  import ws from "ws"\n  const client = new RealtimeClient(url, {\n    ...options,\n    transport: ws\n  })');throw Error("WebSocket not available: ".concat(e))}this._setupConnectionHandlers()}}},{key:"endpointURL",value:function(){return this._appendParams(this.endPoint,Object.assign({},this.params,{vsn:this.vsn}))}},{key:"disconnect",value:function(e,t){var r=this;if(!this.isDisconnecting())if(this._setConnectionState("disconnecting",!0),this.conn){var n=setTimeout(function(){r._setConnectionState("disconnected")},100);this.conn.onclose=function(){clearTimeout(n),r._setConnectionState("disconnected")},"function"==typeof this.conn.close&&(e?this.conn.close(e,null!=t?t:""):this.conn.close()),this._teardownConnection()}else this._setConnectionState("disconnected")}},{key:"getChannels",value:function(){return this.channels}},{key:"removeChannel",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){switch(r.label){case 0:return[4,e.unsubscribe()];case 1:return t=r.sent(),0===this.channels.length&&this.disconnect(),[2,t]}})}).call(this)}},{key:"removeAllChannels",value:function(){return(0,S._)(function(){var e;return(0,I._)(this,function(t){switch(t.label){case 0:return[4,Promise.all(this.channels.map(function(e){return e.unsubscribe()}))];case 1:return e=t.sent(),this.channels=[],this.disconnect(),[2,e]}})}).call(this)}},{key:"log",value:function(e,t,r){this.logger(e,t,r)}},{key:"connectionState",value:function(){switch(this.conn&&this.conn.readyState){case f.connecting:return _.Connecting;case f.open:return _.Open;case f.closing:return _.Closing;default:return _.Closed}}},{key:"isConnected",value:function(){return this.connectionState()===_.Open}},{key:"isConnecting",value:function(){return"connecting"===this._connectionState}},{key:"isDisconnecting",value:function(){return"disconnecting"===this._connectionState}},{key:"channel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{config:{}},r="realtime:".concat(e),n=this.getChannels().find(function(e){return e.topic===r});if(n)return n;var s=new ef("realtime:".concat(e),t,this);return this.channels.push(s),s}},{key:"push",value:function(e){var t=this,r=e.topic,n=e.event,s=e.payload,i=e.ref,a=function(){t.encode(e,function(e){var r;null==(r=t.conn)||r.send(e)})};this.log("push","".concat(r," ").concat(n," (").concat(i,")"),s),this.isConnected()?a():this.sendBuffer.push(a)}},{key:"setAuth",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return(0,S._)(function(){return(0,I._)(this,function(t){switch(t.label){case 0:this._authPromise=this._performAuth(e),t.label=1;case 1:return t.trys.push([1,,3,4]),[4,this._authPromise];case 2:return t.sent(),[3,4];case 3:return this._authPromise=null,[7];case 4:return[2]}})}).call(this)}},{key:"_isManualToken",value:function(){return this._manuallySetToken}},{key:"sendHeartbeat",value:function(){return(0,S._)(function(){var e,t;return(0,I._)(this,function(r){if(e=this,!this.isConnected()){try{this.heartbeatCallback("disconnected")}catch(e){this.log("error","error in heartbeat callback",e)}return[2]}if(this.pendingHeartbeatRef){this.pendingHeartbeatRef=null,this._heartbeatSentAt=null,this.log("transport","heartbeat timeout. Attempting to re-establish connection");try{this.heartbeatCallback("timeout")}catch(e){this.log("error","error in heartbeat callback",e)}return this._wasManualDisconnect=!1,null==(t=this.conn)||t.close(1e3,"heartbeat timeout"),setTimeout(function(){var t;e.isConnected()||null==(t=e.reconnectTimer)||t.scheduleTimeout()},100),[2]}this._heartbeatSentAt=Date.now(),this.pendingHeartbeatRef=this._makeRef(),this.push({topic:"phoenix",event:"heartbeat",payload:{},ref:this.pendingHeartbeatRef});try{this.heartbeatCallback("sent")}catch(e){this.log("error","error in heartbeat callback",e)}return this._setAuthSafely("heartbeat"),[2]})}).call(this)}},{key:"onHeartbeat",value:function(e){this.heartbeatCallback=e}},{key:"flushSendBuffer",value:function(){this.isConnected()&&this.sendBuffer.length>0&&(this.sendBuffer.forEach(function(e){return e()}),this.sendBuffer=[])}},{key:"_makeRef",value:function(){var e=this.ref+1;return e===this.ref?this.ref=0:this.ref=e,this.ref.toString()}},{key:"_leaveOpenTopic",value:function(e){var t=this.channels.find(function(t){return t.topic===e&&(t._isJoined()||t._isJoining())});t&&(this.log("transport",'leaving duplicate topic "'.concat(e,'"')),t.unsubscribe())}},{key:"_remove",value:function(e){this.channels=this.channels.filter(function(t){return t.topic!==e.topic})}},{key:"_onConnMessage",value:function(e){var t=this;this.decode(e.data,function(e){if("phoenix"===e.topic&&"phx_reply"===e.event&&e.ref&&e.ref===t.pendingHeartbeatRef){var r=t._heartbeatSentAt?Date.now()-t._heartbeatSentAt:void 0;try{t.heartbeatCallback("ok"===e.payload.status?"ok":"error",r)}catch(e){t.log("error","error in heartbeat callback",e)}t._heartbeatSentAt=null,t.pendingHeartbeatRef=null}var n=e.topic,s=e.event,i=e.payload,a=e.ref,o=i.status||"";t.log("receive","".concat(o," ").concat(n," ").concat(s," ").concat(a?"(".concat(a,")"):"").trim(),i),t.channels.filter(function(e){return e._isMember(n)}
1).forEach(function(e){return e._trigger(s,i,a)}),t._triggerStateCallbacks("message",e)})}},{key:"_clearTimer",value:function(e){var t;"heartbeat"===e&&this.heartbeatTimer?(clearInterval(this.heartbeatTimer),this.heartbeatTimer=void 0):"reconnect"===e&&(null==(t=this.reconnectTimer)||t.reset())}},{key:"_clearAllTimers",value:function(){this._clearTimer("heartbeat"),this._clearTimer("reconnect")}},{key:"_setupConnectionHandlers",value:function(){var e=this;this.conn&&("binaryType"in this.conn&&(this.conn.binaryType="arraybuffer"),this.conn.onopen=function(){return e._onConnOpen()},this.conn.onerror=function(t){return e._onConnError(t)},this.conn.onmessage=function(t){return e._onConnMessage(t)},this.conn.onclose=function(t){return e._onConnClose(t)},this.conn.readyState===f.open&&this._onConnOpen())}},{key:"_teardownConnection",value:function(){if(this.conn){if(this.conn.readyState===f.open||this.conn.readyState===f.connecting)try{this.conn.close()}catch(e){this.log("error","Error closing connection",e)}this.conn.onopen=null,this.conn.onerror=null,this.conn.onmessage=null,this.conn.onclose=null,this.conn=null}this._clearAllTimers(),this._terminateWorker(),this.channels.forEach(function(e){return e.teardown()})}},{key:"_onConnOpen",value:function(){var e=this;this._setConnectionState("connected"),this.log("transport","connected to ".concat(this.endpointURL())),(this._authPromise||(this.accessToken&&!this.accessTokenValue?this.setAuth():Promise.resolve())).then(function(){e.accessTokenValue&&(e.channels.forEach(function(t){t.updateJoinPayload({access_token:e.accessTokenValue})}),e.sendBuffer=[],e.channels.forEach(function(e){e._isJoining()&&(e.joinPush.sent=!1,e.joinPush.send())})),e.flushSendBuffer()}).catch(function(t){e.log("error","error waiting for auth on connect",t),e.flushSendBuffer()}),this._clearTimer("reconnect"),this.worker?this.workerRef||this._startWorkerHeartbeat():this._startHeartbeat(),this._triggerStateCallbacks("open")}},{key:"_startHeartbeat",value:function(){var e=this;this.heartbeatTimer&&clearInterval(this.heartbeatTimer),this.heartbeatTimer=setInterval(function(){return e.sendHeartbeat()},this.heartbeatIntervalMs)}},{key:"_startWorkerHeartbeat",value:function(){var e=this;this.workerUrl?this.log("worker","starting worker for from ".concat(this.workerUrl)):this.log("worker","starting default worker");var t=this._workerObjectUrl(this.workerUrl);this.workerRef=new Worker(t),this.workerRef.onerror=function(t){e.log("worker","worker error",t.message),e._terminateWorker()},this.workerRef.onmessage=function(t){"keepAlive"===t.data.event&&e.sendHeartbeat()},this.workerRef.postMessage({event:"start",interval:this.heartbeatIntervalMs})}},{key:"_terminateWorker",value:function(){this.workerRef&&(this.log("worker","terminating worker"),this.workerRef.terminate(),this.workerRef=void 0)}},{key:"_onConnClose",value:function(e){var t;this._setConnectionState("disconnected"),this.log("transport","close",e),this._triggerChanError(),this._clearTimer("heartbeat"),this._wasManualDisconnect||null==(t=this.reconnectTimer)||t.scheduleTimeout(),this._triggerStateCallbacks("close",e)}},{key:"_onConnError",value:function(e){this._setConnectionState("disconnected"),this.log("transport","".concat(e)),this._triggerChanError(),this._triggerStateCallbacks("error",e);try{this.heartbeatCallback("error")}catch(e){this.log("error","error in heartbeat callback",e)}}},{key:"_triggerChanError",value:function(){this.channels.forEach(function(e){return e._trigger(p.error)})}},{key:"_appendParams",value:function(e,t){if(0===Object.keys(t).length)return e;var r=e.match(/\?/)?"&":"?",n=new URLSearchParams(t);return"".concat(e).concat(r).concat(n)}},{key:"_workerObjectUrl",value:function(e){var t;if(e)t=e;else{var r=new Blob(['\n  addEventListener("message", (e) => {\n    if (e.data.event === "start") {\n      setInterval(() => postMessage({ event: "keepAlive" }), e.data.interval);\n    }\n  });'],{type:"application/javascript"});t=URL.createObjectURL(r)}return t}},{key:"_setConnectionState",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this._connectionState=e,"connecting"===e?this._wasManualDisconnect=!1:"disconnecting"===e&&(this._wasManualDisconnect=t)}},{key:"_performAuth",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return(0,S._)(function(){var t,r,n;return(0,I._)(this,function(s){switch(s.label){case 0:if(r=!1,!e)return[3,1];return t=e,r=!0,[3,7];case 1:if(!this.accessToken)return[3,6];s.label=2;case 2:return s.trys.push([2,4,,5]),[4,this.accessToken()];case 3:return t=s.sent(),[3,5];case 4:return n=s.sent(),this.log("error","Error fetching access token from callback",n),t=this.accessTokenValue,[3,5];case 5:return[3,7];
1case 6:t=this.accessTokenValue,s.label=7;case 7:return r?this._manuallySetToken=!0:this.accessToken&&(this._manuallySetToken=!1),this.accessTokenValue!=t&&(this.accessTokenValue=t,this.channels.forEach(function(e){var r={access_token:t,version:$};t&&e.updateJoinPayload(r),e.joinedOnce&&e._isJoined()&&e._push(p.access_token,{access_token:t})})),[2]}})}).call(this)}},{key:"_waitForAuthIfNeeded",value:function(){return(0,S._)(function(){return(0,I._)(this,function(e){switch(e.label){case 0:if(!this._authPromise)return[3,2];return[4,this._authPromise];case 1:e.sent(),e.label=2;case 2:return[2]}})}).call(this)}},{key:"_setAuthSafely",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"general";this._isManualToken()||this.setAuth().catch(function(r){e.log("error","Error setting auth in ".concat(t),r)})}},{key:"_triggerStateCallbacks",value:function(e,t){var r=this;try{this.stateChangeCallbacks[e].forEach(function(n){try{n(t)}catch(t){r.log("error","error in ".concat(e," callback"),t)}})}catch(t){this.log("error","error triggering ".concat(e," callbacks"),t)}}},{key:"_setupReconnectionTimer",value:function(){var e=this;this.reconnectTimer=new Z(function(){return(0,S._)(function(){var e;return(0,I._)(this,function(t){return e=this,setTimeout(function(){return(0,S._)(function(){return(0,I._)(this,function(e){switch(e.label){case 0:return[4,this._waitForAuthIfNeeded()];case 1:return e.sent(),this.isConnected()||this.connect(),[2]}})}).call(e)},10),[2]})}).call(e)},this.reconnectAfterMs)}},{key:"_initializeOptions",value:function(e){var t,r,n,s,i,a,o,u,c,l,h,f;switch(this.transport=null!=(t=null==e?void 0:e.transport)?t:null,this.timeout=null!=(r=null==e?void 0:e.timeout)?r:1e4,this.heartbeatIntervalMs=null!=(n=null==e?void 0:e.heartbeatIntervalMs)?n:25e3,this.worker=null!=(s=null==e?void 0:e.worker)&&s,this.accessToken=null!=(i=null==e?void 0:e.accessToken)?i:null,this.heartbeatCallback=null!=(a=null==e?void 0:e.heartbeatCallback)?a:ed,this.vsn=null!=(o=null==e?void 0:e.vsn)?o:X,(null==e?void 0:e.params)&&(this.params=e.params),(null==e?void 0:e.logger)&&(this.logger=e.logger),((null==e?void 0:e.logLevel)||(null==e?void 0:e.log_level))&&(this.logLevel=e.logLevel||e.log_level,this.params=Object.assign(Object.assign({},this.params),{log_level:this.logLevel})),this.reconnectAfterMs=null!=(u=null==e?void 0:e.reconnectAfterMs)?u:function(e){return ep[e-1]||1e4},this.vsn){case"1.0.0":this.encode=null!=(c=null==e?void 0:e.encode)?c:function(e,t){return t(JSON.stringify(e))},this.decode=null!=(l=null==e?void 0:e.decode)?l:function(e,t){return t(JSON.parse(e))};break;case X:this.encode=null!=(h=null==e?void 0:e.encode)?h:this.serializer.encode.bind(this.serializer),this.decode=null!=(f=null==e?void 0:e.decode)?f:this.serializer.decode.bind(this.serializer);break;default:throw Error("Unsupported serializer version: ".concat(this.vsn))}if(this.worker){if("undefined"!=typeof window&&!window.Worker)throw Error("Web Worker is not supported");this.workerUrl=null==e?void 0:e.workerUrl}}}]),e}(),e_=e.i(467034),eg=e.i(299749),ey=e.i(680700),eb=e.i(402048),em=e.i(120786),ew=function(e){function t(e,r){var n,s;return(0,T._)(this,t),(n=(0,E._)(this,t,[e])).name="IcebergError",n.status=r.status,n.icebergType=r.icebergType,n.icebergCode=r.icebergCode,n.details=r.details,n.isCommitStateUnknown="CommitStateUnknownException"===r.icebergType||[500,502,504].includes(r.status)&&(null==(s=r.icebergType)?void 0:s.includes("CommitState"))===!0,n}return(0,A._)(t,e),(0,O._)(t,[{key:"isNotFound",value:function(){return 404===this.status}},{key:"isConflict",value:function(){return 409===this.status}},{key:"isAuthenticationTimeout",value:function(){return 419===this.status}}]),t}((0,j._)(Error));function ek(e){return e.join("\x1f")}var eS=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";(0,T._)(this,e),this.client=t,this.prefix=r}return(0,O._)(e,[{key:"listNamespaces",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){switch(r.label){case 0:return t=e?{parent:ek(e.namespace)}:void 0,[4,this.client.request({method:"GET",path:"".concat(this.prefix,"/namespaces"),query:t})];case 1:return[2,r.sent().data.namespaces.map(function(e){return{namespace:e}})]}})}).call(this)}},{key:"createNamespace",value:function(e,t){return(0,S._)(function(){var r;return(0,I._)(this,function(n){switch(n.label){case 0:return r={namespace:e.namespace,properties:null==t?void 0:t.properties},[4,this.client.request({method:"POST",path:"".concat(this.prefix,"/namespaces"),body:r})];case 1:return[2,n.sent().data]}})}).call(this)}},{key:"dropNamespace",value:function(e){return(0,S._)(function(){return(0,I._)(this,function(t){switch(t.label){case 0:return[4,this.client.request({method:"DELETE",path:"".concat(this.prefix,"/namespaces/").concat(ek(e.namespace))})];case 1:return t.sent(),[2]}})}).call(this)}},{key:"loadNamespaceMetadata",value:function(e){return(0,S._)(function(){return(0,I._)(this,function(t){switch(t.label){case 0:return[4,this.client.request({method:"GET",path:"".concat(this.prefix,"/namespaces/").concat(ek(e.namespace))})];case 1:return[2,{properties:t.sent().data.properties}]}})}).call(this)}},{key:"namespaceExists",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.client.request({method:"HEAD",path:"".concat(this.prefix,"/namespaces/").concat(ek(e.namespace))})];case 1:return r.sent(),[2,!0];case 2:if(t=r.sent(),(0,N._)(t,ew)&&404===t.status)return[2,!1];throw t;case 3:return[2]}})}).call(this)}},{key:"createNamespaceIfNotExists",value:function(e,t){return(0,S._)(function(){var r;return(0,I._)(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.createNamespace(e,t)];case 1:return[2,n.sent()];case 2:if(r=n.sent(),(0,N._)(r,ew)&&409===r.status)return[2];throw r;case 3:return[2]}})}).call(this)}}]),e}();function eE(e){return e.join("\x1f")}var eT=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2?arguments[2]:void 0;(0,T._)(this,e),this.client=t,this.prefix=r,this.accessDelegation=n}return(0,O._)(e,[{key:"listTables",value:function(e){return(0,S._)(function(){return(0,I._)(this,function(t){switch(t.label){case 0:return[4,this.client.request({method:"GET",path:"".concat(this.prefix,"/namespaces/").concat(eE(e.namespace),"/tables")})];case 1:return[2,t.sent().data.identifiers]}})}).call(this)}},{key:"createTable",value:function(e,t){return(0,S._)(function(){var r;return(0,I._)(this,function(n){switch(n.label){case 0:return r={},this.accessDelegation&&(r["X-Iceberg-Access-Delegation"]=this.accessDelegation),[4,this.client.request({method:"POST",path:"".concat(this.prefix,"/namespaces/").concat(eE(e.namespace),"/tables"),body:t,headers:r})];case 1:return[2,n.sent().data.metadata]}})}).call(this)}},{key:"updateTable",value:function(e,t){return(0,S._)(function(){var r;return(0,I._)(this,function(n){switch(n.label){case 0:return[4,this.client.request({method:"POST",path:"".concat(this.prefix,"/namespaces/").concat(eE(e.namespace),"/tables/").concat(e.name),body:t})];case 1:return[2,{"metadata-location":(r=n.sent()).data["metadata-location"],metadata:r.data.metadata}]}})}).call(this)}},{key:"dropTable",value:function(e,t){return(0,S._)(function(){var r;return(0,I._)(this,function(n){switch(n.label){case 0:return[4,this.client.request({method:"DELETE",path:"".concat(this.prefix,"/namespaces/").concat(eE(e.namespace),"/tables/").concat(e.name),query:{purgeRequested:String(null!=(r=null==t?void 0:t.purge)&&r)}})];case 1:return n.sent(),[2]}})}).call(this)}},{key:"loadTable",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){switch(r.label){case 0:return t={},this.accessDelegation&&(t["X-Iceberg-Access-Delegation"]=this.accessDelegation),[4,this.client.request({method:"GET",path:"".concat(this.prefix,"/namespaces/").concat(eE(e.namespace),"/tables/").concat(e.name),headers:t})];case 1:return[2,r.sent().data.metadata]}})}).call(this)}},{key:"tableExists",value:function(e){return(0,S._)(function(){var t,r;return(0,I._)(this,function(n){switch(n.label){case 0:t={},this.accessDelegation&&(t["X-Iceberg-Access-Delegation"]=this.accessDelegation),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.client.request({method:"HEAD",path:"".concat(this.prefix,"/namespaces/").concat(eE(e.namespace),"/tables/").concat(e.name),headers:t})];case 2:return n.sent(),[2,!0];case 3:if(r=n.sent(),(0,N._)(r,ew)&&404===r.status)return[2,!1];throw r;case 4:return[2]}})}).call(this)}},{key:"createTableIfNotExists",value:function(e,t){return(0,S._)(function(){var r;return(0,I._)(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,5]),[4,this.createTable(e,t)];case 1:case 3:return[2,n.sent()];case 2:if(r=n.sent(),!((0,N._)(r,ew)&&409===r.status))return[3,4];return[4,this.loadTable({namespace:e.namespace,name:t.name})];case 4:throw r;case 5:return[2]}})}).call(this)}}]),e}(),eO=function(){function e(t){(0,T._)(this,e);var r,n,s,i,a="v1";t.catalogName&&(a+="/".concat(t.catalogName));var o=t.baseUrl.endsWith("/")?t.baseUrl:"".concat(t.baseUrl,"/");this.client=(s=null!=(n=(r={baseUrl:o,auth:t.auth,fetchImpl:t.fetch}).fetchImpl)?n:globalThis.fetch,{request:function(e){return(0,S._)(function(e){var t,n,i,a,o,u,c,l,h,f,d,p,v,_;return(0,I._)(this,function(g){switch(g.label){case 0:var y;return t=e.method,n=e.path,i=e.query,a=e.body,o=e.headers,u=function(e,t,r){var n=new URL(t,e);if(r){var s=!0,i=!1,a=void 0;try{for(var o,u=Object.entries(r)[Symbol.iterator]();!(s=(o=u.next()).done);s=!0){var c=(0,D._)(o.value,2),l=c[0],h=c[1];void 0!==h&&n.searchParams.set(l,h)}}catch(e){i=!0,a=e}finally{try{s||null==u.return||u.return()}finally{if(i)throw a}}}return n.toString()}(r.baseUrl,n,i),[4,(y=r.auth,(0,S._)(function(){return(0,I._)(this,function(e){switch(e.label){case 0:if(!y||"none"===y.type)return[2,{}];if("bearer"===y.type)return[2,{Authorization:"Bearer ".concat(y.token)}];if("header"===y.type)return[2,(0,eg._)({},y.name,y.value)];if("custom"!==y.type)return[3,2];return[4,y.getHeaders()];case 1:return[2,e.sent()];case 2:return[2,{}]}})})())];case 1:return c=g.sent(),[4,s(u,{method:t,headers:(0,em._)({},a?{"Content-Type":"application/json"}:{},c,o),body:a?JSON.stringify(a):void 0})];case 2:return[4,(l=g.sent()).text()];case 3:if(h=g.sent(),d=(f=(l.headers.get("content-type")||"").includes("application/json"))&&h?JSON.parse(h):h,!l.ok)throw new ew(null!=(_=null==(v=null==(p=f?d:void 0)?void 0:p.error)?void 0:v.message)?_:"Request failed with status ".concat(l.status),{status:l.status,icebergType:null==v?void 0:v.type,icebergCode:null==v?void 0:v.code,details:p});return[2,{status:l.status,headers:l.headers,data:d}]}})}).apply(this,arguments)}}),this.accessDelegation=null==(i=t.accessDelegation)?void 0:i.join(","),this.namespaceOps=new eS(this.client,a),this.tableOps=new eT(this.client,a,this.accessDelegation)}return(0,O._)(e,[{key:"listNamespaces",value:function(e){return(0,S._)(function(){return(0,I._)(this,function(t){return[2,this.namespaceOps.listNamespaces(e)]})}).call(this)}},{key:"createNamespace",value:function(e,t){return(0,S._)(function(){return(0,I._)(this,function(r){return[2,this.namespaceOps.createNamespace(e,t)]})}).call(this)}},{key:"dropNamespace",value:function(e){return(0,S._)(function(){return(0,I._)(this,function(t){switch(t.label){case 0:return[4,this.namespaceOps.dropNamespace(e)];case 1:return t.sent(),[2]}})}).call(this)}},{key:"loadNamespaceMetadata",value:function(e){return(0,S._)(function(){return(0,I._)(this,function(t){return[2,this.namespaceOps.loadNamespaceMetadata(e)]})}).call(this)}},{key:"listTables",value:function(e){return(0,S._)(function(){return(0,I._)(this,function(t){return[2,this.tableOps.listTables(e)]})}).call(this)}},{key:"createTable",value:function(e,t){return(0,S._)(function(){return(0,I._)(this,function(r){return[2,this.tableOps.
1createTable(e,t)]})}).call(this)}},{key:"updateTable",value:function(e,t){return(0,S._)(function(){return(0,I._)(this,function(r){return[2,this.tableOps.updateTable(e,t)]})}).call(this)}},{key:"dropTable",value:function(e,t){return(0,S._)(function(){return(0,I._)(this,function(r){switch(r.label){case 0:return[4,this.tableOps.dropTable(e,t)];case 1:return r.sent(),[2]}})}).call(this)}},{key:"loadTable",value:function(e){return(0,S._)(function(){return(0,I._)(this,function(t){return[2,this.tableOps.loadTable(e)]})}).call(this)}},{key:"namespaceExists",value:function(e){return(0,S._)(function(){return(0,I._)(this,function(t){return[2,this.namespaceOps.namespaceExists(e)]})}).call(this)}},{key:"tableExists",value:function(e){return(0,S._)(function(){return(0,I._)(this,function(t){return[2,this.tableOps.tableExists(e)]})}).call(this)}},{key:"createNamespaceIfNotExists",value:function(e,t){return(0,S._)(function(){return(0,I._)(this,function(r){return[2,this.namespaceOps.createNamespaceIfNotExists(e,t)]})}).call(this)}},{key:"createTableIfNotExists",value:function(e,t){return(0,S._)(function(){return(0,I._)(this,function(r){return[2,this.tableOps.createTableIfNotExists(e,t)]})}).call(this)}}]),e}(),eA=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"storage",s=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;return(0,T._)(this,t),(r=(0,E._)(this,t,[e])).__isStorageError=!0,r.namespace=n,r.name="vectors"===n?"StorageVectorsError":"StorageError",r.status=s,r.statusCode=i,r}return(0,A._)(t,e),t}((0,j._)(Error));function eR(e){return(void 0===e?"undefined":(0,q._)(e))==="object"&&null!==e&&"__isStorageError"in e}var eI=function(e){function t(e,r,n){var s,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"storage";return(0,T._)(this,t),(s=(0,E._)(this,t,[e,i,r,n])).name="vectors"===i?"StorageVectorsApiError":"StorageApiError",s.status=r,s.statusCode=n,s}return(0,A._)(t,e),(0,O._)(t,[{key:"toJSON",value:function(){return{name:this.name,message:this.message,status:this.status,statusCode:this.statusCode}}}]),t}(eA),ej=function(e){function t(e,r){var n,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"storage";return(0,T._)(this,t),(n=(0,E._)(this,t,[e,s])).name="vectors"===s?"StorageVectorsUnknownError":"StorageUnknownError",n.originalError=r,n}return(0,A._)(t,e),t}(eA);(0,A._)(function e(t){return(0,T._)(this,e),(0,E._)(this,e,[t,"vectors"])},eA),(0,A._)(function e(t,r,n){return(0,T._)(this,e),(0,E._)(this,e,[t,r,n,"vectors"])},eI),(0,A._)(function e(t,r){return(0,T._)(this,e),(0,E._)(this,e,[t,r,"vectors"])},ej);var eP=function(e){if((void 0===e?"undefined":(0,q._)(e))!=="object"||null===e)return!1;var t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},eC=function(e){if(Array.isArray(e))return e.map(function(e){return eC(e)});if("function"==typeof e||e!==Object(e))return e;var t={};return Object.entries(e).forEach(function(e){var r=(0,D._)(e,2),n=r[0],s=r[1];t[n.replace(/([-_][a-z])/gi,function(e){return e.toUpperCase().replace(/[-_]/g,"")})]=eC(s)}),t};function eU(e){return(eU="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 ex(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 eN(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ex(Object(r),!0).forEach(function(t){!function(e,t,r){var n;(n=function(e,t){if("object"!=eU(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=eU(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"),(t="symbol"==eU(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)):ex(Object(r)).forEac
1h(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var eL=function(e){var t;return e.msg||e.message||e.error_description||("string"==typeof e.error?e.error:null==(t=e.error)?void 0:t.message)||JSON.stringify(e)},eB=function(e,t,r,n){var s={method:e,headers:(null==t?void 0:t.headers)||{}};return"GET"!==e&&"HEAD"!==e&&n&&(eP(n)?(s.headers=eN({"Content-Type":"application/json"},null==t?void 0:t.headers),s.body=JSON.stringify(n)):s.body=n,(null==t?void 0:t.duplex)&&(s.duplex=t.duplex)),eN(eN({},s),r)};function eD(e,t,r,n,s,i,a){return(0,S._)(function(){return(0,I._)(this,function(o){return[2,new Promise(function(o,u){e(r,eB(t,n,s,i)).then(function(e){if(!e.ok)throw e;if(null==n?void 0:n.noResolveJson)return e;if("vectors"===a){var 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(function(e){return o(e)}).catch(function(e){return(0,S._)(function(){var t,r,n;return(0,I._)(this,function(s){return e&&(void 0===e?"undefined":(0,q._)(e))==="object"&&"status"in e&&"ok"in e&&"number"==typeof e.status?(r=(t=e).status||500,"function"==typeof t.json?t.json().then(function(e){var t=(null==e?void 0:e.statusCode)||(null==e?void 0:e.code)||r+"";u(new eI(eL(e),r,t,a))}).catch(function(){u(new eI(t.statusText||"HTTP ".concat(r," error"),r,r+"",a))}):(n=r+"",u(new eI(t.statusText||"HTTP ".concat(r," error"),r,n,a)))):u(new ej(eL(e),e,a)),[2]})})()})})]})})()}function eq(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"storage";return{get:function(t,r,n,s){return(0,S._)(function(){return(0,I._)(this,function(i){return[2,eD(t,"GET",r,n,s,void 0,e)]})})()},post:function(t,r,n,s,i){return(0,S._)(function(){return(0,I._)(this,function(a){return[2,eD(t,"POST",r,s,i,n,e)]})})()},put:function(t,r,n,s,i){return(0,S._)(function(){return(0,I._)(this,function(a){return[2,eD(t,"PUT",r,s,i,n,e)]})})()},head:function(t,r,n,s){return(0,S._)(function(){return(0,I._)(this,function(i){return[2,eD(t,"HEAD",r,eN(eN({},n),{},{noResolveJson:!0}),s,void 0,e)]})})()},remove:function(t,r,n,s,i){return(0,S._)(function(){return(0,I._)(this,function(a){return[2,eD(t,"DELETE",r,s,i,n,e)]})})()}}}var eM=eq("storage"),eK=eM.get,eW=eM.post,eF=eM.put,ez=eM.head,eJ=eM.remove,eV=eq("vectors"),eH=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"storage";(0,T._)(this,e),this.shouldThrowOnError=!1,this.url=t,this.headers=r,this.fetch=n?function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return n.apply(void 0,(0,R._)(t))}:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return fetch.apply(void 0,(0,R._)(t))},this.namespace=s}return(0,O._)(e,[{key:"throwOnError",value:function(){return this.shouldThrowOnError=!0,this}},{key:"setHeader",value:function(e,t){return this.headers=eN(eN({},this.headers),{},(0,eg._)({},e,t)),this}},{key:"handleOperation",value:function(e){return(0,S._)(function(){var t,r,n;return(0,I._)(this,function(s){switch(s.label){case 0:t=this,s.label=1;case 1:return s.trys.push([1,3,,4]),r={},[4,e()];case 2:return[2,(r.data=s.sent(),r.error=null,r)];case 3:if(n=s.sent(),t.shouldThrowOnError)throw n;if(eR(n))return[2,{data:null,error:n}];throw n;case 4:return[2]}})}).call(this)}}]),e}(),eG=function(){function e(t,r){(0,T._)(this,e),this.downloadFn=t,this.shouldThrowOnError=r}return(0,O._)(e,[{key:"then",value:function(e,t){return this.execute().then(e,t)}},{key:"execute",value:function(){return(0,S._)(function(){var e,t,r;return(0,I._)(this,function(n){switch(n.label){case 0:e=this,n.label=1;case 1:return n.trys.push([1,3,,4]),t={},[4,e.downloadFn()];case 2:return[2,(t.data=n.sent().body,t.error=null,t)];case 3:if(r=n.sent(),e.shouldThrowOnError)throw r;if(eR(r))return[2,{data:null,error:r}];throw r;case 4:return[2]}})}).call(this)}}]),e}();k=Symbol.toStringTag;var eY=function(){function e(t,r){(0,T._)(this,e),this.downloadFn=t,this.shouldThrowOnError=r,this[k]="BlobDownloadBuilder",this.promise=null}return(0,O._)(e,[{key:"asStream",value:function(){return new eG(this.downloadFn,this.shouldThrowOnError)}},{key:"then",value:function(e,t){return this.getPromise().then(e,t)}},{key:"catch",value:function(e){return this.getPromise().catch(e)}},{key:"finally",value:function(e){return this.getPromise().finally(e)}},{key:"getPromise",value:function(){return this.promise||(this.promise=this.execute()),this.promise}},{key:"execute",value:function(){return(0,S._)(function(){var e,t,r;return(0,I._)(this,function(n){switch(n.label){case 0:e=this,n.label=1;case 1:return n.trys.push([1,4,,5]),t={},[4,e.downloadFn()];case 2:return[4,n.sent().blob()];case 3:return[2,(t.data=n.sent(),t.error=null,t)];case 4:if(r=n.sent(),e.shouldThrowOnError)throw r;if(eR(r))return[2,{data:null,error:r}];throw r;case 5:return[2]}})}).call(this)}}]),e}(),e$={limit:100,offset:0,sortBy:{column:"name",order:"asc"}},eX={cacheControl:"3600",contentType:"text/plain;charset=UTF-8",upsert:!1},eQ=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;return(0,T._)(this,t),(r=(0,E._)(this,t,[e,n,i,"storage"])).bucketId=s,r}return(0,A._)(t,e),(0,O._)(t,[{key:"uploadOrUpdate",value:function(e,t,r,n){return(0,S._)(function(){var s;return(0,I._)(this,function(i){return s=this,[2,s.handleOperation(function(){return(0,S._)(function(){var i,a,o,u,c,l,h;return(0,I._)(this,function(f){switch(f.label){case 0:return a=eN(eN({},eX),n),o=eN(eN({},s.headers),"POST"===e&&{"x-upsert":String(a.upsert)}),u=a.metadata,"undefined"!=typeof Blob&&(0,N._)(r,Blob)?((i=new FormData).append("cacheControl",a.cacheControl),u&&i.append("metadata",s.encodeMetadata(u)),i.append("",r)):"undefined"!=typeof FormData&&(0,N._)(r,FormData)?((i=r).has("cacheControl")||i.append("cacheControl",a.cacheControl),u&&!i.has("metadata")&&i.append("metadata",s.encodeMetadata(u))):(i=r,o["cache-control"]="max-age=".concat(a.cacheControl),o["content-type"]=a.contentType,u&&(o["x-metadata"]=s.toBase64(s.encodeMetadata(u))),("undefined"!=typeof ReadableStream&&(0,N._)(i,ReadableStream)||i&&(void 0===i?"undefined":(0,q._)(i))==="object"&&"pipe"in i&&"function"==typeof i.pipe)&&!a.duplex&&(a.duplex="half")),(null==n?void 0:n.headers)&&(o=eN(eN({},o),n.headers)),c=s._removeEmptyFolders(t),l=s._getFinalPath(c),[4,("PUT"==e?eF:eW)(s.fetch,"".concat(s.url,"/object/").concat(l),i,eN({headers:o},(null==a?void 0:a.duplex)?{duplex:a.duplex}:{}))];case 1:return h=f.sent(),[2,{path:c,id:h.Id,fullPath:h.Key}]}})})()})]})}).call(this)}},{key:"upload",value:function(e,t,r){return(0,S._)(function(){return(0,I._)(this,function(n){return[2,this.uploadOrUpdate("POST",e,t,r)]})}).call(this)}},{key:"uploadToSignedUrl",value:function(e,t,r,n){return(0,S._)(function(){var s,i,a,o;return(0,I._)(this,function(u){return s=this,i=s._removeEmptyFolders(e),a=s._getFinalPath(i),(o=new URL(s.url+"/object/upload/sign/".concat(a))).searchParams.set("token",t),[2,s.handleOperation(function(){return(0,S._)(function(){var e,t,a,u;return(0,I._)(this,function(c){switch(c.label){case 0:return t=eN({upsert:eX.upsert},n),a=eN(eN({},s.headers),{"x-upsert":String(t.upsert)}),"undefined"!=typeof Blob&&(0,N._)(r,Blob)?((e=new FormData).append("cacheControl",t.cacheControl),e.append("",r)):"undefined"!=typeof FormData&&(0,N._)(r,FormData)?(e=r).append("cacheControl",t.cacheControl):(e=r,a["cache-control"]="max-age=".concat(t.cacheControl),a["content-type"]=t.contentType),u={path:i},[4,eF(s.fetch,o.toString(),e,{headers:a})];case 1:return[2,(u.fullPath=c.sent().Key,u)]}})})()})]})}).call(this)}},{key:"createSignedUploadUrl",value:function(e,t){return(0,S._)(function(){var r;return(0,I._)(this,function(n){return r=this,[2,r.handleOperation(function(){return(0,S._)(function(){var n,s,i,a,o;return(0,I._)(this,function(u){switch(u.label){case 0:return n=r._getFinalPath(e),s=eN({},r.headers),(null==t?void 0:t.upsert)&&(s["x-upsert"]="true"),[4,eW(r.fetch,"".concat(r.url,"/object/upload/sign/").concat(n),{},{headers:s})];case 1:if(i=u.sent(),!(o=(a=new URL(r.url+i.url)).searchParams.get("token")))throw new eA("No token returned by API");return[2,{signedUrl:a.toString(),path:e,token:o}]}})})()})]})}).call(this)}},{key:"update",value:function(e,t,r){return(0,S._)(function(){return(0,I._)(this,function(n){return[2,this.uploadOrUpdate("PUT",e,t,r)]})}).call(this)}},{key:"move",value:function(e,t,r){return(0,S._)(function(){var n;return(0,I._)(this,function(s){return n=this,[2,n.handleOperation(function(){return(0,S._)(function(){return(0,I._)(this,function(s){switch(s.label){case 0:return[4,eW(n.fetch,"".concat(n.url,"/object/move"),{bucketId:n.bucketId,sourceKey:e,destinationKey:t,de
1stinationBucket:null==r?void 0:r.destinationBucket},{headers:n.headers})];case 1:return[2,s.sent()]}})})()})]})}).call(this)}},{key:"copy",value:function(e,t,r){return(0,S._)(function(){var n;return(0,I._)(this,function(s){return n=this,[2,n.handleOperation(function(){return(0,S._)(function(){var s;return(0,I._)(this,function(i){switch(i.label){case 0:return s={},[4,eW(n.fetch,"".concat(n.url,"/object/copy"),{bucketId:n.bucketId,sourceKey:e,destinationKey:t,destinationBucket:null==r?void 0:r.destinationBucket},{headers:n.headers})];case 1:return[2,(s.path=i.sent().Key,s)]}})})()})]})}).call(this)}},{key:"createSignedUrl",value:function(e,t,r){return(0,S._)(function(){var n;return(0,I._)(this,function(s){return n=this,[2,n.handleOperation(function(){return(0,S._)(function(){var s,i,a,o;return(0,I._)(this,function(u){switch(u.label){case 0:return s=n._getFinalPath(e),[4,eW(n.fetch,"".concat(n.url,"/object/sign/").concat(s),eN({expiresIn:t},(null==r?void 0:r.transform)?{transform:r.transform}:{}),{headers:n.headers})];case 1:return i=u.sent(),a=(null==r?void 0:r.download)?"&download=".concat(!0===r.download?"":r.download):"",o=(null==r?void 0:r.transform)&&i.signedURL.includes("/object/sign/")?i.signedURL.replace("/object/sign/","/render/image/sign/"):i.signedURL,[2,{signedUrl:encodeURI("".concat(n.url).concat(o).concat(a))}]}})})()})]})}).call(this)}},{key:"createSignedUrls",value:function(e,t,r){return(0,S._)(function(){var n;return(0,I._)(this,function(s){return n=this,[2,n.handleOperation(function(){return(0,S._)(function(){var s,i;return(0,I._)(this,function(a){switch(a.label){case 0:return[4,eW(n.fetch,"".concat(n.url,"/object/sign/").concat(n.bucketId),{expiresIn:t,paths:e},{headers:n.headers})];case 1:return s=a.sent(),i=(null==r?void 0:r.download)?"&download=".concat(!0===r.download?"":r.download):"",[2,s.map(function(e){return eN(eN({},e),{},{signedUrl:e.signedURL?encodeURI("".concat(n.url).concat(e.signedURL).concat(i)):null})})]}})})()})]})}).call(this)}},{key:"download",value:function(e,t,r){var n=this,s=void 0!==(null==t?void 0:t.transform)?"render/image/authenticated":"object",i=this.transformOptsToQueryString((null==t?void 0:t.transform)||{}),a=i?"?".concat(i):"",o=this._getFinalPath(e);return new eY(function(){return eK(n.fetch,"".concat(n.url,"/").concat(s,"/").concat(o).concat(a),{headers:n.headers,noResolveJson:!0},r)},this.shouldThrowOnError)}},{key:"info",value:function(e){return(0,S._)(function(){var t,r;return(0,I._)(this,function(n){return t=this,r=t._getFinalPath(e),[2,t.handleOperation(function(){return(0,S._)(function(){return(0,I._)(this,function(e){switch(e.label){case 0:return[4,eK(t.fetch,"".concat(t.url,"/object/info/").concat(r),{headers:t.headers})];case 1:return[2,eC.apply(void 0,[e.sent()])]}})})()})]})}).call(this)}},{key:"exists",value:function(e){return(0,S._)(function(){var t,r,n,s,i;return(0,I._)(this,function(a){switch(a.label){case 0:t=this,r=t._getFinalPath(e),a.label=1;case 1:return a.trys.push([1,3,,4]),[4,ez(t.fetch,"".concat(t.url,"/object/").concat(r),{headers:t.headers})];case 2:return a.sent(),[2,{data:!0,error:null}];case 3:if(n=a.sent(),t.shouldThrowOnError)throw n;if(eR(n)&&void 0!==(i=(0,N._)(n,eI)?n.status:(0,N._)(n,ej)?null==(s=n.originalError)?void 0:s.status:void 0)&&[400,404].includes(i))return[2,{data:!1,error:n}];throw n;case 4:return[2]}})}).call(this)}},{key:"getPublicUrl",value:function(e,t){var r=this._getFinalPath(e),n=[],s=(null==t?void 0:t.download)?"download=".concat(!0===t.download?"":t.download):"";""!==s&&n.push(s);var i=void 0!==(null==t?void 0:t.transform)?"render/image":"object",a=this.transformOptsToQueryString((null==t?void 0:t.transform)||{});""!==a&&n.push(a);var o=n.join("&");return""!==o&&(o="?".concat(o)),{data:{publicUrl:encodeURI("".concat(this.url,"/").concat(i,"/public/").concat(r).concat(o))}}}},{key:"remove",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){return t=this,[2,t.handleOperation(function(){return(0,S._)(function(){return(0,I._)(this,function(r){switch(r.label){case 0:return[4,eJ(t.fetch,"".concat(t.url,"/object/").concat(t.bucketId),{prefixes:e},{headers:t.headers})];case 1:return[2,r.sent()]}})})()})]})}).call(this)}},{key:"list",value:function(e,t,r){return(0,S._)(function(){var n;return(0,I._)(this,function(s){return n=this,[2,n.handleOperation(function(){return(0,S._)(function(){var s;return(0,I._)(this,function(i){switch(i.label){case 0:return s=eN(eN(eN({},e$),t),{},{prefix:e||""}),[4,eW(n.fetch,"".concat(n.url,"/object/list/").concat(n.bucketId),s,{headers:n.headers},r)];case 1:return[2,i.sent()]}})})()})]})}).call(this)}},{key:"listV2",value:function(e,t){return(0,S._)(function(){var r;return(0,I._)(this,function(n){return r=this,[2,r.handleOperation(function(){return(0,S._)(function(){var n;return(0,I._)(this,function(s){switch(s.label){case 0:return n=eN({},e),[4,eW(r.fetch,"".concat(r.url,"/object/list-v2/").concat(r.bucketId),n,{headers:r.headers},t)];case 1:return[2,s.sent()]}})})()})]})}).call(this)}},{key:"encodeMetadata",value:function(e){return JSON.stringify(e)}},{key:"toBase64",value:function(e){return void 0!==e_.Buffer?e_.Buffer.from(e).toString("base64"):btoa(e)}},{key:"_getFinalPath",value:function(e){return"".concat(this.bucketId,"/").concat(e.replace(/^\/+/,""))}},{key:"_removeEmptyFolders",value:function(e){return e.replace(/^\/|\/$/g,"").replace(/\/+/g,"/")}},{key:"transformOptsToQueryString",value:function(e){var t=[];return e.width&&t.push("width=".concat(e.width)),e.height&&t.push("height=".concat(e.height)),e.resize&&t.push("resize=".concat(e.resize)),e.format&&t.push("format=".concat(e.format)),e.quality&&t.push("quality=".concat(e.quality)),t.join("&")}}]),t}(eH),eZ={"X-Client-Info":"storage-js/".concat("2.99.1")},e0=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,s=arguments.length>3?arguments[3]:void 0;(0,T._)(this,t);var i=new URL(e);(null==s?void 0:s.useNewHostname)&&/supabase\.(co|in|red)$/.test(i.hostname)&&!i.hostname.includes("storage.supabase.")&&(i.hostname=i.hostname.replace("supabase.","storage.supabase."));var a=i.href.replace(/\/$/,""),o=eN(eN({},eZ),r);return(0,E._)(this,t,[a,o,n,"storage"])}return(0,A._)(t,e),(0,O._)(t,[{key:"listBuckets",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){return t=this,[2,t.handleOperation(function(){return(0,S._)(function(){var r;return(0,I._)(this,function(n){switch(n.label){case 0:return r=t.listBucketOptionsToQueryString(e),[4,eK(t.fetch,"".concat(t.url,"/bucket").concat(r),{headers:t.headers})];case 1:return[2,n.sent()]}})})()})]})}).call(this)}},{key:"getBucket",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){return t=this,[2,t.handleOperation(function(){return(0,S._)(function(){return(0,I._)(this,function(r){switch(r.label){case 0:return[4,eK(t.fetch,"".concat(t.url,"/bucket/").concat(e),{headers:t.headers})];case 1:return[2,r.sent()]}})})()})]})}).call(this)}},{key:"createBucket",value:function(e){return(0,S._)(function(e){var t,r,n=arguments;return(0,I._)(this,function(s){return t=n.length>1&&void 0!==n[1]?n[1]:{public:!1},r=this,[2,r.handleOperation(function(){return(0,S._)(function(){return(0,I._)(this,function(n){switch(n.label){case 0:return[4,eW(r.fetch,"".concat(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})];case 1:return[2,n.sent()]}})})()})]})}).apply(this,arguments)}},{key:"updateBucket",value:function(e,t){return(0,S._)(function(){var r;return(0,I._)(this,function(n){return r=this,[2,r.handleOperation(function(){return(0,S._)(function(){return(0,I._)(this,function(n){switch(n.label){case 0:return[4,eF(r.fetch,"".concat(r.url,"/bucket/").concat(e),{id:e,name:e,public:t.public,file_size_limit:t.fileSizeLimit,allowed_mime_types:t.allowedMimeTypes},{headers:r.headers})];case 1:return[2,n.sent()]}})})()})]})}).call(this)}},{key:"emptyBucket",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){return t=this,[2,t.handleOperation(function(){return(0,S._)(function(){return(0,I._)(this,function(r){switch(r.label){case 0:return[4,eW(t.fetch,"".concat(t.url,"/bucket/").concat(e,"/empty"),{},{headers:t.headers})];case 1:return[2,r.sent()]}})})()})]})}).call(this)}},{key:"deleteBucket",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){return t=this,[2,t.handleOperation(function(){return(0,S._)(function(){return(0,I._)(this,function(r){switch(r.label){case 0:return[4,eJ(t.fetch,"".concat(t.url,"/bucket/").concat(e),{},{headers:t.headers})];case 1:return[2,r.sent()]}})})()})]})}).call(this)}},{key:"listBucketOptionsToQueryString",value:function(e){var 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():""}}]),t}(eH),e2=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;(0,T._)(this,t);var s=e.replace(/\/$/,""),i=eN(eN({},eZ),r);return(0,E._)(this,t,[s,i,n,"storage"])}return(0,A._)(t,e),(0,O._)(t,[{key:"createBucket",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){return t=this,[2,t.handleOperation(function(){return(0,S._)(function(){return(0,I._)(this,function(r){switch(r.label){case 0:return[4,eW(t.fetch,"".concat(t.url,"/bucket"),{name:e},{headers:t.headers})];case 1:return[2,r.sent()]}})})()})]})}).call(this)}},{key:"listBuckets",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){return t=this,[2,t.handleOperation(function(){return(0,S._)(function(){var r,n,s;return(0,I._)(this,function(i){switch(i.label){case 0:return 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),s=(n=r.toString())?"".concat(t.url,"/bucket?").concat(n):"".concat(t.url,"/bucket"),[4,eK(t.fetch,s,{headers:t.headers})];case 1:return[2,i.sent()]}})})()})]})}).call(this)}},{key:"deleteBucket",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){return t=this,[2,t.handleOperation(function(){return(0,S._)(function(){return(0,I._)(this,function(r){switch(r.label){case 0:return[4,eJ(t.fetch,"".concat(t.url,"/bucket/").concat(e),{},{headers:t.headers})];case 1:return[2,r.sent()]}})})()})]})}).call(this)}},{key:"from",value:function(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 eA("Invalid bucket name: File, folder, and bucket names must follow AWS object key naming guidelines and should avoid the use of any other characters.");var r=new eO({baseUrl:this.url,catalogName:e,auth:{type:"custom",getHeaders:function(){return(0,S._)(function(){return(0,I._)(this,function(e){return[2,t.headers]})})()}},fetch:this.fetch}),n=this.shouldThrowOnError;return new Proxy(r,{get:function(e,t){var r=e[t];return"function"!=typeof r?r:function(){for(var t=arguments.length,s=Array(t),i=0;i<t;i++)s[i]=arguments[i];return(0,S._)(function(){var t,i;return(0,I._)(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),t={},[4,r.apply(e,s)];case 1:return[2,(t.data=a.sent(),t.error=null,t)];case 2:if(i=a.sent(),n)throw i;return[2,{data:null,error:i}];case 3:return[2]}})})()}}})}}]),t}(eH),e1=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;(0,T._)(this,t);var s=e.replace(/\/$/,""),i=eN(eN({},eZ),{},{"Content-Type":"application/json"},r);return(0,E._)(this,t,[s,i,n,"vectors"])}return(0,A._)(t,e),(0,O._)(t,[{key:"createIndex",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){return t=this,[2,t.handleOperation(function(){return(0,S._)(function(){return(0,I._)(this,function(r){switch(r.label){case 0:return[4,eV.post(t.fetch,"".concat(t.url,"/CreateIndex"),e,{headers:t.headers})];case 1:return[2,r.sent()||{}]}})})()})]})}).call(this)}},{key:"getIndex",value:function(e,t){return(0,S._)(function(){var r;return(0,I._)(this,function(n){return r=this,[2,r.handleOperation(function(){return(0,S._)(function(){return(0,I._)(this,function(n){switch(n.label){case 0:return[4,eV.post(r.fetch,"".concat(r.url,"/GetIndex"),{vectorBucketName:e,indexName:t},{headers:r.headers})];case 1:return[2,n.sent()]}})})()})]})}).call(this)}},{key:"listIndexes",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){return t=this,[2,t.handleOperation(function(){return(0,S._)(function(){return(0,I._)(this,function(r){switch(r.label){case 0:return[4,eV.post(t.fetch,"".concat(t.url,"/ListIndexes"),e,{headers:t.headers})];case 1:return[2,r.sent()]}})})()})]})}).call(this)}},{key:"deleteIndex",value:function(e,t){return(0,S._)(function(){var r;return(0,I._)(this,function(n){return r=this,[2,r.handleOperation(function(){return(0,S._)(function(){return(0,I._)(this,function(n){switch(n.label){case 0:return[4,eV.post(r.fetch,"".concat(r.url,"/DeleteIndex"),{vectorBucketName:e,indexName:t},{headers:r.headers})];case 1:return[2,n.sent()||{}]}})})()})]})}).call(this)}}]),t}(eH),e4=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;(0,T._)(this,t);var s=e.replace(/\/$/,""),i=eN(eN({},eZ),{},{"Content-Type":"application/json"},r);return(0,E._)(this,t,[s,i,n,"vectors"])}return(0,A._)(t,e),(0,O._)(t,[{key:"putVectors",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){if(t=this,e.vectors.length<1||e.vectors.length>500)throw Error("Vector batch size must be between 1 and 500 items");return[2,t.handleOperation(function(){return(0,S._)(function(){return(0,I._)(this,function(r){switch(r.label){case 0:return[4,eV.post(t.fetch,"".concat(t.url,"/PutVectors"),e,{headers:t.headers})];case 1:return[2,r.sent()||{}]}})})()})]})}).call(this)}},{key:"getVectors",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){return t=this,[2,t.handleOperation(function(){return(0,S._)(function(){return(0,I._)(this,function(r){switch(r.label){case 0:return[4,eV.post(t.fetch,"".concat(t.url,"/GetVectors"),e,{headers:t.headers})];case 1:return[2,r.sent()]}})})()})]})}).call(this)}},{key:"listVectors",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){if(t=this,void 0!==e.segmentCount){if(e.segmentCount<1||e.segmentCount>16)throw Error("segmentCount must be between 1 and 16");
1if(void 0!==e.segmentIndex&&(e.segmentIndex<0||e.segmentIndex>=e.segmentCount))throw Error("segmentIndex must be between 0 and ".concat(e.segmentCount-1))}return[2,t.handleOperation(function(){return(0,S._)(function(){return(0,I._)(this,function(r){switch(r.label){case 0:return[4,eV.post(t.fetch,"".concat(t.url,"/ListVectors"),e,{headers:t.headers})];case 1:return[2,r.sent()]}})})()})]})}).call(this)}},{key:"queryVectors",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){return t=this,[2,t.handleOperation(function(){return(0,S._)(function(){return(0,I._)(this,function(r){switch(r.label){case 0:return[4,eV.post(t.fetch,"".concat(t.url,"/QueryVectors"),e,{headers:t.headers})];case 1:return[2,r.sent()]}})})()})]})}).call(this)}},{key:"deleteVectors",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){if(t=this,e.keys.length<1||e.keys.length>500)throw Error("Keys batch size must be between 1 and 500 items");return[2,t.handleOperation(function(){return(0,S._)(function(){return(0,I._)(this,function(r){switch(r.label){case 0:return[4,eV.post(t.fetch,"".concat(t.url,"/DeleteVectors"),e,{headers:t.headers})];case 1:return[2,r.sent()||{}]}})})()})]})}).call(this)}}]),t}(eH),e3=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return(0,T._)(this,t),(0,E._)(this,t,[e,r.headers||{},r.fetch])}return(0,A._)(t,e),(0,O._)(t,[{key:"from",value:function(e){return new e5(this.url,this.headers,e,this.fetch)}},{key:"createBucket",value:function(e){var r=this;return(0,S._)(function(){var n;return(0,I._)(this,function(s){return n=this,[2,(0,ey._)((0,eb._)(t.prototype),"createBucket",r).call(n,e)]})}).call(this)}},{key:"getBucket",value:function(e){var r=this;return(0,S._)(function(){var n;return(0,I._)(this,function(s){return n=this,[2,(0,ey._)((0,eb._)(t.prototype),"getBucket",r).call(n,e)]})}).call(this)}},{key:"listBuckets",value:function(){var e=this;return(0,S._)(function(){var r,n,s=arguments;return(0,I._)(this,function(i){return r=s.length>0&&void 0!==s[0]?s[0]:{},n=this,[2,(0,ey._)((0,eb._)(t.prototype),"listBuckets",e).call(n,r)]})}).apply(this,arguments)}},{key:"deleteBucket",value:function(e){var r=this;return(0,S._)(function(){var n;return(0,I._)(this,function(s){return n=this,[2,(0,ey._)((0,eb._)(t.prototype),"deleteBucket",r).call(n,e)]})}).call(this)}}]),t}(function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;(0,T._)(this,t);var s=e.replace(/\/$/,""),i=eN(eN({},eZ),{},{"Content-Type":"application/json"},r);return(0,E._)(this,t,[s,i,n,"vectors"])}return(0,A._)(t,e),(0,O._)(t,[{key:"createBucket",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){return t=this,[2,t.handleOperation(function(){return(0,S._)(function(){return(0,I._)(this,function(r){switch(r.label){case 0:return[4,eV.post(t.fetch,"".concat(t.url,"/CreateVectorBucket"),{vectorBucketName:e},{headers:t.headers})];case 1:return[2,r.sent()||{}]}})})()})]})}).call(this)}},{key:"getBucket",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){return t=this,[2,t.handleOperation(function(){return(0,S._)(function(){return(0,I._)(this,function(r){switch(r.label){case 0:return[4,eV.post(t.fetch,"".concat(t.url,"/GetVectorBucket"),{vectorBucketName:e},{headers:t.headers})];case 1:return[2,r.sent()]}})})()})]})}).call(this)}},{key:"listBuckets",value:function(){return(0,S._)(function(){var e,t,r=arguments;return(0,I._)(this,function(n){return e=r.length>0&&void 0!==r[0]?r[0]:{},t=this,[2,t.handleOperation(function(){return(0,S._)(function(){return(0,I._)(this,function(r){switch(r.label){case 0:return[4,eV.post(t.fetch,"".concat(t.url,"/ListVectorBuckets"),e,{headers:t.headers})];case 1:return[2,r.sent()]}})})()})]})}).apply(this,arguments)}},{key:"deleteBucket",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){return t=this,[2,t.handleOperation(function(){return(0,S._)(function(){return(0,I._)(this,function(r){switch(r.label){case 0:return[4,eV.post(t.fetch,"".concat(t.url,"/DeleteVectorBucket"),{vectorBucketName:e},{headers:t.headers})];case 1:return[2,r.sent()||{}]}})})()})]})}).call(this)}}]),t}(eH)),e5=function(e){function t(e,r,n,s){var i;return(0,T._)(this,t),(i=(0,E._)(this,t,[e,r,s])).vectorBucketName=n,i}return(0,A._)(t,e),(0,O._)(t,[{key:"createIndex",value:function(e){var r=this;return(0,S._)(function(){var n;return(0,I._)(this,function(s){return n=this,[2,(0,ey._)((0,eb._)(t.prototype),"createIndex",r).call(n,eN(eN({},e),{},{vectorBucketName:n.vectorBucketName}))]})}).call(this)}},{key:"listIndexes",value:function(){var e=this;return(0,S._)(function(){var r,n,s=arguments;return(0,I._)(this,function(i){return r=s.length>0&&void 0!==s[0]?s[0]:{},n=this,[2,(0,ey._)((0,eb._)(t.prototype),"listIndexes",e).call(n,eN(eN({},r),{},{vectorBucketName:n.vectorBucketName}))]})}).apply(this,arguments)}},{key:"getIndex",value:function(e){var r=this;return(0,S._)(function(){var n;return(0,I._)(this,function(s){return n=this,[2,(0,ey._)((0,eb._)(t.prototype),"getIndex",r).call(n,n.vectorBucketName,e)]})}).call(this)}},{key:"deleteIndex",value:function(e){var r=this;return(0,S._)(function(){var n;return(0,I._)(this,function(s){return n=this,[2,(0,ey._)((0,eb._)(t.prototype),"deleteIndex",r).call(n,n.vectorBucketName,e)]})}).call(this)}},{key:"index",value:function(e){return new e6(this.url,this.headers,this.vectorBucketName,e,this.fetch)}}]),t}(e1),e6=function(e){function t(e,r,n,s,i){var a;return(0,T._)(this,t),(a=(0,E._)(this,t,[e,r,i])).vectorBucketName=n,a.indexName=s,a}return(0,A._)(t,e),(0,O._)(t,[{key:"putVectors",value:function(e){var r=this;return(0,S._)(function(){var n;return(0,I._)(this,function(s){return n=this,[2,(0,ey._)((0,eb._)(t.prototype),"putVectors",r).call(n,eN(eN({},e),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))]})}).call(this)}},{key:"getVectors",value:function(e){var r=this;return(0,S._)(function(){var n;return(0,I._)(this,function(s){return n=this,[2,(0,ey._)((0,eb._)(t.prototype),"getVectors",r).call(n,eN(eN({},e),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))]})}).call(this)}},{key:"listVectors",value:function(){var e=this;return(0,S._)(function(){var r,n,s=arguments;return(0,I._)(this,function(i){return r=s.length>0&&void 0!==s[0]?s[0]:{},n=this,[2,(0,ey._)((0,eb._)(t.prototype),"listVectors",e).call(n,eN(eN({},r),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))]})}).apply(this,arguments)}},{key:"queryVectors",value:function(e){var r=this;return(0,S._)(function(){var n;return(0,I._)(this,function(s){return n=this,[2,(0,ey._)((0,eb._)(t.prototype),"queryVectors",r).call(n,eN(eN({},e),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))]})}).call(this)}},{key:"deleteVectors",value:function(e){var r=this;return(0,S._)(function(){var n;return(0,I._)(this,function(s){return n=this,[2,(0,ey._)((0,eb._)(t.prototype),"deleteVectors",r).call(n,eN(eN({},e),{},{vectorBucketName:n.vectorBucketName,indexName:n.indexName}))]})}).call(this)}}]),t}(e4),e8=function(e){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,s=arguments.length>3?arguments[3]:void 0;return(0,T._)(this,t),(0,E._)(this,t,[e,r,n,s])}return(0,A._)(t,e),(0,O._)(t,[{key:"from",value:function(e){return new eQ(this.url,this.headers,e,this.fetch)}},{key:"vectors",get:function(){return new e3(this.url+"/vector",{headers:this.headers,fetch:this.fetch})}},{key:"analytics",get:function(){return new e2(this.url+"/iceberg",this.headers,this.fetch)}}]),t}(e0),e7="2.99.1",e9="X-Supabase-Api-Version",te={"2024-01-01":{timestamp:Date.parse("2024-01-01T00:00:00.0Z"),name:"2024-01-01"}},tt=/^([a-z0-9_-]{4})*($|[a-z0-9_-]{3}$|[a-z0-9_-]{2}$)$/i,tr=function(e){function t(e,r,n){var s;return(0,T._)(this,t),(s=(0,E._)(this,t,[e])).__isAuthError=!0,s.name="AuthError",s.status=r,s.code=n,s}return(0,A._)(t,e),t}((0,j._)(Error));function tn(e){return(void 0===e?"undefined":(0,q._)(e))==="object"&&null!==e&&"__isAuthError"in e}var ts=function(e){function t(e,r,n){var s;return(0,T._)(this,t),(s=(0,E._)(this,t,[e,r,n])).name="AuthApiError",s.status=r,s.code=n,s}return(0,A._)(t,e),t}(tr),ti=function(e){function t(e,r){var n;return(0,T._)(this,t),(n=(0,E._)(this,t,[e])).name="AuthUnknownError",n.originalError=r,n}return(0,A._)(t,e),t}(tr),ta=function(e){function t(e,r,n,s){var i;return(0,T._)(this,t),(i=(0,E._)(this,t,[e,n,s])).name=r,i.status=n,i}return(0,A._)(t,e),t}(tr),to=function(e){function t(){return(0,T._)(this,t),(0,E._)(this,t,["Auth session missing!","AuthSessionMissingError",400,void 0])}return(0,A._)(t,e),t}(ta);function tu(e){return tn(e)&&"AuthSessionMissingError"===e.name}var tc=function(e){function t(){return(0,T._)(this,t),(0,E._)(this,t,["Auth session or user missing","AuthInvalidToken
1ResponseError",500,void 0])}return(0,A._)(t,e),t}(ta),tl=function(e){function t(e){return(0,T._)(this,t),(0,E._)(this,t,[e,"AuthInvalidCredentialsError",400,void 0])}return(0,A._)(t,e),t}(ta),th=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return(0,T._)(this,t),(r=(0,E._)(this,t,[e,"AuthImplicitGrantRedirectError",500,void 0])).details=null,r.details=n,r}return(0,A._)(t,e),(0,O._)(t,[{key:"toJSON",value:function(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}]),t}(ta),tf=function(e){function t(e){var r,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;return(0,T._)(this,t),(r=(0,E._)(this,t,[e,"AuthPKCEGrantCodeExchangeError",500,void 0])).details=null,r.details=n,r}return(0,A._)(t,e),(0,O._)(t,[{key:"toJSON",value:function(){return{name:this.name,message:this.message,status:this.status,details:this.details}}}]),t}(ta),td=function(e){function t(){return(0,T._)(this,t),(0,E._)(this,t,["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"])}return(0,A._)(t,e),t}(ta),tp=function(e){function t(e,r){return(0,T._)(this,t),(0,E._)(this,t,[e,"AuthRetryableFetchError",r,void 0])}return(0,A._)(t,e),t}(ta);function tv(e){return tn(e)&&"AuthRetryableFetchError"===e.name}var t_=function(e){function t(e,r,n){var s;return(0,T._)(this,t),(s=(0,E._)(this,t,[e,"AuthWeakPasswordError",r,"weak_password"])).reasons=n,s}return(0,A._)(t,e),t}(ta),tg=function(e){function t(e){return(0,T._)(this,t),(0,E._)(this,t,[e,"AuthInvalidJwtError",400,"invalid_jwt"])}return(0,A._)(t,e),t}(ta),ty="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".split(""),tb=" 	\n\r=".split(""),tm=function(){for(var e=Array(128),t=0;t<e.length;t+=1)e[t]=-1;for(var r=0;r<tb.length;r+=1)e[tb[r].charCodeAt(0)]=-2;for(var n=0;n<ty.length;n+=1)e[ty[n].charCodeAt(0)]=n;return e}();function tw(e,t,r){if(null!==e)for(t.queue=t.queue<<8|e,t.queuedBits+=8;t.queuedBits>=6;)r(ty[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(ty[t.queue>>t.queuedBits-6&63]),t.queuedBits-=6}function tk(e,t,r){var n=tm[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 "'.concat(String.fromCharCode(e),'"'))}function tS(e){for(var t=[],r=function(e){t.push(String.fromCodePoint(e))},n={utf8seq:0,codepoint:0},s={queue:0,queuedBits:0},i=function(e){!function(e,t,r){if(0===t.utf8seq){if(e<=127)return r(e);for(var n=1;n<6;n+=1)if((e>>7-n&1)==0){t.utf8seq=n;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)},a=0;a<e.length;a+=1)tk(e.charCodeAt(a),s,i);return t.join("")}function tE(e){for(var t=[],r={queue:0,queuedBits:0},n=function(e){t.push(e)},s=0;s<e.length;s+=1)tk(e.charCodeAt(s),r,n);return new Uint8Array(t)}function tT(e){var t=[],r={queue:0,queuedBits:0},n=function(e){t.push(e)};return e.forEach(function(e){return tw(e,r,n)}),tw(null,r,n),t.join("")}var tO=function(){return"undefined"!=typeof window&&"undefined"!=typeof document},tA={tested:!1,writable:!1},tR=function(){if(!tO())return!1;try{if("object"!==(0,q._)(globalThis.localStorage))return!1}catch(e){return!1}if(tA.tested)return tA.writable;var e="lswt-".concat(Math.random()).concat(Math.random());try{globalThis.localStorage.setItem(e,e),globalThis.localStorage.removeItem(e),tA.tested=!0,tA.writable=!0}catch(e){tA.tested=!0,tA.writable=!1}return tA.writable},tI=function(e){return e?function(){for(var t=arguments.length,r=Array(t),n=0;n<t;n++)r[n]=arguments[n];return e.apply(void 0,(0,R._)(r))}:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return fetch.apply(void 0,(0,R._)(t))}},tj=function(e,t,r){return(0,S._)(function(){return(0,I._)(this,function(n){switch(n.label){case 0:return[4,e.setItem(t,JSON.stringify(r))];case 1:return n.sent(),[2]}})})()},tP=function(e,t){return(0,S._)(function(){var r;return(0,I._)(this,function(n){switch(n.label){case 0:return[4,e.getItem(t)];case 1:if(!(r=n.sent()))return[2,null];try{return[2,JSON.parse(r)]}catch(e){return[2,r]}}})})()},tC=function(e,t){return(0,S._)(function(){return(0,I._)(this,function(r){switch(r.label){case 0:return[4,e.removeItem(t)];case 1:return r.sent(),[2]}})})()},tU=function e(){var t=this;(0,T._)(this,e),this.promise=new e.promiseConstructor(function(e,r){t.resolve=e,t.reject=r})};function tx(e){var t=e.split(".");if(3!==t.length)throw new tg("Invalid JWT structure");for(var r=0;r<t.length;r++)if(!tt.test(t[r]))throw new tg("JWT not in base64url format");return{header:JSON.parse(tS(t[0])),payload:JSON.parse(tS(t[1])),signature:tE(t[2]),raw:{header:t[0],payload:t[1]}}}function tN(e){return("0"+e.toString(16)).substr(-2)}function tL(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return(0,S._)(function(){var n,s,i,a;return(0,I._)(this,function(o){switch(o.label){case 0:return s=n=function(){var e=new Uint32Array(56);if("undefined"==typeof crypto){for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",r=t.length,n="",s=0;s<56;s++)n+=t.charAt(Math.floor(Math.random()*r));return n}return crypto.getRandomValues(e),Array.from(e,tN).join("")}(),r&&(s+="/PASSWORD_RECOVERY"),[4,tj(e,"".concat(t,"-code-verifier"),s)];case 1:var u;return o.sent(),[4,(u=n,(0,S._)(function(){return(0,I._)(this,function(e){switch(e.label){case 0:if("undefined"==typeof crypto||void 0===crypto.subtle||"undefined"==typeof TextEncoder)return console.warn("WebCrypto API is not supported. Code 
1challenge method will default to use plain instead of sha256."),[2,u];return[4,(0,S._)(function(){var e;return(0,I._)(this,function(t){switch(t.label){case 0:return e=new TextEncoder().encode(u),[4,crypto.subtle.digest("SHA-256",e)];case 1:return[2,Array.from(new Uint8Array(t.sent())).map(function(e){return String.fromCharCode(e)}).join("")]}})})()];case 1:return[2,btoa(e.sent()).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")]}})})())];case 2:return i=o.sent(),a=n===i?"plain":"s256",[2,[i,a]]}})})()}tU.promiseConstructor=Promise;var tB=/^2[0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|1[0-9]|2[0-9]|3[0-1])$/i,tD=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;function tq(e){if(!tD.test(e))throw Error("@supabase/auth-js: Expected parameter to be UUID but is not")}function tM(){return new Proxy({},{get:function(e,t){if("__isUserNotAvailableProxy"===t)return!0;if((void 0===t?"undefined":(0,q._)(t))==="symbol"){var r=t.toString();if("Symbol(Symbol.toPrimitive)"===r||"Symbol(Symbol.toStringTag)"===r||"Symbol(util.inspect.custom)"===r)return}throw Error('@supabase/auth-js: client was created with userStorage option and there was no user stored in the user storage. Accessing the "'.concat(t,'" property of the session object is not supported. Please use getUser() instead.'))},set:function(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 "'.concat(t,'" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.'))},deleteProperty:function(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 "'.concat(t,'" property of the session object is not supported. Please use getUser() to fetch a user object you can manipulate.'))}})}function tK(e){return JSON.parse(JSON.stringify(e))}var tW=function(e){return e.msg||e.message||e.error_description||e.error||JSON.stringify(e)},tF=[502,503,504];function tz(e){return(0,S._)(function(){var t,r,n,s,i;return(0,I._)(this,function(a){switch(a.label){case 0:if(!((void 0===e?"undefined":(0,q._)(e))==="object"&&null!==e&&"status"in e&&"ok"in e&&"json"in e&&"function"==typeof e.json))throw new tp(tW(e),0);if(tF.includes(e.status))throw new tp(tW(e),e.status);a.label=1;case 1:return a.trys.push([1,3,,4]),[4,e.json()];case 2:return r=a.sent(),[3,4];case 3:throw new ti(tW(n=a.sent()),n);case 4:if(s=void 0,(i=function(e){var t=e.headers.get(e9);if(!t||!t.match(tB))return null;try{return new Date("".concat(t,"T00:00:00.0Z"))}catch(e){return null}}(e))&&i.getTime()>=te["2024-01-01"].timestamp&&(void 0===r?"undefined":(0,q._)(r))==="object"&&r&&"string"==typeof r.code?s=r.code:(void 0===r?"undefined":(0,q._)(r))==="object"&&r&&"string"==typeof r.error_code&&(s=r.error_code),s){if("weak_password"===s)throw new t_(tW(r),e.status,(null==(t=r.weak_password)?void 0:t.reasons)||[]);else if("session_not_found"===s)throw new to}else if((void 0===r?"undefined":(0,q._)(r))==="object"&&r&&"object"===(0,q._)(r.weak_password)&&r.weak_password&&Array.isArray(r.weak_password.reasons)&&r.weak_password.reasons.length&&r.weak_password.reasons.reduce(function(e,t){return e&&"string"==typeof t},!0))throw new t_(tW(r),e.status,r.weak_password.reasons);throw new ts(tW(r),e.status||500,s)}})})()}var tJ=function(e,t,r,n){var 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))};function tV(e,t,r,n){return(0,S._)(function(){var s,i,a,o;return(0,I._)(this,function(u){switch(u.label){case 0:var c,l,h,f,d,p;return(i=Object.assign({},null==n?void 0:n.headers))[e9]||(i[e9]=te["2024-01-01"].name),(null==n?void 0:n.jwt)&&(i.Authorization="Bearer ".concat(n.jwt)),a=null!=(s=null==n?void 0:n.query)?s:{},(null==n?void 0:n.redirectTo)&&(a.redirect_to=n.redirectTo),[4,(c=e,l=t,h=r+(Object.keys(a).length?"?"+new URLSearchParams(a).toString():""),f={headers:i,noResolveJson:null==n?void 0:n.noResolveJson},d={},p=null==n?void 0:n.body,(0,S._)(function(){var e,t,r;return(0,I._)(this,function(n){switch(n.label){case 0:e=tJ(l,f,d,p),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,c(h,Object.assign({},e))];case 2:return t=n.sent(),[3,4];case 3:throw console.error(r=n.sent()),new tp(tW(r),0);case 4:if(t.ok)return[3,6];return[4,tz(t)];case 5:n.sent(),n.label=6;case 6:if(null==f?void 0:f.noResolveJson)return[2,t];n.label=7;case 7:return n.trys.push([7,9,,11]),[4,t.json()];case 8:return[2,n.sent()];case 9:return[4,tz(n.sent())];case 10:return n.sent(),[3,11];case 11:return[2]}})})())];case 1:return o=u.sent(),[2,(null==n?void 0:n.xform)?null==n?void 0:n.xform(o):{data:Object.assign({},o),error:null}]}})})()}function tH(e){var t,r,n,s=null;(t=e).access_token&&t.refresh_token&&t.expires_in&&(s=Object.assign({},e),e.expires_at||(s.expires_at=(r=e.expires_in,Math.round(Date.now()/1e3)+r)));return{data:{session:s,user:null!=(n=e.user)?n:e},error:null}}function tG(e){var t=tH(e);return!t.error&&e.weak_password&&"object"===(0,q._)(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(function(e,t){return e&&"string"==typeof t},!0)&&(t.data.weak_password=e.weak_password),t}function tY(e){var t;return{data:{user:null!=(t=e.user)?t:e},error:null}}function t$(e){return{data:e,error:null}}function tX(e){return{data:{properties:{action_link:e.action_link,email_otp:e.email_otp,hashed_token:e.hashed_token,redirect_to:e.redirect_to,verification_type:e.verification_type},user:Object.assign({},(0,L.__rest)(e,["action_link","email_otp","hashed_token","redirect_to","verification_type"]))},error:null}}function tQ(e){return e}var tZ=["global","local","others"],t0=function(){function e(t){var r=t.url,n=t.headers,s=t.fetch;(0,T._)(this,e),this.url=void 0===r?"":r,this.headers=void 0===n?{}:n,this.fetch=tI(s),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)}}return(0,O._)(e,[{key:"signOut",value:function(e){return(0,S._)(function(e){var t,r,n=arguments;return(0,I._)(this,function(s){switch(s.label){case 0:if(t=n.length>1&&void 0!==n[1]?n[1]:tZ[0],0>tZ.indexOf(t))throw Error("@supabase/auth-js: Parameter scope must be one of ".concat(tZ.join(", ")));s.label=1;case 1:return s.trys.push([1,3,,4]),[4,tV(this.fetch,"POST","".concat(this.url,"/logout?scope=").concat(t),{headers:this.headers,jwt:e,noResolveJson:!0})];case 2:return s.sent(),[2,{data:null,error:null}];case 3:if(tn(r=s.sent()))return[2,{data:null,error:r}];throw r;case 4:return[2]}})}).apply(this,arguments)}},{key:"inviteUserByEmail",value:function(e){return(0,S._)(function(e){var t,r,n=arguments;return(0,I._)(this,function(s){switch(s.label){case 0:t=n.length>1&&void 0!==n[1]?n[1]:{},s.label=1;case 1:return s.trys.push([1,3,,4]),[4,tV(this.fetch,"POST","".concat(this.url,"/invite"),{body:{email:e,data:t.data},headers:this.headers,redirectTo:t.redirectTo,xform:tY})];case 2:return[2,s.sent()];case 3:if(tn(r=s.sent()))return[2,{data:{user:null},error:r}];throw r;case 4:return[2]}})}).apply(this,arguments)}},{key:"generateLink",value:function(e){return(0,S._)(function(){var t,r,n,s;return(0,I._)(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),t=e.options,n=Object.assign(Object.assign({},r=(0,L.__rest)(e,["options"])),t),"newEmail"in r&&(n.new_email=null==r?void 0:r.newEmail,delete n.newEmail),[4,tV(this.fetch,"POST","".concat(this.url,"/admin/generate_link"),{body:n,headers:this.headers,xform:tX,redirectTo:null==t?void 0:t.redirectTo})];case 1:return[2,i.sent()];case 2:if(tn(s=i.sent()))return[2,{data:{properties:null,user:null},error:s}];throw s;case 3:return[2]}})}).call(this)}},{key:"createUser",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,tV(this.fetch,"POST","".concat(this.url,"/admin/users"),{body:e,headers:this.headers,xform:tY})];case 1:return[2,r.sent()];case 2:if(tn(t=r.sent()))return[2,{data:{user:null},error:t}];throw t;case 3:return[2]}})}).call(this)}},{key:"listUsers",value:function(e){return(0,S._)(function(){var t,r,n,s,i,a,o,u,c,l,h,f,d;return(0,I._)(this,function(p){switch(p.label){case 0:return p.trys.push([0,3,,4]),u={nextPage:null,lastPage:0,total:0},[4,tV(this.fetch,"GET","".concat(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!=(s=null==(n=null==e?void 0:e.perPage)?void 0:n.toString())?s:""},xform:tQ})];case 1:if((c=p.sent()).error)throw c.error;return[4,c.json()];case 2:return l=p.sent(),h=null!=(i=c.headers.get("x-total-count"))?i:0,(f=null!=(o=null==(a=c.headers.get("link"))?void 0:a.split(","))?o:[]).length>0&&(f.forEach(function(e){var t=parseInt(e.split(";")[0].split("=")[1].substring(0,1)),r=JSON.parse(e.split(";")[1].split("=")[1]);u["".concat(r,"Page")]=t}),u.total=parseInt(h)),[2,{data:Object.assign(Object.assign({},l),u),error:null}];case 3:if(tn(d=p.sent()))return[2,{data:{users:[]},error:d}];throw d;case 4:return[2]}})}).call(this)}},{key:"getUserById",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){switch(r.label){case 0:tq(e),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,tV(this.fetch,"GET","".concat(this.url,"/admin/users/").concat(e),{headers:this.headers,xform:tY})];case 2:return[2,r.sent()];case 3:if(tn(t=r.sent()))return[2,{data:{user:null},error:t}];throw t;case 4:return[2]}})}).call(this)}},{key:"updateUserById",value:function(e,t){return(0,S._)(function(){var r;return(0,I._)(this,function(n){switch(n.label){case 0:tq(e),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,tV(this.fetch,"PUT","".concat(this.url,"/admin/users/").concat(e),{body:t,headers:this.headers,xform:tY})];case 2:return[2,n.sent()];case 3:if(tn(r=n.sent()))return[2,{data:{user:null},error:r}];throw r;case 4:return[2]}})}).call(this)}},{key:"deleteUser",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return(0,S._)(function(){var r;return(0,I._)(this,function(n){switch(n.label){case 0:tq(e),n.label=1;
1case 1:return n.trys.push([1,3,,4]),[4,tV(this.fetch,"DELETE","".concat(this.url,"/admin/users/").concat(e),{headers:this.headers,body:{should_soft_delete:t},xform:tY})];case 2:return[2,n.sent()];case 3:if(tn(r=n.sent()))return[2,{data:{user:null},error:r}];throw r;case 4:return[2]}})}).call(this)}},{key:"_listFactors",value:function(e){return(0,S._)(function(){var t,r;return(0,I._)(this,function(n){switch(n.label){case 0:tq(e.userId),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,tV(this.fetch,"GET","".concat(this.url,"/admin/users/").concat(e.userId,"/factors"),{headers:this.headers,xform:function(e){return{data:{factors:e},error:null}}})];case 2:return[2,{data:(t=n.sent()).data,error:t.error}];case 3:if(tn(r=n.sent()))return[2,{data:null,error:r}];throw r;case 4:return[2]}})}).call(this)}},{key:"_deleteFactor",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){switch(r.label){case 0:tq(e.userId),tq(e.id),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,tV(this.fetch,"DELETE","".concat(this.url,"/admin/users/").concat(e.userId,"/factors/").concat(e.id),{headers:this.headers})];case 2:return[2,{data:r.sent(),error:null}];case 3:if(tn(t=r.sent()))return[2,{data:null,error:t}];throw t;case 4:return[2]}})}).call(this)}},{key:"_listOAuthClients",value:function(e){return(0,S._)(function(){var t,r,n,s,i,a,o,u,c,l,h,f,d;return(0,I._)(this,function(p){switch(p.label){case 0:return p.trys.push([0,3,,4]),u={nextPage:null,lastPage:0,total:0},[4,tV(this.fetch,"GET","".concat(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!=(s=null==(n=null==e?void 0:e.perPage)?void 0:n.toString())?s:""},xform:tQ})];case 1:if((c=p.sent()).error)throw c.error;return[4,c.json()];case 2:return l=p.sent(),h=null!=(i=c.headers.get("x-total-count"))?i:0,(f=null!=(o=null==(a=c.headers.get("link"))?void 0:a.split(","))?o:[]).length>0&&(f.forEach(function(e){var t=parseInt(e.split(";")[0].split("=")[1].substring(0,1)),r=JSON.parse(e.split(";")[1].split("=")[1]);u["".concat(r,"Page")]=t}),u.total=parseInt(h)),[2,{data:Object.assign(Object.assign({},l),u),error:null}];case 3:if(tn(d=p.sent()))return[2,{data:{clients:[]},error:d}];throw d;case 4:return[2]}})}).call(this)}},{key:"_createOAuthClient",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,tV(this.fetch,"POST","".concat(this.url,"/admin/oauth/clients"),{body:e,headers:this.headers,xform:function(e){return{data:e,error:null}}})];case 1:return[2,r.sent()];case 2:if(tn(t=r.sent()))return[2,{data:null,error:t}];throw t;case 3:return[2]}})}).call(this)}},{key:"_getOAuthClient",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,tV(this.fetch,"GET","".concat(this.url,"/admin/oauth/clients/").concat(e),{headers:this.headers,xform:function(e){return{data:e,error:null}}})];case 1:return[2,r.sent()];case 2:if(tn(t=r.sent()))return[2,{data:null,error:t}];throw t;case 3:return[2]}})}).call(this)}},{key:"_updateOAuthClient",value:function(e,t){return(0,S._)(function(){var r;return(0,I._)(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,tV(this.fetch,"PUT","".concat(this.url,"/admin/oauth/clients/").concat(e),{body:t,headers:this.headers,xform:function(e){return{data:e,error:null}}})];case 1:return[2,n.sent()];case 2:if(tn(r=n.sent()))return[2,{data:null,error:r}];throw r;case 3:return[2]}})}).call(this)}},{key:"_deleteOAuthClient",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,tV(this.fetch,"DELETE","".concat(this.url,"/admin/oauth/clients/").concat(e),{headers:this.headers,noResolveJson:!0})];case 1:return r.sent(),[2,{data:null,error:null}];case 2:if(tn(t=r.sent()))return[2,{data:null,error:t}];throw t;case 3:return[2]}})}).call(this)}},{key:"_regenerateOAuthClientSecret",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,tV(this.fetch,"POST","".concat(this.url,"/admin/oauth/clients/").concat(e,"/regenerate_secret"),{headers:this.headers,xform:function(e){return{data:e,error:null}}})];case 1:return[2,r.sent()];case 2:if(tn(t=r.sent()))return[2,{data:null,error:t}];throw t;case 3:return[2]}})}).call(this)}},{key:"_listCustomProviders",value:function(e){return(0,S._)(function(){var t,r;return(0,I._)(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),t={},(null==e?void 0:e.type)&&(t.type=e.type),[4,tV(this.fetch,"GET","".concat(this.url,"/admin/custom-providers"),{headers:this.headers,query:t,xform:function(e){var t;return{data:{providers:null!=(t=null==e?void 0:e.providers)?t:[]},error:null}}})];case 1:return[2,n.sent()];case 2:if(tn(r=n.sent()))return[2,{data:{providers:[]},error:r}];throw r;case 3:return[2]}})}).call(this)}},{key:"_createCustomProvider",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,tV(this.fetch,"POST","".concat(this.url,"/admin/custom-providers"),{body:e,headers:this.headers,xform:function(e){return{data:e,error:null}}})];case 1:return[2,r.sent()];case 2:if(tn(t=r.sent()))return[2,{data:null,error:t}];throw t;case 3:return[2]}})}).call(this)}},{key:"_getCustomProvider",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,tV(this.fetch,"GET","".concat(this.url,"/admin/custom-providers/").concat(e),{headers:this.headers,xform:function(e){return{data:e,error:null}}})];case 1:return[2,r.sent()];case 2:if(tn(t=r.sent()))return[2,{data:null,error:t}];throw t;case 3:return[2]}})}).call(this)}},{key:"_updateCustomProvider",value:function(e,t){return(0,S._)(function(){var r;return(0,I._)(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,tV(this.fetch,"PUT","".concat(this.url,"/admin/custom-providers/").concat(e),{body:t,headers:this.headers,xform:function(e){return{data:e,error:null}}})];case 1:return[2,n.sent()];case 2:if(tn(r=n.sent()))return[2,{data:null,error:r}];throw r;case 3:return[2]}})}).call(this)}},{key:"_deleteCustomProvider",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,tV(this.fetch,"DELET
1E","".concat(this.url,"/admin/custom-providers/").concat(e),{headers:this.headers,noResolveJson:!0})];case 1:return r.sent(),[2,{data:null,error:null}];case 2:if(tn(t=r.sent()))return[2,{data:null,error:t}];throw t;case 3:return[2]}})}).call(this)}}]),e}();function t2(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{getItem:function(t){return e[t]||null},setItem:function(t,r){e[t]=r},removeItem:function(t){delete e[t]}}}var t1={debug:!!(globalThis&&tR()&&globalThis.localStorage&&"true"===globalThis.localStorage.getItem("supabase.gotrue-js.locks.debug"))},t4=function(e){function t(e){var r;return(0,T._)(this,t),(r=(0,E._)(this,t,[e])).isAcquireTimeout=!0,r}return(0,A._)(t,e),t}((0,j._)(Error)),t3=function(e){function t(){return(0,T._)(this,t),(0,E._)(this,t,arguments)}return(0,A._)(t,e),t}(t4);function t5(e,t,r){return(0,S._)(function(){var n,s;return(0,I._)(this,function(i){switch(i.label){case 0:return t1.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire lock",e,t),n=new globalThis.AbortController,t>0&&setTimeout(function(){n.abort(),t1.debug&&console.log("@supabase/gotrue-js: navigatorLock acquire timed out",e)},t),[4,Promise.resolve()];case 1:i.sent(),i.label=2;case 2:return i.trys.push([2,4,,7]),[4,globalThis.navigator.locks.request(e,0===t?{mode:"exclusive",ifAvailable:!0}:{mode:"exclusive",signal:n.signal},function(n){return(0,S._)(function(){return(0,I._)(this,function(s){switch(s.label){case 0:if(!n)return[3,5];t1.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquired",e,n.name),s.label=1;case 1:return s.trys.push([1,,3,4]),[4,r()];case 2:return[2,s.sent()];case 3:return t1.debug&&console.log("@supabase/gotrue-js: navigatorLock: released",e,n.name),[7];case 4:return[3,12];case 5:if(0!==t)return[3,6];throw t1.debug&&console.log("@supabase/gotrue-js: navigatorLock: not immediately available",e),new t3('Acquiring an exclusive Navigator LockManager lock "'.concat(e,'" immediately failed'));case 6:if(!t1.debug)return[3,10];s.label=7;case 7:return s.trys.push([7,9,,10]),[4,globalThis.navigator.locks.query()];case 8:return console.log("@supabase/gotrue-js: Navigator LockManager state",JSON.stringify(s.sent(),null,"  ")),[3,10];case 9:return console.warn("@supabase/gotrue-js: Error when querying Navigator LockManager state",s.sent()),[3,10];case 10: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"),[4,r()];case 11:return[2,s.sent()];case 12:return[2]}})})()})];case 3:case 5:return[2,i.sent()];case 4:if(!((null==(s=i.sent())?void 0:s.name)==="AbortError"&&t>0))return[3,6];return t1.debug&&console.log("@supabase/gotrue-js: navigatorLock: acquire timeout, recovering by stealing lock",e),console.warn('@supabase/gotrue-js: Lock "'.concat(e,'" was not released within ').concat(t,"ms. ")+"This may indicate an orphaned lock from a component unmount (e.g., React Strict Mode). Forcefully acquiring the lock to recover."),[4,Promise.resolve().then(function(){return globalThis.navigator.locks.request(e,{mode:"exclusive",steal:!0},function(t){return(0,S._)(function(){return(0,I._)(this,function(n){switch(n.label){case 0:if(!t)return[3,5];t1.debug&&console.log("@supabase/gotrue-js: navigatorLock: recovered (stolen)",e,t.name),n.label=1;case 1:return n.trys.push([1,,3,4]),[4,r()];case 2:case 6:return[2,n.sent()];case 3:return t1.debug&&console.log("@supabase/gotrue-js: navigatorLock: released (stolen)",e,t.name),[7];case 4:return[3,7];case 5:return console.warn("@supabase/gotrue-js: Navigator LockManager returned null lock even with steal: true"),[4,r()];case 7:return[2]}})})()})})];case 6:throw s;case 7:return[2]}})})()}function t6(e){if(!/^0x[a-fA-F0-9]{40}$/.test(e))throw Error('@supabase/auth-js: Address "'.concat(e,'" is invalid.'));return e.toLowerCase()}(0,A._)(function e(){return(0,T._)(this,e),(0,E._)(this,e,arguments)},t4);var t8=function(e){function t(e){var r,n,s=e.message,i=e.code,a=e.cause,o=e.name;return(0,T._)(this,t),(r=(0,E._)(this,t,[s,{cause:a}])).__isWebAuthnError=!0,r.name=null!=(n=null!=o?o:(0,N._)(a,Error)?a.name:void 0)?n:"Unknown Error",r.code=i,r}return(0,A._)(t,e),t}((0,j._)(Error)),t7=function(e){function t(e,r){var n;return(0,T._)(this,t),(n=(0,E._)(this,t,[{code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:r,message:e}])).name="WebAuthnUnknownError",n.originalError=r,n}return(0,A._)(t,e),t}(t8),t9=new(function(){function e(){(0,T._)(this,e)}return(0,O._)(e,[{key:"createNewAbortSignal",value:function(){if(this.controller){var e=Error("Cancelling existing WebAuthn API call for new one");e.name="AbortError",this.controller.abort(e)}var t=new AbortController;return this.controller=t,t.signal}},{key:"cancelCeremony",value:function(){if(this.controller){var e=Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}}]),e}());function re(e){return"localhost"===e||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(e)}function rt(){var e,t;return!!(tO()&&"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))}var rr={hints:["security-key"],authenticatorSelection:{authenticatorAttachment:"cross-platform",requireResidentKey:!1,userVerification:"preferred",residentKey:"discouraged"},attestation:"direct"},rn={userVerification:"preferred",hints:["security-key"],attestation:"direct"};function rs(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=function(e){return null!==e&&(void 0===e?"undefined":(0,q._)(e))==="object"&&!Array.isArray(e)},s={},i=!0,a=!1,o=void 0;try{for(var u,c=t[Symbol.iterator]();!(i=(u=c.next()).done);i=!0){var l=u.value;if(l)for(var h in l){var f=l[h];if(void 0!==f)if(Array.isArray(f))s[h]=f;else if((0,N._)(f,ArrayBuffer)||ArrayBuffer.isView(f))s[h]=f;else if(n(f)){var d=s[h];n(d)?s[h]=rs(d,f):s[h]=rs(f)}else s[h]=f}}}catch(e){a=!0,o=e}finally{try{i||null==c.return||c.return()}finally{if(a)throw o}}return s}var ri=function(){function e(t){(0,T._)(this,e),this.client=t,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)}return(0,O._)(e,[{key:"_enroll",value:function(e){return(0,S._)(function(){return(0,I._)(this,function(t){return[2,this.client.mfa.enroll(Object.assign(Object.assign({},e),{factorType:"webauthn"}))]})}).call(this)}},{key:"_challenge",value:function(e,t){return(0,S._)(function(e,t){var r,n,s,i,a,o,u,c,l,h,f,d,p,v,_,g,y,b,m,w,k;return(0,I._)(this,function(E){var T,O;switch(E.label){case 0:r=e.factorId,n=e.webauthn,s=e.friendlyName,i=e.signal,E.label=1;case 1:return E.trys.push([1,12,,13]),[4,this.client.mfa.challenge({factorId:r,webauthn:n})];case 2:if(u=(o=E.sent()).data,c=o.error,!u)return[2,{data:null,error:c}];if(l=null!=i?i:t9.createNewAbortSignal(),"create"!==u.webauthn.type)return[3,6];if((h=u.webauthn.credential_options.publicKey.user).name)return[3,5];if(f=s)return[3,4];return[4,this.client.getUser()];case 3:return p=(null==(a=null==(d=E.sent().data.user)?void 0:d.user_metadata)?void 0:a.name)||(null==d?void 0:d.email)||(null==d?void 0:d.id)||"User",h.name="".concat(h.id,":").concat(p),[3,5];case 4:h.name="".concat(h.id,":").concat(f),E.label=5;case 5:h.displayName||(h.displayName=h.name),E.label=6;case 6:switch(u.webauthn.type){case"create":return[3,7];case"request":return[3,9]}return[3,11];case 7:return[4,(T={publicKey:rs(rr,u.webauthn.credential_options.publicKey,(null==t?void 0:t.create)||{}),signal:l},(0,S._)(function(){var e;return(0,I._)(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,navigator.credentials.create(T)];case 1:if(!(e=t.sent()))return[2,{data:null,error:new t7("Empty credential response",e)}];if(!(0,N._)(e,PublicKeyCredential))return[2,{data:null,error:new t7("Browser returned unexpected credential type",e)}];return[2,{data:e,error:null}];case 2:return[2,{data:null,error:function(e){var t,r,n,s=e.error,i=e.options,a=i.publicKey;if(!a)throw Error("options was missing required publicKey property");if("AbortError"===s.name){if((0,N._)(i.signal,AbortSignal))return new t8({message:"Registration ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:s})}else if("ConstraintError"===s.name){if((null==(t=a.authenticatorSelection)?void 0:t.requireResidentKey)===!0)return new t8({message:"Discoverable credentials were required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",cause:s});else if("conditional"===i.mediation&&(null==(r=a.authenticatorSelection)?void 0:r.userVerification)==="required")return new t8({message:"User verification was required during automatic registration but it could not be performed",code:"ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE",cause:s});else if((null==(n=a.authenticatorSelection)?void 0:n.userVerification)==="required")return new t8({message:"User verification was required but no available authenticator supported it",code:"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT",cause:s})}else if("InvalidStateError"===s.name)return new t8({message:"The authenticator was previously registered",code:"ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED",cause:s});else if("NotAllowedError"===s.name)return new t8({message:s.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:s});else if("NotSupportedError"===s.name)return new t8(0===a.pubKeyCredParams.filter(function(e){return"public-key"===e.type}).length?{message:'No entry in pubKeyCredParams was of type "public-key"',code:"ERROR_MALFORMED_PUBKEYCREDPARAMS",cause:s}:{message:"No available authenticator supported any of the specified pubKeyCredParams algorithms",code:"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",cause:s});else if("SecurityError"===s.name){var o=window.location.hostname;if(!re(o))return new t8({message:"".concat(window.location.hostname," is an invali
1d domain"),code:"ERROR_INVALID_DOMAIN",cause:s});if(a.rp.id!==o)return new t8({message:'The RP ID "'.concat(a.rp.id,'" is invalid for this domain'),code:"ERROR_INVALID_RP_ID",cause:s})}else if("TypeError"===s.name){if(a.user.id.byteLength<1||a.user.id.byteLength>64)return new t8({message:"User ID was not between 1 and 64 characters",code:"ERROR_INVALID_USER_ID_LENGTH",cause:s})}else if("UnknownError"===s.name)return new t8({message:"The authenticator was unable to process the specified options, or could not create a new credential",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:s});return new t8({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:s})}({error:t.sent(),options:T})}];case 3:return[2]}})})())];case 8:if(_=(v=E.sent()).data,g=v.error,_)return[2,{data:{factorId:r,challengeId:u.id,webauthn:{type:u.webauthn.type,credential_response:_}},error:null}];return[2,{data:null,error:g}];case 9:return y=rs(rn,u.webauthn.credential_options.publicKey,(null==t?void 0:t.request)||{}),[4,(O=Object.assign(Object.assign({},u.webauthn.credential_options),{publicKey:y,signal:l}),(0,S._)(function(){var e;return(0,I._)(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,navigator.credentials.get(O)];case 1:if(!(e=t.sent()))return[2,{data:null,error:new t7("Empty credential response",e)}];if(!(0,N._)(e,PublicKeyCredential))return[2,{data:null,error:new t7("Browser returned unexpected credential type",e)}];return[2,{data:e,error:null}];case 2:return[2,{data:null,error:function(e){var t=e.error,r=e.options,n=r.publicKey;if(!n)throw Error("options was missing required publicKey property");if("AbortError"===t.name){if((0,N._)(r.signal,AbortSignal))return new t8({message:"Authentication ceremony was sent an abort signal",code:"ERROR_CEREMONY_ABORTED",cause:t})}else if("NotAllowedError"===t.name)return new t8({message:t.message,code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t});else if("SecurityError"===t.name){var s=window.location.hostname;if(!re(s))return new t8({message:"".concat(window.location.hostname," is an invalid domain"),code:"ERROR_INVALID_DOMAIN",cause:t});if(n.rpId!==s)return new t8({message:'The RP ID "'.concat(n.rpId,'" is invalid for this domain'),code:"ERROR_INVALID_RP_ID",cause:t})}else if("UnknownError"===t.name)return new t8({message:"The authenticator was unable to process the specified options, or could not create a new assertion signature",code:"ERROR_AUTHENTICATOR_GENERAL_ERROR",cause:t});return new t8({message:"a Non-Webauthn related error has occurred",code:"ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY",cause:t})}({error:t.sent(),options:O})}];case 3:return[2]}})})())];case 10:if(m=(b=E.sent()).data,w=b.error,m)return[2,{data:{factorId:r,challengeId:u.id,webauthn:{type:u.webauthn.type,credential_response:m}},error:null}];return[2,{data:null,error:w}];case 11:return[3,13];case 12:if(tn(k=E.sent()))return[2,{data:null,error:k}];return[2,{data:null,error:new ti("Unexpected error in challenge",k)}];case 13:return[2]}})}).apply(this,arguments)}},{key:"_verify",value:function(e){return(0,S._)(function(e){var t,r,n;return(0,I._)(this,function(s){return t=e.challengeId,r=e.factorId,n=e.webauthn,[2,this.client.mfa.verify({factorId:r,challengeId:t,webauthn:n})]})}).apply(this,arguments)}},{key:"_authenticate",value:function(e,t){return(0,S._)(function(e,t){var r,n,s,i,a,o,u,c,l,h,f,d,p;return(0,I._)(this,function(v){switch(v.label){case 0:if(r=e.factorId,a=void 0===(i=(s=void 0===(n=e.webauthn)?{}:n).rpId)?"undefined"!=typeof window?window.location.hostname:void 0:i,u=void 0===(o=s.rpOrigins)?"undefined"!=typeof window?[window.location.origin]:void 0:o,c=s.signal,!a)return[2,{data:null,error:new tr("rpId is required for WebAuthn authentication")}];v.label=1;case 1:if(v.trys.push([1,3,,4]),!rt())return[2,{data:null,error:new ti("Browser does not support WebAuthn",null)}];return[4,this.challenge({factorId:r,webauthn:{rpId:a,rpOrigins:u},signal:c},{request:t})];case 2:if(h=(l=v.sent()).data,f=l.error,!h)return[2,{data:null,error:f}];return d=h.webauthn,[2,this._verify({factorId:r,challengeId:h.challengeId,webauthn:{type:d.type,rpId:a,rpOrigins:u,credential_response:d.credential_response}})];case 3:if(tn(p=v.sent()))return[2,{data:null,error:p}];return[2,{data:null,error:new ti("Unexpected error in authenticate",p)}];case 4:return[2]}})}).apply(this,arguments)}},{key:"_register",value:function(e,t){return(0,S._)(function(e,t){var r,n,s,i,a,o,u,c,l,h,f,d,p,v,_,g;return(0,I._)(this,function(y){switch(y.label){case 0:if(r=this,n=e.friendlyName,o=void 0===(a=(i=void 0===(s=e.webauthn)?{}:s).rpId)?"undefined"!=typeof window?window.location.hostname:void 0:a,c=void 0===(u=i.rpOrigins)?"undefined"!=typeof window?[window.location.origin]:void 0:u,l=i.signal,!o)return[2,{data:null,error:new tr("rpId is required for WebAuthn registration")}];y.label=1;case 1:if(y.trys.push([1,6,,7]),!rt())return[2,{data:null,error:new ti("Browser does not support WebAuthn",null)}];return[4,this._enroll({friendlyName:n})];case 2:if(f=(h=y.sent()).data,d=h.error,f)return[3,4];return[4,this.client.mfa.listFactors().then(function(e){var t;return null==(t=e.data)?void 0:t.all.find(function(e){return"webauthn"===e.factor_type&&e.friendly_name===n&&"unverified"!==e.status})}).then(function(e){return e?r.client.mfa.unenroll({factorId:null==e?void 0:e.id}):void 0})];case 3:return y.sent(),[2,{data:null,error:d}];case 4:return[4,this._challenge({factorId:f.id,friendlyName:f.friendly_name,webauthn:{rpId:o,rpOrigins:c},signal:l},{create:t})];case 5:if(v=(p=y.sent()).data,_=p.error,!v)return[2,{data:null,error:_}];return[2,this._verify({factorId:f.id,challengeId:v.challengeId,webauthn:{rpId:o,rpOrigins:c,type:v.webauthn.type,credential_response:v.webauthn.credential_response}})];case 6:if(tn(g=y.sent()))return[2,{data:null,error:g}];return[2,{data:null,error:new ti("Unexpected error in register",g)}];case 7:return[2]}})}).apply(this,arguments)}}]),e}();if(("undefined"==typeof globalThis?"undefined":(0,q._)(globalThis))!=="object")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)}var ra={url:"http://localhost:9999",storageKey:"supabase.auth.token",autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,headers:{"X-Client-Info":"gotrue-js/".concat(e7)},flowType:"implicit",debug:!1,hasCustomAuthorizationHeader:!1,throwOnError:!1,lockAcquireTimeout:5e3,skipAutoInitialize:!1};function ro(e,t,r){return(0,S._)(function(){return(0,I._)(this,function(e){switch(e.label){case 0:return[4,r()];case 1:return[2,e.sent()]}})})()}var ru={},rc=function(){function e(t){var r,n,s,i=this;(0,T._)(this,e),this.userStorage=null,this.memoryStorage=null,this.stateChangeEmitters=new Map,this.autoRefreshTicker=null,this.autoRefreshTickTimeout=null,this.visibilityChangedCallback=null,this.refreshingDeferred=null,this.initializePromise=null,this.detectSessionInUrl=!0,this.hasCustomAuthorizationHeader=!1,this.suppressGetSessionWarning=!1,this.lockAcquired=!1,this.pendingInLock=[],this.broadcastChannel=null,this.logger=console.log;var a=Object.assign(Object.assign({},ra),t);
1if(this.storageKey=a.storageKey,this.instanceID=null!=(r=e.nextInstanceID[this.storageKey])?r:0,e.nextInstanceID[this.storageKey]=this.instanceID+1,this.logDebugMessages=!!a.debug,"function"==typeof a.debug&&(this.logger=a.debug),this.instanceID>0&&tO()){var o="".concat(this._logPrefix()," Multiple GoTrueClient instances detected in the same browser context. It is not an error, but this should be avoided as it may produce undefined behavior when used concurrently under the same storage key.");console.warn(o),this.logDebugMessages&&console.trace(o)}if(this.persistSession=a.persistSession,this.autoRefreshToken=a.autoRefreshToken,this.admin=new t0({url:a.url,headers:a.headers,fetch:a.fetch}),this.url=a.url,this.headers=a.headers,this.fetch=tI(a.fetch),this.lock=a.lock||ro,this.detectSessionInUrl=a.detectSessionInUrl,this.flowType=a.flowType,this.hasCustomAuthorizationHeader=a.hasCustomAuthorizationHeader,this.throwOnError=a.throwOnError,this.lockAcquireTimeout=a.lockAcquireTimeout,a.lock?this.lock=a.lock:this.persistSession&&tO()&&(null==(n=null==globalThis?void 0:globalThis.navigator)?void 0:n.locks)?this.lock=t5:this.lock=ro,this.jwks||(this.jwks={keys:[]},this.jwks_cached_at=Number.MIN_SAFE_INTEGER),this.mfa={verify:this._verify.bind(this),enroll:this._enroll.bind(this),unenroll:this._unenroll.bind(this),challenge:this._challenge.bind(this),listFactors:this._listFactors.bind(this),challengeAndVerify:this._challengeAndVerify.bind(this),getAuthenticatorAssuranceLevel:this._getAuthenticatorAssuranceLevel.bind(this),webauthn:new ri(this)},this.oauth={getAuthorizationDetails:this._getAuthorizationDetails.bind(this),approveAuthorization:this._approveAuthorization.bind(this),denyAuthorization:this._denyAuthorization.bind(this),listGrants:this._listOAuthGrants.bind(this),revokeGrant:this._revokeOAuthGrant.bind(this)},this.persistSession?(a.storage?this.storage=a.storage:tR()?this.storage=globalThis.localStorage:(this.memoryStorage={},this.storage=t2(this.memoryStorage)),a.userStorage&&(this.userStorage=a.userStorage)):(this.memoryStorage={},this.storage=t2(this.memoryStorage)),tO()&&globalThis.BroadcastChannel&&this.persistSession&&this.storageKey){try{this.broadcastChannel=new globalThis.BroadcastChannel(this.storageKey)}catch(e){console.error("Failed to create a new BroadcastChannel, multi-tab state changes will not be available",e)}null==(s=this.broadcastChannel)||s.addEventListener("message",function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){switch(r.label){case 0:this._debug("received broadcast notification from other tab or client",e),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._notifyAllSubscribers(e.data.event,e.data.session,!1)];case 2:return r.sent(),[3,4];case 3:return t=r.sent(),this._debug("#broadcastChannel","error",t),[3,4];case 4:return[2]}})}).call(i)})}a.skipAutoInitialize||this.initialize().catch(function(e){i._debug("#initialize()","error",e)})}return(0,O._)(e,[{key:"jwks",get:function(){var e,t;return null!=(t=null==(e=ru[this.storageKey])?void 0:e.jwks)?t:{keys:[]}},set:function(e){ru[this.storageKey]=Object.assign(Object.assign({},ru[this.storageKey]),{jwks:e})}},{key:"jwks_cached_at",get:function(){var e,t;return null!=(t=null==(e=ru[this.storageKey])?void 0:e.cachedAt)?t:Number.MIN_SAFE_INTEGER},set:function(e){ru[this.storageKey]=Object.assign(Object.assign({},ru[this.storageKey]),{cachedAt:e})}},{key:"isThrowOnErrorEnabled",value:function(){return this.throwOnError}},{key:"_returnResult",value:function(e){if(this.throwOnError&&e&&e.error)throw e.error;return e}},{key:"_logPrefix",value:function(){return"GoTrueClient@"+"".concat(this.storageKey,":").concat(this.instanceID," (").concat(e7,") ").concat(new Date().toISOString())}},{key:"_debug",value:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return this.logDebugMessages&&this.logger.apply(this,[this._logPrefix()].concat((0,R._)(t))),this}},{key:"initialize",value:function(){return(0,S._)(function(){var e;return(0,I._)(this,function(t){switch(t.label){case 0:if(e=this,!this.initializePromise)return[3,2];return[4,this.initializePromise];case 1:case 3:return[2,t.sent()];case 2:return this.initializePromise=(0,S._)(function(){var e;return(0,I._)(this,function(t){switch(t.label){case 0:return e=this,[4,this._acquireLock(this.lockAcquireTimeout,function(){return(0,S._)(function(){return(0,I._)(this,function(e){switch(e.label){case 0:return[4,this._initialize()];case 1:return[2,e.sent()]}})}).call(e)})];case 1:return[2,t.sent()]}})}).call(e),[4,this.initializePromise]}})}).call(this)}},{key:"_initialize",value:function(){return(0,S._)(function(){var e,t,r,n,s,i,a,o,u,c;return(0,I._)(this,function(l){switch(l.label){case 0:e=this,l.label=1;case 1:if(l.trys.push([1,9,10,12]),r={},n="none",!tO())return[3,4];if(r=function(e){var t={},r=new URL(e);if(r.hash&&"#"===r.hash[0])try{new URLSearchParams(r.hash.substring(1)).forEac
1h(function(e,r){t[r]=e})}catch(e){}return r.searchParams.forEach(function(e,r){t[r]=e}),t}(window.location.href),!this._isImplicitGrantCallback(r))return[3,2];return n="implicit",[3,4];case 2:return[4,this._isPKCECallback(r)];case 3:l.sent()&&(n="pkce"),l.label=4;case 4:if(!(tO()&&this.detectSessionInUrl&&"none"!==n))return[3,7];return[4,this._getSessionFromURL(r,n)];case 5:if(i=(s=l.sent()).data,a=s.error)return this._debug("#_initialize()","error detecting session from URL",a),tn(a)&&"AuthImplicitGrantRedirectError"===a.name&&(null==(t=a.details)||t.code),[2,{error:a}];return o=i.session,u=i.redirectType,this._debug("#_initialize()","detected session in URL",o,"redirect type",u),[4,this._saveSession(o)];case 6:return l.sent(),setTimeout(function(){return(0,S._)(function(){return(0,I._)(this,function(e){switch(e.label){case 0:if("recovery"!==u)return[3,2];return[4,this._notifyAllSubscribers("PASSWORD_RECOVERY",o)];case 1:return e.sent(),[3,4];case 2:return[4,this._notifyAllSubscribers("SIGNED_IN",o)];case 3:e.sent(),e.label=4;case 4:return[2]}})}).call(e)},0),[2,{error:null}];case 7:return[4,this._recoverAndRefresh()];case 8:return l.sent(),[2,{error:null}];case 9:if(tn(c=l.sent()))return[2,this._returnResult({error:c})];return[2,this._returnResult({error:new ti("Unexpected error during initialization",c)})];case 10:return[4,this._handleVisibilityChange()];case 11:return l.sent(),this._debug("#_initialize()","end"),[7];case 12:return[2]}})}).call(this)}},{key:"signInAnonymously",value:function(e){return(0,S._)(function(){var t,r,n,s,i,a,o,u,c;return(0,I._)(this,function(l){switch(l.label){case 0:return l.trys.push([0,5,,6]),[4,tV(this.fetch,"POST","".concat(this.url,"/signup"),{headers:this.headers,body:{data:null!=(r=null==(t=null==e?void 0:e.options)?void 0:t.data)?r:{},gotrue_meta_security:{captcha_token:null==(n=null==e?void 0:e.options)?void 0:n.captchaToken}},xform:tH})];case 1:if(i=(s=l.sent()).data,(a=s.error)||!i)return[2,this._returnResult({data:{user:null,session:null},error:a})];if(o=i.session,u=i.user,!i.session)return[3,4];return[4,this._saveSession(i.session)];case 2:return l.sent(),[4,this._notifyAllSubscribers("SIGNED_IN",o)];case 3:l.sent(),l.label=4;case 4:return[2,this._returnResult({data:{user:u,session:o},error:null})];case 5:if(tn(c=l.sent()))return[2,this._returnResult({data:{user:null,session:null},error:c})];throw c;case 6:return[2]}})}).call(this)}},{key:"signUp",value:function(e){return(0,S._)(function(){var t,r,n,s,i,a,o,u,c,l,h,f,d,p,v,_,g,y;return(0,I._)(this,function(b){switch(b.label){case 0:if(b.trys.push([0,13,,15]),!("email"in e))return[3,4];if(i=e.email,a=e.password,o=e.options,u=null,c=null,"pkce"!==this.flowType)return[3,2];return[4,tL(this.storage,this.storageKey)];case 1:u=(l=D._.apply(void 0,[b.sent(),2]))[0],c=l[1],b.label=2;case 2:return[4,tV(this.fetch,"POST","".concat(this.url,"/signup"),{headers:this.headers,redirectTo:null==o?void 0:o.emailRedirectTo,body:{email:i,password:a,data:null!=(t=null==o?void 0:o.data)?t:{},gotrue_meta_security:{captcha_token:null==o?void 0:o.captchaToken},code_challenge:u,code_challenge_method:c},xform:tH})];case 3:case 5:return s=b.sent(),[3,7];case 4:if(!("phone"in e))return[3,6];return h=e.phone,f=e.password,d=e.options,[4,tV(this.fetch,"POST","".concat(this.url,"/signup"),{headers:this.headers,body:{phone:h,password:f,data:null!=(r=null==d?void 0:d.data)?r:{},channel:null!=(n=null==d?void 0:d.channel)?n:"sms",gotrue_meta_security:{captcha_token:null==d?void 0:d.captchaToken}},xform:tH})];case 6:throw new tl("You must provide either an email or phone number and a password");case 7:if(p=s.data,!((v=s.error)||!p))return[3,9];return[4,tC(this.storage,"".concat(this.storageKey,"-code-verifier"))];case 8:return b.sent(),[2,this._returnResult({data:{user:null,session:null},error:v})];case 9:if(_=p.session,g=p.user,!p.session)return[3,12];return[4,this._saveSession(p.session)];case 10:return b.sent(),[4,this._notifyAllSubscribers("SIGNED_IN",_)];case 11:b.sent(),b.label=12;case 12:return[2,this._returnResult({data:{user:g,session:_},error:null})];case 13:return y=b.sent(),[4,tC(this.storage,"".concat(this.storageKey,"-code-verifier"))];case 14:if(b.sent(),tn(y))return[2,this._returnResult({data:{user:null,session:null},error:y})];throw y;case 15:return[2]}})}).call(this)}},{key:"signInWithPassword",value:function(e){return(0,S._)(function(){var t,r,n,s,i,a,o,u,c,l,h;return(0,I._)(this,function(f){switch(f.label){case 0:if(f.trys.push([0,9,,10]),!("email"in e))return[3,2];return r=e.email,n=e.password,s=e.options,[4,tV(this.fetch,"POST","".concat(this.url,"/token?grant_type=password"),{headers:this.headers,body:{email:r,password:n,gotrue_meta_security:{captcha_token:null==s?void 0:s.captchaToken}},xform:tG})];case 1:case 3:return t=f.sent(),[3,5];case 2:if(!("phone"in e))return[3,4];return i=e.phone,a=e.password,o=e.options,[4,tV(this.fetch,"POST","".concat(this.url,"/token?grant_type=password"),{headers:this.headers,body:{phone:i,password:a,gotrue_meta_security:{captcha_token:null==o?void 0:o.captchaToken}},xform:tG})];case 4:throw new tl("You must provide either an email or phone number and a password");case 5:if(u=t.data,c=t.error)return[2,this._returnResult({data:{user:null,session:null},error:c})];if(!u||!u.session||!u.user)return l=new tc,[2,this._returnResult({data:{user:null,session:null},error:l})];if(!u.session)return[3,8];return[4,this._saveSession(u.session)];case 6:return f.sent(),[4,this._notifyAllSubscribers("SIGNED_IN",u.session)];case 7:f.sent(),f.label=8;case 8:return[2,this._returnResult({data:Object.assign({user:u.user,session:u.session},u.weak_password?{weakPassword:u.weak_password}:null),error:c})];case 9:if(tn(h=f.sent()))return[2,this._returnResult({data:{user:null,session:null},error:h})];throw h;case 10:return[2]}})}).call(this)}},{key:"signInWithOAuth",value:function(e){return(0,S._)(function(){var t,r,n,s;return(0,I._)(this,function(i){switch(i.label){case 0:return[4,this._handleProviderSignIn(e.provider,{redirectTo:null==(t=e.options)?void 0:t.redirectTo,scopes:null==(r=e.options)?void 0:r.scopes,queryParams:null==(n=e.options)?void 0:n.queryParams,skipBrowserRedirect:null==(s=e.options)?void 0:s.skipBrowserRedirect})];case 1:return[2,i.sent()]}})}).call(this)}}
1,{key:"exchangeCodeForSession",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){switch(r.label){case 0:return t=this,[4,this.initializePromise];case 1:return r.sent(),[2,this._acquireLock(this.lockAcquireTimeout,function(){return(0,S._)(function(){return(0,I._)(this,function(t){return[2,this._exchangeCodeForSession(e)]})}).call(t)})]}})}).call(this)}},{key:"signInWithWeb3",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){switch(r.label){case 0:switch(t=e.chain){case"ethereum":return[3,1];case"solana":return[3,3]}return[3,5];case 1:return[4,this.signInWithEthereum(e)];case 2:case 4:return[2,r.sent()];case 3:return[4,this.signInWithSolana(e)];case 5:throw Error('@supabase/auth-js: Unsupported chain "'.concat(t,'"'));case 6:return[2]}})}).call(this)}},{key:"signInWithEthereum",value:function(e){return(0,S._)(function(){var t,r,n,s,i,a,o,u,c,l,h,f,d,p,v,_,g,y,b,m,w,k,S,E,T,O,A;return(0,I._)(this,function(R){switch(R.label){case 0:if(!("message"in e))return[3,1];return f=e.message,d=e.signature,[3,6];case 1:if(e.chain,p=e.wallet,v=e.statement,_=e.options,tO())if((void 0===p?"undefined":(0,q._)(p))==="object")g=p;else if("ethereum"in(y=window)&&"object"===(0,q._)(y.ethereum)&&"request"in y.ethereum&&"function"==typeof y.ethereum.request)g=y.ethereum;else throw Error("@supabase/auth-js: No compatible Ethereum wallet interface on the window object (window.ethereum) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'ethereum', wallet: resolvedUserWallet }) instead.");else{if((void 0===p?"undefined":(0,q._)(p))!=="object"||!(null==_?void 0:_.url))throw Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");g=p}return b=new URL(null!=(t=null==_?void 0:_.url)?t:window.location.href),[4,g.request({method:"eth_requestAccounts"}).then(function(e){return e}).catch(function(){throw Error("@supabase/auth-js: Wallet method eth_requestAccounts is missing or invalid")})];case 2:if(!(m=R.sent())||0===m.length)throw Error("@supabase/auth-js: No accounts available. Please ensure the wallet is connected.");if(w=t6(m[0]),k=null==(r=null==_?void 0:_.signInWithEthereum)?void 0:r.chainId)return[3,4];return[4,g.request({method:"eth_chainId"})];case 3:k=parseInt(R.sent(),16),R.label=4;case 4:var I;return f=function(e){var t=e.chainId,r=e.domain,n=e.expirationTime,s=e.issuedAt,i=void 0===s?new Date:s,a=e.nonce,o=e.notBefore,u=e.requestId,c=e.resources,l=e.scheme,h=e.uri,f=e.version;if(!Number.isInteger(t))throw Error('@supabase/auth-js: Invalid SIWE message field "chainId". Chain ID must be a EIP-155 chain ID. Provided value: '.concat(t));if(!r)throw Error('@supabase/auth-js: Invalid SIWE message field "domain". Domain must be provided.');if(a&&a.length<8)throw Error('@supabase/auth-js: Invalid SIWE message field "nonce". Nonce must be at least 8 characters. Provided value: '.concat(a));if(!h)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: ".concat(f));if(null==(k=e.statement)?void 0:k.includes("\n"))throw Error("@supabase/auth-js: Invalid SIWE message field \"statement\". Statement must not include '\\n'. Provided value: ".concat(e.statement));var d=t6(e.address),p=l?"".concat(l,"://").concat(r):r,v=e.statement?"".concat(e.statement,"\n"):"",_="".concat(p," wants you to sign in with your Ethereum account:\n").concat(d,"\n\n").concat(v),g="URI: ".concat(h,"\nVersion: ").concat(f,"\nChain ID: ").concat(t).concat(a?"\nNonce: ".concat(a):"","\nIssued At: ").concat(i.toISOString());if(n&&(g+="\nExpiration Time: ".concat(n.toISOString())),o&&(g+="\nNot Before: ".concat(o.toISOString())),u&&(g+="\nRequest ID: ".concat(u)),c){var y="\nResources:",b=!0,m=!1,w=void 0;try{for(var k,S,E=c[Symbol.iterator]();!(b=(S=E.next()).done);b=!0){var T=S.value;if(!T||"string"!=typeof T)throw Error('@supabase/auth-js: Invalid SIWE message field "resources". Every resource must be a valid string. Provided value: '.concat(T));y+="\n- ".concat(T)}}catch(e){m=!0,w=e}finally{try{b||null==E.return||E.return()}finally{if(m)throw w}}g+=y}return"".concat(_,"\n").concat(g)}({domain:b.host,address:w,statement:v,uri:b.href,version:"1",chainId:k,nonce:null==(n=null==_?void 0:_.signInWithEthereum)?void 0:n.nonce,issuedAt:null!=(i=null==(s=null==_?void 0:_.signInWithEthereum)?void 0:s.issuedAt)?i:new Date,expirationTime:null==(a=null==_?void 0:_.signInWithEthereum)?void 0:a.expirationTime,notBefore:null==(o=null==_?void 0:_.signInWithEthereum)?void 0:o.notBefore,requestId:null==(u=null==_?void 0:_.signInWithEthereum)?void 0:u.requestId,resources:null==(c=null==_?void 0:_.signInWithEthereum)?void 0:c.resources}),[4,g.request({method:"personal_sign",params:[(I=f,"0x"+Array.from(new TextEncoder().encode(I),function(e){return e.toString(16).padStart(2,"0")}).join("")),w]})];case 5:d=R.sent(),R.label=6;case 6:return R.trys.push([6,11,,12]),[4,tV(this.fetch,"POST","".concat(this.url,"/token?grant_type=web3"),{headers:this.headers,body:Object.assign({chain:"ethereum",message:f,signature:d},(null==(l=e.options)?void 0:l.captchaToken)?{gotrue_meta_security:{captcha_token:null==(h=e.options)?void 0:h.captchaToken}}:null),xform:tH})];case 7:if(E=(S=R.sent()).data,T=S.error)throw T;if(!E||!E.session||!E.user)return O=new tc,[2,this._returnResult({data:{user:null,session:null},error:O})];if(!E.session)return[3,10];return[4,this._saveSession(E.session)];case 8:return R.sent(),[4,this._notifyAllSubscribers("SIGNED_IN",E.session)];case 9:R.sent(),R.label=10;case 10:return[2,this._returnResult({data:Object.assign({},E),error:T})];case 11:if(tn(A=R.sent()))return[2,this._returnResult({data:{user:null,session:null},error:A})];throw A;case 12:return[2]}})}).call(this)}},{key:"signInWithSolana",value:function(e){return(0,S._)(function(){var t,r,n,s,i,a,o,u,c,l,h,f,d,p,v,_,g,y,b,m,w,k,S,E,T,O,A,j;return(0,I._)(this,function(I){switch(I.label){case 0:if(!("message"in e))return[3,1];return d=e.message,p=e.signature,[3,5];case 1:if(e.chain,v=e.wallet,_=e.statement,g=e.options,tO())if((void 0===v?"undefined":(0,q._)(v))==="object")y=v;else if("solana"in(b=window)&&"object"===(0,q._)(b.solana)&&("signIn"in b.solana&&"function"==typeof b.solana.signIn||"sign
1Message"in b.solana&&"function"==typeof b.solana.signMessage))y=b.solana;else throw Error("@supabase/auth-js: No compatible Solana wallet interface on the window object (window.solana) detected. Make sure the user already has a wallet installed and connected for this app. Prefer passing the wallet interface object directly to signInWithWeb3({ chain: 'solana', wallet: resolvedUserWallet }) instead.");else{if((void 0===v?"undefined":(0,q._)(v))!=="object"||!(null==g?void 0:g.url))throw Error("@supabase/auth-js: Both wallet and url must be specified in non-browser environments.");y=v}if(m=new URL(null!=(t=null==g?void 0:g.url)?t:window.location.href),!("signIn"in y&&y.signIn))return[3,3];return[4,y.signIn(Object.assign(Object.assign(Object.assign({issuedAt:new Date().toISOString()},null==g?void 0:g.signInWithSolana),{version:"1",domain:m.host,uri:m.href}),_?{statement:_}:null))];case 2:if(Array.isArray(w=I.sent())&&w[0]&&"object"===(0,q._)(w[0]))k=w[0];else if(w&&(void 0===w?"undefined":(0,q._)(w))==="object"&&"signedMessage"in w&&"signature"in w)k=w;else throw Error("@supabase/auth-js: Wallet method signIn() returned unrecognized value");if("signedMessage"in k&&"signature"in k&&("string"==typeof k.signedMessage||(0,N._)(k.signedMessage,Uint8Array))&&(0,N._)(k.signature,Uint8Array))d="string"==typeof k.signedMessage?k.signedMessage:new TextDecoder().decode(k.signedMessage),p=k.signature;else throw Error("@supabase/auth-js: Wallet method signIn() API returned object without signedMessage and signature fields");return[3,5];case 3:if(!("signMessage"in y)||"function"!=typeof y.signMessage||!("publicKey"in y)||(void 0===y?"undefined":(0,q._)(y))!=="object"||!y.publicKey||!("toBase58"in y.publicKey)||"function"!=typeof y.publicKey.toBase58)throw Error("@supabase/auth-js: Wallet does not have a compatible signMessage() and publicKey.toBase58() API");return d=["".concat(m.host," wants you to sign in with your Solana account:"),y.publicKey.toBase58()].concat((0,R._)(_?["",_,""]:[""]),["Version: 1","URI: ".concat(m.href),"Issued At: ".concat(null!=(n=null==(r=null==g?void 0:g.signInWithSolana)?void 0:r.issuedAt)?n:new Date().toISOString())],(0,R._)((null==(s=null==g?void 0:g.signInWithSolana)?void 0:s.notBefore)?["Not Before: ".concat(g.signInWithSolana.notBefore)]:[]),(0,R._)((null==(i=null==g?void 0:g.signInWithSolana)?void 0:i.expirationTime)?["Expiration Time: ".concat(g.signInWithSolana.expirationTime)]:[]),(0,R._)((null==(a=null==g?void 0:g.signInWithSolana)?void 0:a.chainId)?["Chain ID: ".concat(g.signInWithSolana.chainId)]:[]),(0,R._)((null==(o=null==g?void 0:g.signInWithSolana)?void 0:o.nonce)?["Nonce: ".concat(g.signInWithSolana.nonce)]:[]),(0,R._)((null==(u=null==g?void 0:g.signInWithSolana)?void 0:u.requestId)?["Request ID: ".concat(g.signInWithSolana.requestId)]:[]),(0,R._)((null==(l=null==(c=null==g?void 0:g.signInWithSolana)?void 0:c.resources)?void 0:l.length)?["Resources"].concat((0,R._)(g.signInWithSolana.resources.map(function(e){return"- ".concat(e)}))):[])).join("\n"),[4,y.signMessage(new TextEncoder().encode(d),"utf8")];case 4:if(!(S=I.sent())||!(0,N._)(S,Uint8Array))throw Error("@supabase/auth-js: Wallet signMessage() API returned an recognized value");p=S,I.label=5;case 5:return I.trys.push([5,10,,11]),[4,tV(this.fetch,"POST","".concat(this.url,"/token?grant_type=web3"),{headers:this.headers,body:Object.assign({chain:"solana",message:d,signature:tT(p)},(null==(h=e.options)?void 0:h.captchaToken)?{gotrue_meta_security:{captcha_token:null==(f=e.options)?void 0:f.captchaToken}}:null),xform:tH})];case 6:if(T=(E=I.sent()).data,O=E.error)throw O;if(!T||!T.session||!T.user)return A=new tc,[2,this._returnResult({data:{user:null,session:null},error:A})];if(!T.session)return[3,9];return[4,this._saveSession(T.session)];case 7:return I.sent(),[4,this._notifyAllSubscribers("SIGNED_IN",T.session)];case 8:I.sent(),I.label=9;case 9:return[2,this._returnResult({data:Object.assign({},T),error:O})];case 10:if(tn(j=I.sent()))return[2,this._returnResult({data:{user:null,session:null},error:j})];throw j;case 11:return[2]}})}).call(this)}},{key:"_exchangeCodeForSession",value:function(e){return(0,S._)(function(){var t,r,n,s,i,a,o,u,c;return(0,I._)(this,function(l){switch(l.label){case 0:return[4,tP(this.storage,"".concat(this.storageKey,"-code-verifier"))];case 1:t=l.sent(),n=(r=(0,D._)((null!=t?t:"").split("/"),2))[0],s=r[1],l.label=2;case 2:if(l.trys.push([2,8,,10]),!n&&"pkce"===this.flowType)throw new td;return[4,tV(this.fetch,"POST","".concat(this.url,"/token?grant_type=pkce"),{headers:this.headers,body:{auth_code:e,code_verifier:n},xform:tH})];case 3:return a=(i=l.sent()).data,o=i.error,[4,tC(this.storage,"".concat(this.storageKey,"-code-verifier"))];case 4:if(l.sent(),o)throw o;
1if(!a||!a.session||!a.user)return u=new tc,[2,this._returnResult({data:{user:null,session:null,redirectType:null},error:u})];if(!a.session)return[3,7];return[4,this._saveSession(a.session)];case 5:return l.sent(),[4,this._notifyAllSubscribers("SIGNED_IN",a.session)];case 6:l.sent(),l.label=7;case 7:return[2,this._returnResult({data:Object.assign(Object.assign({},a),{redirectType:null!=s?s:null}),error:o})];case 8:return c=l.sent(),[4,tC(this.storage,"".concat(this.storageKey,"-code-verifier"))];case 9:if(l.sent(),tn(c))return[2,this._returnResult({data:{user:null,session:null,redirectType:null},error:c})];throw c;case 10:return[2]}})}).call(this)}},{key:"signInWithIdToken",value:function(e){return(0,S._)(function(){var t,r,n,s,i,a,o,u,c,l;return(0,I._)(this,function(h){switch(h.label){case 0:return h.trys.push([0,5,,6]),t=e.options,r=e.provider,n=e.token,s=e.access_token,i=e.nonce,[4,tV(this.fetch,"POST","".concat(this.url,"/token?grant_type=id_token"),{headers:this.headers,body:{provider:r,id_token:n,access_token:s,nonce:i,gotrue_meta_security:{captcha_token:null==t?void 0:t.captchaToken}},xform:tH})];case 1:if(o=(a=h.sent()).data,u=a.error)return[2,this._returnResult({data:{user:null,session:null},error:u})];if(!o||!o.session||!o.user)return c=new tc,[2,this._returnResult({data:{user:null,session:null},error:c})];if(!o.session)return[3,4];return[4,this._saveSession(o.session)];case 2:return h.sent(),[4,this._notifyAllSubscribers("SIGNED_IN",o.session)];case 3:h.sent(),h.label=4;case 4:return[2,this._returnResult({data:o,error:u})];case 5:if(tn(l=h.sent()))return[2,this._returnResult({data:{user:null,session:null},error:l})];throw l;case 6:return[2]}})}).call(this)}},{key:"signInWithOtp",value:function(e){return(0,S._)(function(){var t,r,n,s,i,a,o,u,c,l,h,f,d,p,v,_,g;return(0,I._)(this,function(y){switch(y.label){case 0:if(y.trys.push([0,7,,9]),!("email"in e))return[3,4];if(a=e.email,o=e.options,u=null,c=null,"pkce"!==this.flowType)return[3,2];return[4,tL(this.storage,this.storageKey)];case 1:u=(l=D._.apply(void 0,[y.sent(),2]))[0],c=l[1],y.label=2;case 2:return[4,tV(this.fetch,"POST","".concat(this.url,"/otp"),{headers:this.headers,body:{email:a,data:null!=(t=null==o?void 0:o.data)?t:{},create_user:null==(r=null==o?void 0:o.shouldCreateUser)||r,gotrue_meta_security:{captcha_token:null==o?void 0:o.captchaToken},code_challenge:u,code_challenge_method:c},redirectTo:null==o?void 0:o.emailRedirectTo})];case 3:return h=y.sent().error,[2,this._returnResult({data:{user:null,session:null},error:h})];case 4:if(!("phone"in e))return[3,6];return f=e.phone,d=e.options,[4,tV(this.fetch,"POST","".concat(this.url,"/otp"),{headers:this.headers,body:{phone:f,data:null!=(n=null==d?void 0:d.data)?n:{},create_user:null==(s=null==d?void 0:d.shouldCreateUser)||s,gotrue_meta_security:{captcha_token:null==d?void 0:d.captchaToken},channel:null!=(i=null==d?void 0:d.channel)?i:"sms"}})];case 5:return v=(p=y.sent()).data,_=p.error,[2,this._returnResult({data:{user:null,session:null,messageId:null==v?void 0:v.message_id},error:_})];case 6:throw new tl("You must provide either an email or phone number.");case 7:return g=y.sent(),[4,tC(this.storage,"".concat(this.storageKey,"-code-verifier"))];case 8:if(y.sent(),tn(g))return[2,this._returnResult({data:{user:null,session:null},error:g})];throw g;case 9:return[2]}})}).call(this)}},{key:"verifyOtp",value:function(e){return(0,S._)(function(){var t,r,n,s,i,a,o,u,c,l;return(0,I._)(this,function(h){switch(h.label){case 0:return h.trys.push([0,5,,6]),n=void 0,s=void 0,"options"in e&&(n=null==(t=e.options)?void 0:t.redirectTo,s=null==(r=e.options)?void 0:r.captchaToken),[4,tV(this.fetch,"POST","".concat(this.url,"/verify"),{headers:this.headers,body:Object.assign(Object.assign({},e),{gotrue_meta_security:{captcha_token:s}}),redirectTo:n,xform:tH})];case 1:if(a=(i=h.sent()).data,o=i.error)throw o;if(!a)throw Error("An error occurred on token verification.");if(u=a.session,c=a.user,!(null==u?void 0:u.access_token))return[3,4];return[4,this._saveSession(u)];case 2:return h.sent(),[4,this._notifyAllSubscribers("recovery"==e.type?"PASSWORD_RECOVERY":"SIGNED_IN",u)];case 3:h.sent(),h.label=4;case 4:return[2,this._returnResult({data:{user:c,session:u},error:null})];case 5:if(tn(l=h.sent()))return[2,this._returnResult({data:{user:null,session:null},error:l})];throw l;case 6:return[2]}})}).call(this)}},{key:"signInWithSSO",value:function(e){return(0,S._)(function(){var t,r,n,s,i,a,o,u,c,l;return(0,I._)(this,function(h){switch(h.label){case 0:if(h.trys.push([0,4,,6]),a=null,o=null,"pkce"!==this.flowType)return[3,2];return[4,tL(this.storage,this.storageKey)];case 1:a=(u=D._.apply(void 0,[h.sent(),2]))[0],o=u[1],h.label=2;case 2:return[4,tV(this.fetch,"POST","".concat(this.url,"/sso"),{body:Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},"providerId"in e?{provider_id:e.providerId}:null),"domain"in e?{domain:e.domain}:null),{redirect_to:null!=(r=null==(t=e.options)?void 0:t.redirectTo)?r:void 0}),(null==(n=null==e?void 0:e.options)?void 0:n.captchaToken)?{gotrue_meta_security:{captcha_token:e.options.captchaToken}}:null),{skip_http_redirect:!0,code_challenge:a,code_challenge_method:o}),headers:this.headers,xform:t$})];case 3:return(null==(s=(c=h.sent()).data)?void 0:s.url)&&tO()&&!(null==(i=e.options)?void 0:i.skipBrowserRedirect)&&window.location.assign(c.data.url),[2,this._returnResult(c)];case 4:return l=h.sent(),[4,tC(this.storage,"".concat(this.storageKey,"-code-verifier"))];case 5:if(h.sent(),tn(l))return[2,this._returnResult({data:null,error:l})];throw l;case 6:return[2]}})}).call(this)}},{key:"reauthenticate",value:function(){return(0,S._)(function(){var e;return(0,I._)(this,function(t){switch(t.label){case 0:return e=this,[4,this.initializePromise];case 1:return t.sent(),[4,this._acquireLock(this.lockAcquireTimeout,function(){return(0,S._)(function(){return(0,I._)(this,function(e){switch(e.label){case 0:return[4,this._reauthenticate()];case 1:return[2,e.sent()]}})}).call(e)})];case 2:return[2,t.sent()]}})}).call(this)}},{key:"_reauthenticate",value:function(){return(0,S._)(function(){var e,t;return(0,I._)(this,function(r){switch(r.label){case 0:e=this,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._useSession(function(t){return(0,S._)(function(){var e,r,n;return(0,I._)(this,function(s){switch(s.label){case 0:if(e=t.data.session,r=t.error)throw r;if(!e)throw new to;return[4,tV(this.fetch,"GET","".concat(this.url,"/reauthenticate"),{headers:this.headers,jwt:e.access_token})];case 1:return n=s.sent().error,[2,this._returnResult({data:{user:null,session:null},error:n})]}})}).call(e)})];case 2:return[2,r.sent()];case 3:if(tn(t=r.sent()))return[2,this._returnResult({data:{user:null,session:null},error:t})];throw t;case 4:return[2]}})}).call(this)}},{key:"resend",value:function(e){return(0,S._)(function(){var t,r,n,s,i,a,o,u,c,l,h,f;return(0,I._)(this,function(d){switch(d.label){case 0:if(d.trys.push([0,5,,6]),t="".concat(this.url,"/resend"),!("email"in e))return[3,2];return r=e.email,n=e.type,s=e.options,[4,tV(this.fetch,"POST",t,{headers:this.headers,body:{email:r,type:n,gotrue_meta_security:{captcha_token:null==s?void 0:s.captchaToken}},redirectTo:null==s?void 0:s.emailRedirectTo})];case 1:return i=d.sent().error,[2,this._returnResult({data:{user:null,session:null},error:i})];case 2:if(!("phone"in e))return[3,4];return a=e.phone,o=e.type,u=e.options,[4,tV(this.fetch,"POST",t,{headers:this.headers,body:{phone:a,type:o,gotrue_meta_security:{captcha_token:null==u?void 0:u.captchaToken}}})];case 3:return l=(c=d.sent()).data,h=c.error,[2,this._returnResult({data:{user:null,session:null,messageId:null==l?void 0:l.message_id},error:h})];case 4:throw new tl("You must provide either an email or phone number and a type");case 5:if(tn(f=d.sent()))return[2,this._returnResult({data:{user:null,session:null},error:f})];throw f;case 6:return[2]}})}).call(this)}},{key:"getSession",value:function(){return(0,S._)(function(){var e;return(0,I._)(this,function(t){switch(t.label){case 0:return e=this,[4,this.initializePromise];case 1:return t.sent(),[4,this._acquireLock(this.lockAcquireTimeout,function(){return(0,S._)(function(){return(0,I._)(this,function(e){return[2,this._useSession(function(e){return(0,S._)(function(){return(0,I._)(this,function(t){return[2,e]})})()})]})}).call(e)})];case 2:return[2,t.sent()]}})}).call(this)}},{key:"_acquireLock",value:function(e,t){return(0,S._)(function(){var r,n,s;return(0,I._)(this,function(i){switch(i.label){case 0:r=this,this._debug("#_acquireLock","begin",e),i.label=1;case 1:if(i.trys.push([1,,3,4]),this.lockAcquired)return n=this.pendingInLock.length?this.pendingInLock[this.pendingInLock.length-1]:Promise.resolve(),s=(0,S._)(function(){return(0,I._)(this,function(e){switch(e.label){case 0:return[4,n];case 1:return e.sent(),[4,t()];case 2:return[2,e.sent()]}})})(),this.pendingInLock.push((0,S._)(function(){return(0,I._)(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,s];case 1:case 2:return e.sent(),[3,3];case 3:return[2]}})})()),[2,s];return[4,this.lock("lock:".concat(this.storageKey),e,function(){return(0,S._)(function(){var e,r;return(0,I._)(this,function(n){switch(n.label){case 0:this._debug("#_acquireLock","lock acquired for storage key",this.storageKey),n.label=1;case 1:return n.trys.push([1,,7,8]),this.lockAcquired=!0,e=t(),this.pendingInLock.push((0,S._)(function(){return(0,I._)(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,e];case 1:case 2:return t.sent(),[3,3];case 3:return[2]}})})()),[4,e];case 2:n.sent(),n.label=3;case 3:if(!this.pendingInLock.length)return[3,5];return[4,Promise.all(r=(0,R._)(this.pendingInLock))];case 4:return n.sent(),this.pendingInLock.splice(0,r.length),[3,3];case 5:return[4,e];case 6:return[2,n.sent()];case 7:return this._debug("#_acquireLock","lock released for storage key",this.storageKey),this.lockAcquired=!1,[7];case 8:return[2]}})}).call(r)})];case 2:return[2,i.sent()];case 3:return this._debug("#_acquireLock","end"),[7];case 4:return[2]}})}).call(this)}},{key:"_useSession",value:function(e){return(0,S._)(function(){return(0,I._)(this,function(t){switch(t.label){case 0:this._debug("#_useSession","begin"),t.label=1;case 1:return t.trys.push([1,,4,5]),[4,this.__loadSession()];case 2:return[4,e(t.sent())];case 3:return[2,t.sent()];case 4:return this._debug("#_useSession","end"),[7];case 5:return[2]}})}).call(this)}},{key:"__loadSession",value:function(){return(0,S._)(function(){var e,t,r,n,s,i,a,o;return(0,I._)(this,function(u){switch(u.label){case 0:this._debug("#__loadSession()","begin"),this.lockAcquired||this._debug("#__loadSession()","used outside of an acquired lock!",Error().stack),u.label=1;case 1:return u.trys.push([1,,10,11]),e=null,[4,tP(this.storage,this.storageKey)];case 2:if(t=u.sent(),this._debug("#getSession()","session from storage",t),null===t)return[3,5];if(!this._isValidSession(t))return[3,3];return e=t,[3,5];case 3:return this._debug("#getSession()","session from storage is not val
1id"),[4,this._removeSession()];case 4:u.sent(),u.label=5;case 5:if(!e)return[2,{data:{session:null},error:null}];if(r=!!e.expires_at&&1e3*e.expires_at-Date.now()<9e4,this._debug("#__loadSession()","session has".concat(r?"":" not"," expired"),"expires_at",e.expires_at),r)return[3,8];if(!this.userStorage)return[3,7];return[4,tP(this.userStorage,this.storageKey+"-user")];case 6:(null==(n=u.sent())?void 0:n.user)?e.user=n.user:e.user=tM(),u.label=7;case 7:if(this.storage.isServer&&e.user&&!e.user.__isUserNotAvailableProxy){var c;s={value:this.suppressGetSessionWarning},e.user=(c=e.user,new Proxy(c,{get:function(e,t,r){if("__isInsecureUserWarningProxy"===t)return!0;if((void 0===t?"undefined":(0,q._)(t))==="symbol"){var n=t.toString();if("Symbol(Symbol.toPrimitive)"===n||"Symbol(Symbol.toStringTag)"===n||"Symbol(util.inspect.custom)"===n||"Symbol(nodejs.util.inspect.custom)"===n)return Reflect.get(e,t,r)}return s.value||"string"!=typeof t||(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."),s.value=!0),Reflect.get(e,t,r)}})),s.value&&(this.suppressGetSessionWarning=!0)}return[2,{data:{session:e},error:null}];case 8:return[4,this._callRefreshToken(e.refresh_token)];case 9:if(a=(i=u.sent()).data,o=i.error)return[2,this._returnResult({data:{session:null},error:o})];return[2,this._returnResult({data:{session:a},error:null})];case 10:return this._debug("#__loadSession()","end"),[7];case 11:return[2]}})}).call(this)}},{key:"getUser",value:function(e){return(0,S._)(function(){var t,r;return(0,I._)(this,function(n){switch(n.label){case 0:if(t=this,!e)return[3,2];return[4,this._getUser(e)];case 1:return[2,n.sent()];case 2:return[4,this.initializePromise];case 3:return n.sent(),[4,this._acquireLock(this.lockAcquireTimeout,function(){return(0,S._)(function(){return(0,I._)(this,function(e){switch(e.label){case 0:return[4,this._getUser()];case 1:return[2,e.sent()]}})}).call(t)})];case 4:return(r=n.sent()).data.user&&(this.suppressGetSessionWarning=!0),[2,r]}})}).call(this)}},{key:"_getUser",value:function(e){return(0,S._)(function(){var t,r;return(0,I._)(this,function(n){switch(n.label){case 0:t=this,n.label=1;case 1:if(n.trys.push([1,5,,10]),!e)return[3,3];return[4,tV(this.fetch,"GET","".concat(this.url,"/user"),{headers:this.headers,jwt:e,xform:tY})];case 2:case 4:return[2,n.sent()];case 3:return[4,this._useSession(function(e){return(0,S._)(function(){var t,r,n,s,i;return(0,I._)(this,function(a){switch(a.label){case 0:if(s=e.data,i=e.error)throw i;if(!(null==(t=s.session)?void 0:t.access_token)&&!this.hasCustomAuthorizationHeader)return[2,{data:{user:null},error:new to}];return[4,tV(this.fetch,"GET","".concat(this.url,"/user"),{headers:this.headers,jwt:null!=(n=null==(r=s.session)?void 0:r.access_token)?n:void 0,xform:tY})];case 1:return[2,a.sent()]}})}).call(t)})];case 5:if(!tn(r=n.sent()))return[3,9];if(!tu(r))return[3,8];return[4,this._removeSession()];case 6:return n.sent(),[4,tC(this.storage,"".concat(this.storageKey,"-code-verifier"))];case 7:n.sent(),n.label=8;case 8:return[2,this._returnResult({data:{user:null},error:r})];case 9:throw r;case 10:return[2]}})}).call(this)}},{key:"updateUser",value:function(e){return(0,S._)(function(e){var t,r,n=arguments;return(0,I._)(this,function(s){switch(s.label){case 0:return t=this,r=n.length>1&&void 0!==n[1]?n[1]:{},[4,this.initializePromise];case 1:return s.sent(),[4,this._acquireLock(this.lockAcquireTimeout,function(){return(0,S._)(function(){return(0,I._)(this,function(t){switch(t.label){case 0:return[4,this._updateUser(e,r)];case 1:return[2,t.sent()]}})}).call(t)})];case 2:return[2,s.sent()]}})}).apply(this,arguments)}},{key:"_updateUser",value:function(e){return(0,S._)(function(e){var t,r,n,s=arguments;return(0,I._)(this,function(i){switch(i.label){case 0:t=this,r=s.length>1&&void 0!==s[1]?s[1]:{},i.label=1;case 1:return i.trys.push([1,3,,5]),[4,this._useSession(function(n){return(0,S._)(function(){var t,s,i,a,o,u,c,l,h;return(0,I._)(this,function(f){switch(f.label){case 0:if(t=n.data,s=n.error)throw s;if(!t.session)throw new to;if(i=t.session,a=null,o=null,"pkce"!==this.flowType||null==e.email)return[3,2];return[4,tL(this.storage,this.storageKey)];case 1:a=(u=D._.apply(void 0,[f.sent(),2]))[0],o=u[1],f.label=2;case 2:return[4,tV(this.fetch,"PUT","".concat(this.url,"/user"),{headers:this.headers,redirectTo:null==r?void 0:r.emailRedirectTo,body:Object.assign(Object.assign({},e),{code_challenge:a,code_challenge_method:o}),jwt:i.access_token,xform:tY})];case 3:if(l=(c=f.sent()).data,h=c.error)throw h;return i.user=l.user,[4,this._saveSession(i)];case 4:return f.sent(),[4,this._notifyAllSubscribers("USER_UPDATED",i)];case 5:return f.sent(),[2,this._returnResult({data:{user:i.user},error:null})]}})}).call(t)})];case 2:return[2,i.sent()];case 3:return n=i.sent(),[4,tC(this.storage,"".concat(this.storageKey,"-code-verifier"))];case 4:if(i.sent(),tn(n))return[2,this._returnResult({data:{user:null},error:n})];throw n;case 5:return[2]}})}).apply(this,arguments)}},{key:"setSession",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){switch(r.label){case 0:return t=this,[4,this.initializePromise];case 1:return r.sent(),[4,this._acquireLock(this.lockAcquireTimeout,function(){return(0,S._)(function(){return(0,I._)(this,function(t){switch(t.label){case 0:return[4,this._setSession(e)];case 1:return[2,t.sent()]}})}).call(t)})];case 2:return[2,r.sent()]}})}).call(this)}},{key:"_setSession",value:function(e){return(0,S._)(function(){var t,r,n,s,i,a,o,u,c,l,h,f;return(0,I._)(this,function(d){switch(d.label){case 0:if(d.trys.push([0,7,,8]),!e.access_token||!e.refresh_token)throw new to;if(r=t=Date.now()/1e3,n=!0,s=null,(i=tx(e.access_token).payload).exp&&(n=(r=i.exp)<=t),!n)return[3,2];return[4,this._callRefreshToken(e.refresh_token)];case 1:if(o=(a=d.sent()).data,u=a.error)return[2,this._returnResult({data:{user:null,session:null},error:u})];if(!o)return[2,{data:{user:null,session:null},error:null}];return s=o,[3,6];case 2:return[4,this._getUser(e.access_token)];case 3:if(l=(c=d.sent()).data,h=c.error)return[2,this._returnResult({data:{user:null,session:null},error:h})];return s={access_token:e.access_token,refresh_token:e.refresh_token,user:l.user,token_type:"bearer",expires_in:r-t,expires_at:r},[4,this._saveSession(s)];case 4:return d.sent(),[4,this._notifyAllSubscribers("SIGNED_IN",s)];case 5:d.sent(),d.label=6;case 6:return[2,this._returnResult({data:{user:s.user,session:s},error:null})];case 7:if(tn(f=d.sent()))return[2,this._returnResult({data:{session:null,user:null},error:f})];throw f;case 8:return[2]}})}).call(this)}},{key:"refreshSession",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){switch(r.label){case 0:return t=this,[4,this.initializePromise];case 1:return r.sent(),[4,this._acquireLock(this.lockAcquireTimeout,function(){return(0,S._)(function(){return(0,I._)(this,function(t){switch(t.label){case 0:return[4,this._refreshSession(e)];case 1:return[2,t.sent()]}})}).call(t)})];case 2:return[2,r.sent()]}})}).call(this)}},{key:"_refreshSession",value:function(e){return(0,S._)(function(){var t,r;return(0,I._)(this,function(n){switch(n.label){case 0:t=this,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this._useSession(function(r){return(0,S._)(function(){var t,n,s,i,a,o;return(0,I._)(this,function(u){switch(u.label){case 0:if(!e){if(n=r.data,s=r.error)throw s;e=null!=(t=n.session)?t:void 0}if(!(null==e?void 0:e.refresh_token))throw new to;return[4,this._callRefreshToken(e.refresh_token)];case 1:if(a=(i=u.sent()).data,o=i.error)return[2,this._returnResult({data:{user:null,session:null},error:o})];if(!a)return[2,this._returnResult({data:{user:null,session:null},error:null})];return[2,this._returnResult({data:{user:a.user,session:a},error:null})]}})}).call(t)})];case 2:return[2,n.sent()];case 3:if(tn(r=n.sent()))return[2,this._returnResult({data:{user:null,session:null},error:r})];throw r;case 4:return[2]}})}).call(this)}},{key:"_getSessionFromURL",value:function(e,t){return(0,S._)(function(){var r,n,s,i,a,o,u,c,l,h,f,d,p,v,_,g,y,b,m,w,k;return(0,I._)(this,function(S){switch(S.label){case 0:if(S.trys.push([0,4,,5]),!tO())throw new th("No browser detected.");
1if(e.error||e.error_description||e.error_code)throw new th(e.error_description||"Error in URL with unspecified error_description",{error:e.error||"unspecified_error",code:e.error_code||"unspecified_code"});switch(t){case"implicit":if("pkce"===this.flowType)throw new tf("Not a valid PKCE flow url.");break;case"pkce":if("implicit"===this.flowType)throw new th("Not a valid implicit grant flow url.")}if("pkce"!==t)return[3,2];if(this._debug("#_initialize()","begin","is PKCE flow",!0),!e.code)throw new tf("No code detected.");return[4,this._exchangeCodeForSession(e.code)];case 1:if(n=(r=S.sent()).data,s=r.error)throw s;return(i=new URL(window.location.href)).searchParams.delete("code"),window.history.replaceState(window.history.state,"",i.toString()),[2,{data:{session:n.session,redirectType:null},error:null}];case 2:if(a=e.provider_token,o=e.provider_refresh_token,u=e.access_token,c=e.refresh_token,l=e.expires_in,h=e.expires_at,f=e.token_type,!u||!l||!c||!f)throw new th("No session defined in URL");return v=(d=Math.round(Date.now()/1e3))+(p=parseInt(l)),h&&(v=parseInt(h)),1e3*(_=v-d)<=3e4&&console.warn("@supabase/gotrue-js: Session as retrieved from URL expires in ".concat(_,"s, should have been closer to ").concat(p,"s")),d-(g=v-p)>=120?console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued over 120s ago, URL could be stale",g,v,d):d-g<0&&console.warn("@supabase/gotrue-js: Session as retrieved from URL was issued in the future? Check the device clock for skew",g,v,d),[4,this._getUser(u)];case 3:if(b=(y=S.sent()).data,m=y.error)throw m;return w={provider_token:a,provider_refresh_token:o,access_token:u,expires_in:p,expires_at:v,refresh_token:c,token_type:f,user:b.user},window.location.hash="",this._debug("#_getSessionFromURL()","clearing window.location.hash"),[2,this._returnResult({data:{session:w,redirectType:e.type},error:null})];case 4:if(tn(k=S.sent()))return[2,this._returnResult({data:{session:null,redirectType:null},error:k})];throw k;case 5:return[2]}})}).call(this)}},{key:"_isImplicitGrantCallback",value:function(e){return"function"==typeof this.detectSessionInUrl?this.detectSessionInUrl(new URL(window.location.href),e):!!(e.access_token||e.error_description)}},{key:"_isPKCECallback",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){switch(r.label){case 0:return[4,tP(this.storage,"".concat(this.storageKey,"-code-verifier"))];case 1:return t=r.sent(),[2,!!(e.code&&t)]}})}).call(this)}},{key:"signOut",value:function(){return(0,S._)(function(){var e,t,r=arguments;return(0,I._)(this,function(n){switch(n.label){case 0:return e=this,t=r.length>0&&void 0!==r[0]?r[0]:{scope:"global"},[4,this.initializePromise];case 1:return n.sent(),[4,this._acquireLock(this.lockAcquireTimeout,function(){return(0,S._)(function(){return(0,I._)(this,function(e){switch(e.label){case 0:return[4,this._signOut(t)];case 1:return[2,e.sent()]}})}).call(e)})];case 2:return[2,n.sent()]}})}).apply(this,arguments)}},{key:"_signOut",value:function(){return(0,S._)(function(){var e,t,r=arguments;return(0,I._)(this,function(n){switch(n.label){case 0:return e=this,t=(r.length>0&&void 0!==r[0]?r[0]:{scope:"global"}).scope,[4,this._useSession(function(r){return(0,S._)(function(){var e,n,s,i,a;return(0,I._)(this,function(o){switch(o.label){case 0:if(n=r.data,(s=r.error)&&!tu(s))return[2,this._returnResult({error:s})];if(!(i=null==(e=n.session)?void 0:e.access_token))return[3,2];return[4,this.admin.signOut(i,t)];case 1:if((a=o.sent().error)&&!(tn(a)&&"AuthApiError"===a.name&&(404===a.status||401===a.status||403===a.status)||tu(a)))return[2,this._returnResult({error:a})];o.label=2;case 2:if("others"===t)return[3,5];return[4,this._removeSession()];case 3:return o.sent(),[4,tC(this.storage,"".concat(this.storageKey,"-code-verifier"))];case 4:o.sent(),o.label=5;case 5:return[2,this._returnResult({error:null})]}})}).call(e)})];case 1:return[2,n.sent()]}})}).apply(this,arguments)}},{key:"onAuthStateChange",value:function(e){var t=this,r=Symbol("auth-callback"),n={id:r,callback:e,unsubscribe:function(){t._debug("#unsubscribe()","state change callback with id removed",r),t.stateChangeEmitters.delete(r)}};return this._debug("#onAuthStateChange()","registered callback with id",r),this.stateChangeEmitters.set(r,n),(0,S._)(function(){var e;return(0,I._)(this,function(t){switch(t.label){case 0:return e=this,[4,this.initializePromise];case 1:return t.sent(),[4,this._acquireLock(this.lockAcquireTimeout,function(){return(0,S._)(function(){return(0,I._)(this,function(e){return this._emitInitialSession(r),[2]})}).call(e)})];case 2:return t.sent(),[2]}})}).call(t),{data:{subscription:n}}}},{key:"_emitInitialSession",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){switch(r.label){case 0:return t=this,[4,this._useSession(function(r){return(0,S._)(function(){var t,n,s,i,a;
1return(0,I._)(this,function(o){switch(o.label){case 0:if(o.trys.push([0,2,,4]),s=r.data.session,i=r.error)throw i;return[4,null==(t=this.stateChangeEmitters.get(e))?void 0:t.callback("INITIAL_SESSION",s)];case 1:return o.sent(),this._debug("INITIAL_SESSION","callback id",e,"session",s),[3,4];case 2:return a=o.sent(),[4,null==(n=this.stateChangeEmitters.get(e))?void 0:n.callback("INITIAL_SESSION",null)];case 3:return o.sent(),this._debug("INITIAL_SESSION","callback id",e,"error",a),console.error(a),[3,4];case 4:return[2]}})}).call(t)})];case 1:return[2,r.sent()]}})}).call(this)}},{key:"resetPasswordForEmail",value:function(e){return(0,S._)(function(e){var t,r,n,s,i,a=arguments;return(0,I._)(this,function(o){switch(o.label){case 0:if(t=a.length>1&&void 0!==a[1]?a[1]:{},r=null,n=null,"pkce"!==this.flowType)return[3,2];return[4,tL(this.storage,this.storageKey,!0)];case 1:r=(s=D._.apply(void 0,[o.sent(),2]))[0],n=s[1],o.label=2;case 2:return o.trys.push([2,4,,6]),[4,tV(this.fetch,"POST","".concat(this.url,"/recover"),{body:{email:e,code_challenge:r,code_challenge_method:n,gotrue_meta_security:{captcha_token:t.captchaToken}},headers:this.headers,redirectTo:t.redirectTo})];case 3:return[2,o.sent()];case 4:return i=o.sent(),[4,tC(this.storage,"".concat(this.storageKey,"-code-verifier"))];case 5:if(o.sent(),tn(i))return[2,this._returnResult({data:null,error:i})];throw i;case 6:return[2]}})}).apply(this,arguments)}},{key:"getUserIdentities",value:function(){return(0,S._)(function(){var e,t,r,n,s;return(0,I._)(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.getUser()];case 1:if(r=(t=i.sent()).data,n=t.error)throw n;return[2,this._returnResult({data:{identities:null!=(e=r.user.identities)?e:[]},error:null})];case 2:if(tn(s=i.sent()))return[2,this._returnResult({data:null,error:s})];throw s;case 3:return[2]}})}).call(this)}},{key:"linkIdentity",value:function(e){return(0,S._)(function(){return(0,I._)(this,function(t){return"token"in e?[2,this.linkIdentityIdToken(e)]:[2,this.linkIdentityOAuth(e)]})}).call(this)}},{key:"linkIdentityOAuth",value:function(e){return(0,S._)(function(){var t,r,n,s,i,a;return(0,I._)(this,function(o){switch(o.label){case 0:t=this,o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this._useSession(function(r){return(0,S._)(function(){var t,n,s,i,a,o,u,c;return(0,I._)(this,function(l){switch(l.label){case 0:if(o=r.data,u=r.error)throw u;return[4,this._getUrlForProvider("".concat(this.url,"/user/identities/authorize"),e.provider,{redirectTo:null==(t=e.options)?void 0:t.redirectTo,scopes:null==(n=e.options)?void 0:n.scopes,queryParams:null==(s=e.options)?void 0:s.queryParams,skipBrowserRedirect:!0})];case 1:return c=l.sent(),[4,tV(this.fetch,"GET",c,{headers:this.headers,jwt:null!=(a=null==(i=o.session)?void 0:i.access_token)?a:void 0})];case 2:return[2,l.sent()]}})}).call(t)})];case 2:if(s=(n=o.sent()).data,i=n.error)throw i;return!tO()||(null==(r=e.options)?void 0:r.skipBrowserRedirect)||window.location.assign(null==s?void 0:s.url),[2,this._returnResult({data:{provider:e.provider,url:null==s?void 0:s.url},error:null})];case 3:if(tn(a=o.sent()))return[2,this._returnResult({data:{provider:e.provider,url:null},error:a})];throw a;case 4:return[2]}})}).call(this)}},{key:"linkIdentityIdToken",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){switch(r.label){case 0:return t=this,[4,this._useSession(function(r){return(0,S._)(function(){var t,n,s,i,a,o,u,c,l,h,f,d;return(0,I._)(this,function(p){switch(p.label){case 0:if(p.trys.push([0,5,,7]),n=r.error,s=r.data.session,n)throw n;return i=e.options,a=e.provider,o=e.token,u=e.access_token,c=e.nonce,[4,tV(this.fetch,"POST","".concat(this.url,"/token?grant_type=id_token"),{headers:this.headers,jwt:null!=(t=null==s?void 0:s.access_token)?t:void 0,body:{provider:a,id_token:o,access_token:u,nonce:c,link_identity:!0,gotrue_meta_security:{captcha_token:null==i?void 0:i.captchaToken}},xform:tH})];case 1:if(h=(l=p.sent()).data,f=l.error)return[2,this._returnResult({data:{user:null,session:null},error:f})];if(!h||!h.session||!h.user)return[2,this._returnResult({data:{user:null,session:null},error:new tc})];if(!h.session)return[3,4];return[4,this._saveSession(h.session)];case 2:return p.sent(),[4,this._notifyAllSubscribers("USER_UPDATED",h.session)];case 3:p.sent(),p.label=4;case 4:return[2,this._returnResult({data:h,error:f})];case 5:return d=p.sent(),[4,tC(this.storage,"".concat(this.storageKey,"-code-verifier"))];case 6:if(p.sent(),tn(d))return[2,this._returnResult({data:{user:null,session:null},error:d})];throw d;case 7:return[2]}})}).call(t)})];case 1:return[2,r.sent()]}})}).call(this)}},{key:"unlinkIdentity",value:function(e){return(0,S._)(function(){var t,r;return(0,I._)(this,function(n){switch(n.label){case 0:t=this,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this._useSession(function(r){return(0,S._)(function(){var t,n,s,i;return(0,I._)(this,function(a){switch(a.label){case 0:if(s=r.data,i=r.error)throw i;
1return[4,tV(this.fetch,"DELETE","".concat(this.url,"/user/identities/").concat(e.identity_id),{headers:this.headers,jwt:null!=(n=null==(t=s.session)?void 0:t.access_token)?n:void 0})];case 1:return[2,a.sent()]}})}).call(t)})];case 2:return[2,n.sent()];case 3:if(tn(r=n.sent()))return[2,this._returnResult({data:null,error:r})];throw r;case 4:return[2]}})}).call(this)}},{key:"_refreshAccessToken",value:function(e){return(0,S._)(function(){var t,r,n,s;return(0,I._)(this,function(i){switch(i.label){case 0:t=this,r="#_refreshAccessToken(".concat(e.substring(0,5),"...)"),this._debug(r,"begin"),i.label=1;case 1:var a,o;return i.trys.push([1,3,4,5]),n=Date.now(),[4,(a=function(n){return(0,S._)(function(){return(0,I._)(this,function(t){switch(t.label){case 0:var s;if(!(n>0))return[3,2];return[4,(s=200*Math.pow(2,n-1),(0,S._)(function(){return(0,I._)(this,function(e){switch(e.label){case 0:return[4,new Promise(function(e){setTimeout(function(){return e(null)},s)})];case 1:return[2,e.sent()]}})})())];case 1:t.sent(),t.label=2;case 2:return this._debug(r,"refreshing attempt",n),[4,tV(this.fetch,"POST","".concat(this.url,"/token?grant_type=refresh_token"),{body:{refresh_token:e},headers:this.headers,xform:tH})];case 3:return[2,t.sent()]}})}).call(t)},o=function(e,t){var r=200*Math.pow(2,e);return t&&tv(t)&&Date.now()+r-n<3e4},new Promise(function(e,t){(0,S._)(function(){var r,n,s;return(0,I._)(this,function(i){switch(i.label){case 0:r=0,i.label=1;case 1:if(!(r<1/0))return[3,6];i.label=2;case 2:return i.trys.push([2,4,,5]),[4,a(r)];case 3:if(n=i.sent(),!o(r,null,n))return e(n),[2];return[3,5];case 4:if(s=i.sent(),!o(r,s))return t(s),[2];return[3,5];case 5:return r++,[3,1];case 6:return[2]}})})()}))];case 2:return[2,i.sent()];case 3:if(s=i.sent(),this._debug(r,"error",s),tn(s))return[2,this._returnResult({data:{session:null,user:null},error:s})];throw s;case 4:return this._debug(r,"end"),[7];case 5:return[2]}})}).call(this)}},{key:"_isValidSession",value:function(e){return(void 0===e?"undefined":(0,q._)(e))==="object"&&null!==e&&"access_token"in e&&"refresh_token"in e&&"expires_at"in e}},{key:"_handleProviderSignIn",value:function(e,t){return(0,S._)(function(){var r;return(0,I._)(this,function(n){switch(n.label){case 0:return[4,this._getUrlForProvider("".concat(this.url,"/authorize"),e,{redirectTo:t.redirectTo,scopes:t.scopes,queryParams:t.queryParams})];case 1:return r=n.sent(),this._debug("#_handleProviderSignIn()","provider",e,"options",t,"url",r),tO()&&!t.skipBrowserRedirect&&window.location.assign(r),[2,{data:{provider:e,url:r},error:null}]}})}).call(this)}},{key:"_recoverAndRefresh",value:function(){return(0,S._)(function(){var e,t,r,n,s,i,a,o,u,c,l,h;return(0,I._)(this,function(f){switch(f.label){case 0:r="#_recoverAndRefresh()",this._debug(r,"begin"),f.label=1;case 1:return f.trys.push([1,30,31,32]),[4,tP(this.storage,this.storageKey)];case 2:if(!((n=f.sent())&&this.userStorage))return[3,6];return[4,tP(this.userStorage,this.storageKey+"-user")];case 3:if(s=f.sent(),!(!this.storage.isServer&&Object.is(this.storage,this.userStorage)&&!s))return[3,5];return s={user:n.user},[4,tj(this.userStorage,this.storageKey+"-user",s)];case 4:f.sent(),f.label=5;case 5:return n.user=null!=(e=null==s?void 0:s.user)?e:tM(),[3,11];case 6:if(!(n&&!n.user)||n.user)return[3,11];return[4,tP(this.storage,this.storageKey+"-user")];case 7:if(!((i=f.sent())&&(null==i?void 0:i.user)))return[3,10];return n.user=i.user,[4,tC(this.storage,this.storageKey+"-user")];case 8:return f.sent(),[4,tj(this.storage,this.storageKey,n)];case 9:return f.sent(),[3,11];case 10:n.user=tM(),f.label=11;case 11:if(this._debug(r,"session from storage",n),this._isValidSession(n))return[3,14];if(this._debug(r,"session is not valid"),null===n)return[3,13];return[4,this._removeSession()];case 12:f.sent(),f.label=13;case 13:return[2];case 14:if(a=(null!=(t=n.expires_at)?t:1/0)*1e3-Date.now()<9e4,this._debug(r,"session has".concat(a?"":" not"," expired with margin of ").concat(9e4,"s")),!a)return[3,18];if(!(this.autoRefreshToken&&n.refresh_token))return[3,17];return[4,this._callRefreshToken(n.refresh_token)];case 15:if(!(o=f.sent().error)||(console.error(o),tv(o)))return[3,17];return this._debug(r,"refresh failed with a non-retryable error, remov
1ing the session",o),[4,this._removeSession()];case 16:f.sent(),f.label=17;case 17:return[3,29];case 18:if(!(n.user&&!0===n.user.__isUserNotAvailableProxy))return[3,27];f.label=19;case 19:return f.trys.push([19,25,,26]),[4,this._getUser(n.access_token)];case 20:if(c=(u=f.sent()).data,!(!u.error&&(null==c?void 0:c.user)))return[3,23];return n.user=c.user,[4,this._saveSession(n)];case 21:return f.sent(),[4,this._notifyAllSubscribers("SIGNED_IN",n)];case 22:return f.sent(),[3,24];case 23:this._debug(r,"could not get user data, skipping SIGNED_IN notification"),f.label=24;case 24:return[3,26];case 25:return console.error("Error getting user data:",l=f.sent()),this._debug(r,"error getting user data, skipping SIGNED_IN notification",l),[3,26];case 26:return[3,29];case 27:return[4,this._notifyAllSubscribers("SIGNED_IN",n)];case 28:f.sent(),f.label=29;case 29:return[3,32];case 30:return h=f.sent(),this._debug(r,"error",h),console.error(h),[2];case 31:return this._debug(r,"end"),[7];case 32:return[2]}})}).call(this)}},{key:"_callRefreshToken",value:function(e){return(0,S._)(function(){var t,r,n,s,i,a,o,u,c;return(0,I._)(this,function(l){switch(l.label){case 0:if(!e)throw new to;if(this.refreshingDeferred)return[2,this.refreshingDeferred.promise];n="#_callRefreshToken(".concat(e.substring(0,5),"...)"),this._debug(n,"begin"),l.label=1;case 1:return l.trys.push([1,5,9,10]),this.refreshingDeferred=new tU,[4,this._refreshAccessToken(e)];case 2:if(i=(s=l.sent()).data,a=s.error)throw a;if(!i.session)throw new to;return[4,this._saveSession(i.session)];case 3:return l.sent(),[4,this._notifyAllSubscribers("TOKEN_REFRESHED",i.session)];case 4:return l.sent(),o={data:i.session,error:null},this.refreshingDeferred.resolve(o),[2,o];case 5:if(u=l.sent(),this._debug(n,"error",u),!tn(u))return[3,8];if(c={data:null,error:u},tv(u))return[3,7];return[4,this._removeSession()];case 6:l.sent(),l.label=7;case 7:return null==(t=this.refreshingDeferred)||t.resolve(c),[2,c];case 8:throw null==(r=this.refreshingDeferred)||r.reject(u),u;case 9:return this.refreshingDeferred=null,this._debug(n,"end"),[7];case 10:return[2]}})}).call(this)}},{key:"_notifyAllSubscribers",value:function(e,t){var r=!(arguments.length>2)||void 0===arguments[2]||arguments[2];return(0,S._)(function(){var n,s,i;return(0,I._)(this,function(a){switch(a.label){case 0:n="#_notifyAllSubscribers(".concat(e,")"),this._debug(n,"begin",t,"broadcast = ".concat(r)),a.label=1;case 1:return a.trys.push([1,,3,4]),this.broadcastChannel&&r&&this.broadcastChannel.postMessage({event:e,session:t}),s=[],[4,Promise.all(Array.from(this.stateChangeEmitters.values()).map(function(r){return(0,S._)(function(){var n;return(0,I._)(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,r.callback(e,t)];case 1:return i.sent(),[3,3];case 2:return n=i.sent(),s.push(n),[3,3];case 3:return[2]}})})()}))];case 2:if(a.sent(),s.length>0){for(i=0;i<s.length;i+=1)console.error(s[i]);throw s[0]}return[3,4];case 3:return this._debug(n,"end"),[7];case 4:return[2]}})}).call(this)}},{key:"_saveSession",value:function(e){return(0,S._)(function(){var t,r,n,s,i;return(0,I._)(this,function(a){switch(a.label){case 0:return this._debug("#_saveSession()",e),this.suppressGetSessionWarning=!0,[4,tC(this.storage,"".concat(this.storageKey,"-code-verifier"))];case 1:if(a.sent(),r=(t=Object.assign({},e)).user&&!0===t.user.__isUserNotAvailableProxy,!this.userStorage)return[3,6];if(!(!r&&t.user))return[3,3];return[4,tj(this.userStorage,this.storageKey+"-user",{user:t.user})];case 2:return a.sent(),[3,4];case 3:a.label=4;case 4:return n=Object.assign({},t),delete n.user,s=tK(n),[4,tj(this.storage,this.storageKey,s)];case 5:return a.sent(),[3,8];case 6:return i=tK(t),[4,tj(this.storage,this.storageKey,i)];case 7:a.sent(),a.label=8;case 8:return[2]}})}).call(this)}},{key:"_removeSession",value:function(){return(0,S._)(function(){return(0,I._)(this,function(e){switch(e.label){case 0:return this._debug("#_removeSession()"),this.suppressGetSessionWarning=!1,[4,tC(this.storage,this.storageKey)];case 1:return e.sent(),[4,tC(this.storage,this.storageKey+"-code-verifier")];case 2:return e.sent(),[4,tC(this.storage,this.storageKey+"-user")];case 3:if(e.sent(),!this.userStorage)return[3,5];return[4,tC(this.userStorage,this.storageKey+"-user")];case 4:e.sent(),e.label=5;case 5:return[4,this._notifyAllSubscribers("SIGNED_OUT",null)];case 6:return e.sent(),[2]}})}).call(this)}},{key:"_removeVisibilityChangedCallback",value:function(){this._debug("#_removeVisibilityChangedCallback()");var e=this.visibilityChangedCallback;this.visibilityChangedCallback=null;try{e&&tO()&&(null==window?void 0:window.removeEventListener)&&window.removeEventListener("visibilitychange",e)}
1catch(e){console.error("removing visibilitychange callback failed",e)}}},{key:"_startAutoRefresh",value:function(){return(0,S._)(function(){var e,t,r;return(0,I._)(this,function(n){switch(n.label){case 0:return e=this,[4,this._stopAutoRefresh()];case 1:return n.sent(),this._debug("#_startAutoRefresh()"),t=setInterval(function(){return e._autoRefreshTokenTick()},3e4),this.autoRefreshTicker=t,t&&(void 0===t?"undefined":(0,q._)(t))==="object"&&"function"==typeof t.unref?t.unref():"undefined"!=typeof Deno&&"function"==typeof Deno.unrefTimer&&Deno.unrefTimer(t),r=setTimeout(function(){return(0,S._)(function(){return(0,I._)(this,function(e){switch(e.label){case 0:return[4,this.initializePromise];case 1:return e.sent(),[4,this._autoRefreshTokenTick()];case 2:return e.sent(),[2]}})}).call(e)},0),this.autoRefreshTickTimeout=r,r&&(void 0===r?"undefined":(0,q._)(r))==="object"&&"function"==typeof r.unref?r.unref():"undefined"!=typeof Deno&&"function"==typeof Deno.unrefTimer&&Deno.unrefTimer(r),[2]}})}).call(this)}},{key:"_stopAutoRefresh",value:function(){return(0,S._)(function(){var e,t;return(0,I._)(this,function(r){return this._debug("#_stopAutoRefresh()"),e=this.autoRefreshTicker,this.autoRefreshTicker=null,e&&clearInterval(e),t=this.autoRefreshTickTimeout,this.autoRefreshTickTimeout=null,t&&clearTimeout(t),[2]})}).call(this)}},{key:"startAutoRefresh",value:function(){return(0,S._)(function(){return(0,I._)(this,function(e){switch(e.label){case 0:return this._removeVisibilityChangedCallback(),[4,this._startAutoRefresh()];case 1:return e.sent(),[2]}})}).call(this)}},{key:"stopAutoRefresh",value:function(){return(0,S._)(function(){return(0,I._)(this,function(e){switch(e.label){case 0:return this._removeVisibilityChangedCallback(),[4,this._stopAutoRefresh()];case 1:return e.sent(),[2]}})}).call(this)}},{key:"_autoRefreshTokenTick",value:function(){return(0,S._)(function(){var e,t;return(0,I._)(this,function(r){switch(r.label){case 0:e=this,this._debug("#_autoRefreshTokenTick()","begin"),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._acquireLock(0,function(){return(0,S._)(function(){var e,t;return(0,I._)(this,function(r){switch(r.label){case 0:e=this,r.label=1;case 1:r.trys.push([1,,6,7]),t=Date.now(),r.label=2;case 2:return r.trys.push([2,4,,5]),[4,this._useSession(function(r){return(0,S._)(function(){var e,n;return(0,I._)(this,function(s){switch(s.label){case 0:if(!(e=r.data.session)||!e.refresh_token||!e.expires_at)return this._debug("#_autoRefreshTokenTick()","no session"),[2];if(n=Math.floor((1e3*e.expires_at-t)/3e4),this._debug("#_autoRefreshTokenTick()","access token expires in ".concat(n," ticks, a tick lasts ").concat(3e4,"ms, refresh threshold is ").concat(3," ticks")),!(n<=3))return[3,2];return[4,this._callRefreshToken(e.refresh_token)];case 1:s.sent(),s.label=2;case 2:return[2]}})}).call(e)})];case 3:return[2,r.sent()];case 4:return console.error("Auto refresh tick failed with error. This is likely a transient error.",r.sent()),[3,5];case 5:return[3,7];case 6:return this._debug("#_autoRefreshTokenTick()","end"),[7];case 7:return[2]}})}).call(e)})];case 2:return r.sent(),[3,4];case 3:if((t=r.sent()).isAcquireTimeout||(0,N._)(t,t4))this._debug("auto refresh token tick lock not available");else throw t;return[3,4];case 4:return[2]}})}).call(this)}},{key:"_handleVisibilityChange",value:function(){return(0,S._)(function(){var e;return(0,I._)(this,function(t){switch(t.label){case 0:if(e=this,this._debug("#_handleVisibilityChange()"),!tO()||!(null==window?void 0:window.addEventListener))return this.autoRefreshToken&&this.startAutoRefresh(),[2,!1];t.label=1;case 1:return t.trys.push([1,3,,4]),this.visibilityChangedCallback=function(){return(0,S._)(function(){var e;return(0,I._)(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this._onVisibilityChanged(!1)];case 1:return t.sent(),[3,3];case 2:return e=t.sent(),this._debug("#visibilityChangedCallback","error",e),[3,3];case 3:return[2]}})}).call(e)},null==window||window.addEventListener("visibilitychange",this.visibilityChangedCallback),[4,this._onVisibilityChanged(!0)];case 2:return t.sent(),[3,4];case 3:return console.error("_handleVisibilityChange",t.sent()),[3,4];case 4:return[2]}})}).call(this)}},{key:"_onVisibilityChanged",value:function(e){return(0,S._)(function(){var t,r;return(0,I._)(this,function(n){switch(n.label){case 0:if(t=this,r="#_onVisibilityChanged(".concat(e,")"),this._debug(r,"visibilityState",document.visibilityState),"visible"!==document.visibilityState)return[3,4];if(this.autoRefreshToken&&this._startAutoRefresh(),e)return[3,3];return[4,this.initializePromise];case 1:return n.sent(),[4,this._acquireLock(this.lockAcquireTimeout,function(){return(0,S._)(function(){return(0,I._)(this,function(e){switch(e.label){case 0:if("visible"!==document.visibilityState)return this._debug(r,"acquired the lock to recover the session, but the browser visibilityState is no longer visible, aborting"),[2];return[4,this._recoverAndRefresh()];case 1:return e.sent(),[2]}})}).call(t)})];case 2:n.sent(),n.label=3;case 3:return[3,5];case 4:"hidden"===document.visibilityState&&this.autoRefreshToken&&this._stopAutoRefresh(),n.label=5;case 5:return[2]}})}).call(this)}},{key:"_getUrlForProvider",value:function(e,t,r){return(0,S._)(function(){var n,s,i,a,o,u;return(0,I._)(this,function(c){switch(c.label){case 0:if(n=["provider=".concat(encodeURIComponent(t))],(null==r?void 0:r.redirectTo)&&n.push("redirect_to=".concat(encodeURIComponent(r.redirectTo))),(null==r?void 0:r.scopes)&&n.push("scopes=".concat(encodeURIComponent(r.scopes))),"pkce"!==this.flowType)return[3,2];return[4,tL(this.storage,this.storageKey)];case 1:i=(s=D._.apply(void 0,[c.sent(),2]))[0],a=s[1],o=new URLSearchParams({code_challenge:"".concat(encodeURIComponent(i)),code_challenge_method:"".concat(encodeURIComponent(a))}),n.push(o.toString()),c.label=2;
1case 2:return(null==r?void 0:r.queryParams)&&(u=new URLSearchParams(r.queryParams),n.push(u.toString())),(null==r?void 0:r.skipBrowserRedirect)&&n.push("skip_http_redirect=".concat(r.skipBrowserRedirect)),[2,"".concat(e,"?").concat(n.join("&"))]}})}).call(this)}},{key:"_unenroll",value:function(e){return(0,S._)(function(){var t,r;return(0,I._)(this,function(n){switch(n.label){case 0:t=this,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this._useSession(function(r){return(0,S._)(function(){var t,n,s;return(0,I._)(this,function(i){switch(i.label){case 0:if(n=r.data,s=r.error)return[2,this._returnResult({data:null,error:s})];return[4,tV(this.fetch,"DELETE","".concat(this.url,"/factors/").concat(e.factorId),{headers:this.headers,jwt:null==(t=null==n?void 0:n.session)?void 0:t.access_token})];case 1:return[2,i.sent()]}})}).call(t)})];case 2:return[2,n.sent()];case 3:if(tn(r=n.sent()))return[2,this._returnResult({data:null,error:r})];throw r;case 4:return[2]}})}).call(this)}},{key:"_enroll",value:function(e){return(0,S._)(function(){var t,r;return(0,I._)(this,function(n){switch(n.label){case 0:t=this,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this._useSession(function(r){return(0,S._)(function(){var t,n,s,i,a,o,u,c;return(0,I._)(this,function(l){switch(l.label){case 0:if(s=r.data,i=r.error)return[2,this._returnResult({data:null,error:i})];return a=Object.assign({friendly_name:e.friendlyName,factor_type:e.factorType},"phone"===e.factorType?{phone:e.phone}:"totp"===e.factorType?{issuer:e.issuer}:{}),[4,tV(this.fetch,"POST","".concat(this.url,"/factors"),{body:a,headers:this.headers,jwt:null==(t=null==s?void 0:s.session)?void 0:t.access_token})];case 1:if(u=(o=l.sent()).data,c=o.error)return[2,this._returnResult({data:null,error:c})];return"totp"===e.factorType&&"totp"===u.type&&(null==(n=null==u?void 0:u.totp)?void 0:n.qr_code)&&(u.totp.qr_code="data:image/svg+xml;utf-8,".concat(u.totp.qr_code)),[2,this._returnResult({data:u,error:null})]}})}).call(t)})];case 2:return[2,n.sent()];case 3:if(tn(r=n.sent()))return[2,this._returnResult({data:null,error:r})];throw r;case 4:return[2]}})}).call(this)}},{key:"_verify",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){return t=this,[2,this._acquireLock(this.lockAcquireTimeout,function(){return(0,S._)(function(){var t,r;return(0,I._)(this,function(n){switch(n.label){case 0:t=this,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this._useSession(function(r){return(0,S._)(function(){var t,n,s,i,a,o,u;return(0,I._)(this,function(c){switch(c.label){case 0:var l,h;if(n=r.data,s=r.error)return[2,this._returnResult({data:null,error:s})];return i=Object.assign({challenge_id:e.challengeId},"webauthn"in e?{webauthn:Object.assign(Object.assign({},e.webauthn),{credential_response:"create"===e.webauthn.type?"toJSON"in(l=e.webauthn.credential_response)&&"function"==typeof l.toJSON?l.toJSON():{id:l.id,rawId:l.id,response:{attestationObject:tT(new Uint8Array(l.response.attestationObject)),clientDataJSON:tT(new Uint8Array(l.response.clientDataJSON))},type:"public-key",clientExtensionResults:l.getClientExtensionResults(),authenticatorAttachment:null!=(h=l.authenticatorAttachment)?h:void 0}:function(e){if("toJSON"in e&&"function"==typeof e.toJSON)return e.toJSON();var t,r=e.getClientExtensionResults(),n=e.response;return{id:e.id,rawId:e.id,response:{authenticatorData:tT(new Uint8Array(n.authenticatorData)),clientDataJSON:tT(new Uint8Array(n.clientDataJSON)),signature:tT(new Uint8Array(n.signature)),userHandle:n.userHandle?tT(new Uint8Array(n.userHandle)):void 0},type:"public-key",clientExtensionResults:r,authenticatorAttachment:null!=(t=e.authenticatorAttachment)?t:void 0}}(e.webauthn.credential_response)})}:{code:e.code}),[4,tV(this.fetch,"POST","".concat(this.url,"/factors/").concat(e.factorId,"/verify"),{body:i,headers:this.headers,jwt:null==(t=null==n?void 0:n.session)?void 0:t.access_token})];case 1:if(o=(a=c.sent()).data,u=a.error)return[2,this._returnResult({data:null,error:u})];return[4,this._saveSession(Object.assign({expires_at:Math.round(Date.now()/1e3)+o.expires_in},o))];case 2:return c.sent(),[4,this._notifyAllSubscribers("MFA_CHALLENGE_VERIFIED",o)];case 3:return c.sent(),[2,this._returnResult({data:o,error:u})]}})}).call(t)})];case 2:return[2,n.sent()];case 3:if(tn(r=n.sent()))return[2,this._returnResult({data:null,error:r})];throw r;case 4:return[2]}})}).call(t)})]})}).call(this)}},{key:"_challenge",value:function(e){return(0,S._)(function(){var t;return(0,I._)(this,function(r){return t=this,[2,this._acquireLock(this.lockAcquireTimeout,function(){return(0,S._)(function(){var t,r;return(0,I._)(this,function(n){switch(n.label){case 0:t=this,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this._useSession(function(r){return(0,S._)(function(){var t,n,s,i,a;return(0,I._)(this,function(o){switch(o.label){case 0:if(n=r.data,s=r.error)return[2,this._returnResult({data:null,error:s})];return[4,tV(this.fetch,"POST","".concat(this.url,"/factors/").concat(e.factorId,"/challenge"),{body:e,headers:this.headers,jwt:null==(t=null==n?void 0:n.session)?void 0:t.access_token})];case 1:if((i=o.sent()).error)return[2,i];if("webauthn"!==(a=i.data).type)return[2,{data:a,error:null}];switch(a.webauthn.type){case"create":return[2,{data:Object.assign(Object.assign({},a),{webauthn:Object.assign(Object.assign({},a.webauthn),{credential_options:Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:function(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);var t=e.challenge,r=e.user,n=e.excludeCredentials,s=(0,L.__rest)(e,["challenge","user","excludeCredentials"]),i=tE(t).buffer,a=Object.assign(Object.assign({},r),{id:tE(r.id).buffer}),o=Object.assign(Object.assign({}
1,s),{challenge:i,user:a});if(n&&n.length>0){o.excludeCredentials=Array(n.length);for(var u=0;u<n.length;u++){var c=n[u];o.excludeCredentials[u]=Object.assign(Object.assign({},c),{id:tE(c.id).buffer,type:c.type||"public-key",transports:c.transports})}}return o}(a.webauthn.credential_options.publicKey)})})}),error:null}];case"request":return[2,{data:Object.assign(Object.assign({},a),{webauthn:Object.assign(Object.assign({},a.webauthn),{credential_options:Object.assign(Object.assign({},a.webauthn.credential_options),{publicKey:function(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);var t=e.challenge,r=e.allowCredentials,n=(0,L.__rest)(e,["challenge","allowCredentials"]),s=tE(t).buffer,i=Object.assign(Object.assign({},n),{challenge:s});if(r&&r.length>0){i.allowCredentials=Array(r.length);for(var a=0;a<r.length;a++){var o=r[a];i.allowCredentials[a]=Object.assign(Object.assign({},o),{id:tE(o.id).buffer,type:o.type||"public-key",transports:o.transports})}}return i}(a.webauthn.credential_options.publicKey)})})}),error:null}]}return[2]}})}).call(t)})];case 2:return[2,n.sent()];case 3:if(tn(r=n.sent()))return[2,this._returnResult({data:null,error:r})];throw r;case 4:return[2]}})}).call(t)})]})}).call(this)}},{key:"_challengeAndVerify",value:function(e){return(0,S._)(function(){var t,r,n;return(0,I._)(this,function(s){switch(s.label){case 0:return[4,this._challenge({factorId:e.factorId})];case 1:if(r=(t=s.sent()).data,n=t.error)return[2,this._returnResult({data:null,error:n})];return[4,this._verify({factorId:e.factorId,challengeId:r.id,code:e.code})];case 2:return[2,s.sent()]}})}).call(this)}},{key:"_listFactors",value:function(){return(0,S._)(function(){var e,t,r,n,s,i,a,o,u,c,l;return(0,I._)(this,function(h){switch(h.label){case 0:return[4,this.getUser()];case 1:if(r=(t=h.sent()).data.user,n=t.error)return[2,{data:null,error:n}];s={all:[],phone:[],totp:[],webauthn:[]},i=!0,a=!1,o=void 0;try{for(u=(null!=(e=null==r?void 0:r.factors)?e:[])[Symbol.iterator]();!(i=(c=u.next()).done);i=!0)l=c.value,s.all.push(l),"verified"===l.status&&s[l.factor_type].push(l)}catch(e){a=!0,o=e}finally{try{i||null==u.return||u.return()}finally{if(a)throw o}}return[2,{data:s,error:null}]}})}).call(this)}},{key:"_getAuthenticatorAssuranceLevel",value:function(e){return(0,S._)(function(){var t,r,n,s,i,a,o,u,c,l,h,f,d,p,v,_,g,y,b;return(0,I._)(this,function(m){switch(m.label){case 0:if(!e)return[3,4];m.label=1;case 1:return m.trys.push([1,3,,4]),i=tx(e).payload,a=null,i.aal&&(a=i.aal),o=a,[4,this.getUser(e)];case 2:if(c=(u=m.sent()).data.user,l=u.error)return[2,this._returnResult({data:null,error:l})];return(null!=(r=null==(t=null==c?void 0:c.factors)?void 0:t.filter(function(e){return"verified"===e.status}))?r:[]).length>0&&(o="aal2"),h=i.amr||[],[2,{data:{currentLevel:a,nextLevel:o,currentAuthenticationMethods:h},error:null}];case 3:if(tn(f=m.sent()))return[2,this._returnResult({data:null,error:f})];throw f;case 4:return[4,this.getSession()];case 5:if(p=(d=m.sent()).data.session,v=d.error)return[2,this._returnResult({data:null,error:v})];if(!p)return[2,{data:{currentLevel:null,nextLevel:null,currentAuthenticationMethods:[]},error:null}];return _=tx(p.access_token).payload,g=null,_.aal&&(g=_.aal),y=g,(null!=(s=null==(n=p.user.factors)?void 0:n.filter(function(e){return"verified"===e.status}))?s:[]).length>0&&(y="aal2"),b=_.amr||[],[2,{data:{currentLevel:g,nextLevel:y,currentAuthenticationMethods:b},error:null}]}})}).call(this)}},{key:"_getAuthorizationDetails",value:function(e){return(0,S._)(function(){var t,r;return(0,I._)(this,function(n){switch(n.label){case 0:t=this,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this._useSession(function(r){return(0,S._)(function(){var t,n;return(0,I._)(this,function(s){switch(s.label){case 0:if(t=r.data.session,n=r.error)return[2,this._returnResult({data:null,error:n})];if(!t)return[2,this._returnResult({data:null,error:new to})];return[4,tV(this.fetch,"GET","".concat(this.url,"/oauth/authorizations/").concat(e),{headers:this.headers,jwt:t.access_token,xform:function(e){return{data:e,error:null}}})];case 1:return[2,s.sent()]}})}).call(t)})];case 2:return[2,n.sent()];case 3:if(tn(r=n.sent()))return[2,this._returnResult({data:null,error:r})];throw r;case 4:return[2]}})}).call(this)}},{key:"_approveAuthorization",value:function(e,t){return(0,S._)(function(){var r,n;return(0,I._)(this,function(s){switch(s.label){case 0:r=this,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this._useSession(function(n){return(0,S._)(function(){var r,s,i;return(0,I._)(this,function(a){switch(a.label){case 0:if(r=n.data.session,s=n.error)return[2,this._returnResult({data:null,error:s})];if(!r)return[2,this._returnResult({data:null,error:new to})];return[4,tV(this.fetch,"POST","".concat(this.url,"/oauth/authorizations/").concat(e,"/consent"),{headers:this.headers,jwt:r.access_token,body:{action:"approve"},xform:function(e){return{data:e,error:null}}})];case 1:return(i=a.sent()).data&&i.data.redirect_url&&tO()&&!(null==t?void 0:t.skipBrowserRedirect)&&window.location.assign(i.data.redirect_url),[2,i]}})}).call(r)})];case 2:return[2,s.sent()];case 3:if(tn(n=s.sent()))return[2,this._returnResult({data:null,error:n})];throw n;case 4:return[2]}})}).call(this)}},{key:"_denyAuthorization",value:function(e,t){return(0,S._)(function(){var r,n;return(0,I._)(this,function(s){switch(s.label){case 0:r=this,s.label=1;case 1:return s.trys.push([1,3,,4]),[4,this._useSession(function(n){return(0,S._)(function(){var r,s,i;return(0,I._)(this,function(a){switch(a.label){case 0:if(r=n.data.session,s=n.error)return[2,this._returnResult({data:null,error:s})];if(!r)return[2,this._returnResult({data:null,error:new to})];return[4,tV(this.fetch,"POST","".concat(this.url,"/oauth/authorizations/").concat(e,"/consent"),{headers:this.headers,jwt:r.access_token,body:{action:"deny"},xform:function(e){return{data:e,error:null}}})];case 1:return(i=a.sent()).data&&i.data.redirect_url&&tO()&&!(null==t?void 0:t.skipBrowserRedirect)&&window.location.assign(i.data.redirect_url),[2,i]}})}).call(r)})];case 2:return[2,s.sent()];case 3:if(tn(n=s.sent()))return[2,this._returnResult({data:null,error:n})];throw n;case 4:return[2]}})}).call(this)}},{key:"_listOAuthGrants",value:function(){return(0,S._)(function(){var e,t;return(0,I._)(this,function(r){switch(r.label){case 0:e=this,r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._useSession(function(t){return(0,S._)(function(){var e,r;return(0,I._)(this,function(n){switch(n.label){case 0:if(e=t.data.session,r=t.error)return[2,this._returnResult({data:null,error:r})];if(!e)return[2,this._returnResult({data:null,error:new to})];return[4,tV(this.fetch,"GET","".concat(this.url,"/user/oauth/grants"),{headers:this.headers,jwt:e.access_token,xform:function(e){return{data:e,error:null}}})];case 1:return[2,n.sent()]}})}).call(e)})];case 2:return[2,r.sent()];case 3:if(tn(t=r.sent()))return[2,this._returnResult({data:null,error:t})];throw t;case 4:return[2]}})}).call(this)}},{key:"_revokeOAuthGrant",value:function(e){return(0,S._)(function(){var t,r;return(0,I._)(this,function(n){switch(n.label){case 0:t=this,n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this._useSession(function(r){return(0,S._)(function(){var t,n;return(0,I._)(this,function(s){switch(s.label){case 0:if(t=r.data.session,n=r.error)return[2,this._returnResult({data:null,error:n})];if(!t)return[2,this._returnResult({data:null,error:new to})];
1return[4,tV(this.fetch,"DELETE","".concat(this.url,"/user/oauth/grants"),{headers:this.headers,jwt:t.access_token,query:{client_id:e.clientId},noResolveJson:!0})];case 1:return s.sent(),[2,{data:{},error:null}]}})}).call(t)})];case 2:return[2,n.sent()];case 3:if(tn(r=n.sent()))return[2,this._returnResult({data:null,error:r})];throw r;case 4:return[2]}})}).call(this)}},{key:"fetchJwk",value:function(e){return(0,S._)(function(e){var t,r,n,s,i,a=arguments;return(0,I._)(this,function(o){switch(o.label){case 0:if((t=(a.length>1&&void 0!==a[1]?a[1]:{keys:[]}).keys.find(function(t){return t.kid===e}))||(r=Date.now(),(t=this.jwks.keys.find(function(t){return t.kid===e}))&&this.jwks_cached_at+6e5>r))return[2,t];return[4,tV(this.fetch,"GET","".concat(this.url,"/.well-known/jwks.json"),{headers:this.headers})];case 1:if(s=(n=o.sent()).data,i=n.error)throw i;if(!s.keys||0===s.keys.length||(this.jwks=s,this.jwks_cached_at=r,!(t=s.keys.find(function(t){return t.kid===e}))))return[2,null];return[2,t]}})}).apply(this,arguments)}},{key:"getClaims",value:function(e){return(0,S._)(function(e){var t,r,n,s,i,a,o,u,c,l,h,f,d,p,v,_,g,y,b=arguments;return(0,I._)(this,function(m){switch(m.label){case 0:t=b.length>1&&void 0!==b[1]?b[1]:{},m.label=1;case 1:if(m.trys.push([1,11,,12]),r=e)return[3,3];return[4,this.getSession()];case 2:if(s=(n=m.sent()).data,(i=n.error)||!s.session)return[2,this._returnResult({data:null,error:i})];r=s.session.access_token,m.label=3;case 3:if(o=(a=tx(r)).header,u=a.payload,c=a.signature,h=(l=a.raw).header,f=l.payload,(null==t?void 0:t.allowExpired)||function(e){if(!e)throw Error("Missing exp claim");if(e<=Math.floor(Date.now()/1e3))throw Error("JWT has expired")}(u.exp),!(!o.alg||o.alg.startsWith("HS")||!o.kid||!("crypto"in globalThis&&"subtle"in globalThis.crypto)))return[3,4];return p=null,[3,6];case 4:return[4,this.fetchJwk(o.kid,(null==t?void 0:t.keys)?{keys:t.keys}:null==t?void 0:t.jwks)];case 5:p=m.sent(),m.label=6;case 6:if(d=p)return[3,8];return[4,this.getUser(r)];case 7:if(v=m.sent().error)throw v;return[2,{data:{claims:u,header:o,signature:c},error:null}];case 8:return _=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")}}(o.alg),[4,crypto.subtle.importKey("jwk",d,_,!0,["verify"])];case 9:var w,k;return g=m.sent(),[4,crypto.subtle.verify(_,g,c,(w="".concat(h,".").concat(f),k=[],!function(e,t){for(var r=0;r<e.length;r+=1){var n=e.charCodeAt(r);if(n>55295&&n<=56319){var s=(n-55296)*1024&65535;n=(e.charCodeAt(r+1)-56320&65535|s)+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: ".concat(e.toString(16)))}(n,t)}}(w,function(e){return k.push(e)}),new Uint8Array(k)))];case 10:if(!m.sent())throw new tg("Invalid JWT signature");return[2,{data:{claims:u,header:o,signature:c},error:null}];case 11:if(tn(y=m.sent()))return[2,this._returnResult({data:null,error:y})];throw y;case 12:return[2]}})}).apply(this,arguments)}}]),e}();rc.nextInstanceID={};var rl="";rl="undefined"!=typeof Deno?"deno":"undefined"!=typeof document?"web":"undefined"!=typeof navigator&&"ReactNative"===navigator.product?"react-native":"node";var rh={headers:{"X-Client-Info":"supabase-js-".concat(rl,"/").concat("2.99.1")}},rf={schema:"public"},rd={autoRefreshToken:!0,persistSession:!0,detectSessionInUrl:!0,flowType:"implicit"},rp={};function rv(e){return(rv="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 r_(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 rg(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};
1t%2?r_(Object(r),!0).forEach(function(t){!function(e,t,r){var n;(n=function(e,t){if("object"!=rv(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=rv(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"),(t="symbol"==rv(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)):r_(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}var ry=function(e,t,r){var n=r?function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return r.apply(void 0,(0,R._)(t))}:function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];return fetch.apply(void 0,(0,R._)(t))},s=Headers;return function(r,i){return(0,S._)(function(){var a,o,u;return(0,I._)(this,function(c){switch(c.label){case 0:return[4,t()];case 1:return o=null!=(a=c.sent())?a:e,(u=new s(null==i?void 0:i.headers)).has("apikey")||u.set("apikey",e),u.has("Authorization")||u.set("Authorization","Bearer ".concat(o)),[2,n(r,rg(rg({},i),{},{headers:u}))]}})})()}},rb=function(e){function t(e){return(0,T._)(this,t),(0,E._)(this,t,[e])}return(0,A._)(t,e),t}(rc),rm=function(){function e(t,r,n){var s,i,a,o,u,c,l,h,f,d,p,v,_,g,y,b=this;(0,T._)(this,e),this.supabaseUrl=t,this.supabaseKey=r;var m=function(e){var 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.")}}(t);if(!r)throw Error("supabaseKey is required.");this.realtimeUrl=new URL("realtime/v1",m),this.realtimeUrl.protocol=this.realtimeUrl.protocol.replace("http","ws"),this.authUrl=new URL("auth/v1",m),this.storageUrl=new URL("storage/v1",m),this.functionsUrl=new URL("functions/v1",m);var w="sb-".concat(m.hostname.split(".")[0],"-auth-token"),k={db:rf,realtime:rp,auth:rg(rg({},rd),{},{storageKey:w}),global:rh},E=(o=(s=null!=n?n:{}).db,u=s.auth,c=s.realtime,l=s.global,h=k.db,f=k.auth,d=k.realtime,p=k.global,v={db:rg(rg({},h),o),auth:rg(rg({},f),u),realtime:rg(rg({},d),c),storage:{},global:rg(rg(rg({},p),l),{},{headers:rg(rg({},null!=(i=null==p?void 0:p.headers)?i:{}),null!=(a=null==l?void 0:l.headers)?a:{})}),accessToken:function(){return(0,S._)(function(){return(0,I._)(this,function(e){return[2,""]})})()}},s.accessToken?v.accessToken=s.accessToken:delete v.accessToken,v);this.storageKey=null!=(_=E.auth.storageKey)?_:"",this.headers=null!=(g=E.global.headers)?g:{},E.accessToken?(this.accessToken=E.accessToken,this.auth=new Proxy({},{get:function(e,t){throw Error("@supabase/supabase-js: Supabase Client is configured with the accessToken option, accessing supabase.auth.".concat(String(t)," is not possible"))}})):this.auth=this._initSupabaseAuthClient(null!=(y=E.auth)?y:{},this.headers,E.global.fetch),this.fetch=ry(r,this._getAccessToken.bind(this),E.global.fetch),this.realtime=this._initRealtimeClient(rg({headers:this.headers,accessToken:this._getAccessToken.bind(this)},E.realtime)),this.accessToken&&Promise.resolve(this.accessToken()).then(function(e){return b.realtime.setAuth(e)}).catch(function(e){return console.warn("Failed to set initial Realtime auth token:",e)}),this.rest=new G(new URL("rest/v1",m).href,{headers:this.headers,schema:E.db.schema,fetch:this.fetch,timeout:E.db.timeout,urlLengthLimit:E.db.urlLengthLimit}),this.storage=new e8(this.storageUrl.href,this.headers,this.fetch,null==n?void 0:n.storage),E.accessToken||this._listenForAuthEvents()}return(0,O._)(e,[{key:"functions",get:function(){return new B(this.functionsUrl.href,{headers:this.headers,customFetch:this.fetch})}},{key:"from",value:function(e){return this.rest.from(e)}},{key:"schema",value:function(e){return this.rest.schema(e)}},{key:"rpc",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{head:!1,get:!1,count:void 0};return this.rest.rpc(e,t,r)}},{key:"channel",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{config:{}};return this.realtime.channel(e,t)}},{key:"getChannels",value:function(){return this.realtime.getChannels()}},{key:"removeChannel",value:function(e){return this.realtime.removeChannel(e)}},{key:"removeAllChannels",value:function(){return this.realtime.removeAllChannels()}},{key:"_getAccessToken",value:function(){return(0,S._)(function(){var e,t,r;return(0,I._)(this,function(n){switch(n.label){case 0:if(e=this,!e.accessToken)return[3,2];return[4,e.accessToken()];case 1:return[2,n.sent()];case 2:return[4,e.auth.getSession()];case 3:return[2,null!=(t=null==(r=n.sent().data.session)?void 0:r.access_token)?t:e.supabaseKey]}})}).call(this)}},{key:"_initSupabaseAuthClient",value:function(e,t,r){var n=e.autoRefreshToken,s=e.persistSession,i=e.detectSessionInUrl,a=e.storage,o=e.userStorage,u=e.storageKey,c=e.flowType,l=e.lock,h=e.debug,f=e.throwOnError,d={Authorization:"Bearer ".concat(this.supabaseKey),apikey:"".concat(this.supabaseKey)};return new rb({url:this.authUrl.href,headers:rg(rg({},d),t),storageKey:u,autoRefreshToken:n,persistSession:s,detectSessionInUrl:i,storage:a,userStorage:o,flowType:c,lock:l,debug:h,throwOnError:f,fetch:r,hasCustomAuthorizationHeader:Object.keys(this.headers).some(function(e){return"authorization"===e.toLowerCase()})})}},{key:"_initRealtimeClient",value:function(e){return new ev(this.realtimeUrl.href,rg(rg({},e),{},{params:rg(rg({},{apikey:this.supabaseKey}),null==e?void 0:e.params)}))}},{key:"_listenForAuthEvents",value:function(){var e=this;return this.auth.onAuthStateChange(function(t,r){e._handleTokenChanged(t,"CLIENT",null==r?void 0:r.access_token)})}},{key:"_handleTokenChanged",value:function(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)}}]),e}();(function(){if("undefined"!=typeof window)return!1;var e=globalThis.process;if(!e)return!1;var t=e.version;if(null==t)return!1;var 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
1ode.js 20 or later. For more information, visit: https://github.com/orgs/supabase/discussions/37217");var rw=new rm("https://evipmhwfbionytxilumu.supabase.co","eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImV2aXBtaHdmYmlvbnl0eGlsdW11Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjM3MzY3NzMsImV4cCI6MjA3OTMxMjc3M30.JakDNj5VrA9GXUYr3ZWU6rMbxPRRBLfdhpF-HXuRz-I",{auth:{persistSession:!0,autoRefreshToken:!0}});e.s(["supabase",()=>rw],922459)}]);

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.