@factorialco/agent-chat 0.3.4 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -81,4 +81,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
81
81
  `))+1))}const i="#".repeat(a),l=n.enter("headingAtx"),s=n.enter("phrasing");o.move(i+" ");let u=n.containerPhrasing(e,{before:"# ",after:`
82
82
  `,...o.current()});return/^[\t ]/.test(u)&&(u=Ft(u.charCodeAt(0))+u.slice(1)),u=u?i+" "+u:i,n.options.closeAtx&&(u+=" "+i),s(),l(),u}iS.peek=xD;function iS(e){return e.value||""}function xD(){return"<"}lS.peek=CD;function lS(e,t,n,r){const a=qu(n),o=a==='"'?"Quote":"Apostrophe",i=n.enter("image");let l=n.enter("label");const s=n.createTracker(r);let u=s.move("![");return u+=s.move(n.safe(e.alt,{before:u,after:"]",...s.current()})),u+=s.move("]("),l(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(l=n.enter("destinationLiteral"),u+=s.move("<"),u+=s.move(n.safe(e.url,{before:u,after:">",...s.current()})),u+=s.move(">")):(l=n.enter("destinationRaw"),u+=s.move(n.safe(e.url,{before:u,after:e.title?" ":")",...s.current()}))),l(),e.title&&(l=n.enter(`title${o}`),u+=s.move(" "+a),u+=s.move(n.safe(e.title,{before:u,after:a,...s.current()})),u+=s.move(a),l()),u+=s.move(")"),i(),u}function CD(){return"!"}sS.peek=ID;function sS(e,t,n,r){const a=e.referenceType,o=n.enter("imageReference");let i=n.enter("label");const l=n.createTracker(r);let s=l.move("![");const u=n.safe(e.alt,{before:s,after:"]",...l.current()});s+=l.move(u+"]["),i();const c=n.stack;n.stack=[],i=n.enter("reference");const d=n.safe(n.associationId(e),{before:s,after:"]",...l.current()});return i(),n.stack=c,o(),a==="full"||!u||u!==d?s+=l.move(d+"]"):a==="shortcut"?s=s.slice(0,-1):s+=l.move("]"),s}function ID(){return"!"}uS.peek=ND;function uS(e,t,n){let r=e.value||"",a="`",o=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(r);)a+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++o<n.unsafe.length;){const i=n.unsafe[o],l=n.compilePattern(i);let s;if(i.atBreak)for(;s=l.exec(r);){let u=s.index;r.charCodeAt(u)===10&&r.charCodeAt(u-1)===13&&u--,r=r.slice(0,u)+" "+r.slice(s.index+1)}}return a+r+a}function ND(){return"`"}function cS(e,t){const n=cu(e);return!!(!t.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(n===e.url||"mailto:"+n===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}dS.peek=OD;function dS(e,t,n,r){const a=qu(n),o=a==='"'?"Quote":"Apostrophe",i=n.createTracker(r);let l,s;if(cS(e,n)){const c=n.stack;n.stack=[],l=n.enter("autolink");let d=i.move("<");return d+=i.move(n.containerPhrasing(e,{before:d,after:">",...i.current()})),d+=i.move(">"),l(),n.stack=c,d}l=n.enter("link"),s=n.enter("label");let u=i.move("[");return u+=i.move(n.containerPhrasing(e,{before:u,after:"](",...i.current()})),u+=i.move("]("),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter("destinationLiteral"),u+=i.move("<"),u+=i.move(n.safe(e.url,{before:u,after:">",...i.current()})),u+=i.move(">")):(s=n.enter("destinationRaw"),u+=i.move(n.safe(e.url,{before:u,after:e.title?" ":")",...i.current()}))),s(),e.title&&(s=n.enter(`title${o}`),u+=i.move(" "+a),u+=i.move(n.safe(e.title,{before:u,after:a,...i.current()})),u+=i.move(a),s()),u+=i.move(")"),l(),u}function OD(e,t,n){return cS(e,n)?"<":"["}pS.peek=LD;function pS(e,t,n,r){const a=e.referenceType,o=n.enter("linkReference");let i=n.enter("label");const l=n.createTracker(r);let s=l.move("[");const u=n.containerPhrasing(e,{before:s,after:"]",...l.current()});s+=l.move(u+"]["),i();const c=n.stack;n.stack=[],i=n.enter("reference");const d=n.safe(n.associationId(e),{before:s,after:"]",...l.current()});return i(),n.stack=c,o(),a==="full"||!u||u!==d?s+=l.move(d+"]"):a==="shortcut"?s=s.slice(0,-1):s+=l.move("]"),s}function LD(){return"["}function $u(e){const t=e.options.bullet||"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function DD(e){const t=$u(e),n=e.options.bulletOther;if(!n)return t==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw new Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function MD(e){const t=e.options.bulletOrdered||".";if(t!=="."&&t!==")")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function gS(e){const t=e.options.rule||"*";if(t!=="*"&&t!=="-"&&t!=="_")throw new Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function FD(e,t,n,r){const a=n.enter("list"),o=n.bulletCurrent;let i=e.ordered?MD(n):$u(n);const l=e.ordered?i==="."?")":".":DD(n);let s=t&&n.bulletLastUsed?i===n.bulletLastUsed:!1;if(!e.ordered){const c=e.children?e.children[0]:void 0;if((i==="*"||i==="-")&&c&&(!c.children||!c.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(s=!0),gS(n)===i&&c){let d=-1;for(;++d<e.children.length;){const f=e.children[d];if(f&&f.type==="listItem"&&f.children&&f.children[0]&&f.children[0].type==="thematicBreak"){s=!0;break}}}}s&&(i=l),n.bulletCurrent=i;const u=n.containerFlow(e,r);return n.bulletLastUsed=i,n.bulletCurrent=o,a(),u}function PD(e){const t=e.options.listItemIndent||"one";if(t!=="tab"&&t!=="one"&&t!=="mixed")throw new Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function BD(e,t,n,r){const a=PD(n);let o=n.bulletCurrent||$u(n);t&&t.type==="list"&&t.ordered&&(o=(typeof t.start=="number"&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+o);let i=o.length+1;(a==="tab"||a==="mixed"&&(t&&t.type==="list"&&t.spread||e.spread))&&(i=Math.ceil(i/4)*4);const l=n.createTracker(r);l.move(o+" ".repeat(i-o.length)),l.shift(i);const s=n.enter("listItem"),u=n.indentLines(n.containerFlow(e,l.current()),c);return s(),u;function c(d,f,p){return f?(p?"":" ".repeat(i))+d:(p?o:o+" ".repeat(i-o.length))+d}}function zD(e,t,n,r){const a=n.enter("paragraph"),o=n.enter("phrasing"),i=n.containerPhrasing(e,r);return o(),a(),i}const UD=un(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function HD(e,t,n,r){return(e.children.some(function(i){return UD(i)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function qD(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}fS.peek=$D;function fS(e,t,n,r){const a=qD(n),o=n.enter("strong"),i=n.createTracker(r),l=i.move(a+a);let s=i.move(n.containerPhrasing(e,{after:a,before:l,...i.current()}));const u=s.charCodeAt(0),c=nn(r.before.charCodeAt(r.before.length-1),u,a);c.inside&&(s=Ft(u)+s.slice(1));const d=s.charCodeAt(s.length-1),f=nn(r.after.charCodeAt(0),d,a);f.inside&&(s=s.slice(0,-1)+Ft(d));const p=i.move(a+a);return o(),n.attentionEncodeSurroundingInfo={after:f.outside,before:c.outside},l+s+p}function $D(e,t,n){return n.options.strong||"*"}function GD(e,t,n,r){return n.safe(e.value,r)}function jD(e){const t=e.options.ruleRepetition||3;if(t<3)throw new Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function WD(e,t,n){const r=(gS(n)+(n.options.ruleSpaces?" ":"")).repeat(jD(n));return n.options.ruleSpaces?r.slice(0,-1):r}const bS={blockquote:bD,break:yh,code:kD,definition:wD,emphasis:oS,hardBreak:yh,heading:_D,html:iS,image:lS,imageReference:sS,inlineCode:uS,link:dS,linkReference:pS,list:FD,listItem:BD,paragraph:zD,root:HD,strong:fS,text:GD,thematicBreak:WD};function VD(){return{enter:{table:YD,tableData:Sh,tableHeader:Sh,tableRow:XD},exit:{codeText:ZD,table:KD,tableData:Os,tableHeader:Os,tableRow:Os}}}function YD(e){const t=e._align;this.enter({type:"table",align:t.map(function(n){return n==="none"?null:n}),children:[]},e),this.data.inTable=!0}function KD(e){this.exit(e),this.data.inTable=void 0}function XD(e){this.enter({type:"tableRow",children:[]},e)}function Os(e){this.exit(e)}function Sh(e){this.enter({type:"tableCell",children:[]},e)}function ZD(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,QD));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function QD(e,t){return t==="|"?t:e}function JD(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,a=t.stringLength,o=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
83
83
  `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:f,table:i,tableCell:s,tableRow:l}};function i(p,b,m,A){return u(c(p,m,A),p.align)}function l(p,b,m,A){const k=d(p,m,A),v=u([k]);return v.slice(0,v.indexOf(`
84
- `))}function s(p,b,m,A){const k=m.enter("tableCell"),v=m.enter("phrasing"),y=m.containerPhrasing(p,{...A,before:o,after:o});return v(),k(),y}function u(p,b){return gD(p,{align:b,alignDelimiters:r,padding:n,stringLength:a})}function c(p,b,m){const A=p.children;let k=-1;const v=[],y=b.enter("table");for(;++k<A.length;)v[k]=d(A[k],b,m);return y(),v}function d(p,b,m){const A=p.children;let k=-1;const v=[],y=b.enter("tableRow");for(;++k<A.length;)v[k]=s(A[k],p,b,m);return y(),v}function f(p,b,m){let A=bS.inlineCode(p,b,m);return m.stack.includes("tableCell")&&(A=A.replace(/\|/g,"\\$&")),A}}function eM(){return{exit:{taskListCheckValueChecked:Eh,taskListCheckValueUnchecked:Eh,paragraph:nM}}}function tM(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:rM}}}function Eh(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function nM(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const a=t.children;let o=-1,i;for(;++o<a.length;){const l=a[o];if(l.type==="paragraph"){i=l;break}}i===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function rM(e,t,n,r){const a=e.children[0],o=typeof e.checked=="boolean"&&a&&a.type==="paragraph",i="["+(e.checked?"x":" ")+"] ",l=n.createTracker(r);o&&l.move(i);let s=bS.listItem(e,t,n,{...r,...l.current()});return o&&(s=s.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),s;function u(c){return c+i}}function aM(){return[FL(),rD(),lD(),VD(),eM()]}function oM(e){return{extensions:[PL(),aD(e),sD(),JD(e),tM()]}}const iM={tokenize:pM,partial:!0},mS={tokenize:gM,partial:!0},hS={tokenize:fM,partial:!0},yS={tokenize:bM,partial:!0},lM={tokenize:mM,partial:!0},SS={name:"wwwAutolink",tokenize:cM,previous:kS},ES={name:"protocolAutolink",tokenize:dM,previous:vS},qe={name:"emailAutolink",tokenize:uM,previous:wS},Be={};function sM(){return{text:Be}}let Je=48;for(;Je<123;)Be[Je]=qe,Je++,Je===58?Je=65:Je===91&&(Je=97);Be[43]=qe;Be[45]=qe;Be[46]=qe;Be[95]=qe;Be[72]=[qe,ES];Be[104]=[qe,ES];Be[87]=[qe,SS];Be[119]=[qe,SS];function uM(e,t,n){const r=this;let a,o;return i;function i(d){return!Qs(d)||!wS.call(r,r.previous)||Gu(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),l(d))}function l(d){return Qs(d)?(e.consume(d),l):d===64?(e.consume(d),s):n(d)}function s(d){return d===46?e.check(lM,c,u)(d):d===45||d===95||Se(d)?(o=!0,e.consume(d),s):c(d)}function u(d){return e.consume(d),a=!0,s}function c(d){return o&&a&&ve(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function cM(e,t,n){const r=this;return a;function a(i){return i!==87&&i!==119||!kS.call(r,r.previous)||Gu(r.events)?n(i):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(iM,e.attempt(mS,e.attempt(hS,o),n),n)(i))}function o(i){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(i)}}function dM(e,t,n){const r=this;let a="",o=!1;return i;function i(d){return(d===72||d===104)&&vS.call(r,r.previous)&&!Gu(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(d),e.consume(d),l):n(d)}function l(d){if(ve(d)&&a.length<5)return a+=String.fromCodePoint(d),e.consume(d),l;if(d===58){const f=a.toLowerCase();if(f==="http"||f==="https")return e.consume(d),s}return n(d)}function s(d){return d===47?(e.consume(d),o?u:(o=!0,s)):n(d)}function u(d){return d===null||Jt(d)||pe(d)||tt(d)||on(d)?n(d):e.attempt(mS,e.attempt(hS,c),n)(d)}function c(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function pM(e,t,n){let r=0;return a;function a(i){return(i===87||i===119)&&r<3?(r++,e.consume(i),a):i===46&&r===3?(e.consume(i),o):n(i)}function o(i){return i===null?n(i):t(i)}}function gM(e,t,n){let r,a,o;return i;function i(u){return u===46||u===95?e.check(yS,s,l)(u):u===null||pe(u)||tt(u)||u!==45&&on(u)?s(u):(o=!0,e.consume(u),i)}function l(u){return u===95?r=!0:(a=r,r=void 0),e.consume(u),i}function s(u){return a||r||!o?n(u):t(u)}}function fM(e,t){let n=0,r=0;return a;function a(i){return i===40?(n++,e.consume(i),a):i===41&&r<n?o(i):i===33||i===34||i===38||i===39||i===41||i===42||i===44||i===46||i===58||i===59||i===60||i===63||i===93||i===95||i===126?e.check(yS,t,o)(i):i===null||pe(i)||tt(i)?t(i):(e.consume(i),a)}function o(i){return i===41&&r++,e.consume(i),a}}function bM(e,t,n){return r;function r(l){return l===33||l===34||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===63||l===95||l===126?(e.consume(l),r):l===38?(e.consume(l),o):l===93?(e.consume(l),a):l===60||l===null||pe(l)||tt(l)?t(l):n(l)}function a(l){return l===null||l===40||l===91||pe(l)||tt(l)?t(l):r(l)}function o(l){return ve(l)?i(l):n(l)}function i(l){return l===59?(e.consume(l),r):ve(l)?(e.consume(l),i):n(l)}}function mM(e,t,n){return r;function r(o){return e.consume(o),a}function a(o){return Se(o)?n(o):t(o)}}function kS(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||pe(e)}function vS(e){return!ve(e)}function wS(e){return!(e===47||Qs(e))}function Qs(e){return e===43||e===45||e===46||e===95||Se(e)}function Gu(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const hM={tokenize:TM,partial:!0};function yM(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:vM,continuation:{tokenize:wM},exit:AM}},text:{91:{name:"gfmFootnoteCall",tokenize:kM},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:SM,resolveTo:EM}}}}function SM(e,t,n){const r=this;let a=r.events.length;const o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i;for(;a--;){const s=r.events[a][1];if(s.type==="labelImage"){i=s;break}if(s.type==="gfmFootnoteCall"||s.type==="labelLink"||s.type==="label"||s.type==="image"||s.type==="link")break}return l;function l(s){if(!i||!i._balanced)return n(s);const u=De(r.sliceSerialize({start:i.end,end:r.now()}));return u.codePointAt(0)!==94||!o.includes(u.slice(1))?n(s):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(s),e.exit("gfmFootnoteCallLabelMarker"),t(s))}}function EM(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},i={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},l=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",a,t],["exit",a,t],["enter",o,t],["enter",i,t],["exit",i,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...l),e}function kM(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o=0,i;return l;function l(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),s}function s(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(d){if(o>999||d===93&&!i||d===null||d===91||pe(d))return n(d);if(d===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return a.includes(De(r.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return pe(d)||(i=!0),o++,e.consume(d),d===92?c:u}function c(d){return d===91||d===92||d===93?(e.consume(d),o++,u):u(d)}}function vM(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o,i=0,l;return s;function s(b){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(b),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(b){return b===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(b),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",c):n(b)}function c(b){if(i>999||b===93&&!l||b===null||b===91||pe(b))return n(b);if(b===93){e.exit("chunkString");const m=e.exit("gfmFootnoteDefinitionLabelString");return o=De(r.sliceSerialize(m)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(b),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return pe(b)||(l=!0),i++,e.consume(b),b===92?d:c}function d(b){return b===91||b===92||b===93?(e.consume(b),i++,c):c(b)}function f(b){return b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),a.includes(o)||a.push(o),le(e,p,"gfmFootnoteDefinitionWhitespace")):n(b)}function p(b){return t(b)}}function wM(e,t,n){return e.check(Bt,t,e.attempt(hM,t,n))}function AM(e){e.exit("gfmFootnoteDefinition")}function TM(e,t,n){const r=this;return le(e,a,"gfmFootnoteDefinitionIndent",5);function a(o){const i=r.events[r.events.length-1];return i&&i[1].type==="gfmFootnoteDefinitionIndent"&&i[2].sliceSerialize(i[1],!0).length===4?t(o):n(o)}}function RM(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:o,resolveAll:a};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function a(i,l){let s=-1;for(;++s<i.length;)if(i[s][0]==="enter"&&i[s][1].type==="strikethroughSequenceTemporary"&&i[s][1]._close){let u=s;for(;u--;)if(i[u][0]==="exit"&&i[u][1].type==="strikethroughSequenceTemporary"&&i[u][1]._open&&i[s][1].end.offset-i[s][1].start.offset===i[u][1].end.offset-i[u][1].start.offset){i[s][1].type="strikethroughSequence",i[u][1].type="strikethroughSequence";const c={type:"strikethrough",start:Object.assign({},i[u][1].start),end:Object.assign({},i[s][1].end)},d={type:"strikethroughText",start:Object.assign({},i[u][1].end),end:Object.assign({},i[s][1].start)},f=[["enter",c,l],["enter",i[u][1],l],["exit",i[u][1],l],["enter",d,l]],p=l.parser.constructs.insideSpan.null;p&&Ce(f,f.length,0,ln(p,i.slice(u+1,s),l)),Ce(f,f.length,0,[["exit",d,l],["enter",i[s][1],l],["exit",i[s][1],l],["exit",c,l]]),Ce(i,u-1,s-u+3,f),s=u+f.length-2;break}}for(s=-1;++s<i.length;)i[s][1].type==="strikethroughSequenceTemporary"&&(i[s][1].type="data");return i}function o(i,l,s){const u=this.previous,c=this.events;let d=0;return f;function f(b){return u===126&&c[c.length-1][1].type!=="characterEscape"?s(b):(i.enter("strikethroughSequenceTemporary"),p(b))}function p(b){const m=ft(u);if(b===126)return d>1?s(b):(i.consume(b),d++,p);if(d<2&&!n)return s(b);const A=i.exit("strikethroughSequenceTemporary"),k=ft(b);return A._open=!k||k===2&&!!m,A._close=!m||m===2&&!!k,l(b)}}}class _M{constructor(){this.map=[]}add(t,n,r){xM(this,t,n,r)}consume(t){if(this.map.sort(function(o,i){return o[0]-i[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let a=r.pop();for(;a;){for(const o of a)t.push(o);a=r.pop()}this.map.length=0}}function xM(e,t,n,r){let a=0;if(!(n===0&&r.length===0)){for(;a<e.map.length;){if(e.map[a][0]===t){e.map[a][1]+=n,e.map[a][2].push(...r);return}a+=1}e.map.push([t,n,r])}}function CM(e,t){let n=!1;const r=[];for(;t<e.length;){const a=e[t];if(n){if(a[0]==="enter")a[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(a[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const o=r.length-1;r[o]=r[o]==="left"?"center":"right"}}else if(a[1].type==="tableDelimiterRow")break}else a[0]==="enter"&&a[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function IM(){return{flow:{null:{name:"table",tokenize:NM,resolveAll:OM}}}}function NM(e,t,n){const r=this;let a=0,o=0,i;return l;function l(R){let I=r.events.length-1;for(;I>-1;){const W=r.events[I][1].type;if(W==="lineEnding"||W==="linePrefix")I--;else break}const N=I>-1?r.events[I][1].type:null,Y=N==="tableHead"||N==="tableRow"?E:s;return Y===E&&r.parser.lazy[r.now().line]?n(R):Y(R)}function s(R){return e.enter("tableHead"),e.enter("tableRow"),u(R)}function u(R){return R===124||(i=!0,o+=1),c(R)}function c(R){return R===null?n(R):Q(R)?o>1?(o=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(R),e.exit("lineEnding"),p):n(R):oe(R)?le(e,c,"whitespace")(R):(o+=1,i&&(i=!1,a+=1),R===124?(e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),i=!0,c):(e.enter("data"),d(R)))}function d(R){return R===null||R===124||pe(R)?(e.exit("data"),c(R)):(e.consume(R),R===92?f:d)}function f(R){return R===92||R===124?(e.consume(R),d):d(R)}function p(R){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(R):(e.enter("tableDelimiterRow"),i=!1,oe(R)?le(e,b,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):b(R))}function b(R){return R===45||R===58?A(R):R===124?(i=!0,e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),m):w(R)}function m(R){return oe(R)?le(e,A,"whitespace")(R):A(R)}function A(R){return R===58?(o+=1,i=!0,e.enter("tableDelimiterMarker"),e.consume(R),e.exit("tableDelimiterMarker"),k):R===45?(o+=1,k(R)):R===null||Q(R)?T(R):w(R)}function k(R){return R===45?(e.enter("tableDelimiterFiller"),v(R)):w(R)}function v(R){return R===45?(e.consume(R),v):R===58?(i=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(R),e.exit("tableDelimiterMarker"),y):(e.exit("tableDelimiterFiller"),y(R))}function y(R){return oe(R)?le(e,T,"whitespace")(R):T(R)}function T(R){return R===124?b(R):R===null||Q(R)?!i||a!==o?w(R):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(R)):w(R)}function w(R){return n(R)}function E(R){return e.enter("tableRow"),C(R)}function C(R){return R===124?(e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),C):R===null||Q(R)?(e.exit("tableRow"),t(R)):oe(R)?le(e,C,"whitespace")(R):(e.enter("data"),D(R))}function D(R){return R===null||R===124||pe(R)?(e.exit("data"),C(R)):(e.consume(R),R===92?x:D)}function x(R){return R===92||R===124?(e.consume(R),D):D(R)}}function OM(e,t){let n=-1,r=!0,a=0,o=[0,0,0,0],i=[0,0,0,0],l=!1,s=0,u,c,d;const f=new _M;for(;++n<e.length;){const p=e[n],b=p[1];p[0]==="enter"?b.type==="tableHead"?(l=!1,s!==0&&(kh(f,t,s,u,c),c=void 0,s=0),u={type:"table",start:Object.assign({},b.start),end:Object.assign({},b.end)},f.add(n,0,[["enter",u,t]])):b.type==="tableRow"||b.type==="tableDelimiterRow"?(r=!0,d=void 0,o=[0,0,0,0],i=[0,n+1,0,0],l&&(l=!1,c={type:"tableBody",start:Object.assign({},b.start),end:Object.assign({},b.end)},f.add(n,0,[["enter",c,t]])),a=b.type==="tableDelimiterRow"?2:c?3:1):a&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")?(r=!1,i[2]===0&&(o[1]!==0&&(i[0]=i[1],d=Yt(f,t,o,a,void 0,d),o=[0,0,0,0]),i[2]=n)):b.type==="tableCellDivider"&&(r?r=!1:(o[1]!==0&&(i[0]=i[1],d=Yt(f,t,o,a,void 0,d)),o=i,i=[o[1],n,0,0])):b.type==="tableHead"?(l=!0,s=n):b.type==="tableRow"||b.type==="tableDelimiterRow"?(s=n,o[1]!==0?(i[0]=i[1],d=Yt(f,t,o,a,n,d)):i[1]!==0&&(d=Yt(f,t,i,a,n,d)),a=0):a&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")&&(i[3]=n)}for(s!==0&&kh(f,t,s,u,c),f.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=CM(t.events,n))}return e}function Yt(e,t,n,r,a,o){const i=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",l="tableContent";n[0]!==0&&(o.end=Object.assign({},ct(t.events,n[0])),e.add(n[0],0,[["exit",o,t]]));const s=ct(t.events,n[1]);if(o={type:i,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[["enter",o,t]]),n[2]!==0){const u=ct(t.events,n[2]),c=ct(t.events,n[3]),d={type:l,start:Object.assign({},u),end:Object.assign({},c)};if(e.add(n[2],0,[["enter",d,t]]),r!==2){const f=t.events[n[2]],p=t.events[n[3]];if(f[1].end=Object.assign({},p[1].end),f[1].type="chunkText",f[1].contentType="text",n[3]>n[2]+1){const b=n[2]+1,m=n[3]-n[2]-1;e.add(b,m,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return a!==void 0&&(o.end=Object.assign({},ct(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function kh(e,t,n,r,a){const o=[],i=ct(t.events,n);a&&(a.end=Object.assign({},i),o.push(["exit",a,t])),r.end=Object.assign({},i),o.push(["exit",r,t]),e.add(n+1,0,o)}function ct(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const LM={name:"tasklistCheck",tokenize:MM};function DM(){return{text:{91:LM}}}function MM(e,t,n){const r=this;return a;function a(s){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(s):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(s),e.exit("taskListCheckMarker"),o)}function o(s){return pe(s)?(e.enter("taskListCheckValueUnchecked"),e.consume(s),e.exit("taskListCheckValueUnchecked"),i):s===88||s===120?(e.enter("taskListCheckValueChecked"),e.consume(s),e.exit("taskListCheckValueChecked"),i):n(s)}function i(s){return s===93?(e.enter("taskListCheckMarker"),e.consume(s),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),l):n(s)}function l(s){return Q(s)?t(s):oe(s)?e.check({tokenize:FM},t,n)(s):n(s)}}function FM(e,t,n){return le(e,r,"whitespace");function r(a){return a===null?n(a):t(a)}}function PM(e){return Kh([sM(),yM(),RM(e),IM(),DM()])}const BM={};function zM(e){const t=this,n=e||BM,r=t.data(),a=r.micromarkExtensions||(r.micromarkExtensions=[]),o=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),i=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);a.push(PM(n)),o.push(aM()),i.push(oM(n))}function ju({children:e,className:t}){return j.jsx("div",{className:Fe("prose prose-sm max-w-none dark:prose-invert",t),children:j.jsx(sT,{remarkPlugins:[zM],components:{code:({_node:n,className:r,children:a,...o})=>{const i=/language-(\w+)/.exec(r||"");return!!i&&i?j.jsx(Qy,{style:Jy.oneDark,language:i[1],PreTag:"div",customStyle:{margin:0,borderRadius:"0.375rem",fontSize:"0.875rem",overflow:"auto",maxWidth:"100%"},wrapLongLines:!0,...o,children:String(a).replace(/\n$/,"")}):j.jsx("code",{className:Fe("relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",r),...o,children:a})},pre:({children:n})=>j.jsx("div",{className:"overflow-x-auto",children:n}),table:({children:n})=>j.jsx("div",{className:"overflow-x-auto",children:j.jsx("table",{className:"w-full border-collapse border border-border",children:n})}),th:({children:n})=>j.jsx("th",{className:"border border-border bg-muted px-4 py-2 text-left font-medium",children:n}),td:({children:n})=>j.jsx("td",{className:"border border-border px-4 py-2",children:n}),blockquote:({children:n})=>j.jsx("blockquote",{className:"border-l-4 border-primary pl-4 italic text-muted-foreground",children:n}),h1:({children:n})=>j.jsx("h1",{className:"mb-4 mt-6 text-2xl font-bold first:mt-0",children:n}),h2:({children:n})=>j.jsx("h2",{className:"mb-3 mt-5 text-xl font-semibold first:mt-0",children:n}),h3:({children:n})=>j.jsx("h3",{className:"mb-2 mt-4 text-lg font-semibold first:mt-0",children:n}),h4:({children:n})=>j.jsx("h4",{className:"mb-2 mt-3 text-base font-semibold first:mt-0",children:n}),h5:({children:n})=>j.jsx("h5",{className:"mb-1 mt-2 text-sm font-semibold first:mt-0",children:n}),h6:({children:n})=>j.jsx("h6",{className:"mb-1 mt-2 text-xs font-semibold first:mt-0",children:n}),p:({children:n})=>j.jsx("p",{className:"mb-3 leading-relaxed last:mb-0",children:n}),ul:({children:n})=>j.jsx("ul",{className:"mb-3 ml-4 list-disc space-y-1",children:n}),ol:({children:n})=>j.jsx("ol",{className:"mb-3 ml-4 list-decimal space-y-1",children:n}),li:({children:n})=>j.jsx("li",{className:"leading-relaxed",children:n}),a:({children:n,href:r})=>j.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:no-underline",children:n}),hr:()=>j.jsx("hr",{className:"my-6 border-border"}),strong:({children:n})=>j.jsx("strong",{className:"font-semibold",children:n}),em:({children:n})=>j.jsx("em",{className:"italic",children:n})},children:e})})}const AS=({content:e,agentName:t,onComplete:n,onChange:r})=>{const{displayText:a}=Dh({text:e,speed:5,startDelay:300,onComplete:n,onChange:r});return j.jsx("div",{className:"flex w-full gap-3 rounded-lg bg-muted p-4",children:j.jsxs("div",{className:"flex-1 w-inherit",children:[j.jsx("div",{className:"text-sm font-semibold",children:t}),j.jsx("div",{className:"mt-1 text-sm break-words",children:j.jsx(ju,{children:a})})]})})},TS=({message:e,agentName:t,handleTypingComplete:n,handleThumbsUp:r,handleThumbsDown:a})=>{const o=r&&a&&e.id!=="1"&&e.role==="assistant",i=e.role==="assistant"&&e.isTyping,l=e.role==="assistant",[s,u]=ae.useState(!1),[c,d]=ae.useState(!1);if(i)return j.jsx(AS,{content:e.content,agentName:t,onComplete:()=>n(e.id)},e.id);const f=()=>{r==null||r(e.id),u(!0)},p=()=>{a==null||a(e.id),d(!0)};return j.jsx("div",{className:Fe("flex w-full gap-3 rounded-lg p-4",l?"bg-muted":"ml-auto w-1/2 bg-primary text-primary-foreground"),children:j.jsxs("div",{className:Fe("flex flex-col flex-1 w-inherit gap-1",!l&&"text-left"),children:[j.jsx("div",{className:"text-sm font-semibold",children:l?t:"You"}),j.jsx("div",{className:Fe("text-sm break-words",!l&&"whitespace-pre-wrap"),children:l?j.jsx(ju,{children:e.content}):e.content}),o&&j.jsxs("div",{className:"flex gap-1",children:[j.jsx("button",{onClick:f,className:"p-1 rounded-md hover:bg-muted-foreground/10 transition-colors "+(s?"text-positive":"text-muted-foreground"),"aria-label":"Thumbs up",disabled:s||c,children:j.jsx(ZS,{size:16,className:"hover:text-foreground "})}),j.jsx("button",{onClick:p,className:"p-1 rounded-md hover:bg-muted-foreground/10 transition-colors "+(c?"text-critical":"text-muted-foreground"),"aria-label":"Thumbs down",disabled:c||s,children:j.jsx(XS,{size:16,className:" "})})]})]})},e.id)},UM=ae.forwardRef(({initialMessages:e=[],onSendMessage:t,agentName:n="Assistant",placeholder:r="Type your message...",className:a,onMessageSent:o,onMessageReceived:i,theme:l="auto",conversationId:s,isEventBased:u=!1,handleThumbsUp:c,handleThumbsDown:d},f)=>{const[p,b]=ae.useState(e),[m,A]=ae.useState(""),[k,v]=ae.useState(!1),y=ae.useRef(null),T=ae.useRef(null),w=ae.useRef(null),E=200;ae.useEffect(()=>{b(e)},[s]),ae.useImperativeHandle(f,()=>({addAssistantMessage:P=>{const B={id:Date.now().toString(),role:"assistant",content:P,timestamp:new Date,isTyping:!0};b(K=>[...K,B]),i==null||i(B),v(!1)}}),[]);const C=P=>{b(B=>B.map(K=>K.id===P?{...K,isTyping:!1}:K))},D=()=>{var P;(P=y.current)==null||P.scrollIntoView({behavior:"smooth"})};ae.useEffect(()=>{D()},[p]),ae.useEffect(()=>{var P;k||(P=T.current)==null||P.focus()},[k]),ae.useEffect(()=>{const P=T.current;if(!P)return;P.style.height="auto";const B=Math.min(P.scrollHeight,E);P.style.height=`${B}px`,P.style.overflowY=P.scrollHeight>E?"auto":"hidden"},[m]);const x=()=>({id:Date.now().toString(),role:"user",content:m.trim(),timestamp:new Date}),R=P=>{b(B=>[...B,P]),A(""),v(!0),o==null||o(P)},I=async P=>{if(!t){v(!1);return}try{const B=await t(P.content);if(B){const K={id:(Date.now()+1).toString(),role:"assistant",content:B,timestamp:new Date,isTyping:!0};b(g=>[...g,K]),i==null||i(K)}}catch(B){console.error("Error sending message:",B);const K={id:(Date.now()+1).toString(),role:"assistant",content:"Sorry, there was an error processing your message.",timestamp:new Date};b(g=>[...g,K])}finally{v(!1)}},N=async P=>{if(!t){v(!1);return}try{await t(P.content)}catch(B){console.error("Error sending message:",B)}},Y=async P=>{if(P==null||P.preventDefault(),!m.trim()||k)return;const B=x();R(B),u?N(B):I(B)},W=P=>{P.key==="Enter"&&!P.shiftKey&&(P.preventDefault(),Y())},$=()=>{switch(l){case"dark":return"bg-gray-900 text-white";case"light":return"bg-white text-gray-900";default:return"bg-white dark:bg-gray-900 text-gray-900 dark:text-white"}},X=p.some(P=>P.isTyping);return j.jsxs("div",{className:Fe("flex h-full flex-col rounded-lg bg-background pb-4",a,$()),children:[j.jsx("div",{className:"flex-1 px-4 overflow-y-auto min-h-0 pb-6 [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",ref:w,children:j.jsxs("div",{className:"space-y-4 pt-4",children:[p.map(P=>j.jsx(TS,{message:P,agentName:n,handleTypingComplete:C,handleThumbsUp:c,handleThumbsDown:d},P.id)),k&&!X&&j.jsx(Lh,{agentName:n,className:"bg-muted"}),j.jsx("div",{ref:y})]})}),j.jsx("div",{className:"p-4 bg-secondary rounded-xl flex-shrink-0",children:j.jsxs("form",{onSubmit:Y,className:"flex gap-2",children:[j.jsx("textarea",{ref:T,value:m,onChange:P=>A(P.target.value),onKeyDown:W,placeholder:r,disabled:k,className:"flex-1 bg-secondary px-3 py-2 text-sm focus:outline-none placeholder:text-muted-foreground resize-none",rows:1}),j.jsx(nu,{type:"submit",disabled:k,variant:"default",size:"icon",className:"rounded-full",children:j.jsx(KS,{})})]})})]})});exports.BreathingLoader=Lh;exports.Button=nu;exports.ChatInterface=UM;exports.Markdown=ju;exports.MessageComponent=TS;exports.TypewriterMessage=AS;exports.cn=Fe;exports.useTypewriter=Dh;
84
+ `))}function s(p,b,m,A){const k=m.enter("tableCell"),v=m.enter("phrasing"),y=m.containerPhrasing(p,{...A,before:o,after:o});return v(),k(),y}function u(p,b){return gD(p,{align:b,alignDelimiters:r,padding:n,stringLength:a})}function c(p,b,m){const A=p.children;let k=-1;const v=[],y=b.enter("table");for(;++k<A.length;)v[k]=d(A[k],b,m);return y(),v}function d(p,b,m){const A=p.children;let k=-1;const v=[],y=b.enter("tableRow");for(;++k<A.length;)v[k]=s(A[k],p,b,m);return y(),v}function f(p,b,m){let A=bS.inlineCode(p,b,m);return m.stack.includes("tableCell")&&(A=A.replace(/\|/g,"\\$&")),A}}function eM(){return{exit:{taskListCheckValueChecked:Eh,taskListCheckValueUnchecked:Eh,paragraph:nM}}}function tM(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:rM}}}function Eh(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function nM(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const a=t.children;let o=-1,i;for(;++o<a.length;){const l=a[o];if(l.type==="paragraph"){i=l;break}}i===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function rM(e,t,n,r){const a=e.children[0],o=typeof e.checked=="boolean"&&a&&a.type==="paragraph",i="["+(e.checked?"x":" ")+"] ",l=n.createTracker(r);o&&l.move(i);let s=bS.listItem(e,t,n,{...r,...l.current()});return o&&(s=s.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,u)),s;function u(c){return c+i}}function aM(){return[FL(),rD(),lD(),VD(),eM()]}function oM(e){return{extensions:[PL(),aD(e),sD(),JD(e),tM()]}}const iM={tokenize:pM,partial:!0},mS={tokenize:gM,partial:!0},hS={tokenize:fM,partial:!0},yS={tokenize:bM,partial:!0},lM={tokenize:mM,partial:!0},SS={name:"wwwAutolink",tokenize:cM,previous:kS},ES={name:"protocolAutolink",tokenize:dM,previous:vS},qe={name:"emailAutolink",tokenize:uM,previous:wS},Be={};function sM(){return{text:Be}}let Je=48;for(;Je<123;)Be[Je]=qe,Je++,Je===58?Je=65:Je===91&&(Je=97);Be[43]=qe;Be[45]=qe;Be[46]=qe;Be[95]=qe;Be[72]=[qe,ES];Be[104]=[qe,ES];Be[87]=[qe,SS];Be[119]=[qe,SS];function uM(e,t,n){const r=this;let a,o;return i;function i(d){return!Qs(d)||!wS.call(r,r.previous)||Gu(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),l(d))}function l(d){return Qs(d)?(e.consume(d),l):d===64?(e.consume(d),s):n(d)}function s(d){return d===46?e.check(lM,c,u)(d):d===45||d===95||Se(d)?(o=!0,e.consume(d),s):c(d)}function u(d){return e.consume(d),a=!0,s}function c(d){return o&&a&&ve(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function cM(e,t,n){const r=this;return a;function a(i){return i!==87&&i!==119||!kS.call(r,r.previous)||Gu(r.events)?n(i):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(iM,e.attempt(mS,e.attempt(hS,o),n),n)(i))}function o(i){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(i)}}function dM(e,t,n){const r=this;let a="",o=!1;return i;function i(d){return(d===72||d===104)&&vS.call(r,r.previous)&&!Gu(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(d),e.consume(d),l):n(d)}function l(d){if(ve(d)&&a.length<5)return a+=String.fromCodePoint(d),e.consume(d),l;if(d===58){const f=a.toLowerCase();if(f==="http"||f==="https")return e.consume(d),s}return n(d)}function s(d){return d===47?(e.consume(d),o?u:(o=!0,s)):n(d)}function u(d){return d===null||Jt(d)||pe(d)||tt(d)||on(d)?n(d):e.attempt(mS,e.attempt(hS,c),n)(d)}function c(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function pM(e,t,n){let r=0;return a;function a(i){return(i===87||i===119)&&r<3?(r++,e.consume(i),a):i===46&&r===3?(e.consume(i),o):n(i)}function o(i){return i===null?n(i):t(i)}}function gM(e,t,n){let r,a,o;return i;function i(u){return u===46||u===95?e.check(yS,s,l)(u):u===null||pe(u)||tt(u)||u!==45&&on(u)?s(u):(o=!0,e.consume(u),i)}function l(u){return u===95?r=!0:(a=r,r=void 0),e.consume(u),i}function s(u){return a||r||!o?n(u):t(u)}}function fM(e,t){let n=0,r=0;return a;function a(i){return i===40?(n++,e.consume(i),a):i===41&&r<n?o(i):i===33||i===34||i===38||i===39||i===41||i===42||i===44||i===46||i===58||i===59||i===60||i===63||i===93||i===95||i===126?e.check(yS,t,o)(i):i===null||pe(i)||tt(i)?t(i):(e.consume(i),a)}function o(i){return i===41&&r++,e.consume(i),a}}function bM(e,t,n){return r;function r(l){return l===33||l===34||l===39||l===41||l===42||l===44||l===46||l===58||l===59||l===63||l===95||l===126?(e.consume(l),r):l===38?(e.consume(l),o):l===93?(e.consume(l),a):l===60||l===null||pe(l)||tt(l)?t(l):n(l)}function a(l){return l===null||l===40||l===91||pe(l)||tt(l)?t(l):r(l)}function o(l){return ve(l)?i(l):n(l)}function i(l){return l===59?(e.consume(l),r):ve(l)?(e.consume(l),i):n(l)}}function mM(e,t,n){return r;function r(o){return e.consume(o),a}function a(o){return Se(o)?n(o):t(o)}}function kS(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||pe(e)}function vS(e){return!ve(e)}function wS(e){return!(e===47||Qs(e))}function Qs(e){return e===43||e===45||e===46||e===95||Se(e)}function Gu(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const hM={tokenize:TM,partial:!0};function yM(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:vM,continuation:{tokenize:wM},exit:AM}},text:{91:{name:"gfmFootnoteCall",tokenize:kM},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:SM,resolveTo:EM}}}}function SM(e,t,n){const r=this;let a=r.events.length;const o=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let i;for(;a--;){const s=r.events[a][1];if(s.type==="labelImage"){i=s;break}if(s.type==="gfmFootnoteCall"||s.type==="labelLink"||s.type==="label"||s.type==="image"||s.type==="link")break}return l;function l(s){if(!i||!i._balanced)return n(s);const u=De(r.sliceSerialize({start:i.end,end:r.now()}));return u.codePointAt(0)!==94||!o.includes(u.slice(1))?n(s):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(s),e.exit("gfmFootnoteCallLabelMarker"),t(s))}}function EM(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},a.end),end:Object.assign({},e[e.length-1][1].start)},i={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},l=[e[n+1],e[n+2],["enter",r,t],e[n+3],e[n+4],["enter",a,t],["exit",a,t],["enter",o,t],["enter",i,t],["exit",i,t],["exit",o,t],e[e.length-2],e[e.length-1],["exit",r,t]];return e.splice(n,e.length-n+1,...l),e}function kM(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o=0,i;return l;function l(d){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),s}function s(d){return d!==94?n(d):(e.enter("gfmFootnoteCallMarker"),e.consume(d),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",u)}function u(d){if(o>999||d===93&&!i||d===null||d===91||pe(d))return n(d);if(d===93){e.exit("chunkString");const f=e.exit("gfmFootnoteCallString");return a.includes(De(r.sliceSerialize(f)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(d)}return pe(d)||(i=!0),o++,e.consume(d),d===92?c:u}function c(d){return d===91||d===92||d===93?(e.consume(d),o++,u):u(d)}}function vM(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o,i=0,l;return s;function s(b){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(b),e.exit("gfmFootnoteDefinitionLabelMarker"),u}function u(b){return b===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(b),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",c):n(b)}function c(b){if(i>999||b===93&&!l||b===null||b===91||pe(b))return n(b);if(b===93){e.exit("chunkString");const m=e.exit("gfmFootnoteDefinitionLabelString");return o=De(r.sliceSerialize(m)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(b),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),f}return pe(b)||(l=!0),i++,e.consume(b),b===92?d:c}function d(b){return b===91||b===92||b===93?(e.consume(b),i++,c):c(b)}function f(b){return b===58?(e.enter("definitionMarker"),e.consume(b),e.exit("definitionMarker"),a.includes(o)||a.push(o),le(e,p,"gfmFootnoteDefinitionWhitespace")):n(b)}function p(b){return t(b)}}function wM(e,t,n){return e.check(Bt,t,e.attempt(hM,t,n))}function AM(e){e.exit("gfmFootnoteDefinition")}function TM(e,t,n){const r=this;return le(e,a,"gfmFootnoteDefinitionIndent",5);function a(o){const i=r.events[r.events.length-1];return i&&i[1].type==="gfmFootnoteDefinitionIndent"&&i[2].sliceSerialize(i[1],!0).length===4?t(o):n(o)}}function RM(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:o,resolveAll:a};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function a(i,l){let s=-1;for(;++s<i.length;)if(i[s][0]==="enter"&&i[s][1].type==="strikethroughSequenceTemporary"&&i[s][1]._close){let u=s;for(;u--;)if(i[u][0]==="exit"&&i[u][1].type==="strikethroughSequenceTemporary"&&i[u][1]._open&&i[s][1].end.offset-i[s][1].start.offset===i[u][1].end.offset-i[u][1].start.offset){i[s][1].type="strikethroughSequence",i[u][1].type="strikethroughSequence";const c={type:"strikethrough",start:Object.assign({},i[u][1].start),end:Object.assign({},i[s][1].end)},d={type:"strikethroughText",start:Object.assign({},i[u][1].end),end:Object.assign({},i[s][1].start)},f=[["enter",c,l],["enter",i[u][1],l],["exit",i[u][1],l],["enter",d,l]],p=l.parser.constructs.insideSpan.null;p&&Ce(f,f.length,0,ln(p,i.slice(u+1,s),l)),Ce(f,f.length,0,[["exit",d,l],["enter",i[s][1],l],["exit",i[s][1],l],["exit",c,l]]),Ce(i,u-1,s-u+3,f),s=u+f.length-2;break}}for(s=-1;++s<i.length;)i[s][1].type==="strikethroughSequenceTemporary"&&(i[s][1].type="data");return i}function o(i,l,s){const u=this.previous,c=this.events;let d=0;return f;function f(b){return u===126&&c[c.length-1][1].type!=="characterEscape"?s(b):(i.enter("strikethroughSequenceTemporary"),p(b))}function p(b){const m=ft(u);if(b===126)return d>1?s(b):(i.consume(b),d++,p);if(d<2&&!n)return s(b);const A=i.exit("strikethroughSequenceTemporary"),k=ft(b);return A._open=!k||k===2&&!!m,A._close=!m||m===2&&!!k,l(b)}}}class _M{constructor(){this.map=[]}add(t,n,r){xM(this,t,n,r)}consume(t){if(this.map.sort(function(o,i){return o[0]-i[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let a=r.pop();for(;a;){for(const o of a)t.push(o);a=r.pop()}this.map.length=0}}function xM(e,t,n,r){let a=0;if(!(n===0&&r.length===0)){for(;a<e.map.length;){if(e.map[a][0]===t){e.map[a][1]+=n,e.map[a][2].push(...r);return}a+=1}e.map.push([t,n,r])}}function CM(e,t){let n=!1;const r=[];for(;t<e.length;){const a=e[t];if(n){if(a[0]==="enter")a[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(a[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const o=r.length-1;r[o]=r[o]==="left"?"center":"right"}}else if(a[1].type==="tableDelimiterRow")break}else a[0]==="enter"&&a[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function IM(){return{flow:{null:{name:"table",tokenize:NM,resolveAll:OM}}}}function NM(e,t,n){const r=this;let a=0,o=0,i;return l;function l(R){let I=r.events.length-1;for(;I>-1;){const W=r.events[I][1].type;if(W==="lineEnding"||W==="linePrefix")I--;else break}const N=I>-1?r.events[I][1].type:null,Y=N==="tableHead"||N==="tableRow"?E:s;return Y===E&&r.parser.lazy[r.now().line]?n(R):Y(R)}function s(R){return e.enter("tableHead"),e.enter("tableRow"),u(R)}function u(R){return R===124||(i=!0,o+=1),c(R)}function c(R){return R===null?n(R):Q(R)?o>1?(o=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(R),e.exit("lineEnding"),p):n(R):oe(R)?le(e,c,"whitespace")(R):(o+=1,i&&(i=!1,a+=1),R===124?(e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),i=!0,c):(e.enter("data"),d(R)))}function d(R){return R===null||R===124||pe(R)?(e.exit("data"),c(R)):(e.consume(R),R===92?f:d)}function f(R){return R===92||R===124?(e.consume(R),d):d(R)}function p(R){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(R):(e.enter("tableDelimiterRow"),i=!1,oe(R)?le(e,b,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):b(R))}function b(R){return R===45||R===58?A(R):R===124?(i=!0,e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),m):w(R)}function m(R){return oe(R)?le(e,A,"whitespace")(R):A(R)}function A(R){return R===58?(o+=1,i=!0,e.enter("tableDelimiterMarker"),e.consume(R),e.exit("tableDelimiterMarker"),k):R===45?(o+=1,k(R)):R===null||Q(R)?T(R):w(R)}function k(R){return R===45?(e.enter("tableDelimiterFiller"),v(R)):w(R)}function v(R){return R===45?(e.consume(R),v):R===58?(i=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(R),e.exit("tableDelimiterMarker"),y):(e.exit("tableDelimiterFiller"),y(R))}function y(R){return oe(R)?le(e,T,"whitespace")(R):T(R)}function T(R){return R===124?b(R):R===null||Q(R)?!i||a!==o?w(R):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(R)):w(R)}function w(R){return n(R)}function E(R){return e.enter("tableRow"),C(R)}function C(R){return R===124?(e.enter("tableCellDivider"),e.consume(R),e.exit("tableCellDivider"),C):R===null||Q(R)?(e.exit("tableRow"),t(R)):oe(R)?le(e,C,"whitespace")(R):(e.enter("data"),D(R))}function D(R){return R===null||R===124||pe(R)?(e.exit("data"),C(R)):(e.consume(R),R===92?x:D)}function x(R){return R===92||R===124?(e.consume(R),D):D(R)}}function OM(e,t){let n=-1,r=!0,a=0,o=[0,0,0,0],i=[0,0,0,0],l=!1,s=0,u,c,d;const f=new _M;for(;++n<e.length;){const p=e[n],b=p[1];p[0]==="enter"?b.type==="tableHead"?(l=!1,s!==0&&(kh(f,t,s,u,c),c=void 0,s=0),u={type:"table",start:Object.assign({},b.start),end:Object.assign({},b.end)},f.add(n,0,[["enter",u,t]])):b.type==="tableRow"||b.type==="tableDelimiterRow"?(r=!0,d=void 0,o=[0,0,0,0],i=[0,n+1,0,0],l&&(l=!1,c={type:"tableBody",start:Object.assign({},b.start),end:Object.assign({},b.end)},f.add(n,0,[["enter",c,t]])),a=b.type==="tableDelimiterRow"?2:c?3:1):a&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")?(r=!1,i[2]===0&&(o[1]!==0&&(i[0]=i[1],d=Yt(f,t,o,a,void 0,d),o=[0,0,0,0]),i[2]=n)):b.type==="tableCellDivider"&&(r?r=!1:(o[1]!==0&&(i[0]=i[1],d=Yt(f,t,o,a,void 0,d)),o=i,i=[o[1],n,0,0])):b.type==="tableHead"?(l=!0,s=n):b.type==="tableRow"||b.type==="tableDelimiterRow"?(s=n,o[1]!==0?(i[0]=i[1],d=Yt(f,t,o,a,n,d)):i[1]!==0&&(d=Yt(f,t,i,a,n,d)),a=0):a&&(b.type==="data"||b.type==="tableDelimiterMarker"||b.type==="tableDelimiterFiller")&&(i[3]=n)}for(s!==0&&kh(f,t,s,u,c),f.consume(t.events),n=-1;++n<t.events.length;){const p=t.events[n];p[0]==="enter"&&p[1].type==="table"&&(p[1]._align=CM(t.events,n))}return e}function Yt(e,t,n,r,a,o){const i=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",l="tableContent";n[0]!==0&&(o.end=Object.assign({},ct(t.events,n[0])),e.add(n[0],0,[["exit",o,t]]));const s=ct(t.events,n[1]);if(o={type:i,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[["enter",o,t]]),n[2]!==0){const u=ct(t.events,n[2]),c=ct(t.events,n[3]),d={type:l,start:Object.assign({},u),end:Object.assign({},c)};if(e.add(n[2],0,[["enter",d,t]]),r!==2){const f=t.events[n[2]],p=t.events[n[3]];if(f[1].end=Object.assign({},p[1].end),f[1].type="chunkText",f[1].contentType="text",n[3]>n[2]+1){const b=n[2]+1,m=n[3]-n[2]-1;e.add(b,m,[])}}e.add(n[3]+1,0,[["exit",d,t]])}return a!==void 0&&(o.end=Object.assign({},ct(t.events,a)),e.add(a,0,[["exit",o,t]]),o=void 0),o}function kh(e,t,n,r,a){const o=[],i=ct(t.events,n);a&&(a.end=Object.assign({},i),o.push(["exit",a,t])),r.end=Object.assign({},i),o.push(["exit",r,t]),e.add(n+1,0,o)}function ct(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const LM={name:"tasklistCheck",tokenize:MM};function DM(){return{text:{91:LM}}}function MM(e,t,n){const r=this;return a;function a(s){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(s):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(s),e.exit("taskListCheckMarker"),o)}function o(s){return pe(s)?(e.enter("taskListCheckValueUnchecked"),e.consume(s),e.exit("taskListCheckValueUnchecked"),i):s===88||s===120?(e.enter("taskListCheckValueChecked"),e.consume(s),e.exit("taskListCheckValueChecked"),i):n(s)}function i(s){return s===93?(e.enter("taskListCheckMarker"),e.consume(s),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),l):n(s)}function l(s){return Q(s)?t(s):oe(s)?e.check({tokenize:FM},t,n)(s):n(s)}}function FM(e,t,n){return le(e,r,"whitespace");function r(a){return a===null?n(a):t(a)}}function PM(e){return Kh([sM(),yM(),RM(e),IM(),DM()])}const BM={};function zM(e){const t=this,n=e||BM,r=t.data(),a=r.micromarkExtensions||(r.micromarkExtensions=[]),o=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),i=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);a.push(PM(n)),o.push(aM()),i.push(oM(n))}function ju({children:e,className:t}){return j.jsx("div",{className:Fe("prose prose-sm max-w-none dark:prose-invert",t),children:j.jsx(sT,{remarkPlugins:[zM],components:{code:({_node:n,className:r,children:a,...o})=>{const i=/language-(\w+)/.exec(r||"");return!!i&&i?j.jsx(Qy,{style:Jy.oneDark,language:i[1],PreTag:"div",customStyle:{margin:0,borderRadius:"0.375rem",fontSize:"0.875rem",overflow:"auto",maxWidth:"100%"},wrapLongLines:!0,...o,children:String(a).replace(/\n$/,"")}):j.jsx("code",{className:Fe("relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm font-semibold",r),...o,children:a})},pre:({children:n})=>j.jsx("div",{className:"overflow-x-auto",children:n}),table:({children:n})=>j.jsx("div",{className:"overflow-x-auto",children:j.jsx("table",{className:"w-full border-collapse border border-border",children:n})}),th:({children:n})=>j.jsx("th",{className:"border border-border bg-muted px-4 py-2 text-left font-medium",children:n}),td:({children:n})=>j.jsx("td",{className:"border border-border px-4 py-2",children:n}),blockquote:({children:n})=>j.jsx("blockquote",{className:"border-l-4 border-primary pl-4 italic text-muted-foreground",children:n}),h1:({children:n})=>j.jsx("h1",{className:"mb-4 mt-6 text-2xl font-bold first:mt-0",children:n}),h2:({children:n})=>j.jsx("h2",{className:"mb-3 mt-5 text-xl font-semibold first:mt-0",children:n}),h3:({children:n})=>j.jsx("h3",{className:"mb-2 mt-4 text-lg font-semibold first:mt-0",children:n}),h4:({children:n})=>j.jsx("h4",{className:"mb-2 mt-3 text-base font-semibold first:mt-0",children:n}),h5:({children:n})=>j.jsx("h5",{className:"mb-1 mt-2 text-sm font-semibold first:mt-0",children:n}),h6:({children:n})=>j.jsx("h6",{className:"mb-1 mt-2 text-xs font-semibold first:mt-0",children:n}),p:({children:n})=>j.jsx("p",{className:"mb-3 leading-relaxed last:mb-0",children:n}),ul:({children:n})=>j.jsx("ul",{className:"mb-3 ml-4 list-disc space-y-1",children:n}),ol:({children:n})=>j.jsx("ol",{className:"mb-3 ml-4 list-decimal space-y-1",children:n}),li:({children:n})=>j.jsx("li",{className:"leading-relaxed",children:n}),a:({children:n,href:r})=>j.jsx("a",{href:r,target:"_blank",rel:"noopener noreferrer",className:"text-primary underline hover:no-underline",children:n}),hr:()=>j.jsx("hr",{className:"my-6 border-border"}),strong:({children:n})=>j.jsx("strong",{className:"font-semibold",children:n}),em:({children:n})=>j.jsx("em",{className:"italic",children:n})},children:e})})}const AS=({content:e,agentName:t,onComplete:n,onChange:r})=>{const{displayText:a}=Dh({text:e,speed:5,startDelay:300,onComplete:n,onChange:r});return j.jsx("div",{className:"flex w-full gap-3 rounded-lg bg-muted p-4",children:j.jsxs("div",{className:"flex-1 w-inherit",children:[j.jsx("div",{className:"text-sm font-semibold",children:t}),j.jsx("div",{className:"mt-1 text-sm break-words",children:j.jsx(ju,{children:a})})]})})},TS=({message:e,agentName:t,handleTypingComplete:n,handleThumbsUp:r,handleThumbsDown:a})=>{const o=r&&a&&e.id!=="1"&&e.role==="assistant",i=e.role==="assistant"&&e.isTyping,l=e.role==="assistant",[s,u]=ae.useState(!1),[c,d]=ae.useState(!1);if(i)return j.jsx(AS,{content:e.content,agentName:t,onComplete:()=>n(e.id)},e.id);const f=()=>{r==null||r(e.id),u(!0)},p=()=>{a==null||a(e.id),d(!0)};return j.jsx("div",{className:Fe("flex w-full gap-3 rounded-lg p-4",l?"bg-muted":"ml-auto w-1/2 bg-primary text-primary-foreground"),children:j.jsxs("div",{className:Fe("flex flex-col flex-1 w-inherit gap-1",!l&&"text-left"),children:[j.jsx("div",{className:"text-sm font-semibold",children:l?t:"You"}),j.jsx("div",{className:Fe("text-sm break-words",!l&&"whitespace-pre-wrap"),children:l?j.jsx(ju,{children:e.content}):e.content}),o&&j.jsxs("div",{className:"flex gap-1",children:[j.jsx("button",{onClick:f,className:"p-1 rounded-md hover:bg-muted-foreground/10 transition-colors "+(s?"text-positive":"text-muted-foreground"),"aria-label":"Thumbs up",disabled:s||c,children:j.jsx(ZS,{size:16,className:"hover:text-foreground "})}),j.jsx("button",{onClick:p,className:"p-1 rounded-md hover:bg-muted-foreground/10 transition-colors "+(c?"text-critical":"text-muted-foreground"),"aria-label":"Thumbs down",disabled:c||s,children:j.jsx(XS,{size:16,className:" "})})]})]})},e.id)},UM=ae.forwardRef(({initialMessages:e=[],onSendMessage:t,agentName:n="Assistant",placeholder:r="Type your message...",className:a,onMessageSent:o,onMessageReceived:i,theme:l="auto",conversationId:s,isEventBased:u=!1,handleThumbsUp:c,handleThumbsDown:d},f)=>{const[p,b]=ae.useState(e),[m,A]=ae.useState(""),[k,v]=ae.useState(!1),y=ae.useRef(null),T=ae.useRef(null),w=ae.useRef(null),E=200;ae.useEffect(()=>{b(e)},[s,e]),ae.useImperativeHandle(f,()=>({addAssistantMessage:P=>{const B={id:Date.now().toString(),role:"assistant",content:P,timestamp:new Date,isTyping:!0};b(K=>[...K,B]),i==null||i(B),v(!1)}}),[]);const C=P=>{b(B=>B.map(K=>K.id===P?{...K,isTyping:!1}:K))},D=()=>{var P;(P=y.current)==null||P.scrollIntoView({behavior:"smooth"})};ae.useEffect(()=>{D()},[p]),ae.useEffect(()=>{var P;k||(P=T.current)==null||P.focus()},[k]),ae.useEffect(()=>{const P=T.current;if(!P)return;P.style.height="auto";const B=Math.min(P.scrollHeight,E);P.style.height=`${B}px`,P.style.overflowY=P.scrollHeight>E?"auto":"hidden"},[m]);const x=()=>({id:Date.now().toString(),role:"user",content:m.trim(),timestamp:new Date}),R=P=>{b(B=>[...B,P]),A(""),v(!0),o==null||o(P)},I=async P=>{if(!t){v(!1);return}try{const B=await t(P.content);if(B){const K={id:(Date.now()+1).toString(),role:"assistant",content:B,timestamp:new Date,isTyping:!0};b(g=>[...g,K]),i==null||i(K)}}catch(B){console.error("Error sending message:",B);const K={id:(Date.now()+1).toString(),role:"assistant",content:"Sorry, there was an error processing your message.",timestamp:new Date};b(g=>[...g,K])}finally{v(!1)}},N=async P=>{if(!t){v(!1);return}try{await t(P.content)}catch(B){console.error("Error sending message:",B)}},Y=async P=>{if(P==null||P.preventDefault(),!m.trim()||k)return;const B=x();R(B),u?N(B):I(B)},W=P=>{P.key==="Enter"&&!P.shiftKey&&(P.preventDefault(),Y())},$=()=>{switch(l){case"dark":return"bg-gray-900 text-white";case"light":return"bg-white text-gray-900";default:return"bg-white dark:bg-gray-900 text-gray-900 dark:text-white"}},X=p.some(P=>P.isTyping);return j.jsxs("div",{className:Fe("flex h-full flex-col rounded-lg bg-background pb-4",a,$()),children:[j.jsx("div",{className:"flex-1 px-4 overflow-y-auto min-h-0 pb-6 [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",ref:w,children:j.jsxs("div",{className:"space-y-4 pt-4",children:[p.map(P=>j.jsx(TS,{message:P,agentName:n,handleTypingComplete:C,handleThumbsUp:c,handleThumbsDown:d},P.id)),k&&!X&&j.jsx(Lh,{agentName:n,className:"bg-muted"}),j.jsx("div",{ref:y})]})}),j.jsx("div",{className:"p-4 bg-secondary rounded-xl flex-shrink-0",children:j.jsxs("form",{onSubmit:Y,className:"flex gap-2",children:[j.jsx("textarea",{ref:T,value:m,onChange:P=>A(P.target.value),onKeyDown:W,placeholder:r,disabled:k,className:"flex-1 bg-secondary px-3 py-2 text-sm focus:outline-none placeholder:text-muted-foreground resize-none",rows:1}),j.jsx(nu,{type:"submit",disabled:k,variant:"default",size:"icon",className:"rounded-full",children:j.jsx(KS,{})})]})})]})});exports.BreathingLoader=Lh;exports.Button=nu;exports.ChatInterface=UM;exports.Markdown=ju;exports.MessageComponent=TS;exports.TypewriterMessage=AS;exports.cn=Fe;exports.useTypewriter=Dh;
package/dist/index.esm.js CHANGED
@@ -44109,7 +44109,7 @@ const jM = ({ content: e, agentName: t, onComplete: n, onChange: r }) => {
44109
44109
  const [p, b] = Le(e), [m, A] = Le(""), [k, v] = Le(!1), y = yn(null), T = yn(null), w = yn(null), E = 200;
44110
44110
  nt(() => {
44111
44111
  b(e);
44112
- }, [s]), DS(f, () => ({
44112
+ }, [s, e]), DS(f, () => ({
44113
44113
  addAssistantMessage: (P) => {
44114
44114
  const B = {
44115
44115
  id: Date.now().toString(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@factorialco/agent-chat",
3
- "version": "0.3.4",
3
+ "version": "0.3.5",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public",