claudius-chat-widget 1.15.0 → 1.16.1

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/claudius.cjs CHANGED
@@ -1,7 +1,8 @@
1
- "use strict";var _e=Object.defineProperty;var Be=(e,t,r)=>t in e?_e(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var J=(e,t,r)=>Be(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),l=require("react");class _ extends Error{constructor(t,r,n,s){super(t),this.status=r,this.code=n,this.retryAfter=s,this.name="ChatApiError"}}class ie extends Error{constructor(){super("Request debounced"),this.name="DebounceError"}}const Pe=3e4;function He(e,t){const r=atob(e),n=new Uint8Array(r.length);for(let s=0;s<r.length;s++)n[s]=r.charCodeAt(s);return new Blob([n],{type:t})}class Ce{constructor(t,r){J(this,"baseUrl");J(this,"maxRetries");J(this,"debounceMs");J(this,"timeoutMs");J(this,"lastSendTime",0);this.baseUrl=t,this.maxRetries=(r==null?void 0:r.maxRetries)??2,this.debounceMs=(r==null?void 0:r.debounceMs)??300,this.timeoutMs=(r==null?void 0:r.timeoutMs)??Pe}async sendMessage(t){if(this.debounceMs>0&&Date.now()-this.lastSendTime<this.debounceMs)throw new ie;this.lastSendTime=Date.now();let r;for(let n=0;n<=this.maxRetries;n++)try{const s=await this.fetchWithTimeout(t);if(s.ok)return await s.json();const o=await s.json().catch(()=>({})),i=s.headers.get("Retry-After"),c=i?Number(i):void 0;if(r=new _(o.error??`Request failed with status ${s.status}`,s.status,o.code,c),!this.isRetryable(s.status))throw r;if(n<this.maxRetries){const u=this.getRetryDelay(s,n);await this.delay(u)}}catch(s){if(s instanceof _){if(!this.isRetryable(s.status,s.code))throw s;if(r=s,n<this.maxRetries){const o=this.getRetryDelay(null,n);await this.delay(o)}}else if(r=new _("Failed to connect. Please try again.",0,"NETWORK_ERROR"),n<this.maxRetries){const o=this.getRetryDelay(null,n);await this.delay(o)}}throw r}buildRequest(t){if(!t.some(o=>{var i;return(i=o.attachments)==null?void 0:i.some(c=>!!c.data)}))return{headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:t})};const n=new FormData,s=t.map(o=>o.attachments?{...o,attachments:o.attachments.map(i=>{const c={...i};return delete c.data,c})}:o);n.append("payload",JSON.stringify({messages:s}));for(const o of t)for(const i of o.attachments??[])i.data&&n.append(i.id,He(i.data,i.mediaType),i.name);return{body:n}}async streamMessage(t,r={}){var s;if(typeof ReadableStream>"u")return this.sendMessage(t);if(this.debounceMs>0&&Date.now()-this.lastSendTime<this.debounceMs)throw new ie;this.lastSendTime=Date.now();let n;for(let o=0;o<=this.maxRetries;o++){let i;try{i=await this.fetchStream(t,r.signal)}catch(u){if((s=r.signal)!=null&&s.aborted)return{reply:"",aborted:!0};if(n=u instanceof _?u:new _("Failed to connect. Please try again.",0,"NETWORK_ERROR"),!this.isRetryable(n.status,n.code))throw n;o<this.maxRetries&&await this.delay(this.getRetryDelay(null,o));continue}if(i.status===404||i.status===405)return this.lastSendTime=0,this.sendMessage(t);if(!i.ok){const u=await i.json().catch(()=>({})),d=i.headers.get("Retry-After");if(n=new _(u.error??`Request failed with status ${i.status}`,i.status,u.code,d?Number(d):void 0),!this.isRetryable(i.status))throw n;o<this.maxRetries&&await this.delay(this.getRetryDelay(i,o));continue}if(!(i.headers.get("Content-Type")??"").includes("text/event-stream"))try{return await i.json()}catch{return this.lastSendTime=0,this.sendMessage(t)}return i.body?this.readSseStream(i.body,r):(this.lastSendTime=0,this.sendMessage(t))}throw n}async readSseStream(t,r){var p,b,D,E,C,m,k;const n=t.getReader(),s=new TextDecoder;let o="",i="";const c=[];let u;const d=()=>{n.cancel().catch(()=>{})};(p=r.signal)==null||p.addEventListener("abort",d,{once:!0});try{for(;;){let T;try{T=await n.read()}catch(A){if((b=r.signal)!=null&&b.aborted)break;throw A}if((D=r.signal)!=null&&D.aborted||T.done)break;o+=s.decode(T.value,{stream:!0});let S;for(;(S=o.indexOf(`
1
+ "use strict";var Qe=Object.defineProperty;var Ze=(e,t,n)=>t in e?Qe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ae=(e,t,n)=>Ze(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),c=require("react");class $ extends Error{constructor(t,n,r,s){super(t),this.status=n,this.code=r,this.retryAfter=s,this.name="ChatApiError"}}class me extends Error{constructor(){super("Request debounced"),this.name="DebounceError"}}const Je=3e4;function Xe(e,t){const n=atob(e),r=new Uint8Array(n.length);for(let s=0;s<n.length;s++)r[s]=n.charCodeAt(s);return new Blob([r],{type:t})}class He{constructor(t,n){ae(this,"baseUrl");ae(this,"maxRetries");ae(this,"debounceMs");ae(this,"timeoutMs");ae(this,"lastSendTime",0);this.baseUrl=t,this.maxRetries=(n==null?void 0:n.maxRetries)??2,this.debounceMs=(n==null?void 0:n.debounceMs)??300,this.timeoutMs=(n==null?void 0:n.timeoutMs)??Je}async sendMessage(t){if(this.debounceMs>0&&Date.now()-this.lastSendTime<this.debounceMs)throw new me;this.lastSendTime=Date.now();let n;for(let r=0;r<=this.maxRetries;r++)try{const s=await this.fetchWithTimeout(t);if(s.ok)return await s.json();const i=await s.json().catch(()=>({})),o=s.headers.get("Retry-After"),u=o?Number(o):void 0;if(n=new $(i.error??`Request failed with status ${s.status}`,s.status,i.code,u),!this.isRetryable(s.status))throw n;if(r<this.maxRetries){const l=this.getRetryDelay(s,r);await this.delay(l)}}catch(s){if(s instanceof $){if(!this.isRetryable(s.status,s.code))throw s;if(n=s,r<this.maxRetries){const i=this.getRetryDelay(null,r);await this.delay(i)}}else if(n=new $("Failed to connect. Please try again.",0,"NETWORK_ERROR"),r<this.maxRetries){const i=this.getRetryDelay(null,r);await this.delay(i)}}throw n}buildRequest(t){if(!t.some(i=>{var o;return(o=i.attachments)==null?void 0:o.some(u=>!!u.data)}))return{headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:t})};const r=new FormData,s=t.map(i=>i.attachments?{...i,attachments:i.attachments.map(o=>{const u={...o};return delete u.data,u})}:i);r.append("payload",JSON.stringify({messages:s}));for(const i of t)for(const o of i.attachments??[])o.data&&r.append(o.id,Xe(o.data,o.mediaType),o.name);return{body:r}}async streamMessage(t,n={}){var s;if(typeof ReadableStream>"u")return this.sendMessage(t);if(this.debounceMs>0&&Date.now()-this.lastSendTime<this.debounceMs)throw new me;this.lastSendTime=Date.now();let r;for(let i=0;i<=this.maxRetries;i++){let o;try{o=await this.fetchStream(t,n.signal)}catch(l){if((s=n.signal)!=null&&s.aborted)return{reply:"",aborted:!0};if(r=l instanceof $?l:new $("Failed to connect. Please try again.",0,"NETWORK_ERROR"),!this.isRetryable(r.status,r.code))throw r;i<this.maxRetries&&await this.delay(this.getRetryDelay(null,i));continue}if(o.status===404||o.status===405)return this.lastSendTime=0,this.sendMessage(t);if(!o.ok){const l=await o.json().catch(()=>({})),d=o.headers.get("Retry-After");if(r=new $(l.error??`Request failed with status ${o.status}`,o.status,l.code,d?Number(d):void 0),!this.isRetryable(o.status))throw r;i<this.maxRetries&&await this.delay(this.getRetryDelay(o,i));continue}if(!(o.headers.get("Content-Type")??"").includes("text/event-stream"))try{return await o.json()}catch{return this.lastSendTime=0,this.sendMessage(t)}return o.body?this.readSseStream(o.body,n):(this.lastSendTime=0,this.sendMessage(t))}throw r}async readSseStream(t,n){var f,y,C,g,h,p,v;const r=t.getReader(),s=new TextDecoder;let i="",o="";const u=[];let l;const d=()=>{r.cancel().catch(()=>{})};(f=n.signal)==null||f.addEventListener("abort",d,{once:!0});try{for(;;){let N;try{N=await r.read()}catch(E){if((y=n.signal)!=null&&y.aborted)break;throw E}if((C=n.signal)!=null&&C.aborted||N.done)break;i+=s.decode(N.value,{stream:!0});let T;for(;(T=i.indexOf(`
2
2
 
3
- `))!==-1;){const A=o.slice(0,S);o=o.slice(S+2);const v=$e(A);if(v){if(v.event==="chunk"){const y=typeof v.data.text=="string"?v.data.text:"";y&&(i+=y,(E=r.onChunk)==null||E.call(r,y,i))}else if(v.event==="tool"){if(typeof v.data.name=="string"){const y=v.data;c.push(y),(C=r.onToolUse)==null||C.call(r,y,c)}}else if(v.event==="done"){const y=Array.isArray(v.data.toolUses)?v.data.toolUses:c;u={reply:typeof v.data.reply=="string"?v.data.reply:i,sources:v.data.sources,...y.length>0?{toolUses:y}:{},...Array.isArray(v.data.attachments)?{attachments:v.data.attachments}:{}}}else if(v.event==="error")throw new _(typeof v.data.error=="string"?v.data.error:"Something went wrong. Please try again.",0,"STREAM_ERROR")}}}}finally{(m=r.signal)==null||m.removeEventListener("abort",d),n.releaseLock()}if((k=r.signal)!=null&&k.aborted)return{reply:i,aborted:!0,...c.length>0?{toolUses:c}:{}};if(u)return u;throw new _("Connection interrupted. Please try again.",0,"STREAM_ERROR")}async fetchStream(t,r){const n=new AbortController,s=()=>n.abort();r==null||r.addEventListener("abort",s,{once:!0});let o=!1;const i=this.timeoutMs>0?setTimeout(()=>{o=!0,n.abort()},this.timeoutMs):void 0,{headers:c,body:u}=this.buildRequest(t);try{return await fetch(`${this.baseUrl}/api/chat/stream`,{method:"POST",headers:c,body:u,signal:n.signal})}catch(d){throw o?new _("Request timed out. Please try again.",0,"TIMEOUT"):d}finally{i!==void 0&&clearTimeout(i),r==null||r.removeEventListener("abort",s)}}async fetchWithTimeout(t){const{headers:r,body:n}=this.buildRequest(t);if(this.timeoutMs<=0)return fetch(`${this.baseUrl}/api/chat`,{method:"POST",headers:r,body:n});const s=new AbortController,o=setTimeout(()=>s.abort(),this.timeoutMs);try{return await fetch(`${this.baseUrl}/api/chat`,{method:"POST",headers:r,body:n,signal:s.signal})}catch(i){throw s.signal.aborted?new _("Request timed out. Please try again.",0,"TIMEOUT"):i}finally{clearTimeout(o)}}isRetryable(t,r){return r==="TIMEOUT"||r==="NETWORK_ERROR"?!0:t===429||t===503}getRetryDelay(t,r){if(t&&t.status===429){const n=t.headers.get("Retry-After");if(n){const s=Number(n);return Math.min(s*1e3,6e4)}}return r===0?1e3:3e3}delay(t){return new Promise(r=>setTimeout(r,t))}}function $e(e){let t="message";const r=[];for(const n of e.split(`
4
- `))n.startsWith("event:")?t=n.slice(6).trim():n.startsWith("data:")&&r.push(n.slice(5).trimStart());if(r.length===0)return null;try{const n=JSON.parse(r.join(`
5
- `));return typeof n!="object"||n===null?null:{event:t,data:n}}catch{return null}}function Ae(e){return typeof e=="string"?{content:e}:e}function he(e,t,r){console.error(`[claudius] plugin "${e.name}" failed in ${t}:`,r)}async function ze(e,t,r){let n=t;for(const s of e){if(!s.onBeforeSend)continue;let o=null;const i={...r,respondWith(c){o={type:"respond",message:n,reply:Ae(c)}},abort(c){o={type:"abort",reason:c}}};try{const c=await s.onBeforeSend(n,i);if(o)return o;c&&(n=c)}catch(c){he(s,"onBeforeSend",c)}}return{type:"send",message:n}}async function Fe(e,t,r){let n=t;for(const s of e)if(s.onAfterReceive)try{const o=await s.onAfterReceive(n,r);o&&(n=o)}catch(o){he(s,"onAfterReceive",o)}return n}async function Ue(e,t,r){for(const n of e){if(!n.onError)continue;let s=null;const o={...r,respondWith(i){s=Ae(i)}};try{if(await n.onError(t,o),s)return s}catch(i){he(n,"onError",i)}}return null}const se={maxSizeBytes:5*1024*1024,maxCount:5,allowedTypes:["image/jpeg","image/png","image/gif","image/webp","application/pdf"]};function Ge(e){return e?e===!0?se:{maxSizeBytes:e.maxSizeBytes??se.maxSizeBytes,maxCount:e.maxCount??se.maxCount,allowedTypes:(e.allowedTypes??se.allowedTypes).map(t=>t.trim().toLowerCase()).filter(Boolean)}:null}function de(e){if(!Number.isFinite(e)||e<0)return"0 B";if(e<1024)return`${e} B`;const t=e/1024;if(t<1024)return`${Math.round(t)} KB`;const r=t/1024;return`${Number.isInteger(r)?r:r.toFixed(1)} MB`}const We={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",pdf:"application/pdf"};function Se(e){var n;const t=(e.type||"").trim().toLowerCase();if(t)return t;const r=((n=e.name.split(".").pop())==null?void 0:n.toLowerCase())??"";return We[r]??""}function Ve(e){return e.startsWith("image/")}function Ye(e){if(Ve(e.mediaType)){if(e.url)try{const t=new URL(e.url);if(t.protocol==="http:"||t.protocol==="https:")return e.url}catch{}if(e.data)return`data:${e.mediaType};base64,${e.data}`}}function qe(e,t,r){const n=[],s=[];let o=Math.max(0,r.maxCount-t);for(const i of e){const c=Se(i);!c||!r.allowedTypes.includes(c)?s.push({file:i,reason:"type"}):i.size>r.maxSizeBytes||i.size===0?s.push({file:i,reason:"size"}):o<=0?s.push({file:i,reason:"count"}):(n.push(i),o-=1)}return{accepted:n,rejected:s}}function Ke(e){return new Promise((t,r)=>{const n=new FileReader;n.onerror=()=>r(n.error??new Error("Failed to read file")),n.onload=()=>{const s=String(n.result??""),o=s.indexOf(",");t(o>=0?s.slice(o+1):s)},n.readAsDataURL(e)})}let be=0;function Qe(){return be+=1,`att-${Date.now().toString(36)}-${be}`}async function Je(e){const t=await Ke(e);return{id:Qe(),name:e.name||"attachment",mediaType:Se(e),size:e.size,data:t}}function Xe(e){return e.map(t=>{var r;return(r=t.attachments)!=null&&r.some(n=>n.data)?{...t,attachments:t.attachments.map(n=>{if(!n.data)return n;const s={...n};return delete s.data,s})}:t})}function Ze(e,t){if(!t||t.length===0)return e;const r=new Map(t.map(n=>[n.id,n]));return e.map(n=>{var s;return(s=n.attachments)!=null&&s.some(o=>r.has(o.id))?{...n,attachments:n.attachments.map(o=>{const i=r.get(o.id);if(!i)return o;const c={...o,key:i.key,url:i.url,expiresAt:i.expiresAt};return delete c.data,c})}:n})}const et=200,tt="claudius:messages";function rt(e,t){let r;try{r=new URL(t).host}catch{r=t}return`${e}:${r}`}function fe(){try{return typeof sessionStorage<"u"?sessionStorage:null}catch{return null}}function nt(e){const t=fe();if(!t)return[];try{const r=t.getItem(e);if(!r)return[];const n=JSON.parse(r);return Array.isArray(n)?n:[]}catch{return[]}}function st({apiUrl:e,persistMessages:t=!0,storageKeyPrefix:r=tt,timeoutMs:n,translations:s,plugins:o,streaming:i=!0}){const c=l.useMemo(()=>new Ce(e,{debounceMs:0,timeoutMs:n}),[e,n]),u=rt(r,e),d=t?nt(u):[],[p,b]=l.useState(d),[D,E]=l.useState(!1),[C,m]=l.useState(!1),[k,T]=l.useState(null),[S,A]=l.useState(null),[v,y]=l.useState(!1),P=l.useRef(d.length),z=l.useRef(!1),j=l.useRef(d),F=l.useRef(null),M=l.useRef(o??[]);M.current=o??[];const O=l.useCallback(g=>{if(!t)return;const f=fe();if(f)try{const h=Xe(g.slice(-et));f.setItem(u,JSON.stringify(h))}catch{}},[t,u]),B=()=>(P.current+=1,`msg-${P.current}`),w=l.useCallback((g,f)=>{if(!s)return f??"Something went wrong. Please try again.";switch(g){case"TIMEOUT":return s.errorTimeout;case"NETWORK_ERROR":return s.errorConnection;case"RATE_LIMITED":return f!=null&&f.includes("minute")?s.errorRateLimitMinute:s.errorRateLimitHour;case"ATTACHMENT_QUOTA_EXCEEDED":return s.errorAttachmentQuota;case"ATTACHMENTS_DISABLED":case"ATTACHMENT_INVALID":case"ATTACHMENT_TOO_LARGE":return s.errorAttachmentRejected;case"VALIDATION_ERROR":case"CONFIG_ERROR":case"SERVICE_ERROR":case"UNKNOWN_ERROR":default:return f??s.errorGeneric}},[s]),G=l.useCallback(g=>!(g instanceof _)||g.code==="TIMEOUT"||g.code==="NETWORK_ERROR"||g.code==="RATE_LIMITED"||g.code==="SERVICE_ERROR"||g.code==="UNKNOWN_ERROR"||g.status>=500||g.status===0,[]),V=l.useCallback(async g=>{var q,H;E(!0),z.current=!0,A(null),y(!1);const f=i&&typeof c.streamMessage=="function";let h=null;const L=x=>{if(h===null){h=B(),T(h);const N=[...j.current,{id:h,role:"assistant",content:"",...x}];j.current=N,b(N)}else{const N=h,R=j.current.map(U=>U.id===N?{...U,...x}:U);j.current=R,b(R)}},Y=()=>{if(h===null)return;const x=h,N=j.current.filter(R=>R.id!==x);j.current=N,b(N)};try{let x,N,R,U,W=!1;if(f){const $=new AbortController;F.current=$,m(!0);const I=await c.streamMessage(g,{signal:$.signal,onChunk:(ae,re)=>L({content:re}),onToolUse:(ae,re)=>L({toolUses:[...re]})});x=I.reply,N=I.sources,R=I.toolUses,U=I.attachments,W=I.aborted??!1}else{const $=await c.sendMessage(g);x=$.reply,N=$.sources,R=$.toolUses,U=$.attachments}if(W&&!x){Y();return}let K={id:h??B(),role:"assistant",content:x,sources:N,toolUses:R};M.current.length>0&&!W&&(K=await Fe(M.current,K,{messages:g,apiUrl:e}));const ce=h!==null?j.current.map($=>$.id===K.id?K:$):[...g,K],Q=Ze(ce,U);j.current=Q,b(Q),O(Q)}catch(x){if(x instanceof ie)return;if(x instanceof _&&((q=x.code)!=null&&q.startsWith("ATTACHMENT"))&&g.length>0){const N=g[g.length-1];if(N.role==="user"&&((H=N.attachments)!=null&&H.length)){const R=g.slice(0,-1);j.current=R,b(R),O(R)}}if(h!==null){O(j.current),x instanceof _?A(w(x.code,x.message)):A((s==null?void 0:s.errorConnection)??"Failed to connect. Please try again."),y(!1);return}if(M.current.length>0){const N=x instanceof Error?x:new Error(String(x)),R=await Ue(M.current,N,{messages:g,apiUrl:e});if(R){const U={id:B(),role:"assistant",content:R.content,sources:R.sources},W=[...g,U];j.current=W,b(W),O(W),A(null),y(!1);return}}x instanceof _?A(w(x.code,x.message)):A((s==null?void 0:s.errorConnection)??"Failed to connect. Please try again."),y(G(x))}finally{E(!1),z.current=!1,m(!1),T(null),F.current=null}},[e,c,w,G,O,i,s]),X=l.useCallback(()=>{var g;(g=F.current)==null||g.abort()},[]),Z=l.useCallback(async(g,f)=>{const h=g.trim(),L=(f==null?void 0:f.filter(x=>x&&x.id))??[];if(!h&&L.length===0||z.current)return;const Y={id:B(),role:"user",content:h,...L.length>0?{attachments:L}:{}};let q=Y;if(M.current.length>0){const x=await ze(M.current,Y,{messages:j.current,apiUrl:e});if(x.type==="abort")return;if(x.type==="respond"){const N={id:B(),role:"assistant",content:x.reply.content,sources:x.reply.sources},R=[...j.current,x.message,N];j.current=R,b(R),O(R),A(null),y(!1);return}q=x.message}const H=[...j.current,q];j.current=H,b(H),O(H),await V(H)},[e,O,V]),ee=l.useCallback(async()=>{if(z.current)return;const g=j.current[j.current.length-1];!g||g.role!=="user"||await V(j.current)},[V]),te=l.useCallback(()=>{if(j.current=[],b([]),A(null),y(!1),t){const g=fe();if(!g)return;try{g.removeItem(u)}catch{}}},[t,u]);return{messages:p,isLoading:D,isStreaming:C,streamingMessageId:k,error:S,canRetry:v,sendMessage:Z,stop:X,retry:ee,clearMessages:te}}function at(e){const[t,r]=l.useState(()=>typeof window>"u"?!1:window.matchMedia(e).matches);return l.useEffect(()=>{const n=window.matchMedia(e);r(n.matches);const s=o=>r(o.matches);return n.addEventListener("change",s),()=>n.removeEventListener("change",s)},[e]),t}function oe(e,t){return e instanceof RegExp?e.test(t):t.toLowerCase().includes(e.toLowerCase())}function ot(){const e=document.documentElement,t=document.body,r=e.scrollTop||t.scrollTop||0,n=Math.max(e.scrollHeight,t.scrollHeight),s=e.clientHeight||window.innerHeight,o=n-s;return o<=0?100:r/o*100}function it({triggers:e,enabled:t,onOpen:r,onGreeting:n}){l.useEffect(()=>{if(!t||!e||e.length===0)return;const s=new Set,o=[],i=typeof window<"u"?window.location.href:"",c=(u,d)=>{s.has(u)||(s.add(u),d==="open"?r():n(d.greeting))};return e.forEach((u,d)=>{switch(u.on){case"url":{oe(u.pattern,i)&&c(d,u.action);break}case"time":{if(u.matchUrl&&!oe(u.matchUrl,i))return;const p=window.setTimeout(()=>c(d,u.action),Math.max(0,u.seconds*1e3));o.push(()=>window.clearTimeout(p));break}case"scroll":{if(u.matchUrl&&!oe(u.matchUrl,i))return;const p=()=>{ot()>=u.percent&&c(d,u.action)};p(),window.addEventListener("scroll",p,{passive:!0}),o.push(()=>window.removeEventListener("scroll",p));break}case"exit-intent":{if(u.matchUrl&&!oe(u.matchUrl,i))return;const p=b=>{b.clientY<=0&&c(d,u.action)};document.addEventListener("mouseleave",p),o.push(()=>document.removeEventListener("mouseleave",p));break}}}),()=>{o.forEach(u=>u())}},[e,t,r,n])}const ct={"bottom-right":"bottom-6 right-6","bottom-left":"bottom-6 left-6","top-right":"top-6 right-6","top-left":"top-6 left-6"},lt=l.forwardRef(function({isOpen:t,onClick:r,position:n="bottom-right",translations:s},o){const i=t?(s==null?void 0:s.closeChat)??"Close chat":(s==null?void 0:s.openChat)??"Open chat";return a.jsx("button",{ref:o,onClick:r,"aria-label":i,className:`fixed ${ct[n]} z-50 flex h-14 w-14 items-center justify-center rounded-claudius-full bg-claudius-accent text-claudius-accent-text shadow-claudius-floating transition-transform hover:scale-105 focus:outline-none focus:ring-2 focus:ring-claudius-accent focus:ring-offset-2`,children:t?a.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}):a.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:a.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})})}),ut=l.memo(function({count:t,isActive:r,onClick:n}){return a.jsxs("button",{onClick:n,"aria-label":"View sources",title:"View sources",className:`group relative flex h-7 w-7 items-center justify-center rounded-claudius-full transition-colors ${r?"bg-claudius-accent text-claudius-accent-text":"text-claudius-text-muted hover:bg-claudius-surface-muted hover:text-claudius-text"}`,children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),a.jsx("polyline",{points:"14 2 14 8 20 8"}),a.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),a.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]}),a.jsx("span",{className:"absolute -right-1 -top-1 flex h-4 min-w-4 items-center justify-center rounded-claudius-full bg-claudius-accent px-1 text-[10px] font-bold text-claudius-accent-text",children:t})]})}),dt=["http:","https:"];function me(e){if(!e||typeof e!="string")return null;const t=e.trim();if(!t)return null;try{const r=new URL(t);return dt.includes(r.protocol)?t:null}catch{return null}}function ft(){return a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),a.jsx("polyline",{points:"14 2 14 8 20 8"})]})}function ye({label:e,onClick:t}){return a.jsx("button",{type:"button",onClick:t,"aria-label":e,className:"absolute -right-1.5 -top-1.5 flex h-5 w-5 items-center justify-center rounded-claudius-full bg-claudius-text text-claudius-surface shadow-claudius-floating hover:opacity-90 focus:outline-none focus-visible:ring-2 focus-visible:ring-claudius-accent",children:a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round","aria-hidden":"true",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}const Me=l.memo(function({attachment:t,variant:r,onRemove:n,removeLabel:s}){const o=Ye(t),i=r==="composer",c=`${t.name} (${de(t.size)})`,u=t.url?me(t.url):null;if(o){const p=a.jsx("img",{src:o,alt:t.name,title:c,loading:"lazy",className:i?"h-12 w-12 rounded-claudius-sm border border-claudius-border object-cover":"max-h-48 max-w-full rounded-claudius-sm object-contain"});return a.jsxs("div",{className:"relative inline-block",children:[!i&&u?a.jsxs("a",{href:u,target:"_blank",rel:"noopener noreferrer",children:[p,a.jsxs("span",{className:"sr-only",children:[c," (opens in a new tab)"]})]}):p,n&&s&&a.jsx(ye,{label:s,onClick:n})]})}const d=a.jsxs("span",{title:c,className:`inline-flex max-w-[220px] items-center gap-1.5 rounded-claudius-sm border px-2 py-1 text-xs ${i?"border-claudius-border bg-claudius-field text-claudius-text":"border-current/30 bg-transparent"}`,children:[a.jsx(ft,{}),a.jsx("span",{className:"truncate",children:t.name}),a.jsx("span",{className:"shrink-0 opacity-70",children:de(t.size)})]});return a.jsxs("div",{className:"relative inline-block",children:[!i&&u?a.jsxs("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"underline-offset-2 hover:underline",children:[d,a.jsx("span",{className:"sr-only",children:" (opens in a new tab)"})]}):d,n&&s&&a.jsx(ye,{label:s,onClick:n})]})});function ht(e){const t=e.lastIndexOf(`
6
- `),r=t===-1?"":e.slice(0,t+1);let n=t===-1?e:e.slice(t+1);return n=pt(n),n=xt(n),r+n}function mt(e){const t=[];for(let r=0;r<e.length-1;r++)e[r]==="*"&&e[r+1]==="*"&&(t.push(r),r++);return t}function gt(e){const t=[];for(let r=0;r<e.length;r++)if(e[r]==="*"){if(e[r+1]==="*"){r++;continue}t.push(r)}return t}function pt(e){const t=mt(e);if(t.length%2===0)return e;const r=t[t.length-1],n=e.slice(r+2);return n.trim()===""?e.slice(0,r)+n:e+"**"}function xt(e){const t=gt(e);if(t.length%2===0)return e;const r=t[t.length-1],n=e.slice(r+1);return n.trim()===""?e.slice(0,r)+n:e+"*"}function bt({toolUse:e,usedLabel:t,detailsLabel:r}){const[n,s]=l.useState(!1),o=e.input!==void 0||e.result!==void 0;return a.jsxs("div",{className:"text-xs text-claudius-text-muted",children:[a.jsxs("button",{type:"button",disabled:!o,onClick:()=>s(i=>!i),"aria-expanded":o?n:void 0,className:"flex items-center gap-1.5 rounded-claudius-full border border-claudius-border bg-claudius-surface px-2 py-0.5 hover:opacity-80 disabled:cursor-default disabled:hover:opacity-100",children:[a.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:a.jsx("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})}),a.jsxs("span",{children:[t," ",a.jsx("span",{className:"font-mono text-claudius-text",children:e.name}),e.isError&&a.jsx("span",{className:"text-claudius-error",children:" ✕"})]}),o&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"sr-only",children:r}),a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:n?"rotate-180":void 0,children:a.jsx("polyline",{points:"6 9 12 15 18 9"})})]})]}),n&&o&&a.jsxs("div",{className:"mt-1 overflow-x-auto rounded-claudius-sm border border-claudius-border bg-claudius-field p-2 font-mono",children:[e.input!==void 0&&a.jsx("pre",{className:"whitespace-pre-wrap break-all",children:JSON.stringify(e.input,null,2)}),e.result!==void 0&&a.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-all border-t border-claudius-border pt-1",children:e.result})]})]})}const we=/(https?:\/\/[^\s)]+)/,ve=/(\*\*[^*]+\*\*)/,je=/(\*[^*]+\*)/;function yt(e,t){const r=e.match(/[.,;:!?'"]+$/),n=r?e.slice(0,-r[0].length):e,s=r?r[0]:"",o=me(n);return o?a.jsxs(a.Fragment,{children:[a.jsxs("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"underline font-medium hover:opacity-80 text-claudius-link",children:[o.replace(/^https?:\/\//,""),a.jsx("span",{className:"sr-only",children:" (opens in a new tab)"})]},t),s]}):e}function wt(e,t){const r=e.split(ve),n=[];return r.forEach((s,o)=>{if(ve.test(s)){const i=s.slice(2,-2);n.push(a.jsx("strong",{children:i},`${t}-b${o}`))}else s.split(je).forEach((c,u)=>{if(je.test(c)){const d=c.slice(1,-1);n.push(a.jsx("em",{children:d},`${t}-b${o}-i${u}`))}else c.split(we).forEach((p,b)=>{we.test(p)?n.push(yt(p,`${t}-b${o}-i${u}-u${b}`)):p&&n.push(p)})})}),n}function vt(e){const t=e.split(`
7
- `);return t.map((r,n)=>a.jsxs("span",{children:[wt(r,`l${n}`),n<t.length-1&&a.jsx("br",{})]},n))}const jt=l.memo(function({role:t,content:r,isStreaming:n=!1,sources:s,attachments:o,toolUses:i,toolUsedLabel:c="Used tool:",toolDetailsLabel:u="Tool details",onSourceClick:d,isSourceActive:p}){const b=t==="user",D=!!o&&o.length>0,E=n?ht(r):r,C=b||r!==""||!(i!=null&&i.length);return a.jsxs("div",{className:`${b?"ml-auto":"mr-auto"} max-w-[85%]`,children:[C&&a.jsxs("div",{className:`rounded-claudius-bubble px-4 py-2.5 text-sm leading-relaxed font-body ${b?"bg-claudius-user-bubble text-claudius-user-bubble-text rounded-br-claudius-tail":"bg-claudius-assistant-bubble text-claudius-assistant-bubble-text rounded-bl-claudius-tail"}`,children:[D&&a.jsx("ul",{className:`flex flex-wrap gap-2 ${r?"mb-2":""}`,"aria-label":"Attachments",children:o.map(m=>a.jsx("li",{children:a.jsx(Me,{attachment:m,variant:"message"})},m.id))}),(r!==""||!D)&&vt(E)]}),!b&&i&&i.length>0&&a.jsx("div",{className:"mt-1 space-y-1",children:i.map((m,k)=>a.jsx(bt,{toolUse:m,usedLabel:c,detailsLabel:u},`${m.name}-${k}`))}),!b&&s&&s.length>0&&d&&a.jsx("div",{className:"mt-1",children:a.jsx(ut,{count:s.length,isActive:p??!1,onClick:d})})]})}),ke={title:"Chat",subtitle:"Ask me anything",welcomeMessage:"Hi! How can I help you today?",closeChat:"Close chat",chatMessages:"Chat messages",typingIndicator:"Assistant is typing",placeholder:"Type your message...",sendMessage:"Send message",stopGenerating:"Stop generating",toolUsed:"Used tool:",toolDetails:"Tool details",typeYourMessage:"Type your message",openChat:"Open chat",dismissGreeting:"Dismiss greeting",attachFile:"Attach a file",removeAttachment:"Remove attachment",attachmentsLabel:"Attachments",dropFilesHint:"Drop files to attach",attachmentTooLarge:"{name} is too large. The maximum size is {max}.",attachmentTypeNotAllowed:"{name} is not a supported file type.",attachmentTooMany:"You can attach up to {max} files per message.",errorGeneric:"Something went wrong. Please try again.",errorConnection:"Failed to connect. Please try again.",errorTimeout:"Request timed out. Please try again.",errorRateLimitMinute:"Too many requests. Please wait a minute.",errorRateLimitHour:"Hourly limit reached. Please try again later.",errorAttachmentRejected:"An attachment was rejected. Please remove it and try again.",errorAttachmentQuota:"Upload limit reached. Please try again later.",errorRetry:"Retry"},ge=ke;function Tt(e){return{...ge,...e}}function le(e,t){return e.replace(/\{(\w+)\}/g,(r,n)=>n in t?String(t[n]):r)}const ue=2e3,Rt=1800;function Te(e){var r;const t=(r=e.dataTransfer)==null?void 0:r.types;return!!t&&Array.from(t).includes("Files")}function Et({onSend:e,isLoading:t,isStreaming:r=!1,onStop:n,placeholder:s,translations:o,attachments:i=null}){const c=o??ge,[u,d]=l.useState(""),[p,b]=l.useState([]),[D,E]=l.useState(null),[C,m]=l.useState(!1),k=l.useRef(null),T=l.useRef(null),S=l.useRef([]),A=l.useRef(0),v=u.length,y=v>=Rt,P=v>=ue,z=s??c.placeholder,j=!!i&&p.length<i.maxCount,F=r&&!!n;l.useEffect(()=>{var f;t||(f=k.current)==null||f.focus()},[t]);const M=l.useCallback((f,h)=>{if(!i)return"";switch(h){case"size":return le(c.attachmentTooLarge,{name:f,max:de(i.maxSizeBytes)});case"type":return le(c.attachmentTypeNotAllowed,{name:f});case"count":return le(c.attachmentTooMany,{max:i.maxCount})}},[i,c]),O=l.useCallback(async f=>{if(!i||f.length===0)return;const{accepted:h,rejected:L}=qe(f,S.current.length,i);if(E(L.length>0?M(L[0].file.name,L[0].reason):null),h.length===0)return;const Y=await Promise.all(h.map(Je));S.current=[...S.current,...Y],b(S.current)},[i,M]),B=l.useCallback(f=>{S.current=S.current.filter(h=>h.id!==f),b(S.current),E(null)},[]),w=f=>{f.preventDefault();const h=u.trim(),L=S.current;!h&&L.length===0||P||(L.length>0?e(h,L):e(h),d(""),S.current=[],b([]),E(null))},G=f=>{const h=f.target.value;h.length<=ue&&d(h)},V=f=>{const h=Array.from(f.target.files??[]);f.target.value="",O(h)},X=f=>{var L;if(!i)return;const h=Array.from(((L=f.clipboardData)==null?void 0:L.files)??[]);h.length!==0&&(f.preventDefault(),O(h))},Z=f=>{!i||!Te(f)||(f.preventDefault(),A.current+=1,m(!0))},ee=f=>{!i||!Te(f)||f.preventDefault()},te=()=>{i&&(A.current=Math.max(0,A.current-1),A.current===0&&m(!1))},g=f=>{var h;i&&(f.preventDefault(),A.current=0,m(!1),O(Array.from(((h=f.dataTransfer)==null?void 0:h.files)??[])))};return a.jsxs("form",{onSubmit:w,onDragEnter:Z,onDragOver:ee,onDragLeave:te,onDrop:g,"data-drag-over":C||void 0,className:`relative border-t border-claudius-border bg-claudius-surface p-3 ${C?"ring-2 ring-inset ring-claudius-accent":""}`,children:[C&&a.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 z-10 flex items-center justify-center bg-claudius-surface text-sm font-medium text-claudius-accent",children:c.dropFilesHint}),i&&p.length>0&&a.jsx("ul",{"aria-label":c.attachmentsLabel,className:"mb-2 flex flex-wrap gap-3 pt-1",children:p.map(f=>a.jsx("li",{children:a.jsx(Me,{attachment:f,variant:"composer",onRemove:()=>B(f.id),removeLabel:`${c.removeAttachment}: ${f.name}`})},f.id))}),a.jsxs("div",{className:"flex gap-2",children:[i&&a.jsxs(a.Fragment,{children:[a.jsx("input",{ref:T,type:"file",multiple:!0,hidden:!0,tabIndex:-1,accept:i.allowedTypes.join(","),onChange:V,"aria-label":c.attachFile}),a.jsx("button",{type:"button",onClick:()=>{var f;return(f=T.current)==null?void 0:f.click()},disabled:t||!j,"aria-label":c.attachFile,title:c.attachFile,className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-claudius-sm border border-claudius-border bg-claudius-field text-claudius-text-muted transition-colors hover:text-claudius-text focus:border-claudius-accent focus:outline-none focus:ring-1 focus:ring-claudius-accent disabled:opacity-50",children:a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:a.jsx("path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"})})})]}),a.jsx("input",{ref:k,type:"text",value:u,onChange:G,onPaste:X,placeholder:z,disabled:t,"aria-label":c.typeYourMessage,"aria-describedby":y?"char-count":void 0,className:"min-w-0 flex-1 rounded-claudius-sm border border-claudius-border bg-claudius-field px-3 py-2 text-sm font-body text-claudius-text placeholder:text-claudius-text-muted focus:border-claudius-accent focus:outline-none focus:ring-1 focus:ring-claudius-accent disabled:opacity-50"}),F?a.jsx("button",{type:"button",onClick:n,"aria-label":c.stopGenerating,className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-claudius-sm bg-claudius-accent text-claudius-accent-text transition-colors hover:opacity-90",children:a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:a.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1.5"})})}):a.jsx("button",{type:"submit",disabled:t||P,"aria-label":c.sendMessage,className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-claudius-sm bg-claudius-accent text-claudius-accent-text transition-colors hover:opacity-90 disabled:opacity-50",children:a.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),a.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]}),D&&a.jsx("div",{role:"alert",className:"mt-1 text-xs text-claudius-error",children:D}),y&&a.jsxs("div",{id:"char-count",className:`mt-1 text-xs text-right ${P?"text-claudius-error":"text-claudius-text-muted"}`,"aria-live":"polite",children:[v,"/",ue]})]})}const Ct=["blog","page","external"],At={blog:"Blog",page:"Page",external:"External"};function St(e){try{return new URL(e).hostname}catch{return e}}const Mt=l.memo(function({sources:t,onClose:r}){const n=Ct.map(o=>({type:o,label:At[o],items:t.filter(i=>i.type===o)})).filter(o=>o.items.length>0),s=t.length===1?"1 source found":`${t.length} sources found`;return a.jsxs("div",{className:"absolute inset-y-0 left-0 z-10 flex w-[280px] flex-col border-r-2 border-claudius-border bg-claudius-surface rounded-r-claudius-lg transition-transform duration-200 ease-out",children:[a.jsxs("div",{className:"flex items-center justify-between border-b border-claudius-border px-4 py-3",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-heading font-semibold text-claudius-text",children:"Sources"}),a.jsx("p",{className:"text-xs text-claudius-text-muted",children:s})]}),a.jsx("button",{onClick:r,"aria-label":"Close sources",className:"flex h-7 w-7 items-center justify-center rounded-claudius-full text-claudius-text-muted transition-colors hover:bg-claudius-surface-muted hover:text-claudius-text",children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),a.jsx("div",{className:"flex-1 overflow-y-auto px-3 py-3 space-y-4",children:n.map(o=>a.jsxs("div",{children:[a.jsx("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-claudius-text-muted",children:o.label}),a.jsx("div",{className:"space-y-2",children:o.items.map(i=>{const c=me(i.url);return c?a.jsxs("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"block rounded-claudius-md border-2 border-claudius-border bg-claudius-surface-muted p-3 transition-colors hover:bg-claudius-border",children:[a.jsx("p",{className:"truncate text-sm font-medium text-claudius-text",children:i.title}),a.jsx("p",{className:"mt-0.5 text-xs text-claudius-text-muted",children:St(c)})]},c):null})})]},o.type))})]})});function kt({title:e,subtitle:t,titleId:r,closeLabel:n,onClose:s}){return a.jsxs("div",{className:"flex items-center gap-3 bg-claudius-accent px-5 py-4",children:[a.jsx("div",{"aria-hidden":"true",className:"flex h-8 w-8 items-center justify-center rounded-claudius-full bg-claudius-accent-soft text-sm font-bold text-claudius-accent-text",children:e.charAt(0).toUpperCase()}),a.jsxs("div",{className:"flex-1",children:[a.jsx("h2",{id:r,className:"text-sm font-heading font-semibold text-claudius-accent-text",children:e}),a.jsx("p",{className:"text-xs text-claudius-accent-text",children:t})]}),a.jsx("button",{onClick:s,"aria-label":n,className:"flex h-10 w-10 items-center justify-center rounded-claudius-full text-claudius-accent-text-muted transition-colors hover:bg-claudius-accent-soft hover:text-claudius-accent-text",children:a.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})}function Nt({message:e,retryLabel:t,onRetry:r}){return a.jsxs("div",{role:"alert",className:"mx-auto flex max-w-[90%] flex-col items-center gap-2 rounded-claudius-sm bg-claudius-error-surface px-3 py-2 text-center text-xs text-claudius-error",children:[a.jsx("span",{children:e}),r&&a.jsx("button",{type:"button",onClick:r,className:"rounded-claudius-md bg-claudius-error px-3 py-1 text-xs font-semibold text-claudius-error-text transition-opacity hover:opacity-90 focus:outline-none focus-visible:ring-2 focus-visible:ring-claudius-error focus-visible:ring-offset-1",children:t})]})}function Lt({label:e}){return a.jsx("div",{role:"status","aria-live":"polite","aria-label":e,className:"mr-auto flex max-w-[85%]",children:a.jsxs("div",{className:"flex gap-1 rounded-claudius-bubble rounded-bl-claudius-tail bg-claudius-assistant-bubble px-4 py-3",children:[a.jsx("span",{className:"h-2 w-2 motion-safe:animate-bounce rounded-claudius-full bg-claudius-text-muted [animation-delay:0ms]"}),a.jsx("span",{className:"h-2 w-2 motion-safe:animate-bounce rounded-claudius-full bg-claudius-text-muted [animation-delay:150ms]"}),a.jsx("span",{className:"h-2 w-2 motion-safe:animate-bounce rounded-claudius-full bg-claudius-text-muted [animation-delay:300ms]"})]})})}function Dt(e,t,r){const[n,s]=l.useState(0),o=l.useRef(0),i=l.useRef(0),c=l.useRef(0),u=l.useRef(!1);return l.useEffect(()=>{const d=e.current;if(!r||!d)return;const p=E=>{if(d.scrollTop>0){u.current=!1;return}u.current=!0,i.current=E.touches[0].clientY,c.current=Date.now()},b=E=>{if(!u.current)return;let C=E.touches[0].clientY-i.current;C<0&&(C=C*.3),o.current=C,s(C)},D=()=>{if(!u.current)return;u.current=!1;const E=o.current,C=(Date.now()-c.current)/1e3,m=d.getBoundingClientRect().height,k=C>.05&&E>0&&E/C>500,T=E>m*.3;k||T?t():(o.current=0,s(0))};return d.addEventListener("touchstart",p,{passive:!0}),d.addEventListener("touchmove",b,{passive:!0}),d.addEventListener("touchend",D),()=>{d.removeEventListener("touchstart",p),d.removeEventListener("touchmove",b),d.removeEventListener("touchend",D)}},[e,t,r]),{offsetY:n}}const Ot='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function It(e,t){l.useEffect(()=>{const r=e.current;if(!r)return;const n=s=>{if(s.key!=="Tab")return;const o=Array.from(r.querySelectorAll(Ot)).filter(d=>!d.hasAttribute("aria-hidden"));if(o.length===0)return;const i=o[0],c=o[o.length-1],u=document.activeElement;s.shiftKey&&u===i?(s.preventDefault(),c.focus()):!s.shiftKey&&u===c&&(s.preventDefault(),i.focus())};return r.addEventListener("keydown",n),()=>r.removeEventListener("keydown",n)},[e,t])}const _t=/\*\*([^*]+)\*\*/g,Bt=/\*([^*]+)\*/g,Pt=/https?:\/\/[^\s)]+/g;function Ht(e){return e.replace(_t,"$1").replace(Bt,"$1").replace(Pt,t=>{try{return new URL(t).hostname}catch{return t}})}const $t={"bottom-right":"bottom-24 right-3 sm:right-6","bottom-left":"bottom-24 left-3 sm:left-6","top-right":"top-24 right-3 sm:right-6","top-left":"top-24 left-3 sm:left-6"};function zt({messages:e,isLoading:t,isStreaming:r=!1,streamingMessageId:n=null,error:s,canRetry:o=!1,onSend:i,onStop:c,onRetry:u,onClose:d,title:p="Chat",subtitle:b="Ask me anything",welcomeMessage:D="Hi! How can I help you today?",placeholder:E,position:C="bottom-right",translations:m,isMobile:k=!1,attachments:T=null}){const S=l.useId(),A=l.useRef(null),v=l.useRef(null),[y,P]=l.useState(null);It(A,!0);const{offsetY:z}=Dt(v,d,k),j=z!==0,F=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)").matches:!1;l.useEffect(()=>{const w=v.current;w&&(w.scrollTop=w.scrollHeight)},[e,t]),l.useEffect(()=>{const w=G=>{G.key==="Escape"&&!G.isComposing&&d()};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[d]);const M=(m==null?void 0:m.closeChat)??"Close chat",O=(m==null?void 0:m.chatMessages)??"Chat messages",B=[...e].reverse().find(w=>w.role==="assistant");return a.jsxs("div",{ref:A,role:"dialog","aria-modal":k?"true":void 0,"aria-labelledby":S,className:k?"claudius-bottom-sheet fixed inset-x-0 bottom-0 z-50 flex h-[90vh] w-full flex-col overflow-hidden rounded-t-claudius-lg bg-claudius-surface shadow-claudius-elevated font-body":`fixed ${$t[C]} z-50 flex h-[min(500px,calc(100vh-7rem))] w-[calc(100vw-1.5rem)] max-w-[380px] sm:max-w-[400px] md:max-w-[440px] flex-col overflow-hidden rounded-claudius-lg bg-claudius-surface shadow-claudius-elevated font-body`,style:k&&!F?{transform:`translateY(${Math.max(0,z)}px)`}:void 0,"data-dragging":j||void 0,children:[k&&a.jsx("div",{className:"flex justify-center py-2","aria-hidden":"true",children:a.jsx("div",{className:"h-1 w-8 rounded-claudius-full bg-claudius-border"})}),a.jsx(kt,{title:p,subtitle:b,titleId:S,closeLabel:M,onClose:d}),a.jsxs("div",{className:"relative flex-1 overflow-hidden",children:[y&&a.jsx(Mt,{sources:y.sources,onClose:()=>P(null)}),a.jsxs("div",{ref:v,role:"log","aria-label":O,className:"h-full space-y-3 overflow-y-auto px-4 py-4",children:[e.length===0&&!s&&a.jsx("div",{className:"mr-auto flex max-w-[85%]",children:a.jsx("div",{className:"rounded-claudius-bubble rounded-bl-claudius-tail bg-claudius-assistant-bubble px-4 py-2.5 text-sm leading-relaxed text-claudius-assistant-bubble-text",children:D})}),e.map(w=>a.jsx(jt,{role:w.role,content:w.content,isStreaming:w.id===n,sources:w.sources,attachments:w.attachments,toolUses:w.toolUses,toolUsedLabel:m==null?void 0:m.toolUsed,toolDetailsLabel:m==null?void 0:m.toolDetails,isSourceActive:(y==null?void 0:y.messageId)===w.id,onSourceClick:()=>{(y==null?void 0:y.messageId)===w.id?P(null):w.sources&&w.sources.length>0&&P({messageId:w.id,sources:w.sources})}},w.id)),t&&!(n!==null&&e.some(w=>w.id===n&&w.content.length>0))&&a.jsx(Lt,{label:(m==null?void 0:m.typingIndicator)??"Assistant is typing"}),s&&a.jsx(Nt,{message:s,retryLabel:(m==null?void 0:m.errorRetry)??"Retry",onRetry:o&&u&&!t?u:void 0})]})]}),a.jsx("div",{"data-claudius-live":"assistant","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:B&&B.id!==n?Ht(B.content):""}),a.jsx(Et,{onSend:i,isLoading:t,isStreaming:r,onStop:c,placeholder:E,translations:m,attachments:T})]})}function Ft({message:e,position:t,onOpen:r,onDismiss:n,dismissLabel:s}){const o=t.startsWith("bottom"),i=t.endsWith("right"),c=["claudius-greeting-bubble","fixed z-40 max-w-xs",o?"bottom-20":"top-20",i?"right-4":"left-4"].join(" ");return a.jsxs("div",{className:c,role:"status","aria-live":"polite",children:[a.jsx("button",{type:"button",onClick:r,className:"block w-full rounded-claudius-lg bg-claudius-surface p-4 pr-8 text-left text-sm font-body text-claudius-text shadow-claudius-floating ring-1 ring-claudius-border transition hover:shadow-claudius-floating-hover focus:outline-none focus:ring-2 focus:ring-claudius-accent",children:e}),a.jsx("button",{type:"button",onClick:u=>{u.stopPropagation(),n()},"aria-label":s,className:"absolute right-1 top-1 flex h-6 w-6 items-center justify-center rounded-claudius-full text-claudius-text-muted hover:bg-claudius-surface-muted focus:outline-none focus:ring-2 focus:ring-claudius-accent",children:a.jsx("span",{"aria-hidden":"true",children:"×"})})]})}const Ut={title:"Chat",subtitle:"Pregúntame lo que quieras",welcomeMessage:"¡Hola! ¿En qué puedo ayudarte hoy?",closeChat:"Cerrar chat",chatMessages:"Mensajes del chat",typingIndicator:"El asistente está escribiendo",placeholder:"Escribe tu mensaje...",sendMessage:"Enviar mensaje",stopGenerating:"Detener la respuesta",toolUsed:"Herramienta usada:",toolDetails:"Detalles de la herramienta",typeYourMessage:"Escribe tu mensaje",openChat:"Abrir chat",dismissGreeting:"Descartar saludo",attachFile:"Adjuntar un archivo",removeAttachment:"Quitar adjunto",attachmentsLabel:"Adjuntos",dropFilesHint:"Suelta los archivos para adjuntarlos",attachmentTooLarge:"{name} es demasiado grande. El tamaño máximo es {max}.",attachmentTypeNotAllowed:"{name} no es un tipo de archivo compatible.",attachmentTooMany:"Puedes adjuntar hasta {max} archivos por mensaje.",errorGeneric:"Algo salió mal. Inténtalo de nuevo.",errorConnection:"No se pudo conectar. Inténtalo de nuevo.",errorTimeout:"La solicitud tardó demasiado. Inténtalo de nuevo.",errorRateLimitMinute:"Demasiadas solicitudes. Espera un minuto.",errorRateLimitHour:"Has alcanzado el límite por hora. Inténtalo más tarde.",errorAttachmentRejected:"Se rechazó un adjunto. Quítalo e inténtalo de nuevo.",errorAttachmentQuota:"Límite de subida alcanzado. Inténtalo más tarde.",errorRetry:"Reintentar"},Gt={title:"Chat",subtitle:"Posez-moi vos questions",welcomeMessage:"Bonjour ! Comment puis-je vous aider aujourd'hui ?",closeChat:"Fermer le chat",chatMessages:"Messages du chat",typingIndicator:"L'assistant écrit",placeholder:"Saisissez votre message...",sendMessage:"Envoyer le message",stopGenerating:"Arrêter la génération",toolUsed:"Outil utilisé :",toolDetails:"Détails de l'outil",typeYourMessage:"Saisissez votre message",openChat:"Ouvrir le chat",dismissGreeting:"Ignorer le message d'accueil",attachFile:"Joindre un fichier",removeAttachment:"Retirer la pièce jointe",attachmentsLabel:"Pièces jointes",dropFilesHint:"Déposez les fichiers pour les joindre",attachmentTooLarge:"{name} est trop volumineux. La taille maximale est de {max}.",attachmentTypeNotAllowed:"{name} n'est pas un type de fichier pris en charge.",attachmentTooMany:"Vous pouvez joindre jusqu'à {max} fichiers par message.",errorGeneric:"Une erreur s'est produite. Veuillez réessayer.",errorConnection:"Échec de la connexion. Veuillez réessayer.",errorTimeout:"La requête a expiré. Veuillez réessayer.",errorRateLimitMinute:"Trop de requêtes. Veuillez patienter une minute.",errorRateLimitHour:"Limite horaire atteinte. Veuillez réessayer plus tard.",errorAttachmentRejected:"Une pièce jointe a été refusée. Retirez-la et réessayez.",errorAttachmentQuota:"Limite d'envoi atteinte. Veuillez réessayer plus tard.",errorRetry:"Réessayer"},Wt={title:"Chat",subtitle:"Fragen Sie mich alles",welcomeMessage:"Hallo! Wie kann ich Ihnen heute helfen?",closeChat:"Chat schließen",chatMessages:"Chat-Nachrichten",typingIndicator:"Der Assistent schreibt",placeholder:"Geben Sie Ihre Nachricht ein...",sendMessage:"Nachricht senden",stopGenerating:"Generierung stoppen",toolUsed:"Verwendetes Tool:",toolDetails:"Tool-Details",typeYourMessage:"Geben Sie Ihre Nachricht ein",openChat:"Chat öffnen",dismissGreeting:"Begrüßung schließen",attachFile:"Datei anhängen",removeAttachment:"Anhang entfernen",attachmentsLabel:"Anhänge",dropFilesHint:"Dateien hier ablegen, um sie anzuhängen",attachmentTooLarge:"{name} ist zu groß. Die maximale Größe beträgt {max}.",attachmentTypeNotAllowed:"{name} ist kein unterstützter Dateityp.",attachmentTooMany:"Sie können bis zu {max} Dateien pro Nachricht anhängen.",errorGeneric:"Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut.",errorConnection:"Verbindung fehlgeschlagen. Bitte versuchen Sie es erneut.",errorTimeout:"Zeitüberschreitung der Anfrage. Bitte versuchen Sie es erneut.",errorRateLimitMinute:"Zu viele Anfragen. Bitte warten Sie eine Minute.",errorRateLimitHour:"Stündliches Limit erreicht. Bitte versuchen Sie es später erneut.",errorAttachmentRejected:"Ein Anhang wurde abgelehnt. Bitte entfernen Sie ihn und versuchen Sie es erneut.",errorAttachmentQuota:"Upload-Limit erreicht. Bitte versuchen Sie es später erneut.",errorRetry:"Erneut versuchen"},pe={en:ke,es:Ut,fr:Gt,de:Wt};function Re(e){if(!e)return;const t=e.toLowerCase().split("-")[0];return Object.prototype.hasOwnProperty.call(pe,t)?t:void 0}function Ne(){const e=typeof document<"u"?Re(document.documentElement.lang):void 0;if(e)return e;const t=typeof navigator<"u"?Re(navigator.language):void 0;return t||"en"}function Le(e={}){const{locale:t,translations:r}=e,n=pe[t??Ne()];return r?{...n,...r}:{...n}}const Ee=["accent","accentText","accentSoft","accentTextMuted","surface","surfaceMuted","text","textMuted","border","userBubble","userBubbleText","assistantBubble","assistantBubbleText","field","error","errorSurface","errorText","link","scrim"],Vt=["sm","md","lg","full","tail"],Yt=["elevated","floating","floatingHover"],qt=["heading","body"],xe={default:{name:"default"},minimal:{name:"minimal",colors:{accent:"#171717",accentText:"#ffffff",surface:"#ffffff",surfaceMuted:"#f5f5f5",text:"#171717",textMuted:"#737373",border:"#e5e5e5",link:"#171717"},colorsDark:{accent:"#fafafa",accentText:"#171717",surface:"#0a0a0a",surfaceMuted:"#1c1c1c",text:"#fafafa",textMuted:"#a3a3a3",border:"#2e2e2e",field:"#1c1c1c",link:"#fafafa"},radii:{sm:"4px",md:"6px",lg:"10px"},shadows:{elevated:"0 4px 16px rgb(0 0 0 / 0.12)",floating:"0 2px 8px rgb(0 0 0 / 0.12)",floatingHover:"0 4px 12px rgb(0 0 0 / 0.16)"}},playful:{name:"playful",colors:{accent:"#8b5cf6",surfaceMuted:"#f5f3ff",assistantBubbleText:"#4c1d95",link:"#7c3aed"},colorsDark:{accent:"#a78bfa",surfaceMuted:"#2e1065",assistantBubbleText:"#ede9fe",link:"#c4b5fd"},radii:{sm:"12px",md:"16px",lg:"24px",tail:"8px"},shadows:{elevated:"0 24px 48px -12px rgb(139 92 246 / 0.35)",floating:"0 10px 20px -5px rgb(139 92 246 / 0.4)",floatingHover:"0 16px 28px -6px rgb(139 92 246 / 0.5)"},fonts:{heading:"ui-rounded, 'Hiragino Maru Gothic ProN', system-ui",body:"ui-rounded, 'Hiragino Maru Gothic ProN', system-ui"}},corporate:{name:"corporate",colors:{accent:"#1e3a5f",surfaceMuted:"#f3f4f6",text:"#1f2937",textMuted:"#6b7280",border:"#d1d5db",link:"#1d4ed8"},colorsDark:{accent:"#2c5282",link:"#93c5fd"},radii:{sm:"4px",md:"6px",lg:"8px",tail:"2px"},shadows:{elevated:"0 8px 24px rgb(15 23 42 / 0.16)",floating:"0 4px 12px rgb(15 23 42 / 0.18)",floatingHover:"0 6px 16px rgb(15 23 42 / 0.24)"},fonts:{heading:"'Segoe UI', 'Helvetica Neue', Arial, system-ui",body:"'Segoe UI', 'Helvetica Neue', Arial, system-ui"}}};function Kt(e){return Object.prototype.hasOwnProperty.call(xe,e)}const Qt=new Set(["light","dark","auto"]);function Jt(e){if(e===void 0)return{mode:"light"};if(typeof e=="string"){if(Qt.has(e))return{mode:e};if(Kt(e)){const t=xe[e];return{mode:t.colorScheme??"light",theme:t}}return{mode:"light",url:e}}return{mode:e.colorScheme??"light",theme:e}}function Xt(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function Zt(e,t){console.warn(`[Claudius] Ignoring unknown theme token "${t}" in "${e}"`)}function ne(e,t,r,n,s,o=""){if(s)for(const[i,c]of Object.entries(s)){if(!n.includes(i)){Zt(t,i);continue}typeof c=="string"&&(e[`${r}${Xt(i)}${o}`]=c)}}function er(e){const t={};ne(t,"colors","--cl-color-",Ee,e.colors);for(const[r,n]of Object.entries({...t}))t[`${r}-dark`]=n;return ne(t,"colorsDark","--cl-color-",Ee,e.colorsDark,"-dark"),ne(t,"radii","--cl-radius-",Vt,e.radii),ne(t,"shadows","--cl-shadow-",Yt,e.shadows),ne(t,"fonts","--cl-font-",qt,e.fonts),t}function tr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function rr(e){const t=l.useMemo(()=>Jt(e),[e]),[r,n]=l.useState(null),s=t.url;l.useEffect(()=>{if(n(null),!s)return;const u=new AbortController;return fetch(s,{signal:u.signal}).then(d=>{if(!d.ok)throw new Error(`HTTP ${d.status}`);return d.json()}).then(d=>{if(!tr(d))throw new Error("theme JSON must be an object");n(d)}).catch(d=>{u.signal.aborted||console.error(`[Claudius] Failed to load theme from ${s}:`,d)}),()=>u.abort()},[s]);const o=t.theme??r??null,i=(r==null?void 0:r.colorScheme)??t.mode,c=l.useMemo(()=>o?er(o):{},[o]);return{mode:i,cssVars:c}}const De="claudius:triggers:dismissed";function nr(){if(typeof window>"u")return!1;try{return window.sessionStorage.getItem(De)==="1"}catch{return!1}}function sr(){if(!(typeof window>"u"))try{window.sessionStorage.setItem(De,"1")}catch{}}function ar({apiUrl:e,title:t,subtitle:r,welcomeMessage:n,placeholder:s,persistMessages:o,storageKeyPrefix:i,requestTimeoutMs:c,theme:u="light",accentColor:d,position:p="bottom-right",locale:b,translations:D,triggers:E,plugins:C,streaming:m=!0,attachments:k=!1}){const[T,S]=l.useState(!1),A=l.useMemo(()=>Ge(k),[k]),[v,y]=l.useState(null),[P,z]=l.useState(nr),j=l.useRef(!1),F=at("(max-width: 639px)"),M=l.useMemo(()=>Le({locale:b,translations:D}),[b,D]),{messages:O,isLoading:B,isStreaming:w,streamingMessageId:G,error:V,canRetry:X,sendMessage:Z,stop:ee,retry:te}=st({apiUrl:e,persistMessages:o,storageKeyPrefix:i,timeoutMs:c,translations:M,plugins:C,streaming:m}),g=l.useRef(null),f=l.useRef(T),{mode:h,cssVars:L}=rr(u),[Y,q]=l.useState(!1);l.useEffect(()=>{if(h!=="auto")return;const I=window.matchMedia("(prefers-color-scheme: dark)");q(I.matches);const ae=re=>q(re.matches);return I.addEventListener("change",ae),()=>I.removeEventListener("change",ae)},[h]),l.useEffect(()=>{var I;f.current&&!T&&((I=g.current)==null||I.focus()),f.current=T},[T]);const H=l.useCallback(()=>{z(!0),sr()},[]),x=l.useCallback(()=>{S(!1),j.current&&(j.current=!1,H())},[H]),N=l.useCallback(()=>{S(I=>!I)},[]),R=l.useCallback(()=>{j.current=!0,y(null),S(!0)},[]),U=l.useCallback(I=>{y(I)},[]),W=l.useCallback(()=>{y(null),R()},[R]),K=l.useCallback(()=>{y(null),H()},[H]);it({triggers:E,enabled:!P&&!T,onOpen:R,onGreeting:U});const ce=h==="dark"||h==="auto"&&Y,Q={...L,...d?{"--cl-color-accent":d,"--cl-color-accent-dark":d}:{}},$=Object.keys(Q).length>0?Q:void 0;return a.jsx("div",{className:"claudius-root",style:$,children:a.jsxs("div",{"data-claudius-dark":ce?"true":"false",children:[T&&F&&a.jsx("div",{className:"claudius-scrim fixed inset-0 z-40 bg-claudius-scrim",onClick:x,"aria-hidden":"true"}),T&&a.jsx(zt,{messages:O,isLoading:B,isStreaming:w,streamingMessageId:G,error:V,canRetry:X,onSend:Z,onStop:ee,onRetry:te,onClose:x,title:t??M.title,subtitle:r??M.subtitle,welcomeMessage:n??M.welcomeMessage,placeholder:s??M.placeholder,position:p,translations:M,isMobile:F,attachments:A}),!(T&&F)&&a.jsx(lt,{ref:g,isOpen:T,onClick:N,position:p,translations:M}),!T&&v&&a.jsx(Ft,{message:v,position:p,onOpen:W,onDismiss:K,dismissLabel:M.dismissGreeting})]})})}function or(e){const{onEvent:t,includeContent:r=!0}=e,n=s=>r?s:"";return{name:"analytics",onBeforeSend(s){t({type:"message_sent",role:"user",content:n(s.content),chars:s.content.length})},onAfterReceive(s){t({type:"message_received",role:"assistant",content:n(s.content),chars:s.content.length})},onError(s){t({type:"chat_error",message:s.message,code:s.code})}}}const Oe=[/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g,/\b\d{3}-\d{2}-\d{4}\b/g,/\b(?:\d[ -]?){13,16}\b/g,/\b(?:\+?1[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}\b/g];function Ie(e,t,r){return t.reduce((n,s)=>(s.lastIndex=0,n.replace(s,r)),e)}function ir(e={}){const{patterns:t=Oe,replacement:r="[redacted]",redactReplies:n=!1}=e,s=o=>{const i=Ie(o.content,t,r);if(i!==o.content)return{...o,content:i}};return{name:"redact-pii",onBeforeSend:s,onAfterReceive:n?s:void 0}}function cr(e,t,r){return typeof e=="function"?e(t):e instanceof RegExp?e.test(t):r?t.includes(e):t.toLowerCase().includes(e.toLowerCase())}function lr(e){const{rules:t,caseSensitive:r=!1}=e;return{name:"canned-responses",onBeforeSend(n,s){for(const o of t)if(cr(o.match,n.content,r)){s.respondWith(o.reply);return}}}}exports.ChatApiClient=Ce;exports.ChatApiError=_;exports.ChatWidget=ar;exports.DEFAULT_ATTACHMENT_OPTIONS=se;exports.DEFAULT_PII_PATTERNS=Oe;exports.DebounceError=ie;exports.builtinThemes=xe;exports.createTranslations=Tt;exports.defaultTranslations=ge;exports.detectLocale=Ne;exports.locales=pe;exports.pluginAnalytics=or;exports.pluginCannedResponses=lr;exports.pluginRedactPII=ir;exports.redactText=Ie;exports.resolveTranslations=Le;
3
+ `))!==-1;){const E=i.slice(0,T);i=i.slice(T+2);const x=et(E);if(x){if(x.event==="chunk"){const S=typeof x.data.text=="string"?x.data.text:"";S&&(o+=S,(g=n.onChunk)==null||g.call(n,S,o))}else if(x.event==="tool"){if(typeof x.data.name=="string"){const S=x.data;u.push(S),(h=n.onToolUse)==null||h.call(n,S,u)}}else if(x.event==="done"){const S=Array.isArray(x.data.toolUses)?x.data.toolUses:u;l={reply:typeof x.data.reply=="string"?x.data.reply:o,sources:x.data.sources,...S.length>0?{toolUses:S}:{},...Array.isArray(x.data.attachments)?{attachments:x.data.attachments}:{}}}else if(x.event==="error")throw new $(typeof x.data.error=="string"?x.data.error:"Something went wrong. Please try again.",0,"STREAM_ERROR")}}}}finally{(p=n.signal)==null||p.removeEventListener("abort",d),r.releaseLock()}if((v=n.signal)!=null&&v.aborted)return{reply:o,aborted:!0,...u.length>0?{toolUses:u}:{}};if(l)return l;throw new $("Connection interrupted. Please try again.",0,"STREAM_ERROR")}async fetchStream(t,n){const r=new AbortController,s=()=>r.abort();n==null||n.addEventListener("abort",s,{once:!0});let i=!1;const o=this.timeoutMs>0?setTimeout(()=>{i=!0,r.abort()},this.timeoutMs):void 0,{headers:u,body:l}=this.buildRequest(t);try{return await fetch(`${this.baseUrl}/api/chat/stream`,{method:"POST",headers:u,body:l,signal:r.signal})}catch(d){throw i?new $("Request timed out. Please try again.",0,"TIMEOUT"):d}finally{o!==void 0&&clearTimeout(o),n==null||n.removeEventListener("abort",s)}}async fetchWithTimeout(t){const{headers:n,body:r}=this.buildRequest(t);if(this.timeoutMs<=0)return fetch(`${this.baseUrl}/api/chat`,{method:"POST",headers:n,body:r});const s=new AbortController,i=setTimeout(()=>s.abort(),this.timeoutMs);try{return await fetch(`${this.baseUrl}/api/chat`,{method:"POST",headers:n,body:r,signal:s.signal})}catch(o){throw s.signal.aborted?new $("Request timed out. Please try again.",0,"TIMEOUT"):o}finally{clearTimeout(i)}}isRetryable(t,n){return n==="TIMEOUT"||n==="NETWORK_ERROR"?!0:t===429||t===503}getRetryDelay(t,n){if(t&&t.status===429){const r=t.headers.get("Retry-After");if(r){const s=Number(r);return Math.min(s*1e3,6e4)}}return n===0?1e3:3e3}delay(t){return new Promise(n=>setTimeout(n,t))}}function et(e){let t="message";const n=[];for(const r of e.split(`
4
+ `))r.startsWith("event:")?t=r.slice(6).trim():r.startsWith("data:")&&n.push(r.slice(5).trimStart());if(n.length===0)return null;try{const r=JSON.parse(n.join(`
5
+ `));return typeof r!="object"||r===null?null:{event:t,data:r}}catch{return null}}function _e(e){return typeof e=="string"?{content:e}:e}function ye(e,t,n){console.error(`[claudius] plugin "${e.name}" failed in ${t}:`,n)}async function tt(e,t,n){let r=t;for(const s of e){if(!s.onBeforeSend)continue;let i=null;const o={...n,respondWith(u){i={type:"respond",message:r,reply:_e(u)}},abort(u){i={type:"abort",reason:u}}};try{const u=await s.onBeforeSend(r,o);if(i)return i;u&&(r=u)}catch(u){ye(s,"onBeforeSend",u)}}return{type:"send",message:r}}async function nt(e,t,n){let r=t;for(const s of e)if(s.onAfterReceive)try{const i=await s.onAfterReceive(r,n);i&&(r=i)}catch(i){ye(s,"onAfterReceive",i)}return r}async function rt(e,t,n){for(const r of e){if(!r.onError)continue;let s=null;const i={...n,respondWith(o){s=_e(o)}};try{if(await r.onError(t,i),s)return s}catch(o){ye(r,"onError",o)}}return null}const de={maxSizeBytes:5*1024*1024,maxCount:5,allowedTypes:["image/jpeg","image/png","image/gif","image/webp","application/pdf"]};function st(e){return e?e===!0?de:{maxSizeBytes:e.maxSizeBytes??de.maxSizeBytes,maxCount:e.maxCount??de.maxCount,allowedTypes:(e.allowedTypes??de.allowedTypes).map(t=>t.trim().toLowerCase()).filter(Boolean)}:null}function xe(e){if(!Number.isFinite(e)||e<0)return"0 B";if(e<1024)return`${e} B`;const t=e/1024;if(t<1024)return`${Math.round(t)} KB`;const n=t/1024;return`${Number.isInteger(n)?n:n.toFixed(1)} MB`}const at={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",pdf:"application/pdf"};function ze(e){var r;const t=(e.type||"").trim().toLowerCase();if(t)return t;const n=((r=e.name.split(".").pop())==null?void 0:r.toLowerCase())??"";return at[n]??""}function ot(e){return e.startsWith("image/")}function it(e){if(ot(e.mediaType)){if(e.url)try{const t=new URL(e.url);if(t.protocol==="http:"||t.protocol==="https:")return e.url}catch{}if(e.data)return`data:${e.mediaType};base64,${e.data}`}}function ct(e,t,n){const r=[],s=[];let i=Math.max(0,n.maxCount-t);for(const o of e){const u=ze(o);!u||!n.allowedTypes.includes(u)?s.push({file:o,reason:"type"}):o.size>n.maxSizeBytes||o.size===0?s.push({file:o,reason:"size"}):i<=0?s.push({file:o,reason:"count"}):(r.push(o),i-=1)}return{accepted:r,rejected:s}}function ut(e){return new Promise((t,n)=>{const r=new FileReader;r.onerror=()=>n(r.error??new Error("Failed to read file")),r.onload=()=>{const s=String(r.result??""),i=s.indexOf(",");t(i>=0?s.slice(i+1):s)},r.readAsDataURL(e)})}let Se=0;function lt(){return Se+=1,`att-${Date.now().toString(36)}-${Se}`}async function dt(e){const t=await ut(e);return{id:lt(),name:e.name||"attachment",mediaType:ze(e),size:e.size,data:t}}function ft(e){return e.map(t=>{var n;return(n=t.attachments)!=null&&n.some(r=>r.data)?{...t,attachments:t.attachments.map(r=>{if(!r.data)return r;const s={...r};return delete s.data,s})}:t})}function ht(e,t){if(!t||t.length===0)return e;const n=new Map(t.map(r=>[r.id,r]));return e.map(r=>{var s;return(s=r.attachments)!=null&&s.some(i=>n.has(i.id))?{...r,attachments:r.attachments.map(i=>{const o=n.get(i.id);if(!o)return i;const u={...i,key:o.key,url:o.url,expiresAt:o.expiresAt};return delete u.data,u})}:r})}const mt=200,pt="claudius:messages";function gt(e,t){let n;try{n=new URL(t).host}catch{n=t}return`${e}:${n}`}function be(){try{return typeof sessionStorage<"u"?sessionStorage:null}catch{return null}}function xt(e){const t=be();if(!t)return[];try{const n=t.getItem(e);if(!n)return[];const r=JSON.parse(n);return Array.isArray(r)?r:[]}catch{return[]}}function bt({apiUrl:e,persistMessages:t=!0,storageKeyPrefix:n=pt,timeoutMs:r,translations:s,plugins:i,streaming:o=!0}){const u=c.useMemo(()=>new He(e,{debounceMs:0,timeoutMs:r}),[e,r]),l=gt(n,e),d=t?xt(l):[],[f,y]=c.useState(d),[C,g]=c.useState(!1),[h,p]=c.useState(!1),[v,N]=c.useState(null),[T,E]=c.useState(null),[x,S]=c.useState(!1),M=c.useRef(d.length),A=c.useRef(!1),b=c.useRef(d),_=c.useRef(null),z=c.useRef(i??[]);z.current=i??[];const I=c.useCallback(R=>{if(!t)return;const B=be();if(B)try{const O=ft(R.slice(-mt));B.setItem(l,JSON.stringify(O))}catch{}},[t,l]),P=()=>(M.current+=1,`msg-${M.current}`),q=c.useCallback((R,B)=>{if(!s)return B??"Something went wrong. Please try again.";switch(R){case"TIMEOUT":return s.errorTimeout;case"NETWORK_ERROR":return s.errorConnection;case"RATE_LIMITED":return B!=null&&B.includes("minute")?s.errorRateLimitMinute:s.errorRateLimitHour;case"ATTACHMENT_QUOTA_EXCEEDED":return s.errorAttachmentQuota;case"ATTACHMENTS_DISABLED":case"ATTACHMENT_INVALID":case"ATTACHMENT_TOO_LARGE":return s.errorAttachmentRejected;case"VALIDATION_ERROR":case"CONFIG_ERROR":case"SERVICE_ERROR":case"UNKNOWN_ERROR":default:return B??s.errorGeneric}},[s]),Q=c.useCallback(R=>!(R instanceof $)||R.code==="TIMEOUT"||R.code==="NETWORK_ERROR"||R.code==="RATE_LIMITED"||R.code==="SERVICE_ERROR"||R.code==="UNKNOWN_ERROR"||R.status>=500||R.status===0,[]),V=c.useCallback(async R=>{var X,H;g(!0),A.current=!0,E(null),S(!1);const B=o&&typeof u.streamMessage=="function";let O=null;const Y=j=>{if(O===null){O=P(),N(O);const k=[...b.current,{id:O,role:"assistant",content:"",...j}];b.current=k,y(k)}else{const k=O,L=b.current.map(F=>F.id===k?{...F,...j}:F);b.current=L,y(L)}},K=()=>{if(O===null)return;const j=O,k=b.current.filter(L=>L.id!==j);b.current=k,y(k)};try{let j,k,L,F,G=!1;if(B){const W=new AbortController;_.current=W,p(!0);const J=await u.streamMessage(R,{signal:W.signal,onChunk:(ie,U)=>Y({content:U}),onToolUse:(ie,U)=>Y({toolUses:[...U]})});j=J.reply,k=J.sources,L=J.toolUses,F=J.attachments,G=J.aborted??!1}else{const W=await u.sendMessage(R);j=W.reply,k=W.sources,L=W.toolUses,F=W.attachments}if(G&&!j){K();return}let ee={id:O??P(),role:"assistant",content:j,sources:k,toolUses:L};z.current.length>0&&!G&&(ee=await nt(z.current,ee,{messages:R,apiUrl:e}));const re=O!==null?b.current.map(W=>W.id===ee.id?ee:W):[...R,ee],ne=ht(re,F);b.current=ne,y(ne),I(ne)}catch(j){if(j instanceof me)return;if(j instanceof $&&((X=j.code)!=null&&X.startsWith("ATTACHMENT"))&&R.length>0){const k=R[R.length-1];if(k.role==="user"&&((H=k.attachments)!=null&&H.length)){const L=R.slice(0,-1);b.current=L,y(L),I(L)}}if(O!==null){I(b.current),j instanceof $?E(q(j.code,j.message)):E((s==null?void 0:s.errorConnection)??"Failed to connect. Please try again."),S(!1);return}if(z.current.length>0){const k=j instanceof Error?j:new Error(String(j)),L=await rt(z.current,k,{messages:R,apiUrl:e});if(L){const F={id:P(),role:"assistant",content:L.content,sources:L.sources},G=[...R,F];b.current=G,y(G),I(G),E(null),S(!1);return}}j instanceof $?E(q(j.code,j.message)):E((s==null?void 0:s.errorConnection)??"Failed to connect. Please try again."),S(Q(j))}finally{g(!1),A.current=!1,p(!1),N(null),_.current=null}},[e,u,q,Q,I,o,s]),Z=c.useCallback(()=>{var R;(R=_.current)==null||R.abort()},[]),w=c.useCallback(async(R,B)=>{const O=R.trim(),Y=(B==null?void 0:B.filter(j=>j&&j.id))??[];if(!O&&Y.length===0||A.current)return;const K={id:P(),role:"user",content:O,...Y.length>0?{attachments:Y}:{}};let X=K;if(z.current.length>0){const j=await tt(z.current,K,{messages:b.current,apiUrl:e});if(j.type==="abort")return;if(j.type==="respond"){const k={id:P(),role:"assistant",content:j.reply.content,sources:j.reply.sources},L=[...b.current,j.message,k];b.current=L,y(L),I(L),E(null),S(!1);return}X=j.message}const H=[...b.current,X];b.current=H,y(H),I(H),await V(H)},[e,I,V]),te=c.useCallback(async()=>{if(A.current)return;const R=b.current[b.current.length-1];!R||R.role!=="user"||await V(b.current)},[V]),oe=c.useCallback(()=>{if(b.current=[],y([]),E(null),S(!1),t){const R=be();if(!R)return;try{R.removeItem(l)}catch{}}},[t,l]);return{messages:f,isLoading:C,isStreaming:h,streamingMessageId:v,error:T,canRetry:x,sendMessage:w,stop:Z,retry:te,clearMessages:oe}}function yt(e){const[t,n]=c.useState(()=>typeof window>"u"?!1:window.matchMedia(e).matches);return c.useEffect(()=>{const r=window.matchMedia(e);n(r.matches);const s=i=>n(i.matches);return r.addEventListener("change",s),()=>r.removeEventListener("change",s)},[e]),t}function he(e,t){return e instanceof RegExp?e.test(t):t.toLowerCase().includes(e.toLowerCase())}function vt(){const e=document.documentElement,t=document.body,n=e.scrollTop||t.scrollTop||0,r=Math.max(e.scrollHeight,t.scrollHeight),s=e.clientHeight||window.innerHeight,i=r-s;return i<=0?100:n/i*100}function wt({triggers:e,enabled:t,onOpen:n,onGreeting:r}){c.useEffect(()=>{if(!t||!e||e.length===0)return;const s=new Set,i=[],o=typeof window<"u"?window.location.href:"",u=(l,d)=>{s.has(l)||(s.add(l),d==="open"?n():r(d.greeting))};return e.forEach((l,d)=>{switch(l.on){case"url":{he(l.pattern,o)&&u(d,l.action);break}case"time":{if(l.matchUrl&&!he(l.matchUrl,o))return;const f=window.setTimeout(()=>u(d,l.action),Math.max(0,l.seconds*1e3));i.push(()=>window.clearTimeout(f));break}case"scroll":{if(l.matchUrl&&!he(l.matchUrl,o))return;const f=()=>{vt()>=l.percent&&u(d,l.action)};f(),window.addEventListener("scroll",f,{passive:!0}),i.push(()=>window.removeEventListener("scroll",f));break}case"exit-intent":{if(l.matchUrl&&!he(l.matchUrl,o))return;const f=y=>{y.clientY<=0&&u(d,l.action)};document.addEventListener("mouseleave",f),i.push(()=>document.removeEventListener("mouseleave",f));break}}}),()=>{i.forEach(l=>l())}},[e,t,n,r])}const Rt={"bottom-right":"bottom-6 right-6","bottom-left":"bottom-6 left-6","top-right":"top-6 right-6","top-left":"top-6 left-6"},jt=c.forwardRef(function({isOpen:t,onClick:n,position:r="bottom-right",translations:s},i){const o=t?(s==null?void 0:s.closeChat)??"Close chat":(s==null?void 0:s.openChat)??"Open chat";return a.jsx("button",{ref:i,onClick:n,"aria-label":o,className:`fixed ${Rt[r]} z-50 flex h-14 w-14 items-center justify-center rounded-claudius-full bg-claudius-accent text-claudius-accent-text shadow-claudius-floating transition-transform hover:scale-105 focus:outline-none focus:ring-2 focus:ring-claudius-accent focus:ring-offset-2`,children:t?a.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}):a.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:a.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})})}),Et=c.memo(function({count:t,isActive:n,onClick:r}){return a.jsxs("button",{onClick:r,"aria-label":"View sources",title:"View sources",className:`group relative flex h-7 w-7 items-center justify-center rounded-claudius-full transition-colors ${n?"bg-claudius-accent text-claudius-accent-text":"text-claudius-text-muted hover:bg-claudius-surface-muted hover:text-claudius-text"}`,children:[a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),a.jsx("polyline",{points:"14 2 14 8 20 8"}),a.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),a.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]}),a.jsx("span",{className:"absolute -right-1 -top-1 flex h-4 min-w-4 items-center justify-center rounded-claudius-full bg-claudius-accent px-1 text-[10px] font-bold text-claudius-accent-text",children:t})]})}),St=["http:","https:"];function ve(e){if(!e||typeof e!="string")return null;const t=e.trim();if(!t)return null;try{const n=new URL(t);return St.includes(n.protocol)?t:null}catch{return null}}function Tt(){return a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),a.jsx("polyline",{points:"14 2 14 8 20 8"})]})}function Te({label:e,onClick:t}){return a.jsx("button",{type:"button",onClick:t,"aria-label":e,className:"absolute -right-1.5 -top-1.5 flex h-5 w-5 items-center justify-center rounded-claudius-full bg-claudius-text text-claudius-surface shadow-claudius-floating hover:opacity-90 focus:outline-none focus-visible:ring-2 focus-visible:ring-claudius-accent",children:a.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round","aria-hidden":"true",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}const Ue=c.memo(function({attachment:t,variant:n,onRemove:r,removeLabel:s}){const i=it(t),o=n==="composer",u=`${t.name} (${xe(t.size)})`,l=t.url?ve(t.url):null;if(i){const f=a.jsx("img",{src:i,alt:t.name,title:u,loading:"lazy",className:o?"h-12 w-12 rounded-claudius-sm border border-claudius-border object-cover":"max-h-48 max-w-full rounded-claudius-sm object-contain"});return a.jsxs("div",{className:"relative inline-block",children:[!o&&l?a.jsxs("a",{href:l,target:"_blank",rel:"noopener noreferrer",children:[f,a.jsxs("span",{className:"sr-only",children:[u," (opens in a new tab)"]})]}):f,r&&s&&a.jsx(Te,{label:s,onClick:r})]})}const d=a.jsxs("span",{title:u,className:`inline-flex max-w-[220px] items-center gap-1.5 rounded-claudius-sm border px-2 py-1 text-xs ${o?"border-claudius-border bg-claudius-field text-claudius-text":"border-current/30 bg-transparent"}`,children:[a.jsx(Tt,{}),a.jsx("span",{className:"truncate",children:t.name}),a.jsx("span",{className:"shrink-0 opacity-70",children:xe(t.size)})]});return a.jsxs("div",{className:"relative inline-block",children:[!o&&l?a.jsxs("a",{href:l,target:"_blank",rel:"noopener noreferrer",className:"underline-offset-2 hover:underline",children:[d,a.jsx("span",{className:"sr-only",children:" (opens in a new tab)"})]}):d,r&&s&&a.jsx(Te,{label:s,onClick:r})]})}),Ce=c.forwardRef(function({label:t,onClick:n,children:r},s){return a.jsx("button",{ref:s,type:"button",onClick:n,"aria-label":t,title:t,className:"flex h-7 w-7 items-center justify-center rounded-claudius-full text-claudius-text-muted transition-colors hover:bg-claudius-surface-muted hover:text-claudius-text",children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r})})});function Ct({state:e,labels:t,onPlay:n,onPause:r,onResume:s,onStop:i}){var f;const o=c.useRef(null),u=c.useRef(null),l=!!((f=o.current)!=null&&f.contains(document.activeElement));c.useEffect(()=>{var y,C;e==="idle"&&l&&!((y=o.current)!=null&&y.contains(document.activeElement))&&((C=u.current)==null||C.focus())},[e,l]);const d=e==="idle"?{label:t.play,onClick:n}:e==="paused"?{label:t.resume,onClick:s}:{label:t.pause,onClick:r};return a.jsxs("div",{ref:o,className:"flex items-center gap-1",children:[a.jsx(Ce,{ref:u,...d,children:e==="idle"?a.jsxs(a.Fragment,{children:[a.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),a.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07",fill:"none"}),a.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14",fill:"none"})]}):e==="paused"?a.jsx("polygon",{points:"6 3 20 12 6 21 6 3"}):a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"}),a.jsx("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"})]})}),e!=="idle"&&a.jsx(Ce,{label:t.stop,onClick:i,children:a.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1.5"})})]})}function kt(e){const t=e.lastIndexOf(`
6
+ `),n=t===-1?"":e.slice(0,t+1);let r=t===-1?e:e.slice(t+1);return r=Nt(r),r=Lt(r),n+r}function At(e){const t=[];for(let n=0;n<e.length-1;n++)e[n]==="*"&&e[n+1]==="*"&&(t.push(n),n++);return t}function Mt(e){const t=[];for(let n=0;n<e.length;n++)if(e[n]==="*"){if(e[n+1]==="*"){n++;continue}t.push(n)}return t}function Nt(e){const t=At(e);if(t.length%2===0)return e;const n=t[t.length-1],r=e.slice(n+2);return r.trim()===""?e.slice(0,n)+r:e+"**"}function Lt(e){const t=Mt(e);if(t.length%2===0)return e;const n=t[t.length-1],r=e.slice(n+1);return r.trim()===""?e.slice(0,n)+r:e+"*"}function Dt({toolUse:e,usedLabel:t,detailsLabel:n}){const[r,s]=c.useState(!1),i=e.input!==void 0||e.result!==void 0;return a.jsxs("div",{className:"text-xs text-claudius-text-muted",children:[a.jsxs("button",{type:"button",disabled:!i,onClick:()=>s(o=>!o),"aria-expanded":i?r:void 0,className:"flex items-center gap-1.5 rounded-claudius-full border border-claudius-border bg-claudius-surface px-2 py-0.5 hover:opacity-80 disabled:cursor-default disabled:hover:opacity-100",children:[a.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:a.jsx("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})}),a.jsxs("span",{children:[t," ",a.jsx("span",{className:"font-mono text-claudius-text",children:e.name}),e.isError&&a.jsx("span",{className:"text-claudius-error",children:" ✕"})]}),i&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"sr-only",children:n}),a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",className:r?"rotate-180":void 0,children:a.jsx("polyline",{points:"6 9 12 15 18 9"})})]})]}),r&&i&&a.jsxs("div",{className:"mt-1 overflow-x-auto rounded-claudius-sm border border-claudius-border bg-claudius-field p-2 font-mono",children:[e.input!==void 0&&a.jsx("pre",{className:"whitespace-pre-wrap break-all",children:JSON.stringify(e.input,null,2)}),e.result!==void 0&&a.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-all border-t border-claudius-border pt-1",children:e.result})]})]})}const ke=/(https?:\/\/[^\s)]+)/,Ae=/(\*\*[^*]+\*\*)/,Me=/(\*[^*]+\*)/;function It(e,t){const n=e.match(/[.,;:!?'"]+$/),r=n?e.slice(0,-n[0].length):e,s=n?n[0]:"",i=ve(r);return i?a.jsxs(a.Fragment,{children:[a.jsxs("a",{href:i,target:"_blank",rel:"noopener noreferrer",className:"underline font-medium hover:opacity-80 text-claudius-link",children:[i.replace(/^https?:\/\//,""),a.jsx("span",{className:"sr-only",children:" (opens in a new tab)"})]},t),s]}):e}function Ot(e,t){const n=e.split(Ae),r=[];return n.forEach((s,i)=>{if(Ae.test(s)){const o=s.slice(2,-2);r.push(a.jsx("strong",{children:o},`${t}-b${i}`))}else s.split(Me).forEach((u,l)=>{if(Me.test(u)){const d=u.slice(1,-1);r.push(a.jsx("em",{children:d},`${t}-b${i}-i${l}`))}else u.split(ke).forEach((f,y)=>{ke.test(f)?r.push(It(f,`${t}-b${i}-i${l}-u${y}`)):f&&r.push(f)})})}),r}function Pt(e){const t=e.split(`
7
+ `);return t.map((n,r)=>a.jsxs("span",{children:[Ot(n,`l${r}`),r<t.length-1&&a.jsx("br",{})]},r))}const Bt=c.memo(function({role:t,content:n,isStreaming:r=!1,sources:s,attachments:i,toolUses:o,toolUsedLabel:u="Used tool:",toolDetailsLabel:l="Tool details",onSourceClick:d,isSourceActive:f,speech:y}){const C=t==="user",g=!!i&&i.length>0,h=r?kt(n):n,p=C||n!==""||!(o!=null&&o.length);return a.jsxs("div",{className:`${C?"ml-auto":"mr-auto"} max-w-[85%]`,children:[p&&a.jsxs("div",{className:`rounded-claudius-bubble px-4 py-2.5 text-sm leading-relaxed font-body ${C?"bg-claudius-user-bubble text-claudius-user-bubble-text rounded-br-claudius-tail":"bg-claudius-assistant-bubble text-claudius-assistant-bubble-text rounded-bl-claudius-tail"}`,children:[g&&a.jsx("ul",{className:`flex flex-wrap gap-2 ${n?"mb-2":""}`,"aria-label":"Attachments",children:i.map(v=>a.jsx("li",{children:a.jsx(Ue,{attachment:v,variant:"message"})},v.id))}),(n!==""||!g)&&Pt(h)]}),!C&&o&&o.length>0&&a.jsx("div",{className:"mt-1 space-y-1",children:o.map((v,N)=>a.jsx(Dt,{toolUse:v,usedLabel:u,detailsLabel:l},`${v.name}-${N}`))}),!C&&s&&s.length>0&&d&&a.jsx("div",{className:"mt-1",children:a.jsx(Et,{count:s.length,isActive:f??!1,onClick:d})}),!C&&y&&a.jsx("div",{className:"mt-1",children:a.jsx(Ct,{...y})})]})}),$e={title:"Chat",subtitle:"Ask me anything",welcomeMessage:"Hi! How can I help you today?",closeChat:"Close chat",chatMessages:"Chat messages",typingIndicator:"Assistant is typing",placeholder:"Type your message...",sendMessage:"Send message",stopGenerating:"Stop generating",toolUsed:"Used tool:",toolDetails:"Tool details",typeYourMessage:"Type your message",openChat:"Open chat",dismissGreeting:"Dismiss greeting",attachFile:"Attach a file",removeAttachment:"Remove attachment",attachmentsLabel:"Attachments",dropFilesHint:"Drop files to attach",attachmentTooLarge:"{name} is too large. The maximum size is {max}.",attachmentTypeNotAllowed:"{name} is not a supported file type.",attachmentTooMany:"You can attach up to {max} files per message.",voiceInput:"Voice input",voiceInputHold:"Hold to talk",voiceListening:"Listening...",voicePermissionDenied:"Microphone access is blocked. Allow it in your browser settings to use voice input.",voiceNoSpeech:"No speech was detected. Please try again.",voiceNoMicrophone:"No microphone was found.",voiceUnavailable:"Voice input is not available right now.",readAloud:"Read aloud",pauseReading:"Pause reading",resumeReading:"Resume reading",stopReading:"Stop reading",errorGeneric:"Something went wrong. Please try again.",errorConnection:"Failed to connect. Please try again.",errorTimeout:"Request timed out. Please try again.",errorRateLimitMinute:"Too many requests. Please wait a minute.",errorRateLimitHour:"Hourly limit reached. Please try again later.",errorAttachmentRejected:"An attachment was rejected. Please remove it and try again.",errorAttachmentQuota:"Upload limit reached. Please try again later.",errorRetry:"Retry"},we=$e;function Ht(e){return{...we,...e}}function Ne(e){return e.key===" "||e.key==="Enter"}function _t({mode:e,isListening:t,disabled:n=!1,onStart:r,onStop:s,label:i}){const o=e==="hold",u=c.useRef(!1),l=()=>{n||u.current||(u.current=!0,r({held:!0}))},d=()=>{u.current&&(u.current=!1,s())},f=h=>{o&&h.detail!==0||(t?s():r({held:!1}))},y=h=>{var p,v;!o||h.button!==0||((v=(p=h.currentTarget).setPointerCapture)==null||v.call(p,h.pointerId),l())},C=h=>{!o||!Ne(h)||(h.preventDefault(),h.repeat||l())},g=h=>{!o||!Ne(h)||(h.preventDefault(),d())};return a.jsx("button",{type:"button",disabled:n,"aria-label":i,"aria-pressed":t,title:i,onClick:f,onPointerDown:y,onPointerUp:d,onPointerCancel:d,onLostPointerCapture:d,onKeyDown:C,onKeyUp:g,onBlur:d,onContextMenu:o?h=>h.preventDefault():void 0,style:o?{WebkitTouchCallout:"none"}:void 0,className:`flex h-11 w-11 shrink-0 items-center justify-center rounded-claudius-sm border transition-colors focus:outline-none focus:ring-1 focus:ring-claudius-accent disabled:opacity-50 ${t?"border-claudius-accent bg-claudius-accent text-claudius-accent-text focus:ring-2 focus:ring-offset-2 focus:ring-offset-claudius-surface":"border-claudius-border bg-claudius-field text-claudius-text-muted hover:text-claudius-text focus:border-claudius-accent"} ${o?"touch-none select-none":""}`,children:t&&!o?a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:a.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1.5"})}):a.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"}),a.jsx("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),a.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"22"})]})})}function zt({active:e}){return a.jsxs("span",{"aria-hidden":"true","data-claudius-voice-level":e?"active":"idle",className:"claudius-voice-level pointer-events-none absolute right-3 top-1/2 flex h-4 -translate-y-1/2 items-center gap-0.5 text-claudius-accent",children:[a.jsx("span",{}),a.jsx("span",{}),a.jsx("span",{}),a.jsx("span",{})]})}function ge(e,t){return e.replace(/\{(\w+)\}/g,(n,r)=>r in t?String(t[r]):n)}const Ut={en:"en-US",es:"es-ES",fr:"fr-FR",de:"de-DE"},$t=["toggle","hold"];function Le(e,t){if(!(!e||!e.includes("-")))return e.toLowerCase().split("-")[0]===t?e:void 0}function Ft(e,t){const n=t==null?void 0:t.trim();if(n)return n;const r=typeof document<"u"?Le(document.documentElement.lang,e):void 0;if(r)return r;const s=typeof navigator<"u"?Le(navigator.language,e):void 0;return s||Ut[e]}function Wt(e,t){const n=typeof e=="object"&&e!==null&&!Array.isArray(e);if(e!==!0&&!n)return null;const r=e===!0?{}:e,s={input:r.input??!0,output:r.output??!0,mode:$t.includes(r.mode)?r.mode:"toggle",autoSubmit:r.autoSubmit??!1,lang:Ft(t,r.lang)};return s.input||s.output?s:null}function Gt(e,t,n){const r=t.trim();if(!r)return e;const s=e.trimEnd();return(s?`${s} ${r}`:r).slice(0,n)}function Vt(e){const t=[];let n=0;for(let r=0;r<e.length;r++){const s=e[r];(s===`
8
+ `||s==="。"||s==="!"||s==="?"||(s==="."||s==="!"||s==="?")&&(r+1===e.length||/\s/.test(e[r+1])))&&(t.push(e.slice(n,r+1)),n=r+1)}return n<e.length&&t.push(e.slice(n)),t}function Kt(e,t=150){const n=[];let r="";const s=()=>{const i=r.trim();i&&n.push(i),r=""};for(const i of Vt(e)){if((r+i).trim().length<=t){r+=i;continue}if(s(),i.trim().length<=t){r=i;continue}for(let o of i.trim().split(/\s+/)){for(r&&`${r} ${o}`.length>t&&s();o.length>t;)n.push(o.slice(0,t)),o=o.slice(t);r=r?`${r} ${o}`:o}}return s(),n}function De(){if(typeof window>"u")return;const e=window;return e.SpeechRecognition??e.webkitSpeechRecognition}function qt(e){switch(e){case"not-allowed":case"service-not-allowed":return"permission";case"no-speech":return"no-speech";case"audio-capture":return"no-microphone";default:return"unavailable"}}function Yt(e){const[t]=c.useState(()=>De()!==void 0),[n,r]=c.useState(!1),[s,i]=c.useState(!1),o=c.useRef(null),u=c.useRef(!1),l=c.useRef(e);c.useEffect(()=>{l.current=e});const d=c.useCallback(g=>{g.onstart=null,g.onend=null,g.onerror=null,g.onresult=null,g.onspeechstart=null,g.onspeechend=null,o.current===g&&(o.current=null),r(!1),i(!1)},[]),f=c.useCallback(()=>{const g=o.current;g&&(d(g),g.abort())},[d]),y=c.useCallback(()=>{const g=o.current;return g?(u.current?g.stop():f(),!0):!1},[f]),C=c.useCallback(()=>{var N,T;const g=De();if(!g||o.current)return!1;const h=new g;h.lang=l.current.lang,h.interimResults=!0,h.continuous=!1;let p="";const v=()=>{u.current=!0};h.onstart=v,h.onspeechstart=()=>{v(),i(!0)},h.onspeechend=()=>i(!1),h.onresult=E=>{var M,A;let x="",S="";for(let b=0;b<E.results.length;b++){const _=E.results[b];_.isFinal?x+=_[0].transcript:S+=_[0].transcript}p=x,v(),i(!0),(A=(M=l.current).onTranscript)==null||A.call(M,x+S)},h.onerror=E=>{var x,S;E.error!=="aborted"&&((S=(x=l.current).onError)==null||S.call(x,qt(E.error))),d(h),h.abort()},h.onend=()=>{var E,x;d(h),(x=(E=l.current).onEnd)==null||x.call(E,p)},o.current=h,u.current=!1,r(!0);try{h.start()}catch{return d(h),(T=(N=l.current).onError)==null||T.call(N,"unavailable"),!1}return!0},[d]);return c.useEffect(()=>f,[f]),{isSupported:t,isListening:n,isSpeechDetected:s,start:C,stop:y,abort:f}}const ce=2e3,Qt=1800;function Ie(e){var n;const t=(n=e.dataTransfer)==null?void 0:n.types;return!!t&&Array.from(t).includes("Files")}function Zt({onSend:e,isLoading:t,isStreaming:n=!1,onStop:r,placeholder:s,translations:i,attachments:o=null,voice:u=null,onVoiceStart:l,isReadingAloud:d=!1}){const f=i??we,[y,C]=c.useState(""),[g,h]=c.useState([]),[p,v]=c.useState(null),[N,T]=c.useState(!1),[E,x]=c.useState(null),S=c.useRef(null),M=c.useRef(null),A=c.useRef([]),b=c.useRef(0),_=c.useRef(""),z=c.useRef(""),I=c.useRef(!1),P=c.useRef(!1),q=c.useRef(!1),Q=m=>{_.current=m,C(m)},V=y.length,Z=V>=Qt,w=V>=ce,te=s??f.placeholder,oe=!!o&&g.length<o.maxCount,R=n&&!!r;c.useEffect(()=>{var m;t||(m=S.current)==null||m.focus()},[t]);const B=c.useCallback((m,D)=>{if(!o)return"";switch(D){case"size":return ge(f.attachmentTooLarge,{name:m,max:xe(o.maxSizeBytes)});case"type":return ge(f.attachmentTypeNotAllowed,{name:m});case"count":return ge(f.attachmentTooMany,{max:o.maxCount})}},[o,f]),O=c.useCallback(async m=>{if(!o||m.length===0)return;const{accepted:D,rejected:se}=ct(m,A.current.length,o);if(v(se.length>0?B(se[0].file.name,se[0].reason):null),D.length===0)return;const Ye=await Promise.all(D.map(dt));A.current=[...A.current,...Ye],h(A.current)},[o,B]),Y=c.useCallback(m=>{A.current=A.current.filter(D=>D.id!==m),h(A.current),v(null)},[]),K=()=>{const m=_.current.trim(),D=A.current;!m&&D.length===0||_.current.length>=ce||(D.length>0?e(m,D):e(m),Q(""),A.current=[],h([]),v(null),x(null))},X=m=>{switch(m){case"permission":return f.voicePermissionDenied;case"no-speech":return f.voiceNoSpeech;case"no-microphone":return f.voiceNoMicrophone;case"unavailable":return f.voiceUnavailable}},H=Yt({lang:(u==null?void 0:u.lang)??"en-US",onTranscript:m=>Q(Gt(z.current,m,ce)),onEnd:m=>{const D=m.trim()!=="";if(D&&(P.current=!0),!I.current){L();return}D&&F()},onError:m=>{m==="no-speech"&&P.current||(q.current=!0,x(X(m)))}}),j=!!(u!=null&&u.input)&&H.isSupported,k=H.isListening;c.useEffect(()=>{const m=S.current;k&&m&&(m.scrollLeft=m.scrollWidth)},[k,y]);const L=()=>{u!=null&&u.autoSubmit&&P.current&&!q.current&&K()},F=()=>{const m=_.current;H.start()&&(z.current=m)},G=({held:m})=>{x(null),I.current=m,P.current=!1,q.current=!1,l==null||l(),F()},ee=()=>{const m=I.current;I.current=!1,!H.stop()&&m&&L()},re=()=>{I.current=!1,H.abort()},{abort:ne}=H;c.useEffect(()=>{!t&&!d||(I.current=!1,ne())},[t,d,ne]);const W=m=>{m.preventDefault(),re(),K()},J=m=>{const D=m.target.value;D.length<=ce&&(re(),x(null),Q(D))},ie=m=>{const D=Array.from(m.target.files??[]);m.target.value="",O(D)},U=m=>{var se;if(!o)return;const D=Array.from(((se=m.clipboardData)==null?void 0:se.files)??[]);D.length!==0&&(m.preventDefault(),O(D))},fe=m=>{!o||!Ie(m)||(m.preventDefault(),b.current+=1,T(!0))},pe=m=>{!o||!Ie(m)||m.preventDefault()},Ke=()=>{o&&(b.current=Math.max(0,b.current-1),b.current===0&&T(!1))},qe=m=>{var D;o&&(m.preventDefault(),b.current=0,T(!1),O(Array.from(((D=m.dataTransfer)==null?void 0:D.files)??[])))};return a.jsxs("form",{onSubmit:W,onDragEnter:fe,onDragOver:pe,onDragLeave:Ke,onDrop:qe,"data-drag-over":N||void 0,className:`relative border-t border-claudius-border bg-claudius-surface p-3 ${N?"ring-2 ring-inset ring-claudius-accent":""}`,children:[N&&a.jsx("div",{"aria-hidden":"true",className:"pointer-events-none absolute inset-0 z-10 flex items-center justify-center bg-claudius-surface text-sm font-medium text-claudius-accent",children:f.dropFilesHint}),o&&g.length>0&&a.jsx("ul",{"aria-label":f.attachmentsLabel,className:"mb-2 flex flex-wrap gap-3 pt-1",children:g.map(m=>a.jsx("li",{children:a.jsx(Ue,{attachment:m,variant:"composer",onRemove:()=>Y(m.id),removeLabel:`${f.removeAttachment}: ${m.name}`})},m.id))}),a.jsxs("div",{className:"flex gap-2",children:[o&&a.jsxs(a.Fragment,{children:[a.jsx("input",{ref:M,type:"file",multiple:!0,hidden:!0,tabIndex:-1,accept:o.allowedTypes.join(","),onChange:ie,"aria-label":f.attachFile}),a.jsx("button",{type:"button",onClick:()=>{var m;return(m=M.current)==null?void 0:m.click()},disabled:t||!oe,"aria-label":f.attachFile,title:f.attachFile,className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-claudius-sm border border-claudius-border bg-claudius-field text-claudius-text-muted transition-colors hover:text-claudius-text focus:border-claudius-accent focus:outline-none focus:ring-1 focus:ring-claudius-accent disabled:opacity-50",children:a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:a.jsx("path",{d:"m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48"})})})]}),a.jsxs("div",{className:"relative min-w-0 flex-1",children:[a.jsx("input",{ref:S,type:"text",value:y,onChange:J,onPaste:U,placeholder:k?f.voiceListening:te,disabled:t,"aria-label":f.typeYourMessage,"aria-describedby":Z?"char-count":void 0,className:`h-full w-full rounded-claudius-sm border border-claudius-border bg-claudius-field py-2 pl-3 text-sm font-body text-claudius-text placeholder:text-claudius-text-muted focus:border-claudius-accent focus:outline-none focus:ring-1 focus:ring-claudius-accent disabled:opacity-50 ${k?"pr-10":"pr-3"}`}),k&&a.jsx(zt,{active:H.isSpeechDetected})]}),j&&u&&a.jsx(_t,{mode:u.mode,isListening:k,disabled:t,onStart:G,onStop:ee,label:u.mode==="hold"?f.voiceInputHold:f.voiceInput}),R?a.jsx("button",{type:"button",onClick:r,"aria-label":f.stopGenerating,className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-claudius-sm bg-claudius-accent text-claudius-accent-text transition-colors hover:opacity-90",children:a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:a.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1.5"})})}):a.jsx("button",{type:"submit",disabled:t||w,"aria-label":f.sendMessage,className:"flex h-11 w-11 shrink-0 items-center justify-center rounded-claudius-sm bg-claudius-accent text-claudius-accent-text transition-colors hover:opacity-90 disabled:opacity-50",children:a.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),a.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]}),(p??E)&&a.jsx("div",{role:"alert",className:"mt-1 text-xs text-claudius-error",children:p??E}),Z&&a.jsxs("div",{id:"char-count",className:`mt-1 text-xs text-right ${w?"text-claudius-error":"text-claudius-text-muted"}`,"aria-live":"polite",children:[V,"/",ce]})]})}const Jt=["blog","page","external"],Xt={blog:"Blog",page:"Page",external:"External"};function en(e){try{return new URL(e).hostname}catch{return e}}const tn=c.memo(function({sources:t,onClose:n}){const r=Jt.map(i=>({type:i,label:Xt[i],items:t.filter(o=>o.type===i)})).filter(i=>i.items.length>0),s=t.length===1?"1 source found":`${t.length} sources found`;return a.jsxs("div",{className:"absolute inset-y-0 left-0 z-10 flex w-[280px] flex-col border-r-2 border-claudius-border bg-claudius-surface rounded-r-claudius-lg transition-transform duration-200 ease-out",children:[a.jsxs("div",{className:"flex items-center justify-between border-b border-claudius-border px-4 py-3",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-sm font-heading font-semibold text-claudius-text",children:"Sources"}),a.jsx("p",{className:"text-xs text-claudius-text-muted",children:s})]}),a.jsx("button",{onClick:n,"aria-label":"Close sources",className:"flex h-7 w-7 items-center justify-center rounded-claudius-full text-claudius-text-muted transition-colors hover:bg-claudius-surface-muted hover:text-claudius-text",children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),a.jsx("div",{className:"flex-1 overflow-y-auto px-3 py-3 space-y-4",children:r.map(i=>a.jsxs("div",{children:[a.jsx("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-claudius-text-muted",children:i.label}),a.jsx("div",{className:"space-y-2",children:i.items.map(o=>{const u=ve(o.url);return u?a.jsxs("a",{href:u,target:"_blank",rel:"noopener noreferrer",className:"block rounded-claudius-md border-2 border-claudius-border bg-claudius-surface-muted p-3 transition-colors hover:bg-claudius-border",children:[a.jsx("p",{className:"truncate text-sm font-medium text-claudius-text",children:o.title}),a.jsx("p",{className:"mt-0.5 text-xs text-claudius-text-muted",children:en(u)})]},u):null})})]},i.type))})]})});function nn({title:e,subtitle:t,titleId:n,closeLabel:r,onClose:s}){return a.jsxs("div",{className:"flex items-center gap-3 bg-claudius-accent px-5 py-4",children:[a.jsx("div",{"aria-hidden":"true",className:"flex h-8 w-8 items-center justify-center rounded-claudius-full bg-claudius-accent-soft text-sm font-bold text-claudius-accent-text",children:e.charAt(0).toUpperCase()}),a.jsxs("div",{className:"flex-1",children:[a.jsx("h2",{id:n,className:"text-sm font-heading font-semibold text-claudius-accent-text",children:e}),a.jsx("p",{className:"text-xs text-claudius-accent-text",children:t})]}),a.jsx("button",{onClick:s,"aria-label":r,className:"flex h-10 w-10 items-center justify-center rounded-claudius-full text-claudius-accent-text-muted transition-colors hover:bg-claudius-accent-soft hover:text-claudius-accent-text",children:a.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),a.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})}function rn({message:e,retryLabel:t,onRetry:n}){return a.jsxs("div",{role:"alert",className:"mx-auto flex max-w-[90%] flex-col items-center gap-2 rounded-claudius-sm bg-claudius-error-surface px-3 py-2 text-center text-xs text-claudius-error",children:[a.jsx("span",{children:e}),n&&a.jsx("button",{type:"button",onClick:n,className:"rounded-claudius-md bg-claudius-error px-3 py-1 text-xs font-semibold text-claudius-error-text transition-opacity hover:opacity-90 focus:outline-none focus-visible:ring-2 focus-visible:ring-claudius-error focus-visible:ring-offset-1",children:t})]})}function sn({label:e}){return a.jsx("div",{role:"status","aria-live":"polite","aria-label":e,className:"mr-auto flex max-w-[85%]",children:a.jsxs("div",{className:"flex gap-1 rounded-claudius-bubble rounded-bl-claudius-tail bg-claudius-assistant-bubble px-4 py-3",children:[a.jsx("span",{className:"h-2 w-2 motion-safe:animate-bounce rounded-claudius-full bg-claudius-text-muted [animation-delay:0ms]"}),a.jsx("span",{className:"h-2 w-2 motion-safe:animate-bounce rounded-claudius-full bg-claudius-text-muted [animation-delay:150ms]"}),a.jsx("span",{className:"h-2 w-2 motion-safe:animate-bounce rounded-claudius-full bg-claudius-text-muted [animation-delay:300ms]"})]})})}function an(e,t,n){const[r,s]=c.useState(0),i=c.useRef(0),o=c.useRef(0),u=c.useRef(0),l=c.useRef(!1);return c.useEffect(()=>{const d=e.current;if(!n||!d)return;const f=g=>{if(d.scrollTop>0){l.current=!1;return}l.current=!0,o.current=g.touches[0].clientY,u.current=Date.now()},y=g=>{if(!l.current)return;let h=g.touches[0].clientY-o.current;h<0&&(h=h*.3),i.current=h,s(h)},C=()=>{if(!l.current)return;l.current=!1;const g=i.current,h=(Date.now()-u.current)/1e3,p=d.getBoundingClientRect().height,v=h>.05&&g>0&&g/h>500,N=g>p*.3;v||N?t():(i.current=0,s(0))};return d.addEventListener("touchstart",f,{passive:!0}),d.addEventListener("touchmove",y,{passive:!0}),d.addEventListener("touchend",C),()=>{d.removeEventListener("touchstart",f),d.removeEventListener("touchmove",y),d.removeEventListener("touchend",C)}},[e,t,n]),{offsetY:r}}const on='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function cn(e,t){c.useEffect(()=>{const n=e.current;if(!n)return;const r=s=>{if(s.key!=="Tab")return;const i=Array.from(n.querySelectorAll(on)).filter(d=>!d.hasAttribute("aria-hidden"));if(i.length===0)return;const o=i[0],u=i[i.length-1],l=document.activeElement;s.shiftKey&&l===o?(s.preventDefault(),u.focus()):!s.shiftKey&&l===u&&(s.preventDefault(),o.focus())};return n.addEventListener("keydown",r),()=>n.removeEventListener("keydown",r)},[e,t])}function ue(){if(!(typeof window>"u")&&!(typeof window.SpeechSynthesisUtterance>"u"))return window.speechSynthesis??void 0}function un(e){const[t]=c.useState(()=>ue()!==void 0),[n,r]=c.useState(null),[s,i]=c.useState(!1),o=c.useRef(0),u=c.useRef(!1),l=c.useRef([]),d=c.useCallback(()=>{o.current+=1,u.current=!1,l.current=[],r(null),i(!1)},[]),f=c.useCallback(()=>{const h=l.current.length>0;d();const p=ue();!h||!p||(p.cancel(),p.paused&&p.resume())},[d]),y=c.useCallback((h,p)=>{const v=ue();if(!v)return;d(),(v.speaking||v.pending)&&v.cancel(),v.paused&&v.resume();const N=Kt(p);if(N.length===0)return;const T=o.current,E=()=>o.current===T;l.current=N.map((x,S)=>{const M=new SpeechSynthesisUtterance(x);return M.lang=e,M.onerror=A=>{if(!E())return;(A.error==="interrupted"||A.error==="canceled")&&!u.current?d():f()},M.onpause=()=>{E()&&i(!0)},M.onresume=()=>{E()&&i(!1)},M.onend=()=>{E()&&(u.current&&!v.paused?f():S===N.length-1&&d())},M}),r(h);for(const x of l.current)v.speak(x)},[e,f,d]),C=c.useCallback(()=>{const h=ue();h&&(u.current=!0,h.pause(),h.paused&&i(!0))},[]),g=c.useCallback(()=>{const h=ue();h&&(u.current=!1,h.resume(),i(!1))},[]);return c.useEffect(()=>f,[f]),{isSupported:t,activeId:n,isPaused:s,speak:y,pause:C,resume:g,cancel:f}}const ln=/\*\*([^*]+)\*\*/g,dn=/\*([^*]+)\*/g,fn=/https?:\/\/[^\s)]+/g;function Oe(e){return e.replace(ln,"$1").replace(dn,"$1").replace(fn,t=>{var s;const n=((s=t.match(/[.,;:!?'"]+$/))==null?void 0:s[0])??"",r=n?t.slice(0,-n.length):t;try{return new URL(r).hostname+n}catch{return t}})}const hn={"bottom-right":"bottom-24 right-3 sm:right-6","bottom-left":"bottom-24 left-3 sm:left-6","top-right":"top-24 right-3 sm:right-6","top-left":"top-24 left-3 sm:left-6"};function mn({messages:e,isLoading:t,isStreaming:n=!1,streamingMessageId:r=null,error:s,canRetry:i=!1,onSend:o,onStop:u,onRetry:l,onClose:d,title:f="Chat",subtitle:y="Ask me anything",welcomeMessage:C="Hi! How can I help you today?",placeholder:g,position:h="bottom-right",translations:p,isMobile:v=!1,attachments:N=null,voice:T=null}){const E=c.useId(),x=c.useRef(null),S=c.useRef(null),[M,A]=c.useState(null);cn(x,!0);const b=un((T==null?void 0:T.lang)??"en-US"),_=!!(T!=null&&T.output)&&b.isSupported,z={play:(p==null?void 0:p.readAloud)??"Read aloud",pause:(p==null?void 0:p.pauseReading)??"Pause reading",resume:(p==null?void 0:p.resumeReading)??"Resume reading",stop:(p==null?void 0:p.stopReading)??"Stop reading"},{offsetY:I}=an(S,d,v),P=I!==0,q=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)").matches:!1;c.useEffect(()=>{const w=S.current;w&&(w.scrollTop=w.scrollHeight)},[e,t]),c.useEffect(()=>{const w=te=>{te.key==="Escape"&&!te.isComposing&&d()};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[d]);const Q=(p==null?void 0:p.closeChat)??"Close chat",V=(p==null?void 0:p.chatMessages)??"Chat messages",Z=[...e].reverse().find(w=>w.role==="assistant");return a.jsxs("div",{ref:x,role:"dialog","aria-modal":v?"true":void 0,"aria-labelledby":E,className:v?"claudius-bottom-sheet fixed inset-x-0 bottom-0 z-50 flex h-[90vh] w-full flex-col overflow-hidden rounded-t-claudius-lg bg-claudius-surface shadow-claudius-elevated font-body":`fixed ${hn[h]} z-50 flex h-[min(500px,calc(100vh-7rem))] w-[calc(100vw-1.5rem)] max-w-[380px] sm:max-w-[400px] md:max-w-[440px] flex-col overflow-hidden rounded-claudius-lg bg-claudius-surface shadow-claudius-elevated font-body`,style:v&&!q?{transform:`translateY(${Math.max(0,I)}px)`}:void 0,"data-dragging":P||void 0,children:[v&&a.jsx("div",{className:"flex justify-center py-2","aria-hidden":"true",children:a.jsx("div",{className:"h-1 w-8 rounded-claudius-full bg-claudius-border"})}),a.jsx(nn,{title:f,subtitle:y,titleId:E,closeLabel:Q,onClose:d}),a.jsxs("div",{className:"relative flex-1 overflow-hidden",children:[M&&a.jsx(tn,{sources:M.sources,onClose:()=>A(null)}),a.jsxs("div",{ref:S,role:"log","aria-label":V,className:"h-full space-y-3 overflow-y-auto px-4 py-4",children:[e.length===0&&!s&&a.jsx("div",{className:"mr-auto flex max-w-[85%]",children:a.jsx("div",{className:"rounded-claudius-bubble rounded-bl-claudius-tail bg-claudius-assistant-bubble px-4 py-2.5 text-sm leading-relaxed text-claudius-assistant-bubble-text",children:C})}),e.map(w=>a.jsx(Bt,{role:w.role,content:w.content,isStreaming:w.id===r,sources:w.sources,attachments:w.attachments,toolUses:w.toolUses,toolUsedLabel:p==null?void 0:p.toolUsed,toolDetailsLabel:p==null?void 0:p.toolDetails,isSourceActive:(M==null?void 0:M.messageId)===w.id,onSourceClick:()=>{(M==null?void 0:M.messageId)===w.id?A(null):w.sources&&w.sources.length>0&&A({messageId:w.id,sources:w.sources})},speech:_&&w.role==="assistant"&&w.id!==r&&w.content.trim()!==""?{state:b.activeId!==w.id?"idle":b.isPaused?"paused":"speaking",labels:z,onPlay:()=>b.speak(w.id,Oe(w.content)),onPause:b.pause,onResume:b.resume,onStop:b.cancel}:void 0},w.id)),t&&!(r!==null&&e.some(w=>w.id===r&&w.content.length>0))&&a.jsx(sn,{label:(p==null?void 0:p.typingIndicator)??"Assistant is typing"}),s&&a.jsx(rn,{message:s,retryLabel:(p==null?void 0:p.errorRetry)??"Retry",onRetry:i&&l&&!t?l:void 0})]})]}),a.jsx("div",{"data-claudius-live":"assistant","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:Z&&Z.id!==r?Oe(Z.content):""}),a.jsx(Zt,{onSend:o,isLoading:t,isStreaming:n,onStop:u,placeholder:g,translations:p,attachments:N,voice:T,onVoiceStart:b.cancel,isReadingAloud:b.activeId!==null})]})}function pn({message:e,position:t,onOpen:n,onDismiss:r,dismissLabel:s}){const i=t.startsWith("bottom"),o=t.endsWith("right"),u=["claudius-greeting-bubble","fixed z-40 max-w-xs",i?"bottom-20":"top-20",o?"right-4":"left-4"].join(" ");return a.jsxs("div",{className:u,role:"status","aria-live":"polite",children:[a.jsx("button",{type:"button",onClick:n,className:"block w-full rounded-claudius-lg bg-claudius-surface p-4 pr-8 text-left text-sm font-body text-claudius-text shadow-claudius-floating ring-1 ring-claudius-border transition hover:shadow-claudius-floating-hover focus:outline-none focus:ring-2 focus:ring-claudius-accent",children:e}),a.jsx("button",{type:"button",onClick:l=>{l.stopPropagation(),r()},"aria-label":s,className:"absolute right-1 top-1 flex h-6 w-6 items-center justify-center rounded-claudius-full text-claudius-text-muted hover:bg-claudius-surface-muted focus:outline-none focus:ring-2 focus:ring-claudius-accent",children:a.jsx("span",{"aria-hidden":"true",children:"×"})})]})}const gn={title:"Chat",subtitle:"Pregúntame lo que quieras",welcomeMessage:"¡Hola! ¿En qué puedo ayudarte hoy?",closeChat:"Cerrar chat",chatMessages:"Mensajes del chat",typingIndicator:"El asistente está escribiendo",placeholder:"Escribe tu mensaje...",sendMessage:"Enviar mensaje",stopGenerating:"Detener la respuesta",toolUsed:"Herramienta usada:",toolDetails:"Detalles de la herramienta",typeYourMessage:"Escribe tu mensaje",openChat:"Abrir chat",dismissGreeting:"Descartar saludo",attachFile:"Adjuntar un archivo",removeAttachment:"Quitar adjunto",attachmentsLabel:"Adjuntos",dropFilesHint:"Suelta los archivos para adjuntarlos",attachmentTooLarge:"{name} es demasiado grande. El tamaño máximo es {max}.",attachmentTypeNotAllowed:"{name} no es un tipo de archivo compatible.",attachmentTooMany:"Puedes adjuntar hasta {max} archivos por mensaje.",voiceInput:"Entrada de voz",voiceInputHold:"Mantén pulsado para hablar",voiceListening:"Escuchando...",voicePermissionDenied:"El acceso al micrófono está bloqueado. Permítelo en la configuración de tu navegador para usar la entrada de voz.",voiceNoSpeech:"No se detectó ninguna voz. Inténtalo de nuevo.",voiceNoMicrophone:"No se encontró ningún micrófono.",voiceUnavailable:"La entrada de voz no está disponible en este momento.",readAloud:"Leer en voz alta",pauseReading:"Pausar la lectura",resumeReading:"Reanudar la lectura",stopReading:"Detener la lectura",errorGeneric:"Algo salió mal. Inténtalo de nuevo.",errorConnection:"No se pudo conectar. Inténtalo de nuevo.",errorTimeout:"La solicitud tardó demasiado. Inténtalo de nuevo.",errorRateLimitMinute:"Demasiadas solicitudes. Espera un minuto.",errorRateLimitHour:"Has alcanzado el límite por hora. Inténtalo más tarde.",errorAttachmentRejected:"Se rechazó un adjunto. Quítalo e inténtalo de nuevo.",errorAttachmentQuota:"Límite de subida alcanzado. Inténtalo más tarde.",errorRetry:"Reintentar"},xn={title:"Chat",subtitle:"Posez-moi vos questions",welcomeMessage:"Bonjour ! Comment puis-je vous aider aujourd'hui ?",closeChat:"Fermer le chat",chatMessages:"Messages du chat",typingIndicator:"L'assistant écrit",placeholder:"Saisissez votre message...",sendMessage:"Envoyer le message",stopGenerating:"Arrêter la génération",toolUsed:"Outil utilisé :",toolDetails:"Détails de l'outil",typeYourMessage:"Saisissez votre message",openChat:"Ouvrir le chat",dismissGreeting:"Ignorer le message d'accueil",attachFile:"Joindre un fichier",removeAttachment:"Retirer la pièce jointe",attachmentsLabel:"Pièces jointes",dropFilesHint:"Déposez les fichiers pour les joindre",attachmentTooLarge:"{name} est trop volumineux. La taille maximale est de {max}.",attachmentTypeNotAllowed:"{name} n'est pas un type de fichier pris en charge.",attachmentTooMany:"Vous pouvez joindre jusqu'à {max} fichiers par message.",voiceInput:"Saisie vocale",voiceInputHold:"Maintenez pour parler",voiceListening:"Écoute en cours...",voicePermissionDenied:"L'accès au microphone est bloqué. Autorisez-le dans les paramètres de votre navigateur pour utiliser la saisie vocale.",voiceNoSpeech:"Aucune voix n'a été détectée. Veuillez réessayer.",voiceNoMicrophone:"Aucun microphone n'a été trouvé.",voiceUnavailable:"La saisie vocale n'est pas disponible pour le moment.",readAloud:"Lire à voix haute",pauseReading:"Mettre la lecture en pause",resumeReading:"Reprendre la lecture",stopReading:"Arrêter la lecture",errorGeneric:"Une erreur s'est produite. Veuillez réessayer.",errorConnection:"Échec de la connexion. Veuillez réessayer.",errorTimeout:"La requête a expiré. Veuillez réessayer.",errorRateLimitMinute:"Trop de requêtes. Veuillez patienter une minute.",errorRateLimitHour:"Limite horaire atteinte. Veuillez réessayer plus tard.",errorAttachmentRejected:"Une pièce jointe a été refusée. Retirez-la et réessayez.",errorAttachmentQuota:"Limite d'envoi atteinte. Veuillez réessayer plus tard.",errorRetry:"Réessayer"},bn={title:"Chat",subtitle:"Fragen Sie mich alles",welcomeMessage:"Hallo! Wie kann ich Ihnen heute helfen?",closeChat:"Chat schließen",chatMessages:"Chat-Nachrichten",typingIndicator:"Der Assistent schreibt",placeholder:"Geben Sie Ihre Nachricht ein...",sendMessage:"Nachricht senden",stopGenerating:"Generierung stoppen",toolUsed:"Verwendetes Tool:",toolDetails:"Tool-Details",typeYourMessage:"Geben Sie Ihre Nachricht ein",openChat:"Chat öffnen",dismissGreeting:"Begrüßung schließen",attachFile:"Datei anhängen",removeAttachment:"Anhang entfernen",attachmentsLabel:"Anhänge",dropFilesHint:"Dateien hier ablegen, um sie anzuhängen",attachmentTooLarge:"{name} ist zu groß. Die maximale Größe beträgt {max}.",attachmentTypeNotAllowed:"{name} ist kein unterstützter Dateityp.",attachmentTooMany:"Sie können bis zu {max} Dateien pro Nachricht anhängen.",voiceInput:"Spracheingabe",voiceInputHold:"Zum Sprechen gedrückt halten",voiceListening:"Ich höre zu...",voicePermissionDenied:"Der Zugriff auf das Mikrofon ist blockiert. Erlauben Sie ihn in den Einstellungen Ihres Browsers, um die Spracheingabe zu nutzen.",voiceNoSpeech:"Es wurde keine Sprache erkannt. Bitte versuchen Sie es erneut.",voiceNoMicrophone:"Es wurde kein Mikrofon gefunden.",voiceUnavailable:"Die Spracheingabe ist momentan nicht verfügbar.",readAloud:"Vorlesen",pauseReading:"Vorlesen pausieren",resumeReading:"Vorlesen fortsetzen",stopReading:"Vorlesen beenden",errorGeneric:"Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut.",errorConnection:"Verbindung fehlgeschlagen. Bitte versuchen Sie es erneut.",errorTimeout:"Zeitüberschreitung der Anfrage. Bitte versuchen Sie es erneut.",errorRateLimitMinute:"Zu viele Anfragen. Bitte warten Sie eine Minute.",errorRateLimitHour:"Stündliches Limit erreicht. Bitte versuchen Sie es später erneut.",errorAttachmentRejected:"Ein Anhang wurde abgelehnt. Bitte entfernen Sie ihn und versuchen Sie es erneut.",errorAttachmentQuota:"Upload-Limit erreicht. Bitte versuchen Sie es später erneut.",errorRetry:"Erneut versuchen"},Re={en:$e,es:gn,fr:xn,de:bn};function Pe(e){if(!e)return;const t=e.toLowerCase().split("-")[0];return Object.prototype.hasOwnProperty.call(Re,t)?t:void 0}function je(){const e=typeof document<"u"?Pe(document.documentElement.lang):void 0;if(e)return e;const t=typeof navigator<"u"?Pe(navigator.language):void 0;return t||"en"}function Fe(e={}){const{locale:t,translations:n}=e,r=Re[t??je()];return n?{...r,...n}:{...r}}const Be=["accent","accentText","accentSoft","accentTextMuted","surface","surfaceMuted","text","textMuted","border","userBubble","userBubbleText","assistantBubble","assistantBubbleText","field","error","errorSurface","errorText","link","scrim"],yn=["sm","md","lg","full","tail"],vn=["elevated","floating","floatingHover"],wn=["heading","body"],Ee={default:{name:"default"},minimal:{name:"minimal",colors:{accent:"#171717",accentText:"#ffffff",surface:"#ffffff",surfaceMuted:"#f5f5f5",text:"#171717",textMuted:"#737373",border:"#e5e5e5",link:"#171717"},colorsDark:{accent:"#fafafa",accentText:"#171717",surface:"#0a0a0a",surfaceMuted:"#1c1c1c",text:"#fafafa",textMuted:"#a3a3a3",border:"#2e2e2e",field:"#1c1c1c",link:"#fafafa"},radii:{sm:"4px",md:"6px",lg:"10px"},shadows:{elevated:"0 4px 16px rgb(0 0 0 / 0.12)",floating:"0 2px 8px rgb(0 0 0 / 0.12)",floatingHover:"0 4px 12px rgb(0 0 0 / 0.16)"}},playful:{name:"playful",colors:{accent:"#8b5cf6",surfaceMuted:"#f5f3ff",assistantBubbleText:"#4c1d95",link:"#7c3aed"},colorsDark:{accent:"#a78bfa",surfaceMuted:"#2e1065",assistantBubbleText:"#ede9fe",link:"#c4b5fd"},radii:{sm:"12px",md:"16px",lg:"24px",tail:"8px"},shadows:{elevated:"0 24px 48px -12px rgb(139 92 246 / 0.35)",floating:"0 10px 20px -5px rgb(139 92 246 / 0.4)",floatingHover:"0 16px 28px -6px rgb(139 92 246 / 0.5)"},fonts:{heading:"ui-rounded, 'Hiragino Maru Gothic ProN', system-ui",body:"ui-rounded, 'Hiragino Maru Gothic ProN', system-ui"}},corporate:{name:"corporate",colors:{accent:"#1e3a5f",surfaceMuted:"#f3f4f6",text:"#1f2937",textMuted:"#6b7280",border:"#d1d5db",link:"#1d4ed8"},colorsDark:{accent:"#2c5282",link:"#93c5fd"},radii:{sm:"4px",md:"6px",lg:"8px",tail:"2px"},shadows:{elevated:"0 8px 24px rgb(15 23 42 / 0.16)",floating:"0 4px 12px rgb(15 23 42 / 0.18)",floatingHover:"0 6px 16px rgb(15 23 42 / 0.24)"},fonts:{heading:"'Segoe UI', 'Helvetica Neue', Arial, system-ui",body:"'Segoe UI', 'Helvetica Neue', Arial, system-ui"}}};function Rn(e){return Object.prototype.hasOwnProperty.call(Ee,e)}const jn=new Set(["light","dark","auto"]);function En(e){if(e===void 0)return{mode:"light"};if(typeof e=="string"){if(jn.has(e))return{mode:e};if(Rn(e)){const t=Ee[e];return{mode:t.colorScheme??"light",theme:t}}return{mode:"light",url:e}}return{mode:e.colorScheme??"light",theme:e}}function Sn(e){return e.replace(/[A-Z]/g,t=>`-${t.toLowerCase()}`)}function Tn(e,t){console.warn(`[Claudius] Ignoring unknown theme token "${t}" in "${e}"`)}function le(e,t,n,r,s,i=""){if(s)for(const[o,u]of Object.entries(s)){if(!r.includes(o)){Tn(t,o);continue}typeof u=="string"&&(e[`${n}${Sn(o)}${i}`]=u)}}function Cn(e){const t={};le(t,"colors","--cl-color-",Be,e.colors);for(const[n,r]of Object.entries({...t}))t[`${n}-dark`]=r;return le(t,"colorsDark","--cl-color-",Be,e.colorsDark,"-dark"),le(t,"radii","--cl-radius-",yn,e.radii),le(t,"shadows","--cl-shadow-",vn,e.shadows),le(t,"fonts","--cl-font-",wn,e.fonts),t}function kn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function An(e){const t=c.useMemo(()=>En(e),[e]),[n,r]=c.useState(null),s=t.url;c.useEffect(()=>{if(r(null),!s)return;const l=new AbortController;return fetch(s,{signal:l.signal}).then(d=>{if(!d.ok)throw new Error(`HTTP ${d.status}`);return d.json()}).then(d=>{if(!kn(d))throw new Error("theme JSON must be an object");r(d)}).catch(d=>{l.signal.aborted||console.error(`[Claudius] Failed to load theme from ${s}:`,d)}),()=>l.abort()},[s]);const i=t.theme??n??null,o=(n==null?void 0:n.colorScheme)??t.mode,u=c.useMemo(()=>i?Cn(i):{},[i]);return{mode:o,cssVars:u}}const We="claudius:triggers:dismissed";function Mn(){if(typeof window>"u")return!1;try{return window.sessionStorage.getItem(We)==="1"}catch{return!1}}function Nn(){if(!(typeof window>"u"))try{window.sessionStorage.setItem(We,"1")}catch{}}function Ln({apiUrl:e,title:t,subtitle:n,welcomeMessage:r,placeholder:s,persistMessages:i,storageKeyPrefix:o,requestTimeoutMs:u,theme:l="light",accentColor:d,position:f="bottom-right",locale:y,translations:C,triggers:g,plugins:h,streaming:p=!0,attachments:v=!1,voice:N=!1}){const[T,E]=c.useState(!1),x=c.useMemo(()=>st(v),[v]),S=c.useMemo(()=>Wt(N,y??je()),[N,y]),[M,A]=c.useState(null),[b,_]=c.useState(Mn),z=c.useRef(!1),I=yt("(max-width: 639px)"),P=c.useMemo(()=>Fe({locale:y,translations:C}),[y,C]),{messages:q,isLoading:Q,isStreaming:V,streamingMessageId:Z,error:w,canRetry:te,sendMessage:oe,stop:R,retry:B}=bt({apiUrl:e,persistMessages:i,storageKeyPrefix:o,timeoutMs:u,translations:P,plugins:h,streaming:p}),O=c.useRef(null),Y=c.useRef(T),{mode:K,cssVars:X}=An(l),[H,j]=c.useState(!1);c.useEffect(()=>{if(K!=="auto")return;const U=window.matchMedia("(prefers-color-scheme: dark)");j(U.matches);const fe=pe=>j(pe.matches);return U.addEventListener("change",fe),()=>U.removeEventListener("change",fe)},[K]),c.useEffect(()=>{var U;Y.current&&!T&&((U=O.current)==null||U.focus()),Y.current=T},[T]);const k=c.useCallback(()=>{_(!0),Nn()},[]),L=c.useCallback(()=>{E(!1),z.current&&(z.current=!1,k())},[k]),F=c.useCallback(()=>{E(U=>!U)},[]),G=c.useCallback(()=>{z.current=!0,A(null),E(!0)},[]),ee=c.useCallback(U=>{A(U)},[]),re=c.useCallback(()=>{A(null),G()},[G]),ne=c.useCallback(()=>{A(null),k()},[k]);wt({triggers:g,enabled:!b&&!T,onOpen:G,onGreeting:ee});const W=K==="dark"||K==="auto"&&H,J={...X,...d?{"--cl-color-accent":d,"--cl-color-accent-dark":d}:{}},ie=Object.keys(J).length>0?J:void 0;return a.jsx("div",{className:"claudius-root",style:ie,children:a.jsxs("div",{"data-claudius-dark":W?"true":"false",children:[T&&I&&a.jsx("div",{className:"claudius-scrim fixed inset-0 z-40 bg-claudius-scrim",onClick:L,"aria-hidden":"true"}),T&&a.jsx(mn,{messages:q,isLoading:Q,isStreaming:V,streamingMessageId:Z,error:w,canRetry:te,onSend:oe,onStop:R,onRetry:B,onClose:L,title:t??P.title,subtitle:n??P.subtitle,welcomeMessage:r??P.welcomeMessage,placeholder:s??P.placeholder,position:f,translations:P,isMobile:I,attachments:x,voice:S}),!(T&&I)&&a.jsx(jt,{ref:O,isOpen:T,onClick:F,position:f,translations:P}),!T&&M&&a.jsx(pn,{message:M,position:f,onOpen:re,onDismiss:ne,dismissLabel:P.dismissGreeting})]})})}function Dn(e){const{onEvent:t,includeContent:n=!0}=e,r=s=>n?s:"";return{name:"analytics",onBeforeSend(s){t({type:"message_sent",role:"user",content:r(s.content),chars:s.content.length})},onAfterReceive(s){t({type:"message_received",role:"assistant",content:r(s.content),chars:s.content.length})},onError(s){t({type:"chat_error",message:s.message,code:s.code})}}}const Ge=[/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/g,/\b\d{3}-\d{2}-\d{4}\b/g,/\b(?:\d[ -]?){13,16}\b/g,/\b(?:\+?1[-.\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}\b/g];function Ve(e,t,n){return t.reduce((r,s)=>(s.lastIndex=0,r.replace(s,n)),e)}function In(e={}){const{patterns:t=Ge,replacement:n="[redacted]",redactReplies:r=!1}=e,s=i=>{const o=Ve(i.content,t,n);if(o!==i.content)return{...i,content:o}};return{name:"redact-pii",onBeforeSend:s,onAfterReceive:r?s:void 0}}function On(e,t,n){return typeof e=="function"?e(t):e instanceof RegExp?e.test(t):n?t.includes(e):t.toLowerCase().includes(e.toLowerCase())}function Pn(e){const{rules:t,caseSensitive:n=!1}=e;return{name:"canned-responses",onBeforeSend(r,s){for(const i of t)if(On(i.match,r.content,n)){s.respondWith(i.reply);return}}}}exports.ChatApiClient=He;exports.ChatApiError=$;exports.ChatWidget=Ln;exports.DEFAULT_ATTACHMENT_OPTIONS=de;exports.DEFAULT_PII_PATTERNS=Ge;exports.DebounceError=me;exports.builtinThemes=Ee;exports.createTranslations=Ht;exports.defaultTranslations=we;exports.detectLocale=je;exports.locales=Re;exports.pluginAnalytics=Dn;exports.pluginCannedResponses=Pn;exports.pluginRedactPII=In;exports.redactText=Ve;exports.resolveTranslations=Fe;
package/dist/claudius.css CHANGED
@@ -1 +1 @@
1
- *,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.\!container{width:100%!important}.container{width:100%}@media(min-width:640px){.\!container{max-width:640px!important}.container{max-width:640px}}@media(min-width:768px){.\!container{max-width:768px!important}.container{max-width:768px}}@media(min-width:1024px){.\!container{max-width:1024px!important}.container{max-width:1024px}}@media(min-width:1280px){.\!container{max-width:1280px!important}.container{max-width:1280px}}@media(min-width:1536px){.\!container{max-width:1536px!important}.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.inset-0{top:0;right:0;bottom:0;left:0}.inset-x-0{left:0;right:0}.inset-y-0{top:0;bottom:0}.-right-1{right:-.25rem}.-right-1\.5{right:-.375rem}.-top-1{top:-.25rem}.-top-1\.5{top:-.375rem}.bottom-0{bottom:0}.bottom-20{bottom:5rem}.bottom-24{bottom:6rem}.bottom-6{bottom:1.5rem}.left-0{left:0}.left-3{left:.75rem}.left-4{left:1rem}.left-6{left:1.5rem}.right-1{right:.25rem}.right-3{right:.75rem}.right-4{right:1rem}.right-6{right:1.5rem}.top-1{top:.25rem}.top-20{top:5rem}.top-24{top:6rem}.top-6{top:1.5rem}.z-10{z-index:10}.z-40{z-index:40}.z-50{z-index:50}.mx-auto{margin-left:auto;margin-right:auto}.mb-2{margin-bottom:.5rem}.ml-auto{margin-left:auto}.mr-auto{margin-right:auto}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.hidden{display:none}.h-1{height:.25rem}.h-10{height:2.5rem}.h-11{height:2.75rem}.h-12{height:3rem}.h-14{height:3.5rem}.h-2{height:.5rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-\[90vh\]{height:90vh}.h-\[min\(500px\,calc\(100vh-7rem\)\)\]{height:min(500px,calc(100vh - 7rem))}.h-full{height:100%}.max-h-48{max-height:12rem}.w-10{width:2.5rem}.w-11{width:2.75rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-2{width:.5rem}.w-5{width:1.25rem}.w-6{width:1.5rem}.w-7{width:1.75rem}.w-8{width:2rem}.w-\[280px\]{width:280px}.w-\[calc\(100vw-1\.5rem\)\]{width:calc(100vw - 1.5rem)}.w-full{width:100%}.min-w-0{min-width:0px}.min-w-4{min-width:1rem}.max-w-\[220px\]{max-width:220px}.max-w-\[380px\]{max-width:380px}.max-w-\[85\%\]{max-width:85%}.max-w-\[90\%\]{max-width:90%}.max-w-full{max-width:100%}.max-w-xs{max-width:20rem}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-claudius-bubble{border-radius:var(--claudius-radius-bubble, var(--cl-radius-lg, 16px))}.rounded-claudius-full{border-radius:var(--cl-radius-full, 9999px)}.rounded-claudius-lg{border-radius:var(--claudius-radius-card, var(--cl-radius-lg, 16px))}.rounded-claudius-md{border-radius:var(--claudius-radius-button, var(--cl-radius-md, 12px))}.rounded-claudius-sm{border-radius:var(--cl-radius-sm, 8px)}.rounded-r-claudius-lg{border-top-right-radius:var(--claudius-radius-card, var(--cl-radius-lg, 16px));border-bottom-right-radius:var(--claudius-radius-card, var(--cl-radius-lg, 16px))}.rounded-t-claudius-lg{border-top-left-radius:var(--claudius-radius-card, var(--cl-radius-lg, 16px));border-top-right-radius:var(--claudius-radius-card, var(--cl-radius-lg, 16px))}.rounded-bl-claudius-tail{border-bottom-left-radius:var(--cl-radius-tail, 2px)}.rounded-br-claudius-tail{border-bottom-right-radius:var(--cl-radius-tail, 2px)}.border{border-width:1px}.border-2{border-width:2px}.border-b{border-bottom-width:1px}.border-r-2{border-right-width:2px}.border-t{border-top-width:1px}.border-claudius-border{border-color:var(--claudius-border, var(--cl-color-border, #e2e8f0))}.bg-claudius-accent{background-color:var(--claudius-primary, var(--cl-color-accent, #2563eb))}.bg-claudius-accent-soft{background-color:var(--cl-color-accent-soft, rgb(255 255 255 / .2))}.bg-claudius-assistant-bubble{background-color:var(--claudius-assistant-bg, var(--cl-color-assistant-bubble, var(--cl-color-surface-muted, #f1f5f9)))}.bg-claudius-border{background-color:var(--claudius-border, var(--cl-color-border, #e2e8f0))}.bg-claudius-error{background-color:var(--claudius-error, var(--cl-color-error, #dc2626))}.bg-claudius-error-surface{background-color:var(--claudius-error-bg, var(--cl-color-error-surface, #fef2f2))}.bg-claudius-field{background-color:var(--cl-color-field, #ffffff)}.bg-claudius-scrim{background-color:var(--cl-color-scrim, rgb(0 0 0 / .5))}.bg-claudius-surface{background-color:var(--cl-color-surface, #ffffff)}.bg-claudius-surface-muted{background-color:var(--claudius-light, var(--cl-color-surface-muted, #f1f5f9))}.bg-claudius-text{background-color:var(--claudius-dark, var(--cl-color-text, #1e293b))}.bg-claudius-text-muted{background-color:var(--claudius-gray, var(--cl-color-text-muted, #64748b))}.bg-claudius-user-bubble{background-color:var(--claudius-user-bg, var(--cl-color-user-bubble, var(--cl-color-accent, #2563eb)))}.bg-transparent{background-color:transparent}.object-contain{-o-object-fit:contain;object-fit:contain}.object-cover{-o-object-fit:cover;object-fit:cover}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.pr-8{padding-right:2rem}.pt-1{padding-top:.25rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.font-body{font-family:var(--claudius-font-body, var(--cl-font-body, system-ui)),sans-serif}.font-heading{font-family:var(--claudius-font-heading, var(--cl-font-heading, system-ui)),sans-serif}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.text-\[10px\]{font-size:10px}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.italic{font-style:italic}.leading-relaxed{line-height:1.625}.tracking-wide{letter-spacing:.025em}.text-claudius-accent{color:var(--claudius-primary, var(--cl-color-accent, #2563eb))}.text-claudius-accent-text{color:var(--cl-color-accent-text, #ffffff)}.text-claudius-accent-text-muted{color:var(--cl-color-accent-text-muted, rgb(255 255 255 / .7))}.text-claudius-assistant-bubble-text{color:var(--claudius-assistant-text, var(--cl-color-assistant-bubble-text, var(--cl-color-text, #1e293b)))}.text-claudius-error{color:var(--claudius-error, var(--cl-color-error, #dc2626))}.text-claudius-error-text{color:var(--cl-color-error-text, #ffffff)}.text-claudius-link{color:var(--cl-color-link, currentColor)}.text-claudius-surface{color:var(--cl-color-surface, #ffffff)}.text-claudius-text{color:var(--claudius-dark, var(--cl-color-text, #1e293b))}.text-claudius-text-muted{color:var(--claudius-gray, var(--cl-color-text-muted, #64748b))}.text-claudius-user-bubble-text{color:var(--claudius-user-text, var(--cl-color-user-bubble-text, #ffffff))}.underline{text-decoration-line:underline}.underline-offset-2{text-underline-offset:2px}.opacity-70{opacity:.7}.shadow-claudius-elevated{--tw-shadow: var(--cl-shadow-elevated, 0 25px 50px -12px rgb(0 0 0 / .25));--tw-shadow-colored: 0 25px 50px -12px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-claudius-floating{--tw-shadow: var(--cl-shadow-floating, 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1));--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.ring-1{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-2{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-inset{--tw-ring-inset: inset}.ring-claudius-accent{--tw-ring-color: var(--claudius-primary, var(--cl-color-accent, #2563eb))}.ring-claudius-border{--tw-ring-color: var(--claudius-border, var(--cl-color-border, #e2e8f0))}.sepia{--tw-sepia: sepia(100%);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-200{transition-duration:.2s}.ease-out{transition-timing-function:cubic-bezier(0,0,.2,1)}.\[animation-delay\:0ms\]{animation-delay:0ms}.\[animation-delay\:150ms\]{animation-delay:.15s}.\[animation-delay\:300ms\]{animation-delay:.3s}[data-claudius-dark=true]{--cl-color-accent: var(--cl-color-accent-dark, #2563eb);--cl-color-accent-text: var(--cl-color-accent-text-dark, #ffffff);--cl-color-accent-soft: var( --cl-color-accent-soft-dark, rgb(255 255 255 / .2) );--cl-color-accent-text-muted: var( --cl-color-accent-text-muted-dark, rgb(255 255 255 / .7) );--cl-color-surface: var(--cl-color-surface-dark, #111827);--cl-color-surface-muted: var(--cl-color-surface-muted-dark, #1f2937);--cl-color-text: var(--cl-color-text-dark, #f3f4f6);--cl-color-text-muted: var(--cl-color-text-muted-dark, #9ca3af);--cl-color-border: var(--cl-color-border-dark, #374151);--cl-color-user-bubble: var( --cl-color-user-bubble-dark, var(--cl-color-accent) );--cl-color-user-bubble-text: var(--cl-color-user-bubble-text-dark, #ffffff);--cl-color-assistant-bubble: var( --cl-color-assistant-bubble-dark, var(--cl-color-surface-muted) );--cl-color-assistant-bubble-text: var( --cl-color-assistant-bubble-text-dark, #e5e7eb );--cl-color-field: var(--cl-color-field-dark, #1f2937);--cl-color-error: var(--cl-color-error-dark, #f87171);--cl-color-error-surface: var( --cl-color-error-surface-dark, rgb(127 29 29 / .3) );--cl-color-error-text: var(--cl-color-error-text-dark, #ffffff);--cl-color-link: var(--cl-color-link-dark, #60a5fa);--cl-color-scrim: var(--cl-color-scrim-dark, rgb(0 0 0 / .5))}.claudius-bottom-sheet{transition:transform .3s cubic-bezier(.32,.72,0,1)}.claudius-bottom-sheet[data-dragging=true]{transition:none}.claudius-scrim{transition:opacity .3s ease}@media(prefers-reduced-motion:reduce){.claudius-bottom-sheet{transition:opacity .2s ease;transform:none!important}.claudius-scrim{transition:opacity .15s ease}}.placeholder\:text-claudius-text-muted::-moz-placeholder{color:var(--claudius-gray, var(--cl-color-text-muted, #64748b))}.placeholder\:text-claudius-text-muted::placeholder{color:var(--claudius-gray, var(--cl-color-text-muted, #64748b))}.hover\:scale-105:hover{--tw-scale-x: 1.05;--tw-scale-y: 1.05;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:bg-claudius-accent-soft:hover{background-color:var(--cl-color-accent-soft, rgb(255 255 255 / .2))}.hover\:bg-claudius-border:hover{background-color:var(--claudius-border, var(--cl-color-border, #e2e8f0))}.hover\:bg-claudius-surface-muted:hover{background-color:var(--claudius-light, var(--cl-color-surface-muted, #f1f5f9))}.hover\:text-claudius-accent-text:hover{color:var(--cl-color-accent-text, #ffffff)}.hover\:text-claudius-text:hover{color:var(--claudius-dark, var(--cl-color-text, #1e293b))}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-80:hover{opacity:.8}.hover\:opacity-90:hover{opacity:.9}.hover\:shadow-claudius-floating-hover:hover{--tw-shadow: var(--cl-shadow-floating-hover, 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1));--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.focus\:border-claudius-accent:focus{border-color:var(--claudius-primary, var(--cl-color-accent, #2563eb))}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-1:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-claudius-accent:focus{--tw-ring-color: var(--claudius-primary, var(--cl-color-accent, #2563eb))}.focus\:ring-offset-2:focus{--tw-ring-offset-width: 2px}.focus-visible\:ring-2:focus-visible{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus-visible\:ring-claudius-accent:focus-visible{--tw-ring-color: var(--claudius-primary, var(--cl-color-accent, #2563eb))}.focus-visible\:ring-claudius-error:focus-visible{--tw-ring-color: var(--claudius-error, var(--cl-color-error, #dc2626))}.focus-visible\:ring-offset-1:focus-visible{--tw-ring-offset-width: 1px}.disabled\:cursor-default:disabled{cursor:default}.disabled\:opacity-50:disabled{opacity:.5}.disabled\:hover\:opacity-100:hover:disabled{opacity:1}@media(prefers-reduced-motion:no-preference){@keyframes bounce{0%,to{transform:translateY(-25%);animation-timing-function:cubic-bezier(.8,0,1,1)}50%{transform:none;animation-timing-function:cubic-bezier(0,0,.2,1)}}.motion-safe\:animate-bounce{animation:bounce 1s infinite}}@media(min-width:640px){.sm\:left-6{left:1.5rem}.sm\:right-6{right:1.5rem}.sm\:max-w-\[400px\]{max-width:400px}}@media(min-width:768px){.md\:max-w-\[440px\]{max-width:440px}}
1
+ *,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.\!container{width:100%!important}.container{width:100%}@media(min-width:640px){.\!container{max-width:640px!important}.container{max-width:640px}}@media(min-width:768px){.\!container{max-width:768px!important}.container{max-width:768px}}@media(min-width:1024px){.\!container{max-width:1024px!important}.container{max-width:1024px}}@media(min-width:1280px){.\!container{max-width:1280px!important}.container{max-width:1280px}}@media(min-width:1536px){.\!container{max-width:1536px!important}.container{max-width:1536px}}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.pointer-events-none{pointer-events:none}.visible{visibility:visible}.invisible{visibility:hidden}.static{position:static}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.inset-0{top:0;right:0;bottom:0;left:0}.inset-x-0{left:0;right:0}.inset-y-0{top:0;bottom:0}.-right-1{right:-.25rem}.-right-1\.5{right:-.375rem}.-top-1{top:-.25rem}.-top-1\.5{top:-.375rem}.bottom-0{bottom:0}.bottom-20{bottom:5rem}.bottom-24{bottom:6rem}.bottom-6{bottom:1.5rem}.left-0{left:0}.left-3{left:.75rem}.left-4{left:1rem}.left-6{left:1.5rem}.right-1{right:.25rem}.right-3{right:.75rem}.right-4{right:1rem}.right-6{right:1.5rem}.top-1{top:.25rem}.top-1\/2{top:50%}.top-20{top:5rem}.top-24{top:6rem}.top-6{top:1.5rem}.z-10{z-index:10}.z-40{z-index:40}.z-50{z-index:50}.mx-auto{margin-left:auto;margin-right:auto}.mb-2{margin-bottom:.5rem}.ml-auto{margin-left:auto}.mr-auto{margin-right:auto}.mt-0\.5{margin-top:.125rem}.mt-1{margin-top:.25rem}.block{display:block}.inline-block{display:inline-block}.inline{display:inline}.flex{display:flex}.inline-flex{display:inline-flex}.hidden{display:none}.h-1{height:.25rem}.h-10{height:2.5rem}.h-11{height:2.75rem}.h-12{height:3rem}.h-14{height:3.5rem}.h-2{height:.5rem}.h-4{height:1rem}.h-5{height:1.25rem}.h-6{height:1.5rem}.h-7{height:1.75rem}.h-8{height:2rem}.h-\[90vh\]{height:90vh}.h-\[min\(500px\,calc\(100vh-7rem\)\)\]{height:min(500px,calc(100vh - 7rem))}.h-full{height:100%}.max-h-48{max-height:12rem}.w-10{width:2.5rem}.w-11{width:2.75rem}.w-12{width:3rem}.w-14{width:3.5rem}.w-2{width:.5rem}.w-5{width:1.25rem}.w-6{width:1.5rem}.w-7{width:1.75rem}.w-8{width:2rem}.w-\[280px\]{width:280px}.w-\[calc\(100vw-1\.5rem\)\]{width:calc(100vw - 1.5rem)}.w-full{width:100%}.min-w-0{min-width:0px}.min-w-4{min-width:1rem}.max-w-\[220px\]{max-width:220px}.max-w-\[380px\]{max-width:380px}.max-w-\[85\%\]{max-width:85%}.max-w-\[90\%\]{max-width:90%}.max-w-full{max-width:100%}.max-w-xs{max-width:20rem}.flex-1{flex:1 1 0%}.shrink-0{flex-shrink:0}.-translate-y-1\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.rotate-180{--tw-rotate: 180deg;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.touch-none{touch-action:none}.select-none{-webkit-user-select:none;-moz-user-select:none;user-select:none}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.justify-center{justify-content:center}.justify-between{justify-content:space-between}.gap-0\.5{gap:.125rem}.gap-1{gap:.25rem}.gap-1\.5{gap:.375rem}.gap-2{gap:.5rem}.gap-3{gap:.75rem}.space-y-1>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.space-y-2>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.space-y-3>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(.75rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.75rem * var(--tw-space-y-reverse))}.space-y-4>:not([hidden])~:not([hidden]){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.whitespace-pre-wrap{white-space:pre-wrap}.break-all{word-break:break-all}.rounded{border-radius:.25rem}.rounded-claudius-bubble{border-radius:var(--claudius-radius-bubble, var(--cl-radius-lg, 16px))}.rounded-claudius-full{border-radius:var(--cl-radius-full, 9999px)}.rounded-claudius-lg{border-radius:var(--claudius-radius-card, var(--cl-radius-lg, 16px))}.rounded-claudius-md{border-radius:var(--claudius-radius-button, var(--cl-radius-md, 12px))}.rounded-claudius-sm{border-radius:var(--cl-radius-sm, 8px)}.rounded-r-claudius-lg{border-top-right-radius:var(--claudius-radius-card, var(--cl-radius-lg, 16px));border-bottom-right-radius:var(--claudius-radius-card, var(--cl-radius-lg, 16px))}.rounded-t-claudius-lg{border-top-left-radius:var(--claudius-radius-card, var(--cl-radius-lg, 16px));border-top-right-radius:var(--claudius-radius-card, var(--cl-radius-lg, 16px))}.rounded-bl-claudius-tail{border-bottom-left-radius:var(--cl-radius-tail, 2px)}.rounded-br-claudius-tail{border-bottom-right-radius:var(--cl-radius-tail, 2px)}.border{border-width:1px}.border-2{border-width:2px}.border-b{border-bottom-width:1px}.border-r-2{border-right-width:2px}.border-t{border-top-width:1px}.border-claudius-accent{border-color:var(--claudius-primary, var(--cl-color-accent, #2563eb))}.border-claudius-border{border-color:var(--claudius-border, var(--cl-color-border, #e2e8f0))}.bg-claudius-accent{background-color:var(--claudius-primary, var(--cl-color-accent, #2563eb))}.bg-claudius-accent-soft{background-color:var(--cl-color-accent-soft, rgb(255 255 255 / .2))}.bg-claudius-assistant-bubble{background-color:var(--claudius-assistant-bg, var(--cl-color-assistant-bubble, var(--cl-color-surface-muted, #f1f5f9)))}.bg-claudius-border{background-color:var(--claudius-border, var(--cl-color-border, #e2e8f0))}.bg-claudius-error{background-color:var(--claudius-error, var(--cl-color-error, #dc2626))}.bg-claudius-error-surface{background-color:var(--claudius-error-bg, var(--cl-color-error-surface, #fef2f2))}.bg-claudius-field{background-color:var(--cl-color-field, #ffffff)}.bg-claudius-scrim{background-color:var(--cl-color-scrim, rgb(0 0 0 / .5))}.bg-claudius-surface{background-color:var(--cl-color-surface, #ffffff)}.bg-claudius-surface-muted{background-color:var(--claudius-light, var(--cl-color-surface-muted, #f1f5f9))}.bg-claudius-text{background-color:var(--claudius-dark, var(--cl-color-text, #1e293b))}.bg-claudius-text-muted{background-color:var(--claudius-gray, var(--cl-color-text-muted, #64748b))}.bg-claudius-user-bubble{background-color:var(--claudius-user-bg, var(--cl-color-user-bubble, var(--cl-color-accent, #2563eb)))}.bg-transparent{background-color:transparent}.object-contain{-o-object-fit:contain;object-fit:contain}.object-cover{-o-object-fit:cover;object-fit:cover}.p-2{padding:.5rem}.p-3{padding:.75rem}.p-4{padding:1rem}.px-1{padding-left:.25rem;padding-right:.25rem}.px-2{padding-left:.5rem;padding-right:.5rem}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.px-5{padding-left:1.25rem;padding-right:1.25rem}.py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.py-1{padding-top:.25rem;padding-bottom:.25rem}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.py-4{padding-top:1rem;padding-bottom:1rem}.pl-3{padding-left:.75rem}.pr-10{padding-right:2.5rem}.pr-3{padding-right:.75rem}.pr-8{padding-right:2rem}.pt-1{padding-top:.25rem}.text-left{text-align:left}.text-center{text-align:center}.text-right{text-align:right}.font-body{font-family:var(--claudius-font-body, var(--cl-font-body, system-ui)),sans-serif}.font-heading{font-family:var(--claudius-font-heading, var(--cl-font-heading, system-ui)),sans-serif}.font-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.text-\[10px\]{font-size:10px}.text-sm{font-size:.875rem;line-height:1.25rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.font-medium{font-weight:500}.font-semibold{font-weight:600}.uppercase{text-transform:uppercase}.italic{font-style:italic}.leading-relaxed{line-height:1.625}.tracking-wide{letter-spacing:.025em}.text-claudius-accent{color:var(--claudius-primary, var(--cl-color-accent, #2563eb))}.text-claudius-accent-text{color:var(--cl-color-accent-text, #ffffff)}.text-claudius-accent-text-muted{color:var(--cl-color-accent-text-muted, rgb(255 255 255 / .7))}.text-claudius-assistant-bubble-text{color:var(--claudius-assistant-text, var(--cl-color-assistant-bubble-text, var(--cl-color-text, #1e293b)))}.text-claudius-error{color:var(--claudius-error, var(--cl-color-error, #dc2626))}.text-claudius-error-text{color:var(--cl-color-error-text, #ffffff)}.text-claudius-link{color:var(--cl-color-link, currentColor)}.text-claudius-surface{color:var(--cl-color-surface, #ffffff)}.text-claudius-text{color:var(--claudius-dark, var(--cl-color-text, #1e293b))}.text-claudius-text-muted{color:var(--claudius-gray, var(--cl-color-text-muted, #64748b))}.text-claudius-user-bubble-text{color:var(--claudius-user-text, var(--cl-color-user-bubble-text, #ffffff))}.underline{text-decoration-line:underline}.underline-offset-2{text-underline-offset:2px}.opacity-70{opacity:.7}.shadow-claudius-elevated{--tw-shadow: var(--cl-shadow-elevated, 0 25px 50px -12px rgb(0 0 0 / .25));--tw-shadow-colored: 0 25px 50px -12px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.shadow-claudius-floating{--tw-shadow: var(--cl-shadow-floating, 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1));--tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.ring{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-1{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-2{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.ring-inset{--tw-ring-inset: inset}.ring-claudius-accent{--tw-ring-color: var(--claudius-primary, var(--cl-color-accent, #2563eb))}.ring-claudius-border{--tw-ring-color: var(--claudius-border, var(--cl-color-border, #e2e8f0))}.blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.sepia{--tw-sepia: sepia(100%);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.transition-transform{transition-property:transform;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-200{transition-duration:.2s}.ease-out{transition-timing-function:cubic-bezier(0,0,.2,1)}.\[animation-delay\:0ms\]{animation-delay:0ms}.\[animation-delay\:150ms\]{animation-delay:.15s}.\[animation-delay\:300ms\]{animation-delay:.3s}[data-claudius-dark=true]{--cl-color-accent: var(--cl-color-accent-dark, #2563eb);--cl-color-accent-text: var(--cl-color-accent-text-dark, #ffffff);--cl-color-accent-soft: var( --cl-color-accent-soft-dark, rgb(255 255 255 / .2) );--cl-color-accent-text-muted: var( --cl-color-accent-text-muted-dark, rgb(255 255 255 / .7) );--cl-color-surface: var(--cl-color-surface-dark, #111827);--cl-color-surface-muted: var(--cl-color-surface-muted-dark, #1f2937);--cl-color-text: var(--cl-color-text-dark, #f3f4f6);--cl-color-text-muted: var(--cl-color-text-muted-dark, #9ca3af);--cl-color-border: var(--cl-color-border-dark, #374151);--cl-color-user-bubble: var( --cl-color-user-bubble-dark, var(--cl-color-accent) );--cl-color-user-bubble-text: var(--cl-color-user-bubble-text-dark, #ffffff);--cl-color-assistant-bubble: var( --cl-color-assistant-bubble-dark, var(--cl-color-surface-muted) );--cl-color-assistant-bubble-text: var( --cl-color-assistant-bubble-text-dark, #e5e7eb );--cl-color-field: var(--cl-color-field-dark, #1f2937);--cl-color-error: var(--cl-color-error-dark, #f87171);--cl-color-error-surface: var( --cl-color-error-surface-dark, rgb(127 29 29 / .3) );--cl-color-error-text: var(--cl-color-error-text-dark, #ffffff);--cl-color-link: var(--cl-color-link-dark, #60a5fa);--cl-color-scrim: var(--cl-color-scrim-dark, rgb(0 0 0 / .5))}.claudius-bottom-sheet{transition:transform .3s cubic-bezier(.32,.72,0,1)}.claudius-bottom-sheet[data-dragging=true]{transition:none}.claudius-scrim{transition:opacity .3s ease}.claudius-voice-level>span{width:3px;height:100%;border-radius:9999px;background:currentColor;opacity:.5;transform:scaleY(.25);animation:claudius-voice-idle 1.2s ease-in-out infinite}.claudius-voice-level[data-claudius-voice-level=active]>span{opacity:1;animation:claudius-voice-active .6s ease-in-out infinite}.claudius-voice-level>span:nth-child(2){animation-delay:-.45s}.claudius-voice-level>span:nth-child(3){animation-delay:-.2s}.claudius-voice-level>span:nth-child(4){animation-delay:-.65s}@keyframes claudius-voice-idle{0%,to{transform:scaleY(.25)}50%{transform:scaleY(.4)}}@keyframes claudius-voice-active{0%,to{transform:scaleY(.3)}50%{transform:scaleY(1)}}@media(prefers-reduced-motion:reduce){.claudius-bottom-sheet{transition:opacity .2s ease;transform:none!important}.claudius-scrim{transition:opacity .15s ease}.claudius-voice-level>span,.claudius-voice-level[data-claudius-voice-level=active]>span{animation:none;transform:scaleY(.6)}}.placeholder\:text-claudius-text-muted::-moz-placeholder{color:var(--claudius-gray, var(--cl-color-text-muted, #64748b))}.placeholder\:text-claudius-text-muted::placeholder{color:var(--claudius-gray, var(--cl-color-text-muted, #64748b))}.hover\:scale-105:hover{--tw-scale-x: 1.05;--tw-scale-y: 1.05;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.hover\:bg-claudius-accent-soft:hover{background-color:var(--cl-color-accent-soft, rgb(255 255 255 / .2))}.hover\:bg-claudius-border:hover{background-color:var(--claudius-border, var(--cl-color-border, #e2e8f0))}.hover\:bg-claudius-surface-muted:hover{background-color:var(--claudius-light, var(--cl-color-surface-muted, #f1f5f9))}.hover\:text-claudius-accent-text:hover{color:var(--cl-color-accent-text, #ffffff)}.hover\:text-claudius-text:hover{color:var(--claudius-dark, var(--cl-color-text, #1e293b))}.hover\:underline:hover{text-decoration-line:underline}.hover\:opacity-80:hover{opacity:.8}.hover\:opacity-90:hover{opacity:.9}.hover\:shadow-claudius-floating-hover:hover{--tw-shadow: var(--cl-shadow-floating-hover, 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1));--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.focus\:border-claudius-accent:focus{border-color:var(--claudius-primary, var(--cl-color-accent, #2563eb))}.focus\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.focus\:ring-1:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(1px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus\:ring-claudius-accent:focus{--tw-ring-color: var(--claudius-primary, var(--cl-color-accent, #2563eb))}.focus\:ring-offset-2:focus{--tw-ring-offset-width: 2px}.focus\:ring-offset-claudius-surface:focus{--tw-ring-offset-color: var(--cl-color-surface, #ffffff)}.focus-visible\:ring-2:focus-visible{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.focus-visible\:ring-claudius-accent:focus-visible{--tw-ring-color: var(--claudius-primary, var(--cl-color-accent, #2563eb))}.focus-visible\:ring-claudius-error:focus-visible{--tw-ring-color: var(--claudius-error, var(--cl-color-error, #dc2626))}.focus-visible\:ring-offset-1:focus-visible{--tw-ring-offset-width: 1px}.disabled\:cursor-default:disabled{cursor:default}.disabled\:opacity-50:disabled{opacity:.5}.disabled\:hover\:opacity-100:hover:disabled{opacity:1}@media(prefers-reduced-motion:no-preference){@keyframes bounce{0%,to{transform:translateY(-25%);animation-timing-function:cubic-bezier(.8,0,1,1)}50%{transform:none;animation-timing-function:cubic-bezier(0,0,.2,1)}}.motion-safe\:animate-bounce{animation:bounce 1s infinite}}@media(min-width:640px){.sm\:left-6{left:1.5rem}.sm\:right-6{right:1.5rem}.sm\:max-w-\[400px\]{max-width:400px}}@media(min-width:768px){.md\:max-w-\[440px\]{max-width:440px}}