import{j as x,cs as Z,x as I,ci as K,S as k,k as C,l as V,p as b,a2 as N,t as v,w,A as n,q,D as $,F as U,ao as R,at as ae,aU as oe,bd as ie,aq as O,_ as Y,aP as G,M as ne,aD as H,ct as se,cg as j,b0 as T,o as ee,Y as le,aY as ce,ak as re,aE as z,L as ue,bh as de,a1 as pe,cu as W,$ as he,C as J,a4 as me,b5 as fe,bg as ge,H as ye,g as E}from"./dashboard-practitioner-b373edf1.js";(function(){try{var u=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},a=new Error().stack;a&&(u._sentryDebugIds=u._sentryDebugIds||{},u._sentryDebugIds[a]="16c62ee9-1430-4477-96f6-19c86e44c1e3",u._sentryDebugIdIdentifier="sentry-dbid-16c62ee9-1430-4477-96f6-19c86e44c1e3")}catch{}})();const ve=x({__name:"ServicesField",setup(u){const a=Z(),{smAndUp:g}=I(),s=K(),e=i=>{i&&s.autocompleteSearchServices(s.searchService)};k(()=>s.searchService,i=>{s.alreadySearchWithSelectedCity=!1});function l(i){s.searchService=i.id}const o=C(!1),r=V(()=>s.listAutocompleteService.length===0);return k(()=>s.searchLocation,(i,d)=>{!!i&&r.value?o.value=!0:r.value&&(o.value=!1)}),k(()=>s.listAutocompleteService,(i,d)=>{0<s.listAutocompleteService.length&&(o.value=!0)}),(i,d)=>(b(),N(O,null,[v(ae,R({id:"search-service-field"},n(a),{modelValue:n(s).searchService,"onUpdate:modelValue":[d[0]||(d[0]=p=>n(s).searchService=p),n(s).autocompleteSearchServices],"bg-color":n(g)?"transparent":"white",class:[{"w-50":n(g)},"search-field"],label:i.$t("heroSection.searchPlaceholder1"),placeholder:i.$t("heroSection.searchPlaceholder1"),clearable:"",flat:"","hide-details":"","prepend-inner-icon":"mdi-magnify","single-line":"",variant:"solo",autocomplete:"off","onUpdate:focused":e}),{"append-inner":w(()=>[n(s).loadingServices?(b(),q($,{key:0,icon:"",size:"small",variant:"text",loading:n(s).loadingServices},null,8,["loading"])):U("",!0)]),_:1},16,["modelValue","bg-color","class","label","placeholder","onUpdate:modelValue"]),v(ie,{modelValue:o.value,"onUpdate:modelValue":d[1]||(d[1]=p=>o.value=p),activator:"#search-service-field","max-height":"300px"},{default:w(()=>[0<n(s).listAutocompleteService.length?(b(),q(oe,{key:0,items:n(s).listAutocompleteService,"onClick:select":l,slim:"",density:"compact"},null,8,["items"])):U("",!0)]),_:1},8,["modelValue"])],64))}});const Q=Y(ve,[["__scopeId","data-v-bfc5e379"]]),Le=G(),te=ne("autocomplete-location",()=>{const u=C([]),a=C(!1),g=C(null),s=V(()=>Object.prototype.hasOwnProperty.call(g.value,"value")&&Object.prototype.hasOwnProperty.call(g.value,"label")&&Object.prototype.hasOwnProperty.call(g.value.value,"city")&&g.value.value.city),e=(r,{layers:i,country:d}={})=>{const p=j(),L={text:r};return d&&(L["boundary.country"]=d),i&&(L.layers=i),p.storedLocationIsEmpty||(L["focus.point.lat"]=p.getLat(),L["focus.point.lon"]=p.getLon()),L},l=H(async r=>{if(!r){a.value=!1;return}try{const i=await Le.getAutocompleteSuggestionsPlaces(r,[]);u.value=i}catch(i){throw new Error(`Error fetching data: ${i}`)}finally{a.value=!1}},200),o=H(async(r,{layers:i,country:d}={})=>{if(!r)return[];a.value=!0;try{const p=await se(e(r,{layers:i,country:d})),{data:L}=p,D=L.features.map(f=>{var t,h,m,c;return{label:f.properties.label,value:{label:f.properties.label,country:f.properties.country,addressLine:f.properties.name,postalCode:f.properties.postalcode,city:f.properties.locality,latitude:(h=(t=f.geometry)==null?void 0:t.coordinates[1])==null?void 0:h.toString(),longitude:(c=(m=f.geometry)==null?void 0:m.coordinates[0])==null?void 0:c.toString()}}});u.value=D}catch(p){console.error(`Error fetching data: ${p}`)}finally{a.value=!1}},100);return{autocompleteLocationList:u,loadingLocation:a,selectedLocation:g,hasCityProp:s,autocompleteLocationRequest:o,autocompleteRequest:l}}),Se=x({__name:"LocationField",props:{displayIcon:{type:Boolean,default:!0},displayCompact:{type:Boolean,default:!1}},setup(u,{expose:a}){const g=Z(),{smAndUp:s}=I(),e=K(),l=j(),o=te(),r=C(!1);T();const i=C(null);C(1),k(()=>e.locationKey,async()=>{await z()});const d=async()=>{i.value=e.searchLocation,e.locationKey++,await z()};k(()=>i.value,t=>{t||(e.searchLocation=null)}),k(()=>e.searchLocation,(t,h)=>{z(()=>{p(),e.searchLocation&&0<o.autocompleteLocationList.length&&(r.value=!0),o.autocompleteLocationList.length===0&&(r.value=!1),e.alreadySearchWithSelectedCity=!1})}),k(()=>o.autocompleteLocationList,t=>{t.length>0&&(r.value=!0)});const p=()=>{(o.autocompleteLocationList.length===0||!e.searchLocation)&&(r.value=!1)},L=async()=>{l.loading=!0,o.selectedLocation=null,await l.askGeolocation(),d()};async function D(t){if(t&&typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"value")&&t.value==="__MY_POSITION__"){await L();return}const h=G();if(typeof t=="string"&&t.length>0&&(e.searchLocation=t,o.selectedLocation=null),t?r.value=!0:r.value=!1,!t)o.autocompleteLocationList=[];else if(typeof t=="object"&&Object.prototype.hasOwnProperty.call(t,"value")){t=t,t.value=await h.getFormatedAddressFromPlace(t.value);const m=t;l.updateStoredLocation({...m.value,coords:{latitude:Number(m.value.latitude),longitude:Number(m.value.longitude)}}),o.selectedLocation=m,e.searchLocation=m.label||null;return}else typeof t=="string"&&await o.autocompleteRequest(t)}const f=V(()=>{const t=o.autocompleteLocationList;return[{label:"Utiliser ma localisation",value:"__MY_POSITION__"},...t]});return ee(()=>{i.value=e.searchLocation}),a({renderingLocationField:d}),(t,h)=>(b(),q(re,R({key:`location-field-${n(e).locationKey}`,"no-filter":"",density:u.displayCompact?"compact":"default",modelValue:i.value,"onUpdate:modelValue":h[1]||(h[1]=m=>i.value=m)},n(g),{items:f.value,loading:n(o).loadingLocation,"bg-color":n(s)?"transparent":"white",class:[n(s)?"w-50":"bg-white rounded-pill","location-field"],label:t.$t("heroSection.searchPlaceholder2"),placeholder:t.$t("heroSection.searchPlaceholder2"),"no-data-text":t.$t("heroSection.noAddressFound"),"hide-no-data":!r.value,variant:"solo","prepend-inner-icon":u.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":D,"onUpdate:modelValue":h[2]||(h[2]=m=>D(m))}),{"append-inner":w(()=>[n(l).loading||n(o).loadingLocation?(b(),q($,{key:0,icon:"",size:"small",variant:"text",loading:n(l).loading||n(o).loadingLocation},null,8,["loading"])):U("",!0)]),append:w(()=>[v(ce,{text:"Utiliser ma localisation",location:"bottom"},{activator:w(({props:m})=>[v($,R(m,{class:"z-100 mr-2",size:"small",icon:"mdi-crosshairs",variant:"text",onClick:h[0]||(h[0]=le(()=>L(),["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=Y(Se,[["__scopeId","data-v-5fd44846"]]);ue();const _e=async u=>u?u.toLowerCase().normalize("NFD").replace(/\p{Diacritic}/gu,"").trim().replace(/\s+/g,"-").replace(/-+/g,"-"):"",be={key:0},we={key:1,class:"d-flex flex-column align-stretch w-100 ga-4 mb-8"},Pe=x({__name:"MainSearchBar",setup(u){const a=T(),{smAndUp:g,mdAndUp:s}=I(),e=K(),l=j(),o=te(),r=G(),i=C(null);k(()=>a.fullPath,async(c,P)=>{e.isInitializing=!0,e.listPractitioners=[];const M=a.params.disciplineSlug??"",S=a.params.city??"",_=a.query.lon??"",y=a.query.lat??"",A=a.query.address??"";if(S)if(S&&M&&!(_||y)){const{status:F,data:B}=await e.getAddrByCityAndDiscipline(S,M);F===200&&(l.updateStoredLocation({city:B.city,addressLine:S,country:B.countrySlug,coords:{latitude:Number(B.latitude),longitude:Number(B.longitude)}}),e.searchLocation=B.city)}else{await o.autocompleteRequest(a.params.city);const F=await r.getFormatedAddressFromPlace(o.autocompleteLocationList[0].value);o.selectedLocation={...o.selectedLocation,label:F.addressLine,value:F},l.updateStoredLocation({...F,coords:{latitude:Number(F.latitude),longitude:Number(F.longitude)}}),_&&y&&(l.storedLocation={...l.storedLocation,coords:{latitude:F.latitude,longitude:F.longitude}})}else _&&y&&(l.storedLocation={...l.storedLocation,coords:{latitude:y,longitude:_}});A&&(l.storedLocation={...l.storedLocation,address:A}),e.searchService||(e.searchService=M),e.searchLocation||(e.searchLocation=S||null),await e.findYourPractitioner(),e.isInitializing=!1,i.value.renderingLocationField()},{immediate:!0});const d=V(()=>l.getLat()),p=V(()=>l.getLon()),L=V(()=>parseFloat(o.selectedLocation.value.latitude)),D=V(()=>parseFloat(o.selectedLocation.value.longitude)),f=async()=>{let c=d.value,P=p.value;const M=e.searchService,S=await _e(M);if(!["SearchPage","DisciplineSearchPage"].includes(E.currentRoute.value.name)){if(!e.searchLocation&&!e.searchService){await E.push({name:"SearchPage"});return}if(e.searchLocation&&!e.searchService){let y={lat:l.getLat(),lon:l.getLon()};l.storedLocationIsEmpty||(y.address=l.storedLocation.city),await E.push({name:"SearchPage",query:y});return}if(!e.searchLocation&&e.searchService){await E.push({name:"DisciplineSearchPage",params:{disciplineSlug:S}});return}}let _="";o.selectedLocation&&o.hasCityProp&&(_=o.selectedLocation.value.city,c=L.value,P=D.value,l.updateStoredLocation({city:o.selectedLocation.value.city,coords:{latitude:c,longitude:P}})),e.searchLocation&&!_&&(_=e.searchLocation);try{let y="";S&&_?y=`/${encodeURIComponent(S)}/${encodeURIComponent(_.toLowerCase())}`:S&&!e.searchLocation&&(y=`/${encodeURIComponent(S)}`);const A={};c&&e.searchLocation&&(A.lat=c),P&&e.searchLocation&&(A.lon=P),e.searchLocation&&(A.address=e.searchLocation),await E.push({path:y,query:A})}catch(y){console.error("Error",y)}},t=V(()=>["SearchPage","DisciplineCitySearchPage","DisciplineSearchPage"].includes(a.name)&&e.loadingFind),h=c=>c&&typeof c=="string"?c.charAt(0).toUpperCase()+c.slice(1):"",m=async()=>{let c=!1;typeof a.params.disciplineSlug=="string"&&(e.searchService=h(a.params.disciplineSlug),c=!0);const P=j();return P.storedLocationIsEmpty||(e.searchLocation=P.storedLocation.city),typeof a.params.city=="string"&&(e.searchLocation=h(a.params.city),c=!0),a.query.lat&&(e.latitude=Number(a.query.lat),c=!0),a.query.lon&&(e.longitude=Number(a.query.lon),c=!0),a.query.address&&(e.searchLocation=h(a.query.address),c=!0),c};return ee(async()=>{await m()}),(c,P)=>(b(),N(O,null,[n(g)?(b(),q(ge,{key:0,class:""},{default:w(()=>[v(fe,{justify:n(a).name==="Home"?"start":"center"},{default:w(()=>[v(de,{color:"white",width:"100%",height:"44px",rounded:"xl",class:"d-flex align-center justify-center px-1",style:pe({maxWidth:n(a).name==="Home"?"900px":"100%"})},{default:w(()=>[v(Q,{onKeydown:W(f,["enter"])}),v(he,{thickness:"2",vertical:"",inset:"",class:"mx-2"}),v(X,{onKeydown:W(f,["enter"]),ref_key:"theLocationField",ref:i},null,512),v($,{class:"px-2 d-flex justify-center align-center",color:"#1A73E9","append-icon":"mdi-chevron-right",icon:!n(s),size:n(s)?"default":38,loading:t.value,onClick:f},{default:w(()=>[n(s)?(b(),N("span",be,J(c.$t("searchPage.searchButton")),1)):U("",!0),n(s)?U("",!0):(b(),q(me,{key:1,icon:"mdi-chevron-right"}))]),_:1},8,["icon","size","loading"])]),_:1},8,["style"])]),_:1},8,["justify"])]),_:1})):U("",!0),n(g)?U("",!0):(b(),N("div",we,[v(Q),v(X,{ref_key:"theLocationField",ref:i},null,512),v($,{style:{height:"48px","font-size":"18px","letter-spacing":"normal"},color:"blue-darken-1",class:"mt-1","append-icon":"mdi-chevron-right",loading:t.value,onClick:f},{default:w(()=>[ye(J(c.$t("searchPage.searchButton")),1)]),_:1},8,["loading"])]))],64))}});const Ve=Y(Pe,[["__scopeId","data-v-18d79909"]]);export{Ve as M,te as u}; //# sourceMappingURL=MainSearchBar-171da578.js.map