1import{N as A,r as l,y as V,b as c,D as K,F as z,_ as j,j as e,aC as W,ar as G,B as d,A as J,L as E,C as X,e as I,P as F,aU as Z,a0 as ee,m as se,aV as te,aD as ae,x as le}from"./index-CZ54c6IG.js";import{P as N,N as v}from"./leaflet-za-qDonq.js";import{M as ne,T as ie,a as w,L as h}from"./TileLayer-DhztnSnI.js";import{a as oe}from"./hooks-DXm5Q3JS.js";/** 2 * @license lucide-react v0.475.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const re=[["line",{x1:"2",x2:"5",y1:"12",y2:"12",key:"bvdh0s"}],["line",{x1:"19",x2:"22",y1:"12",y2:"12",key:"1tbv5k"}],["line",{x1:"12",x2:"12",y1:"2",y2:"5",key:"11lu5j"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}],["circle",{cx:"12",cy:"12",r:"7",key:"fim9np"}]],U=A("Locate",re);/** 7 * @license lucide-react v0.475.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const ce=[["path",{d:"M8.34 8.34 2 9.27l5 4.87L5.82 21 12 17.77 18.18 21l-.59-3.43",ke
11y:"16m0ql"}],["path",{d:"M18.42 12.76 22 9.27l-6.91-1L12 2l-1.44 2.91",key:"1vt8nq"}],["line",{x1:"2",x2:"22",y1:"2",y2:"22",key:"a6p6uj"}]],de=A("StarOff",ce);delete h.Icon.Default.prototype._getIconUrl;h.Icon.Default.mergeOptions({iconRetinaUrl:"https://unpkg.com/[email protected]/dist/images/marker-icon-2x.png",iconUrl:"https://unpkg.com/[email protected]/dist/images/marker-icon.png",shadowUrl:"https://unpkg.com/[email protected]/dist/images/marker-shadow.png"});const q=t=>h.divIcon({className:"",html:`<div style="background:${t};width:28px;height:28px;border-radius:50% 50% 50% 0;transform:rotate(-45deg);border:3px solid white;box-shadow:0 2px 8px rgba(0,0,0,0.3)"></div>`,iconSize:[28,28],iconAnchor:[14,28],popupAnchor:[0,-30]}),xe=h.divIcon({className:"",html:'<div style="background:#6366f1;width:20px;height:20px;border-radius:50%;border:3px solid white;box-shadow:0 0 0 4px rgba(99,102,241,0.3)"></div>',iconSize:[20,20],iconAnchor:[10,10]}),me=[{key:"mental_health",label:"Mental Health",color:"#6366f1",query:"mental health clinic"},{key:"hospital",label:"Hospital",color:"#ef4444",query:"hospital emergency"},{key:"support",label:"Support Center",color:"#10b981",query:"community mental health support center"}];function he({coords:t}){const x=oe();return l.useEffect(()=>{t&&x.setView(t,13)},[t,x]),null}function fe(){const[t,x]=l.useState(null),[i,D]=l.useState(null),[k,C]=l.useState(null),[p,u]=l.useState(!1),[L,$]=l.useState([]),[H,_]=l.useState(!1),[o,S]=l.useState("all"),M=V();l.useEffect(()=>{c.auth.me().then(x).catch(()=>{}),g()},[]);const{data:r=[]}=K({queryKey:["savedLocations",t==null?void 0:t.email],queryFn:()=>c.entities.CrisisLocation.filter({user_email:t.email}),enabled:!!(t!=null&&t.email)}),R=z({mutationFn:s=>c.entities.CrisisLocation.create({user_email:t.email,location_name:s.name,location_type:s.type,address:s.address,phone:s.phone||"",latitude:s.lat,longitude:s.lng,is_safe_location:!0}),onSuccess:()=>{M.invalidateQueries(["savedLocations",t==null?void 0:t.email]),j.success("Location saved to your safe places")}}),B=z({mutationFn:s=>c.entities.CrisisLocation.delete(s),onSuccess:()=>M.invalidateQueries(["savedLocations",t==null?void 0:t.email])}),g=()=>{u(!0),C(null),navigator.geolocation.getCurrentPosition(s=>{const a=[s.coords.latitude,s.coords.longitude];D(a),u(!1),O(s.coords.latitude,s.coords.longitude)},()=>{C("Could not access your location. Please enable location services."),u(!1)},{timeout:1e4})},O=async(s,a)=>{_(!0);try{const n=await c.integrations.Core.InvokeLLM({prompt:`Find 12 real mental health clinics, hospitals, and support centers near coordinates (${s}, ${a}). 12 Return a mix of mental health clinics, hospitals with psychiatric services, and community support centers. 13 For each, provide realistic address data for this geographic area.`,response_json_schema:{type:"object",properties:{places:{type:"array",items:{type:"object",properties:{name:{type:"string"},type:{type:"string",enum:["mental_health","hospital","support"]},address:{type:"string"},phone:{type:"string"},hours:{type:"string"},distance_km:{type:"number"},lat:{type:"number"},lng:{type:"number"},description:{type:"string"}}}}}}});$(n.places||[])}catch{j.error("Could not load nearby places")}finally{_(!1)}},b=s=>{const a=`https://www.google.com/maps/dir/?api=1&destination=${encodeURIComponent(s.address)}`;window.open(a,"_blank")},f=s=>r.some(a=>a.location_name===s.name),Q=s=>{var a;return(a=r.find(n=>n.location_name===s.name))==null?void 0:a.id},P=s=>{f(s)?(B.mutate(Q(s)),j.success("Removed from safe places")):R.mutate(s)},y=o==="all"?L:L.filter(s=>s.type===o),m={mental_health:{color:"#6366f1",label:"Mental Health"},hospital:{color:"#ef4444",label:"Hospital"},support:{color:"#10b981",label:"Support"}},T=i||[43.6532,-79.3832];return e.jsxs("div",{className:"min-h-screen bg-slate-50",children:[e.jsxs("div",{className:"bg-white border-b border-slate-200 px-4 py-4 flex items-center gap-4 sticky top-0 z-[1000]",children:[e.jsx(W,{to:G("Home"),children:e.jsx(d,{variant:"ghost",size:"icon",className:"rounded-xl",children:e.jsx(J,{className:"w-5 h-5"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-xl font-bold text-slate-800",children:"Nearby Support"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Mental health clinics & emergency services"})]}),e.jsxs(d,{variant:"outline",size:"sm",className:"rounded-xl gap-1.5",onClick:g,disabled:p,children:[p?e.jsx(E,{className:"w-4 h-4 animate-spin"}):e.jsx(U,{className:"w-4 h-4"}),p?"Locating...":"My Location"]})]}),e.jsxs("div",{className:"flex flex-col lg:flex-row h-[calc(100vh-65px)]",children:[e.jsxs("div",{className:"relative flex-1 min-h-[300px] lg:min-h-0",children:[k&&e.jsxs("div",{className:"absolute top-4 left-4 right-4 z-[500] bg-amber-50 border border-amber-200 rounded-xl p-3 flex items-start gap-2",children:[e.jsx(X,{className:"w-4 h-4 text-amber-600 flex-shrink-0 mt-0.5"}),e.jsx("p",{className:"text-sm text-amber-700",children:k})]}),e.jsxs(ne,{center:T,zoom:13,style:{height:"100%",width:"100%"},zoomControl:!1,children:[e.jsx(ie,{url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",attribution:"© OpenStreetMap"}),e.jsx(he,{coords:i}),i&&e.jsx(w,{position:i,icon:xe,children:e.jsx(N,{children:e.jsx("strong",{children:"You are here"})})}),y.map((s,a)=>{const n=m[s.type]||m.mental_health;return e.jsx(w,{position:[s.lat,s.lng],icon:q(n.color),children:e.jsx(N,{maxWidth:240,children:e.jsxs("div",{className:"p-1",children:[e.jsx("p",{className:"font-semibold text-slate-800 mb-1",children:s.name}),e.jsx("p",{className:"text-xs text-slate-500 mb-2",children:s.address}),s.phone&&e.jsxs("p",{className:"text-xs text-indigo-600 mb-2",children:["ð ",s.phone]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:()=>b(s),className:"flex-1 text-xs bg-indigo-600 text-white rounded-lg px-2 py-1.5 flex items-center justify-center gap-1",children:[e.jsx(v,{className:"w-3 h-3"})," Directions"]}),e.jsx("button",{onClick:()=>P(s),className:"text-xs border border-slate-200 rounded-lg px-2 py-1.5",children:f(s)?"â ":"â"})]})]})})},a)}),r.map((s,a)=>e.jsx(w,{position:[s.latitude,s.longitude],icon:q("#f59e0b"),children:e.jsxs(N,{children:[e.jsx("p",{className:"font-semibold",children:s.location_name}),e.jsx("p",{className:"text-xs text-amber-600",children:"â Saved safe place"})]})},`saved-${a}`))]})]}),e.jsxs("div",{className:"w-full lg:w-96 bg-white border-t lg:border-t-0 lg:border-l border-slate-200 flex flex-col overflow-hidden",children:[e.jsx("div",{className:"p-4 border-b border-slate-100",children:e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx("button",{onClick:()=>S("all"),className:I("px-3 py-1.5 rounded-full text-xs font-medium transition-all",o==="all"?"bg-slate-800 text-white":"bg-slate-100 text-slate-600"),children:"All"}),me.map(s=>e.jsx("button",{onClick:()=>S(s.key),className:I("px-3 py-1.5 rounded-full text-xs font-medium transition-all",o===s.key?"text-white":"bg-slate-100 text-slate-600"),style:o===s.key?{background:s.
13color}:{},children:s.label},s.key))]})}),e.jsxs("div",{className:"p-4 bg-red-50 border-b border-red-100",children:[e.jsx("p",{className:"text-xs font-semibold text-red-600 mb-2 uppercase tracking-wide",children:"Emergency"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("a",{href:"tel:911",className:"flex items-center gap-2 bg-red-600 text-white rounded-xl px-3 py-2 text-sm font-semibold",children:[e.jsx(F,{className:"w-4 h-4"})," 911"]}),e.jsxs("a",{href:"tel:988",className:"flex items-center gap-2 bg-indigo-600 text-white rounded-xl px-3 py-2 text-sm font-semibold",children:[e.jsx(Z,{className:"w-4 h-4"})," 988"]})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-4 space-y-3",children:[H?e.jsxs("div",{className:"flex flex-col items-center justify-center py-12 gap-3",children:[e.jsx(E,{className:"w-8 h-8 animate-spin text-indigo-500"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Finding nearby support..."})]}):i?y.length===0?e.jsx("p",{className:"text-sm text-slate-400 text-center py-8",children:"No places found nearby"}):y.map((s,a)=>{const n=m[s.type]||m.mental_health,Y=f(s);return e.jsxs(se.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:a*.04},className:"bg-slate-50 rounded-2xl p-4 border border-slate-100",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-xl flex items-center justify-center flex-shrink-0",style:{background:n.color+"20"},children:e.jsx(te,{className:"w-4 h-4",style:{color:n.color}})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("p",{className:"font-semibold text-slate-800 text-sm leading-tight",children:s.name}),e.jsx("button",{onClick:()=>P(s),className:"flex-shrink-0 text-amber-400",children:Y?e.jsx(ae,{className:"w-4 h-4 fill-amber-400"}):e.jsx(de,{className:"w-4 h-4 text-slate-300"})})]}),e.jsx("p",{className:"text-xs text-slate-500 mt-0.5",children:s.address}),s.hours&&e.jsx("p",{className:"text-xs text-slate-400 mt-0.5",children:s.hours}),s.distance_km&&e.jsxs(le,{variant:"outline",className:"mt-1.5 text-[10px] py-0",children:[s.distance_km.toFixed(1)," km away"]})]})]}),e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsxs(d,{size:"sm",className:"flex-1 h-8 text-xs rounded-xl gap-1",onClick:()=>b(s),children:[e.jsx(v,{className:"w-3 h-3"})," Directions"]}),s.phone&&e.jsx(d,{asChild:!0,size:"sm",variant:"outline",className:"h-8 text-xs rounded-xl gap-1",children:e.jsxs("a",{href:`tel:${s.phone}`,children:[e.jsx(F,{className:"w-3 h-3"})," Call"]})})]})]},a)}):e.jsxs("div",{className:"text-center py-12",children:[e.jsx(ee,{className:"w-10 h-10 text-slate-300 mx-auto mb-3"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Enable location to find nearby services"}),e.jsxs(d,{size:"sm",className:"mt-3 rounded-xl",onClick:g,children:[e.jsx(U,{className:"w-4 h-4 mr-1.5"})," Enable Location"]})]}),r.length>0&&e.jsxs("div",{className:"mt-4",children:[e.jsx("p",{className:"text-xs font-semibold text-slate-500 uppercase tracking-wide mb-2",children:"â Your Saved Safe Places"}),r.map((s,a)=>e.jsxs("div",{className:"bg-amber-50 border border-amber-100 rounded-xl p-3 mb-2 flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-800",children:s.location_name}),e.jsx("p",{className:"text-xs text-slate-500",children:s.address})]}),e.jsx("button",{onClick:()=>b(s),className:"text-indigo-600",children:e.jsx(v,{className:"w-4 h-4"})})]},a))]})]})]})]})]})}export{fe as default};
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.