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