1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6334],{82431:(e,t,a)=>{a.d(t,{p:()=>f});var r=a(95155),s=a(12115),l=a(68854),o=a(17910),n=a(20508),i=a(5937),c=a(37354),d=a(97624),m=a(65229),u=a(18085),x=a(20063),h=a(3998),g=a(11647),p=a(65380),b=a(59318),y=a(97866);let f=e=>{let{className:t=""}=e,[a,f]=(0,s.useState)(!1),[w,j]=(0,s.useState)(!1),[v,N]=(0,s.useState)(!1),[k,S]=(0,s.useState)(!1),[_,A]=(0,s.useState)([]),[E,C]=(0,s.useState)(""),[I,D]=(0,s.useState)(!1),T=(0,s.useRef)(null),{user:P,hasRole:H,getCurrentToken:L}=(0,p.A)(),U=(0,x.usePathname)(),R=P?H("super_admin")?"super_admin":H("platform_admin")?"platform_admin":H("admin")?"admin":H("participant")?"participant":H("donor")?"donor":"authenticated":"public",z=!!P,W=(()=>{if(!P)return null;if(P.displayName)return P.displayName.split(" ")[0];if(P.email){let e=P.email.split("@")[0].replace(/[._-]/g," ").split(" ")[0];return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}return null})();(0,s.useEffect)(()=>{let e=()=>{S(window.innerWidth<768)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[]);let M=["What is SHELTR?","How do I donate?","Tell me about PODs","What is Basecamp?","How can I help?"],q=(0,s.useCallback)(()=>{if(!z)return"\uD83D\uDC4B Welcome to SHELTR! I can help you learn about our platform, find ways to donate, or discover how we're ending homelessness together.";let e=W?"\uD83D\uDC4B Hello ".concat(W,"!"):"\uD83D\uDC4B Hello!",t={super_admin:"".concat(e," Great to see you! I have full access to all MCP tools including analytics, system management, shelter operations, and emergency protocols. Try asking me about platform status, donation analytics, or shelter capacity!"),platform_admin:"".concat(e," Nice to see you! I can help with analytics, user management, shelter operations, and knowledge base queries. Ask me about platform metrics, user reports, or shelter management."),admin:"".concat(e," Welcome back! I can assist with participant management, capacity updates, and shelter-specific operations. Try asking about your shelter's status or participant reports."),participant:"".concat(e," I'm here to help! I can assist you with services, update your status, generate QR codes, and access support resources. How can I help you today?"),donor:"".concat(e," Welcome back! I can show you donation impact, generate receipts, and provide transparency reports. Ask me about your donation history or impact metrics!"),authenticated:"".concat(e," You're signed in, so I have access to additional features. I can help with platform information and basic account queries.")};return t[R]||t.authenticated},[z,W,R]);(0,s.useEffect)(()=>{0===_.length&&A([{id:"welcome",text:q(),isUser:!1,timestamp:new Date}])},[q,_.length]),(0,s.useEffect)(()=>{if(!z)return void localStorage.removeItem("sheltr-public-chat");let e=localStorage.getItem("sheltr-public-chat");if(e)try{let t=JSON.parse(e);A(t.map(e=>({...e,timestamp:new Date(e.timestamp)})))}catch(e){console.warn("Failed to load chat history:",e)}},[z]),(0,s.useEffect)(()=>{z&&_.length>1&&localStorage.setItem("sheltr-public-chat",JSON.stringify(_))},[_,z]),(0,s.useEffect)(()=>{(()=>{var e;null==(e=T.current)||e.scrollIntoView({behavior:"smooth"})})()},[_,I]);let O=async e=>{let t=e||E.trim();if(!t||I)return;let a={id:Date.now().toString(),text:t,isUser:!0,timestamp:new Date};A(e=>[...e,a]),C(""),D(!0);try{let e=z?"/api/v1/chatbot/authenticated":"/api/v1/chatbot/public",a="".concat("https://sheltr-api-714964620823.us-central1.run.app").concat(e);console.log("[PublicChatbot] Calling: ".concat(a));let r={message:t,user_id:z?null==P?void 0:P.uid:B(),user_role:R,conversation_context:{page:window.location.pathname,user_agent:navigator.userAgent,timestamp:new Date().toISOString(),authenticated:z,session_type:z?"authenticated":"public",anonymous:!z,...z&&{user_id:null==P?void 0:P.uid,email:null==P?void 0:P.email,first_name:W}}},s={"Content-Type":"application/json"};if(z&&P)try{let e=await L();e?(s.Authorization="Bearer ".concat(e),console.log("[PublicChatbot] Added auth token for authenticated request")):console.warn("[PublicChatbot] No auth token available")}catch(e){console.error("[PublicChatbot] Failed to get auth token:",e)}let l=await fetch(a,{method:"POST",headers:s,body:JSON.stringify(r)});if(l.ok){let e=await l.json(),t=e.response||e.message||"I'm here to help! Could you please rephrase your question?",a=e.actions||[],r={id:(Date.now()+1).toString(),text:t,isUser:!1,timestamp:new Date,actions:a,mcpToolUsed:e.mcp_tool_used,roleRestricted:e.role_restricted||!1};A(e=>[...e,r])}else throw Error("Failed to get response")}catch(t){console.error("Chat error:",t);
1let e={id:(Date.now()+1).toString(),text:"I'm having trouble connecting right now. You can always contact us directly or explore our help sections!",isUser:!1,timestamp:new Date};A(t=>[...t,e])}finally{D(!1)}},B=()=>{let e=localStorage.getItem("sheltr-chat-session");if(!e){let t=new Uint32Array(1);crypto.getRandomValues(t);let a=t[0].toString(36);e="guest_".concat(Date.now(),"_").concat(a),localStorage.setItem("sheltr-chat-session",e)}return e},F=U.startsWith("/dashboard"),V=z&&F;return((0,s.useEffect)(()=>{console.log("PublicChatbot positioning:",{isMobile:k,isAuthenticated:z,isDashboard:F,hasMobileNav:V,pathname:U,user:P?{role:P.role,email:P.email}:null})},[k,z,F,V,U,P]),a)?(0,r.jsxs)("div",{className:"fixed ".concat(k?"inset-x-4":v?"inset-0 m-auto w-[600px] h-[700px]":"bottom-6 right-6 w-96"," bg-white dark:bg-gray-900 border border-gray-200 dark:border-gray-700 rounded-lg shadow-xl z-50 flex flex-col ").concat(t),style:k?V?{bottom:"80px",maxHeight:"calc(100vh - 120px)"}:{bottom:"20px",maxHeight:"calc(100vh - 60px)"}:{},children:[(0,r.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700 bg-blue-600 text-white rounded-t-lg",children:[(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,r.jsx)("div",{className:"w-8 h-8 bg-white/20 rounded-full flex items-center justify-center",children:(()=>{let e={super_admin:(0,r.jsx)(l.A,{className:"h-4 w-4 text-yellow-500"}),platform_admin:(0,r.jsx)(o.A,{className:"h-4 w-4 text-purple-500"}),admin:(0,r.jsx)(o.A,{className:"h-4 w-4 text-blue-500"}),participant:(0,r.jsx)(n.A,{className:"h-4 w-4 text-green-500"}),donor:(0,r.jsx)(n.A,{className:"h-4 w-4 text-orange-500"}),authenticated:(0,r.jsx)(n.A,{className:"h-4 w-4 text-gray-500"}),public:(0,r.jsx)(i.A,{className:"h-4 w-4 text-gray-400"})};return e[R]||e.public})()}),(0,r.jsxs)("div",{children:[(0,r.jsx)("h3",{className:"font-semibold text-sm",children:"SHELTR AI Assistant"}),(0,r.jsxs)("div",{className:"flex items-center space-x-2",children:[(()=>{let e={super_admin:(0,r.jsx)(g.E,{className:"bg-yellow-500 text-white text-xs",children:"Super Admin"}),platform_admin:(0,r.jsx)(g.E,{className:"bg-purple-500 text-white text-xs",children:"Platform Admin"}),admin:(0,r.jsx)(g.E,{className:"bg-blue-500 text-white text-xs",children:"Shelter Admin"}),participant:(0,r.jsx)(g.E,{className:"bg-green-500 text-white text-xs",children:"Participant"}),donor:(0,r.jsx)(g.E,{className:"bg-orange-500 text-white text-xs",children:"Donor"}),authenticated:(0,r.jsx)(g.E,{className:"bg-gray-500 text-white text-xs",children:"User"}),public:(0,r.jsx)(g.E,{className:"bg-gray-400 text-white text-xs",children:"Public"})};return e[R]||e.public})(),z&&(0,r.jsx)(g.E,{className:"bg-green-500 text-white text-xs",children:"MCP"})]})]})]}),(0,r.jsxs)("div",{className:"flex items-center space-x-1",children:[!k&&(0,r.jsx)(h.$,{variant:"ghost",size:"sm",onClick:()=>N(!v),className:"text-white hover:bg-white/20 h-8 w-8 p-0",title:v?"Minimize to corner":"Expand to center",children:(0,r.jsx)("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:v?(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 9l6-6m0 0l-6 6m6-6v6m0-6H9"}):(0,r.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}),(0,r.jsx)(h.$,{variant:"ghost",size:"sm",onClick:()=>j(!w),className:"text-white hover:bg-white/20 h-8 w-8 p-0",children:w?(0,r.jsx)(c.A,{className:"h-4 w-4"}):(0,r.jsx)(d.A,{className:"h-4 w-4"})}),(0,r.jsx)(h.$,{variant:"ghost",size:"sm",onClick:()=>f(!1),className:"text-white hover:bg-white/20 h-8 w-8 p-0",children:(0,r.jsx)(m.A,{className:"h-4 w-4"})})]})]}),!w&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"flex-1 overflow-y-auto p-4 space-y-4 ".concat(v?"max-h-[550px]":"max-h-96"),children:[_.map(e=>(0,r.jsx)("div",{className:"flex ".concat(e.isUser?"justify-end":"justify-start"),children:(0,r.jsxs)("div",{className:"max-w-[80%] p-3 rounded-lg text-sm ".concat(e.isUser?"bg-blue-600 text-white":"bg-gray-100 dark:bg-gray-800 text-gray-900 dark:text-gray-100"),children:[e.isUser?(0,r.jsx)("div",{className:"mb-2",children:e.text}):(0,r.jsx)("div",{className:"prose prose-sm dark:prose-invert max-w-none mb-2",children:(0,r.jsx)(b.oz,{remarkPlugins:[y.A],components:{h1:e=>{let{node:t,...a}=e;return(0,r.jsx)("h1",{className:"text-base font-bold mt-3 mb-2 text-gray-900 dark:text-white",...a})},h2:e=>{let{node:t,...a}=e;return(0,r.jsx)("h2",{className:"text-sm font-bold mt-2 mb-1.5 text-gray-900 dark:text-white",...a})},h3:e=>{let{node:t,...a}=e;return(0,r.jsx)("h3",{className:"text-sm font-semibold mt-2 mb-1 text-gray-900 dark:text-white",...a})},p:e=>{let{node:t,...a}=e;return(0,r.jsx)("p",{className:"mb-2 last:mb-0 text-gray-900 dark:text-gray-100",...a})},ul:e=>{let{node:t,...a}=e;return(0,r.jsx)("ul",{className:"list-disc pl-4 mb-2 space-y-1 text-gray-900 dark:text-gray-100",...a})},ol:e=>{let{node:t,...a}=e;return(0,r.jsx)("ol",{className:"list-decimal pl-4 mb-2 space-y-1 text-gray-900 dark:text-gray-100",...a})},li:e=>{let{node:t,...a}=e;return(0,r.jsx)("li",{className:"text-gray-900 dark:text-gray-100",...a})},code:e=>{let{node:t,inline:a,...s}=e;return a?(0,r.jsx)("code",{className:"bg-gray-200 dark:bg-gray-700 px-1 py-0.5 rounded text-xs font-mono text-gray-900 dark:text-gray-100",...s}):(0,r.jsx)("code",{className:"block bg-gray-200 dark:bg-gray-700 p-2 rounded text-xs font-mono overflow-x-auto mb-2 text-gray-900 dark:text-gray-100",...s})},pre:e=>{let{node:t,...a}=e;return(0,r.jsx)("pre",{className:"mb-2 overflow-x-auto",...a})},a:e=>{let{node:t,...a}=e;
1return(0,r.jsx)("a",{className:"text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300 underline",target:"_blank",rel:"noopener noreferrer",...a})},strong:e=>{let{node:t,...a}=e;return(0,r.jsx)("strong",{className:"font-bold text-gray-900 dark:text-white",...a})},em:e=>{let{node:t,...a}=e;return(0,r.jsx)("em",{className:"italic text-gray-900 dark:text-gray-100",...a})},blockquote:e=>{let{node:t,...a}=e;return(0,r.jsx)("blockquote",{className:"border-l-4 border-blue-600 pl-3 italic my-2 text-gray-700 dark:text-gray-300",...a})},hr:e=>{let{node:t,...a}=e;return(0,r.jsx)("hr",{className:"my-3 border-gray-300 dark:border-gray-600",...a})},table:e=>{let{node:t,...a}=e;return(0,r.jsx)("div",{className:"overflow-x-auto mb-2",children:(0,r.jsx)("table",{className:"min-w-full divide-y divide-gray-300 dark:divide-gray-600",...a})})},thead:e=>{let{node:t,...a}=e;return(0,r.jsx)("thead",{className:"bg-gray-50 dark:bg-gray-800",...a})},tbody:e=>{let{node:t,...a}=e;return(0,r.jsx)("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700",...a})},tr:e=>{let{node:t,...a}=e;return(0,r.jsx)("tr",{...a})},th:e=>{let{node:t,...a}=e;return(0,r.jsx)("th",{className:"px-3 py-2 text-left text-xs font-medium text-gray-700 dark:text-gray-300",...a})},td:e=>{let{node:t,...a}=e;return(0,r.jsx)("td",{className:"px-3 py-2 text-xs text-gray-900 dark:text-gray-100",...a})}},children:e.text})}),e.mcpToolUsed&&(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsxs)(g.E,{className:"bg-green-500 text-white text-xs",children:["MCP: ",e.mcpToolUsed]})}),e.roleRestricted&&(0,r.jsx)("div",{className:"mt-2",children:(0,r.jsx)(g.E,{className:"bg-red-500 text-white text-xs",children:"\uD83D\uDD12 Sign in required"})}),e.actions&&e.actions.length>0&&(0,r.jsx)("div",{className:"flex flex-wrap gap-2 mt-3",children:e.actions.map((e,t)=>{var a;let s=e.url||(null==(a=e.data)?void 0:a.url)||"#",l=e.label||e.text||"Link",o="string"==typeof s&&s.startsWith("http");return(0,r.jsx)("a",{href:s,target:o?"_blank":"_self",rel:o?"noopener noreferrer":void 0,className:"inline-flex items-center px-3 py-1.5 text-xs font-medium text-blue-600 bg-blue-50 border border-blue-200 rounded-md hover:bg-blue-100 dark:text-blue-400 dark:bg-blue-900/20 dark:border-blue-800 dark:hover:bg-blue-900/30 transition-colors",children:l},t)})}),"welcome"===e.id&&!z&&(0,r.jsx)("div",{className:"flex flex-wrap gap-2 mt-3",children:M.map((e,t)=>(0,r.jsx)("button",{onClick:()=>(e=>{C(e),setTimeout(()=>{O(e)},100)})(e),className:"inline-flex items-center px-3 py-1.5 text-xs font-medium text-blue-600 bg-blue-50 border border-blue-200 rounded-full hover:bg-blue-100 hover:border-blue-300 dark:text-blue-400 dark:bg-blue-900/20 dark:border-blue-800 dark:hover:bg-blue-900/30 transition-all duration-200 cursor-pointer",children:e},t))})]})},e.id)),I&&(0,r.jsx)("div",{className:"flex justify-start",children:(0,r.jsx)("div",{className:"bg-gray-100 dark:bg-gray-800 p-3 rounded-lg text-sm",children:(0,r.jsxs)("div",{className:"flex space-x-1",children:[(0,r.jsx)("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce"}),(0,r.jsx)("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"0.1s"}}),(0,r.jsx)("div",{className:"w-2 h-2 bg-gray-400 rounded-full animate-bounce",style:{animationDelay:"0.2s"}})]})})}),(0,r.jsx)("div",{ref:T})]}),(0,r.jsxs)("div",{className:"p-4 border-t border-gray-200 dark:border-gray-700",children:[(0,r.jsxs)("div",{className:"flex space-x-2",children:[(0,r.jsx)("input",{type:"text",value:E,onChange:e=>C(e.target.value),onKeyPress:e=>"Enter"===e.key&&O(),placeholder:z?"super_admin"===R||"platform_admin"===R?"Try: 'Show me platform analytics'":"Ask me anything about SHELTR...":"Ask about SHELTR, donations, or getting help...",className:"flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-800 dark:text-white",disabled:I}),(0,r.jsx)(h.$,{onClick:O,disabled:!E.trim()||I,size:"sm",className:"bg-blue-600 hover:bg-blue-700 px-3",children:(0,r.jsx)(u.A,{className:"h-4 w-4"})})]}),(0,r.jsxs)("div",{className:"flex justify-between items-center mt-2",children:[(0,r.jsx)("p",{className:"text-xs text-gray-500",children:'â¡ For emergencie
1s, type "emergency" or call 911'}),(0,r.jsx)("button",{onClick:()=>{localStorage.removeItem("sheltr-public-chat"),A([{id:"welcome",text:q(),isUser:!1,timestamp:new Date}])},className:"text-xs text-gray-500 hover:text-gray-700 dark:hover:text-gray-300",children:"Clear chat"})]})]})]})]}):(0,r.jsxs)("button",{onClick:()=>f(!0),className:"fixed ".concat(k?V?"bottom-20 right-4":"bottom-6 right-4":"bottom-6 right-6"," bg-blue-600 hover:bg-blue-700 text-white rounded-full p-4 shadow-lg transition-all duration-200 z-40 group ").concat(t),"aria-label":"Open SHELTR AI Assistant",children:[(0,r.jsx)(i.A,{className:"h-6 w-6"}),(0,r.jsx)("div",{className:"absolute -top-2 -left-2 bg-green-500 rounded-full w-3 h-3 animate-pulse"}),(0,r.jsx)("div",{className:"absolute -top-12 right-0 bg-gray-800 text-white text-sm px-3 py-1 rounded-lg opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap",children:"SHELTR AI Assistant"})]})}},86948:(e,t,a)=>{a.d(t,{BT:()=>i,Wu:()=>c,ZB:()=>n,Zp:()=>l,aR:()=>o});var r=a(95155);a(12115);var s=a(64269);function l(e){let{className:t,...a}=e;return(0,r.jsx)("div",{"data-slot":"card",className:(0,s.cn)("bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-sm",t),...a})}function o(e){let{className:t,...a}=e;return(0,r.jsx)("div",{"data-slot":"card-header",className:(0,s.cn)("@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6",t),...a})}function n(e){let{className:t,...a}=e;return(0,r.jsx)("div",{"data-slot":"card-title",className:(0,s.cn)("leading-none font-semibold",t),...a})}function i(e){let{className:t,...a}=e;return(0,r.jsx)("div",{"data-slot":"card-description",className:(0,s.cn)("text-muted-foreground text-sm",t),...a})}function c(e){let{className:t,...a}=e;return(0,r.jsx)("div",{"data-slot":"card-content",className:(0,s.cn)("px-6",t),...a})}}}]);
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.