tevrocsdk 0.1.17 → 0.1.18

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tevrocsdk",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "description": "JavaScript SDK for the Tevroc API.",
5
5
  "main": "./tevroc-sdk.umd.js",
6
6
  "module": "./tevroc-sdk.esm.js",
package/tevroc-sdk.esm.js CHANGED
@@ -3498,6 +3498,7 @@ var isCapacitor = platform === "android" || platform === "ios";
3498
3498
  var isTauri = platform === "tauri";
3499
3499
 
3500
3500
  // src/services/useGoogleAuth.js
3501
+ var googleInitialized = false;
3501
3502
  var googleListeners = [];
3502
3503
  function emitGoogleLogin(user, err = null) {
3503
3504
  googleListeners.forEach((cb) => {
@@ -3512,21 +3513,15 @@ function subscribeGoogleLogin(cb) {
3512
3513
  googleListeners.push(cb);
3513
3514
  return () => {
3514
3515
  const i = googleListeners.indexOf(cb);
3515
- if (i !== -1) {
3516
- googleListeners.splice(i, 1);
3517
- }
3516
+ if (i !== -1) googleListeners.splice(i, 1);
3518
3517
  };
3519
3518
  }
3520
3519
  var authWindowRef = null;
3521
- var initialized = false;
3522
- var tauriUnlisten = null;
3523
- var capacitorListener = null;
3524
3520
  var handleCallback = async (url) => {
3525
3521
  try {
3526
3522
  if (!url?.includes("token=")) return;
3527
3523
  const params = new URLSearchParams(url.split("?")[1]);
3528
3524
  const token = params.get("token");
3529
- if (!token) return;
3530
3525
  const res = await fetch(
3531
3526
  "https://www.googleapis.com/oauth2/v3/userinfo",
3532
3527
  {
@@ -3548,66 +3543,50 @@ var handleCallback = async (url) => {
3548
3543
  localStorage.setItem("idToken", token);
3549
3544
  emitGoogleLogin(profile, null);
3550
3545
  } catch (err) {
3551
- console.error(err);
3552
3546
  emitGoogleLogin(null, err);
3553
3547
  }
3554
3548
  };
3555
- async function initializeGoogleLogin() {
3556
- if (initialized) return;
3557
- initialized = true;
3558
- try {
3559
- if (isCapacitor) {
3560
- capacitorListener = await App.addListener(
3561
- "appUrlOpen",
3562
- async (event) => {
3563
- await handleCallback(event.url);
3564
- }
3565
- );
3566
- }
3567
- if (isTauri) {
3568
- const { listen: listen2 } = await Promise.resolve().then(() => (init_event(), event_exports));
3569
- tauriUnlisten = await listen2(
3570
- "deep-link://open-url",
3571
- async (event) => {
3572
- let url = event.payload;
3573
- if (typeof url === "object") {
3574
- url = url?.url || url?.payload || null;
3575
- }
3576
- if (!url) return;
3577
- if (authWindowRef) {
3578
- try {
3579
- await authWindowRef.close();
3580
- } catch (e) {
3581
- }
3582
- authWindowRef = null;
3583
- }
3584
- await handleCallback(url);
3549
+ var initializeGoogleLogin = async () => {
3550
+ if (googleInitialized) return;
3551
+ googleInitialized = true;
3552
+ if (isCapacitor) {
3553
+ App.addListener("appUrlOpen", (event) => {
3554
+ handleCallback(event.url);
3555
+ });
3556
+ }
3557
+ if (isTauri) {
3558
+ const { listen: listen2 } = await Promise.resolve().then(() => (init_event(), event_exports));
3559
+ await listen2("deep-link://open-url", async (event) => {
3560
+ let url = event.payload;
3561
+ if (typeof url === "object") {
3562
+ url = url?.url || url?.payload || null;
3563
+ }
3564
+ if (!url) return;
3565
+ if (authWindowRef) {
3566
+ try {
3567
+ await authWindowRef.close();
3568
+ authWindowRef = null;
3569
+ } catch (e) {
3585
3570
  }
3586
- );
3587
- }
3588
- console.log("Google login initialized");
3589
- } catch (err) {
3590
- console.error("Google login init failed:", err);
3571
+ }
3572
+ handleCallback(url);
3573
+ });
3591
3574
  }
3592
- }
3575
+ };
3593
3576
  var createGoogleLogin = async ({
3594
3577
  appId = "tevrocsoft",
3595
3578
  serviceUrl = "https://tevrocsoftapi.netlify.app"
3596
3579
  } = {}) => {
3580
+ console.log(isCapacitor, isTauri);
3581
+ return;
3597
3582
  await initializeGoogleLogin();
3598
- let authUrl = `${serviceUrl}/login?mode=mobile&app=${encodeURIComponent(
3599
- appId
3600
- )}`;
3583
+ let authUrl = `${serviceUrl}/login?mode=mobile&app=${appId}`;
3601
3584
  if (isCapacitor) {
3602
- await Browser2.open({
3603
- url: authUrl
3604
- });
3585
+ await Browser2.open({ url: authUrl });
3605
3586
  return;
3606
3587
  }
3607
3588
  if (isTauri) {
3608
- const url = `${serviceUrl}/login?mode=desktop&app=${encodeURIComponent(
3609
- appId
3610
- )}`;
3589
+ const url = `${serviceUrl}/login?mode=desktop&app=${appId}`;
3611
3590
  const win = new WebviewWindow("auth", {
3612
3591
  url,
3613
3592
  title: "Tevroc Login",
@@ -3627,11 +3606,12 @@ var createGoogleLogin = async ({
3627
3606
  }
3628
3607
  const isLocalhost = window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1";
3629
3608
  const mode = isLocalhost ? "localhost" : "netlify";
3630
- authUrl = `${serviceUrl}/login?mode=${mode}&app=${encodeURIComponent(appId)}`;
3609
+ authUrl = `${serviceUrl}/login?mode=${mode}&app=${appId}`;
3631
3610
  window.location.href = authUrl;
3632
3611
  };
3633
3612
 
3634
3613
  // src/services/useYocoPayment.js
3614
+ var paymentInitialized = false;
3635
3615
  var paymentStatusListeners = [];
3636
3616
  function emitPaymentStatus(status, err = null) {
3637
3617
  paymentStatusListeners.forEach((cb) => {
@@ -3646,100 +3626,96 @@ function subscribePaymentStatus(cb) {
3646
3626
  paymentStatusListeners.push(cb);
3647
3627
  return () => {
3648
3628
  const i = paymentStatusListeners.indexOf(cb);
3649
- if (i !== -1) {
3650
- paymentStatusListeners.splice(i, 1);
3651
- }
3629
+ if (i !== -1) paymentStatusListeners.splice(i, 1);
3652
3630
  };
3653
3631
  }
3654
3632
  var paymentWindowRef = null;
3655
- var initialized2 = false;
3656
- var tauriUnlisten2 = null;
3657
- var capacitorListener2 = null;
3658
- function addLog(...msgs) {
3633
+ var logs = [];
3634
+ var addLog = (...msgs) => {
3659
3635
  msgs.forEach((m) => {
3660
- console.log("[TEVROC PAYMENT]", m);
3636
+ const log = {
3637
+ message: m,
3638
+ time: (/* @__PURE__ */ new Date()).toISOString()
3639
+ };
3640
+ logs.push(log);
3641
+ console.log(log);
3661
3642
  });
3662
- }
3663
- async function handlePaymentCallback(url) {
3643
+ };
3644
+ var handlePaymentCallback = async (url, externalCallback = () => {
3645
+ }) => {
3664
3646
  try {
3665
3647
  addLog("PAYMENT CALLBACK:", url);
3666
- if (!url?.includes("state=")) {
3667
- return;
3668
- }
3648
+ if (!url?.includes("state=")) return;
3669
3649
  const params = new URLSearchParams(url.split("?")[1]);
3670
3650
  const state = params.get("state");
3671
3651
  addLog("PAYMENT RESULT:", state);
3672
- if (state === "success") {
3652
+ if (state == "success") {
3673
3653
  addLog("PAYMENT SUCCESS");
3674
3654
  } else {
3675
3655
  addLog("PAYMENT FAILED");
3676
3656
  }
3657
+ externalCallback(state, null);
3677
3658
  emitPaymentStatus(state, null);
3678
3659
  } catch (err) {
3679
- addLog("PAYMENT CALLBACK ERROR:", err?.message);
3660
+ addLog("PAYMENT CALLBACK ERROR:", err.message);
3661
+ externalCallback(null, err);
3680
3662
  emitPaymentStatus(null, err);
3681
3663
  }
3682
- }
3683
- async function initializePayment() {
3684
- if (initialized2) {
3685
- return;
3686
- }
3687
- initialized2 = true;
3688
- try {
3689
- if (isCapacitor) {
3690
- capacitorListener2 = await App.addListener(
3691
- "appUrlOpen",
3692
- async (event) => {
3693
- await handlePaymentCallback(event.url);
3694
- }
3664
+ };
3665
+ var initializePayment = async (externalCallback = () => {
3666
+ }) => {
3667
+ if (paymentInitialized) return;
3668
+ paymentInitialized = true;
3669
+ if (isCapacitor) {
3670
+ App.addListener("appUrlOpen", (event) => {
3671
+ handlePaymentCallback(
3672
+ event.url,
3673
+ externalCallback
3695
3674
  );
3696
- }
3697
- if (isTauri) {
3698
- const { listen: listen2 } = await Promise.resolve().then(() => (init_event(), event_exports));
3699
- tauriUnlisten2 = await listen2(
3700
- "deep-link://open-url",
3701
- async (event) => {
3702
- let url = event.payload;
3703
- if (typeof url === "object") {
3704
- url = url?.url || url?.payload || null;
3705
- }
3706
- if (!url) {
3707
- return;
3708
- }
3709
- if (paymentWindowRef) {
3710
- try {
3711
- await paymentWindowRef.close();
3712
- } catch (e) {
3713
- }
3714
- paymentWindowRef = null;
3715
- }
3716
- await handlePaymentCallback(url);
3675
+ });
3676
+ }
3677
+ if (isTauri) {
3678
+ const { listen: listen2 } = await Promise.resolve().then(() => (init_event(), event_exports));
3679
+ await listen2("deep-link://open-url", async (event) => {
3680
+ let url = event.payload;
3681
+ if (typeof url === "object") {
3682
+ url = url?.url || url?.payload || null;
3683
+ }
3684
+ if (!url) return;
3685
+ if (paymentWindowRef) {
3686
+ try {
3687
+ await paymentWindowRef.close();
3688
+ paymentWindowRef = null;
3689
+ } catch (e) {
3717
3690
  }
3691
+ }
3692
+ handlePaymentCallback(
3693
+ url,
3694
+ externalCallback
3718
3695
  );
3719
- }
3720
- addLog("Payment listeners initialized");
3721
- } catch (err) {
3722
- console.error("Payment initialization failed:", err);
3696
+ });
3723
3697
  }
3724
- }
3698
+ };
3725
3699
  var createPayment = async (amountZAR, {
3726
3700
  appId = "tevrocsoft",
3727
- serviceUrl = "https://tevrocsoftapi.netlify.app"
3701
+ serviceUrl = "https://tevrocsoftapi.netlify.app",
3702
+ externalCallback = () => {
3703
+ }
3728
3704
  } = {}) => {
3729
- await initializePayment();
3705
+ await initializePayment(externalCallback);
3730
3706
  const cents = Math.round(Number(amountZAR) * 100);
3731
3707
  const basePaymentUrl = `${serviceUrl}/pay`;
3732
- const mobileUrl = `${basePaymentUrl}?mode=mobile&amount=${encodeURIComponent(cents)}&app=${encodeURIComponent(appId)}`;
3708
+ const paymentUrl = `${basePaymentUrl}?mode=mobile&amount=${cents}&app=${appId}`;
3733
3709
  if (isCapacitor) {
3734
3710
  await Browser2.open({
3735
- url: mobileUrl
3711
+ url: paymentUrl
3736
3712
  });
3737
3713
  return;
3738
3714
  }
3739
3715
  if (isTauri) {
3740
- const desktopUrl = `${basePaymentUrl}?mode=desktop&amount=${encodeURIComponent(cents)}&app=${encodeURIComponent(appId)}`;
3716
+ const url = `${basePaymentUrl}?mode=desktop&amount=${cents}&app=${appId}`;
3741
3717
  const win = new WebviewWindow("payment", {
3742
- url: desktopUrl,
3718
+ url,
3743
3719
  title: "Complete Payment",
3744
3720
  width: 550,
3745
3721
  height: 600,
@@ -3748,7 +3724,7 @@ var createPayment = async (amountZAR, {
3748
3724
  });
3749
3725
  paymentWindowRef = win;
3750
3726
  win.once("tauri://created", () => {
3751
- addLog("Payment window opened");
3727
+ console.log("Payment window opened");
3752
3728
  });
3753
3729
  win.once("tauri://error", (e) => {
3754
3730
  console.error("Payment window error:", e);
@@ -3757,7 +3733,7 @@ var createPayment = async (amountZAR, {
3757
3733
  }
3758
3734
  const isLocalhost = window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1";
3759
3735
  const mode = isLocalhost ? "localhost" : "netlify";
3760
- window.location.href = `${basePaymentUrl}?mode=${mode}&amount=${encodeURIComponent(cents)}&app=${encodeURIComponent(appId)}`;
3736
+ window.location.href = `${basePaymentUrl}?mode=${mode}&amount=${cents}&app=${appId}`;
3761
3737
  };
3762
3738
 
3763
3739
  // src/index.js
package/tevroc-sdk.min.js CHANGED
@@ -1,4 +1,4 @@
1
- var Tevroc=(()=>{var me=Object.defineProperty;var bt=Object.getOwnPropertyDescriptor;var gt=Object.getOwnPropertyNames;var mt=Object.prototype.hasOwnProperty;var M=(t,e,n)=>()=>{if(n)throw n[0];try{return t&&(e=t(t=0)),e}catch(i){throw n=[i],i}};var se=(t,e)=>{for(var n in e)me(t,n,{get:e[n],enumerable:!0})},_t=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of gt(e))!mt.call(t,r)&&r!==n&&me(t,r,{get:()=>e[r],enumerable:!(i=bt(e,r))||i.enumerable});return t};var vt=t=>_t(me({},"__esModule",{value:!0}),t);var F,K,Pt,Ct,kt,_e,I,E,Ne,Be,ve,an,At,Lt,Et,Tt,Pe,ln,Me,Fe,Ce,un,Y=M(()=>{(function(t){t.Unimplemented="UNIMPLEMENTED",t.Unavailable="UNAVAILABLE"})(F||(F={}));K=class extends Error{constructor(e,n,i){super(e),this.message=e,this.code=n,this.data=i}},Pt=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"},Ct=t=>{let e=t.CapacitorCustomPlatform||null,n=t.Capacitor||{},i=n.Plugins=n.Plugins||{},r=()=>e!==null?e.name:Pt(t),o=()=>r()!=="web",a=l=>{let c=p.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(ne=>ne.name===l)},h=l=>t.console.error(l),p=new Map,m=(l,c={})=>{let ne=p.get(l);if(ne)return console.warn(`Capacitor plugin "${l}" already registered. Cannot register plugins twice.`),ne.proxy;let U=r(),B=u(l),L,pt=async()=>(!L&&U in c?L=typeof c[U]=="function"?L=await c[U]():L=c[U]:e!==null&&!L&&"web"in c&&(L=typeof c.web=="function"?L=await c.web():L=c.web),L),ft=(f,g)=>{var C,O;if(B){let S=B?.methods.find(P=>g===P.name);if(S)return S.rtype==="promise"?P=>n.nativePromise(l,g.toString(),P):(P,ie)=>n.nativeCallback(l,g.toString(),P,ie);if(f)return(C=f[g])===null||C===void 0?void 0:C.bind(f)}else{if(f)return(O=f[g])===null||O===void 0?void 0:O.bind(f);throw new K(`"${l}" plugin is not implemented on ${U}`,F.Unimplemented)}},be=f=>{let g,C=(...O)=>{let S=pt().then(P=>{let ie=ft(P,f);if(ie){let re=ie(...O);return g=re?.remove,re}else throw new K(`"${l}.${f}()" is not implemented on ${U}`,F.Unimplemented)});return f==="addListener"&&(S.remove=async()=>g()),S};return C.toString=()=>`${f.toString()}() { [capacitor code] }`,Object.defineProperty(C,"name",{value:f,writable:!1,configurable:!1}),C},qe=be("addListener"),ze=be("removeListener"),yt=(f,g)=>{let C=qe({eventName:f},g),O=async()=>{let P=await C;ze({eventName:f,callbackId:P},g)},S=new Promise(P=>C.then(()=>P({remove:O})));return S.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await O()},S},ge=new Proxy({},{get(f,g){switch(g){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return B?yt:qe;case"removeListener":return ze;default:return be(g)}}});return i[l]=ge,p.set(l,{name:l,proxy:ge,platforms:new Set([...Object.keys(c),...B?[U]:[]])}),ge};return n.convertFileSrc||(n.convertFileSrc=l=>l),n.getPlatform=r,n.handleError=h,n.isNativePlatform=o,n.isPluginAvailable=a,n.registerPlugin=m,n.Exception=K,n.DEBUG=!!n.DEBUG,n.isLoggingEnabled=!!n.isLoggingEnabled,n},kt=t=>t.Capacitor=Ct(t),_e=kt(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),I=_e.registerPlugin,E=class{constructor(){this.listeners={},this.retainedEventArguments={},this.windowListeners={}}addListener(e,n){let i=!1;this.listeners[e]||(this.listeners[e]=[],i=!0),this.listeners[e].push(n);let o=this.windowListeners[e];o&&!o.registered&&this.addWindowListener(o),i&&this.sendRetainedArgumentsForEvent(e);let a=async()=>this.removeListener(e,n);return Promise.resolve({remove:a})}async removeAllListeners(){this.listeners={};for(let e in this.windowListeners)this.removeWindowListener(this.windowListeners[e]);this.windowListeners={}}notifyListeners(e,n,i){let r=this.listeners[e];if(!r){if(i){let o=this.retainedEventArguments[e];o||(o=[]),o.push(n),this.retainedEventArguments[e]=o}return}r.forEach(o=>o(n))}hasListeners(e){var n;return!!(!((n=this.listeners[e])===null||n===void 0)&&n.length)}registerWindowListener(e,n){this.windowListeners[n]={registered:!1,windowEventName:e,pluginEventName:n,handler:i=>{this.notifyListeners(n,i)}}}unimplemented(e="not implemented"){return new _e.Exception(e,F.Unimplemented)}unavailable(e="not available"){return new _e.Exception(e,F.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)}))}},Ne=t=>encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),Be=t=>t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent),ve=class extends E{async getCookies(){let e=document.cookie,n={};return e.split(";").forEach(i=>{if(i.length<=0)return;let[r,o]=i.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");r=Be(r).trim(),o=Be(o).trim(),n[r]=o}),n}async setCookie(e){try{let n=Ne(e.key),i=Ne(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)}}},an=I("CapacitorCookies",{web:()=>new ve}),At=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)}),Lt=(t={})=>{let e=Object.keys(t);return Object.keys(t).map(r=>r.toLocaleLowerCase()).reduce((r,o,a)=>(r[o]=t[e[a]],r),{})},Et=(t,e=!0)=>t?Object.entries(t).reduce((i,r)=>{let[o,a]=r,u,h;return Array.isArray(a)?(h="",a.forEach(p=>{u=e?encodeURIComponent(p):p,h+=`${o}=${u}&`}),h.slice(0,-1)):(u=e?encodeURIComponent(a):a,h=`${o}=${u}`),`${i}&${h}`},"").substr(1):null,Tt=(t,e={})=>{let n=Object.assign({method:t.method||"GET",headers:t.headers},e),r=Lt(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,h)=>{o.append(h,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},Pe=class extends E{async request(e){let n=Tt(e,e.webFetchExtra),i=Et(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 h,p;switch(u){case"arraybuffer":case"blob":p=await o.blob(),h=await At(p);break;case"json":h=await o.json();break;default:h=await o.text()}let m={};return o.headers.forEach((l,c)=>{m[c]=l}),{data:h,headers:m,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"}))}},ln=I("CapacitorHttp",{web:()=>new Pe});(function(t){t.Dark="DARK",t.Light="LIGHT",t.Default="DEFAULT"})(Me||(Me={}));(function(t){t.StatusBar="StatusBar",t.NavigationBar="NavigationBar"})(Fe||(Fe={}));Ce=class extends E{async setStyle(){this.unavailable("not available for web")}async setAnimation(){this.unavailable("not available for web")}async show(){this.unavailable("not available for web")}async hide(){this.unavailable("not available for web")}},un=I("SystemBars",{web:()=>new Ce})});var je={};se(je,{AppWeb:()=>ke});var ke,Ge=M(()=>{Y();ke=class extends E{constructor(){super(),this.handleVisibilityChange=()=>{let e={isActive:document.hidden!==!0};this.notifyListeners("appStateChange",e),document.hidden?this.notifyListeners("pause",null):this.notifyListeners("resume",null)},document.addEventListener("visibilitychange",this.handleVisibilityChange,!1)}exitApp(){throw this.unimplemented("Not implemented on web.")}async getInfo(){throw this.unimplemented("Not implemented on web.")}async getLaunchUrl(){return{url:""}}async getState(){return{isActive:document.hidden!==!0}}async minimizeApp(){throw this.unimplemented("Not implemented on web.")}async toggleBackButtonHandler(){throw this.unimplemented("Not implemented on web.")}async getAppLanguage(){return{value:navigator.language.split("-")[0].toLowerCase()}}}});var He={};se(He,{Browser:()=>Ot,BrowserWeb:()=>ae});var ae,Ot,Ve=M(()=>{Y();ae=class extends E{constructor(){super(),this._lastWindow=null}async open(e){this._lastWindow=window.open(e.url,e.windowName||"_blank")}async close(){return new Promise((e,n)=>{this._lastWindow!=null?(this._lastWindow.close(),this._lastWindow=null,e()):n("No active window to close!")})}},Ot=new ae});function w(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 D(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 Je=M(()=>{});function Ae(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 $,_,j,ue,ce,b,Ke,de,W=M(()=>{Je();b="__TAURI_TO_IPC_KEY__";Ke=class{constructor(e){$.set(this,void 0),_.set(this,0),j.set(this,[]),ue.set(this,void 0),D(this,$,e||(()=>{}),"f"),this.id=Ae(n=>{let i=n.index;if("end"in n){i==w(this,_,"f")?this.cleanupCallback():D(this,ue,i,"f");return}let r=n.message;if(i==w(this,_,"f")){for(w(this,$,"f").call(this,r),D(this,_,w(this,_,"f")+1,"f");w(this,_,"f")in w(this,j,"f");){let o=w(this,j,"f")[w(this,_,"f")];w(this,$,"f").call(this,o),delete w(this,j,"f")[w(this,_,"f")],D(this,_,w(this,_,"f")+1,"f")}w(this,_,"f")===w(this,ue,"f")&&this.cleanupCallback()}else w(this,j,"f")[i]=r})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(e){D(this,$,e,"f")}get onmessage(){return w(this,$,"f")}[($=new WeakMap,_=new WeakMap,j=new WeakMap,ue=new WeakMap,b)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[b]()}};de=class{get rid(){return w(this,ce,"f")}constructor(e){ce.set(this,void 0),D(this,ce,e,"f")}async close(){return s("plugin:resources|close",{rid:this.rid})}};ce=new WeakMap});var Le={};se(Le,{TauriEvent:()=>d,emit:()=>X,emitTo:()=>ee,listen:()=>R,once:()=>q});async function Ye(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:Ae(e)}).then(o=>async()=>Ye(t,o))}async function q(t,e,n){return R(t,i=>{Ye(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 d,G=M(()=>{W();(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"})(d||(d={}))});var sn={};se(sn,{TevrocClient:()=>ye,TevrocError:()=>N,createClient:()=>Nt});Y();var oe=I("App",{web:()=>Promise.resolve().then(()=>(Ge(),je)).then(t=>new t.AppWeb)});Y();var le=I("Browser",{web:()=>Promise.resolve().then(()=>(Ve(),He)).then(t=>new t.BrowserWeb)});W();var 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 k(this.width*e,this.height*e)}[b](){return{width:this.width,height:this.height}}toJSON(){return this[b]()}},k=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)}[b](){return{width:this.width,height:this.height}}toJSON(){return this[b]()}},v=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 k?this.size:this.size.toPhysical(e)}[b](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[b]()}},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 y(this.x*e,this.y*e)}[b](){return{x:this.x,y:this.y}}toJSON(){return this[b]()}},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 Q(this.x/e,this.y/e)}[b](){return{x:this.x,y:this.y}}toJSON(){return this[b]()}},A=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 y?this.position:this.position.toPhysical(e)}[b](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[b]()}};G();W();G();W();W();var Ee=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 te(t){return t==null?null:typeof t=="string"?t:t instanceof Ee?t.rid:t}var Se;(function(t){t[t.Critical=1]="Critical",t[t.Informational=2]="Informational"})(Se||(Se={}));var Re=class{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}},Ze;(function(t){t.None="none",t.Normal="normal",t.Indeterminate="indeterminate",t.Paused="paused",t.Error="error"})(Ze||(Ze={}));function xe(){return new x(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function Te(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new x(e,{skip:!0})))}var Oe=["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 Te()).find(i=>i.label===e))!==null&&n!==void 0?n:null}static getCurrent(){return xe()}static async getAll(){return Te()}static async getFocusedWindow(){for(let e of await Te())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)}:q(e,n,{target:{kind:"Window",label:this.label}})}async emit(e,n){if(Oe.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(Oe.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 Oe.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 k(e))}async outerSize(){return s("plugin:window|outer_size",{label:this.label}).then(e=>new k(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===Se.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 v?e:new v(e)})}async setMinSize(e){return s("plugin:window|set_min_size",{label:this.label,value:e instanceof v?e:e?new v(e):null})}async setMaxSize(e){return s("plugin:window|set_max_size",{label:this.label,value:e instanceof v?e:e?new v(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: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 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?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(d.WINDOW_RESIZED,n=>{n.payload=new k(n.payload),e(n)})}async onMoved(e){return this.listen(d.WINDOW_MOVED,n=>{n.payload=new y(n.payload),e(n)})}async onCloseRequested(e){return this.listen(d.WINDOW_CLOSE_REQUESTED,async n=>{let i=new Re(n);await e(i),i.isPreventDefault()||await this.destroy()})}async onDragDropEvent(e){let n=await this.listen(d.DRAG_ENTER,a=>{e({...a,payload:{type:"enter",paths:a.payload.paths,position:new y(a.payload.position)}})}),i=await this.listen(d.DRAG_OVER,a=>{e({...a,payload:{type:"over",position:new y(a.payload.position)}})}),r=await this.listen(d.DRAG_DROP,a=>{e({...a,payload:{type:"drop",paths:a.payload.paths,position:new y(a.payload.position)}})}),o=await this.listen(d.DRAG_LEAVE,a=>{e({...a,payload:{type:"leave"}})});return()=>{n(),r(),i(),o()}}async onFocusChanged(e){let n=await this.listen(d.WINDOW_FOCUS,r=>{e({...r,payload:!0})}),i=await this.listen(d.WINDOW_BLUR,r=>{e({...r,payload:!1})});return()=>{n(),i()}}async onScaleChanged(e){return this.listen(d.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(d.WINDOW_THEME_CHANGED,e)}},Qe;(function(t){t.Disabled="disabled",t.Throttle="throttle",t.Suspend="suspend"})(Qe||(Qe={}));var Xe;(function(t){t.Default="default",t.FluentOverlay="fluentOverlay"})(Xe||(Xe={}));var et;(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"})(et||(et={}));var tt;(function(t){t.FollowsWindowActiveState="followsWindowActiveState",t.Active="active",t.Inactive="inactive"})(tt||(tt={}));function Ie(){return new H(xe(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function nt(){return s("plugin:webview|get_all_webviews").then(t=>t.map(e=>new H(new x(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}var Ue=["tauri://created","tauri://error"],H=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 nt()).find(i=>i.label===e))!==null&&n!==void 0?n:null}static getCurrent(){return Ie()}static async getAll(){return nt()}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)}:q(e,n,{target:{kind:"Webview",label:this.label}})}async emit(e,n){if(Ue.includes(e)){for(let i of this.listeners[e]||[])i({event:e,id:-1,payload:n});return}return X(e,n)}async emitTo(e,n,i){if(Ue.includes(n)){for(let r of this.listeners[n]||[])r({event:n,id:-1,payload:i});return}return ee(e,n,i)}_handleTauriEvent(e,n){return Ue.includes(e)?(e in this.listeners?this.listeners[e].push(n):this.listeners[e]=[n],!0):!1}async 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 k(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 v?e:new v(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(d.DRAG_ENTER,a=>{e({...a,payload:{type:"enter",paths:a.payload.paths,position:new y(a.payload.position)}})}),i=await this.listen(d.DRAG_OVER,a=>{e({...a,payload:{type:"over",position:new y(a.payload.position)}})}),r=await this.listen(d.DRAG_DROP,a=>{e({...a,payload:{type:"drop",paths:a.payload.paths,position:new y(a.payload.position)}})}),o=await this.listen(d.DRAG_LEAVE,a=>{e({...a,payload:{type:"leave"}})});return()=>{n(),r(),i(),o()}}};G();W();function St(){let t=Ie();return new T(t.label,{skip:!0})}async function it(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new T(e,{skip:!0})))}var T=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 it()).find(r=>r.label===e))!==null&&n!==void 0?n:null;return i?new t(i.label,{skip:!0}):null}static getCurrent(){return St()}static async getAll(){return it()}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)}:q(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}))}};Rt(T,[x,H]);function Rt(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 xt=()=>{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"},De=xt(),V=De==="android"||De==="ios",J=De==="tauri";var he=[];function rt(t,e=null){he.forEach(n=>{try{n(t,e)}catch(i){console.error("Google listener error:",i)}})}function $e(t){return he.push(t),()=>{let e=he.indexOf(t);e!==-1&&he.splice(e,1)}}var we=null,st=!1,Ut=null,It=null,ot=async t=>{try{if(!t?.includes("token="))return;let n=new URLSearchParams(t.split("?")[1]).get("token");if(!n)return;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};localStorage.setItem("user",JSON.stringify(o)),localStorage.setItem("idToken",n),rt(o,null)}catch(e){console.error(e),rt(null,e)}};async function Dt(){if(!st){st=!0;try{if(V&&(It=await oe.addListener("appUrlOpen",async t=>{await ot(t.url)})),J){let{listen:t}=await Promise.resolve().then(()=>(G(),Le));Ut=await t("deep-link://open-url",async e=>{let n=e.payload;if(typeof n=="object"&&(n=n?.url||n?.payload||null),!!n){if(we){try{await we.close()}catch{}we=null}await ot(n)}})}console.log("Google login initialized")}catch(t){console.error("Google login init failed:",t)}}}var We=async({appId:t="tevrocsoft",serviceUrl:e="https://tevrocsoftapi.netlify.app"}={})=>{await Dt();let n=`${e}/login?mode=mobile&app=${encodeURIComponent(t)}`;if(V){await le.open({url:n});return}if(J){let o=`${e}/login?mode=desktop&app=${encodeURIComponent(t)}`,a=new T("auth",{url:o,title:"Tevroc Login",width:550,height:500,resizable:!0,center:!0});we=a,a.once("tauri://created",()=>{console.log("Auth window opened")}),a.once("tauri://error",u=>{console.error("Auth window error:",u)});return}let r=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"?"localhost":"netlify";n=`${e}/login?mode=${r}&app=${encodeURIComponent(t)}`,window.location.href=n};var pe=[];function at(t,e=null){pe.forEach(n=>{try{n(t,e)}catch(i){console.error("Payment listener error:",i)}})}function ct(t){return pe.push(t),()=>{let e=pe.indexOf(t);e!==-1&&pe.splice(e,1)}}var fe=null,lt=!1,$t=null,Wt=null;function z(...t){t.forEach(e=>{console.log("[TEVROC PAYMENT]",e)})}async function ut(t){try{if(z("PAYMENT CALLBACK:",t),!t?.includes("state="))return;let n=new URLSearchParams(t.split("?")[1]).get("state");z("PAYMENT RESULT:",n),z(n==="success"?"PAYMENT SUCCESS":"PAYMENT FAILED"),at(n,null)}catch(e){z("PAYMENT CALLBACK ERROR:",e?.message),at(null,e)}}async function qt(){if(!lt){lt=!0;try{if(V&&(Wt=await oe.addListener("appUrlOpen",async t=>{await ut(t.url)})),J){let{listen:t}=await Promise.resolve().then(()=>(G(),Le));$t=await t("deep-link://open-url",async e=>{let n=e.payload;if(typeof n=="object"&&(n=n?.url||n?.payload||null),!!n){if(fe){try{await fe.close()}catch{}fe=null}await ut(n)}})}z("Payment listeners initialized")}catch(t){console.error("Payment initialization failed:",t)}}}var dt=async(t,{appId:e="tevrocsoft",serviceUrl:n="https://tevrocsoftapi.netlify.app"}={})=>{await qt();let i=Math.round(Number(t)*100),r=`${n}/pay`,o=`${r}?mode=mobile&amount=${encodeURIComponent(i)}&app=${encodeURIComponent(e)}`;if(V){await le.open({url:o});return}if(J){let h=`${r}?mode=desktop&amount=${encodeURIComponent(i)}&app=${encodeURIComponent(e)}`,p=new T("payment",{url:h,title:"Complete Payment",width:550,height:600,resizable:!0,center:!0});fe=p,p.once("tauri://created",()=>{z("Payment window opened")}),p.once("tauri://error",m=>{console.error("Payment window error:",m)});return}let u=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"?"localhost":"netlify";window.location.href=`${r}?mode=${u}&amount=${encodeURIComponent(i)}&app=${encodeURIComponent(e)}`};var zt=3e4,N=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 Nt(t={}){return new ye(t)}var ye=class{constructor(e={}){let n=e.baseUrl??e.url,i=e.serviceUrl??e.url;if(!n)throw new TypeError("createClient requires a baseUrl");if(this.baseUrl=wt(n),this.serviceUrl=wt(i),this.fetch=(e.fetch??globalThis.fetch).bind(globalThis),typeof this.fetch!="function")throw new TypeError("No fetch implementation available");this.timeoutMs=e.timeoutMs??zt,this.defaultHeaders=nn(e.headers),this.token=e.token??null,this.auth=Mt(this),this.entities=Ft(this),this.functions=Gt(this),this.integrations=Ht(this),this.agents=Vt(this),this.logs=Kt(this),this.connectors=Yt(this),this.customIntegrations=Zt(this),this.sso=Qt(this),this.files=Xt(this),this.payments=Bt(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?tn(n.query):"",a=`${this.baseUrl}${e.startsWith("/")?e:`/${e}`}${o}`,u=new AbortController,h=setTimeout(()=>u.abort(),n.timeoutMs??this.timeoutMs),p=this.token||localStorage.getItem("tevroc_access_token");p&&n.auth!==!1&&r.set("authorization",`Bearer ${p}`),console.log(p);let m=n.body;if(m!=null&&rn(m)&&(r.set("content-type","application/json"),m=JSON.stringify(m)),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:m,signal:n.signal??u.signal});return await en(l,n.parseAs)}catch(l){throw l?.name==="AbortError"?new N("Request timed out",{code:"timeout"}):l instanceof N?l:new N(l?.message??"Network request failed",{code:"network_error",details:l})}finally{clearTimeout(h)}}};function Bt(t){return{create:async({amountZAR:e,appId:n="tevrocsoft",mode:i="web"})=>await dt(e,{appId:n,serviceUrl:t.serviceUrl,mode:i}),onstatus:e=>{if(typeof e!="function")throw new Error("onstatus requires a function");return ct(e)}}}function Mt(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:(e,n)=>{e==="google"&&(We({serviceUrl:t.serviceUrl,redirectTo:n}),n&&$e(async(i,r)=>{let o=await t.request("/provider/google/auth/login",{method:"POST",body:{user:i},auth:!1});window.location.href=n}))},googleLogin:e=>We(e),onGoogleLogin:e=>$e(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 Ft(t){return new Proxy({},{get(e,n){if(typeof n=="string")return jt(t,n)}})}function jt(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 Gt(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 Ht(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={})=>ht(t,"/integrations/core/upload-file",e,n),UploadPrivateFile:(e,n={})=>ht(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 Vt(t){return new Proxy({},{get(e,n){if(typeof n=="string")return Jt(t,n)}})}function Jt(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 Kt(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 Yt(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 Zt(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 Qt(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 Xt(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 ht(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 en(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 N(o.message??t.statusText,{status:t.status,code:o.code??"api_error",details:o.details??r,response:t})}return r}function tn(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 wt(t){return String(t).replace(/\/+$/,"")}function nn(t={}){return Object.fromEntries(new Headers(t).entries())}function rn(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 vt(sn);})();
1
+ var Tevroc=(()=>{var me=Object.defineProperty;var gt=Object.getOwnPropertyDescriptor;var yt=Object.getOwnPropertyNames;var mt=Object.prototype.hasOwnProperty;var F=(t,e,n)=>()=>{if(n)throw n[0];try{return t&&(e=t(t=0)),e}catch(i){throw n=[i],i}};var se=(t,e)=>{for(var n in e)me(t,n,{get:e[n],enumerable:!0})},_t=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of yt(e))!mt.call(t,r)&&r!==n&&me(t,r,{get:()=>e[r],enumerable:!(i=gt(e,r))||i.enumerable});return t};var vt=t=>_t(me({},"__esModule",{value:!0}),t);var j,J,Pt,kt,At,_e,U,E,Ne,Be,ve,rn,Ct,Lt,Et,Ot,Pe,sn,Me,Fe,ke,on,K=F(()=>{(function(t){t.Unimplemented="UNIMPLEMENTED",t.Unavailable="UNAVAILABLE"})(j||(j={}));J=class extends Error{constructor(e,n,i){super(e),this.message=e,this.code=n,this.data=i}},Pt=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"},kt=t=>{let e=t.CapacitorCustomPlatform||null,n=t.Capacitor||{},i=n.Plugins=n.Plugins||{},r=()=>e!==null?e.name:Pt(t),o=()=>r()!=="web",a=l=>{let c=b.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(ne=>ne.name===l)},h=l=>t.console.error(l),b=new Map,g=(l,c={})=>{let ne=b.get(l);if(ne)return console.warn(`Capacitor plugin "${l}" already registered. Cannot register plugins twice.`),ne.proxy;let I=r(),M=u(l),L,pt=async()=>(!L&&I in c?L=typeof c[I]=="function"?L=await c[I]():L=c[I]:e!==null&&!L&&"web"in c&&(L=typeof c.web=="function"?L=await c.web():L=c.web),L),ft=(p,m)=>{var k,T;if(M){let S=M?.methods.find(P=>m===P.name);if(S)return S.rtype==="promise"?P=>n.nativePromise(l,m.toString(),P):(P,ie)=>n.nativeCallback(l,m.toString(),P,ie);if(p)return(k=p[m])===null||k===void 0?void 0:k.bind(p)}else{if(p)return(T=p[m])===null||T===void 0?void 0:T.bind(p);throw new J(`"${l}" plugin is not implemented on ${I}`,j.Unimplemented)}},ge=p=>{let m,k=(...T)=>{let S=pt().then(P=>{let ie=ft(P,p);if(ie){let re=ie(...T);return m=re?.remove,re}else throw new J(`"${l}.${p}()" is not implemented on ${I}`,j.Unimplemented)});return p==="addListener"&&(S.remove=async()=>m()),S};return k.toString=()=>`${p.toString()}() { [capacitor code] }`,Object.defineProperty(k,"name",{value:p,writable:!1,configurable:!1}),k},qe=ge("addListener"),ze=ge("removeListener"),bt=(p,m)=>{let k=qe({eventName:p},m),T=async()=>{let P=await k;ze({eventName:p,callbackId:P},m)},S=new Promise(P=>k.then(()=>P({remove:T})));return S.remove=async()=>{console.warn("Using addListener() without 'await' is deprecated."),await T()},S},ye=new Proxy({},{get(p,m){switch(m){case"$$typeof":return;case"toJSON":return()=>({});case"addListener":return M?bt:qe;case"removeListener":return ze;default:return ge(m)}}});return i[l]=ye,b.set(l,{name:l,proxy:ye,platforms:new Set([...Object.keys(c),...M?[I]:[]])}),ye};return n.convertFileSrc||(n.convertFileSrc=l=>l),n.getPlatform=r,n.handleError=h,n.isNativePlatform=o,n.isPluginAvailable=a,n.registerPlugin=g,n.Exception=J,n.DEBUG=!!n.DEBUG,n.isLoggingEnabled=!!n.isLoggingEnabled,n},At=t=>t.Capacitor=kt(t),_e=At(typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}),U=_e.registerPlugin,E=class{constructor(){this.listeners={},this.retainedEventArguments={},this.windowListeners={}}addListener(e,n){let i=!1;this.listeners[e]||(this.listeners[e]=[],i=!0),this.listeners[e].push(n);let o=this.windowListeners[e];o&&!o.registered&&this.addWindowListener(o),i&&this.sendRetainedArgumentsForEvent(e);let a=async()=>this.removeListener(e,n);return Promise.resolve({remove:a})}async removeAllListeners(){this.listeners={};for(let e in this.windowListeners)this.removeWindowListener(this.windowListeners[e]);this.windowListeners={}}notifyListeners(e,n,i){let r=this.listeners[e];if(!r){if(i){let o=this.retainedEventArguments[e];o||(o=[]),o.push(n),this.retainedEventArguments[e]=o}return}r.forEach(o=>o(n))}hasListeners(e){var n;return!!(!((n=this.listeners[e])===null||n===void 0)&&n.length)}registerWindowListener(e,n){this.windowListeners[n]={registered:!1,windowEventName:e,pluginEventName:n,handler:i=>{this.notifyListeners(n,i)}}}unimplemented(e="not implemented"){return new _e.Exception(e,j.Unimplemented)}unavailable(e="not available"){return new _e.Exception(e,j.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)}))}},Ne=t=>encodeURIComponent(t).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape),Be=t=>t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent),ve=class extends E{async getCookies(){let e=document.cookie,n={};return e.split(";").forEach(i=>{if(i.length<=0)return;let[r,o]=i.replace(/=/,"CAP_COOKIE").split("CAP_COOKIE");r=Be(r).trim(),o=Be(o).trim(),n[r]=o}),n}async setCookie(e){try{let n=Ne(e.key),i=Ne(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)}}},rn=U("CapacitorCookies",{web:()=>new ve}),Ct=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)}),Lt=(t={})=>{let e=Object.keys(t);return Object.keys(t).map(r=>r.toLocaleLowerCase()).reduce((r,o,a)=>(r[o]=t[e[a]],r),{})},Et=(t,e=!0)=>t?Object.entries(t).reduce((i,r)=>{let[o,a]=r,u,h;return Array.isArray(a)?(h="",a.forEach(b=>{u=e?encodeURIComponent(b):b,h+=`${o}=${u}&`}),h.slice(0,-1)):(u=e?encodeURIComponent(a):a,h=`${o}=${u}`),`${i}&${h}`},"").substr(1):null,Ot=(t,e={})=>{let n=Object.assign({method:t.method||"GET",headers:t.headers},e),r=Lt(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,h)=>{o.append(h,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},Pe=class extends E{async request(e){let n=Ot(e,e.webFetchExtra),i=Et(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 h,b;switch(u){case"arraybuffer":case"blob":b=await o.blob(),h=await Ct(b);break;case"json":h=await o.json();break;default:h=await o.text()}let g={};return o.headers.forEach((l,c)=>{g[c]=l}),{data:h,headers:g,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"}))}},sn=U("CapacitorHttp",{web:()=>new Pe});(function(t){t.Dark="DARK",t.Light="LIGHT",t.Default="DEFAULT"})(Me||(Me={}));(function(t){t.StatusBar="StatusBar",t.NavigationBar="NavigationBar"})(Fe||(Fe={}));ke=class extends E{async setStyle(){this.unavailable("not available for web")}async setAnimation(){this.unavailable("not available for web")}async show(){this.unavailable("not available for web")}async hide(){this.unavailable("not available for web")}},on=U("SystemBars",{web:()=>new ke})});var je={};se(je,{AppWeb:()=>Ae});var Ae,Ge=F(()=>{K();Ae=class extends E{constructor(){super(),this.handleVisibilityChange=()=>{let e={isActive:document.hidden!==!0};this.notifyListeners("appStateChange",e),document.hidden?this.notifyListeners("pause",null):this.notifyListeners("resume",null)},document.addEventListener("visibilitychange",this.handleVisibilityChange,!1)}exitApp(){throw this.unimplemented("Not implemented on web.")}async getInfo(){throw this.unimplemented("Not implemented on web.")}async getLaunchUrl(){return{url:""}}async getState(){return{isActive:document.hidden!==!0}}async minimizeApp(){throw this.unimplemented("Not implemented on web.")}async toggleBackButtonHandler(){throw this.unimplemented("Not implemented on web.")}async getAppLanguage(){return{value:navigator.language.split("-")[0].toLowerCase()}}}});var He={};se(He,{Browser:()=>Tt,BrowserWeb:()=>ae});var ae,Tt,Ve=F(()=>{K();ae=class extends E{constructor(){super(),this._lastWindow=null}async open(e){this._lastWindow=window.open(e.url,e.windowName||"_blank")}async close(){return new Promise((e,n)=>{this._lastWindow!=null?(this._lastWindow.close(),this._lastWindow=null,e()):n("No active window to close!")})}},Tt=new ae});function w(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 D(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 Je=F(()=>{});function Ce(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 $,_,G,ue,ce,y,Ke,de,W=F(()=>{Je();y="__TAURI_TO_IPC_KEY__";Ke=class{constructor(e){$.set(this,void 0),_.set(this,0),G.set(this,[]),ue.set(this,void 0),D(this,$,e||(()=>{}),"f"),this.id=Ce(n=>{let i=n.index;if("end"in n){i==w(this,_,"f")?this.cleanupCallback():D(this,ue,i,"f");return}let r=n.message;if(i==w(this,_,"f")){for(w(this,$,"f").call(this,r),D(this,_,w(this,_,"f")+1,"f");w(this,_,"f")in w(this,G,"f");){let o=w(this,G,"f")[w(this,_,"f")];w(this,$,"f").call(this,o),delete w(this,G,"f")[w(this,_,"f")],D(this,_,w(this,_,"f")+1,"f")}w(this,_,"f")===w(this,ue,"f")&&this.cleanupCallback()}else w(this,G,"f")[i]=r})}cleanupCallback(){window.__TAURI_INTERNALS__.unregisterCallback(this.id)}set onmessage(e){D(this,$,e,"f")}get onmessage(){return w(this,$,"f")}[($=new WeakMap,_=new WeakMap,G=new WeakMap,ue=new WeakMap,y)](){return`__CHANNEL__:${this.id}`}toJSON(){return this[y]()}};de=class{get rid(){return w(this,ce,"f")}constructor(e){ce.set(this,void 0),D(this,ce,e,"f")}async close(){return s("plugin:resources|close",{rid:this.rid})}};ce=new WeakMap});var Le={};se(Le,{TauriEvent:()=>d,emit:()=>Q,emitTo:()=>X,listen:()=>x,once:()=>q});async function Ye(t,e){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(t,e),await s("plugin:event|unlisten",{event:t,eventId:e})}async function x(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:Ce(e)}).then(o=>async()=>Ye(t,o))}async function q(t,e,n){return x(t,i=>{Ye(t,i.id),e(i)},n)}async function Q(t,e){await s("plugin:event|emit",{event:t,payload:e})}async function X(t,e,n){await s("plugin:event|emit_to",{target:typeof t=="string"?{kind:"AnyLabel",label:t}:t,event:e,payload:n})}var d,H=F(()=>{W();(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"})(d||(d={}))});var tn={};se(tn,{TevrocClient:()=>be,TevrocError:()=>B,createClient:()=>Wt});K();var oe=U("App",{web:()=>Promise.resolve().then(()=>(Ge(),je)).then(t=>new t.AppWeb)});K();var le=U("Browser",{web:()=>Promise.resolve().then(()=>(Ve(),He)).then(t=>new t.BrowserWeb)});W();var Y=class{constructor(...e){this.type="Logical",e.length===1?"Logical"in e[0]?(this.width=e[0].Logical.width,this.height=e[0].Logical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toPhysical(e){return new A(this.width*e,this.height*e)}[y](){return{width:this.width,height:this.height}}toJSON(){return this[y]()}},A=class{constructor(...e){this.type="Physical",e.length===1?"Physical"in e[0]?(this.width=e[0].Physical.width,this.height=e[0].Physical.height):(this.width=e[0].width,this.height=e[0].height):(this.width=e[0],this.height=e[1])}toLogical(e){return new Y(this.width/e,this.height/e)}[y](){return{width:this.width,height:this.height}}toJSON(){return this[y]()}},v=class{constructor(e){this.size=e}toLogical(e){return this.size instanceof Y?this.size:this.size.toLogical(e)}toPhysical(e){return this.size instanceof A?this.size:this.size.toPhysical(e)}[y](){return{[`${this.size.type}`]:{width:this.size.width,height:this.size.height}}}toJSON(){return this[y]()}},Z=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 f(this.x*e,this.y*e)}[y](){return{x:this.x,y:this.y}}toJSON(){return this[y]()}},f=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 Z(this.x/e,this.y/e)}[y](){return{x:this.x,y:this.y}}toJSON(){return this[y]()}},C=class{constructor(e){this.position=e}toLogical(e){return this.position instanceof Z?this.position:this.position.toLogical(e)}toPhysical(e){return this.position instanceof f?this.position:this.position.toPhysical(e)}[y](){return{[`${this.position.type}`]:{x:this.position.x,y:this.position.y}}}toJSON(){return this[y]()}};H();W();H();W();W();var Ee=class t extends de{constructor(e){super(e)}static async new(e,n,i){return s("plugin:image|new",{rgba:ee(e),width:n,height:i}).then(r=>new t(r))}static async fromBytes(e){return s("plugin:image|from_bytes",{bytes:ee(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 ee(t){return t==null?null:typeof t=="string"?t:t instanceof Ee?t.rid:t}var Se;(function(t){t[t.Critical=1]="Critical",t[t.Informational=2]="Informational"})(Se||(Se={}));var xe=class{constructor(e){this._preventDefault=!1,this.event=e.event,this.id=e.id}preventDefault(){this._preventDefault=!0}isPreventDefault(){return this._preventDefault}},Ze;(function(t){t.None="none",t.Normal="normal",t.Indeterminate="indeterminate",t.Paused="paused",t.Error="error"})(Ze||(Ze={}));function Re(){return new R(window.__TAURI_INTERNALS__.metadata.currentWindow.label,{skip:!0})}async function Oe(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new R(e,{skip:!0})))}var Te=["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 Oe()).find(i=>i.label===e))!==null&&n!==void 0?n:null}static getCurrent(){return Re()}static async getAll(){return Oe()}static async getFocusedWindow(){for(let e of await Oe())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)}:x(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)}:q(e,n,{target:{kind:"Window",label:this.label}})}async emit(e,n){if(Te.includes(e)){for(let i of this.listeners[e]||[])i({event:e,id:-1,payload:n});return}return Q(e,n)}async emitTo(e,n,i){if(Te.includes(n)){for(let r of this.listeners[n]||[])r({event:n,id:-1,payload:i});return}return X(e,n,i)}_handleTauriEvent(e,n){return Te.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 f(e))}async outerPosition(){return s("plugin:window|outer_position",{label:this.label}).then(e=>new f(e))}async innerSize(){return s("plugin:window|inner_size",{label:this.label}).then(e=>new A(e))}async outerSize(){return s("plugin:window|outer_size",{label:this.label}).then(e=>new A(e))}async isFullscreen(){return s("plugin:window|is_fullscreen",{label:this.label})}async isMinimized(){return s("plugin:window|is_minimized",{label:this.label})}async isMaximized(){return s("plugin:window|is_maximized",{label:this.label})}async isFocused(){return s("plugin:window|is_focused",{label:this.label})}async isDecorated(){return s("plugin:window|is_decorated",{label:this.label})}async isResizable(){return s("plugin:window|is_resizable",{label:this.label})}async isMaximizable(){return s("plugin:window|is_maximizable",{label:this.label})}async isMinimizable(){return s("plugin:window|is_minimizable",{label:this.label})}async isClosable(){return s("plugin:window|is_closable",{label:this.label})}async isVisible(){return s("plugin:window|is_visible",{label:this.label})}async title(){return s("plugin:window|title",{label:this.label})}async theme(){return s("plugin:window|theme",{label:this.label})}async isAlwaysOnTop(){return s("plugin:window|is_always_on_top",{label:this.label})}async activityName(){return s("plugin:window|activity_name",{label:this.label})}async sceneIdentifier(){return s("plugin:window|scene_identifier",{label:this.label})}async center(){return s("plugin:window|center",{label:this.label})}async requestUserAttention(e){let n=null;return e&&(e===Se.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 v?e:new v(e)})}async setMinSize(e){return s("plugin:window|set_min_size",{label:this.label,value:e instanceof v?e:e?new v(e):null})}async setMaxSize(e){return s("plugin:window|set_max_size",{label:this.label,value:e instanceof v?e:e?new v(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:ee(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?ee(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(d.WINDOW_RESIZED,n=>{n.payload=new A(n.payload),e(n)})}async onMoved(e){return this.listen(d.WINDOW_MOVED,n=>{n.payload=new f(n.payload),e(n)})}async onCloseRequested(e){return this.listen(d.WINDOW_CLOSE_REQUESTED,async n=>{let i=new xe(n);await e(i),i.isPreventDefault()||await this.destroy()})}async onDragDropEvent(e){let n=await this.listen(d.DRAG_ENTER,a=>{e({...a,payload:{type:"enter",paths:a.payload.paths,position:new f(a.payload.position)}})}),i=await this.listen(d.DRAG_OVER,a=>{e({...a,payload:{type:"over",position:new f(a.payload.position)}})}),r=await this.listen(d.DRAG_DROP,a=>{e({...a,payload:{type:"drop",paths:a.payload.paths,position:new f(a.payload.position)}})}),o=await this.listen(d.DRAG_LEAVE,a=>{e({...a,payload:{type:"leave"}})});return()=>{n(),r(),i(),o()}}async onFocusChanged(e){let n=await this.listen(d.WINDOW_FOCUS,r=>{e({...r,payload:!0})}),i=await this.listen(d.WINDOW_BLUR,r=>{e({...r,payload:!1})});return()=>{n(),i()}}async onScaleChanged(e){return this.listen(d.WINDOW_SCALE_FACTOR_CHANGED,e)}async onThemeChanged(e){return this.listen(d.WINDOW_THEME_CHANGED,e)}},Qe;(function(t){t.Disabled="disabled",t.Throttle="throttle",t.Suspend="suspend"})(Qe||(Qe={}));var Xe;(function(t){t.Default="default",t.FluentOverlay="fluentOverlay"})(Xe||(Xe={}));var et;(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"})(et||(et={}));var tt;(function(t){t.FollowsWindowActiveState="followsWindowActiveState",t.Active="active",t.Inactive="inactive"})(tt||(tt={}));function Ue(){return new V(Re(),window.__TAURI_INTERNALS__.metadata.currentWebview.label,{skip:!0})}async function nt(){return s("plugin:webview|get_all_webviews").then(t=>t.map(e=>new V(new R(e.windowLabel,{skip:!0}),e.label,{skip:!0})))}var Ie=["tauri://created","tauri://error"],V=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 nt()).find(i=>i.label===e))!==null&&n!==void 0?n:null}static getCurrent(){return Ue()}static async getAll(){return nt()}async listen(e,n){return this._handleTauriEvent(e,n)?()=>{let i=this.listeners[e];i.splice(i.indexOf(n),1)}:x(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)}:q(e,n,{target:{kind:"Webview",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 Q(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 X(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 position(){return s("plugin:webview|webview_position",{label:this.label}).then(e=>new f(e))}async size(){return s("plugin:webview|webview_size",{label:this.label}).then(e=>new A(e))}async close(){return s("plugin:webview|webview_close",{label:this.label})}async setSize(e){return s("plugin:webview|set_webview_size",{label:this.label,value:e instanceof v?e:new v(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(d.DRAG_ENTER,a=>{e({...a,payload:{type:"enter",paths:a.payload.paths,position:new f(a.payload.position)}})}),i=await this.listen(d.DRAG_OVER,a=>{e({...a,payload:{type:"over",position:new f(a.payload.position)}})}),r=await this.listen(d.DRAG_DROP,a=>{e({...a,payload:{type:"drop",paths:a.payload.paths,position:new f(a.payload.position)}})}),o=await this.listen(d.DRAG_LEAVE,a=>{e({...a,payload:{type:"leave"}})});return()=>{n(),r(),i(),o()}}};H();W();function St(){let t=Ue();return new O(t.label,{skip:!0})}async function it(){return s("plugin:window|get_all_windows").then(t=>t.map(e=>new O(e,{skip:!0})))}var 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 it()).find(r=>r.label===e))!==null&&n!==void 0?n:null;return i?new t(i.label,{skip:!0}):null}static getCurrent(){return St()}static async getAll(){return it()}async listen(e,n){return this._handleTauriEvent(e,n)?()=>{let i=this.listeners[e];i.splice(i.indexOf(n),1)}:x(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)}:q(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}))}};xt(O,[R,V]);function xt(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 Rt=()=>{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"},De=Rt(),z=De==="android"||De==="ios",N=De==="tauri";var rt=!1,he=[];function st(t,e=null){he.forEach(n=>{try{n(t,e)}catch(i){console.error("Google listener error:",i)}})}function $e(t){return he.push(t),()=>{let e=he.indexOf(t);e!==-1&&he.splice(e,1)}}var we=null,ot=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),st(o,null)}catch(e){st(null,e)}},It=async()=>{if(!rt&&(rt=!0,z&&oe.addListener("appUrlOpen",t=>{ot(t.url)}),N)){let{listen:t}=await Promise.resolve().then(()=>(H(),Le));await t("deep-link://open-url",async e=>{let n=e.payload;if(typeof n=="object"&&(n=n?.url||n?.payload||null),!!n){if(we)try{await we.close(),we=null}catch{}ot(n)}})}},We=async({appId:t="tevrocsoft",serviceUrl:e="https://tevrocsoftapi.netlify.app"}={})=>{console.log(z,N)};var at=!1,pe=[];function lt(t,e=null){pe.forEach(n=>{try{n(t,e)}catch(i){console.error("Payment listener error:",i)}})}function ct(t){return pe.push(t),()=>{let e=pe.indexOf(t);e!==-1&&pe.splice(e,1)}}var fe=null,Ut=[],te=(...t)=>{t.forEach(e=>{let n={message:e,time:new Date().toISOString()};Ut.push(n),console.log(n)})},ut=async(t,e=()=>{})=>{try{if(te("PAYMENT CALLBACK:",t),!t?.includes("state="))return;let i=new URLSearchParams(t.split("?")[1]).get("state");te("PAYMENT RESULT:",i),i=="success"?te("PAYMENT SUCCESS"):te("PAYMENT FAILED"),e(i,null),lt(i,null)}catch(n){te("PAYMENT CALLBACK ERROR:",n.message),e(null,n),lt(null,n)}},Dt=async(t=()=>{})=>{if(!at&&(at=!0,z&&oe.addListener("appUrlOpen",e=>{ut(e.url,t)}),N)){let{listen:e}=await Promise.resolve().then(()=>(H(),Le));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{}ut(i,t)}})}},dt=async(t,{appId:e="tevrocsoft",serviceUrl:n="https://tevrocsoftapi.netlify.app",externalCallback:i=()=>{}}={})=>{await Dt(i);let r=Math.round(Number(t)*100),o=`${n}/pay`,a=`${o}?mode=mobile&amount=${r}&app=${e}`;if(z){await le.open({url:a});return}if(N){let b=`${o}?mode=desktop&amount=${r}&app=${e}`,g=new O("payment",{url:b,title:"Complete Payment",width:550,height:600,resizable:!0,center:!0});fe=g,g.once("tauri://created",()=>{console.log("Payment window opened")}),g.once("tauri://error",l=>{console.error("Payment window error:",l)});return}let h=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"?"localhost":"netlify";window.location.href=`${o}?mode=${h}&amount=${r}&app=${e}`};var $t=3e4,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 Wt(t={}){return new be(t)}var be=class{constructor(e={}){let n=e.baseUrl??e.url,i=e.serviceUrl??e.url;if(!n)throw new TypeError("createClient requires a baseUrl");if(this.baseUrl=wt(n),this.serviceUrl=wt(i),this.fetch=(e.fetch??globalThis.fetch).bind(globalThis),typeof this.fetch!="function")throw new TypeError("No fetch implementation available");this.timeoutMs=e.timeoutMs??$t,this.defaultHeaders=Xt(e.headers),this.token=e.token??null,this.auth=zt(this),this.entities=Nt(this),this.functions=Mt(this),this.integrations=Ft(this),this.agents=jt(this),this.logs=Ht(this),this.connectors=Vt(this),this.customIntegrations=Jt(this),this.sso=Kt(this),this.files=Yt(this),this.payments=qt(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?Qt(n.query):"",a=`${this.baseUrl}${e.startsWith("/")?e:`/${e}`}${o}`,u=new AbortController,h=setTimeout(()=>u.abort(),n.timeoutMs??this.timeoutMs),b=this.token||localStorage.getItem("tevroc_access_token");b&&n.auth!==!1&&r.set("authorization",`Bearer ${b}`),console.log(b);let g=n.body;if(g!=null&&en(g)&&(r.set("content-type","application/json"),g=JSON.stringify(g)),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:g,signal:n.signal??u.signal});return await Zt(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(h)}}};function qt(t){return{create:async({amountZAR:e,appId:n="tevrocsoft",mode:i="web"})=>await dt(e,{appId:n,serviceUrl:t.serviceUrl,mode:i}),onstatus:e=>{if(typeof e!="function")throw new Error("onstatus requires a function");return ct(e)}}}function zt(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:(e,n)=>{e==="google"&&(We({serviceUrl:t.serviceUrl,redirectTo:n}),n&&$e(async(i,r)=>{let o=await t.request("/provider/google/auth/login",{method:"POST",body:{user:i},auth:!1});window.location.href=n}))},googleLogin:e=>We(e),onGoogleLogin:e=>$e(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 Nt(t){return new Proxy({},{get(e,n){if(typeof n=="string")return Bt(t,n)}})}function Bt(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 Mt(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 Ft(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={})=>ht(t,"/integrations/core/upload-file",e,n),UploadPrivateFile:(e,n={})=>ht(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 jt(t){return new Proxy({},{get(e,n){if(typeof n=="string")return Gt(t,n)}})}function Gt(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 Ht(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 Vt(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 Jt(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 Kt(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 Yt(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 ht(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 Zt(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 Qt(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 wt(t){return String(t).replace(/\/+$/,"")}function Xt(t={}){return Object.fromEntries(new Headers(t).entries())}function en(t){let e=typeof ArrayBuffer<"u"&&t instanceof ArrayBuffer,n=typeof Blob<"u"&&t instanceof Blob,i=typeof FormData<"u"&&t instanceof FormData;return typeof t=="object"&&!e&&!n&&!i}return vt(tn);})();
2
2
  /*! Bundled license information:
3
3
 
4
4
  @capacitor/core/dist/index.js:
package/tevroc-sdk.umd.js CHANGED
@@ -3518,6 +3518,7 @@ var Tevroc = (() => {
3518
3518
  var isTauri = platform === "tauri";
3519
3519
 
3520
3520
  // src/services/useGoogleAuth.js
3521
+ var googleInitialized = false;
3521
3522
  var googleListeners = [];
3522
3523
  function emitGoogleLogin(user, err = null) {
3523
3524
  googleListeners.forEach((cb) => {
@@ -3532,21 +3533,15 @@ var Tevroc = (() => {
3532
3533
  googleListeners.push(cb);
3533
3534
  return () => {
3534
3535
  const i = googleListeners.indexOf(cb);
3535
- if (i !== -1) {
3536
- googleListeners.splice(i, 1);
3537
- }
3536
+ if (i !== -1) googleListeners.splice(i, 1);
3538
3537
  };
3539
3538
  }
3540
3539
  var authWindowRef = null;
3541
- var initialized = false;
3542
- var tauriUnlisten = null;
3543
- var capacitorListener = null;
3544
3540
  var handleCallback = async (url) => {
3545
3541
  try {
3546
3542
  if (!url?.includes("token=")) return;
3547
3543
  const params = new URLSearchParams(url.split("?")[1]);
3548
3544
  const token = params.get("token");
3549
- if (!token) return;
3550
3545
  const res = await fetch(
3551
3546
  "https://www.googleapis.com/oauth2/v3/userinfo",
3552
3547
  {
@@ -3568,66 +3563,50 @@ var Tevroc = (() => {
3568
3563
  localStorage.setItem("idToken", token);
3569
3564
  emitGoogleLogin(profile, null);
3570
3565
  } catch (err) {
3571
- console.error(err);
3572
3566
  emitGoogleLogin(null, err);
3573
3567
  }
3574
3568
  };
3575
- async function initializeGoogleLogin() {
3576
- if (initialized) return;
3577
- initialized = true;
3578
- try {
3579
- if (isCapacitor) {
3580
- capacitorListener = await App.addListener(
3581
- "appUrlOpen",
3582
- async (event) => {
3583
- await handleCallback(event.url);
3584
- }
3585
- );
3586
- }
3587
- if (isTauri) {
3588
- const { listen: listen2 } = await Promise.resolve().then(() => (init_event(), event_exports));
3589
- tauriUnlisten = await listen2(
3590
- "deep-link://open-url",
3591
- async (event) => {
3592
- let url = event.payload;
3593
- if (typeof url === "object") {
3594
- url = url?.url || url?.payload || null;
3595
- }
3596
- if (!url) return;
3597
- if (authWindowRef) {
3598
- try {
3599
- await authWindowRef.close();
3600
- } catch (e) {
3601
- }
3602
- authWindowRef = null;
3603
- }
3604
- await handleCallback(url);
3569
+ var initializeGoogleLogin = async () => {
3570
+ if (googleInitialized) return;
3571
+ googleInitialized = true;
3572
+ if (isCapacitor) {
3573
+ App.addListener("appUrlOpen", (event) => {
3574
+ handleCallback(event.url);
3575
+ });
3576
+ }
3577
+ if (isTauri) {
3578
+ const { listen: listen2 } = await Promise.resolve().then(() => (init_event(), event_exports));
3579
+ await listen2("deep-link://open-url", async (event) => {
3580
+ let url = event.payload;
3581
+ if (typeof url === "object") {
3582
+ url = url?.url || url?.payload || null;
3583
+ }
3584
+ if (!url) return;
3585
+ if (authWindowRef) {
3586
+ try {
3587
+ await authWindowRef.close();
3588
+ authWindowRef = null;
3589
+ } catch (e) {
3605
3590
  }
3606
- );
3607
- }
3608
- console.log("Google login initialized");
3609
- } catch (err) {
3610
- console.error("Google login init failed:", err);
3591
+ }
3592
+ handleCallback(url);
3593
+ });
3611
3594
  }
3612
- }
3595
+ };
3613
3596
  var createGoogleLogin = async ({
3614
3597
  appId = "tevrocsoft",
3615
3598
  serviceUrl = "https://tevrocsoftapi.netlify.app"
3616
3599
  } = {}) => {
3600
+ console.log(isCapacitor, isTauri);
3601
+ return;
3617
3602
  await initializeGoogleLogin();
3618
- let authUrl = `${serviceUrl}/login?mode=mobile&app=${encodeURIComponent(
3619
- appId
3620
- )}`;
3603
+ let authUrl = `${serviceUrl}/login?mode=mobile&app=${appId}`;
3621
3604
  if (isCapacitor) {
3622
- await Browser2.open({
3623
- url: authUrl
3624
- });
3605
+ await Browser2.open({ url: authUrl });
3625
3606
  return;
3626
3607
  }
3627
3608
  if (isTauri) {
3628
- const url = `${serviceUrl}/login?mode=desktop&app=${encodeURIComponent(
3629
- appId
3630
- )}`;
3609
+ const url = `${serviceUrl}/login?mode=desktop&app=${appId}`;
3631
3610
  const win = new WebviewWindow("auth", {
3632
3611
  url,
3633
3612
  title: "Tevroc Login",
@@ -3647,11 +3626,12 @@ var Tevroc = (() => {
3647
3626
  }
3648
3627
  const isLocalhost = window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1";
3649
3628
  const mode = isLocalhost ? "localhost" : "netlify";
3650
- authUrl = `${serviceUrl}/login?mode=${mode}&app=${encodeURIComponent(appId)}`;
3629
+ authUrl = `${serviceUrl}/login?mode=${mode}&app=${appId}`;
3651
3630
  window.location.href = authUrl;
3652
3631
  };
3653
3632
 
3654
3633
  // src/services/useYocoPayment.js
3634
+ var paymentInitialized = false;
3655
3635
  var paymentStatusListeners = [];
3656
3636
  function emitPaymentStatus(status, err = null) {
3657
3637
  paymentStatusListeners.forEach((cb) => {
@@ -3666,100 +3646,96 @@ var Tevroc = (() => {
3666
3646
  paymentStatusListeners.push(cb);
3667
3647
  return () => {
3668
3648
  const i = paymentStatusListeners.indexOf(cb);
3669
- if (i !== -1) {
3670
- paymentStatusListeners.splice(i, 1);
3671
- }
3649
+ if (i !== -1) paymentStatusListeners.splice(i, 1);
3672
3650
  };
3673
3651
  }
3674
3652
  var paymentWindowRef = null;
3675
- var initialized2 = false;
3676
- var tauriUnlisten2 = null;
3677
- var capacitorListener2 = null;
3678
- function addLog(...msgs) {
3653
+ var logs = [];
3654
+ var addLog = (...msgs) => {
3679
3655
  msgs.forEach((m) => {
3680
- console.log("[TEVROC PAYMENT]", m);
3656
+ const log = {
3657
+ message: m,
3658
+ time: (/* @__PURE__ */ new Date()).toISOString()
3659
+ };
3660
+ logs.push(log);
3661
+ console.log(log);
3681
3662
  });
3682
- }
3683
- async function handlePaymentCallback(url) {
3663
+ };
3664
+ var handlePaymentCallback = async (url, externalCallback = () => {
3665
+ }) => {
3684
3666
  try {
3685
3667
  addLog("PAYMENT CALLBACK:", url);
3686
- if (!url?.includes("state=")) {
3687
- return;
3688
- }
3668
+ if (!url?.includes("state=")) return;
3689
3669
  const params = new URLSearchParams(url.split("?")[1]);
3690
3670
  const state = params.get("state");
3691
3671
  addLog("PAYMENT RESULT:", state);
3692
- if (state === "success") {
3672
+ if (state == "success") {
3693
3673
  addLog("PAYMENT SUCCESS");
3694
3674
  } else {
3695
3675
  addLog("PAYMENT FAILED");
3696
3676
  }
3677
+ externalCallback(state, null);
3697
3678
  emitPaymentStatus(state, null);
3698
3679
  } catch (err) {
3699
- addLog("PAYMENT CALLBACK ERROR:", err?.message);
3680
+ addLog("PAYMENT CALLBACK ERROR:", err.message);
3681
+ externalCallback(null, err);
3700
3682
  emitPaymentStatus(null, err);
3701
3683
  }
3702
- }
3703
- async function initializePayment() {
3704
- if (initialized2) {
3705
- return;
3706
- }
3707
- initialized2 = true;
3708
- try {
3709
- if (isCapacitor) {
3710
- capacitorListener2 = await App.addListener(
3711
- "appUrlOpen",
3712
- async (event) => {
3713
- await handlePaymentCallback(event.url);
3714
- }
3684
+ };
3685
+ var initializePayment = async (externalCallback = () => {
3686
+ }) => {
3687
+ if (paymentInitialized) return;
3688
+ paymentInitialized = true;
3689
+ if (isCapacitor) {
3690
+ App.addListener("appUrlOpen", (event) => {
3691
+ handlePaymentCallback(
3692
+ event.url,
3693
+ externalCallback
3715
3694
  );
3716
- }
3717
- if (isTauri) {
3718
- const { listen: listen2 } = await Promise.resolve().then(() => (init_event(), event_exports));
3719
- tauriUnlisten2 = await listen2(
3720
- "deep-link://open-url",
3721
- async (event) => {
3722
- let url = event.payload;
3723
- if (typeof url === "object") {
3724
- url = url?.url || url?.payload || null;
3725
- }
3726
- if (!url) {
3727
- return;
3728
- }
3729
- if (paymentWindowRef) {
3730
- try {
3731
- await paymentWindowRef.close();
3732
- } catch (e) {
3733
- }
3734
- paymentWindowRef = null;
3735
- }
3736
- await handlePaymentCallback(url);
3695
+ });
3696
+ }
3697
+ if (isTauri) {
3698
+ const { listen: listen2 } = await Promise.resolve().then(() => (init_event(), event_exports));
3699
+ await listen2("deep-link://open-url", async (event) => {
3700
+ let url = event.payload;
3701
+ if (typeof url === "object") {
3702
+ url = url?.url || url?.payload || null;
3703
+ }
3704
+ if (!url) return;
3705
+ if (paymentWindowRef) {
3706
+ try {
3707
+ await paymentWindowRef.close();
3708
+ paymentWindowRef = null;
3709
+ } catch (e) {
3737
3710
  }
3711
+ }
3712
+ handlePaymentCallback(
3713
+ url,
3714
+ externalCallback
3738
3715
  );
3739
- }
3740
- addLog("Payment listeners initialized");
3741
- } catch (err) {
3742
- console.error("Payment initialization failed:", err);
3716
+ });
3743
3717
  }
3744
- }
3718
+ };
3745
3719
  var createPayment = async (amountZAR, {
3746
3720
  appId = "tevrocsoft",
3747
- serviceUrl = "https://tevrocsoftapi.netlify.app"
3721
+ serviceUrl = "https://tevrocsoftapi.netlify.app",
3722
+ externalCallback = () => {
3723
+ }
3748
3724
  } = {}) => {
3749
- await initializePayment();
3725
+ await initializePayment(externalCallback);
3750
3726
  const cents = Math.round(Number(amountZAR) * 100);
3751
3727
  const basePaymentUrl = `${serviceUrl}/pay`;
3752
- const mobileUrl = `${basePaymentUrl}?mode=mobile&amount=${encodeURIComponent(cents)}&app=${encodeURIComponent(appId)}`;
3728
+ const paymentUrl = `${basePaymentUrl}?mode=mobile&amount=${cents}&app=${appId}`;
3753
3729
  if (isCapacitor) {
3754
3730
  await Browser2.open({
3755
- url: mobileUrl
3731
+ url: paymentUrl
3756
3732
  });
3757
3733
  return;
3758
3734
  }
3759
3735
  if (isTauri) {
3760
- const desktopUrl = `${basePaymentUrl}?mode=desktop&amount=${encodeURIComponent(cents)}&app=${encodeURIComponent(appId)}`;
3736
+ const url = `${basePaymentUrl}?mode=desktop&amount=${cents}&app=${appId}`;
3761
3737
  const win = new WebviewWindow("payment", {
3762
- url: desktopUrl,
3738
+ url,
3763
3739
  title: "Complete Payment",
3764
3740
  width: 550,
3765
3741
  height: 600,
@@ -3768,7 +3744,7 @@ var Tevroc = (() => {
3768
3744
  });
3769
3745
  paymentWindowRef = win;
3770
3746
  win.once("tauri://created", () => {
3771
- addLog("Payment window opened");
3747
+ console.log("Payment window opened");
3772
3748
  });
3773
3749
  win.once("tauri://error", (e) => {
3774
3750
  console.error("Payment window error:", e);
@@ -3777,7 +3753,7 @@ var Tevroc = (() => {
3777
3753
  }
3778
3754
  const isLocalhost = window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1";
3779
3755
  const mode = isLocalhost ? "localhost" : "netlify";
3780
- window.location.href = `${basePaymentUrl}?mode=${mode}&amount=${encodeURIComponent(cents)}&app=${encodeURIComponent(appId)}`;
3756
+ window.location.href = `${basePaymentUrl}?mode=${mode}&amount=${cents}&app=${appId}`;
3781
3757
  };
3782
3758
 
3783
3759
  // src/index.js