"use strict";var m=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var w=Object.prototype.hasOwnProperty;var P=(i,e)=>{for(var t in e)m(i,t,{get:e[t],enumerable:!0})},R=(i,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of h(e))!w.call(i,r)&&r!==t&&m(i,r,{get:()=>e[r],enumerable:!(s=g(e,r))||s.enumerable});return i};var O=i=>R(m({},"__esModule",{value:!0}),i);var C={};P(C,{Body:()=>a,Client:()=>c,Response:()=>l,ResponseType:()=>y,fetch:()=>A,getClient:()=>T});module.exports=O(C);function b(){return window.crypto.getRandomValues(new Uint32Array(1))[0]}function d(i,e=!1){let t=b(),s=`_${t}`;return Object.defineProperty(window,s,{value:r=>(e&&Reflect.deleteProperty(window,s),i?.(r)),writable:!1,configurable:!0}),t}async function f(i,e={}){return new Promise((t,s)=>{let r=d(o=>{t(o),Reflect.deleteProperty(window,`_${n}`)},!0),n=d(o=>{s(o),Reflect.deleteProperty(window,`_${r}`)},!0);window.__TAURI_IPC__({cmd:i,callback:r,error:n,...e})})}async function u(i){return f("tauri",i)}var y=(s=>(s[s.JSON=1]="JSON",s[s.Text=2]="Text",s[s.Binary=3]="Binary",s))(y||{}),a=class{constructor(e,t){this.type=e,this.payload=t}static form(e){let t={},s=(r,n)=>{if(n!==null){let o;typeof n=="string"?o=n:n instanceof Uint8Array||Array.isArray(n)?o=Array.from(n):n instanceof File?o={file:n.name,mime:n.type,fileName:n.name}:typeof n.file=="string"?o={file:n.file,mime:n.mime,fileName:n.fileName}:o={file:Array.from(n.file),mime:n.mime,fileName:n.fileName},t[String(r)]=o}};if(e instanceof FormData)for(let[r,n]of e)s(r,n);else for(let[r,n]of Object.entries(e))s(r,n);return new a("Form",t)}static json(e){return new a("Json",e)}static text(e){return new a("Text",e)}static bytes(e){return new a("Bytes",Array.from(e instanceof ArrayBuffer?new Uint8Array(e):e))}},l=class{constructor(e){this.url=e.url,this.status=e.status,this.ok=this.status>=200&&this.status<300,this.headers=e.headers,this.rawHeaders=e.rawHeaders,this.data=e.data}},c=class{constructor(e){this.id=e}async drop(){return u({__tauriModule:"Http",message:{cmd:"dropClient",client:this.id}})}async request(e){let t=!e.responseType||e.responseType===1;return t&&(e.responseType=2),u({__tauriModule:"Http",message:{cmd:"httpRequest",client:this.id,options:e}}).then(s=>{let r=new l(s);if(t){try{r.data=JSON.parse(r.data)}catch(n){if(r.ok&&r.data==="")r.data={};else if(r.ok)throw Error(`Failed to parse response \`${r.data}\` as JSON: ${n}; try setting the \`responseType\` option to \`ResponseType.Text\` or \`ResponseType.Binary\` if the API does not return a JSON response.`)}return r}return r})}async get(e,t){return this.request({method:"GET",url:e,...t})}async post(e,t,s){return this.request({method:"POST",url:e,body:t,...s})}async put(e,t,s){return this.request({method:"PUT",url:e,body:t,...s})}async patch(e,t){return this.request({method:"PATCH",url:e,...t})}async delete(e,t){return this.request({method:"DELETE",url:e,...t})}};async function T(i){return u({__tauriModule:"Http",message:{cmd:"createClient",options:i}}).then(e=>new c(e))}var p=null;async function A(i,e){return p===null&&(p=await T()),p.request({url:i,method:e?.method??"GET",...e})}