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