@nvwa-app/sdk-web 6.0.47 → 6.0.48
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 +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var D=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var Be=Object.getOwnPropertyNames;var qe=Object.prototype.hasOwnProperty;var ze=(t,e)=>{for(var r in e)D(t,r,{get:e[r],enumerable:!0})},We=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Be(e))!qe.call(t,o)&&o!==r&&D(t,o,{get:()=>e[o],enumerable:!(s=De(e,o))||s.enumerable});return t};var Je=t=>We(D({},"__esModule",{value:!0}),t);var yt={};ze(yt,{default:()=>U,disableIframeHoverInspector:()=>dt,enableIframeHoverInspector:()=>ut,getIframeSourceLocation:()=>pt,localStorage:()=>z,setupIframeHoverInspector:()=>ct,setupIframeSourceLocationListener:()=>ft,webFetch:()=>j});module.exports=Je(yt);var Ge=Object.create,R=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,Ve=Object.getOwnPropertyNames,Ye=Object.getPrototypeOf,Qe=Object.prototype.hasOwnProperty,J=(t,e)=>()=>(t&&(e=t(t=0)),e),E=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Xe=(t,e)=>{for(var r in e)R(t,r,{get:e[r],enumerable:!0})},G=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ve(e))!Qe.call(t,o)&&o!==r&&R(t,o,{get:()=>e[o],enumerable:!(s=Ke(e,o))||s.enumerable});return t},Ze=(t,e,r)=>(r=t!=null?Ge(Ye(t)):{},G(e||!t||!t.__esModule?R(r,"default",{value:t,enumerable:!0}):r,t)),S=t=>G(R({},"__esModule",{value:!0}),t),m=J(()=>{"use strict"}),O={};Xe(O,{__addDisposableResource:()=>we,__assign:()=>L,__asyncDelegator:()=>ce,__asyncGenerator:()=>he,__asyncValues:()=>ue,__await:()=>P,__awaiter:()=>se,__classPrivateFieldGet:()=>me,__classPrivateFieldIn:()=>ge,__classPrivateFieldSet:()=>ye,__createBinding:()=>A,__decorate:()=>Y,__disposeResources:()=>ve,__esDecorate:()=>X,__exportStar:()=>oe,__extends:()=>K,__generator:()=>ae,__importDefault:()=>fe,__importStar:()=>pe,__makeTemplateObject:()=>de,__metadata:()=>re,__param:()=>Q,__propKey:()=>ee,__read:()=>B,__rest:()=>V,__rewriteRelativeImportExtension:()=>be,__runInitializers:()=>Z,__setFunctionName:()=>te,__spread:()=>ne,__spreadArray:()=>le,__spreadArrays:()=>ie,__values:()=>k,default:()=>Oe});function K(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");I(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function V(t,e){var r={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(r[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,s=Object.getOwnPropertySymbols(t);o<s.length;o++)e.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(t,s[o])&&(r[s[o]]=t[s[o]]);return r}function Y(t,e,r,s){var o=arguments.length,a=o<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,r):s,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,s);else for(var i=t.length-1;i>=0;i--)(n=t[i])&&(a=(o<3?n(a):o>3?n(e,r,a):n(e,r))||a);return o>3&&a&&Object.defineProperty(e,r,a),a}function Q(t,e){return function(r,s){e(r,s,t)}}function X(t,e,r,s,o,a){function n(g){if(g!==void 0&&typeof g!="function")throw new TypeError("Function expected");return g}for(var i=s.kind,c=i==="getter"?"get":i==="setter"?"set":"value",l=!e&&t?s.static?t:t.prototype:null,h=e||(l?Object.getOwnPropertyDescriptor(l,s.name):{}),u,f=!1,d=r.length-1;d>=0;d--){var p={};for(var y in s)p[y]=y==="access"?{}:s[y];for(var y in s.access)p.access[y]=s.access[y];p.addInitializer=function(g){if(f)throw new TypeError("Cannot add initializers after decoration has completed");a.push(n(g||null))};var w=(0,r[d])(i==="accessor"?{get:h.get,set:h.set}:h[c],p);if(i==="accessor"){if(w===void 0)continue;if(w===null||typeof w!="object")throw new TypeError("Object expected");(u=n(w.get))&&(h.get=u),(u=n(w.set))&&(h.set=u),(u=n(w.init))&&o.unshift(u)}else(u=n(w))&&(i==="field"?o.unshift(u):h[c]=u)}l&&Object.defineProperty(l,s.name,h),f=!0}function Z(t,e,r){for(var s=arguments.length>2,o=0;o<e.length;o++)r=s?e[o].call(t,r):e[o].call(t);return s?r:void 0}function ee(t){return typeof t=="symbol"?t:"".concat(t)}function te(t,e,r){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(t,"name",{configurable:!0,value:r?"".concat(r," ",e):e})}function re(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function se(t,e,r,s){function o(a){return a instanceof r?a:new r(function(n){n(a)})}return new(r||(r=Promise))(function(a,n){function i(h){try{l(s.next(h))}catch(u){n(u)}}function c(h){try{l(s.throw(h))}catch(u){n(u)}}function l(h){h.done?a(h.value):o(h.value).then(i,c)}l((s=s.apply(t,e||[])).next())})}function ae(t,e){var r={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},s,o,a,n=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return n.next=i(0),n.throw=i(1),n.return=i(2),typeof Symbol=="function"&&(n[Symbol.iterator]=function(){return this}),n;function i(l){return function(h){return c([l,h])}}function c(l){if(s)throw new TypeError("Generator is already executing.");for(;n&&(n=0,l[0]&&(r=0)),r;)try{if(s=1,o&&(a=l[0]&2?o.return:l[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,l[1])).done)return a;switch(o=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,o=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(a=r.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){r.label=l[1];break}if(l[0]===6&&r.label<a[1]){r.label=a[1],a=l;break}if(a&&r.label<a[2]){r.label=a[2],r.ops.push(l);break}a[2]&&r.ops.pop(),r.trys.pop();continue}l=e.call(t,r)}catch(h){l=[6,h],o=0}finally{s=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function oe(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&A(e,t,r)}function k(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],s=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function B(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var s=r.call(t),o,a=[],n;try{for(;(e===void 0||e-- >0)&&!(o=s.next()).done;)a.push(o.value)}catch(i){n={error:i}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return a}function ne(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(B(arguments[e]));return t}function ie(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var s=Array(t),o=0,e=0;e<r;e++)for(var a=arguments[e],n=0,i=a.length;n<i;n++,o++)s[o]=a[n];return s}function le(t,e,r){if(r||arguments.length===2)for(var s=0,o=e.length,a;s<o;s++)(a||!(s in e))&&(a||(a=Array.prototype.slice.call(e,0,s)),a[s]=e[s]);return t.concat(a||Array.prototype.slice.call(e))}function P(t){return this instanceof P?(this.v=t,this):new P(t)}function he(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r.apply(t,e||[]),o,a=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),i("next"),i("throw"),i("return",n),o[Symbol.asyncIterator]=function(){return this},o;function n(d){return function(p){return Promise.resolve(p).then(d,u)}}function i(d,p){s[d]&&(o[d]=function(y){return new Promise(function(w,g){a.push([d,y,w,g])>1||c(d,y)})},p&&(o[d]=p(o[d])))}function c(d,p){try{l(s[d](p))}catch(y){f(a[0][3],y)}}function l(d){d.value instanceof P?Promise.resolve(d.value.v).then(h,u):f(a[0][2],d)}function h(d){c("next",d)}function u(d){c("throw",d)}function f(d,p){d(p),a.shift(),a.length&&c(a[0][0],a[0][1])}}function ce(t){var e,r;return e={},s("next"),s("throw",function(o){throw o}),s("return"),e[Symbol.iterator]=function(){return this},e;function s(o,a){e[o]=t[o]?function(n){return(r=!r)?{value:P(t[o](n)),done:!1}:a?a(n):n}:a}}function ue(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof k=="function"?k(t):t[Symbol.iterator](),r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r);function s(a){r[a]=t[a]&&function(n){return new Promise(function(i,c){n=t[a](n),o(i,c,n.done,n.value)})}}function o(a,n,i,c){Promise.resolve(c).then(function(l){a({value:l,done:i})},n)}}function de(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function pe(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r=N(t),s=0;s<r.length;s++)r[s]!=="default"&&A(e,t,r[s]);return _e(e,t),e}function fe(t){return t&&t.__esModule?t:{default:t}}function me(t,e,r,s){if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?s:r==="a"?s.call(t):s?s.value:e.get(t)}function ye(t,e,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 e=="function"?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?o.call(t,r):o?o.value=r:e.set(t,r),r}function ge(t,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof t=="function"?e===t:t.has(e)}function we(t,e,r){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var s,o;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=e[Symbol.asyncDispose]}if(s===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=e[Symbol.dispose],r&&(o=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");o&&(s=function(){try{o.call(this)}catch(a){return Promise.reject(a)}}),t.stack.push({value:e,dispose:s,async:r})}else r&&t.stack.push({async:!0});return e}function ve(t){function e(a){t.error=t.hasError?new Ee(a,t.error,"An error was suppressed during disposal."):a,t.hasError=!0}var r,s=0;function o(){for(;r=t.stack.pop();)try{if(!r.async&&s===1)return s=0,t.stack.push(r),Promise.resolve().then(o);if(r.dispose){var a=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(a).then(o,function(n){return e(n),o()})}else s|=1}catch(n){e(n)}if(s===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return o()}function be(t,e){return typeof t=="string"&&/^\.\.?\//.test(t)?t.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,s,o,a,n){return s?e?".jsx":".js":o&&(!a||!n)?r:o+a+"."+n.toLowerCase()+"js"}):t}var I,L,A,_e,N,Ee,Oe,T=J(()=>{"use strict";m(),I=function(t,e){return I=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])},I(t,e)},L=function(){return L=Object.assign||function(t){for(var e,r=1,s=arguments.length;r<s;r++){e=arguments[r];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},L.apply(this,arguments)},A=Object.create?(function(t,e,r,s){s===void 0&&(s=r);var o=Object.getOwnPropertyDescriptor(e,r);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,s,o)}):(function(t,e,r,s){s===void 0&&(s=r),t[s]=e[r]}),_e=Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e},N=function(t){return N=Object.getOwnPropertyNames||function(e){var r=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[r.length]=s);return r},N(t)},Ee=typeof SuppressedError=="function"?SuppressedError:function(t,e,r){var s=new Error(r);return s.name="SuppressedError",s.error=t,s.suppressed=e,s},Oe={__extends:K,__assign:L,__rest:V,__decorate:Y,__param:Q,__esDecorate:X,__runInitializers:Z,__propKey:ee,__setFunctionName:te,__metadata:re,__awaiter:se,__generator:ae,__createBinding:A,__exportStar:oe,__values:k,__read:B,__spread:ne,__spreadArrays:ie,__spreadArray:le,__await:P,__asyncGenerator:he,__asyncDelegator:ce,__asyncValues:ue,__makeTemplateObject:de,__importStar:pe,__importDefault:fe,__classPrivateFieldGet:me,__classPrivateFieldSet:ye,__classPrivateFieldIn:ge,__addDisposableResource:we,__disposeResources:ve,__rewriteRelativeImportExtension:be}}),Pe=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}};t.default=e}),Se=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=(T(),S(O)),r=e.__importDefault(Pe()),s=class{constructor(o){var a,n;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=(a=o.shouldThrowOnError)!==null&&a!==void 0?a:!1,this.signal=o.signal,this.isMaybeSingle=(n=o.isMaybeSingle)!==null&&n!==void 0?n:!1,o.fetch?this.fetch=o.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(o,a){return this.headers=new Headers(this.headers),this.headers.set(o,a),this}then(o,a){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 n=this.fetch,i=n(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async c=>{var l,h,u,f;let d=null,p=null,y=null,w=c.status,g=c.statusText;if(c.ok){if(this.method!=="HEAD"){let F=await c.text();F===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&!((l=this.headers.get("Accept"))===null||l===void 0)&&l.includes("application/vnd.pgrst.plan+text")?p=F:p=JSON.parse(F))}let $=(h=this.headers.get("Prefer"))===null||h===void 0?void 0:h.match(/count=(exact|planned|estimated)/),M=(u=c.headers.get("content-range"))===null||u===void 0?void 0:u.split("/");$&&M&&M.length>1&&(y=parseInt(M[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(p)&&(p.length>1?(d={code:"PGRST116",details:`Results contain ${p.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},p=null,y=null,w=406,g="Not Acceptable"):p.length===1?p=p[0]:p=null)}else{let $=await c.text();try{d=JSON.parse($),Array.isArray(d)&&c.status===404&&(p=[],d=null,w=200,g="OK")}catch{c.status===404&&$===""?(w=204,g="No Content"):d={message:$}}if(d&&this.isMaybeSingle&&!((f=d?.details)===null||f===void 0)&&f.includes("0 rows")&&(d=null,w=200,g="OK"),d&&this.shouldThrowOnError)throw new r.default(d)}return{error:d,data:p,count:y,status:w,statusText:g}});return this.shouldThrowOnError||(i=i.catch(c=>{var l,h,u;return{error:{message:`${(l=c?.name)!==null&&l!==void 0?l:"FetchError"}: ${c?.message}`,details:`${(h=c?.stack)!==null&&h!==void 0?h:""}`,hint:"",code:`${(u=c?.code)!==null&&u!==void 0?u:""}`},data:null,count:null,status:0,statusText:""}})),i.then(o,a)}returns(){return this}overrideTypes(){return this}};t.default=s}),Te=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=(T(),S(O)),r=e.__importDefault(Se()),s=class extends r.default{select(o){let a=!1,n=(o??"*").split("").map(i=>/\s/.test(i)&&!a?"":(i==='"'&&(a=!a),i)).join("");return this.url.searchParams.set("select",n),this.headers.append("Prefer","return=representation"),this}order(o,{ascending:a=!0,nullsFirst:n,foreignTable:i,referencedTable:c=i}={}){let l=c?`${c}.order`:"order",h=this.url.searchParams.get(l);return this.url.searchParams.set(l,`${h?`${h},`:""}${o}.${a?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(o,{foreignTable:a,referencedTable:n=a}={}){let i=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(i,`${o}`),this}range(o,a,{foreignTable:n,referencedTable:i=n}={}){let c=typeof i>"u"?"offset":`${i}.offset`,l=typeof i>"u"?"limit":`${i}.limit`;return this.url.searchParams.set(c,`${o}`),this.url.searchParams.set(l,`${a-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:a=!1,settings:n=!1,buffers:i=!1,wal:c=!1,format:l="text"}={}){var h;let u=[o?"analyze":null,a?"verbose":null,n?"settings":null,i?"buffers":null,c?"wal":null].filter(Boolean).join("|"),f=(h=this.headers.get("Accept"))!==null&&h!==void 0?h:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${l}; for="${f}"; options=${u};`),l==="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}};t.default=s}),q=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=(T(),S(O)),r=e.__importDefault(Te()),s=new RegExp("[,()]"),o=class extends r.default{eq(a,n){return this.url.searchParams.append(a,`eq.${n}`),this}neq(a,n){return this.url.searchParams.append(a,`neq.${n}`),this}gt(a,n){return this.url.searchParams.append(a,`gt.${n}`),this}gte(a,n){return this.url.searchParams.append(a,`gte.${n}`),this}lt(a,n){return this.url.searchParams.append(a,`lt.${n}`),this}lte(a,n){return this.url.searchParams.append(a,`lte.${n}`),this}like(a,n){return this.url.searchParams.append(a,`like.${n}`),this}likeAllOf(a,n){return this.url.searchParams.append(a,`like(all).{${n.join(",")}}`),this}likeAnyOf(a,n){return this.url.searchParams.append(a,`like(any).{${n.join(",")}}`),this}ilike(a,n){return this.url.searchParams.append(a,`ilike.${n}`),this}ilikeAllOf(a,n){return this.url.searchParams.append(a,`ilike(all).{${n.join(",")}}`),this}ilikeAnyOf(a,n){return this.url.searchParams.append(a,`ilike(any).{${n.join(",")}}`),this}is(a,n){return this.url.searchParams.append(a,`is.${n}`),this}in(a,n){let i=Array.from(new Set(n)).map(c=>typeof c=="string"&&s.test(c)?`"${c}"`:`${c}`).join(",");return this.url.searchParams.append(a,`in.(${i})`),this}contains(a,n){return typeof n=="string"?this.url.searchParams.append(a,`cs.${n}`):Array.isArray(n)?this.url.searchParams.append(a,`cs.{${n.join(",")}}`):this.url.searchParams.append(a,`cs.${JSON.stringify(n)}`),this}containedBy(a,n){return typeof n=="string"?this.url.searchParams.append(a,`cd.${n}`):Array.isArray(n)?this.url.searchParams.append(a,`cd.{${n.join(",")}}`):this.url.searchParams.append(a,`cd.${JSON.stringify(n)}`),this}rangeGt(a,n){return this.url.searchParams.append(a,`sr.${n}`),this}rangeGte(a,n){return this.url.searchParams.append(a,`nxl.${n}`),this}rangeLt(a,n){return this.url.searchParams.append(a,`sl.${n}`),this}rangeLte(a,n){return this.url.searchParams.append(a,`nxr.${n}`),this}rangeAdjacent(a,n){return this.url.searchParams.append(a,`adj.${n}`),this}overlaps(a,n){return typeof n=="string"?this.url.searchParams.append(a,`ov.${n}`):this.url.searchParams.append(a,`ov.{${n.join(",")}}`),this}textSearch(a,n,{config:i,type:c}={}){let l="";c==="plain"?l="pl":c==="phrase"?l="ph":c==="websearch"&&(l="w");let h=i===void 0?"":`(${i})`;return this.url.searchParams.append(a,`${l}fts${h}.${n}`),this}match(a){return Object.entries(a).forEach(([n,i])=>{this.url.searchParams.append(n,`eq.${i}`)}),this}not(a,n,i){return this.url.searchParams.append(a,`not.${n}.${i}`),this}or(a,{foreignTable:n,referencedTable:i=n}={}){let c=i?`${i}.or`:"or";return this.url.searchParams.append(c,`(${a})`),this}filter(a,n,i){return this.url.searchParams.append(a,`${n}.${i}`),this}};t.default=o}),$e=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=(T(),S(O)),r=e.__importDefault(q()),s=class{constructor(o,{headers:a={},schema:n,fetch:i}){this.url=o,this.headers=new Headers(a),this.schema=n,this.fetch=i}select(o,a){let{head:n=!1,count:i}=a??{},c=n?"HEAD":"GET",l=!1,h=(o??"*").split("").map(u=>/\s/.test(u)&&!l?"":(u==='"'&&(l=!l),u)).join("");return this.url.searchParams.set("select",h),i&&this.headers.append("Prefer",`count=${i}`),new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(o,{count:a,defaultToNull:n=!0}={}){var i;let c="POST";if(a&&this.headers.append("Prefer",`count=${a}`),n||this.headers.append("Prefer","missing=default"),Array.isArray(o)){let l=o.reduce((h,u)=>h.concat(Object.keys(u)),[]);if(l.length>0){let h=[...new Set(l)].map(u=>`"${u}"`);this.url.searchParams.set("columns",h.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})}upsert(o,{onConflict:a,ignoreDuplicates:n=!1,count:i,defaultToNull:c=!0}={}){var l;let h="POST";if(this.headers.append("Prefer",`resolution=${n?"ignore":"merge"}-duplicates`),a!==void 0&&this.url.searchParams.set("on_conflict",a),i&&this.headers.append("Prefer",`count=${i}`),c||this.headers.append("Prefer","missing=default"),Array.isArray(o)){let u=o.reduce((f,d)=>f.concat(Object.keys(d)),[]);if(u.length>0){let f=[...new Set(u)].map(d=>`"${d}"`);this.url.searchParams.set("columns",f.join(","))}}return new r.default({method:h,url:this.url,headers:this.headers,schema:this.schema,body:o,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}update(o,{count:a}={}){var n;let i="PATCH";return a&&this.headers.append("Prefer",`count=${a}`),new r.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:o,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}delete({count:o}={}){var a;let n="DELETE";return o&&this.headers.append("Prefer",`count=${o}`),new r.default({method:n,url:this.url,headers:this.headers,schema:this.schema,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}};t.default=s}),et=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=(T(),S(O)),r=e.__importDefault($e()),s=e.__importDefault(q()),o=class xe{constructor(n,{headers:i={},schema:c,fetch:l}={}){this.url=n,this.headers=new Headers(i),this.schemaName=c,this.fetch=l}from(n){let i=new URL(`${this.url}/${n}`);return new r.default(i,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(n){return new xe(this.url,{headers:this.headers,schema:n,fetch:this.fetch})}rpc(n,i={},{head:c=!1,get:l=!1,count:h}={}){var u;let f,d=new URL(`${this.url}/rpc/${n}`),p;c||l?(f=c?"HEAD":"GET",Object.entries(i).filter(([w,g])=>g!==void 0).map(([w,g])=>[w,Array.isArray(g)?`{${g.join(",")}}`:`${g}`]).forEach(([w,g])=>{d.searchParams.append(w,g)})):(f="POST",p=i);let y=new Headers(this.headers);return h&&y.set("Prefer",`count=${h}`),new s.default({method:f,url:d,headers:y,schema:this.schemaName,body:p,fetch:(u=this.fetch)!==null&&u!==void 0?u:fetch})}};t.default=o}),tt=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0}),t.PostgrestError=t.PostgrestBuilder=t.PostgrestTransformBuilder=t.PostgrestFilterBuilder=t.PostgrestQueryBuilder=t.PostgrestClient=void 0;var e=(T(),S(O)),r=e.__importDefault(et());t.PostgrestClient=r.default;var s=e.__importDefault($e());t.PostgrestQueryBuilder=s.default;var o=e.__importDefault(q());t.PostgrestFilterBuilder=o.default;var a=e.__importDefault(Te());t.PostgrestTransformBuilder=a.default;var n=e.__importDefault(Se());t.PostgrestBuilder=n.default;var i=e.__importDefault(Pe());t.PostgrestError=i.default,t.default={PostgrestClient:r.default,PostgrestQueryBuilder:s.default,PostgrestFilterBuilder:o.default,PostgrestTransformBuilder:a.default,PostgrestBuilder:n.default,PostgrestError:i.default}});m();m();var Le=class{constructor(t,e=""){this.http=t,this.baseUrl=e.replace(/\/$/,"")}async invoke(t,e){let r=this.baseUrl?`${this.baseUrl}/functions/${t}`:`/functions/${t}`;return await(await this.http.fetch(r,{method:e.method||"POST",body:e.body,headers:e.headers})).json()}};m();m();var v="nvwa_current_jwt",b="nvwa_login_token",x="nvwa_user_profile",rt="set-auth-token",st=typeof fetch<"u"?(t,e)=>fetch(t,e):()=>{throw new Error("AuthClient requires fetch")},Ae=class{constructor(t,e={}){this.baseUrl=t.replace(/\/$/,""),this.authPath=(e.authPath??"/auth").replace(/^\//,""),this.fetchImpl=e.fetchImpl??st,this.storage=e.storage??null,this.credentials=e.credentials??"omit",typeof console<"u"&&(console.warn("[NvwaAuth] init baseUrl:",this.baseUrl||"(empty)"),(!this.baseUrl||!this.baseUrl.startsWith("http://")&&!this.baseUrl.startsWith("https://"))&&console.warn("[NvwaAuth] baseUrl \u5E94\u4E3A\u5B8C\u6574\u5730\u5740\uFF08\u5982 https://xxx.nvwa.app\uFF09\uFF0C\u5426\u5219\u5C0F\u7A0B\u5E8F request \u4F1A\u62A5 invalid url"))}async currentUser(){if(this.storage){let r=await this.storage.get(x);if(r!=null)return r}let{data:t}=await this.getSession(),e=t?.user??null;return e&&this.storage&&await this.storage.set(x,e),e}async getCurrentJwt(){if(this.storage){let e=await this.storage.get(v);if(e!=null)return e;let r=await this.storage.get(b),{data:s}=await this.getToken(r??void 0);return s?.token?(await this.storage.set(v,s.token),s.token):null}let{data:t}=await this.getToken();return t?.token??null}async persistLogin(t,e){if(!this.storage)return;let r=e?.headers.get(rt)?.trim()||t.token||t.session?.token;r&&await this.storage.set(b,r),t.user&&await this.storage.set(x,t.user);let s=r??await this.storage.get(b),{data:o}=await this.getToken(s??void 0);o?.token&&await this.storage.set(v,o.token)}async clearLogin(){this.storage&&(await this.storage.remove(b),await this.storage.remove(x),await this.storage.remove(v))}url(t){let e=`${`${this.baseUrl.replace(/\/+$/,"")}/${this.authPath.replace(/^\/+/,"")}`}/${t.replace(/^\/+/,"")}`;return typeof console<"u"&&(console.warn("[NvwaAuth] request URL:",e),!e.startsWith("http://")&&!e.startsWith("https://")&&console.warn("[NvwaAuth] URL \u975E\u5B8C\u6574\u5730\u5740\uFF0C\u5C0F\u7A0B\u5E8F\u4F1A\u62A5 invalid url\uFF0C\u8BF7\u68C0\u67E5 Nvwa \u6784\u9020\u65F6\u4F20\u5165\u7684 baseUrl")),e}async getSession(){try{let t={};if(this.storage){let r=await this.storage.get(b)??await this.storage.get(v);r!=null&&(t.Authorization=`Bearer ${r}`)}let e=await this.fetchImpl(this.url("session"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return e.ok?{data:await e.json()}:{data:null,error:{message:await e.text()||e.statusText,status:e.status}}}catch(t){return{data:null,error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signInWithEmail(t,e){try{let r=await this.fetchImpl(this.url("sign-in/email"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify({email:t,password:e})}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let o=s?JSON.parse(s):void 0;return o&&await this.persistLogin({user:o.user,session:o.session},r),{data:o}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async signOut(){try{let t={};if(this.storage){let r=await this.storage.get(b)??await this.storage.get(v);r!=null&&(t.Authorization=`Bearer ${r}`)}let e=await this.fetchImpl(this.url("sign-out"),{method:"POST",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return await this.clearLogin(),e.ok?{}:{error:{message:await e.text()||e.statusText,status:e.status}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signUp(t){let e=await this.postJson("sign-up/email",t);return e.data&&await this.persistLogin(e.data,e.response),e}async getToken(t){try{let e={};if(t)e.Authorization=`Bearer ${t}`;else if(this.storage){let a=await this.storage.get(b)??await this.storage.get(v);a!=null&&(e.Authorization=`Bearer ${a}`)}let r=await this.fetchImpl(this.url("token"),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let o=s?JSON.parse(s):void 0;return{data:o?.token!=null?{token:o.token}:void 0}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signInWithUsername(t,e){let r=await this.postJson("sign-in/username",{username:t,password:e});return r.data&&await this.persistLogin(r.data,r.response),r}async signInWithPhoneNumber(t,e,r){let s=await this.postJson("sign-in/phone-number",{phoneNumber:t,password:e,rememberMe:r});return s.data&&await this.persistLogin(s.data,s.response),s}async sendPhoneNumberOtp(t){let e=await this.postJson("phone-number/send-otp",{phoneNumber:t});return e.error?{error:e.error}:{}}async verifyPhoneNumber(t,e){let r=await this.postJson("phone-number/verify",{phoneNumber:t,code:e});return r.data&&await this.persistLogin(r.data,r.response),r}async loginWithWeChatCode(t,e){try{let r={"Content-Type":"application/json"};if(this.storage){let n=await this.storage.get(v);n!=null&&(r.Authorization=`Bearer ${n}`)}let s=await this.fetchImpl(this.url("wechat/openplatform/sign-in"),{method:"POST",headers:r,credentials:this.credentials,body:JSON.stringify({code:t,applicationCode:e})}),o=await s.text();if(!s.ok)return{error:{message:o||s.statusText,status:s.status}};let a=o?JSON.parse(o):null;return!a?.token||!a.user?{error:{message:"invalid_wechat_login_response",status:502}}:(this.storage&&(await this.storage.set(v,a.token),await this.storage.set(b,a.token),await this.storage.set(x,a.user)),{data:a})}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async postJson(t,e){try{let r=await this.fetchImpl(this.url(t),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify(e)}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let o=s?JSON.parse(s):void 0;return{data:o?.data??o??void 0,response:r}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}};m();m();var _=class Ce{constructor(e){if(this.headerMap=new Map,e){if(e instanceof Ce)e.forEach((r,s)=>this.set(s,r));else if(Array.isArray(e))for(let[r,s]of e)this.set(r,String(s));else if(typeof e=="object")for(let r of Object.keys(e))this.set(r,String(e[r]))}}append(e,r){let s=e.toLowerCase(),o=this.headerMap.get(s);this.headerMap.set(s,o?`${o}, ${r}`:r)}set(e,r){this.headerMap.set(e.toLowerCase(),String(r))}get(e){return this.headerMap.get(e.toLowerCase())??null}has(e){return this.headerMap.has(e.toLowerCase())}delete(e){this.headerMap.delete(e.toLowerCase())}forEach(e){for(let[r,s]of this.headerMap.entries())e(s,r,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}};m();m();var je=class{constructor(t,e){this.bodyData=t,this.status=e?.status??200,this.statusText=e?.statusText??"",this.headers=at(e?.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 t=await this.text();return new TextEncoder().encode(t).buffer}};function at(t){return t?new _(t):new _}m();m();var Ie=class{constructor(t,e,r){this.storage=t,this.customFetch=e,this.handleUnauthorized=r}async fetch(t,e){return await this.customFetch(t,e)}async fetchWithAuth(t,e){let r=await this.storage.get(v),s=new _(e?.headers);r&&s.set("Authorization",`Bearer ${r}`);let o=e?.method||"GET";if((o==="POST"||o==="PUT"||o==="PATCH")&&e?.body){let n=s.get("Content-Type");(!n||n.includes("text/plain"))&&s.set("Content-Type","application/json")}let a=await this.customFetch(t,{...e,headers:s});if(a.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return a}};m();var ot="/storage",nt=ot+"/generateUploadUrl",Ne=class{constructor(t,e){this.baseUrl=t,this.http=e}async uploadFile(t){let e=await this.http.fetch(this.baseUrl+nt,{method:"POST",body:{fileName:t.name||t.fileName,fileSize:t.size||t.fileSize,fileType:t.type||t.fileType}}),{url:r}=await e.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(r,{method:"PUT",body:t,headers:new _({"Content-Type":t.type||t.fileType||"application/octet-stream"})}),{url:o}=await s.json();return{url:o.split("?")[0]}}};m();m();m();var W=Ze(tt(),1),{PostgrestClient:it,PostgrestQueryBuilder:wt,PostgrestFilterBuilder:vt,PostgrestTransformBuilder:bt,PostgrestBuilder:_t,PostgrestError:Et}=W.default||W,lt="/entities",ke=(t,e)=>new it(t+lt,{fetch:e.fetchWithAuth.bind(e)});m();var Re=class{constructor(t,e){this.baseUrl=t,this.http=e}async execute(t,e){let r=`${this.baseUrl}/capability/${t}/execute`,s=await(await this.http.fetchWithAuth(r,{method:"POST",body:e?JSON.stringify(e):void 0,timeout:6e5})).json();if(s.status!==200)throw new Error(s.message);return s.data}};m();var He=class{constructor(t,e){this.baseUrl=t,this.http=e}async execute(t,e){let r=`${this.baseUrl}/capability/${t}/execute`,s=await(await this.http.fetchWithAuth(r,{method:"POST",body:e!=null?JSON.stringify(e):void 0,timeout:6e5})).json();if(s.status!==200)throw new Error(s.message);return s.data}};m();var Ue=class{constructor(){this.hoverOverlay=null,this.selectedOverlay=null,this.tooltip=null,this.hoverElement=null,this.selectedElement=null,this.hoverUpdateHandler=null,this.selectedUpdateHandler=null,this.createStyles()}createStyles(){if(document.getElementById("__nvwa-inspector-overlay-style"))return;let t=document.createElement("style");t.id="__nvwa-inspector-overlay-style",t.textContent=`
|
|
1
|
+
"use strict";var D=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var Be=Object.getOwnPropertyNames;var qe=Object.prototype.hasOwnProperty;var ze=(t,e)=>{for(var r in e)D(t,r,{get:e[r],enumerable:!0})},We=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Be(e))!qe.call(t,o)&&o!==r&&D(t,o,{get:()=>e[o],enumerable:!(s=De(e,o))||s.enumerable});return t};var Je=t=>We(D({},"__esModule",{value:!0}),t);var yt={};ze(yt,{default:()=>U,disableIframeHoverInspector:()=>dt,enableIframeHoverInspector:()=>ut,getIframeSourceLocation:()=>pt,localStorage:()=>z,setupIframeHoverInspector:()=>ct,setupIframeSourceLocationListener:()=>ft,webFetch:()=>j});module.exports=Je(yt);var Ge=Object.create,R=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,Ve=Object.getOwnPropertyNames,Ye=Object.getPrototypeOf,Qe=Object.prototype.hasOwnProperty,J=(t,e)=>()=>(t&&(e=t(t=0)),e),E=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Xe=(t,e)=>{for(var r in e)R(t,r,{get:e[r],enumerable:!0})},G=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ve(e))!Qe.call(t,o)&&o!==r&&R(t,o,{get:()=>e[o],enumerable:!(s=Ke(e,o))||s.enumerable});return t},Ze=(t,e,r)=>(r=t!=null?Ge(Ye(t)):{},G(e||!t||!t.__esModule?R(r,"default",{value:t,enumerable:!0}):r,t)),S=t=>G(R({},"__esModule",{value:!0}),t),m=J(()=>{"use strict"}),O={};Xe(O,{__addDisposableResource:()=>we,__assign:()=>L,__asyncDelegator:()=>ce,__asyncGenerator:()=>he,__asyncValues:()=>ue,__await:()=>P,__awaiter:()=>se,__classPrivateFieldGet:()=>me,__classPrivateFieldIn:()=>ge,__classPrivateFieldSet:()=>ye,__createBinding:()=>A,__decorate:()=>Y,__disposeResources:()=>ve,__esDecorate:()=>X,__exportStar:()=>oe,__extends:()=>K,__generator:()=>ae,__importDefault:()=>fe,__importStar:()=>pe,__makeTemplateObject:()=>de,__metadata:()=>re,__param:()=>Q,__propKey:()=>ee,__read:()=>B,__rest:()=>V,__rewriteRelativeImportExtension:()=>be,__runInitializers:()=>Z,__setFunctionName:()=>te,__spread:()=>ne,__spreadArray:()=>le,__spreadArrays:()=>ie,__values:()=>k,default:()=>Oe});function K(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");I(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function V(t,e){var r={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(r[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,s=Object.getOwnPropertySymbols(t);o<s.length;o++)e.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(t,s[o])&&(r[s[o]]=t[s[o]]);return r}function Y(t,e,r,s){var o=arguments.length,a=o<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,r):s,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,s);else for(var i=t.length-1;i>=0;i--)(n=t[i])&&(a=(o<3?n(a):o>3?n(e,r,a):n(e,r))||a);return o>3&&a&&Object.defineProperty(e,r,a),a}function Q(t,e){return function(r,s){e(r,s,t)}}function X(t,e,r,s,o,a){function n(g){if(g!==void 0&&typeof g!="function")throw new TypeError("Function expected");return g}for(var i=s.kind,c=i==="getter"?"get":i==="setter"?"set":"value",l=!e&&t?s.static?t:t.prototype:null,h=e||(l?Object.getOwnPropertyDescriptor(l,s.name):{}),u,f=!1,d=r.length-1;d>=0;d--){var p={};for(var y in s)p[y]=y==="access"?{}:s[y];for(var y in s.access)p.access[y]=s.access[y];p.addInitializer=function(g){if(f)throw new TypeError("Cannot add initializers after decoration has completed");a.push(n(g||null))};var w=(0,r[d])(i==="accessor"?{get:h.get,set:h.set}:h[c],p);if(i==="accessor"){if(w===void 0)continue;if(w===null||typeof w!="object")throw new TypeError("Object expected");(u=n(w.get))&&(h.get=u),(u=n(w.set))&&(h.set=u),(u=n(w.init))&&o.unshift(u)}else(u=n(w))&&(i==="field"?o.unshift(u):h[c]=u)}l&&Object.defineProperty(l,s.name,h),f=!0}function Z(t,e,r){for(var s=arguments.length>2,o=0;o<e.length;o++)r=s?e[o].call(t,r):e[o].call(t);return s?r:void 0}function ee(t){return typeof t=="symbol"?t:"".concat(t)}function te(t,e,r){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(t,"name",{configurable:!0,value:r?"".concat(r," ",e):e})}function re(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function se(t,e,r,s){function o(a){return a instanceof r?a:new r(function(n){n(a)})}return new(r||(r=Promise))(function(a,n){function i(h){try{l(s.next(h))}catch(u){n(u)}}function c(h){try{l(s.throw(h))}catch(u){n(u)}}function l(h){h.done?a(h.value):o(h.value).then(i,c)}l((s=s.apply(t,e||[])).next())})}function ae(t,e){var r={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},s,o,a,n=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return n.next=i(0),n.throw=i(1),n.return=i(2),typeof Symbol=="function"&&(n[Symbol.iterator]=function(){return this}),n;function i(l){return function(h){return c([l,h])}}function c(l){if(s)throw new TypeError("Generator is already executing.");for(;n&&(n=0,l[0]&&(r=0)),r;)try{if(s=1,o&&(a=l[0]&2?o.return:l[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,l[1])).done)return a;switch(o=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,o=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(a=r.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){r.label=l[1];break}if(l[0]===6&&r.label<a[1]){r.label=a[1],a=l;break}if(a&&r.label<a[2]){r.label=a[2],r.ops.push(l);break}a[2]&&r.ops.pop(),r.trys.pop();continue}l=e.call(t,r)}catch(h){l=[6,h],o=0}finally{s=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function oe(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&A(e,t,r)}function k(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],s=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function B(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var s=r.call(t),o,a=[],n;try{for(;(e===void 0||e-- >0)&&!(o=s.next()).done;)a.push(o.value)}catch(i){n={error:i}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return a}function ne(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(B(arguments[e]));return t}function ie(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var s=Array(t),o=0,e=0;e<r;e++)for(var a=arguments[e],n=0,i=a.length;n<i;n++,o++)s[o]=a[n];return s}function le(t,e,r){if(r||arguments.length===2)for(var s=0,o=e.length,a;s<o;s++)(a||!(s in e))&&(a||(a=Array.prototype.slice.call(e,0,s)),a[s]=e[s]);return t.concat(a||Array.prototype.slice.call(e))}function P(t){return this instanceof P?(this.v=t,this):new P(t)}function he(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r.apply(t,e||[]),o,a=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),i("next"),i("throw"),i("return",n),o[Symbol.asyncIterator]=function(){return this},o;function n(d){return function(p){return Promise.resolve(p).then(d,u)}}function i(d,p){s[d]&&(o[d]=function(y){return new Promise(function(w,g){a.push([d,y,w,g])>1||c(d,y)})},p&&(o[d]=p(o[d])))}function c(d,p){try{l(s[d](p))}catch(y){f(a[0][3],y)}}function l(d){d.value instanceof P?Promise.resolve(d.value.v).then(h,u):f(a[0][2],d)}function h(d){c("next",d)}function u(d){c("throw",d)}function f(d,p){d(p),a.shift(),a.length&&c(a[0][0],a[0][1])}}function ce(t){var e,r;return e={},s("next"),s("throw",function(o){throw o}),s("return"),e[Symbol.iterator]=function(){return this},e;function s(o,a){e[o]=t[o]?function(n){return(r=!r)?{value:P(t[o](n)),done:!1}:a?a(n):n}:a}}function ue(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof k=="function"?k(t):t[Symbol.iterator](),r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r);function s(a){r[a]=t[a]&&function(n){return new Promise(function(i,c){n=t[a](n),o(i,c,n.done,n.value)})}}function o(a,n,i,c){Promise.resolve(c).then(function(l){a({value:l,done:i})},n)}}function de(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function pe(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r=N(t),s=0;s<r.length;s++)r[s]!=="default"&&A(e,t,r[s]);return _e(e,t),e}function fe(t){return t&&t.__esModule?t:{default:t}}function me(t,e,r,s){if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?s:r==="a"?s.call(t):s?s.value:e.get(t)}function ye(t,e,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 e=="function"?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?o.call(t,r):o?o.value=r:e.set(t,r),r}function ge(t,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof t=="function"?e===t:t.has(e)}function we(t,e,r){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var s,o;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=e[Symbol.asyncDispose]}if(s===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=e[Symbol.dispose],r&&(o=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");o&&(s=function(){try{o.call(this)}catch(a){return Promise.reject(a)}}),t.stack.push({value:e,dispose:s,async:r})}else r&&t.stack.push({async:!0});return e}function ve(t){function e(a){t.error=t.hasError?new Ee(a,t.error,"An error was suppressed during disposal."):a,t.hasError=!0}var r,s=0;function o(){for(;r=t.stack.pop();)try{if(!r.async&&s===1)return s=0,t.stack.push(r),Promise.resolve().then(o);if(r.dispose){var a=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(a).then(o,function(n){return e(n),o()})}else s|=1}catch(n){e(n)}if(s===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return o()}function be(t,e){return typeof t=="string"&&/^\.\.?\//.test(t)?t.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,s,o,a,n){return s?e?".jsx":".js":o&&(!a||!n)?r:o+a+"."+n.toLowerCase()+"js"}):t}var I,L,A,_e,N,Ee,Oe,T=J(()=>{"use strict";m(),I=function(t,e){return I=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])},I(t,e)},L=function(){return L=Object.assign||function(t){for(var e,r=1,s=arguments.length;r<s;r++){e=arguments[r];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},L.apply(this,arguments)},A=Object.create?(function(t,e,r,s){s===void 0&&(s=r);var o=Object.getOwnPropertyDescriptor(e,r);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,s,o)}):(function(t,e,r,s){s===void 0&&(s=r),t[s]=e[r]}),_e=Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e},N=function(t){return N=Object.getOwnPropertyNames||function(e){var r=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[r.length]=s);return r},N(t)},Ee=typeof SuppressedError=="function"?SuppressedError:function(t,e,r){var s=new Error(r);return s.name="SuppressedError",s.error=t,s.suppressed=e,s},Oe={__extends:K,__assign:L,__rest:V,__decorate:Y,__param:Q,__esDecorate:X,__runInitializers:Z,__propKey:ee,__setFunctionName:te,__metadata:re,__awaiter:se,__generator:ae,__createBinding:A,__exportStar:oe,__values:k,__read:B,__spread:ne,__spreadArrays:ie,__spreadArray:le,__await:P,__asyncGenerator:he,__asyncDelegator:ce,__asyncValues:ue,__makeTemplateObject:de,__importStar:pe,__importDefault:fe,__classPrivateFieldGet:me,__classPrivateFieldSet:ye,__classPrivateFieldIn:ge,__addDisposableResource:we,__disposeResources:ve,__rewriteRelativeImportExtension:be}}),Pe=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}};t.default=e}),Se=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=(T(),S(O)),r=e.__importDefault(Pe()),s=class{constructor(o){var a,n;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=(a=o.shouldThrowOnError)!==null&&a!==void 0?a:!1,this.signal=o.signal,this.isMaybeSingle=(n=o.isMaybeSingle)!==null&&n!==void 0?n:!1,o.fetch?this.fetch=o.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(o,a){return this.headers=new Headers(this.headers),this.headers.set(o,a),this}then(o,a){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 n=this.fetch,i=n(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async c=>{var l,h,u,f;let d=null,p=null,y=null,w=c.status,g=c.statusText;if(c.ok){if(this.method!=="HEAD"){let F=await c.text();F===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&!((l=this.headers.get("Accept"))===null||l===void 0)&&l.includes("application/vnd.pgrst.plan+text")?p=F:p=JSON.parse(F))}let $=(h=this.headers.get("Prefer"))===null||h===void 0?void 0:h.match(/count=(exact|planned|estimated)/),M=(u=c.headers.get("content-range"))===null||u===void 0?void 0:u.split("/");$&&M&&M.length>1&&(y=parseInt(M[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(p)&&(p.length>1?(d={code:"PGRST116",details:`Results contain ${p.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},p=null,y=null,w=406,g="Not Acceptable"):p.length===1?p=p[0]:p=null)}else{let $=await c.text();try{d=JSON.parse($),Array.isArray(d)&&c.status===404&&(p=[],d=null,w=200,g="OK")}catch{c.status===404&&$===""?(w=204,g="No Content"):d={message:$}}if(d&&this.isMaybeSingle&&!((f=d?.details)===null||f===void 0)&&f.includes("0 rows")&&(d=null,w=200,g="OK"),d&&this.shouldThrowOnError)throw new r.default(d)}return{error:d,data:p,count:y,status:w,statusText:g}});return this.shouldThrowOnError||(i=i.catch(c=>{var l,h,u;return{error:{message:`${(l=c?.name)!==null&&l!==void 0?l:"FetchError"}: ${c?.message}`,details:`${(h=c?.stack)!==null&&h!==void 0?h:""}`,hint:"",code:`${(u=c?.code)!==null&&u!==void 0?u:""}`},data:null,count:null,status:0,statusText:""}})),i.then(o,a)}returns(){return this}overrideTypes(){return this}};t.default=s}),Te=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=(T(),S(O)),r=e.__importDefault(Se()),s=class extends r.default{select(o){let a=!1,n=(o??"*").split("").map(i=>/\s/.test(i)&&!a?"":(i==='"'&&(a=!a),i)).join("");return this.url.searchParams.set("select",n),this.headers.append("Prefer","return=representation"),this}order(o,{ascending:a=!0,nullsFirst:n,foreignTable:i,referencedTable:c=i}={}){let l=c?`${c}.order`:"order",h=this.url.searchParams.get(l);return this.url.searchParams.set(l,`${h?`${h},`:""}${o}.${a?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(o,{foreignTable:a,referencedTable:n=a}={}){let i=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(i,`${o}`),this}range(o,a,{foreignTable:n,referencedTable:i=n}={}){let c=typeof i>"u"?"offset":`${i}.offset`,l=typeof i>"u"?"limit":`${i}.limit`;return this.url.searchParams.set(c,`${o}`),this.url.searchParams.set(l,`${a-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:a=!1,settings:n=!1,buffers:i=!1,wal:c=!1,format:l="text"}={}){var h;let u=[o?"analyze":null,a?"verbose":null,n?"settings":null,i?"buffers":null,c?"wal":null].filter(Boolean).join("|"),f=(h=this.headers.get("Accept"))!==null&&h!==void 0?h:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${l}; for="${f}"; options=${u};`),l==="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}};t.default=s}),q=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=(T(),S(O)),r=e.__importDefault(Te()),s=new RegExp("[,()]"),o=class extends r.default{eq(a,n){return this.url.searchParams.append(a,`eq.${n}`),this}neq(a,n){return this.url.searchParams.append(a,`neq.${n}`),this}gt(a,n){return this.url.searchParams.append(a,`gt.${n}`),this}gte(a,n){return this.url.searchParams.append(a,`gte.${n}`),this}lt(a,n){return this.url.searchParams.append(a,`lt.${n}`),this}lte(a,n){return this.url.searchParams.append(a,`lte.${n}`),this}like(a,n){return this.url.searchParams.append(a,`like.${n}`),this}likeAllOf(a,n){return this.url.searchParams.append(a,`like(all).{${n.join(",")}}`),this}likeAnyOf(a,n){return this.url.searchParams.append(a,`like(any).{${n.join(",")}}`),this}ilike(a,n){return this.url.searchParams.append(a,`ilike.${n}`),this}ilikeAllOf(a,n){return this.url.searchParams.append(a,`ilike(all).{${n.join(",")}}`),this}ilikeAnyOf(a,n){return this.url.searchParams.append(a,`ilike(any).{${n.join(",")}}`),this}is(a,n){return this.url.searchParams.append(a,`is.${n}`),this}in(a,n){let i=Array.from(new Set(n)).map(c=>typeof c=="string"&&s.test(c)?`"${c}"`:`${c}`).join(",");return this.url.searchParams.append(a,`in.(${i})`),this}contains(a,n){return typeof n=="string"?this.url.searchParams.append(a,`cs.${n}`):Array.isArray(n)?this.url.searchParams.append(a,`cs.{${n.join(",")}}`):this.url.searchParams.append(a,`cs.${JSON.stringify(n)}`),this}containedBy(a,n){return typeof n=="string"?this.url.searchParams.append(a,`cd.${n}`):Array.isArray(n)?this.url.searchParams.append(a,`cd.{${n.join(",")}}`):this.url.searchParams.append(a,`cd.${JSON.stringify(n)}`),this}rangeGt(a,n){return this.url.searchParams.append(a,`sr.${n}`),this}rangeGte(a,n){return this.url.searchParams.append(a,`nxl.${n}`),this}rangeLt(a,n){return this.url.searchParams.append(a,`sl.${n}`),this}rangeLte(a,n){return this.url.searchParams.append(a,`nxr.${n}`),this}rangeAdjacent(a,n){return this.url.searchParams.append(a,`adj.${n}`),this}overlaps(a,n){return typeof n=="string"?this.url.searchParams.append(a,`ov.${n}`):this.url.searchParams.append(a,`ov.{${n.join(",")}}`),this}textSearch(a,n,{config:i,type:c}={}){let l="";c==="plain"?l="pl":c==="phrase"?l="ph":c==="websearch"&&(l="w");let h=i===void 0?"":`(${i})`;return this.url.searchParams.append(a,`${l}fts${h}.${n}`),this}match(a){return Object.entries(a).forEach(([n,i])=>{this.url.searchParams.append(n,`eq.${i}`)}),this}not(a,n,i){return this.url.searchParams.append(a,`not.${n}.${i}`),this}or(a,{foreignTable:n,referencedTable:i=n}={}){let c=i?`${i}.or`:"or";return this.url.searchParams.append(c,`(${a})`),this}filter(a,n,i){return this.url.searchParams.append(a,`${n}.${i}`),this}};t.default=o}),$e=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=(T(),S(O)),r=e.__importDefault(q()),s=class{constructor(o,{headers:a={},schema:n,fetch:i}){this.url=o,this.headers=new Headers(a),this.schema=n,this.fetch=i}select(o,a){let{head:n=!1,count:i}=a??{},c=n?"HEAD":"GET",l=!1,h=(o??"*").split("").map(u=>/\s/.test(u)&&!l?"":(u==='"'&&(l=!l),u)).join("");return this.url.searchParams.set("select",h),i&&this.headers.append("Prefer",`count=${i}`),new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(o,{count:a,defaultToNull:n=!0}={}){var i;let c="POST";if(a&&this.headers.append("Prefer",`count=${a}`),n||this.headers.append("Prefer","missing=default"),Array.isArray(o)){let l=o.reduce((h,u)=>h.concat(Object.keys(u)),[]);if(l.length>0){let h=[...new Set(l)].map(u=>`"${u}"`);this.url.searchParams.set("columns",h.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})}upsert(o,{onConflict:a,ignoreDuplicates:n=!1,count:i,defaultToNull:c=!0}={}){var l;let h="POST";if(this.headers.append("Prefer",`resolution=${n?"ignore":"merge"}-duplicates`),a!==void 0&&this.url.searchParams.set("on_conflict",a),i&&this.headers.append("Prefer",`count=${i}`),c||this.headers.append("Prefer","missing=default"),Array.isArray(o)){let u=o.reduce((f,d)=>f.concat(Object.keys(d)),[]);if(u.length>0){let f=[...new Set(u)].map(d=>`"${d}"`);this.url.searchParams.set("columns",f.join(","))}}return new r.default({method:h,url:this.url,headers:this.headers,schema:this.schema,body:o,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}update(o,{count:a}={}){var n;let i="PATCH";return a&&this.headers.append("Prefer",`count=${a}`),new r.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:o,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}delete({count:o}={}){var a;let n="DELETE";return o&&this.headers.append("Prefer",`count=${o}`),new r.default({method:n,url:this.url,headers:this.headers,schema:this.schema,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}};t.default=s}),et=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=(T(),S(O)),r=e.__importDefault($e()),s=e.__importDefault(q()),o=class xe{constructor(n,{headers:i={},schema:c,fetch:l}={}){this.url=n,this.headers=new Headers(i),this.schemaName=c,this.fetch=l}from(n){let i=new URL(`${this.url}/${n}`);return new r.default(i,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(n){return new xe(this.url,{headers:this.headers,schema:n,fetch:this.fetch})}rpc(n,i={},{head:c=!1,get:l=!1,count:h}={}){var u;let f,d=new URL(`${this.url}/rpc/${n}`),p;c||l?(f=c?"HEAD":"GET",Object.entries(i).filter(([w,g])=>g!==void 0).map(([w,g])=>[w,Array.isArray(g)?`{${g.join(",")}}`:`${g}`]).forEach(([w,g])=>{d.searchParams.append(w,g)})):(f="POST",p=i);let y=new Headers(this.headers);return h&&y.set("Prefer",`count=${h}`),new s.default({method:f,url:d,headers:y,schema:this.schemaName,body:p,fetch:(u=this.fetch)!==null&&u!==void 0?u:fetch})}};t.default=o}),tt=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0}),t.PostgrestError=t.PostgrestBuilder=t.PostgrestTransformBuilder=t.PostgrestFilterBuilder=t.PostgrestQueryBuilder=t.PostgrestClient=void 0;var e=(T(),S(O)),r=e.__importDefault(et());t.PostgrestClient=r.default;var s=e.__importDefault($e());t.PostgrestQueryBuilder=s.default;var o=e.__importDefault(q());t.PostgrestFilterBuilder=o.default;var a=e.__importDefault(Te());t.PostgrestTransformBuilder=a.default;var n=e.__importDefault(Se());t.PostgrestBuilder=n.default;var i=e.__importDefault(Pe());t.PostgrestError=i.default,t.default={PostgrestClient:r.default,PostgrestQueryBuilder:s.default,PostgrestFilterBuilder:o.default,PostgrestTransformBuilder:a.default,PostgrestBuilder:n.default,PostgrestError:i.default}});m();m();var Le=class{constructor(t,e=""){this.http=t,this.baseUrl=e.replace(/\/$/,"")}async invoke(t,e){let r=this.baseUrl?`${this.baseUrl}/functions/${t}`:`/functions/${t}`;return await(await this.http.fetch(r,{method:e.method||"POST",body:e.body,headers:e.headers})).json()}};m();m();var v="nvwa_current_jwt",b="nvwa_login_token",x="nvwa_user_profile",rt="set-auth-token",st=typeof fetch<"u"?(t,e)=>fetch(t,e):()=>{throw new Error("AuthClient requires fetch")},Ae=class{constructor(t,e={}){this.baseUrl=t.replace(/\/$/,""),this.authPath=(e.authPath??"/auth").replace(/^\//,""),this.fetchImpl=e.fetchImpl??st,this.storage=e.storage??null,this.credentials=e.credentials??"omit",typeof console<"u"&&(console.warn("[NvwaAuth] init baseUrl:",this.baseUrl||"(empty)"),(!this.baseUrl||!this.baseUrl.startsWith("http://")&&!this.baseUrl.startsWith("https://"))&&console.warn("[NvwaAuth] baseUrl \u5E94\u4E3A\u5B8C\u6574\u5730\u5740\uFF08\u5982 https://xxx.nvwa.app\uFF09\uFF0C\u5426\u5219\u5C0F\u7A0B\u5E8F request \u4F1A\u62A5 invalid url"))}async currentUser(){if(this.storage){let r=await this.storage.get(x);if(r!=null)return r}let{data:t}=await this.getSession(),e=t?.user??null;return e&&this.storage&&await this.storage.set(x,e),e}async getCurrentJwt(){if(this.storage){let e=await this.storage.get(v);if(e!=null)return e;let r=await this.storage.get(b),{data:s}=await this.getToken(r??void 0);return s?.token?(await this.storage.set(v,s.token),s.token):null}let{data:t}=await this.getToken();return t?.token??null}async persistLogin(t,e){if(!this.storage)return;let r=e?.headers.get(rt)?.trim()||t.token||t.session?.token;r&&await this.storage.set(b,r),t.user&&await this.storage.set(x,t.user);let s=r??await this.storage.get(b),{data:o}=await this.getToken(s??void 0);o?.token&&await this.storage.set(v,o.token)}async clearLogin(){this.storage&&(await this.storage.remove(b),await this.storage.remove(x),await this.storage.remove(v))}url(t){let e=`${`${this.baseUrl.replace(/\/+$/,"")}/${this.authPath.replace(/^\/+/,"")}`}/${t.replace(/^\/+/,"")}`;return typeof console<"u"&&(console.warn("[NvwaAuth] request URL:",e),!e.startsWith("http://")&&!e.startsWith("https://")&&console.warn("[NvwaAuth] URL \u975E\u5B8C\u6574\u5730\u5740\uFF0C\u5C0F\u7A0B\u5E8F\u4F1A\u62A5 invalid url\uFF0C\u8BF7\u68C0\u67E5 Nvwa \u6784\u9020\u65F6\u4F20\u5165\u7684 baseUrl")),e}async getSession(){try{let t={};if(this.storage){let r=await this.storage.get(b)??await this.storage.get(v);r!=null&&(t.Authorization=`Bearer ${r}`)}let e=await this.fetchImpl(this.url("session"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return e.ok?{data:await e.json()}:{data:null,error:{message:await e.text()||e.statusText,status:e.status}}}catch(t){return{data:null,error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signInWithEmail(t,e){try{let r=await this.fetchImpl(this.url("sign-in/email"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify({email:t,password:e})}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let o=s?JSON.parse(s):void 0;return o&&await this.persistLogin({user:o.user,session:o.session},r),{data:o}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async signOut(){try{let t={};if(this.storage){let r=await this.storage.get(b)??await this.storage.get(v);r!=null&&(t.Authorization=`Bearer ${r}`)}let e=await this.fetchImpl(this.url("sign-out"),{method:"POST",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return await this.clearLogin(),e.ok?{}:{error:{message:await e.text()||e.statusText,status:e.status}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signUp(t){let e=await this.postJson("sign-up/email",t);return e.data&&await this.persistLogin(e.data,e.response),e}async getToken(t){try{let e={};if(t)e.Authorization=`Bearer ${t}`;else if(this.storage){let a=await this.storage.get(b)??await this.storage.get(v);a!=null&&(e.Authorization=`Bearer ${a}`)}let r=await this.fetchImpl(this.url("token"),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let o=s?JSON.parse(s):void 0;return{data:o?.token!=null?{token:o.token}:void 0}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signInWithUsername(t,e){let r=await this.postJson("sign-in/username",{username:t,password:e});return r.data&&await this.persistLogin(r.data,r.response),r}async signInWithPhoneNumber(t,e,r){let s=await this.postJson("sign-in/phone-number",{phoneNumber:t,password:e,rememberMe:r});return s.data&&await this.persistLogin(s.data,s.response),s}async sendPhoneNumberOtp(t){let e=await this.postJson("phone-number/send-otp",{phoneNumber:t});return e.error?{error:e.error}:{}}async verifyPhoneNumber(t,e){let r=await this.postJson("phone-number/verify",{phoneNumber:t,code:e});return r.data&&await this.persistLogin(r.data,r.response),r}async loginWithWeChatCode(t,e){try{let r={"Content-Type":"application/json"};if(this.storage){let n=await this.storage.get(v);n!=null&&(r.Authorization=`Bearer ${n}`)}let s=await this.fetchImpl(this.url("wechat/openplatform/sign-in"),{method:"POST",headers:r,credentials:this.credentials,body:JSON.stringify({code:t,applicationCode:e})}),o=await s.text();if(!s.ok)return{error:{message:o||s.statusText,status:s.status}};let a=o?JSON.parse(o):null;return!a?.token||!a.user?{error:{message:"invalid_wechat_login_response",status:502}}:(this.storage&&(await this.storage.set(v,a.token),await this.storage.set(b,a.token),await this.storage.set(x,a.user)),{data:a})}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async getWeChatOpenPlatformIdentity(t){try{let e={};if(this.storage){let n=await this.storage.get(v);n!=null&&(e.Authorization=`Bearer ${n}`)}let r=t?.trim()?`?appId=${encodeURIComponent(t.trim())}`:"",s=await this.fetchImpl(this.url(`wechat/openplatform/identity${r}`),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),o=await s.text();if(!s.ok)return{error:{message:o||s.statusText,status:s.status}};let a=o?JSON.parse(o):null;return!a?.openid||!a.appId?{error:{message:"invalid_wechat_identity_response",status:502}}:{data:a}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async postJson(t,e){try{let r=await this.fetchImpl(this.url(t),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify(e)}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let o=s?JSON.parse(s):void 0;return{data:o?.data??o??void 0,response:r}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}};m();m();var _=class Ce{constructor(e){if(this.headerMap=new Map,e){if(e instanceof Ce)e.forEach((r,s)=>this.set(s,r));else if(Array.isArray(e))for(let[r,s]of e)this.set(r,String(s));else if(typeof e=="object")for(let r of Object.keys(e))this.set(r,String(e[r]))}}append(e,r){let s=e.toLowerCase(),o=this.headerMap.get(s);this.headerMap.set(s,o?`${o}, ${r}`:r)}set(e,r){this.headerMap.set(e.toLowerCase(),String(r))}get(e){return this.headerMap.get(e.toLowerCase())??null}has(e){return this.headerMap.has(e.toLowerCase())}delete(e){this.headerMap.delete(e.toLowerCase())}forEach(e){for(let[r,s]of this.headerMap.entries())e(s,r,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}};m();m();var je=class{constructor(t,e){this.bodyData=t,this.status=e?.status??200,this.statusText=e?.statusText??"",this.headers=at(e?.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 t=await this.text();return new TextEncoder().encode(t).buffer}};function at(t){return t?new _(t):new _}m();m();var Ie=class{constructor(t,e,r){this.storage=t,this.customFetch=e,this.handleUnauthorized=r}async fetch(t,e){return await this.customFetch(t,e)}async fetchWithAuth(t,e){let r=await this.storage.get(v),s=new _(e?.headers);r&&s.set("Authorization",`Bearer ${r}`);let o=e?.method||"GET";if((o==="POST"||o==="PUT"||o==="PATCH")&&e?.body){let n=s.get("Content-Type");(!n||n.includes("text/plain"))&&s.set("Content-Type","application/json")}let a=await this.customFetch(t,{...e,headers:s});if(a.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return a}};m();var ot="/storage",nt=ot+"/generateUploadUrl",Ne=class{constructor(t,e){this.baseUrl=t,this.http=e}async uploadFile(t){let e=await this.http.fetch(this.baseUrl+nt,{method:"POST",body:{fileName:t.name||t.fileName,fileSize:t.size||t.fileSize,fileType:t.type||t.fileType}}),{url:r}=await e.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(r,{method:"PUT",body:t,headers:new _({"Content-Type":t.type||t.fileType||"application/octet-stream"})}),{url:o}=await s.json();return{url:o.split("?")[0]}}};m();m();m();var W=Ze(tt(),1),{PostgrestClient:it,PostgrestQueryBuilder:wt,PostgrestFilterBuilder:vt,PostgrestTransformBuilder:bt,PostgrestBuilder:_t,PostgrestError:Et}=W.default||W,lt="/entities",ke=(t,e)=>new it(t+lt,{fetch:e.fetchWithAuth.bind(e)});m();var Re=class{constructor(t,e){this.baseUrl=t,this.http=e}async execute(t,e){let r=`${this.baseUrl}/capability/${t}/execute`,s=await(await this.http.fetchWithAuth(r,{method:"POST",body:e?JSON.stringify(e):void 0,timeout:6e5})).json();if(s.status!==200)throw new Error(s.message);return s.data}};m();var He=class{constructor(t,e){this.baseUrl=t,this.http=e}async execute(t,e){let r=`${this.baseUrl}/capability/${t}/execute`,s=await(await this.http.fetchWithAuth(r,{method:"POST",body:e!=null?JSON.stringify(e):void 0,timeout:6e5})).json();if(s.status!==200)throw new Error(s.message);return s.data}};m();var Ue=class{constructor(){this.hoverOverlay=null,this.selectedOverlay=null,this.tooltip=null,this.hoverElement=null,this.selectedElement=null,this.hoverUpdateHandler=null,this.selectedUpdateHandler=null,this.createStyles()}createStyles(){if(document.getElementById("__nvwa-inspector-overlay-style"))return;let t=document.createElement("style");t.id="__nvwa-inspector-overlay-style",t.textContent=`
|
|
2
2
|
.__nvwa-inspector-overlay {
|
|
3
3
|
position: absolute;
|
|
4
4
|
pointer-events: none;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var De=Object.create,R=Object.defineProperty,Be=Object.getOwnPropertyDescriptor,qe=Object.getOwnPropertyNames,ze=Object.getPrototypeOf,We=Object.prototype.hasOwnProperty,W=(t,e)=>()=>(t&&(e=t(t=0)),e),E=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Je=(t,e)=>{for(var r in e)R(t,r,{get:e[r],enumerable:!0})},J=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of qe(e))!We.call(t,o)&&o!==r&&R(t,o,{get:()=>e[o],enumerable:!(s=Be(e,o))||s.enumerable});return t},Ge=(t,e,r)=>(r=t!=null?De(ze(t)):{},J(e||!t||!t.__esModule?R(r,"default",{value:t,enumerable:!0}):r,t)),S=t=>J(R({},"__esModule",{value:!0}),t),m=W(()=>{"use strict"}),O={};Je(O,{__addDisposableResource:()=>ge,__assign:()=>L,__asyncDelegator:()=>he,__asyncGenerator:()=>le,__asyncValues:()=>ce,__await:()=>P,__awaiter:()=>re,__classPrivateFieldGet:()=>fe,__classPrivateFieldIn:()=>ye,__classPrivateFieldSet:()=>me,__createBinding:()=>A,__decorate:()=>V,__disposeResources:()=>we,__esDecorate:()=>Q,__exportStar:()=>ae,__extends:()=>G,__generator:()=>se,__importDefault:()=>pe,__importStar:()=>de,__makeTemplateObject:()=>ue,__metadata:()=>te,__param:()=>Y,__propKey:()=>Z,__read:()=>D,__rest:()=>K,__rewriteRelativeImportExtension:()=>ve,__runInitializers:()=>X,__setFunctionName:()=>ee,__spread:()=>oe,__spreadArray:()=>ie,__spreadArrays:()=>ne,__values:()=>k,default:()=>Ee});function G(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");I(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function K(t,e){var r={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(r[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,s=Object.getOwnPropertySymbols(t);o<s.length;o++)e.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(t,s[o])&&(r[s[o]]=t[s[o]]);return r}function V(t,e,r,s){var o=arguments.length,a=o<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,r):s,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,s);else for(var i=t.length-1;i>=0;i--)(n=t[i])&&(a=(o<3?n(a):o>3?n(e,r,a):n(e,r))||a);return o>3&&a&&Object.defineProperty(e,r,a),a}function Y(t,e){return function(r,s){e(r,s,t)}}function Q(t,e,r,s,o,a){function n(g){if(g!==void 0&&typeof g!="function")throw new TypeError("Function expected");return g}for(var i=s.kind,c=i==="getter"?"get":i==="setter"?"set":"value",l=!e&&t?s.static?t:t.prototype:null,h=e||(l?Object.getOwnPropertyDescriptor(l,s.name):{}),u,f=!1,d=r.length-1;d>=0;d--){var p={};for(var y in s)p[y]=y==="access"?{}:s[y];for(var y in s.access)p.access[y]=s.access[y];p.addInitializer=function(g){if(f)throw new TypeError("Cannot add initializers after decoration has completed");a.push(n(g||null))};var w=(0,r[d])(i==="accessor"?{get:h.get,set:h.set}:h[c],p);if(i==="accessor"){if(w===void 0)continue;if(w===null||typeof w!="object")throw new TypeError("Object expected");(u=n(w.get))&&(h.get=u),(u=n(w.set))&&(h.set=u),(u=n(w.init))&&o.unshift(u)}else(u=n(w))&&(i==="field"?o.unshift(u):h[c]=u)}l&&Object.defineProperty(l,s.name,h),f=!0}function X(t,e,r){for(var s=arguments.length>2,o=0;o<e.length;o++)r=s?e[o].call(t,r):e[o].call(t);return s?r:void 0}function Z(t){return typeof t=="symbol"?t:"".concat(t)}function ee(t,e,r){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(t,"name",{configurable:!0,value:r?"".concat(r," ",e):e})}function te(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function re(t,e,r,s){function o(a){return a instanceof r?a:new r(function(n){n(a)})}return new(r||(r=Promise))(function(a,n){function i(h){try{l(s.next(h))}catch(u){n(u)}}function c(h){try{l(s.throw(h))}catch(u){n(u)}}function l(h){h.done?a(h.value):o(h.value).then(i,c)}l((s=s.apply(t,e||[])).next())})}function se(t,e){var r={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},s,o,a,n=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return n.next=i(0),n.throw=i(1),n.return=i(2),typeof Symbol=="function"&&(n[Symbol.iterator]=function(){return this}),n;function i(l){return function(h){return c([l,h])}}function c(l){if(s)throw new TypeError("Generator is already executing.");for(;n&&(n=0,l[0]&&(r=0)),r;)try{if(s=1,o&&(a=l[0]&2?o.return:l[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,l[1])).done)return a;switch(o=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,o=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(a=r.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){r.label=l[1];break}if(l[0]===6&&r.label<a[1]){r.label=a[1],a=l;break}if(a&&r.label<a[2]){r.label=a[2],r.ops.push(l);break}a[2]&&r.ops.pop(),r.trys.pop();continue}l=e.call(t,r)}catch(h){l=[6,h],o=0}finally{s=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function ae(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&A(e,t,r)}function k(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],s=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function D(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var s=r.call(t),o,a=[],n;try{for(;(e===void 0||e-- >0)&&!(o=s.next()).done;)a.push(o.value)}catch(i){n={error:i}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return a}function oe(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(D(arguments[e]));return t}function ne(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var s=Array(t),o=0,e=0;e<r;e++)for(var a=arguments[e],n=0,i=a.length;n<i;n++,o++)s[o]=a[n];return s}function ie(t,e,r){if(r||arguments.length===2)for(var s=0,o=e.length,a;s<o;s++)(a||!(s in e))&&(a||(a=Array.prototype.slice.call(e,0,s)),a[s]=e[s]);return t.concat(a||Array.prototype.slice.call(e))}function P(t){return this instanceof P?(this.v=t,this):new P(t)}function le(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r.apply(t,e||[]),o,a=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),i("next"),i("throw"),i("return",n),o[Symbol.asyncIterator]=function(){return this},o;function n(d){return function(p){return Promise.resolve(p).then(d,u)}}function i(d,p){s[d]&&(o[d]=function(y){return new Promise(function(w,g){a.push([d,y,w,g])>1||c(d,y)})},p&&(o[d]=p(o[d])))}function c(d,p){try{l(s[d](p))}catch(y){f(a[0][3],y)}}function l(d){d.value instanceof P?Promise.resolve(d.value.v).then(h,u):f(a[0][2],d)}function h(d){c("next",d)}function u(d){c("throw",d)}function f(d,p){d(p),a.shift(),a.length&&c(a[0][0],a[0][1])}}function he(t){var e,r;return e={},s("next"),s("throw",function(o){throw o}),s("return"),e[Symbol.iterator]=function(){return this},e;function s(o,a){e[o]=t[o]?function(n){return(r=!r)?{value:P(t[o](n)),done:!1}:a?a(n):n}:a}}function ce(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof k=="function"?k(t):t[Symbol.iterator](),r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r);function s(a){r[a]=t[a]&&function(n){return new Promise(function(i,c){n=t[a](n),o(i,c,n.done,n.value)})}}function o(a,n,i,c){Promise.resolve(c).then(function(l){a({value:l,done:i})},n)}}function ue(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function de(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r=N(t),s=0;s<r.length;s++)r[s]!=="default"&&A(e,t,r[s]);return be(e,t),e}function pe(t){return t&&t.__esModule?t:{default:t}}function fe(t,e,r,s){if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?s:r==="a"?s.call(t):s?s.value:e.get(t)}function me(t,e,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 e=="function"?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?o.call(t,r):o?o.value=r:e.set(t,r),r}function ye(t,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof t=="function"?e===t:t.has(e)}function ge(t,e,r){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var s,o;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=e[Symbol.asyncDispose]}if(s===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=e[Symbol.dispose],r&&(o=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");o&&(s=function(){try{o.call(this)}catch(a){return Promise.reject(a)}}),t.stack.push({value:e,dispose:s,async:r})}else r&&t.stack.push({async:!0});return e}function we(t){function e(a){t.error=t.hasError?new _e(a,t.error,"An error was suppressed during disposal."):a,t.hasError=!0}var r,s=0;function o(){for(;r=t.stack.pop();)try{if(!r.async&&s===1)return s=0,t.stack.push(r),Promise.resolve().then(o);if(r.dispose){var a=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(a).then(o,function(n){return e(n),o()})}else s|=1}catch(n){e(n)}if(s===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return o()}function ve(t,e){return typeof t=="string"&&/^\.\.?\//.test(t)?t.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,s,o,a,n){return s?e?".jsx":".js":o&&(!a||!n)?r:o+a+"."+n.toLowerCase()+"js"}):t}var I,L,A,be,N,_e,Ee,T=W(()=>{"use strict";m(),I=function(t,e){return I=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])},I(t,e)},L=function(){return L=Object.assign||function(t){for(var e,r=1,s=arguments.length;r<s;r++){e=arguments[r];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},L.apply(this,arguments)},A=Object.create?(function(t,e,r,s){s===void 0&&(s=r);var o=Object.getOwnPropertyDescriptor(e,r);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,s,o)}):(function(t,e,r,s){s===void 0&&(s=r),t[s]=e[r]}),be=Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e},N=function(t){return N=Object.getOwnPropertyNames||function(e){var r=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[r.length]=s);return r},N(t)},_e=typeof SuppressedError=="function"?SuppressedError:function(t,e,r){var s=new Error(r);return s.name="SuppressedError",s.error=t,s.suppressed=e,s},Ee={__extends:G,__assign:L,__rest:K,__decorate:V,__param:Y,__esDecorate:Q,__runInitializers:X,__propKey:Z,__setFunctionName:ee,__metadata:te,__awaiter:re,__generator:se,__createBinding:A,__exportStar:ae,__values:k,__read:D,__spread:oe,__spreadArrays:ne,__spreadArray:ie,__await:P,__asyncGenerator:le,__asyncDelegator:he,__asyncValues:ce,__makeTemplateObject:ue,__importStar:de,__importDefault:pe,__classPrivateFieldGet:fe,__classPrivateFieldSet:me,__classPrivateFieldIn:ye,__addDisposableResource:ge,__disposeResources:we,__rewriteRelativeImportExtension:ve}}),Oe=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}};t.default=e}),Pe=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=(T(),S(O)),r=e.__importDefault(Oe()),s=class{constructor(o){var a,n;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=(a=o.shouldThrowOnError)!==null&&a!==void 0?a:!1,this.signal=o.signal,this.isMaybeSingle=(n=o.isMaybeSingle)!==null&&n!==void 0?n:!1,o.fetch?this.fetch=o.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(o,a){return this.headers=new Headers(this.headers),this.headers.set(o,a),this}then(o,a){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 n=this.fetch,i=n(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async c=>{var l,h,u,f;let d=null,p=null,y=null,w=c.status,g=c.statusText;if(c.ok){if(this.method!=="HEAD"){let F=await c.text();F===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&!((l=this.headers.get("Accept"))===null||l===void 0)&&l.includes("application/vnd.pgrst.plan+text")?p=F:p=JSON.parse(F))}let $=(h=this.headers.get("Prefer"))===null||h===void 0?void 0:h.match(/count=(exact|planned|estimated)/),M=(u=c.headers.get("content-range"))===null||u===void 0?void 0:u.split("/");$&&M&&M.length>1&&(y=parseInt(M[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(p)&&(p.length>1?(d={code:"PGRST116",details:`Results contain ${p.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},p=null,y=null,w=406,g="Not Acceptable"):p.length===1?p=p[0]:p=null)}else{let $=await c.text();try{d=JSON.parse($),Array.isArray(d)&&c.status===404&&(p=[],d=null,w=200,g="OK")}catch{c.status===404&&$===""?(w=204,g="No Content"):d={message:$}}if(d&&this.isMaybeSingle&&!((f=d?.details)===null||f===void 0)&&f.includes("0 rows")&&(d=null,w=200,g="OK"),d&&this.shouldThrowOnError)throw new r.default(d)}return{error:d,data:p,count:y,status:w,statusText:g}});return this.shouldThrowOnError||(i=i.catch(c=>{var l,h,u;return{error:{message:`${(l=c?.name)!==null&&l!==void 0?l:"FetchError"}: ${c?.message}`,details:`${(h=c?.stack)!==null&&h!==void 0?h:""}`,hint:"",code:`${(u=c?.code)!==null&&u!==void 0?u:""}`},data:null,count:null,status:0,statusText:""}})),i.then(o,a)}returns(){return this}overrideTypes(){return this}};t.default=s}),Se=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=(T(),S(O)),r=e.__importDefault(Pe()),s=class extends r.default{select(o){let a=!1,n=(o??"*").split("").map(i=>/\s/.test(i)&&!a?"":(i==='"'&&(a=!a),i)).join("");return this.url.searchParams.set("select",n),this.headers.append("Prefer","return=representation"),this}order(o,{ascending:a=!0,nullsFirst:n,foreignTable:i,referencedTable:c=i}={}){let l=c?`${c}.order`:"order",h=this.url.searchParams.get(l);return this.url.searchParams.set(l,`${h?`${h},`:""}${o}.${a?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(o,{foreignTable:a,referencedTable:n=a}={}){let i=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(i,`${o}`),this}range(o,a,{foreignTable:n,referencedTable:i=n}={}){let c=typeof i>"u"?"offset":`${i}.offset`,l=typeof i>"u"?"limit":`${i}.limit`;return this.url.searchParams.set(c,`${o}`),this.url.searchParams.set(l,`${a-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:a=!1,settings:n=!1,buffers:i=!1,wal:c=!1,format:l="text"}={}){var h;let u=[o?"analyze":null,a?"verbose":null,n?"settings":null,i?"buffers":null,c?"wal":null].filter(Boolean).join("|"),f=(h=this.headers.get("Accept"))!==null&&h!==void 0?h:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${l}; for="${f}"; options=${u};`),l==="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}};t.default=s}),B=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=(T(),S(O)),r=e.__importDefault(Se()),s=new RegExp("[,()]"),o=class extends r.default{eq(a,n){return this.url.searchParams.append(a,`eq.${n}`),this}neq(a,n){return this.url.searchParams.append(a,`neq.${n}`),this}gt(a,n){return this.url.searchParams.append(a,`gt.${n}`),this}gte(a,n){return this.url.searchParams.append(a,`gte.${n}`),this}lt(a,n){return this.url.searchParams.append(a,`lt.${n}`),this}lte(a,n){return this.url.searchParams.append(a,`lte.${n}`),this}like(a,n){return this.url.searchParams.append(a,`like.${n}`),this}likeAllOf(a,n){return this.url.searchParams.append(a,`like(all).{${n.join(",")}}`),this}likeAnyOf(a,n){return this.url.searchParams.append(a,`like(any).{${n.join(",")}}`),this}ilike(a,n){return this.url.searchParams.append(a,`ilike.${n}`),this}ilikeAllOf(a,n){return this.url.searchParams.append(a,`ilike(all).{${n.join(",")}}`),this}ilikeAnyOf(a,n){return this.url.searchParams.append(a,`ilike(any).{${n.join(",")}}`),this}is(a,n){return this.url.searchParams.append(a,`is.${n}`),this}in(a,n){let i=Array.from(new Set(n)).map(c=>typeof c=="string"&&s.test(c)?`"${c}"`:`${c}`).join(",");return this.url.searchParams.append(a,`in.(${i})`),this}contains(a,n){return typeof n=="string"?this.url.searchParams.append(a,`cs.${n}`):Array.isArray(n)?this.url.searchParams.append(a,`cs.{${n.join(",")}}`):this.url.searchParams.append(a,`cs.${JSON.stringify(n)}`),this}containedBy(a,n){return typeof n=="string"?this.url.searchParams.append(a,`cd.${n}`):Array.isArray(n)?this.url.searchParams.append(a,`cd.{${n.join(",")}}`):this.url.searchParams.append(a,`cd.${JSON.stringify(n)}`),this}rangeGt(a,n){return this.url.searchParams.append(a,`sr.${n}`),this}rangeGte(a,n){return this.url.searchParams.append(a,`nxl.${n}`),this}rangeLt(a,n){return this.url.searchParams.append(a,`sl.${n}`),this}rangeLte(a,n){return this.url.searchParams.append(a,`nxr.${n}`),this}rangeAdjacent(a,n){return this.url.searchParams.append(a,`adj.${n}`),this}overlaps(a,n){return typeof n=="string"?this.url.searchParams.append(a,`ov.${n}`):this.url.searchParams.append(a,`ov.{${n.join(",")}}`),this}textSearch(a,n,{config:i,type:c}={}){let l="";c==="plain"?l="pl":c==="phrase"?l="ph":c==="websearch"&&(l="w");let h=i===void 0?"":`(${i})`;return this.url.searchParams.append(a,`${l}fts${h}.${n}`),this}match(a){return Object.entries(a).forEach(([n,i])=>{this.url.searchParams.append(n,`eq.${i}`)}),this}not(a,n,i){return this.url.searchParams.append(a,`not.${n}.${i}`),this}or(a,{foreignTable:n,referencedTable:i=n}={}){let c=i?`${i}.or`:"or";return this.url.searchParams.append(c,`(${a})`),this}filter(a,n,i){return this.url.searchParams.append(a,`${n}.${i}`),this}};t.default=o}),Te=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=(T(),S(O)),r=e.__importDefault(B()),s=class{constructor(o,{headers:a={},schema:n,fetch:i}){this.url=o,this.headers=new Headers(a),this.schema=n,this.fetch=i}select(o,a){let{head:n=!1,count:i}=a??{},c=n?"HEAD":"GET",l=!1,h=(o??"*").split("").map(u=>/\s/.test(u)&&!l?"":(u==='"'&&(l=!l),u)).join("");return this.url.searchParams.set("select",h),i&&this.headers.append("Prefer",`count=${i}`),new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(o,{count:a,defaultToNull:n=!0}={}){var i;let c="POST";if(a&&this.headers.append("Prefer",`count=${a}`),n||this.headers.append("Prefer","missing=default"),Array.isArray(o)){let l=o.reduce((h,u)=>h.concat(Object.keys(u)),[]);if(l.length>0){let h=[...new Set(l)].map(u=>`"${u}"`);this.url.searchParams.set("columns",h.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})}upsert(o,{onConflict:a,ignoreDuplicates:n=!1,count:i,defaultToNull:c=!0}={}){var l;let h="POST";if(this.headers.append("Prefer",`resolution=${n?"ignore":"merge"}-duplicates`),a!==void 0&&this.url.searchParams.set("on_conflict",a),i&&this.headers.append("Prefer",`count=${i}`),c||this.headers.append("Prefer","missing=default"),Array.isArray(o)){let u=o.reduce((f,d)=>f.concat(Object.keys(d)),[]);if(u.length>0){let f=[...new Set(u)].map(d=>`"${d}"`);this.url.searchParams.set("columns",f.join(","))}}return new r.default({method:h,url:this.url,headers:this.headers,schema:this.schema,body:o,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}update(o,{count:a}={}){var n;let i="PATCH";return a&&this.headers.append("Prefer",`count=${a}`),new r.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:o,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}delete({count:o}={}){var a;let n="DELETE";return o&&this.headers.append("Prefer",`count=${o}`),new r.default({method:n,url:this.url,headers:this.headers,schema:this.schema,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}};t.default=s}),Ke=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=(T(),S(O)),r=e.__importDefault(Te()),s=e.__importDefault(B()),o=class $e{constructor(n,{headers:i={},schema:c,fetch:l}={}){this.url=n,this.headers=new Headers(i),this.schemaName=c,this.fetch=l}from(n){let i=new URL(`${this.url}/${n}`);return new r.default(i,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(n){return new $e(this.url,{headers:this.headers,schema:n,fetch:this.fetch})}rpc(n,i={},{head:c=!1,get:l=!1,count:h}={}){var u;let f,d=new URL(`${this.url}/rpc/${n}`),p;c||l?(f=c?"HEAD":"GET",Object.entries(i).filter(([w,g])=>g!==void 0).map(([w,g])=>[w,Array.isArray(g)?`{${g.join(",")}}`:`${g}`]).forEach(([w,g])=>{d.searchParams.append(w,g)})):(f="POST",p=i);let y=new Headers(this.headers);return h&&y.set("Prefer",`count=${h}`),new s.default({method:f,url:d,headers:y,schema:this.schemaName,body:p,fetch:(u=this.fetch)!==null&&u!==void 0?u:fetch})}};t.default=o}),Ve=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0}),t.PostgrestError=t.PostgrestBuilder=t.PostgrestTransformBuilder=t.PostgrestFilterBuilder=t.PostgrestQueryBuilder=t.PostgrestClient=void 0;var e=(T(),S(O)),r=e.__importDefault(Ke());t.PostgrestClient=r.default;var s=e.__importDefault(Te());t.PostgrestQueryBuilder=s.default;var o=e.__importDefault(B());t.PostgrestFilterBuilder=o.default;var a=e.__importDefault(Se());t.PostgrestTransformBuilder=a.default;var n=e.__importDefault(Pe());t.PostgrestBuilder=n.default;var i=e.__importDefault(Oe());t.PostgrestError=i.default,t.default={PostgrestClient:r.default,PostgrestQueryBuilder:s.default,PostgrestFilterBuilder:o.default,PostgrestTransformBuilder:a.default,PostgrestBuilder:n.default,PostgrestError:i.default}});m();m();var xe=class{constructor(t,e=""){this.http=t,this.baseUrl=e.replace(/\/$/,"")}async invoke(t,e){let r=this.baseUrl?`${this.baseUrl}/functions/${t}`:`/functions/${t}`;return await(await this.http.fetch(r,{method:e.method||"POST",body:e.body,headers:e.headers})).json()}};m();m();var v="nvwa_current_jwt",b="nvwa_login_token",x="nvwa_user_profile",Ye="set-auth-token",Qe=typeof fetch<"u"?(t,e)=>fetch(t,e):()=>{throw new Error("AuthClient requires fetch")},Le=class{constructor(t,e={}){this.baseUrl=t.replace(/\/$/,""),this.authPath=(e.authPath??"/auth").replace(/^\//,""),this.fetchImpl=e.fetchImpl??Qe,this.storage=e.storage??null,this.credentials=e.credentials??"omit",typeof console<"u"&&(console.warn("[NvwaAuth] init baseUrl:",this.baseUrl||"(empty)"),(!this.baseUrl||!this.baseUrl.startsWith("http://")&&!this.baseUrl.startsWith("https://"))&&console.warn("[NvwaAuth] baseUrl \u5E94\u4E3A\u5B8C\u6574\u5730\u5740\uFF08\u5982 https://xxx.nvwa.app\uFF09\uFF0C\u5426\u5219\u5C0F\u7A0B\u5E8F request \u4F1A\u62A5 invalid url"))}async currentUser(){if(this.storage){let r=await this.storage.get(x);if(r!=null)return r}let{data:t}=await this.getSession(),e=t?.user??null;return e&&this.storage&&await this.storage.set(x,e),e}async getCurrentJwt(){if(this.storage){let e=await this.storage.get(v);if(e!=null)return e;let r=await this.storage.get(b),{data:s}=await this.getToken(r??void 0);return s?.token?(await this.storage.set(v,s.token),s.token):null}let{data:t}=await this.getToken();return t?.token??null}async persistLogin(t,e){if(!this.storage)return;let r=e?.headers.get(Ye)?.trim()||t.token||t.session?.token;r&&await this.storage.set(b,r),t.user&&await this.storage.set(x,t.user);let s=r??await this.storage.get(b),{data:o}=await this.getToken(s??void 0);o?.token&&await this.storage.set(v,o.token)}async clearLogin(){this.storage&&(await this.storage.remove(b),await this.storage.remove(x),await this.storage.remove(v))}url(t){let e=`${`${this.baseUrl.replace(/\/+$/,"")}/${this.authPath.replace(/^\/+/,"")}`}/${t.replace(/^\/+/,"")}`;return typeof console<"u"&&(console.warn("[NvwaAuth] request URL:",e),!e.startsWith("http://")&&!e.startsWith("https://")&&console.warn("[NvwaAuth] URL \u975E\u5B8C\u6574\u5730\u5740\uFF0C\u5C0F\u7A0B\u5E8F\u4F1A\u62A5 invalid url\uFF0C\u8BF7\u68C0\u67E5 Nvwa \u6784\u9020\u65F6\u4F20\u5165\u7684 baseUrl")),e}async getSession(){try{let t={};if(this.storage){let r=await this.storage.get(b)??await this.storage.get(v);r!=null&&(t.Authorization=`Bearer ${r}`)}let e=await this.fetchImpl(this.url("session"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return e.ok?{data:await e.json()}:{data:null,error:{message:await e.text()||e.statusText,status:e.status}}}catch(t){return{data:null,error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signInWithEmail(t,e){try{let r=await this.fetchImpl(this.url("sign-in/email"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify({email:t,password:e})}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let o=s?JSON.parse(s):void 0;return o&&await this.persistLogin({user:o.user,session:o.session},r),{data:o}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async signOut(){try{let t={};if(this.storage){let r=await this.storage.get(b)??await this.storage.get(v);r!=null&&(t.Authorization=`Bearer ${r}`)}let e=await this.fetchImpl(this.url("sign-out"),{method:"POST",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return await this.clearLogin(),e.ok?{}:{error:{message:await e.text()||e.statusText,status:e.status}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signUp(t){let e=await this.postJson("sign-up/email",t);return e.data&&await this.persistLogin(e.data,e.response),e}async getToken(t){try{let e={};if(t)e.Authorization=`Bearer ${t}`;else if(this.storage){let a=await this.storage.get(b)??await this.storage.get(v);a!=null&&(e.Authorization=`Bearer ${a}`)}let r=await this.fetchImpl(this.url("token"),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let o=s?JSON.parse(s):void 0;return{data:o?.token!=null?{token:o.token}:void 0}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signInWithUsername(t,e){let r=await this.postJson("sign-in/username",{username:t,password:e});return r.data&&await this.persistLogin(r.data,r.response),r}async signInWithPhoneNumber(t,e,r){let s=await this.postJson("sign-in/phone-number",{phoneNumber:t,password:e,rememberMe:r});return s.data&&await this.persistLogin(s.data,s.response),s}async sendPhoneNumberOtp(t){let e=await this.postJson("phone-number/send-otp",{phoneNumber:t});return e.error?{error:e.error}:{}}async verifyPhoneNumber(t,e){let r=await this.postJson("phone-number/verify",{phoneNumber:t,code:e});return r.data&&await this.persistLogin(r.data,r.response),r}async loginWithWeChatCode(t,e){try{let r={"Content-Type":"application/json"};if(this.storage){let n=await this.storage.get(v);n!=null&&(r.Authorization=`Bearer ${n}`)}let s=await this.fetchImpl(this.url("wechat/openplatform/sign-in"),{method:"POST",headers:r,credentials:this.credentials,body:JSON.stringify({code:t,applicationCode:e})}),o=await s.text();if(!s.ok)return{error:{message:o||s.statusText,status:s.status}};let a=o?JSON.parse(o):null;return!a?.token||!a.user?{error:{message:"invalid_wechat_login_response",status:502}}:(this.storage&&(await this.storage.set(v,a.token),await this.storage.set(b,a.token),await this.storage.set(x,a.user)),{data:a})}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async postJson(t,e){try{let r=await this.fetchImpl(this.url(t),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify(e)}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let o=s?JSON.parse(s):void 0;return{data:o?.data??o??void 0,response:r}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}};m();m();var _=class Ae{constructor(e){if(this.headerMap=new Map,e){if(e instanceof Ae)e.forEach((r,s)=>this.set(s,r));else if(Array.isArray(e))for(let[r,s]of e)this.set(r,String(s));else if(typeof e=="object")for(let r of Object.keys(e))this.set(r,String(e[r]))}}append(e,r){let s=e.toLowerCase(),o=this.headerMap.get(s);this.headerMap.set(s,o?`${o}, ${r}`:r)}set(e,r){this.headerMap.set(e.toLowerCase(),String(r))}get(e){return this.headerMap.get(e.toLowerCase())??null}has(e){return this.headerMap.has(e.toLowerCase())}delete(e){this.headerMap.delete(e.toLowerCase())}forEach(e){for(let[r,s]of this.headerMap.entries())e(s,r,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}};m();m();var Ce=class{constructor(t,e){this.bodyData=t,this.status=e?.status??200,this.statusText=e?.statusText??"",this.headers=Xe(e?.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 t=await this.text();return new TextEncoder().encode(t).buffer}};function Xe(t){return t?new _(t):new _}m();m();var je=class{constructor(t,e,r){this.storage=t,this.customFetch=e,this.handleUnauthorized=r}async fetch(t,e){return await this.customFetch(t,e)}async fetchWithAuth(t,e){let r=await this.storage.get(v),s=new _(e?.headers);r&&s.set("Authorization",`Bearer ${r}`);let o=e?.method||"GET";if((o==="POST"||o==="PUT"||o==="PATCH")&&e?.body){let n=s.get("Content-Type");(!n||n.includes("text/plain"))&&s.set("Content-Type","application/json")}let a=await this.customFetch(t,{...e,headers:s});if(a.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return a}};m();var Ze="/storage",et=Ze+"/generateUploadUrl",Ie=class{constructor(t,e){this.baseUrl=t,this.http=e}async uploadFile(t){let e=await this.http.fetch(this.baseUrl+et,{method:"POST",body:{fileName:t.name||t.fileName,fileSize:t.size||t.fileSize,fileType:t.type||t.fileType}}),{url:r}=await e.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(r,{method:"PUT",body:t,headers:new _({"Content-Type":t.type||t.fileType||"application/octet-stream"})}),{url:o}=await s.json();return{url:o.split("?")[0]}}};m();m();m();var z=Ge(Ve(),1),{PostgrestClient:tt,PostgrestQueryBuilder:ot,PostgrestFilterBuilder:nt,PostgrestTransformBuilder:it,PostgrestBuilder:lt,PostgrestError:ht}=z.default||z,rt="/entities",Ne=(t,e)=>new tt(t+rt,{fetch:e.fetchWithAuth.bind(e)});m();var ke=class{constructor(t,e){this.baseUrl=t,this.http=e}async execute(t,e){let r=`${this.baseUrl}/capability/${t}/execute`,s=await(await this.http.fetchWithAuth(r,{method:"POST",body:e?JSON.stringify(e):void 0,timeout:6e5})).json();if(s.status!==200)throw new Error(s.message);return s.data}};m();var Re=class{constructor(t,e){this.baseUrl=t,this.http=e}async execute(t,e){let r=`${this.baseUrl}/capability/${t}/execute`,s=await(await this.http.fetchWithAuth(r,{method:"POST",body:e!=null?JSON.stringify(e):void 0,timeout:6e5})).json();if(s.status!==200)throw new Error(s.message);return s.data}};m();var He=class{constructor(){this.hoverOverlay=null,this.selectedOverlay=null,this.tooltip=null,this.hoverElement=null,this.selectedElement=null,this.hoverUpdateHandler=null,this.selectedUpdateHandler=null,this.createStyles()}createStyles(){if(document.getElementById("__nvwa-inspector-overlay-style"))return;let t=document.createElement("style");t.id="__nvwa-inspector-overlay-style",t.textContent=`
|
|
1
|
+
var De=Object.create,R=Object.defineProperty,Be=Object.getOwnPropertyDescriptor,qe=Object.getOwnPropertyNames,ze=Object.getPrototypeOf,We=Object.prototype.hasOwnProperty,W=(t,e)=>()=>(t&&(e=t(t=0)),e),E=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Je=(t,e)=>{for(var r in e)R(t,r,{get:e[r],enumerable:!0})},J=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of qe(e))!We.call(t,o)&&o!==r&&R(t,o,{get:()=>e[o],enumerable:!(s=Be(e,o))||s.enumerable});return t},Ge=(t,e,r)=>(r=t!=null?De(ze(t)):{},J(e||!t||!t.__esModule?R(r,"default",{value:t,enumerable:!0}):r,t)),S=t=>J(R({},"__esModule",{value:!0}),t),m=W(()=>{"use strict"}),O={};Je(O,{__addDisposableResource:()=>ge,__assign:()=>L,__asyncDelegator:()=>he,__asyncGenerator:()=>le,__asyncValues:()=>ce,__await:()=>P,__awaiter:()=>re,__classPrivateFieldGet:()=>fe,__classPrivateFieldIn:()=>ye,__classPrivateFieldSet:()=>me,__createBinding:()=>A,__decorate:()=>V,__disposeResources:()=>we,__esDecorate:()=>Q,__exportStar:()=>ae,__extends:()=>G,__generator:()=>se,__importDefault:()=>pe,__importStar:()=>de,__makeTemplateObject:()=>ue,__metadata:()=>te,__param:()=>Y,__propKey:()=>Z,__read:()=>D,__rest:()=>K,__rewriteRelativeImportExtension:()=>ve,__runInitializers:()=>X,__setFunctionName:()=>ee,__spread:()=>oe,__spreadArray:()=>ie,__spreadArrays:()=>ne,__values:()=>k,default:()=>Ee});function G(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");I(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function K(t,e){var r={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(r[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,s=Object.getOwnPropertySymbols(t);o<s.length;o++)e.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(t,s[o])&&(r[s[o]]=t[s[o]]);return r}function V(t,e,r,s){var o=arguments.length,a=o<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,r):s,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(t,e,r,s);else for(var i=t.length-1;i>=0;i--)(n=t[i])&&(a=(o<3?n(a):o>3?n(e,r,a):n(e,r))||a);return o>3&&a&&Object.defineProperty(e,r,a),a}function Y(t,e){return function(r,s){e(r,s,t)}}function Q(t,e,r,s,o,a){function n(g){if(g!==void 0&&typeof g!="function")throw new TypeError("Function expected");return g}for(var i=s.kind,c=i==="getter"?"get":i==="setter"?"set":"value",l=!e&&t?s.static?t:t.prototype:null,h=e||(l?Object.getOwnPropertyDescriptor(l,s.name):{}),u,f=!1,d=r.length-1;d>=0;d--){var p={};for(var y in s)p[y]=y==="access"?{}:s[y];for(var y in s.access)p.access[y]=s.access[y];p.addInitializer=function(g){if(f)throw new TypeError("Cannot add initializers after decoration has completed");a.push(n(g||null))};var w=(0,r[d])(i==="accessor"?{get:h.get,set:h.set}:h[c],p);if(i==="accessor"){if(w===void 0)continue;if(w===null||typeof w!="object")throw new TypeError("Object expected");(u=n(w.get))&&(h.get=u),(u=n(w.set))&&(h.set=u),(u=n(w.init))&&o.unshift(u)}else(u=n(w))&&(i==="field"?o.unshift(u):h[c]=u)}l&&Object.defineProperty(l,s.name,h),f=!0}function X(t,e,r){for(var s=arguments.length>2,o=0;o<e.length;o++)r=s?e[o].call(t,r):e[o].call(t);return s?r:void 0}function Z(t){return typeof t=="symbol"?t:"".concat(t)}function ee(t,e,r){return typeof e=="symbol"&&(e=e.description?"[".concat(e.description,"]"):""),Object.defineProperty(t,"name",{configurable:!0,value:r?"".concat(r," ",e):e})}function te(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function re(t,e,r,s){function o(a){return a instanceof r?a:new r(function(n){n(a)})}return new(r||(r=Promise))(function(a,n){function i(h){try{l(s.next(h))}catch(u){n(u)}}function c(h){try{l(s.throw(h))}catch(u){n(u)}}function l(h){h.done?a(h.value):o(h.value).then(i,c)}l((s=s.apply(t,e||[])).next())})}function se(t,e){var r={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},s,o,a,n=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return n.next=i(0),n.throw=i(1),n.return=i(2),typeof Symbol=="function"&&(n[Symbol.iterator]=function(){return this}),n;function i(l){return function(h){return c([l,h])}}function c(l){if(s)throw new TypeError("Generator is already executing.");for(;n&&(n=0,l[0]&&(r=0)),r;)try{if(s=1,o&&(a=l[0]&2?o.return:l[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,l[1])).done)return a;switch(o=0,a&&(l=[l[0]&2,a.value]),l[0]){case 0:case 1:a=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,o=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(a=r.trys,!(a=a.length>0&&a[a.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!a||l[1]>a[0]&&l[1]<a[3])){r.label=l[1];break}if(l[0]===6&&r.label<a[1]){r.label=a[1],a=l;break}if(a&&r.label<a[2]){r.label=a[2],r.ops.push(l);break}a[2]&&r.ops.pop(),r.trys.pop();continue}l=e.call(t,r)}catch(h){l=[6,h],o=0}finally{s=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function ae(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&A(e,t,r)}function k(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],s=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&s>=t.length&&(t=void 0),{value:t&&t[s++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function D(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var s=r.call(t),o,a=[],n;try{for(;(e===void 0||e-- >0)&&!(o=s.next()).done;)a.push(o.value)}catch(i){n={error:i}}finally{try{o&&!o.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return a}function oe(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(D(arguments[e]));return t}function ne(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var s=Array(t),o=0,e=0;e<r;e++)for(var a=arguments[e],n=0,i=a.length;n<i;n++,o++)s[o]=a[n];return s}function ie(t,e,r){if(r||arguments.length===2)for(var s=0,o=e.length,a;s<o;s++)(a||!(s in e))&&(a||(a=Array.prototype.slice.call(e,0,s)),a[s]=e[s]);return t.concat(a||Array.prototype.slice.call(e))}function P(t){return this instanceof P?(this.v=t,this):new P(t)}function le(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r.apply(t,e||[]),o,a=[];return o=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),i("next"),i("throw"),i("return",n),o[Symbol.asyncIterator]=function(){return this},o;function n(d){return function(p){return Promise.resolve(p).then(d,u)}}function i(d,p){s[d]&&(o[d]=function(y){return new Promise(function(w,g){a.push([d,y,w,g])>1||c(d,y)})},p&&(o[d]=p(o[d])))}function c(d,p){try{l(s[d](p))}catch(y){f(a[0][3],y)}}function l(d){d.value instanceof P?Promise.resolve(d.value.v).then(h,u):f(a[0][2],d)}function h(d){c("next",d)}function u(d){c("throw",d)}function f(d,p){d(p),a.shift(),a.length&&c(a[0][0],a[0][1])}}function he(t){var e,r;return e={},s("next"),s("throw",function(o){throw o}),s("return"),e[Symbol.iterator]=function(){return this},e;function s(o,a){e[o]=t[o]?function(n){return(r=!r)?{value:P(t[o](n)),done:!1}:a?a(n):n}:a}}function ce(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof k=="function"?k(t):t[Symbol.iterator](),r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r);function s(a){r[a]=t[a]&&function(n){return new Promise(function(i,c){n=t[a](n),o(i,c,n.done,n.value)})}}function o(a,n,i,c){Promise.resolve(c).then(function(l){a({value:l,done:i})},n)}}function ue(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function de(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r=N(t),s=0;s<r.length;s++)r[s]!=="default"&&A(e,t,r[s]);return be(e,t),e}function pe(t){return t&&t.__esModule?t:{default:t}}function fe(t,e,r,s){if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?s:r==="a"?s.call(t):s?s.value:e.get(t)}function me(t,e,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 e=="function"?t!==e||!o:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?o.call(t,r):o?o.value=r:e.set(t,r),r}function ye(t,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof t=="function"?e===t:t.has(e)}function ge(t,e,r){if(e!=null){if(typeof e!="object"&&typeof e!="function")throw new TypeError("Object expected.");var s,o;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=e[Symbol.asyncDispose]}if(s===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=e[Symbol.dispose],r&&(o=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");o&&(s=function(){try{o.call(this)}catch(a){return Promise.reject(a)}}),t.stack.push({value:e,dispose:s,async:r})}else r&&t.stack.push({async:!0});return e}function we(t){function e(a){t.error=t.hasError?new _e(a,t.error,"An error was suppressed during disposal."):a,t.hasError=!0}var r,s=0;function o(){for(;r=t.stack.pop();)try{if(!r.async&&s===1)return s=0,t.stack.push(r),Promise.resolve().then(o);if(r.dispose){var a=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(a).then(o,function(n){return e(n),o()})}else s|=1}catch(n){e(n)}if(s===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return o()}function ve(t,e){return typeof t=="string"&&/^\.\.?\//.test(t)?t.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,s,o,a,n){return s?e?".jsx":".js":o&&(!a||!n)?r:o+a+"."+n.toLowerCase()+"js"}):t}var I,L,A,be,N,_e,Ee,T=W(()=>{"use strict";m(),I=function(t,e){return I=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])},I(t,e)},L=function(){return L=Object.assign||function(t){for(var e,r=1,s=arguments.length;r<s;r++){e=arguments[r];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},L.apply(this,arguments)},A=Object.create?(function(t,e,r,s){s===void 0&&(s=r);var o=Object.getOwnPropertyDescriptor(e,r);(!o||("get"in o?!e.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,s,o)}):(function(t,e,r,s){s===void 0&&(s=r),t[s]=e[r]}),be=Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e},N=function(t){return N=Object.getOwnPropertyNames||function(e){var r=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[r.length]=s);return r},N(t)},_e=typeof SuppressedError=="function"?SuppressedError:function(t,e,r){var s=new Error(r);return s.name="SuppressedError",s.error=t,s.suppressed=e,s},Ee={__extends:G,__assign:L,__rest:K,__decorate:V,__param:Y,__esDecorate:Q,__runInitializers:X,__propKey:Z,__setFunctionName:ee,__metadata:te,__awaiter:re,__generator:se,__createBinding:A,__exportStar:ae,__values:k,__read:D,__spread:oe,__spreadArrays:ne,__spreadArray:ie,__await:P,__asyncGenerator:le,__asyncDelegator:he,__asyncValues:ce,__makeTemplateObject:ue,__importStar:de,__importDefault:pe,__classPrivateFieldGet:fe,__classPrivateFieldSet:me,__classPrivateFieldIn:ye,__addDisposableResource:ge,__disposeResources:we,__rewriteRelativeImportExtension:ve}}),Oe=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}};t.default=e}),Pe=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=(T(),S(O)),r=e.__importDefault(Oe()),s=class{constructor(o){var a,n;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=(a=o.shouldThrowOnError)!==null&&a!==void 0?a:!1,this.signal=o.signal,this.isMaybeSingle=(n=o.isMaybeSingle)!==null&&n!==void 0?n:!1,o.fetch?this.fetch=o.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(o,a){return this.headers=new Headers(this.headers),this.headers.set(o,a),this}then(o,a){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 n=this.fetch,i=n(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async c=>{var l,h,u,f;let d=null,p=null,y=null,w=c.status,g=c.statusText;if(c.ok){if(this.method!=="HEAD"){let F=await c.text();F===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&!((l=this.headers.get("Accept"))===null||l===void 0)&&l.includes("application/vnd.pgrst.plan+text")?p=F:p=JSON.parse(F))}let $=(h=this.headers.get("Prefer"))===null||h===void 0?void 0:h.match(/count=(exact|planned|estimated)/),M=(u=c.headers.get("content-range"))===null||u===void 0?void 0:u.split("/");$&&M&&M.length>1&&(y=parseInt(M[1])),this.isMaybeSingle&&this.method==="GET"&&Array.isArray(p)&&(p.length>1?(d={code:"PGRST116",details:`Results contain ${p.length} rows, application/vnd.pgrst.object+json requires 1 row`,hint:null,message:"JSON object requested, multiple (or no) rows returned"},p=null,y=null,w=406,g="Not Acceptable"):p.length===1?p=p[0]:p=null)}else{let $=await c.text();try{d=JSON.parse($),Array.isArray(d)&&c.status===404&&(p=[],d=null,w=200,g="OK")}catch{c.status===404&&$===""?(w=204,g="No Content"):d={message:$}}if(d&&this.isMaybeSingle&&!((f=d?.details)===null||f===void 0)&&f.includes("0 rows")&&(d=null,w=200,g="OK"),d&&this.shouldThrowOnError)throw new r.default(d)}return{error:d,data:p,count:y,status:w,statusText:g}});return this.shouldThrowOnError||(i=i.catch(c=>{var l,h,u;return{error:{message:`${(l=c?.name)!==null&&l!==void 0?l:"FetchError"}: ${c?.message}`,details:`${(h=c?.stack)!==null&&h!==void 0?h:""}`,hint:"",code:`${(u=c?.code)!==null&&u!==void 0?u:""}`},data:null,count:null,status:0,statusText:""}})),i.then(o,a)}returns(){return this}overrideTypes(){return this}};t.default=s}),Se=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=(T(),S(O)),r=e.__importDefault(Pe()),s=class extends r.default{select(o){let a=!1,n=(o??"*").split("").map(i=>/\s/.test(i)&&!a?"":(i==='"'&&(a=!a),i)).join("");return this.url.searchParams.set("select",n),this.headers.append("Prefer","return=representation"),this}order(o,{ascending:a=!0,nullsFirst:n,foreignTable:i,referencedTable:c=i}={}){let l=c?`${c}.order`:"order",h=this.url.searchParams.get(l);return this.url.searchParams.set(l,`${h?`${h},`:""}${o}.${a?"asc":"desc"}${n===void 0?"":n?".nullsfirst":".nullslast"}`),this}limit(o,{foreignTable:a,referencedTable:n=a}={}){let i=typeof n>"u"?"limit":`${n}.limit`;return this.url.searchParams.set(i,`${o}`),this}range(o,a,{foreignTable:n,referencedTable:i=n}={}){let c=typeof i>"u"?"offset":`${i}.offset`,l=typeof i>"u"?"limit":`${i}.limit`;return this.url.searchParams.set(c,`${o}`),this.url.searchParams.set(l,`${a-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:a=!1,settings:n=!1,buffers:i=!1,wal:c=!1,format:l="text"}={}){var h;let u=[o?"analyze":null,a?"verbose":null,n?"settings":null,i?"buffers":null,c?"wal":null].filter(Boolean).join("|"),f=(h=this.headers.get("Accept"))!==null&&h!==void 0?h:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${l}; for="${f}"; options=${u};`),l==="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}};t.default=s}),B=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=(T(),S(O)),r=e.__importDefault(Se()),s=new RegExp("[,()]"),o=class extends r.default{eq(a,n){return this.url.searchParams.append(a,`eq.${n}`),this}neq(a,n){return this.url.searchParams.append(a,`neq.${n}`),this}gt(a,n){return this.url.searchParams.append(a,`gt.${n}`),this}gte(a,n){return this.url.searchParams.append(a,`gte.${n}`),this}lt(a,n){return this.url.searchParams.append(a,`lt.${n}`),this}lte(a,n){return this.url.searchParams.append(a,`lte.${n}`),this}like(a,n){return this.url.searchParams.append(a,`like.${n}`),this}likeAllOf(a,n){return this.url.searchParams.append(a,`like(all).{${n.join(",")}}`),this}likeAnyOf(a,n){return this.url.searchParams.append(a,`like(any).{${n.join(",")}}`),this}ilike(a,n){return this.url.searchParams.append(a,`ilike.${n}`),this}ilikeAllOf(a,n){return this.url.searchParams.append(a,`ilike(all).{${n.join(",")}}`),this}ilikeAnyOf(a,n){return this.url.searchParams.append(a,`ilike(any).{${n.join(",")}}`),this}is(a,n){return this.url.searchParams.append(a,`is.${n}`),this}in(a,n){let i=Array.from(new Set(n)).map(c=>typeof c=="string"&&s.test(c)?`"${c}"`:`${c}`).join(",");return this.url.searchParams.append(a,`in.(${i})`),this}contains(a,n){return typeof n=="string"?this.url.searchParams.append(a,`cs.${n}`):Array.isArray(n)?this.url.searchParams.append(a,`cs.{${n.join(",")}}`):this.url.searchParams.append(a,`cs.${JSON.stringify(n)}`),this}containedBy(a,n){return typeof n=="string"?this.url.searchParams.append(a,`cd.${n}`):Array.isArray(n)?this.url.searchParams.append(a,`cd.{${n.join(",")}}`):this.url.searchParams.append(a,`cd.${JSON.stringify(n)}`),this}rangeGt(a,n){return this.url.searchParams.append(a,`sr.${n}`),this}rangeGte(a,n){return this.url.searchParams.append(a,`nxl.${n}`),this}rangeLt(a,n){return this.url.searchParams.append(a,`sl.${n}`),this}rangeLte(a,n){return this.url.searchParams.append(a,`nxr.${n}`),this}rangeAdjacent(a,n){return this.url.searchParams.append(a,`adj.${n}`),this}overlaps(a,n){return typeof n=="string"?this.url.searchParams.append(a,`ov.${n}`):this.url.searchParams.append(a,`ov.{${n.join(",")}}`),this}textSearch(a,n,{config:i,type:c}={}){let l="";c==="plain"?l="pl":c==="phrase"?l="ph":c==="websearch"&&(l="w");let h=i===void 0?"":`(${i})`;return this.url.searchParams.append(a,`${l}fts${h}.${n}`),this}match(a){return Object.entries(a).forEach(([n,i])=>{this.url.searchParams.append(n,`eq.${i}`)}),this}not(a,n,i){return this.url.searchParams.append(a,`not.${n}.${i}`),this}or(a,{foreignTable:n,referencedTable:i=n}={}){let c=i?`${i}.or`:"or";return this.url.searchParams.append(c,`(${a})`),this}filter(a,n,i){return this.url.searchParams.append(a,`${n}.${i}`),this}};t.default=o}),Te=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=(T(),S(O)),r=e.__importDefault(B()),s=class{constructor(o,{headers:a={},schema:n,fetch:i}){this.url=o,this.headers=new Headers(a),this.schema=n,this.fetch=i}select(o,a){let{head:n=!1,count:i}=a??{},c=n?"HEAD":"GET",l=!1,h=(o??"*").split("").map(u=>/\s/.test(u)&&!l?"":(u==='"'&&(l=!l),u)).join("");return this.url.searchParams.set("select",h),i&&this.headers.append("Prefer",`count=${i}`),new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(o,{count:a,defaultToNull:n=!0}={}){var i;let c="POST";if(a&&this.headers.append("Prefer",`count=${a}`),n||this.headers.append("Prefer","missing=default"),Array.isArray(o)){let l=o.reduce((h,u)=>h.concat(Object.keys(u)),[]);if(l.length>0){let h=[...new Set(l)].map(u=>`"${u}"`);this.url.searchParams.set("columns",h.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})}upsert(o,{onConflict:a,ignoreDuplicates:n=!1,count:i,defaultToNull:c=!0}={}){var l;let h="POST";if(this.headers.append("Prefer",`resolution=${n?"ignore":"merge"}-duplicates`),a!==void 0&&this.url.searchParams.set("on_conflict",a),i&&this.headers.append("Prefer",`count=${i}`),c||this.headers.append("Prefer","missing=default"),Array.isArray(o)){let u=o.reduce((f,d)=>f.concat(Object.keys(d)),[]);if(u.length>0){let f=[...new Set(u)].map(d=>`"${d}"`);this.url.searchParams.set("columns",f.join(","))}}return new r.default({method:h,url:this.url,headers:this.headers,schema:this.schema,body:o,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}update(o,{count:a}={}){var n;let i="PATCH";return a&&this.headers.append("Prefer",`count=${a}`),new r.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:o,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}delete({count:o}={}){var a;let n="DELETE";return o&&this.headers.append("Prefer",`count=${o}`),new r.default({method:n,url:this.url,headers:this.headers,schema:this.schema,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}};t.default=s}),Ke=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=(T(),S(O)),r=e.__importDefault(Te()),s=e.__importDefault(B()),o=class $e{constructor(n,{headers:i={},schema:c,fetch:l}={}){this.url=n,this.headers=new Headers(i),this.schemaName=c,this.fetch=l}from(n){let i=new URL(`${this.url}/${n}`);return new r.default(i,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(n){return new $e(this.url,{headers:this.headers,schema:n,fetch:this.fetch})}rpc(n,i={},{head:c=!1,get:l=!1,count:h}={}){var u;let f,d=new URL(`${this.url}/rpc/${n}`),p;c||l?(f=c?"HEAD":"GET",Object.entries(i).filter(([w,g])=>g!==void 0).map(([w,g])=>[w,Array.isArray(g)?`{${g.join(",")}}`:`${g}`]).forEach(([w,g])=>{d.searchParams.append(w,g)})):(f="POST",p=i);let y=new Headers(this.headers);return h&&y.set("Prefer",`count=${h}`),new s.default({method:f,url:d,headers:y,schema:this.schemaName,body:p,fetch:(u=this.fetch)!==null&&u!==void 0?u:fetch})}};t.default=o}),Ve=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0}),t.PostgrestError=t.PostgrestBuilder=t.PostgrestTransformBuilder=t.PostgrestFilterBuilder=t.PostgrestQueryBuilder=t.PostgrestClient=void 0;var e=(T(),S(O)),r=e.__importDefault(Ke());t.PostgrestClient=r.default;var s=e.__importDefault(Te());t.PostgrestQueryBuilder=s.default;var o=e.__importDefault(B());t.PostgrestFilterBuilder=o.default;var a=e.__importDefault(Se());t.PostgrestTransformBuilder=a.default;var n=e.__importDefault(Pe());t.PostgrestBuilder=n.default;var i=e.__importDefault(Oe());t.PostgrestError=i.default,t.default={PostgrestClient:r.default,PostgrestQueryBuilder:s.default,PostgrestFilterBuilder:o.default,PostgrestTransformBuilder:a.default,PostgrestBuilder:n.default,PostgrestError:i.default}});m();m();var xe=class{constructor(t,e=""){this.http=t,this.baseUrl=e.replace(/\/$/,"")}async invoke(t,e){let r=this.baseUrl?`${this.baseUrl}/functions/${t}`:`/functions/${t}`;return await(await this.http.fetch(r,{method:e.method||"POST",body:e.body,headers:e.headers})).json()}};m();m();var v="nvwa_current_jwt",b="nvwa_login_token",x="nvwa_user_profile",Ye="set-auth-token",Qe=typeof fetch<"u"?(t,e)=>fetch(t,e):()=>{throw new Error("AuthClient requires fetch")},Le=class{constructor(t,e={}){this.baseUrl=t.replace(/\/$/,""),this.authPath=(e.authPath??"/auth").replace(/^\//,""),this.fetchImpl=e.fetchImpl??Qe,this.storage=e.storage??null,this.credentials=e.credentials??"omit",typeof console<"u"&&(console.warn("[NvwaAuth] init baseUrl:",this.baseUrl||"(empty)"),(!this.baseUrl||!this.baseUrl.startsWith("http://")&&!this.baseUrl.startsWith("https://"))&&console.warn("[NvwaAuth] baseUrl \u5E94\u4E3A\u5B8C\u6574\u5730\u5740\uFF08\u5982 https://xxx.nvwa.app\uFF09\uFF0C\u5426\u5219\u5C0F\u7A0B\u5E8F request \u4F1A\u62A5 invalid url"))}async currentUser(){if(this.storage){let r=await this.storage.get(x);if(r!=null)return r}let{data:t}=await this.getSession(),e=t?.user??null;return e&&this.storage&&await this.storage.set(x,e),e}async getCurrentJwt(){if(this.storage){let e=await this.storage.get(v);if(e!=null)return e;let r=await this.storage.get(b),{data:s}=await this.getToken(r??void 0);return s?.token?(await this.storage.set(v,s.token),s.token):null}let{data:t}=await this.getToken();return t?.token??null}async persistLogin(t,e){if(!this.storage)return;let r=e?.headers.get(Ye)?.trim()||t.token||t.session?.token;r&&await this.storage.set(b,r),t.user&&await this.storage.set(x,t.user);let s=r??await this.storage.get(b),{data:o}=await this.getToken(s??void 0);o?.token&&await this.storage.set(v,o.token)}async clearLogin(){this.storage&&(await this.storage.remove(b),await this.storage.remove(x),await this.storage.remove(v))}url(t){let e=`${`${this.baseUrl.replace(/\/+$/,"")}/${this.authPath.replace(/^\/+/,"")}`}/${t.replace(/^\/+/,"")}`;return typeof console<"u"&&(console.warn("[NvwaAuth] request URL:",e),!e.startsWith("http://")&&!e.startsWith("https://")&&console.warn("[NvwaAuth] URL \u975E\u5B8C\u6574\u5730\u5740\uFF0C\u5C0F\u7A0B\u5E8F\u4F1A\u62A5 invalid url\uFF0C\u8BF7\u68C0\u67E5 Nvwa \u6784\u9020\u65F6\u4F20\u5165\u7684 baseUrl")),e}async getSession(){try{let t={};if(this.storage){let r=await this.storage.get(b)??await this.storage.get(v);r!=null&&(t.Authorization=`Bearer ${r}`)}let e=await this.fetchImpl(this.url("session"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return e.ok?{data:await e.json()}:{data:null,error:{message:await e.text()||e.statusText,status:e.status}}}catch(t){return{data:null,error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signInWithEmail(t,e){try{let r=await this.fetchImpl(this.url("sign-in/email"),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify({email:t,password:e})}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let o=s?JSON.parse(s):void 0;return o&&await this.persistLogin({user:o.user,session:o.session},r),{data:o}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async signOut(){try{let t={};if(this.storage){let r=await this.storage.get(b)??await this.storage.get(v);r!=null&&(t.Authorization=`Bearer ${r}`)}let e=await this.fetchImpl(this.url("sign-out"),{method:"POST",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}});return await this.clearLogin(),e.ok?{}:{error:{message:await e.text()||e.statusText,status:e.status}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signUp(t){let e=await this.postJson("sign-up/email",t);return e.data&&await this.persistLogin(e.data,e.response),e}async getToken(t){try{let e={};if(t)e.Authorization=`Bearer ${t}`;else if(this.storage){let a=await this.storage.get(b)??await this.storage.get(v);a!=null&&(e.Authorization=`Bearer ${a}`)}let r=await this.fetchImpl(this.url("token"),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let o=s?JSON.parse(s):void 0;return{data:o?.token!=null?{token:o.token}:void 0}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signInWithUsername(t,e){let r=await this.postJson("sign-in/username",{username:t,password:e});return r.data&&await this.persistLogin(r.data,r.response),r}async signInWithPhoneNumber(t,e,r){let s=await this.postJson("sign-in/phone-number",{phoneNumber:t,password:e,rememberMe:r});return s.data&&await this.persistLogin(s.data,s.response),s}async sendPhoneNumberOtp(t){let e=await this.postJson("phone-number/send-otp",{phoneNumber:t});return e.error?{error:e.error}:{}}async verifyPhoneNumber(t,e){let r=await this.postJson("phone-number/verify",{phoneNumber:t,code:e});return r.data&&await this.persistLogin(r.data,r.response),r}async loginWithWeChatCode(t,e){try{let r={"Content-Type":"application/json"};if(this.storage){let n=await this.storage.get(v);n!=null&&(r.Authorization=`Bearer ${n}`)}let s=await this.fetchImpl(this.url("wechat/openplatform/sign-in"),{method:"POST",headers:r,credentials:this.credentials,body:JSON.stringify({code:t,applicationCode:e})}),o=await s.text();if(!s.ok)return{error:{message:o||s.statusText,status:s.status}};let a=o?JSON.parse(o):null;return!a?.token||!a.user?{error:{message:"invalid_wechat_login_response",status:502}}:(this.storage&&(await this.storage.set(v,a.token),await this.storage.set(b,a.token),await this.storage.set(x,a.user)),{data:a})}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async getWeChatOpenPlatformIdentity(t){try{let e={};if(this.storage){let n=await this.storage.get(v);n!=null&&(e.Authorization=`Bearer ${n}`)}let r=t?.trim()?`?appId=${encodeURIComponent(t.trim())}`:"",s=await this.fetchImpl(this.url(`wechat/openplatform/identity${r}`),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}}),o=await s.text();if(!s.ok)return{error:{message:o||s.statusText,status:s.status}};let a=o?JSON.parse(o):null;return!a?.openid||!a.appId?{error:{message:"invalid_wechat_identity_response",status:502}}:{data:a}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async postJson(t,e){try{let r=await this.fetchImpl(this.url(t),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify(e)}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let o=s?JSON.parse(s):void 0;return{data:o?.data??o??void 0,response:r}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}};m();m();var _=class Ae{constructor(e){if(this.headerMap=new Map,e){if(e instanceof Ae)e.forEach((r,s)=>this.set(s,r));else if(Array.isArray(e))for(let[r,s]of e)this.set(r,String(s));else if(typeof e=="object")for(let r of Object.keys(e))this.set(r,String(e[r]))}}append(e,r){let s=e.toLowerCase(),o=this.headerMap.get(s);this.headerMap.set(s,o?`${o}, ${r}`:r)}set(e,r){this.headerMap.set(e.toLowerCase(),String(r))}get(e){return this.headerMap.get(e.toLowerCase())??null}has(e){return this.headerMap.has(e.toLowerCase())}delete(e){this.headerMap.delete(e.toLowerCase())}forEach(e){for(let[r,s]of this.headerMap.entries())e(s,r,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}};m();m();var Ce=class{constructor(t,e){this.bodyData=t,this.status=e?.status??200,this.statusText=e?.statusText??"",this.headers=Xe(e?.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 t=await this.text();return new TextEncoder().encode(t).buffer}};function Xe(t){return t?new _(t):new _}m();m();var je=class{constructor(t,e,r){this.storage=t,this.customFetch=e,this.handleUnauthorized=r}async fetch(t,e){return await this.customFetch(t,e)}async fetchWithAuth(t,e){let r=await this.storage.get(v),s=new _(e?.headers);r&&s.set("Authorization",`Bearer ${r}`);let o=e?.method||"GET";if((o==="POST"||o==="PUT"||o==="PATCH")&&e?.body){let n=s.get("Content-Type");(!n||n.includes("text/plain"))&&s.set("Content-Type","application/json")}let a=await this.customFetch(t,{...e,headers:s});if(a.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return a}};m();var Ze="/storage",et=Ze+"/generateUploadUrl",Ie=class{constructor(t,e){this.baseUrl=t,this.http=e}async uploadFile(t){let e=await this.http.fetch(this.baseUrl+et,{method:"POST",body:{fileName:t.name||t.fileName,fileSize:t.size||t.fileSize,fileType:t.type||t.fileType}}),{url:r}=await e.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(r,{method:"PUT",body:t,headers:new _({"Content-Type":t.type||t.fileType||"application/octet-stream"})}),{url:o}=await s.json();return{url:o.split("?")[0]}}};m();m();m();var z=Ge(Ve(),1),{PostgrestClient:tt,PostgrestQueryBuilder:ot,PostgrestFilterBuilder:nt,PostgrestTransformBuilder:it,PostgrestBuilder:lt,PostgrestError:ht}=z.default||z,rt="/entities",Ne=(t,e)=>new tt(t+rt,{fetch:e.fetchWithAuth.bind(e)});m();var ke=class{constructor(t,e){this.baseUrl=t,this.http=e}async execute(t,e){let r=`${this.baseUrl}/capability/${t}/execute`,s=await(await this.http.fetchWithAuth(r,{method:"POST",body:e?JSON.stringify(e):void 0,timeout:6e5})).json();if(s.status!==200)throw new Error(s.message);return s.data}};m();var Re=class{constructor(t,e){this.baseUrl=t,this.http=e}async execute(t,e){let r=`${this.baseUrl}/capability/${t}/execute`,s=await(await this.http.fetchWithAuth(r,{method:"POST",body:e!=null?JSON.stringify(e):void 0,timeout:6e5})).json();if(s.status!==200)throw new Error(s.message);return s.data}};m();var He=class{constructor(){this.hoverOverlay=null,this.selectedOverlay=null,this.tooltip=null,this.hoverElement=null,this.selectedElement=null,this.hoverUpdateHandler=null,this.selectedUpdateHandler=null,this.createStyles()}createStyles(){if(document.getElementById("__nvwa-inspector-overlay-style"))return;let t=document.createElement("style");t.id="__nvwa-inspector-overlay-style",t.textContent=`
|
|
2
2
|
.__nvwa-inspector-overlay {
|
|
3
3
|
position: absolute;
|
|
4
4
|
pointer-events: none;
|