diff --git a/.release-please-manifest.json b/.release-please-manifest.json index dd8fde7..0d1bebe 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.5.0" + ".": "1.6.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 6374fdf..43ec189 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,14 @@ 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.6.0](https://github.com/PMDevSolutions/Claudius/compare/v1.5.0...v1.6.0) (2026-06-13) + + +### Features + +* publish widget to npm as claudius-chat-widget ([4146076](https://github.com/PMDevSolutions/Claudius/commit/414607635f359c20038981ddb324db9944a2c842)) +* publish widget to npm as claudius-chat-widget ([c686212](https://github.com/PMDevSolutions/Claudius/commit/c686212238062bf83a8ad7b35fc16240b87897a2)) + ## [1.5.0](https://github.com/PMDevSolutions/Claudius/compare/v1.4.0...v1.5.0) (2026-06-11) diff --git a/cdn/claudius.iife.js b/cdn/claudius.iife.js index f22df2e..4657464 100644 --- a/cdn/claudius.iife.js +++ b/cdn/claudius.iife.js @@ -38,4 +38,4 @@ var Claudius=(function(Et){"use strict";var np=Object.defineProperty;var rp=(Et, `).replace(md,"")}function Xr(e,t,n){if(t=ws(t),ws(e)!==t&&n)throw Error(a(425))}function Zr(){}var Ru=null,Tu=null;function Lu(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Pu=typeof setTimeout=="function"?setTimeout:void 0,vd=typeof clearTimeout=="function"?clearTimeout:void 0,xs=typeof Promise=="function"?Promise:void 0,gd=typeof queueMicrotask=="function"?queueMicrotask:typeof xs<"u"?function(e){return xs.resolve(null).then(e).catch(yd)}:Pu;function yd(e){setTimeout(function(){throw e})}function Mu(e,t){var n=t,r=0;do{var l=n.nextSibling;if(e.removeChild(n),l&&l.nodeType===8)if(n=l.data,n==="/$"){if(r===0){e.removeChild(l),qn(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=l}while(n);qn(t)}function At(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function Ss(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var En=Math.random().toString(36).slice(2),wt="__reactFiber$"+En,ar="__reactProps$"+En,Ct="__reactContainer$"+En,ju="__reactEvents$"+En,wd="__reactListeners$"+En,xd="__reactHandles$"+En;function bt(e){var t=e[wt];if(t)return t;for(var n=e.parentNode;n;){if(t=n[Ct]||n[wt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Ss(e);e!==null;){if(n=e[wt])return n;e=Ss(e)}return t}e=n,n=e.parentNode}return null}function cr(e){return e=e[wt]||e[Ct],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Cn(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(a(33))}function Jr(e){return e[ar]||null}var zu=[],_n=-1;function Ut(e){return{current:e}}function he(e){0>_n||(e.current=zu[_n],zu[_n]=null,_n--)}function fe(e,t){_n++,zu[_n]=e.current,e.current=t}var Ht={},He=Ut(Ht),Ge=Ut(!1),en=Ht;function Nn(e,t){var n=e.type.contextTypes;if(!n)return Ht;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var l={},u;for(u in n)l[u]=t[u];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=l),l}function Xe(e){return e=e.childContextTypes,e!=null}function qr(){he(Ge),he(He)}function ks(e,t,n){if(He.current!==Ht)throw Error(a(168));fe(He,t),fe(Ge,n)}function Es(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var l in r)if(!(l in t))throw Error(a(108,ae(e)||"Unknown",l));return P({},n,r)}function br(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Ht,en=He.current,fe(He,e),fe(Ge,Ge.current),!0}function Cs(e,t,n){var r=e.stateNode;if(!r)throw Error(a(169));n?(e=Es(e,t,en),r.__reactInternalMemoizedMergedChildContext=e,he(Ge),he(He),fe(He,e)):he(Ge),fe(Ge,n)}var _t=null,el=!1,Ou=!1;function _s(e){_t===null?_t=[e]:_t.push(e)}function Sd(e){el=!0,_s(e)}function Bt(){if(!Ou&&_t!==null){Ou=!0;var e=0,t=ce;try{var n=_t;for(ce=1;e>=i,l-=i,Nt=1<<32-ct(t)+l|n<V?(Oe=H,H=null):Oe=H.sibling;var ue=y(p,H,h[V],C);if(ue===null){H===null&&(H=Oe);break}e&&H&&ue.alternate===null&&t(p,H),c=u(ue,c,V),U===null?I=ue:U.sibling=ue,U=ue,H=Oe}if(V===h.length)return n(p,H),ge&&nn(p,V),I;if(H===null){for(;VV?(Oe=H,H=null):Oe=H.sibling;var Zt=y(p,H,ue.value,C);if(Zt===null){H===null&&(H=Oe);break}e&&H&&Zt.alternate===null&&t(p,H),c=u(Zt,c,V),U===null?I=Zt:U.sibling=Zt,U=Zt,H=Oe}if(ue.done)return n(p,H),ge&&nn(p,V),I;if(H===null){for(;!ue.done;V++,ue=h.next())ue=k(p,ue.value,C),ue!==null&&(c=u(ue,c,V),U===null?I=ue:U.sibling=ue,U=ue);return ge&&nn(p,V),I}for(H=r(p,H);!ue.done;V++,ue=h.next())ue=L(H,p,V,ue.value,C),ue!==null&&(e&&ue.alternate!==null&&H.delete(ue.key===null?V:ue.key),c=u(ue,c,V),U===null?I=ue:U.sibling=ue,U=ue);return e&&H.forEach(function(tp){return t(p,tp)}),ge&&nn(p,V),I}function Ne(p,c,h,C){if(typeof h=="object"&&h!==null&&h.type===ye&&h.key===null&&(h=h.props.children),typeof h=="object"&&h!==null){switch(h.$$typeof){case Re:e:{for(var I=h.key,U=c;U!==null;){if(U.key===I){if(I=h.type,I===ye){if(U.tag===7){n(p,U.sibling),c=l(U,h.props.children),c.return=p,p=c;break e}}else if(U.elementType===I||typeof I=="object"&&I!==null&&I.$$typeof===Ae&&Ms(I)===U.type){n(p,U.sibling),c=l(U,h.props),c.ref=fr(p,U,h),c.return=p,p=c;break e}n(p,U);break}else t(p,U);U=U.sibling}h.type===ye?(c=fn(h.props.children,p.mode,C,h.key),c.return=p,p=c):(C=Tl(h.type,h.key,h.props,null,p.mode,C),C.ref=fr(p,c,h),C.return=p,p=C)}return i(p);case se:e:{for(U=h.key;c!==null;){if(c.key===U)if(c.tag===4&&c.stateNode.containerInfo===h.containerInfo&&c.stateNode.implementation===h.implementation){n(p,c.sibling),c=l(c,h.children||[]),c.return=p,p=c;break e}else{n(p,c);break}else t(p,c);c=c.sibling}c=Mi(h,p.mode,C),c.return=p,p=c}return i(p);case Ae:return U=h._init,Ne(p,c,U(h._payload),C)}if(Hn(h))return j(p,c,h,C);if(A(h))return z(p,c,h,C);ll(p,h)}return typeof h=="string"&&h!==""||typeof h=="number"?(h=""+h,c!==null&&c.tag===6?(n(p,c.sibling),c=l(c,h),c.return=p,p=c):(n(p,c),c=Pi(h,p.mode,C),c.return=p,p=c),i(p)):n(p,c)}return Ne}var Pn=js(!0),zs=js(!1),ul=Ut(null),il=null,Mn=null,Hu=null;function Bu(){Hu=Mn=il=null}function Vu(e){var t=ul.current;he(ul),e._currentValue=t}function Wu(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function jn(e,t){il=e,Hu=Mn=null,e=e.dependencies,e!==null&&e.firstContext!==null&&((e.lanes&t)!==0&&(Ze=!0),e.firstContext=null)}function ut(e){var t=e._currentValue;if(Hu!==e)if(e={context:e,memoizedValue:t,next:null},Mn===null){if(il===null)throw Error(a(308));Mn=e,il.dependencies={lanes:0,firstContext:e}}else Mn=Mn.next=e;return t}var rn=null;function $u(e){rn===null?rn=[e]:rn.push(e)}function Os(e,t,n,r){var l=t.interleaved;return l===null?(n.next=n,$u(t)):(n.next=l.next,l.next=n),t.interleaved=n,Tt(e,r)}function Tt(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Vt=!1;function Qu(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ds(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function Lt(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Wt(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,(re&2)!==0){var l=r.pending;return l===null?t.next=t:(t.next=l.next,l.next=t),r.pending=t,Tt(e,n)}return l=r.interleaved,l===null?(t.next=t,$u(r)):(t.next=l.next,l.next=t),r.interleaved=t,Tt(e,n)}function ol(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,uu(e,n)}}function Is(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var l=null,u=null;if(n=n.firstBaseUpdate,n!==null){do{var i={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};u===null?l=u=i:u=u.next=i,n=n.next}while(n!==null);u===null?l=u=t:u=u.next=t}else l=u=t;n={baseState:r.baseState,firstBaseUpdate:l,lastBaseUpdate:u,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function sl(e,t,n,r){var l=e.updateQueue;Vt=!1;var u=l.firstBaseUpdate,i=l.lastBaseUpdate,o=l.shared.pending;if(o!==null){l.shared.pending=null;var s=o,v=s.next;s.next=null,i===null?u=v:i.next=v,i=s;var x=e.alternate;x!==null&&(x=x.updateQueue,o=x.lastBaseUpdate,o!==i&&(o===null?x.firstBaseUpdate=v:o.next=v,x.lastBaseUpdate=s))}if(u!==null){var k=l.baseState;i=0,x=v=s=null,o=u;do{var y=o.lane,L=o.eventTime;if((r&y)===y){x!==null&&(x=x.next={eventTime:L,lane:0,tag:o.tag,payload:o.payload,callback:o.callback,next:null});e:{var j=e,z=o;switch(y=t,L=n,z.tag){case 1:if(j=z.payload,typeof j=="function"){k=j.call(L,k,y);break e}k=j;break e;case 3:j.flags=j.flags&-65537|128;case 0:if(j=z.payload,y=typeof j=="function"?j.call(L,k,y):j,y==null)break e;k=P({},k,y);break e;case 2:Vt=!0}}o.callback!==null&&o.lane!==0&&(e.flags|=64,y=l.effects,y===null?l.effects=[o]:y.push(o))}else L={eventTime:L,lane:y,tag:o.tag,payload:o.payload,callback:o.callback,next:null},x===null?(v=x=L,s=k):x=x.next=L,i|=y;if(o=o.next,o===null){if(o=l.shared.pending,o===null)break;y=o,o=y.next,y.next=null,l.lastBaseUpdate=y,l.shared.pending=null}}while(!0);if(x===null&&(s=k),l.baseState=s,l.firstBaseUpdate=v,l.lastBaseUpdate=x,t=l.shared.interleaved,t!==null){l=t;do i|=l.lane,l=l.next;while(l!==t)}else u===null&&(l.shared.lanes=0);on|=i,e.lanes=i,e.memoizedState=k}}function Fs(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;tn?n:4,e(!0);var r=Zu.transition;Zu.transition={};try{e(!1),t()}finally{ce=n,Zu.transition=r}}function na(){return it().memoizedState}function _d(e,t,n){var r=Yt(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},ra(e))la(t,n);else if(n=Os(e,t,n,r),n!==null){var l=Ke();vt(n,e,r,l),ua(n,t,r)}}function Nd(e,t,n){var r=Yt(e),l={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(ra(e))la(t,l);else{var u=e.alternate;if(e.lanes===0&&(u===null||u.lanes===0)&&(u=t.lastRenderedReducer,u!==null))try{var i=t.lastRenderedState,o=u(i,n);if(l.hasEagerState=!0,l.eagerState=o,ft(o,i)){var s=t.interleaved;s===null?(l.next=l,$u(t)):(l.next=s.next,s.next=l),t.interleaved=l;return}}catch{}finally{}n=Os(e,t,l,r),n!==null&&(l=Ke(),vt(n,e,r,l),ua(n,t,r))}}function ra(e){var t=e.alternate;return e===Se||t!==null&&t===Se}function la(e,t){mr=fl=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function ua(e,t,n){if((n&4194240)!==0){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,uu(e,n)}}var hl={readContext:ut,useCallback:Be,useContext:Be,useEffect:Be,useImperativeHandle:Be,useInsertionEffect:Be,useLayoutEffect:Be,useMemo:Be,useReducer:Be,useRef:Be,useState:Be,useDebugValue:Be,useDeferredValue:Be,useTransition:Be,useMutableSource:Be,useSyncExternalStore:Be,useId:Be,unstable_isNewReconciler:!1},Rd={readContext:ut,useCallback:function(e,t){return St().memoizedState=[e,t===void 0?null:t],e},useContext:ut,useEffect:Gs,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,dl(4194308,4,Js.bind(null,t,e),n)},useLayoutEffect:function(e,t){return dl(4194308,4,e,t)},useInsertionEffect:function(e,t){return dl(4,2,e,t)},useMemo:function(e,t){var n=St();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=St();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=_d.bind(null,Se,e),[r.memoizedState,e]},useRef:function(e){var t=St();return e={current:e},t.memoizedState=e},useState:Ks,useDebugValue:ri,useDeferredValue:function(e){return St().memoizedState=e},useTransition:function(){var e=Ks(!1),t=e[0];return e=Cd.bind(null,e[1]),St().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Se,l=St();if(ge){if(n===void 0)throw Error(a(407));n=n()}else{if(n=t(),ze===null)throw Error(a(349));(un&30)!==0||Bs(r,t,n)}l.memoizedState=n;var u={value:n,getSnapshot:t};return l.queue=u,Gs(Ws.bind(null,r,u,e),[e]),r.flags|=2048,yr(9,Vs.bind(null,r,u,n,t),void 0,null),n},useId:function(){var e=St(),t=ze.identifierPrefix;if(ge){var n=Rt,r=Nt;n=(r&~(1<<32-ct(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=vr++,0<\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=i.createElement(n,{is:r.is}):(e=i.createElement(n),n==="select"&&(i=e,r.multiple?i.multiple=!0:r.size&&(i.size=r.size))):e=i.createElementNS(e,n),e[wt]=t,e[ar]=r,_a(e,t,!1,!1),t.stateNode=e;e:{switch(i=Xl(n,r),n){case"dialog":pe("cancel",e),pe("close",e),l=r;break;case"iframe":case"object":case"embed":pe("load",e),l=r;break;case"video":case"audio":for(l=0;lFn&&(t.flags|=128,r=!0,wr(u,!1),t.lanes=4194304)}else{if(!r)if(e=al(i),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),wr(u,!0),u.tail===null&&u.tailMode==="hidden"&&!i.alternate&&!ge)return Ve(t),null}else 2*_e()-u.renderingStartTime>Fn&&n!==1073741824&&(t.flags|=128,r=!0,wr(u,!1),t.lanes=4194304);u.isBackwards?(i.sibling=t.child,t.child=i):(n=u.last,n!==null?n.sibling=i:t.child=i,u.last=i)}return u.tail!==null?(t=u.tail,u.rendering=t,u.tail=t.sibling,u.renderingStartTime=_e(),t.sibling=null,n=xe.current,fe(xe,r?n&1|2:n&1),t):(Ve(t),null);case 22:case 23:return Ri(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&(t.mode&1)!==0?(nt&1073741824)!==0&&(Ve(t),t.subtreeFlags&6&&(t.flags|=8192)):Ve(t),null;case 24:return null;case 25:return null}throw Error(a(156,t.tag))}function Dd(e,t){switch(Iu(t),t.tag){case 1:return Xe(t.type)&&qr(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return zn(),he(Ge),he(He),Xu(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 5:return Yu(t),null;case 13:if(he(xe),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(a(340));Ln()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return he(xe),null;case 4:return zn(),null;case 10:return Vu(t.type._context),null;case 22:case 23:return Ri(),null;case 24:return null;default:return null}}var yl=!1,We=!1,Id=typeof WeakSet=="function"?WeakSet:Set,M=null;function Dn(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Ee(e,t,r)}else n.current=null}function mi(e,t,n){try{n()}catch(r){Ee(e,t,r)}}var Ta=!1;function Fd(e,t){if(Ru=Ar,e=is(),wu(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var l=r.anchorOffset,u=r.focusNode;r=r.focusOffset;try{n.nodeType,u.nodeType}catch{n=null;break e}var i=0,o=-1,s=-1,v=0,x=0,k=e,y=null;t:for(;;){for(var L;k!==n||l!==0&&k.nodeType!==3||(o=i+l),k!==u||r!==0&&k.nodeType!==3||(s=i+r),k.nodeType===3&&(i+=k.nodeValue.length),(L=k.firstChild)!==null;)y=k,k=L;for(;;){if(k===e)break t;if(y===n&&++v===l&&(o=i),y===u&&++x===r&&(s=i),(L=k.nextSibling)!==null)break;k=y,y=k.parentNode}k=L}n=o===-1||s===-1?null:{start:o,end:s}}else n=null}n=n||{start:0,end:0}}else n=null;for(Tu={focusedElem:e,selectionRange:n},Ar=!1,M=t;M!==null;)if(t=M,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,M=e;else for(;M!==null;){t=M;try{var j=t.alternate;if((t.flags&1024)!==0)switch(t.tag){case 0:case 11:case 15:break;case 1:if(j!==null){var z=j.memoizedProps,Ne=j.memoizedState,p=t.stateNode,c=p.getSnapshotBeforeUpdate(t.elementType===t.type?z:pt(t.type,z),Ne);p.__reactInternalSnapshotBeforeUpdate=c}break;case 3:var h=t.stateNode.containerInfo;h.nodeType===1?h.textContent="":h.nodeType===9&&h.documentElement&&h.removeChild(h.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(a(163))}}catch(C){Ee(t,t.return,C)}if(e=t.sibling,e!==null){e.return=t.return,M=e;break}M=t.return}return j=Ta,Ta=!1,j}function xr(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var l=r=r.next;do{if((l.tag&e)===e){var u=l.destroy;l.destroy=void 0,u!==void 0&&mi(t,n,u)}l=l.next}while(l!==r)}}function wl(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function vi(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function La(e){var t=e.alternate;t!==null&&(e.alternate=null,La(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[wt],delete t[ar],delete t[ju],delete t[wd],delete t[xd])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function Pa(e){return e.tag===5||e.tag===3||e.tag===4}function Ma(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||Pa(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function gi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=Zr));else if(r!==4&&(e=e.child,e!==null))for(gi(e,t,n),e=e.sibling;e!==null;)gi(e,t,n),e=e.sibling}function yi(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(yi(e,t,n),e=e.sibling;e!==null;)yi(e,t,n),e=e.sibling}var De=null,ht=!1;function $t(e,t,n){for(n=n.child;n!==null;)ja(e,t,n),n=n.sibling}function ja(e,t,n){if(yt&&typeof yt.onCommitFiberUnmount=="function")try{yt.onCommitFiberUnmount(jr,n)}catch{}switch(n.tag){case 5:We||Dn(n,t);case 6:var r=De,l=ht;De=null,$t(e,t,n),De=r,ht=l,De!==null&&(ht?(e=De,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):De.removeChild(n.stateNode));break;case 18:De!==null&&(ht?(e=De,n=n.stateNode,e.nodeType===8?Mu(e.parentNode,n):e.nodeType===1&&Mu(e,n),qn(e)):Mu(De,n.stateNode));break;case 4:r=De,l=ht,De=n.stateNode.containerInfo,ht=!0,$t(e,t,n),De=r,ht=l;break;case 0:case 11:case 14:case 15:if(!We&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){l=r=r.next;do{var u=l,i=u.destroy;u=u.tag,i!==void 0&&((u&2)!==0||(u&4)!==0)&&mi(n,t,i),l=l.next}while(l!==r)}$t(e,t,n);break;case 1:if(!We&&(Dn(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(o){Ee(n,t,o)}$t(e,t,n);break;case 21:$t(e,t,n);break;case 22:n.mode&1?(We=(r=We)||n.memoizedState!==null,$t(e,t,n),We=r):$t(e,t,n);break;default:$t(e,t,n)}}function za(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new Id),t.forEach(function(r){var l=Kd.bind(null,e,r);n.has(r)||(n.add(r),r.then(l,l))})}}function mt(e,t){var n=t.deletions;if(n!==null)for(var r=0;rl&&(l=i),r&=~u}if(r=l,r=_e()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Ud(r/1960))-r,10e?16:e,Kt===null)var r=!1;else{if(e=Kt,Kt=null,Cl=0,(re&6)!==0)throw Error(a(331));var l=re;for(re|=4,M=e.current;M!==null;){var u=M,i=u.child;if((M.flags&16)!==0){var o=u.deletions;if(o!==null){for(var s=0;s_e()-Si?an(e,0):xi|=n),qe(e,t)}function Ka(e,t){t===0&&((e.mode&1)===0?t=1:(t=Or,Or<<=1,(Or&130023424)===0&&(Or=4194304)));var n=Ke();e=Tt(e,t),e!==null&&(Yn(e,t,n),qe(e,n))}function Qd(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ka(e,n)}function Kd(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,l=e.memoizedState;l!==null&&(n=l.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(a(314))}r!==null&&r.delete(t),Ka(e,n)}var Ya;Ya=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Ge.current)Ze=!0;else{if((e.lanes&n)===0&&(t.flags&128)===0)return Ze=!1,zd(e,t,n);Ze=(e.flags&131072)!==0}else Ze=!1,ge&&(t.flags&1048576)!==0&&Ns(t,nl,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;gl(e,t),e=t.pendingProps;var l=Nn(t,He.current);jn(t,n),l=qu(null,t,r,e,l,n);var u=bu();return t.flags|=1,typeof l=="object"&&l!==null&&typeof l.render=="function"&&l.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,Xe(r)?(u=!0,br(t)):u=!1,t.memoizedState=l.state!==null&&l.state!==void 0?l.state:null,Qu(t),l.updater=ml,t.stateNode=l,l._reactInternals=t,ui(t,r,e,n),t=ai(null,t,r,!0,u,n)):(t.tag=0,ge&&u&&Du(t),Qe(null,t,l,n),t=t.child),t;case 16:r=t.elementType;e:{switch(gl(e,t),e=t.pendingProps,l=r._init,r=l(r._payload),t.type=r,l=t.tag=Gd(r),e=pt(r,e),l){case 0:t=si(null,t,r,e,n);break e;case 1:t=wa(null,t,r,e,n);break e;case 11:t=ha(null,t,r,e,n);break e;case 14:t=ma(null,t,r,pt(r.type,e),n);break e}throw Error(a(306,r,""))}return t;case 0:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:pt(r,l),si(e,t,r,l,n);case 1:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:pt(r,l),wa(e,t,r,l,n);case 3:e:{if(xa(t),e===null)throw Error(a(387));r=t.pendingProps,u=t.memoizedState,l=u.element,Ds(e,t),sl(t,r,null,n);var i=t.memoizedState;if(r=i.element,u.isDehydrated)if(u={element:r,isDehydrated:!1,cache:i.cache,pendingSuspenseBoundaries:i.pendingSuspenseBoundaries,transitions:i.transitions},t.updateQueue.baseState=u,t.memoizedState=u,t.flags&256){l=On(Error(a(423)),t),t=Sa(e,t,r,n,l);break e}else if(r!==l){l=On(Error(a(424)),t),t=Sa(e,t,r,n,l);break e}else for(tt=At(t.stateNode.containerInfo.firstChild),et=t,ge=!0,dt=null,n=zs(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Ln(),r===l){t=Pt(e,t,n);break e}Qe(e,t,r,n)}t=t.child}return t;case 5:return As(t),e===null&&Au(t),r=t.type,l=t.pendingProps,u=e!==null?e.memoizedProps:null,i=l.children,Lu(r,l)?i=null:u!==null&&Lu(r,u)&&(t.flags|=32),ya(e,t),Qe(e,t,i,n),t.child;case 6:return e===null&&Au(t),null;case 13:return ka(e,t,n);case 4:return Ku(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Pn(t,null,r,n):Qe(e,t,r,n),t.child;case 11:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:pt(r,l),ha(e,t,r,l,n);case 7:return Qe(e,t,t.pendingProps,n),t.child;case 8:return Qe(e,t,t.pendingProps.children,n),t.child;case 12:return Qe(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,l=t.pendingProps,u=t.memoizedProps,i=l.value,fe(ul,r._currentValue),r._currentValue=i,u!==null)if(ft(u.value,i)){if(u.children===l.children&&!Ge.current){t=Pt(e,t,n);break e}}else for(u=t.child,u!==null&&(u.return=t);u!==null;){var o=u.dependencies;if(o!==null){i=u.child;for(var s=o.firstContext;s!==null;){if(s.context===r){if(u.tag===1){s=Lt(-1,n&-n),s.tag=2;var v=u.updateQueue;if(v!==null){v=v.shared;var x=v.pending;x===null?s.next=s:(s.next=x.next,x.next=s),v.pending=s}}u.lanes|=n,s=u.alternate,s!==null&&(s.lanes|=n),Wu(u.return,n,t),o.lanes|=n;break}s=s.next}}else if(u.tag===10)i=u.type===t.type?null:u.child;else if(u.tag===18){if(i=u.return,i===null)throw Error(a(341));i.lanes|=n,o=i.alternate,o!==null&&(o.lanes|=n),Wu(i,n,t),i=u.sibling}else i=u.child;if(i!==null)i.return=u;else for(i=u;i!==null;){if(i===t){i=null;break}if(u=i.sibling,u!==null){u.return=i.return,i=u;break}i=i.return}u=i}Qe(e,t,l.children,n),t=t.child}return t;case 9:return l=t.type,r=t.pendingProps.children,jn(t,n),l=ut(l),r=r(l),t.flags|=1,Qe(e,t,r,n),t.child;case 14:return r=t.type,l=pt(r,t.pendingProps),l=pt(r.type,l),ma(e,t,r,l,n);case 15:return va(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,l=t.pendingProps,l=t.elementType===r?l:pt(r,l),gl(e,t),t.tag=1,Xe(r)?(e=!0,br(t)):e=!1,jn(t,n),oa(t,r,l),ui(t,r,l,n),ai(null,t,r,!0,e,n);case 19:return Ca(e,t,n);case 22:return ga(e,t,n)}throw Error(a(156,t.tag))};function Ga(e,t){return Ro(e,t)}function Yd(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function st(e,t,n,r){return new Yd(e,t,n,r)}function Li(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Gd(e){if(typeof e=="function")return Li(e)?1:0;if(e!=null){if(e=e.$$typeof,e===ne)return 11;if(e===$e)return 14}return 2}function Xt(e,t){var n=e.alternate;return n===null?(n=st(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Tl(e,t,n,r,l,u){var i=2;if(r=e,typeof e=="function")Li(e)&&(i=1);else if(typeof e=="string")i=5;else e:switch(e){case ye:return fn(n.children,l,u,t);case Le:i=8,l|=8;break;case le:return e=st(12,n,t,l|2),e.elementType=le,e.lanes=u,e;case ke:return e=st(13,n,t,l),e.elementType=ke,e.lanes=u,e;case we:return e=st(19,n,t,l),e.elementType=we,e.lanes=u,e;case ve:return Ll(n,l,u,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Fe:i=10;break e;case te:i=9;break e;case ne:i=11;break e;case $e:i=14;break e;case Ae:i=16,r=null;break e}throw Error(a(130,e==null?e:typeof e,""))}return t=st(i,n,t,l),t.elementType=e,t.type=r,t.lanes=u,t}function fn(e,t,n,r){return e=st(7,e,r,t),e.lanes=n,e}function Ll(e,t,n,r){return e=st(22,e,r,t),e.elementType=ve,e.lanes=n,e.stateNode={isHidden:!1},e}function Pi(e,t,n){return e=st(6,e,null,t),e.lanes=n,e}function Mi(e,t,n){return t=st(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function Xd(e,t,n,r,l){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=lu(0),this.expirationTimes=lu(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=lu(0),this.identifierPrefix=r,this.onRecoverableError=l,this.mutableSourceEagerHydrationData=null}function ji(e,t,n,r,l,u,i,o,s){return e=new Xd(e,t,n,o,s),t===1?(t=1,u===!0&&(t|=8)):t=0,u=st(3,null,null,t),e.current=u,u.stateNode=e,u.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Qu(u),e}function Zd(e,t,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(d)}catch(m){console.error(m)}}return d(),Al.exports=uc(),Al.exports}var $i;function oc(){if($i)return _r;$i=1;var d=ic();return _r.createRoot=d.createRoot,_r.hydrateRoot=d.hydrateRoot,_r}var Qi=oc(),F=Fl();class dn extends Error{constructor(m,a,S,w){super(m),this.status=a,this.code=S,this.retryAfter=w,this.name="ChatApiError"}}class Ki extends Error{constructor(){super("Request debounced"),this.name="DebounceError"}}const sc=3e4;class ac{constructor(m,a){Jt(this,"baseUrl");Jt(this,"maxRetries");Jt(this,"debounceMs");Jt(this,"timeoutMs");Jt(this,"lastSendTime",0);this.baseUrl=m,this.maxRetries=(a==null?void 0:a.maxRetries)??2,this.debounceMs=(a==null?void 0:a.debounceMs)??300,this.timeoutMs=(a==null?void 0:a.timeoutMs)??sc}async sendMessage(m){if(this.debounceMs>0&&Date.now()-this.lastSendTime({})),T=w.headers.get("Retry-After"),D=T?Number(T):void 0;if(a=new dn(_.error??`Request failed with status ${w.status}`,w.status,_.code,D),!this.isRetryable(w.status))throw a;if(Sa.abort(),this.timeoutMs);try{return await fetch(`${this.baseUrl}/api/chat`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:m}),signal:a.signal})}catch(w){throw a.signal.aborted?new dn("Request timed out. Please try again.",0,"TIMEOUT"):w}finally{clearTimeout(S)}}isRetryable(m,a){return a==="TIMEOUT"||a==="NETWORK_ERROR"?!0:m===429||m===503}getRetryDelay(m,a){if(m&&m.status===429){const S=m.headers.get("Retry-After");if(S){const w=Number(S);return Math.min(w*1e3,6e4)}}return a===0?1e3:3e3}delay(m){return new Promise(a=>setTimeout(a,m))}}const cc=200,fc="claudius:messages";function dc(d,m){let a;try{a=new URL(m).host}catch{a=m}return`${d}:${a}`}function Bl(){try{return typeof sessionStorage<"u"?sessionStorage:null}catch{return null}}function pc(d){const m=Bl();if(!m)return[];try{const a=m.getItem(d);if(!a)return[];const S=JSON.parse(a);return Array.isArray(S)?S:[]}catch{return[]}}function hc({apiUrl:d,persistMessages:m=!0,storageKeyPrefix:a=fc,timeoutMs:S,translations:w}){const _=F.useMemo(()=>new ac(d,{debounceMs:0,timeoutMs:S}),[d,S]),T=dc(a,d),D=m?pc(T):[],[N,O]=F.useState(D),[Q,Y]=F.useState(!1),[B,J]=F.useState(null),[G,$]=F.useState(!1),W=F.useRef(D.length),oe=F.useRef(!1),me=F.useRef(D),Ce=F.useCallback(te=>{if(!m)return;const ne=Bl();if(ne)try{const ke=te.slice(-cc);ne.setItem(T,JSON.stringify(ke))}catch{}},[m,T]),de=()=>(W.current+=1,`msg-${W.current}`),Re=F.useCallback((te,ne)=>{if(!w)return ne??"Something went wrong. Please try again.";switch(te){case"TIMEOUT":return w.errorTimeout;case"NETWORK_ERROR":return w.errorConnection;case"RATE_LIMITED":return ne!=null&&ne.includes("minute")?w.errorRateLimitMinute:w.errorRateLimitHour;case"VALIDATION_ERROR":case"CONFIG_ERROR":case"SERVICE_ERROR":case"UNKNOWN_ERROR":default:return ne??w.errorGeneric}},[w]),se=F.useCallback(te=>!(te instanceof dn)||te.code==="TIMEOUT"||te.code==="NETWORK_ERROR"||te.code==="RATE_LIMITED"||te.code==="SERVICE_ERROR"||te.code==="UNKNOWN_ERROR"||te.status>=500||te.status===0,[]),ye=F.useCallback(async te=>{Y(!0),oe.current=!0,J(null),$(!1);try{const ne=await _.sendMessage(te),ke={id:de(),role:"assistant",content:ne.reply,sources:ne.sources},we=[...te,ke];me.current=we,O(we),Ce(we)}catch(ne){if(ne instanceof Ki)return;ne instanceof dn?J(Re(ne.code,ne.message)):J((w==null?void 0:w.errorConnection)??"Failed to connect. Please try again."),$(se(ne))}finally{Y(!1),oe.current=!1}},[_,Re,se,Ce,w]),Le=F.useCallback(async te=>{const ne=te.trim();if(!ne||oe.current)return;const ke={id:de(),role:"user",content:ne},we=[...me.current,ke];me.current=we,O(we),Ce(we),await ye(we)},[Ce,ye]),le=F.useCallback(async()=>{if(oe.current)return;const te=me.current[me.current.length-1];!te||te.role!=="user"||await ye(me.current)},[ye]),Fe=F.useCallback(()=>{if(me.current=[],O([]),J(null),$(!1),m){const te=Bl();if(!te)return;try{te.removeItem(T)}catch{}}},[m,T]);return{messages:N,isLoading:Q,error:B,canRetry:G,sendMessage:Le,retry:le,clearMessages:Fe}}function mc(d){const[m,a]=F.useState(()=>typeof window>"u"?!1:window.matchMedia(d).matches);return F.useEffect(()=>{const S=window.matchMedia(d);a(S.matches);const w=_=>a(_.matches);return S.addEventListener("change",w),()=>S.removeEventListener("change",w)},[d]),m}function Nr(d,m){return d instanceof RegExp?d.test(m):m.toLowerCase().includes(d.toLowerCase())}function vc(){const d=document.documentElement,m=document.body,a=d.scrollTop||m.scrollTop||0,S=Math.max(d.scrollHeight,m.scrollHeight),w=d.clientHeight||window.innerHeight,_=S-w;return _<=0?100:a/_*100}function gc({triggers:d,enabled:m,onOpen:a,onGreeting:S}){F.useEffect(()=>{if(!m||!d||d.length===0)return;const w=new Set,_=[],T=typeof window<"u"?window.location.href:"",D=(N,O)=>{w.has(N)||(w.add(N),O==="open"?a():S(O.greeting))};return d.forEach((N,O)=>{switch(N.on){case"url":{Nr(N.pattern,T)&&D(O,N.action);break}case"time":{if(N.matchUrl&&!Nr(N.matchUrl,T))return;const Q=window.setTimeout(()=>D(O,N.action),Math.max(0,N.seconds*1e3));_.push(()=>window.clearTimeout(Q));break}case"scroll":{if(N.matchUrl&&!Nr(N.matchUrl,T))return;const Q=()=>{vc()>=N.percent&&D(O,N.action)};Q(),window.addEventListener("scroll",Q,{passive:!0}),_.push(()=>window.removeEventListener("scroll",Q));break}case"exit-intent":{if(N.matchUrl&&!Nr(N.matchUrl,T))return;const Q=Y=>{Y.clientY<=0&&D(O,N.action)};document.addEventListener("mouseleave",Q),_.push(()=>document.removeEventListener("mouseleave",Q));break}}}),()=>{_.forEach(N=>N())}},[d,m,a,S])}const yc={"bottom-right":"bottom-6 right-6","bottom-left":"bottom-6 left-6","top-right":"top-6 right-6","top-left":"top-6 left-6"},wc=F.forwardRef(function({isOpen:m,onClick:a,position:S="bottom-right",translations:w},_){const T=m?(w==null?void 0:w.closeChat)??"Close chat":(w==null?void 0:w.openChat)??"Open chat";return E.jsx("button",{ref:_,onClick:a,"aria-label":T,className:`fixed ${yc[S]} 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:m?E.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:[E.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),E.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]}):E.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:E.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"})})})}),xc=F.memo(function({count:m,isActive:a,onClick:S}){return E.jsxs("button",{onClick:S,"aria-label":"View sources",title:"View sources",className:`group relative flex h-7 w-7 items-center justify-center rounded-claudius-full transition-colors ${a?"bg-claudius-accent text-claudius-accent-text":"text-claudius-text-muted hover:bg-claudius-surface-muted hover:text-claudius-text"}`,children:[E.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:[E.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),E.jsx("polyline",{points:"14 2 14 8 20 8"}),E.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),E.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"})]}),E.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:m})]})}),Sc=["http:","https:"];function Yi(d){if(!d||typeof d!="string")return null;const m=d.trim();if(!m)return null;try{const a=new URL(m);return Sc.includes(a.protocol)?m:null}catch{return null}}const Gi=/(https?:\/\/[^\s)]+)/,Xi=/(\*\*[^*]+\*\*)/,Zi=/(\*[^*]+\*)/;function kc(d,m){const a=d.match(/[.,;:!?'"]+$/),S=a?d.slice(0,-a[0].length):d,w=a?a[0]:"",_=Yi(S);return _?E.jsxs(E.Fragment,{children:[E.jsxs("a",{href:_,target:"_blank",rel:"noopener noreferrer",className:"underline font-medium hover:opacity-80 text-claudius-link",children:[_.replace(/^https?:\/\//,""),E.jsx("span",{className:"sr-only",children:" (opens in a new tab)"})]},m),w]}):d}function Ec(d,m){const a=d.split(Xi),S=[];return a.forEach((w,_)=>{if(Xi.test(w)){const T=w.slice(2,-2);S.push(E.jsx("strong",{children:T},`${m}-b${_}`))}else w.split(Zi).forEach((D,N)=>{if(Zi.test(D)){const O=D.slice(1,-1);S.push(E.jsx("em",{children:O},`${m}-b${_}-i${N}`))}else D.split(Gi).forEach((Q,Y)=>{Gi.test(Q)?S.push(kc(Q,`${m}-b${_}-i${N}-u${Y}`)):Q&&S.push(Q)})})}),S}function Cc(d){const m=d.split(` -`);return m.map((a,S)=>E.jsxs("span",{children:[Ec(a,`l${S}`),S0&&w&&E.jsx("div",{className:"mt-1",children:E.jsx(xc,{count:S.length,isActive:_??!1,onClick:w})})]})}),Vl=2e3,Nc=1800;function Rc({onSend:d,isLoading:m,placeholder:a,translations:S}){const[w,_]=F.useState(""),T=F.useRef(null),D=w.length,N=D>=Nc,O=D>=Vl,Q=a??(S==null?void 0:S.placeholder)??"Type your message...",Y=(S==null?void 0:S.sendMessage)??"Send message",B=(S==null?void 0:S.typeYourMessage)??"Type your message";F.useEffect(()=>{var $;m||($=T.current)==null||$.focus()},[m]);const J=$=>{$.preventDefault();const W=w.trim();!W||O||(d(W),_(""))},G=$=>{const W=$.target.value;W.length<=Vl&&_(W)};return E.jsxs("form",{onSubmit:J,className:"border-t border-claudius-border bg-claudius-surface p-3",children:[E.jsxs("div",{className:"flex gap-2",children:[E.jsx("input",{ref:T,type:"text",value:w,onChange:G,placeholder:Q,disabled:m,"aria-label":B,"aria-describedby":N?"char-count":void 0,className:"flex-1 rounded-claudius-sm border border-claudius-border bg-claudius-field px-3 py-2 text-sm font-body text-claudius-text placeholder:text-claudius-text-muted focus:border-claudius-accent focus:outline-none focus:ring-1 focus:ring-claudius-accent disabled:opacity-50"}),E.jsx("button",{type:"submit",disabled:m||O,"aria-label":Y,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:E.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:[E.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),E.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]}),N&&E.jsxs("div",{id:"char-count",className:`mt-1 text-xs text-right ${O?"text-claudius-error":"text-claudius-text-muted"}`,"aria-live":"polite",children:[D,"/",Vl]})]})}const Tc=["blog","page","external"],Lc={blog:"Blog",page:"Page",external:"External"};function Pc(d){try{return new URL(d).hostname}catch{return d}}const Mc=F.memo(function({sources:m,onClose:a}){const S=Tc.map(_=>({type:_,label:Lc[_],items:m.filter(T=>T.type===_)})).filter(_=>_.items.length>0),w=m.length===1?"1 source found":`${m.length} sources found`;return E.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:[E.jsxs("div",{className:"flex items-center justify-between border-b border-claudius-border px-4 py-3",children:[E.jsxs("div",{children:[E.jsx("h3",{className:"text-sm font-heading font-semibold text-claudius-text",children:"Sources"}),E.jsx("p",{className:"text-xs text-claudius-text-muted",children:w})]}),E.jsx("button",{onClick:a,"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:E.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:[E.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),E.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),E.jsx("div",{className:"flex-1 overflow-y-auto px-3 py-3 space-y-4",children:S.map(_=>E.jsxs("div",{children:[E.jsx("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-claudius-text-muted",children:_.label}),E.jsx("div",{className:"space-y-2",children:_.items.map(T=>{const D=Yi(T.url);return D?E.jsxs("a",{href:D,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:[E.jsx("p",{className:"truncate text-sm font-medium text-claudius-text",children:T.title}),E.jsx("p",{className:"mt-0.5 text-xs text-claudius-text-muted",children:Pc(D)})]},D):null})})]},_.type))})]})});function jc(d,m,a){const[S,w]=F.useState(0),_=F.useRef(0),T=F.useRef(0),D=F.useRef(0),N=F.useRef(!1);return F.useEffect(()=>{const O=d.current;if(!a||!O)return;const Q=J=>{if(O.scrollTop>0){N.current=!1;return}N.current=!0,T.current=J.touches[0].clientY,D.current=Date.now()},Y=J=>{if(!N.current)return;let G=J.touches[0].clientY-T.current;G<0&&(G=G*.3),_.current=G,w(G)},B=()=>{if(!N.current)return;N.current=!1;const J=_.current,G=(Date.now()-D.current)/1e3,$=O.getBoundingClientRect().height,W=G>.05&&J>0&&J/G>500,oe=J>$*.3;W||oe?m():(_.current=0,w(0))};return O.addEventListener("touchstart",Q,{passive:!0}),O.addEventListener("touchmove",Y,{passive:!0}),O.addEventListener("touchend",B),()=>{O.removeEventListener("touchstart",Q),O.removeEventListener("touchmove",Y),O.removeEventListener("touchend",B)}},[d,m,a]),{offsetY:S}}const zc='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function Oc(d,m){F.useEffect(()=>{const a=d.current;if(!a)return;const S=w=>{if(w.key!=="Tab")return;const _=Array.from(a.querySelectorAll(zc)).filter(O=>!O.hasAttribute("aria-hidden"));if(_.length===0)return;const T=_[0],D=_[_.length-1],N=document.activeElement;w.shiftKey&&N===T?(w.preventDefault(),D.focus()):!w.shiftKey&&N===D&&(w.preventDefault(),T.focus())};return a.addEventListener("keydown",S),()=>a.removeEventListener("keydown",S)},[d,m])}const Dc=/\*\*([^*]+)\*\*/g,Ic=/\*([^*]+)\*/g,Fc=/https?:\/\/[^\s)]+/g;function Ac(d){return d.replace(Dc,"$1").replace(Ic,"$1").replace(Fc,m=>{try{return new URL(m).hostname}catch{return m}})}function Uc({label:d}){return E.jsx("div",{role:"status","aria-live":"polite","aria-label":d,className:"mr-auto flex max-w-[85%]",children:E.jsxs("div",{className:"flex gap-1 rounded-claudius-bubble rounded-bl-claudius-tail bg-claudius-assistant-bubble px-4 py-3",children:[E.jsx("span",{className:"h-2 w-2 motion-safe:animate-bounce rounded-claudius-full bg-claudius-text-muted [animation-delay:0ms]"}),E.jsx("span",{className:"h-2 w-2 motion-safe:animate-bounce rounded-claudius-full bg-claudius-text-muted [animation-delay:150ms]"}),E.jsx("span",{className:"h-2 w-2 motion-safe:animate-bounce rounded-claudius-full bg-claudius-text-muted [animation-delay:300ms]"})]})})}const Hc={"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 Bc({messages:d,isLoading:m,error:a,canRetry:S=!1,onSend:w,onRetry:_,onClose:T,title:D="Chat",subtitle:N="Ask me anything",welcomeMessage:O="Hi! How can I help you today?",placeholder:Q,position:Y="bottom-right",translations:B,isMobile:J=!1}){const G=F.useId(),$=F.useRef(null),W=F.useRef(null),[oe,me]=F.useState(null);Oc($,!0);const{offsetY:Ce}=jc(W,T,J),de=Ce!==0,Re=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)").matches:!1;F.useEffect(()=>{const le=W.current;le&&(le.scrollTop=le.scrollHeight)},[d,m]),F.useEffect(()=>{const le=Fe=>{Fe.key==="Escape"&&!Fe.isComposing&&T()};return document.addEventListener("keydown",le),()=>document.removeEventListener("keydown",le)},[T]);const se=(B==null?void 0:B.closeChat)??"Close chat",ye=(B==null?void 0:B.chatMessages)??"Chat messages",Le=[...d].reverse().find(le=>le.role==="assistant");return E.jsxs("div",{ref:$,role:"dialog","aria-modal":J?"true":void 0,"aria-labelledby":G,className:J?"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 ${Hc[Y]} 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:J&&!Re?{transform:`translateY(${Math.max(0,Ce)}px)`}:void 0,"data-dragging":de||void 0,children:[J&&E.jsx("div",{className:"flex justify-center py-2","aria-hidden":"true",children:E.jsx("div",{className:"h-1 w-8 rounded-claudius-full bg-claudius-border"})}),E.jsxs("div",{className:"flex items-center gap-3 bg-claudius-accent px-5 py-4",children:[E.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:D.charAt(0).toUpperCase()}),E.jsxs("div",{className:"flex-1",children:[E.jsx("h2",{id:G,className:"text-sm font-heading font-semibold text-claudius-accent-text",children:D}),E.jsx("p",{className:"text-xs text-claudius-accent-text",children:N})]}),E.jsx("button",{onClick:T,"aria-label":se,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:E.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:[E.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),E.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),E.jsxs("div",{className:"relative flex-1 overflow-hidden",children:[oe&&E.jsx(Mc,{sources:oe.sources,onClose:()=>me(null)}),E.jsxs("div",{ref:W,role:"log","aria-label":ye,className:"h-full space-y-3 overflow-y-auto px-4 py-4",children:[d.length===0&&!a&&E.jsx("div",{className:"mr-auto flex max-w-[85%]",children:E.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:O})}),d.map(le=>E.jsx(_c,{role:le.role,content:le.content,sources:le.sources,isSourceActive:(oe==null?void 0:oe.messageId)===le.id,onSourceClick:()=>{(oe==null?void 0:oe.messageId)===le.id?me(null):le.sources&&le.sources.length>0&&me({messageId:le.id,sources:le.sources})}},le.id)),m&&E.jsx(Uc,{label:(B==null?void 0:B.typingIndicator)??"Assistant is typing"}),a&&E.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:[E.jsx("span",{children:a}),S&&_&&!m&&E.jsx("button",{type:"button",onClick:_,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:(B==null?void 0:B.errorRetry)??"Retry"})]})]})]}),E.jsx("div",{"data-claudius-live":"assistant","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:Le?Ac(Le.content):""}),E.jsx(Rc,{onSend:w,isLoading:m,placeholder:Q,translations:B})]})}function Vc({message:d,position:m,onOpen:a,onDismiss:S,dismissLabel:w}){const _=m.startsWith("bottom"),T=m.endsWith("right"),D=["claudius-greeting-bubble","fixed z-40 max-w-xs",_?"bottom-20":"top-20",T?"right-4":"left-4"].join(" ");return E.jsxs("div",{className:D,role:"status","aria-live":"polite",children:[E.jsx("button",{type:"button",onClick:a,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:d}),E.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),S()},"aria-label":w,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:E.jsx("span",{"aria-hidden":"true",children:"×"})})]})}const Ji={en:{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",typeYourMessage:"Type your message",openChat:"Open chat",dismissGreeting:"Dismiss greeting",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.",errorRetry:"Retry"},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",typeYourMessage:"Escribe tu mensaje",openChat:"Abrir chat",dismissGreeting:"Descartar saludo",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.",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",typeYourMessage:"Saisissez votre message",openChat:"Ouvrir le chat",dismissGreeting:"Ignorer le message d'accueil",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.",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",typeYourMessage:"Geben Sie Ihre Nachricht ein",openChat:"Chat öffnen",dismissGreeting:"Begrüßung schließen",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.",errorRetry:"Erneut versuchen"}};function qi(d){if(!d)return;const m=d.toLowerCase().split("-")[0];return Object.prototype.hasOwnProperty.call(Ji,m)?m:void 0}function Wc(){const d=typeof document<"u"?qi(document.documentElement.lang):void 0;if(d)return d;const m=typeof navigator<"u"?qi(navigator.language):void 0;return m||"en"}function $c(d={}){const{locale:m,translations:a}=d,S=Ji[m??Wc()];return a?{...S,...a}:{...S}}const bi=["accent","accentText","accentSoft","accentTextMuted","surface","surfaceMuted","text","textMuted","border","userBubble","userBubbleText","assistantBubble","assistantBubbleText","field","error","errorSurface","errorText","link","scrim"],Qc=["sm","md","lg","full","tail"],Kc=["elevated","floating","floatingHover"],Yc=["heading","body"],eo={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 Gc(d){return Object.prototype.hasOwnProperty.call(eo,d)}const Xc=new Set(["light","dark","auto"]);function Zc(d){if(d===void 0)return{mode:"light"};if(typeof d=="string"){if(Xc.has(d))return{mode:d};if(Gc(d)){const m=eo[d];return{mode:m.colorScheme??"light",theme:m}}return{mode:"light",url:d}}return{mode:d.colorScheme??"light",theme:d}}function Jc(d){return d.replace(/[A-Z]/g,m=>`-${m.toLowerCase()}`)}function qc(d,m){console.warn(`[Claudius] Ignoring unknown theme token "${m}" in "${d}"`)}function Un(d,m,a,S,w,_=""){if(w)for(const[T,D]of Object.entries(w)){if(!S.includes(T)){qc(m,T);continue}typeof D=="string"&&(d[`${a}${Jc(T)}${_}`]=D)}}function bc(d){const m={};Un(m,"colors","--cl-color-",bi,d.colors);for(const[a,S]of Object.entries({...m}))m[`${a}-dark`]=S;return Un(m,"colorsDark","--cl-color-",bi,d.colorsDark,"-dark"),Un(m,"radii","--cl-radius-",Qc,d.radii),Un(m,"shadows","--cl-shadow-",Kc,d.shadows),Un(m,"fonts","--cl-font-",Yc,d.fonts),m}function ef(d){return typeof d=="object"&&d!==null&&!Array.isArray(d)}function tf(d){const m=F.useMemo(()=>Zc(d),[d]),[a,S]=F.useState(null),w=m.url;F.useEffect(()=>{if(S(null),!w)return;const N=new AbortController;return fetch(w,{signal:N.signal}).then(O=>{if(!O.ok)throw new Error(`HTTP ${O.status}`);return O.json()}).then(O=>{if(!ef(O))throw new Error("theme JSON must be an object");S(O)}).catch(O=>{N.signal.aborted||console.error(`[Claudius] Failed to load theme from ${w}:`,O)}),()=>N.abort()},[w]);const _=m.theme??a??null,T=(a==null?void 0:a.colorScheme)??m.mode,D=F.useMemo(()=>_?bc(_):{},[_]);return{mode:T,cssVars:D}}const to="claudius:triggers:dismissed";function nf(){if(typeof window>"u")return!1;try{return window.sessionStorage.getItem(to)==="1"}catch{return!1}}function rf(){if(!(typeof window>"u"))try{window.sessionStorage.setItem(to,"1")}catch{}}function no({apiUrl:d,title:m,subtitle:a,welcomeMessage:S,placeholder:w,persistMessages:_,storageKeyPrefix:T,requestTimeoutMs:D,theme:N="light",accentColor:O,position:Q="bottom-right",locale:Y,translations:B,triggers:J}){const[G,$]=F.useState(!1),[W,oe]=F.useState(null),[me,Ce]=F.useState(nf),de=F.useRef(!1),Re=mc("(max-width: 639px)"),se=F.useMemo(()=>$c({locale:Y,translations:B}),[Y,B]),{messages:ye,isLoading:Le,error:le,canRetry:Fe,sendMessage:te,retry:ne}=hc({apiUrl:d,persistMessages:_,storageKeyPrefix:T,timeoutMs:D,translations:se}),ke=F.useRef(null),we=F.useRef(G),{mode:$e,cssVars:Ae}=tf(N),[ve,R]=F.useState(!1);F.useEffect(()=>{if($e!=="auto")return;const q=window.matchMedia("(prefers-color-scheme: dark)");R(q.matches);const Ue=pn=>R(pn.matches);return q.addEventListener("change",Ue),()=>q.removeEventListener("change",Ue)},[$e]),F.useEffect(()=>{var q;we.current&&!G&&((q=ke.current)==null||q.focus()),we.current=G},[G]);const A=F.useCallback(()=>{Ce(!0),rf()},[]),P=F.useCallback(()=>{$(!1),de.current&&(de.current=!1,A())},[A]),f=F.useCallback(()=>{$(q=>!q)},[]),g=F.useCallback(()=>{de.current=!0,oe(null),$(!0)},[]),K=F.useCallback(q=>{oe(q)},[]),X=F.useCallback(()=>{oe(null),g()},[g]),b=F.useCallback(()=>{oe(null),A()},[A]);gc({triggers:J,enabled:!me&&!G,onOpen:g,onGreeting:K});const ee=$e==="dark"||$e==="auto"&&ve,ae={...Ae,...O?{"--cl-color-accent":O,"--cl-color-accent-dark":O}:{}},ie=Object.keys(ae).length>0?ae:void 0;return E.jsx("div",{className:"claudius-root",style:ie,children:E.jsxs("div",{"data-claudius-dark":ee?"true":"false",children:[G&&Re&&E.jsx("div",{className:"claudius-scrim fixed inset-0 z-40 bg-claudius-scrim",onClick:P,"aria-hidden":"true"}),G&&E.jsx(Bc,{messages:ye,isLoading:Le,error:le,canRetry:Fe,onSend:te,onRetry:ne,onClose:P,title:m??se.title,subtitle:a??se.subtitle,welcomeMessage:S??se.welcomeMessage,placeholder:w??se.placeholder,position:Q,translations:se,isMobile:Re}),!(G&&Re)&&E.jsx(wc,{ref:ke,isOpen:G,onClick:f,position:Q,translations:se}),!G&&W&&E.jsx(Vc,{message:W,position:Q,onOpen:X,onDismiss:b,dismissLabel:se.dismissGreeting})]})})}const lf="1.5.0";typeof window<"u"&&(window.ClaudiusWidgetVersion=lf);function ro(){const d=window.ClaudiusConfig;if(!(d!=null&&d.apiUrl)){console.error("[Claudius] Missing ClaudiusConfig.apiUrl");return}const m=document.createElement("div");m.id="claudius-chat-widget",document.body.appendChild(m),Qi.createRoot(m).render(E.jsx(no,{apiUrl:d.apiUrl,title:d.title,subtitle:d.subtitle,welcomeMessage:d.welcomeMessage,placeholder:d.placeholder,persistMessages:d.persistMessages,storageKeyPrefix:d.storageKeyPrefix,requestTimeoutMs:d.requestTimeoutMs,theme:d.theme,accentColor:d.accentColor,position:d.position,locale:d.locale,translations:d.translations,triggers:d.triggers}))}class lo extends HTMLElement{constructor(){super(...arguments);Jt(this,"root",null);Jt(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"]}connectedCallback(){this.container=document.createElement("div"),this.appendChild(this.container),this.root=Qi.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 a=this.getAttribute("api-url");if(!a){console.error("[Claudius] Missing api-url attribute on ");return}const S=this.getAttribute("persist-messages"),w=S===null?void 0:S!=="false",_=this.getAttribute("request-timeout-ms"),T=_===null?void 0:Number(_);this.root.render(E.jsx(no,{apiUrl:a,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:w,storageKeyPrefix:this.getAttribute("storage-key-prefix")??void 0,requestTimeoutMs:T!==void 0&&Number.isFinite(T)?T:void 0,theme:this.getAttribute("theme")??void 0,accentColor:this.getAttribute("accent-color")??void 0,position:this.getAttribute("position")??void 0}))}}return typeof customElements<"u"&&!customElements.get("claudius-chat")&&customElements.define("claudius-chat",lo),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",ro):ro(),Et.ClaudiusChat=lo,Object.defineProperty(Et,Symbol.toStringTag,{value:"Module"}),Et})({}); +`);return m.map((a,S)=>E.jsxs("span",{children:[Ec(a,`l${S}`),S0&&w&&E.jsx("div",{className:"mt-1",children:E.jsx(xc,{count:S.length,isActive:_??!1,onClick:w})})]})}),Vl=2e3,Nc=1800;function Rc({onSend:d,isLoading:m,placeholder:a,translations:S}){const[w,_]=F.useState(""),T=F.useRef(null),D=w.length,N=D>=Nc,O=D>=Vl,Q=a??(S==null?void 0:S.placeholder)??"Type your message...",Y=(S==null?void 0:S.sendMessage)??"Send message",B=(S==null?void 0:S.typeYourMessage)??"Type your message";F.useEffect(()=>{var $;m||($=T.current)==null||$.focus()},[m]);const J=$=>{$.preventDefault();const W=w.trim();!W||O||(d(W),_(""))},G=$=>{const W=$.target.value;W.length<=Vl&&_(W)};return E.jsxs("form",{onSubmit:J,className:"border-t border-claudius-border bg-claudius-surface p-3",children:[E.jsxs("div",{className:"flex gap-2",children:[E.jsx("input",{ref:T,type:"text",value:w,onChange:G,placeholder:Q,disabled:m,"aria-label":B,"aria-describedby":N?"char-count":void 0,className:"flex-1 rounded-claudius-sm border border-claudius-border bg-claudius-field px-3 py-2 text-sm font-body text-claudius-text placeholder:text-claudius-text-muted focus:border-claudius-accent focus:outline-none focus:ring-1 focus:ring-claudius-accent disabled:opacity-50"}),E.jsx("button",{type:"submit",disabled:m||O,"aria-label":Y,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:E.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:[E.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),E.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]}),N&&E.jsxs("div",{id:"char-count",className:`mt-1 text-xs text-right ${O?"text-claudius-error":"text-claudius-text-muted"}`,"aria-live":"polite",children:[D,"/",Vl]})]})}const Tc=["blog","page","external"],Lc={blog:"Blog",page:"Page",external:"External"};function Pc(d){try{return new URL(d).hostname}catch{return d}}const Mc=F.memo(function({sources:m,onClose:a}){const S=Tc.map(_=>({type:_,label:Lc[_],items:m.filter(T=>T.type===_)})).filter(_=>_.items.length>0),w=m.length===1?"1 source found":`${m.length} sources found`;return E.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:[E.jsxs("div",{className:"flex items-center justify-between border-b border-claudius-border px-4 py-3",children:[E.jsxs("div",{children:[E.jsx("h3",{className:"text-sm font-heading font-semibold text-claudius-text",children:"Sources"}),E.jsx("p",{className:"text-xs text-claudius-text-muted",children:w})]}),E.jsx("button",{onClick:a,"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:E.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:[E.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),E.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),E.jsx("div",{className:"flex-1 overflow-y-auto px-3 py-3 space-y-4",children:S.map(_=>E.jsxs("div",{children:[E.jsx("h4",{className:"mb-2 text-xs font-semibold uppercase tracking-wide text-claudius-text-muted",children:_.label}),E.jsx("div",{className:"space-y-2",children:_.items.map(T=>{const D=Yi(T.url);return D?E.jsxs("a",{href:D,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:[E.jsx("p",{className:"truncate text-sm font-medium text-claudius-text",children:T.title}),E.jsx("p",{className:"mt-0.5 text-xs text-claudius-text-muted",children:Pc(D)})]},D):null})})]},_.type))})]})});function jc(d,m,a){const[S,w]=F.useState(0),_=F.useRef(0),T=F.useRef(0),D=F.useRef(0),N=F.useRef(!1);return F.useEffect(()=>{const O=d.current;if(!a||!O)return;const Q=J=>{if(O.scrollTop>0){N.current=!1;return}N.current=!0,T.current=J.touches[0].clientY,D.current=Date.now()},Y=J=>{if(!N.current)return;let G=J.touches[0].clientY-T.current;G<0&&(G=G*.3),_.current=G,w(G)},B=()=>{if(!N.current)return;N.current=!1;const J=_.current,G=(Date.now()-D.current)/1e3,$=O.getBoundingClientRect().height,W=G>.05&&J>0&&J/G>500,oe=J>$*.3;W||oe?m():(_.current=0,w(0))};return O.addEventListener("touchstart",Q,{passive:!0}),O.addEventListener("touchmove",Y,{passive:!0}),O.addEventListener("touchend",B),()=>{O.removeEventListener("touchstart",Q),O.removeEventListener("touchmove",Y),O.removeEventListener("touchend",B)}},[d,m,a]),{offsetY:S}}const zc='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function Oc(d,m){F.useEffect(()=>{const a=d.current;if(!a)return;const S=w=>{if(w.key!=="Tab")return;const _=Array.from(a.querySelectorAll(zc)).filter(O=>!O.hasAttribute("aria-hidden"));if(_.length===0)return;const T=_[0],D=_[_.length-1],N=document.activeElement;w.shiftKey&&N===T?(w.preventDefault(),D.focus()):!w.shiftKey&&N===D&&(w.preventDefault(),T.focus())};return a.addEventListener("keydown",S),()=>a.removeEventListener("keydown",S)},[d,m])}const Dc=/\*\*([^*]+)\*\*/g,Ic=/\*([^*]+)\*/g,Fc=/https?:\/\/[^\s)]+/g;function Ac(d){return d.replace(Dc,"$1").replace(Ic,"$1").replace(Fc,m=>{try{return new URL(m).hostname}catch{return m}})}function Uc({label:d}){return E.jsx("div",{role:"status","aria-live":"polite","aria-label":d,className:"mr-auto flex max-w-[85%]",children:E.jsxs("div",{className:"flex gap-1 rounded-claudius-bubble rounded-bl-claudius-tail bg-claudius-assistant-bubble px-4 py-3",children:[E.jsx("span",{className:"h-2 w-2 motion-safe:animate-bounce rounded-claudius-full bg-claudius-text-muted [animation-delay:0ms]"}),E.jsx("span",{className:"h-2 w-2 motion-safe:animate-bounce rounded-claudius-full bg-claudius-text-muted [animation-delay:150ms]"}),E.jsx("span",{className:"h-2 w-2 motion-safe:animate-bounce rounded-claudius-full bg-claudius-text-muted [animation-delay:300ms]"})]})})}const Hc={"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 Bc({messages:d,isLoading:m,error:a,canRetry:S=!1,onSend:w,onRetry:_,onClose:T,title:D="Chat",subtitle:N="Ask me anything",welcomeMessage:O="Hi! How can I help you today?",placeholder:Q,position:Y="bottom-right",translations:B,isMobile:J=!1}){const G=F.useId(),$=F.useRef(null),W=F.useRef(null),[oe,me]=F.useState(null);Oc($,!0);const{offsetY:Ce}=jc(W,T,J),de=Ce!==0,Re=typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)").matches:!1;F.useEffect(()=>{const le=W.current;le&&(le.scrollTop=le.scrollHeight)},[d,m]),F.useEffect(()=>{const le=Fe=>{Fe.key==="Escape"&&!Fe.isComposing&&T()};return document.addEventListener("keydown",le),()=>document.removeEventListener("keydown",le)},[T]);const se=(B==null?void 0:B.closeChat)??"Close chat",ye=(B==null?void 0:B.chatMessages)??"Chat messages",Le=[...d].reverse().find(le=>le.role==="assistant");return E.jsxs("div",{ref:$,role:"dialog","aria-modal":J?"true":void 0,"aria-labelledby":G,className:J?"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 ${Hc[Y]} 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:J&&!Re?{transform:`translateY(${Math.max(0,Ce)}px)`}:void 0,"data-dragging":de||void 0,children:[J&&E.jsx("div",{className:"flex justify-center py-2","aria-hidden":"true",children:E.jsx("div",{className:"h-1 w-8 rounded-claudius-full bg-claudius-border"})}),E.jsxs("div",{className:"flex items-center gap-3 bg-claudius-accent px-5 py-4",children:[E.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:D.charAt(0).toUpperCase()}),E.jsxs("div",{className:"flex-1",children:[E.jsx("h2",{id:G,className:"text-sm font-heading font-semibold text-claudius-accent-text",children:D}),E.jsx("p",{className:"text-xs text-claudius-accent-text",children:N})]}),E.jsx("button",{onClick:T,"aria-label":se,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:E.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:[E.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),E.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),E.jsxs("div",{className:"relative flex-1 overflow-hidden",children:[oe&&E.jsx(Mc,{sources:oe.sources,onClose:()=>me(null)}),E.jsxs("div",{ref:W,role:"log","aria-label":ye,className:"h-full space-y-3 overflow-y-auto px-4 py-4",children:[d.length===0&&!a&&E.jsx("div",{className:"mr-auto flex max-w-[85%]",children:E.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:O})}),d.map(le=>E.jsx(_c,{role:le.role,content:le.content,sources:le.sources,isSourceActive:(oe==null?void 0:oe.messageId)===le.id,onSourceClick:()=>{(oe==null?void 0:oe.messageId)===le.id?me(null):le.sources&&le.sources.length>0&&me({messageId:le.id,sources:le.sources})}},le.id)),m&&E.jsx(Uc,{label:(B==null?void 0:B.typingIndicator)??"Assistant is typing"}),a&&E.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:[E.jsx("span",{children:a}),S&&_&&!m&&E.jsx("button",{type:"button",onClick:_,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:(B==null?void 0:B.errorRetry)??"Retry"})]})]})]}),E.jsx("div",{"data-claudius-live":"assistant","aria-live":"polite","aria-atomic":"true",className:"sr-only",children:Le?Ac(Le.content):""}),E.jsx(Rc,{onSend:w,isLoading:m,placeholder:Q,translations:B})]})}function Vc({message:d,position:m,onOpen:a,onDismiss:S,dismissLabel:w}){const _=m.startsWith("bottom"),T=m.endsWith("right"),D=["claudius-greeting-bubble","fixed z-40 max-w-xs",_?"bottom-20":"top-20",T?"right-4":"left-4"].join(" ");return E.jsxs("div",{className:D,role:"status","aria-live":"polite",children:[E.jsx("button",{type:"button",onClick:a,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:d}),E.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),S()},"aria-label":w,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:E.jsx("span",{"aria-hidden":"true",children:"×"})})]})}const Ji={en:{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",typeYourMessage:"Type your message",openChat:"Open chat",dismissGreeting:"Dismiss greeting",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.",errorRetry:"Retry"},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",typeYourMessage:"Escribe tu mensaje",openChat:"Abrir chat",dismissGreeting:"Descartar saludo",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.",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",typeYourMessage:"Saisissez votre message",openChat:"Ouvrir le chat",dismissGreeting:"Ignorer le message d'accueil",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.",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",typeYourMessage:"Geben Sie Ihre Nachricht ein",openChat:"Chat öffnen",dismissGreeting:"Begrüßung schließen",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.",errorRetry:"Erneut versuchen"}};function qi(d){if(!d)return;const m=d.toLowerCase().split("-")[0];return Object.prototype.hasOwnProperty.call(Ji,m)?m:void 0}function Wc(){const d=typeof document<"u"?qi(document.documentElement.lang):void 0;if(d)return d;const m=typeof navigator<"u"?qi(navigator.language):void 0;return m||"en"}function $c(d={}){const{locale:m,translations:a}=d,S=Ji[m??Wc()];return a?{...S,...a}:{...S}}const bi=["accent","accentText","accentSoft","accentTextMuted","surface","surfaceMuted","text","textMuted","border","userBubble","userBubbleText","assistantBubble","assistantBubbleText","field","error","errorSurface","errorText","link","scrim"],Qc=["sm","md","lg","full","tail"],Kc=["elevated","floating","floatingHover"],Yc=["heading","body"],eo={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 Gc(d){return Object.prototype.hasOwnProperty.call(eo,d)}const Xc=new Set(["light","dark","auto"]);function Zc(d){if(d===void 0)return{mode:"light"};if(typeof d=="string"){if(Xc.has(d))return{mode:d};if(Gc(d)){const m=eo[d];return{mode:m.colorScheme??"light",theme:m}}return{mode:"light",url:d}}return{mode:d.colorScheme??"light",theme:d}}function Jc(d){return d.replace(/[A-Z]/g,m=>`-${m.toLowerCase()}`)}function qc(d,m){console.warn(`[Claudius] Ignoring unknown theme token "${m}" in "${d}"`)}function Un(d,m,a,S,w,_=""){if(w)for(const[T,D]of Object.entries(w)){if(!S.includes(T)){qc(m,T);continue}typeof D=="string"&&(d[`${a}${Jc(T)}${_}`]=D)}}function bc(d){const m={};Un(m,"colors","--cl-color-",bi,d.colors);for(const[a,S]of Object.entries({...m}))m[`${a}-dark`]=S;return Un(m,"colorsDark","--cl-color-",bi,d.colorsDark,"-dark"),Un(m,"radii","--cl-radius-",Qc,d.radii),Un(m,"shadows","--cl-shadow-",Kc,d.shadows),Un(m,"fonts","--cl-font-",Yc,d.fonts),m}function ef(d){return typeof d=="object"&&d!==null&&!Array.isArray(d)}function tf(d){const m=F.useMemo(()=>Zc(d),[d]),[a,S]=F.useState(null),w=m.url;F.useEffect(()=>{if(S(null),!w)return;const N=new AbortController;return fetch(w,{signal:N.signal}).then(O=>{if(!O.ok)throw new Error(`HTTP ${O.status}`);return O.json()}).then(O=>{if(!ef(O))throw new Error("theme JSON must be an object");S(O)}).catch(O=>{N.signal.aborted||console.error(`[Claudius] Failed to load theme from ${w}:`,O)}),()=>N.abort()},[w]);const _=m.theme??a??null,T=(a==null?void 0:a.colorScheme)??m.mode,D=F.useMemo(()=>_?bc(_):{},[_]);return{mode:T,cssVars:D}}const to="claudius:triggers:dismissed";function nf(){if(typeof window>"u")return!1;try{return window.sessionStorage.getItem(to)==="1"}catch{return!1}}function rf(){if(!(typeof window>"u"))try{window.sessionStorage.setItem(to,"1")}catch{}}function no({apiUrl:d,title:m,subtitle:a,welcomeMessage:S,placeholder:w,persistMessages:_,storageKeyPrefix:T,requestTimeoutMs:D,theme:N="light",accentColor:O,position:Q="bottom-right",locale:Y,translations:B,triggers:J}){const[G,$]=F.useState(!1),[W,oe]=F.useState(null),[me,Ce]=F.useState(nf),de=F.useRef(!1),Re=mc("(max-width: 639px)"),se=F.useMemo(()=>$c({locale:Y,translations:B}),[Y,B]),{messages:ye,isLoading:Le,error:le,canRetry:Fe,sendMessage:te,retry:ne}=hc({apiUrl:d,persistMessages:_,storageKeyPrefix:T,timeoutMs:D,translations:se}),ke=F.useRef(null),we=F.useRef(G),{mode:$e,cssVars:Ae}=tf(N),[ve,R]=F.useState(!1);F.useEffect(()=>{if($e!=="auto")return;const q=window.matchMedia("(prefers-color-scheme: dark)");R(q.matches);const Ue=pn=>R(pn.matches);return q.addEventListener("change",Ue),()=>q.removeEventListener("change",Ue)},[$e]),F.useEffect(()=>{var q;we.current&&!G&&((q=ke.current)==null||q.focus()),we.current=G},[G]);const A=F.useCallback(()=>{Ce(!0),rf()},[]),P=F.useCallback(()=>{$(!1),de.current&&(de.current=!1,A())},[A]),f=F.useCallback(()=>{$(q=>!q)},[]),g=F.useCallback(()=>{de.current=!0,oe(null),$(!0)},[]),K=F.useCallback(q=>{oe(q)},[]),X=F.useCallback(()=>{oe(null),g()},[g]),b=F.useCallback(()=>{oe(null),A()},[A]);gc({triggers:J,enabled:!me&&!G,onOpen:g,onGreeting:K});const ee=$e==="dark"||$e==="auto"&&ve,ae={...Ae,...O?{"--cl-color-accent":O,"--cl-color-accent-dark":O}:{}},ie=Object.keys(ae).length>0?ae:void 0;return E.jsx("div",{className:"claudius-root",style:ie,children:E.jsxs("div",{"data-claudius-dark":ee?"true":"false",children:[G&&Re&&E.jsx("div",{className:"claudius-scrim fixed inset-0 z-40 bg-claudius-scrim",onClick:P,"aria-hidden":"true"}),G&&E.jsx(Bc,{messages:ye,isLoading:Le,error:le,canRetry:Fe,onSend:te,onRetry:ne,onClose:P,title:m??se.title,subtitle:a??se.subtitle,welcomeMessage:S??se.welcomeMessage,placeholder:w??se.placeholder,position:Q,translations:se,isMobile:Re}),!(G&&Re)&&E.jsx(wc,{ref:ke,isOpen:G,onClick:f,position:Q,translations:se}),!G&&W&&E.jsx(Vc,{message:W,position:Q,onOpen:X,onDismiss:b,dismissLabel:se.dismissGreeting})]})})}const lf="1.6.0";typeof window<"u"&&(window.ClaudiusWidgetVersion=lf);function ro(){const d=window.ClaudiusConfig;if(!(d!=null&&d.apiUrl)){console.error("[Claudius] Missing ClaudiusConfig.apiUrl");return}const m=document.createElement("div");m.id="claudius-chat-widget",document.body.appendChild(m),Qi.createRoot(m).render(E.jsx(no,{apiUrl:d.apiUrl,title:d.title,subtitle:d.subtitle,welcomeMessage:d.welcomeMessage,placeholder:d.placeholder,persistMessages:d.persistMessages,storageKeyPrefix:d.storageKeyPrefix,requestTimeoutMs:d.requestTimeoutMs,theme:d.theme,accentColor:d.accentColor,position:d.position,locale:d.locale,translations:d.translations,triggers:d.triggers}))}class lo extends HTMLElement{constructor(){super(...arguments);Jt(this,"root",null);Jt(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"]}connectedCallback(){this.container=document.createElement("div"),this.appendChild(this.container),this.root=Qi.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 a=this.getAttribute("api-url");if(!a){console.error("[Claudius] Missing api-url attribute on ");return}const S=this.getAttribute("persist-messages"),w=S===null?void 0:S!=="false",_=this.getAttribute("request-timeout-ms"),T=_===null?void 0:Number(_);this.root.render(E.jsx(no,{apiUrl:a,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:w,storageKeyPrefix:this.getAttribute("storage-key-prefix")??void 0,requestTimeoutMs:T!==void 0&&Number.isFinite(T)?T:void 0,theme:this.getAttribute("theme")??void 0,accentColor:this.getAttribute("accent-color")??void 0,position:this.getAttribute("position")??void 0}))}}return typeof customElements<"u"&&!customElements.get("claudius-chat")&&customElements.define("claudius-chat",lo),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",ro):ro(),Et.ClaudiusChat=lo,Object.defineProperty(Et,Symbol.toStringTag,{value:"Module"}),Et})({}); diff --git a/docs/package.json b/docs/package.json index 0549401..702371c 100644 --- a/docs/package.json +++ b/docs/package.json @@ -1,6 +1,6 @@ { "name": "claudius-docs", - "version": "1.5.0", + "version": "1.6.0", "private": true, "type": "module", "scripts": { diff --git a/package.json b/package.json index b60c07b..21e5c1d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "claudius", - "version": "1.5.0", + "version": "1.6.0", "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 c5bc5bf..86a8767 100644 --- a/widget/package.json +++ b/widget/package.json @@ -1,6 +1,6 @@ { "name": "claudius-chat-widget", - "version": "1.5.0", + "version": "1.6.0", "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 eb15d6e..8a4696d 100644 --- a/worker/package.json +++ b/worker/package.json @@ -1,6 +1,6 @@ { "name": "claudius-chat-worker", - "version": "1.5.0", + "version": "1.6.0", "private": true, "type": "module", "scripts": {