tevrocsdk 0.1.24 → 0.1.26
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 +44 -7
- package/tevroc-sdk.min.js +1 -1
- package/tevroc-sdk.umd.js +44 -7
package/package.json
CHANGED
package/tevroc-sdk.esm.js
CHANGED
|
@@ -3586,6 +3586,7 @@ var init_useGoogleAuth = __esm({
|
|
|
3586
3586
|
if (!url?.includes("token=")) return;
|
|
3587
3587
|
const params = new URLSearchParams(url.split("?")[1]);
|
|
3588
3588
|
const token = params.get("token");
|
|
3589
|
+
console.log("Google login token:", token);
|
|
3589
3590
|
const res = await fetch(
|
|
3590
3591
|
"https://www.googleapis.com/oauth2/v3/userinfo",
|
|
3591
3592
|
{
|
|
@@ -3603,6 +3604,7 @@ var init_useGoogleAuth = __esm({
|
|
|
3603
3604
|
photo: googleUser.picture,
|
|
3604
3605
|
accessToken: token
|
|
3605
3606
|
};
|
|
3607
|
+
console.log("Google user profile:", profile);
|
|
3606
3608
|
localStorage.setItem("user", JSON.stringify(profile));
|
|
3607
3609
|
localStorage.setItem("idToken", token);
|
|
3608
3610
|
emitGoogleLogin(profile, null);
|
|
@@ -3645,13 +3647,13 @@ var init_useGoogleAuth = __esm({
|
|
|
3645
3647
|
console.log("appId:", appId, "serviceUrl:", serviceUrl);
|
|
3646
3648
|
console.log(isCapacitor, isTauri);
|
|
3647
3649
|
await initializeGoogleLogin();
|
|
3648
|
-
let authUrl = `${serviceUrl}/login?mode=mobile&app=${appId}`;
|
|
3650
|
+
let authUrl = `${serviceUrl}/login?mode=mobile&app=${encodeURIComponent(appId)}&name=${encodeURIComponent(appName)}`;
|
|
3649
3651
|
if (isCapacitor) {
|
|
3650
3652
|
await Browser2.open({ url: authUrl });
|
|
3651
3653
|
return;
|
|
3652
3654
|
}
|
|
3653
3655
|
if (isTauri) {
|
|
3654
|
-
const url = `${serviceUrl}/login?mode=desktop&app=${appId}`;
|
|
3656
|
+
const url = `${serviceUrl}/login?mode=desktop&app=${encodeURIComponent(appId)}&name=${encodeURIComponent(appName)}`;
|
|
3655
3657
|
const win = new WebviewWindow("auth", {
|
|
3656
3658
|
url,
|
|
3657
3659
|
title: `${appName} Login`,
|
|
@@ -3670,9 +3672,40 @@ var init_useGoogleAuth = __esm({
|
|
|
3670
3672
|
return;
|
|
3671
3673
|
}
|
|
3672
3674
|
const isLocalhost = window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1";
|
|
3675
|
+
const detectedAppId = typeof window !== "undefined" ? window.location.host : appId;
|
|
3673
3676
|
const mode = isLocalhost ? "localhost" : "netlify";
|
|
3674
|
-
|
|
3675
|
-
|
|
3677
|
+
const finalUrl = `${serviceUrl}/login?mode=${mode}&app=${encodeURIComponent(
|
|
3678
|
+
detectedAppId
|
|
3679
|
+
)}&name=${encodeURIComponent(appName)}`;
|
|
3680
|
+
if (isLocalhost) {
|
|
3681
|
+
const popup = window.open(
|
|
3682
|
+
finalUrl,
|
|
3683
|
+
"googleLogin",
|
|
3684
|
+
"width=500,height=650"
|
|
3685
|
+
);
|
|
3686
|
+
if (!popup) {
|
|
3687
|
+
console.error("Popup blocked");
|
|
3688
|
+
return;
|
|
3689
|
+
}
|
|
3690
|
+
const listener = (event) => {
|
|
3691
|
+
if (event.origin !== serviceUrl) return;
|
|
3692
|
+
if (event.data?.type === "google-auth") {
|
|
3693
|
+
const token = event.data?.token || null;
|
|
3694
|
+
const url = token ? `${window.location.href}${window.location.href.includes("?") ? "&" : "?"}token=${token}` : window.location.href;
|
|
3695
|
+
popup.close();
|
|
3696
|
+
window.removeEventListener("message", listener);
|
|
3697
|
+
handleCallback(url);
|
|
3698
|
+
}
|
|
3699
|
+
};
|
|
3700
|
+
window.addEventListener("message", listener);
|
|
3701
|
+
const timer = setInterval(() => {
|
|
3702
|
+
if (popup.closed) {
|
|
3703
|
+
clearInterval(timer);
|
|
3704
|
+
window.removeEventListener("message", listener);
|
|
3705
|
+
}
|
|
3706
|
+
}, 500);
|
|
3707
|
+
return;
|
|
3708
|
+
}
|
|
3676
3709
|
};
|
|
3677
3710
|
}
|
|
3678
3711
|
});
|
|
@@ -3965,7 +3998,8 @@ function createAuthApi(client) {
|
|
|
3965
3998
|
return result;
|
|
3966
3999
|
},
|
|
3967
4000
|
// base44
|
|
3968
|
-
loginWithProvider: async (provider, redirectTo) => {
|
|
4001
|
+
loginWithProvider: async (provider, redirectTo, setToken = () => {
|
|
4002
|
+
}) => {
|
|
3969
4003
|
if (provider === "google") {
|
|
3970
4004
|
const { createGoogleLogin: createGoogleLogin3, subscribeGoogleLogin: subscribeGoogleLogin3 } = await getGoogleModule();
|
|
3971
4005
|
console.log({
|
|
@@ -3983,11 +4017,14 @@ function createAuthApi(client) {
|
|
|
3983
4017
|
console.log("Google callback:", user, err);
|
|
3984
4018
|
unsub();
|
|
3985
4019
|
if (!user) return;
|
|
3986
|
-
await client.request("/
|
|
4020
|
+
let result = await client.request("/auth/google", {
|
|
3987
4021
|
method: "POST",
|
|
3988
|
-
body: { user },
|
|
4022
|
+
body: { accessToken: user.accessToken },
|
|
3989
4023
|
auth: false
|
|
3990
4024
|
});
|
|
4025
|
+
console.log(result);
|
|
4026
|
+
setToken(result.token);
|
|
4027
|
+
console.log("Redirecting to:", redirectTo);
|
|
3991
4028
|
window.location.href = redirectTo;
|
|
3992
4029
|
});
|
|
3993
4030
|
}
|
package/tevroc-sdk.min.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Tevroc=(()=>{var _e=Object.defineProperty;var Rt=Object.getOwnPropertyDescriptor;var Ut=Object.getOwnPropertyNames;var Dt=Object.prototype.hasOwnProperty;var w=(t,e,n)=>()=>{if(n)throw n[0];try{return t&&(e=t(t=0)),e}catch(i){throw n=[i],i}};var j=(t,e)=>{for(var n in e)_e(t,n,{get:e[n],enumerable:!0})},$t=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ut(e))!Dt.call(t,r)&&r!==n&&_e(t,r,{get:()=>e[r],enumerable:!(i=Rt(e,r))||i.enumerable});return t};var Wt=t=>$t(_e({},"__esModule",{value:!0}),t);var G,K,qt,zt,Nt,ve,D,T,Ve,Je,Pe,Pn,Mt,Bt,Ft,jt,ke,kn,Ke,Ye,Ae,An,Y=w(()=>{(function(t){t.Unimplemented="UNIMPLEMENTED",t.Unavailable="UNAVAILABLE"})(G||(G={}));K=class extends Error{constructor(e,n,i){super(e),this.message=e,this.code=n,this.data=i}},qt=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"},zt=t=>{let e=t.CapacitorCustomPlatform||null,n=t.Capacitor||{},i=n.Plugins=n.Plugins||{},r=()=>e!==null?e.name:qt(t),o=()=>r()!=="web",a=l=>{let c=f.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(ie=>ie.name===l)},d=l=>t.console.error(l),f=new Map,y=(l,c={})=>{let ie=f.get(l);if(ie)return console.warn(`Capacitor plugin "${l}" already registered. Cannot register plugins twice.`),ie.proxy;let U=r(),F=u(l),E,St=async()=>(!E&&U in c?E=typeof c[U]=="function"?E=await c[U]():E=c[U]:e!==null&&!E&&"web"in c&&(E=typeof c.web=="function"?E=await c.web():E=c.web),E),xt=(g,_)=>{var A,S;if(F){let x=F?.methods.find(k=>_===k.name);if(x)return x.rtype==="promise"?k=>n.nativePromise(l,_.toString(),k):(k,re)=>n.nativeCallback(l,_.toString(),k,re);if(g)return(A=g[_])===null||A===void 0?void 0:A.bind(g)}else{if(g)return(S=g[_])===null||S===void 0?void 0:S.bind(g);throw new K(`"${l}" plugin is not implemented on ${U}`,G.Unimplemented)}},ye=g=>{let _,A=(...S)=>{let x=St().then(k=>{let re=xt(k,g);if(re){let se=re(...S);return _=se?.remove,se}else throw new K(`"${l}.${g}()" is not implemented on ${U}`,G.Unimplemented)});return g==="addListener"&&(x.remove=async()=>_()),x};return A.toString=()=>`${g.toString()}() { [capacitor code] }`,Object.defineProperty(A,"name",{value:g,writable:!1,configurable:!1}),A},Ge=ye("addListener"),He=ye("removeListener"),It=(g,_)=>{let A=Ge({eventName:g},_),S=async()=>{let k=await A;He({eventName:g,callbackId:k},_)},x=new Promise(k=>A.then(()=>k({remove:S})));return x.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await S()},x},me=new Proxy({},{get(g,_){switch(_){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return F?It:Ge;case"removeListener":return He;default:return ye(_)}}});return i[l]=me,f.set(l,{name:l,proxy:me,platforms:new Set([...Object.keys(c),...F?[U]:[]])}),me};return n.convertFileSrc||(n.convertFileSrc=l=>l),n.getPlatform=r,n.handleError=d,n.isNativePlatform=o,n.isPluginAvailable=a,n.registerPlugin=y,n.Exception=K,n.DEBUG=!!n.DEBUG,n.isLoggingEnabled=!!n.isLoggingEnabled,n},Nt=t=>t.Capacitor=zt(t),ve=Nt(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),D=ve.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 ve.Exception(e,G.Unimplemented)}unavailable(e="not available"){return new ve.Exception(e,G.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)}))}},Ve=t=>encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),Je=t=>t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent),Pe=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=Je(r).trim(),o=Je(o).trim(),n[r]=o}),n}async setCookie(e){try{let n=Ve(e.key),i=Ve(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)}}},Pn=D("CapacitorCookies",{web:()=>new Pe}),Mt=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)}),Bt=(t={})=>{let e=Object.keys(t);return Object.keys(t).map(r=>r.toLocaleLowerCase()).reduce((r,o,a)=>(r[o]=t[e[a]],r),{})},Ft=(t,e=!0)=>t?Object.entries(t).reduce((i,r)=>{let[o,a]=r,u,d;return Array.isArray(a)?(d="",a.forEach(f=>{u=e?encodeURIComponent(f):f,d+=`${o}=${u}&`}),d.slice(0,-1)):(u=e?encodeURIComponent(a):a,d=`${o}=${u}`),`${i}&${d}`},"").substr(1):null,jt=(t,e={})=>{let n=Object.assign({method:t.method||"GET",headers:t.headers},e),r=Bt(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},ke=class extends T{async request(e){let n=jt(e,e.webFetchExtra),i=Ft(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,f;switch(u){case"arraybuffer":case"blob":f=await o.blob(),d=await Mt(f);break;case"json":d=await o.json();break;default:d=await o.text()}let y={};return o.headers.forEach((l,c)=>{y[c]=l}),{data:d,headers:y,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"}))}},kn=D("CapacitorHttp",{web:()=>new ke});(function(t){t.Dark="DARK",t.Light="LIGHT",t.Default="DEFAULT"})(Ke||(Ke={}));(function(t){t.StatusBar="StatusBar",t.NavigationBar="NavigationBar"})(Ye||(Ye={}));Ae=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")}},An=D("SystemBars",{web:()=>new Ae})});var Ze=w(()=>{});var Qe={};j(Qe,{AppWeb:()=>Le});var Le,Xe=w(()=>{Y();Le=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 oe,Ce=w(()=>{Y();Ze();oe=D("App",{web:()=>Promise.resolve().then(()=>(Xe(),Qe)).then(t=>new t.AppWeb)})});var et=w(()=>{});var tt={};j(tt,{Browser:()=>Gt,BrowserWeb:()=>ae});var ae,Gt,nt=w(()=>{Y();ae=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!")})}},Gt=new ae});var le,Ee=w(()=>{Y();et();le=D("Browser",{web:()=>Promise.resolve().then(()=>(nt(),tt)).then(t=>new t.BrowserWeb)})});function p(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 $(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 it=w(()=>{});function Te(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 W,v,H,ue,ce,m,rt,de,q=w(()=>{it();m="__TAURI_TO_IPC_KEY__";rt=class{constructor(e){W.set(this,void 0),v.set(this,0),H.set(this,[]),ue.set(this,void 0),$(this,W,e||(()=>{}),"f"),this.id=Te(n=>{let i=n.index;if("end"in n){i==p(this,v,"f")?this.cleanupCallback():$(this,ue,i,"f");return}let r=n.message;if(i==p(this,v,"f")){for(p(this,W,"f").call(this,r),$(this,v,p(this,v,"f")+1,"f");p(this,v,"f")in p(this,H,"f");){let o=p(this,H,"f")[p(this,v,"f")];p(this,W,"f").call(this,o),delete p(this,H,"f")[p(this,v,"f")],$(this,v,p(this,v,"f")+1,"f")}p(this,v,"f")===p(this,ue,"f")&&this.cleanupCallback()}else p(this,H,"f")[i]=r})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(e){$(this,W,e,"f")}get onmessage(){return p(this,W,"f")}[(W=new WeakMap,v=new WeakMap,H=new WeakMap,ue=new WeakMap,m)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[m]()}};de=class{get rid(){return p(this,ce,"f")}constructor(e){ce.set(this,void 0),$(this,ce,e,"f")}async close(){return s("plugin:resources|close",{rid:this.rid})}};ce=new WeakMap});var Z,L,P,Q,b,C,he=w(()=>{q();Z=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 L(this.width*e,this.height*e)}[m](){return{width:this.width,height:this.height}}toJSON(){return this[m]()}},L=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 Z(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 Z?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof L?this.size:this.size.toPhysical(e)}[m](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[m]()}},Q=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 Q(this.x/e,this.y/e)}[m](){return{x:this.x,y:this.y}}toJSON(){return this[m]()}},C=class{constructor(e){this.position=e}toLogical(e){return this.position instanceof Q?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 Oe={};j(Oe,{TauriEvent:()=>h,emit:()=>X,emitTo:()=>ee,listen:()=>I,once:()=>z});async function st(t,e){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(t,e),await s("plugin:event|unlisten",{event:t,eventId:e})}async function I(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:Te(e)}).then(o=>async()=>st(t,o))}async function z(t,e,n){return I(t,i=>{st(t,i.id),e(i)},n)}async function X(t,e){await s("plugin:event|emit",{event:t,payload:e})}async function ee(t,e,n){await s("plugin:event|emit_to",{target:typeof t=="string"?{kind:"AnyLabel",label:t}:t,event:e,payload:n})}var h,V=w(()=>{q();(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"})(h||(h={}))});function te(t){return t==null?null:typeof t=="string"?t:t instanceof Se?t.rid:t}var Se,ot=w(()=>{q();Se=class t extends de{constructor(e){super(e)}static async new(e,n,i){return s("plugin:image|new",{rgba:te(e),width:n,height:i}).then(r=>new t(r))}static async fromBytes(e){return s("plugin:image|from_bytes",{bytes:te(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 De(){return new R(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function xe(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new R(e,{skip:!0})))}var Re,Ue,at,Ie,R,lt,ut,ct,dt,$e=w(()=>{he();he();V();q();ot();(function(t){t[t.Critical=1]="Critical",t[t.Informational=2]="Informational"})(Re||(Re={}));Ue=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"})(at||(at={}));Ie=["tauri://created","tauri://error"],R=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 De()}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)}:I(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)}:z(e,n,{target:{kind:"Window",label:this.label}})}async emit(e,n){if(Ie.includes(e)){for(let i of this.listeners[e]||[])i({event:e,id:-1,payload:n});return}return X(e,n)}async emitTo(e,n,i){if(Ie.includes(n)){for(let r of this.listeners[n]||[])r({event:n,id:-1,payload:i});return}return ee(e,n,i)}_handleTauriEvent(e,n){return Ie.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 L(e))}async outerSize(){return s("plugin:window|outer_size",{label:this.label}).then(e=>new L(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===Re.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 C?e:new C(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:te(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 C?e:new C(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?te(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(h.WINDOW_RESIZED,n=>{n.payload=new L(n.payload),e(n)})}async onMoved(e){return this.listen(h.WINDOW_MOVED,n=>{n.payload=new b(n.payload),e(n)})}async onCloseRequested(e){return this.listen(h.WINDOW_CLOSE_REQUESTED,async n=>{let i=new Ue(n);await e(i),i.isPreventDefault()||await this.destroy()})}async onDragDropEvent(e){let n=await this.listen(h.DRAG_ENTER,a=>{e({...a,payload:{type:"enter",paths:a.payload.paths,position:new b(a.payload.position)}})}),i=await this.listen(h.DRAG_OVER,a=>{e({...a,payload:{type:"over",position:new b(a.payload.position)}})}),r=await this.listen(h.DRAG_DROP,a=>{e({...a,payload:{type:"drop",paths:a.payload.paths,position:new b(a.payload.position)}})}),o=await this.listen(h.DRAG_LEAVE,a=>{e({...a,payload:{type:"leave"}})});return()=>{n(),r(),i(),o()}}async onFocusChanged(e){let n=await this.listen(h.WINDOW_FOCUS,r=>{e({...r,payload:!0})}),i=await this.listen(h.WINDOW_BLUR,r=>{e({...r,payload:!1})});return()=>{n(),i()}}async onScaleChanged(e){return this.listen(h.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(h.WINDOW_THEME_CHANGED,e)}};(function(t){t.Disabled="disabled",t.Throttle="throttle",t.Suspend="suspend"})(lt||(lt={}));(function(t){t.Default="default",t.FluentOverlay="fluentOverlay"})(ut||(ut={}));(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"})(ct||(ct={}));(function(t){t.FollowsWindowActiveState="followsWindowActiveState",t.Active="active",t.Inactive="inactive"})(dt||(dt={}))});function qe(){return new J(De(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function ht(){return s("plugin:webview|get_all_webviews").then(t=>t.map(e=>new J(new R(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}var We,J,wt=w(()=>{he();V();q();$e();We=["tauri://created","tauri://error"],J=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 ht()).find(i=>i.label===e))!==null&&n!==void 0?n:null}static getCurrent(){return qe()}static async getAll(){return ht()}async listen(e,n){return this._handleTauriEvent(e,n)?()=>{let i=this.listeners[e];i.splice(i.indexOf(n),1)}:I(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)}:z(e,n,{target:{kind:"Webview",label:this.label}})}async emit(e,n){if(We.includes(e)){for(let i of this.listeners[e]||[])i({event:e,id:-1,payload:n});return}return X(e,n)}async emitTo(e,n,i){if(We.includes(n)){for(let r of this.listeners[n]||[])r({event:n,id:-1,payload:i});return}return ee(e,n,i)}_handleTauriEvent(e,n){return We.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 L(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 C?e:new C(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(h.DRAG_ENTER,a=>{e({...a,payload:{type:"enter",paths:a.payload.paths,position:new b(a.payload.position)}})}),i=await this.listen(h.DRAG_OVER,a=>{e({...a,payload:{type:"over",position:new b(a.payload.position)}})}),r=await this.listen(h.DRAG_DROP,a=>{e({...a,payload:{type:"drop",paths:a.payload.paths,position:new b(a.payload.position)}})}),o=await this.listen(h.DRAG_LEAVE,a=>{e({...a,payload:{type:"leave"}})});return()=>{n(),r(),i(),o()}}}});function Ht(){let t=qe();return new O(t.label,{skip:!0})}async function pt(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new O(e,{skip:!0})))}function Vt(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,ze=w(()=>{wt();$e();V();q();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 pt()).find(r=>r.label===e))!==null&&n!==void 0?n:null;return i?new t(i.label,{skip:!0}):null}static getCurrent(){return Ht()}static async getAll(){return pt()}async listen(e,n){return this._handleTauriEvent(e,n)?()=>{let i=this.listeners[e];i.splice(i.indexOf(n),1)}:I(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)}:z(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}))}};Vt(O,[R,J])});var Jt,Ne,N,M,Me=w(()=>{Jt=()=>{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"},Ne=Jt(),N=Ne==="android"||Ne==="ios",M=Ne==="tauri"});var mt={};j(mt,{createGoogleLogin:()=>Yt,initializeGoogleLogin:()=>yt,subscribeGoogleLogin:()=>Kt});function bt(t,e=null){we.forEach(n=>{try{n(t,e)}catch(i){console.error("Google listener error:",i)}})}function Kt(t){return we.push(t),()=>{let e=we.indexOf(t);e!==-1&&we.splice(e,1)}}var gt,we,pe,ft,yt,Yt,_t=w(()=>{Ce();Ee();ze();Me();gt=!1,we=[];pe=null,ft=async t=>{try{if(!t?.includes("token="))return;let n=new URLSearchParams(t.split("?")[1]).get("token"),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};localStorage.setItem("user",JSON.stringify(o)),localStorage.setItem("idToken",n),bt(o,null)}catch(e){bt(null,e)}},yt=async()=>{if(!gt&&(gt=!0,N&&oe.addListener("appUrlOpen",t=>{ft(t.url)}),M)){let{listen:t}=await Promise.resolve().then(()=>(V(),Oe));await t("deep-link://open-url",async e=>{let n=e.payload;if(typeof n=="object"&&(n=n?.url||n?.payload||null),!!n){if(pe)try{await pe.close(),pe=null}catch{}ft(n)}})}},Yt=async({appId:t="tevrocsoft",appName:e="Tevroc",serviceUrl:n="https://tevrocsoftapi.netlify.app"}={})=>{console.log("appId:",t,"serviceUrl:",n),console.log(N,M),await yt();let i=`${n}/login?mode=mobile&app=${t}`;if(N){await le.open({url:i});return}if(M){let a=`${n}/login?mode=desktop&app=${t}`,u=new O("auth",{url:a,title:`${e} Login`,width:550,height:500,resizable:!0,center:!0});pe=u,u.once("tauri://created",()=>{console.log("Auth window opened")}),u.once("tauri://error",d=>{console.error("Auth window error:",d)});return}let o=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"?"localhost":"netlify";i=`${n}/login?mode=${o}&app=${t}`,window.location.href=i}});var Ct={};j(Ct,{createPayment:()=>At,default:()=>Lt,initializePayment:()=>Be,subscribePaymentStatus:()=>Zt});function Pt(t,e=null){ge.forEach(n=>{try{n(t,e)}catch(i){console.error("Payment listener error:",i)}})}function Zt(t){return ge.push(t),()=>{let e=ge.indexOf(t);e!==-1&&ge.splice(e,1)}}function Lt({externalCallback:t=()=>{}}={}){return Be(t),{createPayment:At}}var vt,ge,be,Qt,ne,kt,Be,At,Et=w(()=>{Ce();Ee();ze();Me();vt=!1,ge=[];be=null,Qt=[],ne=(...t)=>{t.forEach(e=>{let n={message:e,time:new Date().toISOString()};Qt.push(n),console.log(n)})},kt=async(t,e=()=>{})=>{try{if(ne("PAYMENT CALLBACK:",t),!t?.includes("state="))return;let i=new URLSearchParams(t.split("?")[1]).get("state");ne("PAYMENT RESULT:",i),i=="success"?ne("PAYMENT SUCCESS"):ne("PAYMENT FAILED"),e(i,null),Pt(i,null)}catch(n){ne("PAYMENT CALLBACK ERROR:",n.message),e(null,n),Pt(null,n)}},Be=async(t=()=>{})=>{if(!vt&&(vt=!0,N&&oe.addListener("appUrlOpen",e=>{kt(e.url,t)}),M)){let{listen:e}=await Promise.resolve().then(()=>(V(),Oe));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{}kt(i,t)}})}},At=async(t,{appId:e="tevrocsoft",serviceUrl:n="https://tevrocsoftapi.netlify.app",externalCallback:i=()=>{}}={})=>{await Be(i);let r=Math.round(Number(t)*100),o=`${n}/pay`,a=`${o}?mode=mobile&amount=${r}&app=${e}`;if(N){await le.open({url:a});return}if(M){let f=`${o}?mode=desktop&amount=${r}&app=${e}`,y=new O("payment",{url:f,title:"Complete Payment",width:550,height:600,resizable:!0,center:!0});be=y,y.once("tauri://created",()=>{console.log("Payment window opened")}),y.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 _n={};j(_n,{TevrocClient:()=>fe,TevrocError:()=>B,createClient:()=>tn});var Fe=null;async function Xt(){return Fe||(Fe=await Promise.resolve().then(()=>(_t(),mt))),Fe}var je=null;async function en(){return je||(je=await Promise.resolve().then(()=>(Et(),Ct))),je}var B=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 tn(t={}){return new fe(t)}var fe=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=Ot(n),this.serviceUrl=Ot(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=yn(e.headers),this.token=e.token??null,this.auth=rn(this),this.entities=sn(this),this.functions=an(this),this.integrations=ln(this),this.agents=un(this),this.logs=dn(this),this.connectors=hn(this),this.customIntegrations=wn(this),this.sso=pn(this),this.files=gn(this),this.payments=nn(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?fn(n.query):"",a=`${this.baseUrl}${e.startsWith("/")?e:`/${e}`}${o}`,u=new AbortController,d=setTimeout(()=>u.abort(),n.timeoutMs??this.timeoutMs),f=this.token||localStorage.getItem("tevroc_access_token");f&&n.auth!==!1&&r.set("authorization",`Bearer ${f}`),console.log(f);let y=n.body;if(y!=null&&mn(y)&&(r.set("content-type","application/json"),y=JSON.stringify(y)),n.headers)for(let[l,c]of Object.entries(n.headers))c!=null&&r.set(l,String(c));try{let l=await this.fetch(a,{method:i,headers:r,body:y,signal:n.signal??u.signal});return await bn(l,n.parseAs)}catch(l){throw l?.name==="AbortError"?new B("Request timed out",{code:"timeout"}):l instanceof B?l:new B(l?.message??"Network request failed",{code:"network_error",details:l})}finally{clearTimeout(d)}}};function nn(t){return{create:async({amountZAR:e,appId:n="tevrocsoft",mode:i="web"})=>{let{createPayment:r}=await en();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 rn(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)=>{if(e==="google"){let{createGoogleLogin:i,subscribeGoogleLogin:r}=await Xt();if(console.log({serviceUrl:t.serviceUrl,appId:t.appId,appName:t.appName}),i({serviceUrl:t.serviceUrl,appId:t.appId,appName:t.appName}),n){let o=r(async(a,u)=>{console.log("Google callback:",a,u),o(),a&&(await t.request("/provider/google/auth/login",{method:"POST",body:{user:a},auth:!1}),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 sn(t){return new Proxy({},{get(e,n){if(typeof n=="string")return on(t,n)}})}function on(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 an(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 ln(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={})=>Tt(t,"/integrations/core/upload-file",e,n),UploadPrivateFile:(e,n={})=>Tt(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 un(t){return new Proxy({},{get(e,n){if(typeof n=="string")return cn(t,n)}})}function cn(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 dn(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 hn(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 wn(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 pn(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 gn(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 Tt(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 bn(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 B(o.message??t.statusText,{status:t.status,code:o.code??"api_error",details:o.details??r,response:t})}return r}function fn(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 Ot(t){return String(t).replace(/\/+$/,"")}function yn(t={}){return Object.fromEntries(new Headers(t).entries())}function mn(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 Wt(_n);})();
|
|
1
|
+
var Tevroc=(()=>{var _e=Object.defineProperty;var xt=Object.getOwnPropertyDescriptor;var Ut=Object.getOwnPropertyNames;var Dt=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 j=(t,e)=>{for(var n in e)_e(t,n,{get:e[n],enumerable:!0})},$t=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ut(e))!Dt.call(t,r)&&r!==n&&_e(t,r,{get:()=>e[r],enumerable:!(i=xt(e,r))||i.enumerable});return t};var Wt=t=>$t(_e({},"__esModule",{value:!0}),t);var H,Y,qt,zt,Nt,ve,D,T,Je,Ke,Pe,Pn,Mt,Bt,Ft,Gt,ke,kn,Ye,Ze,Ce,Cn,Z=g(()=>{(function(t){t.Unimplemented="UNIMPLEMENTED",t.Unavailable="UNAVAILABLE"})(H||(H={}));Y=class extends Error{constructor(e,n,i){super(e),this.message=e,this.code=n,this.data=i}},qt=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"},zt=t=>{let e=t.CapacitorCustomPlatform||null,n=t.Capacitor||{},i=n.Plugins=n.Plugins||{},r=()=>e!==null?e.name:qt(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(F=>F.name===l)},c=l=>t.console.error(l),d=new Map,p=(l,h={})=>{let F=d.get(l);if(F)return console.warn(`Capacitor plugin "${l}" already registered. Cannot register plugins twice.`),F.proxy;let U=r(),G=u(l),E,St=async()=>(!E&&U in h?E=typeof h[U]=="function"?E=await h[U]():E=h[U]:e!==null&&!E&&"web"in h&&(E=typeof h.web=="function"?E=await h.web():E=h.web),E),It=(b,_)=>{var C,S;if(G){let I=G?.methods.find(k=>_===k.name);if(I)return I.rtype==="promise"?k=>n.nativePromise(l,_.toString(),k):(k,re)=>n.nativeCallback(l,_.toString(),k,re);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 Y(`"${l}" plugin is not implemented on ${U}`,H.Unimplemented)}},ye=b=>{let _,C=(...S)=>{let I=St().then(k=>{let re=It(k,b);if(re){let se=re(...S);return _=se?.remove,se}else throw new Y(`"${l}.${b}()" is not implemented on ${U}`,H.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},He=ye("addListener"),Ve=ye("removeListener"),Rt=(b,_)=>{let C=He({eventName:b},_),S=async()=>{let k=await C;Ve({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},me=new Proxy({},{get(b,_){switch(_){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return G?Rt:He;case"removeListener":return Ve;default:return ye(_)}}});return i[l]=me,d.set(l,{name:l,proxy:me,platforms:new Set([...Object.keys(h),...G?[U]:[]])}),me};return n.convertFileSrc||(n.convertFileSrc=l=>l),n.getPlatform=r,n.handleError=c,n.isNativePlatform=o,n.isPluginAvailable=a,n.registerPlugin=p,n.Exception=Y,n.DEBUG=!!n.DEBUG,n.isLoggingEnabled=!!n.isLoggingEnabled,n},Nt=t=>t.Capacitor=zt(t),ve=Nt(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),D=ve.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 ve.Exception(e,H.Unimplemented)}unavailable(e="not available"){return new ve.Exception(e,H.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)}))}},Je=t=>encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),Ke=t=>t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent),Pe=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=Ke(r).trim(),o=Ke(o).trim(),n[r]=o}),n}async setCookie(e){try{let n=Je(e.key),i=Je(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)}}},Pn=D("CapacitorCookies",{web:()=>new Pe}),Mt=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)}),Bt=(t={})=>{let e=Object.keys(t);return Object.keys(t).map(r=>r.toLocaleLowerCase()).reduce((r,o,a)=>(r[o]=t[e[a]],r),{})},Ft=(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,Gt=(t,e={})=>{let n=Object.assign({method:t.method||"GET",headers:t.headers},e),r=Bt(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},ke=class extends T{async request(e){let n=Gt(e,e.webFetchExtra),i=Ft(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 Mt(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"}))}},kn=D("CapacitorHttp",{web:()=>new ke});(function(t){t.Dark="DARK",t.Light="LIGHT",t.Default="DEFAULT"})(Ye||(Ye={}));(function(t){t.StatusBar="StatusBar",t.NavigationBar="NavigationBar"})(Ze||(Ze={}));Ce=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")}},Cn=D("SystemBars",{web:()=>new Ce})});var Qe=g(()=>{});var Xe={};j(Xe,{AppWeb:()=>Le});var Le,et=g(()=>{Z();Le=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 oe,Ae=g(()=>{Z();Qe();oe=D("App",{web:()=>Promise.resolve().then(()=>(et(),Xe)).then(t=>new t.AppWeb)})});var tt=g(()=>{});var nt={};j(nt,{Browser:()=>jt,BrowserWeb:()=>ae});var ae,jt,it=g(()=>{Z();ae=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!")})}},jt=new ae});var le,Ee=g(()=>{Z();tt();le=D("Browser",{web:()=>Promise.resolve().then(()=>(it(),nt)).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 $(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 rt=g(()=>{});function Te(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 W,v,V,ue,ce,m,st,de,q=g(()=>{rt();m="__TAURI_TO_IPC_KEY__";st=class{constructor(e){W.set(this,void 0),v.set(this,0),V.set(this,[]),ue.set(this,void 0),$(this,W,e||(()=>{}),"f"),this.id=Te(n=>{let i=n.index;if("end"in n){i==f(this,v,"f")?this.cleanupCallback():$(this,ue,i,"f");return}let r=n.message;if(i==f(this,v,"f")){for(f(this,W,"f").call(this,r),$(this,v,f(this,v,"f")+1,"f");f(this,v,"f")in f(this,V,"f");){let o=f(this,V,"f")[f(this,v,"f")];f(this,W,"f").call(this,o),delete f(this,V,"f")[f(this,v,"f")],$(this,v,f(this,v,"f")+1,"f")}f(this,v,"f")===f(this,ue,"f")&&this.cleanupCallback()}else f(this,V,"f")[i]=r})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(e){$(this,W,e,"f")}get onmessage(){return f(this,W,"f")}[(W=new WeakMap,v=new WeakMap,V=new WeakMap,ue=new WeakMap,m)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[m]()}};de=class{get rid(){return f(this,ce,"f")}constructor(e){ce.set(this,void 0),$(this,ce,e,"f")}async close(){return s("plugin:resources|close",{rid:this.rid})}};ce=new WeakMap});var Q,L,P,X,y,A,he=g(()=>{q();Q=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 L(this.width*e,this.height*e)}[m](){return{width:this.width,height:this.height}}toJSON(){return this[m]()}},L=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 Q(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 Q?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof L?this.size:this.size.toPhysical(e)}[m](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[m]()}},X=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 X(this.x/e,this.y/e)}[m](){return{x:this.x,y:this.y}}toJSON(){return this[m]()}},A=class{constructor(e){this.position=e}toLogical(e){return this.position instanceof X?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 Oe={};j(Oe,{TauriEvent:()=>w,emit:()=>ee,emitTo:()=>te,listen:()=>R,once:()=>z});async function ot(t,e){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(t,e),await s("plugin:event|unlisten",{event:t,eventId:e})}async function R(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:Te(e)}).then(o=>async()=>ot(t,o))}async function z(t,e,n){return R(t,i=>{ot(t,i.id),e(i)},n)}async function ee(t,e){await s("plugin:event|emit",{event:t,payload:e})}async function te(t,e,n){await s("plugin:event|emit_to",{target:typeof t=="string"?{kind:"AnyLabel",label:t}:t,event:e,payload:n})}var w,J=g(()=>{q();(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 ne(t){return t==null?null:typeof t=="string"?t:t instanceof Se?t.rid:t}var Se,at=g(()=>{q();Se=class t extends de{constructor(e){super(e)}static async new(e,n,i){return s("plugin:image|new",{rgba:ne(e),width:n,height:i}).then(r=>new t(r))}static async fromBytes(e){return s("plugin:image|from_bytes",{bytes:ne(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 De(){return new x(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function Ie(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new x(e,{skip:!0})))}var xe,Ue,lt,Re,x,ut,ct,dt,ht,$e=g(()=>{he();he();J();q();at();(function(t){t[t.Critical=1]="Critical",t[t.Informational=2]="Informational"})(xe||(xe={}));Ue=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"})(lt||(lt={}));Re=["tauri://created","tauri://error"],x=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 Ie()).find(i=>i.label===e))!==null&&n!==void 0?n:null}static getCurrent(){return De()}static async getAll(){return Ie()}static async getFocusedWindow(){for(let e of await Ie())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)}:R(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)}:z(e,n,{target:{kind:"Window",label:this.label}})}async emit(e,n){if(Re.includes(e)){for(let i of this.listeners[e]||[])i({event:e,id:-1,payload:n});return}return ee(e,n)}async emitTo(e,n,i){if(Re.includes(n)){for(let r of this.listeners[n]||[])r({event:n,id:-1,payload:i});return}return te(e,n,i)}_handleTauriEvent(e,n){return Re.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 L(e))}async outerSize(){return s("plugin:window|outer_size",{label:this.label}).then(e=>new L(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===xe.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 A?e:new A(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:ne(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 A?e:new A(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?ne(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 L(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 Ue(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"})(ut||(ut={}));(function(t){t.Default="default",t.FluentOverlay="fluentOverlay"})(ct||(ct={}));(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"})(dt||(dt={}));(function(t){t.FollowsWindowActiveState="followsWindowActiveState",t.Active="active",t.Inactive="inactive"})(ht||(ht={}))});function qe(){return new K(De(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function wt(){return s("plugin:webview|get_all_webviews").then(t=>t.map(e=>new K(new x(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}var We,K,pt=g(()=>{he();J();q();$e();We=["tauri://created","tauri://error"],K=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 wt()).find(i=>i.label===e))!==null&&n!==void 0?n:null}static getCurrent(){return qe()}static async getAll(){return wt()}async listen(e,n){return this._handleTauriEvent(e,n)?()=>{let i=this.listeners[e];i.splice(i.indexOf(n),1)}:R(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)}:z(e,n,{target:{kind:"Webview",label:this.label}})}async emit(e,n){if(We.includes(e)){for(let i of this.listeners[e]||[])i({event:e,id:-1,payload:n});return}return ee(e,n)}async emitTo(e,n,i){if(We.includes(n)){for(let r of this.listeners[n]||[])r({event:n,id:-1,payload:i});return}return te(e,n,i)}_handleTauriEvent(e,n){return We.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 L(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 A?e:new A(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 Ht(){let t=qe();return new O(t.label,{skip:!0})}async function gt(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new O(e,{skip:!0})))}function Vt(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,ze=g(()=>{pt();$e();J();q();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 gt()).find(r=>r.label===e))!==null&&n!==void 0?n:null;return i?new t(i.label,{skip:!0}):null}static getCurrent(){return Ht()}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)}:R(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)}:z(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}))}};Vt(O,[x,K])});var Jt,Ne,N,M,Me=g(()=>{Jt=()=>{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"},Ne=Jt(),N=Ne==="android"||Ne==="ios",M=Ne==="tauri"});var mt={};j(mt,{createGoogleLogin:()=>Yt,initializeGoogleLogin:()=>yt,subscribeGoogleLogin:()=>Kt});function bt(t,e=null){we.forEach(n=>{try{n(t,e)}catch(i){console.error("Google listener error:",i)}})}function Kt(t){return we.push(t),()=>{let e=we.indexOf(t);e!==-1&&we.splice(e,1)}}var ft,we,pe,Be,yt,Yt,_t=g(()=>{Ae();Ee();ze();Me();ft=!1,we=[];pe=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),bt(o,null)}catch(e){bt(null,e)}},yt=async()=>{if(!ft&&(ft=!0,N&&oe.addListener("appUrlOpen",t=>{Be(t.url)}),M)){let{listen:t}=await Promise.resolve().then(()=>(J(),Oe));await t("deep-link://open-url",async e=>{let n=e.payload;if(typeof n=="object"&&(n=n?.url||n?.payload||null),!!n){if(pe)try{await pe.close(),pe=null}catch{}Be(n)}})}},Yt=async({appId:t="tevrocsoft",appName:e="Tevroc",serviceUrl:n="https://tevrocsoftapi.netlify.app"}={})=>{console.log("appId:",t,"serviceUrl:",n),console.log(N,M),await yt();let i=`${n}/login?mode=mobile&app=${encodeURIComponent(t)}&name=${encodeURIComponent(e)}`;if(N){await le.open({url:i});return}if(M){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});pe=d,d.once("tauri://created",()=>{console.log("Auth window opened")}),d.once("tauri://error",p=>{console.error("Auth window error:",p)});return}let r=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1",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,F=h?`${window.location.href}${window.location.href.includes("?")?"&":"?"}token=${h}`:window.location.href;c.close(),window.removeEventListener("message",d),Be(F)}};window.addEventListener("message",d);let p=setInterval(()=>{c.closed&&(clearInterval(p),window.removeEventListener("message",d))},500);return}}});var At={};j(At,{createPayment:()=>Ct,default:()=>Lt,initializePayment:()=>Fe,subscribePaymentStatus:()=>Zt});function Pt(t,e=null){ge.forEach(n=>{try{n(t,e)}catch(i){console.error("Payment listener error:",i)}})}function Zt(t){return ge.push(t),()=>{let e=ge.indexOf(t);e!==-1&&ge.splice(e,1)}}function Lt({externalCallback:t=()=>{}}={}){return Fe(t),{createPayment:Ct}}var vt,ge,fe,Qt,ie,kt,Fe,Ct,Et=g(()=>{Ae();Ee();ze();Me();vt=!1,ge=[];fe=null,Qt=[],ie=(...t)=>{t.forEach(e=>{let n={message:e,time:new Date().toISOString()};Qt.push(n),console.log(n)})},kt=async(t,e=()=>{})=>{try{if(ie("PAYMENT CALLBACK:",t),!t?.includes("state="))return;let i=new URLSearchParams(t.split("?")[1]).get("state");ie("PAYMENT RESULT:",i),i=="success"?ie("PAYMENT SUCCESS"):ie("PAYMENT FAILED"),e(i,null),Pt(i,null)}catch(n){ie("PAYMENT CALLBACK ERROR:",n.message),e(null,n),Pt(null,n)}},Fe=async(t=()=>{})=>{if(!vt&&(vt=!0,N&&oe.addListener("appUrlOpen",e=>{kt(e.url,t)}),M)){let{listen:e}=await Promise.resolve().then(()=>(J(),Oe));await e("deep-link://open-url",async n=>{let i=n.payload;if(typeof i=="object"&&(i=i?.url||i?.payload||null),!!i){if(fe)try{await fe.close(),fe=null}catch{}kt(i,t)}})}},Ct=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(N){await le.open({url:a});return}if(M){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});fe=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 _n={};j(_n,{TevrocClient:()=>be,TevrocError:()=>B,createClient:()=>tn});var Ge=null;async function Xt(){return Ge||(Ge=await Promise.resolve().then(()=>(_t(),mt))),Ge}var je=null;async function en(){return je||(je=await Promise.resolve().then(()=>(Et(),At))),je}var B=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 tn(t={}){return new be(t)}var be=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=Ot(n),this.serviceUrl=Ot(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=yn(e.headers),this.token=e.token??null,this.auth=rn(this),this.entities=sn(this),this.functions=an(this),this.integrations=ln(this),this.agents=un(this),this.logs=dn(this),this.connectors=hn(this),this.customIntegrations=wn(this),this.sso=pn(this),this.files=gn(this),this.payments=nn(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?bn(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&&mn(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 fn(l,n.parseAs)}catch(l){throw l?.name==="AbortError"?new B("Request timed out",{code:"timeout"}):l instanceof B?l:new B(l?.message??"Network request failed",{code:"network_error",details:l})}finally{clearTimeout(c)}}};function nn(t){return{create:async({amountZAR:e,appId:n="tevrocsoft",mode:i="web"})=>{let{createPayment:r}=await en();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 rn(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 Xt();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 sn(t){return new Proxy({},{get(e,n){if(typeof n=="string")return on(t,n)}})}function on(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 an(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 ln(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={})=>Tt(t,"/integrations/core/upload-file",e,n),UploadPrivateFile:(e,n={})=>Tt(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 un(t){return new Proxy({},{get(e,n){if(typeof n=="string")return cn(t,n)}})}function cn(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 dn(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 hn(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 wn(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 pn(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 gn(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 Tt(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 fn(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 B(o.message??t.statusText,{status:t.status,code:o.code??"api_error",details:o.details??r,response:t})}return r}function bn(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 Ot(t){return String(t).replace(/\/+$/,"")}function yn(t={}){return Object.fromEntries(new Headers(t).entries())}function mn(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 Wt(_n);})();
|
|
2
2
|
/*! Bundled license information:
|
|
3
3
|
|
|
4
4
|
@capacitor/core/dist/index.js:
|
package/tevroc-sdk.umd.js
CHANGED
|
@@ -3598,6 +3598,7 @@ var Tevroc = (() => {
|
|
|
3598
3598
|
if (!url?.includes("token=")) return;
|
|
3599
3599
|
const params = new URLSearchParams(url.split("?")[1]);
|
|
3600
3600
|
const token = params.get("token");
|
|
3601
|
+
console.log("Google login token:", token);
|
|
3601
3602
|
const res = await fetch(
|
|
3602
3603
|
"https://www.googleapis.com/oauth2/v3/userinfo",
|
|
3603
3604
|
{
|
|
@@ -3615,6 +3616,7 @@ var Tevroc = (() => {
|
|
|
3615
3616
|
photo: googleUser.picture,
|
|
3616
3617
|
accessToken: token
|
|
3617
3618
|
};
|
|
3619
|
+
console.log("Google user profile:", profile);
|
|
3618
3620
|
localStorage.setItem("user", JSON.stringify(profile));
|
|
3619
3621
|
localStorage.setItem("idToken", token);
|
|
3620
3622
|
emitGoogleLogin(profile, null);
|
|
@@ -3657,13 +3659,13 @@ var Tevroc = (() => {
|
|
|
3657
3659
|
console.log("appId:", appId, "serviceUrl:", serviceUrl);
|
|
3658
3660
|
console.log(isCapacitor, isTauri);
|
|
3659
3661
|
await initializeGoogleLogin();
|
|
3660
|
-
let authUrl = `${serviceUrl}/login?mode=mobile&app=${appId}`;
|
|
3662
|
+
let authUrl = `${serviceUrl}/login?mode=mobile&app=${encodeURIComponent(appId)}&name=${encodeURIComponent(appName)}`;
|
|
3661
3663
|
if (isCapacitor) {
|
|
3662
3664
|
await Browser2.open({ url: authUrl });
|
|
3663
3665
|
return;
|
|
3664
3666
|
}
|
|
3665
3667
|
if (isTauri) {
|
|
3666
|
-
const url = `${serviceUrl}/login?mode=desktop&app=${appId}`;
|
|
3668
|
+
const url = `${serviceUrl}/login?mode=desktop&app=${encodeURIComponent(appId)}&name=${encodeURIComponent(appName)}`;
|
|
3667
3669
|
const win = new WebviewWindow("auth", {
|
|
3668
3670
|
url,
|
|
3669
3671
|
title: `${appName} Login`,
|
|
@@ -3682,9 +3684,40 @@ var Tevroc = (() => {
|
|
|
3682
3684
|
return;
|
|
3683
3685
|
}
|
|
3684
3686
|
const isLocalhost = window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1";
|
|
3687
|
+
const detectedAppId = typeof window !== "undefined" ? window.location.host : appId;
|
|
3685
3688
|
const mode = isLocalhost ? "localhost" : "netlify";
|
|
3686
|
-
|
|
3687
|
-
|
|
3689
|
+
const finalUrl = `${serviceUrl}/login?mode=${mode}&app=${encodeURIComponent(
|
|
3690
|
+
detectedAppId
|
|
3691
|
+
)}&name=${encodeURIComponent(appName)}`;
|
|
3692
|
+
if (isLocalhost) {
|
|
3693
|
+
const popup = window.open(
|
|
3694
|
+
finalUrl,
|
|
3695
|
+
"googleLogin",
|
|
3696
|
+
"width=500,height=650"
|
|
3697
|
+
);
|
|
3698
|
+
if (!popup) {
|
|
3699
|
+
console.error("Popup blocked");
|
|
3700
|
+
return;
|
|
3701
|
+
}
|
|
3702
|
+
const listener = (event) => {
|
|
3703
|
+
if (event.origin !== serviceUrl) return;
|
|
3704
|
+
if (event.data?.type === "google-auth") {
|
|
3705
|
+
const token = event.data?.token || null;
|
|
3706
|
+
const url = token ? `${window.location.href}${window.location.href.includes("?") ? "&" : "?"}token=${token}` : window.location.href;
|
|
3707
|
+
popup.close();
|
|
3708
|
+
window.removeEventListener("message", listener);
|
|
3709
|
+
handleCallback(url);
|
|
3710
|
+
}
|
|
3711
|
+
};
|
|
3712
|
+
window.addEventListener("message", listener);
|
|
3713
|
+
const timer = setInterval(() => {
|
|
3714
|
+
if (popup.closed) {
|
|
3715
|
+
clearInterval(timer);
|
|
3716
|
+
window.removeEventListener("message", listener);
|
|
3717
|
+
}
|
|
3718
|
+
}, 500);
|
|
3719
|
+
return;
|
|
3720
|
+
}
|
|
3688
3721
|
};
|
|
3689
3722
|
}
|
|
3690
3723
|
});
|
|
@@ -3983,7 +4016,8 @@ var Tevroc = (() => {
|
|
|
3983
4016
|
return result;
|
|
3984
4017
|
},
|
|
3985
4018
|
// base44
|
|
3986
|
-
loginWithProvider: async (provider, redirectTo) => {
|
|
4019
|
+
loginWithProvider: async (provider, redirectTo, setToken = () => {
|
|
4020
|
+
}) => {
|
|
3987
4021
|
if (provider === "google") {
|
|
3988
4022
|
const { createGoogleLogin: createGoogleLogin3, subscribeGoogleLogin: subscribeGoogleLogin3 } = await getGoogleModule();
|
|
3989
4023
|
console.log({
|
|
@@ -4001,11 +4035,14 @@ var Tevroc = (() => {
|
|
|
4001
4035
|
console.log("Google callback:", user, err);
|
|
4002
4036
|
unsub();
|
|
4003
4037
|
if (!user) return;
|
|
4004
|
-
await client.request("/
|
|
4038
|
+
let result = await client.request("/auth/google", {
|
|
4005
4039
|
method: "POST",
|
|
4006
|
-
body: { user },
|
|
4040
|
+
body: { accessToken: user.accessToken },
|
|
4007
4041
|
auth: false
|
|
4008
4042
|
});
|
|
4043
|
+
console.log(result);
|
|
4044
|
+
setToken(result.token);
|
|
4045
|
+
console.log("Redirecting to:", redirectTo);
|
|
4009
4046
|
window.location.href = redirectTo;
|
|
4010
4047
|
});
|
|
4011
4048
|
}
|