1import{m as w}from"./map-country-code-to-country-id-DlCcAJSj.js";import{t as y,r as h,o as b}from"./components-BQBQZtji.js";import{D as L}from"./constants-hZ_NGfMm.js";async function S(t,e){const o=`https://api.bark.com/slf/categories?caid=${e.toString()}&coid=${t.toString()}`;try{const r=await fetch(o,{headers:{Accept:"application/json"}});if(!r.ok)return console.warn("getSLFCategoryData: category check failed",{status:r.status,countryId:t,categoryId:e}),null;const n=await r.json();return(Array.isArray(n.data)?n.data:[])[0]??null}catch(r){return console.error("getSLFCategoryData: unexpected error",{error:r,countryId:t,categoryId:e}),null}}async function F(t,e,a){const o="https://api.bark.com",r=Number(e),n=Number(a);if(!Number.isFinite(r)||!Number.isFinite(n))return console.warn("checkPolarisCategoryLocation: invalid lat/lng",{categoryId:t,lat:e,lng:a}),!1;const c=`${o}/slf/available-location?caid=${t.toString()}&lat=${r.toString()}&lng=${n.toString()}&paid=0`;try{const s=await fetch(c,{headers:{Accept:"application/json"}});return s.ok?(await s.json()).data:(console.warn("checkPolarisCategoryLocation: location availability check failed",{status:s.status,categoryId:t,lat:e,lng:a}),!1)}catch(s){return console.error("checkPolarisCategoryLocation: unexpected error",{error:s,categoryId:t,lat:e,lng:a}),!1}}const k=()=>{const e=new URLSearchParams(globalThis.location.search).get("sId");return e!==null&&e.length>0},P=t=>[13].includes(t),N=t=>{try{const e=localStorage.getItem(t);return e?JSON.parse(e):null}catch{return null}},R={"dj-hire":"dj"},$=async(t,e,a,o,r)=>{if(k()||!P(t))return!1;const c="https://www.bark.com";try{const s=await S(t,e);if(!s?.is_polaris_category)return!1;const i=R[s.name_url]||s.name_url,u=new URLSearchParams(globalThis.location.search);u.set("is_organic","true");const f=`${c}/${o}/${r}/m/${i}/?${u.toString()}`;if(!a)return localStorage.setItem("polarisReferrerUrl",globalThis.location.href),globalThis.location.assign(f),!0;const l=`location_${String(a.id)}`,g=N(l)??a,d=await F(e,g.lat,g.lng),p=g.name;return d?(localStorage.setItem("polarisReferrerUrl",globalThis.location.href),globalThis.location.assign(`${f}&location=${encodeURIComponent(p)}`),!0):(localStorage.setItem("polarisReferrerUrl",globalThis.location.href),globalThis.location.assign(f),!0)}catch(s){return console.error("redirectToSLF: unexpected error",s),!1}};function C(t){const e=t?.lang,a=t?.locale,o=(e??L.lang).toLowerCase(),r=(a??L.locale).toLowerCase();return{lang:o,locale:r}}const T=()=>{const[t,e]=h.useState(null),a=y(),{locale:o,lang:r}=C(a);return h.useEffect(()=>{if(window.Bark={ENV:{lang:r,locale:o}},window.BarkRequestFlow){e(window.BarkRequestFlow);return}const n=()=>{e(window.BarkRequestFlow)};return window.addEventListener("nrf-script-loaded",n),()=>{window.removeEventListener("nrf-script-loaded",n)}},[r,o]),t};function D(){return b().find(a=>a.id.startsWith("genericPage")||a.id.startsWith("servicesPage"))?.loaderData?.nrf}const _=({hasModal:t=!1,closeOnExit:e=!1,location:a="new-request-flow-widget",onFinish:o,onExit:r,onError:n=console.error,allowPolarisRedirect:c=!1}={})=>{const s=y(),{locale:i,lang:u}=C(s),f=D(),l=T(),m=h.useCallback(()=>{e&&l?.remove({location:a}),r?.()},[e,r,l,a]);return h.useCallback(async({category_id:g,locationData:d})=>{c&&await $(w(i),g,d??null,u,i)||l&&l.startNewRequestFlowV2({category_id:g,locationData:d,country_id:w(i),location:a,lang:u,locale:i,hasModal:t,allowPolarisRedirect:c,headlessProps:{projectFlow:f?.projectFlow},bark_mode:"martech",onExit:m,onError:n,onFinish:o})},[l,i,u,f?.projectFlow,m,n,o,a,t,c])};export{D as a,_ as u};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.