@nvwa-app/sdk-uniapp 0.4.28 → 0.4.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var le=Object.defineProperty;var Lt=Object.getOwnPropertyDescriptor;var Dt=Object.getOwnPropertyNames;var Bt=Object.prototype.hasOwnProperty;var kt=(e,t)=>{for(var r in t)le(e,r,{get:t[r],enumerable:!0})},Mt=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Dt(t))!Bt.call(e,n)&&n!==r&&le(e,n,{get:()=>t[n],enumerable:!(s=Lt(t,n))||s.enumerable});return e};var Ft=e=>Mt(le({},"__esModule",{value:!0}),e);var ms={};kt(ms,{default:()=>ae,localStorage:()=>xt,polyfill:()=>jt});module.exports=Ft(ms);var Ht=Object.create,ne=Object.defineProperty,qt=Object.getOwnPropertyDescriptor,Gt=Object.getOwnPropertyNames,Wt=Object.getPrototypeOf,zt=Object.prototype.hasOwnProperty,xe=(e,t)=>()=>(e&&(t=e(e=0)),t),D=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Kt=(e,t)=>{for(var r in t)ne(e,r,{get:t[r],enumerable:!0})},Ue=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Gt(t))!zt.call(e,n)&&n!==r&&ne(e,n,{get:()=>t[n],enumerable:!(s=qt(t,n))||s.enumerable});return e},Vt=(e,t,r)=>(r=e!=null?Ht(Wt(e)):{},Ue(t||!e||!e.__esModule?ne(r,"default",{value:e,enumerable:!0}):r,e)),q=e=>Ue(ne({},"__esModule",{value:!0}),e),p=xe(()=>{"use strict"}),B={};Kt(B,{__addDisposableResource:()=>ot,__assign:()=>V,__asyncDelegator:()=>Xe,__asyncGenerator:()=>Je,__asyncValues:()=>Qe,__await:()=>H,__awaiter:()=>Ge,__classPrivateFieldGet:()=>rt,__classPrivateFieldIn:()=>nt,__classPrivateFieldSet:()=>st,__createBinding:()=>Y,__decorate:()=>De,__disposeResources:()=>at,__esDecorate:()=>ke,__exportStar:()=>ze,__extends:()=>Ce,__generator:()=>We,__importDefault:()=>tt,__importStar:()=>et,__makeTemplateObject:()=>Ze,__metadata:()=>qe,__param:()=>Be,__propKey:()=>Fe,__read:()=>ge,__rest:()=>Le,__rewriteRelativeImportExtension:()=>it,__runInitializers:()=>Me,__setFunctionName:()=>He,__spread:()=>Ke,__spreadArray:()=>Ye,__spreadArrays:()=>Ve,__values:()=>se,default:()=>ct});function Ce(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Z(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function Le(e,t){var r={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(e);n<s.length;n++)t.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(e,s[n])&&(r[s[n]]=e[s[n]]);return r}function De(e,t,r,s){var n=arguments.length,o=n<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,r):s,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(e,t,r,s);else for(var l=e.length-1;l>=0;l--)(a=e[l])&&(o=(n<3?a(o):n>3?a(t,r,o):a(t,r))||o);return n>3&&o&&Object.defineProperty(t,r,o),o}function Be(e,t){return function(r,s){t(r,s,e)}}function ke(e,t,r,s,n,o){function a(w){if(w!==void 0&&typeof w!="function")throw new TypeError("Function expected");return w}for(var l=s.kind,u=l==="getter"?"get":l==="setter"?"set":"value",i=!t&&e?s.static?e:e.prototype:null,c=t||(i?Object.getOwnPropertyDescriptor(i,s.name):{}),h,m=!1,f=r.length-1;f>=0;f--){var y={};for(var v in s)y[v]=v==="access"?{}:s[v];for(var v in s.access)y.access[v]=s.access[v];y.addInitializer=function(w){if(m)throw new TypeError("Cannot add initializers after decoration has completed");o.push(a(w||null))};var g=(0,r[f])(l==="accessor"?{get:c.get,set:c.set}:c[u],y);if(l==="accessor"){if(g===void 0)continue;if(g===null||typeof g!="object")throw new TypeError("Object expected");(h=a(g.get))&&(c.get=h),(h=a(g.set))&&(c.set=h),(h=a(g.init))&&n.unshift(h)}else(h=a(g))&&(l==="field"?n.unshift(h):c[u]=h)}i&&Object.defineProperty(i,s.name,c),m=!0}function Me(e,t,r){for(var s=arguments.length>2,n=0;n<t.length;n++)r=s?t[n].call(e,r):t[n].call(e);return s?r:void 0}function Fe(e){return typeof e=="symbol"?e:"".concat(e)}function He(e,t,r){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function qe(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function Ge(e,t,r,s){function n(o){return o instanceof r?o:new r(function(a){a(o)})}return new(r||(r=Promise))(function(o,a){function l(c){try{i(s.next(c))}catch(h){a(h)}}function u(c){try{i(s.throw(c))}catch(h){a(h)}}function i(c){c.done?o(c.value):n(c.value).then(l,u)}i((s=s.apply(e,t||[])).next())})}function We(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},s,n,o,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(i){return function(c){return u([i,c])}}function u(i){if(s)throw new TypeError("Generator is already executing.");for(;a&&(a=0,i[0]&&(r=0)),r;)try{if(s=1,n&&(o=i[0]&2?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[i[0]&2,o.value]),i[0]){case 0:case 1:o=i;break;case 4:return r.label++,{value:i[1],done:!1};case 5:r.label++,n=i[1],i=[0];continue;case 7:i=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!o||i[1]>o[0]&&i[1]<o[3])){r.label=i[1];break}if(i[0]===6&&r.label<o[1]){r.label=o[1],o=i;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(i);break}o[2]&&r.ops.pop(),r.trys.pop();continue}i=t.call(e,r)}catch(c){i=[6,c],n=0}finally{s=o=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}function ze(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Y(t,e,r)}function se(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],s=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&s>=e.length&&(e=void 0),{value:e&&e[s++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function ge(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var s=r.call(e),n,o=[],a;try{for(;(t===void 0||t-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(l){a={error:l}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(a)throw a.error}}return o}function Ke(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(ge(arguments[t]));return e}function Ve(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var s=Array(e),n=0,t=0;t<r;t++)for(var o=arguments[t],a=0,l=o.length;a<l;a++,n++)s[n]=o[a];return s}function Ye(e,t,r){if(r||arguments.length===2)for(var s=0,n=t.length,o;s<n;s++)(o||!(s in t))&&(o||(o=Array.prototype.slice.call(t,0,s)),o[s]=t[s]);return e.concat(o||Array.prototype.slice.call(t))}function H(e){return this instanceof H?(this.v=e,this):new H(e)}function Je(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r.apply(e,t||[]),n,o=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),l("next"),l("throw"),l("return",a),n[Symbol.asyncIterator]=function(){return this},n;function a(f){return function(y){return Promise.resolve(y).then(f,h)}}function l(f,y){s[f]&&(n[f]=function(v){return new Promise(function(g,w){o.push([f,v,g,w])>1||u(f,v)})},y&&(n[f]=y(n[f])))}function u(f,y){try{i(s[f](y))}catch(v){m(o[0][3],v)}}function i(f){f.value instanceof H?Promise.resolve(f.value.v).then(c,h):m(o[0][2],f)}function c(f){u("next",f)}function h(f){u("throw",f)}function m(f,y){f(y),o.shift(),o.length&&u(o[0][0],o[0][1])}}function Xe(e){var t,r;return t={},s("next"),s("throw",function(n){throw n}),s("return"),t[Symbol.iterator]=function(){return this},t;function s(n,o){t[n]=e[n]?function(a){return(r=!r)?{value:H(e[n](a)),done:!1}:o?o(a):a}:o}}function Qe(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof se=="function"?se(e):e[Symbol.iterator](),r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r);function s(o){r[o]=e[o]&&function(a){return new Promise(function(l,u){a=e[o](a),n(l,u,a.done,a.value)})}}function n(o,a,l,u){Promise.resolve(u).then(function(i){o({value:i,done:l})},a)}}function Ze(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function et(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=ee(e),s=0;s<r.length;s++)r[s]!=="default"&&Y(t,e,r[s]);return lt(t,e),t}function tt(e){return e&&e.__esModule?e:{default:e}}function rt(e,t,r,s){if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?s:r==="a"?s.call(e):s?s.value:t.get(e)}function st(e,t,r,s,n){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?n.call(e,r):n?n.value=r:t.set(e,r),r}function nt(e,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof e=="function"?t===e:e.has(t)}function ot(e,t,r){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var s,n;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=t[Symbol.asyncDispose]}if(s===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=t[Symbol.dispose],r&&(n=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");n&&(s=function(){try{n.call(this)}catch(o){return Promise.reject(o)}}),e.stack.push({value:t,dispose:s,async:r})}else r&&e.stack.push({async:!0});return t}function at(e){function t(o){e.error=e.hasError?new ut(o,e.error,"An error was suppressed during disposal."):o,e.hasError=!0}var r,s=0;function n(){for(;r=e.stack.pop();)try{if(!r.async&&s===1)return s=0,e.stack.push(r),Promise.resolve().then(n);if(r.dispose){var o=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(o).then(n,function(a){return t(a),n()})}else s|=1}catch(a){t(a)}if(s===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return n()}function it(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,s,n,o,a){return s?t?".jsx":".js":n&&(!o||!a)?r:n+o+"."+a.toLowerCase()+"js"}):e}var Z,V,Y,lt,ee,ut,ct,G=xe(()=>{"use strict";p(),Z=function(e,t){return Z=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(r[n]=s[n])},Z(e,t)},V=function(){return V=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++){t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},V.apply(this,arguments)},Y=Object.create?(function(e,t,r,s){s===void 0&&(s=r);var n=Object.getOwnPropertyDescriptor(t,r);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,n)}):(function(e,t,r,s){s===void 0&&(s=r),e[s]=t[r]}),lt=Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t},ee=function(e){return ee=Object.getOwnPropertyNames||function(t){var r=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[r.length]=s);return r},ee(e)},ut=typeof SuppressedError=="function"?SuppressedError:function(e,t,r){var s=new Error(r);return s.name="SuppressedError",s.error=e,s.suppressed=t,s},ct={__extends:Ce,__assign:V,__rest:Le,__decorate:De,__param:Be,__esDecorate:ke,__runInitializers:Me,__propKey:Fe,__setFunctionName:He,__metadata:qe,__awaiter:Ge,__generator:We,__createBinding:Y,__exportStar:ze,__values:se,__read:ge,__spread:Ke,__spreadArrays:Ve,__spreadArray:Ye,__await:H,__asyncGenerator:Je,__asyncDelegator:Xe,__asyncValues:Qe,__makeTemplateObject:Ze,__importStar:et,__importDefault:tt,__classPrivateFieldGet:rt,__classPrivateFieldSet:st,__classPrivateFieldIn:nt,__addDisposableResource:ot,__disposeResources:at,__rewriteRelativeImportExtension:it}}),ht=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}};e.default=t}),ft=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(B)),r=t.__importDefault(ht()),s=class{constructor(n){var o,a;this.shouldThrowOnError=!1,this.method=n.method,this.url=n.url,this.headers=new Headers(n.headers),this.schema=n.schema,this.body=n.body,this.shouldThrowOnError=(o=n.shouldThrowOnError)!==null&&o!==void 0?o:!1,this.signal=n.signal,this.isMaybeSingle=(a=n.isMaybeSingle)!==null&&a!==void 0?a:!1,n.fetch?this.fetch=n.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(n,o){return this.headers=new Headers(this.headers),this.headers.set(n,o),this}then(n,o){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let a=this.fetch,l=a(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async u=>{var i,c,h,m;let f=null,y=null,v=null,g=u.status,w=u.statusText;if(u.ok){if(this.method!=="HEAD"){let d=await u.text();d===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&!((i=this.headers.get("Accept"))===null||i===void 0)&&i.includes("application/vnd.pgrst.plan+text")?y=d:y=JSON.parse(d))}let T=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),P=(h=u.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");T&&P&&P.length>1&&(v=parseInt(P[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(y)&&(y.length>1?(f={code:"PGRST116",details:`Results contain ${y.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},y=null,v=null,g=406,w="Not Acceptable"):y.length===1?y=y[0]:y=null)}else{let T=await u.text();try{f=JSON.parse(T),Array.isArray(f)&&u.status===404&&(y=[],f=null,g=200,w="OK")}catch{u.status===404&&T===""?(g=204,w="No Content"):f={message:T}}if(f&&this.isMaybeSingle&&!((m=f?.details)===null||m===void 0)&&m.includes("0 rows")&&(f=null,g=200,w="OK"),f&&this.shouldThrowOnError)throw new r.default(f)}return{error:f,data:y,count:v,status:g,statusText:w}});return this.shouldThrowOnError||(l=l.catch(u=>{var i,c,h;return{error:{message:`${(i=u?.name)!==null&&i!==void 0?i:"FetchError"}: ${u?.message}`,details:`${(c=u?.stack)!==null&&c!==void 0?c:""}`,hint:"",code:`${(h=u?.code)!==null&&h!==void 0?h:""}`},data:null,count:null,status:0,statusText:""}})),l.then(n,o)}returns(){return this}overrideTypes(){return this}};e.default=s}),pt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(B)),r=t.__importDefault(ft()),s=class extends r.default{select(n){let o=!1,a=(n??"*").split("").map(l=>/\s/.test(l)&&!o?"":(l==='"'&&(o=!o),l)).join("");return this.url.searchParams.set("select",a),this.headers.append("Prefer","return=representation"),this}order(n,{ascending:o=!0,nullsFirst:a,foreignTable:l,referencedTable:u=l}={}){let i=u?`${u}.order`:"order",c=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${c?`${c},`:""}${n}.${o?"asc":"desc"}${a===void 0?"":a?".nullsfirst":".nullslast"}`),this}limit(n,{foreignTable:o,referencedTable:a=o}={}){let l=typeof a>"u"?"limit":`${a}.limit`;return this.url.searchParams.set(l,`${n}`),this}range(n,o,{foreignTable:a,referencedTable:l=a}={}){let u=typeof l>"u"?"offset":`${l}.offset`,i=typeof l>"u"?"limit":`${l}.limit`;return this.url.searchParams.set(u,`${n}`),this.url.searchParams.set(i,`${o-n+1}`),this}abortSignal(n){return this.signal=n,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:n=!1,verbose:o=!1,settings:a=!1,buffers:l=!1,wal:u=!1,format:i="text"}={}){var c;let h=[n?"analyze":null,o?"verbose":null,a?"settings":null,l?"buffers":null,u?"wal":null].filter(Boolean).join("|"),m=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${m}"; options=${h};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(n){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${n}`),this}};e.default=s}),ve=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(B)),r=t.__importDefault(pt()),s=new RegExp("[,()]"),n=class extends r.default{eq(o,a){return this.url.searchParams.append(o,`eq.${a}`),this}neq(o,a){return this.url.searchParams.append(o,`neq.${a}`),this}gt(o,a){return this.url.searchParams.append(o,`gt.${a}`),this}gte(o,a){return this.url.searchParams.append(o,`gte.${a}`),this}lt(o,a){return this.url.searchParams.append(o,`lt.${a}`),this}lte(o,a){return this.url.searchParams.append(o,`lte.${a}`),this}like(o,a){return this.url.searchParams.append(o,`like.${a}`),this}likeAllOf(o,a){return this.url.searchParams.append(o,`like(all).{${a.join(",")}}`),this}likeAnyOf(o,a){return this.url.searchParams.append(o,`like(any).{${a.join(",")}}`),this}ilike(o,a){return this.url.searchParams.append(o,`ilike.${a}`),this}ilikeAllOf(o,a){return this.url.searchParams.append(o,`ilike(all).{${a.join(",")}}`),this}ilikeAnyOf(o,a){return this.url.searchParams.append(o,`ilike(any).{${a.join(",")}}`),this}is(o,a){return this.url.searchParams.append(o,`is.${a}`),this}in(o,a){let l=Array.from(new Set(a)).map(u=>typeof u=="string"&&s.test(u)?`"${u}"`:`${u}`).join(",");return this.url.searchParams.append(o,`in.(${l})`),this}contains(o,a){return typeof a=="string"?this.url.searchParams.append(o,`cs.${a}`):Array.isArray(a)?this.url.searchParams.append(o,`cs.{${a.join(",")}}`):this.url.searchParams.append(o,`cs.${JSON.stringify(a)}`),this}containedBy(o,a){return typeof a=="string"?this.url.searchParams.append(o,`cd.${a}`):Array.isArray(a)?this.url.searchParams.append(o,`cd.{${a.join(",")}}`):this.url.searchParams.append(o,`cd.${JSON.stringify(a)}`),this}rangeGt(o,a){return this.url.searchParams.append(o,`sr.${a}`),this}rangeGte(o,a){return this.url.searchParams.append(o,`nxl.${a}`),this}rangeLt(o,a){return this.url.searchParams.append(o,`sl.${a}`),this}rangeLte(o,a){return this.url.searchParams.append(o,`nxr.${a}`),this}rangeAdjacent(o,a){return this.url.searchParams.append(o,`adj.${a}`),this}overlaps(o,a){return typeof a=="string"?this.url.searchParams.append(o,`ov.${a}`):this.url.searchParams.append(o,`ov.{${a.join(",")}}`),this}textSearch(o,a,{config:l,type:u}={}){let i="";u==="plain"?i="pl":u==="phrase"?i="ph":u==="websearch"&&(i="w");let c=l===void 0?"":`(${l})`;return this.url.searchParams.append(o,`${i}fts${c}.${a}`),this}match(o){return Object.entries(o).forEach(([a,l])=>{this.url.searchParams.append(a,`eq.${l}`)}),this}not(o,a,l){return this.url.searchParams.append(o,`not.${a}.${l}`),this}or(o,{foreignTable:a,referencedTable:l=a}={}){let u=l?`${l}.or`:"or";return this.url.searchParams.append(u,`(${o})`),this}filter(o,a,l){return this.url.searchParams.append(o,`${a}.${l}`),this}};e.default=n}),dt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(B)),r=t.__importDefault(ve()),s=class{constructor(n,{headers:o={},schema:a,fetch:l}){this.url=n,this.headers=new Headers(o),this.schema=a,this.fetch=l}select(n,o){let{head:a=!1,count:l}=o??{},u=a?"HEAD":"GET",i=!1,c=(n??"*").split("").map(h=>/\s/.test(h)&&!i?"":(h==='"'&&(i=!i),h)).join("");return this.url.searchParams.set("select",c),l&&this.headers.append("Prefer",`count=${l}`),new r.default({method:u,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(n,{count:o,defaultToNull:a=!0}={}){var l;let u="POST";if(o&&this.headers.append("Prefer",`count=${o}`),a||this.headers.append("Prefer","missing=default"),Array.isArray(n)){let i=n.reduce((c,h)=>c.concat(Object.keys(h)),[]);if(i.length>0){let c=[...new Set(i)].map(h=>`"${h}"`);this.url.searchParams.set("columns",c.join(","))}}return new r.default({method:u,url:this.url,headers:this.headers,schema:this.schema,body:n,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}upsert(n,{onConflict:o,ignoreDuplicates:a=!1,count:l,defaultToNull:u=!0}={}){var i;let c="POST";if(this.headers.append("Prefer",`resolution=${a?"ignore":"merge"}-duplicates`),o!==void 0&&this.url.searchParams.set("on_conflict",o),l&&this.headers.append("Prefer",`count=${l}`),u||this.headers.append("Prefer","missing=default"),Array.isArray(n)){let h=n.reduce((m,f)=>m.concat(Object.keys(f)),[]);if(h.length>0){let m=[...new Set(h)].map(f=>`"${f}"`);this.url.searchParams.set("columns",m.join(","))}}return new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:n,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}update(n,{count:o}={}){var a;let l="PATCH";return o&&this.headers.append("Prefer",`count=${o}`),new r.default({method:l,url:this.url,headers:this.headers,schema:this.schema,body:n,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}delete({count:n}={}){var o;let a="DELETE";return n&&this.headers.append("Prefer",`count=${n}`),new r.default({method:a,url:this.url,headers:this.headers,schema:this.schema,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}};e.default=s}),Yt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(B)),r=t.__importDefault(dt()),s=t.__importDefault(ve()),n=class mt{constructor(a,{headers:l={},schema:u,fetch:i}={}){this.url=a,this.headers=new Headers(l),this.schemaName=u,this.fetch=i}from(a){let l=new URL(`${this.url}/${a}`);return new r.default(l,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(a){return new mt(this.url,{headers:this.headers,schema:a,fetch:this.fetch})}rpc(a,l={},{head:u=!1,get:i=!1,count:c}={}){var h;let m,f=new URL(`${this.url}/rpc/${a}`),y;u||i?(m=u?"HEAD":"GET",Object.entries(l).filter(([g,w])=>w!==void 0).map(([g,w])=>[g,Array.isArray(w)?`{${w.join(",")}}`:`${w}`]).forEach(([g,w])=>{f.searchParams.append(g,w)})):(m="POST",y=l);let v=new Headers(this.headers);return c&&v.set("Prefer",`count=${c}`),new s.default({method:m,url:f,headers:v,schema:this.schemaName,body:y,fetch:(h=this.fetch)!==null&&h!==void 0?h:fetch})}};e.default=n}),Jt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0}),e.PostgrestError=e.PostgrestBuilder=e.PostgrestTransformBuilder=e.PostgrestFilterBuilder=e.PostgrestQueryBuilder=e.PostgrestClient=void 0;var t=(G(),q(B)),r=t.__importDefault(Yt());e.PostgrestClient=r.default;var s=t.__importDefault(dt());e.PostgrestQueryBuilder=s.default;var n=t.__importDefault(ve());e.PostgrestFilterBuilder=n.default;var o=t.__importDefault(pt());e.PostgrestTransformBuilder=o.default;var a=t.__importDefault(ft());e.PostgrestBuilder=a.default;var l=t.__importDefault(ht());e.PostgrestError=l.default,e.default={PostgrestClient:r.default,PostgrestQueryBuilder:s.default,PostgrestFilterBuilder:n.default,PostgrestTransformBuilder:o.default,PostgrestBuilder:a.default,PostgrestError:l.default}});p();p();p();p();p();p();var Xt=Object.defineProperty,Qt=Object.defineProperties,Zt=Object.getOwnPropertyDescriptors,Pe=Object.getOwnPropertySymbols,er=Object.prototype.hasOwnProperty,tr=Object.prototype.propertyIsEnumerable,Se=(e,t,r)=>t in e?Xt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,j=(e,t)=>{for(var r in t||(t={}))er.call(t,r)&&Se(e,r,t[r]);if(Pe)for(var r of Pe(t))tr.call(t,r)&&Se(e,r,t[r]);return e},I=(e,t)=>Qt(e,Zt(t)),rr=class extends Error{constructor(e,t,r){super(t||e.toString(),{cause:r}),this.status=e,this.statusText=t,this.error=r}},sr=async(e,t)=>{var r,s,n,o,a,l;let u=t||{},i={onRequest:[t?.onRequest],onResponse:[t?.onResponse],onSuccess:[t?.onSuccess],onError:[t?.onError],onRetry:[t?.onRetry]};if(!t||!t?.plugins)return{url:e,options:u,hooks:i};for(let c of t?.plugins||[]){if(c.init){let h=await((r=c.init)==null?void 0:r.call(c,e.toString(),t));u=h.options||u,e=h.url}i.onRequest.push((s=c.hooks)==null?void 0:s.onRequest),i.onResponse.push((n=c.hooks)==null?void 0:n.onResponse),i.onSuccess.push((o=c.hooks)==null?void 0:o.onSuccess),i.onError.push((a=c.hooks)==null?void 0:a.onError),i.onRetry.push((l=c.hooks)==null?void 0:l.onRetry)}return{url:e,options:u,hooks:i}},Re=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(){return this.options.delay}},nr=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(e){return Math.min(this.options.maxDelay,this.options.baseDelay*2**e)}};function or(e){if(typeof e=="number")return new Re({type:"linear",attempts:e,delay:1e3});switch(e.type){case"linear":return new Re(e);case"exponential":return new nr(e);default:throw new Error("Invalid retry strategy")}}var ar=async e=>{let t={},r=async s=>typeof s=="function"?await s():s;if(e?.auth){if(e.auth.type==="Bearer"){let s=await r(e.auth.token);if(!s)return t;t.authorization=`Bearer ${s}`}else if(e.auth.type==="Basic"){let s=r(e.auth.username),n=r(e.auth.password);if(!s||!n)return t;t.authorization=`Basic ${btoa(`${s}:${n}`)}`}else if(e.auth.type==="Custom"){let s=r(e.auth.value);if(!s)return t;t.authorization=`${r(e.auth.prefix)} ${s}`}}return t},ir=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function lr(e){let t=e.headers.get("content-type"),r=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!t)return"json";let s=t.split(";").shift()||"";return ir.test(s)?"json":r.has(s)||s.startsWith("text/")?"text":"blob"}function ur(e){try{return JSON.parse(e),!0}catch{return!1}}function yt(e){if(e===void 0)return!1;let t=typeof e;return t==="string"||t==="number"||t==="boolean"||t===null?!0:t!=="object"?!1:Array.isArray(e)?!0:e.buffer?!1:e.constructor&&e.constructor.name==="Object"||typeof e.toJSON=="function"}function Ae(e){try{return JSON.parse(e)}catch{return e}}function $e(e){return typeof e=="function"}function cr(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<"u"&&$e(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&$e(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function hr(e){let t=new Headers(e?.headers),r=await ar(e);for(let[s,n]of Object.entries(r||{}))t.set(s,n);if(!t.has("content-type")){let s=fr(e?.body);s&&t.set("content-type",s)}return t}function fr(e){return yt(e)?"application/json":null}function pr(e){if(!e?.body)return null;let t=new Headers(e?.headers);if(yt(e.body)&&!t.has("content-type")){for(let[r,s]of Object.entries(e?.body))s instanceof Date&&(e.body[r]=s.toISOString());return JSON.stringify(e.body)}return e.body}function dr(e,t){var r;if(t?.method)return t.method.toUpperCase();if(e.startsWith("@")){let s=(r=e.split("@")[1])==null?void 0:r.split("/")[0];return vt.includes(s)?s.toUpperCase():t?.body?"POST":"GET"}return t?.body?"POST":"GET"}function mr(e,t){let r;return!e?.signal&&e?.timeout&&(r=setTimeout(()=>t?.abort(),e?.timeout)),{abortTimeout:r,clearTimeout:()=>{r&&clearTimeout(r)}}}var yr=class gt extends Error{constructor(t,r){super(r||JSON.stringify(t,null,2)),this.issues=t,Object.setPrototypeOf(this,gt.prototype)}};async function te(e,t){let r=await e["~standard"].validate(t);if(r.issues)throw new yr(r.issues);return r.value}var vt=["get","post","put","patch","delete"],gr=e=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(t,r){var s,n,o,a;let l=((n=(s=e.plugins)==null?void 0:s.find(u=>{var i;return(i=u.schema)!=null&&i.config?t.startsWith(u.schema.config.baseURL||"")||t.startsWith(u.schema.config.prefix||""):!1}))==null?void 0:n.schema)||e.schema;if(l){let u=t;(o=l.config)!=null&&o.prefix&&u.startsWith(l.config.prefix)&&(u=u.replace(l.config.prefix,""),l.config.baseURL&&(t=t.replace(l.config.prefix,l.config.baseURL))),(a=l.config)!=null&&a.baseURL&&u.startsWith(l.config.baseURL)&&(u=u.replace(l.config.baseURL,""));let i=l.schema[u];if(i){let c=I(j({},r),{method:i.method,output:i.output});return r?.disableValidation||(c=I(j({},c),{body:i.input?await te(i.input,r?.body):r?.body,params:i.params?await te(i.params,r?.params):r?.params,query:i.query?await te(i.query,r?.query):r?.query})),{url:t,options:c}}}return{url:t,options:r}}}),vr=e=>{async function t(r,s){let n=I(j(j({},e),s),{plugins:[...e?.plugins||[],gr(e||{})]});if(e?.catchAllError)try{return await fe(r,n)}catch(o){return{data:null,error:{status:500,statusText:"Fetch Error",message:"Fetch related error. Captured by catchAllError option. See error property for more details.",error:o}}}return await fe(r,n)}return t};function wr(e,t){let{baseURL:r,params:s,query:n}=t||{query:{},params:{},baseURL:""},o=e.startsWith("http")?e.split("/").slice(0,3).join("/"):r||"";if(e.startsWith("@")){let c=e.toString().split("@")[1].split("/")[0];vt.includes(c)&&(e=e.replace(`@${c}/`,"/"))}o.endsWith("/")||(o+="/");let[a,l]=e.replace(o,"").split("?"),u=new URLSearchParams(l);for(let[c,h]of Object.entries(n||{}))h!=null&&u.set(c,String(h));if(s)if(Array.isArray(s)){let c=a.split("/").filter(h=>h.startsWith(":"));for(let[h,m]of c.entries()){let f=s[h];a=a.replace(m,f)}}else for(let[c,h]of Object.entries(s))a=a.replace(`:${c}`,String(h));a=a.split("/").map(encodeURIComponent).join("/"),a.startsWith("/")&&(a=a.slice(1));let i=u.toString();return i=i.length>0?`?${i}`.replace(/\+/g,"%20"):"",o.startsWith("http")?new URL(`${a}${i}`,o):`${o}${a}${i}`}var fe=async(e,t)=>{var r,s,n,o,a,l,u,i;let{hooks:c,url:h,options:m}=await sr(e,t),f=cr(m),y=new AbortController,v=(r=m.signal)!=null?r:y.signal,g=wr(h,m),w=pr(m),T=await hr(m),P=dr(h,m),d=I(j({},m),{url:g,headers:T,body:w,method:P,signal:v});for(let S of c.onRequest)if(S){let E=await S(d);E instanceof Object&&(d=E)}("pipeTo"in d&&typeof d.pipeTo=="function"||typeof((s=t?.body)==null?void 0:s.pipe)=="function")&&("duplex"in d||(d.duplex="half"));let{clearTimeout:L}=mr(m,y),_=await f(d.url,d);L();let Oe={response:_,request:d};for(let S of c.onResponse)if(S){let E=await S(I(j({},Oe),{response:(n=t?.hookOptions)!=null&&n.cloneResponse?_.clone():_}));E instanceof Response?_=E:E instanceof Object&&(_=E.response)}if(_.ok){if(d.method==="HEAD")return{data:"",error:null};let S=lr(_),E={data:"",response:_,request:d};if(S==="json"||S==="text"){let k=await _.text(),M=await((o=d.jsonParser)!=null?o:Ae)(k);E.data=M}else E.data=await _[S]();d?.output&&d.output&&!d.disableValidation&&(E.data=await te(d.output,E.data));for(let k of c.onSuccess)k&&await k(I(j({},E),{response:(a=t?.hookOptions)!=null&&a.cloneResponse?_.clone():_}));return t?.throw?E.data:{data:E.data,error:null}}let Ut=(l=t?.jsonParser)!=null?l:Ae,J=await _.text(),Te=ur(J),ie=Te?await Ut(J):null,Ct={response:_,responseText:J,request:d,error:I(j({},ie),{status:_.status,statusText:_.statusText})};for(let S of c.onError)S&&await S(I(j({},Ct),{response:(u=t?.hookOptions)!=null&&u.cloneResponse?_.clone():_}));if(t?.retry){let S=or(t.retry),E=(i=t.retryAttempt)!=null?i:0;if(await S.shouldAttemptRetry(E,_)){for(let M of c.onRetry)M&&await M(Oe);let k=S.getDelay(E);return await new Promise(M=>setTimeout(M,k)),await fe(e,I(j({},t),{retryAttempt:E+1}))}}if(t?.throw)throw new rr(_.status,_.statusText,Te?ie:J);return{data:null,error:I(j({},ie),{status:_.status,statusText:_.statusText})}};p();p();var re=Object.create(null),W=e=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?re:globalThis),A=new Proxy(re,{get(e,t){return W()[t]??re[t]},has(e,t){let r=W();return t in r||t in re},set(e,t,r){let s=W(!0);return s[t]=r,!0},deleteProperty(e,t){if(!t)return!1;let r=W(!0);return delete r[t],!0},ownKeys(){let e=W(!0);return Object.keys(e)}}),gs=typeof process<"u"&&process.env&&process.env.NODE_ENV||"";function b(e,t){return typeof process<"u"&&process.env?process.env[e]??t:typeof Deno<"u"?Deno.env.get(e)??t:typeof Bun<"u"?Bun.env[e]??t:t}var vs=Object.freeze({get BETTER_AUTH_SECRET(){return b("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return b("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return b("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return b("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return b("NODE_ENV","development")},get PACKAGE_VERSION(){return b("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return b("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),z=1,O=4,N=8,R=24,je={eterm:O,cons25:O,console:O,cygwin:O,dtterm:O,gnome:O,hurd:O,jfbterm:O,konsole:O,kterm:O,mlterm:O,mosh:R,putty:O,st:O,"rxvt-unicode-24bit":R,terminator:R,"xterm-kitty":R},br=new Map(Object.entries({APPVEYOR:N,BUILDKITE:N,CIRCLECI:R,DRONE:N,GITEA_ACTIONS:R,GITHUB_ACTIONS:R,GITLAB_CI:N,TRAVIS:N})),_r=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function Er(){if(b("FORCE_COLOR")!==void 0)switch(b("FORCE_COLOR")){case"":case"1":case"true":return O;case"2":return N;case"3":return R;default:return z}if(b("NODE_DISABLE_COLORS")!==void 0&&b("NODE_DISABLE_COLORS")!==""||b("NO_COLOR")!==void 0&&b("NO_COLOR")!==""||b("TERM")==="dumb")return z;if(b("TMUX"))return R;if("TF_BUILD"in A&&"AGENT_NAME"in A)return O;if("CI"in A){for(let{0:e,1:t}of br)if(e in A)return t;return b("CI_NAME")==="codeship"?N:z}if("TEAMCITY_VERSION"in A)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(b("TEAMCITY_VERSION"))!==null?O:z;switch(b("TERM_PROGRAM")){case"iTerm.app":return!b("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(b("TERM_PROGRAM_VERSION"))!==null?N:R;case"HyperTerm":case"MacTerm":return R;case"Apple_Terminal":return N}if(b("COLORTERM")==="truecolor"||b("COLORTERM")==="24bit")return R;if(b("TERM")){if(/truecolor/.exec(b("TERM"))!==null)return R;if(/^xterm-256/.exec(b("TERM"))!==null)return N;let e=b("TERM").toLowerCase();if(je[e])return je[e];if(_r.some(t=>t.exec(e)!==null))return O}return b("COLORTERM")?O:z}var x={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",undim:"\x1B[22m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",fg:{black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m"},bg:{black:"\x1B[40m",red:"\x1B[41m",green:"\x1B[42m",yellow:"\x1B[43m",blue:"\x1B[44m",magenta:"\x1B[45m",cyan:"\x1B[46m",white:"\x1B[47m"}},pe=["info","success","warn","error","debug"];function Or(e,t){return pe.indexOf(t)<=pe.indexOf(e)}var Tr={info:x.fg.blue,success:x.fg.green,warn:x.fg.yellow,error:x.fg.red,debug:x.fg.magenta},Pr=(e,t,r)=>{let s=new Date().toISOString();return r?`${x.dim}${s}${x.reset} ${Tr[e]}${e.toUpperCase()}${x.reset} ${x.bright}[Better Auth]:${x.reset} ${t}`:`${s} ${e.toUpperCase()} [Better Auth]: ${t}`},Sr=e=>{let t=e?.disabled!==!0,r=e?.level??"error",s=e?.disableColors!==void 0?!e.disableColors:Er()!==1,n=(o,a,l=[])=>{if(!t||!Or(r,o))return;let u=Pr(o,a,s);if(!e||typeof e.log!="function"){o==="error"?console.error(u,...l):o==="warn"?console.warn(u,...l):console.log(u,...l);return}e.log(o==="success"?"info":o,a,...l)};return{...Object.fromEntries(pe.map(o=>[o,(...[a,...l])=>n(o,a,l)])),get level(){return r}}},ws=Sr();p();p();var we=class extends Error{constructor(e,t){super(e),this.name="BetterAuthError",this.message=e,this.cause=t,this.stack=""}};function Rr(e){try{return(new URL(e).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new we(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function K(e,t="/api/auth"){if(Rr(e))return e;let r=e.replace(/\/+$/,"");return!t||t==="/"?r:(t=t.startsWith("/")?t:`/${t}`,`${r}${t}`)}function Ar(e,t,r,s){if(e)return K(e,t);if(s!==!1){let a=A.BETTER_AUTH_URL||A.NEXT_PUBLIC_BETTER_AUTH_URL||A.PUBLIC_BETTER_AUTH_URL||A.NUXT_PUBLIC_BETTER_AUTH_URL||A.NUXT_PUBLIC_AUTH_URL||(A.BASE_URL!=="/"?A.BASE_URL:void 0);if(a)return K(a,t)}let n=r?.headers.get("x-forwarded-host"),o=r?.headers.get("x-forwarded-proto");if(n&&o)return K(`${o}://${n}`,t);if(r){let a=$r(r.url);if(!a)throw new we("Could not get origin from request. Please provide a valid base URL.");return K(a,t)}if(typeof window<"u"&&window.location)return K(window.location.origin,t)}function $r(e){try{return new URL(e).origin}catch{return null}}p();p();p();var de=Symbol("clean"),$=[],U=0,X=4,jr=0,wt=e=>{let t=[],r={get(){return r.lc||r.listen(()=>{})(),r.value},lc:0,listen(s){return r.lc=t.push(s),()=>{for(let o=U+X;o<$.length;)$[o]===s?$.splice(o,X):o+=X;let n=t.indexOf(s);~n&&(t.splice(n,1),--r.lc||r.off())}},notify(s,n){jr++;let o=!$.length;for(let a of t)$.push(a,r.value,s,n);if(o){for(U=0;U<$.length;U+=X)$[U]($[U+1],$[U+2],$[U+3]);$.length=0}},off(){},set(s){let n=r.value;n!==s&&(r.value=s,r.notify(n))},subscribe(s){let n=r.listen(s);return s(r.value),n},value:e};return process.env.NODE_ENV!=="production"&&(r[de]=()=>{t=[],r.lc=0,r.off()}),r};p();var Ir=5,F=6,Q=10,Nr=(e,t,r,s)=>(e.events=e.events||{},e.events[r+Q]||(e.events[r+Q]=s(n=>{e.events[r].reduceRight((o,a)=>(a(o),o),{shared:{},...n})})),e.events[r]=e.events[r]||[],e.events[r].push(t),()=>{let n=e.events[r],o=n.indexOf(t);n.splice(o,1),n.length||(delete e.events[r],e.events[r+Q](),delete e.events[r+Q])}),xr=1e3,Ur=(e,t)=>Nr(e,r=>{let s=t(r);s&&e.events[F].push(s)},Ir,r=>{let s=e.listen;e.listen=(...o)=>(!e.lc&&!e.active&&(e.active=!0,r()),s(...o));let n=e.off;if(e.events[F]=[],e.off=()=>{n(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let o of e.events[F])o();e.events[F]=[]}},xr)},process.env.NODE_ENV!=="production"){let o=e[de];e[de]=()=>{for(let a of e.events[F])a();e.events[F]=[],e.active=!1,o()}}return()=>{e.listen=s,e.off=n}});p();var Cr=typeof window>"u",Lr=(e,t,r,s)=>{let n=wt({data:null,error:null,isPending:!0,isRefetching:!1,refetch:l=>o(l)}),o=l=>{let u=typeof s=="function"?s({data:n.get().data,error:n.get().error,isPending:n.get().isPending}):s;r(t,{...u,query:{...u?.query,...l?.query},async onSuccess(i){n.set({data:i.data,error:null,isPending:!1,isRefetching:!1,refetch:n.value.refetch}),await u?.onSuccess?.(i)},async onError(i){let{request:c}=i,h=typeof c.retry=="number"?c.retry:c.retry?.attempts,m=c.retryAttempt||0;h&&m<h||(n.set({error:i.error,data:null,isPending:!1,isRefetching:!1,refetch:n.value.refetch}),await u?.onError?.(i))},async onRequest(i){let c=n.get();n.set({isPending:c.data===null,data:c.data,error:null,isRefetching:!0,refetch:n.value.refetch}),await u?.onRequest?.(i)}}).catch(i=>{n.set({error:i,data:null,isPending:!1,isRefetching:!1,refetch:n.value.refetch})})};e=Array.isArray(e)?e:[e];let a=!1;for(let l of e)l.subscribe(()=>{Cr||(a?o():Ur(n,()=>{let u=setTimeout(()=>{a||(o(),a=!0)},0);return()=>{n.off(),l.off(),clearTimeout(u)}}))});return n};p();var Dr={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},Br=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,Ie={true:!0,false:!1,null:null,undefined:void 0,nan:Number.NaN,infinity:Number.POSITIVE_INFINITY,"-infinity":Number.NEGATIVE_INFINITY},kr=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function Mr(e){return e instanceof Date&&!isNaN(e.getTime())}function Fr(e){let t=kr.exec(e);if(!t)return null;let[,r,s,n,o,a,l,u,i,c,h]=t,m=new Date(Date.UTC(parseInt(r,10),parseInt(s,10)-1,parseInt(n,10),parseInt(o,10),parseInt(a,10),parseInt(l,10),u?parseInt(u.padEnd(3,"0"),10):0));if(i){let f=(parseInt(c,10)*60+parseInt(h,10))*(i==="+"?-1:1);m.setUTCMinutes(m.getUTCMinutes()+f)}return Mr(m)?m:null}function Hr(e,t={}){let{strict:r=!1,warnings:s=!1,reviver:n,parseDates:o=!0}=t;if(typeof e!="string")return e;let a=e.trim();if(a.length>0&&a[0]==='"'&&a.endsWith('"')&&!a.slice(1,-1).includes('"'))return a.slice(1,-1);let l=a.toLowerCase();if(l.length<=9&&l in Ie)return Ie[l];if(!Br.test(a)){if(r)throw new SyntaxError("[better-json] Invalid JSON");return e}if(Object.entries(Dr).some(([u,i])=>{let c=i.test(a);return c&&s&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${u} pattern`),c})&&r)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(a,(u,i)=>{if(u==="__proto__"||u==="constructor"&&i&&typeof i=="object"&&"prototype"in i){s&&console.warn(`[better-json] Dropping "${u}" key to prevent prototype pollution`);return}if(o&&typeof i=="string"){let c=Fr(i);if(c)return c}return n?n(u,i):i})}catch(u){if(r)throw u;return e}}function qr(e,t={strict:!0}){return Hr(e,t)}var Gr={id:"redirect",name:"Redirect",hooks:{onSuccess(e){if(e.data?.url&&e.data?.redirect&&typeof window<"u"&&window.location&&window.location)try{window.location.href=e.data.url}catch{}}}};function Wr(e){let t=wt(!1);return{session:Lr(t,"/get-session",e,{method:"GET"}),$sessionSignal:t}}var zr=(e,t)=>{let r="credentials"in Request.prototype,s=Ar(e?.baseURL,e?.basePath,void 0,t)??"/api/auth",n=e?.plugins?.flatMap(d=>d.fetchPlugins).filter(d=>d!==void 0)||[],o={id:"lifecycle-hooks",name:"lifecycle-hooks",hooks:{onSuccess:e?.fetchOptions?.onSuccess,onError:e?.fetchOptions?.onError,onRequest:e?.fetchOptions?.onRequest,onResponse:e?.fetchOptions?.onResponse}},{onSuccess:a,onError:l,onRequest:u,onResponse:i,...c}=e?.fetchOptions||{},h=vr({baseURL:s,...r?{credentials:"include"}:{},method:"GET",jsonParser(d){return d?qr(d,{strict:!1}):null},customFetchImpl:fetch,...c,plugins:[o,...c.plugins||[],...e?.disableDefaultFetchPlugins?[]:[Gr],...n]}),{$sessionSignal:m,session:f}=Wr(h),y=e?.plugins||[],v={},g={$sessionSignal:m,session:f},w={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},T=[{signal:"$sessionSignal",matcher(d){return d==="/sign-out"||d==="/update-user"||d.startsWith("/sign-in")||d.startsWith("/sign-up")||d==="/delete-user"||d==="/verify-email"}}];for(let d of y)d.getAtoms&&Object.assign(g,d.getAtoms?.(h)),d.pathMethods&&Object.assign(w,d.pathMethods),d.atomListeners&&T.push(...d.atomListeners);let P={notify:d=>{g[d].set(!g[d].get())},listen:(d,L)=>{g[d].subscribe(L)},atoms:g};for(let d of y)d.getActions&&Object.assign(v,d.getActions?.(h,P,e));return{get baseURL(){return s},pluginsActions:v,pluginsAtoms:g,pluginPathMethods:w,atomListeners:T,$fetch:h,$store:P}};function Kr(e){return typeof e=="object"&&e!==null&&"get"in e&&typeof e.get=="function"&&"lc"in e&&typeof e.lc=="number"}function Vr(e,t,r){let s=t[e],{fetchOptions:n,query:o,...a}=r||{};return s||(n?.method?n.method:a&&Object.keys(a).length>0?"POST":"GET")}function Yr(e,t,r,s,n){function o(a=[]){return new Proxy(function(){},{get(l,u){if(typeof u!="string"||u==="then"||u==="catch"||u==="finally")return;let i=[...a,u],c=e;for(let h of i)if(c&&typeof c=="object"&&h in c)c=c[h];else{c=void 0;break}return typeof c=="function"||Kr(c)?c:o(i)},apply:async(l,u,i)=>{let c="/"+a.map(T=>T.replace(/[A-Z]/g,P=>`-${P.toLowerCase()}`)).join("/"),h=i[0]||{},m=i[1]||{},{query:f,fetchOptions:y,...v}=h,g={...m,...y},w=Vr(c,r,h);return await t(c,{...g,body:w==="GET"?void 0:{...v,...g?.body||{}},query:f||g?.query,method:w,async onSuccess(T){if(await g?.onSuccess?.(T),!n)return;let P=n.filter(d=>d.matcher(c));if(P.length)for(let d of P){let L=s[d.signal];if(!L)return;let _=L.get();setTimeout(()=>{L.set(!_)},10)}}})}})}return o()}p();function Jr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Xr(e){let{pluginPathMethods:t,pluginsActions:r,pluginsAtoms:s,$fetch:n,atomListeners:o,$store:a}=zr(e),l={};for(let[i,c]of Object.entries(s))l[`use${Jr(i)}`]=c;let u={...r,...l,$fetch:n,$store:a};return Yr(u,n,t,s,o)}p();p();p();function Qr(e){return{authorize(t,r="AND"){let s=!1;for(let[n,o]of Object.entries(t)){let a=e[n];if(!a)return{success:!1,error:`You are not allowed to access resource: ${n}`};if(Array.isArray(o))s=o.every(l=>a.includes(l));else if(typeof o=="object"){let l=o;l.connector==="OR"?s=l.actions.some(u=>a.includes(u)):s=l.actions.every(u=>a.includes(u))}else throw new we("Invalid access control request");if(s&&r==="OR")return{success:s};if(!s&&r==="AND")return{success:!1,error:`unauthorized to access resource "${n}"`}}return s?{success:s}:{success:!1,error:"Not authorized"}},statements:e}}function bt(e){return{newRole(t){return Qr(t)},statements:e}}var Zr={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},be=bt(Zr),bs=be.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),_s=be.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),Es=be.newRole({organization:[],member:[],invitation:[],team:[],ac:["read"]});p();p();p();p();p();p();p();p();p();p();p();var es=class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let t=new Error("Cancelling existing WebAuthn API call for new one");t.name="AbortError",this.controller.abort(t)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}},Os=new es;p();p();p();p();p();p();p();p();var ts={user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]},_t=bt(ts),Ts=_t.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),Ps=_t.newRole({user:[],session:[]});p();p();var rs=()=>({id:"username",$InferServerPlugin:{}}),ss=()=>({id:"phoneNumber",$InferServerPlugin:{},atomListeners:[{matcher(e){return e==="/phone-number/update"||e==="/phone-number/verify"},signal:"$sessionSignal"}]}),ns=()=>({id:"better-auth-client",$InferServerPlugin:{}}),os="/auth",ue="nvwa_login_token",ce="nvwa_current_jwt",he="nvwa_user_profile",Et=class{constructor(e,t,r){this.storage=r;let s=Xr({baseURL:e,basePath:os,plugins:[rs(),ss(),ns()],fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:async()=>{let n=await this.storage.get(ce);if(console.log("jwt",n),n)return n;let o=await this.storage.get(ue);return console.log("loginToken",o),o}}}});this.authClient=s}async currentUser(){return await this.storage.get(he)}async getCurrentJwt(){return await this.storage.get(ce)}async signUp(e){let t=await this.authClient.signUp.email({email:e.email??`${e.username}@nvwa.app`,name:e.name,username:e.username,displayUsername:e.displayUsername,password:e.password});this.handleLogin(t)}async sendPhoneNumberCode(e){await this.authClient.phoneNumber.sendOtp({phoneNumber:e})}async signInWithPhoneNumberCode(e,t){let r=await this.authClient.phoneNumber.verify({phoneNumber:e,code:t});this.handleLogin(r)}async signInWithPhoneNumber(e,t,r=!1){let s=await this.authClient.signIn.phoneNumber({phoneNumber:e,password:t,rememberMe:r});this.handleLogin(s)}async signInWithUsername(e,t){let r=await this.authClient.signIn.username({username:e,password:t});this.handleLogin(r)}async handleLogin(e){if(e.error)throw new Error(e.error.message);await this.storage.set(ue,e.data?.token),await this.storage.set(he,e.data?.user);let{data:t,error:r}=await this.authClient.token();if(r)throw new Error(r.message);await this.storage.set(ce,t.token)}async signOut(){await this.storage.remove(ue),await this.storage.remove(he)}async updateUserPassword(e,t,r=!1){let s=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:r});this.handleLogin(s)}};p();var Ot=class{constructor(e){this.http=e}async invoke(e,t){return await(await this.http.fetch("/functions/"+e,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};p();var Tt=class{constructor(e,t){this.customFetch=e,this.handleUnauthorized=t}async fetch(e,t){return await this.customFetch(e,t)}async fetchWithAuth(e,t){let r=await this.customFetch(e,t);if(r.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return r}};p();p();p();var C=class Pt{constructor(t){if(this.headerMap=new Map,t){if(t instanceof Pt)t.forEach((r,s)=>this.set(s,r));else if(Array.isArray(t))for(let[r,s]of t)this.set(r,String(s));else if(typeof t=="object")for(let r of Object.keys(t))this.set(r,String(t[r]))}}append(t,r){let s=t.toLowerCase(),n=this.headerMap.get(s);this.headerMap.set(s,n?`${n}, ${r}`:r)}set(t,r){this.headerMap.set(t.toLowerCase(),String(r))}get(t){return this.headerMap.get(t.toLowerCase())??null}has(t){return this.headerMap.has(t.toLowerCase())}delete(t){this.headerMap.delete(t.toLowerCase())}forEach(t){for(let[r,s]of this.headerMap.entries())t(s,r,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},St=class Rt{constructor(t){if(this.params=new Map,t){if(typeof t=="string")this.parseString(t);else if(t instanceof Rt)this.params=new Map(t.params);else if(Array.isArray(t))for(let[r,s]of t)this.append(r,s);else if(t&&typeof t=="object")for(let[r,s]of Object.entries(t))this.set(r,s)}}parseString(t){t.startsWith("?")&&(t=t.slice(1));let r=t.split("&");for(let s of r)if(s){let[n,o]=s.split("=");n&&this.append(decodeURIComponent(n),o?decodeURIComponent(o):"")}}append(t,r){let s=this.params.get(t)||[];s.push(r),this.params.set(t,s)}delete(t){this.params.delete(t)}get(t){let r=this.params.get(t);return r?r[0]:null}getAll(t){return this.params.get(t)||[]}has(t){return this.params.has(t)}set(t,r){this.params.set(t,[r])}sort(){let t=Array.from(this.params.entries()).sort(([r],[s])=>r.localeCompare(s));this.params=new Map(t)}toString(){let t=[];for(let[r,s]of this.params.entries())for(let n of s)t.push(`${encodeURIComponent(r)}=${encodeURIComponent(n)}`);return t.join("&")}forEach(t){for(let[r,s]of this.params.entries())for(let n of s)t(n,r,this)}keys(){return this.params.keys()}values(){let t=[];for(let r of this.params.values())t.push(...r);return t[Symbol.iterator]()}entries(){let t=[];for(let[r,s]of this.params.entries())for(let n of s)t.push([r,n]);return t[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},as=class me{constructor(t,r){let s;if(t instanceof me)s=t.href;else if(r){let o=r instanceof me?r.href:r;s=this.resolve(o,t)}else s=t;let n=this.parseUrl(s);this.href=s,this.origin=`${n.protocol}//${n.host}`,this.protocol=n.protocol,this.username=n.username,this.password=n.password,this.host=n.host,this.hostname=n.hostname,this.port=n.port,this.pathname=n.pathname,this.search=n.search,this.searchParams=new St(n.search),this.hash=n.hash}resolve(t,r){if(r.startsWith("http://")||r.startsWith("https://"))return r;if(r.startsWith("//"))return`${this.parseUrl(t).protocol}${r}`;if(r.startsWith("/")){let o=this.parseUrl(t);return`${o.protocol}//${o.host}${r}`}let s=this.parseUrl(t),n=s.pathname.endsWith("/")?s.pathname:s.pathname+"/";return`${s.protocol}//${s.host}${n}${r}`}parseUrl(t){let r=t.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!r)throw new TypeError("Invalid URL");let s=r[2]||"",n=r[4]||"",o=r[5]||"/",a=r[7]?`?${r[7]}`:"",l=r[9]?`#${r[9]}`:"";if(!s&&!n&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let u=n.match(/^([^@]*)@(.+)$/),i="",c="",h=n;if(u){let v=u[1];h=u[2];let g=v.match(/^([^:]*):?(.*)$/);g&&(i=g[1]||"",c=g[2]||"")}let m=h.match(/^([^:]+):?(\d*)$/),f=m?m[1]:h,y=m&&m[2]?m[2]:"";return{protocol:s?`${s}:`:"",username:i,password:c,host:h,hostname:f,port:y,pathname:o,search:a,hash:l}}toString(){let t=this.searchParams.toString(),r=t?`?${t}`:"";return`${this.protocol}//${this.host}${this.pathname}${r}${this.hash}`}toJSON(){return this.toString()}};p();var is=class At{constructor(t,r){if(typeof t=="string")this.url=t;else if(t?.url)this.url=String(t.url);else if(typeof t?.toString=="function")this.url=String(t.toString());else throw new Error("Invalid input for Request");this.method=(r?.method||"GET").toUpperCase(),this.headers=r?.headers instanceof C?r.headers:new C(r?.headers),this.body=r?.body,this.timeout=r?.timeout,this.signal=r?.signal||void 0}clone(){return new At(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};p();var _e=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=ls(t?.headers),this.ok=this.status>=200&&this.status<300}async text(){return typeof this.bodyData=="string"?this.bodyData:this.bodyData==null?"":typeof this.bodyData=="object"?JSON.stringify(this.bodyData):String(this.bodyData)}async json(){if(typeof this.bodyData=="string")try{return JSON.parse(this.bodyData)}catch{}return this.bodyData}async arrayBuffer(){let e=await this.text();return new TextEncoder().encode(e).buffer}};function ls(e){return e?new C(e):new C}p();var $t=class{constructor(){this._aborted=!1,this.listeners=new Set,this.onabort=null}get aborted(){return this._aborted}_trigger(){if(!this._aborted){if(this._aborted=!0,typeof this.onabort=="function")try{this.onabort()}catch{}for(let e of Array.from(this.listeners))try{e()}catch{}this.listeners.clear()}}addEventListener(e,t){if(this._aborted){try{t()}catch{}return}this.listeners.add(t)}removeEventListener(e,t){this.listeners.delete(t)}toString(){return"[object AbortSignal]"}},us=class{constructor(){this._signal=new $t}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};p();function jt(e){e.URL=as,e.URLSearchParams=St,e.Headers=C,e.Request=is,e.Response=_e,e.AbortController=us,e.AbortSignal=$t}var cs="/storage",hs=cs+"/generateUploadUrl",It=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+hs,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:r}=await t.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(r,{method:"PUT",body:e,headers:new C({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:n}=await s.json();return{url:n.split("?")[0]}}};p();p();p();var Ne=Vt(Jt(),1),{PostgrestClient:fs,PostgrestQueryBuilder:Ss,PostgrestFilterBuilder:Rs,PostgrestTransformBuilder:As,PostgrestBuilder:$s,PostgrestError:js}=Ne.default||Ne,ps="/entities",Nt=(e,t)=>new fs(e+ps,{fetch:t.fetchWithAuth});var oe=class{constructor(){this.prefix="nvwa_"}getKey(t){return`${this.prefix}${t}`}async get(t){try{let r=this.getKey(t),s=uni.getStorageSync(r);return s?s.expires&&Date.now()>s.expires?(await this.remove(t),null):s.value:null}catch(r){return console.error("UniAppStorageService get error:",r),null}}async set(t,r,s){try{let n=this.getKey(t),o={value:r,expires:s?Date.now()+s*1e3:null,timestamp:Date.now()};uni.setStorageSync(n,o)}catch(n){throw console.error("UniAppStorageService set error:",n),n}}async remove(t){try{let r=this.getKey(t);uni.removeStorageSync(r)}catch(r){throw console.error("UniAppStorageService remove error:",r),r}}async clear(){try{uni.clearStorageSync()}catch(t){throw console.error("UniAppStorageService clear error:",t),t}}};var ds=(e,t)=>{let r;if(typeof e=="string")r=e;else if(e&&typeof e.toString=="function")r=e.toString();else if(e?.url)r=e.url;else throw new Error("Invalid input for uniappFetch");let s=(t?.method||"GET").toUpperCase(),n={};if(t?.headers){let l=t.headers;if(typeof l?.forEach=="function")l.forEach((u,i)=>{n[i]=u});else if(Array.isArray(l))for(let[u,i]of l)n[u]=i;else Object.assign(n,l)}let o;if(t?.body!==void 0){let l=t.body;if(typeof l=="string")o=l;else if(l&&typeof l=="object"&&typeof l.forEach=="function"){let u={};l.forEach((i,c)=>{u[c]=i}),o=u}else o=l}let a=t?.timeout||3e4;return new Promise((l,u)=>{let i=t?.signal;if(i?.aborted){let f=new Error("The operation was aborted");f.name="AbortError",u(f);return}let c=!1,h=[],m=uni.request({url:r,method:s,data:o,header:n,timeout:a,success:f=>{if(c)return;c=!0;let y=f.statusCode,v="",g=new C,w=f.header||f.headers||{};Object.keys(w).forEach(T=>{let P=w[T];g.set(T,typeof P=="string"?P:String(P))}),l(new _e(f.data,{status:y,statusText:v,headers:g}))},fail:f=>{if(c)return;c=!0;let y=f?.errMsg||f?.message||"Network Error",v=new Error(y);/(abort|aborted|canceled|cancelled)/i.test(String(y))&&(v.name="AbortError"),u(v)}});if(i&&typeof i.addEventListener=="function"){let f=()=>{if(c)return;try{m?.abort?.()}catch{}let y=new Error("The operation was aborted");y.name="AbortError",c=!0,u(y)};i.addEventListener("abort",f),h.push(()=>{try{i.removeEventListener?.("abort",f)}catch{}})}})},Ee=ds;var xt=new oe,ae=class{constructor(t,r){this.auth=new Et(t,Ee,xt),this.httpClient=new Tt(Ee,r),this.fileStorage=new It(t,this.httpClient),this.entities=Nt(t,this.httpClient),this.functions=new Ot(this.httpClient)}};0&&(module.exports={localStorage,polyfill});
1
+ "use strict";var ue=Object.defineProperty;var Lt=Object.getOwnPropertyDescriptor;var Dt=Object.getOwnPropertyNames;var Bt=Object.prototype.hasOwnProperty;var kt=(e,t)=>{for(var r in t)ue(e,r,{get:t[r],enumerable:!0})},Mt=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Dt(t))!Bt.call(e,n)&&n!==r&&ue(e,n,{get:()=>t[n],enumerable:!(s=Lt(t,n))||s.enumerable});return e};var Ft=e=>Mt(ue({},"__esModule",{value:!0}),e);var ms={};kt(ms,{default:()=>ie,localStorage:()=>Te,polyfill:()=>jt});module.exports=Ft(ms);var Ht=Object.create,oe=Object.defineProperty,qt=Object.getOwnPropertyDescriptor,Gt=Object.getOwnPropertyNames,Wt=Object.getPrototypeOf,zt=Object.prototype.hasOwnProperty,Ue=(e,t)=>()=>(e&&(t=e(e=0)),t),D=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Kt=(e,t)=>{for(var r in t)oe(e,r,{get:t[r],enumerable:!0})},Ce=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Gt(t))!zt.call(e,n)&&n!==r&&oe(e,n,{get:()=>t[n],enumerable:!(s=qt(t,n))||s.enumerable});return e},Vt=(e,t,r)=>(r=e!=null?Ht(Wt(e)):{},Ce(t||!e||!e.__esModule?oe(r,"default",{value:e,enumerable:!0}):r,e)),q=e=>Ce(oe({},"__esModule",{value:!0}),e),p=Ue(()=>{"use strict"}),B={};Kt(B,{__addDisposableResource:()=>at,__assign:()=>V,__asyncDelegator:()=>Qe,__asyncGenerator:()=>Xe,__asyncValues:()=>Ze,__await:()=>H,__awaiter:()=>We,__classPrivateFieldGet:()=>st,__classPrivateFieldIn:()=>ot,__classPrivateFieldSet:()=>nt,__createBinding:()=>Y,__decorate:()=>Be,__disposeResources:()=>it,__esDecorate:()=>Me,__exportStar:()=>Ke,__extends:()=>Le,__generator:()=>ze,__importDefault:()=>rt,__importStar:()=>tt,__makeTemplateObject:()=>et,__metadata:()=>Ge,__param:()=>ke,__propKey:()=>He,__read:()=>ge,__rest:()=>De,__rewriteRelativeImportExtension:()=>lt,__runInitializers:()=>Fe,__setFunctionName:()=>qe,__spread:()=>Ve,__spreadArray:()=>Je,__spreadArrays:()=>Ye,__values:()=>ne,default:()=>ht});function Le(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Z(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function De(e,t){var r={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(e);n<s.length;n++)t.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(e,s[n])&&(r[s[n]]=e[s[n]]);return r}function Be(e,t,r,s){var n=arguments.length,o=n<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,r):s,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(e,t,r,s);else for(var l=e.length-1;l>=0;l--)(a=e[l])&&(o=(n<3?a(o):n>3?a(t,r,o):a(t,r))||o);return n>3&&o&&Object.defineProperty(t,r,o),o}function ke(e,t){return function(r,s){t(r,s,e)}}function Me(e,t,r,s,n,o){function a(w){if(w!==void 0&&typeof w!="function")throw new TypeError("Function expected");return w}for(var l=s.kind,u=l==="getter"?"get":l==="setter"?"set":"value",i=!t&&e?s.static?e:e.prototype:null,c=t||(i?Object.getOwnPropertyDescriptor(i,s.name):{}),h,m=!1,f=r.length-1;f>=0;f--){var y={};for(var v in s)y[v]=v==="access"?{}:s[v];for(var v in s.access)y.access[v]=s.access[v];y.addInitializer=function(w){if(m)throw new TypeError("Cannot add initializers after decoration has completed");o.push(a(w||null))};var g=(0,r[f])(l==="accessor"?{get:c.get,set:c.set}:c[u],y);if(l==="accessor"){if(g===void 0)continue;if(g===null||typeof g!="object")throw new TypeError("Object expected");(h=a(g.get))&&(c.get=h),(h=a(g.set))&&(c.set=h),(h=a(g.init))&&n.unshift(h)}else(h=a(g))&&(l==="field"?n.unshift(h):c[u]=h)}i&&Object.defineProperty(i,s.name,c),m=!0}function Fe(e,t,r){for(var s=arguments.length>2,n=0;n<t.length;n++)r=s?t[n].call(e,r):t[n].call(e);return s?r:void 0}function He(e){return typeof e=="symbol"?e:"".concat(e)}function qe(e,t,r){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function Ge(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function We(e,t,r,s){function n(o){return o instanceof r?o:new r(function(a){a(o)})}return new(r||(r=Promise))(function(o,a){function l(c){try{i(s.next(c))}catch(h){a(h)}}function u(c){try{i(s.throw(c))}catch(h){a(h)}}function i(c){c.done?o(c.value):n(c.value).then(l,u)}i((s=s.apply(e,t||[])).next())})}function ze(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},s,n,o,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(i){return function(c){return u([i,c])}}function u(i){if(s)throw new TypeError("Generator is already executing.");for(;a&&(a=0,i[0]&&(r=0)),r;)try{if(s=1,n&&(o=i[0]&2?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[i[0]&2,o.value]),i[0]){case 0:case 1:o=i;break;case 4:return r.label++,{value:i[1],done:!1};case 5:r.label++,n=i[1],i=[0];continue;case 7:i=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!o||i[1]>o[0]&&i[1]<o[3])){r.label=i[1];break}if(i[0]===6&&r.label<o[1]){r.label=o[1],o=i;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(i);break}o[2]&&r.ops.pop(),r.trys.pop();continue}i=t.call(e,r)}catch(c){i=[6,c],n=0}finally{s=o=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}function Ke(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Y(t,e,r)}function ne(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],s=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&s>=e.length&&(e=void 0),{value:e&&e[s++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function ge(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var s=r.call(e),n,o=[],a;try{for(;(t===void 0||t-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(l){a={error:l}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(a)throw a.error}}return o}function Ve(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(ge(arguments[t]));return e}function Ye(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var s=Array(e),n=0,t=0;t<r;t++)for(var o=arguments[t],a=0,l=o.length;a<l;a++,n++)s[n]=o[a];return s}function Je(e,t,r){if(r||arguments.length===2)for(var s=0,n=t.length,o;s<n;s++)(o||!(s in t))&&(o||(o=Array.prototype.slice.call(t,0,s)),o[s]=t[s]);return e.concat(o||Array.prototype.slice.call(t))}function H(e){return this instanceof H?(this.v=e,this):new H(e)}function Xe(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r.apply(e,t||[]),n,o=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),l("next"),l("throw"),l("return",a),n[Symbol.asyncIterator]=function(){return this},n;function a(f){return function(y){return Promise.resolve(y).then(f,h)}}function l(f,y){s[f]&&(n[f]=function(v){return new Promise(function(g,w){o.push([f,v,g,w])>1||u(f,v)})},y&&(n[f]=y(n[f])))}function u(f,y){try{i(s[f](y))}catch(v){m(o[0][3],v)}}function i(f){f.value instanceof H?Promise.resolve(f.value.v).then(c,h):m(o[0][2],f)}function c(f){u("next",f)}function h(f){u("throw",f)}function m(f,y){f(y),o.shift(),o.length&&u(o[0][0],o[0][1])}}function Qe(e){var t,r;return t={},s("next"),s("throw",function(n){throw n}),s("return"),t[Symbol.iterator]=function(){return this},t;function s(n,o){t[n]=e[n]?function(a){return(r=!r)?{value:H(e[n](a)),done:!1}:o?o(a):a}:o}}function Ze(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof ne=="function"?ne(e):e[Symbol.iterator](),r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r);function s(o){r[o]=e[o]&&function(a){return new Promise(function(l,u){a=e[o](a),n(l,u,a.done,a.value)})}}function n(o,a,l,u){Promise.resolve(u).then(function(i){o({value:i,done:l})},a)}}function et(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function tt(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=ee(e),s=0;s<r.length;s++)r[s]!=="default"&&Y(t,e,r[s]);return ut(t,e),t}function rt(e){return e&&e.__esModule?e:{default:e}}function st(e,t,r,s){if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?s:r==="a"?s.call(e):s?s.value:t.get(e)}function nt(e,t,r,s,n){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?n.call(e,r):n?n.value=r:t.set(e,r),r}function ot(e,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof e=="function"?t===e:e.has(t)}function at(e,t,r){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var s,n;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=t[Symbol.asyncDispose]}if(s===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=t[Symbol.dispose],r&&(n=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");n&&(s=function(){try{n.call(this)}catch(o){return Promise.reject(o)}}),e.stack.push({value:t,dispose:s,async:r})}else r&&e.stack.push({async:!0});return t}function it(e){function t(o){e.error=e.hasError?new ct(o,e.error,"An error was suppressed during disposal."):o,e.hasError=!0}var r,s=0;function n(){for(;r=e.stack.pop();)try{if(!r.async&&s===1)return s=0,e.stack.push(r),Promise.resolve().then(n);if(r.dispose){var o=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(o).then(n,function(a){return t(a),n()})}else s|=1}catch(a){t(a)}if(s===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return n()}function lt(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,s,n,o,a){return s?t?".jsx":".js":n&&(!o||!a)?r:n+o+"."+a.toLowerCase()+"js"}):e}var Z,V,Y,ut,ee,ct,ht,G=Ue(()=>{"use strict";p(),Z=function(e,t){return Z=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(r[n]=s[n])},Z(e,t)},V=function(){return V=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++){t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},V.apply(this,arguments)},Y=Object.create?(function(e,t,r,s){s===void 0&&(s=r);var n=Object.getOwnPropertyDescriptor(t,r);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,n)}):(function(e,t,r,s){s===void 0&&(s=r),e[s]=t[r]}),ut=Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t},ee=function(e){return ee=Object.getOwnPropertyNames||function(t){var r=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[r.length]=s);return r},ee(e)},ct=typeof SuppressedError=="function"?SuppressedError:function(e,t,r){var s=new Error(r);return s.name="SuppressedError",s.error=e,s.suppressed=t,s},ht={__extends:Le,__assign:V,__rest:De,__decorate:Be,__param:ke,__esDecorate:Me,__runInitializers:Fe,__propKey:He,__setFunctionName:qe,__metadata:Ge,__awaiter:We,__generator:ze,__createBinding:Y,__exportStar:Ke,__values:ne,__read:ge,__spread:Ve,__spreadArrays:Ye,__spreadArray:Je,__await:H,__asyncGenerator:Xe,__asyncDelegator:Qe,__asyncValues:Ze,__makeTemplateObject:et,__importStar:tt,__importDefault:rt,__classPrivateFieldGet:st,__classPrivateFieldSet:nt,__classPrivateFieldIn:ot,__addDisposableResource:at,__disposeResources:it,__rewriteRelativeImportExtension:lt}}),ft=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}};e.default=t}),pt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(B)),r=t.__importDefault(ft()),s=class{constructor(n){var o,a;this.shouldThrowOnError=!1,this.method=n.method,this.url=n.url,this.headers=new Headers(n.headers),this.schema=n.schema,this.body=n.body,this.shouldThrowOnError=(o=n.shouldThrowOnError)!==null&&o!==void 0?o:!1,this.signal=n.signal,this.isMaybeSingle=(a=n.isMaybeSingle)!==null&&a!==void 0?a:!1,n.fetch?this.fetch=n.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(n,o){return this.headers=new Headers(this.headers),this.headers.set(n,o),this}then(n,o){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let a=this.fetch,l=a(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async u=>{var i,c,h,m;let f=null,y=null,v=null,g=u.status,w=u.statusText;if(u.ok){if(this.method!=="HEAD"){let d=await u.text();d===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&!((i=this.headers.get("Accept"))===null||i===void 0)&&i.includes("application/vnd.pgrst.plan+text")?y=d:y=JSON.parse(d))}let O=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),P=(h=u.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");O&&P&&P.length>1&&(v=parseInt(P[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(y)&&(y.length>1?(f={code:"PGRST116",details:`Results contain ${y.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},y=null,v=null,g=406,w="Not Acceptable"):y.length===1?y=y[0]:y=null)}else{let O=await u.text();try{f=JSON.parse(O),Array.isArray(f)&&u.status===404&&(y=[],f=null,g=200,w="OK")}catch{u.status===404&&O===""?(g=204,w="No Content"):f={message:O}}if(f&&this.isMaybeSingle&&!((m=f?.details)===null||m===void 0)&&m.includes("0 rows")&&(f=null,g=200,w="OK"),f&&this.shouldThrowOnError)throw new r.default(f)}return{error:f,data:y,count:v,status:g,statusText:w}});return this.shouldThrowOnError||(l=l.catch(u=>{var i,c,h;return{error:{message:`${(i=u?.name)!==null&&i!==void 0?i:"FetchError"}: ${u?.message}`,details:`${(c=u?.stack)!==null&&c!==void 0?c:""}`,hint:"",code:`${(h=u?.code)!==null&&h!==void 0?h:""}`},data:null,count:null,status:0,statusText:""}})),l.then(n,o)}returns(){return this}overrideTypes(){return this}};e.default=s}),dt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(B)),r=t.__importDefault(pt()),s=class extends r.default{select(n){let o=!1,a=(n??"*").split("").map(l=>/\s/.test(l)&&!o?"":(l==='"'&&(o=!o),l)).join("");return this.url.searchParams.set("select",a),this.headers.append("Prefer","return=representation"),this}order(n,{ascending:o=!0,nullsFirst:a,foreignTable:l,referencedTable:u=l}={}){let i=u?`${u}.order`:"order",c=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${c?`${c},`:""}${n}.${o?"asc":"desc"}${a===void 0?"":a?".nullsfirst":".nullslast"}`),this}limit(n,{foreignTable:o,referencedTable:a=o}={}){let l=typeof a>"u"?"limit":`${a}.limit`;return this.url.searchParams.set(l,`${n}`),this}range(n,o,{foreignTable:a,referencedTable:l=a}={}){let u=typeof l>"u"?"offset":`${l}.offset`,i=typeof l>"u"?"limit":`${l}.limit`;return this.url.searchParams.set(u,`${n}`),this.url.searchParams.set(i,`${o-n+1}`),this}abortSignal(n){return this.signal=n,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:n=!1,verbose:o=!1,settings:a=!1,buffers:l=!1,wal:u=!1,format:i="text"}={}){var c;let h=[n?"analyze":null,o?"verbose":null,a?"settings":null,l?"buffers":null,u?"wal":null].filter(Boolean).join("|"),m=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${m}"; options=${h};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(n){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${n}`),this}};e.default=s}),ve=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(B)),r=t.__importDefault(dt()),s=new RegExp("[,()]"),n=class extends r.default{eq(o,a){return this.url.searchParams.append(o,`eq.${a}`),this}neq(o,a){return this.url.searchParams.append(o,`neq.${a}`),this}gt(o,a){return this.url.searchParams.append(o,`gt.${a}`),this}gte(o,a){return this.url.searchParams.append(o,`gte.${a}`),this}lt(o,a){return this.url.searchParams.append(o,`lt.${a}`),this}lte(o,a){return this.url.searchParams.append(o,`lte.${a}`),this}like(o,a){return this.url.searchParams.append(o,`like.${a}`),this}likeAllOf(o,a){return this.url.searchParams.append(o,`like(all).{${a.join(",")}}`),this}likeAnyOf(o,a){return this.url.searchParams.append(o,`like(any).{${a.join(",")}}`),this}ilike(o,a){return this.url.searchParams.append(o,`ilike.${a}`),this}ilikeAllOf(o,a){return this.url.searchParams.append(o,`ilike(all).{${a.join(",")}}`),this}ilikeAnyOf(o,a){return this.url.searchParams.append(o,`ilike(any).{${a.join(",")}}`),this}is(o,a){return this.url.searchParams.append(o,`is.${a}`),this}in(o,a){let l=Array.from(new Set(a)).map(u=>typeof u=="string"&&s.test(u)?`"${u}"`:`${u}`).join(",");return this.url.searchParams.append(o,`in.(${l})`),this}contains(o,a){return typeof a=="string"?this.url.searchParams.append(o,`cs.${a}`):Array.isArray(a)?this.url.searchParams.append(o,`cs.{${a.join(",")}}`):this.url.searchParams.append(o,`cs.${JSON.stringify(a)}`),this}containedBy(o,a){return typeof a=="string"?this.url.searchParams.append(o,`cd.${a}`):Array.isArray(a)?this.url.searchParams.append(o,`cd.{${a.join(",")}}`):this.url.searchParams.append(o,`cd.${JSON.stringify(a)}`),this}rangeGt(o,a){return this.url.searchParams.append(o,`sr.${a}`),this}rangeGte(o,a){return this.url.searchParams.append(o,`nxl.${a}`),this}rangeLt(o,a){return this.url.searchParams.append(o,`sl.${a}`),this}rangeLte(o,a){return this.url.searchParams.append(o,`nxr.${a}`),this}rangeAdjacent(o,a){return this.url.searchParams.append(o,`adj.${a}`),this}overlaps(o,a){return typeof a=="string"?this.url.searchParams.append(o,`ov.${a}`):this.url.searchParams.append(o,`ov.{${a.join(",")}}`),this}textSearch(o,a,{config:l,type:u}={}){let i="";u==="plain"?i="pl":u==="phrase"?i="ph":u==="websearch"&&(i="w");let c=l===void 0?"":`(${l})`;return this.url.searchParams.append(o,`${i}fts${c}.${a}`),this}match(o){return Object.entries(o).forEach(([a,l])=>{this.url.searchParams.append(a,`eq.${l}`)}),this}not(o,a,l){return this.url.searchParams.append(o,`not.${a}.${l}`),this}or(o,{foreignTable:a,referencedTable:l=a}={}){let u=l?`${l}.or`:"or";return this.url.searchParams.append(u,`(${o})`),this}filter(o,a,l){return this.url.searchParams.append(o,`${a}.${l}`),this}};e.default=n}),mt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(B)),r=t.__importDefault(ve()),s=class{constructor(n,{headers:o={},schema:a,fetch:l}){this.url=n,this.headers=new Headers(o),this.schema=a,this.fetch=l}select(n,o){let{head:a=!1,count:l}=o??{},u=a?"HEAD":"GET",i=!1,c=(n??"*").split("").map(h=>/\s/.test(h)&&!i?"":(h==='"'&&(i=!i),h)).join("");return this.url.searchParams.set("select",c),l&&this.headers.append("Prefer",`count=${l}`),new r.default({method:u,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(n,{count:o,defaultToNull:a=!0}={}){var l;let u="POST";if(o&&this.headers.append("Prefer",`count=${o}`),a||this.headers.append("Prefer","missing=default"),Array.isArray(n)){let i=n.reduce((c,h)=>c.concat(Object.keys(h)),[]);if(i.length>0){let c=[...new Set(i)].map(h=>`"${h}"`);this.url.searchParams.set("columns",c.join(","))}}return new r.default({method:u,url:this.url,headers:this.headers,schema:this.schema,body:n,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}upsert(n,{onConflict:o,ignoreDuplicates:a=!1,count:l,defaultToNull:u=!0}={}){var i;let c="POST";if(this.headers.append("Prefer",`resolution=${a?"ignore":"merge"}-duplicates`),o!==void 0&&this.url.searchParams.set("on_conflict",o),l&&this.headers.append("Prefer",`count=${l}`),u||this.headers.append("Prefer","missing=default"),Array.isArray(n)){let h=n.reduce((m,f)=>m.concat(Object.keys(f)),[]);if(h.length>0){let m=[...new Set(h)].map(f=>`"${f}"`);this.url.searchParams.set("columns",m.join(","))}}return new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:n,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}update(n,{count:o}={}){var a;let l="PATCH";return o&&this.headers.append("Prefer",`count=${o}`),new r.default({method:l,url:this.url,headers:this.headers,schema:this.schema,body:n,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}delete({count:n}={}){var o;let a="DELETE";return n&&this.headers.append("Prefer",`count=${n}`),new r.default({method:a,url:this.url,headers:this.headers,schema:this.schema,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}};e.default=s}),Yt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(B)),r=t.__importDefault(mt()),s=t.__importDefault(ve()),n=class yt{constructor(a,{headers:l={},schema:u,fetch:i}={}){this.url=a,this.headers=new Headers(l),this.schemaName=u,this.fetch=i}from(a){let l=new URL(`${this.url}/${a}`);return new r.default(l,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(a){return new yt(this.url,{headers:this.headers,schema:a,fetch:this.fetch})}rpc(a,l={},{head:u=!1,get:i=!1,count:c}={}){var h;let m,f=new URL(`${this.url}/rpc/${a}`),y;u||i?(m=u?"HEAD":"GET",Object.entries(l).filter(([g,w])=>w!==void 0).map(([g,w])=>[g,Array.isArray(w)?`{${w.join(",")}}`:`${w}`]).forEach(([g,w])=>{f.searchParams.append(g,w)})):(m="POST",y=l);let v=new Headers(this.headers);return c&&v.set("Prefer",`count=${c}`),new s.default({method:m,url:f,headers:v,schema:this.schemaName,body:y,fetch:(h=this.fetch)!==null&&h!==void 0?h:fetch})}};e.default=n}),Jt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0}),e.PostgrestError=e.PostgrestBuilder=e.PostgrestTransformBuilder=e.PostgrestFilterBuilder=e.PostgrestQueryBuilder=e.PostgrestClient=void 0;var t=(G(),q(B)),r=t.__importDefault(Yt());e.PostgrestClient=r.default;var s=t.__importDefault(mt());e.PostgrestQueryBuilder=s.default;var n=t.__importDefault(ve());e.PostgrestFilterBuilder=n.default;var o=t.__importDefault(dt());e.PostgrestTransformBuilder=o.default;var a=t.__importDefault(pt());e.PostgrestBuilder=a.default;var l=t.__importDefault(ft());e.PostgrestError=l.default,e.default={PostgrestClient:r.default,PostgrestQueryBuilder:s.default,PostgrestFilterBuilder:n.default,PostgrestTransformBuilder:o.default,PostgrestBuilder:a.default,PostgrestError:l.default}});p();p();p();p();p();p();var Xt=Object.defineProperty,Qt=Object.defineProperties,Zt=Object.getOwnPropertyDescriptors,Se=Object.getOwnPropertySymbols,er=Object.prototype.hasOwnProperty,tr=Object.prototype.propertyIsEnumerable,Re=(e,t,r)=>t in e?Xt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,j=(e,t)=>{for(var r in t||(t={}))er.call(t,r)&&Re(e,r,t[r]);if(Se)for(var r of Se(t))tr.call(t,r)&&Re(e,r,t[r]);return e},I=(e,t)=>Qt(e,Zt(t)),rr=class extends Error{constructor(e,t,r){super(t||e.toString(),{cause:r}),this.status=e,this.statusText=t,this.error=r}},sr=async(e,t)=>{var r,s,n,o,a,l;let u=t||{},i={onRequest:[t?.onRequest],onResponse:[t?.onResponse],onSuccess:[t?.onSuccess],onError:[t?.onError],onRetry:[t?.onRetry]};if(!t||!t?.plugins)return{url:e,options:u,hooks:i};for(let c of t?.plugins||[]){if(c.init){let h=await((r=c.init)==null?void 0:r.call(c,e.toString(),t));u=h.options||u,e=h.url}i.onRequest.push((s=c.hooks)==null?void 0:s.onRequest),i.onResponse.push((n=c.hooks)==null?void 0:n.onResponse),i.onSuccess.push((o=c.hooks)==null?void 0:o.onSuccess),i.onError.push((a=c.hooks)==null?void 0:a.onError),i.onRetry.push((l=c.hooks)==null?void 0:l.onRetry)}return{url:e,options:u,hooks:i}},Ae=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(){return this.options.delay}},nr=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(e){return Math.min(this.options.maxDelay,this.options.baseDelay*2**e)}};function or(e){if(typeof e=="number")return new Ae({type:"linear",attempts:e,delay:1e3});switch(e.type){case"linear":return new Ae(e);case"exponential":return new nr(e);default:throw new Error("Invalid retry strategy")}}var ar=async e=>{let t={},r=async s=>typeof s=="function"?await s():s;if(e?.auth){if(e.auth.type==="Bearer"){let s=await r(e.auth.token);if(!s)return t;t.authorization=`Bearer ${s}`}else if(e.auth.type==="Basic"){let s=r(e.auth.username),n=r(e.auth.password);if(!s||!n)return t;t.authorization=`Basic ${btoa(`${s}:${n}`)}`}else if(e.auth.type==="Custom"){let s=r(e.auth.value);if(!s)return t;t.authorization=`${r(e.auth.prefix)} ${s}`}}return t},ir=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function lr(e){let t=e.headers.get("content-type"),r=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!t)return"json";let s=t.split(";").shift()||"";return ir.test(s)?"json":r.has(s)||s.startsWith("text/")?"text":"blob"}function ur(e){try{return JSON.parse(e),!0}catch{return!1}}function gt(e){if(e===void 0)return!1;let t=typeof e;return t==="string"||t==="number"||t==="boolean"||t===null?!0:t!=="object"?!1:Array.isArray(e)?!0:e.buffer?!1:e.constructor&&e.constructor.name==="Object"||typeof e.toJSON=="function"}function $e(e){try{return JSON.parse(e)}catch{return e}}function je(e){return typeof e=="function"}function cr(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<"u"&&je(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&je(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function hr(e){let t=new Headers(e?.headers),r=await ar(e);for(let[s,n]of Object.entries(r||{}))t.set(s,n);if(!t.has("content-type")){let s=fr(e?.body);s&&t.set("content-type",s)}return t}function fr(e){return gt(e)?"application/json":null}function pr(e){if(!e?.body)return null;let t=new Headers(e?.headers);if(gt(e.body)&&!t.has("content-type")){for(let[r,s]of Object.entries(e?.body))s instanceof Date&&(e.body[r]=s.toISOString());return JSON.stringify(e.body)}return e.body}function dr(e,t){var r;if(t?.method)return t.method.toUpperCase();if(e.startsWith("@")){let s=(r=e.split("@")[1])==null?void 0:r.split("/")[0];return wt.includes(s)?s.toUpperCase():t?.body?"POST":"GET"}return t?.body?"POST":"GET"}function mr(e,t){let r;return!e?.signal&&e?.timeout&&(r=setTimeout(()=>t?.abort(),e?.timeout)),{abortTimeout:r,clearTimeout:()=>{r&&clearTimeout(r)}}}var yr=class vt extends Error{constructor(t,r){super(r||JSON.stringify(t,null,2)),this.issues=t,Object.setPrototypeOf(this,vt.prototype)}};async function te(e,t){let r=await e["~standard"].validate(t);if(r.issues)throw new yr(r.issues);return r.value}var wt=["get","post","put","patch","delete"],gr=e=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(t,r){var s,n,o,a;let l=((n=(s=e.plugins)==null?void 0:s.find(u=>{var i;return(i=u.schema)!=null&&i.config?t.startsWith(u.schema.config.baseURL||"")||t.startsWith(u.schema.config.prefix||""):!1}))==null?void 0:n.schema)||e.schema;if(l){let u=t;(o=l.config)!=null&&o.prefix&&u.startsWith(l.config.prefix)&&(u=u.replace(l.config.prefix,""),l.config.baseURL&&(t=t.replace(l.config.prefix,l.config.baseURL))),(a=l.config)!=null&&a.baseURL&&u.startsWith(l.config.baseURL)&&(u=u.replace(l.config.baseURL,""));let i=l.schema[u];if(i){let c=I(j({},r),{method:i.method,output:i.output});return r?.disableValidation||(c=I(j({},c),{body:i.input?await te(i.input,r?.body):r?.body,params:i.params?await te(i.params,r?.params):r?.params,query:i.query?await te(i.query,r?.query):r?.query})),{url:t,options:c}}}return{url:t,options:r}}}),vr=e=>{async function t(r,s){let n=I(j(j({},e),s),{plugins:[...e?.plugins||[],gr(e||{})]});if(e?.catchAllError)try{return await fe(r,n)}catch(o){return{data:null,error:{status:500,statusText:"Fetch Error",message:"Fetch related error. Captured by catchAllError option. See error property for more details.",error:o}}}return await fe(r,n)}return t};function wr(e,t){let{baseURL:r,params:s,query:n}=t||{query:{},params:{},baseURL:""},o=e.startsWith("http")?e.split("/").slice(0,3).join("/"):r||"";if(e.startsWith("@")){let c=e.toString().split("@")[1].split("/")[0];wt.includes(c)&&(e=e.replace(`@${c}/`,"/"))}o.endsWith("/")||(o+="/");let[a,l]=e.replace(o,"").split("?"),u=new URLSearchParams(l);for(let[c,h]of Object.entries(n||{}))h!=null&&u.set(c,String(h));if(s)if(Array.isArray(s)){let c=a.split("/").filter(h=>h.startsWith(":"));for(let[h,m]of c.entries()){let f=s[h];a=a.replace(m,f)}}else for(let[c,h]of Object.entries(s))a=a.replace(`:${c}`,String(h));a=a.split("/").map(encodeURIComponent).join("/"),a.startsWith("/")&&(a=a.slice(1));let i=u.toString();return i=i.length>0?`?${i}`.replace(/\+/g,"%20"):"",o.startsWith("http")?new URL(`${a}${i}`,o):`${o}${a}${i}`}var fe=async(e,t)=>{var r,s,n,o,a,l,u,i;let{hooks:c,url:h,options:m}=await sr(e,t),f=cr(m),y=new AbortController,v=(r=m.signal)!=null?r:y.signal,g=wr(h,m),w=pr(m),O=await hr(m),P=dr(h,m),d=I(j({},m),{url:g,headers:O,body:w,method:P,signal:v});for(let S of c.onRequest)if(S){let E=await S(d);E instanceof Object&&(d=E)}("pipeTo"in d&&typeof d.pipeTo=="function"||typeof((s=t?.body)==null?void 0:s.pipe)=="function")&&("duplex"in d||(d.duplex="half"));let{clearTimeout:L}=mr(m,y),_=await f(d.url,d);L();let Oe={response:_,request:d};for(let S of c.onResponse)if(S){let E=await S(I(j({},Oe),{response:(n=t?.hookOptions)!=null&&n.cloneResponse?_.clone():_}));E instanceof Response?_=E:E instanceof Object&&(_=E.response)}if(_.ok){if(d.method==="HEAD")return{data:"",error:null};let S=lr(_),E={data:"",response:_,request:d};if(S==="json"||S==="text"){let k=await _.text(),M=await((o=d.jsonParser)!=null?o:$e)(k);E.data=M}else E.data=await _[S]();d?.output&&d.output&&!d.disableValidation&&(E.data=await te(d.output,E.data));for(let k of c.onSuccess)k&&await k(I(j({},E),{response:(a=t?.hookOptions)!=null&&a.cloneResponse?_.clone():_}));return t?.throw?E.data:{data:E.data,error:null}}let Ut=(l=t?.jsonParser)!=null?l:$e,J=await _.text(),Pe=ur(J),le=Pe?await Ut(J):null,Ct={response:_,responseText:J,request:d,error:I(j({},le),{status:_.status,statusText:_.statusText})};for(let S of c.onError)S&&await S(I(j({},Ct),{response:(u=t?.hookOptions)!=null&&u.cloneResponse?_.clone():_}));if(t?.retry){let S=or(t.retry),E=(i=t.retryAttempt)!=null?i:0;if(await S.shouldAttemptRetry(E,_)){for(let M of c.onRetry)M&&await M(Oe);let k=S.getDelay(E);return await new Promise(M=>setTimeout(M,k)),await fe(e,I(j({},t),{retryAttempt:E+1}))}}if(t?.throw)throw new rr(_.status,_.statusText,Pe?le:J);return{data:null,error:I(j({},le),{status:_.status,statusText:_.statusText})}};p();p();var re=Object.create(null),W=e=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?re:globalThis),A=new Proxy(re,{get(e,t){return W()[t]??re[t]},has(e,t){let r=W();return t in r||t in re},set(e,t,r){let s=W(!0);return s[t]=r,!0},deleteProperty(e,t){if(!t)return!1;let r=W(!0);return delete r[t],!0},ownKeys(){let e=W(!0);return Object.keys(e)}}),gs=typeof process<"u"&&process.env&&process.env.NODE_ENV||"";function b(e,t){return typeof process<"u"&&process.env?process.env[e]??t:typeof Deno<"u"?Deno.env.get(e)??t:typeof Bun<"u"?Bun.env[e]??t:t}var vs=Object.freeze({get BETTER_AUTH_SECRET(){return b("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return b("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return b("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return b("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return b("NODE_ENV","development")},get PACKAGE_VERSION(){return b("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return b("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),z=1,T=4,N=8,R=24,Ie={eterm:T,cons25:T,console:T,cygwin:T,dtterm:T,gnome:T,hurd:T,jfbterm:T,konsole:T,kterm:T,mlterm:T,mosh:R,putty:T,st:T,"rxvt-unicode-24bit":R,terminator:R,"xterm-kitty":R},br=new Map(Object.entries({APPVEYOR:N,BUILDKITE:N,CIRCLECI:R,DRONE:N,GITEA_ACTIONS:R,GITHUB_ACTIONS:R,GITLAB_CI:N,TRAVIS:N})),_r=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function Er(){if(b("FORCE_COLOR")!==void 0)switch(b("FORCE_COLOR")){case"":case"1":case"true":return T;case"2":return N;case"3":return R;default:return z}if(b("NODE_DISABLE_COLORS")!==void 0&&b("NODE_DISABLE_COLORS")!==""||b("NO_COLOR")!==void 0&&b("NO_COLOR")!==""||b("TERM")==="dumb")return z;if(b("TMUX"))return R;if("TF_BUILD"in A&&"AGENT_NAME"in A)return T;if("CI"in A){for(let{0:e,1:t}of br)if(e in A)return t;return b("CI_NAME")==="codeship"?N:z}if("TEAMCITY_VERSION"in A)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(b("TEAMCITY_VERSION"))!==null?T:z;switch(b("TERM_PROGRAM")){case"iTerm.app":return!b("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(b("TERM_PROGRAM_VERSION"))!==null?N:R;case"HyperTerm":case"MacTerm":return R;case"Apple_Terminal":return N}if(b("COLORTERM")==="truecolor"||b("COLORTERM")==="24bit")return R;if(b("TERM")){if(/truecolor/.exec(b("TERM"))!==null)return R;if(/^xterm-256/.exec(b("TERM"))!==null)return N;let e=b("TERM").toLowerCase();if(Ie[e])return Ie[e];if(_r.some(t=>t.exec(e)!==null))return T}return b("COLORTERM")?T:z}var x={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",undim:"\x1B[22m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",fg:{black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m"},bg:{black:"\x1B[40m",red:"\x1B[41m",green:"\x1B[42m",yellow:"\x1B[43m",blue:"\x1B[44m",magenta:"\x1B[45m",cyan:"\x1B[46m",white:"\x1B[47m"}},pe=["info","success","warn","error","debug"];function Tr(e,t){return pe.indexOf(t)<=pe.indexOf(e)}var Or={info:x.fg.blue,success:x.fg.green,warn:x.fg.yellow,error:x.fg.red,debug:x.fg.magenta},Pr=(e,t,r)=>{let s=new Date().toISOString();return r?`${x.dim}${s}${x.reset} ${Or[e]}${e.toUpperCase()}${x.reset} ${x.bright}[Better Auth]:${x.reset} ${t}`:`${s} ${e.toUpperCase()} [Better Auth]: ${t}`},Sr=e=>{let t=e?.disabled!==!0,r=e?.level??"error",s=e?.disableColors!==void 0?!e.disableColors:Er()!==1,n=(o,a,l=[])=>{if(!t||!Tr(r,o))return;let u=Pr(o,a,s);if(!e||typeof e.log!="function"){o==="error"?console.error(u,...l):o==="warn"?console.warn(u,...l):console.log(u,...l);return}e.log(o==="success"?"info":o,a,...l)};return{...Object.fromEntries(pe.map(o=>[o,(...[a,...l])=>n(o,a,l)])),get level(){return r}}},ws=Sr();p();p();var we=class extends Error{constructor(e,t){super(e),this.name="BetterAuthError",this.message=e,this.cause=t,this.stack=""}};function Rr(e){try{return(new URL(e).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new we(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function K(e,t="/api/auth"){if(Rr(e))return e;let r=e.replace(/\/+$/,"");return!t||t==="/"?r:(t=t.startsWith("/")?t:`/${t}`,`${r}${t}`)}function Ar(e,t,r,s){if(e)return K(e,t);if(s!==!1){let a=A.BETTER_AUTH_URL||A.NEXT_PUBLIC_BETTER_AUTH_URL||A.PUBLIC_BETTER_AUTH_URL||A.NUXT_PUBLIC_BETTER_AUTH_URL||A.NUXT_PUBLIC_AUTH_URL||(A.BASE_URL!=="/"?A.BASE_URL:void 0);if(a)return K(a,t)}let n=r?.headers.get("x-forwarded-host"),o=r?.headers.get("x-forwarded-proto");if(n&&o)return K(`${o}://${n}`,t);if(r){let a=$r(r.url);if(!a)throw new we("Could not get origin from request. Please provide a valid base URL.");return K(a,t)}if(typeof window<"u"&&window.location)return K(window.location.origin,t)}function $r(e){try{return new URL(e).origin}catch{return null}}p();p();p();var de=Symbol("clean"),$=[],C=0,X=4,jr=0,bt=e=>{let t=[],r={get(){return r.lc||r.listen(()=>{})(),r.value},lc:0,listen(s){return r.lc=t.push(s),()=>{for(let o=C+X;o<$.length;)$[o]===s?$.splice(o,X):o+=X;let n=t.indexOf(s);~n&&(t.splice(n,1),--r.lc||r.off())}},notify(s,n){jr++;let o=!$.length;for(let a of t)$.push(a,r.value,s,n);if(o){for(C=0;C<$.length;C+=X)$[C]($[C+1],$[C+2],$[C+3]);$.length=0}},off(){},set(s){let n=r.value;n!==s&&(r.value=s,r.notify(n))},subscribe(s){let n=r.listen(s);return s(r.value),n},value:e};return process.env.NODE_ENV!=="production"&&(r[de]=()=>{t=[],r.lc=0,r.off()}),r};p();var Ir=5,F=6,Q=10,Nr=(e,t,r,s)=>(e.events=e.events||{},e.events[r+Q]||(e.events[r+Q]=s(n=>{e.events[r].reduceRight((o,a)=>(a(o),o),{shared:{},...n})})),e.events[r]=e.events[r]||[],e.events[r].push(t),()=>{let n=e.events[r],o=n.indexOf(t);n.splice(o,1),n.length||(delete e.events[r],e.events[r+Q](),delete e.events[r+Q])}),xr=1e3,Ur=(e,t)=>Nr(e,r=>{let s=t(r);s&&e.events[F].push(s)},Ir,r=>{let s=e.listen;e.listen=(...o)=>(!e.lc&&!e.active&&(e.active=!0,r()),s(...o));let n=e.off;if(e.events[F]=[],e.off=()=>{n(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let o of e.events[F])o();e.events[F]=[]}},xr)},process.env.NODE_ENV!=="production"){let o=e[de];e[de]=()=>{for(let a of e.events[F])a();e.events[F]=[],e.active=!1,o()}}return()=>{e.listen=s,e.off=n}});p();var Cr=typeof window>"u",Lr=(e,t,r,s)=>{let n=bt({data:null,error:null,isPending:!0,isRefetching:!1,refetch:l=>o(l)}),o=l=>{let u=typeof s=="function"?s({data:n.get().data,error:n.get().error,isPending:n.get().isPending}):s;r(t,{...u,query:{...u?.query,...l?.query},async onSuccess(i){n.set({data:i.data,error:null,isPending:!1,isRefetching:!1,refetch:n.value.refetch}),await u?.onSuccess?.(i)},async onError(i){let{request:c}=i,h=typeof c.retry=="number"?c.retry:c.retry?.attempts,m=c.retryAttempt||0;h&&m<h||(n.set({error:i.error,data:null,isPending:!1,isRefetching:!1,refetch:n.value.refetch}),await u?.onError?.(i))},async onRequest(i){let c=n.get();n.set({isPending:c.data===null,data:c.data,error:null,isRefetching:!0,refetch:n.value.refetch}),await u?.onRequest?.(i)}}).catch(i=>{n.set({error:i,data:null,isPending:!1,isRefetching:!1,refetch:n.value.refetch})})};e=Array.isArray(e)?e:[e];let a=!1;for(let l of e)l.subscribe(()=>{Cr||(a?o():Ur(n,()=>{let u=setTimeout(()=>{a||(o(),a=!0)},0);return()=>{n.off(),l.off(),clearTimeout(u)}}))});return n};p();var Dr={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},Br=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,Ne={true:!0,false:!1,null:null,undefined:void 0,nan:Number.NaN,infinity:Number.POSITIVE_INFINITY,"-infinity":Number.NEGATIVE_INFINITY},kr=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function Mr(e){return e instanceof Date&&!isNaN(e.getTime())}function Fr(e){let t=kr.exec(e);if(!t)return null;let[,r,s,n,o,a,l,u,i,c,h]=t,m=new Date(Date.UTC(parseInt(r,10),parseInt(s,10)-1,parseInt(n,10),parseInt(o,10),parseInt(a,10),parseInt(l,10),u?parseInt(u.padEnd(3,"0"),10):0));if(i){let f=(parseInt(c,10)*60+parseInt(h,10))*(i==="+"?-1:1);m.setUTCMinutes(m.getUTCMinutes()+f)}return Mr(m)?m:null}function Hr(e,t={}){let{strict:r=!1,warnings:s=!1,reviver:n,parseDates:o=!0}=t;if(typeof e!="string")return e;let a=e.trim();if(a.length>0&&a[0]==='"'&&a.endsWith('"')&&!a.slice(1,-1).includes('"'))return a.slice(1,-1);let l=a.toLowerCase();if(l.length<=9&&l in Ne)return Ne[l];if(!Br.test(a)){if(r)throw new SyntaxError("[better-json] Invalid JSON");return e}if(Object.entries(Dr).some(([u,i])=>{let c=i.test(a);return c&&s&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${u} pattern`),c})&&r)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(a,(u,i)=>{if(u==="__proto__"||u==="constructor"&&i&&typeof i=="object"&&"prototype"in i){s&&console.warn(`[better-json] Dropping "${u}" key to prevent prototype pollution`);return}if(o&&typeof i=="string"){let c=Fr(i);if(c)return c}return n?n(u,i):i})}catch(u){if(r)throw u;return e}}function qr(e,t={strict:!0}){return Hr(e,t)}var Gr={id:"redirect",name:"Redirect",hooks:{onSuccess(e){if(e.data?.url&&e.data?.redirect&&typeof window<"u"&&window.location&&window.location)try{window.location.href=e.data.url}catch{}}}};function Wr(e){let t=bt(!1);return{session:Lr(t,"/get-session",e,{method:"GET"}),$sessionSignal:t}}var zr=(e,t)=>{let r="credentials"in Request.prototype,s=Ar(e?.baseURL,e?.basePath,void 0,t)??"/api/auth",n=e?.plugins?.flatMap(d=>d.fetchPlugins).filter(d=>d!==void 0)||[],o={id:"lifecycle-hooks",name:"lifecycle-hooks",hooks:{onSuccess:e?.fetchOptions?.onSuccess,onError:e?.fetchOptions?.onError,onRequest:e?.fetchOptions?.onRequest,onResponse:e?.fetchOptions?.onResponse}},{onSuccess:a,onError:l,onRequest:u,onResponse:i,...c}=e?.fetchOptions||{},h=vr({baseURL:s,...r?{credentials:"include"}:{},method:"GET",jsonParser(d){return d?qr(d,{strict:!1}):null},customFetchImpl:fetch,...c,plugins:[o,...c.plugins||[],...e?.disableDefaultFetchPlugins?[]:[Gr],...n]}),{$sessionSignal:m,session:f}=Wr(h),y=e?.plugins||[],v={},g={$sessionSignal:m,session:f},w={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},O=[{signal:"$sessionSignal",matcher(d){return d==="/sign-out"||d==="/update-user"||d.startsWith("/sign-in")||d.startsWith("/sign-up")||d==="/delete-user"||d==="/verify-email"}}];for(let d of y)d.getAtoms&&Object.assign(g,d.getAtoms?.(h)),d.pathMethods&&Object.assign(w,d.pathMethods),d.atomListeners&&O.push(...d.atomListeners);let P={notify:d=>{g[d].set(!g[d].get())},listen:(d,L)=>{g[d].subscribe(L)},atoms:g};for(let d of y)d.getActions&&Object.assign(v,d.getActions?.(h,P,e));return{get baseURL(){return s},pluginsActions:v,pluginsAtoms:g,pluginPathMethods:w,atomListeners:O,$fetch:h,$store:P}};function Kr(e){return typeof e=="object"&&e!==null&&"get"in e&&typeof e.get=="function"&&"lc"in e&&typeof e.lc=="number"}function Vr(e,t,r){let s=t[e],{fetchOptions:n,query:o,...a}=r||{};return s||(n?.method?n.method:a&&Object.keys(a).length>0?"POST":"GET")}function Yr(e,t,r,s,n){function o(a=[]){return new Proxy(function(){},{get(l,u){if(typeof u!="string"||u==="then"||u==="catch"||u==="finally")return;let i=[...a,u],c=e;for(let h of i)if(c&&typeof c=="object"&&h in c)c=c[h];else{c=void 0;break}return typeof c=="function"||Kr(c)?c:o(i)},apply:async(l,u,i)=>{let c="/"+a.map(O=>O.replace(/[A-Z]/g,P=>`-${P.toLowerCase()}`)).join("/"),h=i[0]||{},m=i[1]||{},{query:f,fetchOptions:y,...v}=h,g={...m,...y},w=Vr(c,r,h);return await t(c,{...g,body:w==="GET"?void 0:{...v,...g?.body||{}},query:f||g?.query,method:w,async onSuccess(O){if(await g?.onSuccess?.(O),!n)return;let P=n.filter(d=>d.matcher(c));if(P.length)for(let d of P){let L=s[d.signal];if(!L)return;let _=L.get();setTimeout(()=>{L.set(!_)},10)}}})}})}return o()}p();function Jr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Xr(e){let{pluginPathMethods:t,pluginsActions:r,pluginsAtoms:s,$fetch:n,atomListeners:o,$store:a}=zr(e),l={};for(let[i,c]of Object.entries(s))l[`use${Jr(i)}`]=c;let u={...r,...l,$fetch:n,$store:a};return Yr(u,n,t,s,o)}p();p();p();function Qr(e){return{authorize(t,r="AND"){let s=!1;for(let[n,o]of Object.entries(t)){let a=e[n];if(!a)return{success:!1,error:`You are not allowed to access resource: ${n}`};if(Array.isArray(o))s=o.every(l=>a.includes(l));else if(typeof o=="object"){let l=o;l.connector==="OR"?s=l.actions.some(u=>a.includes(u)):s=l.actions.every(u=>a.includes(u))}else throw new we("Invalid access control request");if(s&&r==="OR")return{success:s};if(!s&&r==="AND")return{success:!1,error:`unauthorized to access resource "${n}"`}}return s?{success:s}:{success:!1,error:"Not authorized"}},statements:e}}function _t(e){return{newRole(t){return Qr(t)},statements:e}}var Zr={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},be=_t(Zr),bs=be.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),_s=be.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),Es=be.newRole({organization:[],member:[],invitation:[],team:[],ac:["read"]});p();p();p();p();p();p();p();p();p();p();p();var es=class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let t=new Error("Cancelling existing WebAuthn API call for new one");t.name="AbortError",this.controller.abort(t)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}},Ts=new es;p();p();p();p();p();p();p();p();var ts={user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]},Et=_t(ts),Os=Et.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),Ps=Et.newRole({user:[],session:[]});p();p();var rs=()=>({id:"username",$InferServerPlugin:{}}),ss=()=>({id:"phoneNumber",$InferServerPlugin:{},atomListeners:[{matcher(e){return e==="/phone-number/update"||e==="/phone-number/verify"},signal:"$sessionSignal"}]}),ns=()=>({id:"better-auth-client",$InferServerPlugin:{}}),os="/auth",ce="nvwa_login_token",se="nvwa_current_jwt",he="nvwa_user_profile",Tt=class{constructor(e,t,r){this.storage=r;let s=Xr({baseURL:e,basePath:os,plugins:[rs(),ss(),ns()],fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:async()=>{let n=await this.storage.get(se);if(console.log("jwt",n),n)return n;let o=await this.storage.get(ce);return console.log("loginToken",o),o}}}});this.authClient=s}async currentUser(){return await this.storage.get(he)}async getCurrentJwt(){return await this.storage.get(se)}async signUp(e){let t=await this.authClient.signUp.email({email:e.email??`${e.username}@nvwa.app`,name:e.name,username:e.username,displayUsername:e.displayUsername,password:e.password});this.handleLogin(t)}async sendPhoneNumberCode(e){await this.authClient.phoneNumber.sendOtp({phoneNumber:e})}async signInWithPhoneNumberCode(e,t){let r=await this.authClient.phoneNumber.verify({phoneNumber:e,code:t});this.handleLogin(r)}async signInWithPhoneNumber(e,t,r=!1){let s=await this.authClient.signIn.phoneNumber({phoneNumber:e,password:t,rememberMe:r});this.handleLogin(s)}async signInWithUsername(e,t){let r=await this.authClient.signIn.username({username:e,password:t});this.handleLogin(r)}async handleLogin(e){if(e.error)throw new Error(e.error.message);await this.storage.set(ce,e.data?.token),await this.storage.set(he,e.data?.user);let{data:t,error:r}=await this.authClient.token();if(r)throw new Error(r.message);await this.storage.set(se,t.token)}async signOut(){await this.storage.remove(ce),await this.storage.remove(he)}async updateUserPassword(e,t,r=!1){let s=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:r});this.handleLogin(s)}};p();var Ot=class{constructor(e){this.http=e}async invoke(e,t){return await(await this.http.fetch("/functions/"+e,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};p();p();p();var U=class Pt{constructor(t){if(this.headerMap=new Map,t){if(t instanceof Pt)t.forEach((r,s)=>this.set(s,r));else if(Array.isArray(t))for(let[r,s]of t)this.set(r,String(s));else if(typeof t=="object")for(let r of Object.keys(t))this.set(r,String(t[r]))}}append(t,r){let s=t.toLowerCase(),n=this.headerMap.get(s);this.headerMap.set(s,n?`${n}, ${r}`:r)}set(t,r){this.headerMap.set(t.toLowerCase(),String(r))}get(t){return this.headerMap.get(t.toLowerCase())??null}has(t){return this.headerMap.has(t.toLowerCase())}delete(t){this.headerMap.delete(t.toLowerCase())}forEach(t){for(let[r,s]of this.headerMap.entries())t(s,r,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},St=class Rt{constructor(t){if(this.params=new Map,t){if(typeof t=="string")this.parseString(t);else if(t instanceof Rt)this.params=new Map(t.params);else if(Array.isArray(t))for(let[r,s]of t)this.append(r,s);else if(t&&typeof t=="object")for(let[r,s]of Object.entries(t))this.set(r,s)}}parseString(t){t.startsWith("?")&&(t=t.slice(1));let r=t.split("&");for(let s of r)if(s){let[n,o]=s.split("=");n&&this.append(decodeURIComponent(n),o?decodeURIComponent(o):"")}}append(t,r){let s=this.params.get(t)||[];s.push(r),this.params.set(t,s)}delete(t){this.params.delete(t)}get(t){let r=this.params.get(t);return r?r[0]:null}getAll(t){return this.params.get(t)||[]}has(t){return this.params.has(t)}set(t,r){this.params.set(t,[r])}sort(){let t=Array.from(this.params.entries()).sort(([r],[s])=>r.localeCompare(s));this.params=new Map(t)}toString(){let t=[];for(let[r,s]of this.params.entries())for(let n of s)t.push(`${encodeURIComponent(r)}=${encodeURIComponent(n)}`);return t.join("&")}forEach(t){for(let[r,s]of this.params.entries())for(let n of s)t(n,r,this)}keys(){return this.params.keys()}values(){let t=[];for(let r of this.params.values())t.push(...r);return t[Symbol.iterator]()}entries(){let t=[];for(let[r,s]of this.params.entries())for(let n of s)t.push([r,n]);return t[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},as=class me{constructor(t,r){let s;if(t instanceof me)s=t.href;else if(r){let o=r instanceof me?r.href:r;s=this.resolve(o,t)}else s=t;let n=this.parseUrl(s);this.href=s,this.origin=`${n.protocol}//${n.host}`,this.protocol=n.protocol,this.username=n.username,this.password=n.password,this.host=n.host,this.hostname=n.hostname,this.port=n.port,this.pathname=n.pathname,this.search=n.search,this.searchParams=new St(n.search),this.hash=n.hash}resolve(t,r){if(r.startsWith("http://")||r.startsWith("https://"))return r;if(r.startsWith("//"))return`${this.parseUrl(t).protocol}${r}`;if(r.startsWith("/")){let o=this.parseUrl(t);return`${o.protocol}//${o.host}${r}`}let s=this.parseUrl(t),n=s.pathname.endsWith("/")?s.pathname:s.pathname+"/";return`${s.protocol}//${s.host}${n}${r}`}parseUrl(t){let r=t.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!r)throw new TypeError("Invalid URL");let s=r[2]||"",n=r[4]||"",o=r[5]||"/",a=r[7]?`?${r[7]}`:"",l=r[9]?`#${r[9]}`:"";if(!s&&!n&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let u=n.match(/^([^@]*)@(.+)$/),i="",c="",h=n;if(u){let v=u[1];h=u[2];let g=v.match(/^([^:]*):?(.*)$/);g&&(i=g[1]||"",c=g[2]||"")}let m=h.match(/^([^:]+):?(\d*)$/),f=m?m[1]:h,y=m&&m[2]?m[2]:"";return{protocol:s?`${s}:`:"",username:i,password:c,host:h,hostname:f,port:y,pathname:o,search:a,hash:l}}toString(){let t=this.searchParams.toString(),r=t?`?${t}`:"";return`${this.protocol}//${this.host}${this.pathname}${r}${this.hash}`}toJSON(){return this.toString()}};p();var is=class At{constructor(t,r){if(typeof t=="string")this.url=t;else if(t?.url)this.url=String(t.url);else if(typeof t?.toString=="function")this.url=String(t.toString());else throw new Error("Invalid input for Request");this.method=(r?.method||"GET").toUpperCase(),this.headers=r?.headers instanceof U?r.headers:new U(r?.headers),this.body=r?.body,this.timeout=r?.timeout,this.signal=r?.signal||void 0}clone(){return new At(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};p();var _e=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=ls(t?.headers),this.ok=this.status>=200&&this.status<300}async text(){return typeof this.bodyData=="string"?this.bodyData:this.bodyData==null?"":typeof this.bodyData=="object"?JSON.stringify(this.bodyData):String(this.bodyData)}async json(){if(typeof this.bodyData=="string")try{return JSON.parse(this.bodyData)}catch{}return this.bodyData}async arrayBuffer(){let e=await this.text();return new TextEncoder().encode(e).buffer}};function ls(e){return e?new U(e):new U}p();var $t=class{constructor(){this._aborted=!1,this.listeners=new Set,this.onabort=null}get aborted(){return this._aborted}_trigger(){if(!this._aborted){if(this._aborted=!0,typeof this.onabort=="function")try{this.onabort()}catch{}for(let e of Array.from(this.listeners))try{e()}catch{}this.listeners.clear()}}addEventListener(e,t){if(this._aborted){try{t()}catch{}return}this.listeners.add(t)}removeEventListener(e,t){this.listeners.delete(t)}toString(){return"[object AbortSignal]"}},us=class{constructor(){this._signal=new $t}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};p();function jt(e){e.URL=as,e.URLSearchParams=St,e.Headers=U,e.Request=is,e.Response=_e,e.AbortController=us,e.AbortSignal=$t}var It=class{constructor(e,t,r){this.storage=e,this.customFetch=t,this.handleUnauthorized=r}async fetch(e,t){return await this.customFetch(e,t)}async fetchWithAuth(e,t){let r=await this.storage.get(se),s=new U(t?.headers);r&&s.set("Authorization",`Bearer ${r}`);let n=await this.customFetch(e,{...t,headers:s});if(n.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return n}};p();var cs="/storage",hs=cs+"/generateUploadUrl",Nt=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+hs,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:r}=await t.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(r,{method:"PUT",body:e,headers:new U({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:n}=await s.json();return{url:n.split("?")[0]}}};p();p();p();var xe=Vt(Jt(),1),{PostgrestClient:fs,PostgrestQueryBuilder:Ss,PostgrestFilterBuilder:Rs,PostgrestTransformBuilder:As,PostgrestBuilder:$s,PostgrestError:js}=xe.default||xe,ps="/entities",xt=(e,t)=>new fs(e+ps,{fetch:t.fetchWithAuth});var ae=class{constructor(){this.prefix="nvwa_"}getKey(t){return`${this.prefix}${t}`}async get(t){try{let r=this.getKey(t),s=uni.getStorageSync(r);return s?s.expires&&Date.now()>s.expires?(await this.remove(t),null):s.value:null}catch(r){return console.error("UniAppStorageService get error:",r),null}}async set(t,r,s){try{let n=this.getKey(t),o={value:r,expires:s?Date.now()+s*1e3:null,timestamp:Date.now()};uni.setStorageSync(n,o)}catch(n){throw console.error("UniAppStorageService set error:",n),n}}async remove(t){try{let r=this.getKey(t);uni.removeStorageSync(r)}catch(r){throw console.error("UniAppStorageService remove error:",r),r}}async clear(){try{uni.clearStorageSync()}catch(t){throw console.error("UniAppStorageService clear error:",t),t}}};var ds=(e,t)=>{let r;if(typeof e=="string")r=e;else if(e&&typeof e.toString=="function")r=e.toString();else if(e?.url)r=e.url;else throw new Error("Invalid input for uniappFetch");let s=(t?.method||"GET").toUpperCase(),n={};if(t?.headers){let l=t.headers;if(typeof l?.forEach=="function")l.forEach((u,i)=>{n[i]=u});else if(Array.isArray(l))for(let[u,i]of l)n[u]=i;else Object.assign(n,l)}let o;if(t?.body!==void 0){let l=t.body;if(typeof l=="string")o=l;else if(l&&typeof l=="object"&&typeof l.forEach=="function"){let u={};l.forEach((i,c)=>{u[c]=i}),o=u}else o=l}let a=t?.timeout||3e4;return new Promise((l,u)=>{let i=t?.signal;if(i?.aborted){let f=new Error("The operation was aborted");f.name="AbortError",u(f);return}let c=!1,h=[],m=uni.request({url:r,method:s,data:o,header:n,timeout:a,success:f=>{if(c)return;c=!0;let y=f.statusCode,v="",g=new U,w=f.header||f.headers||{};Object.keys(w).forEach(O=>{let P=w[O];g.set(O,typeof P=="string"?P:String(P))}),l(new _e(f.data,{status:y,statusText:v,headers:g}))},fail:f=>{if(c)return;c=!0;let y=f?.errMsg||f?.message||"Network Error",v=new Error(y);/(abort|aborted|canceled|cancelled)/i.test(String(y))&&(v.name="AbortError"),u(v)}});if(i&&typeof i.addEventListener=="function"){let f=()=>{if(c)return;try{m?.abort?.()}catch{}let y=new Error("The operation was aborted");y.name="AbortError",c=!0,u(y)};i.addEventListener("abort",f),h.push(()=>{try{i.removeEventListener?.("abort",f)}catch{}})}})},Ee=ds;var Te=new ae,ie=class{constructor(t,r){this.auth=new Tt(t,Ee,Te),this.httpClient=new It(Te,Ee,r),this.fileStorage=new Nt(t,this.httpClient),this.entities=xt(t,this.httpClient),this.functions=new Ot(this.httpClient)}};0&&(module.exports={localStorage,polyfill});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var Ut=Object.create,ne=Object.defineProperty,Ct=Object.getOwnPropertyDescriptor,Lt=Object.getOwnPropertyNames,Dt=Object.getPrototypeOf,Bt=Object.prototype.hasOwnProperty,xe=(e,t)=>()=>(e&&(t=e(e=0)),t),D=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),kt=(e,t)=>{for(var r in t)ne(e,r,{get:t[r],enumerable:!0})},Ue=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Lt(t))!Bt.call(e,o)&&o!==r&&ne(e,o,{get:()=>t[o],enumerable:!(s=Ct(t,o))||s.enumerable});return e},Mt=(e,t,r)=>(r=e!=null?Ut(Dt(e)):{},Ue(t||!e||!e.__esModule?ne(r,"default",{value:e,enumerable:!0}):r,e)),q=e=>Ue(ne({},"__esModule",{value:!0}),e),p=xe(()=>{"use strict"}),B={};kt(B,{__addDisposableResource:()=>ot,__assign:()=>V,__asyncDelegator:()=>Xe,__asyncGenerator:()=>Je,__asyncValues:()=>Qe,__await:()=>H,__awaiter:()=>Ge,__classPrivateFieldGet:()=>rt,__classPrivateFieldIn:()=>nt,__classPrivateFieldSet:()=>st,__createBinding:()=>Y,__decorate:()=>De,__disposeResources:()=>at,__esDecorate:()=>ke,__exportStar:()=>ze,__extends:()=>Ce,__generator:()=>We,__importDefault:()=>tt,__importStar:()=>et,__makeTemplateObject:()=>Ze,__metadata:()=>qe,__param:()=>Be,__propKey:()=>Fe,__read:()=>ye,__rest:()=>Le,__rewriteRelativeImportExtension:()=>it,__runInitializers:()=>Me,__setFunctionName:()=>He,__spread:()=>Ke,__spreadArray:()=>Ye,__spreadArrays:()=>Ve,__values:()=>se,default:()=>ct});function Ce(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Z(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function Le(e,t){var r={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,s=Object.getOwnPropertySymbols(e);o<s.length;o++)t.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(e,s[o])&&(r[s[o]]=e[s[o]]);return r}function De(e,t,r,s){var o=arguments.length,n=o<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,r):s,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,t,r,s);else for(var l=e.length-1;l>=0;l--)(a=e[l])&&(n=(o<3?a(n):o>3?a(t,r,n):a(t,r))||n);return o>3&&n&&Object.defineProperty(t,r,n),n}function Be(e,t){return function(r,s){t(r,s,e)}}function ke(e,t,r,s,o,n){function a(w){if(w!==void 0&&typeof w!="function")throw new TypeError("Function expected");return w}for(var l=s.kind,u=l==="getter"?"get":l==="setter"?"set":"value",i=!t&&e?s.static?e:e.prototype:null,c=t||(i?Object.getOwnPropertyDescriptor(i,s.name):{}),h,m=!1,f=r.length-1;f>=0;f--){var y={};for(var v in s)y[v]=v==="access"?{}:s[v];for(var v in s.access)y.access[v]=s.access[v];y.addInitializer=function(w){if(m)throw new TypeError("Cannot add initializers after decoration has completed");n.push(a(w||null))};var g=(0,r[f])(l==="accessor"?{get:c.get,set:c.set}:c[u],y);if(l==="accessor"){if(g===void 0)continue;if(g===null||typeof g!="object")throw new TypeError("Object expected");(h=a(g.get))&&(c.get=h),(h=a(g.set))&&(c.set=h),(h=a(g.init))&&o.unshift(h)}else(h=a(g))&&(l==="field"?o.unshift(h):c[u]=h)}i&&Object.defineProperty(i,s.name,c),m=!0}function Me(e,t,r){for(var s=arguments.length>2,o=0;o<t.length;o++)r=s?t[o].call(e,r):t[o].call(e);return s?r:void 0}function Fe(e){return typeof e=="symbol"?e:"".concat(e)}function He(e,t,r){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function qe(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function Ge(e,t,r,s){function o(n){return n instanceof r?n:new r(function(a){a(n)})}return new(r||(r=Promise))(function(n,a){function l(c){try{i(s.next(c))}catch(h){a(h)}}function u(c){try{i(s.throw(c))}catch(h){a(h)}}function i(c){c.done?n(c.value):o(c.value).then(l,u)}i((s=s.apply(e,t||[])).next())})}function We(e,t){var r={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},s,o,n,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(i){return function(c){return u([i,c])}}function u(i){if(s)throw new TypeError("Generator is already executing.");for(;a&&(a=0,i[0]&&(r=0)),r;)try{if(s=1,o&&(n=i[0]&2?o.return:i[0]?o.throw||((n=o.return)&&n.call(o),0):o.next)&&!(n=n.call(o,i[1])).done)return n;switch(o=0,n&&(i=[i[0]&2,n.value]),i[0]){case 0:case 1:n=i;break;case 4:return r.label++,{value:i[1],done:!1};case 5:r.label++,o=i[1],i=[0];continue;case 7:i=r.ops.pop(),r.trys.pop();continue;default:if(n=r.trys,!(n=n.length>0&&n[n.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!n||i[1]>n[0]&&i[1]<n[3])){r.label=i[1];break}if(i[0]===6&&r.label<n[1]){r.label=n[1],n=i;break}if(n&&r.label<n[2]){r.label=n[2],r.ops.push(i);break}n[2]&&r.ops.pop(),r.trys.pop();continue}i=t.call(e,r)}catch(c){i=[6,c],o=0}finally{s=n=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}function ze(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Y(t,e,r)}function se(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],s=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&s>=e.length&&(e=void 0),{value:e&&e[s++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function ye(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var s=r.call(e),o,n=[],a;try{for(;(t===void 0||t-- >0)&&!(o=s.next()).done;)n.push(o.value)}catch(l){a={error:l}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(a)throw a.error}}return n}function Ke(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(ye(arguments[t]));return e}function Ve(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var s=Array(e),o=0,t=0;t<r;t++)for(var n=arguments[t],a=0,l=n.length;a<l;a++,o++)s[o]=n[a];return s}function Ye(e,t,r){if(r||arguments.length===2)for(var s=0,o=t.length,n;s<o;s++)(n||!(s in t))&&(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return e.concat(n||Array.prototype.slice.call(t))}function H(e){return this instanceof H?(this.v=e,this):new H(e)}function Je(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r.apply(e,t||[]),o,n=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),l("next"),l("throw"),l("return",a),o[Symbol.asyncIterator]=function(){return this},o;function a(f){return function(y){return Promise.resolve(y).then(f,h)}}function l(f,y){s[f]&&(o[f]=function(v){return new Promise(function(g,w){n.push([f,v,g,w])>1||u(f,v)})},y&&(o[f]=y(o[f])))}function u(f,y){try{i(s[f](y))}catch(v){m(n[0][3],v)}}function i(f){f.value instanceof H?Promise.resolve(f.value.v).then(c,h):m(n[0][2],f)}function c(f){u("next",f)}function h(f){u("throw",f)}function m(f,y){f(y),n.shift(),n.length&&u(n[0][0],n[0][1])}}function Xe(e){var t,r;return t={},s("next"),s("throw",function(o){throw o}),s("return"),t[Symbol.iterator]=function(){return this},t;function s(o,n){t[o]=e[o]?function(a){return(r=!r)?{value:H(e[o](a)),done:!1}:n?n(a):a}:n}}function Qe(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof se=="function"?se(e):e[Symbol.iterator](),r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r);function s(n){r[n]=e[n]&&function(a){return new Promise(function(l,u){a=e[n](a),o(l,u,a.done,a.value)})}}function o(n,a,l,u){Promise.resolve(u).then(function(i){n({value:i,done:l})},a)}}function Ze(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function et(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=ee(e),s=0;s<r.length;s++)r[s]!=="default"&&Y(t,e,r[s]);return lt(t,e),t}function tt(e){return e&&e.__esModule?e:{default:e}}function rt(e,t,r,s){if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?s:r==="a"?s.call(e):s?s.value:t.get(e)}function st(e,t,r,s,o){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?o.call(e,r):o?o.value=r:t.set(e,r),r}function nt(e,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof e=="function"?t===e:e.has(t)}function ot(e,t,r){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var s,o;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=t[Symbol.asyncDispose]}if(s===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=t[Symbol.dispose],r&&(o=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");o&&(s=function(){try{o.call(this)}catch(n){return Promise.reject(n)}}),e.stack.push({value:t,dispose:s,async:r})}else r&&e.stack.push({async:!0});return t}function at(e){function t(n){e.error=e.hasError?new ut(n,e.error,"An error was suppressed during disposal."):n,e.hasError=!0}var r,s=0;function o(){for(;r=e.stack.pop();)try{if(!r.async&&s===1)return s=0,e.stack.push(r),Promise.resolve().then(o);if(r.dispose){var n=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(n).then(o,function(a){return t(a),o()})}else s|=1}catch(a){t(a)}if(s===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return o()}function it(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,s,o,n,a){return s?t?".jsx":".js":o&&(!n||!a)?r:o+n+"."+a.toLowerCase()+"js"}):e}var Z,V,Y,lt,ee,ut,ct,G=xe(()=>{"use strict";p(),Z=function(e,t){return Z=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var o in s)Object.prototype.hasOwnProperty.call(s,o)&&(r[o]=s[o])},Z(e,t)},V=function(){return V=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++){t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},V.apply(this,arguments)},Y=Object.create?(function(e,t,r,s){s===void 0&&(s=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,o)}):(function(e,t,r,s){s===void 0&&(s=r),e[s]=t[r]}),lt=Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t},ee=function(e){return ee=Object.getOwnPropertyNames||function(t){var r=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[r.length]=s);return r},ee(e)},ut=typeof SuppressedError=="function"?SuppressedError:function(e,t,r){var s=new Error(r);return s.name="SuppressedError",s.error=e,s.suppressed=t,s},ct={__extends:Ce,__assign:V,__rest:Le,__decorate:De,__param:Be,__esDecorate:ke,__runInitializers:Me,__propKey:Fe,__setFunctionName:He,__metadata:qe,__awaiter:Ge,__generator:We,__createBinding:Y,__exportStar:ze,__values:se,__read:ye,__spread:Ke,__spreadArrays:Ve,__spreadArray:Ye,__await:H,__asyncGenerator:Je,__asyncDelegator:Xe,__asyncValues:Qe,__makeTemplateObject:Ze,__importStar:et,__importDefault:tt,__classPrivateFieldGet:rt,__classPrivateFieldSet:st,__classPrivateFieldIn:nt,__addDisposableResource:ot,__disposeResources:at,__rewriteRelativeImportExtension:it}}),ht=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}};e.default=t}),ft=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(B)),r=t.__importDefault(ht()),s=class{constructor(o){var n,a;this.shouldThrowOnError=!1,this.method=o.method,this.url=o.url,this.headers=new Headers(o.headers),this.schema=o.schema,this.body=o.body,this.shouldThrowOnError=(n=o.shouldThrowOnError)!==null&&n!==void 0?n:!1,this.signal=o.signal,this.isMaybeSingle=(a=o.isMaybeSingle)!==null&&a!==void 0?a:!1,o.fetch?this.fetch=o.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(o,n){return this.headers=new Headers(this.headers),this.headers.set(o,n),this}then(o,n){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let a=this.fetch,l=a(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async u=>{var i,c,h,m;let f=null,y=null,v=null,g=u.status,w=u.statusText;if(u.ok){if(this.method!=="HEAD"){let d=await u.text();d===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&!((i=this.headers.get("Accept"))===null||i===void 0)&&i.includes("application/vnd.pgrst.plan+text")?y=d:y=JSON.parse(d))}let T=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),P=(h=u.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");T&&P&&P.length>1&&(v=parseInt(P[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(y)&&(y.length>1?(f={code:"PGRST116",details:`Results contain ${y.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},y=null,v=null,g=406,w="Not Acceptable"):y.length===1?y=y[0]:y=null)}else{let T=await u.text();try{f=JSON.parse(T),Array.isArray(f)&&u.status===404&&(y=[],f=null,g=200,w="OK")}catch{u.status===404&&T===""?(g=204,w="No Content"):f={message:T}}if(f&&this.isMaybeSingle&&!((m=f?.details)===null||m===void 0)&&m.includes("0 rows")&&(f=null,g=200,w="OK"),f&&this.shouldThrowOnError)throw new r.default(f)}return{error:f,data:y,count:v,status:g,statusText:w}});return this.shouldThrowOnError||(l=l.catch(u=>{var i,c,h;return{error:{message:`${(i=u?.name)!==null&&i!==void 0?i:"FetchError"}: ${u?.message}`,details:`${(c=u?.stack)!==null&&c!==void 0?c:""}`,hint:"",code:`${(h=u?.code)!==null&&h!==void 0?h:""}`},data:null,count:null,status:0,statusText:""}})),l.then(o,n)}returns(){return this}overrideTypes(){return this}};e.default=s}),pt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(B)),r=t.__importDefault(ft()),s=class extends r.default{select(o){let n=!1,a=(o??"*").split("").map(l=>/\s/.test(l)&&!n?"":(l==='"'&&(n=!n),l)).join("");return this.url.searchParams.set("select",a),this.headers.append("Prefer","return=representation"),this}order(o,{ascending:n=!0,nullsFirst:a,foreignTable:l,referencedTable:u=l}={}){let i=u?`${u}.order`:"order",c=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${c?`${c},`:""}${o}.${n?"asc":"desc"}${a===void 0?"":a?".nullsfirst":".nullslast"}`),this}limit(o,{foreignTable:n,referencedTable:a=n}={}){let l=typeof a>"u"?"limit":`${a}.limit`;return this.url.searchParams.set(l,`${o}`),this}range(o,n,{foreignTable:a,referencedTable:l=a}={}){let u=typeof l>"u"?"offset":`${l}.offset`,i=typeof l>"u"?"limit":`${l}.limit`;return this.url.searchParams.set(u,`${o}`),this.url.searchParams.set(i,`${n-o+1}`),this}abortSignal(o){return this.signal=o,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:o=!1,verbose:n=!1,settings:a=!1,buffers:l=!1,wal:u=!1,format:i="text"}={}){var c;let h=[o?"analyze":null,n?"verbose":null,a?"settings":null,l?"buffers":null,u?"wal":null].filter(Boolean).join("|"),m=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${m}"; options=${h};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(o){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${o}`),this}};e.default=s}),ge=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(B)),r=t.__importDefault(pt()),s=new RegExp("[,()]"),o=class extends r.default{eq(n,a){return this.url.searchParams.append(n,`eq.${a}`),this}neq(n,a){return this.url.searchParams.append(n,`neq.${a}`),this}gt(n,a){return this.url.searchParams.append(n,`gt.${a}`),this}gte(n,a){return this.url.searchParams.append(n,`gte.${a}`),this}lt(n,a){return this.url.searchParams.append(n,`lt.${a}`),this}lte(n,a){return this.url.searchParams.append(n,`lte.${a}`),this}like(n,a){return this.url.searchParams.append(n,`like.${a}`),this}likeAllOf(n,a){return this.url.searchParams.append(n,`like(all).{${a.join(",")}}`),this}likeAnyOf(n,a){return this.url.searchParams.append(n,`like(any).{${a.join(",")}}`),this}ilike(n,a){return this.url.searchParams.append(n,`ilike.${a}`),this}ilikeAllOf(n,a){return this.url.searchParams.append(n,`ilike(all).{${a.join(",")}}`),this}ilikeAnyOf(n,a){return this.url.searchParams.append(n,`ilike(any).{${a.join(",")}}`),this}is(n,a){return this.url.searchParams.append(n,`is.${a}`),this}in(n,a){let l=Array.from(new Set(a)).map(u=>typeof u=="string"&&s.test(u)?`"${u}"`:`${u}`).join(",");return this.url.searchParams.append(n,`in.(${l})`),this}contains(n,a){return typeof a=="string"?this.url.searchParams.append(n,`cs.${a}`):Array.isArray(a)?this.url.searchParams.append(n,`cs.{${a.join(",")}}`):this.url.searchParams.append(n,`cs.${JSON.stringify(a)}`),this}containedBy(n,a){return typeof a=="string"?this.url.searchParams.append(n,`cd.${a}`):Array.isArray(a)?this.url.searchParams.append(n,`cd.{${a.join(",")}}`):this.url.searchParams.append(n,`cd.${JSON.stringify(a)}`),this}rangeGt(n,a){return this.url.searchParams.append(n,`sr.${a}`),this}rangeGte(n,a){return this.url.searchParams.append(n,`nxl.${a}`),this}rangeLt(n,a){return this.url.searchParams.append(n,`sl.${a}`),this}rangeLte(n,a){return this.url.searchParams.append(n,`nxr.${a}`),this}rangeAdjacent(n,a){return this.url.searchParams.append(n,`adj.${a}`),this}overlaps(n,a){return typeof a=="string"?this.url.searchParams.append(n,`ov.${a}`):this.url.searchParams.append(n,`ov.{${a.join(",")}}`),this}textSearch(n,a,{config:l,type:u}={}){let i="";u==="plain"?i="pl":u==="phrase"?i="ph":u==="websearch"&&(i="w");let c=l===void 0?"":`(${l})`;return this.url.searchParams.append(n,`${i}fts${c}.${a}`),this}match(n){return Object.entries(n).forEach(([a,l])=>{this.url.searchParams.append(a,`eq.${l}`)}),this}not(n,a,l){return this.url.searchParams.append(n,`not.${a}.${l}`),this}or(n,{foreignTable:a,referencedTable:l=a}={}){let u=l?`${l}.or`:"or";return this.url.searchParams.append(u,`(${n})`),this}filter(n,a,l){return this.url.searchParams.append(n,`${a}.${l}`),this}};e.default=o}),dt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(B)),r=t.__importDefault(ge()),s=class{constructor(o,{headers:n={},schema:a,fetch:l}){this.url=o,this.headers=new Headers(n),this.schema=a,this.fetch=l}select(o,n){let{head:a=!1,count:l}=n??{},u=a?"HEAD":"GET",i=!1,c=(o??"*").split("").map(h=>/\s/.test(h)&&!i?"":(h==='"'&&(i=!i),h)).join("");return this.url.searchParams.set("select",c),l&&this.headers.append("Prefer",`count=${l}`),new r.default({method:u,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(o,{count:n,defaultToNull:a=!0}={}){var l;let u="POST";if(n&&this.headers.append("Prefer",`count=${n}`),a||this.headers.append("Prefer","missing=default"),Array.isArray(o)){let i=o.reduce((c,h)=>c.concat(Object.keys(h)),[]);if(i.length>0){let c=[...new Set(i)].map(h=>`"${h}"`);this.url.searchParams.set("columns",c.join(","))}}return new r.default({method:u,url:this.url,headers:this.headers,schema:this.schema,body:o,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}upsert(o,{onConflict:n,ignoreDuplicates:a=!1,count:l,defaultToNull:u=!0}={}){var i;let c="POST";if(this.headers.append("Prefer",`resolution=${a?"ignore":"merge"}-duplicates`),n!==void 0&&this.url.searchParams.set("on_conflict",n),l&&this.headers.append("Prefer",`count=${l}`),u||this.headers.append("Prefer","missing=default"),Array.isArray(o)){let h=o.reduce((m,f)=>m.concat(Object.keys(f)),[]);if(h.length>0){let m=[...new Set(h)].map(f=>`"${f}"`);this.url.searchParams.set("columns",m.join(","))}}return new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:o,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}update(o,{count:n}={}){var a;let l="PATCH";return n&&this.headers.append("Prefer",`count=${n}`),new r.default({method:l,url:this.url,headers:this.headers,schema:this.schema,body:o,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}delete({count:o}={}){var n;let a="DELETE";return o&&this.headers.append("Prefer",`count=${o}`),new r.default({method:a,url:this.url,headers:this.headers,schema:this.schema,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}};e.default=s}),Ft=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(B)),r=t.__importDefault(dt()),s=t.__importDefault(ge()),o=class mt{constructor(a,{headers:l={},schema:u,fetch:i}={}){this.url=a,this.headers=new Headers(l),this.schemaName=u,this.fetch=i}from(a){let l=new URL(`${this.url}/${a}`);return new r.default(l,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(a){return new mt(this.url,{headers:this.headers,schema:a,fetch:this.fetch})}rpc(a,l={},{head:u=!1,get:i=!1,count:c}={}){var h;let m,f=new URL(`${this.url}/rpc/${a}`),y;u||i?(m=u?"HEAD":"GET",Object.entries(l).filter(([g,w])=>w!==void 0).map(([g,w])=>[g,Array.isArray(w)?`{${w.join(",")}}`:`${w}`]).forEach(([g,w])=>{f.searchParams.append(g,w)})):(m="POST",y=l);let v=new Headers(this.headers);return c&&v.set("Prefer",`count=${c}`),new s.default({method:m,url:f,headers:v,schema:this.schemaName,body:y,fetch:(h=this.fetch)!==null&&h!==void 0?h:fetch})}};e.default=o}),Ht=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0}),e.PostgrestError=e.PostgrestBuilder=e.PostgrestTransformBuilder=e.PostgrestFilterBuilder=e.PostgrestQueryBuilder=e.PostgrestClient=void 0;var t=(G(),q(B)),r=t.__importDefault(Ft());e.PostgrestClient=r.default;var s=t.__importDefault(dt());e.PostgrestQueryBuilder=s.default;var o=t.__importDefault(ge());e.PostgrestFilterBuilder=o.default;var n=t.__importDefault(pt());e.PostgrestTransformBuilder=n.default;var a=t.__importDefault(ft());e.PostgrestBuilder=a.default;var l=t.__importDefault(ht());e.PostgrestError=l.default,e.default={PostgrestClient:r.default,PostgrestQueryBuilder:s.default,PostgrestFilterBuilder:o.default,PostgrestTransformBuilder:n.default,PostgrestBuilder:a.default,PostgrestError:l.default}});p();p();p();p();p();p();var qt=Object.defineProperty,Gt=Object.defineProperties,Wt=Object.getOwnPropertyDescriptors,Pe=Object.getOwnPropertySymbols,zt=Object.prototype.hasOwnProperty,Kt=Object.prototype.propertyIsEnumerable,Se=(e,t,r)=>t in e?qt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,j=(e,t)=>{for(var r in t||(t={}))zt.call(t,r)&&Se(e,r,t[r]);if(Pe)for(var r of Pe(t))Kt.call(t,r)&&Se(e,r,t[r]);return e},I=(e,t)=>Gt(e,Wt(t)),Vt=class extends Error{constructor(e,t,r){super(t||e.toString(),{cause:r}),this.status=e,this.statusText=t,this.error=r}},Yt=async(e,t)=>{var r,s,o,n,a,l;let u=t||{},i={onRequest:[t?.onRequest],onResponse:[t?.onResponse],onSuccess:[t?.onSuccess],onError:[t?.onError],onRetry:[t?.onRetry]};if(!t||!t?.plugins)return{url:e,options:u,hooks:i};for(let c of t?.plugins||[]){if(c.init){let h=await((r=c.init)==null?void 0:r.call(c,e.toString(),t));u=h.options||u,e=h.url}i.onRequest.push((s=c.hooks)==null?void 0:s.onRequest),i.onResponse.push((o=c.hooks)==null?void 0:o.onResponse),i.onSuccess.push((n=c.hooks)==null?void 0:n.onSuccess),i.onError.push((a=c.hooks)==null?void 0:a.onError),i.onRetry.push((l=c.hooks)==null?void 0:l.onRetry)}return{url:e,options:u,hooks:i}},Re=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(){return this.options.delay}},Jt=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(e){return Math.min(this.options.maxDelay,this.options.baseDelay*2**e)}};function Xt(e){if(typeof e=="number")return new Re({type:"linear",attempts:e,delay:1e3});switch(e.type){case"linear":return new Re(e);case"exponential":return new Jt(e);default:throw new Error("Invalid retry strategy")}}var Qt=async e=>{let t={},r=async s=>typeof s=="function"?await s():s;if(e?.auth){if(e.auth.type==="Bearer"){let s=await r(e.auth.token);if(!s)return t;t.authorization=`Bearer ${s}`}else if(e.auth.type==="Basic"){let s=r(e.auth.username),o=r(e.auth.password);if(!s||!o)return t;t.authorization=`Basic ${btoa(`${s}:${o}`)}`}else if(e.auth.type==="Custom"){let s=r(e.auth.value);if(!s)return t;t.authorization=`${r(e.auth.prefix)} ${s}`}}return t},Zt=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function er(e){let t=e.headers.get("content-type"),r=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!t)return"json";let s=t.split(";").shift()||"";return Zt.test(s)?"json":r.has(s)||s.startsWith("text/")?"text":"blob"}function tr(e){try{return JSON.parse(e),!0}catch{return!1}}function yt(e){if(e===void 0)return!1;let t=typeof e;return t==="string"||t==="number"||t==="boolean"||t===null?!0:t!=="object"?!1:Array.isArray(e)?!0:e.buffer?!1:e.constructor&&e.constructor.name==="Object"||typeof e.toJSON=="function"}function Ae(e){try{return JSON.parse(e)}catch{return e}}function $e(e){return typeof e=="function"}function rr(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<"u"&&$e(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&$e(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function sr(e){let t=new Headers(e?.headers),r=await Qt(e);for(let[s,o]of Object.entries(r||{}))t.set(s,o);if(!t.has("content-type")){let s=nr(e?.body);s&&t.set("content-type",s)}return t}function nr(e){return yt(e)?"application/json":null}function or(e){if(!e?.body)return null;let t=new Headers(e?.headers);if(yt(e.body)&&!t.has("content-type")){for(let[r,s]of Object.entries(e?.body))s instanceof Date&&(e.body[r]=s.toISOString());return JSON.stringify(e.body)}return e.body}function ar(e,t){var r;if(t?.method)return t.method.toUpperCase();if(e.startsWith("@")){let s=(r=e.split("@")[1])==null?void 0:r.split("/")[0];return vt.includes(s)?s.toUpperCase():t?.body?"POST":"GET"}return t?.body?"POST":"GET"}function ir(e,t){let r;return!e?.signal&&e?.timeout&&(r=setTimeout(()=>t?.abort(),e?.timeout)),{abortTimeout:r,clearTimeout:()=>{r&&clearTimeout(r)}}}var lr=class gt extends Error{constructor(t,r){super(r||JSON.stringify(t,null,2)),this.issues=t,Object.setPrototypeOf(this,gt.prototype)}};async function te(e,t){let r=await e["~standard"].validate(t);if(r.issues)throw new lr(r.issues);return r.value}var vt=["get","post","put","patch","delete"],ur=e=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(t,r){var s,o,n,a;let l=((o=(s=e.plugins)==null?void 0:s.find(u=>{var i;return(i=u.schema)!=null&&i.config?t.startsWith(u.schema.config.baseURL||"")||t.startsWith(u.schema.config.prefix||""):!1}))==null?void 0:o.schema)||e.schema;if(l){let u=t;(n=l.config)!=null&&n.prefix&&u.startsWith(l.config.prefix)&&(u=u.replace(l.config.prefix,""),l.config.baseURL&&(t=t.replace(l.config.prefix,l.config.baseURL))),(a=l.config)!=null&&a.baseURL&&u.startsWith(l.config.baseURL)&&(u=u.replace(l.config.baseURL,""));let i=l.schema[u];if(i){let c=I(j({},r),{method:i.method,output:i.output});return r?.disableValidation||(c=I(j({},c),{body:i.input?await te(i.input,r?.body):r?.body,params:i.params?await te(i.params,r?.params):r?.params,query:i.query?await te(i.query,r?.query):r?.query})),{url:t,options:c}}}return{url:t,options:r}}}),cr=e=>{async function t(r,s){let o=I(j(j({},e),s),{plugins:[...e?.plugins||[],ur(e||{})]});if(e?.catchAllError)try{return await ce(r,o)}catch(n){return{data:null,error:{status:500,statusText:"Fetch Error",message:"Fetch related error. Captured by catchAllError option. See error property for more details.",error:n}}}return await ce(r,o)}return t};function hr(e,t){let{baseURL:r,params:s,query:o}=t||{query:{},params:{},baseURL:""},n=e.startsWith("http")?e.split("/").slice(0,3).join("/"):r||"";if(e.startsWith("@")){let c=e.toString().split("@")[1].split("/")[0];vt.includes(c)&&(e=e.replace(`@${c}/`,"/"))}n.endsWith("/")||(n+="/");let[a,l]=e.replace(n,"").split("?"),u=new URLSearchParams(l);for(let[c,h]of Object.entries(o||{}))h!=null&&u.set(c,String(h));if(s)if(Array.isArray(s)){let c=a.split("/").filter(h=>h.startsWith(":"));for(let[h,m]of c.entries()){let f=s[h];a=a.replace(m,f)}}else for(let[c,h]of Object.entries(s))a=a.replace(`:${c}`,String(h));a=a.split("/").map(encodeURIComponent).join("/"),a.startsWith("/")&&(a=a.slice(1));let i=u.toString();return i=i.length>0?`?${i}`.replace(/\+/g,"%20"):"",n.startsWith("http")?new URL(`${a}${i}`,n):`${n}${a}${i}`}var ce=async(e,t)=>{var r,s,o,n,a,l,u,i;let{hooks:c,url:h,options:m}=await Yt(e,t),f=rr(m),y=new AbortController,v=(r=m.signal)!=null?r:y.signal,g=hr(h,m),w=or(m),T=await sr(m),P=ar(h,m),d=I(j({},m),{url:g,headers:T,body:w,method:P,signal:v});for(let S of c.onRequest)if(S){let E=await S(d);E instanceof Object&&(d=E)}("pipeTo"in d&&typeof d.pipeTo=="function"||typeof((s=t?.body)==null?void 0:s.pipe)=="function")&&("duplex"in d||(d.duplex="half"));let{clearTimeout:L}=ir(m,y),_=await f(d.url,d);L();let Oe={response:_,request:d};for(let S of c.onResponse)if(S){let E=await S(I(j({},Oe),{response:(o=t?.hookOptions)!=null&&o.cloneResponse?_.clone():_}));E instanceof Response?_=E:E instanceof Object&&(_=E.response)}if(_.ok){if(d.method==="HEAD")return{data:"",error:null};let S=er(_),E={data:"",response:_,request:d};if(S==="json"||S==="text"){let k=await _.text(),M=await((n=d.jsonParser)!=null?n:Ae)(k);E.data=M}else E.data=await _[S]();d?.output&&d.output&&!d.disableValidation&&(E.data=await te(d.output,E.data));for(let k of c.onSuccess)k&&await k(I(j({},E),{response:(a=t?.hookOptions)!=null&&a.cloneResponse?_.clone():_}));return t?.throw?E.data:{data:E.data,error:null}}let Nt=(l=t?.jsonParser)!=null?l:Ae,J=await _.text(),Te=tr(J),ae=Te?await Nt(J):null,xt={response:_,responseText:J,request:d,error:I(j({},ae),{status:_.status,statusText:_.statusText})};for(let S of c.onError)S&&await S(I(j({},xt),{response:(u=t?.hookOptions)!=null&&u.cloneResponse?_.clone():_}));if(t?.retry){let S=Xt(t.retry),E=(i=t.retryAttempt)!=null?i:0;if(await S.shouldAttemptRetry(E,_)){for(let M of c.onRetry)M&&await M(Oe);let k=S.getDelay(E);return await new Promise(M=>setTimeout(M,k)),await ce(e,I(j({},t),{retryAttempt:E+1}))}}if(t?.throw)throw new Vt(_.status,_.statusText,Te?ae:J);return{data:null,error:I(j({},ae),{status:_.status,statusText:_.statusText})}};p();p();var re=Object.create(null),W=e=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?re:globalThis),A=new Proxy(re,{get(e,t){return W()[t]??re[t]},has(e,t){let r=W();return t in r||t in re},set(e,t,r){let s=W(!0);return s[t]=r,!0},deleteProperty(e,t){if(!t)return!1;let r=W(!0);return delete r[t],!0},ownKeys(){let e=W(!0);return Object.keys(e)}}),us=typeof process<"u"&&process.env&&process.env.NODE_ENV||"";function b(e,t){return typeof process<"u"&&process.env?process.env[e]??t:typeof Deno<"u"?Deno.env.get(e)??t:typeof Bun<"u"?Bun.env[e]??t:t}var cs=Object.freeze({get BETTER_AUTH_SECRET(){return b("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return b("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return b("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return b("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return b("NODE_ENV","development")},get PACKAGE_VERSION(){return b("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return b("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),z=1,O=4,N=8,R=24,je={eterm:O,cons25:O,console:O,cygwin:O,dtterm:O,gnome:O,hurd:O,jfbterm:O,konsole:O,kterm:O,mlterm:O,mosh:R,putty:O,st:O,"rxvt-unicode-24bit":R,terminator:R,"xterm-kitty":R},fr=new Map(Object.entries({APPVEYOR:N,BUILDKITE:N,CIRCLECI:R,DRONE:N,GITEA_ACTIONS:R,GITHUB_ACTIONS:R,GITLAB_CI:N,TRAVIS:N})),pr=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function dr(){if(b("FORCE_COLOR")!==void 0)switch(b("FORCE_COLOR")){case"":case"1":case"true":return O;case"2":return N;case"3":return R;default:return z}if(b("NODE_DISABLE_COLORS")!==void 0&&b("NODE_DISABLE_COLORS")!==""||b("NO_COLOR")!==void 0&&b("NO_COLOR")!==""||b("TERM")==="dumb")return z;if(b("TMUX"))return R;if("TF_BUILD"in A&&"AGENT_NAME"in A)return O;if("CI"in A){for(let{0:e,1:t}of fr)if(e in A)return t;return b("CI_NAME")==="codeship"?N:z}if("TEAMCITY_VERSION"in A)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(b("TEAMCITY_VERSION"))!==null?O:z;switch(b("TERM_PROGRAM")){case"iTerm.app":return!b("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(b("TERM_PROGRAM_VERSION"))!==null?N:R;case"HyperTerm":case"MacTerm":return R;case"Apple_Terminal":return N}if(b("COLORTERM")==="truecolor"||b("COLORTERM")==="24bit")return R;if(b("TERM")){if(/truecolor/.exec(b("TERM"))!==null)return R;if(/^xterm-256/.exec(b("TERM"))!==null)return N;let e=b("TERM").toLowerCase();if(je[e])return je[e];if(pr.some(t=>t.exec(e)!==null))return O}return b("COLORTERM")?O:z}var x={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",undim:"\x1B[22m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",fg:{black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m"},bg:{black:"\x1B[40m",red:"\x1B[41m",green:"\x1B[42m",yellow:"\x1B[43m",blue:"\x1B[44m",magenta:"\x1B[45m",cyan:"\x1B[46m",white:"\x1B[47m"}},he=["info","success","warn","error","debug"];function mr(e,t){return he.indexOf(t)<=he.indexOf(e)}var yr={info:x.fg.blue,success:x.fg.green,warn:x.fg.yellow,error:x.fg.red,debug:x.fg.magenta},gr=(e,t,r)=>{let s=new Date().toISOString();return r?`${x.dim}${s}${x.reset} ${yr[e]}${e.toUpperCase()}${x.reset} ${x.bright}[Better Auth]:${x.reset} ${t}`:`${s} ${e.toUpperCase()} [Better Auth]: ${t}`},vr=e=>{let t=e?.disabled!==!0,r=e?.level??"error",s=e?.disableColors!==void 0?!e.disableColors:dr()!==1,o=(n,a,l=[])=>{if(!t||!mr(r,n))return;let u=gr(n,a,s);if(!e||typeof e.log!="function"){n==="error"?console.error(u,...l):n==="warn"?console.warn(u,...l):console.log(u,...l);return}e.log(n==="success"?"info":n,a,...l)};return{...Object.fromEntries(he.map(n=>[n,(...[a,...l])=>o(n,a,l)])),get level(){return r}}},hs=vr();p();p();var ve=class extends Error{constructor(e,t){super(e),this.name="BetterAuthError",this.message=e,this.cause=t,this.stack=""}};function wr(e){try{return(new URL(e).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new ve(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function K(e,t="/api/auth"){if(wr(e))return e;let r=e.replace(/\/+$/,"");return!t||t==="/"?r:(t=t.startsWith("/")?t:`/${t}`,`${r}${t}`)}function br(e,t,r,s){if(e)return K(e,t);if(s!==!1){let a=A.BETTER_AUTH_URL||A.NEXT_PUBLIC_BETTER_AUTH_URL||A.PUBLIC_BETTER_AUTH_URL||A.NUXT_PUBLIC_BETTER_AUTH_URL||A.NUXT_PUBLIC_AUTH_URL||(A.BASE_URL!=="/"?A.BASE_URL:void 0);if(a)return K(a,t)}let o=r?.headers.get("x-forwarded-host"),n=r?.headers.get("x-forwarded-proto");if(o&&n)return K(`${n}://${o}`,t);if(r){let a=_r(r.url);if(!a)throw new ve("Could not get origin from request. Please provide a valid base URL.");return K(a,t)}if(typeof window<"u"&&window.location)return K(window.location.origin,t)}function _r(e){try{return new URL(e).origin}catch{return null}}p();p();p();var fe=Symbol("clean"),$=[],U=0,X=4,Er=0,wt=e=>{let t=[],r={get(){return r.lc||r.listen(()=>{})(),r.value},lc:0,listen(s){return r.lc=t.push(s),()=>{for(let n=U+X;n<$.length;)$[n]===s?$.splice(n,X):n+=X;let o=t.indexOf(s);~o&&(t.splice(o,1),--r.lc||r.off())}},notify(s,o){Er++;let n=!$.length;for(let a of t)$.push(a,r.value,s,o);if(n){for(U=0;U<$.length;U+=X)$[U]($[U+1],$[U+2],$[U+3]);$.length=0}},off(){},set(s){let o=r.value;o!==s&&(r.value=s,r.notify(o))},subscribe(s){let o=r.listen(s);return s(r.value),o},value:e};return process.env.NODE_ENV!=="production"&&(r[fe]=()=>{t=[],r.lc=0,r.off()}),r};p();var Or=5,F=6,Q=10,Tr=(e,t,r,s)=>(e.events=e.events||{},e.events[r+Q]||(e.events[r+Q]=s(o=>{e.events[r].reduceRight((n,a)=>(a(n),n),{shared:{},...o})})),e.events[r]=e.events[r]||[],e.events[r].push(t),()=>{let o=e.events[r],n=o.indexOf(t);o.splice(n,1),o.length||(delete e.events[r],e.events[r+Q](),delete e.events[r+Q])}),Pr=1e3,Sr=(e,t)=>Tr(e,r=>{let s=t(r);s&&e.events[F].push(s)},Or,r=>{let s=e.listen;e.listen=(...n)=>(!e.lc&&!e.active&&(e.active=!0,r()),s(...n));let o=e.off;if(e.events[F]=[],e.off=()=>{o(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let n of e.events[F])n();e.events[F]=[]}},Pr)},process.env.NODE_ENV!=="production"){let n=e[fe];e[fe]=()=>{for(let a of e.events[F])a();e.events[F]=[],e.active=!1,n()}}return()=>{e.listen=s,e.off=o}});p();var Rr=typeof window>"u",Ar=(e,t,r,s)=>{let o=wt({data:null,error:null,isPending:!0,isRefetching:!1,refetch:l=>n(l)}),n=l=>{let u=typeof s=="function"?s({data:o.get().data,error:o.get().error,isPending:o.get().isPending}):s;r(t,{...u,query:{...u?.query,...l?.query},async onSuccess(i){o.set({data:i.data,error:null,isPending:!1,isRefetching:!1,refetch:o.value.refetch}),await u?.onSuccess?.(i)},async onError(i){let{request:c}=i,h=typeof c.retry=="number"?c.retry:c.retry?.attempts,m=c.retryAttempt||0;h&&m<h||(o.set({error:i.error,data:null,isPending:!1,isRefetching:!1,refetch:o.value.refetch}),await u?.onError?.(i))},async onRequest(i){let c=o.get();o.set({isPending:c.data===null,data:c.data,error:null,isRefetching:!0,refetch:o.value.refetch}),await u?.onRequest?.(i)}}).catch(i=>{o.set({error:i,data:null,isPending:!1,isRefetching:!1,refetch:o.value.refetch})})};e=Array.isArray(e)?e:[e];let a=!1;for(let l of e)l.subscribe(()=>{Rr||(a?n():Sr(o,()=>{let u=setTimeout(()=>{a||(n(),a=!0)},0);return()=>{o.off(),l.off(),clearTimeout(u)}}))});return o};p();var $r={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},jr=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,Ie={true:!0,false:!1,null:null,undefined:void 0,nan:Number.NaN,infinity:Number.POSITIVE_INFINITY,"-infinity":Number.NEGATIVE_INFINITY},Ir=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function Nr(e){return e instanceof Date&&!isNaN(e.getTime())}function xr(e){let t=Ir.exec(e);if(!t)return null;let[,r,s,o,n,a,l,u,i,c,h]=t,m=new Date(Date.UTC(parseInt(r,10),parseInt(s,10)-1,parseInt(o,10),parseInt(n,10),parseInt(a,10),parseInt(l,10),u?parseInt(u.padEnd(3,"0"),10):0));if(i){let f=(parseInt(c,10)*60+parseInt(h,10))*(i==="+"?-1:1);m.setUTCMinutes(m.getUTCMinutes()+f)}return Nr(m)?m:null}function Ur(e,t={}){let{strict:r=!1,warnings:s=!1,reviver:o,parseDates:n=!0}=t;if(typeof e!="string")return e;let a=e.trim();if(a.length>0&&a[0]==='"'&&a.endsWith('"')&&!a.slice(1,-1).includes('"'))return a.slice(1,-1);let l=a.toLowerCase();if(l.length<=9&&l in Ie)return Ie[l];if(!jr.test(a)){if(r)throw new SyntaxError("[better-json] Invalid JSON");return e}if(Object.entries($r).some(([u,i])=>{let c=i.test(a);return c&&s&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${u} pattern`),c})&&r)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(a,(u,i)=>{if(u==="__proto__"||u==="constructor"&&i&&typeof i=="object"&&"prototype"in i){s&&console.warn(`[better-json] Dropping "${u}" key to prevent prototype pollution`);return}if(n&&typeof i=="string"){let c=xr(i);if(c)return c}return o?o(u,i):i})}catch(u){if(r)throw u;return e}}function Cr(e,t={strict:!0}){return Ur(e,t)}var Lr={id:"redirect",name:"Redirect",hooks:{onSuccess(e){if(e.data?.url&&e.data?.redirect&&typeof window<"u"&&window.location&&window.location)try{window.location.href=e.data.url}catch{}}}};function Dr(e){let t=wt(!1);return{session:Ar(t,"/get-session",e,{method:"GET"}),$sessionSignal:t}}var Br=(e,t)=>{let r="credentials"in Request.prototype,s=br(e?.baseURL,e?.basePath,void 0,t)??"/api/auth",o=e?.plugins?.flatMap(d=>d.fetchPlugins).filter(d=>d!==void 0)||[],n={id:"lifecycle-hooks",name:"lifecycle-hooks",hooks:{onSuccess:e?.fetchOptions?.onSuccess,onError:e?.fetchOptions?.onError,onRequest:e?.fetchOptions?.onRequest,onResponse:e?.fetchOptions?.onResponse}},{onSuccess:a,onError:l,onRequest:u,onResponse:i,...c}=e?.fetchOptions||{},h=cr({baseURL:s,...r?{credentials:"include"}:{},method:"GET",jsonParser(d){return d?Cr(d,{strict:!1}):null},customFetchImpl:fetch,...c,plugins:[n,...c.plugins||[],...e?.disableDefaultFetchPlugins?[]:[Lr],...o]}),{$sessionSignal:m,session:f}=Dr(h),y=e?.plugins||[],v={},g={$sessionSignal:m,session:f},w={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},T=[{signal:"$sessionSignal",matcher(d){return d==="/sign-out"||d==="/update-user"||d.startsWith("/sign-in")||d.startsWith("/sign-up")||d==="/delete-user"||d==="/verify-email"}}];for(let d of y)d.getAtoms&&Object.assign(g,d.getAtoms?.(h)),d.pathMethods&&Object.assign(w,d.pathMethods),d.atomListeners&&T.push(...d.atomListeners);let P={notify:d=>{g[d].set(!g[d].get())},listen:(d,L)=>{g[d].subscribe(L)},atoms:g};for(let d of y)d.getActions&&Object.assign(v,d.getActions?.(h,P,e));return{get baseURL(){return s},pluginsActions:v,pluginsAtoms:g,pluginPathMethods:w,atomListeners:T,$fetch:h,$store:P}};function kr(e){return typeof e=="object"&&e!==null&&"get"in e&&typeof e.get=="function"&&"lc"in e&&typeof e.lc=="number"}function Mr(e,t,r){let s=t[e],{fetchOptions:o,query:n,...a}=r||{};return s||(o?.method?o.method:a&&Object.keys(a).length>0?"POST":"GET")}function Fr(e,t,r,s,o){function n(a=[]){return new Proxy(function(){},{get(l,u){if(typeof u!="string"||u==="then"||u==="catch"||u==="finally")return;let i=[...a,u],c=e;for(let h of i)if(c&&typeof c=="object"&&h in c)c=c[h];else{c=void 0;break}return typeof c=="function"||kr(c)?c:n(i)},apply:async(l,u,i)=>{let c="/"+a.map(T=>T.replace(/[A-Z]/g,P=>`-${P.toLowerCase()}`)).join("/"),h=i[0]||{},m=i[1]||{},{query:f,fetchOptions:y,...v}=h,g={...m,...y},w=Mr(c,r,h);return await t(c,{...g,body:w==="GET"?void 0:{...v,...g?.body||{}},query:f||g?.query,method:w,async onSuccess(T){if(await g?.onSuccess?.(T),!o)return;let P=o.filter(d=>d.matcher(c));if(P.length)for(let d of P){let L=s[d.signal];if(!L)return;let _=L.get();setTimeout(()=>{L.set(!_)},10)}}})}})}return n()}p();function Hr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function qr(e){let{pluginPathMethods:t,pluginsActions:r,pluginsAtoms:s,$fetch:o,atomListeners:n,$store:a}=Br(e),l={};for(let[i,c]of Object.entries(s))l[`use${Hr(i)}`]=c;let u={...r,...l,$fetch:o,$store:a};return Fr(u,o,t,s,n)}p();p();p();function Gr(e){return{authorize(t,r="AND"){let s=!1;for(let[o,n]of Object.entries(t)){let a=e[o];if(!a)return{success:!1,error:`You are not allowed to access resource: ${o}`};if(Array.isArray(n))s=n.every(l=>a.includes(l));else if(typeof n=="object"){let l=n;l.connector==="OR"?s=l.actions.some(u=>a.includes(u)):s=l.actions.every(u=>a.includes(u))}else throw new ve("Invalid access control request");if(s&&r==="OR")return{success:s};if(!s&&r==="AND")return{success:!1,error:`unauthorized to access resource "${o}"`}}return s?{success:s}:{success:!1,error:"Not authorized"}},statements:e}}function bt(e){return{newRole(t){return Gr(t)},statements:e}}var Wr={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},we=bt(Wr),fs=we.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),ps=we.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),ds=we.newRole({organization:[],member:[],invitation:[],team:[],ac:["read"]});p();p();p();p();p();p();p();p();p();p();p();var zr=class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let t=new Error("Cancelling existing WebAuthn API call for new one");t.name="AbortError",this.controller.abort(t)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}},ms=new zr;p();p();p();p();p();p();p();p();var Kr={user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]},_t=bt(Kr),ys=_t.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),gs=_t.newRole({user:[],session:[]});p();p();var Vr=()=>({id:"username",$InferServerPlugin:{}}),Yr=()=>({id:"phoneNumber",$InferServerPlugin:{},atomListeners:[{matcher(e){return e==="/phone-number/update"||e==="/phone-number/verify"},signal:"$sessionSignal"}]}),Jr=()=>({id:"better-auth-client",$InferServerPlugin:{}}),Xr="/auth",ie="nvwa_login_token",le="nvwa_current_jwt",ue="nvwa_user_profile",Et=class{constructor(e,t,r){this.storage=r;let s=qr({baseURL:e,basePath:Xr,plugins:[Vr(),Yr(),Jr()],fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:async()=>{let o=await this.storage.get(le);if(console.log("jwt",o),o)return o;let n=await this.storage.get(ie);return console.log("loginToken",n),n}}}});this.authClient=s}async currentUser(){return await this.storage.get(ue)}async getCurrentJwt(){return await this.storage.get(le)}async signUp(e){let t=await this.authClient.signUp.email({email:e.email??`${e.username}@nvwa.app`,name:e.name,username:e.username,displayUsername:e.displayUsername,password:e.password});this.handleLogin(t)}async sendPhoneNumberCode(e){await this.authClient.phoneNumber.sendOtp({phoneNumber:e})}async signInWithPhoneNumberCode(e,t){let r=await this.authClient.phoneNumber.verify({phoneNumber:e,code:t});this.handleLogin(r)}async signInWithPhoneNumber(e,t,r=!1){let s=await this.authClient.signIn.phoneNumber({phoneNumber:e,password:t,rememberMe:r});this.handleLogin(s)}async signInWithUsername(e,t){let r=await this.authClient.signIn.username({username:e,password:t});this.handleLogin(r)}async handleLogin(e){if(e.error)throw new Error(e.error.message);await this.storage.set(ie,e.data?.token),await this.storage.set(ue,e.data?.user);let{data:t,error:r}=await this.authClient.token();if(r)throw new Error(r.message);await this.storage.set(le,t.token)}async signOut(){await this.storage.remove(ie),await this.storage.remove(ue)}async updateUserPassword(e,t,r=!1){let s=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:r});this.handleLogin(s)}};p();var Ot=class{constructor(e){this.http=e}async invoke(e,t){return await(await this.http.fetch("/functions/"+e,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};p();var Tt=class{constructor(e,t){this.customFetch=e,this.handleUnauthorized=t}async fetch(e,t){return await this.customFetch(e,t)}async fetchWithAuth(e,t){let r=await this.customFetch(e,t);if(r.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return r}};p();p();p();var C=class Pt{constructor(t){if(this.headerMap=new Map,t){if(t instanceof Pt)t.forEach((r,s)=>this.set(s,r));else if(Array.isArray(t))for(let[r,s]of t)this.set(r,String(s));else if(typeof t=="object")for(let r of Object.keys(t))this.set(r,String(t[r]))}}append(t,r){let s=t.toLowerCase(),o=this.headerMap.get(s);this.headerMap.set(s,o?`${o}, ${r}`:r)}set(t,r){this.headerMap.set(t.toLowerCase(),String(r))}get(t){return this.headerMap.get(t.toLowerCase())??null}has(t){return this.headerMap.has(t.toLowerCase())}delete(t){this.headerMap.delete(t.toLowerCase())}forEach(t){for(let[r,s]of this.headerMap.entries())t(s,r,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},St=class Rt{constructor(t){if(this.params=new Map,t){if(typeof t=="string")this.parseString(t);else if(t instanceof Rt)this.params=new Map(t.params);else if(Array.isArray(t))for(let[r,s]of t)this.append(r,s);else if(t&&typeof t=="object")for(let[r,s]of Object.entries(t))this.set(r,s)}}parseString(t){t.startsWith("?")&&(t=t.slice(1));let r=t.split("&");for(let s of r)if(s){let[o,n]=s.split("=");o&&this.append(decodeURIComponent(o),n?decodeURIComponent(n):"")}}append(t,r){let s=this.params.get(t)||[];s.push(r),this.params.set(t,s)}delete(t){this.params.delete(t)}get(t){let r=this.params.get(t);return r?r[0]:null}getAll(t){return this.params.get(t)||[]}has(t){return this.params.has(t)}set(t,r){this.params.set(t,[r])}sort(){let t=Array.from(this.params.entries()).sort(([r],[s])=>r.localeCompare(s));this.params=new Map(t)}toString(){let t=[];for(let[r,s]of this.params.entries())for(let o of s)t.push(`${encodeURIComponent(r)}=${encodeURIComponent(o)}`);return t.join("&")}forEach(t){for(let[r,s]of this.params.entries())for(let o of s)t(o,r,this)}keys(){return this.params.keys()}values(){let t=[];for(let r of this.params.values())t.push(...r);return t[Symbol.iterator]()}entries(){let t=[];for(let[r,s]of this.params.entries())for(let o of s)t.push([r,o]);return t[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},Qr=class pe{constructor(t,r){let s;if(t instanceof pe)s=t.href;else if(r){let n=r instanceof pe?r.href:r;s=this.resolve(n,t)}else s=t;let o=this.parseUrl(s);this.href=s,this.origin=`${o.protocol}//${o.host}`,this.protocol=o.protocol,this.username=o.username,this.password=o.password,this.host=o.host,this.hostname=o.hostname,this.port=o.port,this.pathname=o.pathname,this.search=o.search,this.searchParams=new St(o.search),this.hash=o.hash}resolve(t,r){if(r.startsWith("http://")||r.startsWith("https://"))return r;if(r.startsWith("//"))return`${this.parseUrl(t).protocol}${r}`;if(r.startsWith("/")){let n=this.parseUrl(t);return`${n.protocol}//${n.host}${r}`}let s=this.parseUrl(t),o=s.pathname.endsWith("/")?s.pathname:s.pathname+"/";return`${s.protocol}//${s.host}${o}${r}`}parseUrl(t){let r=t.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!r)throw new TypeError("Invalid URL");let s=r[2]||"",o=r[4]||"",n=r[5]||"/",a=r[7]?`?${r[7]}`:"",l=r[9]?`#${r[9]}`:"";if(!s&&!o&&!n.startsWith("/")&&!n.includes("/")&&!n.includes("."))throw new TypeError("Invalid URL");let u=o.match(/^([^@]*)@(.+)$/),i="",c="",h=o;if(u){let v=u[1];h=u[2];let g=v.match(/^([^:]*):?(.*)$/);g&&(i=g[1]||"",c=g[2]||"")}let m=h.match(/^([^:]+):?(\d*)$/),f=m?m[1]:h,y=m&&m[2]?m[2]:"";return{protocol:s?`${s}:`:"",username:i,password:c,host:h,hostname:f,port:y,pathname:n,search:a,hash:l}}toString(){let t=this.searchParams.toString(),r=t?`?${t}`:"";return`${this.protocol}//${this.host}${this.pathname}${r}${this.hash}`}toJSON(){return this.toString()}};p();var Zr=class At{constructor(t,r){if(typeof t=="string")this.url=t;else if(t?.url)this.url=String(t.url);else if(typeof t?.toString=="function")this.url=String(t.toString());else throw new Error("Invalid input for Request");this.method=(r?.method||"GET").toUpperCase(),this.headers=r?.headers instanceof C?r.headers:new C(r?.headers),this.body=r?.body,this.timeout=r?.timeout,this.signal=r?.signal||void 0}clone(){return new At(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};p();var be=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=es(t?.headers),this.ok=this.status>=200&&this.status<300}async text(){return typeof this.bodyData=="string"?this.bodyData:this.bodyData==null?"":typeof this.bodyData=="object"?JSON.stringify(this.bodyData):String(this.bodyData)}async json(){if(typeof this.bodyData=="string")try{return JSON.parse(this.bodyData)}catch{}return this.bodyData}async arrayBuffer(){let e=await this.text();return new TextEncoder().encode(e).buffer}};function es(e){return e?new C(e):new C}p();var $t=class{constructor(){this._aborted=!1,this.listeners=new Set,this.onabort=null}get aborted(){return this._aborted}_trigger(){if(!this._aborted){if(this._aborted=!0,typeof this.onabort=="function")try{this.onabort()}catch{}for(let e of Array.from(this.listeners))try{e()}catch{}this.listeners.clear()}}addEventListener(e,t){if(this._aborted){try{t()}catch{}return}this.listeners.add(t)}removeEventListener(e,t){this.listeners.delete(t)}toString(){return"[object AbortSignal]"}},ts=class{constructor(){this._signal=new $t}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};p();function rs(e){e.URL=Qr,e.URLSearchParams=St,e.Headers=C,e.Request=Zr,e.Response=be,e.AbortController=ts,e.AbortSignal=$t}var ss="/storage",ns=ss+"/generateUploadUrl",jt=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+ns,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:r}=await t.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(r,{method:"PUT",body:e,headers:new C({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:o}=await s.json();return{url:o.split("?")[0]}}};p();p();p();var Ne=Mt(Ht(),1),{PostgrestClient:os,PostgrestQueryBuilder:vs,PostgrestFilterBuilder:ws,PostgrestTransformBuilder:bs,PostgrestBuilder:_s,PostgrestError:Es}=Ne.default||Ne,as="/entities",It=(e,t)=>new os(e+as,{fetch:t.fetchWithAuth});var oe=class{constructor(){this.prefix="nvwa_"}getKey(t){return`${this.prefix}${t}`}async get(t){try{let r=this.getKey(t),s=uni.getStorageSync(r);return s?s.expires&&Date.now()>s.expires?(await this.remove(t),null):s.value:null}catch(r){return console.error("UniAppStorageService get error:",r),null}}async set(t,r,s){try{let o=this.getKey(t),n={value:r,expires:s?Date.now()+s*1e3:null,timestamp:Date.now()};uni.setStorageSync(o,n)}catch(o){throw console.error("UniAppStorageService set error:",o),o}}async remove(t){try{let r=this.getKey(t);uni.removeStorageSync(r)}catch(r){throw console.error("UniAppStorageService remove error:",r),r}}async clear(){try{uni.clearStorageSync()}catch(t){throw console.error("UniAppStorageService clear error:",t),t}}};var is=(e,t)=>{let r;if(typeof e=="string")r=e;else if(e&&typeof e.toString=="function")r=e.toString();else if(e?.url)r=e.url;else throw new Error("Invalid input for uniappFetch");let s=(t?.method||"GET").toUpperCase(),o={};if(t?.headers){let l=t.headers;if(typeof l?.forEach=="function")l.forEach((u,i)=>{o[i]=u});else if(Array.isArray(l))for(let[u,i]of l)o[u]=i;else Object.assign(o,l)}let n;if(t?.body!==void 0){let l=t.body;if(typeof l=="string")n=l;else if(l&&typeof l=="object"&&typeof l.forEach=="function"){let u={};l.forEach((i,c)=>{u[c]=i}),n=u}else n=l}let a=t?.timeout||3e4;return new Promise((l,u)=>{let i=t?.signal;if(i?.aborted){let f=new Error("The operation was aborted");f.name="AbortError",u(f);return}let c=!1,h=[],m=uni.request({url:r,method:s,data:n,header:o,timeout:a,success:f=>{if(c)return;c=!0;let y=f.statusCode,v="",g=new C,w=f.header||f.headers||{};Object.keys(w).forEach(T=>{let P=w[T];g.set(T,typeof P=="string"?P:String(P))}),l(new be(f.data,{status:y,statusText:v,headers:g}))},fail:f=>{if(c)return;c=!0;let y=f?.errMsg||f?.message||"Network Error",v=new Error(y);/(abort|aborted|canceled|cancelled)/i.test(String(y))&&(v.name="AbortError"),u(v)}});if(i&&typeof i.addEventListener=="function"){let f=()=>{if(c)return;try{m?.abort?.()}catch{}let y=new Error("The operation was aborted");y.name="AbortError",c=!0,u(y)};i.addEventListener("abort",f),h.push(()=>{try{i.removeEventListener?.("abort",f)}catch{}})}})},_e=is;var ls=new oe,Ee=class{constructor(t,r){this.auth=new Et(t,_e,ls),this.httpClient=new Tt(_e,r),this.fileStorage=new jt(t,this.httpClient),this.entities=It(t,this.httpClient),this.functions=new Ot(this.httpClient)}};export{Ee as default,ls as localStorage,rs as polyfill};
1
+ var Ct=Object.create,oe=Object.defineProperty,Lt=Object.getOwnPropertyDescriptor,Dt=Object.getOwnPropertyNames,Bt=Object.getPrototypeOf,kt=Object.prototype.hasOwnProperty,xe=(e,t)=>()=>(e&&(t=e(e=0)),t),D=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Mt=(e,t)=>{for(var r in t)oe(e,r,{get:t[r],enumerable:!0})},Ue=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Dt(t))!kt.call(e,n)&&n!==r&&oe(e,n,{get:()=>t[n],enumerable:!(s=Lt(t,n))||s.enumerable});return e},Ft=(e,t,r)=>(r=e!=null?Ct(Bt(e)):{},Ue(t||!e||!e.__esModule?oe(r,"default",{value:e,enumerable:!0}):r,e)),q=e=>Ue(oe({},"__esModule",{value:!0}),e),p=xe(()=>{"use strict"}),B={};Mt(B,{__addDisposableResource:()=>ot,__assign:()=>V,__asyncDelegator:()=>Xe,__asyncGenerator:()=>Je,__asyncValues:()=>Qe,__await:()=>H,__awaiter:()=>Ge,__classPrivateFieldGet:()=>rt,__classPrivateFieldIn:()=>nt,__classPrivateFieldSet:()=>st,__createBinding:()=>Y,__decorate:()=>De,__disposeResources:()=>at,__esDecorate:()=>ke,__exportStar:()=>ze,__extends:()=>Ce,__generator:()=>We,__importDefault:()=>tt,__importStar:()=>et,__makeTemplateObject:()=>Ze,__metadata:()=>qe,__param:()=>Be,__propKey:()=>Fe,__read:()=>ye,__rest:()=>Le,__rewriteRelativeImportExtension:()=>it,__runInitializers:()=>Me,__setFunctionName:()=>He,__spread:()=>Ke,__spreadArray:()=>Ye,__spreadArrays:()=>Ve,__values:()=>ne,default:()=>ct});function Ce(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");Z(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function Le(e,t){var r={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(e);n<s.length;n++)t.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(e,s[n])&&(r[s[n]]=e[s[n]]);return r}function De(e,t,r,s){var n=arguments.length,o=n<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,r):s,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")o=Reflect.decorate(e,t,r,s);else for(var l=e.length-1;l>=0;l--)(a=e[l])&&(o=(n<3?a(o):n>3?a(t,r,o):a(t,r))||o);return n>3&&o&&Object.defineProperty(t,r,o),o}function Be(e,t){return function(r,s){t(r,s,e)}}function ke(e,t,r,s,n,o){function a(w){if(w!==void 0&&typeof w!="function")throw new TypeError("Function expected");return w}for(var l=s.kind,u=l==="getter"?"get":l==="setter"?"set":"value",i=!t&&e?s.static?e:e.prototype:null,c=t||(i?Object.getOwnPropertyDescriptor(i,s.name):{}),h,m=!1,f=r.length-1;f>=0;f--){var y={};for(var v in s)y[v]=v==="access"?{}:s[v];for(var v in s.access)y.access[v]=s.access[v];y.addInitializer=function(w){if(m)throw new TypeError("Cannot add initializers after decoration has completed");o.push(a(w||null))};var g=(0,r[f])(l==="accessor"?{get:c.get,set:c.set}:c[u],y);if(l==="accessor"){if(g===void 0)continue;if(g===null||typeof g!="object")throw new TypeError("Object expected");(h=a(g.get))&&(c.get=h),(h=a(g.set))&&(c.set=h),(h=a(g.init))&&n.unshift(h)}else(h=a(g))&&(l==="field"?n.unshift(h):c[u]=h)}i&&Object.defineProperty(i,s.name,c),m=!0}function Me(e,t,r){for(var s=arguments.length>2,n=0;n<t.length;n++)r=s?t[n].call(e,r):t[n].call(e);return s?r:void 0}function Fe(e){return typeof e=="symbol"?e:"".concat(e)}function He(e,t,r){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function qe(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function Ge(e,t,r,s){function n(o){return o instanceof r?o:new r(function(a){a(o)})}return new(r||(r=Promise))(function(o,a){function l(c){try{i(s.next(c))}catch(h){a(h)}}function u(c){try{i(s.throw(c))}catch(h){a(h)}}function i(c){c.done?o(c.value):n(c.value).then(l,u)}i((s=s.apply(e,t||[])).next())})}function We(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},s,n,o,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=l(0),a.throw=l(1),a.return=l(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function l(i){return function(c){return u([i,c])}}function u(i){if(s)throw new TypeError("Generator is already executing.");for(;a&&(a=0,i[0]&&(r=0)),r;)try{if(s=1,n&&(o=i[0]&2?n.return:i[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,i[1])).done)return o;switch(n=0,o&&(i=[i[0]&2,o.value]),i[0]){case 0:case 1:o=i;break;case 4:return r.label++,{value:i[1],done:!1};case 5:r.label++,n=i[1],i=[0];continue;case 7:i=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!o||i[1]>o[0]&&i[1]<o[3])){r.label=i[1];break}if(i[0]===6&&r.label<o[1]){r.label=o[1],o=i;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(i);break}o[2]&&r.ops.pop(),r.trys.pop();continue}i=t.call(e,r)}catch(c){i=[6,c],n=0}finally{s=o=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}function ze(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&Y(t,e,r)}function ne(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],s=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&s>=e.length&&(e=void 0),{value:e&&e[s++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function ye(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var s=r.call(e),n,o=[],a;try{for(;(t===void 0||t-- >0)&&!(n=s.next()).done;)o.push(n.value)}catch(l){a={error:l}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(a)throw a.error}}return o}function Ke(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(ye(arguments[t]));return e}function Ve(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var s=Array(e),n=0,t=0;t<r;t++)for(var o=arguments[t],a=0,l=o.length;a<l;a++,n++)s[n]=o[a];return s}function Ye(e,t,r){if(r||arguments.length===2)for(var s=0,n=t.length,o;s<n;s++)(o||!(s in t))&&(o||(o=Array.prototype.slice.call(t,0,s)),o[s]=t[s]);return e.concat(o||Array.prototype.slice.call(t))}function H(e){return this instanceof H?(this.v=e,this):new H(e)}function Je(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r.apply(e,t||[]),n,o=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),l("next"),l("throw"),l("return",a),n[Symbol.asyncIterator]=function(){return this},n;function a(f){return function(y){return Promise.resolve(y).then(f,h)}}function l(f,y){s[f]&&(n[f]=function(v){return new Promise(function(g,w){o.push([f,v,g,w])>1||u(f,v)})},y&&(n[f]=y(n[f])))}function u(f,y){try{i(s[f](y))}catch(v){m(o[0][3],v)}}function i(f){f.value instanceof H?Promise.resolve(f.value.v).then(c,h):m(o[0][2],f)}function c(f){u("next",f)}function h(f){u("throw",f)}function m(f,y){f(y),o.shift(),o.length&&u(o[0][0],o[0][1])}}function Xe(e){var t,r;return t={},s("next"),s("throw",function(n){throw n}),s("return"),t[Symbol.iterator]=function(){return this},t;function s(n,o){t[n]=e[n]?function(a){return(r=!r)?{value:H(e[n](a)),done:!1}:o?o(a):a}:o}}function Qe(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof ne=="function"?ne(e):e[Symbol.iterator](),r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r);function s(o){r[o]=e[o]&&function(a){return new Promise(function(l,u){a=e[o](a),n(l,u,a.done,a.value)})}}function n(o,a,l,u){Promise.resolve(u).then(function(i){o({value:i,done:l})},a)}}function Ze(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function et(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=ee(e),s=0;s<r.length;s++)r[s]!=="default"&&Y(t,e,r[s]);return lt(t,e),t}function tt(e){return e&&e.__esModule?e:{default:e}}function rt(e,t,r,s){if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?s:r==="a"?s.call(e):s?s.value:t.get(e)}function st(e,t,r,s,n){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?n.call(e,r):n?n.value=r:t.set(e,r),r}function nt(e,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof e=="function"?t===e:e.has(t)}function ot(e,t,r){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var s,n;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=t[Symbol.asyncDispose]}if(s===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=t[Symbol.dispose],r&&(n=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");n&&(s=function(){try{n.call(this)}catch(o){return Promise.reject(o)}}),e.stack.push({value:t,dispose:s,async:r})}else r&&e.stack.push({async:!0});return t}function at(e){function t(o){e.error=e.hasError?new ut(o,e.error,"An error was suppressed during disposal."):o,e.hasError=!0}var r,s=0;function n(){for(;r=e.stack.pop();)try{if(!r.async&&s===1)return s=0,e.stack.push(r),Promise.resolve().then(n);if(r.dispose){var o=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(o).then(n,function(a){return t(a),n()})}else s|=1}catch(a){t(a)}if(s===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return n()}function it(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,s,n,o,a){return s?t?".jsx":".js":n&&(!o||!a)?r:n+o+"."+a.toLowerCase()+"js"}):e}var Z,V,Y,lt,ee,ut,ct,G=xe(()=>{"use strict";p(),Z=function(e,t){return Z=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,s){r.__proto__=s}||function(r,s){for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&(r[n]=s[n])},Z(e,t)},V=function(){return V=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++){t=arguments[r];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},V.apply(this,arguments)},Y=Object.create?(function(e,t,r,s){s===void 0&&(s=r);var n=Object.getOwnPropertyDescriptor(t,r);(!n||("get"in n?!t.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,n)}):(function(e,t,r,s){s===void 0&&(s=r),e[s]=t[r]}),lt=Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t},ee=function(e){return ee=Object.getOwnPropertyNames||function(t){var r=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[r.length]=s);return r},ee(e)},ut=typeof SuppressedError=="function"?SuppressedError:function(e,t,r){var s=new Error(r);return s.name="SuppressedError",s.error=e,s.suppressed=t,s},ct={__extends:Ce,__assign:V,__rest:Le,__decorate:De,__param:Be,__esDecorate:ke,__runInitializers:Me,__propKey:Fe,__setFunctionName:He,__metadata:qe,__awaiter:Ge,__generator:We,__createBinding:Y,__exportStar:ze,__values:ne,__read:ye,__spread:Ke,__spreadArrays:Ve,__spreadArray:Ye,__await:H,__asyncGenerator:Je,__asyncDelegator:Xe,__asyncValues:Qe,__makeTemplateObject:Ze,__importStar:et,__importDefault:tt,__classPrivateFieldGet:rt,__classPrivateFieldSet:st,__classPrivateFieldIn:nt,__addDisposableResource:ot,__disposeResources:at,__rewriteRelativeImportExtension:it}}),ht=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}};e.default=t}),ft=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(B)),r=t.__importDefault(ht()),s=class{constructor(n){var o,a;this.shouldThrowOnError=!1,this.method=n.method,this.url=n.url,this.headers=new Headers(n.headers),this.schema=n.schema,this.body=n.body,this.shouldThrowOnError=(o=n.shouldThrowOnError)!==null&&o!==void 0?o:!1,this.signal=n.signal,this.isMaybeSingle=(a=n.isMaybeSingle)!==null&&a!==void 0?a:!1,n.fetch?this.fetch=n.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(n,o){return this.headers=new Headers(this.headers),this.headers.set(n,o),this}then(n,o){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let a=this.fetch,l=a(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async u=>{var i,c,h,m;let f=null,y=null,v=null,g=u.status,w=u.statusText;if(u.ok){if(this.method!=="HEAD"){let d=await u.text();d===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&!((i=this.headers.get("Accept"))===null||i===void 0)&&i.includes("application/vnd.pgrst.plan+text")?y=d:y=JSON.parse(d))}let O=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),P=(h=u.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");O&&P&&P.length>1&&(v=parseInt(P[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(y)&&(y.length>1?(f={code:"PGRST116",details:`Results contain ${y.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},y=null,v=null,g=406,w="Not Acceptable"):y.length===1?y=y[0]:y=null)}else{let O=await u.text();try{f=JSON.parse(O),Array.isArray(f)&&u.status===404&&(y=[],f=null,g=200,w="OK")}catch{u.status===404&&O===""?(g=204,w="No Content"):f={message:O}}if(f&&this.isMaybeSingle&&!((m=f?.details)===null||m===void 0)&&m.includes("0 rows")&&(f=null,g=200,w="OK"),f&&this.shouldThrowOnError)throw new r.default(f)}return{error:f,data:y,count:v,status:g,statusText:w}});return this.shouldThrowOnError||(l=l.catch(u=>{var i,c,h;return{error:{message:`${(i=u?.name)!==null&&i!==void 0?i:"FetchError"}: ${u?.message}`,details:`${(c=u?.stack)!==null&&c!==void 0?c:""}`,hint:"",code:`${(h=u?.code)!==null&&h!==void 0?h:""}`},data:null,count:null,status:0,statusText:""}})),l.then(n,o)}returns(){return this}overrideTypes(){return this}};e.default=s}),pt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(B)),r=t.__importDefault(ft()),s=class extends r.default{select(n){let o=!1,a=(n??"*").split("").map(l=>/\s/.test(l)&&!o?"":(l==='"'&&(o=!o),l)).join("");return this.url.searchParams.set("select",a),this.headers.append("Prefer","return=representation"),this}order(n,{ascending:o=!0,nullsFirst:a,foreignTable:l,referencedTable:u=l}={}){let i=u?`${u}.order`:"order",c=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${c?`${c},`:""}${n}.${o?"asc":"desc"}${a===void 0?"":a?".nullsfirst":".nullslast"}`),this}limit(n,{foreignTable:o,referencedTable:a=o}={}){let l=typeof a>"u"?"limit":`${a}.limit`;return this.url.searchParams.set(l,`${n}`),this}range(n,o,{foreignTable:a,referencedTable:l=a}={}){let u=typeof l>"u"?"offset":`${l}.offset`,i=typeof l>"u"?"limit":`${l}.limit`;return this.url.searchParams.set(u,`${n}`),this.url.searchParams.set(i,`${o-n+1}`),this}abortSignal(n){return this.signal=n,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:n=!1,verbose:o=!1,settings:a=!1,buffers:l=!1,wal:u=!1,format:i="text"}={}){var c;let h=[n?"analyze":null,o?"verbose":null,a?"settings":null,l?"buffers":null,u?"wal":null].filter(Boolean).join("|"),m=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${m}"; options=${h};`),i==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(n){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${n}`),this}};e.default=s}),ge=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(B)),r=t.__importDefault(pt()),s=new RegExp("[,()]"),n=class extends r.default{eq(o,a){return this.url.searchParams.append(o,`eq.${a}`),this}neq(o,a){return this.url.searchParams.append(o,`neq.${a}`),this}gt(o,a){return this.url.searchParams.append(o,`gt.${a}`),this}gte(o,a){return this.url.searchParams.append(o,`gte.${a}`),this}lt(o,a){return this.url.searchParams.append(o,`lt.${a}`),this}lte(o,a){return this.url.searchParams.append(o,`lte.${a}`),this}like(o,a){return this.url.searchParams.append(o,`like.${a}`),this}likeAllOf(o,a){return this.url.searchParams.append(o,`like(all).{${a.join(",")}}`),this}likeAnyOf(o,a){return this.url.searchParams.append(o,`like(any).{${a.join(",")}}`),this}ilike(o,a){return this.url.searchParams.append(o,`ilike.${a}`),this}ilikeAllOf(o,a){return this.url.searchParams.append(o,`ilike(all).{${a.join(",")}}`),this}ilikeAnyOf(o,a){return this.url.searchParams.append(o,`ilike(any).{${a.join(",")}}`),this}is(o,a){return this.url.searchParams.append(o,`is.${a}`),this}in(o,a){let l=Array.from(new Set(a)).map(u=>typeof u=="string"&&s.test(u)?`"${u}"`:`${u}`).join(",");return this.url.searchParams.append(o,`in.(${l})`),this}contains(o,a){return typeof a=="string"?this.url.searchParams.append(o,`cs.${a}`):Array.isArray(a)?this.url.searchParams.append(o,`cs.{${a.join(",")}}`):this.url.searchParams.append(o,`cs.${JSON.stringify(a)}`),this}containedBy(o,a){return typeof a=="string"?this.url.searchParams.append(o,`cd.${a}`):Array.isArray(a)?this.url.searchParams.append(o,`cd.{${a.join(",")}}`):this.url.searchParams.append(o,`cd.${JSON.stringify(a)}`),this}rangeGt(o,a){return this.url.searchParams.append(o,`sr.${a}`),this}rangeGte(o,a){return this.url.searchParams.append(o,`nxl.${a}`),this}rangeLt(o,a){return this.url.searchParams.append(o,`sl.${a}`),this}rangeLte(o,a){return this.url.searchParams.append(o,`nxr.${a}`),this}rangeAdjacent(o,a){return this.url.searchParams.append(o,`adj.${a}`),this}overlaps(o,a){return typeof a=="string"?this.url.searchParams.append(o,`ov.${a}`):this.url.searchParams.append(o,`ov.{${a.join(",")}}`),this}textSearch(o,a,{config:l,type:u}={}){let i="";u==="plain"?i="pl":u==="phrase"?i="ph":u==="websearch"&&(i="w");let c=l===void 0?"":`(${l})`;return this.url.searchParams.append(o,`${i}fts${c}.${a}`),this}match(o){return Object.entries(o).forEach(([a,l])=>{this.url.searchParams.append(a,`eq.${l}`)}),this}not(o,a,l){return this.url.searchParams.append(o,`not.${a}.${l}`),this}or(o,{foreignTable:a,referencedTable:l=a}={}){let u=l?`${l}.or`:"or";return this.url.searchParams.append(u,`(${o})`),this}filter(o,a,l){return this.url.searchParams.append(o,`${a}.${l}`),this}};e.default=n}),dt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(B)),r=t.__importDefault(ge()),s=class{constructor(n,{headers:o={},schema:a,fetch:l}){this.url=n,this.headers=new Headers(o),this.schema=a,this.fetch=l}select(n,o){let{head:a=!1,count:l}=o??{},u=a?"HEAD":"GET",i=!1,c=(n??"*").split("").map(h=>/\s/.test(h)&&!i?"":(h==='"'&&(i=!i),h)).join("");return this.url.searchParams.set("select",c),l&&this.headers.append("Prefer",`count=${l}`),new r.default({method:u,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(n,{count:o,defaultToNull:a=!0}={}){var l;let u="POST";if(o&&this.headers.append("Prefer",`count=${o}`),a||this.headers.append("Prefer","missing=default"),Array.isArray(n)){let i=n.reduce((c,h)=>c.concat(Object.keys(h)),[]);if(i.length>0){let c=[...new Set(i)].map(h=>`"${h}"`);this.url.searchParams.set("columns",c.join(","))}}return new r.default({method:u,url:this.url,headers:this.headers,schema:this.schema,body:n,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}upsert(n,{onConflict:o,ignoreDuplicates:a=!1,count:l,defaultToNull:u=!0}={}){var i;let c="POST";if(this.headers.append("Prefer",`resolution=${a?"ignore":"merge"}-duplicates`),o!==void 0&&this.url.searchParams.set("on_conflict",o),l&&this.headers.append("Prefer",`count=${l}`),u||this.headers.append("Prefer","missing=default"),Array.isArray(n)){let h=n.reduce((m,f)=>m.concat(Object.keys(f)),[]);if(h.length>0){let m=[...new Set(h)].map(f=>`"${f}"`);this.url.searchParams.set("columns",m.join(","))}}return new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:n,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}update(n,{count:o}={}){var a;let l="PATCH";return o&&this.headers.append("Prefer",`count=${o}`),new r.default({method:l,url:this.url,headers:this.headers,schema:this.schema,body:n,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}delete({count:n}={}){var o;let a="DELETE";return n&&this.headers.append("Prefer",`count=${n}`),new r.default({method:a,url:this.url,headers:this.headers,schema:this.schema,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}};e.default=s}),Ht=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0});var t=(G(),q(B)),r=t.__importDefault(dt()),s=t.__importDefault(ge()),n=class mt{constructor(a,{headers:l={},schema:u,fetch:i}={}){this.url=a,this.headers=new Headers(l),this.schemaName=u,this.fetch=i}from(a){let l=new URL(`${this.url}/${a}`);return new r.default(l,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(a){return new mt(this.url,{headers:this.headers,schema:a,fetch:this.fetch})}rpc(a,l={},{head:u=!1,get:i=!1,count:c}={}){var h;let m,f=new URL(`${this.url}/rpc/${a}`),y;u||i?(m=u?"HEAD":"GET",Object.entries(l).filter(([g,w])=>w!==void 0).map(([g,w])=>[g,Array.isArray(w)?`{${w.join(",")}}`:`${w}`]).forEach(([g,w])=>{f.searchParams.append(g,w)})):(m="POST",y=l);let v=new Headers(this.headers);return c&&v.set("Prefer",`count=${c}`),new s.default({method:m,url:f,headers:v,schema:this.schemaName,body:y,fetch:(h=this.fetch)!==null&&h!==void 0?h:fetch})}};e.default=n}),qt=D(e=>{"use strict";p(),Object.defineProperty(e,"__esModule",{value:!0}),e.PostgrestError=e.PostgrestBuilder=e.PostgrestTransformBuilder=e.PostgrestFilterBuilder=e.PostgrestQueryBuilder=e.PostgrestClient=void 0;var t=(G(),q(B)),r=t.__importDefault(Ht());e.PostgrestClient=r.default;var s=t.__importDefault(dt());e.PostgrestQueryBuilder=s.default;var n=t.__importDefault(ge());e.PostgrestFilterBuilder=n.default;var o=t.__importDefault(pt());e.PostgrestTransformBuilder=o.default;var a=t.__importDefault(ft());e.PostgrestBuilder=a.default;var l=t.__importDefault(ht());e.PostgrestError=l.default,e.default={PostgrestClient:r.default,PostgrestQueryBuilder:s.default,PostgrestFilterBuilder:n.default,PostgrestTransformBuilder:o.default,PostgrestBuilder:a.default,PostgrestError:l.default}});p();p();p();p();p();p();var Gt=Object.defineProperty,Wt=Object.defineProperties,zt=Object.getOwnPropertyDescriptors,Pe=Object.getOwnPropertySymbols,Kt=Object.prototype.hasOwnProperty,Vt=Object.prototype.propertyIsEnumerable,Se=(e,t,r)=>t in e?Gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,j=(e,t)=>{for(var r in t||(t={}))Kt.call(t,r)&&Se(e,r,t[r]);if(Pe)for(var r of Pe(t))Vt.call(t,r)&&Se(e,r,t[r]);return e},I=(e,t)=>Wt(e,zt(t)),Yt=class extends Error{constructor(e,t,r){super(t||e.toString(),{cause:r}),this.status=e,this.statusText=t,this.error=r}},Jt=async(e,t)=>{var r,s,n,o,a,l;let u=t||{},i={onRequest:[t?.onRequest],onResponse:[t?.onResponse],onSuccess:[t?.onSuccess],onError:[t?.onError],onRetry:[t?.onRetry]};if(!t||!t?.plugins)return{url:e,options:u,hooks:i};for(let c of t?.plugins||[]){if(c.init){let h=await((r=c.init)==null?void 0:r.call(c,e.toString(),t));u=h.options||u,e=h.url}i.onRequest.push((s=c.hooks)==null?void 0:s.onRequest),i.onResponse.push((n=c.hooks)==null?void 0:n.onResponse),i.onSuccess.push((o=c.hooks)==null?void 0:o.onSuccess),i.onError.push((a=c.hooks)==null?void 0:a.onError),i.onRetry.push((l=c.hooks)==null?void 0:l.onRetry)}return{url:e,options:u,hooks:i}},Re=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(){return this.options.delay}},Xt=class{constructor(e){this.options=e}shouldAttemptRetry(e,t){return this.options.shouldRetry?Promise.resolve(e<this.options.attempts&&this.options.shouldRetry(t)):Promise.resolve(e<this.options.attempts)}getDelay(e){return Math.min(this.options.maxDelay,this.options.baseDelay*2**e)}};function Qt(e){if(typeof e=="number")return new Re({type:"linear",attempts:e,delay:1e3});switch(e.type){case"linear":return new Re(e);case"exponential":return new Xt(e);default:throw new Error("Invalid retry strategy")}}var Zt=async e=>{let t={},r=async s=>typeof s=="function"?await s():s;if(e?.auth){if(e.auth.type==="Bearer"){let s=await r(e.auth.token);if(!s)return t;t.authorization=`Bearer ${s}`}else if(e.auth.type==="Basic"){let s=r(e.auth.username),n=r(e.auth.password);if(!s||!n)return t;t.authorization=`Basic ${btoa(`${s}:${n}`)}`}else if(e.auth.type==="Custom"){let s=r(e.auth.value);if(!s)return t;t.authorization=`${r(e.auth.prefix)} ${s}`}}return t},er=/^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;function tr(e){let t=e.headers.get("content-type"),r=new Set(["image/svg","application/xml","application/xhtml","application/html"]);if(!t)return"json";let s=t.split(";").shift()||"";return er.test(s)?"json":r.has(s)||s.startsWith("text/")?"text":"blob"}function rr(e){try{return JSON.parse(e),!0}catch{return!1}}function yt(e){if(e===void 0)return!1;let t=typeof e;return t==="string"||t==="number"||t==="boolean"||t===null?!0:t!=="object"?!1:Array.isArray(e)?!0:e.buffer?!1:e.constructor&&e.constructor.name==="Object"||typeof e.toJSON=="function"}function Ae(e){try{return JSON.parse(e)}catch{return e}}function $e(e){return typeof e=="function"}function sr(e){if(e?.customFetchImpl)return e.customFetchImpl;if(typeof globalThis<"u"&&$e(globalThis.fetch))return globalThis.fetch;if(typeof window<"u"&&$e(window.fetch))return window.fetch;throw new Error("No fetch implementation found")}async function nr(e){let t=new Headers(e?.headers),r=await Zt(e);for(let[s,n]of Object.entries(r||{}))t.set(s,n);if(!t.has("content-type")){let s=or(e?.body);s&&t.set("content-type",s)}return t}function or(e){return yt(e)?"application/json":null}function ar(e){if(!e?.body)return null;let t=new Headers(e?.headers);if(yt(e.body)&&!t.has("content-type")){for(let[r,s]of Object.entries(e?.body))s instanceof Date&&(e.body[r]=s.toISOString());return JSON.stringify(e.body)}return e.body}function ir(e,t){var r;if(t?.method)return t.method.toUpperCase();if(e.startsWith("@")){let s=(r=e.split("@")[1])==null?void 0:r.split("/")[0];return vt.includes(s)?s.toUpperCase():t?.body?"POST":"GET"}return t?.body?"POST":"GET"}function lr(e,t){let r;return!e?.signal&&e?.timeout&&(r=setTimeout(()=>t?.abort(),e?.timeout)),{abortTimeout:r,clearTimeout:()=>{r&&clearTimeout(r)}}}var ur=class gt extends Error{constructor(t,r){super(r||JSON.stringify(t,null,2)),this.issues=t,Object.setPrototypeOf(this,gt.prototype)}};async function te(e,t){let r=await e["~standard"].validate(t);if(r.issues)throw new ur(r.issues);return r.value}var vt=["get","post","put","patch","delete"],cr=e=>({id:"apply-schema",name:"Apply Schema",version:"1.0.0",async init(t,r){var s,n,o,a;let l=((n=(s=e.plugins)==null?void 0:s.find(u=>{var i;return(i=u.schema)!=null&&i.config?t.startsWith(u.schema.config.baseURL||"")||t.startsWith(u.schema.config.prefix||""):!1}))==null?void 0:n.schema)||e.schema;if(l){let u=t;(o=l.config)!=null&&o.prefix&&u.startsWith(l.config.prefix)&&(u=u.replace(l.config.prefix,""),l.config.baseURL&&(t=t.replace(l.config.prefix,l.config.baseURL))),(a=l.config)!=null&&a.baseURL&&u.startsWith(l.config.baseURL)&&(u=u.replace(l.config.baseURL,""));let i=l.schema[u];if(i){let c=I(j({},r),{method:i.method,output:i.output});return r?.disableValidation||(c=I(j({},c),{body:i.input?await te(i.input,r?.body):r?.body,params:i.params?await te(i.params,r?.params):r?.params,query:i.query?await te(i.query,r?.query):r?.query})),{url:t,options:c}}}return{url:t,options:r}}}),hr=e=>{async function t(r,s){let n=I(j(j({},e),s),{plugins:[...e?.plugins||[],cr(e||{})]});if(e?.catchAllError)try{return await ce(r,n)}catch(o){return{data:null,error:{status:500,statusText:"Fetch Error",message:"Fetch related error. Captured by catchAllError option. See error property for more details.",error:o}}}return await ce(r,n)}return t};function fr(e,t){let{baseURL:r,params:s,query:n}=t||{query:{},params:{},baseURL:""},o=e.startsWith("http")?e.split("/").slice(0,3).join("/"):r||"";if(e.startsWith("@")){let c=e.toString().split("@")[1].split("/")[0];vt.includes(c)&&(e=e.replace(`@${c}/`,"/"))}o.endsWith("/")||(o+="/");let[a,l]=e.replace(o,"").split("?"),u=new URLSearchParams(l);for(let[c,h]of Object.entries(n||{}))h!=null&&u.set(c,String(h));if(s)if(Array.isArray(s)){let c=a.split("/").filter(h=>h.startsWith(":"));for(let[h,m]of c.entries()){let f=s[h];a=a.replace(m,f)}}else for(let[c,h]of Object.entries(s))a=a.replace(`:${c}`,String(h));a=a.split("/").map(encodeURIComponent).join("/"),a.startsWith("/")&&(a=a.slice(1));let i=u.toString();return i=i.length>0?`?${i}`.replace(/\+/g,"%20"):"",o.startsWith("http")?new URL(`${a}${i}`,o):`${o}${a}${i}`}var ce=async(e,t)=>{var r,s,n,o,a,l,u,i;let{hooks:c,url:h,options:m}=await Jt(e,t),f=sr(m),y=new AbortController,v=(r=m.signal)!=null?r:y.signal,g=fr(h,m),w=ar(m),O=await nr(m),P=ir(h,m),d=I(j({},m),{url:g,headers:O,body:w,method:P,signal:v});for(let S of c.onRequest)if(S){let E=await S(d);E instanceof Object&&(d=E)}("pipeTo"in d&&typeof d.pipeTo=="function"||typeof((s=t?.body)==null?void 0:s.pipe)=="function")&&("duplex"in d||(d.duplex="half"));let{clearTimeout:L}=lr(m,y),_=await f(d.url,d);L();let Te={response:_,request:d};for(let S of c.onResponse)if(S){let E=await S(I(j({},Te),{response:(n=t?.hookOptions)!=null&&n.cloneResponse?_.clone():_}));E instanceof Response?_=E:E instanceof Object&&(_=E.response)}if(_.ok){if(d.method==="HEAD")return{data:"",error:null};let S=tr(_),E={data:"",response:_,request:d};if(S==="json"||S==="text"){let k=await _.text(),M=await((o=d.jsonParser)!=null?o:Ae)(k);E.data=M}else E.data=await _[S]();d?.output&&d.output&&!d.disableValidation&&(E.data=await te(d.output,E.data));for(let k of c.onSuccess)k&&await k(I(j({},E),{response:(a=t?.hookOptions)!=null&&a.cloneResponse?_.clone():_}));return t?.throw?E.data:{data:E.data,error:null}}let xt=(l=t?.jsonParser)!=null?l:Ae,J=await _.text(),Oe=rr(J),ie=Oe?await xt(J):null,Ut={response:_,responseText:J,request:d,error:I(j({},ie),{status:_.status,statusText:_.statusText})};for(let S of c.onError)S&&await S(I(j({},Ut),{response:(u=t?.hookOptions)!=null&&u.cloneResponse?_.clone():_}));if(t?.retry){let S=Qt(t.retry),E=(i=t.retryAttempt)!=null?i:0;if(await S.shouldAttemptRetry(E,_)){for(let M of c.onRetry)M&&await M(Te);let k=S.getDelay(E);return await new Promise(M=>setTimeout(M,k)),await ce(e,I(j({},t),{retryAttempt:E+1}))}}if(t?.throw)throw new Yt(_.status,_.statusText,Oe?ie:J);return{data:null,error:I(j({},ie),{status:_.status,statusText:_.statusText})}};p();p();var re=Object.create(null),W=e=>globalThis.process?.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?re:globalThis),A=new Proxy(re,{get(e,t){return W()[t]??re[t]},has(e,t){let r=W();return t in r||t in re},set(e,t,r){let s=W(!0);return s[t]=r,!0},deleteProperty(e,t){if(!t)return!1;let r=W(!0);return delete r[t],!0},ownKeys(){let e=W(!0);return Object.keys(e)}}),us=typeof process<"u"&&process.env&&process.env.NODE_ENV||"";function b(e,t){return typeof process<"u"&&process.env?process.env[e]??t:typeof Deno<"u"?Deno.env.get(e)??t:typeof Bun<"u"?Bun.env[e]??t:t}var cs=Object.freeze({get BETTER_AUTH_SECRET(){return b("BETTER_AUTH_SECRET")},get AUTH_SECRET(){return b("AUTH_SECRET")},get BETTER_AUTH_TELEMETRY(){return b("BETTER_AUTH_TELEMETRY")},get BETTER_AUTH_TELEMETRY_ID(){return b("BETTER_AUTH_TELEMETRY_ID")},get NODE_ENV(){return b("NODE_ENV","development")},get PACKAGE_VERSION(){return b("PACKAGE_VERSION","0.0.0")},get BETTER_AUTH_TELEMETRY_ENDPOINT(){return b("BETTER_AUTH_TELEMETRY_ENDPOINT","https://telemetry.better-auth.com/v1/track")}}),z=1,T=4,N=8,R=24,je={eterm:T,cons25:T,console:T,cygwin:T,dtterm:T,gnome:T,hurd:T,jfbterm:T,konsole:T,kterm:T,mlterm:T,mosh:R,putty:T,st:T,"rxvt-unicode-24bit":R,terminator:R,"xterm-kitty":R},pr=new Map(Object.entries({APPVEYOR:N,BUILDKITE:N,CIRCLECI:R,DRONE:N,GITEA_ACTIONS:R,GITHUB_ACTIONS:R,GITLAB_CI:N,TRAVIS:N})),dr=[/ansi/,/color/,/linux/,/direct/,/^con[0-9]*x[0-9]/,/^rxvt/,/^screen/,/^xterm/,/^vt100/,/^vt220/];function mr(){if(b("FORCE_COLOR")!==void 0)switch(b("FORCE_COLOR")){case"":case"1":case"true":return T;case"2":return N;case"3":return R;default:return z}if(b("NODE_DISABLE_COLORS")!==void 0&&b("NODE_DISABLE_COLORS")!==""||b("NO_COLOR")!==void 0&&b("NO_COLOR")!==""||b("TERM")==="dumb")return z;if(b("TMUX"))return R;if("TF_BUILD"in A&&"AGENT_NAME"in A)return T;if("CI"in A){for(let{0:e,1:t}of pr)if(e in A)return t;return b("CI_NAME")==="codeship"?N:z}if("TEAMCITY_VERSION"in A)return/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.exec(b("TEAMCITY_VERSION"))!==null?T:z;switch(b("TERM_PROGRAM")){case"iTerm.app":return!b("TERM_PROGRAM_VERSION")||/^[0-2]\./.exec(b("TERM_PROGRAM_VERSION"))!==null?N:R;case"HyperTerm":case"MacTerm":return R;case"Apple_Terminal":return N}if(b("COLORTERM")==="truecolor"||b("COLORTERM")==="24bit")return R;if(b("TERM")){if(/truecolor/.exec(b("TERM"))!==null)return R;if(/^xterm-256/.exec(b("TERM"))!==null)return N;let e=b("TERM").toLowerCase();if(je[e])return je[e];if(dr.some(t=>t.exec(e)!==null))return T}return b("COLORTERM")?T:z}var x={reset:"\x1B[0m",bright:"\x1B[1m",dim:"\x1B[2m",undim:"\x1B[22m",underscore:"\x1B[4m",blink:"\x1B[5m",reverse:"\x1B[7m",hidden:"\x1B[8m",fg:{black:"\x1B[30m",red:"\x1B[31m",green:"\x1B[32m",yellow:"\x1B[33m",blue:"\x1B[34m",magenta:"\x1B[35m",cyan:"\x1B[36m",white:"\x1B[37m"},bg:{black:"\x1B[40m",red:"\x1B[41m",green:"\x1B[42m",yellow:"\x1B[43m",blue:"\x1B[44m",magenta:"\x1B[45m",cyan:"\x1B[46m",white:"\x1B[47m"}},he=["info","success","warn","error","debug"];function yr(e,t){return he.indexOf(t)<=he.indexOf(e)}var gr={info:x.fg.blue,success:x.fg.green,warn:x.fg.yellow,error:x.fg.red,debug:x.fg.magenta},vr=(e,t,r)=>{let s=new Date().toISOString();return r?`${x.dim}${s}${x.reset} ${gr[e]}${e.toUpperCase()}${x.reset} ${x.bright}[Better Auth]:${x.reset} ${t}`:`${s} ${e.toUpperCase()} [Better Auth]: ${t}`},wr=e=>{let t=e?.disabled!==!0,r=e?.level??"error",s=e?.disableColors!==void 0?!e.disableColors:mr()!==1,n=(o,a,l=[])=>{if(!t||!yr(r,o))return;let u=vr(o,a,s);if(!e||typeof e.log!="function"){o==="error"?console.error(u,...l):o==="warn"?console.warn(u,...l):console.log(u,...l);return}e.log(o==="success"?"info":o,a,...l)};return{...Object.fromEntries(he.map(o=>[o,(...[a,...l])=>n(o,a,l)])),get level(){return r}}},hs=wr();p();p();var ve=class extends Error{constructor(e,t){super(e),this.name="BetterAuthError",this.message=e,this.cause=t,this.stack=""}};function br(e){try{return(new URL(e).pathname.replace(/\/+$/,"")||"/")!=="/"}catch{throw new ve(`Invalid base URL: ${e}. Please provide a valid base URL.`)}}function K(e,t="/api/auth"){if(br(e))return e;let r=e.replace(/\/+$/,"");return!t||t==="/"?r:(t=t.startsWith("/")?t:`/${t}`,`${r}${t}`)}function _r(e,t,r,s){if(e)return K(e,t);if(s!==!1){let a=A.BETTER_AUTH_URL||A.NEXT_PUBLIC_BETTER_AUTH_URL||A.PUBLIC_BETTER_AUTH_URL||A.NUXT_PUBLIC_BETTER_AUTH_URL||A.NUXT_PUBLIC_AUTH_URL||(A.BASE_URL!=="/"?A.BASE_URL:void 0);if(a)return K(a,t)}let n=r?.headers.get("x-forwarded-host"),o=r?.headers.get("x-forwarded-proto");if(n&&o)return K(`${o}://${n}`,t);if(r){let a=Er(r.url);if(!a)throw new ve("Could not get origin from request. Please provide a valid base URL.");return K(a,t)}if(typeof window<"u"&&window.location)return K(window.location.origin,t)}function Er(e){try{return new URL(e).origin}catch{return null}}p();p();p();var fe=Symbol("clean"),$=[],C=0,X=4,Tr=0,wt=e=>{let t=[],r={get(){return r.lc||r.listen(()=>{})(),r.value},lc:0,listen(s){return r.lc=t.push(s),()=>{for(let o=C+X;o<$.length;)$[o]===s?$.splice(o,X):o+=X;let n=t.indexOf(s);~n&&(t.splice(n,1),--r.lc||r.off())}},notify(s,n){Tr++;let o=!$.length;for(let a of t)$.push(a,r.value,s,n);if(o){for(C=0;C<$.length;C+=X)$[C]($[C+1],$[C+2],$[C+3]);$.length=0}},off(){},set(s){let n=r.value;n!==s&&(r.value=s,r.notify(n))},subscribe(s){let n=r.listen(s);return s(r.value),n},value:e};return process.env.NODE_ENV!=="production"&&(r[fe]=()=>{t=[],r.lc=0,r.off()}),r};p();var Or=5,F=6,Q=10,Pr=(e,t,r,s)=>(e.events=e.events||{},e.events[r+Q]||(e.events[r+Q]=s(n=>{e.events[r].reduceRight((o,a)=>(a(o),o),{shared:{},...n})})),e.events[r]=e.events[r]||[],e.events[r].push(t),()=>{let n=e.events[r],o=n.indexOf(t);n.splice(o,1),n.length||(delete e.events[r],e.events[r+Q](),delete e.events[r+Q])}),Sr=1e3,Rr=(e,t)=>Pr(e,r=>{let s=t(r);s&&e.events[F].push(s)},Or,r=>{let s=e.listen;e.listen=(...o)=>(!e.lc&&!e.active&&(e.active=!0,r()),s(...o));let n=e.off;if(e.events[F]=[],e.off=()=>{n(),setTimeout(()=>{if(e.active&&!e.lc){e.active=!1;for(let o of e.events[F])o();e.events[F]=[]}},Sr)},process.env.NODE_ENV!=="production"){let o=e[fe];e[fe]=()=>{for(let a of e.events[F])a();e.events[F]=[],e.active=!1,o()}}return()=>{e.listen=s,e.off=n}});p();var Ar=typeof window>"u",$r=(e,t,r,s)=>{let n=wt({data:null,error:null,isPending:!0,isRefetching:!1,refetch:l=>o(l)}),o=l=>{let u=typeof s=="function"?s({data:n.get().data,error:n.get().error,isPending:n.get().isPending}):s;r(t,{...u,query:{...u?.query,...l?.query},async onSuccess(i){n.set({data:i.data,error:null,isPending:!1,isRefetching:!1,refetch:n.value.refetch}),await u?.onSuccess?.(i)},async onError(i){let{request:c}=i,h=typeof c.retry=="number"?c.retry:c.retry?.attempts,m=c.retryAttempt||0;h&&m<h||(n.set({error:i.error,data:null,isPending:!1,isRefetching:!1,refetch:n.value.refetch}),await u?.onError?.(i))},async onRequest(i){let c=n.get();n.set({isPending:c.data===null,data:c.data,error:null,isRefetching:!0,refetch:n.value.refetch}),await u?.onRequest?.(i)}}).catch(i=>{n.set({error:i,data:null,isPending:!1,isRefetching:!1,refetch:n.value.refetch})})};e=Array.isArray(e)?e:[e];let a=!1;for(let l of e)l.subscribe(()=>{Ar||(a?o():Rr(n,()=>{let u=setTimeout(()=>{a||(o(),a=!0)},0);return()=>{n.off(),l.off(),clearTimeout(u)}}))});return n};p();var jr={proto:/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,constructor:/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,protoShort:/"__proto__"\s*:/,constructorShort:/"constructor"\s*:/},Ir=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/,Ie={true:!0,false:!1,null:null,undefined:void 0,nan:Number.NaN,infinity:Number.POSITIVE_INFINITY,"-infinity":Number.NEGATIVE_INFINITY},Nr=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;function xr(e){return e instanceof Date&&!isNaN(e.getTime())}function Ur(e){let t=Nr.exec(e);if(!t)return null;let[,r,s,n,o,a,l,u,i,c,h]=t,m=new Date(Date.UTC(parseInt(r,10),parseInt(s,10)-1,parseInt(n,10),parseInt(o,10),parseInt(a,10),parseInt(l,10),u?parseInt(u.padEnd(3,"0"),10):0));if(i){let f=(parseInt(c,10)*60+parseInt(h,10))*(i==="+"?-1:1);m.setUTCMinutes(m.getUTCMinutes()+f)}return xr(m)?m:null}function Cr(e,t={}){let{strict:r=!1,warnings:s=!1,reviver:n,parseDates:o=!0}=t;if(typeof e!="string")return e;let a=e.trim();if(a.length>0&&a[0]==='"'&&a.endsWith('"')&&!a.slice(1,-1).includes('"'))return a.slice(1,-1);let l=a.toLowerCase();if(l.length<=9&&l in Ie)return Ie[l];if(!Ir.test(a)){if(r)throw new SyntaxError("[better-json] Invalid JSON");return e}if(Object.entries(jr).some(([u,i])=>{let c=i.test(a);return c&&s&&console.warn(`[better-json] Detected potential prototype pollution attempt using ${u} pattern`),c})&&r)throw new Error("[better-json] Potential prototype pollution attempt detected");try{return JSON.parse(a,(u,i)=>{if(u==="__proto__"||u==="constructor"&&i&&typeof i=="object"&&"prototype"in i){s&&console.warn(`[better-json] Dropping "${u}" key to prevent prototype pollution`);return}if(o&&typeof i=="string"){let c=Ur(i);if(c)return c}return n?n(u,i):i})}catch(u){if(r)throw u;return e}}function Lr(e,t={strict:!0}){return Cr(e,t)}var Dr={id:"redirect",name:"Redirect",hooks:{onSuccess(e){if(e.data?.url&&e.data?.redirect&&typeof window<"u"&&window.location&&window.location)try{window.location.href=e.data.url}catch{}}}};function Br(e){let t=wt(!1);return{session:$r(t,"/get-session",e,{method:"GET"}),$sessionSignal:t}}var kr=(e,t)=>{let r="credentials"in Request.prototype,s=_r(e?.baseURL,e?.basePath,void 0,t)??"/api/auth",n=e?.plugins?.flatMap(d=>d.fetchPlugins).filter(d=>d!==void 0)||[],o={id:"lifecycle-hooks",name:"lifecycle-hooks",hooks:{onSuccess:e?.fetchOptions?.onSuccess,onError:e?.fetchOptions?.onError,onRequest:e?.fetchOptions?.onRequest,onResponse:e?.fetchOptions?.onResponse}},{onSuccess:a,onError:l,onRequest:u,onResponse:i,...c}=e?.fetchOptions||{},h=hr({baseURL:s,...r?{credentials:"include"}:{},method:"GET",jsonParser(d){return d?Lr(d,{strict:!1}):null},customFetchImpl:fetch,...c,plugins:[o,...c.plugins||[],...e?.disableDefaultFetchPlugins?[]:[Dr],...n]}),{$sessionSignal:m,session:f}=Br(h),y=e?.plugins||[],v={},g={$sessionSignal:m,session:f},w={"/sign-out":"POST","/revoke-sessions":"POST","/revoke-other-sessions":"POST","/delete-user":"POST"},O=[{signal:"$sessionSignal",matcher(d){return d==="/sign-out"||d==="/update-user"||d.startsWith("/sign-in")||d.startsWith("/sign-up")||d==="/delete-user"||d==="/verify-email"}}];for(let d of y)d.getAtoms&&Object.assign(g,d.getAtoms?.(h)),d.pathMethods&&Object.assign(w,d.pathMethods),d.atomListeners&&O.push(...d.atomListeners);let P={notify:d=>{g[d].set(!g[d].get())},listen:(d,L)=>{g[d].subscribe(L)},atoms:g};for(let d of y)d.getActions&&Object.assign(v,d.getActions?.(h,P,e));return{get baseURL(){return s},pluginsActions:v,pluginsAtoms:g,pluginPathMethods:w,atomListeners:O,$fetch:h,$store:P}};function Mr(e){return typeof e=="object"&&e!==null&&"get"in e&&typeof e.get=="function"&&"lc"in e&&typeof e.lc=="number"}function Fr(e,t,r){let s=t[e],{fetchOptions:n,query:o,...a}=r||{};return s||(n?.method?n.method:a&&Object.keys(a).length>0?"POST":"GET")}function Hr(e,t,r,s,n){function o(a=[]){return new Proxy(function(){},{get(l,u){if(typeof u!="string"||u==="then"||u==="catch"||u==="finally")return;let i=[...a,u],c=e;for(let h of i)if(c&&typeof c=="object"&&h in c)c=c[h];else{c=void 0;break}return typeof c=="function"||Mr(c)?c:o(i)},apply:async(l,u,i)=>{let c="/"+a.map(O=>O.replace(/[A-Z]/g,P=>`-${P.toLowerCase()}`)).join("/"),h=i[0]||{},m=i[1]||{},{query:f,fetchOptions:y,...v}=h,g={...m,...y},w=Fr(c,r,h);return await t(c,{...g,body:w==="GET"?void 0:{...v,...g?.body||{}},query:f||g?.query,method:w,async onSuccess(O){if(await g?.onSuccess?.(O),!n)return;let P=n.filter(d=>d.matcher(c));if(P.length)for(let d of P){let L=s[d.signal];if(!L)return;let _=L.get();setTimeout(()=>{L.set(!_)},10)}}})}})}return o()}p();function qr(e){return e.charAt(0).toUpperCase()+e.slice(1)}function Gr(e){let{pluginPathMethods:t,pluginsActions:r,pluginsAtoms:s,$fetch:n,atomListeners:o,$store:a}=kr(e),l={};for(let[i,c]of Object.entries(s))l[`use${qr(i)}`]=c;let u={...r,...l,$fetch:n,$store:a};return Hr(u,n,t,s,o)}p();p();p();function Wr(e){return{authorize(t,r="AND"){let s=!1;for(let[n,o]of Object.entries(t)){let a=e[n];if(!a)return{success:!1,error:`You are not allowed to access resource: ${n}`};if(Array.isArray(o))s=o.every(l=>a.includes(l));else if(typeof o=="object"){let l=o;l.connector==="OR"?s=l.actions.some(u=>a.includes(u)):s=l.actions.every(u=>a.includes(u))}else throw new ve("Invalid access control request");if(s&&r==="OR")return{success:s};if(!s&&r==="AND")return{success:!1,error:`unauthorized to access resource "${n}"`}}return s?{success:s}:{success:!1,error:"Not authorized"}},statements:e}}function bt(e){return{newRole(t){return Wr(t)},statements:e}}var zr={organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]},we=bt(zr),fs=we.newRole({organization:["update"],invitation:["create","cancel"],member:["create","update","delete"],team:["create","update","delete"],ac:["create","read","update","delete"]}),ps=we.newRole({organization:["update","delete"],member:["create","update","delete"],invitation:["create","cancel"],team:["create","update","delete"],ac:["create","read","update","delete"]}),ds=we.newRole({organization:[],member:[],invitation:[],team:[],ac:["read"]});p();p();p();p();p();p();p();p();p();p();p();var Kr=class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let t=new Error("Cancelling existing WebAuthn API call for new one");t.name="AbortError",this.controller.abort(t)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=new Error("Manually cancelling existing WebAuthn API call");e.name="AbortError",this.controller.abort(e),this.controller=void 0}}},ms=new Kr;p();p();p();p();p();p();p();p();var Vr={user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]},_t=bt(Vr),ys=_t.newRole({user:["create","list","set-role","ban","impersonate","delete","set-password","get","update"],session:["list","revoke","delete"]}),gs=_t.newRole({user:[],session:[]});p();p();var Yr=()=>({id:"username",$InferServerPlugin:{}}),Jr=()=>({id:"phoneNumber",$InferServerPlugin:{},atomListeners:[{matcher(e){return e==="/phone-number/update"||e==="/phone-number/verify"},signal:"$sessionSignal"}]}),Xr=()=>({id:"better-auth-client",$InferServerPlugin:{}}),Qr="/auth",le="nvwa_login_token",se="nvwa_current_jwt",ue="nvwa_user_profile",Et=class{constructor(e,t,r){this.storage=r;let s=Gr({baseURL:e,basePath:Qr,plugins:[Yr(),Jr(),Xr()],fetchOptions:{customFetchImpl:t,auth:{type:"Bearer",token:async()=>{let n=await this.storage.get(se);if(console.log("jwt",n),n)return n;let o=await this.storage.get(le);return console.log("loginToken",o),o}}}});this.authClient=s}async currentUser(){return await this.storage.get(ue)}async getCurrentJwt(){return await this.storage.get(se)}async signUp(e){let t=await this.authClient.signUp.email({email:e.email??`${e.username}@nvwa.app`,name:e.name,username:e.username,displayUsername:e.displayUsername,password:e.password});this.handleLogin(t)}async sendPhoneNumberCode(e){await this.authClient.phoneNumber.sendOtp({phoneNumber:e})}async signInWithPhoneNumberCode(e,t){let r=await this.authClient.phoneNumber.verify({phoneNumber:e,code:t});this.handleLogin(r)}async signInWithPhoneNumber(e,t,r=!1){let s=await this.authClient.signIn.phoneNumber({phoneNumber:e,password:t,rememberMe:r});this.handleLogin(s)}async signInWithUsername(e,t){let r=await this.authClient.signIn.username({username:e,password:t});this.handleLogin(r)}async handleLogin(e){if(e.error)throw new Error(e.error.message);await this.storage.set(le,e.data?.token),await this.storage.set(ue,e.data?.user);let{data:t,error:r}=await this.authClient.token();if(r)throw new Error(r.message);await this.storage.set(se,t.token)}async signOut(){await this.storage.remove(le),await this.storage.remove(ue)}async updateUserPassword(e,t,r=!1){let s=await this.authClient.changePassword({currentPassword:e,newPassword:t,revokeOtherSessions:r});this.handleLogin(s)}};p();var Tt=class{constructor(e){this.http=e}async invoke(e,t){return await(await this.http.fetch("/functions/"+e,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};p();p();p();var U=class Ot{constructor(t){if(this.headerMap=new Map,t){if(t instanceof Ot)t.forEach((r,s)=>this.set(s,r));else if(Array.isArray(t))for(let[r,s]of t)this.set(r,String(s));else if(typeof t=="object")for(let r of Object.keys(t))this.set(r,String(t[r]))}}append(t,r){let s=t.toLowerCase(),n=this.headerMap.get(s);this.headerMap.set(s,n?`${n}, ${r}`:r)}set(t,r){this.headerMap.set(t.toLowerCase(),String(r))}get(t){return this.headerMap.get(t.toLowerCase())??null}has(t){return this.headerMap.has(t.toLowerCase())}delete(t){this.headerMap.delete(t.toLowerCase())}forEach(t){for(let[r,s]of this.headerMap.entries())t(s,r,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}},Pt=class St{constructor(t){if(this.params=new Map,t){if(typeof t=="string")this.parseString(t);else if(t instanceof St)this.params=new Map(t.params);else if(Array.isArray(t))for(let[r,s]of t)this.append(r,s);else if(t&&typeof t=="object")for(let[r,s]of Object.entries(t))this.set(r,s)}}parseString(t){t.startsWith("?")&&(t=t.slice(1));let r=t.split("&");for(let s of r)if(s){let[n,o]=s.split("=");n&&this.append(decodeURIComponent(n),o?decodeURIComponent(o):"")}}append(t,r){let s=this.params.get(t)||[];s.push(r),this.params.set(t,s)}delete(t){this.params.delete(t)}get(t){let r=this.params.get(t);return r?r[0]:null}getAll(t){return this.params.get(t)||[]}has(t){return this.params.has(t)}set(t,r){this.params.set(t,[r])}sort(){let t=Array.from(this.params.entries()).sort(([r],[s])=>r.localeCompare(s));this.params=new Map(t)}toString(){let t=[];for(let[r,s]of this.params.entries())for(let n of s)t.push(`${encodeURIComponent(r)}=${encodeURIComponent(n)}`);return t.join("&")}forEach(t){for(let[r,s]of this.params.entries())for(let n of s)t(n,r,this)}keys(){return this.params.keys()}values(){let t=[];for(let r of this.params.values())t.push(...r);return t[Symbol.iterator]()}entries(){let t=[];for(let[r,s]of this.params.entries())for(let n of s)t.push([r,n]);return t[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},Zr=class pe{constructor(t,r){let s;if(t instanceof pe)s=t.href;else if(r){let o=r instanceof pe?r.href:r;s=this.resolve(o,t)}else s=t;let n=this.parseUrl(s);this.href=s,this.origin=`${n.protocol}//${n.host}`,this.protocol=n.protocol,this.username=n.username,this.password=n.password,this.host=n.host,this.hostname=n.hostname,this.port=n.port,this.pathname=n.pathname,this.search=n.search,this.searchParams=new Pt(n.search),this.hash=n.hash}resolve(t,r){if(r.startsWith("http://")||r.startsWith("https://"))return r;if(r.startsWith("//"))return`${this.parseUrl(t).protocol}${r}`;if(r.startsWith("/")){let o=this.parseUrl(t);return`${o.protocol}//${o.host}${r}`}let s=this.parseUrl(t),n=s.pathname.endsWith("/")?s.pathname:s.pathname+"/";return`${s.protocol}//${s.host}${n}${r}`}parseUrl(t){let r=t.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!r)throw new TypeError("Invalid URL");let s=r[2]||"",n=r[4]||"",o=r[5]||"/",a=r[7]?`?${r[7]}`:"",l=r[9]?`#${r[9]}`:"";if(!s&&!n&&!o.startsWith("/")&&!o.includes("/")&&!o.includes("."))throw new TypeError("Invalid URL");let u=n.match(/^([^@]*)@(.+)$/),i="",c="",h=n;if(u){let v=u[1];h=u[2];let g=v.match(/^([^:]*):?(.*)$/);g&&(i=g[1]||"",c=g[2]||"")}let m=h.match(/^([^:]+):?(\d*)$/),f=m?m[1]:h,y=m&&m[2]?m[2]:"";return{protocol:s?`${s}:`:"",username:i,password:c,host:h,hostname:f,port:y,pathname:o,search:a,hash:l}}toString(){let t=this.searchParams.toString(),r=t?`?${t}`:"";return`${this.protocol}//${this.host}${this.pathname}${r}${this.hash}`}toJSON(){return this.toString()}};p();var es=class Rt{constructor(t,r){if(typeof t=="string")this.url=t;else if(t?.url)this.url=String(t.url);else if(typeof t?.toString=="function")this.url=String(t.toString());else throw new Error("Invalid input for Request");this.method=(r?.method||"GET").toUpperCase(),this.headers=r?.headers instanceof U?r.headers:new U(r?.headers),this.body=r?.body,this.timeout=r?.timeout,this.signal=r?.signal||void 0}clone(){return new Rt(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};p();var be=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=ts(t?.headers),this.ok=this.status>=200&&this.status<300}async text(){return typeof this.bodyData=="string"?this.bodyData:this.bodyData==null?"":typeof this.bodyData=="object"?JSON.stringify(this.bodyData):String(this.bodyData)}async json(){if(typeof this.bodyData=="string")try{return JSON.parse(this.bodyData)}catch{}return this.bodyData}async arrayBuffer(){let e=await this.text();return new TextEncoder().encode(e).buffer}};function ts(e){return e?new U(e):new U}p();var At=class{constructor(){this._aborted=!1,this.listeners=new Set,this.onabort=null}get aborted(){return this._aborted}_trigger(){if(!this._aborted){if(this._aborted=!0,typeof this.onabort=="function")try{this.onabort()}catch{}for(let e of Array.from(this.listeners))try{e()}catch{}this.listeners.clear()}}addEventListener(e,t){if(this._aborted){try{t()}catch{}return}this.listeners.add(t)}removeEventListener(e,t){this.listeners.delete(t)}toString(){return"[object AbortSignal]"}},rs=class{constructor(){this._signal=new At}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};p();function ss(e){e.URL=Zr,e.URLSearchParams=Pt,e.Headers=U,e.Request=es,e.Response=be,e.AbortController=rs,e.AbortSignal=At}var $t=class{constructor(e,t,r){this.storage=e,this.customFetch=t,this.handleUnauthorized=r}async fetch(e,t){return await this.customFetch(e,t)}async fetchWithAuth(e,t){let r=await this.storage.get(se),s=new U(t?.headers);r&&s.set("Authorization",`Bearer ${r}`);let n=await this.customFetch(e,{...t,headers:s});if(n.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return n}};p();var ns="/storage",os=ns+"/generateUploadUrl",jt=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+os,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:r}=await t.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(r,{method:"PUT",body:e,headers:new U({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:n}=await s.json();return{url:n.split("?")[0]}}};p();p();p();var Ne=Ft(qt(),1),{PostgrestClient:as,PostgrestQueryBuilder:vs,PostgrestFilterBuilder:ws,PostgrestTransformBuilder:bs,PostgrestBuilder:_s,PostgrestError:Es}=Ne.default||Ne,is="/entities",It=(e,t)=>new as(e+is,{fetch:t.fetchWithAuth});var ae=class{constructor(){this.prefix="nvwa_"}getKey(t){return`${this.prefix}${t}`}async get(t){try{let r=this.getKey(t),s=uni.getStorageSync(r);return s?s.expires&&Date.now()>s.expires?(await this.remove(t),null):s.value:null}catch(r){return console.error("UniAppStorageService get error:",r),null}}async set(t,r,s){try{let n=this.getKey(t),o={value:r,expires:s?Date.now()+s*1e3:null,timestamp:Date.now()};uni.setStorageSync(n,o)}catch(n){throw console.error("UniAppStorageService set error:",n),n}}async remove(t){try{let r=this.getKey(t);uni.removeStorageSync(r)}catch(r){throw console.error("UniAppStorageService remove error:",r),r}}async clear(){try{uni.clearStorageSync()}catch(t){throw console.error("UniAppStorageService clear error:",t),t}}};var ls=(e,t)=>{let r;if(typeof e=="string")r=e;else if(e&&typeof e.toString=="function")r=e.toString();else if(e?.url)r=e.url;else throw new Error("Invalid input for uniappFetch");let s=(t?.method||"GET").toUpperCase(),n={};if(t?.headers){let l=t.headers;if(typeof l?.forEach=="function")l.forEach((u,i)=>{n[i]=u});else if(Array.isArray(l))for(let[u,i]of l)n[u]=i;else Object.assign(n,l)}let o;if(t?.body!==void 0){let l=t.body;if(typeof l=="string")o=l;else if(l&&typeof l=="object"&&typeof l.forEach=="function"){let u={};l.forEach((i,c)=>{u[c]=i}),o=u}else o=l}let a=t?.timeout||3e4;return new Promise((l,u)=>{let i=t?.signal;if(i?.aborted){let f=new Error("The operation was aborted");f.name="AbortError",u(f);return}let c=!1,h=[],m=uni.request({url:r,method:s,data:o,header:n,timeout:a,success:f=>{if(c)return;c=!0;let y=f.statusCode,v="",g=new U,w=f.header||f.headers||{};Object.keys(w).forEach(O=>{let P=w[O];g.set(O,typeof P=="string"?P:String(P))}),l(new be(f.data,{status:y,statusText:v,headers:g}))},fail:f=>{if(c)return;c=!0;let y=f?.errMsg||f?.message||"Network Error",v=new Error(y);/(abort|aborted|canceled|cancelled)/i.test(String(y))&&(v.name="AbortError"),u(v)}});if(i&&typeof i.addEventListener=="function"){let f=()=>{if(c)return;try{m?.abort?.()}catch{}let y=new Error("The operation was aborted");y.name="AbortError",c=!0,u(y)};i.addEventListener("abort",f),h.push(()=>{try{i.removeEventListener?.("abort",f)}catch{}})}})},_e=ls;var Nt=new ae,Ee=class{constructor(t,r){this.auth=new Et(t,_e,Nt),this.httpClient=new $t(Nt,_e,r),this.fileStorage=new jt(t,this.httpClient),this.entities=It(t,this.httpClient),this.functions=new Tt(this.httpClient)}};export{Ee as default,Nt as localStorage,ss as polyfill};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nvwa-app/sdk-uniapp",
3
- "version": "0.4.28",
3
+ "version": "0.4.29",
4
4
  "description": "NVWA跨端通用工具类UniApp端实现",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",