import{Q as S}from"./QSelect-7Ay93ffU.js";import{d as C,aa as V,r as g,as as N,af as B,aj as L,aL as Q,al as l,ao as o,ap as y,aq as a,ae as c,at as M,ad as u,aN as _,ah as b}from"./index-BT5eY4j5.js";import{Q as P}from"./QPage-BfEPTOJq.js";import{u as $}from"./index-C91YIOYp.js";import{E as A,_ as E}from"./EntityCardSkeleton-DqdGeiW9.js";import{g as F}from"./getLocation-DdSgzYKT.js";import{u as D}from"./vue-i18n-CUkMLu72.js";import"./QItem-9vG9WSh3.js";import"./QMenu-lMfgNADA.js";import"./selection-DqxIs-MO.js";import"./QCarousel-Cjxkio9d.js";import"./use-panel-CWoWnVAV.js";import"./TouchSwipe-DbDTeaOO.js";import"./QSkeleton-B930fRUI.js";import"./_plugin-vue_export-helper-DlAUqK2U.js";const I={class:"row q-col-gutter-y-md q-col-gutter-x-md q-pa-md"},U={class:"text-h4"},j={class:"col-12"},z={class:"row"},O={key:1,class:"col-12"},R={class:"text-subtitle text-center q-my-lg"},ie=C({__name:"NearMeView",setup(T){const{t:r,tm:k}=D(),h=V(),x=L(),d=Q(),s=g(String(d.query.category??"")||null),m=g(Number(d.query.lat)||null),p=g(Number(d.query.lng)||null),{state:v,isLoading:f,execute:q}=$(async()=>(console.log(s.value),!m.value||!p.value||!s.value?[]:(await new Promise(t=>setTimeout(t,200)),x.entities.filter.byLocation(m.value,p.value,s.value).then(t=>t.status===200?t.data:[]).catch(()=>[]))),[],{immediate:!0});return(t,i)=>(l(),N(P,null,{default:B(()=>[o("div",null,[o("div",I,[o("h1",U,y(a(r)("pages.search")),1),o("div",j,[o("div",z,[c(S,{style:{"min-width":"200px"},dense:"",borderless:"",label:a(r)("entities.edit.form.category"),modelValue:s.value,"onUpdate:modelValue":i[0]||(i[0]=e=>s.value=e),options:a(h).mainCategories.flatMap(e=>a(h).categoriesMap[e]),"option-label":e=>e?a(k)("categories")[e]:""},null,8,["label","modelValue","options","option-label"]),c(M,{color:"primary",size:"sm",icon:"search",disable:!s.value,loading:a(f),onClick:i[1]||(i[1]=e=>{a(F)().then(({latitude:n,longitude:w})=>{m.value=n,p.value=w,a(q)()}).catch(n=>{console.error(n),n.code===1?t.$q.notify({type:"warning",message:a(r)("quickSearch.locationFilterPermission")}):t.$q.notify({type:"negative",message:"Unexpected error! Could not get user location."})})})},null,8,["disable","loading"])])]),a(f)?(l(),u(b,{key:0},_(4,e=>o("div",{key:e,class:"col-12 col-lg-6 col-xl-3"},[c(A)])),64)):a(v).length?(l(!0),u(b,{key:2},_(a(v),e=>(l(),u("div",{key:e.id,class:"col-12 col-lg-6 col-xl-3"},[c(E,{id:e.id,title:e.imeSalona,images:e.slike,address:e.adresa??"",rating:e.prosecnaOcena,"working-hours":e.radnoVreme,"payment-methods":e.paymentMethod.split(" "),"next-available-date":e.nextAvailableDate??null},null,8,["id","title","images","address","rating","working-hours","payment-methods","next-available-date"])]))),128)):(l(),u("div",O,[o("h3",R,y(a(r)("entities.notFound")),1)]))])])]),_:1}))}});export{ie as default};
