async function c(t,{method:n="GET",params:o,body:e,headers:l,base:u}){const p=new URL((u||"")+t||t,window.location.origin);o&&Object.entries(o).forEach(([w,s])=>{s!=null&&p.searchParams.append(w,s)});const a=await fetch(p,{method:n,headers:e instanceof FormData?{...l||{}}:{"Content-Type":"application/json",...l||{}},body:e instanceof FormData?e:e?JSON.stringify(e):void 0}),r=(a.headers.get("content-type")||"").includes("application/json")?await a.json():await a.text();if(!a.ok)throw new Error(typeof r=="string"?r:JSON.stringify(r));return r}const d={get:(t,n)=>c(t,{...n,method:"GET"}),post:(t,n,o)=>c(t,{...o,method:"POST",body:n}),put:(t,n,o)=>c(t,{...o,method:"PUT",body:n}),del:(t,n)=>c(t,{...n,method:"DELETE"})};function i(t){const n=window.location.pathname.split("/").filter(Boolean);return n[n.length-1]==="studio"&&(n[n.length-1]=t),n.join("/")}function g(){const t=i("meta-api");return`${window.location.origin}/${t}`}function h(){const t=i("feedback");return`${window.location.origin}/${t}`}function U(){const t=i("service");return`${window.location.origin}/${t}`}function $(){const t=i("ws");return`${window.location.origin}/${t}`}function E(t,n){const o=new URL(t);return o.protocol=o.protocol.replace("http","ws"),o.toString()}function m(){const t=i("trace");return`${window.location.origin}/${t}`}export{d as a,g as b,$ as c,m as d,h as e,U as g,E as t};
