@nvwa-app/sdk-web 6.0.33 → 6.0.35

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.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { NvwaLocalStorage, NvwaFetch, INvwa, AuthClient, NvwaFileStorage, createPostgrestClient, NvwaEdgeFunctions, NvwaHttpClient, NvwaSkill, NvwaCapability } from '@nvwa-app/sdk-core';
1
+ import { NvwaLocalStorage, NvwaFetch, INvwa, AuthClient, NvwaFileStorage, createPostgrestClient, NvwaEdgeFunctions, NvwaHttpClient, NvwaSkill, NvwaCapability, IPaymentLauncher } from '@nvwa-app/sdk-core';
2
2
 
3
3
  declare class WebNvwaLocalStorage implements NvwaLocalStorage {
4
4
  private prefix;
@@ -46,6 +46,8 @@ declare class Nvwa implements INvwa {
46
46
  httpClient: NvwaHttpClient;
47
47
  skill: NvwaSkill;
48
48
  capability: NvwaCapability;
49
+ endpointType: string;
50
+ payment: IPaymentLauncher;
49
51
  constructor(baseUrl: string, handleUnauthorized: () => void);
50
52
  }
51
53
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { NvwaLocalStorage, NvwaFetch, INvwa, AuthClient, NvwaFileStorage, createPostgrestClient, NvwaEdgeFunctions, NvwaHttpClient, NvwaSkill, NvwaCapability } from '@nvwa-app/sdk-core';
1
+ import { NvwaLocalStorage, NvwaFetch, INvwa, AuthClient, NvwaFileStorage, createPostgrestClient, NvwaEdgeFunctions, NvwaHttpClient, NvwaSkill, NvwaCapability, IPaymentLauncher } from '@nvwa-app/sdk-core';
2
2
 
3
3
  declare class WebNvwaLocalStorage implements NvwaLocalStorage {
4
4
  private prefix;
@@ -46,6 +46,8 @@ declare class Nvwa implements INvwa {
46
46
  httpClient: NvwaHttpClient;
47
47
  skill: NvwaSkill;
48
48
  capability: NvwaCapability;
49
+ endpointType: string;
50
+ payment: IPaymentLauncher;
49
51
  constructor(baseUrl: string, handleUnauthorized: () => void);
50
52
  }
51
53
 
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var F=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames;var Be=Object.prototype.hasOwnProperty;var ze=(e,t)=>{for(var r in t)F(e,r,{get:t[r],enumerable:!0})},qe=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Fe(t))!Be.call(e,o)&&o!==r&&F(e,o,{get:()=>t[o],enumerable:!(s=De(t,o))||s.enumerable});return e};var Ge=e=>qe(F({},"__esModule",{value:!0}),e);var mt={};ze(mt,{default:()=>M,disableIframeHoverInspector:()=>ut,enableIframeHoverInspector:()=>ht,getIframeSourceLocation:()=>dt,localStorage:()=>q,setupIframeHoverInspector:()=>ct,setupIframeSourceLocationListener:()=>pt,webFetch:()=>I});module.exports=Ge(mt);var Je=Object.create,H=Object.defineProperty,We=Object.getOwnPropertyDescriptor,Ke=Object.getOwnPropertyNames,Ve=Object.getPrototypeOf,Ye=Object.prototype.hasOwnProperty,J=(e,t)=>()=>(e&&(t=e(e=0)),t),E=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Qe=(e,t)=>{for(var r in t)H(e,r,{get:t[r],enumerable:!0})},W=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Ke(t))!Ye.call(e,o)&&o!==r&&H(e,o,{get:()=>t[o],enumerable:!(s=We(t,o))||s.enumerable});return e},Xe=(e,t,r)=>(r=e!=null?Je(Ve(e)):{},W(t||!e||!e.__esModule?H(r,"default",{value:e,enumerable:!0}):r,e)),S=e=>W(H({},"__esModule",{value:!0}),e),m=J(()=>{"use strict"}),O={};Qe(O,{__addDisposableResource:()=>ve,__assign:()=>x,__asyncDelegator:()=>he,__asyncGenerator:()=>ce,__asyncValues:()=>ue,__await:()=>P,__awaiter:()=>se,__classPrivateFieldGet:()=>me,__classPrivateFieldIn:()=>ge,__classPrivateFieldSet:()=>ye,__createBinding:()=>j,__decorate:()=>Y,__disposeResources:()=>we,__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:()=>N,default:()=>Oe});function K(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");A(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function V(e,t){var r={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,s=Object.getOwnPropertySymbols(e);o<s.length;o++)t.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(e,s[o])&&(r[s[o]]=e[s[o]]);return r}function Y(e,t,r,s){var o=arguments.length,a=o<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,r):s,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(e,t,r,s);else for(var i=e.length-1;i>=0;i--)(n=e[i])&&(a=(o<3?n(a):o>3?n(t,r,a):n(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a}function Q(e,t){return function(r,s){t(r,s,e)}}function X(e,t,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,h=i==="getter"?"get":i==="setter"?"set":"value",l=!t&&e?s.static?e:e.prototype:null,c=t||(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 v=(0,r[d])(i==="accessor"?{get:c.get,set:c.set}:c[h],p);if(i==="accessor"){if(v===void 0)continue;if(v===null||typeof v!="object")throw new TypeError("Object expected");(u=n(v.get))&&(c.get=u),(u=n(v.set))&&(c.set=u),(u=n(v.init))&&o.unshift(u)}else(u=n(v))&&(i==="field"?o.unshift(u):c[h]=u)}l&&Object.defineProperty(l,s.name,c),f=!0}function Z(e,t,r){for(var s=arguments.length>2,o=0;o<t.length;o++)r=s?t[o].call(e,r):t[o].call(e);return s?r:void 0}function ee(e){return typeof e=="symbol"?e:"".concat(e)}function te(e,t,r){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function re(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function se(e,t,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(c){try{l(s.next(c))}catch(u){n(u)}}function h(c){try{l(s.throw(c))}catch(u){n(u)}}function l(c){c.done?a(c.value):o(c.value).then(i,h)}l((s=s.apply(e,t||[])).next())})}function ae(e,t){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(c){return h([l,c])}}function h(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=t.call(e,r)}catch(c){l=[6,c],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(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&j(t,e,r)}function N(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],s=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&s>=e.length&&(e=void 0),{value:e&&e[s++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function B(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var s=r.call(e),o,a=[],n;try{for(;(t===void 0||t-- >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 e=[],t=0;t<arguments.length;t++)e=e.concat(B(arguments[t]));return e}function ie(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var s=Array(e),o=0,t=0;t<r;t++)for(var a=arguments[t],n=0,i=a.length;n<i;n++,o++)s[o]=a[n];return s}function le(e,t,r){if(r||arguments.length===2)for(var s=0,o=t.length,a;s<o;s++)(a||!(s in t))&&(a||(a=Array.prototype.slice.call(t,0,s)),a[s]=t[s]);return e.concat(a||Array.prototype.slice.call(t))}function P(e){return this instanceof P?(this.v=e,this):new P(e)}function ce(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r.apply(e,t||[]),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(v,g){a.push([d,y,v,g])>1||h(d,y)})},p&&(o[d]=p(o[d])))}function h(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(c,u):f(a[0][2],d)}function c(d){h("next",d)}function u(d){h("throw",d)}function f(d,p){d(p),a.shift(),a.length&&h(a[0][0],a[0][1])}}function he(e){var t,r;return t={},s("next"),s("throw",function(o){throw o}),s("return"),t[Symbol.iterator]=function(){return this},t;function s(o,a){t[o]=e[o]?function(n){return(r=!r)?{value:P(e[o](n)),done:!1}:a?a(n):n}:a}}function ue(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof N=="function"?N(e):e[Symbol.iterator](),r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r);function s(a){r[a]=e[a]&&function(n){return new Promise(function(i,h){n=e[a](n),o(i,h,n.done,n.value)})}}function o(a,n,i,h){Promise.resolve(h).then(function(l){a({value:l,done:i})},n)}}function de(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function pe(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=C(e),s=0;s<r.length;s++)r[s]!=="default"&&j(t,e,r[s]);return _e(t,e),t}function fe(e){return e&&e.__esModule?e:{default:e}}function me(e,t,r,s){if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?s:r==="a"?s.call(e):s?s.value:t.get(e)}function ye(e,t,r,s,o){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?o.call(e,r):o?o.value=r:t.set(e,r),r}function ge(e,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof e=="function"?t===e:e.has(t)}function ve(e,t,r){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var s,o;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=t[Symbol.asyncDispose]}if(s===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=t[Symbol.dispose],r&&(o=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");o&&(s=function(){try{o.call(this)}catch(a){return Promise.reject(a)}}),e.stack.push({value:t,dispose:s,async:r})}else r&&e.stack.push({async:!0});return t}function we(e){function t(a){e.error=e.hasError?new Ee(a,e.error,"An error was suppressed during disposal."):a,e.hasError=!0}var r,s=0;function o(){for(;r=e.stack.pop();)try{if(!r.async&&s===1)return s=0,e.stack.push(r),Promise.resolve().then(o);if(r.dispose){var a=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(a).then(o,function(n){return t(n),o()})}else s|=1}catch(n){t(n)}if(s===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return o()}function be(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,s,o,a,n){return s?t?".jsx":".js":o&&(!a||!n)?r:o+a+"."+n.toLowerCase()+"js"}):e}var A,x,j,_e,C,Ee,Oe,T=J(()=>{"use strict";m(),A=function(e,t){return A=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])},A(e,t)},x=function(){return x=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++){t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},x.apply(this,arguments)},j=Object.create?(function(e,t,r,s){s===void 0&&(s=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,o)}):(function(e,t,r,s){s===void 0&&(s=r),e[s]=t[r]}),_e=Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t},C=function(e){return C=Object.getOwnPropertyNames||function(t){var r=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[r.length]=s);return r},C(e)},Ee=typeof SuppressedError=="function"?SuppressedError:function(e,t,r){var s=new Error(r);return s.name="SuppressedError",s.error=e,s.suppressed=t,s},Oe={__extends:K,__assign:x,__rest:V,__decorate:Y,__param:Q,__esDecorate:X,__runInitializers:Z,__propKey:ee,__setFunctionName:te,__metadata:re,__awaiter:se,__generator:ae,__createBinding:j,__exportStar:oe,__values:N,__read:B,__spread:ne,__spreadArrays:ie,__spreadArray:le,__await:P,__asyncGenerator:ce,__asyncDelegator:he,__asyncValues:ue,__makeTemplateObject:de,__importStar:pe,__importDefault:fe,__classPrivateFieldGet:me,__classPrivateFieldSet:ye,__classPrivateFieldIn:ge,__addDisposableResource:ve,__disposeResources:we,__rewriteRelativeImportExtension:be}}),Pe=E(e=>{"use strict";m(),Object.defineProperty(e,"__esModule",{value:!0});var t=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}};e.default=t}),Se=E(e=>{"use strict";m(),Object.defineProperty(e,"__esModule",{value:!0});var t=(T(),S(O)),r=t.__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 h=>{var l,c,u,f;let d=null,p=null,y=null,v=h.status,g=h.statusText;if(h.ok){if(this.method!=="HEAD"){let D=await h.text();D===""||(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=D:p=JSON.parse(D))}let $=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),U=(u=h.headers.get("content-range"))===null||u===void 0?void 0:u.split("/");$&&U&&U.length>1&&(y=parseInt(U[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,v=406,g="Not Acceptable"):p.length===1?p=p[0]:p=null)}else{let $=await h.text();try{d=JSON.parse($),Array.isArray(d)&&h.status===404&&(p=[],d=null,v=200,g="OK")}catch{h.status===404&&$===""?(v=204,g="No Content"):d={message:$}}if(d&&this.isMaybeSingle&&!((f=d?.details)===null||f===void 0)&&f.includes("0 rows")&&(d=null,v=200,g="OK"),d&&this.shouldThrowOnError)throw new r.default(d)}return{error:d,data:p,count:y,status:v,statusText:g}});return this.shouldThrowOnError||(i=i.catch(h=>{var l,c,u;return{error:{message:`${(l=h?.name)!==null&&l!==void 0?l:"FetchError"}: ${h?.message}`,details:`${(c=h?.stack)!==null&&c!==void 0?c:""}`,hint:"",code:`${(u=h?.code)!==null&&u!==void 0?u:""}`},data:null,count:null,status:0,statusText:""}})),i.then(o,a)}returns(){return this}overrideTypes(){return this}};e.default=s}),Te=E(e=>{"use strict";m(),Object.defineProperty(e,"__esModule",{value:!0});var t=(T(),S(O)),r=t.__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:h=i}={}){let l=h?`${h}.order`:"order",c=this.url.searchParams.get(l);return this.url.searchParams.set(l,`${c?`${c},`:""}${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 h=typeof i>"u"?"offset":`${i}.offset`,l=typeof i>"u"?"limit":`${i}.limit`;return this.url.searchParams.set(h,`${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:h=!1,format:l="text"}={}){var c;let u=[o?"analyze":null,a?"verbose":null,n?"settings":null,i?"buffers":null,h?"wal":null].filter(Boolean).join("|"),f=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"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}};e.default=s}),z=E(e=>{"use strict";m(),Object.defineProperty(e,"__esModule",{value:!0});var t=(T(),S(O)),r=t.__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(h=>typeof h=="string"&&s.test(h)?`"${h}"`:`${h}`).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:h}={}){let l="";h==="plain"?l="pl":h==="phrase"?l="ph":h==="websearch"&&(l="w");let c=i===void 0?"":`(${i})`;return this.url.searchParams.append(a,`${l}fts${c}.${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 h=i?`${i}.or`:"or";return this.url.searchParams.append(h,`(${a})`),this}filter(a,n,i){return this.url.searchParams.append(a,`${n}.${i}`),this}};e.default=o}),$e=E(e=>{"use strict";m(),Object.defineProperty(e,"__esModule",{value:!0});var t=(T(),S(O)),r=t.__importDefault(z()),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??{},h=n?"HEAD":"GET",l=!1,c=(o??"*").split("").map(u=>/\s/.test(u)&&!l?"":(u==='"'&&(l=!l),u)).join("");return this.url.searchParams.set("select",c),i&&this.headers.append("Prefer",`count=${i}`),new r.default({method:h,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(o,{count:a,defaultToNull:n=!0}={}){var i;let h="POST";if(a&&this.headers.append("Prefer",`count=${a}`),n||this.headers.append("Prefer","missing=default"),Array.isArray(o)){let l=o.reduce((c,u)=>c.concat(Object.keys(u)),[]);if(l.length>0){let c=[...new Set(l)].map(u=>`"${u}"`);this.url.searchParams.set("columns",c.join(","))}}return new r.default({method:h,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:h=!0}={}){var l;let c="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}`),h||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:c,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})}};e.default=s}),Ze=E(e=>{"use strict";m(),Object.defineProperty(e,"__esModule",{value:!0});var t=(T(),S(O)),r=t.__importDefault($e()),s=t.__importDefault(z()),o=class xe{constructor(n,{headers:i={},schema:h,fetch:l}={}){this.url=n,this.headers=new Headers(i),this.schemaName=h,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:h=!1,get:l=!1,count:c}={}){var u;let f,d=new URL(`${this.url}/rpc/${n}`),p;h||l?(f=h?"HEAD":"GET",Object.entries(i).filter(([v,g])=>g!==void 0).map(([v,g])=>[v,Array.isArray(g)?`{${g.join(",")}}`:`${g}`]).forEach(([v,g])=>{d.searchParams.append(v,g)})):(f="POST",p=i);let y=new Headers(this.headers);return c&&y.set("Prefer",`count=${c}`),new s.default({method:f,url:d,headers:y,schema:this.schemaName,body:p,fetch:(u=this.fetch)!==null&&u!==void 0?u:fetch})}};e.default=o}),et=E(e=>{"use strict";m(),Object.defineProperty(e,"__esModule",{value:!0}),e.PostgrestError=e.PostgrestBuilder=e.PostgrestTransformBuilder=e.PostgrestFilterBuilder=e.PostgrestQueryBuilder=e.PostgrestClient=void 0;var t=(T(),S(O)),r=t.__importDefault(Ze());e.PostgrestClient=r.default;var s=t.__importDefault($e());e.PostgrestQueryBuilder=s.default;var o=t.__importDefault(z());e.PostgrestFilterBuilder=o.default;var a=t.__importDefault(Te());e.PostgrestTransformBuilder=a.default;var n=t.__importDefault(Se());e.PostgrestBuilder=n.default;var i=t.__importDefault(Pe());e.PostgrestError=i.default,e.default={PostgrestClient:r.default,PostgrestQueryBuilder:s.default,PostgrestFilterBuilder:o.default,PostgrestTransformBuilder:a.default,PostgrestBuilder:n.default,PostgrestError:i.default}});m();m();var je=class{constructor(e,t=""){this.http=e,this.baseUrl=t.replace(/\/$/,"")}async invoke(e,t){let r=this.baseUrl?`${this.baseUrl}/functions/${e}`:`/functions/${e}`;return await(await this.http.fetch(r,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};m();m();var w="nvwa_current_jwt",b="nvwa_login_token",L="nvwa_user_profile",tt="set-auth-token",rt=typeof fetch<"u"?(e,t)=>fetch(e,t):()=>{throw new Error("AuthClient requires fetch")},Ie=class{constructor(e,t={}){this.baseUrl=e.replace(/\/$/,""),this.authPath=(t.authPath??"/auth").replace(/^\//,""),this.fetchImpl=t.fetchImpl??rt,this.storage=t.storage??null,this.credentials=t.credentials??"omit"}async currentUser(){if(this.storage){let r=await this.storage.get(L);if(r!=null)return r}let{data:e}=await this.getSession(),t=e?.user??null;return t&&this.storage&&await this.storage.set(L,t),t}async getCurrentJwt(){if(this.storage){let t=await this.storage.get(w);if(t!=null)return t;let r=await this.storage.get(b),{data:s}=await this.getToken(r??void 0);return s?.token?(await this.storage.set(w,s.token),s.token):null}let{data:e}=await this.getToken();return e?.token??null}async persistLogin(e,t){if(!this.storage)return;let r=t?.headers.get(tt)?.trim()||e.token||e.session?.token;r&&await this.storage.set(b,r),e.user&&await this.storage.set(L,e.user);let s=r??await this.storage.get(b),{data:o}=await this.getToken(s??void 0);o?.token&&await this.storage.set(w,o.token)}async clearLogin(){this.storage&&(await this.storage.remove(b),await this.storage.remove(L),await this.storage.remove(w))}url(e){let t=`${`${this.baseUrl.replace(/\/+$/,"")}/${this.authPath.replace(/^\/+/,"")}`}/${e.replace(/^\/+/,"")}`;return typeof console<"u"&&console.debug&&console.debug("[NvwaAuth] request URL:",t),t}async getSession(){try{let e={};if(this.storage){let r=await this.storage.get(b)??await this.storage.get(w);r!=null&&(e.Authorization=`Bearer ${r}`)}let t=await this.fetchImpl(this.url("session"),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}});return t.ok?{data:await t.json()}:{data:null,error:{message:await t.text()||t.statusText,status:t.status}}}catch(e){return{data:null,error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signInWithEmail(e,t){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:e,password:t})}),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 e={};if(this.storage){let r=await this.storage.get(b)??await this.storage.get(w);r!=null&&(e.Authorization=`Bearer ${r}`)}let t=await this.fetchImpl(this.url("sign-out"),{method:"POST",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}});return await this.clearLogin(),t.ok?{}:{error:{message:await t.text()||t.statusText,status:t.status}}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signUp(e){let t=await this.postJson("sign-up/email",e);return t.data&&await this.persistLogin(t.data,t.response),t}async getToken(e){try{let t={};if(e)t.Authorization=`Bearer ${e}`;else if(this.storage){let a=await this.storage.get(b)??await this.storage.get(w);a!=null&&(t.Authorization=`Bearer ${a}`)}let r=await this.fetchImpl(this.url("token"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}}),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(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signInWithUsername(e,t){let r=await this.postJson("sign-in/username",{username:e,password:t});return r.data&&await this.persistLogin(r.data,r.response),r}async signInWithPhoneNumber(e,t,r){let s=await this.postJson("sign-in/phone-number",{phoneNumber:e,password:t,rememberMe:r});return s.data&&await this.persistLogin(s.data,s.response),s}async sendPhoneNumberOtp(e){let t=await this.postJson("phone-number/send-otp",{phoneNumber:e});return t.error?{error:t.error}:{}}async verifyPhoneNumber(e,t){let r=await this.postJson("phone-number/verify",{phoneNumber:e,code:t});return r.data&&await this.persistLogin(r.data,r.response),r}async postJson(e,t){try{let r=await this.fetchImpl(this.url(e),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify(t)}),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 Le{constructor(t){if(this.headerMap=new Map,t){if(t instanceof Le)t.forEach((r,s)=>this.set(s,r));else if(Array.isArray(t))for(let[r,s]of t)this.set(r,String(s));else if(typeof t=="object")for(let r of Object.keys(t))this.set(r,String(t[r]))}}append(t,r){let s=t.toLowerCase(),o=this.headerMap.get(s);this.headerMap.set(s,o?`${o}, ${r}`:r)}set(t,r){this.headerMap.set(t.toLowerCase(),String(r))}get(t){return this.headerMap.get(t.toLowerCase())??null}has(t){return this.headerMap.has(t.toLowerCase())}delete(t){this.headerMap.delete(t.toLowerCase())}forEach(t){for(let[r,s]of this.headerMap.entries())t(s,r,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}};m();m();var Ae=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=st(t?.headers),this.ok=this.status>=200&&this.status<300}async text(){return typeof this.bodyData=="string"?this.bodyData:this.bodyData==null?"":typeof this.bodyData=="object"?JSON.stringify(this.bodyData):String(this.bodyData)}async json(){if(typeof this.bodyData=="string")try{return JSON.parse(this.bodyData)}catch{}return this.bodyData}async arrayBuffer(){let e=await this.text();return new TextEncoder().encode(e).buffer}};function st(e){return e?new _(e):new _}m();m();var Ce=class{constructor(e,t,r){this.storage=e,this.customFetch=t,this.handleUnauthorized=r}async fetch(e,t){return await this.customFetch(e,t)}async fetchWithAuth(e,t){let r=await this.storage.get(w),s=new _(t?.headers);r&&s.set("Authorization",`Bearer ${r}`);let o=t?.method||"GET";if((o==="POST"||o==="PUT"||o==="PATCH")&&t?.body){let n=s.get("Content-Type");(!n||n.includes("text/plain"))&&s.set("Content-Type","application/json")}let a=await this.customFetch(e,{...t,headers:s});if(a.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return a}};m();var at="/storage",ot=at+"/generateUploadUrl",Ne=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+ot,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:r}=await t.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(r,{method:"PUT",body:e,headers:new _({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:o}=await s.json();return{url:o.split("?")[0]}}};m();m();m();var G=Xe(et(),1),{PostgrestClient:nt,PostgrestQueryBuilder:gt,PostgrestFilterBuilder:vt,PostgrestTransformBuilder:wt,PostgrestBuilder:bt,PostgrestError:_t}=G.default||G,it="/entities",ke=(e,t)=>new nt(e+it,{fetch:t.fetchWithAuth.bind(t)});m();var He=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let r=`${this.baseUrl}/capability/${e}/execute`,s=await(await this.http.fetchWithAuth(r,{method:"POST",body:t?JSON.stringify(t):void 0,timeout:6e5})).json();if(s.status!==200)throw new Error(s.message);return s.data}};m();var Re=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let r=`${this.baseUrl}/capability/${e}/execute`,s=await(await this.http.fetchWithAuth(r,{method:"POST",body:t!=null?JSON.stringify(t):void 0,timeout:6e5})).json();if(s.status!==200)throw new Error(s.message);return s.data}};m();var Me=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 e=document.createElement("style");e.id="__nvwa-inspector-overlay-style",e.textContent=`
1
+ "use strict";var F=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var Be=Object.getOwnPropertyNames;var qe=Object.prototype.hasOwnProperty;var ze=(t,e)=>{for(var r in e)F(t,r,{get:e[r],enumerable:!0})},Ge=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Be(e))!qe.call(t,o)&&o!==r&&F(t,o,{get:()=>e[o],enumerable:!(s=Fe(e,o))||s.enumerable});return t};var Je=t=>Ge(F({},"__esModule",{value:!0}),t);var yt={};ze(yt,{default:()=>M,disableIframeHoverInspector:()=>dt,enableIframeHoverInspector:()=>ut,getIframeSourceLocation:()=>pt,localStorage:()=>z,setupIframeHoverInspector:()=>ct,setupIframeSourceLocationListener:()=>ft,webFetch:()=>I});module.exports=Je(yt);var We=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})},W=(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?We(Ye(t)):{},W(e||!t||!t.__esModule?R(r,"default",{value:t,enumerable:!0}):r,t)),S=t=>W(R({},"__esModule",{value:!0}),t),m=J(()=>{"use strict"}),P={};Xe(P,{__addDisposableResource:()=>ve,__assign:()=>x,__asyncDelegator:()=>ce,__asyncGenerator:()=>he,__asyncValues:()=>ue,__await:()=>O,__awaiter:()=>se,__classPrivateFieldGet:()=>me,__classPrivateFieldIn:()=>ge,__classPrivateFieldSet:()=>ye,__createBinding:()=>L,__decorate:()=>Y,__disposeResources:()=>we,__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:()=>Pe});function K(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");N(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 v=(0,r[d])(i==="accessor"?{get:h.get,set:h.set}:h[c],p);if(i==="accessor"){if(v===void 0)continue;if(v===null||typeof v!="object")throw new TypeError("Object expected");(u=n(v.get))&&(h.get=u),(u=n(v.set))&&(h.set=u),(u=n(v.init))&&o.unshift(u)}else(u=n(v))&&(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)&&L(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 O(t){return this instanceof O?(this.v=t,this):new O(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(v,g){a.push([d,y,v,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 O?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:O(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=C(t),s=0;s<r.length;s++)r[s]!=="default"&&L(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 ve(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 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 N,x,L,_e,C,Ee,Pe,T=J(()=>{"use strict";m(),N=function(t,e){return N=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])},N(t,e)},x=function(){return x=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},x.apply(this,arguments)},L=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},C=function(t){return C=Object.getOwnPropertyNames||function(e){var r=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[r.length]=s);return r},C(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},Pe={__extends:K,__assign:x,__rest:V,__decorate:Y,__param:Q,__esDecorate:X,__runInitializers:Z,__propKey:ee,__setFunctionName:te,__metadata:re,__awaiter:se,__generator:ae,__createBinding:L,__exportStar:oe,__values:k,__read:B,__spread:ne,__spreadArrays:ie,__spreadArray:le,__await:O,__asyncGenerator:he,__asyncDelegator:ce,__asyncValues:ue,__makeTemplateObject:de,__importStar:pe,__importDefault:fe,__classPrivateFieldGet:me,__classPrivateFieldSet:ye,__classPrivateFieldIn:ge,__addDisposableResource:ve,__disposeResources:we,__rewriteRelativeImportExtension:be}}),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}),Se=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=(T(),S(P)),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,v=c.status,g=c.statusText;if(c.ok){if(this.method!=="HEAD"){let D=await c.text();D===""||(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=D:p=JSON.parse(D))}let $=(h=this.headers.get("Prefer"))===null||h===void 0?void 0:h.match(/count=(exact|planned|estimated)/),U=(u=c.headers.get("content-range"))===null||u===void 0?void 0:u.split("/");$&&U&&U.length>1&&(y=parseInt(U[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,v=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,v=200,g="OK")}catch{c.status===404&&$===""?(v=204,g="No Content"):d={message:$}}if(d&&this.isMaybeSingle&&!((f=d?.details)===null||f===void 0)&&f.includes("0 rows")&&(d=null,v=200,g="OK"),d&&this.shouldThrowOnError)throw new r.default(d)}return{error:d,data:p,count:y,status:v,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(P)),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(P)),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(P)),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(P)),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(([v,g])=>g!==void 0).map(([v,g])=>[v,Array.isArray(g)?`{${g.join(",")}}`:`${g}`]).forEach(([v,g])=>{d.searchParams.append(v,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(P)),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(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 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 w="nvwa_current_jwt",b="nvwa_login_token",A="nvwa_user_profile",rt="set-auth-token",st=typeof fetch<"u"?(t,e)=>fetch(t,e):()=>{throw new Error("AuthClient requires fetch")},je=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"}async currentUser(){if(this.storage){let r=await this.storage.get(A);if(r!=null)return r}let{data:t}=await this.getSession(),e=t?.user??null;return e&&this.storage&&await this.storage.set(A,e),e}async getCurrentJwt(){if(this.storage){let e=await this.storage.get(w);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(w,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(A,t.user);let s=r??await this.storage.get(b),{data:o}=await this.getToken(s??void 0);o?.token&&await this.storage.set(w,o.token)}async clearLogin(){this.storage&&(await this.storage.remove(b),await this.storage.remove(A),await this.storage.remove(w))}url(t){let e=`${`${this.baseUrl.replace(/\/+$/,"")}/${this.authPath.replace(/^\/+/,"")}`}/${t.replace(/^\/+/,"")}`;return typeof console<"u"&&console.debug&&console.debug("[NvwaAuth] request URL:",e),e}async getSession(){try{let t={};if(this.storage){let r=await this.storage.get(b)??await this.storage.get(w);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(w);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(w);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 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 Ie{constructor(e){if(this.headerMap=new Map,e){if(e instanceof Ie)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 Ae=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 Ne=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(w),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",Ce=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 G=Ze(tt(),1),{PostgrestClient:it,PostgrestQueryBuilder:vt,PostgrestFilterBuilder:wt,PostgrestTransformBuilder:bt,PostgrestBuilder:_t,PostgrestError:Et}=G.default||G,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 Me=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;
@@ -30,4 +30,4 @@
30
30
  max-width: 400px;
31
31
  word-break: break-all;
32
32
  }
33
- `,document.head.appendChild(e)}createTooltip(){return this.tooltip?this.tooltip:(this.tooltip=document.createElement("div"),this.tooltip.id="__nvwa-inspector-tooltip",document.body.appendChild(this.tooltip),this.tooltip)}createOverlay(e){let t=document.createElement("div");return t.className=`__nvwa-inspector-overlay __nvwa-inspector-overlay-${e}`,document.body.appendChild(t),t}updateOverlayPosition(e,t){if(!t.isConnected)return;let r=t.getBoundingClientRect(),s=window.scrollX||window.pageXOffset,o=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(e.style.left=`${r.left+s}px`,e.style.top=`${r.top+o}px`,e.style.width=`${r.width}px`,e.style.height=`${r.height}px`,e.style.display="block"):e.style.display="none"}removeOverlay(e){e&&e.parentNode&&e.parentNode.removeChild(e)}highlightElement(e,t){if(!e.isConnected)return;if(this.hoverElement===e&&this.hoverOverlay){this.updateOverlayPosition(this.hoverOverlay,e);let n=this.createTooltip();t?n.textContent=t:n.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,n.style.display="block";let i=e.getBoundingClientRect();n.style.left=`${i.left+window.scrollX}px`,n.style.top=`${i.top+window.scrollY-n.offsetHeight-8}px`,i.top<n.offsetHeight+8&&(n.style.top=`${i.bottom+window.scrollY+8}px`);return}this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null);let r=this.createOverlay("hover");this.updateOverlayPosition(r,e),this.hoverOverlay=r,this.hoverElement=e;let s=()=>{this.hoverOverlay&&this.hoverElement&&this.hoverElement.isConnected&&this.updateOverlayPosition(this.hoverOverlay,this.hoverElement)};this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler)),this.hoverUpdateHandler=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s);let o=this.createTooltip();t?o.textContent=t:o.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,o.style.display="block";let a=e.getBoundingClientRect();o.style.left=`${a.left+window.scrollX}px`,o.style.top=`${a.top+window.scrollY-o.offsetHeight-8}px`,a.top<o.offsetHeight+8&&(o.style.top=`${a.bottom+window.scrollY+8}px`)}selectElement(e,t){if(!e.isConnected)return;if(this.selectedElement===e&&this.selectedOverlay){this.updateOverlayPosition(this.selectedOverlay,e);return}this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null);let r=this.createOverlay("selected");this.updateOverlayPosition(r,e),this.selectedOverlay=r,this.selectedElement=e;let s=()=>{this.selectedOverlay&&this.selectedElement&&this.selectedElement.isConnected&&this.updateOverlayPosition(this.selectedOverlay,this.selectedElement)};this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler)),this.selectedUpdateHandler=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s)}removeHighlight(){this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null),this.hoverElement&&(this.hoverElement=null),this.tooltip&&(this.tooltip.style.display="none"),this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler),this.hoverUpdateHandler=null)}clearSelection(){this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null),this.selectedElement&&(this.selectedElement=null),this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler),this.selectedUpdateHandler=null)}cleanup(){this.removeHighlight(),this.clearSelection(),this.tooltip&&this.tooltip.parentNode&&(this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null);let e=document.getElementById("__nvwa-inspector-overlay-style");e&&e.parentNode&&e.parentNode.removeChild(e)}};function Ue(e="root"){if(typeof document>"u")return null;let t=document.getElementById(e)||document.body;if(!t)return null;let r=t.querySelector("[data-source-location]");if(r){let s=r.getAttribute("data-source-location");if(s)return s}if(t.firstElementChild){let s=t.firstElementChild.getAttribute("data-source-location");if(s)return s}return null}m();var Et=typeof fetch<"u"?(e,t)=>fetch(e,t):(()=>{throw new Error("payment client requires fetch")})();var R=class{constructor(){this.prefix="nvwa_"}getKey(t){return`${this.prefix}${t}`}async get(t){try{let r=this.getKey(t),s=localStorage.getItem(r);if(!s)return null;let o=JSON.parse(s);return o.expires&&Date.now()>o.expires?(await this.remove(t),null):o.value}catch(r){return console.error("WebStorageService get error:",r),null}}async set(t,r,s){try{let o=this.getKey(t),a={value:r,expires:s?Date.now()+s*1e3:null,timestamp:Date.now()};localStorage.setItem(o,JSON.stringify(a))}catch(o){throw console.error("WebStorageService set error:",o),o}}async remove(t){try{let r=this.getKey(t);localStorage.removeItem(r)}catch(r){throw console.error("WebStorageService remove error:",r),r}}async clear(){try{Object.keys(localStorage).filter(s=>s.startsWith(this.prefix)).forEach(s=>{localStorage.removeItem(s)})}catch(t){throw console.error("WebStorageService clear error:",t),t}}};var lt=(e,t)=>{let r;if(typeof e=="string")r=e;else if(e&&typeof e.toString=="function")r=e.toString();else if(e?.url)r=e.url;else throw new Error("Invalid input for webFetch");let s;if(t?.headers){let a=t.headers;if(a instanceof _){let n={};a.forEach((i,h)=>{n[h]=i}),s=n}else if(Array.isArray(a)){let n=[];for(let i of a)Array.isArray(i)&&i.length>=2&&n.push([String(i[0]),String(i[1])]);s=n}else typeof a=="object"&&(s=a)}let o={method:t?.method||"GET",headers:s,body:t?.body,credentials:t?.credentials};return t?.signal&&(o.signal=t.signal),globalThis.fetch(r,o).then(async a=>{let n=a.headers.get("content-type")||"",i;if(n.includes("application/json"))i=await a.json();else{let l=await a.text();try{i=JSON.parse(l)}catch{i=l}}let h=new _;return a.headers.forEach((l,c)=>{h.set(c,l)}),new Ae(i,{status:a.status,statusText:a.statusText,headers:h})})},I=lt;function ct(){if(typeof window>"u"||window===window.parent)return;let e=!1,t=new Me;function r(l){if(!l)return!1;let c=l.toLowerCase();return c.includes("/components/")||c.includes("\\components\\")}function s(l){let c=l,u=null;for(;c;){let f=c.getAttribute("data-source-location");if(f)if(r(f)){u||(u=f),c=c.parentElement;continue}else return f;c=c.parentElement}return u}let o=null;function a(l){e&&(o!==null&&cancelAnimationFrame(o),o=requestAnimationFrame(()=>{let c=l.target;if(!c||c===document.body||c===document.documentElement){t.removeHighlight();return}if(c.tagName.toLowerCase()==="img"){let p=s(c);t.highlightElement(c,p);let y={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:p,elementInfo:{tagName:c.tagName.toLowerCase(),className:c.className||"",id:c.id||""}};window.parent.postMessage(y,"*");return}let u=c,f=s(c);if(!f){let p=c.parentElement;for(;p&&p!==document.body&&p!==document.documentElement;){let y=s(p);if(y){u=p,f=y;break}p=p.parentElement}}t.highlightElement(u,f);let d={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:f,elementInfo:{tagName:u.tagName.toLowerCase(),className:u.className||"",id:u.id||""}};window.parent.postMessage(d,"*")}))}function n(){if(!e)return;t.removeHighlight();let l={type:"HOVER_INSPECTOR_ELEMENT_LEAVE"};window.parent.postMessage(l,"*")}function i(l){if(!e)return;l.preventDefault(),l.stopPropagation();let c=l.target;if(!c||c===document.body||c===document.documentElement)return;let u=s(c);t.selectElement(c,u);let f={type:"HOVER_INSPECTOR_ELEMENT_SELECT",sourceLocation:u,elementInfo:{tagName:c.tagName.toLowerCase(),className:c.className||"",id:c.id||""}};window.parent.postMessage(f,"*")}function h(l){l.data?.type==="HOVER_INSPECTOR_ENABLE"?(e=!0,document.addEventListener("mousemove",a),document.addEventListener("mouseleave",n),document.addEventListener("click",i,!0)):l.data?.type==="HOVER_INSPECTOR_DISABLE"&&(e=!1,document.removeEventListener("mousemove",a),document.removeEventListener("mouseleave",n),document.removeEventListener("click",i,!0),t.removeHighlight(),t.clearSelection())}return window.addEventListener("message",h),()=>{window.removeEventListener("message",h),document.removeEventListener("mousemove",a),document.removeEventListener("mouseleave",n),document.removeEventListener("click",i,!0),t.cleanup()}}function ht(e,t){if(!e||!e.contentWindow)throw new Error("Invalid iframe element");let r={type:"HOVER_INSPECTOR_ENABLE"};e.contentWindow.postMessage(r,t)}function ut(e,t){if(!e||!e.contentWindow)return;let r={type:"HOVER_INSPECTOR_DISABLE"};e.contentWindow.postMessage(r,t)}function dt(e,t,r=5e3){return new Promise((s,o)=>{if(!e||!e.contentWindow){o(new Error("Invalid iframe element"));return}let a=`source-location-${Date.now()}-${Math.random()}`,n=setTimeout(()=>{window.removeEventListener("message",i),o(new Error("Request timeout"))},r),i=l=>{l.origin===t&&l.data?.type==="GET_SOURCE_LOCATION_RESPONSE"&&l.data?.requestId===a&&(clearTimeout(n),window.removeEventListener("message",i),l.data.error?o(new Error(l.data.error)):s(l.data.sourceLocation||null))};window.addEventListener("message",i);let h={type:"GET_SOURCE_LOCATION_REQUEST",requestId:a};try{e.contentWindow.postMessage(h,t)}catch(l){clearTimeout(n),window.removeEventListener("message",i),o(l)}})}function pt(){if(typeof window>"u"||window===window.parent)return;let e=t=>{if(t.data?.type==="GET_SOURCE_LOCATION_REQUEST")try{let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:ft(),requestId:t.data.requestId};window.parent.postMessage(s,t.origin)}catch(r){let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:null,error:r instanceof Error?r.message:"Unknown error",requestId:t.data.requestId};window.parent.postMessage(s,t.origin)}};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}}function ft(){return Ue("root")}var q=new R,M=class{constructor(t,r){this.auth=new Ie(t,{fetchImpl:I,storage:q}),this.httpClient=new Ce(q,I,r),this.fileStorage=new Ne(t,this.httpClient),this.entities=ke(t,this.httpClient),this.functions=new je(this.httpClient,t),this.skill=new He(t,this.httpClient),this.capability=new Re(t,this.httpClient)}};0&&(module.exports={disableIframeHoverInspector,enableIframeHoverInspector,getIframeSourceLocation,localStorage,setupIframeHoverInspector,setupIframeSourceLocationListener,webFetch});
33
+ `,document.head.appendChild(t)}createTooltip(){return this.tooltip?this.tooltip:(this.tooltip=document.createElement("div"),this.tooltip.id="__nvwa-inspector-tooltip",document.body.appendChild(this.tooltip),this.tooltip)}createOverlay(t){let e=document.createElement("div");return e.className=`__nvwa-inspector-overlay __nvwa-inspector-overlay-${t}`,document.body.appendChild(e),e}updateOverlayPosition(t,e){if(!e.isConnected)return;let r=e.getBoundingClientRect(),s=window.scrollX||window.pageXOffset,o=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(t.style.left=`${r.left+s}px`,t.style.top=`${r.top+o}px`,t.style.width=`${r.width}px`,t.style.height=`${r.height}px`,t.style.display="block"):t.style.display="none"}removeOverlay(t){t&&t.parentNode&&t.parentNode.removeChild(t)}highlightElement(t,e){if(!t.isConnected)return;if(this.hoverElement===t&&this.hoverOverlay){this.updateOverlayPosition(this.hoverOverlay,t);let n=this.createTooltip();e?n.textContent=e:n.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,n.style.display="block";let i=t.getBoundingClientRect();n.style.left=`${i.left+window.scrollX}px`,n.style.top=`${i.top+window.scrollY-n.offsetHeight-8}px`,i.top<n.offsetHeight+8&&(n.style.top=`${i.bottom+window.scrollY+8}px`);return}this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null);let r=this.createOverlay("hover");this.updateOverlayPosition(r,t),this.hoverOverlay=r,this.hoverElement=t;let s=()=>{this.hoverOverlay&&this.hoverElement&&this.hoverElement.isConnected&&this.updateOverlayPosition(this.hoverOverlay,this.hoverElement)};this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler)),this.hoverUpdateHandler=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s);let o=this.createTooltip();e?o.textContent=e:o.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,o.style.display="block";let a=t.getBoundingClientRect();o.style.left=`${a.left+window.scrollX}px`,o.style.top=`${a.top+window.scrollY-o.offsetHeight-8}px`,a.top<o.offsetHeight+8&&(o.style.top=`${a.bottom+window.scrollY+8}px`)}selectElement(t,e){if(!t.isConnected)return;if(this.selectedElement===t&&this.selectedOverlay){this.updateOverlayPosition(this.selectedOverlay,t);return}this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null);let r=this.createOverlay("selected");this.updateOverlayPosition(r,t),this.selectedOverlay=r,this.selectedElement=t;let s=()=>{this.selectedOverlay&&this.selectedElement&&this.selectedElement.isConnected&&this.updateOverlayPosition(this.selectedOverlay,this.selectedElement)};this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler)),this.selectedUpdateHandler=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s)}removeHighlight(){this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null),this.hoverElement&&(this.hoverElement=null),this.tooltip&&(this.tooltip.style.display="none"),this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler),this.hoverUpdateHandler=null)}clearSelection(){this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null),this.selectedElement&&(this.selectedElement=null),this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler),this.selectedUpdateHandler=null)}cleanup(){this.removeHighlight(),this.clearSelection(),this.tooltip&&this.tooltip.parentNode&&(this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null);let t=document.getElementById("__nvwa-inspector-overlay-style");t&&t.parentNode&&t.parentNode.removeChild(t)}};function Ue(t="root"){if(typeof document>"u")return null;let e=document.getElementById(t)||document.body;if(!e)return null;let r=e.querySelector("[data-source-location]");if(r){let s=r.getAttribute("data-source-location");if(s)return s}if(e.firstElementChild){let s=e.firstElementChild.getAttribute("data-source-location");if(s)return s}return null}m();var H=class{constructor(){this.prefix="nvwa_"}getKey(e){return`${this.prefix}${e}`}async get(e){try{let r=this.getKey(e),s=localStorage.getItem(r);if(!s)return null;let o=JSON.parse(s);return o.expires&&Date.now()>o.expires?(await this.remove(e),null):o.value}catch(r){return console.error("WebStorageService get error:",r),null}}async set(e,r,s){try{let o=this.getKey(e),a={value:r,expires:s?Date.now()+s*1e3:null,timestamp:Date.now()};localStorage.setItem(o,JSON.stringify(a))}catch(o){throw console.error("WebStorageService set error:",o),o}}async remove(e){try{let r=this.getKey(e);localStorage.removeItem(r)}catch(r){throw console.error("WebStorageService remove error:",r),r}}async clear(){try{Object.keys(localStorage).filter(s=>s.startsWith(this.prefix)).forEach(s=>{localStorage.removeItem(s)})}catch(e){throw console.error("WebStorageService clear error:",e),e}}};var ht=(t,e)=>{let r;if(typeof t=="string")r=t;else if(t&&typeof t.toString=="function")r=t.toString();else if(t?.url)r=t.url;else throw new Error("Invalid input for webFetch");let s;if(e?.headers){let a=e.headers;if(a instanceof _){let n={};a.forEach((i,c)=>{n[c]=i}),s=n}else if(Array.isArray(a)){let n=[];for(let i of a)Array.isArray(i)&&i.length>=2&&n.push([String(i[0]),String(i[1])]);s=n}else typeof a=="object"&&(s=a)}let o={method:e?.method||"GET",headers:s,body:e?.body,credentials:e?.credentials};return e?.signal&&(o.signal=e.signal),globalThis.fetch(r,o).then(async a=>{let n=a.headers.get("content-type")||"",i;if(n.includes("application/json"))i=await a.json();else{let l=await a.text();try{i=JSON.parse(l)}catch{i=l}}let c=new _;return a.headers.forEach((l,h)=>{c.set(h,l)}),new Ae(i,{status:a.status,statusText:a.statusText,headers:c})})},I=ht;var De={async requestPayment(t){let e=t;if(typeof e.redirectUrl=="string"){window.location.href=e.redirectUrl;return}if(typeof e.codeUrl=="string"){let r=`https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(e.codeUrl)}`;window.open(r,"_blank","noopener,noreferrer");return}if(typeof e.formHtml=="string"){let r=window.open("","_blank");r&&(r.document.write(e.formHtml),r.document.close());return}throw new Error("requestPayment: unsupported payParams for Desktop-web")}};function ct(){if(typeof window>"u"||window===window.parent)return;let t=!1,e=new Me;function r(l){if(!l)return!1;let h=l.toLowerCase();return h.includes("/components/")||h.includes("\\components\\")}function s(l){let h=l,u=null;for(;h;){let f=h.getAttribute("data-source-location");if(f)if(r(f)){u||(u=f),h=h.parentElement;continue}else return f;h=h.parentElement}return u}let o=null;function a(l){t&&(o!==null&&cancelAnimationFrame(o),o=requestAnimationFrame(()=>{let h=l.target;if(!h||h===document.body||h===document.documentElement){e.removeHighlight();return}if(h.tagName.toLowerCase()==="img"){let p=s(h);e.highlightElement(h,p);let y={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:p,elementInfo:{tagName:h.tagName.toLowerCase(),className:h.className||"",id:h.id||""}};window.parent.postMessage(y,"*");return}let u=h,f=s(h);if(!f){let p=h.parentElement;for(;p&&p!==document.body&&p!==document.documentElement;){let y=s(p);if(y){u=p,f=y;break}p=p.parentElement}}e.highlightElement(u,f);let d={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:f,elementInfo:{tagName:u.tagName.toLowerCase(),className:u.className||"",id:u.id||""}};window.parent.postMessage(d,"*")}))}function n(){if(!t)return;e.removeHighlight();let l={type:"HOVER_INSPECTOR_ELEMENT_LEAVE"};window.parent.postMessage(l,"*")}function i(l){if(!t)return;l.preventDefault(),l.stopPropagation();let h=l.target;if(!h||h===document.body||h===document.documentElement)return;let u=s(h);e.selectElement(h,u);let f={type:"HOVER_INSPECTOR_ELEMENT_SELECT",sourceLocation:u,elementInfo:{tagName:h.tagName.toLowerCase(),className:h.className||"",id:h.id||""}};window.parent.postMessage(f,"*")}function c(l){l.data?.type==="HOVER_INSPECTOR_ENABLE"?(t=!0,document.addEventListener("mousemove",a),document.addEventListener("mouseleave",n),document.addEventListener("click",i,!0)):l.data?.type==="HOVER_INSPECTOR_DISABLE"&&(t=!1,document.removeEventListener("mousemove",a),document.removeEventListener("mouseleave",n),document.removeEventListener("click",i,!0),e.removeHighlight(),e.clearSelection())}return window.addEventListener("message",c),()=>{window.removeEventListener("message",c),document.removeEventListener("mousemove",a),document.removeEventListener("mouseleave",n),document.removeEventListener("click",i,!0),e.cleanup()}}function ut(t,e){if(!t||!t.contentWindow)throw new Error("Invalid iframe element");let r={type:"HOVER_INSPECTOR_ENABLE"};t.contentWindow.postMessage(r,e)}function dt(t,e){if(!t||!t.contentWindow)return;let r={type:"HOVER_INSPECTOR_DISABLE"};t.contentWindow.postMessage(r,e)}function pt(t,e,r=5e3){return new Promise((s,o)=>{if(!t||!t.contentWindow){o(new Error("Invalid iframe element"));return}let a=`source-location-${Date.now()}-${Math.random()}`,n=setTimeout(()=>{window.removeEventListener("message",i),o(new Error("Request timeout"))},r),i=l=>{l.origin===e&&l.data?.type==="GET_SOURCE_LOCATION_RESPONSE"&&l.data?.requestId===a&&(clearTimeout(n),window.removeEventListener("message",i),l.data.error?o(new Error(l.data.error)):s(l.data.sourceLocation||null))};window.addEventListener("message",i);let c={type:"GET_SOURCE_LOCATION_REQUEST",requestId:a};try{t.contentWindow.postMessage(c,e)}catch(l){clearTimeout(n),window.removeEventListener("message",i),o(l)}})}function ft(){if(typeof window>"u"||window===window.parent)return;let t=e=>{if(e.data?.type==="GET_SOURCE_LOCATION_REQUEST")try{let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:mt(),requestId:e.data.requestId};window.parent.postMessage(s,e.origin)}catch(r){let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:null,error:r instanceof Error?r.message:"Unknown error",requestId:e.data.requestId};window.parent.postMessage(s,e.origin)}};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}}function mt(){return Ue("root")}var z=new H,M=class{constructor(e,r){this.endpointType="Desktop-web";this.payment=De;this.auth=new je(e,{fetchImpl:I,storage:z}),this.httpClient=new Ne(z,I,r),this.fileStorage=new Ce(e,this.httpClient),this.entities=ke(e,this.httpClient),this.functions=new Le(this.httpClient,e),this.skill=new Re(e,this.httpClient),this.capability=new He(e,this.httpClient)}};0&&(module.exports={disableIframeHoverInspector,enableIframeHoverInspector,getIframeSourceLocation,localStorage,setupIframeHoverInspector,setupIframeSourceLocationListener,webFetch});
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- var De=Object.create,H=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,Be=Object.getOwnPropertyNames,ze=Object.getPrototypeOf,qe=Object.prototype.hasOwnProperty,G=(e,t)=>()=>(e&&(t=e(e=0)),t),E=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ge=(e,t)=>{for(var r in t)H(e,r,{get:t[r],enumerable:!0})},J=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Be(t))!qe.call(e,o)&&o!==r&&H(e,o,{get:()=>t[o],enumerable:!(s=Fe(t,o))||s.enumerable});return e},Je=(e,t,r)=>(r=e!=null?De(ze(e)):{},J(t||!e||!e.__esModule?H(r,"default",{value:e,enumerable:!0}):r,e)),S=e=>J(H({},"__esModule",{value:!0}),e),m=G(()=>{"use strict"}),O={};Ge(O,{__addDisposableResource:()=>ge,__assign:()=>x,__asyncDelegator:()=>ce,__asyncGenerator:()=>le,__asyncValues:()=>he,__await:()=>P,__awaiter:()=>re,__classPrivateFieldGet:()=>fe,__classPrivateFieldIn:()=>ye,__classPrivateFieldSet:()=>me,__createBinding:()=>j,__decorate:()=>V,__disposeResources:()=>ve,__esDecorate:()=>Q,__exportStar:()=>ae,__extends:()=>W,__generator:()=>se,__importDefault:()=>pe,__importStar:()=>de,__makeTemplateObject:()=>ue,__metadata:()=>te,__param:()=>Y,__propKey:()=>Z,__read:()=>F,__rest:()=>K,__rewriteRelativeImportExtension:()=>we,__runInitializers:()=>X,__setFunctionName:()=>ee,__spread:()=>oe,__spreadArray:()=>ie,__spreadArrays:()=>ne,__values:()=>C,default:()=>Ee});function W(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");L(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function K(e,t){var r={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,s=Object.getOwnPropertySymbols(e);o<s.length;o++)t.indexOf(s[o])<0&&Object.prototype.propertyIsEnumerable.call(e,s[o])&&(r[s[o]]=e[s[o]]);return r}function V(e,t,r,s){var o=arguments.length,a=o<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,r):s,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(e,t,r,s);else for(var i=e.length-1;i>=0;i--)(n=e[i])&&(a=(o<3?n(a):o>3?n(t,r,a):n(t,r))||a);return o>3&&a&&Object.defineProperty(t,r,a),a}function Y(e,t){return function(r,s){t(r,s,e)}}function Q(e,t,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,h=i==="getter"?"get":i==="setter"?"set":"value",l=!t&&e?s.static?e:e.prototype:null,c=t||(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 v=(0,r[d])(i==="accessor"?{get:c.get,set:c.set}:c[h],p);if(i==="accessor"){if(v===void 0)continue;if(v===null||typeof v!="object")throw new TypeError("Object expected");(u=n(v.get))&&(c.get=u),(u=n(v.set))&&(c.set=u),(u=n(v.init))&&o.unshift(u)}else(u=n(v))&&(i==="field"?o.unshift(u):c[h]=u)}l&&Object.defineProperty(l,s.name,c),f=!0}function X(e,t,r){for(var s=arguments.length>2,o=0;o<t.length;o++)r=s?t[o].call(e,r):t[o].call(e);return s?r:void 0}function Z(e){return typeof e=="symbol"?e:"".concat(e)}function ee(e,t,r){return typeof t=="symbol"&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function te(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function re(e,t,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(c){try{l(s.next(c))}catch(u){n(u)}}function h(c){try{l(s.throw(c))}catch(u){n(u)}}function l(c){c.done?a(c.value):o(c.value).then(i,h)}l((s=s.apply(e,t||[])).next())})}function se(e,t){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(c){return h([l,c])}}function h(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=t.call(e,r)}catch(c){l=[6,c],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(e,t){for(var r in e)r!=="default"&&!Object.prototype.hasOwnProperty.call(t,r)&&j(t,e,r)}function C(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],s=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&s>=e.length&&(e=void 0),{value:e&&e[s++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function F(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var s=r.call(e),o,a=[],n;try{for(;(t===void 0||t-- >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 e=[],t=0;t<arguments.length;t++)e=e.concat(F(arguments[t]));return e}function ne(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var s=Array(e),o=0,t=0;t<r;t++)for(var a=arguments[t],n=0,i=a.length;n<i;n++,o++)s[o]=a[n];return s}function ie(e,t,r){if(r||arguments.length===2)for(var s=0,o=t.length,a;s<o;s++)(a||!(s in t))&&(a||(a=Array.prototype.slice.call(t,0,s)),a[s]=t[s]);return e.concat(a||Array.prototype.slice.call(t))}function P(e){return this instanceof P?(this.v=e,this):new P(e)}function le(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r.apply(e,t||[]),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(v,g){a.push([d,y,v,g])>1||h(d,y)})},p&&(o[d]=p(o[d])))}function h(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(c,u):f(a[0][2],d)}function c(d){h("next",d)}function u(d){h("throw",d)}function f(d,p){d(p),a.shift(),a.length&&h(a[0][0],a[0][1])}}function ce(e){var t,r;return t={},s("next"),s("throw",function(o){throw o}),s("return"),t[Symbol.iterator]=function(){return this},t;function s(o,a){t[o]=e[o]?function(n){return(r=!r)?{value:P(e[o](n)),done:!1}:a?a(n):n}:a}}function he(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof C=="function"?C(e):e[Symbol.iterator](),r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r);function s(a){r[a]=e[a]&&function(n){return new Promise(function(i,h){n=e[a](n),o(i,h,n.done,n.value)})}}function o(a,n,i,h){Promise.resolve(h).then(function(l){a({value:l,done:i})},n)}}function ue(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function de(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r=A(e),s=0;s<r.length;s++)r[s]!=="default"&&j(t,e,r[s]);return be(t,e),t}function pe(e){return e&&e.__esModule?e:{default:e}}function fe(e,t,r,s){if(r==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?e!==t||!s:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?s:r==="a"?s.call(e):s?s.value:t.get(e)}function me(e,t,r,s,o){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!o)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?o.call(e,r):o?o.value=r:t.set(e,r),r}function ye(e,t){if(t===null||typeof t!="object"&&typeof t!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof e=="function"?t===e:e.has(t)}function ge(e,t,r){if(t!=null){if(typeof t!="object"&&typeof t!="function")throw new TypeError("Object expected.");var s,o;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");s=t[Symbol.asyncDispose]}if(s===void 0){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");s=t[Symbol.dispose],r&&(o=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");o&&(s=function(){try{o.call(this)}catch(a){return Promise.reject(a)}}),e.stack.push({value:t,dispose:s,async:r})}else r&&e.stack.push({async:!0});return t}function ve(e){function t(a){e.error=e.hasError?new _e(a,e.error,"An error was suppressed during disposal."):a,e.hasError=!0}var r,s=0;function o(){for(;r=e.stack.pop();)try{if(!r.async&&s===1)return s=0,e.stack.push(r),Promise.resolve().then(o);if(r.dispose){var a=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(a).then(o,function(n){return t(n),o()})}else s|=1}catch(n){t(n)}if(s===1)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}return o()}function we(e,t){return typeof e=="string"&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,s,o,a,n){return s?t?".jsx":".js":o&&(!a||!n)?r:o+a+"."+n.toLowerCase()+"js"}):e}var L,x,j,be,A,_e,Ee,T=G(()=>{"use strict";m(),L=function(e,t){return L=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])},L(e,t)},x=function(){return x=Object.assign||function(e){for(var t,r=1,s=arguments.length;r<s;r++){t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},x.apply(this,arguments)},j=Object.create?(function(e,t,r,s){s===void 0&&(s=r);var o=Object.getOwnPropertyDescriptor(t,r);(!o||("get"in o?!t.__esModule:o.writable||o.configurable))&&(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,s,o)}):(function(e,t,r,s){s===void 0&&(s=r),e[s]=t[r]}),be=Object.create?(function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}):function(e,t){e.default=t},A=function(e){return A=Object.getOwnPropertyNames||function(t){var r=[];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(r[r.length]=s);return r},A(e)},_e=typeof SuppressedError=="function"?SuppressedError:function(e,t,r){var s=new Error(r);return s.name="SuppressedError",s.error=e,s.suppressed=t,s},Ee={__extends:W,__assign:x,__rest:K,__decorate:V,__param:Y,__esDecorate:Q,__runInitializers:X,__propKey:Z,__setFunctionName:ee,__metadata:te,__awaiter:re,__generator:se,__createBinding:j,__exportStar:ae,__values:C,__read:F,__spread:oe,__spreadArrays:ne,__spreadArray:ie,__await:P,__asyncGenerator:le,__asyncDelegator:ce,__asyncValues:he,__makeTemplateObject:ue,__importStar:de,__importDefault:pe,__classPrivateFieldGet:fe,__classPrivateFieldSet:me,__classPrivateFieldIn:ye,__addDisposableResource:ge,__disposeResources:ve,__rewriteRelativeImportExtension:we}}),Oe=E(e=>{"use strict";m(),Object.defineProperty(e,"__esModule",{value:!0});var t=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}};e.default=t}),Pe=E(e=>{"use strict";m(),Object.defineProperty(e,"__esModule",{value:!0});var t=(T(),S(O)),r=t.__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 h=>{var l,c,u,f;let d=null,p=null,y=null,v=h.status,g=h.statusText;if(h.ok){if(this.method!=="HEAD"){let D=await h.text();D===""||(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=D:p=JSON.parse(D))}let $=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),U=(u=h.headers.get("content-range"))===null||u===void 0?void 0:u.split("/");$&&U&&U.length>1&&(y=parseInt(U[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,v=406,g="Not Acceptable"):p.length===1?p=p[0]:p=null)}else{let $=await h.text();try{d=JSON.parse($),Array.isArray(d)&&h.status===404&&(p=[],d=null,v=200,g="OK")}catch{h.status===404&&$===""?(v=204,g="No Content"):d={message:$}}if(d&&this.isMaybeSingle&&!((f=d?.details)===null||f===void 0)&&f.includes("0 rows")&&(d=null,v=200,g="OK"),d&&this.shouldThrowOnError)throw new r.default(d)}return{error:d,data:p,count:y,status:v,statusText:g}});return this.shouldThrowOnError||(i=i.catch(h=>{var l,c,u;return{error:{message:`${(l=h?.name)!==null&&l!==void 0?l:"FetchError"}: ${h?.message}`,details:`${(c=h?.stack)!==null&&c!==void 0?c:""}`,hint:"",code:`${(u=h?.code)!==null&&u!==void 0?u:""}`},data:null,count:null,status:0,statusText:""}})),i.then(o,a)}returns(){return this}overrideTypes(){return this}};e.default=s}),Se=E(e=>{"use strict";m(),Object.defineProperty(e,"__esModule",{value:!0});var t=(T(),S(O)),r=t.__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:h=i}={}){let l=h?`${h}.order`:"order",c=this.url.searchParams.get(l);return this.url.searchParams.set(l,`${c?`${c},`:""}${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 h=typeof i>"u"?"offset":`${i}.offset`,l=typeof i>"u"?"limit":`${i}.limit`;return this.url.searchParams.set(h,`${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:h=!1,format:l="text"}={}){var c;let u=[o?"analyze":null,a?"verbose":null,n?"settings":null,i?"buffers":null,h?"wal":null].filter(Boolean).join("|"),f=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"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}};e.default=s}),B=E(e=>{"use strict";m(),Object.defineProperty(e,"__esModule",{value:!0});var t=(T(),S(O)),r=t.__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(h=>typeof h=="string"&&s.test(h)?`"${h}"`:`${h}`).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:h}={}){let l="";h==="plain"?l="pl":h==="phrase"?l="ph":h==="websearch"&&(l="w");let c=i===void 0?"":`(${i})`;return this.url.searchParams.append(a,`${l}fts${c}.${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 h=i?`${i}.or`:"or";return this.url.searchParams.append(h,`(${a})`),this}filter(a,n,i){return this.url.searchParams.append(a,`${n}.${i}`),this}};e.default=o}),Te=E(e=>{"use strict";m(),Object.defineProperty(e,"__esModule",{value:!0});var t=(T(),S(O)),r=t.__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??{},h=n?"HEAD":"GET",l=!1,c=(o??"*").split("").map(u=>/\s/.test(u)&&!l?"":(u==='"'&&(l=!l),u)).join("");return this.url.searchParams.set("select",c),i&&this.headers.append("Prefer",`count=${i}`),new r.default({method:h,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(o,{count:a,defaultToNull:n=!0}={}){var i;let h="POST";if(a&&this.headers.append("Prefer",`count=${a}`),n||this.headers.append("Prefer","missing=default"),Array.isArray(o)){let l=o.reduce((c,u)=>c.concat(Object.keys(u)),[]);if(l.length>0){let c=[...new Set(l)].map(u=>`"${u}"`);this.url.searchParams.set("columns",c.join(","))}}return new r.default({method:h,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:h=!0}={}){var l;let c="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}`),h||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:c,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})}};e.default=s}),We=E(e=>{"use strict";m(),Object.defineProperty(e,"__esModule",{value:!0});var t=(T(),S(O)),r=t.__importDefault(Te()),s=t.__importDefault(B()),o=class $e{constructor(n,{headers:i={},schema:h,fetch:l}={}){this.url=n,this.headers=new Headers(i),this.schemaName=h,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:h=!1,get:l=!1,count:c}={}){var u;let f,d=new URL(`${this.url}/rpc/${n}`),p;h||l?(f=h?"HEAD":"GET",Object.entries(i).filter(([v,g])=>g!==void 0).map(([v,g])=>[v,Array.isArray(g)?`{${g.join(",")}}`:`${g}`]).forEach(([v,g])=>{d.searchParams.append(v,g)})):(f="POST",p=i);let y=new Headers(this.headers);return c&&y.set("Prefer",`count=${c}`),new s.default({method:f,url:d,headers:y,schema:this.schemaName,body:p,fetch:(u=this.fetch)!==null&&u!==void 0?u:fetch})}};e.default=o}),Ke=E(e=>{"use strict";m(),Object.defineProperty(e,"__esModule",{value:!0}),e.PostgrestError=e.PostgrestBuilder=e.PostgrestTransformBuilder=e.PostgrestFilterBuilder=e.PostgrestQueryBuilder=e.PostgrestClient=void 0;var t=(T(),S(O)),r=t.__importDefault(We());e.PostgrestClient=r.default;var s=t.__importDefault(Te());e.PostgrestQueryBuilder=s.default;var o=t.__importDefault(B());e.PostgrestFilterBuilder=o.default;var a=t.__importDefault(Se());e.PostgrestTransformBuilder=a.default;var n=t.__importDefault(Pe());e.PostgrestBuilder=n.default;var i=t.__importDefault(Oe());e.PostgrestError=i.default,e.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(e,t=""){this.http=e,this.baseUrl=t.replace(/\/$/,"")}async invoke(e,t){let r=this.baseUrl?`${this.baseUrl}/functions/${e}`:`/functions/${e}`;return await(await this.http.fetch(r,{method:t.method||"POST",body:t.body,headers:t.headers})).json()}};m();m();var w="nvwa_current_jwt",b="nvwa_login_token",I="nvwa_user_profile",Ve="set-auth-token",Ye=typeof fetch<"u"?(e,t)=>fetch(e,t):()=>{throw new Error("AuthClient requires fetch")},je=class{constructor(e,t={}){this.baseUrl=e.replace(/\/$/,""),this.authPath=(t.authPath??"/auth").replace(/^\//,""),this.fetchImpl=t.fetchImpl??Ye,this.storage=t.storage??null,this.credentials=t.credentials??"omit"}async currentUser(){if(this.storage){let r=await this.storage.get(I);if(r!=null)return r}let{data:e}=await this.getSession(),t=e?.user??null;return t&&this.storage&&await this.storage.set(I,t),t}async getCurrentJwt(){if(this.storage){let t=await this.storage.get(w);if(t!=null)return t;let r=await this.storage.get(b),{data:s}=await this.getToken(r??void 0);return s?.token?(await this.storage.set(w,s.token),s.token):null}let{data:e}=await this.getToken();return e?.token??null}async persistLogin(e,t){if(!this.storage)return;let r=t?.headers.get(Ve)?.trim()||e.token||e.session?.token;r&&await this.storage.set(b,r),e.user&&await this.storage.set(I,e.user);let s=r??await this.storage.get(b),{data:o}=await this.getToken(s??void 0);o?.token&&await this.storage.set(w,o.token)}async clearLogin(){this.storage&&(await this.storage.remove(b),await this.storage.remove(I),await this.storage.remove(w))}url(e){let t=`${`${this.baseUrl.replace(/\/+$/,"")}/${this.authPath.replace(/^\/+/,"")}`}/${e.replace(/^\/+/,"")}`;return typeof console<"u"&&console.debug&&console.debug("[NvwaAuth] request URL:",t),t}async getSession(){try{let e={};if(this.storage){let r=await this.storage.get(b)??await this.storage.get(w);r!=null&&(e.Authorization=`Bearer ${r}`)}let t=await this.fetchImpl(this.url("session"),{method:"GET",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}});return t.ok?{data:await t.json()}:{data:null,error:{message:await t.text()||t.statusText,status:t.status}}}catch(e){return{data:null,error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signInWithEmail(e,t){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:e,password:t})}),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 e={};if(this.storage){let r=await this.storage.get(b)??await this.storage.get(w);r!=null&&(e.Authorization=`Bearer ${r}`)}let t=await this.fetchImpl(this.url("sign-out"),{method:"POST",credentials:this.credentials,...Object.keys(e).length?{headers:e}:{}});return await this.clearLogin(),t.ok?{}:{error:{message:await t.text()||t.statusText,status:t.status}}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async signUp(e){let t=await this.postJson("sign-up/email",e);return t.data&&await this.persistLogin(t.data,t.response),t}async getToken(e){try{let t={};if(e)t.Authorization=`Bearer ${e}`;else if(this.storage){let a=await this.storage.get(b)??await this.storage.get(w);a!=null&&(t.Authorization=`Bearer ${a}`)}let r=await this.fetchImpl(this.url("token"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}}),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(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}async signInWithUsername(e,t){let r=await this.postJson("sign-in/username",{username:e,password:t});return r.data&&await this.persistLogin(r.data,r.response),r}async signInWithPhoneNumber(e,t,r){let s=await this.postJson("sign-in/phone-number",{phoneNumber:e,password:t,rememberMe:r});return s.data&&await this.persistLogin(s.data,s.response),s}async sendPhoneNumberOtp(e){let t=await this.postJson("phone-number/send-otp",{phoneNumber:e});return t.error?{error:t.error}:{}}async verifyPhoneNumber(e,t){let r=await this.postJson("phone-number/verify",{phoneNumber:e,code:t});return r.data&&await this.persistLogin(r.data,r.response),r}async postJson(e,t){try{let r=await this.fetchImpl(this.url(e),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify(t)}),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 Ie{constructor(t){if(this.headerMap=new Map,t){if(t instanceof Ie)t.forEach((r,s)=>this.set(s,r));else if(Array.isArray(t))for(let[r,s]of t)this.set(r,String(s));else if(typeof t=="object")for(let r of Object.keys(t))this.set(r,String(t[r]))}}append(t,r){let s=t.toLowerCase(),o=this.headerMap.get(s);this.headerMap.set(s,o?`${o}, ${r}`:r)}set(t,r){this.headerMap.set(t.toLowerCase(),String(r))}get(t){return this.headerMap.get(t.toLowerCase())??null}has(t){return this.headerMap.has(t.toLowerCase())}delete(t){this.headerMap.delete(t.toLowerCase())}forEach(t){for(let[r,s]of this.headerMap.entries())t(s,r,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}};m();m();var Le=class{constructor(e,t){this.bodyData=e,this.status=t?.status??200,this.statusText=t?.statusText??"",this.headers=Qe(t?.headers),this.ok=this.status>=200&&this.status<300}async text(){return typeof this.bodyData=="string"?this.bodyData:this.bodyData==null?"":typeof this.bodyData=="object"?JSON.stringify(this.bodyData):String(this.bodyData)}async json(){if(typeof this.bodyData=="string")try{return JSON.parse(this.bodyData)}catch{}return this.bodyData}async arrayBuffer(){let e=await this.text();return new TextEncoder().encode(e).buffer}};function Qe(e){return e?new _(e):new _}m();m();var Ae=class{constructor(e,t,r){this.storage=e,this.customFetch=t,this.handleUnauthorized=r}async fetch(e,t){return await this.customFetch(e,t)}async fetchWithAuth(e,t){let r=await this.storage.get(w),s=new _(t?.headers);r&&s.set("Authorization",`Bearer ${r}`);let o=t?.method||"GET";if((o==="POST"||o==="PUT"||o==="PATCH")&&t?.body){let n=s.get("Content-Type");(!n||n.includes("text/plain"))&&s.set("Content-Type","application/json")}let a=await this.customFetch(e,{...t,headers:s});if(a.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return a}};m();var Xe="/storage",Ze=Xe+"/generateUploadUrl",Ce=class{constructor(e,t){this.baseUrl=e,this.http=t}async uploadFile(e){let t=await this.http.fetch(this.baseUrl+Ze,{method:"POST",body:{fileName:e.name||e.fileName,fileSize:e.size||e.fileSize,fileType:e.type||e.fileType}}),{url:r}=await t.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(r,{method:"PUT",body:e,headers:new _({"Content-Type":e.type||e.fileType||"application/octet-stream"})}),{url:o}=await s.json();return{url:o.split("?")[0]}}};m();m();m();var q=Je(Ke(),1),{PostgrestClient:et,PostgrestQueryBuilder:at,PostgrestFilterBuilder:ot,PostgrestTransformBuilder:nt,PostgrestBuilder:it,PostgrestError:lt}=q.default||q,tt="/entities",Ne=(e,t)=>new et(e+tt,{fetch:t.fetchWithAuth.bind(t)});m();var ke=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let r=`${this.baseUrl}/capability/${e}/execute`,s=await(await this.http.fetchWithAuth(r,{method:"POST",body:t?JSON.stringify(t):void 0,timeout:6e5})).json();if(s.status!==200)throw new Error(s.message);return s.data}};m();var He=class{constructor(e,t){this.baseUrl=e,this.http=t}async execute(e,t){let r=`${this.baseUrl}/capability/${e}/execute`,s=await(await this.http.fetchWithAuth(r,{method:"POST",body:t!=null?JSON.stringify(t):void 0,timeout:6e5})).json();if(s.status!==200)throw new Error(s.message);return s.data}};m();var Re=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 e=document.createElement("style");e.id="__nvwa-inspector-overlay-style",e.textContent=`
1
+ var Fe=Object.create,R=Object.defineProperty,Be=Object.getOwnPropertyDescriptor,qe=Object.getOwnPropertyNames,ze=Object.getPrototypeOf,Ge=Object.prototype.hasOwnProperty,G=(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))!Ge.call(t,o)&&o!==r&&R(t,o,{get:()=>e[o],enumerable:!(s=Be(e,o))||s.enumerable});return t},We=(t,e,r)=>(r=t!=null?Fe(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=G(()=>{"use strict"}),P={};Je(P,{__addDisposableResource:()=>ge,__assign:()=>x,__asyncDelegator:()=>he,__asyncGenerator:()=>le,__asyncValues:()=>ce,__await:()=>O,__awaiter:()=>re,__classPrivateFieldGet:()=>fe,__classPrivateFieldIn:()=>ye,__classPrivateFieldSet:()=>me,__createBinding:()=>L,__decorate:()=>V,__disposeResources:()=>ve,__esDecorate:()=>Q,__exportStar:()=>ae,__extends:()=>W,__generator:()=>se,__importDefault:()=>pe,__importStar:()=>de,__makeTemplateObject:()=>ue,__metadata:()=>te,__param:()=>Y,__propKey:()=>Z,__read:()=>F,__rest:()=>K,__rewriteRelativeImportExtension:()=>we,__runInitializers:()=>X,__setFunctionName:()=>ee,__spread:()=>oe,__spreadArray:()=>ie,__spreadArrays:()=>ne,__values:()=>k,default:()=>Ee});function W(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");N(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 v=(0,r[d])(i==="accessor"?{get:h.get,set:h.set}:h[c],p);if(i==="accessor"){if(v===void 0)continue;if(v===null||typeof v!="object")throw new TypeError("Object expected");(u=n(v.get))&&(h.get=u),(u=n(v.set))&&(h.set=u),(u=n(v.init))&&o.unshift(u)}else(u=n(v))&&(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)&&L(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 F(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(F(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 O(t){return this instanceof O?(this.v=t,this):new O(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(v,g){a.push([d,y,v,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 O?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:O(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=C(t),s=0;s<r.length;s++)r[s]!=="default"&&L(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 ve(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 we(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 N,x,L,be,C,_e,Ee,T=G(()=>{"use strict";m(),N=function(t,e){return N=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])},N(t,e)},x=function(){return x=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},x.apply(this,arguments)},L=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},C=function(t){return C=Object.getOwnPropertyNames||function(e){var r=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[r.length]=s);return r},C(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:W,__assign:x,__rest:K,__decorate:V,__param:Y,__esDecorate:Q,__runInitializers:X,__propKey:Z,__setFunctionName:ee,__metadata:te,__awaiter:re,__generator:se,__createBinding:L,__exportStar:ae,__values:k,__read:F,__spread:oe,__spreadArrays:ne,__spreadArray:ie,__await:O,__asyncGenerator:le,__asyncDelegator:he,__asyncValues:ce,__makeTemplateObject:ue,__importStar:de,__importDefault:pe,__classPrivateFieldGet:fe,__classPrivateFieldSet:me,__classPrivateFieldIn:ye,__addDisposableResource:ge,__disposeResources:ve,__rewriteRelativeImportExtension:we}}),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}),Oe=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=(T(),S(P)),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,v=c.status,g=c.statusText;if(c.ok){if(this.method!=="HEAD"){let D=await c.text();D===""||(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=D:p=JSON.parse(D))}let $=(h=this.headers.get("Prefer"))===null||h===void 0?void 0:h.match(/count=(exact|planned|estimated)/),U=(u=c.headers.get("content-range"))===null||u===void 0?void 0:u.split("/");$&&U&&U.length>1&&(y=parseInt(U[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,v=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,v=200,g="OK")}catch{c.status===404&&$===""?(v=204,g="No Content"):d={message:$}}if(d&&this.isMaybeSingle&&!((f=d?.details)===null||f===void 0)&&f.includes("0 rows")&&(d=null,v=200,g="OK"),d&&this.shouldThrowOnError)throw new r.default(d)}return{error:d,data:p,count:y,status:v,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(P)),r=e.__importDefault(Oe()),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(P)),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(P)),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(P)),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(([v,g])=>g!==void 0).map(([v,g])=>[v,Array.isArray(g)?`{${g.join(",")}}`:`${g}`]).forEach(([v,g])=>{d.searchParams.append(v,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(P)),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(Oe());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 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 w="nvwa_current_jwt",b="nvwa_login_token",A="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"}async currentUser(){if(this.storage){let r=await this.storage.get(A);if(r!=null)return r}let{data:t}=await this.getSession(),e=t?.user??null;return e&&this.storage&&await this.storage.set(A,e),e}async getCurrentJwt(){if(this.storage){let e=await this.storage.get(w);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(w,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(A,t.user);let s=r??await this.storage.get(b),{data:o}=await this.getToken(s??void 0);o?.token&&await this.storage.set(w,o.token)}async clearLogin(){this.storage&&(await this.storage.remove(b),await this.storage.remove(A),await this.storage.remove(w))}url(t){let e=`${`${this.baseUrl.replace(/\/+$/,"")}/${this.authPath.replace(/^\/+/,"")}`}/${t.replace(/^\/+/,"")}`;return typeof console<"u"&&console.debug&&console.debug("[NvwaAuth] request URL:",e),e}async getSession(){try{let t={};if(this.storage){let r=await this.storage.get(b)??await this.storage.get(w);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(w);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(w);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 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 je{constructor(e){if(this.headerMap=new Map,e){if(e instanceof je)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 Ie=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 Ae=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(w),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",Ne=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=We(Ve(),1),{PostgrestClient:tt,PostgrestQueryBuilder:ot,PostgrestFilterBuilder:nt,PostgrestTransformBuilder:it,PostgrestBuilder:lt,PostgrestError:ht}=z.default||z,rt="/entities",Ce=(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;
@@ -30,4 +30,4 @@ var De=Object.create,H=Object.defineProperty,Fe=Object.getOwnPropertyDescriptor,
30
30
  max-width: 400px;
31
31
  word-break: break-all;
32
32
  }
33
- `,document.head.appendChild(e)}createTooltip(){return this.tooltip?this.tooltip:(this.tooltip=document.createElement("div"),this.tooltip.id="__nvwa-inspector-tooltip",document.body.appendChild(this.tooltip),this.tooltip)}createOverlay(e){let t=document.createElement("div");return t.className=`__nvwa-inspector-overlay __nvwa-inspector-overlay-${e}`,document.body.appendChild(t),t}updateOverlayPosition(e,t){if(!t.isConnected)return;let r=t.getBoundingClientRect(),s=window.scrollX||window.pageXOffset,o=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(e.style.left=`${r.left+s}px`,e.style.top=`${r.top+o}px`,e.style.width=`${r.width}px`,e.style.height=`${r.height}px`,e.style.display="block"):e.style.display="none"}removeOverlay(e){e&&e.parentNode&&e.parentNode.removeChild(e)}highlightElement(e,t){if(!e.isConnected)return;if(this.hoverElement===e&&this.hoverOverlay){this.updateOverlayPosition(this.hoverOverlay,e);let n=this.createTooltip();t?n.textContent=t:n.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,n.style.display="block";let i=e.getBoundingClientRect();n.style.left=`${i.left+window.scrollX}px`,n.style.top=`${i.top+window.scrollY-n.offsetHeight-8}px`,i.top<n.offsetHeight+8&&(n.style.top=`${i.bottom+window.scrollY+8}px`);return}this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null);let r=this.createOverlay("hover");this.updateOverlayPosition(r,e),this.hoverOverlay=r,this.hoverElement=e;let s=()=>{this.hoverOverlay&&this.hoverElement&&this.hoverElement.isConnected&&this.updateOverlayPosition(this.hoverOverlay,this.hoverElement)};this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler)),this.hoverUpdateHandler=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s);let o=this.createTooltip();t?o.textContent=t:o.textContent=`<${e.tagName.toLowerCase()}> (\u65E0 source location)`,o.style.display="block";let a=e.getBoundingClientRect();o.style.left=`${a.left+window.scrollX}px`,o.style.top=`${a.top+window.scrollY-o.offsetHeight-8}px`,a.top<o.offsetHeight+8&&(o.style.top=`${a.bottom+window.scrollY+8}px`)}selectElement(e,t){if(!e.isConnected)return;if(this.selectedElement===e&&this.selectedOverlay){this.updateOverlayPosition(this.selectedOverlay,e);return}this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null);let r=this.createOverlay("selected");this.updateOverlayPosition(r,e),this.selectedOverlay=r,this.selectedElement=e;let s=()=>{this.selectedOverlay&&this.selectedElement&&this.selectedElement.isConnected&&this.updateOverlayPosition(this.selectedOverlay,this.selectedElement)};this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler)),this.selectedUpdateHandler=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s)}removeHighlight(){this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null),this.hoverElement&&(this.hoverElement=null),this.tooltip&&(this.tooltip.style.display="none"),this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler),this.hoverUpdateHandler=null)}clearSelection(){this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null),this.selectedElement&&(this.selectedElement=null),this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler),this.selectedUpdateHandler=null)}cleanup(){this.removeHighlight(),this.clearSelection(),this.tooltip&&this.tooltip.parentNode&&(this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null);let e=document.getElementById("__nvwa-inspector-overlay-style");e&&e.parentNode&&e.parentNode.removeChild(e)}};function Me(e="root"){if(typeof document>"u")return null;let t=document.getElementById(e)||document.body;if(!t)return null;let r=t.querySelector("[data-source-location]");if(r){let s=r.getAttribute("data-source-location");if(s)return s}if(t.firstElementChild){let s=t.firstElementChild.getAttribute("data-source-location");if(s)return s}return null}m();var ct=typeof fetch<"u"?(e,t)=>fetch(e,t):(()=>{throw new Error("payment client requires fetch")})();var R=class{constructor(){this.prefix="nvwa_"}getKey(t){return`${this.prefix}${t}`}async get(t){try{let r=this.getKey(t),s=localStorage.getItem(r);if(!s)return null;let o=JSON.parse(s);return o.expires&&Date.now()>o.expires?(await this.remove(t),null):o.value}catch(r){return console.error("WebStorageService get error:",r),null}}async set(t,r,s){try{let o=this.getKey(t),a={value:r,expires:s?Date.now()+s*1e3:null,timestamp:Date.now()};localStorage.setItem(o,JSON.stringify(a))}catch(o){throw console.error("WebStorageService set error:",o),o}}async remove(t){try{let r=this.getKey(t);localStorage.removeItem(r)}catch(r){throw console.error("WebStorageService remove error:",r),r}}async clear(){try{Object.keys(localStorage).filter(s=>s.startsWith(this.prefix)).forEach(s=>{localStorage.removeItem(s)})}catch(t){throw console.error("WebStorageService clear error:",t),t}}};var rt=(e,t)=>{let r;if(typeof e=="string")r=e;else if(e&&typeof e.toString=="function")r=e.toString();else if(e?.url)r=e.url;else throw new Error("Invalid input for webFetch");let s;if(t?.headers){let a=t.headers;if(a instanceof _){let n={};a.forEach((i,h)=>{n[h]=i}),s=n}else if(Array.isArray(a)){let n=[];for(let i of a)Array.isArray(i)&&i.length>=2&&n.push([String(i[0]),String(i[1])]);s=n}else typeof a=="object"&&(s=a)}let o={method:t?.method||"GET",headers:s,body:t?.body,credentials:t?.credentials};return t?.signal&&(o.signal=t.signal),globalThis.fetch(r,o).then(async a=>{let n=a.headers.get("content-type")||"",i;if(n.includes("application/json"))i=await a.json();else{let l=await a.text();try{i=JSON.parse(l)}catch{i=l}}let h=new _;return a.headers.forEach((l,c)=>{h.set(c,l)}),new Le(i,{status:a.status,statusText:a.statusText,headers:h})})},M=rt;function Ht(){if(typeof window>"u"||window===window.parent)return;let e=!1,t=new Re;function r(l){if(!l)return!1;let c=l.toLowerCase();return c.includes("/components/")||c.includes("\\components\\")}function s(l){let c=l,u=null;for(;c;){let f=c.getAttribute("data-source-location");if(f)if(r(f)){u||(u=f),c=c.parentElement;continue}else return f;c=c.parentElement}return u}let o=null;function a(l){e&&(o!==null&&cancelAnimationFrame(o),o=requestAnimationFrame(()=>{let c=l.target;if(!c||c===document.body||c===document.documentElement){t.removeHighlight();return}if(c.tagName.toLowerCase()==="img"){let p=s(c);t.highlightElement(c,p);let y={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:p,elementInfo:{tagName:c.tagName.toLowerCase(),className:c.className||"",id:c.id||""}};window.parent.postMessage(y,"*");return}let u=c,f=s(c);if(!f){let p=c.parentElement;for(;p&&p!==document.body&&p!==document.documentElement;){let y=s(p);if(y){u=p,f=y;break}p=p.parentElement}}t.highlightElement(u,f);let d={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:f,elementInfo:{tagName:u.tagName.toLowerCase(),className:u.className||"",id:u.id||""}};window.parent.postMessage(d,"*")}))}function n(){if(!e)return;t.removeHighlight();let l={type:"HOVER_INSPECTOR_ELEMENT_LEAVE"};window.parent.postMessage(l,"*")}function i(l){if(!e)return;l.preventDefault(),l.stopPropagation();let c=l.target;if(!c||c===document.body||c===document.documentElement)return;let u=s(c);t.selectElement(c,u);let f={type:"HOVER_INSPECTOR_ELEMENT_SELECT",sourceLocation:u,elementInfo:{tagName:c.tagName.toLowerCase(),className:c.className||"",id:c.id||""}};window.parent.postMessage(f,"*")}function h(l){l.data?.type==="HOVER_INSPECTOR_ENABLE"?(e=!0,document.addEventListener("mousemove",a),document.addEventListener("mouseleave",n),document.addEventListener("click",i,!0)):l.data?.type==="HOVER_INSPECTOR_DISABLE"&&(e=!1,document.removeEventListener("mousemove",a),document.removeEventListener("mouseleave",n),document.removeEventListener("click",i,!0),t.removeHighlight(),t.clearSelection())}return window.addEventListener("message",h),()=>{window.removeEventListener("message",h),document.removeEventListener("mousemove",a),document.removeEventListener("mouseleave",n),document.removeEventListener("click",i,!0),t.cleanup()}}function Rt(e,t){if(!e||!e.contentWindow)throw new Error("Invalid iframe element");let r={type:"HOVER_INSPECTOR_ENABLE"};e.contentWindow.postMessage(r,t)}function Mt(e,t){if(!e||!e.contentWindow)return;let r={type:"HOVER_INSPECTOR_DISABLE"};e.contentWindow.postMessage(r,t)}function Ut(e,t,r=5e3){return new Promise((s,o)=>{if(!e||!e.contentWindow){o(new Error("Invalid iframe element"));return}let a=`source-location-${Date.now()}-${Math.random()}`,n=setTimeout(()=>{window.removeEventListener("message",i),o(new Error("Request timeout"))},r),i=l=>{l.origin===t&&l.data?.type==="GET_SOURCE_LOCATION_RESPONSE"&&l.data?.requestId===a&&(clearTimeout(n),window.removeEventListener("message",i),l.data.error?o(new Error(l.data.error)):s(l.data.sourceLocation||null))};window.addEventListener("message",i);let h={type:"GET_SOURCE_LOCATION_REQUEST",requestId:a};try{e.contentWindow.postMessage(h,t)}catch(l){clearTimeout(n),window.removeEventListener("message",i),o(l)}})}function Dt(){if(typeof window>"u"||window===window.parent)return;let e=t=>{if(t.data?.type==="GET_SOURCE_LOCATION_REQUEST")try{let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:st(),requestId:t.data.requestId};window.parent.postMessage(s,t.origin)}catch(r){let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:null,error:r instanceof Error?r.message:"Unknown error",requestId:t.data.requestId};window.parent.postMessage(s,t.origin)}};return window.addEventListener("message",e),()=>{window.removeEventListener("message",e)}}function st(){return Me("root")}var Ue=new R,z=class{constructor(t,r){this.auth=new je(t,{fetchImpl:M,storage:Ue}),this.httpClient=new Ae(Ue,M,r),this.fileStorage=new Ce(t,this.httpClient),this.entities=Ne(t,this.httpClient),this.functions=new xe(this.httpClient,t),this.skill=new ke(t,this.httpClient),this.capability=new He(t,this.httpClient)}};export{z as default,Mt as disableIframeHoverInspector,Rt as enableIframeHoverInspector,Ut as getIframeSourceLocation,Ue as localStorage,Ht as setupIframeHoverInspector,Dt as setupIframeSourceLocationListener,M as webFetch};
33
+ `,document.head.appendChild(t)}createTooltip(){return this.tooltip?this.tooltip:(this.tooltip=document.createElement("div"),this.tooltip.id="__nvwa-inspector-tooltip",document.body.appendChild(this.tooltip),this.tooltip)}createOverlay(t){let e=document.createElement("div");return e.className=`__nvwa-inspector-overlay __nvwa-inspector-overlay-${t}`,document.body.appendChild(e),e}updateOverlayPosition(t,e){if(!e.isConnected)return;let r=e.getBoundingClientRect(),s=window.scrollX||window.pageXOffset,o=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(t.style.left=`${r.left+s}px`,t.style.top=`${r.top+o}px`,t.style.width=`${r.width}px`,t.style.height=`${r.height}px`,t.style.display="block"):t.style.display="none"}removeOverlay(t){t&&t.parentNode&&t.parentNode.removeChild(t)}highlightElement(t,e){if(!t.isConnected)return;if(this.hoverElement===t&&this.hoverOverlay){this.updateOverlayPosition(this.hoverOverlay,t);let n=this.createTooltip();e?n.textContent=e:n.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,n.style.display="block";let i=t.getBoundingClientRect();n.style.left=`${i.left+window.scrollX}px`,n.style.top=`${i.top+window.scrollY-n.offsetHeight-8}px`,i.top<n.offsetHeight+8&&(n.style.top=`${i.bottom+window.scrollY+8}px`);return}this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null);let r=this.createOverlay("hover");this.updateOverlayPosition(r,t),this.hoverOverlay=r,this.hoverElement=t;let s=()=>{this.hoverOverlay&&this.hoverElement&&this.hoverElement.isConnected&&this.updateOverlayPosition(this.hoverOverlay,this.hoverElement)};this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler)),this.hoverUpdateHandler=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s);let o=this.createTooltip();e?o.textContent=e:o.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,o.style.display="block";let a=t.getBoundingClientRect();o.style.left=`${a.left+window.scrollX}px`,o.style.top=`${a.top+window.scrollY-o.offsetHeight-8}px`,a.top<o.offsetHeight+8&&(o.style.top=`${a.bottom+window.scrollY+8}px`)}selectElement(t,e){if(!t.isConnected)return;if(this.selectedElement===t&&this.selectedOverlay){this.updateOverlayPosition(this.selectedOverlay,t);return}this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null);let r=this.createOverlay("selected");this.updateOverlayPosition(r,t),this.selectedOverlay=r,this.selectedElement=t;let s=()=>{this.selectedOverlay&&this.selectedElement&&this.selectedElement.isConnected&&this.updateOverlayPosition(this.selectedOverlay,this.selectedElement)};this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler)),this.selectedUpdateHandler=s,window.addEventListener("scroll",s,!0),window.addEventListener("resize",s)}removeHighlight(){this.hoverOverlay&&(this.removeOverlay(this.hoverOverlay),this.hoverOverlay=null),this.hoverElement&&(this.hoverElement=null),this.tooltip&&(this.tooltip.style.display="none"),this.hoverUpdateHandler&&(window.removeEventListener("scroll",this.hoverUpdateHandler,!0),window.removeEventListener("resize",this.hoverUpdateHandler),this.hoverUpdateHandler=null)}clearSelection(){this.selectedOverlay&&(this.removeOverlay(this.selectedOverlay),this.selectedOverlay=null),this.selectedElement&&(this.selectedElement=null),this.selectedUpdateHandler&&(window.removeEventListener("scroll",this.selectedUpdateHandler,!0),window.removeEventListener("resize",this.selectedUpdateHandler),this.selectedUpdateHandler=null)}cleanup(){this.removeHighlight(),this.clearSelection(),this.tooltip&&this.tooltip.parentNode&&(this.tooltip.parentNode.removeChild(this.tooltip),this.tooltip=null);let t=document.getElementById("__nvwa-inspector-overlay-style");t&&t.parentNode&&t.parentNode.removeChild(t)}};function Me(t="root"){if(typeof document>"u")return null;let e=document.getElementById(t)||document.body;if(!e)return null;let r=e.querySelector("[data-source-location]");if(r){let s=r.getAttribute("data-source-location");if(s)return s}if(e.firstElementChild){let s=e.firstElementChild.getAttribute("data-source-location");if(s)return s}return null}m();var H=class{constructor(){this.prefix="nvwa_"}getKey(e){return`${this.prefix}${e}`}async get(e){try{let r=this.getKey(e),s=localStorage.getItem(r);if(!s)return null;let o=JSON.parse(s);return o.expires&&Date.now()>o.expires?(await this.remove(e),null):o.value}catch(r){return console.error("WebStorageService get error:",r),null}}async set(e,r,s){try{let o=this.getKey(e),a={value:r,expires:s?Date.now()+s*1e3:null,timestamp:Date.now()};localStorage.setItem(o,JSON.stringify(a))}catch(o){throw console.error("WebStorageService set error:",o),o}}async remove(e){try{let r=this.getKey(e);localStorage.removeItem(r)}catch(r){throw console.error("WebStorageService remove error:",r),r}}async clear(){try{Object.keys(localStorage).filter(s=>s.startsWith(this.prefix)).forEach(s=>{localStorage.removeItem(s)})}catch(e){throw console.error("WebStorageService clear error:",e),e}}};var st=(t,e)=>{let r;if(typeof t=="string")r=t;else if(t&&typeof t.toString=="function")r=t.toString();else if(t?.url)r=t.url;else throw new Error("Invalid input for webFetch");let s;if(e?.headers){let a=e.headers;if(a instanceof _){let n={};a.forEach((i,c)=>{n[c]=i}),s=n}else if(Array.isArray(a)){let n=[];for(let i of a)Array.isArray(i)&&i.length>=2&&n.push([String(i[0]),String(i[1])]);s=n}else typeof a=="object"&&(s=a)}let o={method:e?.method||"GET",headers:s,body:e?.body,credentials:e?.credentials};return e?.signal&&(o.signal=e.signal),globalThis.fetch(r,o).then(async a=>{let n=a.headers.get("content-type")||"",i;if(n.includes("application/json"))i=await a.json();else{let l=await a.text();try{i=JSON.parse(l)}catch{i=l}}let c=new _;return a.headers.forEach((l,h)=>{c.set(h,l)}),new Ie(i,{status:a.status,statusText:a.statusText,headers:c})})},M=st;var Ue={async requestPayment(t){let e=t;if(typeof e.redirectUrl=="string"){window.location.href=e.redirectUrl;return}if(typeof e.codeUrl=="string"){let r=`https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(e.codeUrl)}`;window.open(r,"_blank","noopener,noreferrer");return}if(typeof e.formHtml=="string"){let r=window.open("","_blank");r&&(r.document.write(e.formHtml),r.document.close());return}throw new Error("requestPayment: unsupported payParams for Desktop-web")}};function Mt(){if(typeof window>"u"||window===window.parent)return;let t=!1,e=new He;function r(l){if(!l)return!1;let h=l.toLowerCase();return h.includes("/components/")||h.includes("\\components\\")}function s(l){let h=l,u=null;for(;h;){let f=h.getAttribute("data-source-location");if(f)if(r(f)){u||(u=f),h=h.parentElement;continue}else return f;h=h.parentElement}return u}let o=null;function a(l){t&&(o!==null&&cancelAnimationFrame(o),o=requestAnimationFrame(()=>{let h=l.target;if(!h||h===document.body||h===document.documentElement){e.removeHighlight();return}if(h.tagName.toLowerCase()==="img"){let p=s(h);e.highlightElement(h,p);let y={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:p,elementInfo:{tagName:h.tagName.toLowerCase(),className:h.className||"",id:h.id||""}};window.parent.postMessage(y,"*");return}let u=h,f=s(h);if(!f){let p=h.parentElement;for(;p&&p!==document.body&&p!==document.documentElement;){let y=s(p);if(y){u=p,f=y;break}p=p.parentElement}}e.highlightElement(u,f);let d={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:f,elementInfo:{tagName:u.tagName.toLowerCase(),className:u.className||"",id:u.id||""}};window.parent.postMessage(d,"*")}))}function n(){if(!t)return;e.removeHighlight();let l={type:"HOVER_INSPECTOR_ELEMENT_LEAVE"};window.parent.postMessage(l,"*")}function i(l){if(!t)return;l.preventDefault(),l.stopPropagation();let h=l.target;if(!h||h===document.body||h===document.documentElement)return;let u=s(h);e.selectElement(h,u);let f={type:"HOVER_INSPECTOR_ELEMENT_SELECT",sourceLocation:u,elementInfo:{tagName:h.tagName.toLowerCase(),className:h.className||"",id:h.id||""}};window.parent.postMessage(f,"*")}function c(l){l.data?.type==="HOVER_INSPECTOR_ENABLE"?(t=!0,document.addEventListener("mousemove",a),document.addEventListener("mouseleave",n),document.addEventListener("click",i,!0)):l.data?.type==="HOVER_INSPECTOR_DISABLE"&&(t=!1,document.removeEventListener("mousemove",a),document.removeEventListener("mouseleave",n),document.removeEventListener("click",i,!0),e.removeHighlight(),e.clearSelection())}return window.addEventListener("message",c),()=>{window.removeEventListener("message",c),document.removeEventListener("mousemove",a),document.removeEventListener("mouseleave",n),document.removeEventListener("click",i,!0),e.cleanup()}}function Ut(t,e){if(!t||!t.contentWindow)throw new Error("Invalid iframe element");let r={type:"HOVER_INSPECTOR_ENABLE"};t.contentWindow.postMessage(r,e)}function Dt(t,e){if(!t||!t.contentWindow)return;let r={type:"HOVER_INSPECTOR_DISABLE"};t.contentWindow.postMessage(r,e)}function Ft(t,e,r=5e3){return new Promise((s,o)=>{if(!t||!t.contentWindow){o(new Error("Invalid iframe element"));return}let a=`source-location-${Date.now()}-${Math.random()}`,n=setTimeout(()=>{window.removeEventListener("message",i),o(new Error("Request timeout"))},r),i=l=>{l.origin===e&&l.data?.type==="GET_SOURCE_LOCATION_RESPONSE"&&l.data?.requestId===a&&(clearTimeout(n),window.removeEventListener("message",i),l.data.error?o(new Error(l.data.error)):s(l.data.sourceLocation||null))};window.addEventListener("message",i);let c={type:"GET_SOURCE_LOCATION_REQUEST",requestId:a};try{t.contentWindow.postMessage(c,e)}catch(l){clearTimeout(n),window.removeEventListener("message",i),o(l)}})}function Bt(){if(typeof window>"u"||window===window.parent)return;let t=e=>{if(e.data?.type==="GET_SOURCE_LOCATION_REQUEST")try{let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:at(),requestId:e.data.requestId};window.parent.postMessage(s,e.origin)}catch(r){let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:null,error:r instanceof Error?r.message:"Unknown error",requestId:e.data.requestId};window.parent.postMessage(s,e.origin)}};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}}function at(){return Me("root")}var De=new H,q=class{constructor(e,r){this.endpointType="Desktop-web";this.payment=Ue;this.auth=new Le(e,{fetchImpl:M,storage:De}),this.httpClient=new Ae(De,M,r),this.fileStorage=new Ne(e,this.httpClient),this.entities=Ce(e,this.httpClient),this.functions=new xe(this.httpClient,e),this.skill=new ke(e,this.httpClient),this.capability=new Re(e,this.httpClient)}};export{q as default,Dt as disableIframeHoverInspector,Ut as enableIframeHoverInspector,Ft as getIframeSourceLocation,De as localStorage,Mt as setupIframeHoverInspector,Bt as setupIframeSourceLocationListener,M as webFetch};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nvwa-app/sdk-web",
3
- "version": "6.0.33",
3
+ "version": "6.0.35",
4
4
  "description": "NVWA跨端通用工具类Web端实现",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",