diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 46e7a46..9a528fe 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.17.0" + ".": "1.17.1" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 194b88a..ad97b61 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.17.1](https://github.com/PMDevSolutions/Claudius/compare/v1.17.0...v1.17.1) (2026-09-20) + + +### Bug Fixes + +* **widget:** conversation export review follow-ups ([a1d0c3b](https://github.com/PMDevSolutions/Claudius/commit/a1d0c3b31110fce39cc981d7e8d7e17d502fbce2)) +* **widget:** escape a block opener dressed up as an email autolink ([09f45fc](https://github.com/PMDevSolutions/Claudius/commit/09f45fc200e265701f9f04eadbb66cb4cf146120)) +* **widget:** keep copyText from rejecting whatever the fallback does ([7a3bf81](https://github.com/PMDevSolutions/Claudius/commit/7a3bf81be589403df824855dc5f71159a7cc2300)) +* **widget:** keep the clipboard fallback from throwing while it tidies up ([03a76a1](https://github.com/PMDevSolutions/Claudius/commit/03a76a105ff2d22b28e87f0ddefe64ab0839f54a)) + ## [1.17.0](https://github.com/PMDevSolutions/Claudius/compare/v1.16.1...v1.17.0) (2026-09-20) diff --git a/cdn/claudius.iife.js b/cdn/claudius.iife.js index c9c8751..cd7a134 100644 --- a/cdn/claudius.iife.js +++ b/cdn/claudius.iife.js @@ -44,7 +44,7 @@ Error generating stack: `+o.message+` `));return typeof c!="object"||c===null?null:{event:a,data:c}}catch{return null}}function du(u){return typeof u=="string"?{content:u}:u}function ao(u,a,i){console.error(`[claudius] plugin "${u.name}" failed in ${a}:`,i)}async function Hc(u,a,i){let c=a;for(const f of u){if(!f.onBeforeSend)continue;let p=null;const v={...i,respondWith(k){p={type:"respond",message:c,reply:du(k)}},abort(k){p={type:"abort",reason:k}}};try{const k=await f.onBeforeSend(c,v);if(p)return p;k&&(c=k)}catch(k){ao(f,"onBeforeSend",k)}}return{type:"send",message:c}}async function $c(u,a,i){let c=a;for(const f of u)if(f.onAfterReceive)try{const p=await f.onAfterReceive(c,i);p&&(c=p)}catch(p){ao(f,"onAfterReceive",p)}return c}async function Vc(u,a,i){for(const c of u){if(!c.onError)continue;let f=null;const p={...i,respondWith(v){f=du(v)}};try{if(await c.onError(a,p),f)return f}catch(v){ao(c,"onError",v)}}return null}const $r={maxSizeBytes:5*1024*1024,maxCount:5,allowedTypes:["image/jpeg","image/png","image/gif","image/webp","application/pdf"]};function Wc(u){return u?u===!0?$r:{maxSizeBytes:u.maxSizeBytes??$r.maxSizeBytes,maxCount:u.maxCount??$r.maxCount,allowedTypes:(u.allowedTypes??$r.allowedTypes).map(a=>a.trim().toLowerCase()).filter(Boolean)}:null}function Vr(u){if(!Number.isFinite(u)||u<0)return"0 B";if(u<1024)return`${u} B`;const a=u/1024;if(a<1024)return`${Math.round(a)} KB`;const i=a/1024;return`${Number.isInteger(i)?i:i.toFixed(1)} MB`}const Qc={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",gif:"image/gif",webp:"image/webp",pdf:"application/pdf"};function fu(u){var c;const a=(u.type||"").trim().toLowerCase();if(a)return a;const i=((c=u.name.split(".").pop())==null?void 0:c.toLowerCase())??"";return Qc[i]??""}function Kc(u){return u.startsWith("image/")}function bc(u){if(Kc(u.mediaType)){if(u.url)try{const a=new URL(u.url);if(a.protocol==="http:"||a.protocol==="https:")return u.url}catch{}if(u.data)return`data:${u.mediaType};base64,${u.data}`}}function Gc(u,a,i){const c=[],f=[];let p=Math.max(0,i.maxCount-a);for(const v of u){const k=fu(v);!k||!i.allowedTypes.includes(k)?f.push({file:v,reason:"type"}):v.size>i.maxSizeBytes||v.size===0?f.push({file:v,reason:"size"}):p<=0?f.push({file:v,reason:"count"}):(c.push(v),p-=1)}return{accepted:c,rejected:f}}function Yc(u){return new Promise((a,i)=>{const c=new FileReader;c.onerror=()=>i(c.error??new Error("Failed to read file")),c.onload=()=>{const f=String(c.result??""),p=f.indexOf(",");a(p>=0?f.slice(p+1):f)},c.readAsDataURL(u)})}let pu=0;function Xc(){return pu+=1,`att-${Date.now().toString(36)}-${pu}`}async function Zc(u){const a=await Yc(u);return{id:Xc(),name:u.name||"attachment",mediaType:fu(u),size:u.size,data:a}}function hu(u){return u.map(a=>{var i;return(i=a.attachments)!=null&&i.some(c=>c.data)?{...a,attachments:a.attachments.map(c=>{if(!c.data)return c;const f={...c};return delete f.data,f})}:a})}function Jc(u,a){if(!a||a.length===0)return u;const i=new Map(a.map(c=>[c.id,c]));return u.map(c=>{var f;return(f=c.attachments)!=null&&f.some(p=>i.has(p.id))?{...c,attachments:c.attachments.map(p=>{const v=i.get(p.id);if(!v)return p;const k={...p,key:v.key,url:v.url,expiresAt:v.expiresAt};return delete k.data,k})}:c})}const qc=200,ed="claudius:messages",qn=()=>new Date().toISOString();function td(u,a){let i;try{i=new URL(a).host}catch{i=a}return`${u}:${i}`}function co(){try{return typeof sessionStorage<"u"?sessionStorage:null}catch{return null}}function nd(u){const a=co();if(!a)return[];try{const i=a.getItem(u);if(!i)return[];const c=JSON.parse(i);return Array.isArray(c)?c:[]}catch{return[]}}function rd({apiUrl:u,persistMessages:a=!0,storageKeyPrefix:i=ed,timeoutMs:c,translations:f,plugins:p,streaming:v=!0}){const k=R.useMemo(()=>new Uc(u,{debounceMs:0,timeoutMs:c}),[u,c]),S=td(i,u),N=a?nd(S):[],[j,O]=R.useState(N),[V,I]=R.useState(!1),[D,P]=R.useState(!1),[F,$]=R.useState(null),[J,B]=R.useState(null),[Q,ue]=R.useState(!1),de=R.useRef(N.length),ae=R.useRef(!1),Z=R.useRef(N),xe=R.useRef(null),pe=R.useRef(p??[]);pe.current=p??[];const Se=R.useCallback(C=>{if(!a)return;const m=co();if(m)try{const T=hu(C.slice(-qc));m.setItem(S,JSON.stringify(T))}catch{}},[a,S]),Ce=()=>(de.current+=1,`msg-${de.current}`),ve=R.useCallback((C,m)=>{if(!f)return m??"Something went wrong. Please try again.";switch(C){case"TIMEOUT":return f.errorTimeout;case"NETWORK_ERROR":return f.errorConnection;case"RATE_LIMITED":return m!=null&&m.includes("minute")?f.errorRateLimitMinute:f.errorRateLimitHour;case"ATTACHMENT_QUOTA_EXCEEDED":return f.errorAttachmentQuota;case"ATTACHMENTS_DISABLED":case"ATTACHMENT_INVALID":case"ATTACHMENT_TOO_LARGE":return f.errorAttachmentRejected;case"VALIDATION_ERROR":case"CONFIG_ERROR":case"SERVICE_ERROR":case"UNKNOWN_ERROR":default:return m??f.errorGeneric}},[f]),Re=R.useCallback(C=>!(C instanceof tt)||C.code==="TIMEOUT"||C.code==="NETWORK_ERROR"||C.code==="RATE_LIMITED"||C.code==="SERVICE_ERROR"||C.code==="UNKNOWN_ERROR"||C.status>=500||C.status===0,[]),ye=R.useCallback(async C=>{var se,ne,ie;I(!0),ae.current=!0,B(null),ue(!1);const m=v&&typeof k.streamMessage=="function";let T=null;const re=K=>{if(T===null){T=Ce(),$(T);const q=[...Z.current,{id:T,role:"assistant",content:"",createdAt:qn(),...K}];Z.current=q,O(q)}else{const q=T,ce=Z.current.map(Ae=>Ae.id===q?{...Ae,...K}:Ae);Z.current=ce,O(ce)}},le=()=>{if(T===null)return;const K=T,q=Z.current.filter(ce=>ce.id!==K);Z.current=q,O(q)};try{let K,q,ce,Ae,Ze=!1;if(m){const Oe=new AbortController;xe.current=Oe,P(!0);const pt=await k.streamMessage(C,{signal:Oe.signal,onChunk:(Mt,ut)=>re({content:ut}),onToolUse:(Mt,ut)=>re({toolUses:[...ut]})});K=pt.reply,q=pt.sources,ce=pt.toolUses,Ae=pt.attachments,Ze=pt.aborted??!1}else{const Oe=await k.sendMessage(C);K=Oe.reply,q=Oe.sources,ce=Oe.toolUses,Ae=Oe.attachments}if(Ze&&!K){le();return}const ft=((se=Z.current.find(Oe=>Oe.id===T))==null?void 0:se.createdAt)??qn();let Fe={id:T??Ce(),role:"assistant",content:K,createdAt:ft,sources:q,toolUses:ce};pe.current.length>0&&!Ze&&(Fe=await $c(pe.current,Fe,{messages:C,apiUrl:u}),Fe.createdAt||(Fe={...Fe,createdAt:ft}));const Kt=T!==null?Z.current.map(Oe=>Oe.id===Fe.id?Fe:Oe):[...C,Fe],_t=Jc(Kt,Ae);Z.current=_t,O(_t),Se(_t)}catch(K){if(K instanceof so)return;if(K instanceof tt&&((ne=K.code)!=null&&ne.startsWith("ATTACHMENT"))&&C.length>0){const q=C[C.length-1];if(q.role==="user"&&((ie=q.attachments)!=null&&ie.length)){const ce=C.slice(0,-1);Z.current=ce,O(ce),Se(ce)}}if(T!==null){Se(Z.current),K instanceof tt?B(ve(K.code,K.message)):B((f==null?void 0:f.errorConnection)??"Failed to connect. Please try again."),ue(!1);return}if(pe.current.length>0){const q=K instanceof Error?K:new Error(String(K)),ce=await Vc(pe.current,q,{messages:C,apiUrl:u});if(ce){const Ae={id:Ce(),role:"assistant",content:ce.content,createdAt:qn(),sources:ce.sources},Ze=[...C,Ae];Z.current=Ze,O(Ze),Se(Ze),B(null),ue(!1);return}}K instanceof tt?B(ve(K.code,K.message)):B((f==null?void 0:f.errorConnection)??"Failed to connect. Please try again."),ue(Re(K))}finally{I(!1),ae.current=!1,P(!1),$(null),xe.current=null}},[u,k,ve,Re,Se,v,f]),_e=R.useCallback(()=>{var C;(C=xe.current)==null||C.abort()},[]),ge=R.useCallback(async(C,m)=>{const T=C.trim(),re=(m==null?void 0:m.filter(ie=>ie&&ie.id))??[];if(!T&&re.length===0||ae.current)return;const le={id:Ce(),role:"user",content:T,createdAt:qn(),...re.length>0?{attachments:re}:{}};let se=le;if(pe.current.length>0){const ie=await Hc(pe.current,le,{messages:Z.current,apiUrl:u});if(ie.type==="abort")return;const K=q=>q.createdAt?q:{...q,createdAt:le.createdAt};if(ie.type==="respond"){const q={id:Ce(),role:"assistant",content:ie.reply.content,createdAt:qn(),sources:ie.reply.sources},ce=[...Z.current,K(ie.message),q];Z.current=ce,O(ce),Se(ce),B(null),ue(!1);return}se=K(ie.message)}const ne=[...Z.current,se];Z.current=ne,O(ne),Se(ne),await ye(ne)},[u,Se,ye]),z=R.useCallback(async()=>{if(ae.current)return;const C=Z.current[Z.current.length-1];!C||C.role!=="user"||await ye(Z.current)},[ye]),X=R.useCallback(()=>{if(Z.current=[],O([]),B(null),ue(!1),a){const C=co();if(!C)return;try{C.removeItem(S)}catch{}}},[a,S]);return{messages:j,isLoading:V,isStreaming:D,streamingMessageId:F,error:J,canRetry:Q,sendMessage:ge,stop:_e,retry:z,clearMessages:X}}function ld(u){const[a,i]=R.useState(()=>typeof window>"u"?!1:window.matchMedia(u).matches);return R.useEffect(()=>{const c=window.matchMedia(u);i(c.matches);const f=p=>i(p.matches);return c.addEventListener("change",f),()=>c.removeEventListener("change",f)},[u]),a}function Wr(u,a){return u instanceof RegExp?u.test(a):a.toLowerCase().includes(u.toLowerCase())}function od(){const u=document.documentElement,a=document.body,i=u.scrollTop||a.scrollTop||0,c=Math.max(u.scrollHeight,a.scrollHeight),f=u.clientHeight||window.innerHeight,p=c-f;return p<=0?100:i/p*100}function id({triggers:u,enabled:a,onOpen:i,onGreeting:c}){R.useEffect(()=>{if(!a||!u||u.length===0)return;const f=new Set,p=[],v=typeof window<"u"?window.location.href:"",k=(S,N)=>{f.has(S)||(f.add(S),N==="open"?i():c(N.greeting))};return u.forEach((S,N)=>{switch(S.on){case"url":{Wr(S.pattern,v)&&k(N,S.action);break}case"time":{if(S.matchUrl&&!Wr(S.matchUrl,v))return;const j=window.setTimeout(()=>k(N,S.action),Math.max(0,S.seconds*1e3));p.push(()=>window.clearTimeout(j));break}case"scroll":{if(S.matchUrl&&!Wr(S.matchUrl,v))return;const j=()=>{od()>=S.percent&&k(N,S.action)};j(),window.addEventListener("scroll",j,{passive:!0}),p.push(()=>window.removeEventListener("scroll",j));break}case"exit-intent":{if(S.matchUrl&&!Wr(S.matchUrl,v))return;const j=O=>{O.clientY<=0&&k(N,S.action)};document.addEventListener("mouseleave",j),p.push(()=>document.removeEventListener("mouseleave",j));break}}}),()=>{p.forEach(S=>S())}},[u,a,i,c])}const ud={"bottom-right":"bottom-6 right-6","bottom-left":"bottom-6 left-6","top-right":"top-6 right-6","top-left":"top-6 left-6"},sd=R.forwardRef(function({isOpen:a,onClick:i,position:c="bottom-right",translations:f},p){const v=a?(f==null?void 0:f.closeChat)??"Close chat":(f==null?void 0:f.openChat)??"Open chat";return y.jsx("button",{ref:p,onClick:i,"aria-label":v,className:`fixed ${ud[c]} 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:a?y.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:[y.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),y.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}):y.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:y.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"})})})}),ad=R.memo(function({count:a,isActive:i,onClick:c}){return y.jsxs("button",{onClick:c,"aria-label":"View sources",title:"View sources",className:`group relative flex h-7 w-7 items-center justify-center rounded-claudius-full transition-colors ${i?"bg-claudius-accent text-claudius-accent-text":"text-claudius-text-muted hover:bg-claudius-surface-muted hover:text-claudius-text"}`,children:[y.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:[y.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),y.jsx("polyline",{points:"14 2 14 8 20 8"}),y.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),y.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]}),y.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:a})]})}),cd=["http:","https:"];function Qr(u){if(!u||typeof u!="string")return null;const a=u.trim();if(!a)return null;try{const i=new URL(a);return cd.includes(i.protocol)?a:null}catch{return null}}function dd(){return y.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:[y.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),y.jsx("polyline",{points:"14 2 14 8 20 8"})]})}function mu({label:u,onClick:a}){return y.jsx("button",{type:"button",onClick:a,"aria-label":u,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:y.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round","aria-hidden":"true",children:[y.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),y.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})}const gu=R.memo(function({attachment:a,variant:i,onRemove:c,removeLabel:f}){const p=bc(a),v=i==="composer",k=`${a.name} (${Vr(a.size)})`,S=a.url?Qr(a.url):null;if(p){const j=y.jsx("img",{src:p,alt:a.name,title:k,loading:"lazy",className:v?"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 y.jsxs("div",{className:"relative inline-block",children:[!v&&S?y.jsxs("a",{href:S,target:"_blank",rel:"noopener noreferrer",children:[j,y.jsxs("span",{className:"sr-only",children:[k," (opens in a new tab)"]})]}):j,c&&f&&y.jsx(mu,{label:f,onClick:c})]})}const N=y.jsxs("span",{title:k,className:`inline-flex max-w-[220px] items-center gap-1.5 rounded-claudius-sm border px-2 py-1 text-xs ${v?"border-claudius-border bg-claudius-field text-claudius-text":"border-current/30 bg-transparent"}`,children:[y.jsx(dd,{}),y.jsx("span",{className:"truncate",children:a.name}),y.jsx("span",{className:"shrink-0 opacity-70",children:Vr(a.size)})]});return y.jsxs("div",{className:"relative inline-block",children:[!v&&S?y.jsxs("a",{href:S,target:"_blank",rel:"noopener noreferrer",className:"underline-offset-2 hover:underline",children:[N,y.jsx("span",{className:"sr-only",children:" (opens in a new tab)"})]}):N,c&&f&&y.jsx(mu,{label:f,onClick:c})]})}),vu=R.forwardRef(function({label:a,onClick:i,children:c},f){return y.jsx("button",{ref:f,type:"button",onClick:i,"aria-label":a,title:a,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:y.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:c})})});function fd({state:u,labels:a,onPlay:i,onPause:c,onResume:f,onStop:p}){var j;const v=R.useRef(null),k=R.useRef(null),S=!!((j=v.current)!=null&&j.contains(document.activeElement));R.useEffect(()=>{var O,V;u==="idle"&&S&&!((O=v.current)!=null&&O.contains(document.activeElement))&&((V=k.current)==null||V.focus())},[u,S]);const N=u==="idle"?{label:a.play,onClick:i}:u==="paused"?{label:a.resume,onClick:f}:{label:a.pause,onClick:c};return y.jsxs("div",{ref:v,className:"flex items-center gap-1",children:[y.jsx(vu,{ref:k,...N,children:u==="idle"?y.jsxs(y.Fragment,{children:[y.jsx("polygon",{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"}),y.jsx("path",{d:"M15.54 8.46a5 5 0 0 1 0 7.07",fill:"none"}),y.jsx("path",{d:"M19.07 4.93a10 10 0 0 1 0 14.14",fill:"none"})]}):u==="paused"?y.jsx("polygon",{points:"6 3 20 12 6 21 6 3"}):y.jsxs(y.Fragment,{children:[y.jsx("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"}),y.jsx("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"})]})}),u!=="idle"&&y.jsx(vu,{label:a.stop,onClick:p,children:y.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1.5"})})]})}function pd(u){const a=u.lastIndexOf(` `),i=a===-1?"":u.slice(0,a+1);let c=a===-1?u:u.slice(a+1);return c=gd(c),c=vd(c),i+c}function hd(u){const a=[];for(let i=0;if(v=>!v),"aria-expanded":p?c: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:[y.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:y.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"})}),y.jsxs("span",{children:[a," ",y.jsx("span",{className:"font-mono text-claudius-text",children:u.name}),u.isError&&y.jsx("span",{className:"text-claudius-error",children:" ✕"})]}),p&&y.jsxs(y.Fragment,{children:[y.jsx("span",{className:"sr-only",children:i}),y.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:c?"rotate-180":void 0,children:y.jsx("polyline",{points:"6 9 12 15 18 9"})})]})]}),c&&p&&y.jsxs("div",{className:"mt-1 overflow-x-auto rounded-claudius-sm border border-claudius-border bg-claudius-field p-2 font-mono",children:[u.input!==void 0&&y.jsx("pre",{className:"whitespace-pre-wrap break-all",children:JSON.stringify(u.input,null,2)}),u.result!==void 0&&y.jsx("pre",{className:"mt-1 whitespace-pre-wrap break-all border-t border-claudius-border pt-1",children:u.result})]})]})}const yu=/(https?:\/\/[^\s)]+)/,wu=/(\*\*[^*]+\*\*)/,xu=/(\*[^*]+\*)/;function wd(u,a){const i=u.match(/[.,;:!?'"]+$/),c=i?u.slice(0,-i[0].length):u,f=i?i[0]:"",p=Qr(c);return p?y.jsxs(y.Fragment,{children:[y.jsxs("a",{href:p,target:"_blank",rel:"noopener noreferrer",className:"underline font-medium hover:opacity-80 text-claudius-link",children:[p.replace(/^https?:\/\//,""),y.jsx("span",{className:"sr-only",children:" (opens in a new tab)"})]},a),f]}):u}function xd(u,a){const i=u.split(wu),c=[];return i.forEach((f,p)=>{if(wu.test(f)){const v=f.slice(2,-2);c.push(y.jsx("strong",{children:v},`${a}-b${p}`))}else f.split(xu).forEach((k,S)=>{if(xu.test(k)){const N=k.slice(1,-1);c.push(y.jsx("em",{children:N},`${a}-b${p}-i${S}`))}else k.split(yu).forEach((j,O)=>{yu.test(j)?c.push(wd(j,`${a}-b${p}-i${S}-u${O}`)):j&&c.push(j)})})}),c}function Sd(u){const a=u.split(` `);return a.map((i,c)=>y.jsxs("span",{children:[xd(i,`l${c}`),c0,D=c?pd(i):i,P=V||i!==""||!(v!=null&&v.length);return y.jsxs("div",{className:`${V?"ml-auto":"mr-auto"} max-w-[85%]`,children:[P&&y.jsxs("div",{className:`rounded-claudius-bubble px-4 py-2.5 text-sm leading-relaxed font-body ${V?"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:[I&&y.jsx("ul",{className:`flex flex-wrap gap-2 ${i?"mb-2":""}`,"aria-label":"Attachments",children:p.map(F=>y.jsx("li",{children:y.jsx(gu,{attachment:F,variant:"message"})},F.id))}),(i!==""||!I)&&Sd(D)]}),!V&&v&&v.length>0&&y.jsx("div",{className:"mt-1 space-y-1",children:v.map((F,$)=>y.jsx(yd,{toolUse:F,usedLabel:k,detailsLabel:S},`${F.name}-${$}`))}),!V&&f&&f.length>0&&N&&y.jsx("div",{className:"mt-1",children:y.jsx(ad,{count:f.length,isActive:j??!1,onClick:N})}),!V&&O&&y.jsx("div",{className:"mt-1",children:y.jsx(fd,{...O})})]})}),Su={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",moreOptions:"More options",copyAsMarkdown:"Copy as Markdown",downloadAsMarkdown:"Download as Markdown",downloadAsJson:"Download as JSON",copiedToClipboard:"Copied to clipboard",copyFailed:"Could not copy. Try downloading instead.",transcriptTitle:"Chat transcript",transcriptExported:"Exported {date}",transcriptUser:"User",transcriptAssistant:"Assistant",transcriptAttachments:"Attachments:",transcriptSources:"Sources:",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"},ku=Su;function Eu(u){return u.key===" "||u.key==="Enter"}function Ed({mode:u,isListening:a,disabled:i=!1,onStart:c,onStop:f,label:p}){const v=u==="hold",k=R.useRef(!1),S=()=>{i||k.current||(k.current=!0,c({held:!0}))},N=()=>{k.current&&(k.current=!1,f())},j=D=>{v&&D.detail!==0||(a?f():c({held:!1}))},O=D=>{var P,F;!v||D.button!==0||((F=(P=D.currentTarget).setPointerCapture)==null||F.call(P,D.pointerId),S())},V=D=>{!v||!Eu(D)||(D.preventDefault(),D.repeat||S())},I=D=>{!v||!Eu(D)||(D.preventDefault(),N())};return y.jsx("button",{type:"button",disabled:i,"aria-label":p,"aria-pressed":a,title:p,onClick:j,onPointerDown:O,onPointerUp:N,onPointerCancel:N,onLostPointerCapture:N,onKeyDown:V,onKeyUp:I,onBlur:N,onContextMenu:v?D=>D.preventDefault():void 0,style:v?{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 ${a?"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"} ${v?"touch-none select-none":""}`,children:a&&!v?y.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:y.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1.5"})}):y.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:[y.jsx("path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z"}),y.jsx("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),y.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"22"})]})})}function Cd({active:u}){return y.jsxs("span",{"aria-hidden":"true","data-claudius-voice-level":u?"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:[y.jsx("span",{}),y.jsx("span",{}),y.jsx("span",{}),y.jsx("span",{})]})}function Kr(u,a){return u.replace(/\{(\w+)\}/g,(i,c)=>c in a?String(a[c]):i)}const Rd={en:"en-US",es:"es-ES",fr:"fr-FR",de:"de-DE"},Td=["toggle","hold"];function Cu(u,a){if(!(!u||!u.includes("-")))return u.toLowerCase().split("-")[0]===a?u:void 0}function Ru(u,a){const i=a==null?void 0:a.trim();if(i)return i;const c=typeof document<"u"?Cu(document.documentElement.lang,u):void 0;if(c)return c;const f=typeof navigator<"u"?Cu(navigator.language,u):void 0;return f||Rd[u]}function Nd(u,a){const i=typeof u=="object"&&u!==null&&!Array.isArray(u);if(u!==!0&&!i)return null;const c=u===!0?{}:u,f={input:c.input??!0,output:c.output??!0,mode:Td.includes(c.mode)?c.mode:"toggle",autoSubmit:c.autoSubmit??!1,lang:Ru(a,c.lang)};return f.input||f.output?f:null}function jd(u){const a=u("voice");if(a===null)return;if(a==="false")return!1;const i={},c=N=>{const j=u(N);return j===null?void 0:j!=="false"},f=u("voice-mode");f!==null&&(i.mode=f);const p=c("voice-auto-submit");p!==void 0&&(i.autoSubmit=p);const v=c("voice-input");v!==void 0&&(i.input=v);const k=c("voice-output");k!==void 0&&(i.output=k);const S=u("voice-lang");return S!==null&&(i.lang=S),Object.keys(i).length>0?i:!0}function _d(u,a,i){const c=a.trim();if(!c)return u;const f=u.trimEnd();return(f?`${f} ${c}`:c).slice(0,i)}function Md(u){const a=[];let i=0;for(let c=0;c{const p=c.trim();p&&i.push(p),c=""};for(const p of Md(u)){if((c+p).trim().length<=a){c+=p;continue}if(f(),p.trim().length<=a){c=p;continue}for(let v of p.trim().split(/\s+/)){for(c&&`${c} ${v}`.length>a&&f();v.length>a;)i.push(v.slice(0,a)),v=v.slice(a);c=c?`${c} ${v}`:v}}return f(),i}function Tu(){if(typeof window>"u")return;const u=window;return u.SpeechRecognition??u.webkitSpeechRecognition}function Pd(u){switch(u){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 Ad(u){const[a]=R.useState(()=>Tu()!==void 0),[i,c]=R.useState(!1),[f,p]=R.useState(!1),v=R.useRef(null),k=R.useRef(!1),S=R.useRef(u);R.useEffect(()=>{S.current=u});const N=R.useCallback(I=>{I.onstart=null,I.onend=null,I.onerror=null,I.onresult=null,I.onspeechstart=null,I.onspeechend=null,v.current===I&&(v.current=null),c(!1),p(!1)},[]),j=R.useCallback(()=>{const I=v.current;I&&(N(I),I.abort())},[N]),O=R.useCallback(()=>{const I=v.current;return I?(k.current?I.stop():j(),!0):!1},[j]),V=R.useCallback(()=>{var $,J;const I=Tu();if(!I||v.current)return!1;const D=new I;D.lang=S.current.lang,D.interimResults=!0,D.continuous=!1;let P="";const F=()=>{k.current=!0};D.onstart=F,D.onspeechstart=()=>{F(),p(!0)},D.onspeechend=()=>p(!1),D.onresult=B=>{var de,ae;let Q="",ue="";for(let Z=0;Z{var Q,ue;B.error!=="aborted"&&((ue=(Q=S.current).onError)==null||ue.call(Q,Pd(B.error))),N(D),D.abort()},D.onend=()=>{var B,Q;N(D),(Q=(B=S.current).onEnd)==null||Q.call(B,P)},v.current=D,k.current=!1,c(!0);try{D.start()}catch{return N(D),(J=($=S.current).onError)==null||J.call($,"unavailable"),!1}return!0},[N]);return R.useEffect(()=>j,[j]),{isSupported:a,isListening:i,isSpeechDetected:f,start:V,stop:O,abort:j}}const er=2e3,Dd=1800;function Nu(u){var i;const a=(i=u.dataTransfer)==null?void 0:i.types;return!!a&&Array.from(a).includes("Files")}function zd({onSend:u,isLoading:a,isStreaming:i=!1,onStop:c,placeholder:f,translations:p,attachments:v=null,voice:k=null,onVoiceStart:S,isReadingAloud:N=!1}){const j=p??ku,[O,V]=R.useState(""),[I,D]=R.useState([]),[P,F]=R.useState(null),[$,J]=R.useState(!1),[B,Q]=R.useState(null),ue=R.useRef(null),de=R.useRef(null),ae=R.useRef([]),Z=R.useRef(0),xe=R.useRef(""),pe=R.useRef(""),Se=R.useRef(!1),Ce=R.useRef(!1),ve=R.useRef(!1),Re=H=>{xe.current=H,V(H)},ye=O.length,_e=ye>=Dd,ge=ye>=er,z=f??j.placeholder,X=!!v&&I.length{var H;a||(H=ue.current)==null||H.focus()},[a]);const m=R.useCallback((H,ke)=>{if(!v)return"";switch(ke){case"size":return Kr(j.attachmentTooLarge,{name:H,max:Vr(v.maxSizeBytes)});case"type":return Kr(j.attachmentTypeNotAllowed,{name:H});case"count":return Kr(j.attachmentTooMany,{max:v.maxCount})}},[v,j]),T=R.useCallback(async H=>{if(!v||H.length===0)return;const{accepted:ke,rejected:It}=Gc(H,ae.current.length,v);if(F(It.length>0?m(It[0].file.name,It[0].reason):null),ke.length===0)return;const Gr=await Promise.all(ke.map(Zc));ae.current=[...ae.current,...Gr],D(ae.current)},[v,m]),re=R.useCallback(H=>{ae.current=ae.current.filter(ke=>ke.id!==H),D(ae.current),F(null)},[]),le=()=>{const H=xe.current.trim(),ke=ae.current;!H&&ke.length===0||xe.current.length>=er||(ke.length>0?u(H,ke):u(H),Re(""),ae.current=[],D([]),F(null),Q(null))},se=H=>{switch(H){case"permission":return j.voicePermissionDenied;case"no-speech":return j.voiceNoSpeech;case"no-microphone":return j.voiceNoMicrophone;case"unavailable":return j.voiceUnavailable}},ne=Ad({lang:(k==null?void 0:k.lang)??"en-US",onTranscript:H=>Re(_d(pe.current,H,er)),onEnd:H=>{const ke=H.trim()!=="";if(ke&&(Ce.current=!0),!Se.current){q();return}ke&&ce()},onError:H=>{H==="no-speech"&&Ce.current||(ve.current=!0,Q(se(H)))}}),ie=!!(k!=null&&k.input)&&ne.isSupported,K=ne.isListening;R.useEffect(()=>{const H=ue.current;K&&H&&(H.scrollLeft=H.scrollWidth)},[K,O]);const q=()=>{k!=null&&k.autoSubmit&&Ce.current&&!ve.current&&le()},ce=()=>{const H=xe.current;ne.start()&&(pe.current=H)},Ae=({held:H})=>{Q(null),Se.current=H,Ce.current=!1,ve.current=!1,S==null||S(),ce()},Ze=()=>{const H=Se.current;Se.current=!1,!ne.stop()&&H&&q()},ft=()=>{Se.current=!1,ne.abort()},{abort:Fe}=ne;R.useEffect(()=>{!a&&!N||(Se.current=!1,Fe())},[a,N,Fe]);const Kt=H=>{H.preventDefault(),ft(),le()},_t=H=>{const ke=H.target.value;ke.length<=er&&(ft(),Q(null),Re(ke))},Oe=H=>{const ke=Array.from(H.target.files??[]);H.target.value="",T(ke)},pt=H=>{var It;if(!v)return;const ke=Array.from(((It=H.clipboardData)==null?void 0:It.files)??[]);ke.length!==0&&(H.preventDefault(),T(ke))},Mt=H=>{!v||!Nu(H)||(H.preventDefault(),Z.current+=1,J(!0))},ut=H=>{!v||!Nu(H)||H.preventDefault()},Ue=()=>{v&&(Z.current=Math.max(0,Z.current-1),Z.current===0&&J(!1))},bt=H=>{var ke;v&&(H.preventDefault(),Z.current=0,J(!1),T(Array.from(((ke=H.dataTransfer)==null?void 0:ke.files)??[])))};return y.jsxs("form",{onSubmit:Kt,onDragEnter:Mt,onDragOver:ut,onDragLeave:Ue,onDrop:bt,"data-drag-over":$||void 0,className:`relative border-t border-claudius-border bg-claudius-surface p-3 ${$?"ring-2 ring-inset ring-claudius-accent":""}`,children:[$&&y.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:j.dropFilesHint}),v&&I.length>0&&y.jsx("ul",{"aria-label":j.attachmentsLabel,className:"mb-2 flex flex-wrap gap-3 pt-1",children:I.map(H=>y.jsx("li",{children:y.jsx(gu,{attachment:H,variant:"composer",onRemove:()=>re(H.id),removeLabel:`${j.removeAttachment}: ${H.name}`})},H.id))}),y.jsxs("div",{className:"flex gap-2",children:[v&&y.jsxs(y.Fragment,{children:[y.jsx("input",{ref:de,type:"file",multiple:!0,hidden:!0,tabIndex:-1,accept:v.allowedTypes.join(","),onChange:Oe,"aria-label":j.attachFile}),y.jsx("button",{type:"button",onClick:()=>{var H;return(H=de.current)==null?void 0:H.click()},disabled:a||!X,"aria-label":j.attachFile,title:j.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:y.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:y.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"})})})]}),y.jsxs("div",{className:"relative min-w-0 flex-1",children:[y.jsx("input",{ref:ue,type:"text",value:O,onChange:_t,onPaste:pt,placeholder:K?j.voiceListening:z,disabled:a,"aria-label":j.typeYourMessage,"aria-describedby":_e?"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&&y.jsx(Cd,{active:ne.isSpeechDetected})]}),ie&&k&&y.jsx(Ed,{mode:k.mode,isListening:K,disabled:a,onStart:Ae,onStop:Ze,label:k.mode==="hold"?j.voiceInputHold:j.voiceInput}),C?y.jsx("button",{type:"button",onClick:c,"aria-label":j.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:y.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:y.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1.5"})})}):y.jsx("button",{type:"submit",disabled:a||ge,"aria-label":j.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:y.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:[y.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),y.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]}),(P??B)&&y.jsx("div",{role:"alert",className:"mt-1 text-xs text-claudius-error",children:P??B}),_e&&y.jsxs("div",{id:"char-count",className:`mt-1 text-xs text-right ${ge?"text-claudius-error":"text-claudius-text-muted"}`,"aria-live":"polite",children:[ye,"/",er]})]})}const Od=["blog","page","external"],Id={blog:"Blog",page:"Page",external:"External"};function Fd(u){try{return new URL(u).hostname}catch{return u}}const Ud=R.memo(function({sources:a,onClose:i}){const c=Od.map(p=>({type:p,label:Id[p],items:a.filter(v=>v.type===p)})).filter(p=>p.items.length>0),f=a.length===1?"1 source found":`${a.length} sources found`;return y.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:[y.jsxs("div",{className:"flex items-center justify-between border-b border-claudius-border px-4 py-3",children:[y.jsxs("div",{children:[y.jsx("h3",{className:"text-sm font-heading font-semibold text-claudius-text",children:"Sources"}),y.jsx("p",{className:"text-xs text-claudius-text-muted",children:f})]}),y.jsx("button",{onClick:i,"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:y.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:[y.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),y.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),y.jsx("div",{className:"flex-1 overflow-y-auto px-3 py-3 space-y-4",children:c.map(p=>y.jsxs("div",{children:[y.jsx("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-claudius-text-muted",children:p.label}),y.jsx("div",{className:"space-y-2",children:p.items.map(v=>{const k=Qr(v.url);return k?y.jsxs("a",{href:k,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:[y.jsx("p",{className:"truncate text-sm font-medium text-claudius-text",children:v.title}),y.jsx("p",{className:"mt-0.5 text-xs text-claudius-text-muted",children:Fd(k)})]},k):null})})]},p.type))})]})});function Bd({title:u,subtitle:a,titleId:i,closeLabel:c,onClose:f,actions:p}){return y.jsxs("div",{className:"flex items-center gap-3 bg-claudius-accent px-5 py-4",children:[y.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:u.charAt(0).toUpperCase()}),y.jsxs("div",{className:"flex-1",children:[y.jsx("h2",{id:i,className:"text-sm font-heading font-semibold text-claudius-accent-text",children:u}),y.jsx("p",{className:"text-xs text-claudius-accent-text",children:a})]}),p,y.jsx("button",{onClick:f,"aria-label":c,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:y.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:[y.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),y.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})}function Hd({message:u,retryLabel:a,onRetry:i}){return y.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:[y.jsx("span",{children:u}),i&&y.jsx("button",{type:"button",onClick:i,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:a})]})}function $d({label:u}){return y.jsx("div",{role:"status","aria-live":"polite","aria-label":u,className:"mr-auto flex max-w-[85%]",children:y.jsxs("div",{className:"flex gap-1 rounded-claudius-bubble rounded-bl-claudius-tail bg-claudius-assistant-bubble px-4 py-3",children:[y.jsx("span",{className:"h-2 w-2 motion-safe:animate-bounce rounded-claudius-full bg-claudius-text-muted [animation-delay:0ms]"}),y.jsx("span",{className:"h-2 w-2 motion-safe:animate-bounce rounded-claudius-full bg-claudius-text-muted [animation-delay:150ms]"}),y.jsx("span",{className:"h-2 w-2 motion-safe:animate-bounce rounded-claudius-full bg-claudius-text-muted [animation-delay:300ms]"})]})})}function Vd({label:u,items:a,onOpen:i}){const[c,f]=R.useState(!1),p=R.useId(),v=R.useId(),k=R.useRef(null),S=R.useRef(null),N=R.useRef([]),j=R.useRef(null),O=$=>{j.current=$,f(!0),i==null||i()},V=$=>{var J;f(!1),(J=S.current)==null||J.focus()};R.useEffect(()=>{var J;if(!c)return;j.current!==null&&((J=N.current[j.current])==null||J.focus(),j.current=null);const $=B=>{var Q;(Q=k.current)!=null&&Q.contains(B.target)||f(!1)};return document.addEventListener("pointerdown",$),()=>document.removeEventListener("pointerdown",$)},[c]);const I=$=>{var B;const J=a.length;(B=N.current[($+J)%J])==null||B.focus()},D=$=>{$.key==="ArrowDown"?($.preventDefault(),O(0)):$.key==="ArrowUp"&&($.preventDefault(),O(a.length-1))},P=$=>{const J=N.current.findIndex(B=>B===document.activeElement);switch($.key){case"ArrowDown":$.preventDefault(),I(J+1);break;case"ArrowUp":$.preventDefault(),I(J===-1?a.length-1:J-1);break;case"Home":$.preventDefault(),I(0);break;case"End":$.preventDefault(),I(a.length-1);break;case"Escape":$.preventDefault(),$.stopPropagation(),V();break;case"Tab":$.shiftKey&&($.preventDefault(),V());break}},F=$=>{var B;const J=$.relatedTarget;J&&((B=k.current)!=null&&B.contains(J)||f(!1))};return y.jsxs("div",{ref:k,className:"relative",children:[y.jsx("button",{ref:S,id:p,type:"button","aria-label":u,"aria-haspopup":"menu","aria-expanded":c,"aria-controls":c?v:void 0,onClick:()=>c?V():O(0),onKeyDown:D,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:y.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[y.jsx("circle",{cx:"12",cy:"5",r:"1.75"}),y.jsx("circle",{cx:"12",cy:"12",r:"1.75"}),y.jsx("circle",{cx:"12",cy:"19",r:"1.75"})]})}),c&&y.jsx("div",{id:v,role:"menu","aria-labelledby":p,tabIndex:-1,onKeyDown:P,onBlur:F,className:"absolute right-0 top-full z-20 mt-1 min-w-[12rem] rounded-claudius-md border border-claudius-border bg-claudius-surface py-1 shadow-claudius-elevated",children:a.map(($,J)=>y.jsx("button",{ref:B=>{N.current[J]=B},type:"button",role:"menuitem",tabIndex:-1,"aria-disabled":$.disabled||void 0,onClick:()=>{$.disabled||(V(),$.onSelect())},className:"flex min-h-[40px] w-full items-center whitespace-nowrap px-4 text-left text-sm text-claudius-text hover:bg-claudius-surface-muted focus:bg-claudius-surface-muted aria-disabled:cursor-default aria-disabled:opacity-50 aria-disabled:hover:bg-transparent",children:$.label},$.id))})]})}function Wd(u,a,i){const[c,f]=R.useState(0),p=R.useRef(0),v=R.useRef(0),k=R.useRef(0),S=R.useRef(!1);return R.useEffect(()=>{const N=u.current;if(!i||!N)return;const j=I=>{if(N.scrollTop>0){S.current=!1;return}S.current=!0,v.current=I.touches[0].clientY,k.current=Date.now()},O=I=>{if(!S.current)return;let D=I.touches[0].clientY-v.current;D<0&&(D=D*.3),p.current=D,f(D)},V=()=>{if(!S.current)return;S.current=!1;const I=p.current,D=(Date.now()-k.current)/1e3,P=N.getBoundingClientRect().height,F=D>.05&&I>0&&I/D>500,$=I>P*.3;F||$?a():(p.current=0,f(0))};return N.addEventListener("touchstart",j,{passive:!0}),N.addEventListener("touchmove",O,{passive:!0}),N.addEventListener("touchend",V),()=>{N.removeEventListener("touchstart",j),N.removeEventListener("touchmove",O),N.removeEventListener("touchend",V)}},[u,a,i]),{offsetY:c}}const Qd='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function Kd(u,a){R.useEffect(()=>{const i=u.current;if(!i)return;const c=f=>{if(f.key!=="Tab")return;const p=Array.from(i.querySelectorAll(Qd)).filter(N=>!N.hasAttribute("aria-hidden"));if(p.length===0)return;const v=p[0],k=p[p.length-1],S=document.activeElement;f.shiftKey&&S===v?(f.preventDefault(),k.focus()):!f.shiftKey&&S===k&&(f.preventDefault(),v.focus())};return i.addEventListener("keydown",c),()=>i.removeEventListener("keydown",c)},[u,a])}function tr(){if(!(typeof window>"u")&&!(typeof window.SpeechSynthesisUtterance>"u"))return window.speechSynthesis??void 0}function bd(u){const[a]=R.useState(()=>tr()!==void 0),[i,c]=R.useState(null),[f,p]=R.useState(!1),v=R.useRef(0),k=R.useRef(!1),S=R.useRef([]),N=R.useCallback(()=>{v.current+=1,k.current=!1,S.current=[],c(null),p(!1)},[]),j=R.useCallback(()=>{const D=S.current.length>0;N();const P=tr();!D||!P||(P.cancel(),P.paused&&P.resume())},[N]),O=R.useCallback((D,P)=>{const F=tr();if(!F)return;N(),(F.speaking||F.pending)&&F.cancel(),F.paused&&F.resume();const $=Ld(P);if($.length===0)return;const J=v.current,B=()=>v.current===J;S.current=$.map((Q,ue)=>{const de=new SpeechSynthesisUtterance(Q);return de.lang=u,de.onerror=ae=>{if(!B())return;(ae.error==="interrupted"||ae.error==="canceled")&&!k.current?N():j()},de.onpause=()=>{B()&&p(!0)},de.onresume=()=>{B()&&p(!1)},de.onend=()=>{B()&&(k.current&&!F.paused?j():ue===$.length-1&&N())},de}),c(D);for(const Q of S.current)F.speak(Q)},[u,j,N]),V=R.useCallback(()=>{const D=tr();D&&(k.current=!0,D.pause(),D.paused&&p(!0))},[]),I=R.useCallback(()=>{const D=tr();D&&(k.current=!1,D.resume(),p(!1))},[]);return R.useEffect(()=>j,[j]),{isSupported:a,activeId:i,isPaused:f,speak:O,pause:V,resume:I,cancel:j}}const Gd=/^([ \t]*)(`{3,}|~{3,})(.*)$/,Yd=/^( {0,3})<(?![A-Za-z][A-Za-z0-9+.-]{1,31}:[^<>\s]*>|[^\s<>@]+@[^\s<>]+>)(?=[A-Za-z!?/])/,Xd=/^(?: {4}|\t)/;function ju(u){let a=0;for(const i of u)if(i===" ")a+=1;else if(i===" ")a+=4-a%4;else break;return a}function _u(u){let a=u.length;for(;a>0&&(u[a-1]===" "||u[a-1]===" ");)a-=1;return a===u.length?u:u.slice(0,a)}function Zd(u){const a=Gd.exec(u);if(!a)return null;const[,i,c,f]=a;return c[0]==="`"&&f.includes("`")?null:{indent:i,indentColumns:ju(i),char:c[0],length:c.length}}function Jd(u,a){const i=u.trim();if(i.length{const p=c.trim();p&&i.push(p),c=""};for(const p of Md(u)){if((c+p).trim().length<=a){c+=p;continue}if(f(),p.trim().length<=a){c=p;continue}for(let v of p.trim().split(/\s+/)){for(c&&`${c} ${v}`.length>a&&f();v.length>a;)i.push(v.slice(0,a)),v=v.slice(a);c=c?`${c} ${v}`:v}}return f(),i}function Tu(){if(typeof window>"u")return;const u=window;return u.SpeechRecognition??u.webkitSpeechRecognition}function Pd(u){switch(u){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 Ad(u){const[a]=R.useState(()=>Tu()!==void 0),[i,c]=R.useState(!1),[f,p]=R.useState(!1),v=R.useRef(null),k=R.useRef(!1),S=R.useRef(u);R.useEffect(()=>{S.current=u});const N=R.useCallback(I=>{I.onstart=null,I.onend=null,I.onerror=null,I.onresult=null,I.onspeechstart=null,I.onspeechend=null,v.current===I&&(v.current=null),c(!1),p(!1)},[]),j=R.useCallback(()=>{const I=v.current;I&&(N(I),I.abort())},[N]),O=R.useCallback(()=>{const I=v.current;return I?(k.current?I.stop():j(),!0):!1},[j]),V=R.useCallback(()=>{var $,J;const I=Tu();if(!I||v.current)return!1;const D=new I;D.lang=S.current.lang,D.interimResults=!0,D.continuous=!1;let P="";const F=()=>{k.current=!0};D.onstart=F,D.onspeechstart=()=>{F(),p(!0)},D.onspeechend=()=>p(!1),D.onresult=B=>{var de,ae;let Q="",ue="";for(let Z=0;Z{var Q,ue;B.error!=="aborted"&&((ue=(Q=S.current).onError)==null||ue.call(Q,Pd(B.error))),N(D),D.abort()},D.onend=()=>{var B,Q;N(D),(Q=(B=S.current).onEnd)==null||Q.call(B,P)},v.current=D,k.current=!1,c(!0);try{D.start()}catch{return N(D),(J=($=S.current).onError)==null||J.call($,"unavailable"),!1}return!0},[N]);return R.useEffect(()=>j,[j]),{isSupported:a,isListening:i,isSpeechDetected:f,start:V,stop:O,abort:j}}const er=2e3,Dd=1800;function Nu(u){var i;const a=(i=u.dataTransfer)==null?void 0:i.types;return!!a&&Array.from(a).includes("Files")}function zd({onSend:u,isLoading:a,isStreaming:i=!1,onStop:c,placeholder:f,translations:p,attachments:v=null,voice:k=null,onVoiceStart:S,isReadingAloud:N=!1}){const j=p??ku,[O,V]=R.useState(""),[I,D]=R.useState([]),[P,F]=R.useState(null),[$,J]=R.useState(!1),[B,Q]=R.useState(null),ue=R.useRef(null),de=R.useRef(null),ae=R.useRef([]),Z=R.useRef(0),xe=R.useRef(""),pe=R.useRef(""),Se=R.useRef(!1),Ce=R.useRef(!1),ve=R.useRef(!1),Re=H=>{xe.current=H,V(H)},ye=O.length,_e=ye>=Dd,ge=ye>=er,z=f??j.placeholder,X=!!v&&I.length{var H;a||(H=ue.current)==null||H.focus()},[a]);const m=R.useCallback((H,ke)=>{if(!v)return"";switch(ke){case"size":return Kr(j.attachmentTooLarge,{name:H,max:Vr(v.maxSizeBytes)});case"type":return Kr(j.attachmentTypeNotAllowed,{name:H});case"count":return Kr(j.attachmentTooMany,{max:v.maxCount})}},[v,j]),T=R.useCallback(async H=>{if(!v||H.length===0)return;const{accepted:ke,rejected:It}=Gc(H,ae.current.length,v);if(F(It.length>0?m(It[0].file.name,It[0].reason):null),ke.length===0)return;const Gr=await Promise.all(ke.map(Zc));ae.current=[...ae.current,...Gr],D(ae.current)},[v,m]),re=R.useCallback(H=>{ae.current=ae.current.filter(ke=>ke.id!==H),D(ae.current),F(null)},[]),le=()=>{const H=xe.current.trim(),ke=ae.current;!H&&ke.length===0||xe.current.length>=er||(ke.length>0?u(H,ke):u(H),Re(""),ae.current=[],D([]),F(null),Q(null))},se=H=>{switch(H){case"permission":return j.voicePermissionDenied;case"no-speech":return j.voiceNoSpeech;case"no-microphone":return j.voiceNoMicrophone;case"unavailable":return j.voiceUnavailable}},ne=Ad({lang:(k==null?void 0:k.lang)??"en-US",onTranscript:H=>Re(_d(pe.current,H,er)),onEnd:H=>{const ke=H.trim()!=="";if(ke&&(Ce.current=!0),!Se.current){q();return}ke&&ce()},onError:H=>{H==="no-speech"&&Ce.current||(ve.current=!0,Q(se(H)))}}),ie=!!(k!=null&&k.input)&&ne.isSupported,K=ne.isListening;R.useEffect(()=>{const H=ue.current;K&&H&&(H.scrollLeft=H.scrollWidth)},[K,O]);const q=()=>{k!=null&&k.autoSubmit&&Ce.current&&!ve.current&&le()},ce=()=>{const H=xe.current;ne.start()&&(pe.current=H)},Ae=({held:H})=>{Q(null),Se.current=H,Ce.current=!1,ve.current=!1,S==null||S(),ce()},Ze=()=>{const H=Se.current;Se.current=!1,!ne.stop()&&H&&q()},ft=()=>{Se.current=!1,ne.abort()},{abort:Fe}=ne;R.useEffect(()=>{!a&&!N||(Se.current=!1,Fe())},[a,N,Fe]);const Kt=H=>{H.preventDefault(),ft(),le()},_t=H=>{const ke=H.target.value;ke.length<=er&&(ft(),Q(null),Re(ke))},Oe=H=>{const ke=Array.from(H.target.files??[]);H.target.value="",T(ke)},pt=H=>{var It;if(!v)return;const ke=Array.from(((It=H.clipboardData)==null?void 0:It.files)??[]);ke.length!==0&&(H.preventDefault(),T(ke))},Mt=H=>{!v||!Nu(H)||(H.preventDefault(),Z.current+=1,J(!0))},ut=H=>{!v||!Nu(H)||H.preventDefault()},Ue=()=>{v&&(Z.current=Math.max(0,Z.current-1),Z.current===0&&J(!1))},bt=H=>{var ke;v&&(H.preventDefault(),Z.current=0,J(!1),T(Array.from(((ke=H.dataTransfer)==null?void 0:ke.files)??[])))};return y.jsxs("form",{onSubmit:Kt,onDragEnter:Mt,onDragOver:ut,onDragLeave:Ue,onDrop:bt,"data-drag-over":$||void 0,className:`relative border-t border-claudius-border bg-claudius-surface p-3 ${$?"ring-2 ring-inset ring-claudius-accent":""}`,children:[$&&y.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:j.dropFilesHint}),v&&I.length>0&&y.jsx("ul",{"aria-label":j.attachmentsLabel,className:"mb-2 flex flex-wrap gap-3 pt-1",children:I.map(H=>y.jsx("li",{children:y.jsx(gu,{attachment:H,variant:"composer",onRemove:()=>re(H.id),removeLabel:`${j.removeAttachment}: ${H.name}`})},H.id))}),y.jsxs("div",{className:"flex gap-2",children:[v&&y.jsxs(y.Fragment,{children:[y.jsx("input",{ref:de,type:"file",multiple:!0,hidden:!0,tabIndex:-1,accept:v.allowedTypes.join(","),onChange:Oe,"aria-label":j.attachFile}),y.jsx("button",{type:"button",onClick:()=>{var H;return(H=de.current)==null?void 0:H.click()},disabled:a||!X,"aria-label":j.attachFile,title:j.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:y.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:y.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"})})})]}),y.jsxs("div",{className:"relative min-w-0 flex-1",children:[y.jsx("input",{ref:ue,type:"text",value:O,onChange:_t,onPaste:pt,placeholder:K?j.voiceListening:z,disabled:a,"aria-label":j.typeYourMessage,"aria-describedby":_e?"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&&y.jsx(Cd,{active:ne.isSpeechDetected})]}),ie&&k&&y.jsx(Ed,{mode:k.mode,isListening:K,disabled:a,onStart:Ae,onStop:Ze,label:k.mode==="hold"?j.voiceInputHold:j.voiceInput}),C?y.jsx("button",{type:"button",onClick:c,"aria-label":j.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:y.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:y.jsx("rect",{x:"6",y:"6",width:"12",height:"12",rx:"1.5"})})}):y.jsx("button",{type:"submit",disabled:a||ge,"aria-label":j.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:y.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:[y.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),y.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]}),(P??B)&&y.jsx("div",{role:"alert",className:"mt-1 text-xs text-claudius-error",children:P??B}),_e&&y.jsxs("div",{id:"char-count",className:`mt-1 text-xs text-right ${ge?"text-claudius-error":"text-claudius-text-muted"}`,"aria-live":"polite",children:[ye,"/",er]})]})}const Od=["blog","page","external"],Id={blog:"Blog",page:"Page",external:"External"};function Fd(u){try{return new URL(u).hostname}catch{return u}}const Ud=R.memo(function({sources:a,onClose:i}){const c=Od.map(p=>({type:p,label:Id[p],items:a.filter(v=>v.type===p)})).filter(p=>p.items.length>0),f=a.length===1?"1 source found":`${a.length} sources found`;return y.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:[y.jsxs("div",{className:"flex items-center justify-between border-b border-claudius-border px-4 py-3",children:[y.jsxs("div",{children:[y.jsx("h3",{className:"text-sm font-heading font-semibold text-claudius-text",children:"Sources"}),y.jsx("p",{className:"text-xs text-claudius-text-muted",children:f})]}),y.jsx("button",{onClick:i,"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:y.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:[y.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),y.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),y.jsx("div",{className:"flex-1 overflow-y-auto px-3 py-3 space-y-4",children:c.map(p=>y.jsxs("div",{children:[y.jsx("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-claudius-text-muted",children:p.label}),y.jsx("div",{className:"space-y-2",children:p.items.map(v=>{const k=Qr(v.url);return k?y.jsxs("a",{href:k,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:[y.jsx("p",{className:"truncate text-sm font-medium text-claudius-text",children:v.title}),y.jsx("p",{className:"mt-0.5 text-xs text-claudius-text-muted",children:Fd(k)})]},k):null})})]},p.type))})]})});function Bd({title:u,subtitle:a,titleId:i,closeLabel:c,onClose:f,actions:p}){return y.jsxs("div",{className:"flex items-center gap-3 bg-claudius-accent px-5 py-4",children:[y.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:u.charAt(0).toUpperCase()}),y.jsxs("div",{className:"flex-1",children:[y.jsx("h2",{id:i,className:"text-sm font-heading font-semibold text-claudius-accent-text",children:u}),y.jsx("p",{className:"text-xs text-claudius-accent-text",children:a})]}),p,y.jsx("button",{onClick:f,"aria-label":c,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:y.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:[y.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),y.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})}function Hd({message:u,retryLabel:a,onRetry:i}){return y.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:[y.jsx("span",{children:u}),i&&y.jsx("button",{type:"button",onClick:i,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:a})]})}function $d({label:u}){return y.jsx("div",{role:"status","aria-live":"polite","aria-label":u,className:"mr-auto flex max-w-[85%]",children:y.jsxs("div",{className:"flex gap-1 rounded-claudius-bubble rounded-bl-claudius-tail bg-claudius-assistant-bubble px-4 py-3",children:[y.jsx("span",{className:"h-2 w-2 motion-safe:animate-bounce rounded-claudius-full bg-claudius-text-muted [animation-delay:0ms]"}),y.jsx("span",{className:"h-2 w-2 motion-safe:animate-bounce rounded-claudius-full bg-claudius-text-muted [animation-delay:150ms]"}),y.jsx("span",{className:"h-2 w-2 motion-safe:animate-bounce rounded-claudius-full bg-claudius-text-muted [animation-delay:300ms]"})]})})}function Vd({label:u,items:a,onOpen:i}){const[c,f]=R.useState(!1),p=R.useId(),v=R.useId(),k=R.useRef(null),S=R.useRef(null),N=R.useRef([]),j=R.useRef(null),O=$=>{j.current=$,f(!0),i==null||i()},V=$=>{var J;f(!1),(J=S.current)==null||J.focus()};R.useEffect(()=>{var J;if(!c)return;j.current!==null&&((J=N.current[j.current])==null||J.focus(),j.current=null);const $=B=>{var Q;(Q=k.current)!=null&&Q.contains(B.target)||f(!1)};return document.addEventListener("pointerdown",$),()=>document.removeEventListener("pointerdown",$)},[c]);const I=$=>{var B;const J=a.length;(B=N.current[($+J)%J])==null||B.focus()},D=$=>{$.key==="ArrowDown"?($.preventDefault(),O(0)):$.key==="ArrowUp"&&($.preventDefault(),O(a.length-1))},P=$=>{const J=N.current.findIndex(B=>B===document.activeElement);switch($.key){case"ArrowDown":$.preventDefault(),I(J+1);break;case"ArrowUp":$.preventDefault(),I(J===-1?a.length-1:J-1);break;case"Home":$.preventDefault(),I(0);break;case"End":$.preventDefault(),I(a.length-1);break;case"Escape":$.preventDefault(),$.stopPropagation(),V();break;case"Tab":$.shiftKey&&($.preventDefault(),V());break}},F=$=>{var B;const J=$.relatedTarget;J&&((B=k.current)!=null&&B.contains(J)||f(!1))};return y.jsxs("div",{ref:k,className:"relative",children:[y.jsx("button",{ref:S,id:p,type:"button","aria-label":u,"aria-haspopup":"menu","aria-expanded":c,"aria-controls":c?v:void 0,onClick:()=>c?V():O(0),onKeyDown:D,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:y.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[y.jsx("circle",{cx:"12",cy:"5",r:"1.75"}),y.jsx("circle",{cx:"12",cy:"12",r:"1.75"}),y.jsx("circle",{cx:"12",cy:"19",r:"1.75"})]})}),c&&y.jsx("div",{id:v,role:"menu","aria-labelledby":p,tabIndex:-1,onKeyDown:P,onBlur:F,className:"absolute right-0 top-full z-20 mt-1 min-w-[12rem] rounded-claudius-md border border-claudius-border bg-claudius-surface py-1 shadow-claudius-elevated",children:a.map(($,J)=>y.jsx("button",{ref:B=>{N.current[J]=B},type:"button",role:"menuitem",tabIndex:-1,"aria-disabled":$.disabled||void 0,onClick:()=>{$.disabled||(V(),$.onSelect())},className:"flex min-h-[40px] w-full items-center whitespace-nowrap px-4 text-left text-sm text-claudius-text hover:bg-claudius-surface-muted focus:bg-claudius-surface-muted aria-disabled:cursor-default aria-disabled:opacity-50 aria-disabled:hover:bg-transparent",children:$.label},$.id))})]})}function Wd(u,a,i){const[c,f]=R.useState(0),p=R.useRef(0),v=R.useRef(0),k=R.useRef(0),S=R.useRef(!1);return R.useEffect(()=>{const N=u.current;if(!i||!N)return;const j=I=>{if(N.scrollTop>0){S.current=!1;return}S.current=!0,v.current=I.touches[0].clientY,k.current=Date.now()},O=I=>{if(!S.current)return;let D=I.touches[0].clientY-v.current;D<0&&(D=D*.3),p.current=D,f(D)},V=()=>{if(!S.current)return;S.current=!1;const I=p.current,D=(Date.now()-k.current)/1e3,P=N.getBoundingClientRect().height,F=D>.05&&I>0&&I/D>500,$=I>P*.3;F||$?a():(p.current=0,f(0))};return N.addEventListener("touchstart",j,{passive:!0}),N.addEventListener("touchmove",O,{passive:!0}),N.addEventListener("touchend",V),()=>{N.removeEventListener("touchstart",j),N.removeEventListener("touchmove",O),N.removeEventListener("touchend",V)}},[u,a,i]),{offsetY:c}}const Qd='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function Kd(u,a){R.useEffect(()=>{const i=u.current;if(!i)return;const c=f=>{if(f.key!=="Tab")return;const p=Array.from(i.querySelectorAll(Qd)).filter(N=>!N.hasAttribute("aria-hidden"));if(p.length===0)return;const v=p[0],k=p[p.length-1],S=document.activeElement;f.shiftKey&&S===v?(f.preventDefault(),k.focus()):!f.shiftKey&&S===k&&(f.preventDefault(),v.focus())};return i.addEventListener("keydown",c),()=>i.removeEventListener("keydown",c)},[u,a])}function tr(){if(!(typeof window>"u")&&!(typeof window.SpeechSynthesisUtterance>"u"))return window.speechSynthesis??void 0}function bd(u){const[a]=R.useState(()=>tr()!==void 0),[i,c]=R.useState(null),[f,p]=R.useState(!1),v=R.useRef(0),k=R.useRef(!1),S=R.useRef([]),N=R.useCallback(()=>{v.current+=1,k.current=!1,S.current=[],c(null),p(!1)},[]),j=R.useCallback(()=>{const D=S.current.length>0;N();const P=tr();!D||!P||(P.cancel(),P.paused&&P.resume())},[N]),O=R.useCallback((D,P)=>{const F=tr();if(!F)return;N(),(F.speaking||F.pending)&&F.cancel(),F.paused&&F.resume();const $=Ld(P);if($.length===0)return;const J=v.current,B=()=>v.current===J;S.current=$.map((Q,ue)=>{const de=new SpeechSynthesisUtterance(Q);return de.lang=u,de.onerror=ae=>{if(!B())return;(ae.error==="interrupted"||ae.error==="canceled")&&!k.current?N():j()},de.onpause=()=>{B()&&p(!0)},de.onresume=()=>{B()&&p(!1)},de.onend=()=>{B()&&(k.current&&!F.paused?j():ue===$.length-1&&N())},de}),c(D);for(const Q of S.current)F.speak(Q)},[u,j,N]),V=R.useCallback(()=>{const D=tr();D&&(k.current=!0,D.pause(),D.paused&&p(!0))},[]),I=R.useCallback(()=>{const D=tr();D&&(k.current=!1,D.resume(),p(!1))},[]);return R.useEffect(()=>j,[j]),{isSupported:a,activeId:i,isPaused:f,speak:O,pause:V,resume:I,cancel:j}}const Gd=/^([ \t]*)(`{3,}|~{3,})(.*)$/,Yd=/^( {0,3})<(?![A-Za-z][A-Za-z0-9+.-]{1,31}:[^<>\s]*>|[A-Za-z0-9][^\s<>@]*@[^\s<>]+>)(?=[A-Za-z!?/])/,Xd=/^(?: {4}|\t)/;function ju(u){let a=0;for(const i of u)if(i===" ")a+=1;else if(i===" ")a+=4-a%4;else break;return a}function _u(u){let a=u.length;for(;a>0&&(u[a-1]===" "||u[a-1]===" ");)a-=1;return a===u.length?u:u.slice(0,a)}function Zd(u){const a=Gd.exec(u);if(!a)return null;const[,i,c,f]=a;return c[0]==="`"&&f.includes("`")?null:{indent:i,indentColumns:ju(i),char:c[0],length:c.length}}function Jd(u,a){const i=u.trim();if(i.length0&&i[i.length-1].trim()==="";)i.pop();i.length>0&&(i[i.length-1]=_u(i[i.length-1]))}return i.join(` `)}const ef=/[\u00a0\u202f]/g;function tf(u){if(u.formatDate)return u.formatDate;const a=f=>new Intl.DateTimeFormat(f,{dateStyle:"medium",timeStyle:"short",timeZone:u.timeZone});let i=null;try{i=a(u.locale)}catch{try{i=a(void 0)}catch{i=null}}const c=i;return c?f=>c.format(f):f=>f.toISOString()}function nf(u){const a=tf(u);return i=>a(i).replace(ef," ")}function rf(u,a){var i;try{return((i=new Intl.DateTimeFormat("en",{timeZone:a,timeZoneName:"longOffset"}).formatToParts(u).find(f=>f.type==="timeZoneName"))==null?void 0:i.value)??""}catch{return""}}function Mu(u){const a=u.replace(/\s+/g," ").trim();if(a==="")return"";const i=Math.max(0,...(a.match(/`+/g)??[]).map(p=>p.length)),c="`".repeat(i+1),f=a.startsWith("`")||a.endsWith("`")?" ":"";return`${c}${f}${a}${f}${c}`}const lf={"(":"%28",")":"%29","<":"%3C",">":"%3E","\\":"%5C"};function of(u,a){const i=jn(u.title||u.url).replace(/\s+/g," ").trim().replace(/[\\[\]<]/g,"\\$&"),c=Qr(jn(u.url));if(!c)return`${a+1}. ${i}`;const f=c.replace(/[()<>\\]/g,p=>lf[p]).replace(/\s/g,"%20");return`${a+1}. [${i}](${f})`}function uf(u){const a=Mu(jn(u.name)),i=Vr(Number(u.size));return`- ${a} (${jn(u.mediaType)}, ${i})`}function jn(u){return typeof u=="string"?u:String(u??"")}function br(u){return Array.isArray(u)?u.filter(a=>a!==null&&typeof a=="object"):[]}function sf(u,a){const{labels:i}=a,c=nf(a),f=a.now??new Date,p=rf(f,a.timeZone),v=c(f)+(p?` (${p})`:""),k=[`# ${i.title}`,Kr(i.exported,{date:v})];for(const S of u){if(S===null||typeof S!="object")continue;const N=S.role==="user"?i.user:i.assistant,j=S.createdAt?new Date(S.createdAt):null,O=j&&!Number.isNaN(j.getTime())?` · ${c(j)}`:"";k.push(`## ${N}${O}`);const V=qd(jn(S.content));V&&k.push(V);const I=br(S.attachments);I.length&&k.push(i.attachments,I.map(uf).join(` @@ -54,4 +54,4 @@ Error generating stack: `+o.message+` `)+` `}function af(u){const a=u.filter(i=>i!==null&&typeof i=="object").map(i=>i.attachments===void 0?i:{...i,attachments:br(i.attachments)});return JSON.stringify(hu(a),null,2)+` -`}function Lu(u,a={}){const i=a.now??new Date;let c;try{const f=new Intl.DateTimeFormat("en",{timeZone:a.timeZone,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(i),p=v=>{var k;return((k=f.find(S=>S.type===v))==null?void 0:k.value)??""};c=`${p("year")}-${p("month")}-${p("day")}`}catch{c=i.toISOString().slice(0,10)}return`chat-transcript-${c}.${u}`}function cf(u){const a=document.activeElement;let i=null;try{return i=document.createElement("textarea"),i.value=u,i.setAttribute("readonly",""),i.setAttribute("aria-hidden","true"),i.style.position="fixed",i.style.top="0",i.style.left="0",i.style.opacity="0",document.body.appendChild(i),i.focus({preventScroll:!0}),i.select(),document.execCommand("copy")}catch{return!1}finally{i==null||i.remove(),a==null||a.focus()}}async function df(u){var a;try{if((a=navigator.clipboard)!=null&&a.writeText)return await navigator.clipboard.writeText(u),!0}catch{}return cf(u)}const ff=4e4;function Pu(u,a,i){const c=URL.createObjectURL(new Blob([a],{type:i})),f=document.createElement("a");f.href=c,f.download=u,f.style.display="none",document.body.appendChild(f),f.click(),f.remove(),setTimeout(()=>URL.revokeObjectURL(c),ff)}const pf=4e3;function hf({enabled:u,messages:a,busy:i,locale:c,translations:f}){const p=f??ku,[v,k]=R.useState(null),S=R.useRef(null),N=R.useRef(!0);R.useEffect(()=>(N.current=!0,()=>{N.current=!1,S.current&&clearTimeout(S.current)}),[]);const j=R.useCallback(()=>{S.current&&clearTimeout(S.current),S.current=null,k(null)},[]),O=R.useCallback(I=>{N.current&&(S.current&&clearTimeout(S.current),k(I),S.current=setTimeout(()=>{S.current=null,k(null)},pf))},[]);return{items:R.useMemo(()=>{if(!u)return[];const I=i||a.length===0,D=()=>sf(a,{locale:c,labels:{title:p.transcriptTitle,exported:p.transcriptExported,user:p.transcriptUser,assistant:p.transcriptAssistant,attachments:p.transcriptAttachments,sources:p.transcriptSources,toolUsed:p.toolUsed}});return[{id:"copy-markdown",label:p.copyAsMarkdown,disabled:I,onSelect:()=>{df(D()).then(P=>O(P?p.copiedToClipboard:p.copyFailed))}},{id:"download-markdown",label:p.downloadAsMarkdown,disabled:I,onSelect:()=>Pu(Lu("md"),D(),"text/markdown;charset=utf-8")},{id:"download-json",label:p.downloadAsJson,disabled:I,onSelect:()=>Pu(Lu("json"),af(a),"application/json")}]},[u,i,a,c,p,O]),status:v,clearStatus:j}}const mf=/\*\*([^*]+)\*\*/g,gf=/\*([^*]+)\*/g,vf=/https?:\/\/[^\s)]+/g;function Au(u){return u.replace(mf,"$1").replace(gf,"$1").replace(vf,a=>{var f;const i=((f=a.match(/[.,;:!?'"]+$/))==null?void 0:f[0])??"",c=i?a.slice(0,-i.length):a;try{return new URL(c).hostname+i}catch{return a}})}const yf={"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 wf({messages:u,isLoading:a,isStreaming:i=!1,streamingMessageId:c=null,error:f,canRetry:p=!1,onSend:v,onStop:k,onRetry:S,onClose:N,title:j="Chat",subtitle:O="Ask me anything",welcomeMessage:V="Hi! How can I help you today?",placeholder:I,position:D="bottom-right",translations:P,isMobile:F=!1,attachments:$=null,voice:J=null,conversationExport:B=!1,locale:Q="en-US"}){const ue=R.useId(),de=R.useRef(null),ae=R.useRef(null),[Z,xe]=R.useState(null);Kd(de,!0);const pe=bd((J==null?void 0:J.lang)??"en-US"),Se=!!(J!=null&&J.output)&&pe.isSupported,Ce={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"},ve=hf({enabled:B,messages:u,busy:a,locale:Q,translations:P}),{offsetY:Re}=Wd(ae,N,F),ye=Re!==0,_e=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)").matches:!1;R.useEffect(()=>{const C=ae.current;C&&(C.scrollTop=C.scrollHeight)},[u,a]),R.useEffect(()=>{const C=m=>{m.key==="Escape"&&!m.isComposing&&!m.defaultPrevented&&N()};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[N]);const ge=(P==null?void 0:P.closeChat)??"Close chat",z=(P==null?void 0:P.chatMessages)??"Chat messages",X=[...u].reverse().find(C=>C.role==="assistant");return y.jsxs("div",{ref:de,role:"dialog","aria-modal":F?"true":void 0,"aria-labelledby":ue,className:F?"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 ${yf[D]} 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:F&&!_e?{transform:`translateY(${Math.max(0,Re)}px)`}:void 0,"data-dragging":ye||void 0,children:[F&&y.jsx("div",{className:"flex justify-center py-2","aria-hidden":"true",children:y.jsx("div",{className:"h-1 w-8 rounded-claudius-full bg-claudius-border"})}),y.jsx(Bd,{title:j,subtitle:O,titleId:ue,closeLabel:ge,onClose:N,actions:B?y.jsx(Vd,{label:(P==null?void 0:P.moreOptions)??"More options",items:ve.items,onOpen:ve.clearStatus}):void 0}),y.jsxs("div",{className:"relative flex-1 overflow-hidden",children:[Z&&y.jsx(Ud,{sources:Z.sources,onClose:()=>xe(null)}),B&&y.jsx("div",{role:"status",className:"pointer-events-none absolute inset-x-0 top-2 z-10 flex justify-center px-4",children:ve.status&&y.jsx("span",{className:"rounded-claudius-full bg-claudius-text px-3 py-1 text-xs text-claudius-surface shadow-claudius-elevated",children:ve.status})}),y.jsxs("div",{ref:ae,role:"log","aria-label":z,className:"h-full space-y-3 overflow-y-auto px-4 py-4",children:[u.length===0&&!f&&y.jsx("div",{className:"mr-auto flex max-w-[85%]",children:y.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:V})}),u.map(C=>y.jsx(kd,{role:C.role,content:C.content,isStreaming:C.id===c,sources:C.sources,attachments:C.attachments,toolUses:C.toolUses,toolUsedLabel:P==null?void 0:P.toolUsed,toolDetailsLabel:P==null?void 0:P.toolDetails,isSourceActive:(Z==null?void 0:Z.messageId)===C.id,onSourceClick:()=>{(Z==null?void 0:Z.messageId)===C.id?xe(null):C.sources&&C.sources.length>0&&xe({messageId:C.id,sources:C.sources})},speech:Se&&C.role==="assistant"&&C.id!==c&&C.content.trim()!==""?{state:pe.activeId!==C.id?"idle":pe.isPaused?"paused":"speaking",labels:Ce,onPlay:()=>pe.speak(C.id,Au(C.content)),onPause:pe.pause,onResume:pe.resume,onStop:pe.cancel}:void 0},C.id)),a&&!(c!==null&&u.some(C=>C.id===c&&C.content.length>0))&&y.jsx($d,{label:(P==null?void 0:P.typingIndicator)??"Assistant is typing"}),f&&y.jsx(Hd,{message:f,retryLabel:(P==null?void 0:P.errorRetry)??"Retry",onRetry:p&&S&&!a?S:void 0})]})]}),y.jsx("div",{"data-claudius-live":"assistant","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:X&&X.id!==c?Au(X.content):""}),y.jsx(zd,{onSend:v,isLoading:a,isStreaming:i,onStop:k,placeholder:I,translations:P,attachments:$,voice:J,onVoiceStart:pe.cancel,isReadingAloud:pe.activeId!==null})]})}function xf({message:u,position:a,onOpen:i,onDismiss:c,dismissLabel:f}){const p=a.startsWith("bottom"),v=a.endsWith("right"),k=["claudius-greeting-bubble","fixed z-40 max-w-xs",p?"bottom-20":"top-20",v?"right-4":"left-4"].join(" ");return y.jsxs("div",{className:k,role:"status","aria-live":"polite",children:[y.jsx("button",{type:"button",onClick:i,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:u}),y.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),c()},"aria-label":f,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:y.jsx("span",{"aria-hidden":"true",children:"×"})})]})}const Du={en:Su,es:{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",moreOptions:"Más opciones",copyAsMarkdown:"Copiar como Markdown",downloadAsMarkdown:"Descargar como Markdown",downloadAsJson:"Descargar como JSON",copiedToClipboard:"Copiado al portapapeles",copyFailed:"No se pudo copiar. Prueba a descargarlo.",transcriptTitle:"Transcripción del chat",transcriptExported:"Exportado el {date}",transcriptUser:"Usuario",transcriptAssistant:"Asistente",transcriptAttachments:"Adjuntos:",transcriptSources:"Fuentes:",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"},fr:{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",moreOptions:"Plus d'options",copyAsMarkdown:"Copier en Markdown",downloadAsMarkdown:"Télécharger en Markdown",downloadAsJson:"Télécharger en JSON",copiedToClipboard:"Copié dans le presse-papiers",copyFailed:"Impossible de copier. Essayez plutôt de télécharger.",transcriptTitle:"Transcription du chat",transcriptExported:"Exporté le {date}",transcriptUser:"Utilisateur",transcriptAssistant:"Assistant",transcriptAttachments:"Pièces jointes :",transcriptSources:"Sources :",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"},de:{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",moreOptions:"Weitere Optionen",copyAsMarkdown:"Als Markdown kopieren",downloadAsMarkdown:"Als Markdown herunterladen",downloadAsJson:"Als JSON herunterladen",copiedToClipboard:"In die Zwischenablage kopiert",copyFailed:"Kopieren nicht möglich. Bitte stattdessen herunterladen.",transcriptTitle:"Chat-Protokoll",transcriptExported:"Exportiert am {date}",transcriptUser:"Nutzer",transcriptAssistant:"Assistent",transcriptAttachments:"Anhänge:",transcriptSources:"Quellen:",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"}};function zu(u){if(!u)return;const a=u.toLowerCase().split("-")[0];return Object.prototype.hasOwnProperty.call(Du,a)?a:void 0}function Ou(){const u=typeof document<"u"?zu(document.documentElement.lang):void 0;if(u)return u;const a=typeof navigator<"u"?zu(navigator.language):void 0;return a||"en"}function Sf(u={}){const{locale:a,translations:i}=u,c=Du[a??Ou()];return i?{...c,...i}:{...c}}const Iu=["accent","accentText","accentSoft","accentTextMuted","surface","surfaceMuted","text","textMuted","border","userBubble","userBubbleText","assistantBubble","assistantBubbleText","field","error","errorSurface","errorText","link","scrim"],kf=["sm","md","lg","full","tail"],Ef=["elevated","floating","floatingHover"],Cf=["heading","body"],Fu={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 Rf(u){return Object.prototype.hasOwnProperty.call(Fu,u)}const Tf=new Set(["light","dark","auto"]);function Nf(u){if(u===void 0)return{mode:"light"};if(typeof u=="string"){if(Tf.has(u))return{mode:u};if(Rf(u)){const a=Fu[u];return{mode:a.colorScheme??"light",theme:a}}return{mode:"light",url:u}}return{mode:u.colorScheme??"light",theme:u}}function jf(u){return u.replace(/[A-Z]/g,a=>`-${a.toLowerCase()}`)}function _f(u,a){console.warn(`[Claudius] Ignoring unknown theme token "${a}" in "${u}"`)}function nr(u,a,i,c,f,p=""){if(f)for(const[v,k]of Object.entries(f)){if(!c.includes(v)){_f(a,v);continue}typeof k=="string"&&(u[`${i}${jf(v)}${p}`]=k)}}function Mf(u){const a={};nr(a,"colors","--cl-color-",Iu,u.colors);for(const[i,c]of Object.entries({...a}))a[`${i}-dark`]=c;return nr(a,"colorsDark","--cl-color-",Iu,u.colorsDark,"-dark"),nr(a,"radii","--cl-radius-",kf,u.radii),nr(a,"shadows","--cl-shadow-",Ef,u.shadows),nr(a,"fonts","--cl-font-",Cf,u.fonts),a}function Lf(u){return typeof u=="object"&&u!==null&&!Array.isArray(u)}function Pf(u){const a=R.useMemo(()=>Nf(u),[u]),[i,c]=R.useState(null),f=a.url;R.useEffect(()=>{if(c(null),!f)return;const S=new AbortController;return fetch(f,{signal:S.signal}).then(N=>{if(!N.ok)throw new Error(`HTTP ${N.status}`);return N.json()}).then(N=>{if(!Lf(N))throw new Error("theme JSON must be an object");c(N)}).catch(N=>{S.signal.aborted||console.error(`[Claudius] Failed to load theme from ${f}:`,N)}),()=>S.abort()},[f]);const p=a.theme??i??null,v=(i==null?void 0:i.colorScheme)??a.mode,k=R.useMemo(()=>p?Mf(p):{},[p]);return{mode:v,cssVars:k}}const Uu="claudius:triggers:dismissed";function Af(){if(typeof window>"u")return!1;try{return window.sessionStorage.getItem(Uu)==="1"}catch{return!1}}function Df(){if(!(typeof window>"u"))try{window.sessionStorage.setItem(Uu,"1")}catch{}}function Bu({apiUrl:u,title:a,subtitle:i,welcomeMessage:c,placeholder:f,persistMessages:p,storageKeyPrefix:v,requestTimeoutMs:k,theme:S="light",accentColor:N,position:j="bottom-right",locale:O,translations:V,triggers:I,plugins:D,streaming:P=!0,attachments:F=!1,voice:$=!1,conversationExport:J=!1}){const[B,Q]=R.useState(!1),ue=R.useMemo(()=>Wc(F),[F]),de=R.useMemo(()=>O??Ou(),[O]),ae=R.useMemo(()=>Nd($,de),[$,de]),Z=R.useMemo(()=>Ru(de),[de]),[xe,pe]=R.useState(null),[Se,Ce]=R.useState(Af),ve=R.useRef(!1),Re=ld("(max-width: 639px)"),ye=R.useMemo(()=>Sf({locale:O,translations:V}),[O,V]),{messages:_e,isLoading:ge,isStreaming:z,streamingMessageId:X,error:C,canRetry:m,sendMessage:T,stop:re,retry:le}=rd({apiUrl:u,persistMessages:p,storageKeyPrefix:v,timeoutMs:k,translations:ye,plugins:D,streaming:P}),se=R.useRef(null),ne=R.useRef(B),{mode:ie,cssVars:K}=Pf(S),[q,ce]=R.useState(!1);R.useEffect(()=>{if(ie!=="auto")return;const Ue=window.matchMedia("(prefers-color-scheme: dark)");ce(Ue.matches);const bt=H=>ce(H.matches);return Ue.addEventListener("change",bt),()=>Ue.removeEventListener("change",bt)},[ie]),R.useEffect(()=>{var Ue;ne.current&&!B&&((Ue=se.current)==null||Ue.focus()),ne.current=B},[B]);const Ae=R.useCallback(()=>{Ce(!0),Df()},[]),Ze=R.useCallback(()=>{Q(!1),ve.current&&(ve.current=!1,Ae())},[Ae]),ft=R.useCallback(()=>{Q(Ue=>!Ue)},[]),Fe=R.useCallback(()=>{ve.current=!0,pe(null),Q(!0)},[]),Kt=R.useCallback(Ue=>{pe(Ue)},[]),_t=R.useCallback(()=>{pe(null),Fe()},[Fe]),Oe=R.useCallback(()=>{pe(null),Ae()},[Ae]);id({triggers:I,enabled:!Se&&!B,onOpen:Fe,onGreeting:Kt});const pt=ie==="dark"||ie==="auto"&&q,Mt={...K,...N?{"--cl-color-accent":N,"--cl-color-accent-dark":N}:{}},ut=Object.keys(Mt).length>0?Mt:void 0;return y.jsx("div",{className:"claudius-root",style:ut,children:y.jsxs("div",{"data-claudius-dark":pt?"true":"false",children:[B&&Re&&y.jsx("div",{className:"claudius-scrim fixed inset-0 z-40 bg-claudius-scrim",onClick:Ze,"aria-hidden":"true"}),B&&y.jsx(wf,{messages:_e,isLoading:ge,isStreaming:z,streamingMessageId:X,error:C,canRetry:m,onSend:T,onStop:re,onRetry:le,onClose:Ze,title:a??ye.title,subtitle:i??ye.subtitle,welcomeMessage:c??ye.welcomeMessage,placeholder:f??ye.placeholder,position:j,translations:ye,isMobile:Re,attachments:ue,voice:ae,conversationExport:J===!0,locale:Z}),!(B&&Re)&&y.jsx(sd,{ref:se,isOpen:B,onClick:ft,position:j,translations:ye}),!B&&xe&&y.jsx(xf,{message:xe,position:j,onOpen:_t,onDismiss:Oe,dismissLabel:ye.dismissGreeting})]})})}const zf="1.17.0";typeof window<"u"&&(window.ClaudiusWidgetVersion=zf);function Hu(){const u=window.ClaudiusConfig;if(!(u!=null&&u.apiUrl)){console.error("[Claudius] Missing ClaudiusConfig.apiUrl");return}const a=document.createElement("div");a.id="claudius-chat-widget",document.body.appendChild(a),cu.createRoot(a).render(y.jsx(Bu,{apiUrl:u.apiUrl,title:u.title,subtitle:u.subtitle,welcomeMessage:u.welcomeMessage,placeholder:u.placeholder,persistMessages:u.persistMessages,storageKeyPrefix:u.storageKeyPrefix,requestTimeoutMs:u.requestTimeoutMs,theme:u.theme,accentColor:u.accentColor,position:u.position,locale:u.locale,translations:u.translations,triggers:u.triggers,attachments:u.attachments,voice:u.voice,conversationExport:u.conversationExport}))}class $u extends HTMLElement{constructor(){super(...arguments);hn(this,"root",null);hn(this,"container",null)}static get observedAttributes(){return["api-url","title","subtitle","welcome-message","placeholder","persist-messages","storage-key-prefix","request-timeout-ms","theme","accent-color","position","attachments","conversation-export","voice","voice-mode","voice-auto-submit","voice-input","voice-output","voice-lang"]}connectedCallback(){this.container=document.createElement("div"),this.appendChild(this.container),this.root=cu.createRoot(this.container),this.render()}disconnectedCallback(){this.root&&(this.root.unmount(),this.root=null),this.container&&(this.container.remove(),this.container=null)}attributeChangedCallback(){this.render()}render(){if(!this.root)return;const i=this.getAttribute("api-url");if(!i){console.error("[Claudius] Missing api-url attribute on ");return}const c=this.getAttribute("persist-messages"),f=c===null?void 0:c!=="false",p=this.getAttribute("request-timeout-ms"),v=p===null?void 0:Number(p),k=this.getAttribute("attachments"),S=k===null?void 0:k!=="false",N=this.getAttribute("conversation-export"),j=N==null?void 0:N.trim().toLowerCase(),O=N===null?void 0:j===""||j==="true";this.root.render(y.jsx(Bu,{apiUrl:i,title:this.getAttribute("title")??void 0,subtitle:this.getAttribute("subtitle")??void 0,welcomeMessage:this.getAttribute("welcome-message")??void 0,placeholder:this.getAttribute("placeholder")??void 0,persistMessages:f,storageKeyPrefix:this.getAttribute("storage-key-prefix")??void 0,requestTimeoutMs:v!==void 0&&Number.isFinite(v)?v:void 0,theme:this.getAttribute("theme")??void 0,accentColor:this.getAttribute("accent-color")??void 0,position:this.getAttribute("position")??void 0,attachments:S,conversationExport:O,voice:jd(V=>this.getAttribute(V))}))}}return typeof customElements<"u"&&!customElements.get("claudius-chat")&&customElements.define("claudius-chat",$u),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Hu):Hu(),Ot.ClaudiusChat=$u,Object.defineProperty(Ot,Symbol.toStringTag,{value:"Module"}),Ot})({}); +`}function Lu(u,a={}){const i=a.now??new Date;let c;try{const f=new Intl.DateTimeFormat("en",{timeZone:a.timeZone,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(i),p=v=>{var k;return((k=f.find(S=>S.type===v))==null?void 0:k.value)??""};c=`${p("year")}-${p("month")}-${p("day")}`}catch{c=i.toISOString().slice(0,10)}return`chat-transcript-${c}.${u}`}function cf(u){const a=document.activeElement;let i=null;try{return i=document.createElement("textarea"),i.value=u,i.setAttribute("readonly",""),i.setAttribute("aria-hidden","true"),i.tabIndex=-1,i.style.position="fixed",i.style.top="0",i.style.left="0",i.style.opacity="0",document.body.appendChild(i),i.focus({preventScroll:!0}),i.select(),document.execCommand("copy")}catch{return!1}finally{try{i==null||i.remove()}catch{}try{a==null||a.focus()}catch{}}}async function df(u){var a;try{if((a=navigator.clipboard)!=null&&a.writeText)return await navigator.clipboard.writeText(u),!0}catch{}try{return cf(u)}catch{return!1}}const ff=4e4;function Pu(u,a,i){const c=URL.createObjectURL(new Blob([a],{type:i})),f=document.createElement("a");f.href=c,f.download=u,f.style.display="none",document.body.appendChild(f),f.click(),f.remove(),setTimeout(()=>URL.revokeObjectURL(c),ff)}const pf=4e3;function hf({enabled:u,messages:a,busy:i,locale:c,translations:f}){const p=f??ku,[v,k]=R.useState(null),S=R.useRef(null),N=R.useRef(!0);R.useEffect(()=>(N.current=!0,()=>{N.current=!1,S.current&&clearTimeout(S.current)}),[]);const j=R.useCallback(()=>{S.current&&clearTimeout(S.current),S.current=null,k(null)},[]),O=R.useCallback(I=>{N.current&&(S.current&&clearTimeout(S.current),k(I),S.current=setTimeout(()=>{S.current=null,k(null)},pf))},[]);return{items:R.useMemo(()=>{if(!u)return[];const I=i||a.length===0,D=()=>sf(a,{locale:c,labels:{title:p.transcriptTitle,exported:p.transcriptExported,user:p.transcriptUser,assistant:p.transcriptAssistant,attachments:p.transcriptAttachments,sources:p.transcriptSources,toolUsed:p.toolUsed}});return[{id:"copy-markdown",label:p.copyAsMarkdown,disabled:I,onSelect:()=>{df(D()).then(P=>O(P?p.copiedToClipboard:p.copyFailed))}},{id:"download-markdown",label:p.downloadAsMarkdown,disabled:I,onSelect:()=>Pu(Lu("md"),D(),"text/markdown;charset=utf-8")},{id:"download-json",label:p.downloadAsJson,disabled:I,onSelect:()=>Pu(Lu("json"),af(a),"application/json")}]},[u,i,a,c,p,O]),status:v,clearStatus:j}}const mf=/\*\*([^*]+)\*\*/g,gf=/\*([^*]+)\*/g,vf=/https?:\/\/[^\s)]+/g;function Au(u){return u.replace(mf,"$1").replace(gf,"$1").replace(vf,a=>{var f;const i=((f=a.match(/[.,;:!?'"]+$/))==null?void 0:f[0])??"",c=i?a.slice(0,-i.length):a;try{return new URL(c).hostname+i}catch{return a}})}const yf={"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 wf({messages:u,isLoading:a,isStreaming:i=!1,streamingMessageId:c=null,error:f,canRetry:p=!1,onSend:v,onStop:k,onRetry:S,onClose:N,title:j="Chat",subtitle:O="Ask me anything",welcomeMessage:V="Hi! How can I help you today?",placeholder:I,position:D="bottom-right",translations:P,isMobile:F=!1,attachments:$=null,voice:J=null,conversationExport:B=!1,locale:Q="en-US"}){const ue=R.useId(),de=R.useRef(null),ae=R.useRef(null),[Z,xe]=R.useState(null);Kd(de,!0);const pe=bd((J==null?void 0:J.lang)??"en-US"),Se=!!(J!=null&&J.output)&&pe.isSupported,Ce={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"},ve=hf({enabled:B,messages:u,busy:a,locale:Q,translations:P}),{offsetY:Re}=Wd(ae,N,F),ye=Re!==0,_e=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)").matches:!1;R.useEffect(()=>{const C=ae.current;C&&(C.scrollTop=C.scrollHeight)},[u,a]),R.useEffect(()=>{const C=m=>{m.key==="Escape"&&!m.isComposing&&!m.defaultPrevented&&N()};return document.addEventListener("keydown",C),()=>document.removeEventListener("keydown",C)},[N]);const ge=(P==null?void 0:P.closeChat)??"Close chat",z=(P==null?void 0:P.chatMessages)??"Chat messages",X=[...u].reverse().find(C=>C.role==="assistant");return y.jsxs("div",{ref:de,role:"dialog","aria-modal":F?"true":void 0,"aria-labelledby":ue,className:F?"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 ${yf[D]} 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:F&&!_e?{transform:`translateY(${Math.max(0,Re)}px)`}:void 0,"data-dragging":ye||void 0,children:[F&&y.jsx("div",{className:"flex justify-center py-2","aria-hidden":"true",children:y.jsx("div",{className:"h-1 w-8 rounded-claudius-full bg-claudius-border"})}),y.jsx(Bd,{title:j,subtitle:O,titleId:ue,closeLabel:ge,onClose:N,actions:B?y.jsx(Vd,{label:(P==null?void 0:P.moreOptions)??"More options",items:ve.items,onOpen:ve.clearStatus}):void 0}),y.jsxs("div",{className:"relative flex-1 overflow-hidden",children:[Z&&y.jsx(Ud,{sources:Z.sources,onClose:()=>xe(null)}),B&&y.jsx("div",{role:"status",className:"pointer-events-none absolute inset-x-0 top-2 z-10 flex justify-center px-4",children:ve.status&&y.jsx("span",{className:"rounded-claudius-full bg-claudius-text px-3 py-1 text-xs text-claudius-surface shadow-claudius-elevated",children:ve.status})}),y.jsxs("div",{ref:ae,role:"log","aria-label":z,className:"h-full space-y-3 overflow-y-auto px-4 py-4",children:[u.length===0&&!f&&y.jsx("div",{className:"mr-auto flex max-w-[85%]",children:y.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:V})}),u.map(C=>y.jsx(kd,{role:C.role,content:C.content,isStreaming:C.id===c,sources:C.sources,attachments:C.attachments,toolUses:C.toolUses,toolUsedLabel:P==null?void 0:P.toolUsed,toolDetailsLabel:P==null?void 0:P.toolDetails,isSourceActive:(Z==null?void 0:Z.messageId)===C.id,onSourceClick:()=>{(Z==null?void 0:Z.messageId)===C.id?xe(null):C.sources&&C.sources.length>0&&xe({messageId:C.id,sources:C.sources})},speech:Se&&C.role==="assistant"&&C.id!==c&&C.content.trim()!==""?{state:pe.activeId!==C.id?"idle":pe.isPaused?"paused":"speaking",labels:Ce,onPlay:()=>pe.speak(C.id,Au(C.content)),onPause:pe.pause,onResume:pe.resume,onStop:pe.cancel}:void 0},C.id)),a&&!(c!==null&&u.some(C=>C.id===c&&C.content.length>0))&&y.jsx($d,{label:(P==null?void 0:P.typingIndicator)??"Assistant is typing"}),f&&y.jsx(Hd,{message:f,retryLabel:(P==null?void 0:P.errorRetry)??"Retry",onRetry:p&&S&&!a?S:void 0})]})]}),y.jsx("div",{"data-claudius-live":"assistant","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:X&&X.id!==c?Au(X.content):""}),y.jsx(zd,{onSend:v,isLoading:a,isStreaming:i,onStop:k,placeholder:I,translations:P,attachments:$,voice:J,onVoiceStart:pe.cancel,isReadingAloud:pe.activeId!==null})]})}function xf({message:u,position:a,onOpen:i,onDismiss:c,dismissLabel:f}){const p=a.startsWith("bottom"),v=a.endsWith("right"),k=["claudius-greeting-bubble","fixed z-40 max-w-xs",p?"bottom-20":"top-20",v?"right-4":"left-4"].join(" ");return y.jsxs("div",{className:k,role:"status","aria-live":"polite",children:[y.jsx("button",{type:"button",onClick:i,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:u}),y.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),c()},"aria-label":f,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:y.jsx("span",{"aria-hidden":"true",children:"×"})})]})}const Du={en:Su,es:{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",moreOptions:"Más opciones",copyAsMarkdown:"Copiar como Markdown",downloadAsMarkdown:"Descargar como Markdown",downloadAsJson:"Descargar como JSON",copiedToClipboard:"Copiado al portapapeles",copyFailed:"No se pudo copiar. Prueba a descargarlo.",transcriptTitle:"Transcripción del chat",transcriptExported:"Exportado el {date}",transcriptUser:"Usuario",transcriptAssistant:"Asistente",transcriptAttachments:"Adjuntos:",transcriptSources:"Fuentes:",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"},fr:{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",moreOptions:"Plus d'options",copyAsMarkdown:"Copier en Markdown",downloadAsMarkdown:"Télécharger en Markdown",downloadAsJson:"Télécharger en JSON",copiedToClipboard:"Copié dans le presse-papiers",copyFailed:"Impossible de copier. Essayez plutôt de télécharger.",transcriptTitle:"Transcription du chat",transcriptExported:"Exporté le {date}",transcriptUser:"Utilisateur",transcriptAssistant:"Assistant",transcriptAttachments:"Pièces jointes :",transcriptSources:"Sources :",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"},de:{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",moreOptions:"Weitere Optionen",copyAsMarkdown:"Als Markdown kopieren",downloadAsMarkdown:"Als Markdown herunterladen",downloadAsJson:"Als JSON herunterladen",copiedToClipboard:"In die Zwischenablage kopiert",copyFailed:"Kopieren nicht möglich. Bitte stattdessen herunterladen.",transcriptTitle:"Chat-Protokoll",transcriptExported:"Exportiert am {date}",transcriptUser:"Nutzer",transcriptAssistant:"Assistent",transcriptAttachments:"Anhänge:",transcriptSources:"Quellen:",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"}};function zu(u){if(!u)return;const a=u.toLowerCase().split("-")[0];return Object.prototype.hasOwnProperty.call(Du,a)?a:void 0}function Ou(){const u=typeof document<"u"?zu(document.documentElement.lang):void 0;if(u)return u;const a=typeof navigator<"u"?zu(navigator.language):void 0;return a||"en"}function Sf(u={}){const{locale:a,translations:i}=u,c=Du[a??Ou()];return i?{...c,...i}:{...c}}const Iu=["accent","accentText","accentSoft","accentTextMuted","surface","surfaceMuted","text","textMuted","border","userBubble","userBubbleText","assistantBubble","assistantBubbleText","field","error","errorSurface","errorText","link","scrim"],kf=["sm","md","lg","full","tail"],Ef=["elevated","floating","floatingHover"],Cf=["heading","body"],Fu={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 Rf(u){return Object.prototype.hasOwnProperty.call(Fu,u)}const Tf=new Set(["light","dark","auto"]);function Nf(u){if(u===void 0)return{mode:"light"};if(typeof u=="string"){if(Tf.has(u))return{mode:u};if(Rf(u)){const a=Fu[u];return{mode:a.colorScheme??"light",theme:a}}return{mode:"light",url:u}}return{mode:u.colorScheme??"light",theme:u}}function jf(u){return u.replace(/[A-Z]/g,a=>`-${a.toLowerCase()}`)}function _f(u,a){console.warn(`[Claudius] Ignoring unknown theme token "${a}" in "${u}"`)}function nr(u,a,i,c,f,p=""){if(f)for(const[v,k]of Object.entries(f)){if(!c.includes(v)){_f(a,v);continue}typeof k=="string"&&(u[`${i}${jf(v)}${p}`]=k)}}function Mf(u){const a={};nr(a,"colors","--cl-color-",Iu,u.colors);for(const[i,c]of Object.entries({...a}))a[`${i}-dark`]=c;return nr(a,"colorsDark","--cl-color-",Iu,u.colorsDark,"-dark"),nr(a,"radii","--cl-radius-",kf,u.radii),nr(a,"shadows","--cl-shadow-",Ef,u.shadows),nr(a,"fonts","--cl-font-",Cf,u.fonts),a}function Lf(u){return typeof u=="object"&&u!==null&&!Array.isArray(u)}function Pf(u){const a=R.useMemo(()=>Nf(u),[u]),[i,c]=R.useState(null),f=a.url;R.useEffect(()=>{if(c(null),!f)return;const S=new AbortController;return fetch(f,{signal:S.signal}).then(N=>{if(!N.ok)throw new Error(`HTTP ${N.status}`);return N.json()}).then(N=>{if(!Lf(N))throw new Error("theme JSON must be an object");c(N)}).catch(N=>{S.signal.aborted||console.error(`[Claudius] Failed to load theme from ${f}:`,N)}),()=>S.abort()},[f]);const p=a.theme??i??null,v=(i==null?void 0:i.colorScheme)??a.mode,k=R.useMemo(()=>p?Mf(p):{},[p]);return{mode:v,cssVars:k}}const Uu="claudius:triggers:dismissed";function Af(){if(typeof window>"u")return!1;try{return window.sessionStorage.getItem(Uu)==="1"}catch{return!1}}function Df(){if(!(typeof window>"u"))try{window.sessionStorage.setItem(Uu,"1")}catch{}}function Bu({apiUrl:u,title:a,subtitle:i,welcomeMessage:c,placeholder:f,persistMessages:p,storageKeyPrefix:v,requestTimeoutMs:k,theme:S="light",accentColor:N,position:j="bottom-right",locale:O,translations:V,triggers:I,plugins:D,streaming:P=!0,attachments:F=!1,voice:$=!1,conversationExport:J=!1}){const[B,Q]=R.useState(!1),ue=R.useMemo(()=>Wc(F),[F]),de=R.useMemo(()=>O??Ou(),[O]),ae=R.useMemo(()=>Nd($,de),[$,de]),Z=R.useMemo(()=>Ru(de),[de]),[xe,pe]=R.useState(null),[Se,Ce]=R.useState(Af),ve=R.useRef(!1),Re=ld("(max-width: 639px)"),ye=R.useMemo(()=>Sf({locale:O,translations:V}),[O,V]),{messages:_e,isLoading:ge,isStreaming:z,streamingMessageId:X,error:C,canRetry:m,sendMessage:T,stop:re,retry:le}=rd({apiUrl:u,persistMessages:p,storageKeyPrefix:v,timeoutMs:k,translations:ye,plugins:D,streaming:P}),se=R.useRef(null),ne=R.useRef(B),{mode:ie,cssVars:K}=Pf(S),[q,ce]=R.useState(!1);R.useEffect(()=>{if(ie!=="auto")return;const Ue=window.matchMedia("(prefers-color-scheme: dark)");ce(Ue.matches);const bt=H=>ce(H.matches);return Ue.addEventListener("change",bt),()=>Ue.removeEventListener("change",bt)},[ie]),R.useEffect(()=>{var Ue;ne.current&&!B&&((Ue=se.current)==null||Ue.focus()),ne.current=B},[B]);const Ae=R.useCallback(()=>{Ce(!0),Df()},[]),Ze=R.useCallback(()=>{Q(!1),ve.current&&(ve.current=!1,Ae())},[Ae]),ft=R.useCallback(()=>{Q(Ue=>!Ue)},[]),Fe=R.useCallback(()=>{ve.current=!0,pe(null),Q(!0)},[]),Kt=R.useCallback(Ue=>{pe(Ue)},[]),_t=R.useCallback(()=>{pe(null),Fe()},[Fe]),Oe=R.useCallback(()=>{pe(null),Ae()},[Ae]);id({triggers:I,enabled:!Se&&!B,onOpen:Fe,onGreeting:Kt});const pt=ie==="dark"||ie==="auto"&&q,Mt={...K,...N?{"--cl-color-accent":N,"--cl-color-accent-dark":N}:{}},ut=Object.keys(Mt).length>0?Mt:void 0;return y.jsx("div",{className:"claudius-root",style:ut,children:y.jsxs("div",{"data-claudius-dark":pt?"true":"false",children:[B&&Re&&y.jsx("div",{className:"claudius-scrim fixed inset-0 z-40 bg-claudius-scrim",onClick:Ze,"aria-hidden":"true"}),B&&y.jsx(wf,{messages:_e,isLoading:ge,isStreaming:z,streamingMessageId:X,error:C,canRetry:m,onSend:T,onStop:re,onRetry:le,onClose:Ze,title:a??ye.title,subtitle:i??ye.subtitle,welcomeMessage:c??ye.welcomeMessage,placeholder:f??ye.placeholder,position:j,translations:ye,isMobile:Re,attachments:ue,voice:ae,conversationExport:J===!0,locale:Z}),!(B&&Re)&&y.jsx(sd,{ref:se,isOpen:B,onClick:ft,position:j,translations:ye}),!B&&xe&&y.jsx(xf,{message:xe,position:j,onOpen:_t,onDismiss:Oe,dismissLabel:ye.dismissGreeting})]})})}const zf="1.17.1";typeof window<"u"&&(window.ClaudiusWidgetVersion=zf);function Hu(){const u=window.ClaudiusConfig;if(!(u!=null&&u.apiUrl)){console.error("[Claudius] Missing ClaudiusConfig.apiUrl");return}const a=document.createElement("div");a.id="claudius-chat-widget",document.body.appendChild(a),cu.createRoot(a).render(y.jsx(Bu,{apiUrl:u.apiUrl,title:u.title,subtitle:u.subtitle,welcomeMessage:u.welcomeMessage,placeholder:u.placeholder,persistMessages:u.persistMessages,storageKeyPrefix:u.storageKeyPrefix,requestTimeoutMs:u.requestTimeoutMs,theme:u.theme,accentColor:u.accentColor,position:u.position,locale:u.locale,translations:u.translations,triggers:u.triggers,attachments:u.attachments,voice:u.voice,conversationExport:u.conversationExport}))}class $u extends HTMLElement{constructor(){super(...arguments);hn(this,"root",null);hn(this,"container",null)}static get observedAttributes(){return["api-url","title","subtitle","welcome-message","placeholder","persist-messages","storage-key-prefix","request-timeout-ms","theme","accent-color","position","attachments","conversation-export","voice","voice-mode","voice-auto-submit","voice-input","voice-output","voice-lang"]}connectedCallback(){this.container=document.createElement("div"),this.appendChild(this.container),this.root=cu.createRoot(this.container),this.render()}disconnectedCallback(){this.root&&(this.root.unmount(),this.root=null),this.container&&(this.container.remove(),this.container=null)}attributeChangedCallback(){this.render()}render(){if(!this.root)return;const i=this.getAttribute("api-url");if(!i){console.error("[Claudius] Missing api-url attribute on ");return}const c=this.getAttribute("persist-messages"),f=c===null?void 0:c!=="false",p=this.getAttribute("request-timeout-ms"),v=p===null?void 0:Number(p),k=this.getAttribute("attachments"),S=k===null?void 0:k!=="false",N=this.getAttribute("conversation-export"),j=N==null?void 0:N.trim().toLowerCase(),O=N===null?void 0:j===""||j==="true";this.root.render(y.jsx(Bu,{apiUrl:i,title:this.getAttribute("title")??void 0,subtitle:this.getAttribute("subtitle")??void 0,welcomeMessage:this.getAttribute("welcome-message")??void 0,placeholder:this.getAttribute("placeholder")??void 0,persistMessages:f,storageKeyPrefix:this.getAttribute("storage-key-prefix")??void 0,requestTimeoutMs:v!==void 0&&Number.isFinite(v)?v:void 0,theme:this.getAttribute("theme")??void 0,accentColor:this.getAttribute("accent-color")??void 0,position:this.getAttribute("position")??void 0,attachments:S,conversationExport:O,voice:jd(V=>this.getAttribute(V))}))}}return typeof customElements<"u"&&!customElements.get("claudius-chat")&&customElements.define("claudius-chat",$u),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Hu):Hu(),Ot.ClaudiusChat=$u,Object.defineProperty(Ot,Symbol.toStringTag,{value:"Module"}),Ot})({}); diff --git a/create-claudius/package.json b/create-claudius/package.json index fa33d9a..00fb9b4 100644 --- a/create-claudius/package.json +++ b/create-claudius/package.json @@ -1,6 +1,6 @@ { "name": "create-claudius", - "version": "1.17.0", + "version": "1.17.1", "description": "Scaffold a Claudius AI chat widget project in one command.", "keywords": [ "claudius", diff --git a/docs/package.json b/docs/package.json index efc4fd3..5be0b45 100644 --- a/docs/package.json +++ b/docs/package.json @@ -1,6 +1,6 @@ { "name": "claudius-docs", - "version": "1.17.0", + "version": "1.17.1", "private": true, "type": "module", "scripts": { diff --git a/package.json b/package.json index c6c2b74..d863519 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "claudius", - "version": "1.17.0", + "version": "1.17.1", "description": "Embeddable AI chat widget for PMDS and client sites. React component + standalone script embed, powered by Cloudflare Workers and Claude.", "private": true, "type": "module", diff --git a/widget/package.json b/widget/package.json index 96e2aec..d30bf4b 100644 --- a/widget/package.json +++ b/widget/package.json @@ -1,6 +1,6 @@ { "name": "claudius-chat-widget", - "version": "1.17.0", + "version": "1.17.1", "type": "module", "description": "Embeddable AI chat widget powered by Claude. Drop-in React component or standalone script embed, backed by a Cloudflare Worker.", "keywords": [ diff --git a/worker/package.json b/worker/package.json index c572331..25684bd 100644 --- a/worker/package.json +++ b/worker/package.json @@ -1,6 +1,6 @@ { "name": "claudius-chat-worker", - "version": "1.17.0", + "version": "1.17.1", "private": true, "type": "module", "scripts": {