@nvwa-app/sdk-uniapp 6.0.43 → 6.0.45
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 B=Object.defineProperty;var Ke=Object.getOwnPropertyDescriptor;var Ve=Object.getOwnPropertyNames;var Ye=Object.prototype.hasOwnProperty;var Qe=(t,e)=>{for(var r in e)B(t,r,{get:e[r],enumerable:!0})},Xe=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Ve(e))!Ye.call(t,a)&&a!==r&&B(t,a,{get:()=>e[a],enumerable:!(s=Ke(e,a))||s.enumerable});return t};var Ze=t=>Xe(B({},"__esModule",{value:!0}),t);var St={};Qe(St,{default:()=>F,disableIframeHoverInspector:()=>Et,enableIframeHoverInspector:()=>bt,getIframeSourceLocation:()=>_t,localStorage:()=>J,polyfill:()=>He,setupIframeHoverInspector:()=>wt,setupIframeSourceLocationListener:()=>Pt,uniappFetch:()=>C});module.exports=Ze(St);var et=Object.create,M=Object.defineProperty,tt=Object.getOwnPropertyDescriptor,rt=Object.getOwnPropertyNames,st=Object.getPrototypeOf,at=Object.prototype.hasOwnProperty,V=(t,e)=>()=>(t&&(e=t(t=0)),e),S=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),nt=(t,e)=>{for(var r in e)M(t,r,{get:e[r],enumerable:!0})},Y=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of rt(e))!at.call(t,a)&&a!==r&&M(t,a,{get:()=>e[a],enumerable:!(s=tt(e,a))||s.enumerable});return t},ot=(t,e,r)=>(r=t!=null?et(st(t)):{},Y(e||!t||!t.__esModule?M(r,"default",{value:t,enumerable:!0}):r,t)),L=t=>Y(M({},"__esModule",{value:!0}),t),g=V(()=>{"use strict"}),T={};nt(T,{__addDisposableResource:()=>Ee,__assign:()=>N,__asyncDelegator:()=>pe,__asyncGenerator:()=>de,__asyncValues:()=>fe,__await:()=>$,__awaiter:()=>oe,__classPrivateFieldGet:()=>ve,__classPrivateFieldIn:()=>be,__classPrivateFieldSet:()=>we,__createBinding:()=>j,__decorate:()=>Z,__disposeResources:()=>_e,__esDecorate:()=>te,__exportStar:()=>le,__extends:()=>Q,__generator:()=>ie,__importDefault:()=>ge,__importStar:()=>ye,__makeTemplateObject:()=>me,__metadata:()=>ne,__param:()=>ee,__propKey:()=>se,__read:()=>W,__rest:()=>X,__rewriteRelativeImportExtension:()=>Pe,__runInitializers:()=>re,__setFunctionName:()=>ae,__spread:()=>ue,__spreadArray:()=>he,__spreadArrays:()=>ce,__values:()=>k,default:()=>Te});function Q(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");U(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function X(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 Z(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 l=t.length-1;l>=0;l--)(o=t[l])&&(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 ee(t,e){return function(r,s){e(r,s,t)}}function te(t,e,r,s,a,n){function o(v){if(v!==void 0&&typeof v!="function")throw new TypeError("Function expected");return v}for(var l=s.kind,c=l==="getter"?"get":l==="setter"?"set":"value",i=!e&&t?s.static?t:t.prototype:null,u=e||(i?Object.getOwnPropertyDescriptor(i,s.name):{}),h,f=!1,d=r.length-1;d>=0;d--){var p={};for(var m in s)p[m]=m==="access"?{}:s[m];for(var m in s.access)p.access[m]=s.access[m];p.addInitializer=function(v){if(f)throw new TypeError("Cannot add initializers after decoration has completed");n.push(o(v||null))};var y=(0,r[d])(l==="accessor"?{get:u.get,set:u.set}:u[c],p);if(l==="accessor"){if(y===void 0)continue;if(y===null||typeof y!="object")throw new TypeError("Object expected");(h=o(y.get))&&(u.get=h),(h=o(y.set))&&(u.set=h),(h=o(y.init))&&a.unshift(h)}else(h=o(y))&&(l==="field"?a.unshift(h):u[c]=h)}i&&Object.defineProperty(i,s.name,u),f=!0}function re(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 se(t){return typeof t=="symbol"?t:"".concat(t)}function ae(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 ne(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function oe(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 l(u){try{i(s.next(u))}catch(h){o(h)}}function c(u){try{i(s.throw(u))}catch(h){o(h)}}function i(u){u.done?n(u.value):a(u.value).then(l,c)}i((s=s.apply(t,e||[])).next())})}function ie(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=l(0),o.throw=l(1),o.return=l(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function l(i){return function(u){return c([i,u])}}function c(i){if(s)throw new TypeError("Generator is already executing.");for(;o&&(o=0,i[0]&&(r=0)),r;)try{if(s=1,a&&(n=i[0]&2?a.return:i[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,i[1])).done)return n;switch(a=0,n&&(i=[i[0]&2,n.value]),i[0]){case 0:case 1:n=i;break;case 4:return r.label++,{value:i[1],done:!1};case 5:r.label++,a=i[1],i=[0];continue;case 7:i=r.ops.pop(),r.trys.pop();continue;default:if(n=r.trys,!(n=n.length>0&&n[n.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!n||i[1]>n[0]&&i[1]<n[3])){r.label=i[1];break}if(i[0]===6&&r.label<n[1]){r.label=n[1],n=i;break}if(n&&r.label<n[2]){r.label=n[2],r.ops.push(i);break}n[2]&&r.ops.pop(),r.trys.pop();continue}i=e.call(t,r)}catch(u){i=[6,u],a=0}finally{s=n=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}function le(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&j(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 W(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(l){o={error:l}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}return n}function ue(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(W(arguments[e]));return t}function ce(){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,l=n.length;o<l;o++,a++)s[a]=n[o];return s}function he(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 $(t){return this instanceof $?(this.v=t,this):new $(t)}function de(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),l("next"),l("throw"),l("return",o),a[Symbol.asyncIterator]=function(){return this},a;function o(d){return function(p){return Promise.resolve(p).then(d,h)}}function l(d,p){s[d]&&(a[d]=function(m){return new Promise(function(y,v){n.push([d,m,y,v])>1||c(d,m)})},p&&(a[d]=p(a[d])))}function c(d,p){try{i(s[d](p))}catch(m){f(n[0][3],m)}}function i(d){d.value instanceof $?Promise.resolve(d.value.v).then(u,h):f(n[0][2],d)}function u(d){c("next",d)}function h(d){c("throw",d)}function f(d,p){d(p),n.shift(),n.length&&c(n[0][0],n[0][1])}}function pe(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:$(t[a](o)),done:!1}:n?n(o):o}:n}}function fe(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(n){r[n]=t[n]&&function(o){return new Promise(function(l,c){o=t[n](o),a(l,c,o.done,o.value)})}}function a(n,o,l,c){Promise.resolve(c).then(function(i){n({value:i,done:l})},o)}}function me(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function ye(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r=R(t),s=0;s<r.length;s++)r[s]!=="default"&&j(e,t,r[s]);return Oe(e,t),e}function ge(t){return t&&t.__esModule?t:{default:t}}function ve(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 we(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 be(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 Ee(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 _e(t){function e(n){t.error=t.hasError?new Se(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 Pe(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 U,N,j,Oe,R,Se,Te,A=V(()=>{"use strict";g(),U=function(t,e){return U=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])},U(t,e)},N=function(){return N=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},N.apply(this,arguments)},j=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]}),Oe=Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e},R=function(t){return R=Object.getOwnPropertyNames||function(e){var r=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[r.length]=s);return r},R(t)},Se=typeof SuppressedError=="function"?SuppressedError:function(t,e,r){var s=new Error(r);return s.name="SuppressedError",s.error=t,s.suppressed=e,s},Te={__extends:Q,__assign:N,__rest:X,__decorate:Z,__param:ee,__esDecorate:te,__runInitializers:re,__propKey:se,__setFunctionName:ae,__metadata:ne,__awaiter:oe,__generator:ie,__createBinding:j,__exportStar:le,__values:k,__read:W,__spread:ue,__spreadArrays:ce,__spreadArray:he,__await:$,__asyncGenerator:de,__asyncDelegator:pe,__asyncValues:fe,__makeTemplateObject:me,__importStar:ye,__importDefault:ge,__classPrivateFieldGet:ve,__classPrivateFieldSet:we,__classPrivateFieldIn:be,__addDisposableResource:Ee,__disposeResources:_e,__rewriteRelativeImportExtension:Pe}}),$e=S(t=>{"use strict";g(),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}),xe=S(t=>{"use strict";g(),Object.defineProperty(t,"__esModule",{value:!0});var e=(A(),L(T)),r=e.__importDefault($e()),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,l=o(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async c=>{var i,u,h,f;let d=null,p=null,m=null,y=c.status,v=c.statusText;if(c.ok){if(this.method!=="HEAD"){let D=await c.text();D===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&!((i=this.headers.get("Accept"))===null||i===void 0)&&i.includes("application/vnd.pgrst.plan+text")?p=D:p=JSON.parse(D))}let E=(u=this.headers.get("Prefer"))===null||u===void 0?void 0:u.match(/count=(exact|planned|estimated)/),P=(h=c.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");E&&P&&P.length>1&&(m=parseInt(P[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,m=null,y=406,v="Not Acceptable"):p.length===1?p=p[0]:p=null)}else{let E=await c.text();try{d=JSON.parse(E),Array.isArray(d)&&c.status===404&&(p=[],d=null,y=200,v="OK")}catch{c.status===404&&E===""?(y=204,v="No Content"):d={message:E}}if(d&&this.isMaybeSingle&&!((f=d?.details)===null||f===void 0)&&f.includes("0 rows")&&(d=null,y=200,v="OK"),d&&this.shouldThrowOnError)throw new r.default(d)}return{error:d,data:p,count:m,status:y,statusText:v}});return this.shouldThrowOnError||(l=l.catch(c=>{var i,u,h;return{error:{message:`${(i=c?.name)!==null&&i!==void 0?i:"FetchError"}: ${c?.message}`,details:`${(u=c?.stack)!==null&&u!==void 0?u:""}`,hint:"",code:`${(h=c?.code)!==null&&h!==void 0?h:""}`},data:null,count:null,status:0,statusText:""}})),l.then(a,n)}returns(){return this}overrideTypes(){return this}};t.default=s}),Le=S(t=>{"use strict";g(),Object.defineProperty(t,"__esModule",{value:!0});var e=(A(),L(T)),r=e.__importDefault(xe()),s=class extends r.default{select(a){let n=!1,o=(a??"*").split("").map(l=>/\s/.test(l)&&!n?"":(l==='"'&&(n=!n),l)).join("");return this.url.searchParams.set("select",o),this.headers.append("Prefer","return=representation"),this}order(a,{ascending:n=!0,nullsFirst:o,foreignTable:l,referencedTable:c=l}={}){let i=c?`${c}.order`:"order",u=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${u?`${u},`:""}${a}.${n?"asc":"desc"}${o===void 0?"":o?".nullsfirst":".nullslast"}`),this}limit(a,{foreignTable:n,referencedTable:o=n}={}){let l=typeof o>"u"?"limit":`${o}.limit`;return this.url.searchParams.set(l,`${a}`),this}range(a,n,{foreignTable:o,referencedTable:l=o}={}){let c=typeof l>"u"?"offset":`${l}.offset`,i=typeof l>"u"?"limit":`${l}.limit`;return this.url.searchParams.set(c,`${a}`),this.url.searchParams.set(i,`${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:l=!1,wal:c=!1,format:i="text"}={}){var u;let h=[a?"analyze":null,n?"verbose":null,o?"settings":null,l?"buffers":null,c?"wal":null].filter(Boolean).join("|"),f=(u=this.headers.get("Accept"))!==null&&u!==void 0?u:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${f}"; options=${h};`),i==="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}),z=S(t=>{"use strict";g(),Object.defineProperty(t,"__esModule",{value:!0});var e=(A(),L(T)),r=e.__importDefault(Le()),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 l=Array.from(new Set(o)).map(c=>typeof c=="string"&&s.test(c)?`"${c}"`:`${c}`).join(",");return this.url.searchParams.append(n,`in.(${l})`),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:l,type:c}={}){let i="";c==="plain"?i="pl":c==="phrase"?i="ph":c==="websearch"&&(i="w");let u=l===void 0?"":`(${l})`;return this.url.searchParams.append(n,`${i}fts${u}.${o}`),this}match(n){return Object.entries(n).forEach(([o,l])=>{this.url.searchParams.append(o,`eq.${l}`)}),this}not(n,o,l){return this.url.searchParams.append(n,`not.${o}.${l}`),this}or(n,{foreignTable:o,referencedTable:l=o}={}){let c=l?`${l}.or`:"or";return this.url.searchParams.append(c,`(${n})`),this}filter(n,o,l){return this.url.searchParams.append(n,`${o}.${l}`),this}};t.default=a}),Ae=S(t=>{"use strict";g(),Object.defineProperty(t,"__esModule",{value:!0});var e=(A(),L(T)),r=e.__importDefault(z()),s=class{constructor(a,{headers:n={},schema:o,fetch:l}){this.url=a,this.headers=new Headers(n),this.schema=o,this.fetch=l}select(a,n){let{head:o=!1,count:l}=n??{},c=o?"HEAD":"GET",i=!1,u=(a??"*").split("").map(h=>/\s/.test(h)&&!i?"":(h==='"'&&(i=!i),h)).join("");return this.url.searchParams.set("select",u),l&&this.headers.append("Prefer",`count=${l}`),new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(a,{count:n,defaultToNull:o=!0}={}){var l;let c="POST";if(n&&this.headers.append("Prefer",`count=${n}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(a)){let i=a.reduce((u,h)=>u.concat(Object.keys(h)),[]);if(i.length>0){let u=[...new Set(i)].map(h=>`"${h}"`);this.url.searchParams.set("columns",u.join(","))}}return new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}upsert(a,{onConflict:n,ignoreDuplicates:o=!1,count:l,defaultToNull:c=!0}={}){var i;let u="POST";if(this.headers.append("Prefer",`resolution=${o?"ignore":"merge"}-duplicates`),n!==void 0&&this.url.searchParams.set("on_conflict",n),l&&this.headers.append("Prefer",`count=${l}`),c||this.headers.append("Prefer","missing=default"),Array.isArray(a)){let h=a.reduce((f,d)=>f.concat(Object.keys(d)),[]);if(h.length>0){let f=[...new Set(h)].map(d=>`"${d}"`);this.url.searchParams.set("columns",f.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})}update(a,{count:n}={}){var o;let l="PATCH";return n&&this.headers.append("Prefer",`count=${n}`),new r.default({method:l,url:this.url,headers:this.headers,schema:this.schema,body: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}),it=S(t=>{"use strict";g(),Object.defineProperty(t,"__esModule",{value:!0});var e=(A(),L(T)),r=e.__importDefault(Ae()),s=e.__importDefault(z()),a=class Ce{constructor(o,{headers:l={},schema:c,fetch:i}={}){this.url=o,this.headers=new Headers(l),this.schemaName=c,this.fetch=i}from(o){let l=new URL(`${this.url}/${o}`);return new r.default(l,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(o){return new Ce(this.url,{headers:this.headers,schema:o,fetch:this.fetch})}rpc(o,l={},{head:c=!1,get:i=!1,count:u}={}){var h;let f,d=new URL(`${this.url}/rpc/${o}`),p;c||i?(f=c?"HEAD":"GET",Object.entries(l).filter(([y,v])=>v!==void 0).map(([y,v])=>[y,Array.isArray(v)?`{${v.join(",")}}`:`${v}`]).forEach(([y,v])=>{d.searchParams.append(y,v)})):(f="POST",p=l);let m=new Headers(this.headers);return u&&m.set("Prefer",`count=${u}`),new s.default({method:f,url:d,headers:m,schema:this.schemaName,body:p,fetch:(h=this.fetch)!==null&&h!==void 0?h:fetch})}};t.default=a}),lt=S(t=>{"use strict";g(),Object.defineProperty(t,"__esModule",{value:!0}),t.PostgrestError=t.PostgrestBuilder=t.PostgrestTransformBuilder=t.PostgrestFilterBuilder=t.PostgrestQueryBuilder=t.PostgrestClient=void 0;var e=(A(),L(T)),r=e.__importDefault(it());t.PostgrestClient=r.default;var s=e.__importDefault(Ae());t.PostgrestQueryBuilder=s.default;var a=e.__importDefault(z());t.PostgrestFilterBuilder=a.default;var n=e.__importDefault(Le());t.PostgrestTransformBuilder=n.default;var o=e.__importDefault(xe());t.PostgrestBuilder=o.default;var l=e.__importDefault($e());t.PostgrestError=l.default,t.default={PostgrestClient:r.default,PostgrestQueryBuilder:s.default,PostgrestFilterBuilder:a.default,PostgrestTransformBuilder:n.default,PostgrestBuilder:o.default,PostgrestError:l.default}});g();g();var Ne=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()}};g();g();var _="nvwa_current_jwt",O="nvwa_login_token",I="nvwa_user_profile",ut="set-auth-token",ct=typeof fetch<"u"?(t,e)=>fetch(t,e):()=>{throw new Error("AuthClient requires fetch")},je=class{constructor(t,e={}){this.baseUrl=t.replace(/\/$/,""),this.authPath=(e.authPath??"/auth").replace(/^\//,""),this.fetchImpl=e.fetchImpl??ct,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(I);if(r!=null)return r}let{data:t}=await this.getSession(),e=t?.user??null;return e&&this.storage&&await this.storage.set(I,e),e}async getCurrentJwt(){if(this.storage){let e=await this.storage.get(_);if(e!=null)return e;let r=await this.storage.get(O),{data:s}=await this.getToken(r??void 0);return s?.token?(await this.storage.set(_,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(ut)?.trim()||t.token||t.session?.token;r&&await this.storage.set(O,r),t.user&&await this.storage.set(I,t.user);let s=r??await this.storage.get(O),{data:a}=await this.getToken(s??void 0);a?.token&&await this.storage.set(_,a.token)}async clearLogin(){this.storage&&(await this.storage.remove(O),await this.storage.remove(I),await this.storage.remove(_))}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 getSocialProviders(){try{let t=await this.fetchImpl(this.url("social/providers"),{method:"GET",credentials:this.credentials});return t.ok?{data:await t.json()}:{error:{message:await t.text()||t.statusText,status:t.status}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}getSocialLoginUrl(t,e={}){let r=this.url("social/start"),s=new URL(r);s.searchParams.set("provider",t);let a=e.includeCurrentUrl??!0,n=e.returnTo??(a?this.getCurrentUrl():void 0);return n&&s.searchParams.set("returnTo",n),s.toString()}getCurrentUrl(){let t=globalThis.location;if(!(!t||typeof t.href!="string"))return t.href}async getSession(){try{let t={};if(this.storage){let r=await this.storage.get(O)??await this.storage.get(_);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(O)??await this.storage.get(_);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(O)??await this.storage.get(_);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 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}}}}};g();g();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(),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()}},Ue=class Re{constructor(e){if(this.params=new Map,e){if(typeof e=="string")this.parseString(e);else if(e instanceof Re)this.params=new Map(e.params);else if(Array.isArray(e))for(let[r,s]of e)this.append(r,s);else if(e&&typeof e=="object")for(let[r,s]of Object.entries(e))this.set(r,s)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let r=e.split("&");for(let s of r)if(s){let[a,n]=s.split("=");a&&this.append(decodeURIComponent(a),n?decodeURIComponent(n):"")}}append(e,r){let s=this.params.get(e)||[];s.push(r),this.params.set(e,s)}delete(e){this.params.delete(e)}get(e){let r=this.params.get(e);return r?r[0]:null}getAll(e){return this.params.get(e)||[]}has(e){return this.params.has(e)}set(e,r){this.params.set(e,[r])}sort(){let e=Array.from(this.params.entries()).sort(([r],[s])=>r.localeCompare(s));this.params=new Map(e)}toString(){let e=[];for(let[r,s]of this.params.entries())for(let a of s)e.push(`${encodeURIComponent(r)}=${encodeURIComponent(a)}`);return e.join("&")}forEach(e){for(let[r,s]of this.params.entries())for(let a of s)e(a,r,this)}keys(){return this.params.keys()}values(){let e=[];for(let r of this.params.values())e.push(...r);return e[Symbol.iterator]()}entries(){let e=[];for(let[r,s]of this.params.entries())for(let a of s)e.push([r,a]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},ht=class q{constructor(e,r){let s;if(e instanceof q)s=e.href;else if(r){let n=r instanceof q?r.href:r;s=this.resolve(n,e)}else s=e;let a=this.parseUrl(s);this.href=s,this.origin=`${a.protocol}//${a.host}`,this.protocol=a.protocol,this.username=a.username,this.password=a.password,this.host=a.host,this.hostname=a.hostname,this.port=a.port,this.pathname=a.pathname,this.search=a.search,this.searchParams=new Ue(a.search),this.hash=a.hash}resolve(e,r){if(r.startsWith("http://")||r.startsWith("https://"))return r;if(r.startsWith("//"))return`${this.parseUrl(e).protocol}${r}`;if(r.startsWith("/")){let n=this.parseUrl(e);return`${n.protocol}//${n.host}${r}`}let s=this.parseUrl(e),a=s.pathname.endsWith("/")?s.pathname:s.pathname+"/";return`${s.protocol}//${s.host}${a}${r}`}parseUrl(e){let r=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!r)throw new TypeError("Invalid URL");let s=r[2]||"",a=r[4]||"",n=r[5]||"/",o=r[7]?`?${r[7]}`:"",l=r[9]?`#${r[9]}`:"";if(!s&&!a&&!n.startsWith("/")&&!n.includes("/")&&!n.includes("."))throw new TypeError("Invalid URL");let c=a.match(/^([^@]*)@(.+)$/),i="",u="",h=a;if(c){let m=c[1];h=c[2];let y=m.match(/^([^:]*):?(.*)$/);y&&(i=y[1]||"",u=y[2]||"")}let f=h.match(/^([^:]+):?(\d*)$/),d=f?f[1]:h,p=f&&f[2]?f[2]:"";return{protocol:s?`${s}:`:"",username:i,password:u,host:h,hostname:d,port:p,pathname:n,search:o,hash:l}}toString(){let e=this.searchParams.toString(),r=e?`?${e}`:"";return`${this.protocol}//${this.host}${this.pathname}${r}${this.hash}`}toJSON(){return this.toString()}};g();var dt=class ke{constructor(e,r){if(typeof e=="string")this.url=e;else if(e?.url)this.url=String(e.url);else if(typeof e?.toString=="function")this.url=String(e.toString());else throw new Error("Invalid input for Request");this.method=(r?.method||"GET").toUpperCase(),this.headers=r?.headers instanceof b?r.headers:new b(r?.headers),this.body=r?.body,this.timeout=r?.timeout,this.signal=r?.signal||void 0}clone(){return new ke(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};g();var G=class{constructor(t,e){this.bodyData=t,this.status=e?.status??200,this.statusText=e?.statusText??"",this.headers=pt(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 pt(t){return t?new b(t):new b}g();var Me=class{constructor(){this._aborted=!1,this.listeners=new Set,this.onabort=null}get aborted(){return this._aborted}_trigger(){if(!this._aborted){if(this._aborted=!0,typeof this.onabort=="function")try{this.onabort()}catch{}for(let t of Array.from(this.listeners))try{t()}catch{}this.listeners.clear()}}addEventListener(t,e){if(this._aborted){try{e()}catch{}return}this.listeners.add(e)}removeEventListener(t,e){this.listeners.delete(e)}toString(){return"[object AbortSignal]"}},ft=class{constructor(){this._signal=new Me}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};g();function He(t){t.URL=ht,t.URLSearchParams=Ue,t.Headers=b,t.Request=dt,t.Response=G,t.AbortController=ft,t.AbortSignal=Me}var Fe=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(_),s=new b(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}};g();var mt="/storage",yt=mt+"/generateUploadUrl",De=class{constructor(t,e){this.baseUrl=t,this.http=e}async uploadFile(t){let e=await this.http.fetch(this.baseUrl+yt,{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:a}=await s.json();return{url:a.split("?")[0]}}};g();g();g();var K=ot(lt(),1),{PostgrestClient:gt,PostgrestQueryBuilder:$t,PostgrestFilterBuilder:xt,PostgrestTransformBuilder:Lt,PostgrestBuilder:At,PostgrestError:Ct}=K.default||K,vt="/entities",Be=(t,e)=>new gt(t+vt,{fetch:e.fetchWithAuth.bind(e)});g();var qe=class{constructor(t,e){this.baseUrl=t,this.http=e}async execute(t,e){let r=`${this.baseUrl}/capability/${t}/execute`,s=await(await this.http.fetchWithAuth(r,{method:"POST",body:e?JSON.stringify(e):void 0,timeout:6e5})).json();if(s.status!==200)throw new Error(s.message);return s.data}};g();var We=class{constructor(t,e){this.baseUrl=t,this.http=e}async execute(t,e){let r=`${this.baseUrl}/capability/${t}/execute`,s=await(await this.http.fetchWithAuth(r,{method:"POST",body:e!=null?JSON.stringify(e):void 0,timeout:6e5})).json();if(s.status!==200)throw new Error(s.message);return s.data}};g();var ze=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 Ke=Object.getOwnPropertyDescriptor;var Ve=Object.getOwnPropertyNames;var Ye=Object.prototype.hasOwnProperty;var Qe=(t,e)=>{for(var r in e)D(t,r,{get:e[r],enumerable:!0})},Xe=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Ve(e))!Ye.call(t,a)&&a!==r&&D(t,a,{get:()=>e[a],enumerable:!(s=Ke(e,a))||s.enumerable});return t};var Ze=t=>Xe(D({},"__esModule",{value:!0}),t);var Tt={};Qe(Tt,{default:()=>F,disableIframeHoverInspector:()=>_t,enableIframeHoverInspector:()=>Et,getIframeSourceLocation:()=>Pt,localStorage:()=>J,polyfill:()=>He,setupIframeHoverInspector:()=>bt,setupIframeSourceLocationListener:()=>Ot,uniappFetch:()=>C});module.exports=Ze(Tt);var et=Object.create,M=Object.defineProperty,tt=Object.getOwnPropertyDescriptor,rt=Object.getOwnPropertyNames,st=Object.getPrototypeOf,at=Object.prototype.hasOwnProperty,V=(t,e)=>()=>(t&&(e=t(t=0)),e),S=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),nt=(t,e)=>{for(var r in e)M(t,r,{get:e[r],enumerable:!0})},Y=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of rt(e))!at.call(t,a)&&a!==r&&M(t,a,{get:()=>e[a],enumerable:!(s=tt(e,a))||s.enumerable});return t},ot=(t,e,r)=>(r=t!=null?et(st(t)):{},Y(e||!t||!t.__esModule?M(r,"default",{value:t,enumerable:!0}):r,t)),L=t=>Y(M({},"__esModule",{value:!0}),t),g=V(()=>{"use strict"}),T={};nt(T,{__addDisposableResource:()=>Ee,__assign:()=>j,__asyncDelegator:()=>pe,__asyncGenerator:()=>de,__asyncValues:()=>fe,__await:()=>$,__awaiter:()=>oe,__classPrivateFieldGet:()=>ve,__classPrivateFieldIn:()=>be,__classPrivateFieldSet:()=>we,__createBinding:()=>N,__decorate:()=>Z,__disposeResources:()=>_e,__esDecorate:()=>te,__exportStar:()=>le,__extends:()=>Q,__generator:()=>ie,__importDefault:()=>ge,__importStar:()=>ye,__makeTemplateObject:()=>me,__metadata:()=>ne,__param:()=>ee,__propKey:()=>se,__read:()=>W,__rest:()=>X,__rewriteRelativeImportExtension:()=>Pe,__runInitializers:()=>re,__setFunctionName:()=>ae,__spread:()=>ue,__spreadArray:()=>he,__spreadArrays:()=>ce,__values:()=>R,default:()=>Te});function Q(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");k(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function X(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 Z(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 ee(t,e){return function(r,s){e(r,s,t)}}function te(t,e,r,s,a,n){function o(v){if(v!==void 0&&typeof v!="function")throw new TypeError("Function expected");return v}for(var i=s.kind,c=i==="getter"?"get":i==="setter"?"set":"value",l=!e&&t?s.static?t:t.prototype:null,u=e||(l?Object.getOwnPropertyDescriptor(l,s.name):{}),h,f=!1,d=r.length-1;d>=0;d--){var p={};for(var m in s)p[m]=m==="access"?{}:s[m];for(var m in s.access)p.access[m]=s.access[m];p.addInitializer=function(v){if(f)throw new TypeError("Cannot add initializers after decoration has completed");n.push(o(v||null))};var y=(0,r[d])(i==="accessor"?{get:u.get,set:u.set}:u[c],p);if(i==="accessor"){if(y===void 0)continue;if(y===null||typeof y!="object")throw new TypeError("Object expected");(h=o(y.get))&&(u.get=h),(h=o(y.set))&&(u.set=h),(h=o(y.init))&&a.unshift(h)}else(h=o(y))&&(i==="field"?a.unshift(h):u[c]=h)}l&&Object.defineProperty(l,s.name,u),f=!0}function re(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 se(t){return typeof t=="symbol"?t:"".concat(t)}function ae(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 ne(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function oe(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(u){try{l(s.next(u))}catch(h){o(h)}}function c(u){try{l(s.throw(u))}catch(h){o(h)}}function l(u){u.done?n(u.value):a(u.value).then(i,c)}l((s=s.apply(t,e||[])).next())})}function ie(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(u){return c([l,u])}}function c(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(u){l=[6,u],a=0}finally{s=n=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function le(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&N(e,t,r)}function R(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 W(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 ue(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(W(arguments[e]));return t}function ce(){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 he(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 $(t){return this instanceof $?(this.v=t,this):new $(t)}function de(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,h)}}function i(d,p){s[d]&&(a[d]=function(m){return new Promise(function(y,v){n.push([d,m,y,v])>1||c(d,m)})},p&&(a[d]=p(a[d])))}function c(d,p){try{l(s[d](p))}catch(m){f(n[0][3],m)}}function l(d){d.value instanceof $?Promise.resolve(d.value.v).then(u,h):f(n[0][2],d)}function u(d){c("next",d)}function h(d){c("throw",d)}function f(d,p){d(p),n.shift(),n.length&&c(n[0][0],n[0][1])}}function pe(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:$(t[a](o)),done:!1}:n?n(o):o}:n}}function fe(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 R=="function"?R(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,c){o=t[n](o),a(i,c,o.done,o.value)})}}function a(n,o,i,c){Promise.resolve(c).then(function(l){n({value:l,done:i})},o)}}function me(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function ye(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r=U(t),s=0;s<r.length;s++)r[s]!=="default"&&N(e,t,r[s]);return Oe(e,t),e}function ge(t){return t&&t.__esModule?t:{default:t}}function ve(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 we(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 be(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 Ee(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 _e(t){function e(n){t.error=t.hasError?new Se(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 Pe(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 k,j,N,Oe,U,Se,Te,A=V(()=>{"use strict";g(),k=function(t,e){return k=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])},k(t,e)},j=function(){return j=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},j.apply(this,arguments)},N=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]}),Oe=Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e},U=function(t){return U=Object.getOwnPropertyNames||function(e){var r=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[r.length]=s);return r},U(t)},Se=typeof SuppressedError=="function"?SuppressedError:function(t,e,r){var s=new Error(r);return s.name="SuppressedError",s.error=t,s.suppressed=e,s},Te={__extends:Q,__assign:j,__rest:X,__decorate:Z,__param:ee,__esDecorate:te,__runInitializers:re,__propKey:se,__setFunctionName:ae,__metadata:ne,__awaiter:oe,__generator:ie,__createBinding:N,__exportStar:le,__values:R,__read:W,__spread:ue,__spreadArrays:ce,__spreadArray:he,__await:$,__asyncGenerator:de,__asyncDelegator:pe,__asyncValues:fe,__makeTemplateObject:me,__importStar:ye,__importDefault:ge,__classPrivateFieldGet:ve,__classPrivateFieldSet:we,__classPrivateFieldIn:be,__addDisposableResource:Ee,__disposeResources:_e,__rewriteRelativeImportExtension:Pe}}),$e=S(t=>{"use strict";g(),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}),xe=S(t=>{"use strict";g(),Object.defineProperty(t,"__esModule",{value:!0});var e=(A(),L(T)),r=e.__importDefault($e()),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 c=>{var l,u,h,f;let d=null,p=null,m=null,y=c.status,v=c.statusText;if(c.ok){if(this.method!=="HEAD"){let B=await c.text();B===""||(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=B:p=JSON.parse(B))}let E=(u=this.headers.get("Prefer"))===null||u===void 0?void 0:u.match(/count=(exact|planned|estimated)/),P=(h=c.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");E&&P&&P.length>1&&(m=parseInt(P[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,m=null,y=406,v="Not Acceptable"):p.length===1?p=p[0]:p=null)}else{let E=await c.text();try{d=JSON.parse(E),Array.isArray(d)&&c.status===404&&(p=[],d=null,y=200,v="OK")}catch{c.status===404&&E===""?(y=204,v="No Content"):d={message:E}}if(d&&this.isMaybeSingle&&!((f=d?.details)===null||f===void 0)&&f.includes("0 rows")&&(d=null,y=200,v="OK"),d&&this.shouldThrowOnError)throw new r.default(d)}return{error:d,data:p,count:m,status:y,statusText:v}});return this.shouldThrowOnError||(i=i.catch(c=>{var l,u,h;return{error:{message:`${(l=c?.name)!==null&&l!==void 0?l:"FetchError"}: ${c?.message}`,details:`${(u=c?.stack)!==null&&u!==void 0?u:""}`,hint:"",code:`${(h=c?.code)!==null&&h!==void 0?h:""}`},data:null,count:null,status:0,statusText:""}})),i.then(a,n)}returns(){return this}overrideTypes(){return this}};t.default=s}),Le=S(t=>{"use strict";g(),Object.defineProperty(t,"__esModule",{value:!0});var e=(A(),L(T)),r=e.__importDefault(xe()),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:c=i}={}){let l=c?`${c}.order`:"order",u=this.url.searchParams.get(l);return this.url.searchParams.set(l,`${u?`${u},`:""}${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 c=typeof i>"u"?"offset":`${i}.offset`,l=typeof i>"u"?"limit":`${i}.limit`;return this.url.searchParams.set(c,`${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:c=!1,format:l="text"}={}){var u;let h=[a?"analyze":null,n?"verbose":null,o?"settings":null,i?"buffers":null,c?"wal":null].filter(Boolean).join("|"),f=(u=this.headers.get("Accept"))!==null&&u!==void 0?u:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${l}; for="${f}"; options=${h};`),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}),z=S(t=>{"use strict";g(),Object.defineProperty(t,"__esModule",{value:!0});var e=(A(),L(T)),r=e.__importDefault(Le()),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(c=>typeof c=="string"&&s.test(c)?`"${c}"`:`${c}`).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:c}={}){let l="";c==="plain"?l="pl":c==="phrase"?l="ph":c==="websearch"&&(l="w");let u=i===void 0?"":`(${i})`;return this.url.searchParams.append(n,`${l}fts${u}.${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 c=i?`${i}.or`:"or";return this.url.searchParams.append(c,`(${n})`),this}filter(n,o,i){return this.url.searchParams.append(n,`${o}.${i}`),this}};t.default=a}),Ae=S(t=>{"use strict";g(),Object.defineProperty(t,"__esModule",{value:!0});var e=(A(),L(T)),r=e.__importDefault(z()),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??{},c=o?"HEAD":"GET",l=!1,u=(a??"*").split("").map(h=>/\s/.test(h)&&!l?"":(h==='"'&&(l=!l),h)).join("");return this.url.searchParams.set("select",u),i&&this.headers.append("Prefer",`count=${i}`),new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(a,{count:n,defaultToNull:o=!0}={}){var i;let c="POST";if(n&&this.headers.append("Prefer",`count=${n}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(a)){let l=a.reduce((u,h)=>u.concat(Object.keys(h)),[]);if(l.length>0){let u=[...new Set(l)].map(h=>`"${h}"`);this.url.searchParams.set("columns",u.join(","))}}return new r.default({method:c,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:c=!0}={}){var l;let u="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}`),c||this.headers.append("Prefer","missing=default"),Array.isArray(a)){let h=a.reduce((f,d)=>f.concat(Object.keys(d)),[]);if(h.length>0){let f=[...new Set(h)].map(d=>`"${d}"`);this.url.searchParams.set("columns",f.join(","))}}return new r.default({method:u,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}),it=S(t=>{"use strict";g(),Object.defineProperty(t,"__esModule",{value:!0});var e=(A(),L(T)),r=e.__importDefault(Ae()),s=e.__importDefault(z()),a=class Ce{constructor(o,{headers:i={},schema:c,fetch:l}={}){this.url=o,this.headers=new Headers(i),this.schemaName=c,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 Ce(this.url,{headers:this.headers,schema:o,fetch:this.fetch})}rpc(o,i={},{head:c=!1,get:l=!1,count:u}={}){var h;let f,d=new URL(`${this.url}/rpc/${o}`),p;c||l?(f=c?"HEAD":"GET",Object.entries(i).filter(([y,v])=>v!==void 0).map(([y,v])=>[y,Array.isArray(v)?`{${v.join(",")}}`:`${v}`]).forEach(([y,v])=>{d.searchParams.append(y,v)})):(f="POST",p=i);let m=new Headers(this.headers);return u&&m.set("Prefer",`count=${u}`),new s.default({method:f,url:d,headers:m,schema:this.schemaName,body:p,fetch:(h=this.fetch)!==null&&h!==void 0?h:fetch})}};t.default=a}),lt=S(t=>{"use strict";g(),Object.defineProperty(t,"__esModule",{value:!0}),t.PostgrestError=t.PostgrestBuilder=t.PostgrestTransformBuilder=t.PostgrestFilterBuilder=t.PostgrestQueryBuilder=t.PostgrestClient=void 0;var e=(A(),L(T)),r=e.__importDefault(it());t.PostgrestClient=r.default;var s=e.__importDefault(Ae());t.PostgrestQueryBuilder=s.default;var a=e.__importDefault(z());t.PostgrestFilterBuilder=a.default;var n=e.__importDefault(Le());t.PostgrestTransformBuilder=n.default;var o=e.__importDefault(xe());t.PostgrestBuilder=o.default;var i=e.__importDefault($e());t.PostgrestError=i.default,t.default={PostgrestClient:r.default,PostgrestQueryBuilder:s.default,PostgrestFilterBuilder:a.default,PostgrestTransformBuilder:n.default,PostgrestBuilder:o.default,PostgrestError:i.default}});g();g();var je=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()}};g();g();var _="nvwa_current_jwt",O="nvwa_login_token",I="nvwa_user_profile",ut="set-auth-token",ct=typeof fetch<"u"?(t,e)=>fetch(t,e):()=>{throw new Error("AuthClient requires fetch")},Ne=class{constructor(t,e={}){this.authBaseUrl=ht(e.authBaseUrl??t).replace(/\/$/,""),this.authPath=(e.authPath??"/auth").replace(/^\//,""),this.fetchImpl=e.fetchImpl??ct,this.storage=e.storage??null,this.credentials=e.credentials??"omit",typeof console<"u"&&(console.warn("[NvwaAuth] init authBaseUrl:",this.authBaseUrl||"(empty)"),(!this.authBaseUrl||!this.authBaseUrl.startsWith("http://")&&!this.authBaseUrl.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(I);if(r!=null)return r}let{data:t}=await this.getSession(),e=t?.user??null;return e&&this.storage&&await this.storage.set(I,e),e}async getCurrentJwt(){if(this.storage){let e=await this.storage.get(_);if(e!=null)return e;let r=await this.storage.get(O),{data:s}=await this.getToken(r??void 0);return s?.token?(await this.storage.set(_,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(ut)?.trim()||t.token||t.session?.token;r&&await this.storage.set(O,r),t.user&&await this.storage.set(I,t.user);let s=r??await this.storage.get(O),{data:a}=await this.getToken(s??void 0);a?.token&&await this.storage.set(_,a.token)}async clearLogin(){this.storage&&(await this.storage.remove(O),await this.storage.remove(I),await this.storage.remove(_))}url(t){let e=`${`${this.authBaseUrl.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 getSocialProviders(){try{let t=await this.fetchImpl(this.url("social/providers"),{method:"GET",credentials:this.credentials});return t.ok?{data:await t.json()}:{error:{message:await t.text()||t.statusText,status:t.status}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}getSocialLoginUrl(t,e={}){let r=this.url("social/start"),s=new URL(r);s.searchParams.set("provider",t);let a=e.includeCurrentUrl??!0,n=e.returnTo??(a?this.getCurrentUrl():void 0);return n&&s.searchParams.set("returnTo",n),s.toString()}getCurrentUrl(){let t=globalThis.location;if(!(!t||typeof t.href!="string"))return t.href}shouldBootstrapFromCookie(t,e){return t||e==="include"?!1:this.getCurrentUrl()!=null}async getSession(){try{let t={};if(this.storage){let r=await this.storage.get(O)??await this.storage.get(_);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(O)??await this.storage.get(_);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,e={}){try{let r={};if(t)r.Authorization=`Bearer ${t}`;else if(this.storage){let i=await this.storage.get(O)??await this.storage.get(_);i!=null&&(r.Authorization=`Bearer ${i}`)}let s=e.credentialsOverride??this.credentials,a=await this.fetchImpl(this.url("token"),{method:"GET",credentials:s,...Object.keys(r).length?{headers:r}:{}}),n=await a.text();if(!a.ok)return e.allowCookieBootstrap!==!1&&this.shouldBootstrapFromCookie(!!r.Authorization,s)?await this.getToken(void 0,{credentialsOverride:"include",allowCookieBootstrap:!1}):{error:{message:n||a.statusText,status:a.status}};let o=n?JSON.parse(n):void 0;return o?.token!=null?{data:{token:o.token}}:e.allowCookieBootstrap!==!1&&this.shouldBootstrapFromCookie(!!r.Authorization,s)?await this.getToken(void 0,{credentialsOverride:"include",allowCookieBootstrap:!1}):{data:void 0}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async signInWithUsername(t,e){let r=await this.postJson("sign-in/username",{username:t,password:e});return r.data&&await this.persistLogin(r.data,r.response),r}async signInWithPhoneNumber(t,e,r){let s=await this.postJson("sign-in/phone-number",{phoneNumber:t,password:e,rememberMe:r});return s.data&&await this.persistLogin(s.data,s.response),s}async sendPhoneNumberOtp(t){let e=await this.postJson("phone-number/send-otp",{phoneNumber:t});return e.error?{error:e.error}:{}}async verifyPhoneNumber(t,e){let r=await this.postJson("phone-number/verify",{phoneNumber:t,code:e});return r.data&&await this.persistLogin(r.data,r.response),r}async postJson(t,e){try{let r=await this.fetchImpl(this.url(t),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify(e)}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let 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}}}}};function ht(t){let e=t.replace(/\/$/,"");try{let r=new URL(e),s=r.hostname.split(".");if(s.length<2)return r.origin;let a=s[0],n=a.lastIndexOf("-");if(n<=0||n>=a.length-1)return r.origin;let o=a.slice(n+1);if(!/^[a-z0-9]{8,}$/i.test(o))return r.origin;let i=s.slice(1).join(".");return r.hostname=`${o}.${i}`,r.origin}catch{return e}}g();g();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(),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()}},ke=class Ue{constructor(e){if(this.params=new Map,e){if(typeof e=="string")this.parseString(e);else if(e instanceof Ue)this.params=new Map(e.params);else if(Array.isArray(e))for(let[r,s]of e)this.append(r,s);else if(e&&typeof e=="object")for(let[r,s]of Object.entries(e))this.set(r,s)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let r=e.split("&");for(let s of r)if(s){let[a,n]=s.split("=");a&&this.append(decodeURIComponent(a),n?decodeURIComponent(n):"")}}append(e,r){let s=this.params.get(e)||[];s.push(r),this.params.set(e,s)}delete(e){this.params.delete(e)}get(e){let r=this.params.get(e);return r?r[0]:null}getAll(e){return this.params.get(e)||[]}has(e){return this.params.has(e)}set(e,r){this.params.set(e,[r])}sort(){let e=Array.from(this.params.entries()).sort(([r],[s])=>r.localeCompare(s));this.params=new Map(e)}toString(){let e=[];for(let[r,s]of this.params.entries())for(let a of s)e.push(`${encodeURIComponent(r)}=${encodeURIComponent(a)}`);return e.join("&")}forEach(e){for(let[r,s]of this.params.entries())for(let a of s)e(a,r,this)}keys(){return this.params.keys()}values(){let e=[];for(let r of this.params.values())e.push(...r);return e[Symbol.iterator]()}entries(){let e=[];for(let[r,s]of this.params.entries())for(let a of s)e.push([r,a]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},dt=class q{constructor(e,r){let s;if(e instanceof q)s=e.href;else if(r){let n=r instanceof q?r.href:r;s=this.resolve(n,e)}else s=e;let a=this.parseUrl(s);this.href=s,this.origin=`${a.protocol}//${a.host}`,this.protocol=a.protocol,this.username=a.username,this.password=a.password,this.host=a.host,this.hostname=a.hostname,this.port=a.port,this.pathname=a.pathname,this.search=a.search,this.searchParams=new ke(a.search),this.hash=a.hash}resolve(e,r){if(r.startsWith("http://")||r.startsWith("https://"))return r;if(r.startsWith("//"))return`${this.parseUrl(e).protocol}${r}`;if(r.startsWith("/")){let n=this.parseUrl(e);return`${n.protocol}//${n.host}${r}`}let s=this.parseUrl(e),a=s.pathname.endsWith("/")?s.pathname:s.pathname+"/";return`${s.protocol}//${s.host}${a}${r}`}parseUrl(e){let r=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!r)throw new TypeError("Invalid URL");let s=r[2]||"",a=r[4]||"",n=r[5]||"/",o=r[7]?`?${r[7]}`:"",i=r[9]?`#${r[9]}`:"";if(!s&&!a&&!n.startsWith("/")&&!n.includes("/")&&!n.includes("."))throw new TypeError("Invalid URL");let c=a.match(/^([^@]*)@(.+)$/),l="",u="",h=a;if(c){let m=c[1];h=c[2];let y=m.match(/^([^:]*):?(.*)$/);y&&(l=y[1]||"",u=y[2]||"")}let f=h.match(/^([^:]+):?(\d*)$/),d=f?f[1]:h,p=f&&f[2]?f[2]:"";return{protocol:s?`${s}:`:"",username:l,password:u,host:h,hostname:d,port:p,pathname:n,search:o,hash:i}}toString(){let e=this.searchParams.toString(),r=e?`?${e}`:"";return`${this.protocol}//${this.host}${this.pathname}${r}${this.hash}`}toJSON(){return this.toString()}};g();var pt=class Re{constructor(e,r){if(typeof e=="string")this.url=e;else if(e?.url)this.url=String(e.url);else if(typeof e?.toString=="function")this.url=String(e.toString());else throw new Error("Invalid input for Request");this.method=(r?.method||"GET").toUpperCase(),this.headers=r?.headers instanceof b?r.headers:new b(r?.headers),this.body=r?.body,this.timeout=r?.timeout,this.signal=r?.signal||void 0}clone(){return new Re(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};g();var G=class{constructor(t,e){this.bodyData=t,this.status=e?.status??200,this.statusText=e?.statusText??"",this.headers=ft(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 ft(t){return t?new b(t):new b}g();var Me=class{constructor(){this._aborted=!1,this.listeners=new Set,this.onabort=null}get aborted(){return this._aborted}_trigger(){if(!this._aborted){if(this._aborted=!0,typeof this.onabort=="function")try{this.onabort()}catch{}for(let t of Array.from(this.listeners))try{t()}catch{}this.listeners.clear()}}addEventListener(t,e){if(this._aborted){try{e()}catch{}return}this.listeners.add(e)}removeEventListener(t,e){this.listeners.delete(e)}toString(){return"[object AbortSignal]"}},mt=class{constructor(){this._signal=new Me}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};g();function He(t){t.URL=dt,t.URLSearchParams=ke,t.Headers=b,t.Request=pt,t.Response=G,t.AbortController=mt,t.AbortSignal=Me}var Fe=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(_),s=new b(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}};g();var yt="/storage",gt=yt+"/generateUploadUrl",Be=class{constructor(t,e){this.baseUrl=t,this.http=e}async uploadFile(t){let e=await this.http.fetch(this.baseUrl+gt,{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:a}=await s.json();return{url:a.split("?")[0]}}};g();g();g();var K=ot(lt(),1),{PostgrestClient:vt,PostgrestQueryBuilder:xt,PostgrestFilterBuilder:Lt,PostgrestTransformBuilder:At,PostgrestBuilder:Ct,PostgrestError:jt}=K.default||K,wt="/entities",De=(t,e)=>new vt(t+wt,{fetch:e.fetchWithAuth.bind(e)});g();var qe=class{constructor(t,e){this.baseUrl=t,this.http=e}async execute(t,e){let r=`${this.baseUrl}/capability/${t}/execute`,s=await(await this.http.fetchWithAuth(r,{method:"POST",body:e?JSON.stringify(e):void 0,timeout:6e5})).json();if(s.status!==200)throw new Error(s.message);return s.data}};g();var We=class{constructor(t,e){this.baseUrl=t,this.http=e}async execute(t,e){let r=`${this.baseUrl}/capability/${t}/execute`,s=await(await this.http.fetchWithAuth(r,{method:"POST",body:e!=null?JSON.stringify(e):void 0,timeout:6e5})).json();if(s.status!==200)throw new Error(s.message);return s.data}};g();var ze=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,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 l=t.getBoundingClientRect();o.style.left=`${l.left+window.scrollX}px`,o.style.top=`${l.top+window.scrollY-o.offsetHeight-8}px`,l.top<o.offsetHeight+8&&(o.style.top=`${l.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 Ge(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}g();var H=class{constructor(){this.prefix="nvwa_"}getKey(e){return`${this.prefix}${e}`}async get(e){try{let r=this.getKey(e),s=uni.getStorageSync(r);return s?s.expires&&Date.now()>s.expires?(await this.remove(e),null):s.value:null}catch(r){return console.error("UniAppStorageService 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()};uni.setStorageSync(a,n)}catch(a){throw console.error("UniAppStorageService set error:",a),a}}async remove(e){try{let r=this.getKey(e);uni.removeStorageSync(r)}catch(r){throw console.error("UniAppStorageService remove error:",r),r}}async clear(){try{uni.clearStorageSync()}catch(e){throw console.error("UniAppStorageService clear error:",e),e}}};var C=(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 uniappFetch");typeof console<"u"&&(console.warn("[NvwaUni] request url:",r,"method:",(e?.method||"GET").toUpperCase()),!r.startsWith("http://")&&!r.startsWith("https://")&&console.warn("[NvwaUni] url \u975E\u5B8C\u6574\u5730\u5740\uFF0C\u5C0F\u7A0B\u5E8F uni.request \u4F1A\u62A5 invalid url\uFF0C\u8BF7\u68C0\u67E5 baseUrl \u662F\u5426\u4F20\u5165\u5B8C\u6574\u57DF\u540D"));let s=(e?.method||"GET").toUpperCase(),a={};if(e?.headers){let l=e.headers;if(typeof l?.forEach=="function")l.forEach((c,i)=>{a[i]=c});else if(Array.isArray(l))for(let[c,i]of l)a[c]=i;else Object.assign(a,l)}let n;if(e?.body!==void 0){let l=e.body;if(typeof l=="string")n=l;else if(l&&typeof l=="object"&&typeof l.forEach=="function"){let c={};l.forEach((i,u)=>{c[u]=i}),n=c}else n=l}let o=e?.timeout||3e4;return new Promise((l,c)=>{let i=e?.signal;if(i?.aborted){let d=new Error("The operation was aborted");d.name="AbortError",c(d);return}let u=!1,h=[],f=uni.request({url:r,method:s,data:n,header:a,timeout:o,success:d=>{if(u)return;u=!0;let p=d.statusCode,m="",y=new b,v=d.header||d.headers||{};Object.keys(v).forEach(E=>{let P=v[E];y.set(E,typeof P=="string"?P:String(P))}),l(new G(d.data,{status:p,statusText:m,headers:y}))},fail:d=>{if(u)return;u=!0;let p=d?.errMsg||d?.message||"Network Error",m=new Error(p);/(abort|aborted|canceled|cancelled)/i.test(String(p))&&(m.name="AbortError"),c(m)}});if(i&&typeof i.addEventListener=="function"){let d=()=>{if(u)return;try{f?.abort?.()}catch{}let p=new Error("The operation was aborted");p.name="AbortError",u=!0,c(p)};i.addEventListener("abort",d),h.push(()=>{try{i.removeEventListener?.("abort",d)}catch{}})}})};typeof globalThis.fetch!="function"&&(globalThis.fetch=C);var w="Mobile-web";try{if(typeof uni<"u"&&typeof uni?.getSystemInfoSync=="function"){let t=uni.getSystemInfoSync()??{},e=t.uniPlatform,r=t.osName,s=t.ua??(typeof navigator<"u"?navigator.userAgent:"");e==="mp-weixin"?w="MP-Wechat":e==="mp-alipay"?w="MP-Alipay":e==="app"?r==="ios"?w="IOS":r==="android"?w="Android":r==="harmonyos"&&(w="Harmony"):(e==="web"||e==="h5")&&(w=s&&/MicroMessenger/i.test(s)?"Wechat-H5":"Mobile-web")}else typeof navigator<"u"&&/MicroMessenger/i.test(navigator.userAgent)&&(w="Wechat-H5")}catch{w="Mobile-web"}var Je={async requestPayment(t){let e=t,r=e.jsapiPayParams??e;if(typeof r.timeStamp=="string"&&typeof r.nonceStr=="string"&&typeof r.package=="string"&&typeof r.paySign=="string"){await new Promise((a,n)=>{uni.requestPayment({provider:"wxpay",timeStamp:r.timeStamp,nonceStr:r.nonceStr,package:r.package,signType:r.signType??"RSA",paySign:r.paySign,success:()=>a(),fail:o=>n(o)})});return}if(typeof e.redirectUrl=="string"){typeof window<"u"?window.location.href=e.redirectUrl:globalThis.plus?.runtime?.openURL?.(e.redirectUrl);return}if(typeof e.codeUrl=="string"){let a=`https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(e.codeUrl)}`;typeof window<"u"?window.open(a,"_blank"):globalThis.plus?.runtime?.openURL?.(a);return}throw new Error("requestPayment: unsupported payParams for current endpoint")}};function wt(){if(typeof window>"u"||window===window.parent)return;let t=!1,e=new ze;function r(i){if(!i)return!1;let u=i.toLowerCase();return u.includes("/components/")||u.includes("\\components\\")}function s(i){let u=i,h=null;for(;u;){let f=u.getAttribute("data-source-location");if(f)if(r(f)){h||(h=f),u=u.parentElement;continue}else return f;u=u.parentElement}return h}let a=null;function n(i){t&&(a!==null&&cancelAnimationFrame(a),a=requestAnimationFrame(()=>{let u=i.target;if(!u||u===document.body||u===document.documentElement){e.removeHighlight();return}if(u.tagName.toLowerCase()==="img"){let p=s(u);e.highlightElement(u,p);let m={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:p,elementInfo:{tagName:u.tagName.toLowerCase(),className:u.className||"",id:u.id||""}};window.parent.postMessage(m,"*");return}let h=u,f=s(u);if(!f){let p=u.parentElement;for(;p&&p!==document.body&&p!==document.documentElement;){let m=s(p);if(m){h=p,f=m;break}p=p.parentElement}}e.highlightElement(h,f);let d={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:f,elementInfo:{tagName:h.tagName.toLowerCase(),className:h.className||"",id:h.id||""}};window.parent.postMessage(d,"*")}))}function o(){if(!t)return;e.removeHighlight();let i={type:"HOVER_INSPECTOR_ELEMENT_LEAVE"};window.parent.postMessage(i,"*")}function l(i){if(!t)return;i.preventDefault(),i.stopPropagation();let u=i.target;if(!u||u===document.body||u===document.documentElement)return;let h=s(u);e.selectElement(u,h);let f={type:"HOVER_INSPECTOR_ELEMENT_SELECT",sourceLocation:h,elementInfo:{tagName:u.tagName.toLowerCase(),className:u.className||"",id:u.id||""}};window.parent.postMessage(f,"*")}function c(i){i.data?.type==="HOVER_INSPECTOR_ENABLE"?(t=!0,document.addEventListener("mousemove",n),document.addEventListener("mouseleave",o),document.addEventListener("click",l,!0)):i.data?.type==="HOVER_INSPECTOR_DISABLE"&&(t=!1,document.removeEventListener("mousemove",n),document.removeEventListener("mouseleave",o),document.removeEventListener("click",l,!0),e.removeHighlight(),e.clearSelection())}return window.addEventListener("message",c),()=>{window.removeEventListener("message",c),document.removeEventListener("mousemove",n),document.removeEventListener("mouseleave",o),document.removeEventListener("click",l,!0),e.cleanup()}}function bt(t,e){if(!t||!t.contentWindow)throw new Error("Invalid iframe element");let r={type:"HOVER_INSPECTOR_ENABLE"};t.contentWindow.postMessage(r,e)}function Et(t,e){if(!t||!t.contentWindow)return;let r={type:"HOVER_INSPECTOR_DISABLE"};t.contentWindow.postMessage(r,e)}function _t(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",l),a(new Error("Request timeout"))},r),l=i=>{i.origin===e&&i.data?.type==="GET_SOURCE_LOCATION_RESPONSE"&&i.data?.requestId===n&&(clearTimeout(o),window.removeEventListener("message",l),i.data.error?a(new Error(i.data.error)):s(i.data.sourceLocation||null))};window.addEventListener("message",l);let c={type:"GET_SOURCE_LOCATION_REQUEST",requestId:n};try{t.contentWindow.postMessage(c,e)}catch(i){clearTimeout(o),window.removeEventListener("message",l),a(i)}})}function Pt(){if(typeof window>"u"||window===window.parent)return;let t=e=>{if(e.data?.type==="GET_SOURCE_LOCATION_REQUEST")try{let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:Ot(),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 Ot(){return Ge("app")}var J=new H,F=class{constructor(e,r){this.payment=Je;this.endpointType=w;typeof console<"u"&&console.warn("[Nvwa] uniapp init baseUrl:",e||"(empty)"),this.auth=new je(e,{fetchImpl:C,storage:J}),this.httpClient=new Fe(J,C,r),this.fileStorage=new De(e,this.httpClient),this.entities=Be(e,this.httpClient),this.functions=new Ne(this.httpClient,e),this.skill=new qe(e,this.httpClient),this.capability=new We(e,this.httpClient)}};0&&(module.exports={disableIframeHoverInspector,enableIframeHoverInspector,getIframeSourceLocation,localStorage,polyfill,setupIframeHoverInspector,setupIframeSourceLocationListener,uniappFetch});
|
|
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 Ge(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}g();var H=class{constructor(){this.prefix="nvwa_"}getKey(e){return`${this.prefix}${e}`}async get(e){try{let r=this.getKey(e),s=uni.getStorageSync(r);return s?s.expires&&Date.now()>s.expires?(await this.remove(e),null):s.value:null}catch(r){return console.error("UniAppStorageService 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()};uni.setStorageSync(a,n)}catch(a){throw console.error("UniAppStorageService set error:",a),a}}async remove(e){try{let r=this.getKey(e);uni.removeStorageSync(r)}catch(r){throw console.error("UniAppStorageService remove error:",r),r}}async clear(){try{uni.clearStorageSync()}catch(e){throw console.error("UniAppStorageService clear error:",e),e}}};var C=(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 uniappFetch");typeof console<"u"&&(console.warn("[NvwaUni] request url:",r,"method:",(e?.method||"GET").toUpperCase()),!r.startsWith("http://")&&!r.startsWith("https://")&&console.warn("[NvwaUni] url \u975E\u5B8C\u6574\u5730\u5740\uFF0C\u5C0F\u7A0B\u5E8F uni.request \u4F1A\u62A5 invalid url\uFF0C\u8BF7\u68C0\u67E5 baseUrl \u662F\u5426\u4F20\u5165\u5B8C\u6574\u57DF\u540D"));let s=(e?.method||"GET").toUpperCase(),a={};if(e?.headers){let i=e.headers;if(typeof i?.forEach=="function")i.forEach((c,l)=>{a[l]=c});else if(Array.isArray(i))for(let[c,l]of i)a[c]=l;else Object.assign(a,i)}let n;if(e?.body!==void 0){let i=e.body;if(typeof i=="string")n=i;else if(i&&typeof i=="object"&&typeof i.forEach=="function"){let c={};i.forEach((l,u)=>{c[u]=l}),n=c}else n=i}let o=e?.timeout||3e4;return new Promise((i,c)=>{let l=e?.signal;if(l?.aborted){let d=new Error("The operation was aborted");d.name="AbortError",c(d);return}let u=!1,h=[],f=uni.request({url:r,method:s,data:n,header:a,timeout:o,success:d=>{if(u)return;u=!0;let p=d.statusCode,m="",y=new b,v=d.header||d.headers||{};Object.keys(v).forEach(E=>{let P=v[E];y.set(E,typeof P=="string"?P:String(P))}),i(new G(d.data,{status:p,statusText:m,headers:y}))},fail:d=>{if(u)return;u=!0;let p=d?.errMsg||d?.message||"Network Error",m=new Error(p);/(abort|aborted|canceled|cancelled)/i.test(String(p))&&(m.name="AbortError"),c(m)}});if(l&&typeof l.addEventListener=="function"){let d=()=>{if(u)return;try{f?.abort?.()}catch{}let p=new Error("The operation was aborted");p.name="AbortError",u=!0,c(p)};l.addEventListener("abort",d),h.push(()=>{try{l.removeEventListener?.("abort",d)}catch{}})}})};typeof globalThis.fetch!="function"&&(globalThis.fetch=C);var w="Mobile-web";try{if(typeof uni<"u"&&typeof uni?.getSystemInfoSync=="function"){let t=uni.getSystemInfoSync()??{},e=t.uniPlatform,r=t.osName,s=t.ua??(typeof navigator<"u"?navigator.userAgent:"");e==="mp-weixin"?w="MP-Wechat":e==="mp-alipay"?w="MP-Alipay":e==="app"?r==="ios"?w="IOS":r==="android"?w="Android":r==="harmonyos"&&(w="Harmony"):(e==="web"||e==="h5")&&(w=s&&/MicroMessenger/i.test(s)?"Wechat-H5":"Mobile-web")}else typeof navigator<"u"&&/MicroMessenger/i.test(navigator.userAgent)&&(w="Wechat-H5")}catch{w="Mobile-web"}var Je={async requestPayment(t){let e=t,r=e.jsapiPayParams??e;if(typeof r.timeStamp=="string"&&typeof r.nonceStr=="string"&&typeof r.package=="string"&&typeof r.paySign=="string"){await new Promise((a,n)=>{uni.requestPayment({provider:"wxpay",timeStamp:r.timeStamp,nonceStr:r.nonceStr,package:r.package,signType:r.signType??"RSA",paySign:r.paySign,success:()=>a(),fail:o=>n(o)})});return}if(typeof e.redirectUrl=="string"){typeof window<"u"?window.location.href=e.redirectUrl:globalThis.plus?.runtime?.openURL?.(e.redirectUrl);return}if(typeof e.codeUrl=="string"){let a=`https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(e.codeUrl)}`;typeof window<"u"?window.open(a,"_blank"):globalThis.plus?.runtime?.openURL?.(a);return}throw new Error("requestPayment: unsupported payParams for current endpoint")}};function bt(){if(typeof window>"u"||window===window.parent)return;let t=!1,e=new ze;function r(l){if(!l)return!1;let u=l.toLowerCase();return u.includes("/components/")||u.includes("\\components\\")}function s(l){let u=l,h=null;for(;u;){let f=u.getAttribute("data-source-location");if(f)if(r(f)){h||(h=f),u=u.parentElement;continue}else return f;u=u.parentElement}return h}let a=null;function n(l){t&&(a!==null&&cancelAnimationFrame(a),a=requestAnimationFrame(()=>{let u=l.target;if(!u||u===document.body||u===document.documentElement){e.removeHighlight();return}if(u.tagName.toLowerCase()==="img"){let p=s(u);e.highlightElement(u,p);let m={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:p,elementInfo:{tagName:u.tagName.toLowerCase(),className:u.className||"",id:u.id||""}};window.parent.postMessage(m,"*");return}let h=u,f=s(u);if(!f){let p=u.parentElement;for(;p&&p!==document.body&&p!==document.documentElement;){let m=s(p);if(m){h=p,f=m;break}p=p.parentElement}}e.highlightElement(h,f);let d={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:f,elementInfo:{tagName:h.tagName.toLowerCase(),className:h.className||"",id:h.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 u=l.target;if(!u||u===document.body||u===document.documentElement)return;let h=s(u);e.selectElement(u,h);let f={type:"HOVER_INSPECTOR_ELEMENT_SELECT",sourceLocation:h,elementInfo:{tagName:u.tagName.toLowerCase(),className:u.className||"",id:u.id||""}};window.parent.postMessage(f,"*")}function c(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",c),()=>{window.removeEventListener("message",c),document.removeEventListener("mousemove",n),document.removeEventListener("mouseleave",o),document.removeEventListener("click",i,!0),e.cleanup()}}function Et(t,e){if(!t||!t.contentWindow)throw new Error("Invalid iframe element");let r={type:"HOVER_INSPECTOR_ENABLE"};t.contentWindow.postMessage(r,e)}function _t(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 c={type:"GET_SOURCE_LOCATION_REQUEST",requestId:n};try{t.contentWindow.postMessage(c,e)}catch(l){clearTimeout(o),window.removeEventListener("message",i),a(l)}})}function Ot(){if(typeof window>"u"||window===window.parent)return;let t=e=>{if(e.data?.type==="GET_SOURCE_LOCATION_REQUEST")try{let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:St(),requestId:e.data.requestId};window.parent.postMessage(s,e.origin)}catch(r){let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:null,error:r instanceof Error?r.message:"Unknown error",requestId:e.data.requestId};window.parent.postMessage(s,e.origin)}};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}}function St(){return Ge("app")}var J=new H,F=class{constructor(e,r){this.payment=Je;this.endpointType=w;typeof console<"u"&&console.warn("[Nvwa] uniapp init baseUrl:",e||"(empty)"),this.auth=new Ne(e,{fetchImpl:C,storage:J}),this.httpClient=new Fe(J,C,r),this.fileStorage=new Be(e,this.httpClient),this.entities=De(e,this.httpClient),this.functions=new je(this.httpClient,e),this.skill=new qe(e,this.httpClient),this.capability=new We(e,this.httpClient)}};0&&(module.exports={disableIframeHoverInspector,enableIframeHoverInspector,getIframeSourceLocation,localStorage,polyfill,setupIframeHoverInspector,setupIframeSourceLocationListener,uniappFetch});
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Je=Object.create,H=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,Ve=Object.getOwnPropertyNames,Ye=Object.getPrototypeOf,Qe=Object.prototype.hasOwnProperty,K=(t,e)=>()=>(t&&(e=t(t=0)),e),S=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Xe=(t,e)=>{for(var r in e)H(t,r,{get:e[r],enumerable:!0})},V=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Ve(e))!Qe.call(t,a)&&a!==r&&H(t,a,{get:()=>e[a],enumerable:!(s=Ke(e,a))||s.enumerable});return t},Ze=(t,e,r)=>(r=t!=null?Je(Ye(t)):{},V(e||!t||!t.__esModule?H(r,"default",{value:t,enumerable:!0}):r,t)),A=t=>V(H({},"__esModule",{value:!0}),t),g=K(()=>{"use strict"}),T={};Xe(T,{__addDisposableResource:()=>be,__assign:()=>N,__asyncDelegator:()=>de,__asyncGenerator:()=>he,__asyncValues:()=>pe,__await:()=>$,__awaiter:()=>ne,__classPrivateFieldGet:()=>ge,__classPrivateFieldIn:()=>we,__classPrivateFieldSet:()=>ve,__createBinding:()=>j,__decorate:()=>X,__disposeResources:()=>Ee,__esDecorate:()=>ee,__exportStar:()=>ie,__extends:()=>Y,__generator:()=>oe,__importDefault:()=>ye,__importStar:()=>me,__makeTemplateObject:()=>fe,__metadata:()=>ae,__param:()=>Z,__propKey:()=>re,__read:()=>q,__rest:()=>Q,__rewriteRelativeImportExtension:()=>_e,__runInitializers:()=>te,__setFunctionName:()=>se,__spread:()=>le,__spreadArray:()=>ce,__spreadArrays:()=>ue,__values:()=>M,default:()=>Se});function Y(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");R(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function Q(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 X(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 l=t.length-1;l>=0;l--)(o=t[l])&&(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 Z(t,e){return function(r,s){e(r,s,t)}}function ee(t,e,r,s,a,n){function o(v){if(v!==void 0&&typeof v!="function")throw new TypeError("Function expected");return v}for(var l=s.kind,c=l==="getter"?"get":l==="setter"?"set":"value",i=!e&&t?s.static?t:t.prototype:null,u=e||(i?Object.getOwnPropertyDescriptor(i,s.name):{}),h,f=!1,d=r.length-1;d>=0;d--){var p={};for(var m in s)p[m]=m==="access"?{}:s[m];for(var m in s.access)p.access[m]=s.access[m];p.addInitializer=function(v){if(f)throw new TypeError("Cannot add initializers after decoration has completed");n.push(o(v||null))};var y=(0,r[d])(l==="accessor"?{get:u.get,set:u.set}:u[c],p);if(l==="accessor"){if(y===void 0)continue;if(y===null||typeof y!="object")throw new TypeError("Object expected");(h=o(y.get))&&(u.get=h),(h=o(y.set))&&(u.set=h),(h=o(y.init))&&a.unshift(h)}else(h=o(y))&&(l==="field"?a.unshift(h):u[c]=h)}i&&Object.defineProperty(i,s.name,u),f=!0}function te(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 re(t){return typeof t=="symbol"?t:"".concat(t)}function se(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 ae(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function ne(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 l(u){try{i(s.next(u))}catch(h){o(h)}}function c(u){try{i(s.throw(u))}catch(h){o(h)}}function i(u){u.done?n(u.value):a(u.value).then(l,c)}i((s=s.apply(t,e||[])).next())})}function oe(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=l(0),o.throw=l(1),o.return=l(2),typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function l(i){return function(u){return c([i,u])}}function c(i){if(s)throw new TypeError("Generator is already executing.");for(;o&&(o=0,i[0]&&(r=0)),r;)try{if(s=1,a&&(n=i[0]&2?a.return:i[0]?a.throw||((n=a.return)&&n.call(a),0):a.next)&&!(n=n.call(a,i[1])).done)return n;switch(a=0,n&&(i=[i[0]&2,n.value]),i[0]){case 0:case 1:n=i;break;case 4:return r.label++,{value:i[1],done:!1};case 5:r.label++,a=i[1],i=[0];continue;case 7:i=r.ops.pop(),r.trys.pop();continue;default:if(n=r.trys,!(n=n.length>0&&n[n.length-1])&&(i[0]===6||i[0]===2)){r=0;continue}if(i[0]===3&&(!n||i[1]>n[0]&&i[1]<n[3])){r.label=i[1];break}if(i[0]===6&&r.label<n[1]){r.label=n[1],n=i;break}if(n&&r.label<n[2]){r.label=n[2],r.ops.push(i);break}n[2]&&r.ops.pop(),r.trys.pop();continue}i=e.call(t,r)}catch(u){i=[6,u],a=0}finally{s=n=0}if(i[0]&5)throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}function ie(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&j(e,t,r)}function M(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 q(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(l){o={error:l}}finally{try{a&&!a.done&&(r=s.return)&&r.call(s)}finally{if(o)throw o.error}}return n}function le(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(q(arguments[e]));return t}function ue(){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,l=n.length;o<l;o++,a++)s[a]=n[o];return s}function ce(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 $(t){return this instanceof $?(this.v=t,this):new $(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),l("next"),l("throw"),l("return",o),a[Symbol.asyncIterator]=function(){return this},a;function o(d){return function(p){return Promise.resolve(p).then(d,h)}}function l(d,p){s[d]&&(a[d]=function(m){return new Promise(function(y,v){n.push([d,m,y,v])>1||c(d,m)})},p&&(a[d]=p(a[d])))}function c(d,p){try{i(s[d](p))}catch(m){f(n[0][3],m)}}function i(d){d.value instanceof $?Promise.resolve(d.value.v).then(u,h):f(n[0][2],d)}function u(d){c("next",d)}function h(d){c("throw",d)}function f(d,p){d(p),n.shift(),n.length&&c(n[0][0],n[0][1])}}function de(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:$(t[a](o)),done:!1}:n?n(o):o}:n}}function pe(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 M=="function"?M(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(l,c){o=t[n](o),a(l,c,o.done,o.value)})}}function a(n,o,l,c){Promise.resolve(c).then(function(i){n({value:i,done:l})},o)}}function fe(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function me(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"&&j(e,t,r[s]);return Pe(e,t),e}function ye(t){return t&&t.__esModule?t:{default:t}}function ge(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 ve(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 we(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 be(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 Ee(t){function e(n){t.error=t.hasError?new Oe(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 _e(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 R,N,j,Pe,k,Oe,Se,C=K(()=>{"use strict";g(),R=function(t,e){return R=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])},R(t,e)},N=function(){return N=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},N.apply(this,arguments)},j=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]}),Pe=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)},Oe=typeof SuppressedError=="function"?SuppressedError:function(t,e,r){var s=new Error(r);return s.name="SuppressedError",s.error=t,s.suppressed=e,s},Se={__extends:Y,__assign:N,__rest:Q,__decorate:X,__param:Z,__esDecorate:ee,__runInitializers:te,__propKey:re,__setFunctionName:se,__metadata:ae,__awaiter:ne,__generator:oe,__createBinding:j,__exportStar:ie,__values:M,__read:q,__spread:le,__spreadArrays:ue,__spreadArray:ce,__await:$,__asyncGenerator:he,__asyncDelegator:de,__asyncValues:pe,__makeTemplateObject:fe,__importStar:me,__importDefault:ye,__classPrivateFieldGet:ge,__classPrivateFieldSet:ve,__classPrivateFieldIn:we,__addDisposableResource:be,__disposeResources:Ee,__rewriteRelativeImportExtension:_e}}),Te=S(t=>{"use strict";g(),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}),$e=S(t=>{"use strict";g(),Object.defineProperty(t,"__esModule",{value:!0});var e=(C(),A(T)),r=e.__importDefault(Te()),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,l=o(this.url.toString(),{method:this.method,headers:this.headers,body:JSON.stringify(this.body),signal:this.signal}).then(async c=>{var i,u,h,f;let d=null,p=null,m=null,y=c.status,v=c.statusText;if(c.ok){if(this.method!=="HEAD"){let D=await c.text();D===""||(this.headers.get("Accept")==="text/csv"||this.headers.get("Accept")&&!((i=this.headers.get("Accept"))===null||i===void 0)&&i.includes("application/vnd.pgrst.plan+text")?p=D:p=JSON.parse(D))}let E=(u=this.headers.get("Prefer"))===null||u===void 0?void 0:u.match(/count=(exact|planned|estimated)/),P=(h=c.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");E&&P&&P.length>1&&(m=parseInt(P[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,m=null,y=406,v="Not Acceptable"):p.length===1?p=p[0]:p=null)}else{let E=await c.text();try{d=JSON.parse(E),Array.isArray(d)&&c.status===404&&(p=[],d=null,y=200,v="OK")}catch{c.status===404&&E===""?(y=204,v="No Content"):d={message:E}}if(d&&this.isMaybeSingle&&!((f=d?.details)===null||f===void 0)&&f.includes("0 rows")&&(d=null,y=200,v="OK"),d&&this.shouldThrowOnError)throw new r.default(d)}return{error:d,data:p,count:m,status:y,statusText:v}});return this.shouldThrowOnError||(l=l.catch(c=>{var i,u,h;return{error:{message:`${(i=c?.name)!==null&&i!==void 0?i:"FetchError"}: ${c?.message}`,details:`${(u=c?.stack)!==null&&u!==void 0?u:""}`,hint:"",code:`${(h=c?.code)!==null&&h!==void 0?h:""}`},data:null,count:null,status:0,statusText:""}})),l.then(a,n)}returns(){return this}overrideTypes(){return this}};t.default=s}),xe=S(t=>{"use strict";g(),Object.defineProperty(t,"__esModule",{value:!0});var e=(C(),A(T)),r=e.__importDefault($e()),s=class extends r.default{select(a){let n=!1,o=(a??"*").split("").map(l=>/\s/.test(l)&&!n?"":(l==='"'&&(n=!n),l)).join("");return this.url.searchParams.set("select",o),this.headers.append("Prefer","return=representation"),this}order(a,{ascending:n=!0,nullsFirst:o,foreignTable:l,referencedTable:c=l}={}){let i=c?`${c}.order`:"order",u=this.url.searchParams.get(i);return this.url.searchParams.set(i,`${u?`${u},`:""}${a}.${n?"asc":"desc"}${o===void 0?"":o?".nullsfirst":".nullslast"}`),this}limit(a,{foreignTable:n,referencedTable:o=n}={}){let l=typeof o>"u"?"limit":`${o}.limit`;return this.url.searchParams.set(l,`${a}`),this}range(a,n,{foreignTable:o,referencedTable:l=o}={}){let c=typeof l>"u"?"offset":`${l}.offset`,i=typeof l>"u"?"limit":`${l}.limit`;return this.url.searchParams.set(c,`${a}`),this.url.searchParams.set(i,`${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:l=!1,wal:c=!1,format:i="text"}={}){var u;let h=[a?"analyze":null,n?"verbose":null,o?"settings":null,l?"buffers":null,c?"wal":null].filter(Boolean).join("|"),f=(u=this.headers.get("Accept"))!==null&&u!==void 0?u:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${i}; for="${f}"; options=${h};`),i==="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}),W=S(t=>{"use strict";g(),Object.defineProperty(t,"__esModule",{value:!0});var e=(C(),A(T)),r=e.__importDefault(xe()),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 l=Array.from(new Set(o)).map(c=>typeof c=="string"&&s.test(c)?`"${c}"`:`${c}`).join(",");return this.url.searchParams.append(n,`in.(${l})`),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:l,type:c}={}){let i="";c==="plain"?i="pl":c==="phrase"?i="ph":c==="websearch"&&(i="w");let u=l===void 0?"":`(${l})`;return this.url.searchParams.append(n,`${i}fts${u}.${o}`),this}match(n){return Object.entries(n).forEach(([o,l])=>{this.url.searchParams.append(o,`eq.${l}`)}),this}not(n,o,l){return this.url.searchParams.append(n,`not.${o}.${l}`),this}or(n,{foreignTable:o,referencedTable:l=o}={}){let c=l?`${l}.or`:"or";return this.url.searchParams.append(c,`(${n})`),this}filter(n,o,l){return this.url.searchParams.append(n,`${o}.${l}`),this}};t.default=a}),Le=S(t=>{"use strict";g(),Object.defineProperty(t,"__esModule",{value:!0});var e=(C(),A(T)),r=e.__importDefault(W()),s=class{constructor(a,{headers:n={},schema:o,fetch:l}){this.url=a,this.headers=new Headers(n),this.schema=o,this.fetch=l}select(a,n){let{head:o=!1,count:l}=n??{},c=o?"HEAD":"GET",i=!1,u=(a??"*").split("").map(h=>/\s/.test(h)&&!i?"":(h==='"'&&(i=!i),h)).join("");return this.url.searchParams.set("select",u),l&&this.headers.append("Prefer",`count=${l}`),new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(a,{count:n,defaultToNull:o=!0}={}){var l;let c="POST";if(n&&this.headers.append("Prefer",`count=${n}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(a)){let i=a.reduce((u,h)=>u.concat(Object.keys(h)),[]);if(i.length>0){let u=[...new Set(i)].map(h=>`"${h}"`);this.url.searchParams.set("columns",u.join(","))}}return new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,body:a,fetch:(l=this.fetch)!==null&&l!==void 0?l:fetch})}upsert(a,{onConflict:n,ignoreDuplicates:o=!1,count:l,defaultToNull:c=!0}={}){var i;let u="POST";if(this.headers.append("Prefer",`resolution=${o?"ignore":"merge"}-duplicates`),n!==void 0&&this.url.searchParams.set("on_conflict",n),l&&this.headers.append("Prefer",`count=${l}`),c||this.headers.append("Prefer","missing=default"),Array.isArray(a)){let h=a.reduce((f,d)=>f.concat(Object.keys(d)),[]);if(h.length>0){let f=[...new Set(h)].map(d=>`"${d}"`);this.url.searchParams.set("columns",f.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})}update(a,{count:n}={}){var o;let l="PATCH";return n&&this.headers.append("Prefer",`count=${n}`),new r.default({method:l,url:this.url,headers:this.headers,schema:this.schema,body: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}),et=S(t=>{"use strict";g(),Object.defineProperty(t,"__esModule",{value:!0});var e=(C(),A(T)),r=e.__importDefault(Le()),s=e.__importDefault(W()),a=class Ae{constructor(o,{headers:l={},schema:c,fetch:i}={}){this.url=o,this.headers=new Headers(l),this.schemaName=c,this.fetch=i}from(o){let l=new URL(`${this.url}/${o}`);return new r.default(l,{headers:new Headers(this.headers),schema:this.schemaName,fetch:this.fetch})}schema(o){return new Ae(this.url,{headers:this.headers,schema:o,fetch:this.fetch})}rpc(o,l={},{head:c=!1,get:i=!1,count:u}={}){var h;let f,d=new URL(`${this.url}/rpc/${o}`),p;c||i?(f=c?"HEAD":"GET",Object.entries(l).filter(([y,v])=>v!==void 0).map(([y,v])=>[y,Array.isArray(v)?`{${v.join(",")}}`:`${v}`]).forEach(([y,v])=>{d.searchParams.append(y,v)})):(f="POST",p=l);let m=new Headers(this.headers);return u&&m.set("Prefer",`count=${u}`),new s.default({method:f,url:d,headers:m,schema:this.schemaName,body:p,fetch:(h=this.fetch)!==null&&h!==void 0?h:fetch})}};t.default=a}),tt=S(t=>{"use strict";g(),Object.defineProperty(t,"__esModule",{value:!0}),t.PostgrestError=t.PostgrestBuilder=t.PostgrestTransformBuilder=t.PostgrestFilterBuilder=t.PostgrestQueryBuilder=t.PostgrestClient=void 0;var e=(C(),A(T)),r=e.__importDefault(et());t.PostgrestClient=r.default;var s=e.__importDefault(Le());t.PostgrestQueryBuilder=s.default;var a=e.__importDefault(W());t.PostgrestFilterBuilder=a.default;var n=e.__importDefault(xe());t.PostgrestTransformBuilder=n.default;var o=e.__importDefault($e());t.PostgrestBuilder=o.default;var l=e.__importDefault(Te());t.PostgrestError=l.default,t.default={PostgrestClient:r.default,PostgrestQueryBuilder:s.default,PostgrestFilterBuilder:a.default,PostgrestTransformBuilder:n.default,PostgrestBuilder:o.default,PostgrestError:l.default}});g();g();var Ce=class{constructor(t,e=""){this.http=t,this.baseUrl=e.replace(/\/$/,"")}async invoke(t,e){let r=this.baseUrl?`${this.baseUrl}/functions/${t}`:`/functions/${t}`;return await(await this.http.fetch(r,{method:e.method||"POST",body:e.body,headers:e.headers})).json()}};g();g();var _="nvwa_current_jwt",O="nvwa_login_token",U="nvwa_user_profile",rt="set-auth-token",st=typeof fetch<"u"?(t,e)=>fetch(t,e):()=>{throw new Error("AuthClient requires fetch")},Ne=class{constructor(t,e={}){this.baseUrl=t.replace(/\/$/,""),this.authPath=(e.authPath??"/auth").replace(/^\//,""),this.fetchImpl=e.fetchImpl??st,this.storage=e.storage??null,this.credentials=e.credentials??"omit",typeof console<"u"&&(console.warn("[NvwaAuth] init baseUrl:",this.baseUrl||"(empty)"),(!this.baseUrl||!this.baseUrl.startsWith("http://")&&!this.baseUrl.startsWith("https://"))&&console.warn("[NvwaAuth] baseUrl \u5E94\u4E3A\u5B8C\u6574\u5730\u5740\uFF08\u5982 https://xxx.nvwa.app\uFF09\uFF0C\u5426\u5219\u5C0F\u7A0B\u5E8F request \u4F1A\u62A5 invalid url"))}async currentUser(){if(this.storage){let r=await this.storage.get(U);if(r!=null)return r}let{data:t}=await this.getSession(),e=t?.user??null;return e&&this.storage&&await this.storage.set(U,e),e}async getCurrentJwt(){if(this.storage){let e=await this.storage.get(_);if(e!=null)return e;let r=await this.storage.get(O),{data:s}=await this.getToken(r??void 0);return s?.token?(await this.storage.set(_,s.token),s.token):null}let{data:t}=await this.getToken();return t?.token??null}async persistLogin(t,e){if(!this.storage)return;let r=e?.headers.get(rt)?.trim()||t.token||t.session?.token;r&&await this.storage.set(O,r),t.user&&await this.storage.set(U,t.user);let s=r??await this.storage.get(O),{data:a}=await this.getToken(s??void 0);a?.token&&await this.storage.set(_,a.token)}async clearLogin(){this.storage&&(await this.storage.remove(O),await this.storage.remove(U),await this.storage.remove(_))}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 getSocialProviders(){try{let t=await this.fetchImpl(this.url("social/providers"),{method:"GET",credentials:this.credentials});return t.ok?{data:await t.json()}:{error:{message:await t.text()||t.statusText,status:t.status}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}getSocialLoginUrl(t,e={}){let r=this.url("social/start"),s=new URL(r);s.searchParams.set("provider",t);let a=e.includeCurrentUrl??!0,n=e.returnTo??(a?this.getCurrentUrl():void 0);return n&&s.searchParams.set("returnTo",n),s.toString()}getCurrentUrl(){let t=globalThis.location;if(!(!t||typeof t.href!="string"))return t.href}async getSession(){try{let t={};if(this.storage){let r=await this.storage.get(O)??await this.storage.get(_);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(O)??await this.storage.get(_);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(O)??await this.storage.get(_);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 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}}}}};g();g();var b=class je{constructor(e){if(this.headerMap=new Map,e){if(e instanceof je)e.forEach((r,s)=>this.set(s,r));else if(Array.isArray(e))for(let[r,s]of e)this.set(r,String(s));else if(typeof e=="object")for(let r of Object.keys(e))this.set(r,String(e[r]))}}append(e,r){let s=e.toLowerCase(),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()}},Ie=class Ue{constructor(e){if(this.params=new Map,e){if(typeof e=="string")this.parseString(e);else if(e instanceof Ue)this.params=new Map(e.params);else if(Array.isArray(e))for(let[r,s]of e)this.append(r,s);else if(e&&typeof e=="object")for(let[r,s]of Object.entries(e))this.set(r,s)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let r=e.split("&");for(let s of r)if(s){let[a,n]=s.split("=");a&&this.append(decodeURIComponent(a),n?decodeURIComponent(n):"")}}append(e,r){let s=this.params.get(e)||[];s.push(r),this.params.set(e,s)}delete(e){this.params.delete(e)}get(e){let r=this.params.get(e);return r?r[0]:null}getAll(e){return this.params.get(e)||[]}has(e){return this.params.has(e)}set(e,r){this.params.set(e,[r])}sort(){let e=Array.from(this.params.entries()).sort(([r],[s])=>r.localeCompare(s));this.params=new Map(e)}toString(){let e=[];for(let[r,s]of this.params.entries())for(let a of s)e.push(`${encodeURIComponent(r)}=${encodeURIComponent(a)}`);return e.join("&")}forEach(e){for(let[r,s]of this.params.entries())for(let a of s)e(a,r,this)}keys(){return this.params.keys()}values(){let e=[];for(let r of this.params.values())e.push(...r);return e[Symbol.iterator]()}entries(){let e=[];for(let[r,s]of this.params.entries())for(let a of s)e.push([r,a]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},at=class B{constructor(e,r){let s;if(e instanceof B)s=e.href;else if(r){let n=r instanceof B?r.href:r;s=this.resolve(n,e)}else s=e;let a=this.parseUrl(s);this.href=s,this.origin=`${a.protocol}//${a.host}`,this.protocol=a.protocol,this.username=a.username,this.password=a.password,this.host=a.host,this.hostname=a.hostname,this.port=a.port,this.pathname=a.pathname,this.search=a.search,this.searchParams=new Ie(a.search),this.hash=a.hash}resolve(e,r){if(r.startsWith("http://")||r.startsWith("https://"))return r;if(r.startsWith("//"))return`${this.parseUrl(e).protocol}${r}`;if(r.startsWith("/")){let n=this.parseUrl(e);return`${n.protocol}//${n.host}${r}`}let s=this.parseUrl(e),a=s.pathname.endsWith("/")?s.pathname:s.pathname+"/";return`${s.protocol}//${s.host}${a}${r}`}parseUrl(e){let r=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!r)throw new TypeError("Invalid URL");let s=r[2]||"",a=r[4]||"",n=r[5]||"/",o=r[7]?`?${r[7]}`:"",l=r[9]?`#${r[9]}`:"";if(!s&&!a&&!n.startsWith("/")&&!n.includes("/")&&!n.includes("."))throw new TypeError("Invalid URL");let c=a.match(/^([^@]*)@(.+)$/),i="",u="",h=a;if(c){let m=c[1];h=c[2];let y=m.match(/^([^:]*):?(.*)$/);y&&(i=y[1]||"",u=y[2]||"")}let f=h.match(/^([^:]+):?(\d*)$/),d=f?f[1]:h,p=f&&f[2]?f[2]:"";return{protocol:s?`${s}:`:"",username:i,password:u,host:h,hostname:d,port:p,pathname:n,search:o,hash:l}}toString(){let e=this.searchParams.toString(),r=e?`?${e}`:"";return`${this.protocol}//${this.host}${this.pathname}${r}${this.hash}`}toJSON(){return this.toString()}};g();var nt=class Re{constructor(e,r){if(typeof e=="string")this.url=e;else if(e?.url)this.url=String(e.url);else if(typeof e?.toString=="function")this.url=String(e.toString());else throw new Error("Invalid input for Request");this.method=(r?.method||"GET").toUpperCase(),this.headers=r?.headers instanceof b?r.headers:new b(r?.headers),this.body=r?.body,this.timeout=r?.timeout,this.signal=r?.signal||void 0}clone(){return new Re(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};g();var z=class{constructor(t,e){this.bodyData=t,this.status=e?.status??200,this.statusText=e?.statusText??"",this.headers=ot(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 ot(t){return t?new b(t):new b}g();var ke=class{constructor(){this._aborted=!1,this.listeners=new Set,this.onabort=null}get aborted(){return this._aborted}_trigger(){if(!this._aborted){if(this._aborted=!0,typeof this.onabort=="function")try{this.onabort()}catch{}for(let t of Array.from(this.listeners))try{t()}catch{}this.listeners.clear()}}addEventListener(t,e){if(this._aborted){try{e()}catch{}return}this.listeners.add(e)}removeEventListener(t,e){this.listeners.delete(e)}toString(){return"[object AbortSignal]"}},it=class{constructor(){this._signal=new ke}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};g();function lt(t){t.URL=at,t.URLSearchParams=Ie,t.Headers=b,t.Request=nt,t.Response=z,t.AbortController=it,t.AbortSignal=ke}var Me=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(_),s=new b(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}};g();var ut="/storage",ct=ut+"/generateUploadUrl",He=class{constructor(t,e){this.baseUrl=t,this.http=e}async uploadFile(t){let e=await this.http.fetch(this.baseUrl+ct,{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:a}=await s.json();return{url:a.split("?")[0]}}};g();g();g();var J=Ze(tt(),1),{PostgrestClient:ht,PostgrestQueryBuilder:ft,PostgrestFilterBuilder:mt,PostgrestTransformBuilder:yt,PostgrestBuilder:gt,PostgrestError:vt}=J.default||J,dt="/entities",Fe=(t,e)=>new ht(t+dt,{fetch:e.fetchWithAuth.bind(e)});g();var De=class{constructor(t,e){this.baseUrl=t,this.http=e}async execute(t,e){let r=`${this.baseUrl}/capability/${t}/execute`,s=await(await this.http.fetchWithAuth(r,{method:"POST",body:e?JSON.stringify(e):void 0,timeout:6e5})).json();if(s.status!==200)throw new Error(s.message);return s.data}};g();var Be=class{constructor(t,e){this.baseUrl=t,this.http=e}async execute(t,e){let r=`${this.baseUrl}/capability/${t}/execute`,s=await(await this.http.fetchWithAuth(r,{method:"POST",body:e!=null?JSON.stringify(e):void 0,timeout:6e5})).json();if(s.status!==200)throw new Error(s.message);return s.data}};g();var qe=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 Je=Object.create,H=Object.defineProperty,Ke=Object.getOwnPropertyDescriptor,Ve=Object.getOwnPropertyNames,Ye=Object.getPrototypeOf,Qe=Object.prototype.hasOwnProperty,K=(t,e)=>()=>(t&&(e=t(t=0)),e),S=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Xe=(t,e)=>{for(var r in e)H(t,r,{get:e[r],enumerable:!0})},V=(t,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of Ve(e))!Qe.call(t,a)&&a!==r&&H(t,a,{get:()=>e[a],enumerable:!(s=Ke(e,a))||s.enumerable});return t},Ze=(t,e,r)=>(r=t!=null?Je(Ye(t)):{},V(e||!t||!t.__esModule?H(r,"default",{value:t,enumerable:!0}):r,t)),A=t=>V(H({},"__esModule",{value:!0}),t),g=K(()=>{"use strict"}),T={};Xe(T,{__addDisposableResource:()=>be,__assign:()=>j,__asyncDelegator:()=>de,__asyncGenerator:()=>he,__asyncValues:()=>pe,__await:()=>$,__awaiter:()=>ne,__classPrivateFieldGet:()=>ge,__classPrivateFieldIn:()=>we,__classPrivateFieldSet:()=>ve,__createBinding:()=>N,__decorate:()=>X,__disposeResources:()=>Ee,__esDecorate:()=>ee,__exportStar:()=>ie,__extends:()=>Y,__generator:()=>oe,__importDefault:()=>ye,__importStar:()=>me,__makeTemplateObject:()=>fe,__metadata:()=>ae,__param:()=>Z,__propKey:()=>re,__read:()=>q,__rest:()=>Q,__rewriteRelativeImportExtension:()=>_e,__runInitializers:()=>te,__setFunctionName:()=>se,__spread:()=>le,__spreadArray:()=>ce,__spreadArrays:()=>ue,__values:()=>M,default:()=>Se});function Y(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");U(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}function Q(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 X(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 Z(t,e){return function(r,s){e(r,s,t)}}function ee(t,e,r,s,a,n){function o(v){if(v!==void 0&&typeof v!="function")throw new TypeError("Function expected");return v}for(var i=s.kind,c=i==="getter"?"get":i==="setter"?"set":"value",l=!e&&t?s.static?t:t.prototype:null,u=e||(l?Object.getOwnPropertyDescriptor(l,s.name):{}),h,f=!1,d=r.length-1;d>=0;d--){var p={};for(var m in s)p[m]=m==="access"?{}:s[m];for(var m in s.access)p.access[m]=s.access[m];p.addInitializer=function(v){if(f)throw new TypeError("Cannot add initializers after decoration has completed");n.push(o(v||null))};var y=(0,r[d])(i==="accessor"?{get:u.get,set:u.set}:u[c],p);if(i==="accessor"){if(y===void 0)continue;if(y===null||typeof y!="object")throw new TypeError("Object expected");(h=o(y.get))&&(u.get=h),(h=o(y.set))&&(u.set=h),(h=o(y.init))&&a.unshift(h)}else(h=o(y))&&(i==="field"?a.unshift(h):u[c]=h)}l&&Object.defineProperty(l,s.name,u),f=!0}function te(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 re(t){return typeof t=="symbol"?t:"".concat(t)}function se(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 ae(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function ne(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(u){try{l(s.next(u))}catch(h){o(h)}}function c(u){try{l(s.throw(u))}catch(h){o(h)}}function l(u){u.done?n(u.value):a(u.value).then(i,c)}l((s=s.apply(t,e||[])).next())})}function oe(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(u){return c([l,u])}}function c(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(u){l=[6,u],a=0}finally{s=n=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}function ie(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&N(e,t,r)}function M(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 q(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 le(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(q(arguments[e]));return t}function ue(){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 ce(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 $(t){return this instanceof $?(this.v=t,this):new $(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,h)}}function i(d,p){s[d]&&(a[d]=function(m){return new Promise(function(y,v){n.push([d,m,y,v])>1||c(d,m)})},p&&(a[d]=p(a[d])))}function c(d,p){try{l(s[d](p))}catch(m){f(n[0][3],m)}}function l(d){d.value instanceof $?Promise.resolve(d.value.v).then(u,h):f(n[0][2],d)}function u(d){c("next",d)}function h(d){c("throw",d)}function f(d,p){d(p),n.shift(),n.length&&c(n[0][0],n[0][1])}}function de(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:$(t[a](o)),done:!1}:n?n(o):o}:n}}function pe(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 M=="function"?M(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,c){o=t[n](o),a(i,c,o.done,o.value)})}}function a(n,o,i,c){Promise.resolve(c).then(function(l){n({value:l,done:i})},o)}}function fe(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}function me(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r=R(t),s=0;s<r.length;s++)r[s]!=="default"&&N(e,t,r[s]);return Pe(e,t),e}function ye(t){return t&&t.__esModule?t:{default:t}}function ge(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 ve(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 we(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 be(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 Ee(t){function e(n){t.error=t.hasError?new Oe(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 _e(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 U,j,N,Pe,R,Oe,Se,C=K(()=>{"use strict";g(),U=function(t,e){return U=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])},U(t,e)},j=function(){return j=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},j.apply(this,arguments)},N=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]}),Pe=Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e},R=function(t){return R=Object.getOwnPropertyNames||function(e){var r=[];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(r[r.length]=s);return r},R(t)},Oe=typeof SuppressedError=="function"?SuppressedError:function(t,e,r){var s=new Error(r);return s.name="SuppressedError",s.error=t,s.suppressed=e,s},Se={__extends:Y,__assign:j,__rest:Q,__decorate:X,__param:Z,__esDecorate:ee,__runInitializers:te,__propKey:re,__setFunctionName:se,__metadata:ae,__awaiter:ne,__generator:oe,__createBinding:N,__exportStar:ie,__values:M,__read:q,__spread:le,__spreadArrays:ue,__spreadArray:ce,__await:$,__asyncGenerator:he,__asyncDelegator:de,__asyncValues:pe,__makeTemplateObject:fe,__importStar:me,__importDefault:ye,__classPrivateFieldGet:ge,__classPrivateFieldSet:ve,__classPrivateFieldIn:we,__addDisposableResource:be,__disposeResources:Ee,__rewriteRelativeImportExtension:_e}}),Te=S(t=>{"use strict";g(),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}),$e=S(t=>{"use strict";g(),Object.defineProperty(t,"__esModule",{value:!0});var e=(C(),A(T)),r=e.__importDefault(Te()),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 c=>{var l,u,h,f;let d=null,p=null,m=null,y=c.status,v=c.statusText;if(c.ok){if(this.method!=="HEAD"){let B=await c.text();B===""||(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=B:p=JSON.parse(B))}let E=(u=this.headers.get("Prefer"))===null||u===void 0?void 0:u.match(/count=(exact|planned|estimated)/),P=(h=c.headers.get("content-range"))===null||h===void 0?void 0:h.split("/");E&&P&&P.length>1&&(m=parseInt(P[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,m=null,y=406,v="Not Acceptable"):p.length===1?p=p[0]:p=null)}else{let E=await c.text();try{d=JSON.parse(E),Array.isArray(d)&&c.status===404&&(p=[],d=null,y=200,v="OK")}catch{c.status===404&&E===""?(y=204,v="No Content"):d={message:E}}if(d&&this.isMaybeSingle&&!((f=d?.details)===null||f===void 0)&&f.includes("0 rows")&&(d=null,y=200,v="OK"),d&&this.shouldThrowOnError)throw new r.default(d)}return{error:d,data:p,count:m,status:y,statusText:v}});return this.shouldThrowOnError||(i=i.catch(c=>{var l,u,h;return{error:{message:`${(l=c?.name)!==null&&l!==void 0?l:"FetchError"}: ${c?.message}`,details:`${(u=c?.stack)!==null&&u!==void 0?u:""}`,hint:"",code:`${(h=c?.code)!==null&&h!==void 0?h:""}`},data:null,count:null,status:0,statusText:""}})),i.then(a,n)}returns(){return this}overrideTypes(){return this}};t.default=s}),xe=S(t=>{"use strict";g(),Object.defineProperty(t,"__esModule",{value:!0});var e=(C(),A(T)),r=e.__importDefault($e()),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:c=i}={}){let l=c?`${c}.order`:"order",u=this.url.searchParams.get(l);return this.url.searchParams.set(l,`${u?`${u},`:""}${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 c=typeof i>"u"?"offset":`${i}.offset`,l=typeof i>"u"?"limit":`${i}.limit`;return this.url.searchParams.set(c,`${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:c=!1,format:l="text"}={}){var u;let h=[a?"analyze":null,n?"verbose":null,o?"settings":null,i?"buffers":null,c?"wal":null].filter(Boolean).join("|"),f=(u=this.headers.get("Accept"))!==null&&u!==void 0?u:"application/json";return this.headers.set("Accept",`application/vnd.pgrst.plan+${l}; for="${f}"; options=${h};`),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}),W=S(t=>{"use strict";g(),Object.defineProperty(t,"__esModule",{value:!0});var e=(C(),A(T)),r=e.__importDefault(xe()),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(c=>typeof c=="string"&&s.test(c)?`"${c}"`:`${c}`).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:c}={}){let l="";c==="plain"?l="pl":c==="phrase"?l="ph":c==="websearch"&&(l="w");let u=i===void 0?"":`(${i})`;return this.url.searchParams.append(n,`${l}fts${u}.${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 c=i?`${i}.or`:"or";return this.url.searchParams.append(c,`(${n})`),this}filter(n,o,i){return this.url.searchParams.append(n,`${o}.${i}`),this}};t.default=a}),Le=S(t=>{"use strict";g(),Object.defineProperty(t,"__esModule",{value:!0});var e=(C(),A(T)),r=e.__importDefault(W()),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??{},c=o?"HEAD":"GET",l=!1,u=(a??"*").split("").map(h=>/\s/.test(h)&&!l?"":(h==='"'&&(l=!l),h)).join("");return this.url.searchParams.set("select",u),i&&this.headers.append("Prefer",`count=${i}`),new r.default({method:c,url:this.url,headers:this.headers,schema:this.schema,fetch:this.fetch})}insert(a,{count:n,defaultToNull:o=!0}={}){var i;let c="POST";if(n&&this.headers.append("Prefer",`count=${n}`),o||this.headers.append("Prefer","missing=default"),Array.isArray(a)){let l=a.reduce((u,h)=>u.concat(Object.keys(h)),[]);if(l.length>0){let u=[...new Set(l)].map(h=>`"${h}"`);this.url.searchParams.set("columns",u.join(","))}}return new r.default({method:c,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:c=!0}={}){var l;let u="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}`),c||this.headers.append("Prefer","missing=default"),Array.isArray(a)){let h=a.reduce((f,d)=>f.concat(Object.keys(d)),[]);if(h.length>0){let f=[...new Set(h)].map(d=>`"${d}"`);this.url.searchParams.set("columns",f.join(","))}}return new r.default({method:u,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}),et=S(t=>{"use strict";g(),Object.defineProperty(t,"__esModule",{value:!0});var e=(C(),A(T)),r=e.__importDefault(Le()),s=e.__importDefault(W()),a=class Ae{constructor(o,{headers:i={},schema:c,fetch:l}={}){this.url=o,this.headers=new Headers(i),this.schemaName=c,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 Ae(this.url,{headers:this.headers,schema:o,fetch:this.fetch})}rpc(o,i={},{head:c=!1,get:l=!1,count:u}={}){var h;let f,d=new URL(`${this.url}/rpc/${o}`),p;c||l?(f=c?"HEAD":"GET",Object.entries(i).filter(([y,v])=>v!==void 0).map(([y,v])=>[y,Array.isArray(v)?`{${v.join(",")}}`:`${v}`]).forEach(([y,v])=>{d.searchParams.append(y,v)})):(f="POST",p=i);let m=new Headers(this.headers);return u&&m.set("Prefer",`count=${u}`),new s.default({method:f,url:d,headers:m,schema:this.schemaName,body:p,fetch:(h=this.fetch)!==null&&h!==void 0?h:fetch})}};t.default=a}),tt=S(t=>{"use strict";g(),Object.defineProperty(t,"__esModule",{value:!0}),t.PostgrestError=t.PostgrestBuilder=t.PostgrestTransformBuilder=t.PostgrestFilterBuilder=t.PostgrestQueryBuilder=t.PostgrestClient=void 0;var e=(C(),A(T)),r=e.__importDefault(et());t.PostgrestClient=r.default;var s=e.__importDefault(Le());t.PostgrestQueryBuilder=s.default;var a=e.__importDefault(W());t.PostgrestFilterBuilder=a.default;var n=e.__importDefault(xe());t.PostgrestTransformBuilder=n.default;var o=e.__importDefault($e());t.PostgrestBuilder=o.default;var i=e.__importDefault(Te());t.PostgrestError=i.default,t.default={PostgrestClient:r.default,PostgrestQueryBuilder:s.default,PostgrestFilterBuilder:a.default,PostgrestTransformBuilder:n.default,PostgrestBuilder:o.default,PostgrestError:i.default}});g();g();var Ce=class{constructor(t,e=""){this.http=t,this.baseUrl=e.replace(/\/$/,"")}async invoke(t,e){let r=this.baseUrl?`${this.baseUrl}/functions/${t}`:`/functions/${t}`;return await(await this.http.fetch(r,{method:e.method||"POST",body:e.body,headers:e.headers})).json()}};g();g();var _="nvwa_current_jwt",O="nvwa_login_token",k="nvwa_user_profile",rt="set-auth-token",st=typeof fetch<"u"?(t,e)=>fetch(t,e):()=>{throw new Error("AuthClient requires fetch")},je=class{constructor(t,e={}){this.authBaseUrl=at(e.authBaseUrl??t).replace(/\/$/,""),this.authPath=(e.authPath??"/auth").replace(/^\//,""),this.fetchImpl=e.fetchImpl??st,this.storage=e.storage??null,this.credentials=e.credentials??"omit",typeof console<"u"&&(console.warn("[NvwaAuth] init authBaseUrl:",this.authBaseUrl||"(empty)"),(!this.authBaseUrl||!this.authBaseUrl.startsWith("http://")&&!this.authBaseUrl.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(k);if(r!=null)return r}let{data:t}=await this.getSession(),e=t?.user??null;return e&&this.storage&&await this.storage.set(k,e),e}async getCurrentJwt(){if(this.storage){let e=await this.storage.get(_);if(e!=null)return e;let r=await this.storage.get(O),{data:s}=await this.getToken(r??void 0);return s?.token?(await this.storage.set(_,s.token),s.token):null}let{data:t}=await this.getToken();return t?.token??null}async persistLogin(t,e){if(!this.storage)return;let r=e?.headers.get(rt)?.trim()||t.token||t.session?.token;r&&await this.storage.set(O,r),t.user&&await this.storage.set(k,t.user);let s=r??await this.storage.get(O),{data:a}=await this.getToken(s??void 0);a?.token&&await this.storage.set(_,a.token)}async clearLogin(){this.storage&&(await this.storage.remove(O),await this.storage.remove(k),await this.storage.remove(_))}url(t){let e=`${`${this.authBaseUrl.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 getSocialProviders(){try{let t=await this.fetchImpl(this.url("social/providers"),{method:"GET",credentials:this.credentials});return t.ok?{data:await t.json()}:{error:{message:await t.text()||t.statusText,status:t.status}}}catch(t){return{error:{message:t instanceof Error?t.message:String(t),status:0}}}}getSocialLoginUrl(t,e={}){let r=this.url("social/start"),s=new URL(r);s.searchParams.set("provider",t);let a=e.includeCurrentUrl??!0,n=e.returnTo??(a?this.getCurrentUrl():void 0);return n&&s.searchParams.set("returnTo",n),s.toString()}getCurrentUrl(){let t=globalThis.location;if(!(!t||typeof t.href!="string"))return t.href}shouldBootstrapFromCookie(t,e){return t||e==="include"?!1:this.getCurrentUrl()!=null}async getSession(){try{let t={};if(this.storage){let r=await this.storage.get(O)??await this.storage.get(_);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(O)??await this.storage.get(_);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,e={}){try{let r={};if(t)r.Authorization=`Bearer ${t}`;else if(this.storage){let i=await this.storage.get(O)??await this.storage.get(_);i!=null&&(r.Authorization=`Bearer ${i}`)}let s=e.credentialsOverride??this.credentials,a=await this.fetchImpl(this.url("token"),{method:"GET",credentials:s,...Object.keys(r).length?{headers:r}:{}}),n=await a.text();if(!a.ok)return e.allowCookieBootstrap!==!1&&this.shouldBootstrapFromCookie(!!r.Authorization,s)?await this.getToken(void 0,{credentialsOverride:"include",allowCookieBootstrap:!1}):{error:{message:n||a.statusText,status:a.status}};let o=n?JSON.parse(n):void 0;return o?.token!=null?{data:{token:o.token}}:e.allowCookieBootstrap!==!1&&this.shouldBootstrapFromCookie(!!r.Authorization,s)?await this.getToken(void 0,{credentialsOverride:"include",allowCookieBootstrap:!1}):{data:void 0}}catch(r){return{error:{message:r instanceof Error?r.message:String(r),status:0}}}}async signInWithUsername(t,e){let r=await this.postJson("sign-in/username",{username:t,password:e});return r.data&&await this.persistLogin(r.data,r.response),r}async signInWithPhoneNumber(t,e,r){let s=await this.postJson("sign-in/phone-number",{phoneNumber:t,password:e,rememberMe:r});return s.data&&await this.persistLogin(s.data,s.response),s}async sendPhoneNumberOtp(t){let e=await this.postJson("phone-number/send-otp",{phoneNumber:t});return e.error?{error:e.error}:{}}async verifyPhoneNumber(t,e){let r=await this.postJson("phone-number/verify",{phoneNumber:t,code:e});return r.data&&await this.persistLogin(r.data,r.response),r}async postJson(t,e){try{let r=await this.fetchImpl(this.url(t),{method:"POST",headers:{"Content-Type":"application/json"},credentials:this.credentials,body:JSON.stringify(e)}),s=await r.text();if(!r.ok)return{error:{message:s||r.statusText,status:r.status}};let 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}}}}};function at(t){let e=t.replace(/\/$/,"");try{let r=new URL(e),s=r.hostname.split(".");if(s.length<2)return r.origin;let a=s[0],n=a.lastIndexOf("-");if(n<=0||n>=a.length-1)return r.origin;let o=a.slice(n+1);if(!/^[a-z0-9]{8,}$/i.test(o))return r.origin;let i=s.slice(1).join(".");return r.hostname=`${o}.${i}`,r.origin}catch{return e}}g();g();var b=class Ne{constructor(e){if(this.headerMap=new Map,e){if(e instanceof Ne)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()}},Ie=class ke{constructor(e){if(this.params=new Map,e){if(typeof e=="string")this.parseString(e);else if(e instanceof ke)this.params=new Map(e.params);else if(Array.isArray(e))for(let[r,s]of e)this.append(r,s);else if(e&&typeof e=="object")for(let[r,s]of Object.entries(e))this.set(r,s)}}parseString(e){e.startsWith("?")&&(e=e.slice(1));let r=e.split("&");for(let s of r)if(s){let[a,n]=s.split("=");a&&this.append(decodeURIComponent(a),n?decodeURIComponent(n):"")}}append(e,r){let s=this.params.get(e)||[];s.push(r),this.params.set(e,s)}delete(e){this.params.delete(e)}get(e){let r=this.params.get(e);return r?r[0]:null}getAll(e){return this.params.get(e)||[]}has(e){return this.params.has(e)}set(e,r){this.params.set(e,[r])}sort(){let e=Array.from(this.params.entries()).sort(([r],[s])=>r.localeCompare(s));this.params=new Map(e)}toString(){let e=[];for(let[r,s]of this.params.entries())for(let a of s)e.push(`${encodeURIComponent(r)}=${encodeURIComponent(a)}`);return e.join("&")}forEach(e){for(let[r,s]of this.params.entries())for(let a of s)e(a,r,this)}keys(){return this.params.keys()}values(){let e=[];for(let r of this.params.values())e.push(...r);return e[Symbol.iterator]()}entries(){let e=[];for(let[r,s]of this.params.entries())for(let a of s)e.push([r,a]);return e[Symbol.iterator]()}[Symbol.iterator](){return this.entries()}get size(){return this.params.size}},nt=class D{constructor(e,r){let s;if(e instanceof D)s=e.href;else if(r){let n=r instanceof D?r.href:r;s=this.resolve(n,e)}else s=e;let a=this.parseUrl(s);this.href=s,this.origin=`${a.protocol}//${a.host}`,this.protocol=a.protocol,this.username=a.username,this.password=a.password,this.host=a.host,this.hostname=a.hostname,this.port=a.port,this.pathname=a.pathname,this.search=a.search,this.searchParams=new Ie(a.search),this.hash=a.hash}resolve(e,r){if(r.startsWith("http://")||r.startsWith("https://"))return r;if(r.startsWith("//"))return`${this.parseUrl(e).protocol}${r}`;if(r.startsWith("/")){let n=this.parseUrl(e);return`${n.protocol}//${n.host}${r}`}let s=this.parseUrl(e),a=s.pathname.endsWith("/")?s.pathname:s.pathname+"/";return`${s.protocol}//${s.host}${a}${r}`}parseUrl(e){let r=e.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?$/);if(!r)throw new TypeError("Invalid URL");let s=r[2]||"",a=r[4]||"",n=r[5]||"/",o=r[7]?`?${r[7]}`:"",i=r[9]?`#${r[9]}`:"";if(!s&&!a&&!n.startsWith("/")&&!n.includes("/")&&!n.includes("."))throw new TypeError("Invalid URL");let c=a.match(/^([^@]*)@(.+)$/),l="",u="",h=a;if(c){let m=c[1];h=c[2];let y=m.match(/^([^:]*):?(.*)$/);y&&(l=y[1]||"",u=y[2]||"")}let f=h.match(/^([^:]+):?(\d*)$/),d=f?f[1]:h,p=f&&f[2]?f[2]:"";return{protocol:s?`${s}:`:"",username:l,password:u,host:h,hostname:d,port:p,pathname:n,search:o,hash:i}}toString(){let e=this.searchParams.toString(),r=e?`?${e}`:"";return`${this.protocol}//${this.host}${this.pathname}${r}${this.hash}`}toJSON(){return this.toString()}};g();var ot=class Ue{constructor(e,r){if(typeof e=="string")this.url=e;else if(e?.url)this.url=String(e.url);else if(typeof e?.toString=="function")this.url=String(e.toString());else throw new Error("Invalid input for Request");this.method=(r?.method||"GET").toUpperCase(),this.headers=r?.headers instanceof b?r.headers:new b(r?.headers),this.body=r?.body,this.timeout=r?.timeout,this.signal=r?.signal||void 0}clone(){return new Ue(this.url,{method:this.method,headers:this.headers,body:this.body,timeout:this.timeout})}toString(){return this.url}};g();var z=class{constructor(t,e){this.bodyData=t,this.status=e?.status??200,this.statusText=e?.statusText??"",this.headers=it(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 it(t){return t?new b(t):new b}g();var Re=class{constructor(){this._aborted=!1,this.listeners=new Set,this.onabort=null}get aborted(){return this._aborted}_trigger(){if(!this._aborted){if(this._aborted=!0,typeof this.onabort=="function")try{this.onabort()}catch{}for(let t of Array.from(this.listeners))try{t()}catch{}this.listeners.clear()}}addEventListener(t,e){if(this._aborted){try{e()}catch{}return}this.listeners.add(e)}removeEventListener(t,e){this.listeners.delete(e)}toString(){return"[object AbortSignal]"}},lt=class{constructor(){this._signal=new Re}get signal(){return this._signal}abort(){this._signal._trigger()}toString(){return"[object AbortController]"}};g();function ut(t){t.URL=nt,t.URLSearchParams=Ie,t.Headers=b,t.Request=ot,t.Response=z,t.AbortController=lt,t.AbortSignal=Re}var Me=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(_),s=new b(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}};g();var ct="/storage",ht=ct+"/generateUploadUrl",He=class{constructor(t,e){this.baseUrl=t,this.http=e}async uploadFile(t){let e=await this.http.fetch(this.baseUrl+ht,{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:a}=await s.json();return{url:a.split("?")[0]}}};g();g();g();var J=Ze(tt(),1),{PostgrestClient:dt,PostgrestQueryBuilder:mt,PostgrestFilterBuilder:yt,PostgrestTransformBuilder:gt,PostgrestBuilder:vt,PostgrestError:wt}=J.default||J,pt="/entities",Fe=(t,e)=>new dt(t+pt,{fetch:e.fetchWithAuth.bind(e)});g();var Be=class{constructor(t,e){this.baseUrl=t,this.http=e}async execute(t,e){let r=`${this.baseUrl}/capability/${t}/execute`,s=await(await this.http.fetchWithAuth(r,{method:"POST",body:e?JSON.stringify(e):void 0,timeout:6e5})).json();if(s.status!==200)throw new Error(s.message);return s.data}};g();var De=class{constructor(t,e){this.baseUrl=t,this.http=e}async execute(t,e){let r=`${this.baseUrl}/capability/${t}/execute`,s=await(await this.http.fetchWithAuth(r,{method:"POST",body:e!=null?JSON.stringify(e):void 0,timeout:6e5})).json();if(s.status!==200)throw new Error(s.message);return s.data}};g();var qe=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 Je=Object.create,H=Object.defineProperty,Ke=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,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 l=t.getBoundingClientRect();o.style.left=`${l.left+window.scrollX}px`,o.style.top=`${l.top+window.scrollY-o.offsetHeight-8}px`,l.top<o.offsetHeight+8&&(o.style.top=`${l.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 We(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}g();var F=class{constructor(){this.prefix="nvwa_"}getKey(e){return`${this.prefix}${e}`}async get(e){try{let r=this.getKey(e),s=uni.getStorageSync(r);return s?s.expires&&Date.now()>s.expires?(await this.remove(e),null):s.value:null}catch(r){return console.error("UniAppStorageService 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()};uni.setStorageSync(a,n)}catch(a){throw console.error("UniAppStorageService set error:",a),a}}async remove(e){try{let r=this.getKey(e);uni.removeStorageSync(r)}catch(r){throw console.error("UniAppStorageService remove error:",r),r}}async clear(){try{uni.clearStorageSync()}catch(e){throw console.error("UniAppStorageService clear error:",e),e}}};var I=(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 uniappFetch");typeof console<"u"&&(console.warn("[NvwaUni] request url:",r,"method:",(e?.method||"GET").toUpperCase()),!r.startsWith("http://")&&!r.startsWith("https://")&&console.warn("[NvwaUni] url \u975E\u5B8C\u6574\u5730\u5740\uFF0C\u5C0F\u7A0B\u5E8F uni.request \u4F1A\u62A5 invalid url\uFF0C\u8BF7\u68C0\u67E5 baseUrl \u662F\u5426\u4F20\u5165\u5B8C\u6574\u57DF\u540D"));let s=(e?.method||"GET").toUpperCase(),a={};if(e?.headers){let l=e.headers;if(typeof l?.forEach=="function")l.forEach((c,i)=>{a[i]=c});else if(Array.isArray(l))for(let[c,i]of l)a[c]=i;else Object.assign(a,l)}let n;if(e?.body!==void 0){let l=e.body;if(typeof l=="string")n=l;else if(l&&typeof l=="object"&&typeof l.forEach=="function"){let c={};l.forEach((i,u)=>{c[u]=i}),n=c}else n=l}let o=e?.timeout||3e4;return new Promise((l,c)=>{let i=e?.signal;if(i?.aborted){let d=new Error("The operation was aborted");d.name="AbortError",c(d);return}let u=!1,h=[],f=uni.request({url:r,method:s,data:n,header:a,timeout:o,success:d=>{if(u)return;u=!0;let p=d.statusCode,m="",y=new b,v=d.header||d.headers||{};Object.keys(v).forEach(E=>{let P=v[E];y.set(E,typeof P=="string"?P:String(P))}),l(new z(d.data,{status:p,statusText:m,headers:y}))},fail:d=>{if(u)return;u=!0;let p=d?.errMsg||d?.message||"Network Error",m=new Error(p);/(abort|aborted|canceled|cancelled)/i.test(String(p))&&(m.name="AbortError"),c(m)}});if(i&&typeof i.addEventListener=="function"){let d=()=>{if(u)return;try{f?.abort?.()}catch{}let p=new Error("The operation was aborted");p.name="AbortError",u=!0,c(p)};i.addEventListener("abort",d),h.push(()=>{try{i.removeEventListener?.("abort",d)}catch{}})}})};typeof globalThis.fetch!="function"&&(globalThis.fetch=I);var w="Mobile-web";try{if(typeof uni<"u"&&typeof uni?.getSystemInfoSync=="function"){let t=uni.getSystemInfoSync()??{},e=t.uniPlatform,r=t.osName,s=t.ua??(typeof navigator<"u"?navigator.userAgent:"");e==="mp-weixin"?w="MP-Wechat":e==="mp-alipay"?w="MP-Alipay":e==="app"?r==="ios"?w="IOS":r==="android"?w="Android":r==="harmonyos"&&(w="Harmony"):(e==="web"||e==="h5")&&(w=s&&/MicroMessenger/i.test(s)?"Wechat-H5":"Mobile-web")}else typeof navigator<"u"&&/MicroMessenger/i.test(navigator.userAgent)&&(w="Wechat-H5")}catch{w="Mobile-web"}var ze={async requestPayment(t){let e=t,r=e.jsapiPayParams??e;if(typeof r.timeStamp=="string"&&typeof r.nonceStr=="string"&&typeof r.package=="string"&&typeof r.paySign=="string"){await new Promise((a,n)=>{uni.requestPayment({provider:"wxpay",timeStamp:r.timeStamp,nonceStr:r.nonceStr,package:r.package,signType:r.signType??"RSA",paySign:r.paySign,success:()=>a(),fail:o=>n(o)})});return}if(typeof e.redirectUrl=="string"){typeof window<"u"?window.location.href=e.redirectUrl:globalThis.plus?.runtime?.openURL?.(e.redirectUrl);return}if(typeof e.codeUrl=="string"){let a=`https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(e.codeUrl)}`;typeof window<"u"?window.open(a,"_blank"):globalThis.plus?.runtime?.openURL?.(a);return}throw new Error("requestPayment: unsupported payParams for current endpoint")}};function Qt(){if(typeof window>"u"||window===window.parent)return;let t=!1,e=new qe;function r(i){if(!i)return!1;let u=i.toLowerCase();return u.includes("/components/")||u.includes("\\components\\")}function s(i){let u=i,h=null;for(;u;){let f=u.getAttribute("data-source-location");if(f)if(r(f)){h||(h=f),u=u.parentElement;continue}else return f;u=u.parentElement}return h}let a=null;function n(i){t&&(a!==null&&cancelAnimationFrame(a),a=requestAnimationFrame(()=>{let u=i.target;if(!u||u===document.body||u===document.documentElement){e.removeHighlight();return}if(u.tagName.toLowerCase()==="img"){let p=s(u);e.highlightElement(u,p);let m={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:p,elementInfo:{tagName:u.tagName.toLowerCase(),className:u.className||"",id:u.id||""}};window.parent.postMessage(m,"*");return}let h=u,f=s(u);if(!f){let p=u.parentElement;for(;p&&p!==document.body&&p!==document.documentElement;){let m=s(p);if(m){h=p,f=m;break}p=p.parentElement}}e.highlightElement(h,f);let d={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:f,elementInfo:{tagName:h.tagName.toLowerCase(),className:h.className||"",id:h.id||""}};window.parent.postMessage(d,"*")}))}function o(){if(!t)return;e.removeHighlight();let i={type:"HOVER_INSPECTOR_ELEMENT_LEAVE"};window.parent.postMessage(i,"*")}function l(i){if(!t)return;i.preventDefault(),i.stopPropagation();let u=i.target;if(!u||u===document.body||u===document.documentElement)return;let h=s(u);e.selectElement(u,h);let f={type:"HOVER_INSPECTOR_ELEMENT_SELECT",sourceLocation:h,elementInfo:{tagName:u.tagName.toLowerCase(),className:u.className||"",id:u.id||""}};window.parent.postMessage(f,"*")}function c(i){i.data?.type==="HOVER_INSPECTOR_ENABLE"?(t=!0,document.addEventListener("mousemove",n),document.addEventListener("mouseleave",o),document.addEventListener("click",l,!0)):i.data?.type==="HOVER_INSPECTOR_DISABLE"&&(t=!1,document.removeEventListener("mousemove",n),document.removeEventListener("mouseleave",o),document.removeEventListener("click",l,!0),e.removeHighlight(),e.clearSelection())}return window.addEventListener("message",c),()=>{window.removeEventListener("message",c),document.removeEventListener("mousemove",n),document.removeEventListener("mouseleave",o),document.removeEventListener("click",l,!0),e.cleanup()}}function Xt(t,e){if(!t||!t.contentWindow)throw new Error("Invalid iframe element");let r={type:"HOVER_INSPECTOR_ENABLE"};t.contentWindow.postMessage(r,e)}function Zt(t,e){if(!t||!t.contentWindow)return;let r={type:"HOVER_INSPECTOR_DISABLE"};t.contentWindow.postMessage(r,e)}function er(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",l),a(new Error("Request timeout"))},r),l=i=>{i.origin===e&&i.data?.type==="GET_SOURCE_LOCATION_RESPONSE"&&i.data?.requestId===n&&(clearTimeout(o),window.removeEventListener("message",l),i.data.error?a(new Error(i.data.error)):s(i.data.sourceLocation||null))};window.addEventListener("message",l);let c={type:"GET_SOURCE_LOCATION_REQUEST",requestId:n};try{t.contentWindow.postMessage(c,e)}catch(i){clearTimeout(o),window.removeEventListener("message",l),a(i)}})}function tr(){if(typeof window>"u"||window===window.parent)return;let t=e=>{if(e.data?.type==="GET_SOURCE_LOCATION_REQUEST")try{let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:pt(),requestId:e.data.requestId};window.parent.postMessage(s,e.origin)}catch(r){let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:null,error:r instanceof Error?r.message:"Unknown error",requestId:e.data.requestId};window.parent.postMessage(s,e.origin)}};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}}function pt(){return We("app")}var Ge=new F,G=class{constructor(e,r){this.payment=ze;this.endpointType=w;typeof console<"u"&&console.warn("[Nvwa] uniapp init baseUrl:",e||"(empty)"),this.auth=new Ne(e,{fetchImpl:I,storage:Ge}),this.httpClient=new Me(Ge,I,r),this.fileStorage=new He(e,this.httpClient),this.entities=Fe(e,this.httpClient),this.functions=new Ce(this.httpClient,e),this.skill=new De(e,this.httpClient),this.capability=new Be(e,this.httpClient)}};export{G as default,Zt as disableIframeHoverInspector,Xt as enableIframeHoverInspector,er as getIframeSourceLocation,Ge as localStorage,lt as polyfill,Qt as setupIframeHoverInspector,tr as setupIframeSourceLocationListener,I as uniappFetch};
|
|
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 We(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}g();var F=class{constructor(){this.prefix="nvwa_"}getKey(e){return`${this.prefix}${e}`}async get(e){try{let r=this.getKey(e),s=uni.getStorageSync(r);return s?s.expires&&Date.now()>s.expires?(await this.remove(e),null):s.value:null}catch(r){return console.error("UniAppStorageService 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()};uni.setStorageSync(a,n)}catch(a){throw console.error("UniAppStorageService set error:",a),a}}async remove(e){try{let r=this.getKey(e);uni.removeStorageSync(r)}catch(r){throw console.error("UniAppStorageService remove error:",r),r}}async clear(){try{uni.clearStorageSync()}catch(e){throw console.error("UniAppStorageService clear error:",e),e}}};var I=(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 uniappFetch");typeof console<"u"&&(console.warn("[NvwaUni] request url:",r,"method:",(e?.method||"GET").toUpperCase()),!r.startsWith("http://")&&!r.startsWith("https://")&&console.warn("[NvwaUni] url \u975E\u5B8C\u6574\u5730\u5740\uFF0C\u5C0F\u7A0B\u5E8F uni.request \u4F1A\u62A5 invalid url\uFF0C\u8BF7\u68C0\u67E5 baseUrl \u662F\u5426\u4F20\u5165\u5B8C\u6574\u57DF\u540D"));let s=(e?.method||"GET").toUpperCase(),a={};if(e?.headers){let i=e.headers;if(typeof i?.forEach=="function")i.forEach((c,l)=>{a[l]=c});else if(Array.isArray(i))for(let[c,l]of i)a[c]=l;else Object.assign(a,i)}let n;if(e?.body!==void 0){let i=e.body;if(typeof i=="string")n=i;else if(i&&typeof i=="object"&&typeof i.forEach=="function"){let c={};i.forEach((l,u)=>{c[u]=l}),n=c}else n=i}let o=e?.timeout||3e4;return new Promise((i,c)=>{let l=e?.signal;if(l?.aborted){let d=new Error("The operation was aborted");d.name="AbortError",c(d);return}let u=!1,h=[],f=uni.request({url:r,method:s,data:n,header:a,timeout:o,success:d=>{if(u)return;u=!0;let p=d.statusCode,m="",y=new b,v=d.header||d.headers||{};Object.keys(v).forEach(E=>{let P=v[E];y.set(E,typeof P=="string"?P:String(P))}),i(new z(d.data,{status:p,statusText:m,headers:y}))},fail:d=>{if(u)return;u=!0;let p=d?.errMsg||d?.message||"Network Error",m=new Error(p);/(abort|aborted|canceled|cancelled)/i.test(String(p))&&(m.name="AbortError"),c(m)}});if(l&&typeof l.addEventListener=="function"){let d=()=>{if(u)return;try{f?.abort?.()}catch{}let p=new Error("The operation was aborted");p.name="AbortError",u=!0,c(p)};l.addEventListener("abort",d),h.push(()=>{try{l.removeEventListener?.("abort",d)}catch{}})}})};typeof globalThis.fetch!="function"&&(globalThis.fetch=I);var w="Mobile-web";try{if(typeof uni<"u"&&typeof uni?.getSystemInfoSync=="function"){let t=uni.getSystemInfoSync()??{},e=t.uniPlatform,r=t.osName,s=t.ua??(typeof navigator<"u"?navigator.userAgent:"");e==="mp-weixin"?w="MP-Wechat":e==="mp-alipay"?w="MP-Alipay":e==="app"?r==="ios"?w="IOS":r==="android"?w="Android":r==="harmonyos"&&(w="Harmony"):(e==="web"||e==="h5")&&(w=s&&/MicroMessenger/i.test(s)?"Wechat-H5":"Mobile-web")}else typeof navigator<"u"&&/MicroMessenger/i.test(navigator.userAgent)&&(w="Wechat-H5")}catch{w="Mobile-web"}var ze={async requestPayment(t){let e=t,r=e.jsapiPayParams??e;if(typeof r.timeStamp=="string"&&typeof r.nonceStr=="string"&&typeof r.package=="string"&&typeof r.paySign=="string"){await new Promise((a,n)=>{uni.requestPayment({provider:"wxpay",timeStamp:r.timeStamp,nonceStr:r.nonceStr,package:r.package,signType:r.signType??"RSA",paySign:r.paySign,success:()=>a(),fail:o=>n(o)})});return}if(typeof e.redirectUrl=="string"){typeof window<"u"?window.location.href=e.redirectUrl:globalThis.plus?.runtime?.openURL?.(e.redirectUrl);return}if(typeof e.codeUrl=="string"){let a=`https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(e.codeUrl)}`;typeof window<"u"?window.open(a,"_blank"):globalThis.plus?.runtime?.openURL?.(a);return}throw new Error("requestPayment: unsupported payParams for current endpoint")}};function Xt(){if(typeof window>"u"||window===window.parent)return;let t=!1,e=new qe;function r(l){if(!l)return!1;let u=l.toLowerCase();return u.includes("/components/")||u.includes("\\components\\")}function s(l){let u=l,h=null;for(;u;){let f=u.getAttribute("data-source-location");if(f)if(r(f)){h||(h=f),u=u.parentElement;continue}else return f;u=u.parentElement}return h}let a=null;function n(l){t&&(a!==null&&cancelAnimationFrame(a),a=requestAnimationFrame(()=>{let u=l.target;if(!u||u===document.body||u===document.documentElement){e.removeHighlight();return}if(u.tagName.toLowerCase()==="img"){let p=s(u);e.highlightElement(u,p);let m={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:p,elementInfo:{tagName:u.tagName.toLowerCase(),className:u.className||"",id:u.id||""}};window.parent.postMessage(m,"*");return}let h=u,f=s(u);if(!f){let p=u.parentElement;for(;p&&p!==document.body&&p!==document.documentElement;){let m=s(p);if(m){h=p,f=m;break}p=p.parentElement}}e.highlightElement(h,f);let d={type:"HOVER_INSPECTOR_ELEMENT_HOVER",sourceLocation:f,elementInfo:{tagName:h.tagName.toLowerCase(),className:h.className||"",id:h.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 u=l.target;if(!u||u===document.body||u===document.documentElement)return;let h=s(u);e.selectElement(u,h);let f={type:"HOVER_INSPECTOR_ELEMENT_SELECT",sourceLocation:h,elementInfo:{tagName:u.tagName.toLowerCase(),className:u.className||"",id:u.id||""}};window.parent.postMessage(f,"*")}function c(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",c),()=>{window.removeEventListener("message",c),document.removeEventListener("mousemove",n),document.removeEventListener("mouseleave",o),document.removeEventListener("click",i,!0),e.cleanup()}}function Zt(t,e){if(!t||!t.contentWindow)throw new Error("Invalid iframe element");let r={type:"HOVER_INSPECTOR_ENABLE"};t.contentWindow.postMessage(r,e)}function er(t,e){if(!t||!t.contentWindow)return;let r={type:"HOVER_INSPECTOR_DISABLE"};t.contentWindow.postMessage(r,e)}function tr(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 c={type:"GET_SOURCE_LOCATION_REQUEST",requestId:n};try{t.contentWindow.postMessage(c,e)}catch(l){clearTimeout(o),window.removeEventListener("message",i),a(l)}})}function rr(){if(typeof window>"u"||window===window.parent)return;let t=e=>{if(e.data?.type==="GET_SOURCE_LOCATION_REQUEST")try{let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:ft(),requestId:e.data.requestId};window.parent.postMessage(s,e.origin)}catch(r){let s={type:"GET_SOURCE_LOCATION_RESPONSE",sourceLocation:null,error:r instanceof Error?r.message:"Unknown error",requestId:e.data.requestId};window.parent.postMessage(s,e.origin)}};return window.addEventListener("message",t),()=>{window.removeEventListener("message",t)}}function ft(){return We("app")}var Ge=new F,G=class{constructor(e,r){this.payment=ze;this.endpointType=w;typeof console<"u"&&console.warn("[Nvwa] uniapp init baseUrl:",e||"(empty)"),this.auth=new je(e,{fetchImpl:I,storage:Ge}),this.httpClient=new Me(Ge,I,r),this.fileStorage=new He(e,this.httpClient),this.entities=Fe(e,this.httpClient),this.functions=new Ce(this.httpClient,e),this.skill=new Be(e,this.httpClient),this.capability=new De(e,this.httpClient)}};export{G as default,er as disableIframeHoverInspector,Zt as enableIframeHoverInspector,tr as getIframeSourceLocation,Ge as localStorage,ut as polyfill,Xt as setupIframeHoverInspector,rr as setupIframeSourceLocationListener,I as uniappFetch};
|