@nameless26/widget 0.1.0 → 0.1.2

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.js CHANGED
@@ -1,22 +1,60 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),o=require("react");function R(t){return`nexus_widget_session_${t}`}function H(t){const r=sessionStorage.getItem(R(t));if(r)return r;const n=crypto.randomUUID();return sessionStorage.setItem(R(t),n),n}async function*W(t,r){const n=new TextDecoder;let u="";try{for(;;){if(r.aborted)return;const{done:a,value:x}=await t.read();if(a)return;u+=n.decode(x,{stream:!0});const c=u.split(`
2
-
3
- `);u=c.pop()??"";for(const y of c)for(const b of y.split(`
4
- `)){if(!b.startsWith("data: "))continue;const d=b.slice(6).trim();try{yield JSON.parse(d)}catch{}}}}finally{t.releaseLock()}}function D({agentId:t,baseUrl:r="http://localhost:8000/api",endUserId:n}){const[u,a]=o.useState([]),[x,c]=o.useState(!1),[y,b]=o.useState(!0),[d,h]=o.useState(null),[v,p]=o.useState(null),[m,k]=o.useState(null),s=o.useRef(H(t)),w=o.useRef(null),T=o.useCallback(async()=>{var N;(N=w.current)==null||N.abort(),b(!0),h(null);const i=new AbortController;w.current=i;try{const f=await fetch(`${r}/widget/session`,{method:"POST",signal:i.signal,headers:{"Content-Type":"application/json"},body:JSON.stringify({agentId:t,sessionId:s.current})});if(!f.ok)throw new Error(`HTTP ${f.status}`);const j=await f.json();k(j.token);const S=await fetch(`${r}/chat/history`,{method:"POST",signal:i.signal,headers:{"Content-Type":"application/json",Authorization:`Bearer ${j.token}`},body:JSON.stringify({agentId:t,sessionId:s.current})});if(!S.ok)throw new Error(`HTTP ${S.status}`);const l=await S.json();a(l.messages??[]),p(l.conversationId??null)}catch(f){(f==null?void 0:f.name)!=="AbortError"&&h("Unable to initialize widget session.")}finally{b(!1)}},[t]);o.useEffect(()=>(T(),()=>{var i;(i=w.current)==null||i.abort()}),[T]);const O=o.useCallback(()=>{var i;(i=w.current)==null||i.abort(),c(!1)},[]),P=o.useCallback(()=>{var i;(i=w.current)==null||i.abort(),a([]),p(null),h(null),c(!1),s.current=crypto.randomUUID(),k(null),T()},[T]),E=o.useCallback(async i=>{var S;if(!i.trim()||x||!m)return;(S=w.current)==null||S.abort();const N=new AbortController;w.current=N,h(null);const f=`u_${Date.now()}`,j=`a_${Date.now()}`;a(l=>[...l,{id:f,role:"user",content:i.trim()}]),c(!0);try{const l=await fetch(`${r}/chat`,{method:"POST",signal:N.signal,headers:{"Content-Type":"application/json",Authorization:`Bearer ${m}`},body:JSON.stringify({agent_id:t,message:i.trim(),session_id:s.current,end_user_id:n})});if(!l.ok||!l.body)throw new Error(`HTTP ${l.status}`);a(g=>[...g,{id:j,role:"assistant",content:""}]);const $=l.body.getReader();for await(const g of W($,N.signal))switch(g.type){case"start":p(g.conversationId);break;case"token":a(I=>I.map(C=>C.id===j?{...C,content:C.content+g.content}:C));break;case"done":break;case"error":h(g.message),a(I=>I.filter(C=>C.id!==j));break}}catch(l){if((l==null?void 0:l.name)==="AbortError")return;h("Something went wrong. Please try again."),a($=>$.filter(g=>g.id!==f&&g.id!==j))}finally{c(!1)}},[t,n,x,m]);return{messages:u,isLoading:x,historyLoading:y,error:d,conversationId:v,send:E,reset:P,cancel:O}}function _({color:t}){return e.jsx("div",{className:`flex items-end gap-1 px-3 py-2.5 rounded-2xl rounded-bl-sm w-fit\r
5
- bg-[rgba(255,255,255,0.06)]`,children:[0,1,2].map(r=>e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:t,opacity:.6,animation:`nexusBounce 1.2s ease-in-out ${r*.2}s infinite`}},r))})}function z({msg:t,primaryColor:r}){const n=t.role==="user";return e.jsx("div",{className:`flex ${n?"justify-end":"justify-start"}`,children:e.jsx("div",{style:n?{background:r}:void 0,className:`max-w-[82%] px-3 py-2.5 rounded-2xl text-sm leading-relaxed
6
- ${n?"text-white rounded-br-sm":"bg-[rgba(255,255,255,0.06)] text-[rgba(255,255,255,0.8)] rounded-bl-sm"}`,children:t.content})})}function B({agentName:t,messages:r,isLoading:n,error:u,primaryColor:a,welcomeMessage:x,onSend:c,onReset:y,onClose:b}){const[d,h]=o.useState(""),v=o.useRef(null),p=o.useRef(null);o.useEffect(()=>{var s;(s=v.current)==null||s.scrollIntoView({behavior:"smooth"})},[r,n]),o.useEffect(()=>{var s;(s=p.current)==null||s.focus()},[]);const m=()=>{!d.trim()||n||(c(d),h(""))},k=s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),m())};return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),s=require("react");function W({color:t}){return e.jsx("div",{style:{background:"var(--nx-surface)"},className:`flex items-end gap-1 px-3 py-2.5 rounded-2xl rounded-bl-sm w-fit\r
2
+ bg-[rgba(255,255,255,0.06)]`,children:[0,1,2].map(o=>e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:t,opacity:.6,animation:`nexusBounce 1.2s ease-in-out ${o*.2}s infinite`}},o))})}function z({msg:t,primaryColor:o}){const n=t.role==="user";return t.content?e.jsx("div",{className:`flex ${n?"justify-end":"justify-start"}`,children:e.jsx("div",{style:n?{background:o}:{background:"var(--nx-surface)",color:"var(--nx-text)"},className:`max-w-[82%] px-3 py-2.5 rounded-2xl text-sm leading-relaxed
3
+ ${n?"text-white rounded-br-sm":"bg-[rgba(255,255,255,0.06)] text-[rgba(255,255,255,0.8)] rounded-bl-sm"}`,children:t.content})}):e.jsx(e.Fragment,{})}function L({agentName:t,messages:o,isLoading:n,error:f,primaryColor:u,welcomeMessage:l,onSend:b,onClose:c,isFullView:r,onToggleFullView:g}){const[x,d]=s.useState(""),N=s.useRef(null),p=s.useRef(null);s.useEffect(()=>{N.current?.scrollIntoView({behavior:"smooth"})},[o,n]),s.useEffect(()=>{p.current?.focus()},[]);const j=()=>{!x.trim()||n||(b(x),d(""))},C=a=>{a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),j())};return e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
7
4
  @keyframes nexusBounce {
8
5
  0%, 80%, 100% { transform: translateY(0); }
9
6
  40% { transform: translateY(-5px); }
10
7
  }
