import{g as x,cp as Y,u as N,bP as I,h as C,j as w,M as U,l as y,X as B,q as g,w as v,y as o,n as k,B as D,C as P,al as z,aJ as ee,ag as te,cq as ae,ai as j,_ as Z,ab as G,cr as oe,cs as K,ct as se,cl as E,ap as O,R as ne,ak as ie,aI as le,a7 as ce,K as re,o as ue,aQ as de,W as pe,cu as H,T as me,F as W,A as J,$ as he,at as ge,aP as fe,d as q}from"./dashboard-practitioner-050058d6.js";(function(){try{var d=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},p=new Error().stack;p&&(d._sentryDebugIds=d._sentryDebugIds||{},d._sentryDebugIds[p]="09838b6a-678b-46ab-9e1e-1d7c272debdf",d._sentryDebugIdIdentifier="sentry-dbid-09838b6a-678b-46ab-9e1e-1d7c272debdf")}catch{}})();const ye=x({__name:"ServicesField",setup(d){const p=Y(),{smAndUp:a}=N(),n=I(),m=c=>{c&&n.autocompleteSearchServices(n.searchService)};function e(c){n.searchService=c.id}const s=C(!1),i=w(()=>n.listAutocompleteService.length===0);return U(()=>n.searchLocation,(c,t)=>{!!c&&i.value?s.value=!0:i.value&&(s.value=!1)}),U(()=>n.listAutocompleteService,(c,t)=>{0<n.listAutocompleteService.length&&(s.value=!0)}),(c,t)=>(y(),B(j,null,[g(ee,z({id:"search-service-field"},o(p),{modelValue:o(n).searchService,"onUpdate:modelValue":[t[0]||(t[0]=l=>o(n).searchService=l),o(n).autocompleteSearchServices],"bg-color":o(a)?"transparent":"white",class:[{"w-50":o(a)},"search-field"],label:c.$t("heroSection.searchPlaceholder1"),placeholder:c.$t("heroSection.searchPlaceholder1"),clearable:"",flat:"","hide-details":"","prepend-inner-icon":"mdi-magnify","single-line":"",variant:"solo",autocomplete:"off","onUpdate:focused":m}),{"append-inner":v(()=>[o(n).loadingServices?(y(),k(D,{key:0,icon:"",size:"small",variant:"text",loading:o(n).loadingServices},null,8,["loading"])):P("",!0)]),_:1},16,["modelValue","bg-color","class","label","placeholder","onUpdate:modelValue"]),g(ae,{modelValue:s.value,"onUpdate:modelValue":t[1]||(t[1]=l=>s.value=l),activator:"#search-service-field","max-height":"300px"},{default:v(()=>[0<o(n).listAutocompleteService.length?(y(),k(te,{key:0,items:o(n).listAutocompleteService,"onClick:select":e,slim:"",density:"compact"},null,8,["items"])):P("",!0)]),_:1},8,["modelValue"])],64))}});const Q=Z(ye,[["__scopeId","data-v-bc8a1af9"]]),ve=G(),T=oe("autocomplete-location",()=>{const d=C([]),p=C(!1),a=C(null),n=w(()=>Object.prototype.hasOwnProperty.call(a.value,"value")&&Object.prototype.hasOwnProperty.call(a.value,"label")&&Object.prototype.hasOwnProperty.call(a.value.value,"city")&&a.value.value.city),m=(i,{layers:c,country:t}={})=>{const l=E(),u={text:i};return t&&(u["boundary.country"]=t),c&&(u.layers=c),l.storedLocationIsEmpty||(u["focus.point.lat"]=l.getLat(),u["focus.point.lon"]=l.getLon()),u},e=K(async i=>{if(!i){p.value=!1;return}try{const c=await ve.getAutocompleteSuggestionsPlaces(i,[]);d.value=c}catch(c){throw new Error(`Error fetching data: ${c}`)}finally{p.value=!1}},200),s=K(async(i,{layers:c,country:t}={})=>{if(!i)return[];p.value=!0;try{const l=await se(m(i,{layers:c,country:t})),{data:u}=l,R=u.features.map(h=>{var A,V,$,r;return{label:h.properties.label,value:{label:h.properties.label,country:h.properties.country,addressLine:h.properties.name,postalCode:h.properties.postalcode,city:h.properties.locality,latitude:(V=(A=h.geometry)==null?void 0:A.coordinates[1])==null?void 0:V.toString(),longitude:(r=($=h.geometry)==null?void 0:$.coordinates[0])==null?void 0:r.toString()}}});d.value=R}catch(l){console.error(`Error fetching data: ${l}`)}finally{p.value=!1}},100);return{autocompleteLocationList:d,loadingLocation:p,selectedLocation:a,hasCityProp:n,autocompleteLocationRequest:s,autocompleteRequest:e}}),Le=x({__name:"LocationField",props:{displayIcon:{type:Boolean,default:!0},displayCompact:{type:Boolean,default:!1}},setup(d){const p=Y(),{smAndUp:a}=N(),n=I(),m=E(),e=T(),s=C(!1);O(),U(()=>n.searchLocation,(t,l)=>{ce(()=>{i(),n.searchLocation&&0<e.autocompleteLocationList.length&&(s.value=!0),e.autocompleteLocationList.length===0&&(s.value=!1)})}),U(()=>e.autocompleteLocationList,t=>{t.length>0&&(s.value=!0)});const i=()=>{(e.autocompleteLocationList.length===0||!n.searchLocation)&&(s.value=!1)};async function c(t){const l=G();if(typeof t=="string"&&t.length>0&&(n.searchLocation=t,e.selectedLocation=null),t?s.value=!0:s.value=!1,!t)e.autocompleteLocationList=[];else if(typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"value")){t=t,t.value=await l.getFormatedAddressFromPlace(t.value);const u=t;m.updateStoredLocation({...u.value,coords:{latitude:Number(u.value.latitude),longitude:Number(u.value.longitude)}}),e.selectedLocation=u,n.searchLocation=u.label||null;return}else typeof t=="string"&&await e.autocompleteRequest(t)}return(t,l)=>(y(),k(le,z({"no-filter":"",density:d.displayCompact?"compact":"default",modelValue:o(n).searchLocation,"onUpdate:modelValue":l[1]||(l[1]=u=>o(n).searchLocation=u)},o(p),{items:o(e).autocompleteLocationList,loading:o(e).loadingLocation,"bg-color":o(a)?"transparent":"white",class:[{"w-50":o(a)},"location-field"],label:t.$t("heroSection.searchPlaceholder2"),placeholder:t.$t("heroSection.searchPlaceholder2"),"no-data-text":t.$t("heroSection.noAddressFound"),"hide-no-data":!s.value,variant:"solo","prepend-inner-icon":d.displayIcon?"mdi-map-marker-radius-outline":"",flat:"","hide-details":"",clearable:"","single-line":"","item-title":"label","item-value":"value","return-object":"","auto-select-first":!0,autocomplete:"none","onUpdate:search":c,"onUpdate:modelValue":l[2]||(l[2]=u=>c(u))}),{"append-inner":v(()=>[o(m).loading||o(e).loadingLocation?(y(),k(D,{key:0,icon:"",size:"small",variant:"text",loading:o(m).loading||o(e).loadingLocation},null,8,["loading"])):P("",!0)]),append:v(()=>[g(ie,{text:"Utiliser ma localisation",location:"bottom"},{activator:v(({props:u})=>[g(D,z(u,{class:"z-100 mr-2",size:"small",icon:"mdi-crosshairs",variant:"text",onClick:l[0]||(l[0]=ne(()=>{o(m).loading=!0,o(e).selectedLocation=null,o(m).askGeolocation()},["prevent","stop"]))}),null,16)]),_:1})]),_:1},16,["density","modelValue","items","loading","bg-color","class","label","placeholder","no-data-text","hide-no-data","prepend-inner-icon"]))}});const X=Z(Le,[["__scopeId","data-v-0b1c2b09"]]);re();const Se=async d=>d?d.toLowerCase().normalize("NFD").replace(/\p{Diacritic}/gu,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-"):"",be={key:1,class:"d-flex flex-column align-stretch w-100 ga-4 mb-8"},we=x({__name:"MainSearchBar",setup(d){const p=C([]),a=O(),{smAndUp:n,mdAndUp:m}=N(),e=I(),s=E(),i=T(),c=G();U(()=>a.fullPath,async(r,L)=>{p.value=[];const M=a.params.disicplineSlug??"",F=a.params.city??"",S=a.query.lon??"",f=a.query.lat??"",b=a.query.address??"";if(a.params.city){await i.autocompleteRequest(a.params.city);const _=await c.getFormatedAddressFromPlace(i.autocompleteLocationList[0].value);i.selectedLocation={...i.selectedLocation,label:_.addressLine,value:_},console.log("autocompleteLocationStore.selectedLocation",i.selectedLocation),s.updateStoredLocation({..._,coords:{latitude:Number(_.latitude),longitude:Number(_.longitude)}}),S&&f&&(s.storedLocation={...s.storedLocation,coords:{latitude:_.latitude,longitude:_.longitude}})}else S&&f&&(s.storedLocation={...s.storedLocation,coords:{latitude:f,longitude:S}});b&&(s.storedLocation={...s.storedLocation,address:b}),e.searchService||(e.searchService=M),e.searchLocation||(e.searchLocation=F||null),await e.findYourPractitioner(),e.isInitializing=!1},{immediate:!0});const t=w(()=>s.getLat()),l=w(()=>s.getLon()),u=w(()=>parseFloat(i.selectedLocation.value.latitude)),R=w(()=>parseFloat(i.selectedLocation.value.longitude)),h=async()=>{let r=t.value,L=l.value;if(!["SearchPage","DisciplineSearchPage"].includes(q.currentRoute.value.name)){if(!e.searchLocation&&!e.searchService){await q.push({name:"SearchPage"});return}if(e.searchLocation&&!e.searchService){let f={lat:s.getLat(),lon:s.getLon()};s.storedLocationIsEmpty||(f.address=s.storedLocation.city),await q.push({name:"SearchPage",query:f});return}if(!e.searchLocation&&e.searchService){await q.push({name:"DisciplineSearchPage"});return}}const M=e.searchService,F=await Se(M);let S="";i.selectedLocation&&i.hasCityProp&&(S=i.selectedLocation.value.city,r=u.value,L=R.value,s.updateStoredLocation({city:i.selectedLocation.value.city,coords:{latitude:r,longitude:L}})),e.searchLocation&&!S&&(S=e.searchLocation);try{let f="";F&&S?f=`/${encodeURIComponent(F)}/${encodeURIComponent(S.toLowerCase())}`:F&&!e.searchLocation&&(f=`/${encodeURIComponent(F)}`);const b={};r&&e.searchLocation&&(b.lat=r),L&&e.searchLocation&&(b.lon=L),e.searchLocation&&(b.address=e.searchLocation),await q.push({path:f,query:b})}catch(f){console.error("Error",f)}},A=w(()=>["SearchPage","DisciplineCitySearchPage","DisciplineSearchPage"].includes(a.name)&&e.loadingFind),V=r=>r&&typeof r=="string"?r.charAt(0).toUpperCase()+r.slice(1):"",$=async()=>{let r=!1;typeof a.params.disciplineSlug=="string"&&(e.searchService=V(a.params.disciplineSlug),r=!0);const L=E();return L.storedLocationIsEmpty||(e.searchLocation=L.storedLocation.city),typeof a.params.city=="string"&&(e.searchLocation=V(a.params.city),r=!0),a.query.lat&&(e.latitude=Number(a.query.lat),r=!0),a.query.lon&&(e.longitude=Number(a.query.lon),r=!0),a.query.address&&(e.searchLocation=V(a.query.address),r=!0),r};return ue(async()=>{await $()}),(r,L)=>(y(),B(j,null,[o(n)?(y(),k(fe,{key:0,class:"px-6"},{default:v(()=>[g(ge,{justify:o(a).name==="Home"?"start":"center"},{default:v(()=>[g(de,{color:"white",width:"100%",height:"50px",rounded:"xl",class:"px-2 d-flex align-center justify-center mb-lg-10",style:pe({maxWidth:o(a).name==="Home"?"900px":"100%"})},{default:v(()=>[g(Q,{onKeydown:H(h,["enter"])}),g(me,{thickness:"2",vertical:"",inset:"",class:"mx-2"}),g(X,{onKeydown:H(h,["enter"])}),g(D,{color:"blue","append-icon":"mdi-chevron-right",icon:!o(m),size:o(m)?"default":38,loading:A.value,onClick:h},{default:v(()=>[o(m)?(y(),B(j,{key:0},[W(J(r.$t("searchPage.searchButton")),1)],64)):P("",!0),o(m)?P("",!0):(y(),k(he,{key:1,icon:"mdi-chevron-right"}))]),_:1},8,["icon","size","loading"])]),_:1},8,["style"])]),_:1},8,["justify"])]),_:1})):P("",!0),o(n)?P("",!0):(y(),B("div",be,[g(Q),g(X),g(D,{style:{height:"48px","font-size":"18px","letter-spacing":"normal"},color:"blue-darken-1",class:"mt-1","append-icon":"mdi-chevron-right",loading:A.value,onClick:h},{default:v(()=>[W(J(r.$t("searchPage.searchButton")),1)]),_:1},8,["loading"])]))],64))}});export{we as _}; //# sourceMappingURL=MainSearchBar.vue_vue_type_script_setup_true_lang-46a87960.js.map