@brainfish-ai/components 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import*as e from"react";import t,{memo as a,useState as r,useRef as n,useEffect as o,useCallback as s,createContext as i,useMemo as l,useContext as c,lazy as d,Suspense as m,forwardRef as u,useImperativeHandle as p}from"react";import{AnimatePresence as h,motion as f}from"framer-motion";import*as g from"@radix-ui/react-tooltip";import{clsx as y}from"clsx";import{twMerge as b}from"tailwind-merge";import{jsx as v,Fragment as E}from"react/jsx-runtime";import{cva as x}from"class-variance-authority";import{XCircle as w,CheckCircle as N,Clipboard as k,Download as C,ArrowsOut as I,Heart as F,ThumbsUp as j,ThumbsDown as S,Check as z,Copy as A,CaretDown as O,ArrowSquareOut as T,CaretRight as R,ArrowsVertical as L,ArrowDown as D,MagnifyingGlass as Q,X as q,Circle as B,Image as _,ArrowRight as $,ArrowLeft as P,ArrowsInSimple as U,ArrowsOutSimple as M}from"@phosphor-icons/react";import{useForm as V}from"react-hook-form";import{ajvResolver as W}from"@hookform/resolvers/ajv";import*as Z from"@radix-ui/react-label";import H from"rehype-raw";import K from"remark-gfm";import{Prism as G}from"react-syntax-highlighter";import{a11yDark as J}from"react-syntax-highlighter/dist/esm/styles/prism";import Y from"react-markdown";import X from"mermaid";import{createId as ee}from"@paralleldrive/cuid2";import*as te from"@radix-ui/react-collapsible";import{useImmerReducer as ae}from"use-immer";import{useSearchParam as re,useEffectOnce as ne}from"react-use";import*as oe from"@radix-ui/react-dropdown-menu";import{ChevronRightIcon as se,CheckIcon as ie,DotFilledIcon as le}from"@radix-ui/react-icons";import*as ce from"@radix-ui/react-scroll-area";import*as de from"@radix-ui/react-switch";function me(e,t){return({opacityVariable:a,opacityValue:r})=>`rgb(var(${e}, ${t}) / ${void 0!==r?r:`var(${a}, 1)`})`}const ue={50:"#FAFAFA",100:"#F5F5F5",200:"#E5E5E5",300:"#D4D4D4",400:"#A3A3A3",500:"#737373",600:"#525252",700:"#404040",800:"#262626",900:"#171717",DEFAULT:"#171717"},pe={primary:{50:"#F7FEE8",100:"#ECFCCC",200:"#D9F99E",300:"#BEF265",400:"#A3E635",500:"#84CC17",600:"#65A30E",700:"#4E7C10",800:"#406213",900:"#375415",DEFAULT:me("--bfc-primary","#A3E635"),foreground:me("--bfc-primary-foreground",ue.DEFAULT)},dark:ue,orange:{50:"#FFF7EE",100:"#FFEDD6",200:"#FED7AB",300:"#FDBA75",400:"#FB923D",500:"#F97317",600:"#EA590D",700:"#C2420D",800:"#9A3513",900:"#7C2E13",DEFAULT:"#FB923D"},yellow:{50:"#FFFBEC",100:"#FEF3C8",200:"#FDE68B",300:"#FCD34E",400:"#FBBF25",500:"#F59E0C",600:"#D97707",700:"#B4540A",800:"#92410F",900:"#783610",DEFAULT:"#FBBF25"},green:{50:"#EDFDF5",100:"#D2FAE5",200:"#A8F3D0",300:"#6FE7B7",400:"#35D399",500:"#11B981",600:"#069669",700:"#057857",800:"#075F47",900:"#074F3C",DEFAULT:"#35D399"},blue:{50:"#F0F6FF",100:"#DCEAFE",200:"#C0DBFE",300:"#94C5FD",400:"#61A5FA",500:"#3C82F6",600:"#2663EB",700:"#1E4FD8",800:"#1F41AF",900:"#1F3B8A",DEFAULT:"#61A5FA"},purple:{50:"#F5F4FF",100:"#EDEAFE",200:"#DED7FE",300:"#C5B6FD",400:"#A78CFA",500:"#8C5DF6",600:"#7C3BED",700:"#6D29D9",800:"#5B22B6",900:"#4D1E95",DEFAULT:"#8C5DF6"},pink:{50:"#F5F4FF",100:"#FAE9FF",200:"#F5D1FE",300:"#F0ACFC",400:"#E87AF9",500:"#D947EF",600:"#C027D3",700:"#A21DAF",800:"#861A8F",900:"#701B75",DEFAULT:"#E87AF9"},red:{50:"#FFF2F3",100:"#FFE5E6",200:"#FECED4",300:"#FDA5B0",400:"#FB7286",500:"#F4405E",600:"#E11E49",700:"#BE133D",800:"#9F133A",900:"#881438",DEFAULT:"#F4405E"}};function he(e,t){var a={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(a[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(e);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(a[r[n]]=e[r[n]])}return a}function fe(e,t,a,r){return new(a||(a=Promise))((function(n,o){function s(e){try{l(r.next(e))}catch(e){o(e)}}function i(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof a?t:new a((function(e){e(t)}))).then(s,i)}l((r=r.apply(e,t||[])).next())}))}function ge(...e){return b(y(e))}function ye(e){const t={en:[/i(?:\s|['\u2018\u2019])?m(?:\s+really)?\s+not\s+sure/i,/i(?:\s+am)?(?:\s+really)?\s+not\s+sure/i,/i\s+(?:really\s+)?don(?:['\u2018\u2019])?t\s+know/i,/it(?:['\u2018\u2019]s| is) unclear/i,/cannot determine/i,/hard to say/i,/difficult to determine/i,/need more information/i],es:[/no (?:lo )?sé/i,/no estoy seguro/i,/no es claro/i,/desconocido/i],fr:[/je ne sais pas/i,/je ne suis pas sûr/i,/ce n'est pas clair/i,/inconnu/i],de:[/ich weiß nicht/i,/ich bin nicht sicher/i,/es ist unklar/i,/unbekannt/i],it:[/non lo so/i,/non sono sicuro/i,/non è chiaro/i,/sconosciuto/i],pt:[/não sei/i,/não tenho certeza/i,/não está claro/i,/desconhecido/i],nl:[/ik weet het niet/i,/ik weet niet zeker/i,/het is onduidelijk/i,/onbekend/i],pl:[/nie wiem/i,/nie jestem pewien/i,/to nie jest jasne/i,/nieznany/i],ru:[/я не знаю/i,/я не уверен/i,/это не ясно/i,/неизвестно/i],ja:[/知りません/i,/よくわからない/i,/不明です/i,/未知/i],ko:[/모릅니다/i,/잘 모르겠습니다/i,/불확실합니다/i,/알 수 없음/i],zh:[/我不知道/i,/我不确定/i,/不清楚/i,/未知/i],"zh-TW":[/我不知道/i,/我不確定/i,/不清楚/i,/未知/i]};let a=null;for(const[r,n]of Object.entries(t))for(const t of n){const n=e.match(t);n&&(null===a||n.index<a.index)&&(a={index:n.index,language:r})}return a?{uncertain:!0,language:a.language}:{uncertain:!1,language:null}}"function"==typeof SuppressedError&&SuppressedError;const be=t=>{var{delayDuration:a=200}=t,r=he(t,["delayDuration"]);return e.createElement(g.Provider,Object.assign({delayDuration:a},r))},ve=g.Root,Ee=g.Trigger,xe=e.forwardRef(((t,a)=>{var{className:r,sideOffset:n=4,background:o,textColor:s,borderColor:i,style:l}=t,c=he(t,["className","sideOffset","background","textColor","borderColor","style"]);return e.createElement(g.Portal,null,e.createElement(g.Content,Object.assign({ref:a,sideOffset:n,className:ge("z-50 overflow-hidden rounded-lg px-4 py-3 text-sm font-medium shadow-lg animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",r),style:Object.assign(Object.assign({},l),{backgroundColor:o||"#ffffff",color:s||"rgb(31 41 55)",borderColor:i||"rgb(243 244 246)",borderWidth:"1px",borderStyle:"solid"})},c)))}));function we(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Ne(...e){return t=>{let a=!1;const r=e.map((e=>{const r=we(e,t);return a||"function"!=typeof r||(a=!0),r}));if(a)return()=>{for(let t=0;t<r.length;t++){const a=r[t];"function"==typeof a?a():we(e[t],null)}}}}xe.displayName=g.Content.displayName;var ke=e.forwardRef(((t,a)=>{const{children:r,...n}=t,o=e.Children.toArray(r),s=o.find(Fe);if(s){const t=s.props.children,r=o.map((a=>a===s?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:a));return v(Ce,{...n,ref:a,children:e.isValidElement(t)?e.cloneElement(t,void 0,r):null})}return v(Ce,{...n,ref:a,children:r})}));ke.displayName="Slot";var Ce=e.forwardRef(((t,a)=>{const{children:r,...n}=t;if(e.isValidElement(r)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,a=t&&"isReactWarning"in t&&t.isReactWarning;if(a)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,a=t&&"isReactWarning"in t&&t.isReactWarning,a)return e.props.ref;return e.props.ref||e.ref}(r);return e.cloneElement(r,{...je(n,r.props),ref:a?Ne(a,t):t})}return e.Children.count(r)>1?e.Children.only(null):null}));Ce.displayName="SlotClone";var Ie=({children:e})=>v(E,{children:e});function Fe(t){return e.isValidElement(t)&&t.type===Ie}function je(e,t){const a={...t};for(const r in t){const n=e[r],o=t[r];/^on[A-Z]/.test(r)?n&&o?a[r]=(...e)=>{o(...e),n(...e)}:n&&(a[r]=n):"style"===r?a[r]={...n,...o}:"className"===r&&(a[r]=[n,o].filter(Boolean).join(" "))}return{...e,...a}}const Se=x("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline",dark:"bg-dark-700 text-white shadow hover:bg-dark-800 dark:bg-primary dark:text-primary-foreground dark:hover:bg-primary/90"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),ze=e.forwardRef(((t,a)=>{var{className:r,variant:n,size:o,asChild:s=!1}=t,i=he(t,["className","variant","size","asChild"]);const l=s?ke:"button";return e.createElement(l,Object.assign({className:ge(Se({variant:n,size:o,className:r})),ref:a},i))}));function Ae({suggestions:e,onQuestionClick:a,title:r="Suggested questions"}){return e&&0!==e.length?t.createElement("div",{className:"w-full p-3","data-name":"Suggestions"},t.createElement("h3",{className:"text-base font-medium mb-4 text-foreground"},r),t.createElement("div",{className:"flex flex-wrap gap-2"},e.map((e=>t.createElement(ze,{key:e.id,onClick:()=>a(e),variant:"outline",className:"border-border font-normal whitespace-normal h-auto text-left"},void 0!==e.messageCount&&t.createElement(be,null,t.createElement(ve,null,t.createElement(Ee,{asChild:!0},t.createElement("span",{className:"bg-gray-100 text-gray-600 px-2 py-0.5 rounded-full text-xs min-w-[20px] border flex items-center justify-center border-border"},e.messageCount)),t.createElement(xe,null,t.createElement("p",null,e.messageCount," messages in this conversation")))),t.createElement("span",{className:""},e.question)))))):null}ze.displayName="Button";const Oe=e.forwardRef(((t,a)=>{var{className:r,type:n}=t,o=he(t,["className","type"]);return e.createElement("input",Object.assign({type:n,className:ge("flex h-12 w-full rounded-md border border-input bg-transparent px-4 py-3 text-base transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",r),ref:a},o))}));Oe.displayName="Input";const Te=x("font-bold leading-6 peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Re=e.forwardRef(((t,a)=>{var{className:r}=t,n=he(t,["className"]);return e.createElement(Z.Root,Object.assign({ref:a,className:ge(Te(),r)},n))}));function Le({block:e}){var a;const{schema:r,initialValues:n,state:o}=e,s=null!==(a=r.properties)&&void 0!==a?a:{},i="ready"===o,l="processing"===o,c="completed"===o,{getValues:d,register:m,handleSubmit:u,formState:{errors:p}}=V({defaultValues:n,resolver:W(r,{removeAdditional:!0})}),h=Object.keys(s).map((e=>{var a;const n=s[e],o=(e=>{var t,a;return null!==(a=null===(t=r.required)||void 0===t?void 0:t.includes(e))&&void 0!==a&&a})(e),l=`${null!==(a=n.title)&&void 0!==a?a:e}${o?"*":""}`,c=n.description,u=p[e],h=o&&""===String(d(e)).replace(/^(null|undefined)$/,"")?"Please provide a value":null==u?void 0:u.message;let f=c?String(c):null;return u&&(f=c?t.createElement(t.Fragment,null,c," - ",t.createElement("span",{className:"italic"},h)):h),t.createElement("div",{key:e,className:"py-2 flex flex-col gap-2"},t.createElement(Re,{htmlFor:e},l),t.createElement(Oe,Object.assign({type:"text",disabled:!i,className:ge("border-dark-300",{"border-red-600":!!u})},m(e))),f&&t.createElement("span",{className:ge("flex text-sm leading-6 font-medium gap-1.5 items-center",{"text-red-600":!!u})},u&&t.createElement(w,{weight:"fill",size:20,className:"inline-block align-middle"}),t.createElement("span",null,f)))}));return t.createElement("div",{className:"relative"},t.createElement("form",{className:"flex flex-col justify-stretch",onSubmit:t=>(t.preventDefault(),e.onSubmit&&u(e.onSubmit)(t),!1)},h,t.createElement("div",{className:"mt-4"},t.createElement(ze,{type:"submit",variant:"dark",disabled:!i,className:"w-full rounded-s"},i&&"Submit",l&&"Processing...",c&&"Completed"))))}function De(e){return null}Re.displayName=Z.Root.displayName;const Qe={javascript:".js",python:".py",java:".java",c:".c",cpp:".cpp","c++":".cpp","c#":".cs",ruby:".rb",php:".php",swift:".swift","objective-c":".m",kotlin:".kt",typescript:".ts",go:".go",perl:".pl",rust:".rs",scala:".scala",haskell:".hs",lua:".lua",shell:".sh",sql:".sql",html:".html",css:".css"},qe=G,Be=a((({language:e,value:a})=>{const[n,o]=r(!1);return t.createElement("div",{className:"relative font-sans text-sm mt-1"},t.createElement("div",{className:"relative rounded-t-lg bg-zinc-800/80 font-sans text-sm backdrop-blur"},t.createElement("div",{className:"flex h-8 items-center justify-between px-3"},t.createElement("span",{className:"text-xs font-medium text-zinc-400"},e),t.createElement("div",{className:"flex gap-1"},t.createElement(ze,{variant:"ghost",size:"icon",className:"size-5 text-zinc-400 hover:bg-zinc-700/50 hover:text-zinc-100",onClick:()=>{fe(void 0,void 0,void 0,(function*(){if(navigator.clipboard&&navigator.clipboard.writeText)try{yield navigator.clipboard.writeText(a),o(!0),setTimeout((()=>{o(!1)}),2e3)}catch(e){console.error("Failed to copy:",e)}}))}},n?t.createElement(N,{size:18}):t.createElement(k,{size:18})),t.createElement(ze,{variant:"ghost",size:"icon",className:"size-5 text-zinc-400 hover:bg-zinc-700/50 hover:text-zinc-100",onClick:()=>{const t=Qe[e]||".file",r=`file-${((e,t=!1)=>{const a="ABCDEFGHJKLMNPQRSTUVWXY3456789";let r="";for(let t=0;t<e;t+=1)r+=a.charAt(Math.floor(30*Math.random()));return t?r.toLowerCase():r})(3,!0)}${t}`,n=new Blob([a],{type:"text/plain"}),o=URL.createObjectURL(n),s=document.createElement("a");s.download=r,s.href=o,s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(o)}},t.createElement(C,{size:18}))))),t.createElement("div",{className:"rounded-b-lg"},t.createElement(qe,{language:e,style:J,PreTag:"div",wrapLongLines:!0,customStyle:{margin:0,borderTopLeftRadius:0,borderTopRightRadius:0}},a)))}));Be.displayName="CodeBlock";const _e=e.forwardRef((({src:t,border:a,width:r="100%",height:n="400px",title:o},s)=>{const[i,l]=e.useState(!1),[c,d]=e.useState(!1);return e.useEffect((()=>{let e=!0;return setTimeout((()=>{e&&l(!0)}),0),()=>{e=!1}}),[]),e.createElement("div",{className:"overflow-hidden rounded-lg mt-4 relative "+(a?"border":""),style:{width:r,height:n}},i&&e.createElement(e.Fragment,null,e.createElement("div",{className:"absolute w-full h-full "+(c?"hidden":"block")},e.createElement("div",{className:"absolute inset-0 bg-muted/10 rounded-lg"},e.createElement("div",{className:"absolute inset-0"},e.createElement("div",{className:"h-full w-full shimmer"}),e.createElement("div",{className:"absolute left-1/2 top-1/2 -translate-1/2 flex flex-col items-center gap-2"},e.createElement("div",{className:"modern-spinner"}),e.createElement("div",{className:"text-sm text-muted-foreground"},"Loading..."))))),e.createElement("div",{className:c?"visible":"invisible"},e.createElement("iframe",{ref:s,src:t,sandbox:"allow-same-origin allow-scripts allow-popups allow-forms allow-downloads",width:r,height:n,title:"embed",loading:"lazy",allowFullScreen:!0,className:"block rounded-lg",onLoad:()=>d(!0)}),o&&e.createElement("span",{className:"block text-center text-sm font-medium"},o))))}));function $e(t){const a=t.attrs.href.replace("share","embed");return e.createElement(_e,Object.assign({},t,{src:a,title:"Loom Embed"}))}function Pe(t){return e.createElement(_e,Object.assign({},t,{src:t.attrs.href,title:"Supademo Embed"}))}function Ue(t){return e.createElement(_e,Object.assign({},t,{src:t.attrs.href,title:"Typeform Embed"}))}function Me(t){const a=t.attrs.href.match(/(http|https)?:\/\/(www\.)?vimeo\.com\/(?:channels\/(?:\w+\/)?|groups\/([^/]*)\/videos\/|)(\d+)(?:\/|\?)?([\d\w]+)?/);if(!a)return null;const r=a[4],n=a[5],o=`https://player.vimeo.com/video/${r}?byline=0${n?`&h=${n}`:""}`;return e.createElement(_e,Object.assign({},t,{src:o,title:`Vimeo Embed (${r})`,height:"412px",border:!1}))}function Ve(t){const a=(e=>{const t=[/^https?:\/\/([a-zA-Z0-9-_~]+)\.wistia\.com\/medias\/([a-zA-Z0-9-_~]+)\/?$/,/^https?:\/\/fast\.wistia\.com\/embed\/iframe\/([a-zA-Z0-9-_~]+)\/?$/,/^fast\.wistia\.com\/embed\/iframe\/([a-zA-Z0-9-_~]+)\/?$/,/^([a-zA-Z0-9-_~]+)\.wistia\.com\/medias\/([a-zA-Z0-9-_~]+)\/?$/];for(const a of t){const t=e.match(a);if(t)return t}return null})(t.attrs.href);if(!a)return null;const r=a[1],n=a[2]||a[1],o=r?`https://${r}.wistia.com/embed/iframe/${n}?seo=true&videoFoam=false`:`https://fast.wistia.com/embed/iframe/${n}`;return e.createElement(_e,Object.assign({},t,{src:o,border:!0,title:`Wistia Embed (${n})`}))}function We(t){const a=(e=>{const t=e.match(/(?:https?:\/\/)?(?:www\.)?youtu\.?be(?:\.com)?\/?.*(?:watch|embed)?(?:.*v=|v\/|\/)([a-zA-Z0-9_-]{11})$/i);return t?t[1]:null})(t.attrs.href);return a?e.createElement(_e,Object.assign({},t,{src:`https://www.youtube.com/embed/${a}?modestbranding=1`,title:`YouTube Embed (${a})`})):null}$e.isMatch=e=>/^https:\/\/(www\.)?(use)?loom\.com\/(embed|share)\/(.*)$/.test(e),Pe.isMatch=e=>/^https:\/\/app\.supademo\.com\/embed\/(.*)$/.test(e),Ue.isMatch=e=>/^https:\/\/([A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)\.typeform\.com\/to\/(.*)$/.test(e),Me.isMatch=e=>/^(https?):\/\/(www\.)?vimeo\.com\/(?:channels\/(?:\w+\/)?|groups\/([^/]*)\/videos\/|)?(\d+)(\/)?(?:\?.*|#.*)?$/i.test(e),Ve.isMatch=e=>[/^https?:\/\/([a-zA-Z0-9-_~]+)\.wistia\.com\/medias\/([a-zA-Z0-9-_~]+)(\/)?(\?.*)?$/i,/^https?:\/\/fast\.wistia\.com\/embed\/iframe\/([a-zA-Z0-9-_~]+)(\/)?(\?.*)?$/i,/^fast\.wistia\.com\/embed\/iframe\/([a-zA-Z0-9-_~]+)(\/)?(\?.*)?$/i,/^([a-zA-Z0-9-_~]+)\.wistia\.com\/medias\/([a-zA-Z0-9-_~]+)(\/)?(\?.*)?$/i].some((t=>t.test(e))),We.isMatch=e=>/^(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:watch\?v=|embed\/|v\/|shorts\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})(?:\/|[?&].*)?$/i.test(e);const Ze=[$e,Pe,Ue,We,Ve,Me],He=t=>{const{href:a}=t.attrs,r=((t,a)=>e.useMemo((()=>{try{const e=a.find((e=>e.isMatch(t)));return e?{Component:e}:null}catch(e){return console.error("Error finding embed match:",e),null}}),[t,a]))(a,Ze);if(r){const{Component:a}=r;return e.createElement(a,Object.assign({},t))}return null},Ke=a(Y,((e,t)=>e.children===t.children)),Ge={startOnLoad:!1,theme:"default",securityLevel:"loose",fontFamily:"inherit",secure:["secure","securityLevel","startOnLoad","maxTextSize"]},Je=({content:e})=>{const[a,s]=r(""),[i,l]=r(null),c=n(null),[d,m]=r(!1);return o((()=>{(()=>{try{X.initialize(Ge),m(!0)}catch(e){console.error("Error initializing mermaid:",e),l("Failed to initialize diagram renderer")}})()}),[]),o((()=>{if(!d)return;fe(void 0,void 0,void 0,(function*(){try{const t=`mermaid-${Math.random().toString(36).substr(2,9)}`,{svg:a}=yield X.render(t,e);s(a),l(null)}catch(e){console.error("Error rendering mermaid diagram:",e),l("Failed to render diagram")}}))}),[e,d]),i?t.createElement("div",{className:"text-red-500 bg-red-50 p-4 rounded-md"},i,t.createElement("pre",{className:"mt-2 text-sm"},e)):t.createElement("div",{ref:c,className:"my-4 overflow-auto",dangerouslySetInnerHTML:{__html:a}})},Ye=({src:t,alt:a})=>{const[r,n]=e.useState(!1),[o,s]=e.useState(!1),[i,l]=e.useState(!1),[c,d]=e.useState(!0),[m,u]=e.useState({width:0,height:0}),p=e.useRef(null),g=()=>{n(!r)};return!t||i?null:e.createElement("figure",{className:"relative inline-block my-4 px-4 w-full sm:w-auto"},e.createElement("div",{className:"flex items-center justify-center min-h-[100px]"},e.createElement("button",{type:"button",onClick:g,className:"border-0 p-0 bg-transparent relative group","aria-label":r?"Zoom out image":"Zoom in image"},c&&e.createElement("div",{className:"rounded-md bg-gray-200 dark:bg-gray-800 animate-pulse",style:{width:m.width||300,height:m.height||200,maxHeight:300}}),e.createElement("img",{ref:p,src:t,alt:a,onError:()=>{d(!1),l(!0)},onLoad:()=>{if(p.current){const{naturalWidth:e,naturalHeight:t}=p.current,a=300,r=e/t,n=Math.min(a,t);u({width:n*r,height:n})}d(!1)},className:"max-h-[300px] w-auto object-contain cursor-zoom-in hover:opacity-90 transition-opacity "+(c?"opacity-0 absolute":"opacity-100 relative")}),!c&&e.createElement("div",{className:"absolute bottom-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity"},e.createElement("div",{className:"bg-black/50 text-white p-1.5 rounded-lg"},e.createElement(I,{size:16}))))),a&&!c&&e.createElement("div",{className:"relative mt-1"},e.createElement("figcaption",{className:"text-sm text-gray-600 dark:text-gray-400 text-center group cursor-default",onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1)},e.createElement("div",{className:"line-clamp-2 hover:text-gray-700 dark:hover:text-gray-300"},a)),o&&e.createElement("div",{className:"absolute bottom-full left-0 right-0 mb-1 p-2 bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 text-sm text-gray-600 dark:text-gray-400 z-10"},a)),e.createElement(h,null,r&&e.createElement(e.Fragment,null,e.createElement(f.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/80 z-50",onClick:g}),e.createElement(f.div,{initial:{scale:.5,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.5,opacity:0},className:"fixed inset-0 z-50 flex flex-col items-center justify-center cursor-zoom-out gap-4 p-4 sm:p-8",onClick:g},e.createElement("div",{className:"max-w-[95vw] sm:max-w-[90vw] max-h-[80vh]"},e.createElement("img",{src:t,alt:a,className:"w-full h-full object-contain"})),a&&e.createElement("div",{className:"max-w-[95vw] sm:max-w-[90vw] text-white text-center text-sm"},a)))))},Xe=a((({message:e,isStreaming:a})=>{const[n,s]=r(e.content);o((()=>{var t;const a=ye(e.content);a.uncertain&&a.language&&(null===(t=e.uncertaintyFallbackText)||void 0===t?void 0:t[a.language])?s(e.uncertaintyFallbackText[a.language]):s(e.content)}),[e.content,e.uncertaintyFallbackText,a]);const i=n.replace(/^\n+|(\n+|\\)+$/g,"");return t.createElement(Ke,{className:"dark:prose-invert prose flex-1",remarkPlugins:[K],rehypePlugins:[H],components:{p:({children:e})=>t.createElement("div",{className:"ptag"},e),code:e=>{var{inline:a,className:r,children:n}=e,o=he(e,["inline","className","children"]);const s=/language-(\w+)/.exec(r||""),i=s&&s[1];return a||"mermaid"!==i&&"mermaidjs"!==i?!a&&i?t.createElement(Be,Object.assign({key:Math.random(),language:i,value:String(n).replace(/\n$/,"")},o)):t.createElement("code",Object.assign({className:`text-red-400 bg-slate-200 border-slate-300 border rounded p-0.5 ${r}`.trim()},o),n):t.createElement(Je,{content:String(n).replace(/\n$/,"")})},marker:({children:e})=>t.createElement("div",{className:"my-2"},t.createElement("span",{className:"highlight"},e)),table:({children:e})=>t.createElement("table",{className:"border-collapse border border-black px-3 py-1 dark:border-white"},e),th:({children:e})=>t.createElement("th",{className:"break-words border border-black bg-gray-500 px-3 py-1 text-white dark:border-white"},e),td:({children:e})=>t.createElement("td",{className:"break-words border border-black px-3 py-1 dark:border-white"},e),a(e){var{children:a}=e,r=he(e,["children"]);if(r.href){const e=He({attrs:{href:r.href}});if(t.isValidElement(e))return e}return t.createElement("a",Object.assign({className:"link text-link",target:"_blank",rel:"noopener noreferrer"},r),a)},pre:({children:e})=>t.createElement(t.Fragment,null,e),img({src:e,alt:a}){const r=He({attrs:{href:null!=e?e:""}});return t.isValidElement(r)?r:t.createElement(Ye,{src:e,alt:a})},li:e=>{var{children:a}=e,r=he(e,["children"]);return t.createElement("li",Object.assign({},r),a)},ul:({children:e})=>t.createElement("ul",{className:"ml-4 my-4 list-outside space-y-4 list-disc",role:"list"},e),ol:({children:e})=>t.createElement("ol",{className:"ml-4 my-4 list-outside space-y-4 list-decimal",role:"list"},e),strong:e=>{var{children:a}=e,r=he(e,["children"]);return t.createElement("span",Object.assign({className:"font-semibold"},r),a)},h1:e=>{var{children:a}=e,r=he(e,["children"]);return t.createElement("h1",Object.assign({className:"text-2xl font-bold"},r),a)},h2:e=>{var{children:a}=e,r=he(e,["children"]);return t.createElement("h2",Object.assign({className:"text-xl font-bold"},r),a)},h3:e=>{var{children:a}=e,r=he(e,["children"]);return t.createElement("h3",Object.assign({className:"text-lg font-bold"},r),a)},h4:e=>{var{children:a}=e,r=he(e,["children"]);return t.createElement("h4",Object.assign({className:"text-base font-bold"},r),a)},h5:e=>{var{children:a}=e,r=he(e,["children"]);return t.createElement("h5",Object.assign({className:"text-base font-semibold"},r),a)},h6:e=>{var{children:a}=e,r=he(e,["children"]);return t.createElement("h6",Object.assign({className:"text-sm font-semibold"},r),a)}}},i)}));function et({block:e}){if(!e.text||""===e.text.trim())return t.createElement("div",{className:"w-full"},t.createElement("div",{className:"space-y-4"},t.createElement("div",{className:"space-y-3"},t.createElement("div",{className:"h-4 rounded w-3/4 shimmer"}),t.createElement("div",{className:"h-4 rounded w-full shimmer"}),t.createElement("div",{className:"h-4 rounded w-5/6 shimmer"}))));const{text:a}=e;return t.createElement("div",{className:"w-full"},t.createElement("div",{className:"prose prose-sm max-w-none text-foreground"},t.createElement(Xe,{message:{content:a}})))}function tt({block:e}){switch(e.type){case"markdown-text":return t.createElement(et,{block:e});case"action-buttons":return t.createElement(De,{block:e});case"action-input-form":return t.createElement(Le,{block:e});default:return null}}Xe.displayName="FormattedMessage";const at=({text:e=""}={})=>({id:ee(),type:"markdown-text",text:e}),rt=e=>"markdown-text"===e.type,nt=e=>"action-input-form"===e.type,ot=te.Root,st=te.CollapsibleTrigger,it=e=>{var{children:a}=e,r=he(e,["children"]);return t.createElement(te.CollapsibleContent,Object.assign({},r),t.createElement("style",null,'\n .CollapsibleContent[data-state="open"] {\n animation: slideDown 200ms ease-in-out;\n }\n .CollapsibleContent[data-state="closed"] {\n animation: slideUp 200ms ease-in-out;\n }\n\n @keyframes slideDown {\n from {\n height: 0;\n }\n to {\n height: var(--radix-collapsible-content-height);\n }\n }\n\n @keyframes slideUp {\n from {\n height: var(--radix-collapsible-content-height);\n }\n to {\n height: 0;\n }\n }\n '),a)};function lt({feedback:e,onFeedback:a,textConfig:n={},disabled:o=!1}){const[s,i]=r(!1),l=e=>{a&&("accept"===e&&(i(!0),setTimeout((()=>i(!1)),2e3)),a(e))};return t.createElement("div",{className:"flex justify-end gap-2","data-name":"Feedback"},t.createElement(be,null,t.createElement(ve,null,t.createElement(Ee,{asChild:!0},t.createElement("div",{className:"relative"},t.createElement(h,null,s&&t.createElement(t.Fragment,null,Array.from({length:8}).map(((e,a)=>t.createElement(f.div,{key:a,className:"absolute top-1/2 left-1/2 origin-center",initial:{opacity:0,scale:.3,x:0,y:0},animate:{opacity:[0,1,1,0],scale:[.3,1,1,0],x:[0,30*Math.cos(a*(Math.PI/4))],y:[0,30*Math.sin(a*(Math.PI/4))],rotate:[0,a%2?45:-45]},transition:{duration:1.2,ease:[.4,0,.2,1],times:[0,.3,.7,1],delay:.1*a}},t.createElement(F,{className:"size-4 text-rose-500",style:{filter:"drop-shadow(0 0 3px rgba(255, 75, 110, 0.8))",strokeWidth:2.5}})))),t.createElement(f.div,{className:"absolute inset-0 rounded-full bg-primary",initial:{opacity:0,scale:.8},animate:{opacity:[0,.15,.15,0],scale:[.8,1.8,1.8,2]},transition:{duration:1.2,ease:"easeOut",times:[0,.3,.7,1]}}))),t.createElement(ze,{variant:"ghost",size:"sm",className:"rounded-md size-8 flex items-center justify-center transition-all duration-200 transform hover:scale-105 active:scale-95 "+("accept"===e?"bg-green-100 text-green-600 hover:bg-green-200":"text-dark-500"),onClick:()=>l("accept"),disabled:o},t.createElement(f.div,{initial:{scale:1},animate:{scale:"accept"===e?[1,1.2,1]:1},transition:{duration:.3}},t.createElement(j,{weight:"bold"}))))),t.createElement(xe,null,t.createElement("p",null,n.positiveAnswerText||"Helpful")))),t.createElement(be,null,t.createElement(ve,null,t.createElement(Ee,{asChild:!0},t.createElement(ze,{variant:"ghost",size:"sm",className:"rounded-md size-8 flex items-center justify-center transition-all duration-200 transform hover:scale-105 active:scale-95 "+("reject"===e?"bg-red-100 text-red-600 hover:bg-red-200":"text-dark-500"),onClick:()=>l("reject"),disabled:o},t.createElement(f.div,{initial:{scale:1},animate:{scale:"reject"===e?[1,1.2,1]:1},transition:{duration:.3}},t.createElement(S,{weight:"bold"})))),t.createElement(xe,null,t.createElement("p",null,n.negativeAnswerText||"Not helpful")))))}const ct="answers/set_answers",dt="answers/clear_all",mt="answers/create_empty_answer",ut="answers/append_block",pt="answers/append_stream_chunk",ht="answers/update_search_results",ft="answers/set_follow_up_questions",gt="answers/finish_streaming",yt="answers/set_error_state",bt="answers/set_user_feedback",vt="answers/clear_user_feedback",Et="answers/mark_as_uncertain",xt="answers/request_action_inputs",wt="answers/invoke_action",Nt="answers/add_action_buttons",kt=()=>({type:dt}),Ct=({text:e,index:t})=>({type:pt,payload:{text:e,index:t}}),It=({error:e,index:t})=>({type:yt,payload:{error:e,index:t}}),Ft=({index:e}={})=>({type:gt,payload:{index:e}}),jt=({uncertaintyText:e,index:t})=>({type:Et,payload:{uncertaintyText:e,index:t}}),St=({searchIntentId:e,actionId:t,schema:a,initialValues:r,onSubmit:n,index:o})=>({type:xt,payload:{searchIntentId:e,actionId:t,schema:a,initialValues:r,onSubmit:n,index:o}}),zt=({searchIntentId:e,index:t})=>({type:Nt,payload:{searchIntentId:e,index:t}}),At=(e,t)=>e.at(null!=t?t:-1),Ot=e=>e.blocks.at(-1),Tt=[],Rt=(e,t)=>{var a;switch(t.type){case ct:return e.length=0,void e.push(...t.payload.answers);case dt:return void(e.length=0);case mt:return void e.push({id:"pending-"+ee(),state:"fetching-search-results",question:t.payload.query,blocks:[at()],isUncertain:!1});case ht:{const a=At(e,t.payload.index);return void(a&&(a.searchQueryId=t.payload.searchQueryId,a.searchResults=t.payload.results,a.state="fetching-stream"))}case pt:{const a=At(e,t.payload.index),r=a&&Ot(a);return void(a&&!a.isUncertain&&r&&rt(r)&&(a.state="streaming",r.text+=t.payload.text))}case yt:{const r=At(e,null!==(a=t.payload.index)&&void 0!==a?a:-1),n=r&&Ot(r);return void(n&&rt(n)&&(n.text+=t.payload.error))}case ut:{const a=At(e,t.payload.index);return void(a&&a.blocks.push(t.payload.block))}case gt:{const a=At(e,t.payload.index);return void(a&&"streaming"===a.state&&(a.state="completed"))}case Et:{const a=At(e,t.payload.index),r=a&&Ot(a);return void(a&&r&&rt(r)&&(a.isUncertain=!0,r.text=t.payload.uncertaintyText))}case bt:{const a=At(e,t.payload.index);return void(a&&(a.feedback=t.payload.feedback))}case vt:{const a=At(e,t.payload.index);return void(a&&delete a.feedback)}case xt:{const a=At(e,t.payload.index);return void(a&&(a.state="getting-action-inputs",a.searchIntentId=t.payload.searchIntentId,a.blocks.push((({actionId:e,schema:t,initialValues:a,onSubmit:r})=>({id:ee(),type:"action-input-form",state:"ready",actionId:e,schema:t,initialValues:a,onSubmit:r}))({actionId:t.payload.actionId,schema:t.payload.schema,initialValues:t.payload.initialValues,onSubmit:t.payload.onSubmit}))))}case Nt:{const a=At(e,t.payload.index);return void(a&&(a.searchIntentId=t.payload.searchIntentId,a.blocks.push({id:ee(),type:"action-buttons"})))}case wt:{const a=At(e,t.payload.index),r=null==a?void 0:a.blocks.findIndex(nt);return void(a&&r&&(a.state="fetching-stream",a.blocks.splice(r,1,at())))}case ft:{const a=At(e,t.payload.index);return void(a&&(a.followUpQuestions=t.payload.questions))}default:throw new Error(`Answer List Reducer: unknown action type '${t.type}'`)}},Lt="conversation",Dt=i(void 0),Qt=({children:e,searchPath:a})=>{const[n,o]=r(""),[i,c]=r(""),[d,m]=r(""),[u,p]=r(!1),[h,f]=r(!1),[g,y]=ae(Rt,Tt),[b,v]=r(0),[E,x]=r(!1),[w,N]=r(""),[k,C]=r(!1),{conversationId:I,setConversationId:F,clearConversationId:j}=(e=>{const t=re(Lt),[a,n]=r(null!=t?t:void 0);return{conversationId:a,setConversationId:s((t=>{const a=new URL(window.location.href);e&&(a.pathname=e),t?a.searchParams.set(Lt,t):a.searchParams.delete(Lt);const r=a.toString();window.history.replaceState(Object.assign(Object.assign({},window.history.state),{newUrl:r,url:r}),"",r),n(t)}),[e]),clearConversationId:s((()=>{const e=new URL(window.location.href);e.searchParams.delete(Lt);const t=e.toString();window.history.replaceState(Object.assign(Object.assign({},window.history.state),{newUrl:t,url:t}),"",t),n(void 0)}),[])}})(a),S=l((()=>({query:n,setQuery:o,queryId:i,setQueryId:c,followUpQuery:d,setFollowUpQuery:m,isSearching:u,setIsSearching:p,showResults:h,setShowResults:f,answers:g,answerListDispatch:y,activeAnswerIndex:b,setActiveAnswerIndex:v,conversationId:I,setConversationId:F,clearConversationId:j,isLoadingConversation:E,setIsLoadingConversation:x,loadError:w,setLoadError:N,showMobileCloseWidgetButton:k,setShowMobileCloseWidgetButton:C})),[n,i,d,u,h,g,y,b,I,F,j,E,w,k]);return t.createElement(Dt.Provider,{value:S},e)},qt=()=>{const e=c(Dt);if(!e)throw new Error("useChatSearch must be used within a ChatSearchProvider");return e},Bt=()=>{const{showResults:e,answers:t}=qt();return Boolean(e||t.length>0)},_t={maxRetries:3,baseDelay:1e3,shouldRetry:e=>{if(e instanceof TypeError)return!0;const t=e;return!!t.status&&t.status>=500}};let $t=Object.assign({},_t),Pt=Object.assign({},{emptyResponse:"I apologize, but I couldn't generate an answer at this time. Please try again.",errorResponse:"I encountered an error while processing your request. Please try again."});function Ut(e){return fe(this,void 0,void 0,(function*(){return new Promise((t=>setTimeout(t,e)))}))}function Mt(e,t={}){return fe(this,void 0,void 0,(function*(){const{retry:a={},headers:r={},body:n,isStream:o=!1,fallback:s={}}=t,i=he(t,["retry","headers","body","isStream","fallback"]),l=Object.assign(Object.assign({},$t),a),c=Object.assign(Object.assign({},Pt),s);let d=1;for(;;)try{const t=yield fetch(e,Object.assign(Object.assign({},i),{headers:Object.assign({"Content-Type":"application/json"},r),body:n?JSON.stringify(n):void 0}));if(t.ok){if(o){if(!t.ok)throw new Error("Failed to fetch answer");return t}const e=yield t.json();if(!e||"object"==typeof e&&0===Object.keys(e).length){const e=new Error(c.emptyResponse);throw e.name="EmptyResponseError",e}return e}const a=new Error(c.errorResponse);throw a.status=t.status,a.data=yield t.json().catch((()=>{})),a}catch(e){const t=yield Promise.resolve(l.shouldRetry(e,d));if(d>=l.maxRetries||!t){if(e instanceof Error&&"EmptyResponseError"===e.name)return{message:e.message};throw e}console.warn(`Request failed, attempt ${d} of ${l.maxRetries}. Retrying...`);const a=.3*Math.random()+.85;yield Ut(l.baseDelay*Math.pow(2,d-1)*a),d++}}))}const Vt={maxRetries:3,baseDelay:300,shouldRetry:e=>{if(e instanceof TypeError)return!0;const t=e;return!!t.status&&(t.status>=500||429===t.status)}},Wt={maxRetries:3,baseDelay:500,shouldRetry:e=>{if(e instanceof TypeError)return!0;const t=e;return!!t.status&&t.status>=500}};function Zt({endpoint:e,headers:t,body:a}){return fe(this,void 0,void 0,(function*(){return Mt(e,{method:"POST",headers:t,retry:Wt,isStream:!0,fallback:{emptyResponse:"I apologize, but I couldn't generate an answer for your query. Please try rephrasing your question.",errorResponse:"I encountered an issue while generating the answer. Please try again in a moment."},body:a})}))}const Ht=({loadConversationEndpoint:e,headers:t,mergedTextConfig:a})=>{const{setIsLoadingConversation:r,setShowResults:n,answerListDispatch:o,conversationId:i,setConversationId:l,clearConversationId:c,setLoadError:d}=qt(),m=s((s=>{if(!e)return;r(!0),r(!0),n(!0);const i=new AbortController;return function({endpoint:e,conversationId:t,headers:a,signal:r}){return fe(this,void 0,void 0,(function*(){return{data:(yield Mt(e,{method:"POST",headers:a,body:{conversationId:t},signal:r})).data}}))}({endpoint:e,conversationId:s,headers:t,signal:i.signal}).then((({data:e})=>{const t=e.map((e=>({id:e.searchQueryId,state:"completed",question:e.question,isUncertain:ye(e.answer).uncertain,searchQueryId:e.searchQueryId,searchIntentId:e.searchIntentId,blocks:e.answer.split("---").map((e=>at({text:e.trim()})))})));o((({answers:e})=>({type:ct,payload:{answers:e}}))({answers:t})),n(!0)})).catch((e=>{console.error("Error loading conversation:",e),o(kt()),c(),n(!1),d(a.errorText||"An error occurred")})).finally((()=>{r(!1)})),()=>i.abort("Conversation loader aborted")}),[e,r,n,t,o,l,d,a.errorText]);return ne((()=>{let e;return i&&(console.log("loading conversation",i),e=m(i)),()=>null==e?void 0:e()})),{loadConversationById:m}},Kt=(e,t)=>{const[a,n]=r(`rgb(var(${t}))`),s=(()=>{const[e,t]=r((()=>document.documentElement.classList.contains("dark")));return o((()=>{const e=new MutationObserver((()=>{t(document.documentElement.classList.contains("dark"))}));return e.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>e.disconnect()}),[]),e})();return o((()=>{const a=getComputedStyle(document.documentElement).getPropertyValue(e).trim().match(/^(\d+)\s+(\d+)\s+(\d+)$/);if(a){const r=function(e){const[t,a,r]=e.split(",").map(Number),[n,o,s]=[t,a,r].map((e=>(e/=255)<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)));return.2126*n+.7152*o+.0722*s}(a.slice(1).join(","));n(r<=.5?s?"rgb(var(--bfc-ring))":`rgb(var(${e}))`:s?`rgb(var(${e}))`:`rgb(var(${t}))`)}}),[e,t,s]),a},Gt=e=>{var{loading:a,className:r}=e,n=he(e,["loading","className"]);const o=Kt("--bfc-primary","--bfc-border");return t.createElement("svg",Object.assign({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",className:ge("min-w-5",r)},n),t.createElement("path",{className:a?"animate-spin":"",d:"M7.54672 16.0031L2.66234 14.2031C2.51881 14.1498 2.39502 14.0539 2.3076 13.9282C2.22019 13.8025 2.17333 13.6531 2.17333 13.5C2.17333 13.3469 2.22019 13.1975 2.3076 13.0718C2.39502 12.9461 2.51881 12.8501 2.66234 12.7969L7.54672 10.9969C7.64981 10.9589 7.74344 10.899 7.82113 10.8213C7.89882 10.7436 7.95873 10.65 7.99672 10.5469L9.79672 5.66249C9.84999 5.51896 9.94592 5.39517 10.0716 5.30775C10.1973 5.22033 10.3467 5.17348 10.4998 5.17348C10.6529 5.17348 10.8024 5.22033 10.9281 5.30775C11.0538 5.39517 11.1497 5.51896 11.203 5.66249L13.003 10.5469C13.041 10.65 13.1009 10.7436 13.1786 10.8213C13.2562 10.899 13.3499 10.9589 13.453 10.9969L18.3373 12.7969C18.4809 12.8501 18.6047 12.9461 18.6921 13.0718C18.7795 13.1975 18.8264 13.3469 18.8264 13.5C18.8264 13.6531 18.7795 13.8025 18.6921 13.9282C18.6047 14.0539 18.4809 14.1498 18.3373 14.2031L13.453 16.0031C13.3499 16.0411 13.2562 16.101 13.1786 16.1787C13.1009 16.2564 13.041 16.35 13.003 16.4531L11.203 21.3375C11.1497 21.481 11.0538 21.6048 10.9281 21.6922C10.8024 21.7796 10.6529 21.8265 10.4998 21.8265C10.3467 21.8265 10.1973 21.7796 10.0716 21.6922C9.94592 21.6048 9.84999 21.481 9.79672 21.3375L7.99672 16.4531C7.95873 16.35 7.89882 16.2564 7.82113 16.1787C7.74344 16.101 7.64981 16.0411 7.54672 16.0031Z",stroke:o,strokeWidth:"1.5",strokeLinecap:"round",fill:"rgb(var(--bfc-primary))",strokeLinejoin:"round"}),t.createElement("path",{d:"M18.7497 3.75L14.2497 3.75",stroke:"rgb(var(--bfc-primary))",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),t.createElement("path",{d:"M16.4999 6V1.5",stroke:"rgb(var(--bfc-primary))",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),t.createElement("path",{d:"M22.4999 8.25001H19.4999",stroke:"rgb(var(--bfc-primary))",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),t.createElement("path",{d:"M20.9998 9.75002V6.75002",stroke:"rgb(var(--bfc-primary))",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}))};function Jt({blocks:e=[],question:a,searchResults:n,state:o="completed",searchQueryId:s,feedback:i,onFeedback:l,disableFeedback:c=!1,textConfig:d={}}){const[m,u]=r(!1),[p,h]=r(!1),f=e.filter(rt).map((e=>e.text)).join("\n\n---\n\n"),g=("fetching-search-results"===o||"fetching-stream"===o)&&1===e.length,y="fetching-search-results"===o,b="getting-action-inputs"===o||"completed"===o,v="completed"===o,E=()=>fe(this,void 0,void 0,(function*(){try{yield navigator.clipboard.writeText(f)}catch(e){console.warn("Clipboard API failed, using fallback:",e);const t=document.createElement("textarea");t.value=f,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.focus(),t.select();try{document.execCommand("copy")}catch(e){console.error("Fallback: Oops, unable to copy",e)}document.body.removeChild(t)}u(!0),setTimeout((()=>u(!1)),2e3)}));return t.createElement("div",{className:"rounded-lg relative mx-auto overflow-hidden bg-card border border-primary mb-4","data-name":"SearchResults"},t.createElement("div",{className:"p-4 pb-0"},t.createElement("div",{className:"flex items-start justify-between gap-2 min-h-9"},t.createElement("div",{className:"flex gap-1"},t.createElement(Gt,{loading:!b}),t.createElement("h2",{className:"leading-normal font-semibold m-0 text-foreground self-center"},a)),v&&t.createElement(be,null,t.createElement(ve,null,t.createElement(Ee,{asChild:!0},t.createElement(ze,{variant:"ghost",size:"icon",onClick:()=>{E()},className:"-mt-1 flex-shrink-0"},m?t.createElement(z,{className:"text-feedback-positive",weight:"bold"}):t.createElement(A,{className:"text-secondary-foreground",weight:"bold"}))),t.createElement(xe,null,t.createElement("p",null,m?"Copied!":"Copy")))))),g&&t.createElement("div",{className:"space-y-4 mt-2 px-4"},t.createElement("div",{className:"flex items-center gap-2"},t.createElement("div",{className:"size-5 rounded-full bg-primary/30"}),t.createElement("div",{className:"flex items-center gap-2 text-sm text-foreground"},y?d.loadingSearchText:d.loadingAnswerText))),t.createElement("div",{className:"flex flex-col"},null==e?void 0:e.map(((e,a)=>t.createElement("div",{key:a,className:"p-4 border-b last:border-b-0 border-dashed"},t.createElement(tt,{block:e}))))),v&&!c&&t.createElement("div",{className:"p-4 pt-0"},t.createElement(lt,{feedback:i,onFeedback:e=>{l&&s&&l(e)},textConfig:d,disabled:c})),n&&n.length>0&&t.createElement("div",{className:"overflow-hidden bg-card border-dashed border-0 border-t-2"},t.createElement(ot,{open:p,onOpenChange:h,className:"w-full"},t.createElement("div",null,t.createElement(st,{asChild:!0},t.createElement(ze,{variant:"secondary",className:"w-full justify-between h-11","data-name":"RelatedSources"},t.createElement("div",{className:"flex items-center gap-2"},t.createElement("span",{className:"font-medium truncate text-base"},"Sources")),t.createElement(O,{className:"size-4 flex-shrink-0 transition-transform duration-200 text-secondary-foreground "+(p?"rotate-180":""),weight:"bold"}),t.createElement("span",{className:"sr-only"},"Toggle")))),t.createElement(it,{className:"divide-y divide-gray-200 dark:divide-border overflow-hidden CollapsibleContent"},n.map((e=>t.createElement("a",{key:e.id,href:e.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 p-3 transition-colors duration-200 hover:bg-accent bg-card text-foreground"},t.createElement("span",{className:"flex-grow truncate"},e.title),t.createElement(T,{className:"size-4 flex-shrink-0 text-secondary-foreground",weight:"bold"}))))))))}const Yt=f(ze);function Xt({questions:e,onQuestionClick:a}){return e.length?t.createElement(f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"w-full"},t.createElement("div",{className:"rounded-lg overflow-hidden bg-card border border-dark-300"},t.createElement("h3",{className:"px-4 py-3 border-b border-b-dark-300 font-bold"},"Follow-up questions"),e.map(((e,r)=>r<3?t.createElement(Yt,{key:r,initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.1*r},onClick:()=>a(e),variant:"ghost",className:"w-full text-left"},t.createElement("span",{className:"flex-grow"},e),t.createElement(R,{className:"",weight:"bold"})):null)))):null}const ea=e=>{var{iconName:a}=e,r=he(e,["iconName"]);const n=d((()=>import("@phosphor-icons/react").then((e=>({default:e[a]})))));return t.createElement(m,{fallback:t.createElement("div",null,"Loading...")},t.createElement(n,Object.assign({},r)))},ta=f(ze),aa=({nextBestActions:e,onActionClick:a})=>e.length?t.createElement(f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"w-full"},t.createElement("div",{className:"rounded-lg overflow-hidden bg-card border border-dark-300 divide-y divide-dark-300"},e.map(((e,r)=>{const n=()=>{a(e)},o="w-full h-12 py-2 px-4 inline-flex items-center justify-center gap-2 whitespace-nowrap text-base font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 hover:bg-accent hover:text-accent-foreground";switch(e.type){case"email":return t.createElement(f.a,{key:e.id,initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.1*r},href:`mailto:${e.value}`,target:"_blank",rel:"noopener noreferrer",className:o,onClick:()=>n()},t.createElement(ea,{iconName:e.icon}),t.createElement("span",{className:"flex-grow"},e.label),t.createElement(ea,{iconName:"ArrowSquareOut"}));case"link":return t.createElement(f.a,{key:e.id,initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.1*r},href:e.value,target:"_blank",rel:"noopener noreferrer",className:o,onClick:()=>n()},t.createElement(ea,{iconName:e.icon}),t.createElement("span",{className:"flex-grow"},e.label),t.createElement(ea,{iconName:"ArrowSquareOut"}));case"phone":return t.createElement(f.a,{key:e.id,initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.1*r},href:`tel:${e.value}`,target:"_blank",rel:"noopener noreferrer",className:o,onClick:()=>n()},t.createElement(ea,{iconName:e.icon}),t.createElement("span",{className:"flex-grow"},e.label));default:return t.createElement(ta,{key:e.id,initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.1*r},className:"w-full text-left h-12 rounded-none",variant:"ghost",onClick:()=>n()},t.createElement(ea,{iconName:"ArrowCircleRight"}),t.createElement("span",{className:"flex-grow"},e.label),t.createElement(ea,{iconName:"ArrowSquareOut"}))}})))):null;function ra({questions:e,activeIndex:a,onNavigate:n,offset:s}){const[i,l]=r(a);o((()=>{l(a)}),[a]);const c=e.length,d=(()=>{const e=[];let t=null;const r=a=>{null!==t&&a-t>1&&e.push("ellipsis"),e.push(a),t=a};r(0);for(let e=Math.max(1,a-2);e<=Math.min(c-2,a+2);e++)r(e);return c>1&&r(c-1),e})();return t.createElement("nav",{"aria-label":"Question timeline navigation",className:"fixed left-4 top-1/2 -translate-y-1/2 z-40 flex flex-col gap-3",style:Object.assign({},s?{left:`${s}px`}:{})},t.createElement(f.div,{className:"flex flex-col items-center space-y-3",role:"list",initial:!1,animate:{y:0},transition:{type:"spring",stiffness:300,damping:30}},t.createElement(h,null,d.map(((r,o)=>{if("ellipsis"===r)return t.createElement(f.div,{key:`ellipsis-${o}`,className:"h-8 flex items-center justify-center","aria-hidden":"true",initial:{opacity:0,y:i>a?-20:20},animate:{opacity:1,y:0},exit:{opacity:0,y:i>a?20:-20},transition:{duration:.2}},t.createElement(L,{className:"size-4 text-foreground"}));const s=r,l=e[s];return t.createElement(f.div,{key:s,className:"relative group isolate",role:"listitem",initial:{opacity:0,y:i>a?-20:20},animate:{opacity:1,y:0},exit:{opacity:0,y:i>a?20:-20},transition:{duration:.2},layout:!0},t.createElement(be,{delayDuration:100},t.createElement(ve,null,t.createElement(Ee,{asChild:!0},t.createElement("button",{onClick:()=>n(s),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||n(s)},className:ge("flex items-center justify-center size-8 rounded-full transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 hover:opacity-90 cursor-pointer ring-primary ",s===a?"bg-primary text-primary-foreground":"bg-stone-300 text-zinc-800"),"aria-label":`Navigate to question ${s+1}: ${l}`,"aria-current":s===a?"step":void 0},s+1)),t.createElement(xe,{side:"right",sideOffset:8,className:"max-w-[300px] bg-card text-card-foreground border-foreground/35"},t.createElement("p",{className:"break-words leading-relaxed"},l)))))})))))}function na({onClick:e}){return t.createElement(ze,{size:"icon",variant:"secondary",className:"fixed bottom-20 right-4 rounded-full transition-opacity duration-300 border-border shadow-md",onClick:e},t.createElement(D,{className:"size-5"}))}const oa=oe.Root,sa=oe.Trigger,ia=oe.Group,la=oe.Portal,ca=oe.Sub,da=oe.RadioGroup,ma=e.forwardRef(((t,a)=>{var{className:r,inset:n,children:o}=t,s=he(t,["className","inset","children"]);return e.createElement(oe.SubTrigger,Object.assign({ref:a,className:ge("flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm !outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",n&&"pl-8",r)},s),o,e.createElement(se,{className:"ml-auto"}))}));ma.displayName=oe.SubTrigger.displayName;const ua=e.forwardRef(((t,a)=>{var{className:r}=t,n=he(t,["className"]);return e.createElement(oe.SubContent,Object.assign({ref:a,className:ge("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",r)},n))}));ua.displayName=oe.SubContent.displayName;const pa=e.forwardRef(((t,a)=>{var{className:r,sideOffset:n=4}=t,o=he(t,["className","sideOffset"]);return e.createElement(oe.Portal,null,e.createElement(oe.Content,Object.assign({ref:a,sideOffset:n,className:ge("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",r)},o)))}));pa.displayName=oe.Content.displayName;const ha=e.forwardRef(((t,a)=>{var{className:r,inset:n}=t,o=he(t,["className","inset"]);return e.createElement(oe.Item,Object.assign({ref:a,className:ge("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm !outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-5 [&>svg]:shrink-0",n&&"pl-8",r)},o))}));ha.displayName=oe.Item.displayName;const fa=e.forwardRef(((t,a)=>{var{className:r,children:n,checked:o}=t,s=he(t,["className","children","checked"]);return e.createElement(oe.CheckboxItem,Object.assign({ref:a,className:ge("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm !outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",r),checked:o},s),e.createElement("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center"},e.createElement(oe.ItemIndicator,null,e.createElement(ie,{className:"h-4 w-4"}))),n)}));fa.displayName=oe.CheckboxItem.displayName;const ga=e.forwardRef(((t,a)=>{var{className:r,children:n}=t,o=he(t,["className","children"]);return e.createElement(oe.RadioItem,Object.assign({ref:a,className:ge("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm !outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",r)},o),e.createElement("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center"},e.createElement(oe.ItemIndicator,null,e.createElement(le,{className:"h-2 w-2 fill-current"}))),n)}));ga.displayName=oe.RadioItem.displayName;const ya=e.forwardRef(((t,a)=>{var{className:r,inset:n}=t,o=he(t,["className","inset"]);return e.createElement(oe.Label,Object.assign({ref:a,className:ge("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",r)},o))}));ya.displayName=oe.Label.displayName;const ba=e.forwardRef(((t,a)=>{var{className:r}=t,n=he(t,["className"]);return e.createElement(oe.Separator,Object.assign({ref:a,className:ge("-mx-1 my-1 h-px bg-muted",r)},n))}));ba.displayName=oe.Separator.displayName;const va=t=>{var{className:a}=t,r=he(t,["className"]);return e.createElement("span",Object.assign({className:ge("ml-auto text-xs tracking-widest opacity-60",a)},r))};va.displayName="DropdownMenuShortcut";const Ea=t.forwardRef((({query:e,onQueryChange:a,onSearch:s,textConfig:i,collections:l=[],currentCollectionId:c,onCollectionChange:d,disableImageAttachment:m=!1,attachedImages:u=[],onImageUpload:p,onRemoveImage:g,isSearching:y=!1,autocompleteSuggestions:b=[],onAutocompleteSuggestionSelect:v},E)=>{var x;const w=n(null),[k,C]=r(!1);o((()=>{const e=e=>{e.target.closest(".suggestions-dropdown")||C(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]),o((()=>{e.trim()&&C(!0)}),[e]);const I=k&&e.trim()&&b.length>0,F={hidden:{opacity:0,x:-4},visible:{opacity:1,x:0,transition:{duration:.2}}};return t.createElement("div",{className:"relative w-full","data-name":"PrimarySearch"},t.createElement("div",{className:ge("w-full overflow-hidden bg-background border border-border transition-all",I?"rounded-t-md":"rounded-md")},t.createElement("div",{className:"p-3 flex items-center bg-card"},t.createElement(Q,{className:"h-5 w-5 mr-2 text-muted-foreground","aria-hidden":!0,role:"presentation"}),t.createElement("textarea",{ref:E,value:e,onChange:e=>{var t;a(e.target.value),(t=e.target).style.height="auto",t.style.height=`${t.scrollHeight}px`},onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),s())},onFocus:()=>C(!0),placeholder:i.searchPlaceholder,className:"\n w-full\n resize-none\n !outline-none\n text-base\n py-1\n min-h-9\n overflow-hidden\n border-none\n bg-transparent\n shadow-none\n placeholder:text-gray-400\n text-dark-900\n dark:text-neutral-200\n !ring-0\n ",rows:1}),y&&t.createElement("div",{className:"flex items-center justify-center ml-2"},t.createElement("div",{className:"animate-spin rounded-full size-4 border-2 border-t-transparent border-primary"}))),!m&&u.length>0&&t.createElement("div",{className:"flex gap-2 mt-3 overflow-x-auto pb-1 px-3"},u.map(((e,a)=>t.createElement("div",{key:a,className:"relative group rounded-lg overflow-hidden flex-shrink-0 size-20"},t.createElement("img",{src:e.preview,alt:`Attached ${a+1}`,className:"w-full h-full object-cover"}),t.createElement("button",{onClick:()=>null==g?void 0:g(a),className:"\n absolute\n top-1\n right-1\n rounded-full\n p-1\n opacity-0\n group-hover:opacity-100\n transition-opacity\n duration-200\n hover:bg-black/70\n bg-black/50\n "},t.createElement(q,{className:"size-3 text-white","aria-label":"Remove image"})))))),!I&&t.createElement("div",{className:"flex items-center justify-between px-3 py-2 border-t border-border"},t.createElement("div",{className:"flex gap-1"},l.length>0&&t.createElement(oa,null,t.createElement(sa,{asChild:!0},t.createElement(ze,{variant:"ghost",size:"sm",className:"\n transition-all\n duration-200\n rounded-md\n h-8\n flex\n items-center\n gap-1\n hover:bg-opacity-80\n text-foreground\n "},(null===(x=l.find((e=>e.id===c)))||void 0===x?void 0:x.name)||i.allDocumentsText||"All documents",t.createElement(O,{className:"size-4 text-secondary-foreground"}))),t.createElement(pa,{className:"max-w-48"},l.map((e=>t.createElement(ha,{key:e.id,onClick:()=>null==d?void 0:d(e.id)},e.id===c?t.createElement(N,{className:"rounded-full text-primary-500 !size-5",weight:"fill"}):t.createElement(B,{className:"rounded-full !size-5 text-gray-300"}),t.createElement("span",{className:"text-sm truncate"},e.name)))))),!m&&t.createElement(t.Fragment,null,t.createElement("input",{type:"file",ref:w,accept:"image/*",multiple:!0,className:"hidden",onChange:p}),t.createElement(ze,{variant:"ghost",size:"sm",className:"rounded-md h-8 hover:bg-opacity-80 dark:text-neutral-200",onClick:()=>{var e;return null===(e=w.current)||void 0===e?void 0:e.click()},"aria-label":i.attachImageText},t.createElement(_,{className:"size-4 text-secondary-foreground"}),t.createElement("span",{className:"hidden @sm:block"},i.attachImageText)))),t.createElement("div",{className:"flex items-center"},t.createElement(ze,{size:"sm",disabled:!e||y,"aria-disabled":!e||y,className:"rounded-md size-8 disabled:opacity-50 bg-primary",onClick:s},y?t.createElement("div",{className:"flex items-center",role:"status","aria-live":"polite"},t.createElement("div",{className:"animate-spin rounded-full size-4 border-2 border-t-transparent border-white","aria-hidden":"true"}),t.createElement("span",{className:"sr-only"},"Loading")):t.createElement($,{className:"text-primary-foreground",size:16,weight:"bold","aria-label":"Submit question"}))))),t.createElement(h,{mode:"wait"},I&&t.createElement(f.div,{variants:{hidden:{opacity:0,scale:.95,transformOrigin:"top"},visible:{opacity:1,scale:1,transition:{type:"spring",stiffness:500,damping:30,mass:.5}},exit:{opacity:0,scale:.95,transition:{duration:.15,ease:"easeOut"}}},initial:"hidden",animate:"visible",exit:"exit",className:"\n suggestions-dropdown\n absolute\n left-0\n right-0\n z-50\n overflow-hidden\n bg-card\n border-border\n border-b border-l border-r border-solid rounded-b-md shadow-md -mt-px\n "},t.createElement(f.div,{className:"md:hidden",variants:F},e.trim()&&t.createElement("div",{role:"option","aria-selected":!1,tabIndex:0,className:"\n px-4 py-3\n cursor-pointer\n flex\n items-center\n gap-3\n transition-colors\n duration-200\n hover:bg-gray-50/50\n text-foreground\n bg-gray-100\n border-b border border-border\n dark:bg-slate-500\n dark:border-dark-800/20\n ",onClick:()=>{s(),C(!1)},onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),s(),C(!1))}},t.createElement(Q,{className:"size-4 flex-shrink-0 text-secondary-foreground"}),t.createElement("span",{className:"text-[15px]"},e),t.createElement("div",{className:"ml-auto flex items-center"},t.createElement(R,{className:"size-4 text-secondary-foreground"})))),t.createElement(f.div,{variants:{visible:{transition:{staggerChildren:.03,delayChildren:.05}}},initial:"hidden",animate:"visible"},b.map((e=>t.createElement(f.div,{key:e.id,variants:F,role:"option","aria-selected":!1,tabIndex:0,className:"px-4 py-3 cursor-pointer flex items-center gap-3 transition-colors duration-200 hover:bg-gray-200/50 text-foreground",onClick:()=>{null==v||v(e),C(!1)},onKeyDown:t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),null==v||v(e),C(!1))}},t.createElement(Q,{className:"size-4 flex-shrink-0 text-secondary-foreground"}),t.createElement("span",{className:"text-[15px]"},e.question),t.createElement("div",{className:"ml-auto flex items-center"},t.createElement(R,{className:"size-4 text-secondary-foreground"})))))))))}));Ea.displayName="PrimarySearch";var xa="FollowUpSearchBar-module_followUpSearchBar__DiKdH";const wa=e.forwardRef(((t,a)=>{var{className:r}=t,n=he(t,["className"]);return e.createElement("textarea",Object.assign({className:ge("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",r),ref:a},n))}));wa.displayName="Textarea";const Na=t.forwardRef((({initialQuery:e="",onQueryChange:a,isSearching:s,handleFollowUpSearch:i,textConfig:l},c)=>{const[d,m]=r(e),u=n(null);o((()=>{u.current&&(u.current.style.height="inherit",u.current.style.height=`${u.current.scrollHeight}px`)}),[d]),o((()=>{m(e)}),[e]);return t.createElement(f.footer,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5},className:xa},t.createElement("div",{className:"container flex items-center justify-center p-3"},t.createElement("div",{className:"relative flex w-full items-center gap-2 rounded bg-card px-2 border border-dark-400"},t.createElement("div",{className:"size-6 flex flex-shrink-0 justify-center items-center"},t.createElement(Q,{className:"size-5 text-secondary-foreground"})),t.createElement(wa,{ref:e=>{u.current=e,"function"==typeof c?c(e):c&&"current"in c&&(c.current=e)},value:d,onChange:e=>{m(e.target.value)},onBlur:()=>{d!==e&&a(d)},onKeyDown:e=>{if("Enter"===e.key&&!e.shiftKey&&!s){e.preventDefault();const t=d;a(t),i(t),m("")}},placeholder:l.followUpPlaceholder,className:"min-h-[44px] w-full resize-none border-0 shadow-none bg-transparent px-0 py-2.5 focus:outline-none focus:ring-0 focus-visible:ring-0",rows:1}),t.createElement(ze,{type:"button",size:"icon",disabled:s||!d.trim(),onClick:()=>{const e=d;a(e),i(e),m("")},className:ge("size-8 shrink-0 rounded",d?"bg-primary text-primary-foreground":"bg-dark-400 dark:bg-muted text-white")},s?t.createElement("div",{className:"animate-spin rounded-full size-4 sm:size-5 border-2 border-dark/40 !border-t-foreground dark:border-dark-500 "}):t.createElement($,{className:"size-6"})))))}));function ka(e){var{headerText:a,onToggleSizeButtonClick:r,onBackButtonClick:n,onCloseWidgetClick:o,className:s}=e,i=he(e,["headerText","onToggleSizeButtonClick","onBackButtonClick","onCloseWidgetClick","className"]);const l=Bt(),[c,d]=t.useState(!1),{isSearching:m,showMobileCloseWidgetButton:u}=qt();return t.createElement("div",Object.assign({className:ge("w-full px-3 py-4 flex items-center justify-between","bg-primary h-14 leading-6","@3xl:bg-transparent @3xl:h-auto @3xl:leading-normal","@3xl:justify-center @3xl:space-y-4 @3xl:p-0",s)},i),t.createElement(f.h1,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,delay:.3},className:"@3xl:text-5xl m-0 text-primary-foreground @3xl:text-foreground flex gap-1 items-center font-bold text-base"},l&&t.createElement(ze,{size:"icon",variant:"ghost",onClick:n,"aria-label":"Go back",className:"@3xl:hidden",disabled:m},t.createElement(P,null)),t.createElement("span",null,a)),t.createElement("div",{className:"@3xl:hidden"},!u&&t.createElement(ze,{size:"icon",variant:"ghost",onClick:()=>{d((e=>!e)),r()},"aria-label":c?"Collapse widget":"Expand widget",className:"text-primary-foreground"},c?t.createElement(U,null):t.createElement(M,null)),t.createElement(ze,{size:"icon",variant:"ghost",onClick:o,"aria-label":"Close widget",className:"text-primary-foreground"},t.createElement(q,null))))}Na.displayName="FollowUpSearchBar";const Ca={headerText:"How can we help you today?",searchPlaceholder:"Ask a question or type a search term here ...",attachImageText:"Attach image",allDocumentsText:"All documents",loadingSearchText:"Searching for relevant content...",loadingAnswerText:"Crafting a response...",errorText:"Sorry, there was an error generating the answer.",followUpPlaceholder:"Ask follow-up",positiveAnswerText:"Helpful",negativeAnswerText:"Not helpful",uncertaintyFallbackText:{en:"Sorry, I can't find a clear answer to your question. Please try rephrasing or check the related sources below.",es:"Lo siento, no puedo encontrar una respuesta clara. Intente reformular la pregunta o consulte las fuentes relacionadas.",fr:"Désolé, je ne trouve pas de réponse claire. Essayez de reformuler ou consultez les sources connexes.",de:"Entschuldigung, ich finde keine klare Antwort. Versuchen Sie es anders zu formulieren oder sehen Sie sich die verwandten Quellen an.",it:"Mi dispiace, non trovo una risposta chiara. Prova a riformulare o consulta le fonti correlate.",pt:"Desculpe, não encontro uma resposta clara. Tente reformular ou consulte as fontes relacionadas.",nl:"Sorry, ik kan geen duidelijk antwoord vinden. Probeer het anders te formuleren of bekijk de gerelateerde bronnen.",pl:"Przepraszam, nie znajduję jasnej odpowiedzi. Spróbuj przeformułować pytanie lub sprawdź powiązane źródła.",ru:"Извините, я не могу найти четкого ответа. Попробуйте переформулировать или ознакомьтесь со связанными источниками.",ja:"申し訳ありませんが、明確な回答が見つかりません。質問の言い換えや、関連ソースをご確認ください。",ko:"죄송합니다. 명확한 답변을 찾을 수 없습니다. 질문을 다시 작성하거나 관련 소스를 확인해 주세요.",zh:"抱歉,找不到明确的答案。请尝试重新表述或查看相关来源。","zh-TW":"抱歉,找不到明確的答案。請嘗試重新表述或查看相關來源。"}},Ia=i(void 0);function Fa({children:e,flags:a}){return t.createElement(Ia.Provider,{value:null!=a?a:{}},e)}function ja({query:e,endpoint:t,collectionId:a,headers:n,conversationId:i,delay:l=300}){const[c,d]=r([]),[m,u]=r(!1),[p,h]=r(),f=function(e,t){const[a,n]=r(e);return o((()=>{const a=setTimeout((()=>{n(e)}),t);return()=>{clearTimeout(a)}}),[e,t]),a}(e,l),g=s((()=>fe(this,void 0,void 0,(function*(){var e;if(f.trim()){u(!0),h(void 0);try{const r=yield function({endpoint:e,query:t,collectionId:a,headers:r,conversationId:n}){return fe(this,void 0,void 0,(function*(){return yield Mt(e,{method:"POST",headers:r,retry:Vt,body:Object.assign(Object.assign({query:t},a&&"all"!==a&&{collectionId:a}),n&&{conversationId:n})})}))}({endpoint:t,query:f,collectionId:a,headers:n,conversationId:i});d(null===(e=null==r?void 0:r.response)||void 0===e?void 0:e.results)}catch(e){console.error("Error fetching autocomplete suggestions:",e),h(e instanceof Error?e.message:"Failed to fetch suggestions"),d([])}finally{u(!1)}}else d([])}))),[f,t,a,n,i]);return o((()=>{g()}),[g]),{suggestions:c,isLoading:m,error:p}}const Sa=e.forwardRef(((t,a)=>{var{className:r,children:n}=t,o=he(t,["className","children"]);return e.createElement(ce.Root,Object.assign({className:ge("relative overflow-hidden",r)},o),e.createElement(ce.Viewport,{ref:a,className:"h-full w-full rounded-[inherit]"},n),e.createElement(za,null),e.createElement(ce.Corner,null))}));Sa.displayName=ce.Root.displayName;const za=e.forwardRef(((t,a)=>{var{className:r,orientation:n="vertical"}=t,o=he(t,["className","orientation"]);return e.createElement(ce.ScrollAreaScrollbar,Object.assign({ref:a,orientation:n,className:ge("flex touch-none select-none transition-colors","vertical"===n&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===n&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",r)},o),e.createElement(ce.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-dark-400"}))}));za.displayName=ce.ScrollAreaScrollbar.displayName;const Aa=u((({suggestions:e=[],collections:a=[],selectedCollectionId:s,onCollectionChange:i,searchEndpoint:l,answerStreamEndpoint:c,feedbackEndpoint:d,loadConversationEndpoint:m,autocompleteEndpoint:u,disableFollowUpQuestions:g=!1,disableImageAttachment:y=!1,disableFeedback:b=!1,siblingNode:v,offset:E=0,headers:x,textConfig:w={},followUpQuestionsEndpoint:N,className:k,onToggleSizeButtonClick:C,trackEvent:I,onCloseWidget:F,isWidgetMode:j=!0,nextBestActions:S,onNextBestActionClick:z},A)=>{const{answers:O,answerListDispatch:T,query:R,setQuery:L,followUpQuery:D,setFollowUpQuery:Q,isSearching:q,setIsSearching:B,showResults:_,setShowResults:$,activeAnswerIndex:P,setActiveAnswerIndex:U,conversationId:M,setConversationId:V,clearConversationId:W,isLoadingConversation:Z,setShowMobileCloseWidgetButton:H}=qt(),K=Object.assign(Object.assign({},Ca),w),[G,J]=r(!1),[Y,X]=r([]),[te,ae]=r(s),[re,ne]=r(!0),oe=n(null),se=n([]),ie=n(null),le=n(null),ce=n(null),de=n(null),{suggestions:me}=ja({query:R,endpoint:u||"",collectionId:te,headers:x,conversationId:M,delay:300}),{loadConversationById:ue}=Ht({loadConversationEndpoint:m,headers:x,mergedTextConfig:K}),{scrollToLastAnswer:pe,scrollToAnswer:he}=((e,t)=>({scrollToLastAnswer:()=>{requestAnimationFrame((()=>{var a;const r=null===(a=e.current)||void 0===a?void 0:a[e.current.length-1],n=t.current;if(r&&n){const e=r.getBoundingClientRect(),t=n.getBoundingClientRect(),a=n.scrollTop+(e.top-t.top)-80;n.scrollTo({top:a,behavior:"smooth"})}}))},scrollToAnswer:a=>{requestAnimationFrame((()=>{var r;const n=null===(r=e.current)||void 0===r?void 0:r[a],o=t.current;if(n&&o){const e=n.getBoundingClientRect(),t=o.getBoundingClientRect(),a=o.scrollTop+(e.top-t.top)-80;o.scrollTo({top:a,behavior:"smooth"})}}))}}))(se,ie),{subscribeToStateChanges:be}=(()=>{const e=n([]),{showResults:t,answers:a,isLoadingConversation:r,loadError:s}=qt();return o((()=>{const n={showResults:t,answers:a,isLoading:r,error:s};e.current.forEach((e=>e(n)))}),[t,a,r,s]),{subscribeToStateChanges:n=>(e.current.push(n),n({showResults:t,answers:a,isLoading:r,error:s}),()=>{e.current=e.current.filter((e=>e!==n))})}})(),ve=(e,t)=>fe(void 0,void 0,void 0,(function*(){if(N&&!g)try{const a=yield function({endpoint:e,searchQueryId:t,headers:a,conversationId:r}){return fe(this,void 0,void 0,(function*(){return(yield Mt(e,{method:"POST",headers:a,body:Object.assign({searchQueryId:t},r&&{conversationId:r})})).questions}))}({endpoint:N,searchQueryId:e,headers:x,conversationId:t});return a}catch(e){return void console.error("Error fetching follow-up questions:",e)}})),Ee=({reader:e,searchQueryId:t,conversationId:a,onFirstEvent:r})=>fe(void 0,void 0,void 0,(function*(){var n,o,s,i;let l="";try{let c,d,m=!1,u=!0,p=!1;for(;({done:m,value:d}=yield e.read()),!m;){u&&(u=!1,null==r||r());const e=(new TextDecoder).decode(d).split(/\n\n/).filter((e=>e.startsWith("data: "))).map((e=>e.replace(/^data: /,"").trim()));for(const r of e)try{const e=JSON.parse(r);if("answer-text-chunk"===e.type){l+=e.content,T(Ct({text:e.content}));const t=ye(l);if(p=t.uncertain,p){const e=null!==(i=null!==(s=null===(n=K.uncertaintyFallbackText)||void 0===n?void 0:n[null!==(o=t.language)&&void 0!==o?o:"en"])&&void 0!==s?s:l)&&void 0!==i?i:"I don't know.";T(jt({uncertaintyText:e}))}}"action-buttons"===e.type&&(c=e.searchIntentId,T(zt({searchIntentId:c}))),"get-action-inputs"===e.type&&(c=e.searchIntentId,T(St({searchIntentId:e.searchIntentId,actionId:e.actionId,schema:e.schema,initialValues:e.values,onSubmit:r=>we({searchQueryId:t,conversationId:a,searchIntentId:e.searchIntentId,actionId:e.actionId,parameters:r})})))}catch(e){console.warn("Failed to parse answer stream block")}}return{answer:l,searchIntentId:c,isUncertain:p}}finally{e.releaseLock()}})),xe=({searchQueryId:e,conversationId:t})=>fe(void 0,void 0,void 0,(function*(){var a;try{const r=ve(e),n=null===(a=(yield Zt({endpoint:c,headers:x,body:{type:"generate-for-query",conversationId:t,searchQueryId:e}})).body)||void 0===a?void 0:a.getReader();if(!n)return;const{answer:o,searchIntentId:s,isUncertain:i}=yield Ee({reader:n,searchQueryId:e,conversationId:t,onFirstEvent:()=>{null==I||I("First Streamed Answer Chunk Received",{conversationId:t,searchQueryId:e})}});if(!o)return;r.then((e=>{e&&e.length>0&&!s&&T((({questions:e,index:t})=>({type:ft,payload:{questions:e,index:t}}))({questions:e}))})),i?null==I||I("Answer Not Found",{conversationId:t,searchQueryId:e}):null==I||I("Answer Found",{conversationId:t,searchQueryId:e})}catch(e){console.error("Error generating answer for query:",e),T(It({error:K.errorText||"An error occurred."}))}finally{T(Ft())}})),we=({searchQueryId:e,searchIntentId:t,conversationId:a,actionId:r,parameters:n})=>fe(void 0,void 0,void 0,(function*(){var o;T((({index:e}={})=>({type:wt,payload:{index:e}}))());try{const s=null===(o=(yield Zt({endpoint:c,headers:x,body:{type:"invoke-action",conversationId:a,searchQueryId:e,searchIntentId:t,actionId:r,parameters:n}})).body)||void 0===o?void 0:o.getReader();if(!s)return;yield Ee({reader:s,searchQueryId:e})}catch(e){console.error("Error generating answer for action:",e),T(It({error:K.errorText||"An error occurred."}))}finally{T(Ft()),B(!1)}})),Ne=(e,t)=>fe(void 0,void 0,void 0,(function*(){const a=yield function({endpoint:e,query:t,collectionId:a,headers:r,conversationId:n}){var o;return fe(this,void 0,void 0,(function*(){const s=yield Mt(e,{method:"POST",headers:r,retry:Vt,body:Object.assign(Object.assign({query:t,limit:5},a&&"all"!==a&&{collectionId:a}),n&&{conversationId:n})});return{results:null==s?void 0:s.data,searchQueryId:null===(o=null==s?void 0:s.searchQuery)||void 0===o?void 0:o.id}}))}({endpoint:l,query:e,collectionId:te,headers:x,conversationId:t});return 0===a.results.length&&(null==I||I("No Articles Found",{conversationId:t,searchQuery:e})),T((({searchQueryId:e,results:t,index:a})=>({type:ht,payload:{searchQueryId:e,results:t,index:a}}))({searchQueryId:a.searchQueryId,results:a.results})),a.searchQueryId})),ke=({searchQuery:e=R.trim(),event:t})=>fe(void 0,void 0,void 0,(function*(){var a;if(!e)return;const r=M||ee();V(r),B(!0),$(!0),U(O.length),pe(),T((({id:e,query:t})=>({type:mt,payload:{id:e,query:t}}))({query:e})),yield Promise.resolve(),null===(a=de.current)||void 0===a||a.focus();try{const a=yield Ne(e,r);t&&(null==I||I(t.name,Object.assign({conversationId:r,searchQuery:e,searchQueryId:a},t.metaData))),yield xe({searchQueryId:a,conversationId:r})}catch(a){console.error("Error generating answer:",a),t&&(null==I||I(`${t.name} - Search Error`,Object.assign({conversationId:r,searchQuery:e},t.metaData))),T(It({error:K.errorText||"An error occurred."}))}finally{B(!1)}})),Ce=e=>{if(e)return L(e),void ke({searchQuery:e,event:{name:"New Thread Created with Query"}});L(""),Q(""),$(!1),T(kt()),U(0),X([]),W(),null==I||I("New Thread Created",{oldConversationId:M}),oe.current&&(oe.current.style.height="auto")};p(A,(()=>({createNewThread:Ce,showFollowUpThread:e=>{ne(e)},subscribeToStateChanges:be,focusSearchField:()=>{var e,t;return(null===(e=ce.current)||void 0===e?void 0:e.focus())||(null===(t=de.current)||void 0===t?void 0:t.focus())},showCloseButton:(e=!0)=>{H(e)}}))),o((()=>{ae(s)}),[s]);const Ie=(e,t,a)=>fe(void 0,void 0,void 0,(function*(){if(d){T((({feedback:e,index:t})=>({type:bt,payload:{feedback:e,index:t}}))({feedback:e,index:a}));try{yield function({endpoint:e,searchQueryId:t,response:a,headers:r,conversationId:n}){return fe(this,void 0,void 0,(function*(){yield Mt(e,{method:"POST",headers:r,body:Object.assign({searchQueryId:t,response:a},n&&{conversationId:n})})}))}({endpoint:d,searchQueryId:t,response:e,headers:x,conversationId:M}),null==I||I("accept"===e?"Answer Accepted":"Answer Rejected",{conversationId:M,searchQueryId:t})}catch(e){console.error("Error sending feedback:",e),T((({index:e}={})=>({type:vt,payload:{index:e}}))({index:a}))}}}));o((()=>{const e=()=>{const e=window.innerHeight+window.pageYOffset>=document.documentElement.scrollHeight-100;J(!e)};return window.addEventListener("scroll",e),()=>window.removeEventListener("scroll",e)}),[]),o((()=>()=>{Y.forEach((e=>URL.revokeObjectURL(e.preview)))}),[Y]);o((()=>{const e=()=>{new URLSearchParams(window.location.search).get("conversation")||(L(""),Q(""),$(!1),T(kt()),U(0),X([]),oe.current&&(oe.current.style.height="auto"))};return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)}),[]);const Fe=e=>{null==I||I("Follow-up Question Clicked",{conversationId:M,question:e}),ke({searchQuery:e,event:{name:"Follow-up Question Clicked"}})};return t.createElement("div",{className:ge("w-full relative h-dvh flex flex-col justify-between @container",k),"data-name":"ChatSearch"},(j||!_)&&t.createElement(ka,{"data-name":"Header",headerText:K.headerText,onToggleSizeButtonClick:()=>{null==C||C()},onBackButtonClick:()=>{Ce()},onCloseWidgetClick:()=>null==F?void 0:F(),className:"@3xl:mb-4"}),t.createElement(Sa,{className:"w-full relative h-auto flex-grow",ref:ie},t.createElement(h,null,Z?t.createElement(f.div,{key:"loading",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"w-full flex items-center justify-center py-20","data-name":"loading"},t.createElement("div",{className:"flex flex-col items-center gap-4"},t.createElement("div",{className:"animate-spin rounded-full size-8 border-2 border-t-transparent border-primary"}),t.createElement("p",{className:"text-sm text-secondary-foreground"},"Loading conversation..."))):_?t.createElement(f.div,{key:"results",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.5},className:"w-full max-w-[100vw] space-y-4 p-3 md:p-4"},O.map(((e,a)=>t.createElement(f.div,{key:a,ref:e=>se.current[a]=e,initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,delay:.1*a}},t.createElement(Jt,{blocks:e.blocks,question:e.question,state:e.state,searchResults:e.searchResults,searchQueryId:e.searchQueryId,feedback:e.feedback,onFeedback:t=>{Ie(t,e.searchQueryId,a)},disableFeedback:b,textConfig:K}),a===O.length-1&&!g&&e.followUpQuestions&&"completed"===e.state&&t.createElement(t.Fragment,null,t.createElement("div",{className:"mt-4"},t.createElement(Xt,{questions:e.followUpQuestions,onQuestionClick:Fe})),t.createElement("div",{className:"mt-4"},t.createElement(aa,{nextBestActions:S||[],onActionClick:t=>(({action:e,searchQueryId:t,query:a,answer:r})=>{null==I||I("Next Best Action Clicked",{conversationId:M,searchQueryId:t,action:e.label}),null==z||z({action:e,searchQueryId:t,query:a,answer:r})})({action:t,searchQueryId:e.searchQueryId||"",query:R,answer:e.blocks.filter(rt).map((e=>e.text)).join("\n\n---\n\n")})}))))))):t.createElement(f.div,{key:"search",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5},className:"w-full"},t.createElement("div",{className:"pb-4 px-3 bg-primary @3xl:px-0 @3xl:bg-transparent"},t.createElement(f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,delay:.4}},t.createElement(Ea,{ref:ce,query:R,onQueryChange:e=>{var t;L(e),oe.current&&((t=oe.current).style.height="auto",t.style.height=`${t.scrollHeight}px`)},onSearch:()=>{((e=R.trim())=>{fe(void 0,void 0,void 0,(function*(){yield ke({searchQuery:e,event:{name:"Primary Field Search Submitted"}})}))})()},textConfig:K,collections:a,currentCollectionId:te,onCollectionChange:e=>{ae(e),null==i||i(e)},disableImageAttachment:y,attachedImages:Y,onImageUpload:e=>{const t=e.target.files;if(t){const e=Array.from(t).map((e=>({file:e,preview:URL.createObjectURL(e)})));X((t=>[...t,...e]))}le.current&&(le.current.value="")},onRemoveImage:e=>{X((t=>(URL.revokeObjectURL(t[e].preview),t.filter(((t,a)=>a!==e)))))},isSearching:q,autocompleteSuggestions:me,onAutocompleteSuggestionSelect:e=>{ke({searchQuery:e.question,event:{name:"Autocomplete Suggestion Clicked"}})}}))),t.createElement(Ae,{suggestions:e,onQuestionClick:e=>{if(e.conversationId)return null==I||I("Recent Conversation Clicked",{conversationId:M,question:e.question}),void ue(e.conversationId);ke({searchQuery:e.question,event:{name:"Suggested Question Clicked"}})},title:K.suggestionsTitle}),v)),_&&O.length>1&&t.createElement("div",{className:"hidden lg:block"},t.createElement(ra,{questions:O.map((e=>e.question)),activeIndex:P,onNavigate:e=>{U(e),he(e)},offset:E}))),_&&re&&t.createElement(Na,{ref:de,initialQuery:D,onQueryChange:Q,isSearching:q,handleFollowUpSearch:e=>fe(void 0,void 0,void 0,(function*(){const t=void 0!==e?e:D;t.trim()&&(L(t),Q(""),yield ke({searchQuery:t,event:{name:"Follow-up Search Field Submitted"}}))})),textConfig:K}),G&&_&&t.createElement(na,{onClick:pe}))}));Aa.displayName="ChatSearch";const Oa=u(((e,a)=>{var{featureFlags:r}=e,n=he(e,["featureFlags"]);return t.createElement(Fa,{flags:r},t.createElement(Qt,{searchPath:n.searchPath},t.createElement(Aa,Object.assign({},n,{ref:a}))))}));Oa.displayName="ChatSearch";const Ta=e.forwardRef(((t,a)=>{var{className:r}=t,n=he(t,["className"]);return e.createElement(de.Root,Object.assign({className:ge("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:!outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",r)},n,{ref:a}),e.createElement(de.Thumb,{className:ge("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")}))}));Ta.displayName=de.Root.displayName;export{pe as BrainfishColors,ze as Button,Oa as ChatSearch,Qt as ChatSearchProvider,Be as CodeBlock,ot as Collapsible,it as CollapsibleContent,st as CollapsibleTrigger,oa as DropdownMenu,fa as DropdownMenuCheckboxItem,pa as DropdownMenuContent,ia as DropdownMenuGroup,ha as DropdownMenuItem,ya as DropdownMenuLabel,la as DropdownMenuPortal,da as DropdownMenuRadioGroup,ga as DropdownMenuRadioItem,ba as DropdownMenuSeparator,va as DropdownMenuShortcut,ca as DropdownMenuSub,ua as DropdownMenuSubContent,ma as DropdownMenuSubTrigger,sa as DropdownMenuTrigger,Xe as FormattedMessage,Oe as Input,Re as Label,Ke as MemoizedReactMarkdown,Je as MermaidDiagram,Sa as ScrollArea,za as ScrollBar,Ta as Switch,wa as Textarea,ve as Tooltip,xe as TooltipContent,be as TooltipProvider,Ee as TooltipTrigger,Ye as ZoomableImage,Se as buttonVariants,me as customColor,qt as useChatSearch,Bt as useIsChatSearchDirty};
1
+ import*as e from"react";import t,{memo as a,useState as r,useRef as n,useEffect as o,useCallback as s,createContext as i,useMemo as l,useContext as c,lazy as d,Suspense as m,forwardRef as u,useImperativeHandle as p}from"react";import{AnimatePresence as h,motion as f}from"framer-motion";import*as g from"@radix-ui/react-tooltip";import{clsx as y}from"clsx";import{twMerge as b}from"tailwind-merge";import{jsx as v,Fragment as E}from"react/jsx-runtime";import{cva as x}from"class-variance-authority";import{XCircle as w,CheckCircle as N,Clipboard as k,Download as C,ArrowsOut as I,Heart as F,ThumbsUp as j,ThumbsDown as S,Check as z,Copy as A,CaretDown as O,ArrowSquareOut as T,CaretRight as R,ArrowsVertical as D,ArrowDown as L,MagnifyingGlass as Q,X as q,Circle as B,Image as _,ArrowRight as $,ArrowLeft as P,ArrowsInSimple as U,ArrowsOutSimple as M}from"@phosphor-icons/react";import{useForm as V}from"react-hook-form";import{ajvResolver as W}from"@hookform/resolvers/ajv";import*as Z from"@radix-ui/react-label";import H from"rehype-raw";import K from"remark-gfm";import{Prism as G}from"react-syntax-highlighter";import{a11yDark as J}from"react-syntax-highlighter/dist/esm/styles/prism";import Y from"react-markdown";import X from"mermaid";import{createId as ee}from"@paralleldrive/cuid2";import*as te from"@radix-ui/react-collapsible";import{useImmerReducer as ae}from"use-immer";import{useSearchParam as re,useEffectOnce as ne}from"react-use";import*as oe from"@radix-ui/react-dropdown-menu";import{ChevronRightIcon as se,CheckIcon as ie,DotFilledIcon as le}from"@radix-ui/react-icons";import*as ce from"@radix-ui/react-scroll-area";import*as de from"@radix-ui/react-switch";function me(e,t){return({opacityVariable:a,opacityValue:r})=>`rgb(var(${e}, ${t}) / ${void 0!==r?r:`var(${a}, 1)`})`}const ue={50:"#FAFAFA",100:"#F5F5F5",200:"#E5E5E5",300:"#D4D4D4",400:"#A3A3A3",500:"#737373",600:"#525252",700:"#404040",800:"#262626",900:"#171717",DEFAULT:"#171717"},pe={primary:{50:"#F7FEE8",100:"#ECFCCC",200:"#D9F99E",300:"#BEF265",400:"#A3E635",500:"#84CC17",600:"#65A30E",700:"#4E7C10",800:"#406213",900:"#375415",DEFAULT:me("--bfc-primary","#A3E635"),foreground:me("--bfc-primary-foreground",ue.DEFAULT)},dark:ue,orange:{50:"#FFF7EE",100:"#FFEDD6",200:"#FED7AB",300:"#FDBA75",400:"#FB923D",500:"#F97317",600:"#EA590D",700:"#C2420D",800:"#9A3513",900:"#7C2E13",DEFAULT:"#FB923D"},yellow:{50:"#FFFBEC",100:"#FEF3C8",200:"#FDE68B",300:"#FCD34E",400:"#FBBF25",500:"#F59E0C",600:"#D97707",700:"#B4540A",800:"#92410F",900:"#783610",DEFAULT:"#FBBF25"},green:{50:"#EDFDF5",100:"#D2FAE5",200:"#A8F3D0",300:"#6FE7B7",400:"#35D399",500:"#11B981",600:"#069669",700:"#057857",800:"#075F47",900:"#074F3C",DEFAULT:"#35D399"},blue:{50:"#F0F6FF",100:"#DCEAFE",200:"#C0DBFE",300:"#94C5FD",400:"#61A5FA",500:"#3C82F6",600:"#2663EB",700:"#1E4FD8",800:"#1F41AF",900:"#1F3B8A",DEFAULT:"#61A5FA"},purple:{50:"#F5F4FF",100:"#EDEAFE",200:"#DED7FE",300:"#C5B6FD",400:"#A78CFA",500:"#8C5DF6",600:"#7C3BED",700:"#6D29D9",800:"#5B22B6",900:"#4D1E95",DEFAULT:"#8C5DF6"},pink:{50:"#F5F4FF",100:"#FAE9FF",200:"#F5D1FE",300:"#F0ACFC",400:"#E87AF9",500:"#D947EF",600:"#C027D3",700:"#A21DAF",800:"#861A8F",900:"#701B75",DEFAULT:"#E87AF9"},red:{50:"#FFF2F3",100:"#FFE5E6",200:"#FECED4",300:"#FDA5B0",400:"#FB7286",500:"#F4405E",600:"#E11E49",700:"#BE133D",800:"#9F133A",900:"#881438",DEFAULT:"#F4405E"}};function he(e,t){var a={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(a[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(e);n<r.length;n++)t.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(e,r[n])&&(a[r[n]]=e[r[n]])}return a}function fe(e,t,a,r){return new(a||(a=Promise))((function(n,o){function s(e){try{l(r.next(e))}catch(e){o(e)}}function i(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof a?t:new a((function(e){e(t)}))).then(s,i)}l((r=r.apply(e,t||[])).next())}))}function ge(...e){return b(y(e))}function ye(e){const t={en:[/i(?:\s|['\u2018\u2019])?m(?:\s+really)?\s+not\s+sure/i,/i(?:\s+am)?(?:\s+really)?\s+not\s+sure/i,/i\s+(?:really\s+)?don(?:['\u2018\u2019])?t\s+know/i,/it(?:['\u2018\u2019]s| is) unclear/i,/cannot determine/i,/hard to say/i,/difficult to determine/i,/need more information/i],es:[/no (?:lo )?sé/i,/no estoy seguro/i,/no es claro/i,/desconocido/i],fr:[/je ne sais pas/i,/je ne suis pas sûr/i,/ce n'est pas clair/i,/inconnu/i],de:[/ich weiß nicht/i,/ich bin nicht sicher/i,/es ist unklar/i,/unbekannt/i],it:[/non lo so/i,/non sono sicuro/i,/non è chiaro/i,/sconosciuto/i],pt:[/não sei/i,/não tenho certeza/i,/não está claro/i,/desconhecido/i],nl:[/ik weet het niet/i,/ik weet niet zeker/i,/het is onduidelijk/i,/onbekend/i],pl:[/nie wiem/i,/nie jestem pewien/i,/to nie jest jasne/i,/nieznany/i],ru:[/я не знаю/i,/я не уверен/i,/это не ясно/i,/неизвестно/i],ja:[/知りません/i,/よくわからない/i,/不明です/i,/未知/i],ko:[/모릅니다/i,/잘 모르겠습니다/i,/불확실합니다/i,/알 수 없음/i],zh:[/我不知道/i,/我不确定/i,/不清楚/i,/未知/i],"zh-TW":[/我不知道/i,/我不確定/i,/不清楚/i,/未知/i]};let a=null;for(const[r,n]of Object.entries(t))for(const t of n){const n=e.match(t);n&&(null===a||n.index<a.index)&&(a={index:n.index,language:r})}return a?{uncertain:!0,language:a.language}:{uncertain:!1,language:null}}"function"==typeof SuppressedError&&SuppressedError;const be=t=>{var{delayDuration:a=200}=t,r=he(t,["delayDuration"]);return e.createElement(g.Provider,Object.assign({delayDuration:a},r))},ve=g.Root,Ee=g.Trigger,xe=e.forwardRef(((t,a)=>{var{className:r,sideOffset:n=4,background:o,textColor:s,borderColor:i,style:l}=t,c=he(t,["className","sideOffset","background","textColor","borderColor","style"]);return e.createElement(g.Portal,null,e.createElement(g.Content,Object.assign({ref:a,sideOffset:n,className:ge("z-50 overflow-hidden rounded-lg px-4 py-3 text-sm font-medium shadow-lg animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",r),style:Object.assign(Object.assign({},l),{backgroundColor:o||"#ffffff",color:s||"rgb(31 41 55)",borderColor:i||"rgb(243 244 246)",borderWidth:"1px",borderStyle:"solid"})},c)))}));function we(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}function Ne(...e){return t=>{let a=!1;const r=e.map((e=>{const r=we(e,t);return a||"function"!=typeof r||(a=!0),r}));if(a)return()=>{for(let t=0;t<r.length;t++){const a=r[t];"function"==typeof a?a():we(e[t],null)}}}}xe.displayName=g.Content.displayName;var ke=e.forwardRef(((t,a)=>{const{children:r,...n}=t,o=e.Children.toArray(r),s=o.find(Fe);if(s){const t=s.props.children,r=o.map((a=>a===s?e.Children.count(t)>1?e.Children.only(null):e.isValidElement(t)?t.props.children:null:a));return v(Ce,{...n,ref:a,children:e.isValidElement(t)?e.cloneElement(t,void 0,r):null})}return v(Ce,{...n,ref:a,children:r})}));ke.displayName="Slot";var Ce=e.forwardRef(((t,a)=>{const{children:r,...n}=t;if(e.isValidElement(r)){const t=function(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,a=t&&"isReactWarning"in t&&t.isReactWarning;if(a)return e.ref;if(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,a=t&&"isReactWarning"in t&&t.isReactWarning,a)return e.props.ref;return e.props.ref||e.ref}(r);return e.cloneElement(r,{...je(n,r.props),ref:a?Ne(a,t):t})}return e.Children.count(r)>1?e.Children.only(null):null}));Ce.displayName="SlotClone";var Ie=({children:e})=>v(E,{children:e});function Fe(t){return e.isValidElement(t)&&t.type===Ie}function je(e,t){const a={...t};for(const r in t){const n=e[r],o=t[r];/^on[A-Z]/.test(r)?n&&o?a[r]=(...e)=>{o(...e),n(...e)}:n&&(a[r]=n):"style"===r?a[r]={...n,...o}:"className"===r&&(a[r]=[n,o].filter(Boolean).join(" "))}return{...e,...a}}const Se=x("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",{variants:{variant:{default:"bg-primary text-primary-foreground shadow hover:bg-primary/90",destructive:"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",outline:"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline",dark:"bg-dark-700 text-white shadow hover:bg-dark-800 dark:bg-primary dark:text-primary-foreground dark:hover:bg-primary/90"},size:{default:"h-9 px-4 py-2",sm:"h-8 rounded-md px-3 text-xs",lg:"h-10 rounded-md px-8",icon:"h-9 w-9"}},defaultVariants:{variant:"default",size:"default"}}),ze=e.forwardRef(((t,a)=>{var{className:r,variant:n,size:o,asChild:s=!1}=t,i=he(t,["className","variant","size","asChild"]);const l=s?ke:"button";return e.createElement(l,Object.assign({className:ge(Se({variant:n,size:o,className:r})),ref:a},i))}));function Ae({suggestions:e,onQuestionClick:a,title:r="Suggested questions"}){return e&&0!==e.length?t.createElement("div",{className:"w-full p-3","data-name":"Suggestions"},t.createElement("h3",{className:"text-base font-medium mb-4 text-foreground"},r),t.createElement("div",{className:"flex flex-wrap gap-2"},e.map((e=>t.createElement(ze,{key:e.id,onClick:()=>a(e),variant:"outline",className:"border-border font-normal whitespace-normal h-auto text-left"},void 0!==e.messageCount&&t.createElement(be,null,t.createElement(ve,null,t.createElement(Ee,{asChild:!0},t.createElement("span",{className:"bg-gray-100 text-gray-600 px-2 py-0.5 rounded-full text-xs min-w-[20px] border flex items-center justify-center border-border"},e.messageCount)),t.createElement(xe,null,t.createElement("p",null,e.messageCount," messages in this conversation")))),t.createElement("span",{className:""},e.question)))))):null}ze.displayName="Button";const Oe=e.forwardRef(((t,a)=>{var{className:r,type:n}=t,o=he(t,["className","type"]);return e.createElement("input",Object.assign({type:n,className:ge("flex h-12 w-full rounded-md border border-input bg-transparent px-4 py-3 text-base transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",r),ref:a},o))}));Oe.displayName="Input";const Te=x("font-bold leading-6 peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Re=e.forwardRef(((t,a)=>{var{className:r}=t,n=he(t,["className"]);return e.createElement(Z.Root,Object.assign({ref:a,className:ge(Te(),r)},n))}));function De({block:e}){var a;const{schema:r,initialValues:n,state:o}=e,s=null!==(a=r.properties)&&void 0!==a?a:{},i="ready"===o,l="processing"===o,c="completed"===o,{getValues:d,register:m,handleSubmit:u,formState:{errors:p}}=V({defaultValues:n,resolver:W(r,{removeAdditional:!0})}),h=Object.keys(s).map((e=>{var a;const n=s[e],o=(e=>{var t,a;return null!==(a=null===(t=r.required)||void 0===t?void 0:t.includes(e))&&void 0!==a&&a})(e),l=`${null!==(a=n.title)&&void 0!==a?a:e}${o?"*":""}`,c=n.description,u=p[e],h=o&&""===String(d(e)).replace(/^(null|undefined)$/,"")?"Please provide a value":null==u?void 0:u.message;let f=c?String(c):null;return u&&(f=c?t.createElement(t.Fragment,null,c," - ",t.createElement("span",{className:"italic"},h)):h),t.createElement("div",{key:e,className:"py-2 flex flex-col gap-2"},t.createElement(Re,{htmlFor:e},l),t.createElement(Oe,Object.assign({type:"text",disabled:!i,className:ge("border-dark-300",{"border-red-600":!!u})},m(e))),f&&t.createElement("span",{className:ge("flex text-sm leading-6 font-medium gap-1.5 items-center",{"text-red-600":!!u})},u&&t.createElement(w,{weight:"fill",size:20,className:"inline-block align-middle"}),t.createElement("span",null,f)))}));return t.createElement("div",{className:"relative"},t.createElement("form",{className:"flex flex-col justify-stretch",onSubmit:t=>(t.preventDefault(),e.onSubmit&&u(e.onSubmit)(t),!1)},h,t.createElement("div",{className:"mt-4"},t.createElement(ze,{type:"submit",variant:"dark",disabled:!i,className:"w-full rounded-s"},i&&"Submit",l&&"Processing...",c&&"Completed"))))}function Le(e){return null}Re.displayName=Z.Root.displayName;const Qe={javascript:".js",python:".py",java:".java",c:".c",cpp:".cpp","c++":".cpp","c#":".cs",ruby:".rb",php:".php",swift:".swift","objective-c":".m",kotlin:".kt",typescript:".ts",go:".go",perl:".pl",rust:".rs",scala:".scala",haskell:".hs",lua:".lua",shell:".sh",sql:".sql",html:".html",css:".css"},qe=G,Be=a((({language:e,value:a})=>{const[n,o]=r(!1);return t.createElement("div",{className:"relative font-sans text-sm mt-1"},t.createElement("div",{className:"relative rounded-t-lg bg-zinc-800/80 font-sans text-sm backdrop-blur"},t.createElement("div",{className:"flex h-8 items-center justify-between px-3"},t.createElement("span",{className:"text-xs font-medium text-zinc-400"},e),t.createElement("div",{className:"flex gap-1"},t.createElement(ze,{variant:"ghost",size:"icon",className:"size-5 text-zinc-400 hover:bg-zinc-700/50 hover:text-zinc-100",onClick:()=>{fe(void 0,void 0,void 0,(function*(){if(navigator.clipboard&&navigator.clipboard.writeText)try{yield navigator.clipboard.writeText(a),o(!0),setTimeout((()=>{o(!1)}),2e3)}catch(e){console.error("Failed to copy:",e)}}))}},n?t.createElement(N,{size:18}):t.createElement(k,{size:18})),t.createElement(ze,{variant:"ghost",size:"icon",className:"size-5 text-zinc-400 hover:bg-zinc-700/50 hover:text-zinc-100",onClick:()=>{const t=Qe[e]||".file",r=`file-${((e,t=!1)=>{const a="ABCDEFGHJKLMNPQRSTUVWXY3456789";let r="";for(let t=0;t<e;t+=1)r+=a.charAt(Math.floor(30*Math.random()));return t?r.toLowerCase():r})(3,!0)}${t}`,n=new Blob([a],{type:"text/plain"}),o=URL.createObjectURL(n),s=document.createElement("a");s.download=r,s.href=o,s.style.display="none",document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(o)}},t.createElement(C,{size:18}))))),t.createElement("div",{className:"rounded-b-lg"},t.createElement(qe,{language:e,style:J,PreTag:"div",wrapLongLines:!0,customStyle:{margin:0,borderTopLeftRadius:0,borderTopRightRadius:0}},a)))}));Be.displayName="CodeBlock";const _e=e.forwardRef((({src:t,border:a,width:r="100%",height:n="400px",title:o},s)=>{const[i,l]=e.useState(!1),[c,d]=e.useState(!1);return e.useEffect((()=>{let e=!0;return setTimeout((()=>{e&&l(!0)}),0),()=>{e=!1}}),[]),e.createElement("div",{className:"overflow-hidden rounded-lg mt-4 relative "+(a?"border":""),style:{width:r,height:n}},i&&e.createElement(e.Fragment,null,e.createElement("div",{className:"absolute w-full h-full "+(c?"hidden":"block")},e.createElement("div",{className:"absolute inset-0 bg-muted/10 rounded-lg"},e.createElement("div",{className:"absolute inset-0"},e.createElement("div",{className:"h-full w-full shimmer"}),e.createElement("div",{className:"absolute left-1/2 top-1/2 -translate-1/2 flex flex-col items-center gap-2"},e.createElement("div",{className:"modern-spinner"}),e.createElement("div",{className:"text-sm text-muted-foreground"},"Loading..."))))),e.createElement("div",{className:c?"visible":"invisible"},e.createElement("iframe",{ref:s,src:t,sandbox:"allow-same-origin allow-scripts allow-popups allow-forms allow-downloads",width:r,height:n,title:"embed",loading:"lazy",allowFullScreen:!0,className:"block rounded-lg",onLoad:()=>d(!0)}),o&&e.createElement("span",{className:"block text-center text-sm font-medium"},o))))}));function $e(t){const a=t.attrs.href.replace("share","embed");return e.createElement(_e,Object.assign({},t,{src:a,title:"Loom Embed"}))}function Pe(t){return e.createElement(_e,Object.assign({},t,{src:t.attrs.href,title:"Supademo Embed"}))}function Ue(t){return e.createElement(_e,Object.assign({},t,{src:t.attrs.href,title:"Typeform Embed"}))}function Me(t){const a=t.attrs.href.match(/(http|https)?:\/\/(www\.)?vimeo\.com\/(?:channels\/(?:\w+\/)?|groups\/([^/]*)\/videos\/|)(\d+)(?:\/|\?)?([\d\w]+)?/);if(!a)return null;const r=a[4],n=a[5],o=`https://player.vimeo.com/video/${r}?byline=0${n?`&h=${n}`:""}`;return e.createElement(_e,Object.assign({},t,{src:o,title:`Vimeo Embed (${r})`,height:"412px",border:!1}))}function Ve(t){const a=(e=>{const t=[/^https?:\/\/([a-zA-Z0-9-_~]+)\.wistia\.com\/medias\/([a-zA-Z0-9-_~]+)\/?$/,/^https?:\/\/fast\.wistia\.com\/embed\/iframe\/([a-zA-Z0-9-_~]+)\/?$/,/^fast\.wistia\.com\/embed\/iframe\/([a-zA-Z0-9-_~]+)\/?$/,/^([a-zA-Z0-9-_~]+)\.wistia\.com\/medias\/([a-zA-Z0-9-_~]+)\/?$/];for(const a of t){const t=e.match(a);if(t)return t}return null})(t.attrs.href);if(!a)return null;const r=a[1],n=a[2]||a[1],o=r?`https://${r}.wistia.com/embed/iframe/${n}?seo=true&videoFoam=false`:`https://fast.wistia.com/embed/iframe/${n}`;return e.createElement(_e,Object.assign({},t,{src:o,border:!0,title:`Wistia Embed (${n})`}))}function We(t){const a=(e=>{const t=e.match(/(?:https?:\/\/)?(?:www\.)?youtu\.?be(?:\.com)?\/?.*(?:watch|embed)?(?:.*v=|v\/|\/)([a-zA-Z0-9_-]{11})$/i);return t?t[1]:null})(t.attrs.href);return a?e.createElement(_e,Object.assign({},t,{src:`https://www.youtube.com/embed/${a}?modestbranding=1`,title:`YouTube Embed (${a})`})):null}$e.isMatch=e=>/^https:\/\/(www\.)?(use)?loom\.com\/(embed|share)\/(.*)$/.test(e),Pe.isMatch=e=>/^https:\/\/app\.supademo\.com\/embed\/(.*)$/.test(e),Ue.isMatch=e=>/^https:\/\/([A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)\.typeform\.com\/to\/(.*)$/.test(e),Me.isMatch=e=>/^(https?):\/\/(www\.)?vimeo\.com\/(?:channels\/(?:\w+\/)?|groups\/([^/]*)\/videos\/|)?(\d+)(\/)?(?:\?.*|#.*)?$/i.test(e),Ve.isMatch=e=>[/^https?:\/\/([a-zA-Z0-9-_~]+)\.wistia\.com\/medias\/([a-zA-Z0-9-_~]+)(\/)?(\?.*)?$/i,/^https?:\/\/fast\.wistia\.com\/embed\/iframe\/([a-zA-Z0-9-_~]+)(\/)?(\?.*)?$/i,/^fast\.wistia\.com\/embed\/iframe\/([a-zA-Z0-9-_~]+)(\/)?(\?.*)?$/i,/^([a-zA-Z0-9-_~]+)\.wistia\.com\/medias\/([a-zA-Z0-9-_~]+)(\/)?(\?.*)?$/i].some((t=>t.test(e))),We.isMatch=e=>/^(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:watch\?v=|embed\/|v\/|shorts\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})(?:\/|[?&].*)?$/i.test(e);const Ze=[$e,Pe,Ue,We,Ve,Me],He=t=>{const{href:a}=t.attrs,r=((t,a)=>e.useMemo((()=>{try{const e=a.find((e=>e.isMatch(t)));return e?{Component:e}:null}catch(e){return console.error("Error finding embed match:",e),null}}),[t,a]))(a,Ze);if(r){const{Component:a}=r;return e.createElement(a,Object.assign({},t))}return null},Ke=a(Y,((e,t)=>e.children===t.children)),Ge={startOnLoad:!1,theme:"default",securityLevel:"loose",fontFamily:"inherit",secure:["secure","securityLevel","startOnLoad","maxTextSize"]},Je=({content:e})=>{const[a,s]=r(""),[i,l]=r(null),c=n(null),[d,m]=r(!1);return o((()=>{(()=>{try{X.initialize(Ge),m(!0)}catch(e){console.error("Error initializing mermaid:",e),l("Failed to initialize diagram renderer")}})()}),[]),o((()=>{if(!d)return;fe(void 0,void 0,void 0,(function*(){try{const t=`mermaid-${Math.random().toString(36).substr(2,9)}`,{svg:a}=yield X.render(t,e);s(a),l(null)}catch(e){console.error("Error rendering mermaid diagram:",e),l("Failed to render diagram")}}))}),[e,d]),i?t.createElement("div",{className:"text-red-500 bg-red-50 p-4 rounded-md"},i,t.createElement("pre",{className:"mt-2 text-sm"},e)):t.createElement("div",{ref:c,className:"my-4 overflow-auto",dangerouslySetInnerHTML:{__html:a}})},Ye=({src:t,alt:a})=>{const[r,n]=e.useState(!1),[o,s]=e.useState(!1),[i,l]=e.useState(!1),[c,d]=e.useState(!0),[m,u]=e.useState({width:0,height:0}),p=e.useRef(null),g=()=>{n(!r)};return!t||i?null:e.createElement("figure",{className:"relative inline-block my-4 px-4 w-full sm:w-auto"},e.createElement("div",{className:"flex items-center justify-center min-h-[100px]"},e.createElement("button",{type:"button",onClick:g,className:"border-0 p-0 bg-transparent relative group","aria-label":r?"Zoom out image":"Zoom in image"},c&&e.createElement("div",{className:"rounded-md bg-gray-200 dark:bg-gray-800 animate-pulse",style:{width:m.width||300,height:m.height||200,maxHeight:300}}),e.createElement("img",{ref:p,src:t,alt:a,onError:()=>{d(!1),l(!0)},onLoad:()=>{if(p.current){const{naturalWidth:e,naturalHeight:t}=p.current,a=300,r=e/t,n=Math.min(a,t);u({width:n*r,height:n})}d(!1)},className:"max-h-[300px] w-auto object-contain cursor-zoom-in hover:opacity-90 transition-opacity "+(c?"opacity-0 absolute":"opacity-100 relative")}),!c&&e.createElement("div",{className:"absolute bottom-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity"},e.createElement("div",{className:"bg-black/50 text-white p-1.5 rounded-lg"},e.createElement(I,{size:16}))))),a&&!c&&e.createElement("div",{className:"relative mt-1"},e.createElement("figcaption",{className:"text-sm text-gray-600 dark:text-gray-400 text-center group cursor-default",onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1)},e.createElement("div",{className:"line-clamp-2 hover:text-gray-700 dark:hover:text-gray-300"},a)),o&&e.createElement("div",{className:"absolute bottom-full left-0 right-0 mb-1 p-2 bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 text-sm text-gray-600 dark:text-gray-400 z-10"},a)),e.createElement(h,null,r&&e.createElement(e.Fragment,null,e.createElement(f.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"fixed inset-0 bg-black/80 z-50",onClick:g}),e.createElement(f.div,{initial:{scale:.5,opacity:0},animate:{scale:1,opacity:1},exit:{scale:.5,opacity:0},className:"fixed inset-0 z-50 flex flex-col items-center justify-center cursor-zoom-out gap-4 p-4 sm:p-8",onClick:g},e.createElement("div",{className:"max-w-[95vw] sm:max-w-[90vw] max-h-[80vh]"},e.createElement("img",{src:t,alt:a,className:"w-full h-full object-contain"})),a&&e.createElement("div",{className:"max-w-[95vw] sm:max-w-[90vw] text-white text-center text-sm"},a)))))},Xe=a((({message:e,isStreaming:a})=>{const[n,s]=r(e.content);o((()=>{var t;const a=ye(e.content);a.uncertain&&a.language&&(null===(t=e.uncertaintyFallbackText)||void 0===t?void 0:t[a.language])?s(e.uncertaintyFallbackText[a.language]):s(e.content)}),[e.content,e.uncertaintyFallbackText,a]);const i=n.replace(/^\n+|(\n+|\\)+$/g,"");return t.createElement(Ke,{className:"dark:prose-invert prose flex-1",remarkPlugins:[K],rehypePlugins:[H],components:{p:({children:e})=>t.createElement("div",{className:"ptag"},e),code:e=>{var{inline:a,className:r,children:n}=e,o=he(e,["inline","className","children"]);const s=/language-(\w+)/.exec(r||""),i=s&&s[1];return a||"mermaid"!==i&&"mermaidjs"!==i?!a&&i?t.createElement(Be,Object.assign({key:Math.random(),language:i,value:String(n).replace(/\n$/,"")},o)):t.createElement("code",Object.assign({className:`text-red-400 bg-slate-200 border-slate-300 border rounded p-0.5 ${r}`.trim()},o),n):t.createElement(Je,{content:String(n).replace(/\n$/,"")})},marker:({children:e})=>t.createElement("div",{className:"my-2"},t.createElement("span",{className:"highlight"},e)),table:({children:e})=>t.createElement("table",{className:"border-collapse border border-black px-3 py-1 dark:border-white"},e),th:({children:e})=>t.createElement("th",{className:"break-words border border-black bg-gray-500 px-3 py-1 text-white dark:border-white"},e),td:({children:e})=>t.createElement("td",{className:"break-words border border-black px-3 py-1 dark:border-white"},e),a(e){var{children:a}=e,r=he(e,["children"]);if(r.href){const e=He({attrs:{href:r.href}});if(t.isValidElement(e))return e}return t.createElement("a",Object.assign({className:"link text-link",target:"_blank",rel:"noopener noreferrer"},r),a)},pre:({children:e})=>t.createElement(t.Fragment,null,e),img({src:e,alt:a}){const r=He({attrs:{href:null!=e?e:""}});return t.isValidElement(r)?r:t.createElement(Ye,{src:e,alt:a})},li:e=>{var{children:a}=e,r=he(e,["children"]);return t.createElement("li",Object.assign({},r),a)},ul:({children:e})=>t.createElement("ul",{className:"ml-4 my-4 list-outside space-y-4 list-disc",role:"list"},e),ol:({children:e})=>t.createElement("ol",{className:"ml-4 my-4 list-outside space-y-4 list-decimal",role:"list"},e),strong:e=>{var{children:a}=e,r=he(e,["children"]);return t.createElement("span",Object.assign({className:"font-semibold"},r),a)},h1:e=>{var{children:a}=e,r=he(e,["children"]);return t.createElement("h1",Object.assign({className:"text-2xl font-bold"},r),a)},h2:e=>{var{children:a}=e,r=he(e,["children"]);return t.createElement("h2",Object.assign({className:"text-xl font-bold"},r),a)},h3:e=>{var{children:a}=e,r=he(e,["children"]);return t.createElement("h3",Object.assign({className:"text-lg font-bold"},r),a)},h4:e=>{var{children:a}=e,r=he(e,["children"]);return t.createElement("h4",Object.assign({className:"text-base font-bold"},r),a)},h5:e=>{var{children:a}=e,r=he(e,["children"]);return t.createElement("h5",Object.assign({className:"text-base font-semibold"},r),a)},h6:e=>{var{children:a}=e,r=he(e,["children"]);return t.createElement("h6",Object.assign({className:"text-sm font-semibold"},r),a)}}},i)}));function et({block:e}){if(!e.text||""===e.text.trim())return t.createElement("div",{className:"w-full"},t.createElement("div",{className:"space-y-4"},t.createElement("div",{className:"space-y-3"},t.createElement("div",{className:"h-4 rounded w-3/4 shimmer"}),t.createElement("div",{className:"h-4 rounded w-full shimmer"}),t.createElement("div",{className:"h-4 rounded w-5/6 shimmer"}))));const{text:a}=e;return t.createElement("div",{className:"w-full"},t.createElement("div",{className:"prose prose-sm max-w-none text-foreground"},t.createElement(Xe,{message:{content:a}})))}function tt({block:e}){switch(e.type){case"markdown-text":return t.createElement(et,{block:e});case"action-buttons":return t.createElement(Le,{block:e});case"action-input-form":return t.createElement(De,{block:e});default:return null}}Xe.displayName="FormattedMessage";const at=({text:e=""}={})=>({id:ee(),type:"markdown-text",text:e}),rt=e=>"markdown-text"===e.type,nt=e=>"action-input-form"===e.type,ot=te.Root,st=te.CollapsibleTrigger,it=e=>{var{children:a}=e,r=he(e,["children"]);return t.createElement(te.CollapsibleContent,Object.assign({},r),t.createElement("style",null,'\n .CollapsibleContent[data-state="open"] {\n animation: slideDown 200ms ease-in-out;\n }\n .CollapsibleContent[data-state="closed"] {\n animation: slideUp 200ms ease-in-out;\n }\n\n @keyframes slideDown {\n from {\n height: 0;\n }\n to {\n height: var(--radix-collapsible-content-height);\n }\n }\n\n @keyframes slideUp {\n from {\n height: var(--radix-collapsible-content-height);\n }\n to {\n height: 0;\n }\n }\n '),a)};function lt({feedback:e,onFeedback:a,textConfig:n={},disabled:o=!1}){const[s,i]=r(!1),l=e=>{a&&("accept"===e&&(i(!0),setTimeout((()=>i(!1)),2e3)),a(e))};return t.createElement("div",{className:"flex justify-end gap-2","data-name":"Feedback"},t.createElement(be,null,t.createElement(ve,null,t.createElement(Ee,{asChild:!0},t.createElement("div",{className:"relative"},t.createElement(h,null,s&&t.createElement(t.Fragment,null,Array.from({length:8}).map(((e,a)=>t.createElement(f.div,{key:a,className:"absolute top-1/2 left-1/2 origin-center",initial:{opacity:0,scale:.3,x:0,y:0},animate:{opacity:[0,1,1,0],scale:[.3,1,1,0],x:[0,30*Math.cos(a*(Math.PI/4))],y:[0,30*Math.sin(a*(Math.PI/4))],rotate:[0,a%2?45:-45]},transition:{duration:1.2,ease:[.4,0,.2,1],times:[0,.3,.7,1],delay:.1*a}},t.createElement(F,{className:"size-4 text-rose-500",style:{filter:"drop-shadow(0 0 3px rgba(255, 75, 110, 0.8))",strokeWidth:2.5}})))),t.createElement(f.div,{className:"absolute inset-0 rounded-full bg-primary",initial:{opacity:0,scale:.8},animate:{opacity:[0,.15,.15,0],scale:[.8,1.8,1.8,2]},transition:{duration:1.2,ease:"easeOut",times:[0,.3,.7,1]}}))),t.createElement(ze,{variant:"ghost",size:"sm",className:"rounded-md size-8 flex items-center justify-center transition-all duration-200 transform hover:scale-105 active:scale-95 "+("accept"===e?"bg-green-100 text-green-600 hover:bg-green-200":"text-dark-500"),onClick:()=>l("accept"),disabled:o},t.createElement(f.div,{initial:{scale:1},animate:{scale:"accept"===e?[1,1.2,1]:1},transition:{duration:.3}},t.createElement(j,{weight:"bold"}))))),t.createElement(xe,null,t.createElement("p",null,n.positiveAnswerText||"Helpful")))),t.createElement(be,null,t.createElement(ve,null,t.createElement(Ee,{asChild:!0},t.createElement(ze,{variant:"ghost",size:"sm",className:"rounded-md size-8 flex items-center justify-center transition-all duration-200 transform hover:scale-105 active:scale-95 "+("reject"===e?"bg-red-100 text-red-600 hover:bg-red-200":"text-dark-500"),onClick:()=>l("reject"),disabled:o},t.createElement(f.div,{initial:{scale:1},animate:{scale:"reject"===e?[1,1.2,1]:1},transition:{duration:.3}},t.createElement(S,{weight:"bold"})))),t.createElement(xe,null,t.createElement("p",null,n.negativeAnswerText||"Not helpful")))))}const ct="answers/set_answers",dt="answers/clear_all",mt="answers/create_empty_answer",ut="answers/append_block",pt="answers/append_stream_chunk",ht="answers/update_search_results",ft="answers/set_follow_up_questions",gt="answers/finish_streaming",yt="answers/set_error_state",bt="answers/set_user_feedback",vt="answers/clear_user_feedback",Et="answers/mark_as_uncertain",xt="answers/request_action_inputs",wt="answers/invoke_action",Nt="answers/add_action_buttons",kt=()=>({type:dt}),Ct=({text:e,index:t})=>({type:pt,payload:{text:e,index:t}}),It=({error:e,index:t})=>({type:yt,payload:{error:e,index:t}}),Ft=({index:e}={})=>({type:gt,payload:{index:e}}),jt=({uncertaintyText:e,index:t})=>({type:Et,payload:{uncertaintyText:e,index:t}}),St=({searchIntentId:e,actionId:t,schema:a,initialValues:r,onSubmit:n,index:o})=>({type:xt,payload:{searchIntentId:e,actionId:t,schema:a,initialValues:r,onSubmit:n,index:o}}),zt=({searchIntentId:e,index:t})=>({type:Nt,payload:{searchIntentId:e,index:t}}),At=(e,t)=>e.at(null!=t?t:-1),Ot=e=>e.blocks.at(-1),Tt=[],Rt=(e,t)=>{var a;switch(t.type){case ct:return e.length=0,void e.push(...t.payload.answers);case dt:return void(e.length=0);case mt:return void e.push({id:"pending-"+ee(),state:"fetching-search-results",question:t.payload.query,blocks:[at()],isUncertain:!1});case ht:{const a=At(e,t.payload.index);return void(a&&(a.searchQueryId=t.payload.searchQueryId,a.searchResults=t.payload.results,a.state="fetching-stream"))}case pt:{const a=At(e,t.payload.index),r=a&&Ot(a);return void(a&&!a.isUncertain&&r&&rt(r)&&(a.state="streaming",r.text+=t.payload.text))}case yt:{const r=At(e,null!==(a=t.payload.index)&&void 0!==a?a:-1),n=r&&Ot(r);return void(n&&rt(n)&&(n.text+=t.payload.error))}case ut:{const a=At(e,t.payload.index);return void(a&&a.blocks.push(t.payload.block))}case gt:{const a=At(e,t.payload.index);return void(a&&"streaming"===a.state&&(a.state="completed"))}case Et:{const a=At(e,t.payload.index),r=a&&Ot(a);return void(a&&r&&rt(r)&&(a.isUncertain=!0,r.text=t.payload.uncertaintyText))}case bt:{const a=At(e,t.payload.index);return void(a&&(a.feedback=t.payload.feedback))}case vt:{const a=At(e,t.payload.index);return void(a&&delete a.feedback)}case xt:{const a=At(e,t.payload.index);return void(a&&(a.state="getting-action-inputs",a.searchIntentId=t.payload.searchIntentId,a.blocks.push((({actionId:e,schema:t,initialValues:a,onSubmit:r})=>({id:ee(),type:"action-input-form",state:"ready",actionId:e,schema:t,initialValues:a,onSubmit:r}))({actionId:t.payload.actionId,schema:t.payload.schema,initialValues:t.payload.initialValues,onSubmit:t.payload.onSubmit}))))}case Nt:{const a=At(e,t.payload.index);return void(a&&(a.searchIntentId=t.payload.searchIntentId,a.blocks.push({id:ee(),type:"action-buttons"})))}case wt:{const a=At(e,t.payload.index),r=null==a?void 0:a.blocks.findIndex(nt);return void(a&&r&&(a.state="fetching-stream",a.blocks.splice(r,1,at())))}case ft:{const a=At(e,t.payload.index);return void(a&&(a.followUpQuestions=t.payload.questions))}default:throw new Error(`Answer List Reducer: unknown action type '${t.type}'`)}},Dt="conversation",Lt=i(void 0),Qt=({children:e,searchPath:a})=>{const[n,o]=r(""),[i,c]=r(""),[d,m]=r(""),[u,p]=r(!1),[h,f]=r(!1),[g,y]=ae(Rt,Tt),[b,v]=r(0),[E,x]=r(!1),[w,N]=r(""),[k,C]=r(!1),{conversationId:I,setConversationId:F,clearConversationId:j}=(e=>{const t=re(Dt),[a,n]=r(null!=t?t:void 0);return{conversationId:a,setConversationId:s((t=>{const a=new URL(window.location.href);e&&(a.pathname=e),t?a.searchParams.set(Dt,t):a.searchParams.delete(Dt);const r=a.toString();window.history.replaceState(Object.assign(Object.assign({},window.history.state),{newUrl:r,url:r}),"",r),n(t)}),[e]),clearConversationId:s((()=>{const e=new URL(window.location.href);e.searchParams.delete(Dt);const t=e.toString();window.history.replaceState(Object.assign(Object.assign({},window.history.state),{newUrl:t,url:t}),"",t),n(void 0)}),[])}})(a),S=l((()=>({query:n,setQuery:o,queryId:i,setQueryId:c,followUpQuery:d,setFollowUpQuery:m,isSearching:u,setIsSearching:p,showResults:h,setShowResults:f,answers:g,answerListDispatch:y,activeAnswerIndex:b,setActiveAnswerIndex:v,conversationId:I,setConversationId:F,clearConversationId:j,isLoadingConversation:E,setIsLoadingConversation:x,loadError:w,setLoadError:N,showMobileCloseWidgetButton:k,setShowMobileCloseWidgetButton:C})),[n,i,d,u,h,g,y,b,I,F,j,E,w,k]);return t.createElement(Lt.Provider,{value:S},e)},qt=()=>{const e=c(Lt);if(!e)throw new Error("useChatSearch must be used within a ChatSearchProvider");return e},Bt=()=>{const{showResults:e,answers:t}=qt();return Boolean(e||t.length>0)},_t={maxRetries:3,baseDelay:1e3,shouldRetry:e=>{if(e instanceof TypeError)return!0;const t=e;return!!t.status&&t.status>=500}};let $t=Object.assign({},_t),Pt=Object.assign({},{emptyResponse:"I apologize, but I couldn't generate an answer at this time. Please try again.",errorResponse:"I encountered an error while processing your request. Please try again."});function Ut(e){return fe(this,void 0,void 0,(function*(){return new Promise((t=>setTimeout(t,e)))}))}function Mt(e,t={}){return fe(this,void 0,void 0,(function*(){const{retry:a={},headers:r={},body:n,isStream:o=!1,fallback:s={}}=t,i=he(t,["retry","headers","body","isStream","fallback"]),l=Object.assign(Object.assign({},$t),a),c=Object.assign(Object.assign({},Pt),s);let d=1;for(;;)try{const t=yield fetch(e,Object.assign(Object.assign({},i),{headers:Object.assign({"Content-Type":"application/json"},r),body:n?JSON.stringify(n):void 0}));if(t.ok){if(o){if(!t.ok)throw new Error("Failed to fetch answer");return t}const e=yield t.json();if(!e||"object"==typeof e&&0===Object.keys(e).length){const e=new Error(c.emptyResponse);throw e.name="EmptyResponseError",e}return e}const a=new Error(c.errorResponse);throw a.status=t.status,a.data=yield t.json().catch((()=>{})),a}catch(e){const t=yield Promise.resolve(l.shouldRetry(e,d));if(d>=l.maxRetries||!t){if(e instanceof Error&&"EmptyResponseError"===e.name)return{message:e.message};throw e}console.warn(`Request failed, attempt ${d} of ${l.maxRetries}. Retrying...`);const a=.3*Math.random()+.85;yield Ut(l.baseDelay*Math.pow(2,d-1)*a),d++}}))}const Vt={maxRetries:3,baseDelay:300,shouldRetry:e=>{if(e instanceof TypeError)return!0;const t=e;return!!t.status&&(t.status>=500||429===t.status)}},Wt={maxRetries:3,baseDelay:500,shouldRetry:e=>{if(e instanceof TypeError)return!0;const t=e;return!!t.status&&t.status>=500}};function Zt({endpoint:e,headers:t,body:a}){return fe(this,void 0,void 0,(function*(){return Mt(e,{method:"POST",headers:t,retry:Wt,isStream:!0,fallback:{emptyResponse:"I apologize, but I couldn't generate an answer for your query. Please try rephrasing your question.",errorResponse:"I encountered an issue while generating the answer. Please try again in a moment."},body:a})}))}const Ht=({loadConversationEndpoint:e,headers:t,mergedTextConfig:a})=>{const{setIsLoadingConversation:r,setShowResults:n,answerListDispatch:o,conversationId:i,setConversationId:l,clearConversationId:c,setLoadError:d}=qt(),m=s((s=>{if(!e)return;r(!0),r(!0),n(!0);const i=new AbortController;return function({endpoint:e,conversationId:t,headers:a,signal:r}){return fe(this,void 0,void 0,(function*(){return{data:(yield Mt(e,{method:"POST",headers:a,body:{conversationId:t},signal:r})).data}}))}({endpoint:e,conversationId:s,headers:t,signal:i.signal}).then((({data:e})=>{const t=e.map((e=>({id:e.searchQueryId,state:"completed",question:e.question,isUncertain:ye(e.answer).uncertain,searchQueryId:e.searchQueryId,searchIntentId:e.searchIntentId,blocks:e.answer.split("---").map((e=>at({text:e.trim()})))})));o((({answers:e})=>({type:ct,payload:{answers:e}}))({answers:t})),n(!0)})).catch((e=>{console.error("Error loading conversation:",e),o(kt()),c(),n(!1),d(a.errorText||"An error occurred")})).finally((()=>{r(!1)})),()=>i.abort("Conversation loader aborted")}),[e,r,n,t,o,l,d,a.errorText]);return ne((()=>{let e;return i&&(console.log("loading conversation",i),e=m(i)),()=>null==e?void 0:e()})),{loadConversationById:m}},Kt=(e,t)=>{const[a,n]=r(`rgb(var(${t}))`),s=(()=>{const[e,t]=r((()=>document.documentElement.classList.contains("dark")));return o((()=>{const e=new MutationObserver((()=>{t(document.documentElement.classList.contains("dark"))}));return e.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>e.disconnect()}),[]),e})();return o((()=>{const a=getComputedStyle(document.documentElement).getPropertyValue(e).trim().match(/^(\d+)\s+(\d+)\s+(\d+)$/);if(a){const r=function(e){const[t,a,r]=e.split(",").map(Number),[n,o,s]=[t,a,r].map((e=>(e/=255)<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)));return.2126*n+.7152*o+.0722*s}(a.slice(1).join(","));n(r<=.5?s?"rgb(var(--bfc-ring))":`rgb(var(${e}))`:s?`rgb(var(${e}))`:`rgb(var(${t}))`)}}),[e,t,s]),a},Gt=e=>{var{loading:a,className:r}=e,n=he(e,["loading","className"]);const o=Kt("--bfc-primary","--bfc-border");return t.createElement("svg",Object.assign({width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",className:ge("min-w-5",r)},n),t.createElement("path",{className:a?"animate-spin":"",d:"M7.54672 16.0031L2.66234 14.2031C2.51881 14.1498 2.39502 14.0539 2.3076 13.9282C2.22019 13.8025 2.17333 13.6531 2.17333 13.5C2.17333 13.3469 2.22019 13.1975 2.3076 13.0718C2.39502 12.9461 2.51881 12.8501 2.66234 12.7969L7.54672 10.9969C7.64981 10.9589 7.74344 10.899 7.82113 10.8213C7.89882 10.7436 7.95873 10.65 7.99672 10.5469L9.79672 5.66249C9.84999 5.51896 9.94592 5.39517 10.0716 5.30775C10.1973 5.22033 10.3467 5.17348 10.4998 5.17348C10.6529 5.17348 10.8024 5.22033 10.9281 5.30775C11.0538 5.39517 11.1497 5.51896 11.203 5.66249L13.003 10.5469C13.041 10.65 13.1009 10.7436 13.1786 10.8213C13.2562 10.899 13.3499 10.9589 13.453 10.9969L18.3373 12.7969C18.4809 12.8501 18.6047 12.9461 18.6921 13.0718C18.7795 13.1975 18.8264 13.3469 18.8264 13.5C18.8264 13.6531 18.7795 13.8025 18.6921 13.9282C18.6047 14.0539 18.4809 14.1498 18.3373 14.2031L13.453 16.0031C13.3499 16.0411 13.2562 16.101 13.1786 16.1787C13.1009 16.2564 13.041 16.35 13.003 16.4531L11.203 21.3375C11.1497 21.481 11.0538 21.6048 10.9281 21.6922C10.8024 21.7796 10.6529 21.8265 10.4998 21.8265C10.3467 21.8265 10.1973 21.7796 10.0716 21.6922C9.94592 21.6048 9.84999 21.481 9.79672 21.3375L7.99672 16.4531C7.95873 16.35 7.89882 16.2564 7.82113 16.1787C7.74344 16.101 7.64981 16.0411 7.54672 16.0031Z",stroke:o,strokeWidth:"1.5",strokeLinecap:"round",fill:"rgb(var(--bfc-primary))",strokeLinejoin:"round"}),t.createElement("path",{d:"M18.7497 3.75L14.2497 3.75",stroke:"rgb(var(--bfc-primary))",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),t.createElement("path",{d:"M16.4999 6V1.5",stroke:"rgb(var(--bfc-primary))",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),t.createElement("path",{d:"M22.4999 8.25001H19.4999",stroke:"rgb(var(--bfc-primary))",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),t.createElement("path",{d:"M20.9998 9.75002V6.75002",stroke:"rgb(var(--bfc-primary))",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}))};function Jt({blocks:e=[],question:a,searchResults:n,state:o="completed",searchQueryId:s,feedback:i,onFeedback:l,disableFeedback:c=!1,textConfig:d={}}){const[m,u]=r(!1),[p,h]=r(!1),f=e.filter(rt).map((e=>e.text)).join("\n\n---\n\n"),g=("fetching-search-results"===o||"fetching-stream"===o)&&1===e.length,y="fetching-search-results"===o,b="getting-action-inputs"===o||"completed"===o,v="completed"===o,E=()=>fe(this,void 0,void 0,(function*(){try{yield navigator.clipboard.writeText(f)}catch(e){console.warn("Clipboard API failed, using fallback:",e);const t=document.createElement("textarea");t.value=f,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.focus(),t.select();try{document.execCommand("copy")}catch(e){console.error("Fallback: Oops, unable to copy",e)}document.body.removeChild(t)}u(!0),setTimeout((()=>u(!1)),2e3)}));return t.createElement("div",{className:"rounded-lg relative mx-auto overflow-hidden bg-card border border-primary mb-4","data-name":"SearchResults"},t.createElement("div",{className:"p-4 pb-0"},t.createElement("div",{className:"flex items-start justify-between gap-2 min-h-9"},t.createElement("div",{className:"flex gap-1"},t.createElement(Gt,{loading:!b}),t.createElement("h2",{className:"leading-normal font-semibold m-0 text-foreground self-center"},a)),v&&t.createElement(be,null,t.createElement(ve,null,t.createElement(Ee,{asChild:!0},t.createElement(ze,{variant:"ghost",size:"icon",onClick:()=>{E()},className:"-mt-1 flex-shrink-0"},m?t.createElement(z,{className:"text-feedback-positive",weight:"bold"}):t.createElement(A,{className:"text-secondary-foreground",weight:"bold"}))),t.createElement(xe,null,t.createElement("p",null,m?"Copied!":"Copy")))))),g&&t.createElement("div",{className:"space-y-4 mt-2 px-4"},t.createElement("div",{className:"flex items-center gap-2"},t.createElement("div",{className:"size-5 rounded-full bg-primary/30"}),t.createElement("div",{className:"flex items-center gap-2 text-sm text-foreground"},y?d.loadingSearchText:d.loadingAnswerText))),t.createElement("div",{className:"flex flex-col"},null==e?void 0:e.map(((e,a)=>t.createElement("div",{key:a,className:"p-4 border-b last:border-b-0 border-dashed"},t.createElement(tt,{block:e}))))),v&&!c&&t.createElement("div",{className:"p-4 pt-0"},t.createElement(lt,{feedback:i,onFeedback:e=>{l&&s&&l(e)},textConfig:d,disabled:c})),n&&n.length>0&&t.createElement("div",{className:"overflow-hidden bg-card border-dashed border-0 border-t-2"},t.createElement(ot,{open:p,onOpenChange:h,className:"w-full"},t.createElement("div",null,t.createElement(st,{asChild:!0},t.createElement(ze,{variant:"secondary",className:"w-full justify-between h-11","data-name":"RelatedSources"},t.createElement("div",{className:"flex items-center gap-2"},t.createElement("span",{className:"font-medium truncate text-base"},"Sources")),t.createElement(O,{className:"size-4 flex-shrink-0 transition-transform duration-200 text-secondary-foreground "+(p?"rotate-180":""),weight:"bold"}),t.createElement("span",{className:"sr-only"},"Toggle")))),t.createElement(it,{className:"divide-y divide-gray-200 dark:divide-border overflow-hidden CollapsibleContent"},n.map((e=>t.createElement("a",{key:e.id,href:e.url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 p-3 transition-colors duration-200 hover:bg-accent bg-card text-foreground"},t.createElement("span",{className:"flex-grow truncate"},e.title),t.createElement(T,{className:"size-4 flex-shrink-0 text-secondary-foreground",weight:"bold"}))))))))}const Yt=f(ze);function Xt({questions:e,onQuestionClick:a}){return e.length?t.createElement(f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"w-full"},t.createElement("div",{className:"rounded-lg overflow-hidden bg-card border border-dark-300"},t.createElement("h3",{className:"px-4 py-3 border-b border-b-dark-300 font-bold"},"Follow-up questions"),e.map(((e,r)=>r<3?t.createElement(Yt,{key:r,initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.1*r},onClick:()=>a(e),variant:"ghost",className:"w-full text-left"},t.createElement("span",{className:"flex-grow"},e),t.createElement(R,{className:"",weight:"bold"})):null)))):null}const ea=e=>{var{iconName:a}=e,r=he(e,["iconName"]);const n=d((()=>import("@phosphor-icons/react").then((e=>({default:e[a]})))));return t.createElement(m,{fallback:t.createElement("div",null,"Loading...")},t.createElement(n,Object.assign({},r)))},ta=f(ze),aa=({nextBestActions:e,onActionClick:a})=>e.length?t.createElement(f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"w-full"},t.createElement("div",{className:"rounded-lg overflow-hidden bg-card border border-dark-300 divide-y divide-dark-300"},e.map(((e,r)=>{const n=()=>{a(e)},o="w-full h-12 py-2 px-4 inline-flex items-center justify-center gap-2 whitespace-nowrap text-base font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 hover:bg-accent hover:text-accent-foreground";switch(e.type){case"email":return t.createElement(f.a,{key:e.id,initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.1*r},href:`mailto:${e.value}`,target:"_blank",rel:"noopener noreferrer",className:o,onClick:()=>n()},t.createElement(ea,{iconName:e.icon}),t.createElement("span",{className:"flex-grow"},e.label),t.createElement(ea,{iconName:"ArrowSquareOut"}));case"link":return t.createElement(f.a,{key:e.id,initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.1*r},href:e.value,target:"_blank",rel:"noopener noreferrer",className:o,onClick:()=>n()},t.createElement(ea,{iconName:e.icon}),t.createElement("span",{className:"flex-grow"},e.label),t.createElement(ea,{iconName:"ArrowSquareOut"}));case"phone":return t.createElement(f.a,{key:e.id,initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.1*r},href:`tel:${e.value}`,target:"_blank",rel:"noopener noreferrer",className:o,onClick:()=>n()},t.createElement(ea,{iconName:e.icon}),t.createElement("span",{className:"flex-grow"},e.label));default:return t.createElement(ta,{key:e.id,initial:{opacity:0,x:-20},animate:{opacity:1,x:0},transition:{delay:.1*r},className:"w-full text-left h-12 rounded-none",variant:"ghost",onClick:()=>n()},t.createElement(ea,{iconName:"ArrowCircleRight"}),t.createElement("span",{className:"flex-grow"},e.label),t.createElement(ea,{iconName:"ArrowSquareOut"}))}})))):null;function ra({questions:e,activeIndex:a,onNavigate:n,offset:s}){const[i,l]=r(a);o((()=>{l(a)}),[a]);const c=e.length,d=(()=>{const e=[];let t=null;const r=a=>{null!==t&&a-t>1&&e.push("ellipsis"),e.push(a),t=a};r(0);for(let e=Math.max(1,a-2);e<=Math.min(c-2,a+2);e++)r(e);return c>1&&r(c-1),e})();return t.createElement("nav",{"aria-label":"Question timeline navigation",className:"fixed left-4 top-1/2 -translate-y-1/2 z-40 flex flex-col gap-3",style:Object.assign({},s?{left:`${s}px`}:{})},t.createElement(f.div,{className:"flex flex-col items-center space-y-3",role:"list",initial:!1,animate:{y:0},transition:{type:"spring",stiffness:300,damping:30}},t.createElement(h,null,d.map(((r,o)=>{if("ellipsis"===r)return t.createElement(f.div,{key:`ellipsis-${o}`,className:"h-8 flex items-center justify-center","aria-hidden":"true",initial:{opacity:0,y:i>a?-20:20},animate:{opacity:1,y:0},exit:{opacity:0,y:i>a?20:-20},transition:{duration:.2}},t.createElement(D,{className:"size-4 text-foreground"}));const s=r,l=e[s];return t.createElement(f.div,{key:s,className:"relative group isolate",role:"listitem",initial:{opacity:0,y:i>a?-20:20},animate:{opacity:1,y:0},exit:{opacity:0,y:i>a?20:-20},transition:{duration:.2},layout:!0},t.createElement(be,{delayDuration:100},t.createElement(ve,null,t.createElement(Ee,{asChild:!0},t.createElement("button",{onClick:()=>n(s),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||n(s)},className:ge("flex items-center justify-center size-8 rounded-full transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-offset-2 hover:opacity-90 cursor-pointer ring-primary ",s===a?"bg-primary text-primary-foreground":"bg-stone-300 text-zinc-800"),"aria-label":`Navigate to question ${s+1}: ${l}`,"aria-current":s===a?"step":void 0},s+1)),t.createElement(xe,{side:"right",sideOffset:8,className:"max-w-[300px] bg-card text-card-foreground border-foreground/35"},t.createElement("p",{className:"break-words leading-relaxed"},l)))))})))))}function na({onClick:e}){return t.createElement(ze,{size:"icon",variant:"secondary",className:"fixed bottom-20 right-4 rounded-full transition-opacity duration-300 border-border shadow-md",onClick:e},t.createElement(L,{className:"size-5"}))}const oa=oe.Root,sa=oe.Trigger,ia=oe.Group,la=oe.Portal,ca=oe.Sub,da=oe.RadioGroup,ma=e.forwardRef(((t,a)=>{var{className:r,inset:n,children:o}=t,s=he(t,["className","inset","children"]);return e.createElement(oe.SubTrigger,Object.assign({ref:a,className:ge("flex cursor-default gap-2 select-none items-center rounded-sm px-2 py-1.5 text-sm !outline-none focus:bg-accent data-[state=open]:bg-accent [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",n&&"pl-8",r)},s),o,e.createElement(se,{className:"ml-auto"}))}));ma.displayName=oe.SubTrigger.displayName;const ua=e.forwardRef(((t,a)=>{var{className:r}=t,n=he(t,["className"]);return e.createElement(oe.SubContent,Object.assign({ref:a,className:ge("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",r)},n))}));ua.displayName=oe.SubContent.displayName;const pa=e.forwardRef(((t,a)=>{var{className:r,sideOffset:n=4}=t,o=he(t,["className","sideOffset"]);return e.createElement(oe.Portal,null,e.createElement(oe.Content,Object.assign({ref:a,sideOffset:n,className:ge("z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md","data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",r)},o)))}));pa.displayName=oe.Content.displayName;const ha=e.forwardRef(((t,a)=>{var{className:r,inset:n}=t,o=he(t,["className","inset"]);return e.createElement(oe.Item,Object.assign({ref:a,className:ge("relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm !outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>svg]:size-5 [&>svg]:shrink-0",n&&"pl-8",r)},o))}));ha.displayName=oe.Item.displayName;const fa=e.forwardRef(((t,a)=>{var{className:r,children:n,checked:o}=t,s=he(t,["className","children","checked"]);return e.createElement(oe.CheckboxItem,Object.assign({ref:a,className:ge("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm !outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",r),checked:o},s),e.createElement("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center"},e.createElement(oe.ItemIndicator,null,e.createElement(ie,{className:"h-4 w-4"}))),n)}));fa.displayName=oe.CheckboxItem.displayName;const ga=e.forwardRef(((t,a)=>{var{className:r,children:n}=t,o=he(t,["className","children"]);return e.createElement(oe.RadioItem,Object.assign({ref:a,className:ge("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm !outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",r)},o),e.createElement("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center"},e.createElement(oe.ItemIndicator,null,e.createElement(le,{className:"h-2 w-2 fill-current"}))),n)}));ga.displayName=oe.RadioItem.displayName;const ya=e.forwardRef(((t,a)=>{var{className:r,inset:n}=t,o=he(t,["className","inset"]);return e.createElement(oe.Label,Object.assign({ref:a,className:ge("px-2 py-1.5 text-sm font-semibold",n&&"pl-8",r)},o))}));ya.displayName=oe.Label.displayName;const ba=e.forwardRef(((t,a)=>{var{className:r}=t,n=he(t,["className"]);return e.createElement(oe.Separator,Object.assign({ref:a,className:ge("-mx-1 my-1 h-px bg-muted",r)},n))}));ba.displayName=oe.Separator.displayName;const va=t=>{var{className:a}=t,r=he(t,["className"]);return e.createElement("span",Object.assign({className:ge("ml-auto text-xs tracking-widest opacity-60",a)},r))};va.displayName="DropdownMenuShortcut";const Ea=t.forwardRef((({query:e,onQueryChange:a,onSearch:s,textConfig:i,collections:l=[],currentCollectionId:c,onCollectionChange:d,disableImageAttachment:m=!1,attachedImages:u=[],onImageUpload:p,onRemoveImage:g,isSearching:y=!1,autocompleteSuggestions:b=[],onAutocompleteSuggestionSelect:v},E)=>{var x;const w=n(null),[k,C]=r(!1);o((()=>{const e=e=>{e.target.closest(".suggestions-dropdown")||C(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]),o((()=>{e.trim()&&C(!0)}),[e]);const I=k&&e.trim()&&b.length>0,F={hidden:{opacity:0,x:-4},visible:{opacity:1,x:0,transition:{duration:.2}}};return t.createElement("div",{className:"relative w-full","data-name":"PrimarySearch"},t.createElement("div",{className:ge("w-full overflow-hidden bg-background border border-border transition-all",I?"rounded-t-md":"rounded-md")},t.createElement("div",{className:"p-3 flex items-center bg-card"},t.createElement(Q,{className:"h-5 w-5 mr-2 text-muted-foreground","aria-hidden":!0,role:"presentation"}),t.createElement("textarea",{ref:E,value:e,onChange:e=>{var t;a(e.target.value),(t=e.target).style.height="auto",t.style.height=`${t.scrollHeight}px`},onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),s())},onFocus:()=>C(!0),placeholder:i.searchPlaceholder,className:"\n w-full\n resize-none\n !outline-none\n text-base\n py-1\n min-h-9\n overflow-hidden\n border-none\n bg-transparent\n shadow-none\n placeholder:text-gray-400\n text-dark-900\n dark:text-neutral-200\n !ring-0\n ",rows:1}),y&&t.createElement("div",{className:"flex items-center justify-center ml-2"},t.createElement("div",{className:"animate-spin rounded-full size-4 border-2 border-t-transparent border-primary"}))),!m&&u.length>0&&t.createElement("div",{className:"flex gap-2 mt-3 overflow-x-auto pb-1 px-3"},u.map(((e,a)=>t.createElement("div",{key:a,className:"relative group rounded-lg overflow-hidden flex-shrink-0 size-20"},t.createElement("img",{src:e.preview,alt:`Attached ${a+1}`,className:"w-full h-full object-cover"}),t.createElement("button",{onClick:()=>null==g?void 0:g(a),className:"\n absolute\n top-1\n right-1\n rounded-full\n p-1\n opacity-0\n group-hover:opacity-100\n transition-opacity\n duration-200\n hover:bg-black/70\n bg-black/50\n "},t.createElement(q,{className:"size-3 text-white","aria-label":"Remove image"})))))),!I&&t.createElement("div",{className:"flex items-center justify-between px-3 py-2 border-t border-border"},t.createElement("div",{className:"flex gap-1"},l.length>0&&t.createElement(oa,null,t.createElement(sa,{asChild:!0},t.createElement(ze,{variant:"ghost",size:"sm",className:"\n transition-all\n duration-200\n rounded-md\n h-8\n flex\n items-center\n gap-1\n hover:bg-opacity-80\n text-foreground\n "},(null===(x=l.find((e=>e.id===c)))||void 0===x?void 0:x.name)||i.allDocumentsText||"All documents",t.createElement(O,{className:"size-4 text-secondary-foreground"}))),t.createElement(pa,{className:"max-w-48"},l.map((e=>t.createElement(ha,{key:e.id,onClick:()=>null==d?void 0:d(e.id)},e.id===c?t.createElement(N,{className:"rounded-full text-primary-500 !size-5",weight:"fill"}):t.createElement(B,{className:"rounded-full !size-5 text-gray-300"}),t.createElement("span",{className:"text-sm truncate"},e.name)))))),!m&&t.createElement(t.Fragment,null,t.createElement("input",{type:"file",ref:w,accept:"image/*",multiple:!0,className:"hidden",onChange:p}),t.createElement(ze,{variant:"ghost",size:"sm",className:"rounded-md h-8 hover:bg-opacity-80 dark:text-neutral-200",onClick:()=>{var e;return null===(e=w.current)||void 0===e?void 0:e.click()},"aria-label":i.attachImageText},t.createElement(_,{className:"size-4 text-secondary-foreground"}),t.createElement("span",{className:"hidden @sm:block"},i.attachImageText)))),t.createElement("div",{className:"flex items-center"},t.createElement(ze,{size:"sm",disabled:!e||y,"aria-disabled":!e||y,className:"rounded-md size-8 disabled:opacity-50 bg-primary",onClick:s},y?t.createElement("div",{className:"flex items-center",role:"status","aria-live":"polite"},t.createElement("div",{className:"animate-spin rounded-full size-4 border-2 border-t-transparent border-white","aria-hidden":"true"}),t.createElement("span",{className:"sr-only"},"Loading")):t.createElement($,{className:"text-primary-foreground",size:16,weight:"bold","aria-label":"Submit question"}))))),t.createElement(h,{mode:"wait"},I&&t.createElement(f.div,{variants:{hidden:{opacity:0,scale:.95,transformOrigin:"top"},visible:{opacity:1,scale:1,transition:{type:"spring",stiffness:500,damping:30,mass:.5}},exit:{opacity:0,scale:.95,transition:{duration:.15,ease:"easeOut"}}},initial:"hidden",animate:"visible",exit:"exit",className:"\n suggestions-dropdown\n absolute\n left-0\n right-0\n z-50\n overflow-hidden\n bg-card\n border-border\n border-b border-l border-r border-solid rounded-b-md shadow-md -mt-px\n "},t.createElement(f.div,{className:"md:hidden",variants:F},e.trim()&&t.createElement("div",{role:"option","aria-selected":!1,tabIndex:0,className:"\n px-4 py-3\n cursor-pointer\n flex\n items-center\n gap-3\n transition-colors\n duration-200\n hover:bg-gray-50/50\n text-foreground\n bg-gray-100\n border-b border border-border\n dark:bg-slate-500\n dark:border-dark-800/20\n ",onClick:()=>{s(),C(!1)},onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),s(),C(!1))}},t.createElement(Q,{className:"size-4 flex-shrink-0 text-secondary-foreground"}),t.createElement("span",{className:"text-[15px]"},e),t.createElement("div",{className:"ml-auto flex items-center"},t.createElement(R,{className:"size-4 text-secondary-foreground"})))),t.createElement(f.div,{variants:{visible:{transition:{staggerChildren:.03,delayChildren:.05}}},initial:"hidden",animate:"visible"},b.map((e=>t.createElement(f.div,{key:e.id,variants:F,role:"option","aria-selected":!1,tabIndex:0,className:"px-4 py-3 cursor-pointer flex items-center gap-3 transition-colors duration-200 hover:bg-gray-200/50 text-foreground",onClick:()=>{null==v||v(e),C(!1)},onKeyDown:t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),null==v||v(e),C(!1))}},t.createElement(Q,{className:"size-4 flex-shrink-0 text-secondary-foreground"}),t.createElement("span",{className:"text-[15px]"},e.question),t.createElement("div",{className:"ml-auto flex items-center"},t.createElement(R,{className:"size-4 text-secondary-foreground"})))))))))}));Ea.displayName="PrimarySearch";var xa="FollowUpSearchBar-module_followUpSearchBar__DiKdH";const wa=e.forwardRef(((t,a)=>{var{className:r}=t,n=he(t,["className"]);return e.createElement("textarea",Object.assign({className:ge("flex min-h-[60px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",r),ref:a},n))}));wa.displayName="Textarea";const Na=t.forwardRef((({initialQuery:e="",onQueryChange:a,isSearching:s,handleFollowUpSearch:i,textConfig:l},c)=>{const[d,m]=r(e),u=n(null);o((()=>{u.current&&(u.current.style.height="inherit",u.current.style.height=`${u.current.scrollHeight}px`)}),[d]),o((()=>{m(e)}),[e]);return t.createElement(f.footer,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5},className:xa},t.createElement("div",{className:"container flex items-center justify-center p-3"},t.createElement("div",{className:"relative flex w-full items-center gap-2 rounded bg-card px-2 border border-dark-400"},t.createElement("div",{className:"size-6 flex flex-shrink-0 justify-center items-center"},t.createElement(Q,{className:"size-5 text-secondary-foreground"})),t.createElement(wa,{ref:e=>{u.current=e,"function"==typeof c?c(e):c&&"current"in c&&(c.current=e)},value:d,onChange:e=>{m(e.target.value)},onBlur:()=>{d!==e&&a(d)},onKeyDown:e=>{if("Enter"===e.key&&!e.shiftKey&&!s){e.preventDefault();const t=d;a(t),i(t),m("")}},placeholder:l.followUpPlaceholder,className:"min-h-[44px] w-full resize-none border-0 shadow-none bg-transparent px-0 py-2.5 focus:outline-none focus:ring-0 focus-visible:ring-0",rows:1}),t.createElement(ze,{type:"button",size:"icon",disabled:s||!d.trim(),onClick:()=>{const e=d;a(e),i(e),m("")},className:ge("size-8 shrink-0 rounded",d?"bg-primary text-primary-foreground":"bg-dark-400 dark:bg-muted text-white")},s?t.createElement("div",{className:"animate-spin rounded-full size-4 sm:size-5 border-2 border-dark/40 !border-t-foreground dark:border-dark-500 "}):t.createElement($,{className:"size-6"})))))}));function ka(e){var{headerText:a,onToggleSizeButtonClick:r,onBackButtonClick:n,onCloseWidgetClick:o,className:s}=e,i=he(e,["headerText","onToggleSizeButtonClick","onBackButtonClick","onCloseWidgetClick","className"]);const l=Bt(),[c,d]=t.useState(!1),{isSearching:m,showMobileCloseWidgetButton:u}=qt();return t.createElement("div",Object.assign({className:ge("w-full px-3 py-4 flex items-center justify-between","bg-primary h-14 leading-6","@3xl:bg-transparent @3xl:h-auto @3xl:leading-normal","@3xl:justify-center @3xl:space-y-4 @3xl:p-0",s)},i),t.createElement(f.h1,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,delay:.3},className:"@3xl:text-5xl m-0 text-primary-foreground @3xl:text-foreground flex gap-1 items-center font-bold text-base"},l&&t.createElement(ze,{size:"icon",variant:"ghost",onClick:n,"aria-label":"Go back",className:"@3xl:hidden",disabled:m},t.createElement(P,null)),t.createElement("span",null,a)),t.createElement("div",{className:"@3xl:hidden"},!u&&t.createElement(ze,{size:"icon",variant:"ghost",onClick:()=>{d((e=>!e)),r()},"aria-label":c?"Collapse widget":"Expand widget",className:"text-primary-foreground"},c?t.createElement(U,null):t.createElement(M,null)),t.createElement(ze,{size:"icon",variant:"ghost",onClick:o,"aria-label":"Close widget",className:"text-primary-foreground"},t.createElement(q,null))))}Na.displayName="FollowUpSearchBar";const Ca={headerText:"How can we help you today?",searchPlaceholder:"Ask a question or type a search term here ...",attachImageText:"Attach image",allDocumentsText:"All documents",loadingSearchText:"Searching for relevant content...",loadingAnswerText:"Crafting a response...",errorText:"Sorry, there was an error generating the answer.",followUpPlaceholder:"Ask follow-up",positiveAnswerText:"Helpful",negativeAnswerText:"Not helpful",uncertaintyFallbackText:{en:"Sorry, I can't find a clear answer to your question. Please try rephrasing or check the related sources below.",es:"Lo siento, no puedo encontrar una respuesta clara. Intente reformular la pregunta o consulte las fuentes relacionadas.",fr:"Désolé, je ne trouve pas de réponse claire. Essayez de reformuler ou consultez les sources connexes.",de:"Entschuldigung, ich finde keine klare Antwort. Versuchen Sie es anders zu formulieren oder sehen Sie sich die verwandten Quellen an.",it:"Mi dispiace, non trovo una risposta chiara. Prova a riformulare o consulta le fonti correlate.",pt:"Desculpe, não encontro uma resposta clara. Tente reformular ou consulte as fontes relacionadas.",nl:"Sorry, ik kan geen duidelijk antwoord vinden. Probeer het anders te formuleren of bekijk de gerelateerde bronnen.",pl:"Przepraszam, nie znajduję jasnej odpowiedzi. Spróbuj przeformułować pytanie lub sprawdź powiązane źródła.",ru:"Извините, я не могу найти четкого ответа. Попробуйте переформулировать или ознакомьтесь со связанными источниками.",ja:"申し訳ありませんが、明確な回答が見つかりません。質問の言い換えや、関連ソースをご確認ください。",ko:"죄송합니다. 명확한 답변을 찾을 수 없습니다. 질문을 다시 작성하거나 관련 소스를 확인해 주세요.",zh:"抱歉,找不到明确的答案。请尝试重新表述或查看相关来源。","zh-TW":"抱歉,找不到明確的答案。請嘗試重新表述或查看相關來源。"}},Ia=i(void 0);function Fa({children:e,flags:a}){return t.createElement(Ia.Provider,{value:null!=a?a:{}},e)}function ja({query:e,endpoint:t,collectionId:a,headers:n,conversationId:i,delay:l=300}){const[c,d]=r([]),[m,u]=r(!1),[p,h]=r(),f=function(e,t){const[a,n]=r(e);return o((()=>{const a=setTimeout((()=>{n(e)}),t);return()=>{clearTimeout(a)}}),[e,t]),a}(e,l),g=s((()=>fe(this,void 0,void 0,(function*(){var e;if(f.trim()){u(!0),h(void 0);try{const r=yield function({endpoint:e,query:t,collectionId:a,headers:r,conversationId:n}){return fe(this,void 0,void 0,(function*(){return yield Mt(e,{method:"POST",headers:r,retry:Vt,body:Object.assign(Object.assign({query:t},a&&"all"!==a&&{collectionId:a}),n&&{conversationId:n})})}))}({endpoint:t,query:f,collectionId:a,headers:n,conversationId:i});d(null===(e=null==r?void 0:r.response)||void 0===e?void 0:e.results)}catch(e){console.error("Error fetching autocomplete suggestions:",e),h(e instanceof Error?e.message:"Failed to fetch suggestions"),d([])}finally{u(!1)}}else d([])}))),[f,t,a,n,i]);return o((()=>{g()}),[g]),{suggestions:c,isLoading:m,error:p}}const Sa=e.forwardRef(((t,a)=>{var{className:r,children:n}=t,o=he(t,["className","children"]);return e.createElement(ce.Root,Object.assign({className:ge("relative overflow-hidden",r)},o),e.createElement(ce.Viewport,{ref:a,className:"h-full w-full rounded-[inherit]"},n),e.createElement(za,null),e.createElement(ce.Corner,null))}));Sa.displayName=ce.Root.displayName;const za=e.forwardRef(((t,a)=>{var{className:r,orientation:n="vertical"}=t,o=he(t,["className","orientation"]);return e.createElement(ce.ScrollAreaScrollbar,Object.assign({ref:a,orientation:n,className:ge("flex touch-none select-none transition-colors","vertical"===n&&"h-full w-2.5 border-l border-l-transparent p-[1px]","horizontal"===n&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",r)},o),e.createElement(ce.ScrollAreaThumb,{className:"relative flex-1 rounded-full bg-dark-400"}))}));za.displayName=ce.ScrollAreaScrollbar.displayName;const Aa=u((({suggestions:e=[],collections:a=[],selectedCollectionId:s,onCollectionChange:i,searchEndpoint:l,answerStreamEndpoint:c,feedbackEndpoint:d,loadConversationEndpoint:m,autocompleteEndpoint:u,disableFollowUpQuestions:g=!1,disableImageAttachment:y=!1,disableFeedback:b=!1,siblingNode:v,offset:E=0,headers:x,textConfig:w={},followUpQuestionsEndpoint:N,className:k,onToggleSizeButtonClick:C,trackEvent:I,onCloseWidget:F,isWidgetMode:j=!0,nextBestActions:S,onNextBestActionClick:z,userData:A},O)=>{const{answers:T,answerListDispatch:R,query:D,setQuery:L,followUpQuery:Q,setFollowUpQuery:q,isSearching:B,setIsSearching:_,showResults:$,setShowResults:P,activeAnswerIndex:U,setActiveAnswerIndex:M,conversationId:V,setConversationId:W,clearConversationId:Z,isLoadingConversation:H,setShowMobileCloseWidgetButton:K}=qt(),G=Object.assign(Object.assign({},Ca),w),[J,Y]=r(!1),[X,te]=r([]),[ae,re]=r(s),[ne,oe]=r(!0),se=n(null),ie=n([]),le=n(null),ce=n(null),de=n(null),me=n(null),{suggestions:ue}=ja({query:D,endpoint:u||"",collectionId:ae,headers:x,conversationId:V,delay:300}),{loadConversationById:pe}=Ht({loadConversationEndpoint:m,headers:x,mergedTextConfig:G}),{scrollToLastAnswer:he,scrollToAnswer:be}=((e,t)=>({scrollToLastAnswer:()=>{requestAnimationFrame((()=>{var a;const r=null===(a=e.current)||void 0===a?void 0:a[e.current.length-1],n=t.current;if(r&&n){const e=r.getBoundingClientRect(),t=n.getBoundingClientRect(),a=n.scrollTop+(e.top-t.top)-80;n.scrollTo({top:a,behavior:"smooth"})}}))},scrollToAnswer:a=>{requestAnimationFrame((()=>{var r;const n=null===(r=e.current)||void 0===r?void 0:r[a],o=t.current;if(n&&o){const e=n.getBoundingClientRect(),t=o.getBoundingClientRect(),a=o.scrollTop+(e.top-t.top)-80;o.scrollTo({top:a,behavior:"smooth"})}}))}}))(ie,le),{subscribeToStateChanges:ve}=(()=>{const e=n([]),{showResults:t,answers:a,isLoadingConversation:r,loadError:s}=qt();return o((()=>{const n={showResults:t,answers:a,isLoading:r,error:s};e.current.forEach((e=>e(n)))}),[t,a,r,s]),{subscribeToStateChanges:n=>(e.current.push(n),n({showResults:t,answers:a,isLoading:r,error:s}),()=>{e.current=e.current.filter((e=>e!==n))})}})(),Ee=(e,t)=>fe(void 0,void 0,void 0,(function*(){if(N&&!g)try{const a=yield function({endpoint:e,searchQueryId:t,headers:a,conversationId:r}){return fe(this,void 0,void 0,(function*(){return(yield Mt(e,{method:"POST",headers:a,body:Object.assign({searchQueryId:t},r&&{conversationId:r})})).questions}))}({endpoint:N,searchQueryId:e,headers:x,conversationId:t});return a}catch(e){return void console.error("Error fetching follow-up questions:",e)}})),xe=({reader:e,searchQueryId:t,conversationId:a,onFirstEvent:r})=>fe(void 0,void 0,void 0,(function*(){var n,o,s,i;let l="";try{let c,d,m=!1,u=!0,p=!1;for(;({done:m,value:d}=yield e.read()),!m;){u&&(u=!1,null==r||r());const e=(new TextDecoder).decode(d).split(/\n\n/).filter((e=>e.startsWith("data: "))).map((e=>e.replace(/^data: /,"").trim()));for(const r of e)try{const e=JSON.parse(r);if("answer-text-chunk"===e.type){l+=e.content,R(Ct({text:e.content}));const t=ye(l);if(p=t.uncertain,p){const e=null!==(i=null!==(s=null===(n=G.uncertaintyFallbackText)||void 0===n?void 0:n[null!==(o=t.language)&&void 0!==o?o:"en"])&&void 0!==s?s:l)&&void 0!==i?i:"I don't know.";R(jt({uncertaintyText:e}))}}"action-buttons"===e.type&&(c=e.searchIntentId,R(zt({searchIntentId:c}))),"get-action-inputs"===e.type&&(c=e.searchIntentId,R(St({searchIntentId:e.searchIntentId,actionId:e.actionId,schema:e.schema,initialValues:e.values,onSubmit:r=>Ne({searchQueryId:t,conversationId:a,searchIntentId:e.searchIntentId,actionId:e.actionId,parameters:r})})))}catch(e){console.warn("Failed to parse answer stream block")}}return{answer:l,searchIntentId:c,isUncertain:p}}finally{e.releaseLock()}})),we=({searchQueryId:e,conversationId:t})=>fe(void 0,void 0,void 0,(function*(){var a;try{const r=Ee(e),n=null===(a=(yield Zt({endpoint:c,headers:x,body:{type:"generate-for-query",conversationId:t,searchQueryId:e,userData:A}})).body)||void 0===a?void 0:a.getReader();if(!n)return;const{answer:o,searchIntentId:s,isUncertain:i}=yield xe({reader:n,searchQueryId:e,conversationId:t,onFirstEvent:()=>{null==I||I("First Streamed Answer Chunk Received",{conversationId:t,searchQueryId:e})}});if(!o)return;r.then((e=>{e&&e.length>0&&!s&&R((({questions:e,index:t})=>({type:ft,payload:{questions:e,index:t}}))({questions:e}))})),i?null==I||I("Answer Not Found",{conversationId:t,searchQueryId:e}):null==I||I("Answer Found",{conversationId:t,searchQueryId:e})}catch(e){console.error("Error generating answer for query:",e),R(It({error:G.errorText||"An error occurred."}))}finally{R(Ft())}})),Ne=({searchQueryId:e,searchIntentId:t,conversationId:a,actionId:r,parameters:n})=>fe(void 0,void 0,void 0,(function*(){var o;R((({index:e}={})=>({type:wt,payload:{index:e}}))());try{const s=null===(o=(yield Zt({endpoint:c,headers:x,body:{type:"invoke-action",conversationId:a,searchQueryId:e,searchIntentId:t,actionId:r,parameters:n,userData:A}})).body)||void 0===o?void 0:o.getReader();if(!s)return;yield xe({reader:s,searchQueryId:e})}catch(e){console.error("Error generating answer for action:",e),R(It({error:G.errorText||"An error occurred."}))}finally{R(Ft()),_(!1)}})),ke=(e,t)=>fe(void 0,void 0,void 0,(function*(){const a=yield function({endpoint:e,query:t,collectionId:a,headers:r,conversationId:n}){var o;return fe(this,void 0,void 0,(function*(){const s=yield Mt(e,{method:"POST",headers:r,retry:Vt,body:Object.assign(Object.assign({query:t,limit:5},a&&"all"!==a&&{collectionId:a}),n&&{conversationId:n})});return{results:null==s?void 0:s.data,searchQueryId:null===(o=null==s?void 0:s.searchQuery)||void 0===o?void 0:o.id}}))}({endpoint:l,query:e,collectionId:ae,headers:x,conversationId:t});return 0===a.results.length&&(null==I||I("No Articles Found",{conversationId:t,searchQuery:e})),R((({searchQueryId:e,results:t,index:a})=>({type:ht,payload:{searchQueryId:e,results:t,index:a}}))({searchQueryId:a.searchQueryId,results:a.results})),a.searchQueryId})),Ce=({searchQuery:e=D.trim(),event:t})=>fe(void 0,void 0,void 0,(function*(){var a;if(!e)return;const r=V||ee();W(r),_(!0),P(!0),M(T.length),he(),R((({id:e,query:t})=>({type:mt,payload:{id:e,query:t}}))({query:e})),yield Promise.resolve(),null===(a=me.current)||void 0===a||a.focus();try{const a=yield ke(e,r);t&&(null==I||I(t.name,Object.assign({conversationId:r,searchQuery:e,searchQueryId:a},t.metaData))),yield we({searchQueryId:a,conversationId:r})}catch(a){console.error("Error generating answer:",a),t&&(null==I||I(`${t.name} - Search Error`,Object.assign({conversationId:r,searchQuery:e},t.metaData))),R(It({error:G.errorText||"An error occurred."}))}finally{_(!1)}})),Ie=e=>{if(e)return L(e),void Ce({searchQuery:e,event:{name:"New Thread Created with Query"}});L(""),q(""),P(!1),R(kt()),M(0),te([]),Z(),null==I||I("New Thread Created",{oldConversationId:V}),se.current&&(se.current.style.height="auto")};p(O,(()=>({createNewThread:Ie,showFollowUpThread:e=>{oe(e)},subscribeToStateChanges:ve,focusSearchField:()=>{var e,t;return(null===(e=de.current)||void 0===e?void 0:e.focus())||(null===(t=me.current)||void 0===t?void 0:t.focus())},showCloseButton:(e=!0)=>{K(e)}}))),o((()=>{re(s)}),[s]);const Fe=(e,t,a)=>fe(void 0,void 0,void 0,(function*(){if(d){R((({feedback:e,index:t})=>({type:bt,payload:{feedback:e,index:t}}))({feedback:e,index:a}));try{yield function({endpoint:e,searchQueryId:t,response:a,headers:r,conversationId:n}){return fe(this,void 0,void 0,(function*(){yield Mt(e,{method:"POST",headers:r,body:Object.assign({searchQueryId:t,response:a},n&&{conversationId:n})})}))}({endpoint:d,searchQueryId:t,response:e,headers:x,conversationId:V}),null==I||I("accept"===e?"Answer Accepted":"Answer Rejected",{conversationId:V,searchQueryId:t})}catch(e){console.error("Error sending feedback:",e),R((({index:e}={})=>({type:vt,payload:{index:e}}))({index:a}))}}}));o((()=>{const e=()=>{const e=window.innerHeight+window.pageYOffset>=document.documentElement.scrollHeight-100;Y(!e)};return window.addEventListener("scroll",e),()=>window.removeEventListener("scroll",e)}),[]),o((()=>()=>{X.forEach((e=>URL.revokeObjectURL(e.preview)))}),[X]);o((()=>{const e=()=>{new URLSearchParams(window.location.search).get("conversation")||(L(""),q(""),P(!1),R(kt()),M(0),te([]),se.current&&(se.current.style.height="auto"))};return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)}),[]);const je=e=>{null==I||I("Follow-up Question Clicked",{conversationId:V,question:e}),Ce({searchQuery:e,event:{name:"Follow-up Question Clicked"}})};return t.createElement("div",{className:ge("w-full relative h-dvh flex flex-col justify-between @container",k),"data-name":"ChatSearch"},(j||!$)&&t.createElement(ka,{"data-name":"Header",headerText:G.headerText,onToggleSizeButtonClick:()=>{null==C||C()},onBackButtonClick:()=>{Ie()},onCloseWidgetClick:()=>null==F?void 0:F(),className:"@3xl:mb-4"}),t.createElement(Sa,{className:"w-full relative h-auto flex-grow",ref:le},t.createElement(h,null,H?t.createElement(f.div,{key:"loading",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"w-full flex items-center justify-center py-20","data-name":"loading"},t.createElement("div",{className:"flex flex-col items-center gap-4"},t.createElement("div",{className:"animate-spin rounded-full size-8 border-2 border-t-transparent border-primary"}),t.createElement("p",{className:"text-sm text-secondary-foreground"},"Loading conversation..."))):$?t.createElement(f.div,{key:"results",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.5},className:"w-full max-w-[100vw] space-y-4 p-3 md:p-4"},T.map(((e,a)=>t.createElement(f.div,{key:a,ref:e=>ie.current[a]=e,initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,delay:.1*a}},t.createElement(Jt,{blocks:e.blocks,question:e.question,state:e.state,searchResults:e.searchResults,searchQueryId:e.searchQueryId,feedback:e.feedback,onFeedback:t=>{Fe(t,e.searchQueryId,a)},disableFeedback:b,textConfig:G}),a===T.length-1&&!g&&e.followUpQuestions&&"completed"===e.state&&t.createElement(t.Fragment,null,t.createElement("div",{className:"mt-4"},t.createElement(Xt,{questions:e.followUpQuestions,onQuestionClick:je})),t.createElement("div",{className:"mt-4"},t.createElement(aa,{nextBestActions:S||[],onActionClick:t=>(({action:e,searchQueryId:t,query:a,answer:r})=>{null==I||I("Next Best Action Clicked",{conversationId:V,searchQueryId:t,action:e.label}),null==z||z({action:e,searchQueryId:t,query:a,answer:r})})({action:t,searchQueryId:e.searchQueryId||"",query:D,answer:e.blocks.filter(rt).map((e=>e.text)).join("\n\n---\n\n")})}))))))):t.createElement(f.div,{key:"search",initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5},className:"w-full"},t.createElement("div",{className:"pb-4 px-3 bg-primary @3xl:px-0 @3xl:bg-transparent"},t.createElement(f.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},transition:{duration:.5,delay:.4}},t.createElement(Ea,{ref:de,query:D,onQueryChange:e=>{var t;L(e),se.current&&((t=se.current).style.height="auto",t.style.height=`${t.scrollHeight}px`)},onSearch:()=>{((e=D.trim())=>{fe(void 0,void 0,void 0,(function*(){yield Ce({searchQuery:e,event:{name:"Primary Field Search Submitted"}})}))})()},textConfig:G,collections:a,currentCollectionId:ae,onCollectionChange:e=>{re(e),null==i||i(e)},disableImageAttachment:y,attachedImages:X,onImageUpload:e=>{const t=e.target.files;if(t){const e=Array.from(t).map((e=>({file:e,preview:URL.createObjectURL(e)})));te((t=>[...t,...e]))}ce.current&&(ce.current.value="")},onRemoveImage:e=>{te((t=>(URL.revokeObjectURL(t[e].preview),t.filter(((t,a)=>a!==e)))))},isSearching:B,autocompleteSuggestions:ue,onAutocompleteSuggestionSelect:e=>{Ce({searchQuery:e.question,event:{name:"Autocomplete Suggestion Clicked"}})}}))),t.createElement(Ae,{suggestions:e,onQuestionClick:e=>{if(e.conversationId)return null==I||I("Recent Conversation Clicked",{conversationId:V,question:e.question}),void pe(e.conversationId);Ce({searchQuery:e.question,event:{name:"Suggested Question Clicked"}})},title:G.suggestionsTitle}),v)),$&&T.length>1&&t.createElement("div",{className:"hidden lg:block"},t.createElement(ra,{questions:T.map((e=>e.question)),activeIndex:U,onNavigate:e=>{M(e),be(e)},offset:E}))),$&&ne&&t.createElement(Na,{ref:me,initialQuery:Q,onQueryChange:q,isSearching:B,handleFollowUpSearch:e=>fe(void 0,void 0,void 0,(function*(){const t=void 0!==e?e:Q;t.trim()&&(L(t),q(""),yield Ce({searchQuery:t,event:{name:"Follow-up Search Field Submitted"}}))})),textConfig:G}),J&&$&&t.createElement(na,{onClick:he}))}));Aa.displayName="ChatSearch";const Oa=u(((e,a)=>{var{featureFlags:r}=e,n=he(e,["featureFlags"]);return t.createElement(Fa,{flags:r},t.createElement(Qt,{searchPath:n.searchPath},t.createElement(Aa,Object.assign({},n,{ref:a}))))}));Oa.displayName="ChatSearch";const Ta=e.forwardRef(((t,a)=>{var{className:r}=t,n=he(t,["className"]);return e.createElement(de.Root,Object.assign({className:ge("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:!outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",r)},n,{ref:a}),e.createElement(de.Thumb,{className:ge("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")}))}));Ta.displayName=de.Root.displayName;export{pe as BrainfishColors,ze as Button,Oa as ChatSearch,Qt as ChatSearchProvider,Be as CodeBlock,ot as Collapsible,it as CollapsibleContent,st as CollapsibleTrigger,oa as DropdownMenu,fa as DropdownMenuCheckboxItem,pa as DropdownMenuContent,ia as DropdownMenuGroup,ha as DropdownMenuItem,ya as DropdownMenuLabel,la as DropdownMenuPortal,da as DropdownMenuRadioGroup,ga as DropdownMenuRadioItem,ba as DropdownMenuSeparator,va as DropdownMenuShortcut,ca as DropdownMenuSub,ua as DropdownMenuSubContent,ma as DropdownMenuSubTrigger,sa as DropdownMenuTrigger,Xe as FormattedMessage,Oe as Input,Re as Label,Ke as MemoizedReactMarkdown,Je as MermaidDiagram,Sa as ScrollArea,za as ScrollBar,Ta as Switch,wa as Textarea,ve as Tooltip,xe as TooltipContent,be as TooltipProvider,Ee as TooltipTrigger,Ye as ZoomableImage,Se as buttonVariants,me as customColor,qt as useChatSearch,Bt as useIsChatSearchDirty};
2
2
  //# sourceMappingURL=index.js.map