tevrocsdk 0.1.29 → 0.1.30
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/package.json +1 -1
- package/tevroc-sdk.esm.js +54 -8
- package/tevroc-sdk.min.js +1 -1
- package/tevroc-sdk.umd.js +54 -8
package/package.json
CHANGED
package/tevroc-sdk.esm.js
CHANGED
|
@@ -3907,7 +3907,6 @@ function createClient(options = {}) {
|
|
|
3907
3907
|
}
|
|
3908
3908
|
var TevrocClient = class {
|
|
3909
3909
|
constructor(options = {}) {
|
|
3910
|
-
console.log(options);
|
|
3911
3910
|
const baseUrl = options.baseUrl ?? options.url;
|
|
3912
3911
|
const serviceUrl = options.serviceUrl ?? options.url;
|
|
3913
3912
|
if (!baseUrl) throw new TypeError("createClient requires a baseUrl");
|
|
@@ -3915,8 +3914,9 @@ var TevrocClient = class {
|
|
|
3915
3914
|
this.serviceUrl = normalizeBaseUrl(serviceUrl);
|
|
3916
3915
|
this.appId = options.appId;
|
|
3917
3916
|
this.appName = options.appName;
|
|
3918
|
-
this.
|
|
3919
|
-
|
|
3917
|
+
this.transport = options.axios ?? null;
|
|
3918
|
+
this.fetch = options.fetch ?? globalThis.fetch;
|
|
3919
|
+
if (!this.transport && typeof this.fetch !== "function") {
|
|
3920
3920
|
throw new TypeError("No fetch implementation available");
|
|
3921
3921
|
}
|
|
3922
3922
|
this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
@@ -3938,15 +3938,15 @@ var TevrocClient = class {
|
|
|
3938
3938
|
setToken(token) {
|
|
3939
3939
|
this.token = token || null;
|
|
3940
3940
|
if (this.token) {
|
|
3941
|
-
|
|
3941
|
+
safeLocalStorage()?.setItem("tevroc_access_token", this.token);
|
|
3942
3942
|
} else {
|
|
3943
|
-
|
|
3943
|
+
safeLocalStorage()?.removeItem("tevroc_access_token");
|
|
3944
3944
|
}
|
|
3945
3945
|
return this;
|
|
3946
3946
|
}
|
|
3947
3947
|
clearToken() {
|
|
3948
3948
|
this.token = null;
|
|
3949
|
-
|
|
3949
|
+
safeLocalStorage()?.removeItem("tevroc_access_token");
|
|
3950
3950
|
return this;
|
|
3951
3951
|
}
|
|
3952
3952
|
async request(path, options = {}) {
|
|
@@ -3956,11 +3956,13 @@ var TevrocClient = class {
|
|
|
3956
3956
|
const url = `${this.baseUrl}${path.startsWith("/") ? path : `/${path}`}${query}`;
|
|
3957
3957
|
const controller = new AbortController();
|
|
3958
3958
|
const timeout = setTimeout(() => controller.abort(), options.timeoutMs ?? this.timeoutMs);
|
|
3959
|
-
const token = this.token ||
|
|
3959
|
+
const token = this.token || getStoredToken();
|
|
3960
3960
|
if (token && options.auth !== false) {
|
|
3961
3961
|
headers.set("authorization", `Bearer ${token}`);
|
|
3962
3962
|
}
|
|
3963
|
-
|
|
3963
|
+
if (this.appId) {
|
|
3964
|
+
headers.set("x-app-id", this.appId);
|
|
3965
|
+
}
|
|
3964
3966
|
let body = options.body;
|
|
3965
3967
|
if (body !== void 0 && body !== null && isJsonBody(body)) {
|
|
3966
3968
|
headers.set("content-type", "application/json");
|
|
@@ -3972,6 +3974,18 @@ var TevrocClient = class {
|
|
|
3972
3974
|
}
|
|
3973
3975
|
}
|
|
3974
3976
|
try {
|
|
3977
|
+
if (this.transport) {
|
|
3978
|
+
const response2 = await this.transport.request({
|
|
3979
|
+
url,
|
|
3980
|
+
method,
|
|
3981
|
+
headers: Object.fromEntries(headers.entries()),
|
|
3982
|
+
data: body,
|
|
3983
|
+
signal: options.signal ?? controller.signal,
|
|
3984
|
+
timeout: options.timeoutMs ?? this.timeoutMs,
|
|
3985
|
+
validateStatus: () => true
|
|
3986
|
+
});
|
|
3987
|
+
return await parseAxiosResponse(response2, options.parseAs);
|
|
3988
|
+
}
|
|
3975
3989
|
const response = await this.fetch(url, {
|
|
3976
3990
|
method,
|
|
3977
3991
|
headers,
|
|
@@ -4068,6 +4082,7 @@ function createAuthApi(client) {
|
|
|
4068
4082
|
if (result.token) client.setToken(result.token);
|
|
4069
4083
|
return result;
|
|
4070
4084
|
},
|
|
4085
|
+
loginViaEmailPassword: (email, password) => client.auth.login({ email, password }),
|
|
4071
4086
|
async logout() {
|
|
4072
4087
|
const result = await client.request("/auth/logout", { method: "POST" });
|
|
4073
4088
|
client.clearToken();
|
|
@@ -4100,6 +4115,7 @@ function createEntityApi(client, entity) {
|
|
|
4100
4115
|
update: (id, patch) => client.request(`${base}/${encodeURIComponent(id)}`, { method: "PATCH", body: patch }),
|
|
4101
4116
|
delete: (id) => client.request(`${base}/${encodeURIComponent(id)}`, { method: "DELETE" }),
|
|
4102
4117
|
query: (input = {}) => client.request(`${base}/query`, { method: "POST", body: input }),
|
|
4118
|
+
filter: (filter = {}, sortOrOptions, limit) => client.request(`${base}/query`, { method: "POST", body: normalizeFilterInput(filter, sortOrOptions, limit) }),
|
|
4103
4119
|
bulkCreate: (records) => client.request(`${base}/bulk`, { method: "POST", body: { records } }),
|
|
4104
4120
|
bulkUpdate: (records) => client.request(`${base}/bulk`, { method: "PATCH", body: { records } }),
|
|
4105
4121
|
bulkDelete: (ids) => client.request(`${base}/bulk`, { method: "DELETE", body: { ids } }),
|
|
@@ -4222,6 +4238,23 @@ function upload(client, path, file, options) {
|
|
|
4222
4238
|
if (options.contentType) headers["content-type"] = options.contentType;
|
|
4223
4239
|
return client.request(path, { method: "POST", body: file, headers });
|
|
4224
4240
|
}
|
|
4241
|
+
async function parseAxiosResponse(response, parseAs) {
|
|
4242
|
+
if (parseAs === "response") return response;
|
|
4243
|
+
const headers = response.headers ?? {};
|
|
4244
|
+
const contentType = typeof headers.get === "function" ? headers.get("content-type") ?? "" : String(headers["content-type"] ?? headers["Content-Type"] ?? "");
|
|
4245
|
+
const isJson = contentType.includes("application/json");
|
|
4246
|
+
const data = response.data;
|
|
4247
|
+
if (response.status < 200 || response.status >= 300) {
|
|
4248
|
+
const error = isJson && data?.error ? data.error : {};
|
|
4249
|
+
throw new TevrocError(error.message ?? response.statusText ?? "Request failed", {
|
|
4250
|
+
status: response.status,
|
|
4251
|
+
code: error.code ?? "api_error",
|
|
4252
|
+
details: error.details ?? data,
|
|
4253
|
+
response
|
|
4254
|
+
});
|
|
4255
|
+
}
|
|
4256
|
+
return data;
|
|
4257
|
+
}
|
|
4225
4258
|
async function parseResponse(response, parseAs) {
|
|
4226
4259
|
if (parseAs === "response") return response;
|
|
4227
4260
|
const contentType = response.headers.get("content-type") ?? "";
|
|
@@ -4257,6 +4290,19 @@ function normalizeBaseUrl(url) {
|
|
|
4257
4290
|
function normalizeHeaders(headers = {}) {
|
|
4258
4291
|
return Object.fromEntries(new Headers(headers).entries());
|
|
4259
4292
|
}
|
|
4293
|
+
function safeLocalStorage() {
|
|
4294
|
+
return typeof globalThis !== "undefined" ? globalThis.localStorage : void 0;
|
|
4295
|
+
}
|
|
4296
|
+
function getStoredToken() {
|
|
4297
|
+
return safeLocalStorage()?.getItem("tevroc_access_token") ?? null;
|
|
4298
|
+
}
|
|
4299
|
+
function normalizeFilterInput(filter = {}, sortOrOptions, limit) {
|
|
4300
|
+
const input = { filter };
|
|
4301
|
+
if (typeof sortOrOptions === "string") input.sort = sortOrOptions;
|
|
4302
|
+
else if (sortOrOptions && typeof sortOrOptions === "object") Object.assign(input, sortOrOptions);
|
|
4303
|
+
if (limit !== void 0) input.limit = limit;
|
|
4304
|
+
return input;
|
|
4305
|
+
}
|
|
4260
4306
|
function isJsonBody(body) {
|
|
4261
4307
|
const isArrayBuffer = typeof ArrayBuffer !== "undefined" && body instanceof ArrayBuffer;
|
|
4262
4308
|
const isBlob = typeof Blob !== "undefined" && body instanceof Blob;
|
package/tevroc-sdk.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Tevroc=(()=>{var Pe=Object.defineProperty;var Dt=Object.getOwnPropertyDescriptor;var $t=Object.getOwnPropertyNames;var Wt=Object.prototype.hasOwnProperty;var g=(t,e,n)=>()=>{if(n)throw n[0];try{return t&&(e=t(t=0)),e}catch(i){throw n=[i],i}};var W=(t,e)=>{for(var n in e)Pe(t,n,{get:e[n],enumerable:!0})},qt=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of $t(e))!Wt.call(t,r)&&r!==n&&Pe(t,r,{get:()=>e[r],enumerable:!(i=Dt(e,r))||i.enumerable});return t};var zt=t=>qt(Pe({},"__esModule",{value:!0}),t);var Ke={};W(Ke,{isCapacitor:()=>R,isNative:()=>Mt,isTauri:()=>x,platform:()=>q});var Nt,q,R,x,Mt,ae=g(()=>{Nt=()=>{if(typeof window<"u"&&(window.__TAURI__||window.__TAURI_INTERNALS__))return"tauri";if(typeof window<"u"){if(window.Capacitor?.isNativePlatform?.())return window.Capacitor.getPlatform();if(window.Capacitor?.getPlatform){let t=window.Capacitor.getPlatform();if(t==="ios"||t==="android")return t}}return"web"},q=Nt(),R=q==="android"||q==="ios",x=q==="tauri",Mt=q==="android"||q==="ios"||q==="tauri"});var V,Z,Bt,Ft,Gt,ke,z,T,Ye,Ze,Ce,En,jt,Ht,Vt,Jt,Ae,Tn,Qe,Xe,Le,On,Q=g(()=>{(function(t){t.Unimplemented="UNIMPLEMENTED",t.Unavailable="UNAVAILABLE"})(V||(V={}));Z=class extends Error{constructor(e,n,i){super(e),this.message=e,this.code=n,this.data=i}},Bt=t=>{var e,n;return t?.androidBridge?"android":!((n=(e=t?.webkit)===null||e===void 0?void 0:e.messageHandlers)===null||n===void 0)&&n.bridge?"ios":"web"},Ft=t=>{let e=t.CapacitorCustomPlatform||null,n=t.Capacitor||{},i=n.Plugins=n.Plugins||{},r=()=>e!==null?e.name:Bt(t),o=()=>r()!=="web",a=l=>{let h=d.get(l);return!!(h?.platforms.has(r())||u(l))},u=l=>{var h;return(h=n.PluginHeaders)===null||h===void 0?void 0:h.find(j=>j.name===l)},c=l=>t.console.error(l),d=new Map,p=(l,h={})=>{let j=d.get(l);if(j)return console.warn(`Capacitor plugin "${l}" already registered. Cannot register plugins twice.`),j.proxy;let $=r(),H=u(l),E,Rt=async()=>(!E&&$ in h?E=typeof h[$]=="function"?E=await h[$]():E=h[$]:e!==null&&!E&&"web"in h&&(E=typeof h.web=="function"?E=await h.web():E=h.web),E),xt=(b,_)=>{var C,S;if(H){let I=H?.methods.find(k=>_===k.name);if(I)return I.rtype==="promise"?k=>n.nativePromise(l,_.toString(),k):(k,se)=>n.nativeCallback(l,_.toString(),k,se);if(b)return(C=b[_])===null||C===void 0?void 0:C.bind(b)}else{if(b)return(S=b[_])===null||S===void 0?void 0:S.bind(b);throw new Z(`"${l}" plugin is not implemented on ${$}`,V.Unimplemented)}},_e=b=>{let _,C=(...S)=>{let I=Rt().then(k=>{let se=xt(k,b);if(se){let oe=se(...S);return _=oe?.remove,oe}else throw new Z(`"${l}.${b}()" is not implemented on ${$}`,V.Unimplemented)});return b==="addListener"&&(I.remove=async()=>_()),I};return C.toString=()=>`${b.toString()}() { [capacitor code] }`,Object.defineProperty(C,"name",{value:b,writable:!1,configurable:!1}),C},Ve=_e("addListener"),Je=_e("removeListener"),Ut=(b,_)=>{let C=Ve({eventName:b},_),S=async()=>{let k=await C;Je({eventName:b,callbackId:k},_)},I=new Promise(k=>C.then(()=>k({remove:S})));return I.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await S()},I},ve=new Proxy({},{get(b,_){switch(_){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return H?Ut:Ve;case"removeListener":return Je;default:return _e(_)}}});return i[l]=ve,d.set(l,{name:l,proxy:ve,platforms:new Set([...Object.keys(h),...H?[$]:[]])}),ve};return n.convertFileSrc||(n.convertFileSrc=l=>l),n.getPlatform=r,n.handleError=c,n.isNativePlatform=o,n.isPluginAvailable=a,n.registerPlugin=p,n.Exception=Z,n.DEBUG=!!n.DEBUG,n.isLoggingEnabled=!!n.isLoggingEnabled,n},Gt=t=>t.Capacitor=Ft(t),ke=Gt(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),z=ke.registerPlugin,T=class{constructor(){this.listeners={},this.retainedEventArguments={},this.windowListeners={}}addListener(e,n){let i=!1;this.listeners[e]||(this.listeners[e]=[],i=!0),this.listeners[e].push(n);let o=this.windowListeners[e];o&&!o.registered&&this.addWindowListener(o),i&&this.sendRetainedArgumentsForEvent(e);let a=async()=>this.removeListener(e,n);return Promise.resolve({remove:a})}async removeAllListeners(){this.listeners={};for(let e in this.windowListeners)this.removeWindowListener(this.windowListeners[e]);this.windowListeners={}}notifyListeners(e,n,i){let r=this.listeners[e];if(!r){if(i){let o=this.retainedEventArguments[e];o||(o=[]),o.push(n),this.retainedEventArguments[e]=o}return}r.forEach(o=>o(n))}hasListeners(e){var n;return!!(!((n=this.listeners[e])===null||n===void 0)&&n.length)}registerWindowListener(e,n){this.windowListeners[n]={registered:!1,windowEventName:e,pluginEventName:n,handler:i=>{this.notifyListeners(n,i)}}}unimplemented(e="not implemented"){return new ke.Exception(e,V.Unimplemented)}unavailable(e="not available"){return new ke.Exception(e,V.Unavailable)}async removeListener(e,n){let i=this.listeners[e];if(!i)return;let r=i.indexOf(n);this.listeners[e].splice(r,1),this.listeners[e].length||this.removeWindowListener(this.windowListeners[e])}addWindowListener(e){window.addEventListener(e.windowEventName,e.handler),e.registered=!0}removeWindowListener(e){e&&(window.removeEventListener(e.windowEventName,e.handler),e.registered=!1)}sendRetainedArgumentsForEvent(e){let n=this.retainedEventArguments[e];n&&(delete this.retainedEventArguments[e],n.forEach(i=>{this.notifyListeners(e,i)}))}},Ye=t=>encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),Ze=t=>t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent),Ce=class extends T{async getCookies(){let e=document.cookie,n={};return e.split(";").forEach(i=>{if(i.length<=0)return;let[r,o]=i.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");r=Ze(r).trim(),o=Ze(o).trim(),n[r]=o}),n}async setCookie(e){try{let n=Ye(e.key),i=Ye(e.value),r=e.expires?`; expires=${e.expires.replace("expires=","")}`:"",o=(e.path||"/").replace("path=",""),a=e.url!=null&&e.url.length>0?`domain=${e.url}`:"";document.cookie=`${n}=${i||""}${r}; path=${o}; ${a};`}catch(n){return Promise.reject(n)}}async deleteCookie(e){try{document.cookie=`${e.key}=; Max-Age=0`}catch(n){return Promise.reject(n)}}async clearCookies(){try{let e=document.cookie.split(";")||[];for(let n of e)document.cookie=n.replace(/^ +/,"").replace(/=.*/,`=;expires=${new Date().toUTCString()};path=/`)}catch(e){return Promise.reject(e)}}async clearAllCookies(){try{await this.clearCookies()}catch(e){return Promise.reject(e)}}},En=z("CapacitorCookies",{web:()=>new Ce}),jt=async t=>new Promise((e,n)=>{let i=new FileReader;i.onload=()=>{let r=i.result;e(r.indexOf(",")>=0?r.split(",")[1]:r)},i.onerror=r=>n(r),i.readAsDataURL(t)}),Ht=(t={})=>{let e=Object.keys(t);return Object.keys(t).map(r=>r.toLocaleLowerCase()).reduce((r,o,a)=>(r[o]=t[e[a]],r),{})},Vt=(t,e=!0)=>t?Object.entries(t).reduce((i,r)=>{let[o,a]=r,u,c;return Array.isArray(a)?(c="",a.forEach(d=>{u=e?encodeURIComponent(d):d,c+=`${o}=${u}&`}),c.slice(0,-1)):(u=e?encodeURIComponent(a):a,c=`${o}=${u}`),`${i}&${c}`},"").substr(1):null,Jt=(t,e={})=>{let n=Object.assign({method:t.method||"GET",headers:t.headers},e),r=Ht(t.headers)["content-type"]||"";if(typeof t.data=="string")n.body=t.data;else if(r.includes("application/x-www-form-urlencoded")){let o=new URLSearchParams;for(let[a,u]of Object.entries(t.data||{}))o.set(a,u);n.body=o.toString()}else if(r.includes("multipart/form-data")||t.data instanceof FormData){let o=new FormData;if(t.data instanceof FormData)t.data.forEach((u,c)=>{o.append(c,u)});else for(let u of Object.keys(t.data))o.append(u,t.data[u]);n.body=o;let a=new Headers(n.headers);a.delete("content-type"),n.headers=a}else(r.includes("application/json")||typeof t.data=="object")&&(n.body=JSON.stringify(t.data));return n},Ae=class extends T{async request(e){let n=Jt(e,e.webFetchExtra),i=Vt(e.params,e.shouldEncodeUrlParams),r=i?`${e.url}?${i}`:e.url,o=await fetch(r,n),a=o.headers.get("content-type")||"",{responseType:u="text"}=o.ok?e:{};a.includes("application/json")&&(u="json");let c,d;switch(u){case"arraybuffer":case"blob":d=await o.blob(),c=await jt(d);break;case"json":c=await o.json();break;default:c=await o.text()}let p={};return o.headers.forEach((l,h)=>{p[h]=l}),{data:c,headers:p,status:o.status,url:o.url}}async get(e){return this.request(Object.assign(Object.assign({},e),{method:"GET"}))}async post(e){return this.request(Object.assign(Object.assign({},e),{method:"POST"}))}async put(e){return this.request(Object.assign(Object.assign({},e),{method:"PUT"}))}async patch(e){return this.request(Object.assign(Object.assign({},e),{method:"PATCH"}))}async delete(e){return this.request(Object.assign(Object.assign({},e),{method:"DELETE"}))}},Tn=z("CapacitorHttp",{web:()=>new Ae});(function(t){t.Dark="DARK",t.Light="LIGHT",t.Default="DEFAULT"})(Qe||(Qe={}));(function(t){t.StatusBar="StatusBar",t.NavigationBar="NavigationBar"})(Xe||(Xe={}));Le=class extends T{async setStyle(){this.unavailable("not available for web")}async setAnimation(){this.unavailable("not available for web")}async show(){this.unavailable("not available for web")}async hide(){this.unavailable("not available for web")}},On=z("SystemBars",{web:()=>new Le})});var et=g(()=>{});var tt={};W(tt,{AppWeb:()=>Ee});var Ee,nt=g(()=>{Q();Ee=class extends T{constructor(){super(),this.handleVisibilityChange=()=>{let e={isActive:document.hidden!==!0};this.notifyListeners("appStateChange",e),document.hidden?this.notifyListeners("pause",null):this.notifyListeners("resume",null)},document.addEventListener("visibilitychange",this.handleVisibilityChange,!1)}exitApp(){throw this.unimplemented("Not implemented on web.")}async getInfo(){throw this.unimplemented("Not implemented on web.")}async getLaunchUrl(){return{url:""}}async getState(){return{isActive:document.hidden!==!0}}async minimizeApp(){throw this.unimplemented("Not implemented on web.")}async toggleBackButtonHandler(){throw this.unimplemented("Not implemented on web.")}async getAppLanguage(){return{value:navigator.language.split("-")[0].toLowerCase()}}}});var le,Te=g(()=>{Q();et();le=z("App",{web:()=>Promise.resolve().then(()=>(nt(),tt)).then(t=>new t.AppWeb)})});var it=g(()=>{});var rt={};W(rt,{Browser:()=>Kt,BrowserWeb:()=>ue});var ue,Kt,st=g(()=>{Q();ue=class extends T{constructor(){super(),this._lastWindow=null}async open(e){this._lastWindow=window.open(e.url,e.windowName||"_blank")}async close(){return new Promise((e,n)=>{this._lastWindow!=null?(this._lastWindow.close(),this._lastWindow=null,e()):n("No active window to close!")})}},Kt=new ue});var ce,Oe=g(()=>{Q();it();ce=z("Browser",{web:()=>Promise.resolve().then(()=>(st(),rt)).then(t=>new t.BrowserWeb)})});function f(t,e,n,i){if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?i:n==="a"?i.call(t):i?i.value:e.get(t)}function N(t,e,n,i,r){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?r.call(t,n):r?r.value=n:e.set(t,n),n}var ot=g(()=>{});function Se(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}async function s(t,e={},n){return window.__TAURI_INTERNALS__.invoke(t,e,n)}var M,v,J,de,he,m,at,we,B=g(()=>{ot();m="__TAURI_TO_IPC_KEY__";at=class{constructor(e){M.set(this,void 0),v.set(this,0),J.set(this,[]),de.set(this,void 0),N(this,M,e||(()=>{}),"f"),this.id=Se(n=>{let i=n.index;if("end"in n){i==f(this,v,"f")?this.cleanupCallback():N(this,de,i,"f");return}let r=n.message;if(i==f(this,v,"f")){for(f(this,M,"f").call(this,r),N(this,v,f(this,v,"f")+1,"f");f(this,v,"f")in f(this,J,"f");){let o=f(this,J,"f")[f(this,v,"f")];f(this,M,"f").call(this,o),delete f(this,J,"f")[f(this,v,"f")],N(this,v,f(this,v,"f")+1,"f")}f(this,v,"f")===f(this,de,"f")&&this.cleanupCallback()}else f(this,J,"f")[i]=r})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(e){N(this,M,e,"f")}get onmessage(){return f(this,M,"f")}[(M=new WeakMap,v=new WeakMap,J=new WeakMap,de=new WeakMap,m)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[m]()}};we=class{get rid(){return f(this,he,"f")}constructor(e){he.set(this,void 0),N(this,he,e,"f")}async close(){return s("plugin:resources|close",{rid:this.rid})}};he=new WeakMap});var X,A,P,ee,y,L,pe=g(()=>{B();X=class{constructor(...e){this.type="Logical",e.length===1?"Logical"in e[0]?(this.width=e[0].Logical.width,this.height=e[0].Logical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toPhysical(e){return new A(this.width*e,this.height*e)}[m](){return{width:this.width,height:this.height}}toJSON(){return this[m]()}},A=class{constructor(...e){this.type="Physical",e.length===1?"Physical"in e[0]?(this.width=e[0].Physical.width,this.height=e[0].Physical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toLogical(e){return new X(this.width/e,this.height/e)}[m](){return{width:this.width,height:this.height}}toJSON(){return this[m]()}},P=class{constructor(e){this.size=e}toLogical(e){return this.size instanceof X?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof A?this.size:this.size.toPhysical(e)}[m](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[m]()}},ee=class{constructor(...e){this.type="Logical",e.length===1?"Logical"in e[0]?(this.x=e[0].Logical.x,this.y=e[0].Logical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toPhysical(e){return new y(this.x*e,this.y*e)}[m](){return{x:this.x,y:this.y}}toJSON(){return this[m]()}},y=class{constructor(...e){this.type="Physical",e.length===1?"Physical"in e[0]?(this.x=e[0].Physical.x,this.y=e[0].Physical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toLogical(e){return new ee(this.x/e,this.y/e)}[m](){return{x:this.x,y:this.y}}toJSON(){return this[m]()}},L=class{constructor(e){this.position=e}toLogical(e){return this.position instanceof ee?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof y?this.position:this.position.toPhysical(e)}[m](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[m]()}}});var Ie={};W(Ie,{TauriEvent:()=>w,emit:()=>te,emitTo:()=>ne,listen:()=>U,once:()=>F});async function lt(t,e){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(t,e),await s("plugin:event|unlisten",{event:t,eventId:e})}async function U(t,e,n){var i;let r=typeof n?.target=="string"?{kind:"AnyLabel",label:n.target}:(i=n?.target)!==null&&i!==void 0?i:{kind:"Any"};return s("plugin:event|listen",{event:t,target:r,handler:Se(e)}).then(o=>async()=>lt(t,o))}async function F(t,e,n){return U(t,i=>{lt(t,i.id),e(i)},n)}async function te(t,e){await s("plugin:event|emit",{event:t,payload:e})}async function ne(t,e,n){await s("plugin:event|emit_to",{target:typeof t=="string"?{kind:"AnyLabel",label:t}:t,event:e,payload:n})}var w,K=g(()=>{B();(function(t){t.WINDOW_RESIZED="tauri://resize",t.WINDOW_MOVED="tauri://move",t.WINDOW_CLOSE_REQUESTED="tauri://close-requested",t.WINDOW_DESTROYED="tauri://destroyed",t.WINDOW_FOCUS="tauri://focus",t.WINDOW_BLUR="tauri://blur",t.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",t.WINDOW_THEME_CHANGED="tauri://theme-changed",t.WINDOW_CREATED="tauri://window-created",t.WINDOW_SUSPENDED="tauri://suspended",t.WINDOW_RESUMED="tauri://resumed",t.WEBVIEW_CREATED="tauri://webview-created",t.DRAG_ENTER="tauri://drag-enter",t.DRAG_OVER="tauri://drag-over",t.DRAG_DROP="tauri://drag-drop",t.DRAG_LEAVE="tauri://drag-leave"})(w||(w={}))});function ie(t){return t==null?null:typeof t=="string"?t:t instanceof Re?t.rid:t}var Re,ut=g(()=>{B();Re=class t extends we{constructor(e){super(e)}static async new(e,n,i){return s("plugin:image|new",{rgba:ie(e),width:n,height:i}).then(r=>new t(r))}static async fromBytes(e){return s("plugin:image|from_bytes",{bytes:ie(e)}).then(n=>new t(n))}static async fromPath(e){return s("plugin:image|from_path",{path:e}).then(n=>new t(n))}async rgba(){return s("plugin:image|rgba",{rid:this.rid}).then(e=>new Uint8Array(e))}async size(){return s("plugin:image|size",{rid:this.rid})}}});function We(){return new D(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function xe(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new D(e,{skip:!0})))}var De,$e,ct,Ue,D,dt,ht,wt,pt,qe=g(()=>{pe();pe();K();B();ut();(function(t){t[t.Critical=1]="Critical",t[t.Informational=2]="Informational"})(De||(De={}));$e=class{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}};(function(t){t.None="none",t.Normal="normal",t.Indeterminate="indeterminate",t.Paused="paused",t.Error="error"})(ct||(ct={}));Ue=["tauri://created","tauri://error"],D=class{constructor(e,n={}){var i;this.label=e,this.listeners=Object.create(null),n?.skip||s("plugin:window|create",{options:{...n,parent:typeof n.parent=="string"?n.parent:(i=n.parent)===null||i===void 0?void 0:i.label,label:e}}).then(async()=>this.emit("tauri://created")).catch(async r=>this.emit("tauri://error",r))}static async getByLabel(e){var n;return(n=(await xe()).find(i=>i.label===e))!==null&&n!==void 0?n:null}static getCurrent(){return We()}static async getAll(){return xe()}static async getFocusedWindow(){for(let e of await xe())if(await e.isFocused())return e;return null}async listen(e,n){return this._handleTauriEvent(e,n)?()=>{let i=this.listeners[e];i.splice(i.indexOf(n),1)}:U(e,n,{target:{kind:"Window",label:this.label}})}async once(e,n){return this._handleTauriEvent(e,n)?()=>{let i=this.listeners[e];i.splice(i.indexOf(n),1)}:F(e,n,{target:{kind:"Window",label:this.label}})}async emit(e,n){if(Ue.includes(e)){for(let i of this.listeners[e]||[])i({event:e,id:-1,payload:n});return}return te(e,n)}async emitTo(e,n,i){if(Ue.includes(n)){for(let r of this.listeners[n]||[])r({event:n,id:-1,payload:i});return}return ne(e,n,i)}_handleTauriEvent(e,n){return Ue.includes(e)?(e in this.listeners?this.listeners[e].push(n):this.listeners[e]=[n],!0):!1}async scaleFactor(){return s("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return s("plugin:window|inner_position",{label:this.label}).then(e=>new y(e))}async outerPosition(){return s("plugin:window|outer_position",{label:this.label}).then(e=>new y(e))}async innerSize(){return s("plugin:window|inner_size",{label:this.label}).then(e=>new A(e))}async outerSize(){return s("plugin:window|outer_size",{label:this.label}).then(e=>new A(e))}async isFullscreen(){return s("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return s("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return s("plugin:window|is_maximized",{label:this.label})}async isFocused(){return s("plugin:window|is_focused",{label:this.label})}async isDecorated(){return s("plugin:window|is_decorated",{label:this.label})}async isResizable(){return s("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return s("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return s("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return s("plugin:window|is_closable",{label:this.label})}async isVisible(){return s("plugin:window|is_visible",{label:this.label})}async title(){return s("plugin:window|title",{label:this.label})}async theme(){return s("plugin:window|theme",{label:this.label})}async isAlwaysOnTop(){return s("plugin:window|is_always_on_top",{label:this.label})}async activityName(){return s("plugin:window|activity_name",{label:this.label})}async sceneIdentifier(){return s("plugin:window|scene_identifier",{label:this.label})}async center(){return s("plugin:window|center",{label:this.label})}async requestUserAttention(e){let n=null;return e&&(e===De.Critical?n={type:"Critical"}:n={type:"Informational"}),s("plugin:window|request_user_attention",{label:this.label,value:n})}async setResizable(e){return s("plugin:window|set_resizable",{label:this.label,value:e})}async setEnabled(e){return s("plugin:window|set_enabled",{label:this.label,value:e})}async isEnabled(){return s("plugin:window|is_enabled",{label:this.label})}async setMaximizable(e){return s("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return s("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return s("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return s("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return s("plugin:window|maximize",{label:this.label})}async unmaximize(){return s("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return s("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return s("plugin:window|minimize",{label:this.label})}async unminimize(){return s("plugin:window|unminimize",{label:this.label})}async show(){return s("plugin:window|show",{label:this.label})}async hide(){return s("plugin:window|hide",{label:this.label})}async close(){return s("plugin:window|close",{label:this.label})}async destroy(){return s("plugin:window|destroy",{label:this.label})}async setDecorations(e){return s("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return s("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return s("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return s("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return s("plugin:window|set_always_on_top",{label:this.label,value:e})}async setAlwaysOnBottom(e){return s("plugin:window|set_always_on_bottom",{label:this.label,value:e})}async setContentProtected(e){return s("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){return s("plugin:window|set_size",{label:this.label,value:e instanceof P?e:new P(e)})}async setMinSize(e){return s("plugin:window|set_min_size",{label:this.label,value:e instanceof P?e:e?new P(e):null})}async setMaxSize(e){return s("plugin:window|set_max_size",{label:this.label,value:e instanceof P?e:e?new P(e):null})}async setSizeConstraints(e){function n(i){return i?{Logical:i}:null}return s("plugin:window|set_size_constraints",{label:this.label,value:{minWidth:n(e?.minWidth),minHeight:n(e?.minHeight),maxWidth:n(e?.maxWidth),maxHeight:n(e?.maxHeight)}})}async setPosition(e){return s("plugin:window|set_position",{label:this.label,value:e instanceof L?e:new L(e)})}async setFullscreen(e){return s("plugin:window|set_fullscreen",{label:this.label,value:e})}async setSimpleFullscreen(e){return s("plugin:window|set_simple_fullscreen",{label:this.label,value:e})}async setFocus(){return s("plugin:window|set_focus",{label:this.label})}async setFocusable(e){return s("plugin:window|set_focusable",{label:this.label,value:e})}async setIcon(e){return s("plugin:window|set_icon",{label:this.label,value:ie(e)})}async setSkipTaskbar(e){return s("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return s("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return s("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return s("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setBackgroundColor(e){return s("plugin:window|set_background_color",{color:e})}async setCursorPosition(e){return s("plugin:window|set_cursor_position",{label:this.label,value:e instanceof L?e:new L(e)})}async setIgnoreCursorEvents(e){return s("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return s("plugin:window|start_dragging",{label:this.label})}async startResizeDragging(e){return s("plugin:window|start_resize_dragging",{label:this.label,value:e})}async setBadgeCount(e){return s("plugin:window|set_badge_count",{label:this.label,value:e})}async setBadgeLabel(e){return s("plugin:window|set_badge_label",{label:this.label,value:e})}async setOverlayIcon(e){return s("plugin:window|set_overlay_icon",{label:this.label,value:e?ie(e):void 0})}async setProgressBar(e){return s("plugin:window|set_progress_bar",{label:this.label,value:e})}async setVisibleOnAllWorkspaces(e){return s("plugin:window|set_visible_on_all_workspaces",{label:this.label,value:e})}async setTitleBarStyle(e){return s("plugin:window|set_title_bar_style",{label:this.label,value:e})}async setTheme(e){return s("plugin:window|set_theme",{label:this.label,value:e})}async onResized(e){return this.listen(w.WINDOW_RESIZED,n=>{n.payload=new A(n.payload),e(n)})}async onMoved(e){return this.listen(w.WINDOW_MOVED,n=>{n.payload=new y(n.payload),e(n)})}async onCloseRequested(e){return this.listen(w.WINDOW_CLOSE_REQUESTED,async n=>{let i=new $e(n);await e(i),i.isPreventDefault()||await this.destroy()})}async onDragDropEvent(e){let n=await this.listen(w.DRAG_ENTER,a=>{e({...a,payload:{type:"enter",paths:a.payload.paths,position:new y(a.payload.position)}})}),i=await this.listen(w.DRAG_OVER,a=>{e({...a,payload:{type:"over",position:new y(a.payload.position)}})}),r=await this.listen(w.DRAG_DROP,a=>{e({...a,payload:{type:"drop",paths:a.payload.paths,position:new y(a.payload.position)}})}),o=await this.listen(w.DRAG_LEAVE,a=>{e({...a,payload:{type:"leave"}})});return()=>{n(),r(),i(),o()}}async onFocusChanged(e){let n=await this.listen(w.WINDOW_FOCUS,r=>{e({...r,payload:!0})}),i=await this.listen(w.WINDOW_BLUR,r=>{e({...r,payload:!1})});return()=>{n(),i()}}async onScaleChanged(e){return this.listen(w.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(w.WINDOW_THEME_CHANGED,e)}};(function(t){t.Disabled="disabled",t.Throttle="throttle",t.Suspend="suspend"})(dt||(dt={}));(function(t){t.Default="default",t.FluentOverlay="fluentOverlay"})(ht||(ht={}));(function(t){t.AppearanceBased="appearanceBased",t.Light="light",t.Dark="dark",t.MediumLight="mediumLight",t.UltraDark="ultraDark",t.Titlebar="titlebar",t.Selection="selection",t.Menu="menu",t.Popover="popover",t.Sidebar="sidebar",t.HeaderView="headerView",t.Sheet="sheet",t.WindowBackground="windowBackground",t.HudWindow="hudWindow",t.FullScreenUI="fullScreenUI",t.Tooltip="tooltip",t.ContentBackground="contentBackground",t.UnderWindowBackground="underWindowBackground",t.UnderPageBackground="underPageBackground",t.Mica="mica",t.Blur="blur",t.Acrylic="acrylic",t.Tabbed="tabbed",t.TabbedDark="tabbedDark",t.TabbedLight="tabbedLight"})(wt||(wt={}));(function(t){t.FollowsWindowActiveState="followsWindowActiveState",t.Active="active",t.Inactive="inactive"})(pt||(pt={}))});function Ne(){return new Y(We(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function gt(){return s("plugin:webview|get_all_webviews").then(t=>t.map(e=>new Y(new D(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}var ze,Y,ft=g(()=>{pe();K();B();qe();ze=["tauri://created","tauri://error"],Y=class{constructor(e,n,i){this.window=e,this.label=n,this.listeners=Object.create(null),i?.skip||s("plugin:webview|create_webview",{windowLabel:e.label,options:{...i,label:n}}).then(async()=>this.emit("tauri://created")).catch(async r=>this.emit("tauri://error",r))}static async getByLabel(e){var n;return(n=(await gt()).find(i=>i.label===e))!==null&&n!==void 0?n:null}static getCurrent(){return Ne()}static async getAll(){return gt()}async listen(e,n){return this._handleTauriEvent(e,n)?()=>{let i=this.listeners[e];i.splice(i.indexOf(n),1)}:U(e,n,{target:{kind:"Webview",label:this.label}})}async once(e,n){return this._handleTauriEvent(e,n)?()=>{let i=this.listeners[e];i.splice(i.indexOf(n),1)}:F(e,n,{target:{kind:"Webview",label:this.label}})}async emit(e,n){if(ze.includes(e)){for(let i of this.listeners[e]||[])i({event:e,id:-1,payload:n});return}return te(e,n)}async emitTo(e,n,i){if(ze.includes(n)){for(let r of this.listeners[n]||[])r({event:n,id:-1,payload:i});return}return ne(e,n,i)}_handleTauriEvent(e,n){return ze.includes(e)?(e in this.listeners?this.listeners[e].push(n):this.listeners[e]=[n],!0):!1}async position(){return s("plugin:webview|webview_position",{label:this.label}).then(e=>new y(e))}async size(){return s("plugin:webview|webview_size",{label:this.label}).then(e=>new A(e))}async close(){return s("plugin:webview|webview_close",{label:this.label})}async setSize(e){return s("plugin:webview|set_webview_size",{label:this.label,value:e instanceof P?e:new P(e)})}async setPosition(e){return s("plugin:webview|set_webview_position",{label:this.label,value:e instanceof L?e:new L(e)})}async setFocus(){return s("plugin:webview|set_webview_focus",{label:this.label})}async setAutoResize(e){return s("plugin:webview|set_webview_auto_resize",{label:this.label,value:e})}async hide(){return s("plugin:webview|webview_hide",{label:this.label})}async show(){return s("plugin:webview|webview_show",{label:this.label})}async setZoom(e){return s("plugin:webview|set_webview_zoom",{label:this.label,value:e})}async reparent(e){return s("plugin:webview|reparent",{label:this.label,window:typeof e=="string"?e:e.label})}async clearAllBrowsingData(){return s("plugin:webview|clear_all_browsing_data")}async setBackgroundColor(e){return s("plugin:webview|set_webview_background_color",{color:e})}async onDragDropEvent(e){let n=await this.listen(w.DRAG_ENTER,a=>{e({...a,payload:{type:"enter",paths:a.payload.paths,position:new y(a.payload.position)}})}),i=await this.listen(w.DRAG_OVER,a=>{e({...a,payload:{type:"over",position:new y(a.payload.position)}})}),r=await this.listen(w.DRAG_DROP,a=>{e({...a,payload:{type:"drop",paths:a.payload.paths,position:new y(a.payload.position)}})}),o=await this.listen(w.DRAG_LEAVE,a=>{e({...a,payload:{type:"leave"}})});return()=>{n(),r(),i(),o()}}}});function Yt(){let t=Ne();return new O(t.label,{skip:!0})}async function bt(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new O(e,{skip:!0})))}function Zt(t,e){(Array.isArray(e)?e:[e]).forEach(n=>{Object.getOwnPropertyNames(n.prototype).forEach(i=>{var r;typeof t.prototype=="object"&&t.prototype&&i in t.prototype||Object.defineProperty(t.prototype,i,(r=Object.getOwnPropertyDescriptor(n.prototype,i))!==null&&r!==void 0?r:Object.create(null))})})}var O,Me=g(()=>{ft();qe();K();B();O=class t{constructor(e,n={}){var i;this.label=e,this.listeners=Object.create(null),n?.skip||s("plugin:webview|create_webview_window",{options:{...n,parent:typeof n.parent=="string"?n.parent:(i=n.parent)===null||i===void 0?void 0:i.label,label:e}}).then(async()=>this.emit("tauri://created")).catch(async r=>this.emit("tauri://error",r))}static async getByLabel(e){var n;let i=(n=(await bt()).find(r=>r.label===e))!==null&&n!==void 0?n:null;return i?new t(i.label,{skip:!0}):null}static getCurrent(){return Yt()}static async getAll(){return bt()}async listen(e,n){return this._handleTauriEvent(e,n)?()=>{let i=this.listeners[e];i.splice(i.indexOf(n),1)}:U(e,n,{target:{kind:"WebviewWindow",label:this.label}})}async once(e,n){return this._handleTauriEvent(e,n)?()=>{let i=this.listeners[e];i.splice(i.indexOf(n),1)}:F(e,n,{target:{kind:"WebviewWindow",label:this.label}})}async setBackgroundColor(e){return s("plugin:window|set_background_color",{color:e}).then(()=>s("plugin:webview|set_webview_background_color",{color:e}))}};Zt(O,[D,Y])});var vt={};W(vt,{createGoogleLogin:()=>Xt,initializeGoogleLogin:()=>_t,subscribeGoogleLogin:()=>Qt});function mt(t,e=null){ge.forEach(n=>{try{n(t,e)}catch(i){console.error("Google listener error:",i)}})}function Qt(t){return ge.push(t),()=>{let e=ge.indexOf(t);e!==-1&&ge.splice(e,1)}}var yt,ge,fe,Be,_t,Xt,Pt=g(()=>{Te();Oe();Me();ae();yt=!1,ge=[];fe=null,Be=async t=>{try{if(!t?.includes("token="))return;let n=new URLSearchParams(t.split("?")[1]).get("token");console.log("Google login token:",n);let r=await(await fetch("https://www.googleapis.com/oauth2/v3/userinfo",{headers:{Authorization:`Bearer ${n}`}})).json(),o={id:r.sub,firstName:r.given_name,lastName:r.family_name,email:r.email,photo:r.picture,accessToken:n};console.log("Google user profile:",o),localStorage.setItem("user",JSON.stringify(o)),localStorage.setItem("idToken",n),mt(o,null)}catch(e){mt(null,e)}},_t=async()=>{if(!yt&&(yt=!0,R&&le.addListener("appUrlOpen",t=>{Be(t.url)}),x)){let{listen:t}=await Promise.resolve().then(()=>(K(),Ie));await t("deep-link://open-url",async e=>{let n=e.payload;if(typeof n=="object"&&(n=n?.url||n?.payload||null),!!n){if(fe)try{await fe.close(),fe=null}catch{}Be(n)}})}},Xt=async({appId:t="tevrocsoft",appName:e="Tevroc",serviceUrl:n="https://tevrocsoftapi.netlify.app"}={})=>{console.log("appId:",t,"serviceUrl:",n),console.log(R,x),await _t();let i=`${n}/login?mode=mobile&app=${encodeURIComponent(t)}&name=${encodeURIComponent(e)}`;if(R){await ce.open({url:i});return}if(x){let c=`${n}/login?mode=desktop&app=${encodeURIComponent(t)}&name=${encodeURIComponent(e)}`,d=new O("auth",{url:c,title:`${e} Login`,width:550,height:500,resizable:!0,center:!0});fe=d,d.once("tauri://created",()=>{console.log("Auth window opened")}),d.once("tauri://error",p=>{console.error("Auth window error:",p)});return}let r=!0,o=typeof window<"u"?window.location.host:t,u=`${n}/login?mode=${r?"localhost":"netlify"}&app=${encodeURIComponent(o)}&name=${encodeURIComponent(e)}`;if(r){let c=window.open(u,"googleLogin","width=500,height=650");if(!c){console.error("Popup blocked");return}let d=l=>{if(l.origin===n&&l.data?.type==="google-auth"){let h=l.data?.token||null,j=h?`${window.location.href}${window.location.href.includes("?")?"&":"?"}token=${h}`:window.location.href;c.close(),window.removeEventListener("message",d),Be(j)}};window.addEventListener("message",d);let p=setInterval(()=>{c.closed&&(clearInterval(p),window.removeEventListener("message",d))},500);return}}});var Tt={};W(Tt,{createPayment:()=>Lt,default:()=>Et,initializePayment:()=>Fe,subscribePaymentStatus:()=>en});function Ct(t,e=null){be.forEach(n=>{try{n(t,e)}catch(i){console.error("Payment listener error:",i)}})}function en(t){return be.push(t),()=>{let e=be.indexOf(t);e!==-1&&be.splice(e,1)}}function Et({externalCallback:t=()=>{}}={}){return Fe(t),{createPayment:Lt}}var kt,be,ye,tn,re,At,Fe,Lt,Ot=g(()=>{Te();Oe();Me();ae();kt=!1,be=[];ye=null,tn=[],re=(...t)=>{t.forEach(e=>{let n={message:e,time:new Date().toISOString()};tn.push(n),console.log(n)})},At=async(t,e=()=>{})=>{try{if(re("PAYMENT CALLBACK:",t),!t?.includes("state="))return;let i=new URLSearchParams(t.split("?")[1]).get("state");re("PAYMENT RESULT:",i),i=="success"?re("PAYMENT SUCCESS"):re("PAYMENT FAILED"),e(i,null),Ct(i,null)}catch(n){re("PAYMENT CALLBACK ERROR:",n.message),e(null,n),Ct(null,n)}},Fe=async(t=()=>{})=>{if(!kt&&(kt=!0,R&&le.addListener("appUrlOpen",e=>{At(e.url,t)}),x)){let{listen:e}=await Promise.resolve().then(()=>(K(),Ie));await e("deep-link://open-url",async n=>{let i=n.payload;if(typeof i=="object"&&(i=i?.url||i?.payload||null),!!i){if(ye)try{await ye.close(),ye=null}catch{}At(i,t)}})}},Lt=async(t,{appId:e="tevrocsoft",serviceUrl:n="https://tevrocsoftapi.netlify.app",externalCallback:i=()=>{}}={})=>{await Fe(i);let r=Math.round(Number(t)*100),o=`${n}/pay`,a=`${o}?mode=mobile&amount=${r}&app=${e}`;if(R){await ce.open({url:a});return}if(x){let d=`${o}?mode=desktop&amount=${r}&app=${e}`,p=new O("payment",{url:d,title:"Complete Payment",width:550,height:600,resizable:!0,center:!0});ye=p,p.once("tauri://created",()=>{console.log("Payment window opened")}),p.once("tauri://error",l=>{console.error("Payment window error:",l)});return}let c=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"?"localhost":"netlify";window.location.href=`${o}?mode=${c}&amount=${r}&app=${e}`}});var An={};W(An,{TevrocClient:()=>me,TevrocError:()=>G,createClient:()=>on});var Ge=null;async function nn(){return Ge||(Ge=await Promise.resolve().then(()=>(ae(),Ke))),Ge}var je=null;async function rn(){return je||(je=await Promise.resolve().then(()=>(Pt(),vt))),je}var He=null;async function sn(){return He||(He=await Promise.resolve().then(()=>(Ot(),Tt))),He}var G=class extends Error{constructor(e,n={}){super(e),this.name="TevrocError",this.status=n.status,this.code=n.code,this.details=n.details,this.response=n.response}};function on(t={}){return new me(t)}var me=class{constructor(e={}){console.log(e);let n=e.baseUrl??e.url,i=e.serviceUrl??e.url;if(!n)throw new TypeError("createClient requires a baseUrl");if(this.baseUrl=It(n),this.serviceUrl=It(i),this.appId=e.appId,this.appName=e.appName,this.fetch=(e.fetch??globalThis.fetch).bind(globalThis),typeof this.fetch!="function")throw new TypeError("No fetch implementation available");this.timeoutMs=e.timeoutMs??3e4,this.defaultHeaders=kn(e.headers),this.token=e.token??null,this.auth=un(this),this.entities=cn(this),this.functions=hn(this),this.integrations=wn(this),this.agents=pn(this),this.logs=fn(this),this.connectors=bn(this),this.customIntegrations=yn(this),this.sso=mn(this),this.files=_n(this),this.payments=ln(this),this.platform=an(this)}setToken(e){return this.token=e||null,this.token?localStorage.setItem("tevroc_access_token",this.token):localStorage.removeItem("tevroc_access_token"),this}clearToken(){return this.token=null,localStorage.removeItem("tevroc_access_token"),this}async request(e,n={}){let i=(n.method??"GET").toUpperCase(),r=new Headers(this.defaultHeaders),o=n.query?Pn(n.query):"",a=`${this.baseUrl}${e.startsWith("/")?e:`/${e}`}${o}`,u=new AbortController,c=setTimeout(()=>u.abort(),n.timeoutMs??this.timeoutMs),d=this.token||localStorage.getItem("tevroc_access_token");d&&n.auth!==!1&&r.set("authorization",`Bearer ${d}`),console.log(d);let p=n.body;if(p!=null&&Cn(p)&&(r.set("content-type","application/json"),p=JSON.stringify(p)),n.headers)for(let[l,h]of Object.entries(n.headers))h!=null&&r.set(l,String(h));try{let l=await this.fetch(a,{method:i,headers:r,body:p,signal:n.signal??u.signal});return await vn(l,n.parseAs)}catch(l){throw l?.name==="AbortError"?new G("Request timed out",{code:"timeout"}):l instanceof G?l:new G(l?.message??"Network request failed",{code:"network_error",details:l})}finally{clearTimeout(c)}}};function an(t){return(async function(){let{isNative:e,isCapacitor:n,isTauri:i,platform:r}=await nn();return{platform:r,isCapacitor:n,isTauri:i,isNative:e}})()}function ln(t){return{create:async({amountZAR:e,appId:n="tevrocsoft",mode:i="web"})=>{let{createPayment:r}=await sn();return await r(e,{appId:n,serviceUrl:t.serviceUrl,mode:i})},onstatus:e=>{if(typeof e!="function")throw new Error("onstatus requires a function");return subscribePaymentStatus(e)}}}function un(t){return{async register(e){let n=await t.request("/auth/register",{method:"POST",body:e,auth:!1});return n.token&&t.setToken(n.token),n},loginWithProvider:async(e,n,i=()=>{})=>{if(e==="google"){let{createGoogleLogin:r,subscribeGoogleLogin:o}=await rn();if(console.log({serviceUrl:t.serviceUrl,appId:t.appId,appName:t.appName}),r({serviceUrl:t.serviceUrl,appId:t.appId,appName:t.appName}),n){let a=o(async(u,c)=>{if(console.log("Google callback:",u,c),a(),!u)return;let d=await t.request("/auth/google",{method:"POST",body:{accessToken:u.accessToken},auth:!1});console.log(d),i(d.token),console.log("Redirecting to:",n),window.location.href=n})}}},googleLogin:e=>createGoogleLogin(e),onGoogleLogin:e=>subscribeGoogleLogin(e),async login(e){let n=await t.request("/auth/login",{method:"POST",body:e,auth:!1});return n.token&&t.setToken(n.token),n},async logout(){let e=await t.request("/auth/logout",{method:"POST"});return t.clearToken(),e},me:()=>t.request("/auth/me"),verifyOtp:e=>t.request("/auth/verify-otp",{method:"POST",body:e,auth:!1}),changePassword:e=>t.request("/auth/change-password",{method:"POST",body:e}),resetPassword:e=>t.request("/auth/reset-password",{method:"POST",body:e,auth:!1}),loginUrl:e=>t.request("/auth/login-url",{query:e?{redirectTo:e}:void 0,auth:!1})}}function cn(t){return new Proxy({},{get(e,n){if(typeof n=="string")return dn(t,n)}})}function dn(t,e){let n=`/entities/${encodeURIComponent(e)}`;return{list:i=>t.request(n,{query:i}),get:i=>t.request(`${n}/${encodeURIComponent(i)}`),create:i=>t.request(n,{method:"POST",body:i}),update:(i,r)=>t.request(`${n}/${encodeURIComponent(i)}`,{method:"PATCH",body:r}),delete:i=>t.request(`${n}/${encodeURIComponent(i)}`,{method:"DELETE"}),query:(i={})=>t.request(`${n}/query`,{method:"POST",body:i}),bulkCreate:i=>t.request(`${n}/bulk`,{method:"POST",body:{records:i}}),bulkUpdate:i=>t.request(`${n}/bulk`,{method:"PATCH",body:{records:i}}),bulkDelete:i=>t.request(`${n}/bulk`,{method:"DELETE",body:{ids:i}}),import:i=>t.request(`${n}/import`,{method:"POST",body:{records:i}})}}function hn(t){return new Proxy({invoke:(e,n)=>t.request(`/functions/${encodeURIComponent(e)}`,{method:"POST",body:n})},{get(e,n){if(n in e)return e[n];if(typeof n=="string")return i=>e.invoke(n,i)}})}function wn(t){return{Core:{InvokeLLM:e=>t.request("/integrations/core/invoke-llm",{method:"POST",body:e}),GenerateImage:e=>t.request("/integrations/core/generate-image",{method:"POST",body:e}),UploadFile:(e,n={})=>St(t,"/integrations/core/upload-file",e,n),UploadPrivateFile:(e,n={})=>St(t,"/integrations/core/upload-private-file",e,n),CreateFileSignedUrl:e=>t.request("/integrations/core/create-file-signed-url",{method:"POST",body:e}),SendEmail:e=>t.request("/integrations/core/send-email",{method:"POST",body:e}),ExtractDataFromUploadedFile:e=>t.request("/integrations/core/extract-data-from-uploaded-file",{method:"POST",body:e})}}}function pn(t){return new Proxy({},{get(e,n){if(typeof n=="string")return gn(t,n)}})}function gn(t,e){let n=`/agents/${encodeURIComponent(e)}/conversations`;return{createConversation:(i={})=>t.request(n,{method:"POST",body:i}),listConversations:()=>t.request(n),getConversation:i=>t.request(`${n}/${encodeURIComponent(i)}`),deleteConversation:i=>t.request(`${n}/${encodeURIComponent(i)}`,{method:"DELETE"}),addMessage:(i,r)=>t.request(`${n}/${encodeURIComponent(i)}/messages`,{method:"POST",body:r}),listMessages:i=>t.request(`${n}/${encodeURIComponent(i)}/messages`)}}function fn(t){return{list:e=>t.request("/app-logs",{query:e}),create:e=>t.request("/app-logs",{method:"POST",body:e}),get:e=>t.request(`/app-logs/${encodeURIComponent(e)}`)}}function bn(t){return{list:()=>t.request("/connectors"),get:e=>t.request(`/connectors/${encodeURIComponent(e)}`),connect:(e,n={})=>t.request(`/connectors/${encodeURIComponent(e)}/connect`,{method:"POST",body:n}),disconnect:e=>t.request(`/connectors/${encodeURIComponent(e)}/disconnect`,{method:"POST"}),status:e=>t.request(`/connectors/${encodeURIComponent(e)}/status`),user:{list:()=>t.request("/user-connectors"),get:e=>t.request(`/user-connectors/${encodeURIComponent(e)}`),refresh:e=>t.request(`/user-connectors/${encodeURIComponent(e)}/refresh`,{method:"POST"}),delete:e=>t.request(`/user-connectors/${encodeURIComponent(e)}`,{method:"DELETE"})}}}function yn(t){return new Proxy({invoke:(e,n,i)=>t.request(`/custom-integrations/${encodeURIComponent(e)}/${encodeURIComponent(n)}`,{method:"POST",body:i})},{get(e,n){if(n in e)return e[n];if(typeof n=="string")return new Proxy({},{get(i,r){if(typeof r=="string")return o=>e.invoke(n,r,o)}})}})}function mn(t){return{accessToken:e=>t.request("/sso/access-token",{method:"POST",body:e,auth:!1}),callback:e=>t.request("/sso/callback",{query:e,auth:!1})}}function _n(t){return{url:e=>`${t.baseUrl}/files/${encodeURIComponent(e)}`,privateUrl:e=>`${t.baseUrl}/private-files/${encodeURIComponent(e)}`,get:e=>t.request(`/files/${encodeURIComponent(e)}`,{parseAs:"response",auth:!1}),getPrivate:e=>t.request(`/private-files/${encodeURIComponent(e)}`,{parseAs:"response"})}}function St(t,e,n,i){let r={};return i.filename&&(r["x-filename"]=i.filename),i.contentType&&(r["content-type"]=i.contentType),t.request(e,{method:"POST",body:n,headers:r})}async function vn(t,e){if(e==="response")return t;let i=(t.headers.get("content-type")??"").includes("application/json"),r=i?await t.json():await t.text();if(!t.ok){let o=i&&r?.error?r.error:{};throw new G(o.message??t.statusText,{status:t.status,code:o.code??"api_error",details:o.details??r,response:t})}return r}function Pn(t){let e=new URLSearchParams;for(let[i,r]of Object.entries(t))if(r!=null)if(Array.isArray(r))for(let o of r)e.append(i,String(o));else e.set(i,String(r));let n=e.toString();return n?`?${n}`:""}function It(t){return String(t).replace(/\/+$/,"")}function kn(t={}){return Object.fromEntries(new Headers(t).entries())}function Cn(t){let e=typeof ArrayBuffer<"u"&&t instanceof ArrayBuffer,n=typeof Blob<"u"&&t instanceof Blob,i=typeof FormData<"u"&&t instanceof FormData;return typeof t=="object"&&!e&&!n&&!i}return zt(An);})();
|
|
1
|
+
var Tevroc=(()=>{var ke=Object.defineProperty;var $t=Object.getOwnPropertyDescriptor;var Wt=Object.getOwnPropertyNames;var qt=Object.prototype.hasOwnProperty;var f=(t,e,n)=>()=>{if(n)throw n[0];try{return t&&(e=t(t=0)),e}catch(i){throw n=[i],i}};var q=(t,e)=>{for(var n in e)ke(t,n,{get:e[n],enumerable:!0})},zt=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Wt(e))!qt.call(t,r)&&r!==n&&ke(t,r,{get:()=>e[r],enumerable:!(i=$t(e,r))||i.enumerable});return t};var Nt=t=>zt(ke({},"__esModule",{value:!0}),t);var Ye={};q(Ye,{isCapacitor:()=>x,isNative:()=>Bt,isTauri:()=>R,platform:()=>z});var Mt,z,x,R,Bt,ae=f(()=>{Mt=()=>{if(typeof window<"u"&&(window.__TAURI__||window.__TAURI_INTERNALS__))return"tauri";if(typeof window<"u"){if(window.Capacitor?.isNativePlatform?.())return window.Capacitor.getPlatform();if(window.Capacitor?.getPlatform){let t=window.Capacitor.getPlatform();if(t==="ios"||t==="android")return t}}return"web"},z=Mt(),x=z==="android"||z==="ios",R=z==="tauri",Bt=z==="android"||z==="ios"||z==="tauri"});var V,Z,Ft,jt,Gt,Ce,N,E,Ze,Qe,Ae,In,Ht,Vt,Jt,Kt,Le,xn,Xe,et,Te,Rn,Q=f(()=>{(function(t){t.Unimplemented="UNIMPLEMENTED",t.Unavailable="UNAVAILABLE"})(V||(V={}));Z=class extends Error{constructor(e,n,i){super(e),this.message=e,this.code=n,this.data=i}},Ft=t=>{var e,n;return t?.androidBridge?"android":!((n=(e=t?.webkit)===null||e===void 0?void 0:e.messageHandlers)===null||n===void 0)&&n.bridge?"ios":"web"},jt=t=>{let e=t.CapacitorCustomPlatform||null,n=t.Capacitor||{},i=n.Plugins=n.Plugins||{},r=()=>e!==null?e.name:Ft(t),o=()=>r()!=="web",a=l=>{let c=h.get(l);return!!(c?.platforms.has(r())||u(l))},u=l=>{var c;return(c=n.PluginHeaders)===null||c===void 0?void 0:c.find(G=>G.name===l)},d=l=>t.console.error(l),h=new Map,w=(l,c={})=>{let G=h.get(l);if(G)return console.warn(`Capacitor plugin "${l}" already registered. Cannot register plugins twice.`),G.proxy;let W=r(),H=u(l),T,Rt=async()=>(!T&&W in c?T=typeof c[W]=="function"?T=await c[W]():T=c[W]:e!==null&&!T&&"web"in c&&(T=typeof c.web=="function"?T=await c.web():T=c.web),T),Ut=(y,_)=>{var C,O;if(H){let I=H?.methods.find(k=>_===k.name);if(I)return I.rtype==="promise"?k=>n.nativePromise(l,_.toString(),k):(k,se)=>n.nativeCallback(l,_.toString(),k,se);if(y)return(C=y[_])===null||C===void 0?void 0:C.bind(y)}else{if(y)return(O=y[_])===null||O===void 0?void 0:O.bind(y);throw new Z(`"${l}" plugin is not implemented on ${W}`,V.Unimplemented)}},ve=y=>{let _,C=(...O)=>{let I=Rt().then(k=>{let se=Ut(k,y);if(se){let oe=se(...O);return _=oe?.remove,oe}else throw new Z(`"${l}.${y}()" is not implemented on ${W}`,V.Unimplemented)});return y==="addListener"&&(I.remove=async()=>_()),I};return C.toString=()=>`${y.toString()}() { [capacitor code] }`,Object.defineProperty(C,"name",{value:y,writable:!1,configurable:!1}),C},Je=ve("addListener"),Ke=ve("removeListener"),Dt=(y,_)=>{let C=Je({eventName:y},_),O=async()=>{let k=await C;Ke({eventName:y,callbackId:k},_)},I=new Promise(k=>C.then(()=>k({remove:O})));return I.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await O()},I},Pe=new Proxy({},{get(y,_){switch(_){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return H?Dt:Je;case"removeListener":return Ke;default:return ve(_)}}});return i[l]=Pe,h.set(l,{name:l,proxy:Pe,platforms:new Set([...Object.keys(c),...H?[W]:[]])}),Pe};return n.convertFileSrc||(n.convertFileSrc=l=>l),n.getPlatform=r,n.handleError=d,n.isNativePlatform=o,n.isPluginAvailable=a,n.registerPlugin=w,n.Exception=Z,n.DEBUG=!!n.DEBUG,n.isLoggingEnabled=!!n.isLoggingEnabled,n},Gt=t=>t.Capacitor=jt(t),Ce=Gt(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),N=Ce.registerPlugin,E=class{constructor(){this.listeners={},this.retainedEventArguments={},this.windowListeners={}}addListener(e,n){let i=!1;this.listeners[e]||(this.listeners[e]=[],i=!0),this.listeners[e].push(n);let o=this.windowListeners[e];o&&!o.registered&&this.addWindowListener(o),i&&this.sendRetainedArgumentsForEvent(e);let a=async()=>this.removeListener(e,n);return Promise.resolve({remove:a})}async removeAllListeners(){this.listeners={};for(let e in this.windowListeners)this.removeWindowListener(this.windowListeners[e]);this.windowListeners={}}notifyListeners(e,n,i){let r=this.listeners[e];if(!r){if(i){let o=this.retainedEventArguments[e];o||(o=[]),o.push(n),this.retainedEventArguments[e]=o}return}r.forEach(o=>o(n))}hasListeners(e){var n;return!!(!((n=this.listeners[e])===null||n===void 0)&&n.length)}registerWindowListener(e,n){this.windowListeners[n]={registered:!1,windowEventName:e,pluginEventName:n,handler:i=>{this.notifyListeners(n,i)}}}unimplemented(e="not implemented"){return new Ce.Exception(e,V.Unimplemented)}unavailable(e="not available"){return new Ce.Exception(e,V.Unavailable)}async removeListener(e,n){let i=this.listeners[e];if(!i)return;let r=i.indexOf(n);this.listeners[e].splice(r,1),this.listeners[e].length||this.removeWindowListener(this.windowListeners[e])}addWindowListener(e){window.addEventListener(e.windowEventName,e.handler),e.registered=!0}removeWindowListener(e){e&&(window.removeEventListener(e.windowEventName,e.handler),e.registered=!1)}sendRetainedArgumentsForEvent(e){let n=this.retainedEventArguments[e];n&&(delete this.retainedEventArguments[e],n.forEach(i=>{this.notifyListeners(e,i)}))}},Ze=t=>encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),Qe=t=>t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent),Ae=class extends E{async getCookies(){let e=document.cookie,n={};return e.split(";").forEach(i=>{if(i.length<=0)return;let[r,o]=i.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");r=Qe(r).trim(),o=Qe(o).trim(),n[r]=o}),n}async setCookie(e){try{let n=Ze(e.key),i=Ze(e.value),r=e.expires?`; expires=${e.expires.replace("expires=","")}`:"",o=(e.path||"/").replace("path=",""),a=e.url!=null&&e.url.length>0?`domain=${e.url}`:"";document.cookie=`${n}=${i||""}${r}; path=${o}; ${a};`}catch(n){return Promise.reject(n)}}async deleteCookie(e){try{document.cookie=`${e.key}=; Max-Age=0`}catch(n){return Promise.reject(n)}}async clearCookies(){try{let e=document.cookie.split(";")||[];for(let n of e)document.cookie=n.replace(/^ +/,"").replace(/=.*/,`=;expires=${new Date().toUTCString()};path=/`)}catch(e){return Promise.reject(e)}}async clearAllCookies(){try{await this.clearCookies()}catch(e){return Promise.reject(e)}}},In=N("CapacitorCookies",{web:()=>new Ae}),Ht=async t=>new Promise((e,n)=>{let i=new FileReader;i.onload=()=>{let r=i.result;e(r.indexOf(",")>=0?r.split(",")[1]:r)},i.onerror=r=>n(r),i.readAsDataURL(t)}),Vt=(t={})=>{let e=Object.keys(t);return Object.keys(t).map(r=>r.toLocaleLowerCase()).reduce((r,o,a)=>(r[o]=t[e[a]],r),{})},Jt=(t,e=!0)=>t?Object.entries(t).reduce((i,r)=>{let[o,a]=r,u,d;return Array.isArray(a)?(d="",a.forEach(h=>{u=e?encodeURIComponent(h):h,d+=`${o}=${u}&`}),d.slice(0,-1)):(u=e?encodeURIComponent(a):a,d=`${o}=${u}`),`${i}&${d}`},"").substr(1):null,Kt=(t,e={})=>{let n=Object.assign({method:t.method||"GET",headers:t.headers},e),r=Vt(t.headers)["content-type"]||"";if(typeof t.data=="string")n.body=t.data;else if(r.includes("application/x-www-form-urlencoded")){let o=new URLSearchParams;for(let[a,u]of Object.entries(t.data||{}))o.set(a,u);n.body=o.toString()}else if(r.includes("multipart/form-data")||t.data instanceof FormData){let o=new FormData;if(t.data instanceof FormData)t.data.forEach((u,d)=>{o.append(d,u)});else for(let u of Object.keys(t.data))o.append(u,t.data[u]);n.body=o;let a=new Headers(n.headers);a.delete("content-type"),n.headers=a}else(r.includes("application/json")||typeof t.data=="object")&&(n.body=JSON.stringify(t.data));return n},Le=class extends E{async request(e){let n=Kt(e,e.webFetchExtra),i=Jt(e.params,e.shouldEncodeUrlParams),r=i?`${e.url}?${i}`:e.url,o=await fetch(r,n),a=o.headers.get("content-type")||"",{responseType:u="text"}=o.ok?e:{};a.includes("application/json")&&(u="json");let d,h;switch(u){case"arraybuffer":case"blob":h=await o.blob(),d=await Ht(h);break;case"json":d=await o.json();break;default:d=await o.text()}let w={};return o.headers.forEach((l,c)=>{w[c]=l}),{data:d,headers:w,status:o.status,url:o.url}}async get(e){return this.request(Object.assign(Object.assign({},e),{method:"GET"}))}async post(e){return this.request(Object.assign(Object.assign({},e),{method:"POST"}))}async put(e){return this.request(Object.assign(Object.assign({},e),{method:"PUT"}))}async patch(e){return this.request(Object.assign(Object.assign({},e),{method:"PATCH"}))}async delete(e){return this.request(Object.assign(Object.assign({},e),{method:"DELETE"}))}},xn=N("CapacitorHttp",{web:()=>new Le});(function(t){t.Dark="DARK",t.Light="LIGHT",t.Default="DEFAULT"})(Xe||(Xe={}));(function(t){t.StatusBar="StatusBar",t.NavigationBar="NavigationBar"})(et||(et={}));Te=class extends E{async setStyle(){this.unavailable("not available for web")}async setAnimation(){this.unavailable("not available for web")}async show(){this.unavailable("not available for web")}async hide(){this.unavailable("not available for web")}},Rn=N("SystemBars",{web:()=>new Te})});var tt=f(()=>{});var nt={};q(nt,{AppWeb:()=>Ee});var Ee,it=f(()=>{Q();Ee=class extends E{constructor(){super(),this.handleVisibilityChange=()=>{let e={isActive:document.hidden!==!0};this.notifyListeners("appStateChange",e),document.hidden?this.notifyListeners("pause",null):this.notifyListeners("resume",null)},document.addEventListener("visibilitychange",this.handleVisibilityChange,!1)}exitApp(){throw this.unimplemented("Not implemented on web.")}async getInfo(){throw this.unimplemented("Not implemented on web.")}async getLaunchUrl(){return{url:""}}async getState(){return{isActive:document.hidden!==!0}}async minimizeApp(){throw this.unimplemented("Not implemented on web.")}async toggleBackButtonHandler(){throw this.unimplemented("Not implemented on web.")}async getAppLanguage(){return{value:navigator.language.split("-")[0].toLowerCase()}}}});var le,Se=f(()=>{Q();tt();le=N("App",{web:()=>Promise.resolve().then(()=>(it(),nt)).then(t=>new t.AppWeb)})});var rt=f(()=>{});var st={};q(st,{Browser:()=>Yt,BrowserWeb:()=>ue});var ue,Yt,ot=f(()=>{Q();ue=class extends E{constructor(){super(),this._lastWindow=null}async open(e){this._lastWindow=window.open(e.url,e.windowName||"_blank")}async close(){return new Promise((e,n)=>{this._lastWindow!=null?(this._lastWindow.close(),this._lastWindow=null,e()):n("No active window to close!")})}},Yt=new ue});var ce,Oe=f(()=>{Q();rt();ce=N("Browser",{web:()=>Promise.resolve().then(()=>(ot(),st)).then(t=>new t.BrowserWeb)})});function g(t,e,n,i){if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?i:n==="a"?i.call(t):i?i.value:e.get(t)}function M(t,e,n,i,r){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?r.call(t,n):r?r.value=n:e.set(t,n),n}var at=f(()=>{});function Ie(t,e=!1){return window.__TAURI_INTERNALS__.transformCallback(t,e)}async function s(t,e={},n){return window.__TAURI_INTERNALS__.invoke(t,e,n)}var B,v,J,de,he,m,lt,we,F=f(()=>{at();m="__TAURI_TO_IPC_KEY__";lt=class{constructor(e){B.set(this,void 0),v.set(this,0),J.set(this,[]),de.set(this,void 0),M(this,B,e||(()=>{}),"f"),this.id=Ie(n=>{let i=n.index;if("end"in n){i==g(this,v,"f")?this.cleanupCallback():M(this,de,i,"f");return}let r=n.message;if(i==g(this,v,"f")){for(g(this,B,"f").call(this,r),M(this,v,g(this,v,"f")+1,"f");g(this,v,"f")in g(this,J,"f");){let o=g(this,J,"f")[g(this,v,"f")];g(this,B,"f").call(this,o),delete g(this,J,"f")[g(this,v,"f")],M(this,v,g(this,v,"f")+1,"f")}g(this,v,"f")===g(this,de,"f")&&this.cleanupCallback()}else g(this,J,"f")[i]=r})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(e){M(this,B,e,"f")}get onmessage(){return g(this,B,"f")}[(B=new WeakMap,v=new WeakMap,J=new WeakMap,de=new WeakMap,m)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[m]()}};we=class{get rid(){return g(this,he,"f")}constructor(e){he.set(this,void 0),M(this,he,e,"f")}async close(){return s("plugin:resources|close",{rid:this.rid})}};he=new WeakMap});var X,A,P,ee,b,L,pe=f(()=>{F();X=class{constructor(...e){this.type="Logical",e.length===1?"Logical"in e[0]?(this.width=e[0].Logical.width,this.height=e[0].Logical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toPhysical(e){return new A(this.width*e,this.height*e)}[m](){return{width:this.width,height:this.height}}toJSON(){return this[m]()}},A=class{constructor(...e){this.type="Physical",e.length===1?"Physical"in e[0]?(this.width=e[0].Physical.width,this.height=e[0].Physical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toLogical(e){return new X(this.width/e,this.height/e)}[m](){return{width:this.width,height:this.height}}toJSON(){return this[m]()}},P=class{constructor(e){this.size=e}toLogical(e){return this.size instanceof X?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof A?this.size:this.size.toPhysical(e)}[m](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[m]()}},ee=class{constructor(...e){this.type="Logical",e.length===1?"Logical"in e[0]?(this.x=e[0].Logical.x,this.y=e[0].Logical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toPhysical(e){return new b(this.x*e,this.y*e)}[m](){return{x:this.x,y:this.y}}toJSON(){return this[m]()}},b=class{constructor(...e){this.type="Physical",e.length===1?"Physical"in e[0]?(this.x=e[0].Physical.x,this.y=e[0].Physical.y):(this.x=e[0].x,this.y=e[0].y):(this.x=e[0],this.y=e[1])}toLogical(e){return new ee(this.x/e,this.y/e)}[m](){return{x:this.x,y:this.y}}toJSON(){return this[m]()}},L=class{constructor(e){this.position=e}toLogical(e){return this.position instanceof ee?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof b?this.position:this.position.toPhysical(e)}[m](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[m]()}}});var xe={};q(xe,{TauriEvent:()=>p,emit:()=>te,emitTo:()=>ne,listen:()=>U,once:()=>j});async function ut(t,e){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(t,e),await s("plugin:event|unlisten",{event:t,eventId:e})}async function U(t,e,n){var i;let r=typeof n?.target=="string"?{kind:"AnyLabel",label:n.target}:(i=n?.target)!==null&&i!==void 0?i:{kind:"Any"};return s("plugin:event|listen",{event:t,target:r,handler:Ie(e)}).then(o=>async()=>ut(t,o))}async function j(t,e,n){return U(t,i=>{ut(t,i.id),e(i)},n)}async function te(t,e){await s("plugin:event|emit",{event:t,payload:e})}async function ne(t,e,n){await s("plugin:event|emit_to",{target:typeof t=="string"?{kind:"AnyLabel",label:t}:t,event:e,payload:n})}var p,K=f(()=>{F();(function(t){t.WINDOW_RESIZED="tauri://resize",t.WINDOW_MOVED="tauri://move",t.WINDOW_CLOSE_REQUESTED="tauri://close-requested",t.WINDOW_DESTROYED="tauri://destroyed",t.WINDOW_FOCUS="tauri://focus",t.WINDOW_BLUR="tauri://blur",t.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",t.WINDOW_THEME_CHANGED="tauri://theme-changed",t.WINDOW_CREATED="tauri://window-created",t.WINDOW_SUSPENDED="tauri://suspended",t.WINDOW_RESUMED="tauri://resumed",t.WEBVIEW_CREATED="tauri://webview-created",t.DRAG_ENTER="tauri://drag-enter",t.DRAG_OVER="tauri://drag-over",t.DRAG_DROP="tauri://drag-drop",t.DRAG_LEAVE="tauri://drag-leave"})(p||(p={}))});function ie(t){return t==null?null:typeof t=="string"?t:t instanceof Re?t.rid:t}var Re,ct=f(()=>{F();Re=class t extends we{constructor(e){super(e)}static async new(e,n,i){return s("plugin:image|new",{rgba:ie(e),width:n,height:i}).then(r=>new t(r))}static async fromBytes(e){return s("plugin:image|from_bytes",{bytes:ie(e)}).then(n=>new t(n))}static async fromPath(e){return s("plugin:image|from_path",{path:e}).then(n=>new t(n))}async rgba(){return s("plugin:image|rgba",{rid:this.rid}).then(e=>new Uint8Array(e))}async size(){return s("plugin:image|size",{rid:this.rid})}}});function qe(){return new D(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function Ue(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new D(e,{skip:!0})))}var $e,We,dt,De,D,ht,wt,pt,ft,ze=f(()=>{pe();pe();K();F();ct();(function(t){t[t.Critical=1]="Critical",t[t.Informational=2]="Informational"})($e||($e={}));We=class{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}};(function(t){t.None="none",t.Normal="normal",t.Indeterminate="indeterminate",t.Paused="paused",t.Error="error"})(dt||(dt={}));De=["tauri://created","tauri://error"],D=class{constructor(e,n={}){var i;this.label=e,this.listeners=Object.create(null),n?.skip||s("plugin:window|create",{options:{...n,parent:typeof n.parent=="string"?n.parent:(i=n.parent)===null||i===void 0?void 0:i.label,label:e}}).then(async()=>this.emit("tauri://created")).catch(async r=>this.emit("tauri://error",r))}static async getByLabel(e){var n;return(n=(await Ue()).find(i=>i.label===e))!==null&&n!==void 0?n:null}static getCurrent(){return qe()}static async getAll(){return Ue()}static async getFocusedWindow(){for(let e of await Ue())if(await e.isFocused())return e;return null}async listen(e,n){return this._handleTauriEvent(e,n)?()=>{let i=this.listeners[e];i.splice(i.indexOf(n),1)}:U(e,n,{target:{kind:"Window",label:this.label}})}async once(e,n){return this._handleTauriEvent(e,n)?()=>{let i=this.listeners[e];i.splice(i.indexOf(n),1)}:j(e,n,{target:{kind:"Window",label:this.label}})}async emit(e,n){if(De.includes(e)){for(let i of this.listeners[e]||[])i({event:e,id:-1,payload:n});return}return te(e,n)}async emitTo(e,n,i){if(De.includes(n)){for(let r of this.listeners[n]||[])r({event:n,id:-1,payload:i});return}return ne(e,n,i)}_handleTauriEvent(e,n){return De.includes(e)?(e in this.listeners?this.listeners[e].push(n):this.listeners[e]=[n],!0):!1}async scaleFactor(){return s("plugin:window|scale_factor",{label:this.label})}async innerPosition(){return s("plugin:window|inner_position",{label:this.label}).then(e=>new b(e))}async outerPosition(){return s("plugin:window|outer_position",{label:this.label}).then(e=>new b(e))}async innerSize(){return s("plugin:window|inner_size",{label:this.label}).then(e=>new A(e))}async outerSize(){return s("plugin:window|outer_size",{label:this.label}).then(e=>new A(e))}async isFullscreen(){return s("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return s("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return s("plugin:window|is_maximized",{label:this.label})}async isFocused(){return s("plugin:window|is_focused",{label:this.label})}async isDecorated(){return s("plugin:window|is_decorated",{label:this.label})}async isResizable(){return s("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return s("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return s("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return s("plugin:window|is_closable",{label:this.label})}async isVisible(){return s("plugin:window|is_visible",{label:this.label})}async title(){return s("plugin:window|title",{label:this.label})}async theme(){return s("plugin:window|theme",{label:this.label})}async isAlwaysOnTop(){return s("plugin:window|is_always_on_top",{label:this.label})}async activityName(){return s("plugin:window|activity_name",{label:this.label})}async sceneIdentifier(){return s("plugin:window|scene_identifier",{label:this.label})}async center(){return s("plugin:window|center",{label:this.label})}async requestUserAttention(e){let n=null;return e&&(e===$e.Critical?n={type:"Critical"}:n={type:"Informational"}),s("plugin:window|request_user_attention",{label:this.label,value:n})}async setResizable(e){return s("plugin:window|set_resizable",{label:this.label,value:e})}async setEnabled(e){return s("plugin:window|set_enabled",{label:this.label,value:e})}async isEnabled(){return s("plugin:window|is_enabled",{label:this.label})}async setMaximizable(e){return s("plugin:window|set_maximizable",{label:this.label,value:e})}async setMinimizable(e){return s("plugin:window|set_minimizable",{label:this.label,value:e})}async setClosable(e){return s("plugin:window|set_closable",{label:this.label,value:e})}async setTitle(e){return s("plugin:window|set_title",{label:this.label,value:e})}async maximize(){return s("plugin:window|maximize",{label:this.label})}async unmaximize(){return s("plugin:window|unmaximize",{label:this.label})}async toggleMaximize(){return s("plugin:window|toggle_maximize",{label:this.label})}async minimize(){return s("plugin:window|minimize",{label:this.label})}async unminimize(){return s("plugin:window|unminimize",{label:this.label})}async show(){return s("plugin:window|show",{label:this.label})}async hide(){return s("plugin:window|hide",{label:this.label})}async close(){return s("plugin:window|close",{label:this.label})}async destroy(){return s("plugin:window|destroy",{label:this.label})}async setDecorations(e){return s("plugin:window|set_decorations",{label:this.label,value:e})}async setShadow(e){return s("plugin:window|set_shadow",{label:this.label,value:e})}async setEffects(e){return s("plugin:window|set_effects",{label:this.label,value:e})}async clearEffects(){return s("plugin:window|set_effects",{label:this.label,value:null})}async setAlwaysOnTop(e){return s("plugin:window|set_always_on_top",{label:this.label,value:e})}async setAlwaysOnBottom(e){return s("plugin:window|set_always_on_bottom",{label:this.label,value:e})}async setContentProtected(e){return s("plugin:window|set_content_protected",{label:this.label,value:e})}async setSize(e){return s("plugin:window|set_size",{label:this.label,value:e instanceof P?e:new P(e)})}async setMinSize(e){return s("plugin:window|set_min_size",{label:this.label,value:e instanceof P?e:e?new P(e):null})}async setMaxSize(e){return s("plugin:window|set_max_size",{label:this.label,value:e instanceof P?e:e?new P(e):null})}async setSizeConstraints(e){function n(i){return i?{Logical:i}:null}return s("plugin:window|set_size_constraints",{label:this.label,value:{minWidth:n(e?.minWidth),minHeight:n(e?.minHeight),maxWidth:n(e?.maxWidth),maxHeight:n(e?.maxHeight)}})}async setPosition(e){return s("plugin:window|set_position",{label:this.label,value:e instanceof L?e:new L(e)})}async setFullscreen(e){return s("plugin:window|set_fullscreen",{label:this.label,value:e})}async setSimpleFullscreen(e){return s("plugin:window|set_simple_fullscreen",{label:this.label,value:e})}async setFocus(){return s("plugin:window|set_focus",{label:this.label})}async setFocusable(e){return s("plugin:window|set_focusable",{label:this.label,value:e})}async setIcon(e){return s("plugin:window|set_icon",{label:this.label,value:ie(e)})}async setSkipTaskbar(e){return s("plugin:window|set_skip_taskbar",{label:this.label,value:e})}async setCursorGrab(e){return s("plugin:window|set_cursor_grab",{label:this.label,value:e})}async setCursorVisible(e){return s("plugin:window|set_cursor_visible",{label:this.label,value:e})}async setCursorIcon(e){return s("plugin:window|set_cursor_icon",{label:this.label,value:e})}async setBackgroundColor(e){return s("plugin:window|set_background_color",{color:e})}async setCursorPosition(e){return s("plugin:window|set_cursor_position",{label:this.label,value:e instanceof L?e:new L(e)})}async setIgnoreCursorEvents(e){return s("plugin:window|set_ignore_cursor_events",{label:this.label,value:e})}async startDragging(){return s("plugin:window|start_dragging",{label:this.label})}async startResizeDragging(e){return s("plugin:window|start_resize_dragging",{label:this.label,value:e})}async setBadgeCount(e){return s("plugin:window|set_badge_count",{label:this.label,value:e})}async setBadgeLabel(e){return s("plugin:window|set_badge_label",{label:this.label,value:e})}async setOverlayIcon(e){return s("plugin:window|set_overlay_icon",{label:this.label,value:e?ie(e):void 0})}async setProgressBar(e){return s("plugin:window|set_progress_bar",{label:this.label,value:e})}async setVisibleOnAllWorkspaces(e){return s("plugin:window|set_visible_on_all_workspaces",{label:this.label,value:e})}async setTitleBarStyle(e){return s("plugin:window|set_title_bar_style",{label:this.label,value:e})}async setTheme(e){return s("plugin:window|set_theme",{label:this.label,value:e})}async onResized(e){return this.listen(p.WINDOW_RESIZED,n=>{n.payload=new A(n.payload),e(n)})}async onMoved(e){return this.listen(p.WINDOW_MOVED,n=>{n.payload=new b(n.payload),e(n)})}async onCloseRequested(e){return this.listen(p.WINDOW_CLOSE_REQUESTED,async n=>{let i=new We(n);await e(i),i.isPreventDefault()||await this.destroy()})}async onDragDropEvent(e){let n=await this.listen(p.DRAG_ENTER,a=>{e({...a,payload:{type:"enter",paths:a.payload.paths,position:new b(a.payload.position)}})}),i=await this.listen(p.DRAG_OVER,a=>{e({...a,payload:{type:"over",position:new b(a.payload.position)}})}),r=await this.listen(p.DRAG_DROP,a=>{e({...a,payload:{type:"drop",paths:a.payload.paths,position:new b(a.payload.position)}})}),o=await this.listen(p.DRAG_LEAVE,a=>{e({...a,payload:{type:"leave"}})});return()=>{n(),r(),i(),o()}}async onFocusChanged(e){let n=await this.listen(p.WINDOW_FOCUS,r=>{e({...r,payload:!0})}),i=await this.listen(p.WINDOW_BLUR,r=>{e({...r,payload:!1})});return()=>{n(),i()}}async onScaleChanged(e){return this.listen(p.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(p.WINDOW_THEME_CHANGED,e)}};(function(t){t.Disabled="disabled",t.Throttle="throttle",t.Suspend="suspend"})(ht||(ht={}));(function(t){t.Default="default",t.FluentOverlay="fluentOverlay"})(wt||(wt={}));(function(t){t.AppearanceBased="appearanceBased",t.Light="light",t.Dark="dark",t.MediumLight="mediumLight",t.UltraDark="ultraDark",t.Titlebar="titlebar",t.Selection="selection",t.Menu="menu",t.Popover="popover",t.Sidebar="sidebar",t.HeaderView="headerView",t.Sheet="sheet",t.WindowBackground="windowBackground",t.HudWindow="hudWindow",t.FullScreenUI="fullScreenUI",t.Tooltip="tooltip",t.ContentBackground="contentBackground",t.UnderWindowBackground="underWindowBackground",t.UnderPageBackground="underPageBackground",t.Mica="mica",t.Blur="blur",t.Acrylic="acrylic",t.Tabbed="tabbed",t.TabbedDark="tabbedDark",t.TabbedLight="tabbedLight"})(pt||(pt={}));(function(t){t.FollowsWindowActiveState="followsWindowActiveState",t.Active="active",t.Inactive="inactive"})(ft||(ft={}))});function Me(){return new Y(qe(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function gt(){return s("plugin:webview|get_all_webviews").then(t=>t.map(e=>new Y(new D(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}var Ne,Y,yt=f(()=>{pe();K();F();ze();Ne=["tauri://created","tauri://error"],Y=class{constructor(e,n,i){this.window=e,this.label=n,this.listeners=Object.create(null),i?.skip||s("plugin:webview|create_webview",{windowLabel:e.label,options:{...i,label:n}}).then(async()=>this.emit("tauri://created")).catch(async r=>this.emit("tauri://error",r))}static async getByLabel(e){var n;return(n=(await gt()).find(i=>i.label===e))!==null&&n!==void 0?n:null}static getCurrent(){return Me()}static async getAll(){return gt()}async listen(e,n){return this._handleTauriEvent(e,n)?()=>{let i=this.listeners[e];i.splice(i.indexOf(n),1)}:U(e,n,{target:{kind:"Webview",label:this.label}})}async once(e,n){return this._handleTauriEvent(e,n)?()=>{let i=this.listeners[e];i.splice(i.indexOf(n),1)}:j(e,n,{target:{kind:"Webview",label:this.label}})}async emit(e,n){if(Ne.includes(e)){for(let i of this.listeners[e]||[])i({event:e,id:-1,payload:n});return}return te(e,n)}async emitTo(e,n,i){if(Ne.includes(n)){for(let r of this.listeners[n]||[])r({event:n,id:-1,payload:i});return}return ne(e,n,i)}_handleTauriEvent(e,n){return Ne.includes(e)?(e in this.listeners?this.listeners[e].push(n):this.listeners[e]=[n],!0):!1}async position(){return s("plugin:webview|webview_position",{label:this.label}).then(e=>new b(e))}async size(){return s("plugin:webview|webview_size",{label:this.label}).then(e=>new A(e))}async close(){return s("plugin:webview|webview_close",{label:this.label})}async setSize(e){return s("plugin:webview|set_webview_size",{label:this.label,value:e instanceof P?e:new P(e)})}async setPosition(e){return s("plugin:webview|set_webview_position",{label:this.label,value:e instanceof L?e:new L(e)})}async setFocus(){return s("plugin:webview|set_webview_focus",{label:this.label})}async setAutoResize(e){return s("plugin:webview|set_webview_auto_resize",{label:this.label,value:e})}async hide(){return s("plugin:webview|webview_hide",{label:this.label})}async show(){return s("plugin:webview|webview_show",{label:this.label})}async setZoom(e){return s("plugin:webview|set_webview_zoom",{label:this.label,value:e})}async reparent(e){return s("plugin:webview|reparent",{label:this.label,window:typeof e=="string"?e:e.label})}async clearAllBrowsingData(){return s("plugin:webview|clear_all_browsing_data")}async setBackgroundColor(e){return s("plugin:webview|set_webview_background_color",{color:e})}async onDragDropEvent(e){let n=await this.listen(p.DRAG_ENTER,a=>{e({...a,payload:{type:"enter",paths:a.payload.paths,position:new b(a.payload.position)}})}),i=await this.listen(p.DRAG_OVER,a=>{e({...a,payload:{type:"over",position:new b(a.payload.position)}})}),r=await this.listen(p.DRAG_DROP,a=>{e({...a,payload:{type:"drop",paths:a.payload.paths,position:new b(a.payload.position)}})}),o=await this.listen(p.DRAG_LEAVE,a=>{e({...a,payload:{type:"leave"}})});return()=>{n(),r(),i(),o()}}}});function Zt(){let t=Me();return new S(t.label,{skip:!0})}async function bt(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new S(e,{skip:!0})))}function Qt(t,e){(Array.isArray(e)?e:[e]).forEach(n=>{Object.getOwnPropertyNames(n.prototype).forEach(i=>{var r;typeof t.prototype=="object"&&t.prototype&&i in t.prototype||Object.defineProperty(t.prototype,i,(r=Object.getOwnPropertyDescriptor(n.prototype,i))!==null&&r!==void 0?r:Object.create(null))})})}var S,Be=f(()=>{yt();ze();K();F();S=class t{constructor(e,n={}){var i;this.label=e,this.listeners=Object.create(null),n?.skip||s("plugin:webview|create_webview_window",{options:{...n,parent:typeof n.parent=="string"?n.parent:(i=n.parent)===null||i===void 0?void 0:i.label,label:e}}).then(async()=>this.emit("tauri://created")).catch(async r=>this.emit("tauri://error",r))}static async getByLabel(e){var n;let i=(n=(await bt()).find(r=>r.label===e))!==null&&n!==void 0?n:null;return i?new t(i.label,{skip:!0}):null}static getCurrent(){return Zt()}static async getAll(){return bt()}async listen(e,n){return this._handleTauriEvent(e,n)?()=>{let i=this.listeners[e];i.splice(i.indexOf(n),1)}:U(e,n,{target:{kind:"WebviewWindow",label:this.label}})}async once(e,n){return this._handleTauriEvent(e,n)?()=>{let i=this.listeners[e];i.splice(i.indexOf(n),1)}:j(e,n,{target:{kind:"WebviewWindow",label:this.label}})}async setBackgroundColor(e){return s("plugin:window|set_background_color",{color:e}).then(()=>s("plugin:webview|set_webview_background_color",{color:e}))}};Qt(S,[D,Y])});var Pt={};q(Pt,{createGoogleLogin:()=>en,initializeGoogleLogin:()=>vt,subscribeGoogleLogin:()=>Xt});function _t(t,e=null){fe.forEach(n=>{try{n(t,e)}catch(i){console.error("Google listener error:",i)}})}function Xt(t){return fe.push(t),()=>{let e=fe.indexOf(t);e!==-1&&fe.splice(e,1)}}var mt,fe,ge,Fe,vt,en,kt=f(()=>{Se();Oe();Be();ae();mt=!1,fe=[];ge=null,Fe=async t=>{try{if(!t?.includes("token="))return;let n=new URLSearchParams(t.split("?")[1]).get("token");console.log("Google login token:",n);let r=await(await fetch("https://www.googleapis.com/oauth2/v3/userinfo",{headers:{Authorization:`Bearer ${n}`}})).json(),o={id:r.sub,firstName:r.given_name,lastName:r.family_name,email:r.email,photo:r.picture,accessToken:n};console.log("Google user profile:",o),localStorage.setItem("user",JSON.stringify(o)),localStorage.setItem("idToken",n),_t(o,null)}catch(e){_t(null,e)}},vt=async()=>{if(!mt&&(mt=!0,x&&le.addListener("appUrlOpen",t=>{Fe(t.url)}),R)){let{listen:t}=await Promise.resolve().then(()=>(K(),xe));await t("deep-link://open-url",async e=>{let n=e.payload;if(typeof n=="object"&&(n=n?.url||n?.payload||null),!!n){if(ge)try{await ge.close(),ge=null}catch{}Fe(n)}})}},en=async({appId:t="tevrocsoft",appName:e="Tevroc",serviceUrl:n="https://tevrocsoftapi.netlify.app"}={})=>{console.log("appId:",t,"serviceUrl:",n),console.log(x,R),await vt();let i=`${n}/login?mode=mobile&app=${encodeURIComponent(t)}&name=${encodeURIComponent(e)}`;if(x){await ce.open({url:i});return}if(R){let d=`${n}/login?mode=desktop&app=${encodeURIComponent(t)}&name=${encodeURIComponent(e)}`,h=new S("auth",{url:d,title:`${e} Login`,width:550,height:500,resizable:!0,center:!0});ge=h,h.once("tauri://created",()=>{console.log("Auth window opened")}),h.once("tauri://error",w=>{console.error("Auth window error:",w)});return}let r=!0,o=typeof window<"u"?window.location.host:t,u=`${n}/login?mode=${r?"localhost":"netlify"}&app=${encodeURIComponent(o)}&name=${encodeURIComponent(e)}`;if(r){let d=window.open(u,"googleLogin","width=500,height=650");if(!d){console.error("Popup blocked");return}let h=l=>{if(l.origin===n&&l.data?.type==="google-auth"){let c=l.data?.token||null,G=c?`${window.location.href}${window.location.href.includes("?")?"&":"?"}token=${c}`:window.location.href;d.close(),window.removeEventListener("message",h),Fe(G)}};window.addEventListener("message",h);let w=setInterval(()=>{d.closed&&(clearInterval(w),window.removeEventListener("message",h))},500);return}}});var St={};q(St,{createPayment:()=>Tt,default:()=>Et,initializePayment:()=>je,subscribePaymentStatus:()=>tn});function At(t,e=null){ye.forEach(n=>{try{n(t,e)}catch(i){console.error("Payment listener error:",i)}})}function tn(t){return ye.push(t),()=>{let e=ye.indexOf(t);e!==-1&&ye.splice(e,1)}}function Et({externalCallback:t=()=>{}}={}){return je(t),{createPayment:Tt}}var Ct,ye,be,nn,re,Lt,je,Tt,Ot=f(()=>{Se();Oe();Be();ae();Ct=!1,ye=[];be=null,nn=[],re=(...t)=>{t.forEach(e=>{let n={message:e,time:new Date().toISOString()};nn.push(n),console.log(n)})},Lt=async(t,e=()=>{})=>{try{if(re("PAYMENT CALLBACK:",t),!t?.includes("state="))return;let i=new URLSearchParams(t.split("?")[1]).get("state");re("PAYMENT RESULT:",i),i=="success"?re("PAYMENT SUCCESS"):re("PAYMENT FAILED"),e(i,null),At(i,null)}catch(n){re("PAYMENT CALLBACK ERROR:",n.message),e(null,n),At(null,n)}},je=async(t=()=>{})=>{if(!Ct&&(Ct=!0,x&&le.addListener("appUrlOpen",e=>{Lt(e.url,t)}),R)){let{listen:e}=await Promise.resolve().then(()=>(K(),xe));await e("deep-link://open-url",async n=>{let i=n.payload;if(typeof i=="object"&&(i=i?.url||i?.payload||null),!!i){if(be)try{await be.close(),be=null}catch{}Lt(i,t)}})}},Tt=async(t,{appId:e="tevrocsoft",serviceUrl:n="https://tevrocsoftapi.netlify.app",externalCallback:i=()=>{}}={})=>{await je(i);let r=Math.round(Number(t)*100),o=`${n}/pay`,a=`${o}?mode=mobile&amount=${r}&app=${e}`;if(x){await ce.open({url:a});return}if(R){let h=`${o}?mode=desktop&amount=${r}&app=${e}`,w=new S("payment",{url:h,title:"Complete Payment",width:550,height:600,resizable:!0,center:!0});be=w,w.once("tauri://created",()=>{console.log("Payment window opened")}),w.once("tauri://error",l=>{console.error("Payment window error:",l)});return}let d=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"?"localhost":"netlify";window.location.href=`${o}?mode=${d}&amount=${r}&app=${e}`}});var Sn={};q(Sn,{TevrocClient:()=>_e,TevrocError:()=>$,createClient:()=>an});var Ge=null;async function rn(){return Ge||(Ge=await Promise.resolve().then(()=>(ae(),Ye))),Ge}var He=null;async function sn(){return He||(He=await Promise.resolve().then(()=>(kt(),Pt))),He}var Ve=null;async function on(){return Ve||(Ve=await Promise.resolve().then(()=>(Ot(),St))),Ve}var $=class extends Error{constructor(e,n={}){super(e),this.name="TevrocError",this.status=n.status,this.code=n.code,this.details=n.details,this.response=n.response}};function an(t={}){return new _e(t)}var _e=class{constructor(e={}){let n=e.baseUrl??e.url,i=e.serviceUrl??e.url;if(!n)throw new TypeError("createClient requires a baseUrl");if(this.baseUrl=xt(n),this.serviceUrl=xt(i),this.appId=e.appId,this.appName=e.appName,this.transport=e.axios??null,this.fetch=e.fetch??globalThis.fetch,!this.transport&&typeof this.fetch!="function")throw new TypeError("No fetch implementation available");this.timeoutMs=e.timeoutMs??3e4,this.defaultHeaders=An(e.headers),this.token=e.token??null,this.auth=cn(this),this.entities=dn(this),this.functions=wn(this),this.integrations=pn(this),this.agents=fn(this),this.logs=yn(this),this.connectors=bn(this),this.customIntegrations=mn(this),this.sso=_n(this),this.files=vn(this),this.payments=un(this),this.platform=ln(this)}setToken(e){return this.token=e||null,this.token?me()?.setItem("tevroc_access_token",this.token):me()?.removeItem("tevroc_access_token"),this}clearToken(){return this.token=null,me()?.removeItem("tevroc_access_token"),this}async request(e,n={}){let i=(n.method??"GET").toUpperCase(),r=new Headers(this.defaultHeaders),o=n.query?Cn(n.query):"",a=`${this.baseUrl}${e.startsWith("/")?e:`/${e}`}${o}`,u=new AbortController,d=setTimeout(()=>u.abort(),n.timeoutMs??this.timeoutMs),h=this.token||Ln();h&&n.auth!==!1&&r.set("authorization",`Bearer ${h}`),this.appId&&r.set("x-app-id",this.appId);let w=n.body;if(w!=null&&En(w)&&(r.set("content-type","application/json"),w=JSON.stringify(w)),n.headers)for(let[l,c]of Object.entries(n.headers))c!=null&&r.set(l,String(c));try{if(this.transport){let c=await this.transport.request({url:a,method:i,headers:Object.fromEntries(r.entries()),data:w,signal:n.signal??u.signal,timeout:n.timeoutMs??this.timeoutMs,validateStatus:()=>!0});return await Pn(c,n.parseAs)}let l=await this.fetch(a,{method:i,headers:r,body:w,signal:n.signal??u.signal});return await kn(l,n.parseAs)}catch(l){throw l?.name==="AbortError"?new $("Request timed out",{code:"timeout"}):l instanceof $?l:new $(l?.message??"Network request failed",{code:"network_error",details:l})}finally{clearTimeout(d)}}};function ln(t){return(async function(){let{isNative:e,isCapacitor:n,isTauri:i,platform:r}=await rn();return{platform:r,isCapacitor:n,isTauri:i,isNative:e}})()}function un(t){return{create:async({amountZAR:e,appId:n="tevrocsoft",mode:i="web"})=>{let{createPayment:r}=await on();return await r(e,{appId:n,serviceUrl:t.serviceUrl,mode:i})},onstatus:e=>{if(typeof e!="function")throw new Error("onstatus requires a function");return subscribePaymentStatus(e)}}}function cn(t){return{async register(e){let n=await t.request("/auth/register",{method:"POST",body:e,auth:!1});return n.token&&t.setToken(n.token),n},loginWithProvider:async(e,n,i=()=>{})=>{if(e==="google"){let{createGoogleLogin:r,subscribeGoogleLogin:o}=await sn();if(console.log({serviceUrl:t.serviceUrl,appId:t.appId,appName:t.appName}),r({serviceUrl:t.serviceUrl,appId:t.appId,appName:t.appName}),n){let a=o(async(u,d)=>{if(console.log("Google callback:",u,d),a(),!u)return;let h=await t.request("/auth/google",{method:"POST",body:{accessToken:u.accessToken},auth:!1});console.log(h),i(h.token),console.log("Redirecting to:",n),window.location.href=n})}}},googleLogin:e=>createGoogleLogin(e),onGoogleLogin:e=>subscribeGoogleLogin(e),async login(e){let n=await t.request("/auth/login",{method:"POST",body:e,auth:!1});return n.token&&t.setToken(n.token),n},loginViaEmailPassword:(e,n)=>t.auth.login({email:e,password:n}),async logout(){let e=await t.request("/auth/logout",{method:"POST"});return t.clearToken(),e},me:()=>t.request("/auth/me"),verifyOtp:e=>t.request("/auth/verify-otp",{method:"POST",body:e,auth:!1}),changePassword:e=>t.request("/auth/change-password",{method:"POST",body:e}),resetPassword:e=>t.request("/auth/reset-password",{method:"POST",body:e,auth:!1}),loginUrl:e=>t.request("/auth/login-url",{query:e?{redirectTo:e}:void 0,auth:!1})}}function dn(t){return new Proxy({},{get(e,n){if(typeof n=="string")return hn(t,n)}})}function hn(t,e){let n=`/entities/${encodeURIComponent(e)}`;return{list:i=>t.request(n,{query:i}),get:i=>t.request(`${n}/${encodeURIComponent(i)}`),create:i=>t.request(n,{method:"POST",body:i}),update:(i,r)=>t.request(`${n}/${encodeURIComponent(i)}`,{method:"PATCH",body:r}),delete:i=>t.request(`${n}/${encodeURIComponent(i)}`,{method:"DELETE"}),query:(i={})=>t.request(`${n}/query`,{method:"POST",body:i}),filter:(i={},r,o)=>t.request(`${n}/query`,{method:"POST",body:Tn(i,r,o)}),bulkCreate:i=>t.request(`${n}/bulk`,{method:"POST",body:{records:i}}),bulkUpdate:i=>t.request(`${n}/bulk`,{method:"PATCH",body:{records:i}}),bulkDelete:i=>t.request(`${n}/bulk`,{method:"DELETE",body:{ids:i}}),import:i=>t.request(`${n}/import`,{method:"POST",body:{records:i}})}}function wn(t){return new Proxy({invoke:(e,n)=>t.request(`/functions/${encodeURIComponent(e)}`,{method:"POST",body:n})},{get(e,n){if(n in e)return e[n];if(typeof n=="string")return i=>e.invoke(n,i)}})}function pn(t){return{Core:{InvokeLLM:e=>t.request("/integrations/core/invoke-llm",{method:"POST",body:e}),GenerateImage:e=>t.request("/integrations/core/generate-image",{method:"POST",body:e}),UploadFile:(e,n={})=>It(t,"/integrations/core/upload-file",e,n),UploadPrivateFile:(e,n={})=>It(t,"/integrations/core/upload-private-file",e,n),CreateFileSignedUrl:e=>t.request("/integrations/core/create-file-signed-url",{method:"POST",body:e}),SendEmail:e=>t.request("/integrations/core/send-email",{method:"POST",body:e}),ExtractDataFromUploadedFile:e=>t.request("/integrations/core/extract-data-from-uploaded-file",{method:"POST",body:e})}}}function fn(t){return new Proxy({},{get(e,n){if(typeof n=="string")return gn(t,n)}})}function gn(t,e){let n=`/agents/${encodeURIComponent(e)}/conversations`;return{createConversation:(i={})=>t.request(n,{method:"POST",body:i}),listConversations:()=>t.request(n),getConversation:i=>t.request(`${n}/${encodeURIComponent(i)}`),deleteConversation:i=>t.request(`${n}/${encodeURIComponent(i)}`,{method:"DELETE"}),addMessage:(i,r)=>t.request(`${n}/${encodeURIComponent(i)}/messages`,{method:"POST",body:r}),listMessages:i=>t.request(`${n}/${encodeURIComponent(i)}/messages`)}}function yn(t){return{list:e=>t.request("/app-logs",{query:e}),create:e=>t.request("/app-logs",{method:"POST",body:e}),get:e=>t.request(`/app-logs/${encodeURIComponent(e)}`)}}function bn(t){return{list:()=>t.request("/connectors"),get:e=>t.request(`/connectors/${encodeURIComponent(e)}`),connect:(e,n={})=>t.request(`/connectors/${encodeURIComponent(e)}/connect`,{method:"POST",body:n}),disconnect:e=>t.request(`/connectors/${encodeURIComponent(e)}/disconnect`,{method:"POST"}),status:e=>t.request(`/connectors/${encodeURIComponent(e)}/status`),user:{list:()=>t.request("/user-connectors"),get:e=>t.request(`/user-connectors/${encodeURIComponent(e)}`),refresh:e=>t.request(`/user-connectors/${encodeURIComponent(e)}/refresh`,{method:"POST"}),delete:e=>t.request(`/user-connectors/${encodeURIComponent(e)}`,{method:"DELETE"})}}}function mn(t){return new Proxy({invoke:(e,n,i)=>t.request(`/custom-integrations/${encodeURIComponent(e)}/${encodeURIComponent(n)}`,{method:"POST",body:i})},{get(e,n){if(n in e)return e[n];if(typeof n=="string")return new Proxy({},{get(i,r){if(typeof r=="string")return o=>e.invoke(n,r,o)}})}})}function _n(t){return{accessToken:e=>t.request("/sso/access-token",{method:"POST",body:e,auth:!1}),callback:e=>t.request("/sso/callback",{query:e,auth:!1})}}function vn(t){return{url:e=>`${t.baseUrl}/files/${encodeURIComponent(e)}`,privateUrl:e=>`${t.baseUrl}/private-files/${encodeURIComponent(e)}`,get:e=>t.request(`/files/${encodeURIComponent(e)}`,{parseAs:"response",auth:!1}),getPrivate:e=>t.request(`/private-files/${encodeURIComponent(e)}`,{parseAs:"response"})}}function It(t,e,n,i){let r={};return i.filename&&(r["x-filename"]=i.filename),i.contentType&&(r["content-type"]=i.contentType),t.request(e,{method:"POST",body:n,headers:r})}async function Pn(t,e){if(e==="response")return t;let n=t.headers??{},r=(typeof n.get=="function"?n.get("content-type")??"":String(n["content-type"]??n["Content-Type"]??"")).includes("application/json"),o=t.data;if(t.status<200||t.status>=300){let a=r&&o?.error?o.error:{};throw new $(a.message??t.statusText??"Request failed",{status:t.status,code:a.code??"api_error",details:a.details??o,response:t})}return o}async function kn(t,e){if(e==="response")return t;let i=(t.headers.get("content-type")??"").includes("application/json"),r=i?await t.json():await t.text();if(!t.ok){let o=i&&r?.error?r.error:{};throw new $(o.message??t.statusText,{status:t.status,code:o.code??"api_error",details:o.details??r,response:t})}return r}function Cn(t){let e=new URLSearchParams;for(let[i,r]of Object.entries(t))if(r!=null)if(Array.isArray(r))for(let o of r)e.append(i,String(o));else e.set(i,String(r));let n=e.toString();return n?`?${n}`:""}function xt(t){return String(t).replace(/\/+$/,"")}function An(t={}){return Object.fromEntries(new Headers(t).entries())}function me(){return typeof globalThis<"u"?globalThis.localStorage:void 0}function Ln(){return me()?.getItem("tevroc_access_token")??null}function Tn(t={},e,n){let i={filter:t};return typeof e=="string"?i.sort=e:e&&typeof e=="object"&&Object.assign(i,e),n!==void 0&&(i.limit=n),i}function En(t){let e=typeof ArrayBuffer<"u"&&t instanceof ArrayBuffer,n=typeof Blob<"u"&&t instanceof Blob,i=typeof FormData<"u"&&t instanceof FormData;return typeof t=="object"&&!e&&!n&&!i}return Nt(Sn);})();
|
|
2
2
|
/*! Bundled license information:
|
|
3
3
|
|
|
4
4
|
@capacitor/core/dist/index.js:
|
package/tevroc-sdk.umd.js
CHANGED
|
@@ -3925,7 +3925,6 @@ var Tevroc = (() => {
|
|
|
3925
3925
|
}
|
|
3926
3926
|
var TevrocClient = class {
|
|
3927
3927
|
constructor(options = {}) {
|
|
3928
|
-
console.log(options);
|
|
3929
3928
|
const baseUrl = options.baseUrl ?? options.url;
|
|
3930
3929
|
const serviceUrl = options.serviceUrl ?? options.url;
|
|
3931
3930
|
if (!baseUrl) throw new TypeError("createClient requires a baseUrl");
|
|
@@ -3933,8 +3932,9 @@ var Tevroc = (() => {
|
|
|
3933
3932
|
this.serviceUrl = normalizeBaseUrl(serviceUrl);
|
|
3934
3933
|
this.appId = options.appId;
|
|
3935
3934
|
this.appName = options.appName;
|
|
3936
|
-
this.
|
|
3937
|
-
|
|
3935
|
+
this.transport = options.axios ?? null;
|
|
3936
|
+
this.fetch = options.fetch ?? globalThis.fetch;
|
|
3937
|
+
if (!this.transport && typeof this.fetch !== "function") {
|
|
3938
3938
|
throw new TypeError("No fetch implementation available");
|
|
3939
3939
|
}
|
|
3940
3940
|
this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
@@ -3956,15 +3956,15 @@ var Tevroc = (() => {
|
|
|
3956
3956
|
setToken(token) {
|
|
3957
3957
|
this.token = token || null;
|
|
3958
3958
|
if (this.token) {
|
|
3959
|
-
|
|
3959
|
+
safeLocalStorage()?.setItem("tevroc_access_token", this.token);
|
|
3960
3960
|
} else {
|
|
3961
|
-
|
|
3961
|
+
safeLocalStorage()?.removeItem("tevroc_access_token");
|
|
3962
3962
|
}
|
|
3963
3963
|
return this;
|
|
3964
3964
|
}
|
|
3965
3965
|
clearToken() {
|
|
3966
3966
|
this.token = null;
|
|
3967
|
-
|
|
3967
|
+
safeLocalStorage()?.removeItem("tevroc_access_token");
|
|
3968
3968
|
return this;
|
|
3969
3969
|
}
|
|
3970
3970
|
async request(path, options = {}) {
|
|
@@ -3974,11 +3974,13 @@ var Tevroc = (() => {
|
|
|
3974
3974
|
const url = `${this.baseUrl}${path.startsWith("/") ? path : `/${path}`}${query}`;
|
|
3975
3975
|
const controller = new AbortController();
|
|
3976
3976
|
const timeout = setTimeout(() => controller.abort(), options.timeoutMs ?? this.timeoutMs);
|
|
3977
|
-
const token = this.token ||
|
|
3977
|
+
const token = this.token || getStoredToken();
|
|
3978
3978
|
if (token && options.auth !== false) {
|
|
3979
3979
|
headers.set("authorization", `Bearer ${token}`);
|
|
3980
3980
|
}
|
|
3981
|
-
|
|
3981
|
+
if (this.appId) {
|
|
3982
|
+
headers.set("x-app-id", this.appId);
|
|
3983
|
+
}
|
|
3982
3984
|
let body = options.body;
|
|
3983
3985
|
if (body !== void 0 && body !== null && isJsonBody(body)) {
|
|
3984
3986
|
headers.set("content-type", "application/json");
|
|
@@ -3990,6 +3992,18 @@ var Tevroc = (() => {
|
|
|
3990
3992
|
}
|
|
3991
3993
|
}
|
|
3992
3994
|
try {
|
|
3995
|
+
if (this.transport) {
|
|
3996
|
+
const response2 = await this.transport.request({
|
|
3997
|
+
url,
|
|
3998
|
+
method,
|
|
3999
|
+
headers: Object.fromEntries(headers.entries()),
|
|
4000
|
+
data: body,
|
|
4001
|
+
signal: options.signal ?? controller.signal,
|
|
4002
|
+
timeout: options.timeoutMs ?? this.timeoutMs,
|
|
4003
|
+
validateStatus: () => true
|
|
4004
|
+
});
|
|
4005
|
+
return await parseAxiosResponse(response2, options.parseAs);
|
|
4006
|
+
}
|
|
3993
4007
|
const response = await this.fetch(url, {
|
|
3994
4008
|
method,
|
|
3995
4009
|
headers,
|
|
@@ -4086,6 +4100,7 @@ var Tevroc = (() => {
|
|
|
4086
4100
|
if (result.token) client.setToken(result.token);
|
|
4087
4101
|
return result;
|
|
4088
4102
|
},
|
|
4103
|
+
loginViaEmailPassword: (email, password) => client.auth.login({ email, password }),
|
|
4089
4104
|
async logout() {
|
|
4090
4105
|
const result = await client.request("/auth/logout", { method: "POST" });
|
|
4091
4106
|
client.clearToken();
|
|
@@ -4118,6 +4133,7 @@ var Tevroc = (() => {
|
|
|
4118
4133
|
update: (id, patch) => client.request(`${base}/${encodeURIComponent(id)}`, { method: "PATCH", body: patch }),
|
|
4119
4134
|
delete: (id) => client.request(`${base}/${encodeURIComponent(id)}`, { method: "DELETE" }),
|
|
4120
4135
|
query: (input = {}) => client.request(`${base}/query`, { method: "POST", body: input }),
|
|
4136
|
+
filter: (filter = {}, sortOrOptions, limit) => client.request(`${base}/query`, { method: "POST", body: normalizeFilterInput(filter, sortOrOptions, limit) }),
|
|
4121
4137
|
bulkCreate: (records) => client.request(`${base}/bulk`, { method: "POST", body: { records } }),
|
|
4122
4138
|
bulkUpdate: (records) => client.request(`${base}/bulk`, { method: "PATCH", body: { records } }),
|
|
4123
4139
|
bulkDelete: (ids) => client.request(`${base}/bulk`, { method: "DELETE", body: { ids } }),
|
|
@@ -4240,6 +4256,23 @@ var Tevroc = (() => {
|
|
|
4240
4256
|
if (options.contentType) headers["content-type"] = options.contentType;
|
|
4241
4257
|
return client.request(path, { method: "POST", body: file, headers });
|
|
4242
4258
|
}
|
|
4259
|
+
async function parseAxiosResponse(response, parseAs) {
|
|
4260
|
+
if (parseAs === "response") return response;
|
|
4261
|
+
const headers = response.headers ?? {};
|
|
4262
|
+
const contentType = typeof headers.get === "function" ? headers.get("content-type") ?? "" : String(headers["content-type"] ?? headers["Content-Type"] ?? "");
|
|
4263
|
+
const isJson = contentType.includes("application/json");
|
|
4264
|
+
const data = response.data;
|
|
4265
|
+
if (response.status < 200 || response.status >= 300) {
|
|
4266
|
+
const error = isJson && data?.error ? data.error : {};
|
|
4267
|
+
throw new TevrocError(error.message ?? response.statusText ?? "Request failed", {
|
|
4268
|
+
status: response.status,
|
|
4269
|
+
code: error.code ?? "api_error",
|
|
4270
|
+
details: error.details ?? data,
|
|
4271
|
+
response
|
|
4272
|
+
});
|
|
4273
|
+
}
|
|
4274
|
+
return data;
|
|
4275
|
+
}
|
|
4243
4276
|
async function parseResponse(response, parseAs) {
|
|
4244
4277
|
if (parseAs === "response") return response;
|
|
4245
4278
|
const contentType = response.headers.get("content-type") ?? "";
|
|
@@ -4275,6 +4308,19 @@ var Tevroc = (() => {
|
|
|
4275
4308
|
function normalizeHeaders(headers = {}) {
|
|
4276
4309
|
return Object.fromEntries(new Headers(headers).entries());
|
|
4277
4310
|
}
|
|
4311
|
+
function safeLocalStorage() {
|
|
4312
|
+
return typeof globalThis !== "undefined" ? globalThis.localStorage : void 0;
|
|
4313
|
+
}
|
|
4314
|
+
function getStoredToken() {
|
|
4315
|
+
return safeLocalStorage()?.getItem("tevroc_access_token") ?? null;
|
|
4316
|
+
}
|
|
4317
|
+
function normalizeFilterInput(filter = {}, sortOrOptions, limit) {
|
|
4318
|
+
const input = { filter };
|
|
4319
|
+
if (typeof sortOrOptions === "string") input.sort = sortOrOptions;
|
|
4320
|
+
else if (sortOrOptions && typeof sortOrOptions === "object") Object.assign(input, sortOrOptions);
|
|
4321
|
+
if (limit !== void 0) input.limit = limit;
|
|
4322
|
+
return input;
|
|
4323
|
+
}
|
|
4278
4324
|
function isJsonBody(body) {
|
|
4279
4325
|
const isArrayBuffer = typeof ArrayBuffer !== "undefined" && body instanceof ArrayBuffer;
|
|
4280
4326
|
const isBlob = typeof Blob !== "undefined" && body instanceof Blob;
|