import{r as e}from"./authSession-CrP9lMPq.js";import{r as t}from"./norm-CeclA1Tu.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(){return a(`/api/market/taxonomy`)}async function d(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 f(e,t){return o(`/api/market/salary-anchors`,e,t)}async function p(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}/api/market/salary-advice`,{method:`POST`,headers:c,body:JSON.stringify(n),signal:a});if(!u.ok||!u.body){r?.({type:`error`,message:`Service unavailable`});return}let d=u.body.getReader(),f=new TextDecoder,p=``;for(;;){let{done:e,value:t}=await d.read();if(e)break;p+=f.decode(t,{stream:!0});let n=p.split(`
`);p=n.pop()||``;for(let e of n){if(!e.startsWith(`data: `))continue;let t=e.slice(6).trim();if(!(!t||t===`[DONE]`))try{r?.(JSON.parse(t))}catch{}}}}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{c as a,p as c,f as i,l as n,u as o,s as r,d as s,m as t};