11
- `}),e.jsxs("div",{style:{fontFamily:"system-ui, -apple-system, sans-serif"},className:`flex flex-col overflow-hidden rounded-2xl shadow-2xl\r
12
- border border-[rgba(255,255,255,0.08)]`,role:"dialog","aria-label":`${t} chat`,children:[e.jsxs("div",{style:{background:a},className:"flex items-center justify-between px-4 py-3 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-white/40"}),e.jsx("span",{className:"text-white text-sm font-medium",children:t})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:y,"aria-label":"Start new conversation",className:`p-1.5 rounded-full text-white/60 hover:text-white\r
13
- hover:bg-white/15 transition-colors`,children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[e.jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),e.jsx("path",{d:"M3 3v5h5"})]})}),e.jsx("button",{onClick:b,"aria-label":"Close chat",className:`p-1.5 rounded-full text-white/60 hover:text-white\r
14
- hover:bg-white/15 transition-colors`,children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M18 6 6 18M6 6l12 12"})})})]})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-4 space-y-3 bg-[#0d0d1a]",style:{minHeight:0},children:[r.length===0&&e.jsx("div",{className:"flex justify-start",children:e.jsx("div",{className:`max-w-[82%] px-3 py-2.5 rounded-2xl rounded-bl-sm\r
15
- bg-[rgba(255,255,255,0.06)] text-sm\r
16
- text-[rgba(255,255,255,0.8)] leading-relaxed`,children:x})}),r.map(s=>e.jsx(z,{msg:s,primaryColor:a},s.id)),n&&e.jsx("div",{className:"flex justify-start",children:e.jsx(_,{color:a})}),u&&e.jsx("div",{className:"text-center text-xs text-red-400/70 py-1",children:u}),e.jsx("div",{ref:v})]}),e.jsxs("div",{className:`px-3 py-3 bg-[#0d0d1a] border-t border-[rgba(255,255,255,0.06)]\r
17
- flex items-end gap-2 shrink-0`,children:[e.jsx("textarea",{ref:p,rows:1,value:d,onChange:s=>h(s.target.value),onKeyDown:k,placeholder:"Type a message…",disabled:n,style:{resize:"none",maxHeight:100,overflowY:"auto"},className:`flex-1 bg-[rgba(255,255,255,0.05)] border border-[rgba(255,255,255,0.08)]\r
18
- rounded-xl px-3 py-2.5 text-sm text-white/80 placeholder-white/25\r
19
- focus:outline-none focus:border-[rgba(255,255,255,0.18)]\r
20
- transition-colors disabled:opacity-40`}),e.jsx("button",{onClick:m,disabled:!d.trim()||n,"aria-label":"Send message",style:{background:d.trim()&&!n?a:void 0},className:`shrink-0 w-9 h-9 rounded-xl flex items-center justify-center\r
21
- bg-[rgba(255,255,255,0.08)] transition-colors\r
22
- disabled:opacity-40 disabled:cursor-not-allowed`,children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",strokeLinecap:"round",children:[e.jsx("path",{d:"m22 2-7 20-4-9-9-4Z"}),e.jsx("path",{d:"M22 2 11 13"})]})})]})]})]})}const M=o.forwardRef(({agentId:t,baseUrl:r,primaryColor:n="#6366f1",position:u="bottom-right",welcomeMessage:a="Hi! How can I help you today?",agentName:x="Assistant",endUserId:c},y)=>{const{messages:b,isLoading:d,historyLoading:h,error:v,conversationId:p,send:m,reset:k,cancel:s}=D({agentId:t,baseUrl:r,endUserId:c});return e.jsx("div",{ref:y,style:{position:"fixed",[u==="bottom-left"?"left":"right"]:"20px",bottom:"20px",zIndex:9999,fontFamily:"system-ui, -apple-system, sans-serif"},children:e.jsx(B,{agentName:x,messages:b,isLoading:d,error:v,primaryColor:n,welcomeMessage:a,onSend:m,onReset:k,onClose:s})})});M.displayName="NexusWidget";exports.NexusWidget=M;exports.useChat=D;
8
+ button {
9
+ cursor: pointer;
10
+ }
11
+ `}),e.jsxs("div",{style:{fontFamily:"system-ui, -apple-system, sans-serif",position:"relative",background:"var(--nx-bg)",borderColor:r?"none":"var(--nx-border)"},className:`flex flex-col overflow-hidden shadow-2xl h-full ${r?"":"rounded-2xl border"}`,role:"dialog","aria-label":`${t} chat`,children:[!r&&e.jsxs("div",{style:{background:"var(--nx-bg)",borderBottom:"1px solid var(--nx-border)"},className:"flex items-center justify-between px-4 py-3 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-[var(--nx-text)]/40"}),e.jsx("span",{style:{color:u},className:"text-sm font-medium",children:t})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:g,"aria-label":"Expand to full view",className:"nexus-ctrl-btn p-2",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"})})}),e.jsx("button",{onClick:c,"aria-label":"Close chat",className:"nexus-ctrl-btn p-2",children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M18 6 6 18M6 6l12 12"})})})]})]}),r&&e.jsxs("div",{className:"absolute top-4 right-4 flex items-center gap-2",style:{zIndex:10},children:[e.jsx("button",{onClick:g,"aria-label":"Exit full view",className:"nexus-ctrl-btn p-2",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3"})})}),e.jsx("button",{onClick:c,"aria-label":"Close chat",className:"nexus-ctrl-btn p-2",children:e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M18 6 6 18M6 6l12 12"})})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",style:{minHeight:0,background:"var(--nx-bg)"},children:e.jsxs("div",{className:"space-y-3 p-2",style:r?{maxWidth:720,margin:"0 auto"}:void 0,children:[o.length===0&&e.jsx("div",{className:"flex justify-start",children:e.jsx("div",{style:{background:"var(--nx-surface)",color:"var(--nx-text)"},className:"max-w-[82%] px-3 py-2.5 rounded-2xl rounded-bl-sm text-sm leading-relaxed",children:l})}),o.map(a=>e.jsx(z,{msg:a,primaryColor:u},a.id)),n&&e.jsx("div",{className:"flex justify-start",children:e.jsx(W,{color:u})}),f&&e.jsx("div",{className:"text-center text-xs text-red-400/70 py-1",children:f}),e.jsx("div",{ref:N})]})}),e.jsx("div",{style:{background:"var(--nx-bg)",borderColor:r?"none":"var(--nx-border)"},className:`${!r&&"border-t"} shrink-0 px-2.5`,children:e.jsxs("div",{className:"relative w-full mx-auto flex items-center shadow rounded-xl",style:{maxWidth:r?720:"none",marginBottom:r?20:12,marginTop:r?0:10},children:[e.jsx("textarea",{ref:p,rows:1,value:x,onChange:a=>{d(a.target.value),a.target.style.height="auto",a.target.style.height=`${Math.min(a.target.scrollHeight,100)}px`},onKeyDown:C,placeholder:"Type a message…",disabled:n,style:{resize:"none",minHeight:44,maxHeight:100,overflowY:"auto",paddingRight:52},className:`nexus-input w-full border rounded-xl px-3 py-2.5 text-sm\r
12
+ transition-colors disabled:opacity-40`}),e.jsx("button",{onClick:j,disabled:!x.trim()||n,"aria-label":"Send message",style:{position:"absolute",right:6,bottom:6,background:x.trim()&&!n?u:"var(--nx-surface)"},className:`w-8 h-8 rounded-lg flex items-center justify-center\r
13
+ transition-colors disabled:opacity-40\r
14
+ disabled:cursor-not-allowed`,children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:x.trim()&&!n?"white":"var(--nx-text-muted)",viewBox:"0 0 16 16",children:e.jsx("path",{fillRule:"evenodd",d:"M8 12a.5.5 0 0 0 .5-.5V5.707l2.146 2.147a.5.5 0 0 0 .708-.708l-3-3a.5.5 0 0 0-.708 0l-3 3a.5.5 0 1 0 .708.708L7.5 5.707V11.5a.5.5 0 0 0 .5.5"})})})]})})]})]})}function H(t){return`nexus_widget_session_${t}`}function A(t){const o=sessionStorage.getItem(H(t));if(o)return o;const n=crypto.randomUUID();return sessionStorage.setItem(H(t),n),n}async function*_(t,o){const n=new TextDecoder;let f="";try{for(;;){if(o.aborted)return;const{done:u,value:l}=await t.read();if(u)return;f+=n.decode(l,{stream:!0});const b=f.split(`
15
+
16
+ `);f=b.pop()??"";for(const c of b)for(const r of c.split(`
17
+ `)){if(!r.startsWith("data: "))continue;const g=r.slice(6).trim();try{yield JSON.parse(g)}catch{}}}}finally{t.releaseLock()}}function P({agentId:t,baseUrl:o,agentCoreUrl:n,endUserId:f}){const[u,l]=s.useState([]),[b,c]=s.useState(!1),[r,g]=s.useState(!0),[x,d]=s.useState(null),[N,p]=s.useState(null),[j,C]=s.useState(null),a=s.useRef(A(t)),m=s.useRef(null),S=s.useCallback(async()=>{m.current?.abort(),g(!0),d(null);const y=new AbortController;m.current=y;try{const i=await fetch(`${o}/widget/session`,{method:"POST",signal:y.signal,headers:{"Content-Type":"application/json"},body:JSON.stringify({agentId:t,sessionId:a.current})});if(!i.ok)throw new Error(`HTTP ${i.status}`);const k=await i.json();C(k.token);const v=await fetch(`${o}/chat/history`,{method:"POST",signal:y.signal,headers:{"Content-Type":"application/json",Authorization:`Bearer ${k.token}`},body:JSON.stringify({agentId:t,sessionId:a.current})});if(v.status==404){l([]),p(null);return}if(!v.ok)throw new Error(`HTTP ${v.status}`);const h=await v.json();l(h.messages??[]),p(h.conversationId??null)}catch(i){console.log(i),i.status!=404&&i?.name!=="AbortError"&&d("Error Loading History")}finally{g(!1)}},[t]);s.useEffect(()=>(S(),()=>{m.current?.abort()}),[S]);const M=s.useCallback(()=>{m.current?.abort(),c(!1)},[]),E=s.useCallback(()=>{m.current?.abort(),l([]),p(null),d(null),c(!1),a.current=crypto.randomUUID(),C(null),S()},[S]),T=s.useCallback(async y=>{if(!y.trim()||b||!j)return;m.current?.abort();const i=new AbortController;m.current=i,d(null);const k=`u_${Date.now()}`,v=`a_${Date.now()}`;l(h=>[...h,{id:k,role:"user",content:y.trim()}]),c(!0);try{const h=await fetch(`${n}/chat`,{method:"POST",signal:i.signal,headers:{"Content-Type":"application/json",Authorization:`Bearer ${j}`},body:JSON.stringify({agent_id:t,message:y.trim(),session_id:a.current})});if(!h.ok||!h.body)throw new Error(`HTTP ${h.status}`);l(w=>[...w,{id:v,role:"assistant",content:""}]);const $=h.body.getReader();for await(const w of _($,i.signal))switch(w.type){case"start":p(w.conversationId);break;case"token":l(I=>I.map(B=>B.id===v?{...B,content:B.content+w.content}:B));break;case"done":break;case"error":d(w.message),l(I=>I.filter(B=>B.id!==v));break}}catch(h){if(h?.name==="AbortError")return;d("Something went wrong. Please try again."),l($=>$.filter(w=>w.id!==k&&w.id!==v))}finally{c(!1)}},[t,f,b,j]);return{messages:u,isLoading:b,historyLoading:r,error:x,conversationId:N,send:T,reset:E,cancel:M}}const O={bg:"#0d0d1a",surface:"rgba(255,255,255,0.06)",border:"rgba(255,255,255,0.08)",text:"rgba(255,255,255,0.82)",textMuted:"rgba(255,255,255,0.25)",inputBg:"rgba(255,255,255,0.05)",inputBorder:"rgba(255,255,255,0.08)",inputBorderFocus:"rgba(255,255,255,0.20)",error:"rgba(248,113,113,0.75)"},D={bg:"#f8f9fb",surface:"rgba(0,0,0,0.055)",border:"rgba(0,0,0,0.09)",text:"rgba(0,0,0,0.82)",textMuted:"rgba(0,0,0,0.38)",inputBg:"rgba(0,0,0,0.04)",inputBorder:"rgba(0,0,0,0.10)",inputBorderFocus:"rgba(0,0,0,0.22)",error:"rgba(220,38,38,0.80)"};function R(t){return t==="system"?typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?O:D:t==="dark"?O:D}function U(t){return{"--nx-bg":t.bg,"--nx-surface":t.surface,"--nx-border":t.border,"--nx-text":t.text,"--nx-text-muted":t.textMuted,"--nx-input-bg":t.inputBg,"--nx-input-border":t.inputBorder,"--nx-input-border-focus":t.inputBorderFocus,"--nx-error":t.error}}function J({agentId:t,agentName:o,baseUrl:n,agentCoreUrl:f,primaryColor:u="#6366f1",welcomeMessage:l="Hi! How can I help you?",position:b="bottom-right",theme:c="dark"}){const[r,g]=s.useState(!1),[x,d]=s.useState(!1),[N,p]=s.useState(()=>R(c)),j=s.useRef(null),{messages:C,isLoading:a,error:m,send:S,reset:M,cancel:E}=P({agentId:t,baseUrl:n,agentCoreUrl:f}),T=b!=="bottom-left",y=()=>{E(),g(!1),d(!1)};return s.useEffect(()=>{if(p(R(c)),c!=="system")return;const i=window.matchMedia("(prefers-color-scheme: dark)"),k=()=>p(R("system"));return i.addEventListener("change",k),()=>i.removeEventListener("change",k)},[c]),e.jsxs(e.Fragment,{children:[e.jsx("style",{children:`
18
+ .nexus-bubble-btn {
19
+ transition: transform 0.2s ease, box-shadow 0.15s ease, opacity 0.18s ease;
20
+ }
21
+ .nexus-bubble-btn:hover {
22
+ transform: scale(1.07) !important;
23
+ box-shadow: 0 6px 28px rgba(0, 0, 0, 0.35) !important;
24
+ }
25
+ .nexus-bubble-btn:active { transform: scale(0.96) !important; }
26
+ .nexus-input::-webkit-scrollbar {
27
+ display: none;
28
+ }
29
+ .nexus-input {
30
+ background: var(--nx-input-bg);
31
+ border-color: var(--nx-input-border);
32
+ color: var(--nx-text);
33
+ width: 100%;
34
+ scrollbar-width: none;
35
+ -ms-overflow-style: none;
36
+ }
37
+ .nexus-input::placeholder { color: var(--nx-text-muted); }
38
+ .nexus-input:focus { border-color: var(--nx-input-border-focus); outline: none; }
39
+
40
+ .nexus-ctrl-btn {
41
+ color: var(--nx-text-muted);
42
+ transition: color 0.15s ease, background 0.15s ease;
43
+ border-radius: 50%;
44
+ }
45
+ .nexus-ctrl-btn:hover {
46
+ color: var(--nx-text);
47
+ background: var(--nx-surface);
48
+ }
49
+ `}),e.jsxs("div",{ref:j,style:{position:"fixed",inset:0,zIndex:9999,pointerEvents:"none",fontFamily:"system-ui, -apple-system, sans-serif",...U(N)},children:[e.jsx("div",{style:x?{position:"absolute",inset:0,opacity:1,pointerEvents:"auto",transition:"all 0.25s ease"}:r?{position:"absolute",[T?"right":"left"]:0,top:0,bottom:0,width:380,opacity:1,pointerEvents:"auto",transition:"all 0.28s cubic-bezier(0.34, 1.45, 0.64, 1)"}:{position:"absolute",[T?"right":"left"]:20,bottom:88,width:420,height:"calc(100vh - 108px)",border:"1px solid var(--nx-border)",opacity:0,transform:"scale(0.82) translateY(12px)",transformOrigin:`bottom ${T?"right":"left"}`,pointerEvents:"none",transition:"all 0.2s ease-in"},children:r&&e.jsx(L,{agentName:o??"Assistant",messages:C,isLoading:a,error:m??null,primaryColor:u,welcomeMessage:l,onSend:S,onReset:M,onClose:y,onToggleFullView:()=>d(i=>!i),isFullView:x})}),e.jsx("button",{className:"nexus-bubble-btn",onClick:()=>g(i=>!i),"aria-label":r?"Close chat":"Open chat","aria-expanded":r,style:{position:"absolute",[T?"right":"left"]:20,bottom:20,width:56,height:56,borderRadius:"50%",background:u,border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:"0 4px 20px rgba(0, 0, 0, 0.28)",pointerEvents:"auto",opacity:r?0:1,transform:r?"scale(0.5)":"scale(1)"},children:e.jsx("span",{style:{position:"relative",width:40,height:40},children:e.jsx("span",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",transition:"opacity 0.2s ease, transform 0.2s ease",opacity:r?0:1,transform:r?"scale(0.65) rotate(-15deg)":"scale(1) rotate(0deg)"},children:e.jsxs("svg",{width:"512",height:"512",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("circle",{cx:"256",cy:"256",r:"220",fill:"#6366f1"}),e.jsx("rect",{x:"156",y:"150",width:"200",height:"170",rx:"36",fill:"white"}),e.jsx("line",{x1:"256",y1:"120",x2:"256",y2:"150",stroke:"white","stroke-width":"10","stroke-linecap":"round"}),e.jsx("circle",{cx:"256",cy:"105",r:"14",fill:"white"}),e.jsx("circle",{cx:"210",cy:"220",r:"18",fill:"#6366f1"}),e.jsx("circle",{cx:"302",cy:"220",r:"18",fill:"#6366f1"}),e.jsx("rect",{x:"206",y:"265",width:"100",height:"16",rx:"8",fill:"#6366f1"}),e.jsx("rect",{x:"132",y:"205",width:"24",height:"60",rx:"12",fill:"white"}),e.jsx("rect",{x:"356",y:"205",width:"24",height:"60",rx:"12",fill:"white"}),e.jsx("path",{d:`M180 340
50
+ h152
51
+ a24 24 0 0 1 24 24
52
+ v20
53
+ a24 24 0 0 1 -24 24
54
+ h-80
55
+ l-28 24
56
+ 8-24
57
+ h-52
58
+ a24 24 0 0 1 -24 -24
59
+ v-20
60
+ a24 24 0 0 1 24 -24z`,fill:"white"}),e.jsx("circle",{cx:"220",cy:"374",r:"8",fill:"#6366f1"}),e.jsx("circle",{cx:"256",cy:"374",r:"8",fill:"#6366f1"}),e.jsx("circle",{cx:"292",cy:"374",r:"8",fill:"#6366f1"})]})})})})]})]})}exports.NexusWidget=J;exports.useChat=P;