PageSourceSearch

https://vierrapipeline.com/assets/AskAQuestionPanel-D88tdB6i.js

js vierrapipeline.com collected 2026-10-09 22:03:07 UTC 7,187 bytes, 1 lines download raw bytes

1import{ij as C,r as s,j as e,cW as E,ay as H,aF as R,L as j,a as W}from"./index-C-B5SaCl.js";const N="https://nohyebjnythqmwatmkoa.supabase.co/functions/v1";function $({onClose:c}){const a=C(),[n,f]=s.useState(""),[o,S]=s.useState(null),[v,m]=s.useState(null),[F,b]=s.useState(!1),[l,h]=s.useState(!1),[i,d]=s.useState("idle"),[u,k]=s.useState(null),x=s.useRef(null);s.useEffect(()=>{var t;(t=x.current)==null||t.scrollIntoView({block:"nearest",behavior:"smooth"})},[v,l,u,i]),s.useEffect(()=>{const t=p=>p.key==="Escape"&&c();return window.addEventListener("keydown",t),()=>window.removeEventListener("keydown",t)},[c]);const y=s.useCallback(async t=>{const p=t.trim();if(!(!p||l)){if(f(""),k(null),S(p),m(null),b(!1),d("idle"),h(!0),a.preview||!a.token){h(!1),m("This is a preview, so questions aren't sent anywhere. In a live presentation this would be answered from your valuation and our published information.");return}try{const g=await fetch(`${N}/pvp-ask`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:a.token,question:p})}),r=await g.json().catch(()=>({}));if(!g.ok||!(r!=null&&r.answer))throw new Error((r==null?void 0:r.error)??"unavailable");m(String(r.answer)),b(r.needs_human===!0)}catch{k(`We couldn't answer that just now. ${a.valuerFirstName??"Your valuer"} can pick it up for you.`)}finally{h(!1)}}},[a.preview,a.token,a.valuerFirstName,l]),q=s.useCallback(async()=>{if(i==="idle"){if(d("sending"),a.preview||!a.token){d("done");return}try{const t=o??n.trim();t&&await fetch(`${N}/pvp-ask`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:a.token,question:t,request_human:!0})})}catch{}d("done")}},[a.preview,a.token,n,i,o]),w=a.askSuggestions.filter(Boolean).slice(0,4),A=F||!!u;return e.jsxs("div",{className:"fixed inset-0 z-[80] flex items-end sm:items-center sm:justify-center",role:"dialog","aria-modal":"true","aria-label":"Ask a question",children:[e.jsx("button",{"aria-label":"Close",onClick:c,className:"absolute inset-0",style:{background:"rgba(6,8,12,0.55)",backdropFilter:"blur(3px)"}}),e.jsxs("div",{className:"relative w-full sm:max-w-[34rem] max-h-[86svh] flex flex-col overflow-hidden",style:{background:"var(--pvp-paper)",color:"var(--pvp-ink)",borderRadius:"var(--pvp-radius, 14px)",border:"1px solid var(--pvp-hairline)",boxShadow:"0 24px 70px rgba(0,0,0,0.35)",margin:"0 auto"},children:[e.jsxs("header",{className:"flex items-start justify-between gap-4 px-5 sm:px-7 pt-5 pb-5",style:{borderBottom:"1px solid var(--pvp-hairline)"},children:[e.jsxs("div",{className:"flex items-start gap-3.5",children:[e.jsx("div",{className:"shrink-0 inline-flex items-center justify-center h-10 w-10",style:{background:"var(--pvp-accent)",color:"var(--pvp-accent-ink)",borderRadius:"999px"},children:e.jsx(E,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-[1.15rem] leading-tight",style:{fontFamily:"var(--pvp-display)",fontWeight:500,color:"var(--pvp-ink)"},children:"Ask a question"}),e.jsx("p",{className:"mt-1 text-[0.84rem] leading-relaxed max-w-[22rem]",style:{fontFamily:"var(--pvp-body)",fontWeight:300,color:"var(--pvp-ink-soft)"},children:a.askIntro??(a.product==="post_val"?"Ask anything about your valuation or the strategy. Answers come from your published plan.":"Ask anything about how we work. Questions about your own home are best answered at the valuation.")})]})]}),e.jsx("button",{onClick:c,"aria-label":"Close",className:"shrink-0 -mr-1 -mt-1 p-2 opacity-60 hover:opacity-100 transition-opacity",style:{color:"var(--pvp-ink)"},children:e.jsx(H,{className:"h-5 w-5"})})]}),e.jsxs("form",{onSubmit:t=>{t.preventDefault(),y(n)},className:"px-5 sm:px-7 pt-5 pb-5",style:{borderBottom:"1px solid var(--pvp-hairline)"},children:[e.jsx("label",{htmlFor:"ask-question-input",className:"block mb-2 text-[0.82rem] tracking-wide uppercase",style:{fontFamily:"var(--pvp-body)",fontWeight:500,color:"var(--pvp-ink-soft)",opacity:.8},children:"Your question"}),e.jsxs("div",{className:"flex items-end gap-2",children:[e.jsx("textarea",{id:"ask-question-input",value:n,onChange:t=>f(t.target.value),onKeyDown:t=>{t.key==="Enter"&&!t.shiftKey&&(t.preventDefault(),y(n))},rows:2,maxLength:800,placeholder:"Type your question here…","aria-label":"Your question",className:"flex-1 resize-none bg-transparent outline-none px-4 py-3.5 text-[0.98rem] transition-shadow focus:ring-2",style:{fontFamily:"var(--pvp-body)",border:"1.5px solid var(--pvp-hairline)",borderRadius:"var(--pvp-radius, 12px)",maxHeight:"8rem",boxShadow:"inset 0 1px 2px rgba(0,0,0,0.04)"}}),e.jsx("button",{type:"submit",disabled:l||!n.trim(),"aria-label":"Send question",className:"shrink-0 inline-flex items-center justify-center h-12 w-12 disabled:opacity-40 transition-transform active:scale-95",style:{borderRadius:"999px",background:"var(--pvp-accent)",color:"var(--pvp-accent-ink)"},children:e.jsx(R,{className:"h-5 w-5"})})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 sm:px-7 py-5 space-y-4",children:[!
1o&&w.length>0&&e.jsxs("div",{className:"space-y-2.5",children:[e.jsx("p",{className:"text-[0.75rem] tracking-wide uppercase",style:{fontFamily:"var(--pvp-body)",fontWeight:500,color:"var(--pvp-ink-soft)",opacity:.7},children:"Suggested questions"}),w.map(t=>e.jsx("button",{onClick:()=>y(t),className:"block w-full text-left px-3.5 py-2.5 text-[0.82rem] transition-opacity hover:opacity-80",style:{border:"1px solid var(--pvp-hairline)",borderRadius:"var(--pvp-radius, 10px)",fontFamily:"var(--pvp-body)",fontWeight:400,lineHeight:1.35},children:t},t))]}),o&&e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"px-4 py-3 text-[0.95rem]",style:{fontFamily:"var(--pvp-body)",fontWeight:400,lineHeight:1.5,whiteSpace:"pre-wrap",borderRadius:"var(--pvp-radius, 12px)",background:"var(--pvp-accent)",color:"var(--pvp-accent-ink)"},children:o}),l?e.jsxs("div",{className:"flex items-center gap-2 text-[0.85rem]",style:{opacity:.6},children:[e.jsx(j,{className:"h-3.5 w-3.5 animate-spin"})," Thinking…"]}):u?e.jsx("p",{className:"text-[0.9rem]",style:{opacity:.75,fontFamily:"var(--pvp-body)"},children:u}):v?e.jsx("div",{ref:x,className:"text-[0.92rem] px-1",style:{fontFamily:"var(--pvp-body)",fontWeight:300,lineHeight:1.65,whiteSpace:"pre-wrap",color:"var(--pvp-ink)"},children:v}):null]}),A&&e.jsx("div",{className:"pt-1",ref:x,children:i==="done"?e.jsxs("p",{className:"inline-flex items-center gap-2 text-[0.88rem]",style:{fontFamily:"var(--pvp-body)",opacity:.8},children:[e.jsx(W,{className:"h-4 w-4"})," That's with"," ",a.valuerFirstName?`${a.valuerFirstName} and the team`:"the team"," — they'll come back to you."]}):e.jsxs("button",{onClick:q,disabled:i==="sending",className:"inline-flex items-center gap-2 px-5 py-3 text-[0.9rem]",style:{fontFamily:"var(--pvp-body)",fontWeight:500,borderRadius:"999px",background:"var(--pvp-accent)",color:"var(--pvp-accent-ink)"},children:[i==="sending"&&e.jsx(j,{className:"h-4 w-4 animate-spin"}),a.product==="post_val"?`Ask ${a.valuerFirstName??"our valuer"} to come back to me`:`Have ${a.valuerFirstName??"the valuer"} cover this at the valuation`]})})]})]})]})}export{$ 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.