PageSourceSearch

https://stratamate.ai/assets/BuildingAssistant-BHhaAUOS.js

js stratamate.ai collected 2026-10-05 12:52:41 UTC 8,124 bytes, 2 lines download raw bytes

1import{a9 as a,a7 as e,w as W,T as B,a3 as T,F as A,i as R,S as $,_ as M,u as K,l as O,K as G,a6 as U}from"./index-fPjNcR6N.js";import{B as x}from"./bot-CEj6zgOL.js";const z=["Can I have a pet in my building?","What are the renovation approval rules?","What does our insurance cover?","When is the next AGM due?","What are the parking rules?","How are levies calculated?"];function P({schemeId:l,buildingName:F,apiUrl:C=""}){const[u,p]=a.useState(!1),[d,g]=a.useState([]),[o,f]=a.useState(""),[c,b]=a.useState(!1),[w,j]=a.useState(null),[h,k]=a.useState(null),y=a.useRef(null),N=a.useRef(null),v=a.useCallback(()=>{var s;(s=y.current)==null||s.scrollIntoView({behavior:"smooth"})},[]);a.useEffect(()=>{v()},[d,v]),a.useEffect(()=>{u&&setTimeout(()=>{var s;return(s=N.current)==null?void 0:s.focus()},100)},[u]);const m=async s=>{if(!s.trim()||c)return;const n={role:"user",content:s.trim()};g(t=>[...t,n]),f(""),j(null),b(!0);try{const t=d.map(i=>({role:i.role,content:i.content})),r=await U(`${C}/api/buildings/${l}/chat`,{method:"POST",body:JSON.stringify({message:s.trim(),history:t})});if(!r.ok){const i=await r.json().catch(()=>({}));throw new Error(i.detail||"Failed to get a response")}const E=await r.json(),D={role:"assistant",content:E.reply,sources:E.sources};g(i=>[...i,D])}catch(t){j(t.message||"Something went wrong. Please try again.")}finally{b(!1)}},S=s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),m(o))};return u?e.jsxs("div",{className:"fixed bottom-6 right-6 z-50 w-[380px] max-w-[calc(100vw-2rem)] h-[560px] max-h-[calc(100vh-3rem)] bg-white rounded-2xl shadow-2xl border border-[#DCE5EF] flex flex-col overflow-hidden animate-fade-in",children:[e.jsxs("div",{className:"bg-[#1E3A5F] px-4 py-3 flex items-center gap-3 shrink-0",children:[e.jsx("div",{className:"w-9 h-9 rounded-xl bg-white/15 flex items-center justify-center",children:e.jsx(x,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"text-lg font-bold text-white leading-tight",children:"Building Assistant"}),e.jsxs("p",{className:"text-sm text-white/60 truncate",children:[F||"Your building"," — powered by AI"]})]}),e.jsx("button",{onClick:()=>p(!1),className:"w-7 h-7 rounded-lg bg-white/10 hover:bg-white/20 flex items-center justify-center transition-colors cursor-pointer",children:e.jsx(T,{className:"w-4 h-4 text-white/70"})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-3 space-y-3",children:[d.length===0&&e.jsxs("div",{className:"space-y-4 animate-fade-in",children:[e.jsxs("div",{className:"text-center py-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-[#1E3A5F]/8 flex items-center justify-center mx-auto mb-3",children:e.jsx(x,{className:"w-6 h-6 text-[#1E3A5F]"})}),e.jsx("p",{className:"text-lg font-bold text-[#1E3A5F]",children:"Ask me anything about your building"}),e.jsx("p",{className:"text-base text-gray-400 mt-1",children:"I can answer questions about your by-laws, insurance, levies, and NSW strata law."})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("p",{className:"text-sm font-semibold text-gray-400 uppercase tracking-wide px-1",children:"Try asking"}),z.map((s,n)=>e.jsx("button",{onClick:()=>m(s),className:"w-full text-left px-3 py-2 rounded-xl text-base font-medium text-[#1E3A5F] bg-[#F7F9FC] hover:bg-[#EEF2F7] border border-[#DCE5EF] hover:border-[#2A9090]/30 transition-all cursor-pointer",children:s},n))]})]}),d.map((s,n)=>e.jsxs("div",{className:`flex gap-2 ${s.role==="user"?"justify-end":"justify-start"}`,children:[s.role==="assistant"&&e.jsx("div",{className:"w-7 h-7 rounded-lg bg-[#1E3A5F]/8 flex items-center justify-center shrink-0 mt-0.5",children:e.jsx(x,{className:"w-3.5 h-3.5 text-[#1E3A5F]"})}),e.jsxs("div",{className:`max-w-[85%] ${s.role==="user"?"order-first":""}`,children:[e.jsx("div",{className:`px-3 py-2 rounded-xl text-lg leading-relaxed ${s.role==="user"?"bg-[#2A9090] text-white rounded-br-sm":"bg-[#F7F9FC] text-[#1E3A5F] border border-[#DCE5EF] rounded-bl-sm"}`,children:s.role==="assistant"?e.jsx("div",{className:"whitespace-pre-wrap prose-sm",children:s.content.split(`
2`).map((t,r)=>t.startsWith("- ")||t.startsWith("* ")?e.jsx("p",{className:"pl-2 my-0.5",children:t},r):t.startsWith("**")&&t.endsWith("**")?e.jsx("p",{className:"font-bold my-1",children:t.replace(/\*\*/g,"")},r):t?e.jsx("p",{className:"my-0.5",children:t},r):e.jsx("br",{},r))}):s.content}),s.sources&&s.sources.length>0&&e.jsxs("div",{className:"mt-1",children:[e.jsxs("button",{onClick:()=>k(h===n?null:n),className:"flex items-center gap-1 text-sm font-semibold text-gray-400 hover:text-[#2A9090] transition-colors cursor-pointer",children:[e.jsx(A,{className:"w-3 h-3"}),s.sources.length," source",s.sources.length!==1?"s":"",e.jsx(R,{className:`w-3 h-3 transition-transform ${h===n?"rotate-180":""}`})]}),h===n&&e.jsx("div",{className:"mt-1.5 space-y-1 animate-fade-in",children:s.sources.map((t,r)=>e.jsxs("div",{className:"flex items-start gap-1.5 px-2 py-1.5 rounded-lg bg-white border border-[#DCE5EF] text-sm",children:[t.type==="legislation"?e.jsx($,{className:"w-3 h-3 text-[#7C3AED] shrink-0 mt-0.5"}):e.jsx(A,{className:"w-3 h-3 text-[#2A9090] shrink-0 mt-0.5"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold text-[#1E3A5F] truncate",children:t.title}),t.detail&&e.jsx("p",{className:"text-gray-400 line-clamp-2 mt-0.5",children:t.detail})]})]},r))})]})]}),s.role==="user"&&e.jsx("div",{className:"w-7 h-7 rounded-lg bg-[#2A9090]/10 flex items-center justify-center shrink-0 mt-0.5",children:e.jsx(M,{className:"w-3.5 h-3.5 text-[#2A9090]"})})]},n)),c&&e.jsxs("div",{className:"flex gap-2 justify-start",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-[#1E3A5F]/8 flex items-center justify-center shrink-0",children:e.jsx(x,{className:"w-3.5 h-3.5 text-[#1E3A5F]"})}),e.jsx("div",{className:"px-3 py-2 rounded-xl bg-[#F7F9FC] border border-[#DCE5EF] rounded-bl-sm",children:e.jsxs("div",{className:"flex items-center gap-2 text-base text-gray-400",children:[e.jsx(K,{className:"w-3.5 h-3.5 animate-spin"}),"Thinking..."]})})]}),w&&e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-xl bg-[#C0392B]/5 border border-[#C0392B]/15 text-base text-[#C0392B]",children:[e.jsx(O,{className:"w-3.5 h-3.5 shrink-0"}),e.jsx("span",{children:w})]}),e.jsx("div",{ref:y})]}),e.jsxs("div",{className:"shrink-0 border-t border-[#DCE5EF] px-3 py-3 bg-white",children:[!l&&e.jsx("p",{className:"text-sm text-gray-400 text-center mb-2",children:"Register your building to unlock the Building Assistant."}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{ref:N,type:"text",value:o,onChange:s=>
2f(s.target.value),onKeyDown:S,placeholder:l?"Ask about your building...":"Register a building first",disabled:!l||c,className:"flex-1 px-3 py-2.5 rounded-xl border border-[#DCE5EF] text-lg text-[#1E3A5F] placeholder:text-gray-400 focus:outline-none focus:border-[#2A9090] focus:ring-1 focus:ring-[#2A9090] disabled:opacity-50 disabled:cursor-not-allowed"}),e.jsx("button",{onClick:()=>m(o),disabled:!o.trim()||c||!l,className:`w-10 h-10 rounded-xl flex items-center justify-center transition-all cursor-pointer ${o.trim()&&!c&&l?"bg-[#2A9090] text-white hover:bg-[#238080] shadow-sm":"bg-gray-100 text-gray-300 cursor-not-allowed"}`,children:e.jsx(G,{className:"w-4 h-4"})})]}),e.jsx("p",{className:"text-[9px] text-gray-300 text-center mt-2",children:"AI answers based on your uploaded documents and NSW legislation. Not legal advice."})]})]}):e.jsxs("button",{onClick:()=>p(!0),className:"fixed bottom-6 right-6 z-50 w-14 h-14 bg-[#1E3A5F] hover:bg-[#2A4A6F] text-white rounded-full shadow-lg hover:shadow-xl flex items-center justify-center transition-all duration-300 cursor-pointer group",title:"Ask your Building Assistant",children:[e.jsx(W,{className:"w-6 h-6 group-hover:scale-110 transition-transform"}),e.jsx("span",{className:"absolute -top-1 -right-1 w-4 h-4 bg-[#2A9090] rounded-full flex items-center justify-center",children:e.jsx(B,{className:"w-2.5 h-2.5 text-white"})})]})}export{P 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.