@nvwa-app/sdk-web 6.2.0 → 6.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -2
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
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 n of De(e))!Be.call(t,n)&&n!==r&&D(t,n,{get:()=>e[n],enumerable:!(s=Fe(e,n))||s.enumerable});return t};var We=t=>ze(D({},"__esModule",{value:!0}),t);var gt={};qe(gt,{default:()=>U,disableIframeHoverInspector:()=>dt,enableIframeHoverInspector:()=>ut,getIframeSourceLocation:()=>pt,localStorage:()=>z,setupIframeHoverInspector:()=>ht,setupIframeSourceLocationListener:()=>ft,webFetch:()=>L});module.exports=We(gt);var Ge=Object.create,R=Object.defineProperty,Je=Object.getOwnPropertyDescriptor,Ke=Object.getOwnPropertyNames,Ve=Object.getPrototypeOf,Qe=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 n of Ke(e))!Qe.call(t,n)&&n!==r&&R(t,n,{get:()=>e[n],enumerable:!(s=Je(e,n))||s.enumerable});return t},Xe=(t,e,r)=>(r=t!=null?Ge(Ve(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"}),P={};Ye(P,{__addDisposableResource:()=>ve,__assign:()=>A,__asyncDelegator:()=>he,__asyncGenerator:()=>ce,__asyncValues:()=>ue,__await:()=>S,__awaiter:()=>se,__classPrivateFieldGet:()=>me,__classPrivateFieldIn:()=>ye,__classPrivateFieldSet:()=>ge,__createBinding:()=>I,__decorate:()=>Q,__disposeResources:()=>we,__esDecorate:()=>X,__exportStar:()=>ne,__extends:()=>K,__generator:()=>ae,__importDefault:()=>fe,__importStar:()=>pe,__makeTemplateObject:()=>de,__metadata:()=>re,__param:()=>Y,__propKey:()=>ee,__read:()=>B,__rest:()=>V,__rewriteRelativeImportExtension:()=>_e,__runInitializers:()=>Z,__setFunctionName:()=>te,__spread:()=>oe,__spreadArray:()=>le,__spreadArrays:()=>ie,__values:()=>k,default:()=>Pe});function K(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");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 n=0,s=Object.getOwnPropertySymbols(t);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(r[s[n]]=t[s[n]]);return r}function Q(t,e,r,s){var n=arguments.length,a=n<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,r):s,o;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--)(o=t[i])&&(a=(n<3?o(a):n>3?o(e,r,a):o(e,r))||a);return n>3&&a&&Object.defineProperty(e,r,a),a}function Y(t,e){return function(r,s){e(r,s,t)}}function X(t,e,r,s,n,a){function o(y){if(y!==void 0&&typeof y!="function")throw new TypeError("Function expected");return y}for(var i=s.kind,h=i==="getter"?"get":i==="setter"?"set":"value",l=!e&&t?s.static?t:t.prototype:null,c=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(o(y||null))};var v=(0,r[d])(i==="accessor"?{get:c.get,set:c.set}:c[h],p);if(i==="accessor"){if(v===void 0)continue;if(v===null||typeof v!="object")throw new TypeError("Object expected");(u=o(v.get))&&(c.get=u),(u=o(v.set))&&(c.set=u),(u=o(v.init))&&n.unshift(u)}else(u=o(v))&&(i==="field"?n.unshift(u):c[h]=u)}l&&Object.defineProperty(l,s.name,c),f=!0}function Z(t,e,r){for(var s=arguments.length>2,n=0;n<e.length;n++)r=s?e[n].call(t,r):e[n].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 n(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function i(c){try{l(s.next(c))}catch(u){o(u)}}function h(c){try{l(s.throw(c))}catch(u){o(u)}}function l(c){c.done?a(c.value):n(c.value).then(i,h)}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,n,a,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=i(0),o.throw=i(1),o.return=i(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function i(l){return function(c){return h([l,c])}}function h(l){if(s)throw new TypeError("Generator is already executing.");for(;o&&(o=0,l[0]&&(r=0)),r;)try{if(s=1,n&&(a=l[0]&2?n.return:l[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,l[1])).done)return a;switch(n=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++,n=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(c){l=[6,c],n=0}finally{s=a=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function ne(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&I(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),n,a=[],o;try{for(;(e===void 0||e-- >0)&&!(n=s.next()).done;)a.push(n.value)}catch(i){o={error:i}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}return a}function oe(){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),n=0,e=0;e<r;e++)for(var a=arguments[e],o=0,i=a.length;o<i;o++,n++)s[n]=a[o];return s}function le(t,e,r){if(r||arguments.length===2)for(var s=0,n=e.length,a;s<n;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 ce(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=r.apply(t,e||[]),n,a=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),i("next"),i("throw"),i("return",o),n[Symbol.asyncIterator]=function(){return this},n;function o(d){return function(p){return Promise.resolve(p).then(d,u)}}function i(d,p){s[d]&&(n[d]=function(g){return new Promise(function(v,y){a.push([d,g,v,y])>1||h(d,g)})},p&&(n[d]=p(n[d])))}function h(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(c,u):f(a[0][2],d)}function c(d){h("next",d)}function u(d){h("throw",d)}function f(d,p){d(p),a.shift(),a.length&&h(a[0][0],a[0][1])}}function he(t){var e,r;return e={},s("next"),s("throw",function(n){throw n}),s("return"),e[Symbol.iterator]=function(){return this},e;function s(n,a){e[n]=t[n]?function(o){return(r=!r)?{value:S(t[n](o)),done:!1}:a?a(o):o}: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(o){return new Promise(function(i,h){o=t[a](o),n(i,h,o.done,o.value)})}}function n(a,o,i,h){Promise.resolve(h).then(function(l){a({value:l,done:i})},o)}}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"&&I(e,t,r[s]);return be(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,n){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?n.call(t,r):n?n.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,n;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&&(n=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");n&&(s=function(){try{n.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 n(){for(;r=t.stack.pop();)try{if(!r.async&&s===1)return s=0,t.stack.push(r),Promise.resolve().then(n);if(r.dispose){var a=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(a).then(n,function(o){return e(o),n()})}else s|=1}catch(o){e(o)}if(s===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return n()}function _e(t,e){return typeof t=="string"&&/^\.\.?\//.test(t)?t.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,s,n,a,o){return s?e?".jsx":".js":n&&(!a||!o)?r:n+a+"."+o.toLowerCase()+"js"}):t}var j,A,I,be,N,Ee,Pe,$=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 n in s)Object.prototype.hasOwnProperty.call(s,n)&&(r[n]=s[n])},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 n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},A.apply(this,arguments)},I=Object.create?(function(t,e,r,s){s===void 0&&(s=r);var n=Object.getOwnPropertyDescriptor(e,r);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,s,n)}):(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)},Ee=typeof SuppressedError=="function"?SuppressedError:function(t,e,r){var s=new Error(r);return s.name="SuppressedError",s.error=t,s.suppressed=e,s},Pe={__extends:K,__assign:A,__rest:V,__decorate:Q,__param:Y,__esDecorate:X,__runInitializers:Z,__propKey:ee,__setFunctionName:te,__metadata:re,__awaiter:se,__generator:ae,__createBinding:I,__exportStar:ne,__values:k,__read:B,__spread:oe,__spreadArrays:ie,__spreadArray:le,__await:S,__asyncGenerator:ce,__asyncDelegator:he,__asyncValues:ue,__makeTemplateObject:de,__importStar:pe,__importDefault:fe,__classPrivateFieldGet:me,__classPrivateFieldSet:ge,__classPrivateFieldIn:ye,__addDisposableResource:ve,__disposeResources:we,__rewriteRelativeImportExtension:_e}}),Oe=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}};t.default=e}),Se=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=($(),T(P)),r=e.__importDefault(Oe()),s=class{constructor(n){var a,o;this.shouldThrowOnError=!1,this.method=n.method,this.url=n.url,this.headers=new Headers(n.headers),this.schema=n.schema,this.body=n.body,this.shouldThrowOnError=(a=n.shouldThrowOnError)!==null&&a!==void 0?a:!1,this.signal=n.signal,this.isMaybeSingle=(o=n.isMaybeSingle)!==null&&o!==void 0?o:!1,n.fetch?this.fetch=n.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(n,a){return this.headers=new Headers(this.headers),this.headers.set(n,a),this}then(n,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 o=this.fetch,i=o(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async h=>{var l,c,u,f;let d=null,p=null,g=null,v=h.status,y=h.statusText;if(h.ok){if(this.method!=="HEAD"){let F=await h.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=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),M=(u=h.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 h.text();try{d=JSON.parse(x),Array.isArray(d)&&h.status===404&&(p=[],d=null,v=200,y="OK")}catch{h.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(h=>{var l,c,u;return{error:{message:`${(l=h?.name)!==null&&l!==void 0?l:"FetchError"}: ${h?.message}`,details:`${(c=h?.stack)!==null&&c!==void 0?c:""}`,hint:"",code:`${(u=h?.code)!==null&&u!==void 0?u:""}`},data:null,count:null,status:0,statusText:""}})),i.then(n,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(P)),r=e.__importDefault(Se()),s=class extends r.default{select(n){let a=!1,o=(n??"*").split("").map(i=>/\s/.test(i)&&!a?"":(i==='"'&&(a=!a),i)).join("");return this.url.searchParams.set("select",o),this.headers.append("Prefer","return=representation"),this}order(n,{ascending:a=!0,nullsFirst:o,foreignTable:i,referencedTable:h=i}={}){let l=h?`${h}.order`:"order",c=this.url.searchParams.get(l);return this.url.searchParams.set(l,`${c?`${c},`:""}${n}.${a?"asc":"desc"}${o===void 0?"":o?".nullsfirst":".nullslast"}`),this}limit(n,{foreignTable:a,referencedTable:o=a}={}){let i=typeof o>"u"?"limit":`${o}.limit`;return this.url.searchParams.set(i,`${n}`),this}range(n,a,{foreignTable:o,referencedTable:i=o}={}){let h=typeof i>"u"?"offset":`${i}.offset`,l=typeof i>"u"?"limit":`${i}.limit`;return this.url.searchParams.set(h,`${n}`),this.url.searchParams.set(l,`${a-n+1}`),this}abortSignal(n){return this.signal=n,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:n=!1,verbose:a=!1,settings:o=!1,buffers:i=!1,wal:h=!1,format:l="text"}={}){var c;let u=[n?"analyze":null,a?"verbose":null,o?"settings":null,i?"buffers":null,h?"wal":null].filter(Boolean).join("|"),f=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${l}; for="${f}"; options=${u};`),l==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(n){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${n}`),this}};t.default=s}),q=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=($(),T(P)),r=e.__importDefault(Te()),s=new RegExp("[,()]"),n=class extends r.default{eq(a,o){return this.url.searchParams.append(a,`eq.${o}`),this}neq(a,o){return this.url.searchParams.append(a,`neq.${o}`),this}gt(a,o){return this.url.searchParams.append(a,`gt.${o}`),this}gte(a,o){return this.url.searchParams.append(a,`gte.${o}`),this}lt(a,o){return this.url.searchParams.append(a,`lt.${o}`),this}lte(a,o){return this.url.searchParams.append(a,`lte.${o}`),this}like(a,o){return this.url.searchParams.append(a,`like.${o}`),this}likeAllOf(a,o){return this.url.searchParams.append(a,`like(all).{${o.join(",")}}`),this}likeAnyOf(a,o){return this.url.searchParams.append(a,`like(any).{${o.join(",")}}`),this}ilike(a,o){return this.url.searchParams.append(a,`ilike.${o}`),this}ilikeAllOf(a,o){return this.url.searchParams.append(a,`ilike(all).{${o.join(",")}}`),this}ilikeAnyOf(a,o){return this.url.searchParams.append(a,`ilike(any).{${o.join(",")}}`),this}is(a,o){return this.url.searchParams.append(a,`is.${o}`),this}in(a,o){let i=Array.from(new Set(o)).map(h=>typeof h=="string"&&s.test(h)?`"${h}"`:`${h}`).join(",");return this.url.searchParams.append(a,`in.(${i})`),this}contains(a,o){return typeof o=="string"?this.url.searchParams.append(a,`cs.${o}`):Array.isArray(o)?this.url.searchParams.append(a,`cs.{${o.join(",")}}`):this.url.searchParams.append(a,`cs.${JSON.stringify(o)}`),this}containedBy(a,o){return typeof o=="string"?this.url.searchParams.append(a,`cd.${o}`):Array.isArray(o)?this.url.searchParams.append(a,`cd.{${o.join(",")}}`):this.url.searchParams.append(a,`cd.${JSON.stringify(o)}`),this}rangeGt(a,o){return this.url.searchParams.append(a,`sr.${o}`),this}rangeGte(a,o){return this.url.searchParams.append(a,`nxl.${o}`),this}rangeLt(a,o){return this.url.searchParams.append(a,`sl.${o}`),this}rangeLte(a,o){return this.url.searchParams.append(a,`nxr.${o}`),this}rangeAdjacent(a,o){return this.url.searchParams.append(a,`adj.${o}`),this}overlaps(a,o){return typeof o=="string"?this.url.searchParams.append(a,`ov.${o}`):this.url.searchParams.append(a,`ov.{${o.join(",")}}`),this}textSearch(a,o,{config:i,type:h}={}){let l="";h==="plain"?l="pl":h==="phrase"?l="ph":h==="websearch"&&(l="w");let c=i===void 0?"":`(${i})`;return this.url.searchParams.append(a,`${l}fts${c}.${o}`),this}match(a){return Object.entries(a).forEach(([o,i])=>{this.url.searchParams.append(o,`eq.${i}`)}),this}not(a,o,i){return this.url.searchParams.append(a,`not.${o}.${i}`),this}or(a,{foreignTable:o,referencedTable:i=o}={}){let h=i?`${i}.or`:"or";return this.url.searchParams.append(h,`(${a})`),this}filter(a,o,i){return this.url.searchParams.append(a,`${o}.${i}`),this}};t.default=n}),$e=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=($(),T(P)),r=e.__importDefault(q()),s=class{constructor(n,{headers:a={},schema:o,fetch:i}){this.url=n,this.headers=new Headers(a),this.schema=o,this.fetch=i}select(n,a){let{head:o=!1,count:i}=a??{},h=o?"HEAD":"GET",l=!1,c=(n??"*").split("").map(u=>/\s/.test(u)&&!l?"":(u==='"'&&(l=!l),u)).join("");return this.url.searchParams.set("select",c),i&&this.headers.append("Prefer",`count=${i}`),new r.default({method:h,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(n,{count:a,defaultToNull:o=!0}={}){var i;let h="POST";if(a&&this.headers.append("Prefer",`count=${a}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(n)){let l=n.reduce((c,u)=>c.concat(Object.keys(u)),[]);if(l.length>0){let c=[...new Set(l)].map(u=>`"${u}"`);this.url.searchParams.set("columns",c.join(","))}}return new r.default({method:h,url:this.url,headers:this.headers,schema:this.schema,body:n,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}upsert(n,{onConflict:a,ignoreDuplicates:o=!1,count:i,defaultToNull:h=!0}={}){var l;let c="POST";if(this.headers.append("Prefer",`resolution=${o?"ignore":"merge"}-duplicates`),a!==void 0&&this.url.searchParams.set("on_conflict",a),i&&this.headers.append("Prefer",`count=${i}`),h||this.headers.append("Prefer","missing=default"),Array.isArray(n)){let u=n.reduce((f,d)=>f.concat(Object.keys(d)),[]);if(u.length>0){let f=[...new Set(u)].map(d=>`"${d}"`);this.url.searchParams.set("columns",f.join(","))}}return new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:n,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}update(n,{count:a}={}){var o;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:n,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}delete({count:n}={}){var a;let o="DELETE";return n&&this.headers.append("Prefer",`count=${n}`),new r.default({method:o,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(P)),r=e.__importDefault($e()),s=e.__importDefault(q()),n=class xe{constructor(o,{headers:i={},schema:h,fetch:l}={}){this.url=o,this.headers=new Headers(i),this.schemaName=h,this.fetch=l}from(o){let i=new URL(`${this.url}/${o}`);return new r.default(i,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(o){return new xe(this.url,{headers:this.headers,schema:o,fetch:this.fetch})}rpc(o,i={},{head:h=!1,get:l=!1,count:c}={}){var u;let f,d=new URL(`${this.url}/rpc/${o}`),p;h||l?(f=h?"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 c&&g.set("Prefer",`count=${c}`),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=n}),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(P)),r=e.__importDefault(Ze());t.PostgrestClient=r.default;var s=e.__importDefault($e());t.PostgrestQueryBuilder=s.default;var n=e.__importDefault(q());t.PostgrestFilterBuilder=n.default;var a=e.__importDefault(Te());t.PostgrestTransformBuilder=a.default;var o=e.__importDefault(Se());t.PostgrestBuilder=o.default;var i=e.__importDefault(Oe());t.PostgrestError=i.default,t.default={PostgrestClient:r.default,PostgrestQueryBuilder:s.default,PostgrestFilterBuilder:n.default,PostgrestTransformBuilder:a.default,PostgrestBuilder:o.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",_="nvwa_login_token",O="nvwa_user_profile",tt="set-auth-token",rt=typeof fetch<"u"?(t,e)=>fetch(t,e):()=>{throw new Error("AuthClient requires fetch")},Ie=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(O);if(r!=null)return r}let{data:t}=await this.getSession(),e=t?.user??null;return e&&this.storage&&await this.storage.set(O,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(_),{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(tt)?.trim()||t.token||t.session?.token;r&&await this.storage.set(_,r),t.user&&await this.storage.set(O,t.user);let s=r??await this.storage.get(_),{data:n}=await this.getToken(s??void 0);n?.token&&await this.storage.set(w,n.token)}async clearLogin(){this.storage&&(await this.storage.remove(_),await this.storage.remove(O),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(_)??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 n=s?JSON.parse(s):void 0;return n&&await this.persistLogin({user:n.user,session:n.session},r),{data:n}}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(_)??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(_)??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 n=s?JSON.parse(s):void 0;return{data:n?.token!=null?{token:n.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 o=await this.storage.get(w);o!=null&&(r.Authorization=`Bearer ${o}`)}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})}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let a=n?JSON.parse(n):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(_,a.token),await this.storage.set(O,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 o=await this.storage.get(w);o!=null&&(r.Authorization=`Bearer ${o}`)}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})}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let a=n?JSON.parse(n):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(_,a.token),await this.storage.set(O,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 o=await this.storage.get(w);o!=null&&(e.Authorization=`Bearer ${o}`)}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}:{}}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let a=n?JSON.parse(n):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 o=await this.storage.get(w);o!=null&&(e.Authorization=`Bearer ${o}`)}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}:{}}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let a=n?JSON.parse(n):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 n=s?JSON.parse(s):void 0;return{data:n?.data??n??void 0,response:r}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}};m();m();var b=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(),n=this.headerMap.get(s);this.headerMap.set(s,n?`${n}, ${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=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 b(t):new b}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 b(e?.headers);r&&s.set("Authorization",`Bearer ${r}`);let n=e?.method||"GET";if((n==="POST"||n==="PUT"||n==="PATCH")&&e?.body){let o=s.get("Content-Type");(!o||o.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",nt=at+"/generateUploadUrl",Ne=class{constructor(t,e){this.baseUrl=t,this.http=e}async uploadFile(t){let e=await this.http.fetch(this.baseUrl+nt,{method:"POST",body:{fileName:t.name||t.fileName,fileSize:t.size||t.fileSize,fileType:t.type||t.fileType}}),{url:r}=await e.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(r,{method:"PUT",body:t,headers:new b({"Content-Type":t.type||t.fileType||"application/octet-stream"})}),{url:n}=await s.json();return{url:n.split("?")[0]}}};m();m();m();var W=Xe(et(),1),{PostgrestClient:ot,PostgrestQueryBuilder:vt,PostgrestFilterBuilder:wt,PostgrestTransformBuilder:_t,PostgrestBuilder:bt,PostgrestError:Et}=W.default||W,it="/entities",ke=(t,e)=>new ot(t+it,{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=`
|
|
1
|
+
"use strict";var D=Object.defineProperty;var Fe=Object.getOwnPropertyDescriptor;var De=Object.getOwnPropertyNames;var Be=Object.prototype.hasOwnProperty;var Ge=(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 a of De(e))!Be.call(t,a)&&a!==r&&D(t,a,{get:()=>e[a],enumerable:!(s=Fe(e,a))||s.enumerable});return t};var ze=t=>qe(D({},"__esModule",{value:!0}),t);var gt={};Ge(gt,{default:()=>H,disableIframeHoverInspector:()=>dt,enableIframeHoverInspector:()=>ct,getIframeSourceLocation:()=>pt,localStorage:()=>q,setupIframeHoverInspector:()=>ut,setupIframeSourceLocationListener:()=>ft,webFetch:()=>A});module.exports=ze(gt);var Je=Object.create,U=Object.defineProperty,We=Object.getOwnPropertyDescriptor,Ke=Object.getOwnPropertyNames,Ve=Object.getPrototypeOf,Qe=Object.prototype.hasOwnProperty,J=(t,e)=>()=>(t&&(e=t(t=0)),e),O=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Ye=(t,e)=>{for(var r in e)U(t,r,{get:e[r],enumerable:!0})},W=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Ke(e))!Qe.call(t,a)&&a!==r&&U(t,a,{get:()=>e[a],enumerable:!(s=We(e,a))||s.enumerable});return t},Xe=(t,e,r)=>(r=t!=null?Je(Ve(t)):{},W(e||!t||!t.__esModule?U(r,"default",{value:t,enumerable:!0}):r,t)),T=t=>W(U({},"__esModule",{value:!0}),t),m=J(()=>{"use strict"}),P={};Ye(P,{__addDisposableResource:()=>we,__assign:()=>L,__asyncDelegator:()=>ue,__asyncGenerator:()=>he,__asyncValues:()=>ce,__await:()=>S,__awaiter:()=>se,__classPrivateFieldGet:()=>me,__classPrivateFieldIn:()=>ye,__classPrivateFieldSet:()=>ge,__createBinding:()=>C,__decorate:()=>Q,__disposeResources:()=>ve,__esDecorate:()=>X,__exportStar:()=>ne,__extends:()=>K,__generator:()=>ae,__importDefault:()=>fe,__importStar:()=>pe,__makeTemplateObject:()=>de,__metadata:()=>re,__param:()=>Y,__propKey:()=>ee,__read:()=>B,__rest:()=>V,__rewriteRelativeImportExtension:()=>be,__runInitializers:()=>Z,__setFunctionName:()=>te,__spread:()=>oe,__spreadArray:()=>le,__spreadArrays:()=>ie,__values:()=>N,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 a=0,s=Object.getOwnPropertySymbols(t);a<s.length;a++)e.indexOf(s[a])<0&&Object.prototype.propertyIsEnumerable.call(t,s[a])&&(r[s[a]]=t[s[a]]);return r}function Q(t,e,r,s){var a=arguments.length,n=a<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,r):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(t,e,r,s);else for(var i=t.length-1;i>=0;i--)(o=t[i])&&(n=(a<3?o(n):a>3?o(e,r,n):o(e,r))||n);return a>3&&n&&Object.defineProperty(e,r,n),n}function Y(t,e){return function(r,s){e(r,s,t)}}function X(t,e,r,s,a,n){function o(y){if(y!==void 0&&typeof y!="function")throw new TypeError("Function expected");return y}for(var i=s.kind,u=i==="getter"?"get":i==="setter"?"set":"value",l=!e&&t?s.static?t:t.prototype:null,h=e||(l?Object.getOwnPropertyDescriptor(l,s.name):{}),c,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");n.push(o(y||null))};var w=(0,r[d])(i==="accessor"?{get:h.get,set:h.set}:h[u],p);if(i==="accessor"){if(w===void 0)continue;if(w===null||typeof w!="object")throw new TypeError("Object expected");(c=o(w.get))&&(h.get=c),(c=o(w.set))&&(h.set=c),(c=o(w.init))&&a.unshift(c)}else(c=o(w))&&(i==="field"?a.unshift(c):h[u]=c)}l&&Object.defineProperty(l,s.name,h),f=!0}function Z(t,e,r){for(var s=arguments.length>2,a=0;a<e.length;a++)r=s?e[a].call(t,r):e[a].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 a(n){return n instanceof r?n:new r(function(o){o(n)})}return new(r||(r=Promise))(function(n,o){function i(h){try{l(s.next(h))}catch(c){o(c)}}function u(h){try{l(s.throw(h))}catch(c){o(c)}}function l(h){h.done?n(h.value):a(h.value).then(i,u)}l((s=s.apply(t,e||[])).next())})}function ae(t,e){var r={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},s,a,n,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=i(0),o.throw=i(1),o.return=i(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function i(l){return function(h){return u([l,h])}}function u(l){if(s)throw new TypeError("Generator is already executing.");for(;o&&(o=0,l[0]&&(r=0)),r;)try{if(s=1,a&&(n=l[0]&2?a.return:l[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,l[1])).done)return n;switch(a=0,n&&(l=[l[0]&2,n.value]),l[0]){case 0:case 1:n=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,a=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(n=r.trys,!(n=n.length>0&&n[n.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!n||l[1]>n[0]&&l[1]<n[3])){r.label=l[1];break}if(l[0]===6&&r.label<n[1]){r.label=n[1],n=l;break}if(n&&r.label<n[2]){r.label=n[2],r.ops.push(l);break}n[2]&&r.ops.pop(),r.trys.pop();continue}l=e.call(t,r)}catch(h){l=[6,h],a=0}finally{s=n=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function ne(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&C(e,t,r)}function N(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),a,n=[],o;try{for(;(e===void 0||e-- >0)&&!(a=s.next()).done;)n.push(a.value)}catch(i){o={error:i}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}return n}function oe(){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),a=0,e=0;e<r;e++)for(var n=arguments[e],o=0,i=n.length;o<i;o++,a++)s[a]=n[o];return s}function le(t,e,r){if(r||arguments.length===2)for(var s=0,a=e.length,n;s<a;s++)(n||!(s in e))&&(n||(n=Array.prototype.slice.call(e,0,s)),n[s]=e[s]);return t.concat(n||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||[]),a,n=[];return a=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),i("next"),i("throw"),i("return",o),a[Symbol.asyncIterator]=function(){return this},a;function o(d){return function(p){return Promise.resolve(p).then(d,c)}}function i(d,p){s[d]&&(a[d]=function(g){return new Promise(function(w,y){n.push([d,g,w,y])>1||u(d,g)})},p&&(a[d]=p(a[d])))}function u(d,p){try{l(s[d](p))}catch(g){f(n[0][3],g)}}function l(d){d.value instanceof S?Promise.resolve(d.value.v).then(h,c):f(n[0][2],d)}function h(d){u("next",d)}function c(d){u("throw",d)}function f(d,p){d(p),n.shift(),n.length&&u(n[0][0],n[0][1])}}function ue(t){var e,r;return e={},s("next"),s("throw",function(a){throw a}),s("return"),e[Symbol.iterator]=function(){return this},e;function s(a,n){e[a]=t[a]?function(o){return(r=!r)?{value:S(t[a](o)),done:!1}:n?n(o):o}:n}}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 N=="function"?N(t):t[Symbol.iterator](),r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r);function s(n){r[n]=t[n]&&function(o){return new Promise(function(i,u){o=t[n](o),a(i,u,o.done,o.value)})}}function a(n,o,i,u){Promise.resolve(u).then(function(l){n({value:l,done:i})},o)}}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=k(t),s=0;s<r.length;s++)r[s]!=="default"&&C(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,a){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!a:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?a.call(t,r):a?a.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,a;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&&(a=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");a&&(s=function(){try{a.call(this)}catch(n){return Promise.reject(n)}}),t.stack.push({value:e,dispose:s,async:r})}else r&&t.stack.push({async:!0});return e}function ve(t){function e(n){t.error=t.hasError?new Ee(n,t.error,"An error was suppressed during disposal."):n,t.hasError=!0}var r,s=0;function a(){for(;r=t.stack.pop();)try{if(!r.async&&s===1)return s=0,t.stack.push(r),Promise.resolve().then(a);if(r.dispose){var n=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(n).then(a,function(o){return e(o),a()})}else s|=1}catch(o){e(o)}if(s===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return a()}function be(t,e){return typeof t=="string"&&/^\.\.?\//.test(t)?t.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,s,a,n,o){return s?e?".jsx":".js":a&&(!n||!o)?r:a+n+"."+o.toLowerCase()+"js"}):t}var j,L,C,_e,k,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 a in s)Object.prototype.hasOwnProperty.call(s,a)&&(r[a]=s[a])},j(t,e)},L=function(){return L=Object.assign||function(t){for(var e,r=1,s=arguments.length;r<s;r++){e=arguments[r];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])}return t},L.apply(this,arguments)},C=Object.create?(function(t,e,r,s){s===void 0&&(s=r);var a=Object.getOwnPropertyDescriptor(e,r);(!a||("get"in a?!e.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,s,a)}):(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},k=function(t){return k=Object.getOwnPropertyNames||function(e){var r=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[r.length]=s);return r},k(t)},Ee=typeof SuppressedError=="function"?SuppressedError:function(t,e,r){var s=new Error(r);return s.name="SuppressedError",s.error=t,s.suppressed=e,s},Oe={__extends:K,__assign:L,__rest:V,__decorate:Q,__param:Y,__esDecorate:X,__runInitializers:Z,__propKey:ee,__setFunctionName:te,__metadata:re,__awaiter:se,__generator:ae,__createBinding:C,__exportStar:ne,__values:N,__read:B,__spread:oe,__spreadArrays:ie,__spreadArray:le,__await:S,__asyncGenerator:he,__asyncDelegator:ue,__asyncValues:ce,__makeTemplateObject:de,__importStar:pe,__importDefault:fe,__classPrivateFieldGet:me,__classPrivateFieldSet:ge,__classPrivateFieldIn:ye,__addDisposableResource:we,__disposeResources:ve,__rewriteRelativeImportExtension:be}}),Pe=O(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=O(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=($(),T(P)),r=e.__importDefault(Pe()),s=class{constructor(a){var n,o;this.shouldThrowOnError=!1,this.method=a.method,this.url=a.url,this.headers=new Headers(a.headers),this.schema=a.schema,this.body=a.body,this.shouldThrowOnError=(n=a.shouldThrowOnError)!==null&&n!==void 0?n:!1,this.signal=a.signal,this.isMaybeSingle=(o=a.isMaybeSingle)!==null&&o!==void 0?o:!1,a.fetch?this.fetch=a.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(a,n){return this.headers=new Headers(this.headers),this.headers.set(a,n),this}then(a,n){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let o=this.fetch,i=o(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async u=>{var l,h,c,f;let d=null,p=null,g=null,w=u.status,y=u.statusText;if(u.ok){if(this.method!=="HEAD"){let F=await u.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=(c=u.headers.get("content-range"))===null||c===void 0?void 0:c.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 u.text();try{d=JSON.parse(x),Array.isArray(d)&&u.status===404&&(p=[],d=null,w=200,y="OK")}catch{u.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(u=>{var l,h,c;return{error:{message:`${(l=u?.name)!==null&&l!==void 0?l:"FetchError"}: ${u?.message}`,details:`${(h=u?.stack)!==null&&h!==void 0?h:""}`,hint:"",code:`${(c=u?.code)!==null&&c!==void 0?c:""}`},data:null,count:null,status:0,statusText:""}})),i.then(a,n)}returns(){return this}overrideTypes(){return this}};t.default=s}),Te=O(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=($(),T(P)),r=e.__importDefault(Se()),s=class extends r.default{select(a){let n=!1,o=(a??"*").split("").map(i=>/\s/.test(i)&&!n?"":(i==='"'&&(n=!n),i)).join("");return this.url.searchParams.set("select",o),this.headers.append("Prefer","return=representation"),this}order(a,{ascending:n=!0,nullsFirst:o,foreignTable:i,referencedTable:u=i}={}){let l=u?`${u}.order`:"order",h=this.url.searchParams.get(l);return this.url.searchParams.set(l,`${h?`${h},`:""}${a}.${n?"asc":"desc"}${o===void 0?"":o?".nullsfirst":".nullslast"}`),this}limit(a,{foreignTable:n,referencedTable:o=n}={}){let i=typeof o>"u"?"limit":`${o}.limit`;return this.url.searchParams.set(i,`${a}`),this}range(a,n,{foreignTable:o,referencedTable:i=o}={}){let u=typeof i>"u"?"offset":`${i}.offset`,l=typeof i>"u"?"limit":`${i}.limit`;return this.url.searchParams.set(u,`${a}`),this.url.searchParams.set(l,`${n-a+1}`),this}abortSignal(a){return this.signal=a,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:a=!1,verbose:n=!1,settings:o=!1,buffers:i=!1,wal:u=!1,format:l="text"}={}){var h;let c=[a?"analyze":null,n?"verbose":null,o?"settings":null,i?"buffers":null,u?"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=${c};`),l==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(a){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${a}`),this}};t.default=s}),G=O(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=($(),T(P)),r=e.__importDefault(Te()),s=new RegExp("[,()]"),a=class extends r.default{eq(n,o){return this.url.searchParams.append(n,`eq.${o}`),this}neq(n,o){return this.url.searchParams.append(n,`neq.${o}`),this}gt(n,o){return this.url.searchParams.append(n,`gt.${o}`),this}gte(n,o){return this.url.searchParams.append(n,`gte.${o}`),this}lt(n,o){return this.url.searchParams.append(n,`lt.${o}`),this}lte(n,o){return this.url.searchParams.append(n,`lte.${o}`),this}like(n,o){return this.url.searchParams.append(n,`like.${o}`),this}likeAllOf(n,o){return this.url.searchParams.append(n,`like(all).{${o.join(",")}}`),this}likeAnyOf(n,o){return this.url.searchParams.append(n,`like(any).{${o.join(",")}}`),this}ilike(n,o){return this.url.searchParams.append(n,`ilike.${o}`),this}ilikeAllOf(n,o){return this.url.searchParams.append(n,`ilike(all).{${o.join(",")}}`),this}ilikeAnyOf(n,o){return this.url.searchParams.append(n,`ilike(any).{${o.join(",")}}`),this}is(n,o){return this.url.searchParams.append(n,`is.${o}`),this}in(n,o){let i=Array.from(new Set(o)).map(u=>typeof u=="string"&&s.test(u)?`"${u}"`:`${u}`).join(",");return this.url.searchParams.append(n,`in.(${i})`),this}contains(n,o){return typeof o=="string"?this.url.searchParams.append(n,`cs.${o}`):Array.isArray(o)?this.url.searchParams.append(n,`cs.{${o.join(",")}}`):this.url.searchParams.append(n,`cs.${JSON.stringify(o)}`),this}containedBy(n,o){return typeof o=="string"?this.url.searchParams.append(n,`cd.${o}`):Array.isArray(o)?this.url.searchParams.append(n,`cd.{${o.join(",")}}`):this.url.searchParams.append(n,`cd.${JSON.stringify(o)}`),this}rangeGt(n,o){return this.url.searchParams.append(n,`sr.${o}`),this}rangeGte(n,o){return this.url.searchParams.append(n,`nxl.${o}`),this}rangeLt(n,o){return this.url.searchParams.append(n,`sl.${o}`),this}rangeLte(n,o){return this.url.searchParams.append(n,`nxr.${o}`),this}rangeAdjacent(n,o){return this.url.searchParams.append(n,`adj.${o}`),this}overlaps(n,o){return typeof o=="string"?this.url.searchParams.append(n,`ov.${o}`):this.url.searchParams.append(n,`ov.{${o.join(",")}}`),this}textSearch(n,o,{config:i,type:u}={}){let l="";u==="plain"?l="pl":u==="phrase"?l="ph":u==="websearch"&&(l="w");let h=i===void 0?"":`(${i})`;return this.url.searchParams.append(n,`${l}fts${h}.${o}`),this}match(n){return Object.entries(n).forEach(([o,i])=>{this.url.searchParams.append(o,`eq.${i}`)}),this}not(n,o,i){return this.url.searchParams.append(n,`not.${o}.${i}`),this}or(n,{foreignTable:o,referencedTable:i=o}={}){let u=i?`${i}.or`:"or";return this.url.searchParams.append(u,`(${n})`),this}filter(n,o,i){return this.url.searchParams.append(n,`${o}.${i}`),this}};t.default=a}),$e=O(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=($(),T(P)),r=e.__importDefault(G()),s=class{constructor(a,{headers:n={},schema:o,fetch:i}){this.url=a,this.headers=new Headers(n),this.schema=o,this.fetch=i}select(a,n){let{head:o=!1,count:i}=n??{},u=o?"HEAD":"GET",l=!1,h=(a??"*").split("").map(c=>/\s/.test(c)&&!l?"":(c==='"'&&(l=!l),c)).join("");return this.url.searchParams.set("select",h),i&&this.headers.append("Prefer",`count=${i}`),new r.default({method:u,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(a,{count:n,defaultToNull:o=!0}={}){var i;let u="POST";if(n&&this.headers.append("Prefer",`count=${n}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(a)){let l=a.reduce((h,c)=>h.concat(Object.keys(c)),[]);if(l.length>0){let h=[...new Set(l)].map(c=>`"${c}"`);this.url.searchParams.set("columns",h.join(","))}}return new r.default({method:u,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}upsert(a,{onConflict:n,ignoreDuplicates:o=!1,count:i,defaultToNull:u=!0}={}){var l;let h="POST";if(this.headers.append("Prefer",`resolution=${o?"ignore":"merge"}-duplicates`),n!==void 0&&this.url.searchParams.set("on_conflict",n),i&&this.headers.append("Prefer",`count=${i}`),u||this.headers.append("Prefer","missing=default"),Array.isArray(a)){let c=a.reduce((f,d)=>f.concat(Object.keys(d)),[]);if(c.length>0){let f=[...new Set(c)].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:a,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}update(a,{count:n}={}){var o;let i="PATCH";return n&&this.headers.append("Prefer",`count=${n}`),new r.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}delete({count:a}={}){var n;let o="DELETE";return a&&this.headers.append("Prefer",`count=${a}`),new r.default({method:o,url:this.url,headers:this.headers,schema:this.schema,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}};t.default=s}),Ze=O(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=($(),T(P)),r=e.__importDefault($e()),s=e.__importDefault(G()),a=class xe{constructor(o,{headers:i={},schema:u,fetch:l}={}){this.url=o,this.headers=new Headers(i),this.schemaName=u,this.fetch=l}from(o){let i=new URL(`${this.url}/${o}`);return new r.default(i,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(o){return new xe(this.url,{headers:this.headers,schema:o,fetch:this.fetch})}rpc(o,i={},{head:u=!1,get:l=!1,count:h}={}){var c;let f,d=new URL(`${this.url}/rpc/${o}`),p;u||l?(f=u?"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:(c=this.fetch)!==null&&c!==void 0?c:fetch})}};t.default=a}),et=O(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(P)),r=e.__importDefault(Ze());t.PostgrestClient=r.default;var s=e.__importDefault($e());t.PostgrestQueryBuilder=s.default;var a=e.__importDefault(G());t.PostgrestFilterBuilder=a.default;var n=e.__importDefault(Te());t.PostgrestTransformBuilder=n.default;var o=e.__importDefault(Se());t.PostgrestBuilder=o.default;var i=e.__importDefault(Pe());t.PostgrestError=i.default,t.default={PostgrestClient:r.default,PostgrestQueryBuilder:s.default,PostgrestFilterBuilder:a.default,PostgrestTransformBuilder:n.default,PostgrestBuilder:o.default,PostgrestError:i.default}});m();m();var Le=class{constructor(t,e=""){this.http=t,this.baseUrl=e.replace(/\/$/,"")}async invoke(t,e){let r=this.baseUrl?`${this.baseUrl}/functions/${t}`:`/functions/${t}`;return await(await this.http.fetch(r,{method:e.method||"POST",body:e.body,headers:e.headers})).json()}};m();m();var v="nvwa_current_jwt",b="nvwa_login_token",_="nvwa_user_profile",tt="set-auth-token",rt=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??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(_);if(r!=null)return r}let{data:t}=await this.getSession(),e=t?.user??null;return e&&this.storage&&await this.storage.set(_,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(_,t.user);let s=r??await this.storage.get(b),{data:a}=await this.getToken(s??void 0);a?.token&&await this.storage.set(v,a.token)}async clearLogin(){this.storage&&(await this.storage.remove(b),await this.storage.remove(_),await this.storage.remove(v))}getGoogleOpenPlatformLoginUrl(t){let e=new URLSearchParams({return_url:t});return`${this.url("google/openplatform/login")}?${e.toString()}`}startGoogleOpenPlatformLogin(t){let e=this.getGoogleOpenPlatformLoginUrl(t);if(typeof globalThis<"u"&&"location"in globalThis){globalThis.location.href=e;return}throw new Error("startGoogleOpenPlatformLogin requires a browser environment with location")}async completeGoogleOpenPlatformLoginFromCurrentUrl(t){let e;if(t!=null&&t!=="")e=t;else if(typeof globalThis<"u"&&"location"in globalThis)e=globalThis.location.href;else return{error:{message:"completeGoogleOpenPlatformLoginFromCurrentUrl requires url or browser location",status:0}};let r;try{r=new URL(e).searchParams.get("exchange_code")}catch{return{error:{message:"invalid_callback_url",status:400}}}return r?.trim()?await this.loginWithGoogleExchangeCode(r.trim()):{error:{message:"missing_exchange_code",status:400}}}async loginWithGoogleExchangeCode(t){try{let e={"Content-Type":"application/json"};if(this.storage){let n=await this.storage.get(v);n!=null&&(e.Authorization=`Bearer ${n}`)}let r=await this.fetchImpl(this.url("google/openplatform/sign-in"),{method:"POST",headers:e,credentials:this.credentials,body:JSON.stringify({exchangeCode:t})}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let a=s?JSON.parse(s):null;return!a?.token||!a.user?{error:{message:"invalid_google_login_response",status:502}}:(this.storage&&(await this.storage.set(v,a.token),await this.storage.set(b,a.token),await this.storage.set(_,a.user)),{data:a})}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getGoogleOpenPlatformIdentity(){try{let t={};if(this.storage){let a=await this.storage.get(v);a!=null&&(t.Authorization=`Bearer ${a}`)}let e=await this.fetchImpl(this.url("google/openplatform/identity"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}}),r=await e.text();if(!e.ok)return{error:{message:r||e.statusText,status:e.status}};let s=r?JSON.parse(r):null;return s?.sub?{data:s}:{error:{message:"invalid_google_identity_response",status:502}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}getGithubOpenPlatformLoginUrl(t){let e=new URLSearchParams({return_url:t});return`${this.url("github/openplatform/login")}?${e.toString()}`}startGithubOpenPlatformLogin(t){let e=this.getGithubOpenPlatformLoginUrl(t);if(typeof globalThis<"u"&&"location"in globalThis){globalThis.location.href=e;return}throw new Error("startGithubOpenPlatformLogin requires a browser environment with location")}async completeGithubOpenPlatformLoginFromCurrentUrl(t){let e;if(t!=null&&t!=="")e=t;else if(typeof globalThis<"u"&&"location"in globalThis)e=globalThis.location.href;else return{error:{message:"completeGithubOpenPlatformLoginFromCurrentUrl requires url or browser location",status:0}};let r;try{r=new URL(e).searchParams.get("exchange_code")}catch{return{error:{message:"invalid_callback_url",status:400}}}return r?.trim()?await this.loginWithGithubExchangeCode(r.trim()):{error:{message:"missing_exchange_code",status:400}}}async loginWithGithubExchangeCode(t){try{let e={"Content-Type":"application/json"};if(this.storage){let n=await this.storage.get(v);n!=null&&(e.Authorization=`Bearer ${n}`)}let r=await this.fetchImpl(this.url("github/openplatform/sign-in"),{method:"POST",headers:e,credentials:this.credentials,body:JSON.stringify({exchangeCode:t})}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let a=s?JSON.parse(s):null;return!a?.token||!a.user?{error:{message:"invalid_github_login_response",status:502}}:(this.storage&&(await this.storage.set(v,a.token),await this.storage.set(b,a.token),await this.storage.set(_,a.user)),{data:a})}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getGithubOpenPlatformIdentity(){try{let t={};if(this.storage){let a=await this.storage.get(v);a!=null&&(t.Authorization=`Bearer ${a}`)}let e=await this.fetchImpl(this.url("github/openplatform/identity"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}}),r=await e.text();if(!e.ok)return{error:{message:r||e.statusText,status:e.status}};let s=r?JSON.parse(r):null;return s?.sub?{data:s}:{error:{message:"invalid_github_identity_response",status:502}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}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 a=s?JSON.parse(s):void 0;return a&&await this.persistLogin({user:a.user,session:a.session},r),{data:a}}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 n=await this.storage.get(b)??await this.storage.get(v);n!=null&&(e.Authorization=`Bearer ${n}`)}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 a=s?JSON.parse(s):void 0;return{data:a?.token!=null?{token:a.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 o=await this.storage.get(v);o!=null&&(r.Authorization=`Bearer ${o}`)}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})}),a=await s.text();if(!s.ok)return{error:{message:a||s.statusText,status:s.status}};let n=a?JSON.parse(a):null;return!n?.token||!n.user?{error:{message:"invalid_wechat_login_response",status:502}}:(this.storage&&(await this.storage.set(v,n.token),await this.storage.set(b,n.token),await this.storage.set(_,n.user)),{data:n})}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 o=await this.storage.get(v);o!=null&&(r.Authorization=`Bearer ${o}`)}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})}),a=await s.text();if(!s.ok)return{error:{message:a||s.statusText,status:s.status}};let n=a?JSON.parse(a):null;return!n?.token||!n.user?{error:{message:"invalid_alipay_login_response",status:502}}:(this.storage&&(await this.storage.set(v,n.token),await this.storage.set(b,n.token),await this.storage.set(_,n.user)),{data:n})}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async getWeChatOpenPlatformIdentity(t){try{let e={};if(this.storage){let o=await this.storage.get(v);o!=null&&(e.Authorization=`Bearer ${o}`)}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}:{}}),a=await s.text();if(!s.ok)return{error:{message:a||s.statusText,status:s.status}};let n=a?JSON.parse(a):null;return!n?.openid||!n.appId?{error:{message:"invalid_wechat_identity_response",status:502}}:{data:n}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getAlipayOpenPlatformIdentity(t){try{let e={};if(this.storage){let o=await this.storage.get(v);o!=null&&(e.Authorization=`Bearer ${o}`)}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}:{}}),a=await s.text();if(!s.ok)return{error:{message:a||s.statusText,status:s.status}};let n=a?JSON.parse(a):null;return!n?.openid||!n.appId?{error:{message:"invalid_alipay_identity_response",status:502}}:{data:n}}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 a=s?JSON.parse(s):void 0;return{data:a?.data??a??void 0,response:r}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}};m();m();var E=class Ie{constructor(e){if(this.headerMap=new Map,e){if(e instanceof Ie)e.forEach((r,s)=>this.set(s,r));else if(Array.isArray(e))for(let[r,s]of e)this.set(r,String(s));else if(typeof e=="object")for(let r of Object.keys(e))this.set(r,String(e[r]))}}append(e,r){let s=e.toLowerCase(),a=this.headerMap.get(s);this.headerMap.set(s,a?`${a}, ${r}`:r)}set(e,r){this.headerMap.set(e.toLowerCase(),String(r))}get(e){return this.headerMap.get(e.toLowerCase())??null}has(e){return this.headerMap.has(e.toLowerCase())}delete(e){this.headerMap.delete(e.toLowerCase())}forEach(e){for(let[r,s]of this.headerMap.entries())e(s,r,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}};m();m();var Ae=class{constructor(t,e){this.bodyData=t,this.status=e?.status??200,this.statusText=e?.statusText??"",this.headers=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 E(t):new E}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(e?.headers);r&&s.set("Authorization",`Bearer ${r}`);let a=e?.method||"GET";if((a==="POST"||a==="PUT"||a==="PATCH")&&e?.body){let o=s.get("Content-Type");(!o||o.includes("text/plain"))&&s.set("Content-Type","application/json")}let n=await this.customFetch(t,{...e,headers:s});if(n.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return n}};m();var at="/storage",nt=at+"/generateUploadUrl",ke=class{constructor(t,e){this.baseUrl=t,this.http=e}async uploadFile(t){let e=await this.http.fetch(this.baseUrl+nt,{method:"POST",body:{fileName:t.name||t.fileName,fileSize:t.size||t.fileSize,fileType:t.type||t.fileType}}),{url:r}=await e.json();if(!r)throw new Error("\u83B7\u53D6\u4E0A\u4F20URL\u5931\u8D25");let s=await this.http.fetch(r,{method:"PUT",body:t,headers:new E({"Content-Type":t.type||t.fileType||"application/octet-stream"})}),{url:a}=await s.json();return{url:a.split("?")[0]}}};m();m();m();var z=Xe(et(),1),{PostgrestClient:ot,PostgrestQueryBuilder:wt,PostgrestFilterBuilder:vt,PostgrestTransformBuilder:bt,PostgrestBuilder:_t,PostgrestError:Et}=z.default||z,it="/entities",Ne=(t,e)=>new ot(t+it,{fetch:e.fetchWithAuth.bind(e)});m();var Ue=class{constructor(){this.hoverOverlay=null,this.selectedOverlay=null,this.tooltip=null,this.hoverElement=null,this.selectedElement=null,this.hoverUpdateHandler=null,this.selectedUpdateHandler=null,this.createStyles()}createStyles(){if(document.getElementById("__nvwa-inspector-overlay-style"))return;let t=document.createElement("style");t.id="__nvwa-inspector-overlay-style",t.textContent=`
|
|
2
2
|
.__nvwa-inspector-overlay {
|
|
3
3
|
position: absolute;
|
|
4
4
|
pointer-events: none;
|
|
@@ -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,n=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(t.style.left=`${r.left+s}px`,t.style.top=`${r.top+n}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 o=this.createTooltip();e?o.textContent=e:o.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,o.style.display="block";let i=t.getBoundingClientRect();o.style.left=`${i.left+window.scrollX}px`,o.style.top=`${i.top+window.scrollY-o.offsetHeight-8}px`,i.top<o.offsetHeight+8&&(o.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 n=this.createTooltip();e?n.textContent=e:n.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,n.style.display="block";let a=t.getBoundingClientRect();n.style.left=`${a.left+window.scrollX}px`,n.style.top=`${a.top+window.scrollY-n.offsetHeight-8}px`,a.top<n.offsetHeight+8&&(n.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();function Ue(t){let e=t;if(typeof e.kind=="string")return e;if(typeof e.tradeNO=="string")return{kind:"alipay_miniprogram",tradeNO:e.tradeNO};if(typeof e.clientSecret=="string")return{kind:"stripe_client_secret",clientSecret:e.clientSecret};if(typeof e.redirectUrl=="string")return{kind:"redirect_url",redirectUrl:e.redirectUrl};if(typeof e.formHtml=="string")return{kind:"alipay_page",formHtml:e.formHtml};if(typeof e.codeUrl=="string")return{kind:"wechat_native_qr",codeUrl:e.codeUrl};let r=e.jsapiPayParams??e;return typeof r.timeStamp=="string"&&typeof r.nonceStr=="string"&&typeof r.package=="string"&&typeof r.paySign=="string"&&typeof r.appId=="string"?{kind:"wechat_jsapi",mode:"jsapi",jsapiPayParams:{appId:r.appId,timeStamp:r.timeStamp,nonceStr:r.nonceStr,package:r.package,signType:r.signType??"RSA",paySign:r.paySign}}:null}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 n=JSON.parse(s);return n.expires&&Date.now()>n.expires?(await this.remove(e),null):n.value}catch(r){return console.error("WebStorageService get error:",r),null}}async set(e,r,s){try{let n=this.getKey(e),a={value:r,expires:s?Date.now()+s*1e3:null,timestamp:Date.now()};localStorage.setItem(n,JSON.stringify(a))}catch(n){throw console.error("WebStorageService set error:",n),n}}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 b){let o={};a.forEach((i,h)=>{o[h]=i}),s=o}else if(Array.isArray(a)){let o=[];for(let i of a)Array.isArray(i)&&i.length>=2&&o.push([String(i[0]),String(i[1])]);s=o}else typeof a=="object"&&(s=a)}let n={method:e?.method||"GET",headers:s,body:e?.body,credentials:e?.credentials};return e?.signal&&(n.signal=e.signal),globalThis.fetch(r,n).then(async a=>{let o=a.headers.get("content-type")||"",i;if(o.includes("application/json"))i=await a.json();else{let l=await a.text();try{i=JSON.parse(l)}catch{i=l}}let h=new b;return a.headers.forEach((l,c)=>{h.set(c,l)}),new Le(i,{status:a.status,statusText:a.statusText,headers:h})})},L=lt;function ct(t){return`https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(t)}`}var Me={async requestPayment(t,e){let r=Ue(t);if(r?.kind==="redirect_url"){window.location.href=r.redirectUrl;return}if(r?.kind==="wechat_native_qr"){let n=ct(r.codeUrl);window.open(n,"_blank","noopener,noreferrer");return}if(r?.kind==="alipay_page"){let n=window.open("","_blank");n&&(n.document.write(r.formHtml),n.document.close());return}let s=new Error("requestPayment: unsupported payParams for Desktop-web");throw e?.onFailure?.(s),s}};function ht(){if(typeof window>"u"||window===window.parent)return;let t=!1,e=new Re;function r(l){if(!l)return!1;let c=l.toLowerCase();return c.includes("/components/")||c.includes("\\components\\")}function s(l){let c=l,u=null;for(;c;){let f=c.getAttribute("data-source-location");if(f)if(r(f)){u||(u=f),c=c.parentElement;continue}else return f;c=c.parentElement}return u}let n=null;function a(l){t&&(n!==null&&cancelAnimationFrame(n),n=requestAnimationFrame(()=>{let c=l.target;if(!c||c===document.body||c===document.documentElement){e.removeHighlight();return}if(c.tagName.toLowerCase()==="img"){let p=s(c);e.highlightElement(c,p);let g={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:p,elementInfo:{tagName:c.tagName.toLowerCase(),className:c.className||"",id:c.id||""}};window.parent.postMessage(g,"*");return}let u=c,f=s(c);if(!f){let p=c.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 o(){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 c=l.target;if(!c||c===document.body||c===document.documentElement)return;let u=s(c);e.selectElement(c,u);let f={type:"HOVER_INSPECTOR_ELEMENT_SELECT",sourceLocation:u,elementInfo:{tagName:c.tagName.toLowerCase(),className:c.className||"",id:c.id||""}};window.parent.postMessage(f,"*")}function h(l){l.data?.type==="HOVER_INSPECTOR_ENABLE"?(t=!0,document.addEventListener("mousemove",a),document.addEventListener("mouseleave",o),document.addEventListener("click",i,!0)):l.data?.type==="HOVER_INSPECTOR_DISABLE"&&(t=!1,document.removeEventListener("mousemove",a),document.removeEventListener("mouseleave",o),document.removeEventListener("click",i,!0),e.removeHighlight(),e.clearSelection())}return window.addEventListener("message",h),()=>{window.removeEventListener("message",h),document.removeEventListener("mousemove",a),document.removeEventListener("mouseleave",o),document.removeEventListener("click",i,!0),e.cleanup()}}function ut(t,e){if(!t||!t.contentWindow)throw new Error("Invalid iframe element");let r={type:"HOVER_INSPECTOR_ENABLE"};t.contentWindow.postMessage(r,e)}function dt(t,e){if(!t||!t.contentWindow)return;let r={type:"HOVER_INSPECTOR_DISABLE"};t.contentWindow.postMessage(r,e)}function pt(t,e,r=5e3){return new Promise((s,n)=>{if(!t||!t.contentWindow){n(new Error("Invalid iframe element"));return}let a=`source-location-${Date.now()}-${Math.random()}`,o=setTimeout(()=>{window.removeEventListener("message",i),n(new Error("Request timeout"))},r),i=l=>{l.origin===e&&l.data?.type==="GET_SOURCE_LOCATION_RESPONSE"&&l.data?.requestId===a&&(clearTimeout(o),window.removeEventListener("message",i),l.data.error?n(new Error(l.data.error)):s(l.data.sourceLocation||null))};window.addEventListener("message",i);let h={type:"GET_SOURCE_LOCATION_REQUEST",requestId:a};try{t.contentWindow.postMessage(h,e)}catch(l){clearTimeout(o),window.removeEventListener("message",i),n(l)}})}function ft(){if(typeof window>"u"||window===window.parent)return;let t=e=>{if(e.data?.type==="GET_SOURCE_LOCATION_REQUEST")try{let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:mt(),requestId:e.data.requestId};window.parent.postMessage(s,e.origin)}catch(r){let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:null,error:r instanceof Error?r.message:"Unknown error",requestId:e.data.requestId};window.parent.postMessage(s,e.origin)}};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}}function mt(){return He("root")}var z=new H,U=class{constructor(e,r){this.endpointType="Desktop-web";this.payment=Me;this.auth=new Ie(e,{fetchImpl:L,storage:z}),this.httpClient=new je(z,L,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});
|
|
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,a=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(t.style.left=`${r.left+s}px`,t.style.top=`${r.top+a}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 o=this.createTooltip();e?o.textContent=e:o.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,o.style.display="block";let i=t.getBoundingClientRect();o.style.left=`${i.left+window.scrollX}px`,o.style.top=`${i.top+window.scrollY-o.offsetHeight-8}px`,i.top<o.offsetHeight+8&&(o.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 a=this.createTooltip();e?a.textContent=e:a.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,a.style.display="block";let n=t.getBoundingClientRect();a.style.left=`${n.left+window.scrollX}px`,a.style.top=`${n.top+window.scrollY-a.offsetHeight-8}px`,n.top<a.offsetHeight+8&&(a.style.top=`${n.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 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 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();function He(t){let e=t;if(typeof e.kind=="string")return e;if(typeof e.tradeNO=="string")return{kind:"alipay_miniprogram",tradeNO:e.tradeNO};if(typeof e.clientSecret=="string")return{kind:"stripe_client_secret",clientSecret:e.clientSecret};if(typeof e.redirectUrl=="string")return{kind:"redirect_url",redirectUrl:e.redirectUrl};if(typeof e.formHtml=="string")return{kind:"alipay_page",formHtml:e.formHtml};if(typeof e.codeUrl=="string")return{kind:"wechat_native_qr",codeUrl:e.codeUrl};let r=e.jsapiPayParams??e;return typeof r.timeStamp=="string"&&typeof r.nonceStr=="string"&&typeof r.package=="string"&&typeof r.paySign=="string"&&typeof r.appId=="string"?{kind:"wechat_jsapi",mode:"jsapi",jsapiPayParams:{appId:r.appId,timeStamp:r.timeStamp,nonceStr:r.nonceStr,package:r.package,signType:r.signType??"RSA",paySign:r.paySign}}:null}var R=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 a=JSON.parse(s);return a.expires&&Date.now()>a.expires?(await this.remove(e),null):a.value}catch(r){return console.error("WebStorageService get error:",r),null}}async set(e,r,s){try{let a=this.getKey(e),n={value:r,expires:s?Date.now()+s*1e3:null,timestamp:Date.now()};localStorage.setItem(a,JSON.stringify(n))}catch(a){throw console.error("WebStorageService set error:",a),a}}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 n=e.headers;if(n instanceof E){let o={};n.forEach((i,u)=>{o[u]=i}),s=o}else if(Array.isArray(n)){let o=[];for(let i of n)Array.isArray(i)&&i.length>=2&&o.push([String(i[0]),String(i[1])]);s=o}else typeof n=="object"&&(s=n)}let a={method:e?.method||"GET",headers:s,body:e?.body,credentials:e?.credentials};return e?.signal&&(a.signal=e.signal),globalThis.fetch(r,a).then(async n=>{let o=n.headers.get("content-type")||"",i;if(o.includes("application/json"))i=await n.json();else{let l=await n.text();try{i=JSON.parse(l)}catch{i=l}}let u=new E;return n.headers.forEach((l,h)=>{u.set(h,l)}),new Ae(i,{status:n.status,statusText:n.statusText,headers:u})})},A=lt;function ht(t){return`https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(t)}`}var Me={async requestPayment(t,e){let r=He(t);if(r?.kind==="redirect_url"){window.location.href=r.redirectUrl;return}if(r?.kind==="wechat_native_qr"){let a=ht(r.codeUrl);window.open(a,"_blank","noopener,noreferrer");return}if(r?.kind==="alipay_page"){let a=window.open("","_blank");a&&(a.document.write(r.formHtml),a.document.close());return}let s=new Error("requestPayment: unsupported payParams for Desktop-web");throw e?.onFailure?.(s),s}};function ut(){if(typeof window>"u"||window===window.parent)return;let t=!1,e=new Ue;function r(l){if(!l)return!1;let h=l.toLowerCase();return h.includes("/components/")||h.includes("\\components\\")}function s(l){let h=l,c=null;for(;h;){let f=h.getAttribute("data-source-location");if(f)if(r(f)){c||(c=f),h=h.parentElement;continue}else return f;h=h.parentElement}return c}let a=null;function n(l){t&&(a!==null&&cancelAnimationFrame(a),a=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 c=h,f=s(h);if(!f){let p=h.parentElement;for(;p&&p!==document.body&&p!==document.documentElement;){let g=s(p);if(g){c=p,f=g;break}p=p.parentElement}}e.highlightElement(c,f);let d={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:f,elementInfo:{tagName:c.tagName.toLowerCase(),className:c.className||"",id:c.id||""}};window.parent.postMessage(d,"*")}))}function o(){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 c=s(h);e.selectElement(h,c);let f={type:"HOVER_INSPECTOR_ELEMENT_SELECT",sourceLocation:c,elementInfo:{tagName:h.tagName.toLowerCase(),className:h.className||"",id:h.id||""}};window.parent.postMessage(f,"*")}function u(l){l.data?.type==="HOVER_INSPECTOR_ENABLE"?(t=!0,document.addEventListener("mousemove",n),document.addEventListener("mouseleave",o),document.addEventListener("click",i,!0)):l.data?.type==="HOVER_INSPECTOR_DISABLE"&&(t=!1,document.removeEventListener("mousemove",n),document.removeEventListener("mouseleave",o),document.removeEventListener("click",i,!0),e.removeHighlight(),e.clearSelection())}return window.addEventListener("message",u),()=>{window.removeEventListener("message",u),document.removeEventListener("mousemove",n),document.removeEventListener("mouseleave",o),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 dt(t,e){if(!t||!t.contentWindow)return;let r={type:"HOVER_INSPECTOR_DISABLE"};t.contentWindow.postMessage(r,e)}function pt(t,e,r=5e3){return new Promise((s,a)=>{if(!t||!t.contentWindow){a(new Error("Invalid iframe element"));return}let n=`source-location-${Date.now()}-${Math.random()}`,o=setTimeout(()=>{window.removeEventListener("message",i),a(new Error("Request timeout"))},r),i=l=>{l.origin===e&&l.data?.type==="GET_SOURCE_LOCATION_RESPONSE"&&l.data?.requestId===n&&(clearTimeout(o),window.removeEventListener("message",i),l.data.error?a(new Error(l.data.error)):s(l.data.sourceLocation||null))};window.addEventListener("message",i);let u={type:"GET_SOURCE_LOCATION_REQUEST",requestId:n};try{t.contentWindow.postMessage(u,e)}catch(l){clearTimeout(o),window.removeEventListener("message",i),a(l)}})}function ft(){if(typeof window>"u"||window===window.parent)return;let t=e=>{if(e.data?.type==="GET_SOURCE_LOCATION_REQUEST")try{let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:mt(),requestId:e.data.requestId};window.parent.postMessage(s,e.origin)}catch(r){let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:null,error:r instanceof Error?r.message:"Unknown error",requestId:e.data.requestId};window.parent.postMessage(s,e.origin)}};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}}function mt(){return Re("root")}var q=new R,H=class{constructor(e,r){this.endpointType="Desktop-web";this.payment=Me;this.auth=new Ce(e,{fetchImpl:A,storage:q}),this.httpClient=new je(q,A,r),this.fileStorage=new ke(e,this.httpClient),this.entities=Ne(e,this.httpClient),this.functions=new Le(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})},G=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Be(e))!ze.call(t,n)&&n!==r&&R(t,n,{get:()=>e[n],enumerable:!(s=De(e,n))||s.enumerable});return t},Ge=(t,e,r)=>(r=t!=null?Fe(qe(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"}),P={};We(P,{__addDisposableResource:()=>ye,__assign:()=>A,__asyncDelegator:()=>ce,__asyncGenerator:()=>le,__asyncValues:()=>he,__await:()=>S,__awaiter:()=>re,__classPrivateFieldGet:()=>fe,__classPrivateFieldIn:()=>ge,__classPrivateFieldSet:()=>me,__createBinding:()=>I,__decorate:()=>V,__disposeResources:()=>ve,__esDecorate:()=>Y,__exportStar:()=>ae,__extends:()=>J,__generator:()=>se,__importDefault:()=>pe,__importStar:()=>de,__makeTemplateObject:()=>ue,__metadata:()=>te,__param:()=>Q,__propKey:()=>Z,__read:()=>D,__rest:()=>K,__rewriteRelativeImportExtension:()=>we,__runInitializers:()=>X,__setFunctionName:()=>ee,__spread:()=>ne,__spreadArray:()=>ie,__spreadArrays:()=>oe,__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 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 n=0,s=Object.getOwnPropertySymbols(t);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(r[s[n]]=t[s[n]]);return r}function V(t,e,r,s){var n=arguments.length,a=n<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,r):s,o;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--)(o=t[i])&&(a=(n<3?o(a):n>3?o(e,r,a):o(e,r))||a);return n>3&&a&&Object.defineProperty(e,r,a),a}function Q(t,e){return function(r,s){e(r,s,t)}}function Y(t,e,r,s,n,a){function o(y){if(y!==void 0&&typeof y!="function")throw new TypeError("Function expected");return y}for(var i=s.kind,h=i==="getter"?"get":i==="setter"?"set":"value",l=!e&&t?s.static?t:t.prototype:null,c=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(o(y||null))};var v=(0,r[d])(i==="accessor"?{get:c.get,set:c.set}:c[h],p);if(i==="accessor"){if(v===void 0)continue;if(v===null||typeof v!="object")throw new TypeError("Object expected");(u=o(v.get))&&(c.get=u),(u=o(v.set))&&(c.set=u),(u=o(v.init))&&n.unshift(u)}else(u=o(v))&&(i==="field"?n.unshift(u):c[h]=u)}l&&Object.defineProperty(l,s.name,c),f=!0}function X(t,e,r){for(var s=arguments.length>2,n=0;n<e.length;n++)r=s?e[n].call(t,r):e[n].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 n(a){return a instanceof r?a:new r(function(o){o(a)})}return new(r||(r=Promise))(function(a,o){function i(c){try{l(s.next(c))}catch(u){o(u)}}function h(c){try{l(s.throw(c))}catch(u){o(u)}}function l(c){c.done?a(c.value):n(c.value).then(i,h)}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,n,a,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=i(0),o.throw=i(1),o.return=i(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function i(l){return function(c){return h([l,c])}}function h(l){if(s)throw new TypeError("Generator is already executing.");for(;o&&(o=0,l[0]&&(r=0)),r;)try{if(s=1,n&&(a=l[0]&2?n.return:l[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,l[1])).done)return a;switch(n=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++,n=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(c){l=[6,c],n=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)&&I(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),n,a=[],o;try{for(;(e===void 0||e-- >0)&&!(n=s.next()).done;)a.push(n.value)}catch(i){o={error:i}}finally{try{n&&!n.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}return a}function ne(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(D(arguments[e]));return t}function oe(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var s=Array(t),n=0,e=0;e<r;e++)for(var a=arguments[e],o=0,i=a.length;o<i;o++,n++)s[n]=a[o];return s}function ie(t,e,r){if(r||arguments.length===2)for(var s=0,n=e.length,a;s<n;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||[]),n,a=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),i("next"),i("throw"),i("return",o),n[Symbol.asyncIterator]=function(){return this},n;function o(d){return function(p){return Promise.resolve(p).then(d,u)}}function i(d,p){s[d]&&(n[d]=function(g){return new Promise(function(v,y){a.push([d,g,v,y])>1||h(d,g)})},p&&(n[d]=p(n[d])))}function h(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(c,u):f(a[0][2],d)}function c(d){h("next",d)}function u(d){h("throw",d)}function f(d,p){d(p),a.shift(),a.length&&h(a[0][0],a[0][1])}}function ce(t){var e,r;return e={},s("next"),s("throw",function(n){throw n}),s("return"),e[Symbol.iterator]=function(){return this},e;function s(n,a){e[n]=t[n]?function(o){return(r=!r)?{value:S(t[n](o)),done:!1}:a?a(o):o}:a}}function he(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(o){return new Promise(function(i,h){o=t[a](o),n(i,h,o.done,o.value)})}}function n(a,o,i,h){Promise.resolve(h).then(function(l){a({value:l,done:i})},o)}}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"&&I(e,t,r[s]);return _e(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,n){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!n)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?n.call(t,r):n?n.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,n;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&&(n=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");n&&(s=function(){try{n.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 be(a,t.error,"An error was suppressed during disposal."):a,t.hasError=!0}var r,s=0;function n(){for(;r=t.stack.pop();)try{if(!r.async&&s===1)return s=0,t.stack.push(r),Promise.resolve().then(n);if(r.dispose){var a=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(a).then(n,function(o){return e(o),n()})}else s|=1}catch(o){e(o)}if(s===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return n()}function we(t,e){return typeof t=="string"&&/^\.\.?\//.test(t)?t.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,s,n,a,o){return s?e?".jsx":".js":n&&(!a||!o)?r:n+a+"."+o.toLowerCase()+"js"}):t}var j,A,I,_e,N,be,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 n in s)Object.prototype.hasOwnProperty.call(s,n)&&(r[n]=s[n])},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 n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},A.apply(this,arguments)},I=Object.create?(function(t,e,r,s){s===void 0&&(s=r);var n=Object.getOwnPropertyDescriptor(e,r);(!n||("get"in n?!e.__esModule:n.writable||n.configurable))&&(n={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,s,n)}):(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)},be=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:J,__assign:A,__rest:K,__decorate:V,__param:Q,__esDecorate:Y,__runInitializers:X,__propKey:Z,__setFunctionName:ee,__metadata:te,__awaiter:re,__generator:se,__createBinding:I,__exportStar:ae,__values:k,__read:D,__spread:ne,__spreadArrays:oe,__spreadArray:ie,__await:S,__asyncGenerator:le,__asyncDelegator:ce,__asyncValues:he,__makeTemplateObject:ue,__importStar:de,__importDefault:pe,__classPrivateFieldGet:fe,__classPrivateFieldSet:me,__classPrivateFieldIn:ge,__addDisposableResource:ye,__disposeResources:ve,__rewriteRelativeImportExtension:we}}),Pe=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=class extends Error{constructor(r){super(r.message),this.name="PostgrestError",this.details=r.details,this.hint=r.hint,this.code=r.code}};t.default=e}),Oe=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=($(),T(P)),r=e.__importDefault(Pe()),s=class{constructor(n){var a,o;this.shouldThrowOnError=!1,this.method=n.method,this.url=n.url,this.headers=new Headers(n.headers),this.schema=n.schema,this.body=n.body,this.shouldThrowOnError=(a=n.shouldThrowOnError)!==null&&a!==void 0?a:!1,this.signal=n.signal,this.isMaybeSingle=(o=n.isMaybeSingle)!==null&&o!==void 0?o:!1,n.fetch?this.fetch=n.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(n,a){return this.headers=new Headers(this.headers),this.headers.set(n,a),this}then(n,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 o=this.fetch,i=o(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async h=>{var l,c,u,f;let d=null,p=null,g=null,v=h.status,y=h.statusText;if(h.ok){if(this.method!=="HEAD"){let F=await h.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=(c=this.headers.get("Prefer"))===null||c===void 0?void 0:c.match(/count=(exact|planned|estimated)/),M=(u=h.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 h.text();try{d=JSON.parse(x),Array.isArray(d)&&h.status===404&&(p=[],d=null,v=200,y="OK")}catch{h.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(h=>{var l,c,u;return{error:{message:`${(l=h?.name)!==null&&l!==void 0?l:"FetchError"}: ${h?.message}`,details:`${(c=h?.stack)!==null&&c!==void 0?c:""}`,hint:"",code:`${(u=h?.code)!==null&&u!==void 0?u:""}`},data:null,count:null,status:0,statusText:""}})),i.then(n,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(P)),r=e.__importDefault(Oe()),s=class extends r.default{select(n){let a=!1,o=(n??"*").split("").map(i=>/\s/.test(i)&&!a?"":(i==='"'&&(a=!a),i)).join("");return this.url.searchParams.set("select",o),this.headers.append("Prefer","return=representation"),this}order(n,{ascending:a=!0,nullsFirst:o,foreignTable:i,referencedTable:h=i}={}){let l=h?`${h}.order`:"order",c=this.url.searchParams.get(l);return this.url.searchParams.set(l,`${c?`${c},`:""}${n}.${a?"asc":"desc"}${o===void 0?"":o?".nullsfirst":".nullslast"}`),this}limit(n,{foreignTable:a,referencedTable:o=a}={}){let i=typeof o>"u"?"limit":`${o}.limit`;return this.url.searchParams.set(i,`${n}`),this}range(n,a,{foreignTable:o,referencedTable:i=o}={}){let h=typeof i>"u"?"offset":`${i}.offset`,l=typeof i>"u"?"limit":`${i}.limit`;return this.url.searchParams.set(h,`${n}`),this.url.searchParams.set(l,`${a-n+1}`),this}abortSignal(n){return this.signal=n,this}single(){return this.headers.set("Accept","application/vnd.pgrst.object+json"),this}maybeSingle(){return this.method==="GET"?this.headers.set("Accept","application/json"):this.headers.set("Accept","application/vnd.pgrst.object+json"),this.isMaybeSingle=!0,this}csv(){return this.headers.set("Accept","text/csv"),this}geojson(){return this.headers.set("Accept","application/geo+json"),this}explain({analyze:n=!1,verbose:a=!1,settings:o=!1,buffers:i=!1,wal:h=!1,format:l="text"}={}){var c;let u=[n?"analyze":null,a?"verbose":null,o?"settings":null,i?"buffers":null,h?"wal":null].filter(Boolean).join("|"),f=(c=this.headers.get("Accept"))!==null&&c!==void 0?c:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${l}; for="${f}"; options=${u};`),l==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(n){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${n}`),this}};t.default=s}),B=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=($(),T(P)),r=e.__importDefault(Se()),s=new RegExp("[,()]"),n=class extends r.default{eq(a,o){return this.url.searchParams.append(a,`eq.${o}`),this}neq(a,o){return this.url.searchParams.append(a,`neq.${o}`),this}gt(a,o){return this.url.searchParams.append(a,`gt.${o}`),this}gte(a,o){return this.url.searchParams.append(a,`gte.${o}`),this}lt(a,o){return this.url.searchParams.append(a,`lt.${o}`),this}lte(a,o){return this.url.searchParams.append(a,`lte.${o}`),this}like(a,o){return this.url.searchParams.append(a,`like.${o}`),this}likeAllOf(a,o){return this.url.searchParams.append(a,`like(all).{${o.join(",")}}`),this}likeAnyOf(a,o){return this.url.searchParams.append(a,`like(any).{${o.join(",")}}`),this}ilike(a,o){return this.url.searchParams.append(a,`ilike.${o}`),this}ilikeAllOf(a,o){return this.url.searchParams.append(a,`ilike(all).{${o.join(",")}}`),this}ilikeAnyOf(a,o){return this.url.searchParams.append(a,`ilike(any).{${o.join(",")}}`),this}is(a,o){return this.url.searchParams.append(a,`is.${o}`),this}in(a,o){let i=Array.from(new Set(o)).map(h=>typeof h=="string"&&s.test(h)?`"${h}"`:`${h}`).join(",");return this.url.searchParams.append(a,`in.(${i})`),this}contains(a,o){return typeof o=="string"?this.url.searchParams.append(a,`cs.${o}`):Array.isArray(o)?this.url.searchParams.append(a,`cs.{${o.join(",")}}`):this.url.searchParams.append(a,`cs.${JSON.stringify(o)}`),this}containedBy(a,o){return typeof o=="string"?this.url.searchParams.append(a,`cd.${o}`):Array.isArray(o)?this.url.searchParams.append(a,`cd.{${o.join(",")}}`):this.url.searchParams.append(a,`cd.${JSON.stringify(o)}`),this}rangeGt(a,o){return this.url.searchParams.append(a,`sr.${o}`),this}rangeGte(a,o){return this.url.searchParams.append(a,`nxl.${o}`),this}rangeLt(a,o){return this.url.searchParams.append(a,`sl.${o}`),this}rangeLte(a,o){return this.url.searchParams.append(a,`nxr.${o}`),this}rangeAdjacent(a,o){return this.url.searchParams.append(a,`adj.${o}`),this}overlaps(a,o){return typeof o=="string"?this.url.searchParams.append(a,`ov.${o}`):this.url.searchParams.append(a,`ov.{${o.join(",")}}`),this}textSearch(a,o,{config:i,type:h}={}){let l="";h==="plain"?l="pl":h==="phrase"?l="ph":h==="websearch"&&(l="w");let c=i===void 0?"":`(${i})`;return this.url.searchParams.append(a,`${l}fts${c}.${o}`),this}match(a){return Object.entries(a).forEach(([o,i])=>{this.url.searchParams.append(o,`eq.${i}`)}),this}not(a,o,i){return this.url.searchParams.append(a,`not.${o}.${i}`),this}or(a,{foreignTable:o,referencedTable:i=o}={}){let h=i?`${i}.or`:"or";return this.url.searchParams.append(h,`(${a})`),this}filter(a,o,i){return this.url.searchParams.append(a,`${o}.${i}`),this}};t.default=n}),Te=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=($(),T(P)),r=e.__importDefault(B()),s=class{constructor(n,{headers:a={},schema:o,fetch:i}){this.url=n,this.headers=new Headers(a),this.schema=o,this.fetch=i}select(n,a){let{head:o=!1,count:i}=a??{},h=o?"HEAD":"GET",l=!1,c=(n??"*").split("").map(u=>/\s/.test(u)&&!l?"":(u==='"'&&(l=!l),u)).join("");return this.url.searchParams.set("select",c),i&&this.headers.append("Prefer",`count=${i}`),new r.default({method:h,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(n,{count:a,defaultToNull:o=!0}={}){var i;let h="POST";if(a&&this.headers.append("Prefer",`count=${a}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(n)){let l=n.reduce((c,u)=>c.concat(Object.keys(u)),[]);if(l.length>0){let c=[...new Set(l)].map(u=>`"${u}"`);this.url.searchParams.set("columns",c.join(","))}}return new r.default({method:h,url:this.url,headers:this.headers,schema:this.schema,body:n,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}upsert(n,{onConflict:a,ignoreDuplicates:o=!1,count:i,defaultToNull:h=!0}={}){var l;let c="POST";if(this.headers.append("Prefer",`resolution=${o?"ignore":"merge"}-duplicates`),a!==void 0&&this.url.searchParams.set("on_conflict",a),i&&this.headers.append("Prefer",`count=${i}`),h||this.headers.append("Prefer","missing=default"),Array.isArray(n)){let u=n.reduce((f,d)=>f.concat(Object.keys(d)),[]);if(u.length>0){let f=[...new Set(u)].map(d=>`"${d}"`);this.url.searchParams.set("columns",f.join(","))}}return new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:n,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}update(n,{count:a}={}){var o;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:n,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}delete({count:n}={}){var a;let o="DELETE";return n&&this.headers.append("Prefer",`count=${n}`),new r.default({method:o,url:this.url,headers:this.headers,schema:this.schema,fetch:(a=this.fetch)!==null&&a!==void 0?a:fetch})}};t.default=s}),Je=E(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=($(),T(P)),r=e.__importDefault(Te()),s=e.__importDefault(B()),n=class $e{constructor(o,{headers:i={},schema:h,fetch:l}={}){this.url=o,this.headers=new Headers(i),this.schemaName=h,this.fetch=l}from(o){let i=new URL(`${this.url}/${o}`);return new r.default(i,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(o){return new $e(this.url,{headers:this.headers,schema:o,fetch:this.fetch})}rpc(o,i={},{head:h=!1,get:l=!1,count:c}={}){var u;let f,d=new URL(`${this.url}/rpc/${o}`),p;h||l?(f=h?"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 c&&g.set("Prefer",`count=${c}`),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=n}),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(P)),r=e.__importDefault(Je());t.PostgrestClient=r.default;var s=e.__importDefault(Te());t.PostgrestQueryBuilder=s.default;var n=e.__importDefault(B());t.PostgrestFilterBuilder=n.default;var a=e.__importDefault(Se());t.PostgrestTransformBuilder=a.default;var o=e.__importDefault(Oe());t.PostgrestBuilder=o.default;var i=e.__importDefault(Pe());t.PostgrestError=i.default,t.default={PostgrestClient:r.default,PostgrestQueryBuilder:s.default,PostgrestFilterBuilder:n.default,PostgrestTransformBuilder:a.default,PostgrestBuilder:o.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",_="nvwa_login_token",O="nvwa_user_profile",Ve="set-auth-token",Qe=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??Qe,this.storage=e.storage??null,this.credentials=e.credentials??"omit",typeof console<"u"&&(console.warn("[NvwaAuth] init baseUrl:",this.baseUrl||"(empty)"),(!this.baseUrl||!this.baseUrl.startsWith("http://")&&!this.baseUrl.startsWith("https://"))&&console.warn("[NvwaAuth] baseUrl \u5E94\u4E3A\u5B8C\u6574\u5730\u5740\uFF08\u5982 https://xxx.nvwa.app\uFF09\uFF0C\u5426\u5219\u5C0F\u7A0B\u5E8F request \u4F1A\u62A5 invalid url"))}async currentUser(){if(this.storage){let r=await this.storage.get(O);if(r!=null)return r}let{data:t}=await this.getSession(),e=t?.user??null;return e&&this.storage&&await this.storage.set(O,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(_),{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(Ve)?.trim()||t.token||t.session?.token;r&&await this.storage.set(_,r),t.user&&await this.storage.set(O,t.user);let s=r??await this.storage.get(_),{data:n}=await this.getToken(s??void 0);n?.token&&await this.storage.set(w,n.token)}async clearLogin(){this.storage&&(await this.storage.remove(_),await this.storage.remove(O),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(_)??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 n=s?JSON.parse(s):void 0;return n&&await this.persistLogin({user:n.user,session:n.session},r),{data:n}}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(_)??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(_)??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 n=s?JSON.parse(s):void 0;return{data:n?.token!=null?{token:n.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 o=await this.storage.get(w);o!=null&&(r.Authorization=`Bearer ${o}`)}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})}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let a=n?JSON.parse(n):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(_,a.token),await this.storage.set(O,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 o=await this.storage.get(w);o!=null&&(r.Authorization=`Bearer ${o}`)}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})}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let a=n?JSON.parse(n):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(_,a.token),await this.storage.set(O,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 o=await this.storage.get(w);o!=null&&(e.Authorization=`Bearer ${o}`)}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}:{}}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let a=n?JSON.parse(n):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 o=await this.storage.get(w);o!=null&&(e.Authorization=`Bearer ${o}`)}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}:{}}),n=await s.text();if(!s.ok)return{error:{message:n||s.statusText,status:s.status}};let a=n?JSON.parse(n):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 n=s?JSON.parse(s):void 0;return{data:n?.data??n??void 0,response:r}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}};m();m();var b=class Ie{constructor(e){if(this.headerMap=new Map,e){if(e instanceof Ie)e.forEach((r,s)=>this.set(s,r));else if(Array.isArray(e))for(let[r,s]of e)this.set(r,String(s));else if(typeof e=="object")for(let r of Object.keys(e))this.set(r,String(e[r]))}}append(e,r){let s=e.toLowerCase(),n=this.headerMap.get(s);this.headerMap.set(s,n?`${n}, ${r}`:r)}set(e,r){this.headerMap.set(e.toLowerCase(),String(r))}get(e){return this.headerMap.get(e.toLowerCase())??null}has(e){return this.headerMap.has(e.toLowerCase())}delete(e){this.headerMap.delete(e.toLowerCase())}forEach(e){for(let[r,s]of this.headerMap.entries())e(s,r,this)}entries(){return this.headerMap.entries()}keys(){return this.headerMap.keys()}values(){return this.headerMap.values()}[Symbol.iterator](){return this.entries()}};m();m();var Ce=class{constructor(t,e){this.bodyData=t,this.status=e?.status??200,this.statusText=e?.statusText??"",this.headers=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 b(t):new b}m();m();var Le=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 b(e?.headers);r&&s.set("Authorization",`Bearer ${r}`);let n=e?.method||"GET";if((n==="POST"||n==="PUT"||n==="PATCH")&&e?.body){let o=s.get("Content-Type");(!o||o.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 b({"Content-Type":t.type||t.fileType||"application/octet-stream"})}),{url:n}=await s.json();return{url:n.split("?")[0]}}};m();m();m();var z=Ge(Ke(),1),{PostgrestClient:et,PostgrestQueryBuilder:nt,PostgrestFilterBuilder:ot,PostgrestTransformBuilder:it,PostgrestBuilder:lt,PostgrestError:ct}=z.default||z,tt="/entities",Ne=(t,e)=>new et(t+tt,{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=`
|
|
1
|
+
var Fe=Object.create,U=Object.defineProperty,De=Object.getOwnPropertyDescriptor,Be=Object.getOwnPropertyNames,Ge=Object.getPrototypeOf,qe=Object.prototype.hasOwnProperty,z=(t,e)=>()=>(t&&(e=t(t=0)),e),O=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ze=(t,e)=>{for(var r in e)U(t,r,{get:e[r],enumerable:!0})},J=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Be(e))!qe.call(t,a)&&a!==r&&U(t,a,{get:()=>e[a],enumerable:!(s=De(e,a))||s.enumerable});return t},Je=(t,e,r)=>(r=t!=null?Fe(Ge(t)):{},J(e||!t||!t.__esModule?U(r,"default",{value:t,enumerable:!0}):r,t)),T=t=>J(U({},"__esModule",{value:!0}),t),m=z(()=>{"use strict"}),P={};ze(P,{__addDisposableResource:()=>ye,__assign:()=>L,__asyncDelegator:()=>he,__asyncGenerator:()=>le,__asyncValues:()=>ue,__await:()=>S,__awaiter:()=>re,__classPrivateFieldGet:()=>fe,__classPrivateFieldIn:()=>ge,__classPrivateFieldSet:()=>me,__createBinding:()=>C,__decorate:()=>V,__disposeResources:()=>we,__esDecorate:()=>Y,__exportStar:()=>ae,__extends:()=>W,__generator:()=>se,__importDefault:()=>pe,__importStar:()=>de,__makeTemplateObject:()=>ce,__metadata:()=>te,__param:()=>Q,__propKey:()=>Z,__read:()=>D,__rest:()=>K,__rewriteRelativeImportExtension:()=>ve,__runInitializers:()=>X,__setFunctionName:()=>ee,__spread:()=>ne,__spreadArray:()=>ie,__spreadArrays:()=>oe,__values:()=>N,default:()=>Ee});function W(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");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 a=0,s=Object.getOwnPropertySymbols(t);a<s.length;a++)e.indexOf(s[a])<0&&Object.prototype.propertyIsEnumerable.call(t,s[a])&&(r[s[a]]=t[s[a]]);return r}function V(t,e,r,s){var a=arguments.length,n=a<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,r):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(t,e,r,s);else for(var i=t.length-1;i>=0;i--)(o=t[i])&&(n=(a<3?o(n):a>3?o(e,r,n):o(e,r))||n);return a>3&&n&&Object.defineProperty(e,r,n),n}function Q(t,e){return function(r,s){e(r,s,t)}}function Y(t,e,r,s,a,n){function o(y){if(y!==void 0&&typeof y!="function")throw new TypeError("Function expected");return y}for(var i=s.kind,u=i==="getter"?"get":i==="setter"?"set":"value",l=!e&&t?s.static?t:t.prototype:null,h=e||(l?Object.getOwnPropertyDescriptor(l,s.name):{}),c,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");n.push(o(y||null))};var w=(0,r[d])(i==="accessor"?{get:h.get,set:h.set}:h[u],p);if(i==="accessor"){if(w===void 0)continue;if(w===null||typeof w!="object")throw new TypeError("Object expected");(c=o(w.get))&&(h.get=c),(c=o(w.set))&&(h.set=c),(c=o(w.init))&&a.unshift(c)}else(c=o(w))&&(i==="field"?a.unshift(c):h[u]=c)}l&&Object.defineProperty(l,s.name,h),f=!0}function X(t,e,r){for(var s=arguments.length>2,a=0;a<e.length;a++)r=s?e[a].call(t,r):e[a].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 a(n){return n instanceof r?n:new r(function(o){o(n)})}return new(r||(r=Promise))(function(n,o){function i(h){try{l(s.next(h))}catch(c){o(c)}}function u(h){try{l(s.throw(h))}catch(c){o(c)}}function l(h){h.done?n(h.value):a(h.value).then(i,u)}l((s=s.apply(t,e||[])).next())})}function se(t,e){var r={label:0,sent:function(){if(n[0]&1)throw n[1];return n[1]},trys:[],ops:[]},s,a,n,o=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return o.next=i(0),o.throw=i(1),o.return=i(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function i(l){return function(h){return u([l,h])}}function u(l){if(s)throw new TypeError("Generator is already executing.");for(;o&&(o=0,l[0]&&(r=0)),r;)try{if(s=1,a&&(n=l[0]&2?a.return:l[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,l[1])).done)return n;switch(a=0,n&&(l=[l[0]&2,n.value]),l[0]){case 0:case 1:n=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,a=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(n=r.trys,!(n=n.length>0&&n[n.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!n||l[1]>n[0]&&l[1]<n[3])){r.label=l[1];break}if(l[0]===6&&r.label<n[1]){r.label=n[1],n=l;break}if(n&&r.label<n[2]){r.label=n[2],r.ops.push(l);break}n[2]&&r.ops.pop(),r.trys.pop();continue}l=e.call(t,r)}catch(h){l=[6,h],a=0}finally{s=n=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)&&C(e,t,r)}function N(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),a,n=[],o;try{for(;(e===void 0||e-- >0)&&!(a=s.next()).done;)n.push(a.value)}catch(i){o={error:i}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}return n}function ne(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(D(arguments[e]));return t}function oe(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var s=Array(t),a=0,e=0;e<r;e++)for(var n=arguments[e],o=0,i=n.length;o<i;o++,a++)s[a]=n[o];return s}function ie(t,e,r){if(r||arguments.length===2)for(var s=0,a=e.length,n;s<a;s++)(n||!(s in e))&&(n||(n=Array.prototype.slice.call(e,0,s)),n[s]=e[s]);return t.concat(n||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||[]),a,n=[];return a=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),i("next"),i("throw"),i("return",o),a[Symbol.asyncIterator]=function(){return this},a;function o(d){return function(p){return Promise.resolve(p).then(d,c)}}function i(d,p){s[d]&&(a[d]=function(g){return new Promise(function(w,y){n.push([d,g,w,y])>1||u(d,g)})},p&&(a[d]=p(a[d])))}function u(d,p){try{l(s[d](p))}catch(g){f(n[0][3],g)}}function l(d){d.value instanceof S?Promise.resolve(d.value.v).then(h,c):f(n[0][2],d)}function h(d){u("next",d)}function c(d){u("throw",d)}function f(d,p){d(p),n.shift(),n.length&&u(n[0][0],n[0][1])}}function he(t){var e,r;return e={},s("next"),s("throw",function(a){throw a}),s("return"),e[Symbol.iterator]=function(){return this},e;function s(a,n){e[a]=t[a]?function(o){return(r=!r)?{value:S(t[a](o)),done:!1}:n?n(o):o}:n}}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 N=="function"?N(t):t[Symbol.iterator](),r={},s("next"),s("throw"),s("return"),r[Symbol.asyncIterator]=function(){return this},r);function s(n){r[n]=t[n]&&function(o){return new Promise(function(i,u){o=t[n](o),a(i,u,o.done,o.value)})}}function a(n,o,i,u){Promise.resolve(u).then(function(l){n({value:l,done:i})},o)}}function ce(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=k(t),s=0;s<r.length;s++)r[s]!=="default"&&C(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,a){if(s==="m")throw new TypeError("Private method is not writable");if(s==="a"&&!a)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!a:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return s==="a"?a.call(t,r):a?a.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,a;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&&(a=s)}if(typeof s!="function")throw new TypeError("Object not disposable.");a&&(s=function(){try{a.call(this)}catch(n){return Promise.reject(n)}}),t.stack.push({value:e,dispose:s,async:r})}else r&&t.stack.push({async:!0});return e}function we(t){function e(n){t.error=t.hasError?new _e(n,t.error,"An error was suppressed during disposal."):n,t.hasError=!0}var r,s=0;function a(){for(;r=t.stack.pop();)try{if(!r.async&&s===1)return s=0,t.stack.push(r),Promise.resolve().then(a);if(r.dispose){var n=r.dispose.call(r.value);if(r.async)return s|=2,Promise.resolve(n).then(a,function(o){return e(o),a()})}else s|=1}catch(o){e(o)}if(s===1)return t.hasError?Promise.reject(t.error):Promise.resolve();if(t.hasError)throw t.error}return a()}function ve(t,e){return typeof t=="string"&&/^\.\.?\//.test(t)?t.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,function(r,s,a,n,o){return s?e?".jsx":".js":a&&(!n||!o)?r:a+n+"."+o.toLowerCase()+"js"}):t}var j,L,C,be,k,_e,Ee,$=z(()=>{"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 a in s)Object.prototype.hasOwnProperty.call(s,a)&&(r[a]=s[a])},j(t,e)},L=function(){return L=Object.assign||function(t){for(var e,r=1,s=arguments.length;r<s;r++){e=arguments[r];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a])}return t},L.apply(this,arguments)},C=Object.create?(function(t,e,r,s){s===void 0&&(s=r);var a=Object.getOwnPropertyDescriptor(e,r);(!a||("get"in a?!e.__esModule:a.writable||a.configurable))&&(a={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,s,a)}):(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},k=function(t){return k=Object.getOwnPropertyNames||function(e){var r=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[r.length]=s);return r},k(t)},_e=typeof SuppressedError=="function"?SuppressedError:function(t,e,r){var s=new Error(r);return s.name="SuppressedError",s.error=t,s.suppressed=e,s},Ee={__extends:W,__assign:L,__rest:K,__decorate:V,__param:Q,__esDecorate:Y,__runInitializers:X,__propKey:Z,__setFunctionName:ee,__metadata:te,__awaiter:re,__generator:se,__createBinding:C,__exportStar:ae,__values:N,__read:D,__spread:ne,__spreadArrays:oe,__spreadArray:ie,__await:S,__asyncGenerator:le,__asyncDelegator:he,__asyncValues:ue,__makeTemplateObject:ce,__importStar:de,__importDefault:pe,__classPrivateFieldGet:fe,__classPrivateFieldSet:me,__classPrivateFieldIn:ge,__addDisposableResource:ye,__disposeResources:we,__rewriteRelativeImportExtension:ve}}),Oe=O(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=O(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=($(),T(P)),r=e.__importDefault(Oe()),s=class{constructor(a){var n,o;this.shouldThrowOnError=!1,this.method=a.method,this.url=a.url,this.headers=new Headers(a.headers),this.schema=a.schema,this.body=a.body,this.shouldThrowOnError=(n=a.shouldThrowOnError)!==null&&n!==void 0?n:!1,this.signal=a.signal,this.isMaybeSingle=(o=a.isMaybeSingle)!==null&&o!==void 0?o:!1,a.fetch?this.fetch=a.fetch:this.fetch=fetch}throwOnError(){return this.shouldThrowOnError=!0,this}setHeader(a,n){return this.headers=new Headers(this.headers),this.headers.set(a,n),this}then(a,n){this.schema===void 0||(["GET","HEAD"].includes(this.method)?this.headers.set("Accept-Profile",this.schema):this.headers.set("Content-Profile",this.schema)),this.method!=="GET"&&this.method!=="HEAD"&&this.headers.set("Content-Type","application/json");let o=this.fetch,i=o(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async u=>{var l,h,c,f;let d=null,p=null,g=null,w=u.status,y=u.statusText;if(u.ok){if(this.method!=="HEAD"){let F=await u.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=(c=u.headers.get("content-range"))===null||c===void 0?void 0:c.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 u.text();try{d=JSON.parse(x),Array.isArray(d)&&u.status===404&&(p=[],d=null,w=200,y="OK")}catch{u.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(u=>{var l,h,c;return{error:{message:`${(l=u?.name)!==null&&l!==void 0?l:"FetchError"}: ${u?.message}`,details:`${(h=u?.stack)!==null&&h!==void 0?h:""}`,hint:"",code:`${(c=u?.code)!==null&&c!==void 0?c:""}`},data:null,count:null,status:0,statusText:""}})),i.then(a,n)}returns(){return this}overrideTypes(){return this}};t.default=s}),Se=O(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=($(),T(P)),r=e.__importDefault(Pe()),s=class extends r.default{select(a){let n=!1,o=(a??"*").split("").map(i=>/\s/.test(i)&&!n?"":(i==='"'&&(n=!n),i)).join("");return this.url.searchParams.set("select",o),this.headers.append("Prefer","return=representation"),this}order(a,{ascending:n=!0,nullsFirst:o,foreignTable:i,referencedTable:u=i}={}){let l=u?`${u}.order`:"order",h=this.url.searchParams.get(l);return this.url.searchParams.set(l,`${h?`${h},`:""}${a}.${n?"asc":"desc"}${o===void 0?"":o?".nullsfirst":".nullslast"}`),this}limit(a,{foreignTable:n,referencedTable:o=n}={}){let i=typeof o>"u"?"limit":`${o}.limit`;return this.url.searchParams.set(i,`${a}`),this}range(a,n,{foreignTable:o,referencedTable:i=o}={}){let u=typeof i>"u"?"offset":`${i}.offset`,l=typeof i>"u"?"limit":`${i}.limit`;return this.url.searchParams.set(u,`${a}`),this.url.searchParams.set(l,`${n-a+1}`),this}abortSignal(a){return this.signal=a,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:a=!1,verbose:n=!1,settings:o=!1,buffers:i=!1,wal:u=!1,format:l="text"}={}){var h;let c=[a?"analyze":null,n?"verbose":null,o?"settings":null,i?"buffers":null,u?"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=${c};`),l==="json"?this:this}rollback(){return this.headers.append("Prefer","tx=rollback"),this}returns(){return this}maxAffected(a){return this.headers.append("Prefer","handling=strict"),this.headers.append("Prefer",`max-affected=${a}`),this}};t.default=s}),B=O(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=($(),T(P)),r=e.__importDefault(Se()),s=new RegExp("[,()]"),a=class extends r.default{eq(n,o){return this.url.searchParams.append(n,`eq.${o}`),this}neq(n,o){return this.url.searchParams.append(n,`neq.${o}`),this}gt(n,o){return this.url.searchParams.append(n,`gt.${o}`),this}gte(n,o){return this.url.searchParams.append(n,`gte.${o}`),this}lt(n,o){return this.url.searchParams.append(n,`lt.${o}`),this}lte(n,o){return this.url.searchParams.append(n,`lte.${o}`),this}like(n,o){return this.url.searchParams.append(n,`like.${o}`),this}likeAllOf(n,o){return this.url.searchParams.append(n,`like(all).{${o.join(",")}}`),this}likeAnyOf(n,o){return this.url.searchParams.append(n,`like(any).{${o.join(",")}}`),this}ilike(n,o){return this.url.searchParams.append(n,`ilike.${o}`),this}ilikeAllOf(n,o){return this.url.searchParams.append(n,`ilike(all).{${o.join(",")}}`),this}ilikeAnyOf(n,o){return this.url.searchParams.append(n,`ilike(any).{${o.join(",")}}`),this}is(n,o){return this.url.searchParams.append(n,`is.${o}`),this}in(n,o){let i=Array.from(new Set(o)).map(u=>typeof u=="string"&&s.test(u)?`"${u}"`:`${u}`).join(",");return this.url.searchParams.append(n,`in.(${i})`),this}contains(n,o){return typeof o=="string"?this.url.searchParams.append(n,`cs.${o}`):Array.isArray(o)?this.url.searchParams.append(n,`cs.{${o.join(",")}}`):this.url.searchParams.append(n,`cs.${JSON.stringify(o)}`),this}containedBy(n,o){return typeof o=="string"?this.url.searchParams.append(n,`cd.${o}`):Array.isArray(o)?this.url.searchParams.append(n,`cd.{${o.join(",")}}`):this.url.searchParams.append(n,`cd.${JSON.stringify(o)}`),this}rangeGt(n,o){return this.url.searchParams.append(n,`sr.${o}`),this}rangeGte(n,o){return this.url.searchParams.append(n,`nxl.${o}`),this}rangeLt(n,o){return this.url.searchParams.append(n,`sl.${o}`),this}rangeLte(n,o){return this.url.searchParams.append(n,`nxr.${o}`),this}rangeAdjacent(n,o){return this.url.searchParams.append(n,`adj.${o}`),this}overlaps(n,o){return typeof o=="string"?this.url.searchParams.append(n,`ov.${o}`):this.url.searchParams.append(n,`ov.{${o.join(",")}}`),this}textSearch(n,o,{config:i,type:u}={}){let l="";u==="plain"?l="pl":u==="phrase"?l="ph":u==="websearch"&&(l="w");let h=i===void 0?"":`(${i})`;return this.url.searchParams.append(n,`${l}fts${h}.${o}`),this}match(n){return Object.entries(n).forEach(([o,i])=>{this.url.searchParams.append(o,`eq.${i}`)}),this}not(n,o,i){return this.url.searchParams.append(n,`not.${o}.${i}`),this}or(n,{foreignTable:o,referencedTable:i=o}={}){let u=i?`${i}.or`:"or";return this.url.searchParams.append(u,`(${n})`),this}filter(n,o,i){return this.url.searchParams.append(n,`${o}.${i}`),this}};t.default=a}),Te=O(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=($(),T(P)),r=e.__importDefault(B()),s=class{constructor(a,{headers:n={},schema:o,fetch:i}){this.url=a,this.headers=new Headers(n),this.schema=o,this.fetch=i}select(a,n){let{head:o=!1,count:i}=n??{},u=o?"HEAD":"GET",l=!1,h=(a??"*").split("").map(c=>/\s/.test(c)&&!l?"":(c==='"'&&(l=!l),c)).join("");return this.url.searchParams.set("select",h),i&&this.headers.append("Prefer",`count=${i}`),new r.default({method:u,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(a,{count:n,defaultToNull:o=!0}={}){var i;let u="POST";if(n&&this.headers.append("Prefer",`count=${n}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(a)){let l=a.reduce((h,c)=>h.concat(Object.keys(c)),[]);if(l.length>0){let h=[...new Set(l)].map(c=>`"${c}"`);this.url.searchParams.set("columns",h.join(","))}}return new r.default({method:u,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(i=this.fetch)!==null&&i!==void 0?i:fetch})}upsert(a,{onConflict:n,ignoreDuplicates:o=!1,count:i,defaultToNull:u=!0}={}){var l;let h="POST";if(this.headers.append("Prefer",`resolution=${o?"ignore":"merge"}-duplicates`),n!==void 0&&this.url.searchParams.set("on_conflict",n),i&&this.headers.append("Prefer",`count=${i}`),u||this.headers.append("Prefer","missing=default"),Array.isArray(a)){let c=a.reduce((f,d)=>f.concat(Object.keys(d)),[]);if(c.length>0){let f=[...new Set(c)].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:a,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}update(a,{count:n}={}){var o;let i="PATCH";return n&&this.headers.append("Prefer",`count=${n}`),new r.default({method:i,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(o=this.fetch)!==null&&o!==void 0?o:fetch})}delete({count:a}={}){var n;let o="DELETE";return a&&this.headers.append("Prefer",`count=${a}`),new r.default({method:o,url:this.url,headers:this.headers,schema:this.schema,fetch:(n=this.fetch)!==null&&n!==void 0?n:fetch})}};t.default=s}),We=O(t=>{"use strict";m(),Object.defineProperty(t,"__esModule",{value:!0});var e=($(),T(P)),r=e.__importDefault(Te()),s=e.__importDefault(B()),a=class $e{constructor(o,{headers:i={},schema:u,fetch:l}={}){this.url=o,this.headers=new Headers(i),this.schemaName=u,this.fetch=l}from(o){let i=new URL(`${this.url}/${o}`);return new r.default(i,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(o){return new $e(this.url,{headers:this.headers,schema:o,fetch:this.fetch})}rpc(o,i={},{head:u=!1,get:l=!1,count:h}={}){var c;let f,d=new URL(`${this.url}/rpc/${o}`),p;u||l?(f=u?"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:(c=this.fetch)!==null&&c!==void 0?c:fetch})}};t.default=a}),Ke=O(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(P)),r=e.__importDefault(We());t.PostgrestClient=r.default;var s=e.__importDefault(Te());t.PostgrestQueryBuilder=s.default;var a=e.__importDefault(B());t.PostgrestFilterBuilder=a.default;var n=e.__importDefault(Se());t.PostgrestTransformBuilder=n.default;var o=e.__importDefault(Pe());t.PostgrestBuilder=o.default;var i=e.__importDefault(Oe());t.PostgrestError=i.default,t.default={PostgrestClient:r.default,PostgrestQueryBuilder:s.default,PostgrestFilterBuilder:a.default,PostgrestTransformBuilder:n.default,PostgrestBuilder:o.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",_="nvwa_user_profile",Ve="set-auth-token",Qe=typeof fetch<"u"?(t,e)=>fetch(t,e):()=>{throw new Error("AuthClient requires fetch")},Le=class{constructor(t,e={}){this.baseUrl=t.replace(/\/$/,""),this.authPath=(e.authPath??"/auth").replace(/^\//,""),this.fetchImpl=e.fetchImpl??Qe,this.storage=e.storage??null,this.credentials=e.credentials??"omit",typeof console<"u"&&(console.warn("[NvwaAuth] init baseUrl:",this.baseUrl||"(empty)"),(!this.baseUrl||!this.baseUrl.startsWith("http://")&&!this.baseUrl.startsWith("https://"))&&console.warn("[NvwaAuth] baseUrl \u5E94\u4E3A\u5B8C\u6574\u5730\u5740\uFF08\u5982 https://xxx.nvwa.app\uFF09\uFF0C\u5426\u5219\u5C0F\u7A0B\u5E8F request \u4F1A\u62A5 invalid url"))}async currentUser(){if(this.storage){let r=await this.storage.get(_);if(r!=null)return r}let{data:t}=await this.getSession(),e=t?.user??null;return e&&this.storage&&await this.storage.set(_,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(_,t.user);let s=r??await this.storage.get(b),{data:a}=await this.getToken(s??void 0);a?.token&&await this.storage.set(v,a.token)}async clearLogin(){this.storage&&(await this.storage.remove(b),await this.storage.remove(_),await this.storage.remove(v))}getGoogleOpenPlatformLoginUrl(t){let e=new URLSearchParams({return_url:t});return`${this.url("google/openplatform/login")}?${e.toString()}`}startGoogleOpenPlatformLogin(t){let e=this.getGoogleOpenPlatformLoginUrl(t);if(typeof globalThis<"u"&&"location"in globalThis){globalThis.location.href=e;return}throw new Error("startGoogleOpenPlatformLogin requires a browser environment with location")}async completeGoogleOpenPlatformLoginFromCurrentUrl(t){let e;if(t!=null&&t!=="")e=t;else if(typeof globalThis<"u"&&"location"in globalThis)e=globalThis.location.href;else return{error:{message:"completeGoogleOpenPlatformLoginFromCurrentUrl requires url or browser location",status:0}};let r;try{r=new URL(e).searchParams.get("exchange_code")}catch{return{error:{message:"invalid_callback_url",status:400}}}return r?.trim()?await this.loginWithGoogleExchangeCode(r.trim()):{error:{message:"missing_exchange_code",status:400}}}async loginWithGoogleExchangeCode(t){try{let e={"Content-Type":"application/json"};if(this.storage){let n=await this.storage.get(v);n!=null&&(e.Authorization=`Bearer ${n}`)}let r=await this.fetchImpl(this.url("google/openplatform/sign-in"),{method:"POST",headers:e,credentials:this.credentials,body:JSON.stringify({exchangeCode:t})}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let a=s?JSON.parse(s):null;return!a?.token||!a.user?{error:{message:"invalid_google_login_response",status:502}}:(this.storage&&(await this.storage.set(v,a.token),await this.storage.set(b,a.token),await this.storage.set(_,a.user)),{data:a})}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getGoogleOpenPlatformIdentity(){try{let t={};if(this.storage){let a=await this.storage.get(v);a!=null&&(t.Authorization=`Bearer ${a}`)}let e=await this.fetchImpl(this.url("google/openplatform/identity"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}}),r=await e.text();if(!e.ok)return{error:{message:r||e.statusText,status:e.status}};let s=r?JSON.parse(r):null;return s?.sub?{data:s}:{error:{message:"invalid_google_identity_response",status:502}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}getGithubOpenPlatformLoginUrl(t){let e=new URLSearchParams({return_url:t});return`${this.url("github/openplatform/login")}?${e.toString()}`}startGithubOpenPlatformLogin(t){let e=this.getGithubOpenPlatformLoginUrl(t);if(typeof globalThis<"u"&&"location"in globalThis){globalThis.location.href=e;return}throw new Error("startGithubOpenPlatformLogin requires a browser environment with location")}async completeGithubOpenPlatformLoginFromCurrentUrl(t){let e;if(t!=null&&t!=="")e=t;else if(typeof globalThis<"u"&&"location"in globalThis)e=globalThis.location.href;else return{error:{message:"completeGithubOpenPlatformLoginFromCurrentUrl requires url or browser location",status:0}};let r;try{r=new URL(e).searchParams.get("exchange_code")}catch{return{error:{message:"invalid_callback_url",status:400}}}return r?.trim()?await this.loginWithGithubExchangeCode(r.trim()):{error:{message:"missing_exchange_code",status:400}}}async loginWithGithubExchangeCode(t){try{let e={"Content-Type":"application/json"};if(this.storage){let n=await this.storage.get(v);n!=null&&(e.Authorization=`Bearer ${n}`)}let r=await this.fetchImpl(this.url("github/openplatform/sign-in"),{method:"POST",headers:e,credentials:this.credentials,body:JSON.stringify({exchangeCode:t})}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let a=s?JSON.parse(s):null;return!a?.token||!a.user?{error:{message:"invalid_github_login_response",status:502}}:(this.storage&&(await this.storage.set(v,a.token),await this.storage.set(b,a.token),await this.storage.set(_,a.user)),{data:a})}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getGithubOpenPlatformIdentity(){try{let t={};if(this.storage){let a=await this.storage.get(v);a!=null&&(t.Authorization=`Bearer ${a}`)}let e=await this.fetchImpl(this.url("github/openplatform/identity"),{method:"GET",credentials:this.credentials,...Object.keys(t).length?{headers:t}:{}}),r=await e.text();if(!e.ok)return{error:{message:r||e.statusText,status:e.status}};let s=r?JSON.parse(r):null;return s?.sub?{data:s}:{error:{message:"invalid_github_identity_response",status:502}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}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 a=s?JSON.parse(s):void 0;return a&&await this.persistLogin({user:a.user,session:a.session},r),{data:a}}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 n=await this.storage.get(b)??await this.storage.get(v);n!=null&&(e.Authorization=`Bearer ${n}`)}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 a=s?JSON.parse(s):void 0;return{data:a?.token!=null?{token:a.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 o=await this.storage.get(v);o!=null&&(r.Authorization=`Bearer ${o}`)}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})}),a=await s.text();if(!s.ok)return{error:{message:a||s.statusText,status:s.status}};let n=a?JSON.parse(a):null;return!n?.token||!n.user?{error:{message:"invalid_wechat_login_response",status:502}}:(this.storage&&(await this.storage.set(v,n.token),await this.storage.set(b,n.token),await this.storage.set(_,n.user)),{data:n})}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 o=await this.storage.get(v);o!=null&&(r.Authorization=`Bearer ${o}`)}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})}),a=await s.text();if(!s.ok)return{error:{message:a||s.statusText,status:s.status}};let n=a?JSON.parse(a):null;return!n?.token||!n.user?{error:{message:"invalid_alipay_login_response",status:502}}:(this.storage&&(await this.storage.set(v,n.token),await this.storage.set(b,n.token),await this.storage.set(_,n.user)),{data:n})}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async getWeChatOpenPlatformIdentity(t){try{let e={};if(this.storage){let o=await this.storage.get(v);o!=null&&(e.Authorization=`Bearer ${o}`)}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}:{}}),a=await s.text();if(!s.ok)return{error:{message:a||s.statusText,status:s.status}};let n=a?JSON.parse(a):null;return!n?.openid||!n.appId?{error:{message:"invalid_wechat_identity_response",status:502}}:{data:n}}catch(e){return{error:{message:e instanceof Error?e.message:String(e),status:0}}}}async getAlipayOpenPlatformIdentity(t){try{let e={};if(this.storage){let o=await this.storage.get(v);o!=null&&(e.Authorization=`Bearer ${o}`)}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}:{}}),a=await s.text();if(!s.ok)return{error:{message:a||s.statusText,status:s.status}};let n=a?JSON.parse(a):null;return!n?.openid||!n.appId?{error:{message:"invalid_alipay_identity_response",status:502}}:{data:n}}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 a=s?JSON.parse(s):void 0;return{data:a?.data??a??void 0,response:r}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}};m();m();var E=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(),a=this.headerMap.get(s);this.headerMap.set(s,a?`${a}, ${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=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 E(t):new E}m();m();var Ae=class{constructor(t,e,r){this.storage=t,this.customFetch=e,this.handleUnauthorized=r}async fetch(t,e){return await this.customFetch(t,e)}async fetchWithAuth(t,e){let r=await this.storage.get(v),s=new E(e?.headers);r&&s.set("Authorization",`Bearer ${r}`);let a=e?.method||"GET";if((a==="POST"||a==="PUT"||a==="PATCH")&&e?.body){let o=s.get("Content-Type");(!o||o.includes("text/plain"))&&s.set("Content-Type","application/json")}let n=await this.customFetch(t,{...e,headers:s});if(n.status===401)throw this.handleUnauthorized(),new Error("\u672A\u767B\u5F55");return n}};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 E({"Content-Type":t.type||t.fileType||"application/octet-stream"})}),{url:a}=await s.json();return{url:a.split("?")[0]}}};m();m();m();var q=Je(Ke(),1),{PostgrestClient:et,PostgrestQueryBuilder:nt,PostgrestFilterBuilder:ot,PostgrestTransformBuilder:it,PostgrestBuilder:lt,PostgrestError:ht}=q.default||q,tt="/entities",ke=(t,e)=>new et(t+tt,{fetch:e.fetchWithAuth.bind(e)});m();var Ne=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,n=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(t.style.left=`${r.left+s}px`,t.style.top=`${r.top+n}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 o=this.createTooltip();e?o.textContent=e:o.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,o.style.display="block";let i=t.getBoundingClientRect();o.style.left=`${i.left+window.scrollX}px`,o.style.top=`${i.top+window.scrollY-o.offsetHeight-8}px`,i.top<o.offsetHeight+8&&(o.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 n=this.createTooltip();e?n.textContent=e:n.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,n.style.display="block";let a=t.getBoundingClientRect();n.style.left=`${a.left+window.scrollX}px`,n.style.top=`${a.top+window.scrollY-n.offsetHeight-8}px`,a.top<n.offsetHeight+8&&(n.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 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 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();function He(t){let e=t;if(typeof e.kind=="string")return e;if(typeof e.tradeNO=="string")return{kind:"alipay_miniprogram",tradeNO:e.tradeNO};if(typeof e.clientSecret=="string")return{kind:"stripe_client_secret",clientSecret:e.clientSecret};if(typeof e.redirectUrl=="string")return{kind:"redirect_url",redirectUrl:e.redirectUrl};if(typeof e.formHtml=="string")return{kind:"alipay_page",formHtml:e.formHtml};if(typeof e.codeUrl=="string")return{kind:"wechat_native_qr",codeUrl:e.codeUrl};let r=e.jsapiPayParams??e;return typeof r.timeStamp=="string"&&typeof r.nonceStr=="string"&&typeof r.package=="string"&&typeof r.paySign=="string"&&typeof r.appId=="string"?{kind:"wechat_jsapi",mode:"jsapi",jsapiPayParams:{appId:r.appId,timeStamp:r.timeStamp,nonceStr:r.nonceStr,package:r.package,signType:r.signType??"RSA",paySign:r.paySign}}:null}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 n=JSON.parse(s);return n.expires&&Date.now()>n.expires?(await this.remove(e),null):n.value}catch(r){return console.error("WebStorageService get error:",r),null}}async set(e,r,s){try{let n=this.getKey(e),a={value:r,expires:s?Date.now()+s*1e3:null,timestamp:Date.now()};localStorage.setItem(n,JSON.stringify(a))}catch(n){throw console.error("WebStorageService set error:",n),n}}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 b){let o={};a.forEach((i,h)=>{o[h]=i}),s=o}else if(Array.isArray(a)){let o=[];for(let i of a)Array.isArray(i)&&i.length>=2&&o.push([String(i[0]),String(i[1])]);s=o}else typeof a=="object"&&(s=a)}let n={method:e?.method||"GET",headers:s,body:e?.body,credentials:e?.credentials};return e?.signal&&(n.signal=e.signal),globalThis.fetch(r,n).then(async a=>{let o=a.headers.get("content-type")||"",i;if(o.includes("application/json"))i=await a.json();else{let l=await a.text();try{i=JSON.parse(l)}catch{i=l}}let h=new b;return a.headers.forEach((l,c)=>{h.set(c,l)}),new Ce(i,{status:a.status,statusText:a.statusText,headers:h})})},U=rt;function st(t){return`https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(t)}`}var Ue={async requestPayment(t,e){let r=He(t);if(r?.kind==="redirect_url"){window.location.href=r.redirectUrl;return}if(r?.kind==="wechat_native_qr"){let n=st(r.codeUrl);window.open(n,"_blank","noopener,noreferrer");return}if(r?.kind==="alipay_page"){let n=window.open("","_blank");n&&(n.document.write(r.formHtml),n.document.close());return}let s=new Error("requestPayment: unsupported payParams for Desktop-web");throw e?.onFailure?.(s),s}};function Ht(){if(typeof window>"u"||window===window.parent)return;let t=!1,e=new ke;function r(l){if(!l)return!1;let c=l.toLowerCase();return c.includes("/components/")||c.includes("\\components\\")}function s(l){let c=l,u=null;for(;c;){let f=c.getAttribute("data-source-location");if(f)if(r(f)){u||(u=f),c=c.parentElement;continue}else return f;c=c.parentElement}return u}let n=null;function a(l){t&&(n!==null&&cancelAnimationFrame(n),n=requestAnimationFrame(()=>{let c=l.target;if(!c||c===document.body||c===document.documentElement){e.removeHighlight();return}if(c.tagName.toLowerCase()==="img"){let p=s(c);e.highlightElement(c,p);let g={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:p,elementInfo:{tagName:c.tagName.toLowerCase(),className:c.className||"",id:c.id||""}};window.parent.postMessage(g,"*");return}let u=c,f=s(c);if(!f){let p=c.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 o(){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 c=l.target;if(!c||c===document.body||c===document.documentElement)return;let u=s(c);e.selectElement(c,u);let f={type:"HOVER_INSPECTOR_ELEMENT_SELECT",sourceLocation:u,elementInfo:{tagName:c.tagName.toLowerCase(),className:c.className||"",id:c.id||""}};window.parent.postMessage(f,"*")}function h(l){l.data?.type==="HOVER_INSPECTOR_ENABLE"?(t=!0,document.addEventListener("mousemove",a),document.addEventListener("mouseleave",o),document.addEventListener("click",i,!0)):l.data?.type==="HOVER_INSPECTOR_DISABLE"&&(t=!1,document.removeEventListener("mousemove",a),document.removeEventListener("mouseleave",o),document.removeEventListener("click",i,!0),e.removeHighlight(),e.clearSelection())}return window.addEventListener("message",h),()=>{window.removeEventListener("message",h),document.removeEventListener("mousemove",a),document.removeEventListener("mouseleave",o),document.removeEventListener("click",i,!0),e.cleanup()}}function Ut(t,e){if(!t||!t.contentWindow)throw new Error("Invalid iframe element");let r={type:"HOVER_INSPECTOR_ENABLE"};t.contentWindow.postMessage(r,e)}function Mt(t,e){if(!t||!t.contentWindow)return;let r={type:"HOVER_INSPECTOR_DISABLE"};t.contentWindow.postMessage(r,e)}function Ft(t,e,r=5e3){return new Promise((s,n)=>{if(!t||!t.contentWindow){n(new Error("Invalid iframe element"));return}let a=`source-location-${Date.now()}-${Math.random()}`,o=setTimeout(()=>{window.removeEventListener("message",i),n(new Error("Request timeout"))},r),i=l=>{l.origin===e&&l.data?.type==="GET_SOURCE_LOCATION_RESPONSE"&&l.data?.requestId===a&&(clearTimeout(o),window.removeEventListener("message",i),l.data.error?n(new Error(l.data.error)):s(l.data.sourceLocation||null))};window.addEventListener("message",i);let h={type:"GET_SOURCE_LOCATION_REQUEST",requestId:a};try{t.contentWindow.postMessage(h,e)}catch(l){clearTimeout(o),window.removeEventListener("message",i),n(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:at(),requestId:e.data.requestId};window.parent.postMessage(s,e.origin)}catch(r){let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:null,error:r instanceof Error?r.message:"Unknown error",requestId:e.data.requestId};window.parent.postMessage(s,e.origin)}};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}}function at(){return Re("root")}var Me=new H,q=class{constructor(e,r){this.endpointType="Desktop-web";this.payment=Ue;this.auth=new Ae(e,{fetchImpl:U,storage:Me}),this.httpClient=new Le(Me,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,Mt as disableIframeHoverInspector,Ut as enableIframeHoverInspector,Ft as getIframeSourceLocation,Me as localStorage,Ht as setupIframeHoverInspector,Dt 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(),s=window.scrollX||window.pageXOffset,a=window.scrollY||window.pageYOffset;r.width>0&&r.height>0?(t.style.left=`${r.left+s}px`,t.style.top=`${r.top+a}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 o=this.createTooltip();e?o.textContent=e:o.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,o.style.display="block";let i=t.getBoundingClientRect();o.style.left=`${i.left+window.scrollX}px`,o.style.top=`${i.top+window.scrollY-o.offsetHeight-8}px`,i.top<o.offsetHeight+8&&(o.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 a=this.createTooltip();e?a.textContent=e:a.textContent=`<${t.tagName.toLowerCase()}> (\u65E0 source location)`,a.style.display="block";let n=t.getBoundingClientRect();a.style.left=`${n.left+window.scrollX}px`,a.style.top=`${n.top+window.scrollY-a.offsetHeight-8}px`,n.top<a.offsetHeight+8&&(a.style.top=`${n.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();function Re(t){let e=t;if(typeof e.kind=="string")return e;if(typeof e.tradeNO=="string")return{kind:"alipay_miniprogram",tradeNO:e.tradeNO};if(typeof e.clientSecret=="string")return{kind:"stripe_client_secret",clientSecret:e.clientSecret};if(typeof e.redirectUrl=="string")return{kind:"redirect_url",redirectUrl:e.redirectUrl};if(typeof e.formHtml=="string")return{kind:"alipay_page",formHtml:e.formHtml};if(typeof e.codeUrl=="string")return{kind:"wechat_native_qr",codeUrl:e.codeUrl};let r=e.jsapiPayParams??e;return typeof r.timeStamp=="string"&&typeof r.nonceStr=="string"&&typeof r.package=="string"&&typeof r.paySign=="string"&&typeof r.appId=="string"?{kind:"wechat_jsapi",mode:"jsapi",jsapiPayParams:{appId:r.appId,timeStamp:r.timeStamp,nonceStr:r.nonceStr,package:r.package,signType:r.signType??"RSA",paySign:r.paySign}}:null}var R=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 a=JSON.parse(s);return a.expires&&Date.now()>a.expires?(await this.remove(e),null):a.value}catch(r){return console.error("WebStorageService get error:",r),null}}async set(e,r,s){try{let a=this.getKey(e),n={value:r,expires:s?Date.now()+s*1e3:null,timestamp:Date.now()};localStorage.setItem(a,JSON.stringify(n))}catch(a){throw console.error("WebStorageService set error:",a),a}}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 n=e.headers;if(n instanceof E){let o={};n.forEach((i,u)=>{o[u]=i}),s=o}else if(Array.isArray(n)){let o=[];for(let i of n)Array.isArray(i)&&i.length>=2&&o.push([String(i[0]),String(i[1])]);s=o}else typeof n=="object"&&(s=n)}let a={method:e?.method||"GET",headers:s,body:e?.body,credentials:e?.credentials};return e?.signal&&(a.signal=e.signal),globalThis.fetch(r,a).then(async n=>{let o=n.headers.get("content-type")||"",i;if(o.includes("application/json"))i=await n.json();else{let l=await n.text();try{i=JSON.parse(l)}catch{i=l}}let u=new E;return n.headers.forEach((l,h)=>{u.set(h,l)}),new Ie(i,{status:n.status,statusText:n.statusText,headers:u})})},H=rt;function st(t){return`https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(t)}`}var He={async requestPayment(t,e){let r=Re(t);if(r?.kind==="redirect_url"){window.location.href=r.redirectUrl;return}if(r?.kind==="wechat_native_qr"){let a=st(r.codeUrl);window.open(a,"_blank","noopener,noreferrer");return}if(r?.kind==="alipay_page"){let a=window.open("","_blank");a&&(a.document.write(r.formHtml),a.document.close());return}let s=new Error("requestPayment: unsupported payParams for Desktop-web");throw e?.onFailure?.(s),s}};function Rt(){if(typeof window>"u"||window===window.parent)return;let t=!1,e=new Ne;function r(l){if(!l)return!1;let h=l.toLowerCase();return h.includes("/components/")||h.includes("\\components\\")}function s(l){let h=l,c=null;for(;h;){let f=h.getAttribute("data-source-location");if(f)if(r(f)){c||(c=f),h=h.parentElement;continue}else return f;h=h.parentElement}return c}let a=null;function n(l){t&&(a!==null&&cancelAnimationFrame(a),a=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 c=h,f=s(h);if(!f){let p=h.parentElement;for(;p&&p!==document.body&&p!==document.documentElement;){let g=s(p);if(g){c=p,f=g;break}p=p.parentElement}}e.highlightElement(c,f);let d={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:f,elementInfo:{tagName:c.tagName.toLowerCase(),className:c.className||"",id:c.id||""}};window.parent.postMessage(d,"*")}))}function o(){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 c=s(h);e.selectElement(h,c);let f={type:"HOVER_INSPECTOR_ELEMENT_SELECT",sourceLocation:c,elementInfo:{tagName:h.tagName.toLowerCase(),className:h.className||"",id:h.id||""}};window.parent.postMessage(f,"*")}function u(l){l.data?.type==="HOVER_INSPECTOR_ENABLE"?(t=!0,document.addEventListener("mousemove",n),document.addEventListener("mouseleave",o),document.addEventListener("click",i,!0)):l.data?.type==="HOVER_INSPECTOR_DISABLE"&&(t=!1,document.removeEventListener("mousemove",n),document.removeEventListener("mouseleave",o),document.removeEventListener("click",i,!0),e.removeHighlight(),e.clearSelection())}return window.addEventListener("message",u),()=>{window.removeEventListener("message",u),document.removeEventListener("mousemove",n),document.removeEventListener("mouseleave",o),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 Mt(t,e){if(!t||!t.contentWindow)return;let r={type:"HOVER_INSPECTOR_DISABLE"};t.contentWindow.postMessage(r,e)}function Ft(t,e,r=5e3){return new Promise((s,a)=>{if(!t||!t.contentWindow){a(new Error("Invalid iframe element"));return}let n=`source-location-${Date.now()}-${Math.random()}`,o=setTimeout(()=>{window.removeEventListener("message",i),a(new Error("Request timeout"))},r),i=l=>{l.origin===e&&l.data?.type==="GET_SOURCE_LOCATION_RESPONSE"&&l.data?.requestId===n&&(clearTimeout(o),window.removeEventListener("message",i),l.data.error?a(new Error(l.data.error)):s(l.data.sourceLocation||null))};window.addEventListener("message",i);let u={type:"GET_SOURCE_LOCATION_REQUEST",requestId:n};try{t.contentWindow.postMessage(u,e)}catch(l){clearTimeout(o),window.removeEventListener("message",i),a(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:at(),requestId:e.data.requestId};window.parent.postMessage(s,e.origin)}catch(r){let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:null,error:r instanceof Error?r.message:"Unknown error",requestId:e.data.requestId};window.parent.postMessage(s,e.origin)}};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}}function at(){return Ue("root")}var Me=new R,G=class{constructor(e,r){this.endpointType="Desktop-web";this.payment=He;this.auth=new Le(e,{fetchImpl:H,storage:Me}),this.httpClient=new Ae(Me,H,r),this.fileStorage=new je(e,this.httpClient),this.entities=ke(e,this.httpClient),this.functions=new xe(this.httpClient,e)}};export{G as default,Mt as disableIframeHoverInspector,Ht as enableIframeHoverInspector,Ft as getIframeSourceLocation,Me as localStorage,Rt as setupIframeHoverInspector,Dt as setupIframeSourceLocationListener,H as webFetch};
|