general-ai-chat-bot 0.2.2 → 0.2.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/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var te=Object.create;var C=Object.defineProperty;var oe=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var ae=Object.getPrototypeOf,se=Object.prototype.hasOwnProperty;var ne=(e,t)=>{for(var o in t)C(e,o,{get:t[o],enumerable:!0})},V=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of re(t))!se.call(e,a)&&a!==o&&C(e,a,{get:()=>t[a],enumerable:!(r=oe(t,a))||r.enumerable});return e};var E=(e,t,o)=>(o=e!=null?te(ae(e)):{},V(t||!e||!e.__esModule?C(o,"default",{value:e,enumerable:!0}):o,e)),ie=e=>V(C({},"__esModule",{value:!0}),e);var Ce={};ne(Ce,{ApiProvider:()=>_,ChatBot:()=>O,ChatBotProvider:()=>A,createFetchAdapter:()=>I,useApiConfig:()=>z,useChatBotConfig:()=>N});module.exports=ie(Ce);var B=require("react");var x=require("react"),q=require("react/jsx-runtime"),F=(0,x.createContext)(null),A=({config:e,children:t})=>(0,q.jsx)(F.Provider,{value:e,children:t}),_=A,M=()=>(0,x.useContext)(F),N=()=>{let e=M();if(!e)throw new Error("useChatBotConfig must be used inside ChatBotProvider or ApiProvider");return e},z=N;var g=require("react");var l=E(require("react"),1);var le=E(require("react"),1);function j(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function H(...e){return t=>{let o=!1,r=e.map(a=>{let s=j(a,t);return!o&&typeof s=="function"&&(o=!0),s});if(o)return()=>{for(let a=0;a<r.length;a++){let s=r[a];typeof s=="function"?s():j(e[a],null)}}}}var y=require("react/jsx-runtime");function ce(e){let t=de(e),o=l.forwardRef((r,a)=>{let{children:s,...c}=r,i=l.Children.toArray(s),p=i.find(ue);if(p){let d=p.props.children,f=i.map(h=>h===p?l.Children.count(d)>1?l.Children.only(null):l.isValidElement(d)?d.props.children:null:h);return(0,y.jsx)(t,{...c,ref:a,children:l.isValidElement(d)?l.cloneElement(d,void 0,f):null})}return(0,y.jsx)(t,{...c,ref:a,children:s})});return o.displayName=`${e}.Slot`,o}var D=ce("Slot");function de(e){let t=l.forwardRef((o,r)=>{let{children:a,...s}=o;if(l.isValidElement(a)){let c=he(a),i=fe(s,a.props);return a.type!==l.Fragment&&(i.ref=r?H(r,c):c),l.cloneElement(a,i)}return l.Children.count(a)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var pe=Symbol("radix.slottable");function ue(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===pe}function fe(e,t){let o={...t};for(let r in t){let a=e[r],s=t[r];/^on[A-Z]/.test(r)?a&&s?o[r]=(...i)=>{let p=s(...i);return a(...i),p}:a&&(o[r]=a):r==="style"?o[r]={...a,...s}:r==="className"&&(o[r]=[a,s].filter(Boolean).join(" "))}return{...e,...o}}function he(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,o=t&&"isReactWarning"in t&&t.isReactWarning;return o?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,o=t&&"isReactWarning"in t&&t.isReactWarning,o?e.props.ref:e.props.ref||e.ref)}var K=require("class-variance-authority");function $(e){var t,o,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(o=$(e[t]))&&(r&&(r+=" "),r+=o)}else for(o in e)e[o]&&(r&&(r+=" "),r+=o);return r}function L(){for(var e,t,o=0,r="",a=arguments.length;o<a;o++)(e=arguments[o])&&(t=$(e))&&(r&&(r+=" "),r+=t);return r}var W=require("tailwind-merge");function w(...e){return(0,W.twMerge)(L(e))}var G=require("react/jsx-runtime"),me=(0,K.cva)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function R({className:e,variant:t,size:o,asChild:r=!1,...a}){return(0,G.jsx)(r?D:"button",{"data-slot":"button",className:w(me({variant:t,size:o,className:e})),...a})}var v=require("lucide-react");var U=require("react/jsx-runtime");function J({className:e,...t}){return(0,U.jsx)("textarea",{"data-slot":"textarea",className:w("wrap-break-word break-normal border-input placeholder:text-muted-foreground aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base transition-[color,box-shadow] outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),...t})}var n=require("react/jsx-runtime");function k(e){let{messages:t,handleSendMessage:o,isOpen:r,isSending:a,setIsOpen:s}=e,[c,i]=(0,g.useState)(""),p=(0,g.useRef)(null),d=c.trim().length>0&&!a;(0,g.useEffect)(()=>{p.current?.scrollIntoView({behavior:"smooth"})},[t]);let f=()=>{if(!d)return;let u=c;i(""),o(u)},h=u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),f())};return(0,n.jsxs)(n.Fragment,{children:[!r&&(0,n.jsx)(R,{onClick:()=>s(!0),className:"fixed bottom-6 right-6 h-12 w-12 rounded-full bg-slate-900 hover:bg-slate-800 shadow-lg hover:shadow-xl transition-all duration-200 z-50 border border-slate-200",size:"icon",children:(0,n.jsx)(v.MessageCircle,{className:"h-5 w-5 text-white"})}),r&&(0,n.jsxs)("div",{className:"fixed bottom-6 right-6 h-[75vh] w-[400px] max-w-[calc(100vw-3rem)] bg-white border border-slate-200 rounded-lg shadow-xl z-50 flex flex-col overflow-hidden",children:[(0,n.jsxs)("div",{className:"border-b border-slate-100 p-3 flex items-center justify-between bg-white",children:[(0,n.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,n.jsx)("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),(0,n.jsx)("span",{className:"text-sm font-medium text-slate-900",children:"Assistant"})]}),(0,n.jsx)(R,{variant:"ghost",size:"icon",onClick:()=>s(!1),className:"h-6 w-6 text-slate-400 hover:text-slate-600",children:(0,n.jsx)(v.X,{className:"h-3 w-3"})})]}),(0,n.jsxs)("div",{className:"flex-1 overflow-y-auto p-4 space-y-3 bg-slate-50/30",children:[t.map((u,b)=>(0,n.jsx)("div",{className:`flex ${u.role==="assistant"?"justify-start":"justify-end"}`,children:(0,n.jsx)("div",{className:`max-w-[75%] px-3 py-2 rounded-lg text-sm ${u.role==="assistant"?"bg-white border border-slate-200 text-slate-700":"bg-slate-900 text-white"}`,children:u.content})},b)),(0,n.jsx)("div",{ref:p})]}),(0,n.jsx)("div",{className:"border-t border-slate-100 p-3 bg-white",children:(0,n.jsxs)("div",{className:"flex space-x-2",children:[(0,n.jsx)(J,{value:c,onChange:u=>i(u.target.value),onKeyDown:h,rows:2,placeholder:"What's on your mind? \u{1F4AD}",className:"min-h-[3rem] resize-none border-none flex-1 bg-white/80 placeholder:text-gray-400"}),(0,n.jsx)(R,{onClick:f,size:"icon",disabled:!d,className:"self-center bg-slate-900 hover:bg-slate-800 h-9 w-9",children:(0,n.jsx)(v.Send,{className:"h-3 w-3"})})]})})]})]})}var X=require("react/jsx-runtime"),ge="Hi! I'm your digital assistant. How can I help you today?",ve="Apologies, I ran into a problem. Please try again later.";function O({style:e,adapter:t,welcomeMessage:o=ge,errorMessage:r=ve}){let a=M(),s=t??a?.adapter,[c,i]=(0,B.useState)(!1),[p,d]=(0,B.useState)(!1),[f,h]=(0,B.useState)(()=>[{content:o,role:"assistant"}]);if(!s)throw new Error("ChatBot requires an adapter prop or a ChatBotProvider/ApiProvider config with an adapter.");return(0,X.jsx)(k,{messages:f,handleSendMessage:async b=>{if(!b.trim())return;d(!0);let ee={content:b,role:"user"},T=[...f,ee];h(T);try{let S=await s.sendMessage(T);h(P=>[...P,S])}catch{let S={content:r,role:"assistant"};h(P=>[...P,S])}finally{d(!1)}},isOpen:c,isSending:p,setIsOpen:i})}var m=E(require("zod")),Z=m.default.object({role:m.default.enum(["user","assistant"]),content:m.default.string()}),Q=m.default.object({messages:m.default.array(Z).min(1)}),Y=m.default.object({message:Z});var be=async e=>typeof e=="function"?await e():e,I=({apiUrl:e,fetch:t=globalThis.fetch,headers:o})=>{if(!e)throw new Error("apiUrl is required");return{async sendMessage(r){if(typeof t!="function")throw new Error("Fetch API is not available. Provide a fetch implementation.");let a={messages:r},s=Q.safeParse(a);if(!s.success)throw new Error("Invalid chat request payload.");let c=new Headers(await be(o));c.has("Content-Type")||c.set("Content-Type","application/json");let i=await t(e,{method:"POST",headers:c,body:JSON.stringify(s.data)});if(!i.ok){let f=i.statusText?` ${i.statusText}`:"";throw new Error(`Chat request failed with ${i.status}${f}`)}let p=await i.json(),d=Y.safeParse(p);if(!d.success)throw new Error("Invalid chat response payload.");return d.data.message}}};0&&(module.exports={ApiProvider,ChatBot,ChatBotProvider,createFetchAdapter,useApiConfig,useChatBotConfig});
|
|
1
|
+
"use strict";var pe=Object.create;var B=Object.defineProperty;var ue=Object.getOwnPropertyDescriptor;var me=Object.getOwnPropertyNames;var fe=Object.getPrototypeOf,be=Object.prototype.hasOwnProperty;var he=(e,t)=>{for(var s in t)B(e,s,{get:t[s],enumerable:!0})},j=(e,t,s,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of me(t))!be.call(e,a)&&a!==s&&B(e,a,{get:()=>t[a],enumerable:!(r=ue(t,a))||r.enumerable});return e};var I=(e,t,s)=>(s=e!=null?pe(fe(e)):{},j(t||!e||!e.__esModule?B(s,"default",{value:e,enumerable:!0}):s,e)),ge=e=>j(B({},"__esModule",{value:!0}),e);var Ae={};he(Ae,{ApiProvider:()=>$,ChatBot:()=>L,ChatBotProvider:()=>E,createFetchAdapter:()=>F,useApiConfig:()=>H,useChatBotConfig:()=>T});module.exports=ge(Ae);var A=require("react");var R=require("react"),W=require("react/jsx-runtime"),q=(0,R.createContext)(null),E=({config:e,children:t})=>(0,W.jsx)(q.Provider,{value:e,children:t}),$=E,M=()=>(0,R.useContext)(q),T=()=>{let e=M();if(!e)throw new Error("useChatBotConfig must be used inside ChatBotProvider or ApiProvider");return e},H=T;var se=require("lucide-react");var h=require("lucide-react"),v=require("react");function K(e){var t,s,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(s=K(e[t]))&&(r&&(r+=" "),r+=s)}else for(s in e)e[s]&&(r&&(r+=" "),r+=s);return r}function U(){for(var e,t,s=0,r="",a=arguments.length;s<a;s++)(e=arguments[s])&&(t=K(e))&&(r&&(r+=" "),r+=t);return r}var G=require("tailwind-merge");function b(...e){return(0,G.twMerge)(U(e))}var l=I(require("react"),1);var xe=I(require("react"),1);function J(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function X(...e){return t=>{let s=!1,r=e.map(a=>{let n=J(a,t);return!s&&typeof n=="function"&&(s=!0),n});if(s)return()=>{for(let a=0;a<r.length;a++){let n=r[a];typeof n=="function"?n():J(e[a],null)}}}}var P=require("react/jsx-runtime");function Ce(e){let t=ve(e),s=l.forwardRef((r,a)=>{let{children:n,...d}=r,i=l.Children.toArray(n),p=i.find(ye);if(p){let u=p.props.children,m=i.map(f=>f===p?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:f);return(0,P.jsx)(t,{...d,ref:a,children:l.isValidElement(u)?l.cloneElement(u,void 0,m):null})}return(0,P.jsx)(t,{...d,ref:a,children:n})});return s.displayName=`${e}.Slot`,s}var Y=Ce("Slot");function ve(e){let t=l.forwardRef((s,r)=>{let{children:a,...n}=s;if(l.isValidElement(a)){let d=_e(a),i=Ne(n,a.props);return a.type!==l.Fragment&&(i.ref=r?X(r,d):d),l.cloneElement(a,i)}return l.Children.count(a)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var we=Symbol("radix.slottable");function ye(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===we}function Ne(e,t){let s={...t};for(let r in t){let a=e[r],n=t[r];/^on[A-Z]/.test(r)?a&&n?s[r]=(...i)=>{let p=n(...i);return a(...i),p}:a&&(s[r]=a):r==="style"?s[r]={...a,...n}:r==="className"&&(s[r]=[a,n].filter(Boolean).join(" "))}return{...e,...s}}function _e(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,s=t&&"isReactWarning"in t&&t.isReactWarning;return s?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,s=t&&"isReactWarning"in t&&t.isReactWarning,s?e.props.ref:e.props.ref||e.ref)}var Z=require("class-variance-authority");var Q=require("react/jsx-runtime"),Be=(0,Z.cva)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function S({className:e,variant:t,size:s,asChild:r=!1,...a}){return(0,Q.jsx)(r?Y:"button",{"data-slot":"button",className:b(Be({variant:t,size:s,className:e})),...a})}var te=require("react/jsx-runtime");function ee({className:e,...t}){return(0,te.jsx)("textarea",{"data-slot":"textarea",className:b("wrap-break-word break-normal border-input placeholder:text-muted-foreground aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base transition-[color,box-shadow] outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),...t})}var o=require("react/jsx-runtime");function w({theme:e,messages:t,handleSendMessage:s,isOpen:r,isSending:a,setIsOpen:n}){let[d,i]=(0,v.useState)(""),p=(0,v.useRef)(null),u=d.trim().length>0&&!a,m=e.launchIcon,f=e.assistantIcon;(0,v.useEffect)(()=>{p.current?.scrollIntoView({behavior:"smooth"})},[t,a]);let C=()=>{if(!u)return;let c=d;i(""),s(c)},N=c=>{c.key==="Enter"&&!c.shiftKey&&(c.preventDefault(),C())};return(0,o.jsxs)(o.Fragment,{children:[!r&&(0,o.jsx)(S,{"aria-controls":"general-ai-chat-bot-window","aria-expanded":!1,"aria-label":`Open ${e.title}`,className:e.launchButtonClassName,onClick:()=>n(!0),size:"icon",children:(0,o.jsx)(m,{className:"size-5"})}),r&&(0,o.jsxs)("section",{"aria-label":e.title,className:e.windowClassName,id:"general-ai-chat-bot-window",role:"dialog",children:[(0,o.jsxs)("div",{className:e.headerClassName,children:[(0,o.jsxs)("div",{className:"flex items-center gap-3",children:[(0,o.jsx)("div",{className:e.headerIconClassName,children:(0,o.jsx)(f,{className:"size-5"})}),(0,o.jsxs)("div",{className:"min-w-0",children:[(0,o.jsx)("p",{className:e.titleClassName,children:e.title}),(0,o.jsxs)("div",{className:"flex items-center gap-2",children:[(0,o.jsx)("span",{className:e.statusDotClassName}),(0,o.jsx)("p",{className:e.subtitleClassName,children:a?e.busyLabel:e.subtitle})]})]})]}),(0,o.jsx)(S,{"aria-label":"Close chat window",className:e.closeButtonClassName,onClick:()=>n(!1),size:"icon",variant:"ghost",children:(0,o.jsx)(h.X,{className:"size-4"})})]}),(0,o.jsxs)("div",{"aria-live":"polite",className:e.messagesClassName,role:"log",children:[t.map((c,_)=>{let g=c.role==="user";return(0,o.jsxs)("div",{className:b("flex items-end gap-2",g?"justify-end":"justify-start"),children:[!g&&(0,o.jsx)("div",{className:e.assistantAvatarClassName,children:(0,o.jsx)(f,{className:"size-4"})}),(0,o.jsx)("div",{className:b("max-w-[82%] whitespace-pre-wrap break-words rounded-[22px] px-4 py-3 text-sm leading-6 shadow-sm",g?e.userBubbleClassName:e.assistantBubbleClassName),children:c.content}),g&&(0,o.jsx)("div",{className:e.userAvatarClassName,children:"You"})]},`${c.role}-${_}-${c.content}`)}),a&&(0,o.jsxs)("div",{className:"flex items-end gap-2",children:[(0,o.jsx)("div",{className:e.assistantAvatarClassName,children:(0,o.jsx)(h.Bot,{className:"size-4"})}),(0,o.jsxs)("div",{className:e.typingBubbleClassName,children:[(0,o.jsx)("span",{className:"sr-only",children:e.busyLabel}),(0,o.jsx)("div",{className:"flex items-center gap-1.5",children:[0,1,2].map(c=>(0,o.jsx)("span",{className:b("size-2 rounded-full animate-pulse",e.typingDotClassName,c===1&&"[animation-delay:150ms]",c===2&&"[animation-delay:300ms]")},c))})]})]}),(0,o.jsx)("div",{ref:p})]}),(0,o.jsxs)("div",{className:e.composerClassName,children:[(0,o.jsxs)("div",{className:"relative",children:[(0,o.jsx)(ee,{className:b("max-h-32 resize-none pb-14 text-sm leading-6",e.textareaClassName),onChange:c=>i(c.target.value),onKeyDown:N,placeholder:e.placeholder,rows:2,value:d}),(0,o.jsx)(S,{"aria-label":"Send message",className:e.sendButtonClassName,disabled:!u,onClick:C,size:"icon",children:(0,o.jsx)(h.Send,{className:"size-4"})})]}),(0,o.jsx)("p",{className:e.helperTextClassName,children:"Press Enter to send \xB7 Shift+Enter for a new line"})]})]})]})}var y={bot:h.Bot,sparkles:h.Sparkles};var ae=require("react/jsx-runtime");function V(e){return(0,ae.jsx)(w,{...e,theme:{title:"Minimal assistant",subtitle:"Clean, focused support",busyLabel:"Thinking through your request",placeholder:"Ask a question or describe what you need\u2026",launchIcon:se.MessageCircle,assistantIcon:y.bot,launchButtonClassName:"fixed bottom-6 right-6 z-50 size-14 rounded-full border border-slate-200 bg-slate-900 text-white shadow-[0_18px_35px_-15px_rgba(15,23,42,0.8)] transition-all hover:-translate-y-0.5 hover:bg-slate-800",windowClassName:"fixed bottom-4 left-4 right-4 z-50 flex h-[min(42rem,78vh)] flex-col overflow-hidden rounded-[28px] border border-slate-200/80 bg-white/95 shadow-[0_24px_80px_-28px_rgba(15,23,42,0.45)] backdrop-blur sm:left-auto sm:right-6 sm:w-[400px]",headerClassName:"flex items-center justify-between border-b border-slate-200/80 bg-white/90 px-4 py-4",headerIconClassName:"flex size-11 items-center justify-center rounded-2xl bg-slate-900 text-white shadow-sm",titleClassName:"text-sm font-semibold text-slate-900",subtitleClassName:"text-xs text-slate-500",statusDotClassName:"size-2 rounded-full bg-emerald-500",closeButtonClassName:"size-8 rounded-full text-slate-500 hover:bg-slate-100 hover:text-slate-900",messagesClassName:"flex-1 space-y-4 overflow-y-auto bg-gradient-to-b from-slate-50 to-white px-4 py-4",assistantAvatarClassName:"flex size-8 shrink-0 items-center justify-center rounded-full bg-white text-slate-700 ring-1 ring-slate-200 shadow-sm",assistantBubbleClassName:"bg-white text-slate-700 ring-1 ring-slate-200",userAvatarClassName:"flex h-8 items-center rounded-full bg-slate-900 px-2 text-[10px] font-semibold uppercase tracking-wide text-white/90",userBubbleClassName:"bg-slate-900 text-white",composerClassName:"border-t border-slate-200/80 bg-white/95 p-4 backdrop-blur",textareaClassName:"min-h-[60px] rounded-2xl border-slate-200 bg-slate-50/80 pr-14 shadow-none focus-visible:ring-slate-300",helperTextClassName:"mt-2 text-[11px] text-slate-400",sendButtonClassName:"absolute bottom-3 right-3 size-10 rounded-xl bg-slate-900 text-white hover:bg-slate-800",typingBubbleClassName:"rounded-[22px] bg-white px-4 py-3 shadow-sm ring-1 ring-slate-200",typingDotClassName:"bg-slate-400"}})}var re=require("lucide-react");var oe=require("react/jsx-runtime");function O(e){return(0,oe.jsx)(w,{...e,theme:{title:"Modern assistant",subtitle:"Fast answers with a polished feel",busyLabel:"Composing a response",placeholder:"Type your message\u2026",launchIcon:re.MessageCircleMore,assistantIcon:y.bot,launchButtonClassName:"fixed bottom-6 right-6 z-50 size-14 rounded-full border border-white/20 bg-gradient-to-br from-cyan-500 via-blue-500 to-violet-600 text-white shadow-[0_24px_50px_-18px_rgba(59,130,246,0.85)] transition-all hover:-translate-y-1 hover:shadow-[0_28px_60px_-18px_rgba(99,102,241,0.75)]",windowClassName:"fixed bottom-4 left-4 right-4 z-50 flex h-[min(44rem,80vh)] flex-col overflow-hidden rounded-[30px] border border-slate-700/70 bg-slate-950 text-white shadow-[0_35px_90px_-30px_rgba(15,23,42,0.95)] sm:left-auto sm:right-6 sm:w-[420px]",headerClassName:"flex items-center justify-between border-b border-white/10 bg-gradient-to-r from-slate-950 via-slate-900 to-slate-950 px-5 py-4",headerIconClassName:"flex size-11 items-center justify-center rounded-2xl bg-gradient-to-br from-cyan-400/25 to-violet-500/25 text-cyan-100 ring-1 ring-white/10",titleClassName:"text-sm font-semibold text-white",subtitleClassName:"text-xs text-slate-300",statusDotClassName:"size-2 rounded-full bg-cyan-400 shadow-[0_0_12px_rgba(34,211,238,0.8)]",closeButtonClassName:"size-8 rounded-full text-slate-400 hover:bg-white/10 hover:text-white",messagesClassName:"flex-1 space-y-4 overflow-y-auto bg-[radial-gradient(circle_at_top,_rgba(56,189,248,0.14),_transparent_35%),linear-gradient(180deg,_#020617_0%,_#0f172a_55%,_#111827_100%)] px-5 py-5",assistantAvatarClassName:"flex size-8 shrink-0 items-center justify-center rounded-full bg-slate-900 text-cyan-200 ring-1 ring-cyan-400/20",assistantBubbleClassName:"border border-white/10 bg-white/8 text-slate-100 backdrop-blur-sm",userAvatarClassName:"flex h-8 items-center rounded-full bg-white/10 px-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-slate-200 ring-1 ring-white/10",userBubbleClassName:"bg-gradient-to-br from-cyan-500 to-violet-600 text-white shadow-[0_14px_30px_-18px_rgba(34,211,238,0.9)]",composerClassName:"border-t border-white/10 bg-slate-950/95 p-4 backdrop-blur-xl",textareaClassName:"min-h-[64px] rounded-2xl border-white/10 bg-white/5 pr-14 text-white placeholder:text-slate-400 focus-visible:ring-cyan-400/40",helperTextClassName:"mt-2 text-[11px] text-slate-500",sendButtonClassName:"absolute bottom-3 right-3 size-10 rounded-xl bg-gradient-to-br from-cyan-400 to-violet-500 text-white hover:from-cyan-300 hover:to-violet-400",typingBubbleClassName:"rounded-[22px] border border-white/10 bg-white/8 px-4 py-3 backdrop-blur-sm",typingDotClassName:"bg-cyan-300"}})}var ne=require("lucide-react");var ie=require("react/jsx-runtime");function D(e){return(0,ie.jsx)(w,{...e,theme:{title:"Playful assistant",subtitle:"Bright, friendly, and upbeat",busyLabel:"Dreaming up something fun",placeholder:"Say hi, brainstorm, or ask anything \u2728",launchIcon:ne.SmilePlus,assistantIcon:y.sparkles,launchButtonClassName:"fixed bottom-6 right-6 z-50 size-14 rounded-[22px] border-2 border-white/70 bg-[linear-gradient(135deg,_#f472b6_0%,_#f59e0b_100%)] text-white shadow-[0_24px_50px_-18px_rgba(244,114,182,0.75)] transition-all hover:-translate-y-1 hover:rotate-3",windowClassName:"fixed bottom-4 left-4 right-4 z-50 flex h-[min(44rem,80vh)] flex-col overflow-hidden rounded-[32px] border-2 border-rose-200 bg-[linear-gradient(180deg,_#fff7ed_0%,_#fff1f2_45%,_#fdf2f8_100%)] shadow-[0_35px_90px_-32px_rgba(244,114,182,0.55)] sm:left-auto sm:right-6 sm:w-[410px]",headerClassName:"flex items-center justify-between border-b border-rose-200/70 bg-white/60 px-5 py-4 backdrop-blur",headerIconClassName:"flex size-11 items-center justify-center rounded-[18px] bg-[linear-gradient(135deg,_#f472b6_0%,_#fb7185_50%,_#f59e0b_100%)] text-white shadow-md",titleClassName:"text-sm font-semibold text-rose-950",subtitleClassName:"text-xs text-rose-700/80",statusDotClassName:"size-2 rounded-full bg-emerald-500 shadow-[0_0_12px_rgba(16,185,129,0.55)]",closeButtonClassName:"size-8 rounded-full text-rose-500 hover:bg-white/80 hover:text-rose-700",messagesClassName:"flex-1 space-y-4 overflow-y-auto bg-[radial-gradient(circle_at_top_left,_rgba(253,186,116,0.35),_transparent_30%),radial-gradient(circle_at_top_right,_rgba(244,114,182,0.22),_transparent_28%),linear-gradient(180deg,_rgba(255,255,255,0.8),_rgba(255,241,242,0.65))] px-5 py-5",assistantAvatarClassName:"flex size-8 shrink-0 items-center justify-center rounded-full bg-white text-rose-500 ring-2 ring-rose-100 shadow-sm",assistantBubbleClassName:"border border-rose-100 bg-white/95 text-rose-950",userAvatarClassName:"flex h-8 items-center rounded-full bg-amber-300/80 px-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-amber-950 ring-1 ring-amber-400/50",userBubbleClassName:"bg-[linear-gradient(135deg,_#f472b6_0%,_#fb7185_55%,_#f59e0b_100%)] text-white shadow-[0_16px_32px_-18px_rgba(244,114,182,0.7)]",composerClassName:"border-t border-rose-200/70 bg-white/70 p-4 backdrop-blur",textareaClassName:"min-h-[64px] rounded-[24px] border-rose-200 bg-white/90 pr-14 text-rose-950 placeholder:text-rose-300 focus-visible:ring-rose-300",helperTextClassName:"mt-2 text-[11px] text-rose-400",sendButtonClassName:"absolute bottom-3 right-3 size-10 rounded-2xl bg-[linear-gradient(135deg,_#fb7185_0%,_#f59e0b_100%)] text-white hover:brightness-105",typingBubbleClassName:"rounded-[22px] border border-rose-100 bg-white/90 px-4 py-3 shadow-sm",typingDotClassName:"bg-rose-400"}})}var k=require("react/jsx-runtime"),Re="Hi! I'm your digital assistant. How can I help you today?",Pe="Apologies, I ran into a problem. Please try again later.";function L({style:e,adapter:t,welcomeMessage:s=Re,errorMessage:r=Pe}){let a=M(),n=t??a?.adapter,[d,i]=(0,A.useState)(!1),[p,u]=(0,A.useState)(!1),[m,f]=(0,A.useState)(()=>[{content:s,role:"assistant"}]);if(!n)throw new Error("ChatBot requires an adapter prop or a ChatBotProvider/ApiProvider config with an adapter.");let C=async N=>{if(!N.trim())return;u(!0);let c={content:N,role:"user"},_=[...m,c];f(_);try{let g=await n.sendMessage(_);f(z=>[...z,g])}catch{let g={content:r,role:"assistant"};f(z=>[...z,g])}finally{u(!1)}};switch(e){case"modern":return(0,k.jsx)(O,{messages:m,handleSendMessage:C,isOpen:d,isSending:p,setIsOpen:i});case"playful":return(0,k.jsx)(D,{messages:m,handleSendMessage:C,isOpen:d,isSending:p,setIsOpen:i});default:return(0,k.jsx)(V,{messages:m,handleSendMessage:C,isOpen:d,isSending:p,setIsOpen:i})}}var x=I(require("zod")),le=x.default.object({role:x.default.enum(["user","assistant"]),content:x.default.string()}),de=x.default.object({messages:x.default.array(le).min(1)}),ce=x.default.object({message:le});var Se=async e=>typeof e=="function"?await e():e,F=({apiUrl:e,fetch:t=globalThis.fetch,headers:s})=>{if(!e)throw new Error("apiUrl is required");return{async sendMessage(r){if(typeof t!="function")throw new Error("Fetch API is not available. Provide a fetch implementation.");let a={messages:r},n=de.safeParse(a);if(!n.success)throw new Error("Invalid chat request payload.");let d=new Headers(await Se(s));d.has("Content-Type")||d.set("Content-Type","application/json");let i=await t(e,{method:"POST",headers:d,body:JSON.stringify(n.data)});if(!i.ok){let m=i.statusText?` ${i.statusText}`:"";throw new Error(`Chat request failed with ${i.status}${m}`)}let p=await i.json(),u=ce.safeParse(p);if(!u.success)throw new Error("Invalid chat response payload.");return u.data.message}}};0&&(module.exports={ApiProvider,ChatBot,ChatBotProvider,createFetchAdapter,useApiConfig,useChatBotConfig});
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/components/chat-bot/index.tsx","../src/lib/api-provider.tsx","../src/components/chat-bot/chat-bot-minimal.tsx","../node_modules/@radix-ui/react-slot/src/slot.tsx","../node_modules/@radix-ui/react-compose-refs/src/compose-refs.tsx","../src/components/ui/button.tsx","../node_modules/clsx/dist/clsx.mjs","../src/lib/utils.ts","../src/components/ui/textarea.tsx","../src/lib/schema.ts","../src/chat-bots/adapters/fetch.ts"],"sourcesContent":["export { default as ChatBot } from \"./components/chat-bot\";\r\nexport {\r\n ApiProvider,\r\n ChatBotProvider,\r\n useApiConfig,\r\n useChatBotConfig,\r\n} from \"./lib/api-provider\";\r\nexport { createFetchAdapter } from \"./chat-bots/adapters\";\r\n\r\nexport type {\r\n ChatBotAdapter,\r\n ChatBotConfig,\r\n ChatBotProps,\r\n ChatBotRequest,\r\n ChatBotResponse,\r\n ChatBotStyle,\r\n ChatConfig,\r\n ChatMessage,\r\n CreateFetchAdapterOptions,\r\n} from \"./chat-bots/chat-bot\";\r\nexport type { ApiConfig, ChatBotProviderProps } from \"./lib/api-provider\";\r\n","\"use client\";\r\n\r\nimport { useState } from \"react\";\r\nimport type {\r\n ChatBotProps,\r\n ChatMessage,\r\n} from \"../../chat-bots/chat-bot\";\r\nimport { useOptionalChatBotConfig } from \"../../lib/api-provider\";\r\nimport ChatBotMinimal from \"./chat-bot-minimal\";\r\n\r\nconst DEFAULT_WELCOME_MESSAGE =\r\n \"Hi! I'm your digital assistant. How can I help you today?\";\r\nconst DEFAULT_ERROR_MESSAGE =\r\n \"Apologies, I ran into a problem. Please try again later.\";\r\n\r\nexport default function ChatBot({\r\n style,\r\n adapter: adapterProp,\r\n welcomeMessage = DEFAULT_WELCOME_MESSAGE,\r\n errorMessage: errorMessageText = DEFAULT_ERROR_MESSAGE,\r\n}: ChatBotProps) {\r\n const config = useOptionalChatBotConfig();\r\n const adapter = adapterProp ?? config?.adapter;\r\n const [isOpen, setIsOpen] = useState(false);\r\n const [isSending, setIsSending] = useState(false);\r\n const [messages, setMessages] = useState<ChatMessage[]>(() => [\r\n {\r\n content: welcomeMessage,\r\n role: \"assistant\",\r\n },\r\n ]);\r\n\r\n if (!adapter) {\r\n throw new Error(\r\n \"ChatBot requires an adapter prop or a ChatBotProvider/ApiProvider config with an adapter.\",\r\n );\r\n }\r\n\r\n const handleSendMessage = async (inputValue: string) => {\r\n if (!inputValue.trim()) {\r\n return;\r\n }\r\n\r\n setIsSending(true);\r\n\r\n const userMessage: ChatMessage = {\r\n content: inputValue,\r\n role: \"user\",\r\n };\r\n\r\n const updatedMessages = [...messages, userMessage];\r\n setMessages(updatedMessages);\r\n\r\n try {\r\n const response = await adapter.sendMessage(updatedMessages);\r\n setMessages((prev) => [...prev, response]);\r\n } catch {\r\n const errorMessage: ChatMessage = {\r\n content: errorMessageText,\r\n role: \"assistant\",\r\n };\r\n setMessages((prev) => [...prev, errorMessage]);\r\n } finally {\r\n setIsSending(false);\r\n }\r\n };\r\n\r\n switch (style) {\r\n /*\r\n case \"modern\":\r\n return (\r\n <ChatBotModern\r\n messages={messages}\r\n handleSendMessage={handleSendMessage}\r\n isOpen={isOpen}\r\n isSending={isSending}\r\n setIsOpen={setIsOpen}\r\n />\r\n );\r\n case \"playful\":\r\n return (\r\n <ChatBotPlayful\r\n messages={messages}\r\n handleSendMessage={handleSendMessage}\r\n isOpen={isOpen}\r\n isSending={isSending}\r\n setIsOpen={setIsOpen}\r\n />\r\n );\r\n */\r\n default:\r\n return (\r\n <ChatBotMinimal\r\n messages={messages}\r\n handleSendMessage={handleSendMessage}\r\n isOpen={isOpen}\r\n isSending={isSending}\r\n setIsOpen={setIsOpen}\r\n />\r\n );\r\n }\r\n}\r\n","import React, { createContext, useContext } from \"react\";\r\nimport type { ChatBotConfig } from \"../chat-bots/chat-bot\";\r\n\r\nexport interface ApiConfig extends ChatBotConfig {}\r\n\r\nexport interface ChatBotProviderProps {\r\n config: ChatBotConfig;\r\n children: React.ReactNode;\r\n}\r\n\r\nconst ChatBotContext = createContext<ChatBotConfig | null>(null);\r\n\r\nexport const ChatBotProvider = ({\r\n config,\r\n children,\r\n}: ChatBotProviderProps) => {\r\n return <ChatBotContext.Provider value={config}>{children}</ChatBotContext.Provider>;\r\n};\r\n\r\nexport const ApiProvider = ChatBotProvider;\r\n\r\nexport const useOptionalChatBotConfig = (): ChatBotConfig | null => {\r\n return useContext(ChatBotContext);\r\n};\r\n\r\nexport const useChatBotConfig = (): ChatBotConfig => {\r\n const context = useOptionalChatBotConfig();\r\n if (!context) {\r\n throw new Error(\r\n \"useChatBotConfig must be used inside ChatBotProvider or ApiProvider\",\r\n );\r\n }\r\n\r\n return context;\r\n};\r\n\r\nexport const useApiConfig = useChatBotConfig;\r\n","\"use client\";\r\n\r\nimport type React from \"react\";\r\n\r\nimport { useState, useRef, useEffect } from \"react\";\r\nimport { Button } from \"../ui/button\";\r\nimport { MessageCircle, X, Send } from \"lucide-react\";\r\nimport { Textarea } from \"../ui/textarea\";\r\nimport type { ChatBotViewProps } from \"../../chat-bots/chat-bot\";\r\n\r\nexport default function ChatBotMinimal(props: ChatBotViewProps) {\r\n const { messages, handleSendMessage, isOpen, isSending, setIsOpen } = props;\r\n const [inputValue, setInputValue] = useState(\"\");\r\n const messagesEndRef = useRef<HTMLDivElement>(null);\r\n const canSend = inputValue.trim().length > 0 && !isSending;\r\n\r\n useEffect(() => {\r\n messagesEndRef.current?.scrollIntoView({ behavior: \"smooth\" });\r\n }, [messages]);\r\n\r\n const submitMessage = () => {\r\n if (!canSend) {\r\n return;\r\n }\r\n\r\n const nextMessage = inputValue;\r\n setInputValue(\"\");\r\n void handleSendMessage(nextMessage);\r\n };\r\n\r\n const handleKeyPress = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\r\n if (e.key === \"Enter\" && !e.shiftKey) {\r\n e.preventDefault();\r\n submitMessage();\r\n }\r\n };\r\n\r\n return (\r\n <>\r\n {/* Minimal Chat Button */}\r\n {!isOpen && (\r\n <Button\r\n onClick={() => setIsOpen(true)}\r\n className=\"fixed bottom-6 right-6 h-12 w-12 rounded-full bg-slate-900 hover:bg-slate-800 shadow-lg hover:shadow-xl transition-all duration-200 z-50 border border-slate-200\"\r\n size=\"icon\"\r\n >\r\n <MessageCircle className=\"h-5 w-5 text-white\" />\r\n </Button>\r\n )}\r\n\r\n {/* Minimal Chat Window */}\r\n {isOpen && (\r\n <div className=\"fixed bottom-6 right-6 h-[75vh] w-[400px] max-w-[calc(100vw-3rem)] bg-white border border-slate-200 rounded-lg shadow-xl z-50 flex flex-col overflow-hidden\">\r\n {/* Simple Header */}\r\n <div className=\"border-b border-slate-100 p-3 flex items-center justify-between bg-white\">\r\n <div className=\"flex items-center space-x-2\">\r\n <div className=\"w-2 h-2 bg-green-500 rounded-full\"></div>\r\n <span className=\"text-sm font-medium text-slate-900\">\r\n Assistant\r\n </span>\r\n </div>\r\n <Button\r\n variant=\"ghost\"\r\n size=\"icon\"\r\n onClick={() => setIsOpen(false)}\r\n className=\"h-6 w-6 text-slate-400 hover:text-slate-600\"\r\n >\r\n <X className=\"h-3 w-3\" />\r\n </Button>\r\n </div>\r\n\r\n {/* Messages */}\r\n <div className=\"flex-1 overflow-y-auto p-4 space-y-3 bg-slate-50/30\">\r\n {messages.map((message, i) => (\r\n <div\r\n key={i}\r\n className={`flex ${message.role === \"assistant\" ? \"justify-start\" : \"justify-end\"}`}\r\n >\r\n <div\r\n className={`max-w-[75%] px-3 py-2 rounded-lg text-sm ${\r\n message.role === \"assistant\"\r\n ? \"bg-white border border-slate-200 text-slate-700\"\r\n : \"bg-slate-900 text-white\"\r\n }`}\r\n >\r\n {message.content}\r\n </div>\r\n </div>\r\n ))}\r\n <div ref={messagesEndRef} />\r\n </div>\r\n\r\n {/* Simple Input */}\r\n <div className=\"border-t border-slate-100 p-3 bg-white\">\r\n <div className=\"flex space-x-2\">\r\n <Textarea\r\n value={inputValue}\r\n onChange={(e) => setInputValue(e.target.value)}\r\n onKeyDown={handleKeyPress}\r\n rows={2}\r\n placeholder=\"What's on your mind? 💭\"\r\n className=\"min-h-[3rem] resize-none border-none flex-1 bg-white/80 placeholder:text-gray-400\"\r\n />\r\n <Button\r\n onClick={submitMessage}\r\n size=\"icon\"\r\n disabled={!canSend}\r\n className=\"self-center bg-slate-900 hover:bg-slate-800 h-9 w-9\"\r\n >\r\n <Send className=\"h-3 w-3\" />\r\n </Button>\r\n </div>\r\n </div>\r\n </div>\r\n )}\r\n </>\r\n );\r\n}\r\n","import * as React from 'react';\nimport { composeRefs } from '@radix-ui/react-compose-refs';\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotProps extends React.HTMLAttributes<HTMLElement> {\n children?: React.ReactNode;\n}\n\n/* @__NO_SIDE_EFFECTS__ */ export function createSlot(ownerName: string) {\n const SlotClone = createSlotClone(ownerName);\n const Slot = React.forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props;\n const childrenArray = React.Children.toArray(children);\n const slottable = childrenArray.find(isSlottable);\n\n if (slottable) {\n // the new element to render is the one passed as a child of `Slottable`\n const newElement = slottable.props.children;\n\n const newChildren = childrenArray.map((child) => {\n if (child === slottable) {\n // because the new element will be the one rendered, we are only interested\n // in grabbing its children (`newElement.props.children`)\n if (React.Children.count(newElement) > 1) return React.Children.only(null);\n return React.isValidElement(newElement)\n ? (newElement.props as { children: React.ReactNode }).children\n : null;\n } else {\n return child;\n }\n });\n\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {React.isValidElement(newElement)\n ? React.cloneElement(newElement, undefined, newChildren)\n : null}\n </SlotClone>\n );\n }\n\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {children}\n </SlotClone>\n );\n });\n\n Slot.displayName = `${ownerName}.Slot`;\n return Slot;\n}\n\nconst Slot = createSlot('Slot');\n\n/* -------------------------------------------------------------------------------------------------\n * SlotClone\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotCloneProps {\n children: React.ReactNode;\n}\n\n/* @__NO_SIDE_EFFECTS__ */ function createSlotClone(ownerName: string) {\n const SlotClone = React.forwardRef<any, SlotCloneProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props;\n\n if (React.isValidElement(children)) {\n const childrenRef = getElementRef(children);\n const props = mergeProps(slotProps, children.props as AnyProps);\n // do not pass ref to React.Fragment for React 19 compatibility\n if (children.type !== React.Fragment) {\n props.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;\n }\n return React.cloneElement(children, props);\n }\n\n return React.Children.count(children) > 1 ? React.Children.only(null) : null;\n });\n\n SlotClone.displayName = `${ownerName}.SlotClone`;\n return SlotClone;\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * -----------------------------------------------------------------------------------------------*/\n\nconst SLOTTABLE_IDENTIFIER = Symbol('radix.slottable');\n\ninterface SlottableProps {\n children: React.ReactNode;\n}\n\ninterface SlottableComponent extends React.FC<SlottableProps> {\n __radixId: symbol;\n}\n\n/* @__NO_SIDE_EFFECTS__ */ export function createSlottable(ownerName: string) {\n const Slottable: SlottableComponent = ({ children }) => {\n return <>{children}</>;\n };\n Slottable.displayName = `${ownerName}.Slottable`;\n Slottable.__radixId = SLOTTABLE_IDENTIFIER;\n return Slottable;\n}\n\nconst Slottable = createSlottable('Slottable');\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype AnyProps = Record<string, any>;\n\nfunction isSlottable(\n child: React.ReactNode\n): child is React.ReactElement<SlottableProps, typeof Slottable> {\n return (\n React.isValidElement(child) &&\n typeof child.type === 'function' &&\n '__radixId' in child.type &&\n child.type.__radixId === SLOTTABLE_IDENTIFIER\n );\n}\n\nfunction mergeProps(slotProps: AnyProps, childProps: AnyProps) {\n // all child props should override\n const overrideProps = { ...childProps };\n\n for (const propName in childProps) {\n const slotPropValue = slotProps[propName];\n const childPropValue = childProps[propName];\n\n const isHandler = /^on[A-Z]/.test(propName);\n if (isHandler) {\n // if the handler exists on both, we compose them\n if (slotPropValue && childPropValue) {\n overrideProps[propName] = (...args: unknown[]) => {\n const result = childPropValue(...args);\n slotPropValue(...args);\n return result;\n };\n }\n // but if it exists only on the slot, we use only this one\n else if (slotPropValue) {\n overrideProps[propName] = slotPropValue;\n }\n }\n // if it's `style`, we merge them\n else if (propName === 'style') {\n overrideProps[propName] = { ...slotPropValue, ...childPropValue };\n } else if (propName === 'className') {\n overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(' ');\n }\n }\n\n return { ...slotProps, ...overrideProps };\n}\n\n// Before React 19 accessing `element.props.ref` will throw a warning and suggest using `element.ref`\n// After React 19 accessing `element.ref` does the opposite.\n// https://github.com/facebook/react/pull/28348\n//\n// Access the ref using the method that doesn't yield a warning.\nfunction getElementRef(element: React.ReactElement) {\n // React <=18 in DEV\n let getter = Object.getOwnPropertyDescriptor(element.props, 'ref')?.get;\n let mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning;\n if (mayWarn) {\n return (element as any).ref;\n }\n\n // React 19 in DEV\n getter = Object.getOwnPropertyDescriptor(element, 'ref')?.get;\n mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning;\n if (mayWarn) {\n return (element.props as { ref?: React.Ref<unknown> }).ref;\n }\n\n // Not DEV\n return (element.props as { ref?: React.Ref<unknown> }).ref || (element as any).ref;\n}\n\nexport {\n Slot,\n Slottable,\n //\n Slot as Root,\n};\nexport type { SlotProps };\n","import * as React from 'react';\n\ntype PossibleRef<T> = React.Ref<T> | undefined;\n\n/**\n * Set a given ref to a given value\n * This utility takes care of different types of refs: callback refs and RefObject(s)\n */\nfunction setRef<T>(ref: PossibleRef<T>, value: T) {\n if (typeof ref === 'function') {\n return ref(value);\n } else if (ref !== null && ref !== undefined) {\n ref.current = value;\n }\n}\n\n/**\n * A utility to compose multiple refs together\n * Accepts callback refs and RefObject(s)\n */\nfunction composeRefs<T>(...refs: PossibleRef<T>[]): React.RefCallback<T> {\n return (node) => {\n let hasCleanup = false;\n const cleanups = refs.map((ref) => {\n const cleanup = setRef(ref, node);\n if (!hasCleanup && typeof cleanup == 'function') {\n hasCleanup = true;\n }\n return cleanup;\n });\n\n // React <19 will log an error to the console if a callback ref returns a\n // value. We don't use ref cleanups internally so this will only happen if a\n // user's ref callback returns a value, which we only expect if they are\n // using the cleanup functionality added in React 19.\n if (hasCleanup) {\n return () => {\n for (let i = 0; i < cleanups.length; i++) {\n const cleanup = cleanups[i];\n if (typeof cleanup == 'function') {\n cleanup();\n } else {\n setRef(refs[i], null);\n }\n }\n };\n }\n };\n}\n\n/**\n * A custom hook that composes multiple refs\n * Accepts callback refs and RefObject(s)\n */\nfunction useComposedRefs<T>(...refs: PossibleRef<T>[]): React.RefCallback<T> {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useCallback(composeRefs(...refs), refs);\n}\n\nexport { composeRefs, useComposedRefs };\n","import * as React from \"react\";\r\nimport { Slot } from \"@radix-ui/react-slot\";\r\nimport { cva, type VariantProps } from \"class-variance-authority\";\r\n\r\nimport { cn } from \"../../lib/utils\";\r\n\r\nconst buttonVariants = cva(\r\n \"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive\",\r\n {\r\n variants: {\r\n variant: {\r\n default:\r\n \"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90\",\r\n destructive:\r\n \"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60\",\r\n outline:\r\n \"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50\",\r\n secondary:\r\n \"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80\",\r\n ghost:\r\n \"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50\",\r\n link: \"text-primary underline-offset-4 hover:underline\",\r\n },\r\n size: {\r\n default: \"h-9 px-4 py-2 has-[>svg]:px-3\",\r\n sm: \"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5\",\r\n lg: \"h-10 rounded-md px-6 has-[>svg]:px-4\",\r\n icon: \"size-9\",\r\n },\r\n },\r\n defaultVariants: {\r\n variant: \"default\",\r\n size: \"default\",\r\n },\r\n },\r\n);\r\n\r\nfunction Button({\r\n className,\r\n variant,\r\n size,\r\n asChild = false,\r\n ...props\r\n}: React.ComponentProps<\"button\"> &\r\n VariantProps<typeof buttonVariants> & {\r\n asChild?: boolean;\r\n }) {\r\n const Comp = asChild ? Slot : \"button\";\r\n\r\n return (\r\n <Comp\r\n data-slot=\"button\"\r\n className={cn(buttonVariants({ variant, size, className }))}\r\n {...props}\r\n />\r\n );\r\n}\r\n\r\nexport { Button, buttonVariants };\r\n","function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f)}else for(f in e)e[f]&&(n&&(n+=\" \"),n+=f);return n}export function clsx(){for(var e,t,f=0,n=\"\",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;","import { clsx, type ClassValue } from \"clsx\";\r\nimport { twMerge } from \"tailwind-merge\";\r\n\r\nexport function cn(...inputs: ClassValue[]) {\r\n return twMerge(clsx(inputs));\r\n}\r\n","import * as React from \"react\";\r\n\r\nimport { cn } from \"../../lib/utils\";\r\n\r\nfunction Textarea({ className, ...props }: React.ComponentProps<\"textarea\">) {\r\n return (\r\n <textarea\r\n data-slot=\"textarea\"\r\n className={cn(\r\n \"wrap-break-word break-normal border-input placeholder:text-muted-foreground aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base transition-[color,box-shadow] outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\",\r\n className,\r\n )}\r\n {...props}\r\n />\r\n );\r\n}\r\n\r\nexport { Textarea };\r\n","import z from \"zod\";\r\n\r\nexport const messageSchema = z.object({\r\n role: z.enum([\"user\", \"assistant\"]),\r\n content: z.string(),\r\n});\r\n\r\nexport const chatRequestSchema = z.object({\r\n messages: z.array(messageSchema).min(1),\r\n});\r\n\r\nexport const chatResponseSchema = z.object({\r\n message: messageSchema,\r\n});\r\n","import type {\n ChatBotAdapter,\n ChatBotRequest,\n CreateFetchAdapterOptions,\n} from \"../chat-bot\";\nimport { chatRequestSchema, chatResponseSchema } from \"../../lib/schema\";\n\nconst resolveHeaders = async (headers: CreateFetchAdapterOptions[\"headers\"]) => {\n if (typeof headers === \"function\") {\n return await headers();\n }\n\n return headers;\n};\n\nexport const createFetchAdapter = ({\n apiUrl,\n fetch: fetchImplementation = globalThis.fetch,\n headers,\n}: CreateFetchAdapterOptions): ChatBotAdapter => {\n if (!apiUrl) {\n throw new Error(\"apiUrl is required\");\n }\n\n return {\n async sendMessage(messages) {\n if (typeof fetchImplementation !== \"function\") {\n throw new Error(\"Fetch API is not available. Provide a fetch implementation.\");\n }\n\n const requestPayload: ChatBotRequest = { messages };\n const parsedRequest = chatRequestSchema.safeParse(requestPayload);\n\n if (!parsedRequest.success) {\n throw new Error(\"Invalid chat request payload.\");\n }\n\n const requestHeaders = new Headers(await resolveHeaders(headers));\n if (!requestHeaders.has(\"Content-Type\")) {\n requestHeaders.set(\"Content-Type\", \"application/json\");\n }\n\n const response = await fetchImplementation(apiUrl, {\n method: \"POST\",\n headers: requestHeaders,\n body: JSON.stringify(parsedRequest.data),\n });\n\n if (!response.ok) {\n const statusText = response.statusText ? ` ${response.statusText}` : \"\";\n throw new Error(`Chat request failed with ${response.status}${statusText}`);\n }\n\n const responseJson = await response.json();\n const parsedResponse = chatResponseSchema.safeParse(responseJson);\n\n if (!parsedResponse.success) {\n throw new Error(\"Invalid chat response payload.\");\n }\n\n return parsedResponse.data.message;\n },\n };\n};"],"mappings":"skBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,iBAAAE,EAAA,YAAAC,EAAA,oBAAAC,EAAA,uBAAAC,EAAA,iBAAAC,EAAA,qBAAAC,IAAA,eAAAC,GAAAR,ICEA,IAAAS,EAAyB,iBCFzB,IAAAC,EAAiD,iBAgBxCC,EAAA,6BANHC,KAAiB,iBAAoC,IAAI,EAElDC,EAAkB,CAAC,CAC9B,OAAAC,EACA,SAAAC,CACF,OACS,OAACH,EAAe,SAAf,CAAwB,MAAOE,EAAS,SAAAC,EAAS,EAG9CC,EAAcH,EAEdI,EAA2B,O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AI,CAAC,CACxC,CAAC,EAEYG,EAAqB,EAAAF,QAAE,OAAO,CACzC,QAASD,CACX,CAAC,ECND,IAAMI,GAAiB,MAAOC,GACxB,OAAOA,GAAY,WACd,MAAMA,EAAQ,EAGhBA,EAGIC,EAAqB,CAAC,CACjC,OAAAC,EACA,MAAOC,EAAsB,WAAW,MACxC,QAAAH,CACF,IAAiD,CAC/C,GAAI,CAACE,EACH,MAAM,IAAI,MAAM,oBAAoB,EAGtC,MAAO,CACL,MAAM,YAAYE,EAAU,CAC1B,GAAI,OAAOD,GAAwB,WACjC,MAAM,IAAI,MAAM,6DAA6D,EAG/E,IAAME,EAAiC,CAAE,SAAAD,CAAS,EAC5CE,EAAgBC,EAAkB,UAAUF,CAAc,EAEhE,GAAI,CAACC,EAAc,QACjB,MAAM,IAAI,MAAM,+BAA+B,EAGjD,IAAME,EAAiB,IAAI,QAAQ,MAAMT,GAAeC,CAAO,CAAC,EAC3DQ,EAAe,IAAI,cAAc,GACpCA,EAAe,IAAI,eAAgB,kBAAkB,EAGvD,IAAMC,EAAW,MAAMN,EAAoBD,EAAQ,CACjD,OAAQ,OACR,QAASM,EACT,KAAM,KAAK,UAAUF,EAAc,IAAI,CACzC,CAAC,EAED,GAAI,CAACG,EAAS,GAAI,CAChB,IAAMC,EAAaD,EAAS,WAAa,IAAIA,EAAS,UAAU,GAAK,GACrE,MAAM,IAAI,MAAM,4BAA4BA,EAAS,MAAM,GAAGC,CAAU,EAAE,CAC5E,CAEA,IAAMC,EAAe,MAAMF,EAAS,KAAK,EACnCG,EAAiBC,EAAmB,UAAUF,CAAY,EAEhE,GAAI,CAACC,EAAe,QAClB,MAAM,IAAI,MAAM,gCAAgC,EAGlD,OAAOA,EAAe,KAAK,OAC7B,CACF,CACF","names":["index_exports","__export","ApiProvider","ChatBot","ChatBotProvider","createFetchAdapter","useApiConfig","useChatBotConfig","__toCommonJS","import_react","import_react","import_jsx_runtime","ChatBotContext","ChatBotProvider","config","children","ApiProvider","useOptionalChatBotConfig","useChatBotConfig","context","useApiConfig","import_react","React","React","setRef","ref","value","composeRefs","refs","node","hasCleanup","cleanups","cleanup","i","import_jsx_runtime","createSlot","ownerName","SlotClone","createSlotClone","Slot","props","forwardedRef","children","slotProps","childrenArray","slottable","isSlottable","newElement","newChildren","child","childrenRef","getElementRef","mergeProps","composeRefs","SLOTTABLE_IDENTIFIER","isSlottable","child","SLOTTABLE_IDENTIFIER","mergeProps","slotProps","childProps","overrideProps","propName","slotPropValue","childPropValue","args","result","getElementRef","element","getter","mayWarn","import_class_variance_authority","r","f","n","o","clsx","import_tailwind_merge","cn","inputs","clsx","import_jsx_runtime","buttonVariants","Button","className","variant","size","asChild","props","Slot","cn","import_lucide_react","import_jsx_runtime","Textarea","className","props","cn","import_jsx_runtime","ChatBotMinimal","props","messages","handleSendMessage","isOpen","isSending","setIsOpen","inputValue","setInputValue","messagesEndRef","canSend","submitMessage","nextMessage","handleKeyPress","e","Button","message","i","Textarea","import_jsx_runtime","DEFAULT_WELCOME_MESSAGE","DEFAULT_ERROR_MESSAGE","ChatBot","style","adapterProp","welcomeMessage","errorMessageText","config","useOptionalChatBotConfig","adapter","isOpen","setIsOpen","isSending","setIsSending","messages","setMessages","ChatBotMinimal","inputValue","userMessage","updatedMessages","response","prev","errorMessage","import_zod","messageSchema","z","chatRequestSchema","chatResponseSchema","resolveHeaders","headers","createFetchAdapter","apiUrl","fetchImplementation","messages","requestPayload","parsedRequest","chatRequestSchema","requestHeaders","response","statusText","responseJson","parsedResponse","chatResponseSchema"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/components/chat-bot/index.tsx","../src/lib/api-provider.tsx","../src/components/chat-bot/chat-bot-minimal.tsx","../src/components/chat-bot/chat-bot-shell.tsx","../node_modules/clsx/dist/clsx.mjs","../src/lib/utils.ts","../node_modules/@radix-ui/react-slot/src/slot.tsx","../node_modules/@radix-ui/react-compose-refs/src/compose-refs.tsx","../src/components/ui/button.tsx","../src/components/ui/textarea.tsx","../src/components/chat-bot/chat-bot-modern.tsx","../src/components/chat-bot/chat-bot-playful.tsx","../src/lib/schema.ts","../src/chat-bots/adapters/fetch.ts"],"sourcesContent":["export { default as ChatBot } from \"./components/chat-bot\";\r\nexport {\r\n ApiProvider,\r\n ChatBotProvider,\r\n useApiConfig,\r\n useChatBotConfig,\r\n} from \"./lib/api-provider\";\r\nexport { createFetchAdapter } from \"./chat-bots/adapters\";\r\n\r\nexport type {\r\n ChatBotAdapter,\r\n ChatBotConfig,\r\n ChatBotProps,\r\n ChatBotRequest,\r\n ChatBotResponse,\r\n ChatBotStyle,\r\n ChatConfig,\r\n ChatMessage,\r\n CreateFetchAdapterOptions,\r\n} from \"./chat-bots/chat-bot\";\r\nexport type { ApiConfig, ChatBotProviderProps } from \"./lib/api-provider\";\r\n","\"use client\";\r\n\r\nimport { useState } from \"react\";\r\nimport type {\r\n ChatBotProps,\r\n ChatMessage,\r\n} from \"../../chat-bots/chat-bot\";\r\nimport { useOptionalChatBotConfig } from \"../../lib/api-provider\";\r\nimport ChatBotMinimal from \"./chat-bot-minimal\";\r\nimport ChatBotModern from \"./chat-bot-modern\";\r\nimport ChatBotPlayful from \"./chat-bot-playful\";\r\n\r\nconst DEFAULT_WELCOME_MESSAGE =\r\n \"Hi! I'm your digital assistant. How can I help you today?\";\r\nconst DEFAULT_ERROR_MESSAGE =\r\n \"Apologies, I ran into a problem. Please try again later.\";\r\n\r\nexport default function ChatBot({\r\n style,\r\n adapter: adapterProp,\r\n welcomeMessage = DEFAULT_WELCOME_MESSAGE,\r\n errorMessage: errorMessageText = DEFAULT_ERROR_MESSAGE,\r\n}: ChatBotProps) {\r\n const config = useOptionalChatBotConfig();\r\n const adapter = adapterProp ?? config?.adapter;\r\n const [isOpen, setIsOpen] = useState(false);\r\n const [isSending, setIsSending] = useState(false);\r\n const [messages, setMessages] = useState<ChatMessage[]>(() => [\r\n {\r\n content: welcomeMessage,\r\n role: \"assistant\",\r\n },\r\n ]);\r\n\r\n if (!adapter) {\r\n throw new Error(\r\n \"ChatBot requires an adapter prop or a ChatBotProvider/ApiProvider config with an adapter.\",\r\n );\r\n }\r\n\r\n const handleSendMessage = async (inputValue: string) => {\r\n if (!inputValue.trim()) {\r\n return;\r\n }\r\n\r\n setIsSending(true);\r\n\r\n const userMessage: ChatMessage = {\r\n content: inputValue,\r\n role: \"user\",\r\n };\r\n\r\n const updatedMessages = [...messages, userMessage];\r\n setMessages(updatedMessages);\r\n\r\n try {\r\n const response = await adapter.sendMessage(updatedMessages);\r\n setMessages((prev) => [...prev, response]);\r\n } catch {\r\n const errorMessage: ChatMessage = {\r\n content: errorMessageText,\r\n role: \"assistant\",\r\n };\r\n setMessages((prev) => [...prev, errorMessage]);\r\n } finally {\r\n setIsSending(false);\r\n }\r\n };\r\n\r\n switch (style) {\r\n case \"modern\":\r\n return (\r\n <ChatBotModern\r\n messages={messages}\r\n handleSendMessage={handleSendMessage}\r\n isOpen={isOpen}\r\n isSending={isSending}\r\n setIsOpen={setIsOpen}\r\n />\r\n );\r\n case \"playful\":\r\n return (\r\n <ChatBotPlayful\r\n messages={messages}\r\n handleSendMessage={handleSendMessage}\r\n isOpen={isOpen}\r\n isSending={isSending}\r\n setIsOpen={setIsOpen}\r\n />\r\n );\r\n default:\r\n return (\r\n <ChatBotMinimal\r\n messages={messages}\r\n handleSendMessage={handleSendMessage}\r\n isOpen={isOpen}\r\n isSending={isSending}\r\n setIsOpen={setIsOpen}\r\n />\r\n );\r\n }\r\n}\r\n","import React, { createContext, useContext } from \"react\";\r\nimport type { ChatBotConfig } from \"../chat-bots/chat-bot\";\r\n\r\nexport interface ApiConfig extends ChatBotConfig {}\r\n\r\nexport interface ChatBotProviderProps {\r\n config: ChatBotConfig;\r\n children: React.ReactNode;\r\n}\r\n\r\nconst ChatBotContext = createContext<ChatBotConfig | null>(null);\r\n\r\nexport const ChatBotProvider = ({\r\n config,\r\n children,\r\n}: ChatBotProviderProps) => {\r\n return <ChatBotContext.Provider value={config}>{children}</ChatBotContext.Provider>;\r\n};\r\n\r\nexport const ApiProvider = ChatBotProvider;\r\n\r\nexport const useOptionalChatBotConfig = (): ChatBotConfig | null => {\r\n return useContext(ChatBotContext);\r\n};\r\n\r\nexport const useChatBotConfig = (): ChatBotConfig => {\r\n const context = useOptionalChatBotConfig();\r\n if (!context) {\r\n throw new Error(\r\n \"useChatBotConfig must be used inside ChatBotProvider or ApiProvider\",\r\n );\r\n }\r\n\r\n return context;\r\n};\r\n\r\nexport const useApiConfig = useChatBotConfig;\r\n","\"use client\";\r\n\r\nimport { MessageCircle } from \"lucide-react\";\r\nimport type { ChatBotViewProps } from \"../../chat-bots/chat-bot\";\r\nimport { ChatBotShell, sharedAssistantIcons } from \"./chat-bot-shell\";\r\n\r\nexport default function ChatBotMinimal(props: ChatBotViewProps) {\r\n return (\r\n <ChatBotShell\r\n {...props}\r\n theme={{\r\n title: \"Minimal assistant\",\r\n subtitle: \"Clean, focused support\",\r\n busyLabel: \"Thinking through your request\",\r\n placeholder: \"Ask a question or describe what you need…\",\r\n launchIcon: MessageCircle,\r\n assistantIcon: sharedAssistantIcons.bot,\r\n launchButtonClassName:\r\n \"fixed bottom-6 right-6 z-50 size-14 rounded-full border border-slate-200 bg-slate-900 text-white shadow-[0_18px_35px_-15px_rgba(15,23,42,0.8)] transition-all hover:-translate-y-0.5 hover:bg-slate-800\",\r\n windowClassName:\r\n \"fixed bottom-4 left-4 right-4 z-50 flex h-[min(42rem,78vh)] flex-col overflow-hidden rounded-[28px] border border-slate-200/80 bg-white/95 shadow-[0_24px_80px_-28px_rgba(15,23,42,0.45)] backdrop-blur sm:left-auto sm:right-6 sm:w-[400px]\",\r\n headerClassName:\r\n \"flex items-center justify-between border-b border-slate-200/80 bg-white/90 px-4 py-4\",\r\n headerIconClassName:\r\n \"flex size-11 items-center justify-center rounded-2xl bg-slate-900 text-white shadow-sm\",\r\n titleClassName: \"text-sm font-semibold text-slate-900\",\r\n subtitleClassName: \"text-xs text-slate-500\",\r\n statusDotClassName: \"size-2 rounded-full bg-emerald-500\",\r\n closeButtonClassName:\r\n \"size-8 rounded-full text-slate-500 hover:bg-slate-100 hover:text-slate-900\",\r\n messagesClassName:\r\n \"flex-1 space-y-4 overflow-y-auto bg-gradient-to-b from-slate-50 to-white px-4 py-4\",\r\n assistantAvatarClassName:\r\n \"flex size-8 shrink-0 items-center justify-center rounded-full bg-white text-slate-700 ring-1 ring-slate-200 shadow-sm\",\r\n assistantBubbleClassName:\r\n \"bg-white text-slate-700 ring-1 ring-slate-200\",\r\n userAvatarClassName:\r\n \"flex h-8 items-center rounded-full bg-slate-900 px-2 text-[10px] font-semibold uppercase tracking-wide text-white/90\",\r\n userBubbleClassName: \"bg-slate-900 text-white\",\r\n composerClassName:\r\n \"border-t border-slate-200/80 bg-white/95 p-4 backdrop-blur\",\r\n textareaClassName:\r\n \"min-h-[60px] rounded-2xl border-slate-200 bg-slate-50/80 pr-14 shadow-none focus-visible:ring-slate-300\",\r\n helperTextClassName: \"mt-2 text-[11px] text-slate-400\",\r\n sendButtonClassName:\r\n \"absolute bottom-3 right-3 size-10 rounded-xl bg-slate-900 text-white hover:bg-slate-800\",\r\n typingBubbleClassName:\r\n \"rounded-[22px] bg-white px-4 py-3 shadow-sm ring-1 ring-slate-200\",\r\n typingDotClassName: \"bg-slate-400\",\r\n }}\r\n />\r\n );\r\n}\r\n","\"use client\";\n\nimport { Bot, Send, Sparkles, X, type LucideIcon } from \"lucide-react\";\nimport { useEffect, useRef, useState, type KeyboardEvent } from \"react\";\nimport type { ChatBotViewProps } from \"../../chat-bots/chat-bot\";\nimport { cn } from \"../../lib/utils\";\nimport { Button } from \"../ui/button\";\nimport { Textarea } from \"../ui/textarea\";\n\nexport interface ChatBotTheme {\n title: string;\n subtitle: string;\n busyLabel: string;\n placeholder: string;\n launchIcon: LucideIcon;\n assistantIcon: LucideIcon;\n launchButtonClassName: string;\n windowClassName: string;\n headerClassName: string;\n headerIconClassName: string;\n titleClassName: string;\n subtitleClassName: string;\n statusDotClassName: string;\n closeButtonClassName: string;\n messagesClassName: string;\n assistantAvatarClassName: string;\n assistantBubbleClassName: string;\n userAvatarClassName: string;\n userBubbleClassName: string;\n composerClassName: string;\n textareaClassName: string;\n helperTextClassName: string;\n sendButtonClassName: string;\n typingBubbleClassName: string;\n typingDotClassName: string;\n}\n\nexport function ChatBotShell({\n theme,\n messages,\n handleSendMessage,\n isOpen,\n isSending,\n setIsOpen,\n}: ChatBotViewProps & { theme: ChatBotTheme }) {\n const [inputValue, setInputValue] = useState(\"\");\n const messagesEndRef = useRef<HTMLDivElement>(null);\n const canSend = inputValue.trim().length > 0 && !isSending;\n const LaunchIcon = theme.launchIcon;\n const AssistantIcon = theme.assistantIcon;\n\n useEffect(() => {\n messagesEndRef.current?.scrollIntoView({ behavior: \"smooth\" });\n }, [messages, isSending]);\n\n const submitMessage = () => {\n if (!canSend) {\n return;\n }\n\n const nextMessage = inputValue;\n setInputValue(\"\");\n void handleSendMessage(nextMessage);\n };\n\n const handleKeyPress = (event: KeyboardEvent<HTMLTextAreaElement>) => {\n if (event.key === \"Enter\" && !event.shiftKey) {\n event.preventDefault();\n submitMessage();\n }\n };\n\n return (\n <>\n {!isOpen && (\n <Button\n aria-controls=\"general-ai-chat-bot-window\"\n aria-expanded={false}\n aria-label={`Open ${theme.title}`}\n className={theme.launchButtonClassName}\n onClick={() => setIsOpen(true)}\n size=\"icon\"\n >\n <LaunchIcon className=\"size-5\" />\n </Button>\n )}\n\n {isOpen && (\n <section\n aria-label={theme.title}\n className={theme.windowClassName}\n id=\"general-ai-chat-bot-window\"\n role=\"dialog\"\n >\n <div className={theme.headerClassName}>\n <div className=\"flex items-center gap-3\">\n <div className={theme.headerIconClassName}>\n <AssistantIcon className=\"size-5\" />\n </div>\n <div className=\"min-w-0\">\n <p className={theme.titleClassName}>{theme.title}</p>\n <div className=\"flex items-center gap-2\">\n <span className={theme.statusDotClassName} />\n <p className={theme.subtitleClassName}>\n {isSending ? theme.busyLabel : theme.subtitle}\n </p>\n </div>\n </div>\n </div>\n\n <Button\n aria-label=\"Close chat window\"\n className={theme.closeButtonClassName}\n onClick={() => setIsOpen(false)}\n size=\"icon\"\n variant=\"ghost\"\n >\n <X className=\"size-4\" />\n </Button>\n </div>\n\n <div aria-live=\"polite\" className={theme.messagesClassName} role=\"log\">\n {messages.map((message, index) => {\n const isUser = message.role === \"user\";\n\n return (\n <div\n key={`${message.role}-${index}-${message.content}`}\n className={cn(\n \"flex items-end gap-2\",\n isUser ? \"justify-end\" : \"justify-start\",\n )}\n >\n {!isUser && (\n <div className={theme.assistantAvatarClassName}>\n <AssistantIcon className=\"size-4\" />\n </div>\n )}\n\n <div\n className={cn(\n \"max-w-[82%] whitespace-pre-wrap break-words rounded-[22px] px-4 py-3 text-sm leading-6 shadow-sm\",\n isUser\n ? theme.userBubbleClassName\n : theme.assistantBubbleClassName,\n )}\n >\n {message.content}\n </div>\n\n {isUser && <div className={theme.userAvatarClassName}>You</div>}\n </div>\n );\n })}\n\n {isSending && (\n <div className=\"flex items-end gap-2\">\n <div className={theme.assistantAvatarClassName}>\n <Bot className=\"size-4\" />\n </div>\n <div className={theme.typingBubbleClassName}>\n <span className=\"sr-only\">{theme.busyLabel}</span>\n <div className=\"flex items-center gap-1.5\">\n {[0, 1, 2].map((dot) => (\n <span\n key={dot}\n className={cn(\n \"size-2 rounded-full animate-pulse\",\n theme.typingDotClassName,\n dot === 1 && \"[animation-delay:150ms]\",\n dot === 2 && \"[animation-delay:300ms]\",\n )}\n />\n ))}\n </div>\n </div>\n </div>\n )}\n\n <div ref={messagesEndRef} />\n </div>\n\n <div className={theme.composerClassName}>\n <div className=\"relative\">\n <Textarea\n className={cn(\n \"max-h-32 resize-none pb-14 text-sm leading-6\",\n theme.textareaClassName,\n )}\n onChange={(event) => setInputValue(event.target.value)}\n onKeyDown={handleKeyPress}\n placeholder={theme.placeholder}\n rows={2}\n value={inputValue}\n />\n <Button\n aria-label=\"Send message\"\n className={theme.sendButtonClassName}\n disabled={!canSend}\n onClick={submitMessage}\n size=\"icon\"\n >\n <Send className=\"size-4\" />\n </Button>\n </div>\n\n <p className={theme.helperTextClassName}>\n Press Enter to send · Shift+Enter for a new line\n </p>\n </div>\n </section>\n )}\n </>\n );\n}\n\nexport const sharedAssistantIcons = {\n bot: Bot,\n sparkles: Sparkles,\n};","function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f)}else for(f in e)e[f]&&(n&&(n+=\" \"),n+=f);return n}export function clsx(){for(var e,t,f=0,n=\"\",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;","import { clsx, type ClassValue } from \"clsx\";\r\nimport { twMerge } from \"tailwind-merge\";\r\n\r\nexport function cn(...inputs: ClassValue[]) {\r\n return twMerge(clsx(inputs));\r\n}\r\n","import * as React from 'react';\nimport { composeRefs } from '@radix-ui/react-compose-refs';\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotProps extends React.HTMLAttributes<HTMLElement> {\n children?: React.ReactNode;\n}\n\n/* @__NO_SIDE_EFFECTS__ */ export function createSlot(ownerName: string) {\n const SlotClone = createSlotClone(ownerName);\n const Slot = React.forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props;\n const childrenArray = React.Children.toArray(children);\n const slottable = childrenArray.find(isSlottable);\n\n if (slottable) {\n // the new element to render is the one passed as a child of `Slottable`\n const newElement = slottable.props.children;\n\n const newChildren = childrenArray.map((child) => {\n if (child === slottable) {\n // because the new element will be the one rendered, we are only interested\n // in grabbing its children (`newElement.props.children`)\n if (React.Children.count(newElement) > 1) return React.Children.only(null);\n return React.isValidElement(newElement)\n ? (newElement.props as { children: React.ReactNode }).children\n : null;\n } else {\n return child;\n }\n });\n\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {React.isValidElement(newElement)\n ? React.cloneElement(newElement, undefined, newChildren)\n : null}\n </SlotClone>\n );\n }\n\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {children}\n </SlotClone>\n );\n });\n\n Slot.displayName = `${ownerName}.Slot`;\n return Slot;\n}\n\nconst Slot = createSlot('Slot');\n\n/* -------------------------------------------------------------------------------------------------\n * SlotClone\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotCloneProps {\n children: React.ReactNode;\n}\n\n/* @__NO_SIDE_EFFECTS__ */ function createSlotClone(ownerName: string) {\n const SlotClone = React.forwardRef<any, SlotCloneProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props;\n\n if (React.isValidElement(children)) {\n const childrenRef = getElementRef(children);\n const props = mergeProps(slotProps, children.props as AnyProps);\n // do not pass ref to React.Fragment for React 19 compatibility\n if (children.type !== React.Fragment) {\n props.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;\n }\n return React.cloneElement(children, props);\n }\n\n return React.Children.count(children) > 1 ? React.Children.only(null) : null;\n });\n\n SlotClone.displayName = `${ownerName}.SlotClone`;\n return SlotClone;\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * -----------------------------------------------------------------------------------------------*/\n\nconst SLOTTABLE_IDENTIFIER = Symbol('radix.slottable');\n\ninterface SlottableProps {\n children: React.ReactNode;\n}\n\ninterface SlottableComponent extends React.FC<SlottableProps> {\n __radixId: symbol;\n}\n\n/* @__NO_SIDE_EFFECTS__ */ export function createSlottable(ownerName: string) {\n const Slottable: SlottableComponent = ({ children }) => {\n return <>{children}</>;\n };\n Slottable.displayName = `${ownerName}.Slottable`;\n Slottable.__radixId = SLOTTABLE_IDENTIFIER;\n return Slottable;\n}\n\nconst Slottable = createSlottable('Slottable');\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype AnyProps = Record<string, any>;\n\nfunction isSlottable(\n child: React.ReactNode\n): child is React.ReactElement<SlottableProps, typeof Slottable> {\n return (\n React.isValidElement(child) &&\n typeof child.type === 'function' &&\n '__radixId' in child.type &&\n child.type.__radixId === SLOTTABLE_IDENTIFIER\n );\n}\n\nfunction mergeProps(slotProps: AnyProps, childProps: AnyProps) {\n // all child props should override\n const overrideProps = { ...childProps };\n\n for (const propName in childProps) {\n const slotPropValue = slotProps[propName];\n const childPropValue = childProps[propName];\n\n const isHandler = /^on[A-Z]/.test(propName);\n if (isHandler) {\n // if the handler exists on both, we compose them\n if (slotPropValue && childPropValue) {\n overrideProps[propName] = (...args: unknown[]) => {\n const result = childPropValue(...args);\n slotPropValue(...args);\n return result;\n };\n }\n // but if it exists only on the slot, we use only this one\n else if (slotPropValue) {\n overrideProps[propName] = slotPropValue;\n }\n }\n // if it's `style`, we merge them\n else if (propName === 'style') {\n overrideProps[propName] = { ...slotPropValue, ...childPropValue };\n } else if (propName === 'className') {\n overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(' ');\n }\n }\n\n return { ...slotProps, ...overrideProps };\n}\n\n// Before React 19 accessing `element.props.ref` will throw a warning and suggest using `element.ref`\n// After React 19 accessing `element.ref` does the opposite.\n// https://github.com/facebook/react/pull/28348\n//\n// Access the ref using the method that doesn't yield a warning.\nfunction getElementRef(element: React.ReactElement) {\n // React <=18 in DEV\n let getter = Object.getOwnPropertyDescriptor(element.props, 'ref')?.get;\n let mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning;\n if (mayWarn) {\n return (element as any).ref;\n }\n\n // React 19 in DEV\n getter = Object.getOwnPropertyDescriptor(element, 'ref')?.get;\n mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning;\n if (mayWarn) {\n return (element.props as { ref?: React.Ref<unknown> }).ref;\n }\n\n // Not DEV\n return (element.props as { ref?: React.Ref<unknown> }).ref || (element as any).ref;\n}\n\nexport {\n Slot,\n Slottable,\n //\n Slot as Root,\n};\nexport type { SlotProps };\n","import * as React from 'react';\n\ntype PossibleRef<T> = React.Ref<T> | undefined;\n\n/**\n * Set a given ref to a given value\n * This utility takes care of different types of refs: callback refs and RefObject(s)\n */\nfunction setRef<T>(ref: PossibleRef<T>, value: T) {\n if (typeof ref === 'function') {\n return ref(value);\n } else if (ref !== null && ref !== undefined) {\n ref.current = value;\n }\n}\n\n/**\n * A utility to compose multiple refs together\n * Accepts callback refs and RefObject(s)\n */\nfunction composeRefs<T>(...refs: PossibleRef<T>[]): React.RefCallback<T> {\n return (node) => {\n let hasCleanup = false;\n const cleanups = refs.map((ref) => {\n const cleanup = setRef(ref, node);\n if (!hasCleanup && typeof cleanup == 'function') {\n hasCleanup = true;\n }\n return cleanup;\n });\n\n // React <19 will log an error to the console if a callback ref returns a\n // value. We don't use ref cleanups internally so this will only happen if a\n // user's ref callback returns a value, which we only expect if they are\n // using the cleanup functionality added in React 19.\n if (hasCleanup) {\n return () => {\n for (let i = 0; i < cleanups.length; i++) {\n const cleanup = cleanups[i];\n if (typeof cleanup == 'function') {\n cleanup();\n } else {\n setRef(refs[i], null);\n }\n }\n };\n }\n };\n}\n\n/**\n * A custom hook that composes multiple refs\n * Accepts callback refs and RefObject(s)\n */\nfunction useComposedRefs<T>(...refs: PossibleRef<T>[]): React.RefCallback<T> {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useCallback(composeRefs(...refs), refs);\n}\n\nexport { composeRefs, useComposedRefs };\n","import * as React from \"react\";\r\nimport { Slot } from \"@radix-ui/react-slot\";\r\nimport { cva, type VariantProps } from \"class-variance-authority\";\r\n\r\nimport { cn } from \"../../lib/utils\";\r\n\r\nconst buttonVariants = cva(\r\n \"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive\",\r\n {\r\n variants: {\r\n variant: {\r\n default:\r\n \"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90\",\r\n destructive:\r\n \"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60\",\r\n outline:\r\n \"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50\",\r\n secondary:\r\n \"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80\",\r\n ghost:\r\n \"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50\",\r\n link: \"text-primary underline-offset-4 hover:underline\",\r\n },\r\n size: {\r\n default: \"h-9 px-4 py-2 has-[>svg]:px-3\",\r\n sm: \"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5\",\r\n lg: \"h-10 rounded-md px-6 has-[>svg]:px-4\",\r\n icon: \"size-9\",\r\n },\r\n },\r\n defaultVariants: {\r\n variant: \"default\",\r\n size: \"default\",\r\n },\r\n },\r\n);\r\n\r\nfunction Button({\r\n className,\r\n variant,\r\n size,\r\n asChild = false,\r\n ...props\r\n}: React.ComponentProps<\"button\"> &\r\n VariantProps<typeof buttonVariants> & {\r\n asChild?: boolean;\r\n }) {\r\n const Comp = asChild ? Slot : \"button\";\r\n\r\n return (\r\n <Comp\r\n data-slot=\"button\"\r\n className={cn(buttonVariants({ variant, size, className }))}\r\n {...props}\r\n />\r\n );\r\n}\r\n\r\nexport { Button, buttonVariants };\r\n","import * as React from \"react\";\r\n\r\nimport { cn } from \"../../lib/utils\";\r\n\r\nfunction Textarea({ className, ...props }: React.ComponentProps<\"textarea\">) {\r\n return (\r\n <textarea\r\n data-slot=\"textarea\"\r\n className={cn(\r\n \"wrap-break-word break-normal border-input placeholder:text-muted-foreground aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base transition-[color,box-shadow] outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\",\r\n className,\r\n )}\r\n {...props}\r\n />\r\n );\r\n}\r\n\r\nexport { Textarea };\r\n","\"use client\";\n\nimport { MessageCircleMore } from \"lucide-react\";\nimport type { ChatBotViewProps } from \"../../chat-bots/chat-bot\";\nimport { ChatBotShell, sharedAssistantIcons } from \"./chat-bot-shell\";\n\nexport default function ChatBotModern(props: ChatBotViewProps) {\n return (\n <ChatBotShell\n {...props}\n theme={{\n title: \"Modern assistant\",\n subtitle: \"Fast answers with a polished feel\",\n busyLabel: \"Composing a response\",\n placeholder: \"Type your message…\",\n launchIcon: MessageCircleMore,\n assistantIcon: sharedAssistantIcons.bot,\n launchButtonClassName:\n \"fixed bottom-6 right-6 z-50 size-14 rounded-full border border-white/20 bg-gradient-to-br from-cyan-500 via-blue-500 to-violet-600 text-white shadow-[0_24px_50px_-18px_rgba(59,130,246,0.85)] transition-all hover:-translate-y-1 hover:shadow-[0_28px_60px_-18px_rgba(99,102,241,0.75)]\",\n windowClassName:\n \"fixed bottom-4 left-4 right-4 z-50 flex h-[min(44rem,80vh)] flex-col overflow-hidden rounded-[30px] border border-slate-700/70 bg-slate-950 text-white shadow-[0_35px_90px_-30px_rgba(15,23,42,0.95)] sm:left-auto sm:right-6 sm:w-[420px]\",\n headerClassName:\n \"flex items-center justify-between border-b border-white/10 bg-gradient-to-r from-slate-950 via-slate-900 to-slate-950 px-5 py-4\",\n headerIconClassName:\n \"flex size-11 items-center justify-center rounded-2xl bg-gradient-to-br from-cyan-400/25 to-violet-500/25 text-cyan-100 ring-1 ring-white/10\",\n titleClassName: \"text-sm font-semibold text-white\",\n subtitleClassName: \"text-xs text-slate-300\",\n statusDotClassName:\n \"size-2 rounded-full bg-cyan-400 shadow-[0_0_12px_rgba(34,211,238,0.8)]\",\n closeButtonClassName:\n \"size-8 rounded-full text-slate-400 hover:bg-white/10 hover:text-white\",\n messagesClassName:\n \"flex-1 space-y-4 overflow-y-auto bg-[radial-gradient(circle_at_top,_rgba(56,189,248,0.14),_transparent_35%),linear-gradient(180deg,_#020617_0%,_#0f172a_55%,_#111827_100%)] px-5 py-5\",\n assistantAvatarClassName:\n \"flex size-8 shrink-0 items-center justify-center rounded-full bg-slate-900 text-cyan-200 ring-1 ring-cyan-400/20\",\n assistantBubbleClassName:\n \"border border-white/10 bg-white/8 text-slate-100 backdrop-blur-sm\",\n userAvatarClassName:\n \"flex h-8 items-center rounded-full bg-white/10 px-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-slate-200 ring-1 ring-white/10\",\n userBubbleClassName:\n \"bg-gradient-to-br from-cyan-500 to-violet-600 text-white shadow-[0_14px_30px_-18px_rgba(34,211,238,0.9)]\",\n composerClassName:\n \"border-t border-white/10 bg-slate-950/95 p-4 backdrop-blur-xl\",\n textareaClassName:\n \"min-h-[64px] rounded-2xl border-white/10 bg-white/5 pr-14 text-white placeholder:text-slate-400 focus-visible:ring-cyan-400/40\",\n helperTextClassName: \"mt-2 text-[11px] text-slate-500\",\n sendButtonClassName:\n \"absolute bottom-3 right-3 size-10 rounded-xl bg-gradient-to-br from-cyan-400 to-violet-500 text-white hover:from-cyan-300 hover:to-violet-400\",\n typingBubbleClassName:\n \"rounded-[22px] border border-white/10 bg-white/8 px-4 py-3 backdrop-blur-sm\",\n typingDotClassName: \"bg-cyan-300\",\n }}\n />\n );\n}","\"use client\";\n\nimport { SmilePlus } from \"lucide-react\";\nimport type { ChatBotViewProps } from \"../../chat-bots/chat-bot\";\nimport { ChatBotShell, sharedAssistantIcons } from \"./chat-bot-shell\";\n\nexport default function ChatBotPlayful(props: ChatBotViewProps) {\n return (\n <ChatBotShell\n {...props}\n theme={{\n title: \"Playful assistant\",\n subtitle: \"Bright, friendly, and upbeat\",\n busyLabel: \"Dreaming up something fun\",\n placeholder: \"Say hi, brainstorm, or ask anything ✨\",\n launchIcon: SmilePlus,\n assistantIcon: sharedAssistantIcons.sparkles,\n launchButtonClassName:\n \"fixed bottom-6 right-6 z-50 size-14 rounded-[22px] border-2 border-white/70 bg-[linear-gradient(135deg,_#f472b6_0%,_#f59e0b_100%)] text-white shadow-[0_24px_50px_-18px_rgba(244,114,182,0.75)] transition-all hover:-translate-y-1 hover:rotate-3\",\n windowClassName:\n \"fixed bottom-4 left-4 right-4 z-50 flex h-[min(44rem,80vh)] flex-col overflow-hidden rounded-[32px] border-2 border-rose-200 bg-[linear-gradient(180deg,_#fff7ed_0%,_#fff1f2_45%,_#fdf2f8_100%)] shadow-[0_35px_90px_-32px_rgba(244,114,182,0.55)] sm:left-auto sm:right-6 sm:w-[410px]\",\n headerClassName:\n \"flex items-center justify-between border-b border-rose-200/70 bg-white/60 px-5 py-4 backdrop-blur\",\n headerIconClassName:\n \"flex size-11 items-center justify-center rounded-[18px] bg-[linear-gradient(135deg,_#f472b6_0%,_#fb7185_50%,_#f59e0b_100%)] text-white shadow-md\",\n titleClassName: \"text-sm font-semibold text-rose-950\",\n subtitleClassName: \"text-xs text-rose-700/80\",\n statusDotClassName:\n \"size-2 rounded-full bg-emerald-500 shadow-[0_0_12px_rgba(16,185,129,0.55)]\",\n closeButtonClassName:\n \"size-8 rounded-full text-rose-500 hover:bg-white/80 hover:text-rose-700\",\n messagesClassName:\n \"flex-1 space-y-4 overflow-y-auto bg-[radial-gradient(circle_at_top_left,_rgba(253,186,116,0.35),_transparent_30%),radial-gradient(circle_at_top_right,_rgba(244,114,182,0.22),_transparent_28%),linear-gradient(180deg,_rgba(255,255,255,0.8),_rgba(255,241,242,0.65))] px-5 py-5\",\n assistantAvatarClassName:\n \"flex size-8 shrink-0 items-center justify-center rounded-full bg-white text-rose-500 ring-2 ring-rose-100 shadow-sm\",\n assistantBubbleClassName:\n \"border border-rose-100 bg-white/95 text-rose-950\",\n userAvatarClassName:\n \"flex h-8 items-center rounded-full bg-amber-300/80 px-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-amber-950 ring-1 ring-amber-400/50\",\n userBubbleClassName:\n \"bg-[linear-gradient(135deg,_#f472b6_0%,_#fb7185_55%,_#f59e0b_100%)] text-white shadow-[0_16px_32px_-18px_rgba(244,114,182,0.7)]\",\n composerClassName:\n \"border-t border-rose-200/70 bg-white/70 p-4 backdrop-blur\",\n textareaClassName:\n \"min-h-[64px] rounded-[24px] border-rose-200 bg-white/90 pr-14 text-rose-950 placeholder:text-rose-300 focus-visible:ring-rose-300\",\n helperTextClassName: \"mt-2 text-[11px] text-rose-400\",\n sendButtonClassName:\n \"absolute bottom-3 right-3 size-10 rounded-2xl bg-[linear-gradient(135deg,_#fb7185_0%,_#f59e0b_100%)] text-white hover:brightness-105\",\n typingBubbleClassName:\n \"rounded-[22px] border border-rose-100 bg-white/90 px-4 py-3 shadow-sm\",\n typingDotClassName: \"bg-rose-400\",\n }}\n />\n );\n}","import z from \"zod\";\r\n\r\nexport const messageSchema = z.object({\r\n role: z.enum([\"user\", \"assistant\"]),\r\n content: z.string(),\r\n});\r\n\r\nexport const chatRequestSchema = z.object({\r\n messages: z.array(messageSchema).min(1),\r\n});\r\n\r\nexport const chatResponseSchema = z.object({\r\n message: messageSchema,\r\n});\r\n","import type {\n ChatBotAdapter,\n ChatBotRequest,\n CreateFetchAdapterOptions,\n} from \"../chat-bot\";\nimport { chatRequestSchema, chatResponseSchema } from \"../../lib/schema\";\n\nconst resolveHeaders = async (headers: CreateFetchAdapterOptions[\"headers\"]) => {\n if (typeof headers === \"function\") {\n return await headers();\n }\n\n return headers;\n};\n\nexport const createFetchAdapter = ({\n apiUrl,\n fetch: fetchImplementation = globalThis.fetch,\n headers,\n}: CreateFetchAdapterOptions): ChatBotAdapter => {\n if (!apiUrl) {\n throw new Error(\"apiUrl is required\");\n }\n\n return {\n async sendMessage(messages) {\n if (typeof fetchImplementation !== \"function\") {\n throw new Error(\"Fetch API is not available. Provide a fetch implementation.\");\n }\n\n const requestPayload: ChatBotRequest = { messages };\n const parsedRequest = chatRequestSchema.safeParse(requestPayload);\n\n if (!parsedRequest.success) {\n throw new Error(\"Invalid chat request payload.\");\n }\n\n const requestHeaders = new Headers(await resolveHeaders(headers));\n if (!requestHeaders.has(\"Content-Type\")) {\n requestHeaders.set(\"Content-Type\", \"application/json\");\n }\n\n const response = await fetchImplementation(apiUrl, {\n method: \"POST\",\n headers: requestHeaders,\n body: JSON.stringify(parsedRequest.data),\n });\n\n if (!response.ok) {\n const statusText = response.statusText ? ` ${response.statusText}` : \"\";\n throw new Error(`Chat request failed with ${response.status}${statusText}`);\n }\n\n const responseJson = await response.json();\n const parsedResponse = chatResponseSchema.safeParse(responseJson);\n\n if (!parsedResponse.success) {\n throw new Error(\"Invalid chat response payload.\");\n }\n\n return parsedResponse.data.message;\n },\n };\n};"],"mappings":"skBAAA,IAAAA,GAAA,GAAAC,GAAAD,GAAA,iBAAAE,EAAA,YAAAC,EAAA,oBAAAC,EAAA,uBAAAC,EAAA,iBAAAC,EAAA,qBAAAC,IAAA,eAAAC,GAAAR,ICEA,IAAAS,EAAyB,iBCFzB,IAAAC,EAAiD,iBAgBxCC,EAAA,6BANHC,KAAiB,iBAAoC,IAAI,EAElDC,EAAkB,CAAC,CAC9B,OAAAC,EACA,SAAAC,CACF,OACS,OAACH,EAAe,SAAf,CAAwB,MAAOE,EAAS,SAAAC,EAAS,EAG9CC,EAAcH,EAEdI,EAA2B,OAC/B,cAAWL,CAAc,EAGrBM,EAAmB,IAAqB,CACnD,IAAMC,EAAUF,EAAyB,EACzC,GAAI,CAACE,EACH,MAAM,IAAI,MACR,qEACF,EAGF,OAAOA,CACT,EAEaC,EAAeF,EClC5B,IAAAG,GAA8B,wBCA9B,IAAAC,EAAwD,wBACxDC,EAAgE,iBCHhE,SAASC,EAAE,EAAE,CAAC,IAAI,EAAEC,EAAEC,EAAE,GAAG,GAAa,OAAO,GAAjB,UAA8B,OAAO,GAAjB,SAAmBA,GAAG,UAAoB,OAAO,GAAjB,SAAmB,GAAG,MAAM,QAAQ,CAAC,EAAE,CAAC,I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BACrB,kBACE,6DACF,kBACE,0GACF,oBAAqB,kCACrB,oBACE,0FACF,sBACE,oEACF,mBAAoB,cACtB,EACF,CAEJ,CQlDA,IAAAC,GAAkC,wBAM9B,IAAAC,GAAA,6BAFW,SAARC,EAA+BC,EAAyB,CAC7D,SACE,QAACC,EAAA,CACE,GAAGD,EACJ,MAAO,CACL,MAAO,mBACP,SAAU,oCACV,UAAW,uBACX,YAAa,0BACb,WAAY,qBACZ,cAAeE,EAAqB,IACpC,sBACE,4RACF,gBACE,6OACF,gBACE,kIACF,oBACE,8IACF,eAAgB,mCAChB,kBAAmB,yBACnB,mBACE,yEACF,qBACE,wEACF,kBACE,wLACF,yBACE,mHACF,yBACE,oEACF,oBACE,gJACF,oBACE,2GACF,kBACE,gEACF,kBACE,iIACF,oBAAqB,kCACrB,oBACE,gJACF,sBACE,8EACF,mBAAoB,aACtB,EACF,CAEJ,CCpDA,IAAAC,GAA0B,wBAMtB,IAAAC,GAAA,6BAFW,SAARC,EAAgCC,EAAyB,CAC9D,SACE,QAACC,EAAA,CACE,GAAGD,EACJ,MAAO,CACL,MAAO,oBACP,SAAU,+BACV,UAAW,4BACX,YAAa,6CACb,WAAY,aACZ,cAAeE,EAAqB,SACpC,sBACE,qPACF,gBACE,0RACF,gBACE,oGACF,oBACE,mJACF,eAAgB,sCAChB,kBAAmB,2BACnB,mBACE,6EACF,qBACE,0EACF,kBACE,oRACF,yBACE,sHACF,yBACE,mDACF,oBACE,wJACF,oBACE,kIACF,kBACE,4DACF,kBACE,oIACF,oBAAqB,iCACrB,oBACE,uIACF,sBACE,wEACF,mBAAoB,aACtB,EACF,CAEJ,CXkBQ,IAAAC,EAAA,6BA5DFC,GACJ,4DACIC,GACJ,2DAEa,SAARC,EAAyB,CAC9B,MAAAC,EACA,QAASC,EACT,eAAAC,EAAiBL,GACjB,aAAcM,EAAmBL,EACnC,EAAiB,CACf,IAAMM,EAASC,EAAyB,EAClCC,EAAUL,GAAeG,GAAQ,QACjC,CAACG,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AMD,EAAa,EAAE,IAAI,CAAC,CACxC,CAAC,EAEYG,GAAqB,EAAAF,QAAE,OAAO,CACzC,QAASD,EACX,CAAC,ECND,IAAMI,GAAiB,MAAOC,GACxB,OAAOA,GAAY,WACd,MAAMA,EAAQ,EAGhBA,EAGIC,EAAqB,CAAC,CACjC,OAAAC,EACA,MAAOC,EAAsB,WAAW,MACxC,QAAAH,CACF,IAAiD,CAC/C,GAAI,CAACE,EACH,MAAM,IAAI,MAAM,oBAAoB,EAGtC,MAAO,CACL,MAAM,YAAYE,EAAU,CAC1B,GAAI,OAAOD,GAAwB,WACjC,MAAM,IAAI,MAAM,6DAA6D,EAG/E,IAAME,EAAiC,CAAE,SAAAD,CAAS,EAC5CE,EAAgBC,GAAkB,UAAUF,CAAc,EAEhE,GAAI,CAACC,EAAc,QACjB,MAAM,IAAI,MAAM,+BAA+B,EAGjD,IAAME,EAAiB,IAAI,QAAQ,MAAMT,GAAeC,CAAO,CAAC,EAC3DQ,EAAe,IAAI,cAAc,GACpCA,EAAe,IAAI,eAAgB,kBAAkB,EAGvD,IAAMC,EAAW,MAAMN,EAAoBD,EAAQ,CACjD,OAAQ,OACR,QAASM,EACT,KAAM,KAAK,UAAUF,EAAc,IAAI,CACzC,CAAC,EAED,GAAI,CAACG,EAAS,GAAI,CAChB,IAAMC,EAAaD,EAAS,WAAa,IAAIA,EAAS,UAAU,GAAK,GACrE,MAAM,IAAI,MAAM,4BAA4BA,EAAS,MAAM,GAAGC,CAAU,EAAE,CAC5E,CAEA,IAAMC,EAAe,MAAMF,EAAS,KAAK,EACnCG,EAAiBC,GAAmB,UAAUF,CAAY,EAEhE,GAAI,CAACC,EAAe,QAClB,MAAM,IAAI,MAAM,gCAAgC,EAGlD,OAAOA,EAAe,KAAK,OAC7B,CACF,CACF","names":["index_exports","__export","ApiProvider","ChatBot","ChatBotProvider","createFetchAdapter","useApiConfig","useChatBotConfig","__toCommonJS","import_react","import_react","import_jsx_runtime","ChatBotContext","ChatBotProvider","config","children","ApiProvider","useOptionalChatBotConfig","useChatBotConfig","context","useApiConfig","import_lucide_react","import_lucide_react","import_react","r","f","n","o","clsx","import_tailwind_merge","cn","inputs","clsx","React","React","setRef","ref","value","composeRefs","refs","node","hasCleanup","cleanups","cleanup","i","import_jsx_runtime","createSlot","ownerName","SlotClone","createSlotClone","Slot","props","forwardedRef","children","slotProps","childrenArray","slottable","isSlottable","newElement","newChildren","child","childrenRef","getElementRef","mergeProps","composeRefs","SLOTTABLE_IDENTIFIER","isSlottable","child","SLOTTABLE_IDENTIFIER","mergeProps","slotProps","childProps","overrideProps","propName","slotPropValue","childPropValue","args","result","getElementRef","element","getter","mayWarn","import_class_variance_authority","import_jsx_runtime","buttonVariants","Button","className","variant","size","asChild","props","Slot","cn","import_jsx_runtime","Textarea","className","props","cn","import_jsx_runtime","ChatBotShell","theme","messages","handleSendMessage","isOpen","isSending","setIsOpen","inputValue","setInputValue","messagesEndRef","canSend","LaunchIcon","AssistantIcon","submitMessage","nextMessage","handleKeyPress","event","Button","message","index","isUser","cn","dot","Textarea","sharedAssistantIcons","import_jsx_runtime","ChatBotMinimal","props","ChatBotShell","sharedAssistantIcons","import_lucide_react","import_jsx_runtime","ChatBotModern","props","ChatBotShell","sharedAssistantIcons","import_lucide_react","import_jsx_runtime","ChatBotPlayful","props","ChatBotShell","sharedAssistantIcons","import_jsx_runtime","DEFAULT_WELCOME_MESSAGE","DEFAULT_ERROR_MESSAGE","ChatBot","style","adapterProp","welcomeMessage","errorMessageText","config","useOptionalChatBotConfig","adapter","isOpen","setIsOpen","isSending","setIsSending","messages","setMessages","handleSendMessage","inputValue","userMessage","updatedMessages","response","prev","errorMessage","ChatBotModern","ChatBotPlayful","ChatBotMinimal","import_zod","messageSchema","z","chatRequestSchema","chatResponseSchema","resolveHeaders","headers","createFetchAdapter","apiUrl","fetchImplementation","messages","requestPayload","parsedRequest","chatRequestSchema","requestHeaders","response","statusText","responseJson","parsedResponse","chatResponseSchema"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{useState as B}from"react";import{createContext as D,useContext as $}from"react";import{jsx as K}from"react/jsx-runtime";var P=D(null),E=({config:e,children:t})=>K(P.Provider,{value:e,children:t}),L=E,w=()=>$(P),A=()=>{let e=w();if(!e)throw new Error("useChatBotConfig must be used inside ChatBotProvider or ApiProvider");return e},W=A;import{useState as se,useRef as ne,useEffect as ie}from"react";import*as i from"react";import*as G from"react";function M(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function N(...e){return t=>{let r=!1,o=e.map(a=>{let s=M(a,t);return!r&&typeof s=="function"&&(r=!0),s});if(r)return()=>{for(let a=0;a<o.length;a++){let s=o[a];typeof s=="function"?s():M(e[a],null)}}}}import{Fragment as Re,jsx as k}from"react/jsx-runtime";function J(e){let t=U(e),r=i.forwardRef((o,a)=>{let{children:s,...l}=o,n=i.Children.toArray(s),p=n.find(Z);if(p){let c=p.props.children,f=n.map(h=>h===p?i.Children.count(c)>1?i.Children.only(null):i.isValidElement(c)?c.props.children:null:h);return k(t,{...l,ref:a,children:i.isValidElement(c)?i.cloneElement(c,void 0,f):null})}return k(t,{...l,ref:a,children:s})});return r.displayName=`${e}.Slot`,r}var O=J("Slot");function U(e){let t=i.forwardRef((r,o)=>{let{children:a,...s}=r;if(i.isValidElement(a)){let l=Y(a),n=Q(s,a.props);return a.type!==i.Fragment&&(n.ref=o?N(o,l):l),i.cloneElement(a,n)}return i.Children.count(a)>1?i.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var X=Symbol("radix.slottable");function Z(e){return i.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===X}function Q(e,t){let r={...t};for(let o in t){let a=e[o],s=t[o];/^on[A-Z]/.test(o)?a&&s?r[o]=(...n)=>{let p=s(...n);return a(...n),p}:a&&(r[o]=a):o==="style"?r[o]={...a,...s}:o==="className"&&(r[o]=[a,s].filter(Boolean).join(" "))}return{...e,...r}}function Y(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}import{cva as te}from"class-variance-authority";function I(e){var t,r,o="";if(typeof e=="string"||typeof e=="number")o+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(r=I(e[t]))&&(o&&(o+=" "),o+=r)}else for(r in e)e[r]&&(o&&(o+=" "),o+=r);return o}function T(){for(var e,t,r=0,o="",a=arguments.length;r<a;r++)(e=arguments[r])&&(t=I(e))&&(o&&(o+=" "),o+=t);return o}import{twMerge as ee}from"tailwind-merge";function b(...e){return ee(T(e))}import{jsx as re}from"react/jsx-runtime";var oe=te("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function C({className:e,variant:t,size:r,asChild:o=!1,...a}){return re(o?O:"button",{"data-slot":"button",className:b(oe({variant:t,size:r,className:e})),...a})}import{MessageCircle as le,X as ce,Send as de}from"lucide-react";import{jsx as ae}from"react/jsx-runtime";function V({className:e,...t}){return ae("textarea",{"data-slot":"textarea",className:b("wrap-break-word break-normal border-input placeholder:text-muted-foreground aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base transition-[color,box-shadow] outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),...t})}import{Fragment as pe,jsx as d,jsxs as m}from"react/jsx-runtime";function R(e){let{messages:t,handleSendMessage:r,isOpen:o,isSending:a,setIsOpen:s}=e,[l,n]=se(""),p=ne(null),c=l.trim().length>0&&!a;ie(()=>{p.current?.scrollIntoView({behavior:"smooth"})},[t]);let f=()=>{if(!c)return;let u=l;n(""),r(u)},h=u=>{u.key==="Enter"&&!u.shiftKey&&(u.preventDefault(),f())};return m(pe,{children:[!o&&d(C,{onClick:()=>s(!0),className:"fixed bottom-6 right-6 h-12 w-12 rounded-full bg-slate-900 hover:bg-slate-800 shadow-lg hover:shadow-xl transition-all duration-200 z-50 border border-slate-200",size:"icon",children:d(le,{className:"h-5 w-5 text-white"})}),o&&m("div",{className:"fixed bottom-6 right-6 h-[75vh] w-[400px] max-w-[calc(100vw-3rem)] bg-white border border-slate-200 rounded-lg shadow-xl z-50 flex flex-col overflow-hidden",children:[m("div",{className:"border-b border-slate-100 p-3 flex items-center justify-between bg-white",children:[m("div",{className:"flex items-center space-x-2",children:[d("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),d("span",{className:"text-sm font-medium text-slate-900",children:"Assistant"})]}),d(C,{variant:"ghost",size:"icon",onClick:()=>s(!1),className:"h-6 w-6 text-slate-400 hover:text-slate-600",children:d(ce,{className:"h-3 w-3"})})]}),m("div",{className:"flex-1 overflow-y-auto p-4 space-y-3 bg-slate-50/30",children:[t.map((u,v)=>d("div",{className:`flex ${u.role==="assistant"?"justify-start":"justify-end"}`,children:d("div",{className:`max-w-[75%] px-3 py-2 rounded-lg text-sm ${u.role==="assistant"?"bg-white border border-slate-200 text-slate-700":"bg-slate-900 text-white"}`,children:u.content})},v)),d("div",{ref:p})]}),d("div",{className:"border-t border-slate-100 p-3 bg-white",children:m("div",{className:"flex space-x-2",children:[d(V,{value:l,onChange:u=>n(u.target.value),onKeyDown:h,rows:2,placeholder:"What's on your mind? \u{1F4AD}",className:"min-h-[3rem] resize-none border-none flex-1 bg-white/80 placeholder:text-gray-400"}),d(C,{onClick:f,size:"icon",disabled:!c,className:"self-center bg-slate-900 hover:bg-slate-800 h-9 w-9",children:d(de,{className:"h-3 w-3"})})]})})]})]})}import{jsx as he}from"react/jsx-runtime";var ue="Hi! I'm your digital assistant. How can I help you today?",fe="Apologies, I ran into a problem. Please try again later.";function F({style:e,adapter:t,welcomeMessage:r=ue,errorMessage:o=fe}){let a=w(),s=t??a?.adapter,[l,n]=B(!1),[p,c]=B(!1),[f,h]=B(()=>[{content:r,role:"assistant"}]);if(!s)throw new Error("ChatBot requires an adapter prop or a ChatBotProvider/ApiProvider config with an adapter.");return he(R,{messages:f,handleSendMessage:async v=>{if(!v.trim())return;c(!0);let H={content:v,role:"user"},S=[...f,H];h(S);try{let x=await s.sendMessage(S);h(y=>[...y,x])}catch{let x={content:o,role:"assistant"};h(y=>[...y,x])}finally{c(!1)}},isOpen:l,isSending:p,setIsOpen:n})}import g from"zod";var _=g.object({role:g.enum(["user","assistant"]),content:g.string()}),z=g.object({messages:g.array(_).min(1)}),q=g.object({message:_});var me=async e=>typeof e=="function"?await e():e,j=({apiUrl:e,fetch:t=globalThis.fetch,headers:r})=>{if(!e)throw new Error("apiUrl is required");return{async sendMessage(o){if(typeof t!="function")throw new Error("Fetch API is not available. Provide a fetch implementation.");let a={messages:o},s=z.safeParse(a);if(!s.success)throw new Error("Invalid chat request payload.");let l=new Headers(await me(r));l.has("Content-Type")||l.set("Content-Type","application/json");let n=await t(e,{method:"POST",headers:l,body:JSON.stringify(s.data)});if(!n.ok){let f=n.statusText?` ${n.statusText}`:"";throw new Error(`Chat request failed with ${n.status}${f}`)}let p=await n.json(),c=q.safeParse(p);if(!c.success)throw new Error("Invalid chat response payload.");return c.data.message}}};export{L as ApiProvider,F as ChatBot,E as ChatBotProvider,j as createFetchAdapter,W as useApiConfig,A as useChatBotConfig};
|
|
1
|
+
import{useState as k}from"react";import{createContext as G,useContext as J}from"react";import{jsx as Z}from"react/jsx-runtime";var I=G(null),E=({config:e,children:t})=>Z(I.Provider,{value:e,children:t}),X=E,R=()=>J(I),M=()=>{let e=R();if(!e)throw new Error("useChatBotConfig must be used inside ChatBotProvider or ApiProvider");return e},Y=M;import{MessageCircle as xe}from"lucide-react";import{Bot as q,Send as pe,Sparkles as ue,X as me}from"lucide-react";import{useEffect as fe,useRef as be,useState as he}from"react";function T(e){var t,r,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(r=T(e[t]))&&(s&&(s+=" "),s+=r)}else for(r in e)e[r]&&(s&&(s+=" "),s+=r);return s}function V(){for(var e,t,r=0,s="",a=arguments.length;r<a;r++)(e=arguments[r])&&(t=T(e))&&(s&&(s+=" "),s+=t);return s}import{twMerge as Q}from"tailwind-merge";function h(...e){return Q(V(e))}import*as l from"react";import*as ee from"react";function O(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function D(...e){return t=>{let r=!1,s=e.map(a=>{let o=O(a,t);return!r&&typeof o=="function"&&(r=!0),o});if(r)return()=>{for(let a=0;a<s.length;a++){let o=s[a];typeof o=="function"?o():O(e[a],null)}}}}import{Fragment as De,jsx as L}from"react/jsx-runtime";function te(e){let t=se(e),r=l.forwardRef((s,a)=>{let{children:o,...d}=s,i=l.Children.toArray(o),p=i.find(re);if(p){let u=p.props.children,f=i.map(b=>b===p?l.Children.count(u)>1?l.Children.only(null):l.isValidElement(u)?u.props.children:null:b);return L(t,{...d,ref:a,children:l.isValidElement(u)?l.cloneElement(u,void 0,f):null})}return L(t,{...d,ref:a,children:o})});return r.displayName=`${e}.Slot`,r}var F=te("Slot");function se(e){let t=l.forwardRef((r,s)=>{let{children:a,...o}=r;if(l.isValidElement(a)){let d=ne(a),i=oe(o,a.props);return a.type!==l.Fragment&&(i.ref=s?D(s,d):d),l.cloneElement(a,i)}return l.Children.count(a)>1?l.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var ae=Symbol("radix.slottable");function re(e){return l.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===ae}function oe(e,t){let r={...t};for(let s in t){let a=e[s],o=t[s];/^on[A-Z]/.test(s)?a&&o?r[s]=(...i)=>{let p=o(...i);return a(...i),p}:a&&(r[s]=a):s==="style"?r[s]={...a,...o}:s==="className"&&(r[s]=[a,o].filter(Boolean).join(" "))}return{...e,...r}}function ne(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}import{cva as ie}from"class-variance-authority";import{jsx as de}from"react/jsx-runtime";var le=ie("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function _({className:e,variant:t,size:r,asChild:s=!1,...a}){return de(s?F:"button",{"data-slot":"button",className:h(le({variant:t,size:r,className:e})),...a})}import{jsx as ce}from"react/jsx-runtime";function j({className:e,...t}){return ce("textarea",{"data-slot":"textarea",className:h("wrap-break-word break-normal border-input placeholder:text-muted-foreground aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base transition-[color,box-shadow] outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",e),...t})}import{Fragment as ge,jsx as n,jsxs as m}from"react/jsx-runtime";function C({theme:e,messages:t,handleSendMessage:r,isOpen:s,isSending:a,setIsOpen:o}){let[d,i]=he(""),p=be(null),u=d.trim().length>0&&!a,f=e.launchIcon,b=e.assistantIcon;fe(()=>{p.current?.scrollIntoView({behavior:"smooth"})},[t,a]);let x=()=>{if(!u)return;let c=d;i(""),r(c)},y=c=>{c.key==="Enter"&&!c.shiftKey&&(c.preventDefault(),x())};return m(ge,{children:[!s&&n(_,{"aria-controls":"general-ai-chat-bot-window","aria-expanded":!1,"aria-label":`Open ${e.title}`,className:e.launchButtonClassName,onClick:()=>o(!0),size:"icon",children:n(f,{className:"size-5"})}),s&&m("section",{"aria-label":e.title,className:e.windowClassName,id:"general-ai-chat-bot-window",role:"dialog",children:[m("div",{className:e.headerClassName,children:[m("div",{className:"flex items-center gap-3",children:[n("div",{className:e.headerIconClassName,children:n(b,{className:"size-5"})}),m("div",{className:"min-w-0",children:[n("p",{className:e.titleClassName,children:e.title}),m("div",{className:"flex items-center gap-2",children:[n("span",{className:e.statusDotClassName}),n("p",{className:e.subtitleClassName,children:a?e.busyLabel:e.subtitle})]})]})]}),n(_,{"aria-label":"Close chat window",className:e.closeButtonClassName,onClick:()=>o(!1),size:"icon",variant:"ghost",children:n(me,{className:"size-4"})})]}),m("div",{"aria-live":"polite",className:e.messagesClassName,role:"log",children:[t.map((c,N)=>{let g=c.role==="user";return m("div",{className:h("flex items-end gap-2",g?"justify-end":"justify-start"),children:[!g&&n("div",{className:e.assistantAvatarClassName,children:n(b,{className:"size-4"})}),n("div",{className:h("max-w-[82%] whitespace-pre-wrap break-words rounded-[22px] px-4 py-3 text-sm leading-6 shadow-sm",g?e.userBubbleClassName:e.assistantBubbleClassName),children:c.content}),g&&n("div",{className:e.userAvatarClassName,children:"You"})]},`${c.role}-${N}-${c.content}`)}),a&&m("div",{className:"flex items-end gap-2",children:[n("div",{className:e.assistantAvatarClassName,children:n(q,{className:"size-4"})}),m("div",{className:e.typingBubbleClassName,children:[n("span",{className:"sr-only",children:e.busyLabel}),n("div",{className:"flex items-center gap-1.5",children:[0,1,2].map(c=>n("span",{className:h("size-2 rounded-full animate-pulse",e.typingDotClassName,c===1&&"[animation-delay:150ms]",c===2&&"[animation-delay:300ms]")},c))})]})]}),n("div",{ref:p})]}),m("div",{className:e.composerClassName,children:[m("div",{className:"relative",children:[n(j,{className:h("max-h-32 resize-none pb-14 text-sm leading-6",e.textareaClassName),onChange:c=>i(c.target.value),onKeyDown:y,placeholder:e.placeholder,rows:2,value:d}),n(_,{"aria-label":"Send message",className:e.sendButtonClassName,disabled:!u,onClick:x,size:"icon",children:n(pe,{className:"size-4"})})]}),n("p",{className:e.helperTextClassName,children:"Press Enter to send \xB7 Shift+Enter for a new line"})]})]})]})}var v={bot:q,sparkles:ue};import{jsx as Ce}from"react/jsx-runtime";function P(e){return Ce(C,{...e,theme:{title:"Minimal assistant",subtitle:"Clean, focused support",busyLabel:"Thinking through your request",placeholder:"Ask a question or describe what you need\u2026",launchIcon:xe,assistantIcon:v.bot,launchButtonClassName:"fixed bottom-6 right-6 z-50 size-14 rounded-full border border-slate-200 bg-slate-900 text-white shadow-[0_18px_35px_-15px_rgba(15,23,42,0.8)] transition-all hover:-translate-y-0.5 hover:bg-slate-800",windowClassName:"fixed bottom-4 left-4 right-4 z-50 flex h-[min(42rem,78vh)] flex-col overflow-hidden rounded-[28px] border border-slate-200/80 bg-white/95 shadow-[0_24px_80px_-28px_rgba(15,23,42,0.45)] backdrop-blur sm:left-auto sm:right-6 sm:w-[400px]",headerClassName:"flex items-center justify-between border-b border-slate-200/80 bg-white/90 px-4 py-4",headerIconClassName:"flex size-11 items-center justify-center rounded-2xl bg-slate-900 text-white shadow-sm",titleClassName:"text-sm font-semibold text-slate-900",subtitleClassName:"text-xs text-slate-500",statusDotClassName:"size-2 rounded-full bg-emerald-500",closeButtonClassName:"size-8 rounded-full text-slate-500 hover:bg-slate-100 hover:text-slate-900",messagesClassName:"flex-1 space-y-4 overflow-y-auto bg-gradient-to-b from-slate-50 to-white px-4 py-4",assistantAvatarClassName:"flex size-8 shrink-0 items-center justify-center rounded-full bg-white text-slate-700 ring-1 ring-slate-200 shadow-sm",assistantBubbleClassName:"bg-white text-slate-700 ring-1 ring-slate-200",userAvatarClassName:"flex h-8 items-center rounded-full bg-slate-900 px-2 text-[10px] font-semibold uppercase tracking-wide text-white/90",userBubbleClassName:"bg-slate-900 text-white",composerClassName:"border-t border-slate-200/80 bg-white/95 p-4 backdrop-blur",textareaClassName:"min-h-[60px] rounded-2xl border-slate-200 bg-slate-50/80 pr-14 shadow-none focus-visible:ring-slate-300",helperTextClassName:"mt-2 text-[11px] text-slate-400",sendButtonClassName:"absolute bottom-3 right-3 size-10 rounded-xl bg-slate-900 text-white hover:bg-slate-800",typingBubbleClassName:"rounded-[22px] bg-white px-4 py-3 shadow-sm ring-1 ring-slate-200",typingDotClassName:"bg-slate-400"}})}import{MessageCircleMore as ve}from"lucide-react";import{jsx as we}from"react/jsx-runtime";function S(e){return we(C,{...e,theme:{title:"Modern assistant",subtitle:"Fast answers with a polished feel",busyLabel:"Composing a response",placeholder:"Type your message\u2026",launchIcon:ve,assistantIcon:v.bot,launchButtonClassName:"fixed bottom-6 right-6 z-50 size-14 rounded-full border border-white/20 bg-gradient-to-br from-cyan-500 via-blue-500 to-violet-600 text-white shadow-[0_24px_50px_-18px_rgba(59,130,246,0.85)] transition-all hover:-translate-y-1 hover:shadow-[0_28px_60px_-18px_rgba(99,102,241,0.75)]",windowClassName:"fixed bottom-4 left-4 right-4 z-50 flex h-[min(44rem,80vh)] flex-col overflow-hidden rounded-[30px] border border-slate-700/70 bg-slate-950 text-white shadow-[0_35px_90px_-30px_rgba(15,23,42,0.95)] sm:left-auto sm:right-6 sm:w-[420px]",headerClassName:"flex items-center justify-between border-b border-white/10 bg-gradient-to-r from-slate-950 via-slate-900 to-slate-950 px-5 py-4",headerIconClassName:"flex size-11 items-center justify-center rounded-2xl bg-gradient-to-br from-cyan-400/25 to-violet-500/25 text-cyan-100 ring-1 ring-white/10",titleClassName:"text-sm font-semibold text-white",subtitleClassName:"text-xs text-slate-300",statusDotClassName:"size-2 rounded-full bg-cyan-400 shadow-[0_0_12px_rgba(34,211,238,0.8)]",closeButtonClassName:"size-8 rounded-full text-slate-400 hover:bg-white/10 hover:text-white",messagesClassName:"flex-1 space-y-4 overflow-y-auto bg-[radial-gradient(circle_at_top,_rgba(56,189,248,0.14),_transparent_35%),linear-gradient(180deg,_#020617_0%,_#0f172a_55%,_#111827_100%)] px-5 py-5",assistantAvatarClassName:"flex size-8 shrink-0 items-center justify-center rounded-full bg-slate-900 text-cyan-200 ring-1 ring-cyan-400/20",assistantBubbleClassName:"border border-white/10 bg-white/8 text-slate-100 backdrop-blur-sm",userAvatarClassName:"flex h-8 items-center rounded-full bg-white/10 px-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-slate-200 ring-1 ring-white/10",userBubbleClassName:"bg-gradient-to-br from-cyan-500 to-violet-600 text-white shadow-[0_14px_30px_-18px_rgba(34,211,238,0.9)]",composerClassName:"border-t border-white/10 bg-slate-950/95 p-4 backdrop-blur-xl",textareaClassName:"min-h-[64px] rounded-2xl border-white/10 bg-white/5 pr-14 text-white placeholder:text-slate-400 focus-visible:ring-cyan-400/40",helperTextClassName:"mt-2 text-[11px] text-slate-500",sendButtonClassName:"absolute bottom-3 right-3 size-10 rounded-xl bg-gradient-to-br from-cyan-400 to-violet-500 text-white hover:from-cyan-300 hover:to-violet-400",typingBubbleClassName:"rounded-[22px] border border-white/10 bg-white/8 px-4 py-3 backdrop-blur-sm",typingDotClassName:"bg-cyan-300"}})}import{SmilePlus as ye}from"lucide-react";import{jsx as Ne}from"react/jsx-runtime";function A(e){return Ne(C,{...e,theme:{title:"Playful assistant",subtitle:"Bright, friendly, and upbeat",busyLabel:"Dreaming up something fun",placeholder:"Say hi, brainstorm, or ask anything \u2728",launchIcon:ye,assistantIcon:v.sparkles,launchButtonClassName:"fixed bottom-6 right-6 z-50 size-14 rounded-[22px] border-2 border-white/70 bg-[linear-gradient(135deg,_#f472b6_0%,_#f59e0b_100%)] text-white shadow-[0_24px_50px_-18px_rgba(244,114,182,0.75)] transition-all hover:-translate-y-1 hover:rotate-3",windowClassName:"fixed bottom-4 left-4 right-4 z-50 flex h-[min(44rem,80vh)] flex-col overflow-hidden rounded-[32px] border-2 border-rose-200 bg-[linear-gradient(180deg,_#fff7ed_0%,_#fff1f2_45%,_#fdf2f8_100%)] shadow-[0_35px_90px_-32px_rgba(244,114,182,0.55)] sm:left-auto sm:right-6 sm:w-[410px]",headerClassName:"flex items-center justify-between border-b border-rose-200/70 bg-white/60 px-5 py-4 backdrop-blur",headerIconClassName:"flex size-11 items-center justify-center rounded-[18px] bg-[linear-gradient(135deg,_#f472b6_0%,_#fb7185_50%,_#f59e0b_100%)] text-white shadow-md",titleClassName:"text-sm font-semibold text-rose-950",subtitleClassName:"text-xs text-rose-700/80",statusDotClassName:"size-2 rounded-full bg-emerald-500 shadow-[0_0_12px_rgba(16,185,129,0.55)]",closeButtonClassName:"size-8 rounded-full text-rose-500 hover:bg-white/80 hover:text-rose-700",messagesClassName:"flex-1 space-y-4 overflow-y-auto bg-[radial-gradient(circle_at_top_left,_rgba(253,186,116,0.35),_transparent_30%),radial-gradient(circle_at_top_right,_rgba(244,114,182,0.22),_transparent_28%),linear-gradient(180deg,_rgba(255,255,255,0.8),_rgba(255,241,242,0.65))] px-5 py-5",assistantAvatarClassName:"flex size-8 shrink-0 items-center justify-center rounded-full bg-white text-rose-500 ring-2 ring-rose-100 shadow-sm",assistantBubbleClassName:"border border-rose-100 bg-white/95 text-rose-950",userAvatarClassName:"flex h-8 items-center rounded-full bg-amber-300/80 px-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-amber-950 ring-1 ring-amber-400/50",userBubbleClassName:"bg-[linear-gradient(135deg,_#f472b6_0%,_#fb7185_55%,_#f59e0b_100%)] text-white shadow-[0_16px_32px_-18px_rgba(244,114,182,0.7)]",composerClassName:"border-t border-rose-200/70 bg-white/70 p-4 backdrop-blur",textareaClassName:"min-h-[64px] rounded-[24px] border-rose-200 bg-white/90 pr-14 text-rose-950 placeholder:text-rose-300 focus-visible:ring-rose-300",helperTextClassName:"mt-2 text-[11px] text-rose-400",sendButtonClassName:"absolute bottom-3 right-3 size-10 rounded-2xl bg-[linear-gradient(135deg,_#fb7185_0%,_#f59e0b_100%)] text-white hover:brightness-105",typingBubbleClassName:"rounded-[22px] border border-rose-100 bg-white/90 px-4 py-3 shadow-sm",typingDotClassName:"bg-rose-400"}})}import{jsx as z}from"react/jsx-runtime";var _e="Hi! I'm your digital assistant. How can I help you today?",Be="Apologies, I ran into a problem. Please try again later.";function $({style:e,adapter:t,welcomeMessage:r=_e,errorMessage:s=Be}){let a=R(),o=t??a?.adapter,[d,i]=k(!1),[p,u]=k(!1),[f,b]=k(()=>[{content:r,role:"assistant"}]);if(!o)throw new Error("ChatBot requires an adapter prop or a ChatBotProvider/ApiProvider config with an adapter.");let x=async y=>{if(!y.trim())return;u(!0);let c={content:y,role:"user"},N=[...f,c];b(N);try{let g=await o.sendMessage(N);b(B=>[...B,g])}catch{let g={content:s,role:"assistant"};b(B=>[...B,g])}finally{u(!1)}};switch(e){case"modern":return z(S,{messages:f,handleSendMessage:x,isOpen:d,isSending:p,setIsOpen:i});case"playful":return z(A,{messages:f,handleSendMessage:x,isOpen:d,isSending:p,setIsOpen:i});default:return z(P,{messages:f,handleSendMessage:x,isOpen:d,isSending:p,setIsOpen:i})}}import w from"zod";var H=w.object({role:w.enum(["user","assistant"]),content:w.string()}),W=w.object({messages:w.array(H).min(1)}),K=w.object({message:H});var Re=async e=>typeof e=="function"?await e():e,U=({apiUrl:e,fetch:t=globalThis.fetch,headers:r})=>{if(!e)throw new Error("apiUrl is required");return{async sendMessage(s){if(typeof t!="function")throw new Error("Fetch API is not available. Provide a fetch implementation.");let a={messages:s},o=W.safeParse(a);if(!o.success)throw new Error("Invalid chat request payload.");let d=new Headers(await Re(r));d.has("Content-Type")||d.set("Content-Type","application/json");let i=await t(e,{method:"POST",headers:d,body:JSON.stringify(o.data)});if(!i.ok){let f=i.statusText?` ${i.statusText}`:"";throw new Error(`Chat request failed with ${i.status}${f}`)}let p=await i.json(),u=K.safeParse(p);if(!u.success)throw new Error("Invalid chat response payload.");return u.data.message}}};export{X as ApiProvider,$ as ChatBot,E as ChatBotProvider,U as createFetchAdapter,Y as useApiConfig,M as useChatBotConfig};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/chat-bot/index.tsx","../src/lib/api-provider.tsx","../src/components/chat-bot/chat-bot-minimal.tsx","../node_modules/@radix-ui/react-slot/src/slot.tsx","../node_modules/@radix-ui/react-compose-refs/src/compose-refs.tsx","../src/components/ui/button.tsx","../node_modules/clsx/dist/clsx.mjs","../src/lib/utils.ts","../src/components/ui/textarea.tsx","../src/lib/schema.ts","../src/chat-bots/adapters/fetch.ts"],"sourcesContent":["\"use client\";\r\n\r\nimport { useState } from \"react\";\r\nimport type {\r\n ChatBotProps,\r\n ChatMessage,\r\n} from \"../../chat-bots/chat-bot\";\r\nimport { useOptionalChatBotConfig } from \"../../lib/api-provider\";\r\nimport ChatBotMinimal from \"./chat-bot-minimal\";\r\n\r\nconst DEFAULT_WELCOME_MESSAGE =\r\n \"Hi! I'm your digital assistant. How can I help you today?\";\r\nconst DEFAULT_ERROR_MESSAGE =\r\n \"Apologies, I ran into a problem. Please try again later.\";\r\n\r\nexport default function ChatBot({\r\n style,\r\n adapter: adapterProp,\r\n welcomeMessage = DEFAULT_WELCOME_MESSAGE,\r\n errorMessage: errorMessageText = DEFAULT_ERROR_MESSAGE,\r\n}: ChatBotProps) {\r\n const config = useOptionalChatBotConfig();\r\n const adapter = adapterProp ?? config?.adapter;\r\n const [isOpen, setIsOpen] = useState(false);\r\n const [isSending, setIsSending] = useState(false);\r\n const [messages, setMessages] = useState<ChatMessage[]>(() => [\r\n {\r\n content: welcomeMessage,\r\n role: \"assistant\",\r\n },\r\n ]);\r\n\r\n if (!adapter) {\r\n throw new Error(\r\n \"ChatBot requires an adapter prop or a ChatBotProvider/ApiProvider config with an adapter.\",\r\n );\r\n }\r\n\r\n const handleSendMessage = async (inputValue: string) => {\r\n if (!inputValue.trim()) {\r\n return;\r\n }\r\n\r\n setIsSending(true);\r\n\r\n const userMessage: ChatMessage = {\r\n content: inputValue,\r\n role: \"user\",\r\n };\r\n\r\n const updatedMessages = [...messages, userMessage];\r\n setMessages(updatedMessages);\r\n\r\n try {\r\n const response = await adapter.sendMessage(updatedMessages);\r\n setMessages((prev) => [...prev, response]);\r\n } catch {\r\n const errorMessage: ChatMessage = {\r\n content: errorMessageText,\r\n role: \"assistant\",\r\n };\r\n setMessages((prev) => [...prev, errorMessage]);\r\n } finally {\r\n setIsSending(false);\r\n }\r\n };\r\n\r\n switch (style) {\r\n /*\r\n case \"modern\":\r\n return (\r\n <ChatBotModern\r\n messages={messages}\r\n handleSendMessage={handleSendMessage}\r\n isOpen={isOpen}\r\n isSending={isSending}\r\n setIsOpen={setIsOpen}\r\n />\r\n );\r\n case \"playful\":\r\n return (\r\n <ChatBotPlayful\r\n messages={messages}\r\n handleSendMessage={handleSendMessage}\r\n isOpen={isOpen}\r\n isSending={isSending}\r\n setIsOpen={setIsOpen}\r\n />\r\n );\r\n */\r\n default:\r\n return (\r\n <ChatBotMinimal\r\n messages={messages}\r\n handleSendMessage={handleSendMessage}\r\n isOpen={isOpen}\r\n isSending={isSending}\r\n setIsOpen={setIsOpen}\r\n />\r\n );\r\n }\r\n}\r\n","import React, { createContext, useContext } from \"react\";\r\nimport type { ChatBotConfig } from \"../chat-bots/chat-bot\";\r\n\r\nexport interface ApiConfig extends ChatBotConfig {}\r\n\r\nexport interface ChatBotProviderProps {\r\n config: ChatBotConfig;\r\n children: React.ReactNode;\r\n}\r\n\r\nconst ChatBotContext = createContext<ChatBotConfig | null>(null);\r\n\r\nexport const ChatBotProvider = ({\r\n config,\r\n children,\r\n}: ChatBotProviderProps) => {\r\n return <ChatBotContext.Provider value={config}>{children}</ChatBotContext.Provider>;\r\n};\r\n\r\nexport const ApiProvider = ChatBotProvider;\r\n\r\nexport const useOptionalChatBotConfig = (): ChatBotConfig | null => {\r\n return useContext(ChatBotContext);\r\n};\r\n\r\nexport const useChatBotConfig = (): ChatBotConfig => {\r\n const context = useOptionalChatBotConfig();\r\n if (!context) {\r\n throw new Error(\r\n \"useChatBotConfig must be used inside ChatBotProvider or ApiProvider\",\r\n );\r\n }\r\n\r\n return context;\r\n};\r\n\r\nexport const useApiConfig = useChatBotConfig;\r\n","\"use client\";\r\n\r\nimport type React from \"react\";\r\n\r\nimport { useState, useRef, useEffect } from \"react\";\r\nimport { Button } from \"../ui/button\";\r\nimport { MessageCircle, X, Send } from \"lucide-react\";\r\nimport { Textarea } from \"../ui/textarea\";\r\nimport type { ChatBotViewProps } from \"../../chat-bots/chat-bot\";\r\n\r\nexport default function ChatBotMinimal(props: ChatBotViewProps) {\r\n const { messages, handleSendMessage, isOpen, isSending, setIsOpen } = props;\r\n const [inputValue, setInputValue] = useState(\"\");\r\n const messagesEndRef = useRef<HTMLDivElement>(null);\r\n const canSend = inputValue.trim().length > 0 && !isSending;\r\n\r\n useEffect(() => {\r\n messagesEndRef.current?.scrollIntoView({ behavior: \"smooth\" });\r\n }, [messages]);\r\n\r\n const submitMessage = () => {\r\n if (!canSend) {\r\n return;\r\n }\r\n\r\n const nextMessage = inputValue;\r\n setInputValue(\"\");\r\n void handleSendMessage(nextMessage);\r\n };\r\n\r\n const handleKeyPress = (e: React.KeyboardEvent<HTMLTextAreaElement>) => {\r\n if (e.key === \"Enter\" && !e.shiftKey) {\r\n e.preventDefault();\r\n submitMessage();\r\n }\r\n };\r\n\r\n return (\r\n <>\r\n {/* Minimal Chat Button */}\r\n {!isOpen && (\r\n <Button\r\n onClick={() => setIsOpen(true)}\r\n className=\"fixed bottom-6 right-6 h-12 w-12 rounded-full bg-slate-900 hover:bg-slate-800 shadow-lg hover:shadow-xl transition-all duration-200 z-50 border border-slate-200\"\r\n size=\"icon\"\r\n >\r\n <MessageCircle className=\"h-5 w-5 text-white\" />\r\n </Button>\r\n )}\r\n\r\n {/* Minimal Chat Window */}\r\n {isOpen && (\r\n <div className=\"fixed bottom-6 right-6 h-[75vh] w-[400px] max-w-[calc(100vw-3rem)] bg-white border border-slate-200 rounded-lg shadow-xl z-50 flex flex-col overflow-hidden\">\r\n {/* Simple Header */}\r\n <div className=\"border-b border-slate-100 p-3 flex items-center justify-between bg-white\">\r\n <div className=\"flex items-center space-x-2\">\r\n <div className=\"w-2 h-2 bg-green-500 rounded-full\"></div>\r\n <span className=\"text-sm font-medium text-slate-900\">\r\n Assistant\r\n </span>\r\n </div>\r\n <Button\r\n variant=\"ghost\"\r\n size=\"icon\"\r\n onClick={() => setIsOpen(false)}\r\n className=\"h-6 w-6 text-slate-400 hover:text-slate-600\"\r\n >\r\n <X className=\"h-3 w-3\" />\r\n </Button>\r\n </div>\r\n\r\n {/* Messages */}\r\n <div className=\"flex-1 overflow-y-auto p-4 space-y-3 bg-slate-50/30\">\r\n {messages.map((message, i) => (\r\n <div\r\n key={i}\r\n className={`flex ${message.role === \"assistant\" ? \"justify-start\" : \"justify-end\"}`}\r\n >\r\n <div\r\n className={`max-w-[75%] px-3 py-2 rounded-lg text-sm ${\r\n message.role === \"assistant\"\r\n ? \"bg-white border border-slate-200 text-slate-700\"\r\n : \"bg-slate-900 text-white\"\r\n }`}\r\n >\r\n {message.content}\r\n </div>\r\n </div>\r\n ))}\r\n <div ref={messagesEndRef} />\r\n </div>\r\n\r\n {/* Simple Input */}\r\n <div className=\"border-t border-slate-100 p-3 bg-white\">\r\n <div className=\"flex space-x-2\">\r\n <Textarea\r\n value={inputValue}\r\n onChange={(e) => setInputValue(e.target.value)}\r\n onKeyDown={handleKeyPress}\r\n rows={2}\r\n placeholder=\"What's on your mind? 💭\"\r\n className=\"min-h-[3rem] resize-none border-none flex-1 bg-white/80 placeholder:text-gray-400\"\r\n />\r\n <Button\r\n onClick={submitMessage}\r\n size=\"icon\"\r\n disabled={!canSend}\r\n className=\"self-center bg-slate-900 hover:bg-slate-800 h-9 w-9\"\r\n >\r\n <Send className=\"h-3 w-3\" />\r\n </Button>\r\n </div>\r\n </div>\r\n </div>\r\n )}\r\n </>\r\n );\r\n}\r\n","import * as React from 'react';\nimport { composeRefs } from '@radix-ui/react-compose-refs';\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotProps extends React.HTMLAttributes<HTMLElement> {\n children?: React.ReactNode;\n}\n\n/* @__NO_SIDE_EFFECTS__ */ export function createSlot(ownerName: string) {\n const SlotClone = createSlotClone(ownerName);\n const Slot = React.forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props;\n const childrenArray = React.Children.toArray(children);\n const slottable = childrenArray.find(isSlottable);\n\n if (slottable) {\n // the new element to render is the one passed as a child of `Slottable`\n const newElement = slottable.props.children;\n\n const newChildren = childrenArray.map((child) => {\n if (child === slottable) {\n // because the new element will be the one rendered, we are only interested\n // in grabbing its children (`newElement.props.children`)\n if (React.Children.count(newElement) > 1) return React.Children.only(null);\n return React.isValidElement(newElement)\n ? (newElement.props as { children: React.ReactNode }).children\n : null;\n } else {\n return child;\n }\n });\n\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {React.isValidElement(newElement)\n ? React.cloneElement(newElement, undefined, newChildren)\n : null}\n </SlotClone>\n );\n }\n\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {children}\n </SlotClone>\n );\n });\n\n Slot.displayName = `${ownerName}.Slot`;\n return Slot;\n}\n\nconst Slot = createSlot('Slot');\n\n/* -------------------------------------------------------------------------------------------------\n * SlotClone\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotCloneProps {\n children: React.ReactNode;\n}\n\n/* @__NO_SIDE_EFFECTS__ */ function createSlotClone(ownerName: string) {\n const SlotClone = React.forwardRef<any, SlotCloneProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props;\n\n if (React.isValidElement(children)) {\n const childrenRef = getElementRef(children);\n const props = mergeProps(slotProps, children.props as AnyProps);\n // do not pass ref to React.Fragment for React 19 compatibility\n if (children.type !== React.Fragment) {\n props.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;\n }\n return React.cloneElement(children, props);\n }\n\n return React.Children.count(children) > 1 ? React.Children.only(null) : null;\n });\n\n SlotClone.displayName = `${ownerName}.SlotClone`;\n return SlotClone;\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * -----------------------------------------------------------------------------------------------*/\n\nconst SLOTTABLE_IDENTIFIER = Symbol('radix.slottable');\n\ninterface SlottableProps {\n children: React.ReactNode;\n}\n\ninterface SlottableComponent extends React.FC<SlottableProps> {\n __radixId: symbol;\n}\n\n/* @__NO_SIDE_EFFECTS__ */ export function createSlottable(ownerName: string) {\n const Slottable: SlottableComponent = ({ children }) => {\n return <>{children}</>;\n };\n Slottable.displayName = `${ownerName}.Slottable`;\n Slottable.__radixId = SLOTTABLE_IDENTIFIER;\n return Slottable;\n}\n\nconst Slottable = createSlottable('Slottable');\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype AnyProps = Record<string, any>;\n\nfunction isSlottable(\n child: React.ReactNode\n): child is React.ReactElement<SlottableProps, typeof Slottable> {\n return (\n React.isValidElement(child) &&\n typeof child.type === 'function' &&\n '__radixId' in child.type &&\n child.type.__radixId === SLOTTABLE_IDENTIFIER\n );\n}\n\nfunction mergeProps(slotProps: AnyProps, childProps: AnyProps) {\n // all child props should override\n const overrideProps = { ...childProps };\n\n for (const propName in childProps) {\n const slotPropValue = slotProps[propName];\n const childPropValue = childProps[propName];\n\n const isHandler = /^on[A-Z]/.test(propName);\n if (isHandler) {\n // if the handler exists on both, we compose them\n if (slotPropValue && childPropValue) {\n overrideProps[propName] = (...args: unknown[]) => {\n const result = childPropValue(...args);\n slotPropValue(...args);\n return result;\n };\n }\n // but if it exists only on the slot, we use only this one\n else if (slotPropValue) {\n overrideProps[propName] = slotPropValue;\n }\n }\n // if it's `style`, we merge them\n else if (propName === 'style') {\n overrideProps[propName] = { ...slotPropValue, ...childPropValue };\n } else if (propName === 'className') {\n overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(' ');\n }\n }\n\n return { ...slotProps, ...overrideProps };\n}\n\n// Before React 19 accessing `element.props.ref` will throw a warning and suggest using `element.ref`\n// After React 19 accessing `element.ref` does the opposite.\n// https://github.com/facebook/react/pull/28348\n//\n// Access the ref using the method that doesn't yield a warning.\nfunction getElementRef(element: React.ReactElement) {\n // React <=18 in DEV\n let getter = Object.getOwnPropertyDescriptor(element.props, 'ref')?.get;\n let mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning;\n if (mayWarn) {\n return (element as any).ref;\n }\n\n // React 19 in DEV\n getter = Object.getOwnPropertyDescriptor(element, 'ref')?.get;\n mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning;\n if (mayWarn) {\n return (element.props as { ref?: React.Ref<unknown> }).ref;\n }\n\n // Not DEV\n return (element.props as { ref?: React.Ref<unknown> }).ref || (element as any).ref;\n}\n\nexport {\n Slot,\n Slottable,\n //\n Slot as Root,\n};\nexport type { SlotProps };\n","import * as React from 'react';\n\ntype PossibleRef<T> = React.Ref<T> | undefined;\n\n/**\n * Set a given ref to a given value\n * This utility takes care of different types of refs: callback refs and RefObject(s)\n */\nfunction setRef<T>(ref: PossibleRef<T>, value: T) {\n if (typeof ref === 'function') {\n return ref(value);\n } else if (ref !== null && ref !== undefined) {\n ref.current = value;\n }\n}\n\n/**\n * A utility to compose multiple refs together\n * Accepts callback refs and RefObject(s)\n */\nfunction composeRefs<T>(...refs: PossibleRef<T>[]): React.RefCallback<T> {\n return (node) => {\n let hasCleanup = false;\n const cleanups = refs.map((ref) => {\n const cleanup = setRef(ref, node);\n if (!hasCleanup && typeof cleanup == 'function') {\n hasCleanup = true;\n }\n return cleanup;\n });\n\n // React <19 will log an error to the console if a callback ref returns a\n // value. We don't use ref cleanups internally so this will only happen if a\n // user's ref callback returns a value, which we only expect if they are\n // using the cleanup functionality added in React 19.\n if (hasCleanup) {\n return () => {\n for (let i = 0; i < cleanups.length; i++) {\n const cleanup = cleanups[i];\n if (typeof cleanup == 'function') {\n cleanup();\n } else {\n setRef(refs[i], null);\n }\n }\n };\n }\n };\n}\n\n/**\n * A custom hook that composes multiple refs\n * Accepts callback refs and RefObject(s)\n */\nfunction useComposedRefs<T>(...refs: PossibleRef<T>[]): React.RefCallback<T> {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useCallback(composeRefs(...refs), refs);\n}\n\nexport { composeRefs, useComposedRefs };\n","import * as React from \"react\";\r\nimport { Slot } from \"@radix-ui/react-slot\";\r\nimport { cva, type VariantProps } from \"class-variance-authority\";\r\n\r\nimport { cn } from \"../../lib/utils\";\r\n\r\nconst buttonVariants = cva(\r\n \"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive\",\r\n {\r\n variants: {\r\n variant: {\r\n default:\r\n \"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90\",\r\n destructive:\r\n \"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60\",\r\n outline:\r\n \"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50\",\r\n secondary:\r\n \"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80\",\r\n ghost:\r\n \"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50\",\r\n link: \"text-primary underline-offset-4 hover:underline\",\r\n },\r\n size: {\r\n default: \"h-9 px-4 py-2 has-[>svg]:px-3\",\r\n sm: \"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5\",\r\n lg: \"h-10 rounded-md px-6 has-[>svg]:px-4\",\r\n icon: \"size-9\",\r\n },\r\n },\r\n defaultVariants: {\r\n variant: \"default\",\r\n size: \"default\",\r\n },\r\n },\r\n);\r\n\r\nfunction Button({\r\n className,\r\n variant,\r\n size,\r\n asChild = false,\r\n ...props\r\n}: React.ComponentProps<\"button\"> &\r\n VariantProps<typeof buttonVariants> & {\r\n asChild?: boolean;\r\n }) {\r\n const Comp = asChild ? Slot : \"button\";\r\n\r\n return (\r\n <Comp\r\n data-slot=\"button\"\r\n className={cn(buttonVariants({ variant, size, className }))}\r\n {...props}\r\n />\r\n );\r\n}\r\n\r\nexport { Button, buttonVariants };\r\n","function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f)}else for(f in e)e[f]&&(n&&(n+=\" \"),n+=f);return n}export function clsx(){for(var e,t,f=0,n=\"\",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;","import { clsx, type ClassValue } from \"clsx\";\r\nimport { twMerge } from \"tailwind-merge\";\r\n\r\nexport function cn(...inputs: ClassValue[]) {\r\n return twMerge(clsx(inputs));\r\n}\r\n","import * as React from \"react\";\r\n\r\nimport { cn } from \"../../lib/utils\";\r\n\r\nfunction Textarea({ className, ...props }: React.ComponentProps<\"textarea\">) {\r\n return (\r\n <textarea\r\n data-slot=\"textarea\"\r\n className={cn(\r\n \"wrap-break-word break-normal border-input placeholder:text-muted-foreground aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base transition-[color,box-shadow] outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\",\r\n className,\r\n )}\r\n {...props}\r\n />\r\n );\r\n}\r\n\r\nexport { Textarea };\r\n","import z from \"zod\";\r\n\r\nexport const messageSchema = z.object({\r\n role: z.enum([\"user\", \"assistant\"]),\r\n content: z.string(),\r\n});\r\n\r\nexport const chatRequestSchema = z.object({\r\n messages: z.array(messageSchema).min(1),\r\n});\r\n\r\nexport const chatResponseSchema = z.object({\r\n message: messageSchema,\r\n});\r\n","import type {\n ChatBotAdapter,\n ChatBotRequest,\n CreateFetchAdapterOptions,\n} from \"../chat-bot\";\nimport { chatRequestSchema, chatResponseSchema } from \"../../lib/schema\";\n\nconst resolveHeaders = async (headers: CreateFetchAdapterOptions[\"headers\"]) => {\n if (typeof headers === \"function\") {\n return await headers();\n }\n\n return headers;\n};\n\nexport const createFetchAdapter = ({\n apiUrl,\n fetch: fetchImplementation = globalThis.fetch,\n headers,\n}: CreateFetchAdapterOptions): ChatBotAdapter => {\n if (!apiUrl) {\n throw new Error(\"apiUrl is required\");\n }\n\n return {\n async sendMessage(messages) {\n if (typeof fetchImplementation !== \"function\") {\n throw new Error(\"Fetch API is not available. Provide a fetch implementation.\");\n }\n\n const requestPayload: ChatBotRequest = { messages };\n const parsedRequest = chatRequestSchema.safeParse(requestPayload);\n\n if (!parsedRequest.success) {\n throw new Error(\"Invalid chat request payload.\");\n }\n\n const requestHeaders = new Headers(await resolveHeaders(headers));\n if (!requestHeaders.has(\"Content-Type\")) {\n requestHeaders.set(\"Content-Type\", \"application/json\");\n }\n\n const response = await fetchImplementation(apiUrl, {\n method: \"POST\",\n headers: requestHeaders,\n body: JSON.stringify(parsedRequest.data),\n });\n\n if (!response.ok) {\n const statusText = response.statusText ? ` ${response.statusText}` : \"\";\n throw new Error(`Chat request failed with ${response.status}${statusText}`);\n }\n\n const responseJson = await response.json();\n const parsedResponse = chatResponseSchema.safeParse(responseJson);\n\n if (!parsedResponse.success) {\n throw new Error(\"Invalid chat response payload.\");\n }\n\n return parsedResponse.data.message;\n },\n };\n};"],"mappings":"AAEA,OAAS,YAAAA,MAAgB,QCFzB,OAAgB,iBAAAC,EAAe,cAAAC,MAAkB,QAgBxC,cAAAC,MAAA,oBANT,IAAMC,EAAiBH,EAAoC,IAAI,EAElDI,EAAkB,CAAC,CAC9B,OAAAC,EACA,SAAAC,CACF,IACSJ,EAACC,EAAe,SAAf,CAAwB,MAAOE,EAAS,SAAAC,EAAS,EAG9CC,EAAcH,EAEdI,EAA2B,IAC/BP,E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,CAACC,EAAe,QAClB,MAAM,IAAI,MAAM,gCAAgC,EAGlD,OAAOA,EAAe,KAAK,OAC7B,CACF,CACF","names":["useState","createContext","useContext","jsx","ChatBotContext","ChatBotProvider","config","children","ApiProvider","useOptionalChatBotConfig","useChatBotConfig","context","useApiConfig","useState","useRef","useEffect","React","React","setRef","ref","value","composeRefs","refs","node","hasCleanup","cleanups","cleanup","i","Fragment","jsx","createSlot","ownerName","SlotClone","createSlotClone","Slot","props","forwardedRef","children","slotProps","childrenArray","slottable","isSlottable","newElement","newChildren","child","childrenRef","getElementRef","mergeProps","composeRefs","SLOTTABLE_IDENTIFIER","isSlottable","child","SLOTTABLE_IDENTIFIER","mergeProps","slotProps","childProps","overrideProps","propName","slotPropValue","childPropValue","args","result","getElementRef","element","getter","mayWarn","cva","r","f","n","o","clsx","twMerge","cn","inputs","clsx","jsx","buttonVariants","cva","Button","className","variant","size","asChild","props","Slot","cn","MessageCircle","X","Send","jsx","Textarea","className","props","cn","Fragment","jsx","jsxs","ChatBotMinimal","props","messages","handleSendMessage","isOpen","isSending","setIsOpen","inputValue","setInputValue","useState","messagesEndRef","useRef","canSend","useEffect","submitMessage","nextMessage","handleKeyPress","e","Button","MessageCircle","X","message","i","Textarea","Send","jsx","DEFAULT_WELCOME_MESSAGE","DEFAULT_ERROR_MESSAGE","ChatBot","style","adapterProp","welcomeMessage","errorMessageText","config","useOptionalChatBotConfig","adapter","isOpen","setIsOpen","useState","isSending","setIsSending","messages","setMessages","ChatBotMinimal","inputValue","userMessage","updatedMessages","response","prev","errorMessage","z","messageSchema","chatRequestSchema","chatResponseSchema","resolveHeaders","headers","createFetchAdapter","apiUrl","fetchImplementation","messages","requestPayload","parsedRequest","chatRequestSchema","requestHeaders","response","statusText","responseJson","parsedResponse","chatResponseSchema"]}
|
|
1
|
+
{"version":3,"sources":["../src/components/chat-bot/index.tsx","../src/lib/api-provider.tsx","../src/components/chat-bot/chat-bot-minimal.tsx","../src/components/chat-bot/chat-bot-shell.tsx","../node_modules/clsx/dist/clsx.mjs","../src/lib/utils.ts","../node_modules/@radix-ui/react-slot/src/slot.tsx","../node_modules/@radix-ui/react-compose-refs/src/compose-refs.tsx","../src/components/ui/button.tsx","../src/components/ui/textarea.tsx","../src/components/chat-bot/chat-bot-modern.tsx","../src/components/chat-bot/chat-bot-playful.tsx","../src/lib/schema.ts","../src/chat-bots/adapters/fetch.ts"],"sourcesContent":["\"use client\";\r\n\r\nimport { useState } from \"react\";\r\nimport type {\r\n ChatBotProps,\r\n ChatMessage,\r\n} from \"../../chat-bots/chat-bot\";\r\nimport { useOptionalChatBotConfig } from \"../../lib/api-provider\";\r\nimport ChatBotMinimal from \"./chat-bot-minimal\";\r\nimport ChatBotModern from \"./chat-bot-modern\";\r\nimport ChatBotPlayful from \"./chat-bot-playful\";\r\n\r\nconst DEFAULT_WELCOME_MESSAGE =\r\n \"Hi! I'm your digital assistant. How can I help you today?\";\r\nconst DEFAULT_ERROR_MESSAGE =\r\n \"Apologies, I ran into a problem. Please try again later.\";\r\n\r\nexport default function ChatBot({\r\n style,\r\n adapter: adapterProp,\r\n welcomeMessage = DEFAULT_WELCOME_MESSAGE,\r\n errorMessage: errorMessageText = DEFAULT_ERROR_MESSAGE,\r\n}: ChatBotProps) {\r\n const config = useOptionalChatBotConfig();\r\n const adapter = adapterProp ?? config?.adapter;\r\n const [isOpen, setIsOpen] = useState(false);\r\n const [isSending, setIsSending] = useState(false);\r\n const [messages, setMessages] = useState<ChatMessage[]>(() => [\r\n {\r\n content: welcomeMessage,\r\n role: \"assistant\",\r\n },\r\n ]);\r\n\r\n if (!adapter) {\r\n throw new Error(\r\n \"ChatBot requires an adapter prop or a ChatBotProvider/ApiProvider config with an adapter.\",\r\n );\r\n }\r\n\r\n const handleSendMessage = async (inputValue: string) => {\r\n if (!inputValue.trim()) {\r\n return;\r\n }\r\n\r\n setIsSending(true);\r\n\r\n const userMessage: ChatMessage = {\r\n content: inputValue,\r\n role: \"user\",\r\n };\r\n\r\n const updatedMessages = [...messages, userMessage];\r\n setMessages(updatedMessages);\r\n\r\n try {\r\n const response = await adapter.sendMessage(updatedMessages);\r\n setMessages((prev) => [...prev, response]);\r\n } catch {\r\n const errorMessage: ChatMessage = {\r\n content: errorMessageText,\r\n role: \"assistant\",\r\n };\r\n setMessages((prev) => [...prev, errorMessage]);\r\n } finally {\r\n setIsSending(false);\r\n }\r\n };\r\n\r\n switch (style) {\r\n case \"modern\":\r\n return (\r\n <ChatBotModern\r\n messages={messages}\r\n handleSendMessage={handleSendMessage}\r\n isOpen={isOpen}\r\n isSending={isSending}\r\n setIsOpen={setIsOpen}\r\n />\r\n );\r\n case \"playful\":\r\n return (\r\n <ChatBotPlayful\r\n messages={messages}\r\n handleSendMessage={handleSendMessage}\r\n isOpen={isOpen}\r\n isSending={isSending}\r\n setIsOpen={setIsOpen}\r\n />\r\n );\r\n default:\r\n return (\r\n <ChatBotMinimal\r\n messages={messages}\r\n handleSendMessage={handleSendMessage}\r\n isOpen={isOpen}\r\n isSending={isSending}\r\n setIsOpen={setIsOpen}\r\n />\r\n );\r\n }\r\n}\r\n","import React, { createContext, useContext } from \"react\";\r\nimport type { ChatBotConfig } from \"../chat-bots/chat-bot\";\r\n\r\nexport interface ApiConfig extends ChatBotConfig {}\r\n\r\nexport interface ChatBotProviderProps {\r\n config: ChatBotConfig;\r\n children: React.ReactNode;\r\n}\r\n\r\nconst ChatBotContext = createContext<ChatBotConfig | null>(null);\r\n\r\nexport const ChatBotProvider = ({\r\n config,\r\n children,\r\n}: ChatBotProviderProps) => {\r\n return <ChatBotContext.Provider value={config}>{children}</ChatBotContext.Provider>;\r\n};\r\n\r\nexport const ApiProvider = ChatBotProvider;\r\n\r\nexport const useOptionalChatBotConfig = (): ChatBotConfig | null => {\r\n return useContext(ChatBotContext);\r\n};\r\n\r\nexport const useChatBotConfig = (): ChatBotConfig => {\r\n const context = useOptionalChatBotConfig();\r\n if (!context) {\r\n throw new Error(\r\n \"useChatBotConfig must be used inside ChatBotProvider or ApiProvider\",\r\n );\r\n }\r\n\r\n return context;\r\n};\r\n\r\nexport const useApiConfig = useChatBotConfig;\r\n","\"use client\";\r\n\r\nimport { MessageCircle } from \"lucide-react\";\r\nimport type { ChatBotViewProps } from \"../../chat-bots/chat-bot\";\r\nimport { ChatBotShell, sharedAssistantIcons } from \"./chat-bot-shell\";\r\n\r\nexport default function ChatBotMinimal(props: ChatBotViewProps) {\r\n return (\r\n <ChatBotShell\r\n {...props}\r\n theme={{\r\n title: \"Minimal assistant\",\r\n subtitle: \"Clean, focused support\",\r\n busyLabel: \"Thinking through your request\",\r\n placeholder: \"Ask a question or describe what you need…\",\r\n launchIcon: MessageCircle,\r\n assistantIcon: sharedAssistantIcons.bot,\r\n launchButtonClassName:\r\n \"fixed bottom-6 right-6 z-50 size-14 rounded-full border border-slate-200 bg-slate-900 text-white shadow-[0_18px_35px_-15px_rgba(15,23,42,0.8)] transition-all hover:-translate-y-0.5 hover:bg-slate-800\",\r\n windowClassName:\r\n \"fixed bottom-4 left-4 right-4 z-50 flex h-[min(42rem,78vh)] flex-col overflow-hidden rounded-[28px] border border-slate-200/80 bg-white/95 shadow-[0_24px_80px_-28px_rgba(15,23,42,0.45)] backdrop-blur sm:left-auto sm:right-6 sm:w-[400px]\",\r\n headerClassName:\r\n \"flex items-center justify-between border-b border-slate-200/80 bg-white/90 px-4 py-4\",\r\n headerIconClassName:\r\n \"flex size-11 items-center justify-center rounded-2xl bg-slate-900 text-white shadow-sm\",\r\n titleClassName: \"text-sm font-semibold text-slate-900\",\r\n subtitleClassName: \"text-xs text-slate-500\",\r\n statusDotClassName: \"size-2 rounded-full bg-emerald-500\",\r\n closeButtonClassName:\r\n \"size-8 rounded-full text-slate-500 hover:bg-slate-100 hover:text-slate-900\",\r\n messagesClassName:\r\n \"flex-1 space-y-4 overflow-y-auto bg-gradient-to-b from-slate-50 to-white px-4 py-4\",\r\n assistantAvatarClassName:\r\n \"flex size-8 shrink-0 items-center justify-center rounded-full bg-white text-slate-700 ring-1 ring-slate-200 shadow-sm\",\r\n assistantBubbleClassName:\r\n \"bg-white text-slate-700 ring-1 ring-slate-200\",\r\n userAvatarClassName:\r\n \"flex h-8 items-center rounded-full bg-slate-900 px-2 text-[10px] font-semibold uppercase tracking-wide text-white/90\",\r\n userBubbleClassName: \"bg-slate-900 text-white\",\r\n composerClassName:\r\n \"border-t border-slate-200/80 bg-white/95 p-4 backdrop-blur\",\r\n textareaClassName:\r\n \"min-h-[60px] rounded-2xl border-slate-200 bg-slate-50/80 pr-14 shadow-none focus-visible:ring-slate-300\",\r\n helperTextClassName: \"mt-2 text-[11px] text-slate-400\",\r\n sendButtonClassName:\r\n \"absolute bottom-3 right-3 size-10 rounded-xl bg-slate-900 text-white hover:bg-slate-800\",\r\n typingBubbleClassName:\r\n \"rounded-[22px] bg-white px-4 py-3 shadow-sm ring-1 ring-slate-200\",\r\n typingDotClassName: \"bg-slate-400\",\r\n }}\r\n />\r\n );\r\n}\r\n","\"use client\";\n\nimport { Bot, Send, Sparkles, X, type LucideIcon } from \"lucide-react\";\nimport { useEffect, useRef, useState, type KeyboardEvent } from \"react\";\nimport type { ChatBotViewProps } from \"../../chat-bots/chat-bot\";\nimport { cn } from \"../../lib/utils\";\nimport { Button } from \"../ui/button\";\nimport { Textarea } from \"../ui/textarea\";\n\nexport interface ChatBotTheme {\n title: string;\n subtitle: string;\n busyLabel: string;\n placeholder: string;\n launchIcon: LucideIcon;\n assistantIcon: LucideIcon;\n launchButtonClassName: string;\n windowClassName: string;\n headerClassName: string;\n headerIconClassName: string;\n titleClassName: string;\n subtitleClassName: string;\n statusDotClassName: string;\n closeButtonClassName: string;\n messagesClassName: string;\n assistantAvatarClassName: string;\n assistantBubbleClassName: string;\n userAvatarClassName: string;\n userBubbleClassName: string;\n composerClassName: string;\n textareaClassName: string;\n helperTextClassName: string;\n sendButtonClassName: string;\n typingBubbleClassName: string;\n typingDotClassName: string;\n}\n\nexport function ChatBotShell({\n theme,\n messages,\n handleSendMessage,\n isOpen,\n isSending,\n setIsOpen,\n}: ChatBotViewProps & { theme: ChatBotTheme }) {\n const [inputValue, setInputValue] = useState(\"\");\n const messagesEndRef = useRef<HTMLDivElement>(null);\n const canSend = inputValue.trim().length > 0 && !isSending;\n const LaunchIcon = theme.launchIcon;\n const AssistantIcon = theme.assistantIcon;\n\n useEffect(() => {\n messagesEndRef.current?.scrollIntoView({ behavior: \"smooth\" });\n }, [messages, isSending]);\n\n const submitMessage = () => {\n if (!canSend) {\n return;\n }\n\n const nextMessage = inputValue;\n setInputValue(\"\");\n void handleSendMessage(nextMessage);\n };\n\n const handleKeyPress = (event: KeyboardEvent<HTMLTextAreaElement>) => {\n if (event.key === \"Enter\" && !event.shiftKey) {\n event.preventDefault();\n submitMessage();\n }\n };\n\n return (\n <>\n {!isOpen && (\n <Button\n aria-controls=\"general-ai-chat-bot-window\"\n aria-expanded={false}\n aria-label={`Open ${theme.title}`}\n className={theme.launchButtonClassName}\n onClick={() => setIsOpen(true)}\n size=\"icon\"\n >\n <LaunchIcon className=\"size-5\" />\n </Button>\n )}\n\n {isOpen && (\n <section\n aria-label={theme.title}\n className={theme.windowClassName}\n id=\"general-ai-chat-bot-window\"\n role=\"dialog\"\n >\n <div className={theme.headerClassName}>\n <div className=\"flex items-center gap-3\">\n <div className={theme.headerIconClassName}>\n <AssistantIcon className=\"size-5\" />\n </div>\n <div className=\"min-w-0\">\n <p className={theme.titleClassName}>{theme.title}</p>\n <div className=\"flex items-center gap-2\">\n <span className={theme.statusDotClassName} />\n <p className={theme.subtitleClassName}>\n {isSending ? theme.busyLabel : theme.subtitle}\n </p>\n </div>\n </div>\n </div>\n\n <Button\n aria-label=\"Close chat window\"\n className={theme.closeButtonClassName}\n onClick={() => setIsOpen(false)}\n size=\"icon\"\n variant=\"ghost\"\n >\n <X className=\"size-4\" />\n </Button>\n </div>\n\n <div aria-live=\"polite\" className={theme.messagesClassName} role=\"log\">\n {messages.map((message, index) => {\n const isUser = message.role === \"user\";\n\n return (\n <div\n key={`${message.role}-${index}-${message.content}`}\n className={cn(\n \"flex items-end gap-2\",\n isUser ? \"justify-end\" : \"justify-start\",\n )}\n >\n {!isUser && (\n <div className={theme.assistantAvatarClassName}>\n <AssistantIcon className=\"size-4\" />\n </div>\n )}\n\n <div\n className={cn(\n \"max-w-[82%] whitespace-pre-wrap break-words rounded-[22px] px-4 py-3 text-sm leading-6 shadow-sm\",\n isUser\n ? theme.userBubbleClassName\n : theme.assistantBubbleClassName,\n )}\n >\n {message.content}\n </div>\n\n {isUser && <div className={theme.userAvatarClassName}>You</div>}\n </div>\n );\n })}\n\n {isSending && (\n <div className=\"flex items-end gap-2\">\n <div className={theme.assistantAvatarClassName}>\n <Bot className=\"size-4\" />\n </div>\n <div className={theme.typingBubbleClassName}>\n <span className=\"sr-only\">{theme.busyLabel}</span>\n <div className=\"flex items-center gap-1.5\">\n {[0, 1, 2].map((dot) => (\n <span\n key={dot}\n className={cn(\n \"size-2 rounded-full animate-pulse\",\n theme.typingDotClassName,\n dot === 1 && \"[animation-delay:150ms]\",\n dot === 2 && \"[animation-delay:300ms]\",\n )}\n />\n ))}\n </div>\n </div>\n </div>\n )}\n\n <div ref={messagesEndRef} />\n </div>\n\n <div className={theme.composerClassName}>\n <div className=\"relative\">\n <Textarea\n className={cn(\n \"max-h-32 resize-none pb-14 text-sm leading-6\",\n theme.textareaClassName,\n )}\n onChange={(event) => setInputValue(event.target.value)}\n onKeyDown={handleKeyPress}\n placeholder={theme.placeholder}\n rows={2}\n value={inputValue}\n />\n <Button\n aria-label=\"Send message\"\n className={theme.sendButtonClassName}\n disabled={!canSend}\n onClick={submitMessage}\n size=\"icon\"\n >\n <Send className=\"size-4\" />\n </Button>\n </div>\n\n <p className={theme.helperTextClassName}>\n Press Enter to send · Shift+Enter for a new line\n </p>\n </div>\n </section>\n )}\n </>\n );\n}\n\nexport const sharedAssistantIcons = {\n bot: Bot,\n sparkles: Sparkles,\n};","function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f)}else for(f in e)e[f]&&(n&&(n+=\" \"),n+=f);return n}export function clsx(){for(var e,t,f=0,n=\"\",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;","import { clsx, type ClassValue } from \"clsx\";\r\nimport { twMerge } from \"tailwind-merge\";\r\n\r\nexport function cn(...inputs: ClassValue[]) {\r\n return twMerge(clsx(inputs));\r\n}\r\n","import * as React from 'react';\nimport { composeRefs } from '@radix-ui/react-compose-refs';\n\n/* -------------------------------------------------------------------------------------------------\n * Slot\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotProps extends React.HTMLAttributes<HTMLElement> {\n children?: React.ReactNode;\n}\n\n/* @__NO_SIDE_EFFECTS__ */ export function createSlot(ownerName: string) {\n const SlotClone = createSlotClone(ownerName);\n const Slot = React.forwardRef<HTMLElement, SlotProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props;\n const childrenArray = React.Children.toArray(children);\n const slottable = childrenArray.find(isSlottable);\n\n if (slottable) {\n // the new element to render is the one passed as a child of `Slottable`\n const newElement = slottable.props.children;\n\n const newChildren = childrenArray.map((child) => {\n if (child === slottable) {\n // because the new element will be the one rendered, we are only interested\n // in grabbing its children (`newElement.props.children`)\n if (React.Children.count(newElement) > 1) return React.Children.only(null);\n return React.isValidElement(newElement)\n ? (newElement.props as { children: React.ReactNode }).children\n : null;\n } else {\n return child;\n }\n });\n\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {React.isValidElement(newElement)\n ? React.cloneElement(newElement, undefined, newChildren)\n : null}\n </SlotClone>\n );\n }\n\n return (\n <SlotClone {...slotProps} ref={forwardedRef}>\n {children}\n </SlotClone>\n );\n });\n\n Slot.displayName = `${ownerName}.Slot`;\n return Slot;\n}\n\nconst Slot = createSlot('Slot');\n\n/* -------------------------------------------------------------------------------------------------\n * SlotClone\n * -----------------------------------------------------------------------------------------------*/\n\ninterface SlotCloneProps {\n children: React.ReactNode;\n}\n\n/* @__NO_SIDE_EFFECTS__ */ function createSlotClone(ownerName: string) {\n const SlotClone = React.forwardRef<any, SlotCloneProps>((props, forwardedRef) => {\n const { children, ...slotProps } = props;\n\n if (React.isValidElement(children)) {\n const childrenRef = getElementRef(children);\n const props = mergeProps(slotProps, children.props as AnyProps);\n // do not pass ref to React.Fragment for React 19 compatibility\n if (children.type !== React.Fragment) {\n props.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;\n }\n return React.cloneElement(children, props);\n }\n\n return React.Children.count(children) > 1 ? React.Children.only(null) : null;\n });\n\n SlotClone.displayName = `${ownerName}.SlotClone`;\n return SlotClone;\n}\n\n/* -------------------------------------------------------------------------------------------------\n * Slottable\n * -----------------------------------------------------------------------------------------------*/\n\nconst SLOTTABLE_IDENTIFIER = Symbol('radix.slottable');\n\ninterface SlottableProps {\n children: React.ReactNode;\n}\n\ninterface SlottableComponent extends React.FC<SlottableProps> {\n __radixId: symbol;\n}\n\n/* @__NO_SIDE_EFFECTS__ */ export function createSlottable(ownerName: string) {\n const Slottable: SlottableComponent = ({ children }) => {\n return <>{children}</>;\n };\n Slottable.displayName = `${ownerName}.Slottable`;\n Slottable.__radixId = SLOTTABLE_IDENTIFIER;\n return Slottable;\n}\n\nconst Slottable = createSlottable('Slottable');\n\n/* ---------------------------------------------------------------------------------------------- */\n\ntype AnyProps = Record<string, any>;\n\nfunction isSlottable(\n child: React.ReactNode\n): child is React.ReactElement<SlottableProps, typeof Slottable> {\n return (\n React.isValidElement(child) &&\n typeof child.type === 'function' &&\n '__radixId' in child.type &&\n child.type.__radixId === SLOTTABLE_IDENTIFIER\n );\n}\n\nfunction mergeProps(slotProps: AnyProps, childProps: AnyProps) {\n // all child props should override\n const overrideProps = { ...childProps };\n\n for (const propName in childProps) {\n const slotPropValue = slotProps[propName];\n const childPropValue = childProps[propName];\n\n const isHandler = /^on[A-Z]/.test(propName);\n if (isHandler) {\n // if the handler exists on both, we compose them\n if (slotPropValue && childPropValue) {\n overrideProps[propName] = (...args: unknown[]) => {\n const result = childPropValue(...args);\n slotPropValue(...args);\n return result;\n };\n }\n // but if it exists only on the slot, we use only this one\n else if (slotPropValue) {\n overrideProps[propName] = slotPropValue;\n }\n }\n // if it's `style`, we merge them\n else if (propName === 'style') {\n overrideProps[propName] = { ...slotPropValue, ...childPropValue };\n } else if (propName === 'className') {\n overrideProps[propName] = [slotPropValue, childPropValue].filter(Boolean).join(' ');\n }\n }\n\n return { ...slotProps, ...overrideProps };\n}\n\n// Before React 19 accessing `element.props.ref` will throw a warning and suggest using `element.ref`\n// After React 19 accessing `element.ref` does the opposite.\n// https://github.com/facebook/react/pull/28348\n//\n// Access the ref using the method that doesn't yield a warning.\nfunction getElementRef(element: React.ReactElement) {\n // React <=18 in DEV\n let getter = Object.getOwnPropertyDescriptor(element.props, 'ref')?.get;\n let mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning;\n if (mayWarn) {\n return (element as any).ref;\n }\n\n // React 19 in DEV\n getter = Object.getOwnPropertyDescriptor(element, 'ref')?.get;\n mayWarn = getter && 'isReactWarning' in getter && getter.isReactWarning;\n if (mayWarn) {\n return (element.props as { ref?: React.Ref<unknown> }).ref;\n }\n\n // Not DEV\n return (element.props as { ref?: React.Ref<unknown> }).ref || (element as any).ref;\n}\n\nexport {\n Slot,\n Slottable,\n //\n Slot as Root,\n};\nexport type { SlotProps };\n","import * as React from 'react';\n\ntype PossibleRef<T> = React.Ref<T> | undefined;\n\n/**\n * Set a given ref to a given value\n * This utility takes care of different types of refs: callback refs and RefObject(s)\n */\nfunction setRef<T>(ref: PossibleRef<T>, value: T) {\n if (typeof ref === 'function') {\n return ref(value);\n } else if (ref !== null && ref !== undefined) {\n ref.current = value;\n }\n}\n\n/**\n * A utility to compose multiple refs together\n * Accepts callback refs and RefObject(s)\n */\nfunction composeRefs<T>(...refs: PossibleRef<T>[]): React.RefCallback<T> {\n return (node) => {\n let hasCleanup = false;\n const cleanups = refs.map((ref) => {\n const cleanup = setRef(ref, node);\n if (!hasCleanup && typeof cleanup == 'function') {\n hasCleanup = true;\n }\n return cleanup;\n });\n\n // React <19 will log an error to the console if a callback ref returns a\n // value. We don't use ref cleanups internally so this will only happen if a\n // user's ref callback returns a value, which we only expect if they are\n // using the cleanup functionality added in React 19.\n if (hasCleanup) {\n return () => {\n for (let i = 0; i < cleanups.length; i++) {\n const cleanup = cleanups[i];\n if (typeof cleanup == 'function') {\n cleanup();\n } else {\n setRef(refs[i], null);\n }\n }\n };\n }\n };\n}\n\n/**\n * A custom hook that composes multiple refs\n * Accepts callback refs and RefObject(s)\n */\nfunction useComposedRefs<T>(...refs: PossibleRef<T>[]): React.RefCallback<T> {\n // eslint-disable-next-line react-hooks/exhaustive-deps\n return React.useCallback(composeRefs(...refs), refs);\n}\n\nexport { composeRefs, useComposedRefs };\n","import * as React from \"react\";\r\nimport { Slot } from \"@radix-ui/react-slot\";\r\nimport { cva, type VariantProps } from \"class-variance-authority\";\r\n\r\nimport { cn } from \"../../lib/utils\";\r\n\r\nconst buttonVariants = cva(\r\n \"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive\",\r\n {\r\n variants: {\r\n variant: {\r\n default:\r\n \"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90\",\r\n destructive:\r\n \"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60\",\r\n outline:\r\n \"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50\",\r\n secondary:\r\n \"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80\",\r\n ghost:\r\n \"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50\",\r\n link: \"text-primary underline-offset-4 hover:underline\",\r\n },\r\n size: {\r\n default: \"h-9 px-4 py-2 has-[>svg]:px-3\",\r\n sm: \"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5\",\r\n lg: \"h-10 rounded-md px-6 has-[>svg]:px-4\",\r\n icon: \"size-9\",\r\n },\r\n },\r\n defaultVariants: {\r\n variant: \"default\",\r\n size: \"default\",\r\n },\r\n },\r\n);\r\n\r\nfunction Button({\r\n className,\r\n variant,\r\n size,\r\n asChild = false,\r\n ...props\r\n}: React.ComponentProps<\"button\"> &\r\n VariantProps<typeof buttonVariants> & {\r\n asChild?: boolean;\r\n }) {\r\n const Comp = asChild ? Slot : \"button\";\r\n\r\n return (\r\n <Comp\r\n data-slot=\"button\"\r\n className={cn(buttonVariants({ variant, size, className }))}\r\n {...props}\r\n />\r\n );\r\n}\r\n\r\nexport { Button, buttonVariants };\r\n","import * as React from \"react\";\r\n\r\nimport { cn } from \"../../lib/utils\";\r\n\r\nfunction Textarea({ className, ...props }: React.ComponentProps<\"textarea\">) {\r\n return (\r\n <textarea\r\n data-slot=\"textarea\"\r\n className={cn(\r\n \"wrap-break-word break-normal border-input placeholder:text-muted-foreground aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive dark:bg-input/30 flex field-sizing-content min-h-16 w-full rounded-md border bg-transparent px-3 py-2 text-base transition-[color,box-shadow] outline-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm\",\r\n className,\r\n )}\r\n {...props}\r\n />\r\n );\r\n}\r\n\r\nexport { Textarea };\r\n","\"use client\";\n\nimport { MessageCircleMore } from \"lucide-react\";\nimport type { ChatBotViewProps } from \"../../chat-bots/chat-bot\";\nimport { ChatBotShell, sharedAssistantIcons } from \"./chat-bot-shell\";\n\nexport default function ChatBotModern(props: ChatBotViewProps) {\n return (\n <ChatBotShell\n {...props}\n theme={{\n title: \"Modern assistant\",\n subtitle: \"Fast answers with a polished feel\",\n busyLabel: \"Composing a response\",\n placeholder: \"Type your message…\",\n launchIcon: MessageCircleMore,\n assistantIcon: sharedAssistantIcons.bot,\n launchButtonClassName:\n \"fixed bottom-6 right-6 z-50 size-14 rounded-full border border-white/20 bg-gradient-to-br from-cyan-500 via-blue-500 to-violet-600 text-white shadow-[0_24px_50px_-18px_rgba(59,130,246,0.85)] transition-all hover:-translate-y-1 hover:shadow-[0_28px_60px_-18px_rgba(99,102,241,0.75)]\",\n windowClassName:\n \"fixed bottom-4 left-4 right-4 z-50 flex h-[min(44rem,80vh)] flex-col overflow-hidden rounded-[30px] border border-slate-700/70 bg-slate-950 text-white shadow-[0_35px_90px_-30px_rgba(15,23,42,0.95)] sm:left-auto sm:right-6 sm:w-[420px]\",\n headerClassName:\n \"flex items-center justify-between border-b border-white/10 bg-gradient-to-r from-slate-950 via-slate-900 to-slate-950 px-5 py-4\",\n headerIconClassName:\n \"flex size-11 items-center justify-center rounded-2xl bg-gradient-to-br from-cyan-400/25 to-violet-500/25 text-cyan-100 ring-1 ring-white/10\",\n titleClassName: \"text-sm font-semibold text-white\",\n subtitleClassName: \"text-xs text-slate-300\",\n statusDotClassName:\n \"size-2 rounded-full bg-cyan-400 shadow-[0_0_12px_rgba(34,211,238,0.8)]\",\n closeButtonClassName:\n \"size-8 rounded-full text-slate-400 hover:bg-white/10 hover:text-white\",\n messagesClassName:\n \"flex-1 space-y-4 overflow-y-auto bg-[radial-gradient(circle_at_top,_rgba(56,189,248,0.14),_transparent_35%),linear-gradient(180deg,_#020617_0%,_#0f172a_55%,_#111827_100%)] px-5 py-5\",\n assistantAvatarClassName:\n \"flex size-8 shrink-0 items-center justify-center rounded-full bg-slate-900 text-cyan-200 ring-1 ring-cyan-400/20\",\n assistantBubbleClassName:\n \"border border-white/10 bg-white/8 text-slate-100 backdrop-blur-sm\",\n userAvatarClassName:\n \"flex h-8 items-center rounded-full bg-white/10 px-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-slate-200 ring-1 ring-white/10\",\n userBubbleClassName:\n \"bg-gradient-to-br from-cyan-500 to-violet-600 text-white shadow-[0_14px_30px_-18px_rgba(34,211,238,0.9)]\",\n composerClassName:\n \"border-t border-white/10 bg-slate-950/95 p-4 backdrop-blur-xl\",\n textareaClassName:\n \"min-h-[64px] rounded-2xl border-white/10 bg-white/5 pr-14 text-white placeholder:text-slate-400 focus-visible:ring-cyan-400/40\",\n helperTextClassName: \"mt-2 text-[11px] text-slate-500\",\n sendButtonClassName:\n \"absolute bottom-3 right-3 size-10 rounded-xl bg-gradient-to-br from-cyan-400 to-violet-500 text-white hover:from-cyan-300 hover:to-violet-400\",\n typingBubbleClassName:\n \"rounded-[22px] border border-white/10 bg-white/8 px-4 py-3 backdrop-blur-sm\",\n typingDotClassName: \"bg-cyan-300\",\n }}\n />\n );\n}","\"use client\";\n\nimport { SmilePlus } from \"lucide-react\";\nimport type { ChatBotViewProps } from \"../../chat-bots/chat-bot\";\nimport { ChatBotShell, sharedAssistantIcons } from \"./chat-bot-shell\";\n\nexport default function ChatBotPlayful(props: ChatBotViewProps) {\n return (\n <ChatBotShell\n {...props}\n theme={{\n title: \"Playful assistant\",\n subtitle: \"Bright, friendly, and upbeat\",\n busyLabel: \"Dreaming up something fun\",\n placeholder: \"Say hi, brainstorm, or ask anything ✨\",\n launchIcon: SmilePlus,\n assistantIcon: sharedAssistantIcons.sparkles,\n launchButtonClassName:\n \"fixed bottom-6 right-6 z-50 size-14 rounded-[22px] border-2 border-white/70 bg-[linear-gradient(135deg,_#f472b6_0%,_#f59e0b_100%)] text-white shadow-[0_24px_50px_-18px_rgba(244,114,182,0.75)] transition-all hover:-translate-y-1 hover:rotate-3\",\n windowClassName:\n \"fixed bottom-4 left-4 right-4 z-50 flex h-[min(44rem,80vh)] flex-col overflow-hidden rounded-[32px] border-2 border-rose-200 bg-[linear-gradient(180deg,_#fff7ed_0%,_#fff1f2_45%,_#fdf2f8_100%)] shadow-[0_35px_90px_-32px_rgba(244,114,182,0.55)] sm:left-auto sm:right-6 sm:w-[410px]\",\n headerClassName:\n \"flex items-center justify-between border-b border-rose-200/70 bg-white/60 px-5 py-4 backdrop-blur\",\n headerIconClassName:\n \"flex size-11 items-center justify-center rounded-[18px] bg-[linear-gradient(135deg,_#f472b6_0%,_#fb7185_50%,_#f59e0b_100%)] text-white shadow-md\",\n titleClassName: \"text-sm font-semibold text-rose-950\",\n subtitleClassName: \"text-xs text-rose-700/80\",\n statusDotClassName:\n \"size-2 rounded-full bg-emerald-500 shadow-[0_0_12px_rgba(16,185,129,0.55)]\",\n closeButtonClassName:\n \"size-8 rounded-full text-rose-500 hover:bg-white/80 hover:text-rose-700\",\n messagesClassName:\n \"flex-1 space-y-4 overflow-y-auto bg-[radial-gradient(circle_at_top_left,_rgba(253,186,116,0.35),_transparent_30%),radial-gradient(circle_at_top_right,_rgba(244,114,182,0.22),_transparent_28%),linear-gradient(180deg,_rgba(255,255,255,0.8),_rgba(255,241,242,0.65))] px-5 py-5\",\n assistantAvatarClassName:\n \"flex size-8 shrink-0 items-center justify-center rounded-full bg-white text-rose-500 ring-2 ring-rose-100 shadow-sm\",\n assistantBubbleClassName:\n \"border border-rose-100 bg-white/95 text-rose-950\",\n userAvatarClassName:\n \"flex h-8 items-center rounded-full bg-amber-300/80 px-2 text-[10px] font-semibold uppercase tracking-[0.18em] text-amber-950 ring-1 ring-amber-400/50\",\n userBubbleClassName:\n \"bg-[linear-gradient(135deg,_#f472b6_0%,_#fb7185_55%,_#f59e0b_100%)] text-white shadow-[0_16px_32px_-18px_rgba(244,114,182,0.7)]\",\n composerClassName:\n \"border-t border-rose-200/70 bg-white/70 p-4 backdrop-blur\",\n textareaClassName:\n \"min-h-[64px] rounded-[24px] border-rose-200 bg-white/90 pr-14 text-rose-950 placeholder:text-rose-300 focus-visible:ring-rose-300\",\n helperTextClassName: \"mt-2 text-[11px] text-rose-400\",\n sendButtonClassName:\n \"absolute bottom-3 right-3 size-10 rounded-2xl bg-[linear-gradient(135deg,_#fb7185_0%,_#f59e0b_100%)] text-white hover:brightness-105\",\n typingBubbleClassName:\n \"rounded-[22px] border border-rose-100 bg-white/90 px-4 py-3 shadow-sm\",\n typingDotClassName: \"bg-rose-400\",\n }}\n />\n );\n}","import z from \"zod\";\r\n\r\nexport const messageSchema = z.object({\r\n role: z.enum([\"user\", \"assistant\"]),\r\n content: z.string(),\r\n});\r\n\r\nexport const chatRequestSchema = z.object({\r\n messages: z.array(messageSchema).min(1),\r\n});\r\n\r\nexport const chatResponseSchema = z.object({\r\n message: messageSchema,\r\n});\r\n","import type {\n ChatBotAdapter,\n ChatBotRequest,\n CreateFetchAdapterOptions,\n} from \"../chat-bot\";\nimport { chatRequestSchema, chatResponseSchema } from \"../../lib/schema\";\n\nconst resolveHeaders = async (headers: CreateFetchAdapterOptions[\"headers\"]) => {\n if (typeof headers === \"function\") {\n return await headers();\n }\n\n return headers;\n};\n\nexport const createFetchAdapter = ({\n apiUrl,\n fetch: fetchImplementation = globalThis.fetch,\n headers,\n}: CreateFetchAdapterOptions): ChatBotAdapter => {\n if (!apiUrl) {\n throw new Error(\"apiUrl is required\");\n }\n\n return {\n async sendMessage(messages) {\n if (typeof fetchImplementation !== \"function\") {\n throw new Error(\"Fetch API is not available. Provide a fetch implementation.\");\n }\n\n const requestPayload: ChatBotRequest = { messages };\n const parsedRequest = chatRequestSchema.safeParse(requestPayload);\n\n if (!parsedRequest.success) {\n throw new Error(\"Invalid chat request payload.\");\n }\n\n const requestHeaders = new Headers(await resolveHeaders(headers));\n if (!requestHeaders.has(\"Content-Type\")) {\n requestHeaders.set(\"Content-Type\", \"application/json\");\n }\n\n const response = await fetchImplementation(apiUrl, {\n method: \"POST\",\n headers: requestHeaders,\n body: JSON.stringify(parsedRequest.data),\n });\n\n if (!response.ok) {\n const statusText = response.statusText ? ` ${response.statusText}` : \"\";\n throw new Error(`Chat request failed with ${response.status}${statusText}`);\n }\n\n const responseJson = await response.json();\n const parsedResponse = chatResponseSchema.safeParse(responseJson);\n\n if (!parsedResponse.success) {\n throw new Error(\"Invalid chat response payload.\");\n }\n\n return parsedResponse.data.message;\n },\n };\n};"],"mappings":"AAEA,OAAS,YAAAA,MAAgB,QCFzB,OAAgB,iBAAAC,EAAe,cAAAC,MAAkB,QAgBxC,cAAAC,MAAA,oBANT,IAAMC,EAAiBH,EAAoC,IAAI,EAElDI,EAAkB,CAAC,CAC9B,OAAAC,EACA,SAAAC,CACF,IACSJ,EAACC,EAAe,SAAf,CAAwB,MAAOE,EAAS,SAAAC,EAAS,EAG9CC,EAAcH,EAEdI,EAA2B,IAC/BP,EAAWE,CAAc,EAGrBM,EAAmB,IAAqB,CACnD,IAAMC,EAAUF,EAAyB,EACzC,GAAI,CAACE,EACH,MAAM,IAAI,MACR,qEACF,EAGF,OAAOA,CACT,EAEaC,EAAeF,EClC5B,OAAS,iBAAAG,OAAqB,eCA9B,OAAS,OAAAC,EAAK,QAAAC,GAAM,YAAAC,GAAU,KAAAC,OAA0B,eACxD,OAAS,aAAAC,GAAW,UAAAC,GAAQ,YAAAC,OAAoC,QCHhE,SAASC,EAAE,EAAE,CAAC,IAAI,EAAEC,EAAEC,EAAE,GAAG,GAAa,OAAO,GAAjB,UAA8B,OAAO,GAAjB,SAAmBA,GAAG,UAAoB,OAAO,GAAjB,SAAmB,GAAG,MAAM,QAAQ,CAAC,EAAE,CAAC,IAAIC,EAAE,EAAE,OAAO,IAAI,EAAE,EAAE,EAAEA,EAAE,IAAI,EAAE,CAAC,IAAIF,EAAED,EAAE,EAAE,CAAC,CAAC,KAAKE,IAAIA,GAAG,KAAKA,GAAGD,EAAE,KAAM,KAAIA,KAAK,EAAE,EAAEA,CAAC,IAAIC,IAAIA,GAAG,KAAKA,GAAGD,GAAG,OAAOC,CAAC,CA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BAAqB,0BACrB,kBACE,6DACF,kBACE,0GACF,oBAAqB,kCACrB,oBACE,0FACF,sBACE,oEACF,mBAAoB,cACtB,EACF,CAEJ,CQlDA,OAAS,qBAAAC,OAAyB,eAM9B,cAAAC,OAAA,oBAFW,SAARC,EAA+BC,EAAyB,CAC7D,OACEF,GAACG,EAAA,CACE,GAAGD,EACJ,MAAO,CACL,MAAO,mBACP,SAAU,oCACV,UAAW,uBACX,YAAa,0BACb,WAAYE,GACZ,cAAeC,EAAqB,IACpC,sBACE,4RACF,gBACE,6OACF,gBACE,kIACF,oBACE,8IACF,eAAgB,mCAChB,kBAAmB,yBACnB,mBACE,yEACF,qBACE,wEACF,kBACE,wLACF,yBACE,mHACF,yBACE,oEACF,oBACE,gJACF,oBACE,2GACF,kBACE,gEACF,kBACE,iIACF,oBAAqB,kCACrB,oBACE,gJACF,sBACE,8EACF,mBAAoB,aACtB,EACF,CAEJ,CCpDA,OAAS,aAAAC,OAAiB,eAMtB,cAAAC,OAAA,oBAFW,SAARC,EAAgCC,EAAyB,CAC9D,OACEF,GAACG,EAAA,CACE,GAAGD,EACJ,MAAO,CACL,MAAO,oBACP,SAAU,+BACV,UAAW,4BACX,YAAa,6CACb,WAAYE,GACZ,cAAeC,EAAqB,SACpC,sBACE,qPACF,gBACE,0RACF,gBACE,oGACF,oBACE,mJACF,eAAgB,sCAChB,kBAAmB,2BACnB,mBACE,6EACF,qBACE,0EACF,kBACE,oRACF,yBACE,sHACF,yBACE,mDACF,oBACE,wJACF,oBACE,kIACF,kBACE,4DACF,kBACE,oIACF,oBAAqB,iCACrB,oBACE,uIACF,sBACE,wEACF,mBAAoB,aACtB,EACF,CAEJ,CXkBQ,cAAAC,MAAA,oBA5DR,IAAMC,GACJ,4DACIC,GACJ,2DAEa,SAARC,EAAyB,CAC9B,MAAAC,EACA,QAASC,EACT,eAAAC,EAAiBL,GACjB,aAAcM,EAAmBL,EACnC,EAAiB,CACf,IAAMM,EAASC,EAAyB,EAClCC,EAAU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,CACxC,SAAUA,EAAE,MAAMC,CAAa,EAAE,IAAI,CAAC,CACxC,CAAC,EAEYE,EAAqBH,EAAE,OAAO,CACzC,QAASC,CACX,CAAC,ECND,IAAMG,GAAiB,MAAOC,GACxB,OAAOA,GAAY,WACd,MAAMA,EAAQ,EAGhBA,EAGIC,EAAqB,CAAC,CACjC,OAAAC,EACA,MAAOC,EAAsB,WAAW,MACxC,QAAAH,CACF,IAAiD,CAC/C,GAAI,CAACE,EACH,MAAM,IAAI,MAAM,oBAAoB,EAGtC,MAAO,CACL,MAAM,YAAYE,EAAU,CAC1B,GAAI,OAAOD,GAAwB,WACjC,MAAM,IAAI,MAAM,6DAA6D,EAG/E,IAAME,EAAiC,CAAE,SAAAD,CAAS,EAC5CE,EAAgBC,EAAkB,UAAUF,CAAc,EAEhE,GAAI,CAACC,EAAc,QACjB,MAAM,IAAI,MAAM,+BAA+B,EAGjD,IAAME,EAAiB,IAAI,QAAQ,MAAMT,GAAeC,CAAO,CAAC,EAC3DQ,EAAe,IAAI,cAAc,GACpCA,EAAe,IAAI,eAAgB,kBAAkB,EAGvD,IAAMC,EAAW,MAAMN,EAAoBD,EAAQ,CACjD,OAAQ,OACR,QAASM,EACT,KAAM,KAAK,UAAUF,EAAc,IAAI,CACzC,CAAC,EAED,GAAI,CAACG,EAAS,GAAI,CAChB,IAAMC,EAAaD,EAAS,WAAa,IAAIA,EAAS,UAAU,GAAK,GACrE,MAAM,IAAI,MAAM,4BAA4BA,EAAS,MAAM,GAAGC,CAAU,EAAE,CAC5E,CAEA,IAAMC,EAAe,MAAMF,EAAS,KAAK,EACnCG,EAAiBC,EAAmB,UAAUF,CAAY,EAEhE,GAAI,CAACC,EAAe,QAClB,MAAM,IAAI,MAAM,gCAAgC,EAGlD,OAAOA,EAAe,KAAK,OAC7B,CACF,CACF","names":["useState","createContext","useContext","jsx","ChatBotContext","ChatBotProvider","config","children","ApiProvider","useOptionalChatBotConfig","useChatBotConfig","context","useApiConfig","MessageCircle","Bot","Send","Sparkles","X","useEffect","useRef","useState","r","f","n","o","clsx","twMerge","cn","inputs","clsx","React","React","setRef","ref","value","composeRefs","refs","node","hasCleanup","cleanups","cleanup","i","Fragment","jsx","createSlot","ownerName","SlotClone","createSlotClone","Slot","props","forwardedRef","children","slotProps","childrenArray","slottable","isSlottable","newElement","newChildren","child","childrenRef","getElementRef","mergeProps","composeRefs","SLOTTABLE_IDENTIFIER","isSlottable","child","SLOTTABLE_IDENTIFIER","mergeProps","slotProps","childProps","overrideProps","propName","slotPropValue","childPropValue","args","result","getElementRef","element","getter","mayWarn","cva","jsx","buttonVariants","cva","Button","className","variant","size","asChild","props","Slot","cn","jsx","Textarea","className","props","cn","Fragment","jsx","jsxs","ChatBotShell","theme","messages","handleSendMessage","isOpen","isSending","setIsOpen","inputValue","setInputValue","useState","messagesEndRef","useRef","canSend","LaunchIcon","AssistantIcon","useEffect","submitMessage","nextMessage","handleKeyPress","event","Button","X","message","index","isUser","cn","Bot","dot","Textarea","Send","sharedAssistantIcons","Sparkles","jsx","ChatBotMinimal","props","ChatBotShell","MessageCircle","sharedAssistantIcons","MessageCircleMore","jsx","ChatBotModern","props","ChatBotShell","MessageCircleMore","sharedAssistantIcons","SmilePlus","jsx","ChatBotPlayful","props","ChatBotShell","SmilePlus","sharedAssistantIcons","jsx","DEFAULT_WELCOME_MESSAGE","DEFAULT_ERROR_MESSAGE","ChatBot","style","adapterProp","welcomeMessage","errorMessageText","config","useOptionalChatBotConfig","adapter","isOpen","setIsOpen","useState","isSending","setIsSending","messages","setMessages","handleSendMessage","inputValue","userMessage","updatedMessages","response","prev","errorMessage","ChatBotModern","ChatBotPlayful","ChatBotMinimal","z","messageSchema","chatRequestSchema","chatResponseSchema","resolveHeaders","headers","createFetchAdapter","apiUrl","fetchImplementation","messages","requestPayload","parsedRequest","chatRequestSchema","requestHeaders","response","statusText","responseJson","parsedResponse","chatResponseSchema"]}
|