import{r as e}from"./authSession-Dulxhbeq.js";import{r as t}from"./norm-f7iXVy-b.js";var n=`https://api2.bysjob.com`,r=()=>{let e=String(globalThis?.location?.protocol||``);return e===`chrome-extension:`||e===`moz-extension:`||e===`safari-extension:`},i=()=>{try{let e=t(`https://api2.bysjob.com`);if(e)return e.replace(/\/+$/g,``)}catch{}if(!r()){let e=String(globalThis?.location?.origin||``).replace(/\/+$/g,``);if(e.includes(`localhost`)||e.includes(`127.0.0.1`))return e}return n};async function a(n){let r=await e(),a=i(),o={"Content-Type":`application/json`},s=t(r?.accessToken||r?.token);s&&(o.Authorization=`Bearer ${s}`,o[`x-auth-token`]=s);let c=await fetch(`${a}${n}`,{headers:o});if(!c.ok){let e=await c.json().catch(()=>({}));throw Error(e.error||`HTTP ${c.status}`)}let l=await c.json();if(!l.ok)throw Error(l.error||`unknown error`);return l.data}async function o(n,r,a){let o=await e(),s=i(),c={"Content-Type":`application/json`},l=t(o?.accessToken||o?.token);l&&(c.Authorization=`Bearer ${l}`,c[`x-auth-token`]=l);let u=await fetch(`${s}${n}`,{method:`POST`,headers:c,body:JSON.stringify(r||{}),signal:a});if(!u.ok){let e=await u.json().catch(()=>({}));throw Error(e.error||`HTTP ${u.status}`)}let d=await u.json();if(!d.ok)throw Error(d.error||`unknown error`);return d.data}async function s(e,t,n){let r=new URLSearchParams;return e&&r.set(`family`,e),t&&r.set(`sub_family`,t),n&&r.set(`city`,n),a(`/api/market/stats?${r}`)}async function c(e,t,n,r,i){let o=new URLSearchParams({family:e,salary:String(t)});return n&&o.set(`sub_family`,n),i&&o.set(`l3`,i),r&&o.set(`city`,r),a(`/api/market/salary-position?${o}`)}async function l(e,t,n,r=20){let i=new URLSearchParams({limit:String(r)});return e&&i.set(`family`,e),t&&i.set(`sub_family`,t),n&&i.set(`city`,n),a(`/api/market/skills?${i}`)}async function u(e,t,n,r=10){let i=new URLSearchParams({limit:String(r)});return e&&i.set(`family`,e),t&&i.set(`sub_family`,t),n&&i.set(`city`,n),a(`/api/market/companies?${i}`)}async function d(){return a(`/api/market/taxonomy`)}async function f(e,t,n){let r=new URLSearchParams({l1:e});t&&r.set(`l2`,t),n&&r.set(`city`,n);let i=await a(`/api/market/taxonomy/l3?${r}`);return Array.isArray(i)?i:[]}async function p(e,t){return o(`/api/market/salary-anchors`,e,t)}async function m(e){let t=i(),n=await fetch(`${t}/api/market/dashboard`,{signal:e});if(!n.ok)return null;let r=await n.json().catch(()=>null);return!r||!r.ok?null:r.data}export{p as a,f as c,s as i,m as n,c as o,l as r,d as s,u as t};