@cuadra-ai/uikit 0.4.3 → 0.4.4

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 CHANGED
@@ -17,7 +17,7 @@
17
17
  `))+1))}const n="#".repeat(i),c=t.enter("headingAtx"),s=t.enter("phrasing");o.move(n+" ");let d=t.containerPhrasing(e,{before:"# ",after:`
18
18
  `,...o.current()});return/^[\t ]/.test(d)&&(d=ke(d.charCodeAt(0))+d.slice(1)),d=d?n+" "+d:n,t.options.closeAtx&&(d+=" "+n),s(),c(),d}Xt.peek=Ln;function Xt(e){return e.value||""}function Ln(){return"<"}Kt.peek=Rn;function Kt(e,r,t,a){const i=et(t),o=i==='"'?"Quote":"Apostrophe",n=t.enter("image");let c=t.enter("label");const s=t.createTracker(a);let d=s.move("![");return d+=s.move(t.safe(e.alt,{before:d,after:"]",...s.current()})),d+=s.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=t.enter("destinationLiteral"),d+=s.move("<"),d+=s.move(t.safe(e.url,{before:d,after:">",...s.current()})),d+=s.move(">")):(c=t.enter("destinationRaw"),d+=s.move(t.safe(e.url,{before:d,after:e.title?" ":")",...s.current()}))),c(),e.title&&(c=t.enter(`title${o}`),d+=s.move(" "+i),d+=s.move(t.safe(e.title,{before:d,after:i,...s.current()})),d+=s.move(i),c()),d+=s.move(")"),n(),d}function Rn(){return"!"}Qt.peek=Dn;function Qt(e,r,t,a){const i=e.referenceType,o=t.enter("imageReference");let n=t.enter("label");const c=t.createTracker(a);let s=c.move("![");const d=t.safe(e.alt,{before:s,after:"]",...c.current()});s+=c.move(d+"]["),n();const f=t.stack;t.stack=[],n=t.enter("reference");const l=t.safe(t.associationId(e),{before:s,after:"]",...c.current()});return n(),t.stack=f,o(),i==="full"||!d||d!==l?s+=c.move(l+"]"):i==="shortcut"?s=s.slice(0,-1):s+=c.move("]"),s}function Dn(){return"!"}Gt.peek=_n;function Gt(e,r,t){let a=e.value||"",i="`",o=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(a);)i+="`";for(/[^ \r\n]/.test(a)&&(/^[ \r\n]/.test(a)&&/[ \r\n]$/.test(a)||/^`|`$/.test(a))&&(a=" "+a+" ");++o<t.unsafe.length;){const n=t.unsafe[o],c=t.compilePattern(n);let s;if(n.atBreak)for(;s=c.exec(a);){let d=s.index;a.charCodeAt(d)===10&&a.charCodeAt(d-1)===13&&d--,a=a.slice(0,d)+" "+a.slice(s.index+1)}}return i+a+i}function _n(){return"`"}function Yt(e,r){const t=Ht(e);return!!(!r.options.resourceLink&&e.url&&!e.title&&e.children&&e.children.length===1&&e.children[0].type==="text"&&(t===e.url||"mailto:"+t===e.url)&&/^[a-z][a-z+.-]+:/i.test(e.url)&&!/[\0- <>\u007F]/.test(e.url))}Zt.peek=Fn;function Zt(e,r,t,a){const i=et(t),o=i==='"'?"Quote":"Apostrophe",n=t.createTracker(a);let c,s;if(Yt(e,t)){const f=t.stack;t.stack=[],c=t.enter("autolink");let l=n.move("<");return l+=n.move(t.containerPhrasing(e,{before:l,after:">",...n.current()})),l+=n.move(">"),c(),t.stack=f,l}c=t.enter("link"),s=t.enter("label");let d=n.move("[");return d+=n.move(t.containerPhrasing(e,{before:d,after:"](",...n.current()})),d+=n.move("]("),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=t.enter("destinationLiteral"),d+=n.move("<"),d+=n.move(t.safe(e.url,{before:d,after:">",...n.current()})),d+=n.move(">")):(s=t.enter("destinationRaw"),d+=n.move(t.safe(e.url,{before:d,after:e.title?" ":")",...n.current()}))),s(),e.title&&(s=t.enter(`title${o}`),d+=n.move(" "+i),d+=n.move(t.safe(e.title,{before:d,after:i,...n.current()})),d+=n.move(i),s()),d+=n.move(")"),c(),d}function Fn(e,r,t){return Yt(e,t)?"<":"["}Jt.peek=zn;function Jt(e,r,t,a){const i=e.referenceType,o=t.enter("linkReference");let n=t.enter("label");const c=t.createTracker(a);let s=c.move("[");const d=t.containerPhrasing(e,{before:s,after:"]",...c.current()});s+=c.move(d+"]["),n();const f=t.stack;t.stack=[],n=t.enter("reference");const l=t.safe(t.associationId(e),{before:s,after:"]",...c.current()});return n(),t.stack=f,o(),i==="full"||!d||d!==l?s+=c.move(l+"]"):i==="shortcut"?s=s.slice(0,-1):s+=c.move("]"),s}function zn(){return"["}function tt(e){const r=e.options.bullet||"*";if(r!=="*"&&r!=="+"&&r!=="-")throw new Error("Cannot serialize items with `"+r+"` for `options.bullet`, expected `*`, `+`, or `-`");return r}function Un(e){const r=tt(e),t=e.options.bulletOther;if(!t)return r==="*"?"-":"*";if(t!=="*"&&t!=="+"&&t!=="-")throw new Error("Cannot serialize items with `"+t+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(t===r)throw new Error("Expected `bullet` (`"+r+"`) and `bulletOther` (`"+t+"`) to be different");return t}function $n(e){const r=e.options.bulletOrdered||".";if(r!=="."&&r!==")")throw new Error("Cannot serialize items with `"+r+"` for `options.bulletOrdered`, expected `.` or `)`");return r}function er(e){const r=e.options.rule||"*";if(r!=="*"&&r!=="-"&&r!=="_")throw new Error("Cannot serialize rules with `"+r+"` for `options.rule`, expected `*`, `-`, or `_`");return r}function On(e,r,t,a){const i=t.enter("list"),o=t.bulletCurrent;let n=e.ordered?$n(t):tt(t);const c=e.ordered?n==="."?")":".":Un(t);let s=r&&t.bulletLastUsed?n===t.bulletLastUsed:!1;if(!e.ordered){const f=e.children?e.children[0]:void 0;if((n==="*"||n==="-")&&f&&(!f.children||!f.children[0])&&t.stack[t.stack.length-1]==="list"&&t.stack[t.stack.length-2]==="listItem"&&t.stack[t.stack.length-3]==="list"&&t.stack[t.stack.length-4]==="listItem"&&t.indexStack[t.indexStack.length-1]===0&&t.indexStack[t.indexStack.length-2]===0&&t.indexStack[t.indexStack.length-3]===0&&(s=!0),er(t)===n&&f){let l=-1;for(;++l<e.children.length;){const p=e.children[l];if(p&&p.type==="listItem"&&p.children&&p.children[0]&&p.children[0].type==="thematicBreak"){s=!0;break}}}}s&&(n=c),t.bulletCurrent=n;const d=t.containerFlow(e,a);return t.bulletLastUsed=n,t.bulletCurrent=o,i(),d}function Bn(e){const r=e.options.listItemIndent||"one";if(r!=="tab"&&r!=="one"&&r!=="mixed")throw new Error("Cannot serialize items with `"+r+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return r}function Wn(e,r,t,a){const i=Bn(t);let o=t.bulletCurrent||tt(t);r&&r.type==="list"&&r.ordered&&(o=(typeof r.start=="number"&&r.start>-1?r.start:1)+(t.options.incrementListMarker===!1?0:r.children.indexOf(e))+o);let n=o.length+1;(i==="tab"||i==="mixed"&&(r&&r.type==="list"&&r.spread||e.spread))&&(n=Math.ceil(n/4)*4);const c=t.createTracker(a);c.move(o+" ".repeat(n-o.length)),c.shift(n);const s=t.enter("listItem"),d=t.indentLines(t.containerFlow(e,c.current()),f);return s(),d;function f(l,p,g){return p?(g?"":" ".repeat(n))+l:(g?o:o+" ".repeat(n-o.length))+l}}function qn(e,r,t,a){const i=t.enter("paragraph"),o=t.enter("phrasing"),n=t.containerPhrasing(e,a);return o(),i(),n}const Hn=De(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Vn(e,r,t,a){return(e.children.some(function(n){return Hn(n)})?t.containerPhrasing:t.containerFlow).call(t,e,a)}function Xn(e){const r=e.options.strong||"*";if(r!=="*"&&r!=="_")throw new Error("Cannot serialize strong with `"+r+"` for `options.strong`, expected `*`, or `_`");return r}tr.peek=Kn;function tr(e,r,t,a){const i=Xn(t),o=t.enter("strong"),n=t.createTracker(a),c=n.move(i+i);let s=n.move(t.containerPhrasing(e,{after:i,before:c,...n.current()}));const d=s.charCodeAt(0),f=Pe(a.before.charCodeAt(a.before.length-1),d,i);f.inside&&(s=ke(d)+s.slice(1));const l=s.charCodeAt(s.length-1),p=Pe(a.after.charCodeAt(0),l,i);p.inside&&(s=s.slice(0,-1)+ke(l));const g=n.move(i+i);return o(),t.attentionEncodeSurroundingInfo={after:p.outside,before:f.outside},c+s+g}function Kn(e,r,t){return t.options.strong||"*"}function Qn(e,r,t,a){return t.safe(e.value,a)}function Gn(e){const r=e.options.ruleRepetition||3;if(r<3)throw new Error("Cannot serialize rules with repetition `"+r+"` for `options.ruleRepetition`, expected `3` or more");return r}function Yn(e,r,t){const a=(er(t)+(t.options.ruleSpaces?" ":"")).repeat(Gn(t));return t.options.ruleSpaces?a.slice(0,-1):a}const rr={blockquote:xn,break:kt,code:vn,definition:Tn,emphasis:qt,hardBreak:kt,heading:Pn,html:Xt,image:Kt,imageReference:Qt,inlineCode:Gt,link:Zt,linkReference:Jt,list:On,listItem:Wn,paragraph:qn,root:Vn,strong:tr,text:Qn,thematicBreak:Yn};function Zn(){return{enter:{table:Jn,tableData:vt,tableHeader:vt,tableRow:ti},exit:{codeText:ri,table:ei,tableData:Be,tableHeader:Be,tableRow:Be}}}function Jn(e){const r=e._align;this.enter({type:"table",align:r.map(function(t){return t==="none"?null:t}),children:[]},e),this.data.inTable=!0}function ei(e){this.exit(e),this.data.inTable=void 0}function ti(e){this.enter({type:"tableRow",children:[]},e)}function Be(e){this.exit(e)}function vt(e){this.enter({type:"tableCell",children:[]},e)}function ri(e){let r=this.resume();this.data.inTable&&(r=r.replace(/\\([\\|])/g,ai));const t=this.stack[this.stack.length-1];t.type,t.value=r,this.exit(e)}function ai(e,r){return r==="|"?r:e}function ni(e){const r=e||{},t=r.tableCellPadding,a=r.tablePipeAlign,i=r.stringLength,o=t?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
19
19
  `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:p,table:n,tableCell:s,tableRow:c}};function n(g,h,y,b){return d(f(g,y,b),g.align)}function c(g,h,y,b){const w=l(g,y,b),k=d([w]);return k.slice(0,k.indexOf(`
20
- `))}function s(g,h,y,b){const w=y.enter("tableCell"),k=y.enter("phrasing"),C=y.containerPhrasing(g,{...b,before:o,after:o});return k(),w(),C}function d(g,h){return pn(g,{align:h,alignDelimiters:a,padding:t,stringLength:i})}function f(g,h,y){const b=g.children;let w=-1;const k=[],C=h.enter("table");for(;++w<b.length;)k[w]=l(b[w],h,y);return C(),k}function l(g,h,y){const b=g.children;let w=-1;const k=[],C=h.enter("tableRow");for(;++w<b.length;)k[w]=s(b[w],g,h,y);return C(),k}function p(g,h,y){let b=rr.inlineCode(g,h,y);return y.stack.includes("tableCell")&&(b=b.replace(/\|/g,"\\$&")),b}}function ii(){return{exit:{taskListCheckValueChecked:jt,taskListCheckValueUnchecked:jt,paragraph:si}}}function oi(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:ci}}}function jt(e){const r=this.stack[this.stack.length-2];r.type,r.checked=e.type==="taskListCheckValueChecked"}function si(e){const r=this.stack[this.stack.length-2];if(r&&r.type==="listItem"&&typeof r.checked=="boolean"){const t=this.stack[this.stack.length-1];t.type;const a=t.children[0];if(a&&a.type==="text"){const i=r.children;let o=-1,n;for(;++o<i.length;){const c=i[o];if(c.type==="paragraph"){n=c;break}}n===t&&(a.value=a.value.slice(1),a.value.length===0?t.children.shift():t.position&&a.position&&typeof a.position.start.offset=="number"&&(a.position.start.column++,a.position.start.offset++,t.position.start=Object.assign({},a.position.start)))}}this.exit(e)}function ci(e,r,t,a){const i=e.children[0],o=typeof e.checked=="boolean"&&i&&i.type==="paragraph",n="["+(e.checked?"x":" ")+"] ",c=t.createTracker(a);o&&c.move(n);let s=rr.listItem(e,r,t,{...a,...c.current()});return o&&(s=s.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,d)),s;function d(f){return f+n}}function ui(){return[Fa(),nn(),un(),Zn(),ii()]}function li(e){return{extensions:[za(),on(e),ln(),ni(e),oi()]}}function Se(e,r,t,a){const i=e.length;let o=0,n;if(r<0?r=-r>i?0:i+r:r=r>i?i:r,t=t>0?t:0,a.length<1e4)n=Array.from(a),n.unshift(r,t),e.splice(...n);else for(t&&e.splice(r,t);o<a.length;)n=a.slice(o,o+1e4),n.unshift(r,0),e.splice(...n),o+=1e4,r+=1e4}const Tt={}.hasOwnProperty;function di(e){const r={};let t=-1;for(;++t<e.length;)fi(r,e[t]);return r}function fi(e,r){let t;for(t in r){const i=(Tt.call(e,t)?e[t]:void 0)||(e[t]={}),o=r[t];let n;if(o)for(n in o){Tt.call(i,n)||(i[n]=[]);const c=o[n];hi(i[n],Array.isArray(c)?c:c?[c]:[])}}}function hi(e,r){let t=-1;const a=[];for(;++t<r.length;)(r[t].add==="after"?e:a).push(r[t]);Se(e,0,0,a)}const mi={tokenize:wi,partial:!0},ar={tokenize:ki,partial:!0},nr={tokenize:Ci,partial:!0},ir={tokenize:vi,partial:!0},pi={tokenize:ji,partial:!0},or={name:"wwwAutolink",tokenize:bi,previous:cr},sr={name:"protocolAutolink",tokenize:yi,previous:ur},te={name:"emailAutolink",tokenize:xi,previous:lr},K={};function gi(){return{text:K}}let ne=48;for(;ne<123;)K[ne]=te,ne++,ne===58?ne=65:ne===91&&(ne=97);K[43]=te;K[45]=te;K[46]=te;K[95]=te;K[72]=[te,sr];K[104]=[te,sr];K[87]=[te,or];K[119]=[te,or];function xi(e,r,t){const a=this;let i,o;return n;function n(l){return!Ge(l)||!lr.call(a,a.previous)||rt(a.events)?t(l):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),c(l))}function c(l){return Ge(l)?(e.consume(l),c):l===64?(e.consume(l),s):t(l)}function s(l){return l===46?e.check(pi,f,d)(l):l===45||l===95||Je(l)?(o=!0,e.consume(l),s):f(l)}function d(l){return e.consume(l),i=!0,s}function f(l){return o&&i&&we(a.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),r(l)):t(l)}}function bi(e,r,t){const a=this;return i;function i(n){return n!==87&&n!==119||!cr.call(a,a.previous)||rt(a.events)?t(n):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(mi,e.attempt(ar,e.attempt(nr,o),t),t)(n))}function o(n){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),r(n)}}function yi(e,r,t){const a=this;let i="",o=!1;return n;function n(l){return(l===72||l===104)&&ur.call(a,a.previous)&&!rt(a.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(l),e.consume(l),c):t(l)}function c(l){if(we(l)&&i.length<5)return i+=String.fromCodePoint(l),e.consume(l),c;if(l===58){const p=i.toLowerCase();if(p==="http"||p==="https")return e.consume(l),s}return t(l)}function s(l){return l===47?(e.consume(l),o?d:(o=!0,s)):t(l)}function d(l){return l===null||va(l)||q(l)||ie(l)||Le(l)?t(l):e.attempt(ar,e.attempt(nr,f),t)(l)}function f(l){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),r(l)}}function wi(e,r,t){let a=0;return i;function i(n){return(n===87||n===119)&&a<3?(a++,e.consume(n),i):n===46&&a===3?(e.consume(n),o):t(n)}function o(n){return n===null?t(n):r(n)}}function ki(e,r,t){let a,i,o;return n;function n(d){return d===46||d===95?e.check(ir,s,c)(d):d===null||q(d)||ie(d)||d!==45&&Le(d)?s(d):(o=!0,e.consume(d),n)}function c(d){return d===95?a=!0:(i=a,a=void 0),e.consume(d),n}function s(d){return i||a||!o?t(d):r(d)}}function Ci(e,r){let t=0,a=0;return i;function i(n){return n===40?(t++,e.consume(n),i):n===41&&a<t?o(n):n===33||n===34||n===38||n===39||n===41||n===42||n===44||n===46||n===58||n===59||n===60||n===63||n===93||n===95||n===126?e.check(ir,r,o)(n):n===null||q(n)||ie(n)?r(n):(e.consume(n),i)}function o(n){return n===41&&a++,e.consume(n),i}}function vi(e,r,t){return a;function a(c){return c===33||c===34||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===63||c===95||c===126?(e.consume(c),a):c===38?(e.consume(c),o):c===93?(e.consume(c),i):c===60||c===null||q(c)||ie(c)?r(c):t(c)}function i(c){return c===null||c===40||c===91||q(c)||ie(c)?r(c):a(c)}function o(c){return we(c)?n(c):t(c)}function n(c){return c===59?(e.consume(c),a):we(c)?(e.consume(c),n):t(c)}}function ji(e,r,t){return a;function a(o){return e.consume(o),i}function i(o){return Je(o)?t(o):r(o)}}function cr(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||q(e)}function ur(e){return!we(e)}function lr(e){return!(e===47||Ge(e))}function Ge(e){return e===43||e===45||e===46||e===95||Je(e)}function rt(e){let r=e.length,t=!1;for(;r--;){const a=e[r][1];if((a.type==="labelLink"||a.type==="labelImage")&&!a._balanced){t=!0;break}if(a._gfmAutolinkLiteralWalkedInto){t=!1;break}}return e.length>0&&!t&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),t}function Ti(e,r,t){const a=[];let i=-1;for(;++i<e.length;){const o=e[i].resolveAll;o&&!a.includes(o)&&(r=o(r,t),a.push(o))}return r}function ee(e,r,t,a){const i=a?a-1:Number.POSITIVE_INFINITY;let o=0;return n;function n(s){return J(s)?(e.enter(t),c(s)):r(s)}function c(s){return J(s)&&o++<i?(e.consume(s),c):(e.exit(t),r(s))}}const Mi={partial:!0,tokenize:Ai};function Ai(e,r,t){return a;function a(o){return J(o)?ee(e,i,"linePrefix")(o):i(o)}function i(o){return o===null||de(o)?r(o):t(o)}}const Ii={tokenize:_i,partial:!0};function Si(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Li,continuation:{tokenize:Ri},exit:Di}},text:{91:{name:"gfmFootnoteCall",tokenize:Pi},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Ni,resolveTo:Ei}}}}function Ni(e,r,t){const a=this;let i=a.events.length;const o=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let n;for(;i--;){const s=a.events[i][1];if(s.type==="labelImage"){n=s;break}if(s.type==="gfmFootnoteCall"||s.type==="labelLink"||s.type==="label"||s.type==="image"||s.type==="link")break}return c;function c(s){if(!n||!n._balanced)return t(s);const d=Ce(a.sliceSerialize({start:n.end,end:a.now()}));return d.codePointAt(0)!==94||!o.includes(d.slice(1))?t(s):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(s),e.exit("gfmFootnoteCallLabelMarker"),r(s))}}function Ei(e,r){let t=e.length;for(;t--;)if(e[t][1].type==="labelImage"&&e[t][0]==="enter"){e[t][1];break}e[t+1][1].type="data",e[t+3][1].type="gfmFootnoteCallLabelMarker";const a={type:"gfmFootnoteCall",start:Object.assign({},e[t+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[t+3][1].end),end:Object.assign({},e[t+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},n={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},c=[e[t+1],e[t+2],["enter",a,r],e[t+3],e[t+4],["enter",i,r],["exit",i,r],["enter",o,r],["enter",n,r],["exit",n,r],["exit",o,r],e[e.length-2],e[e.length-1],["exit",a,r]];return e.splice(t,e.length-t+1,...c),e}function Pi(e,r,t){const a=this,i=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let o=0,n;return c;function c(l){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),s}function s(l){return l!==94?t(l):(e.enter("gfmFootnoteCallMarker"),e.consume(l),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",d)}function d(l){if(o>999||l===93&&!n||l===null||l===91||q(l))return t(l);if(l===93){e.exit("chunkString");const p=e.exit("gfmFootnoteCallString");return i.includes(Ce(a.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),r):t(l)}return q(l)||(n=!0),o++,e.consume(l),l===92?f:d}function f(l){return l===91||l===92||l===93?(e.consume(l),o++,d):d(l)}}function Li(e,r,t){const a=this,i=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let o,n=0,c;return s;function s(h){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(h),e.exit("gfmFootnoteDefinitionLabelMarker"),d}function d(h){return h===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(h),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",f):t(h)}function f(h){if(n>999||h===93&&!c||h===null||h===91||q(h))return t(h);if(h===93){e.exit("chunkString");const y=e.exit("gfmFootnoteDefinitionLabelString");return o=Ce(a.sliceSerialize(y)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(h),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return q(h)||(c=!0),n++,e.consume(h),h===92?l:f}function l(h){return h===91||h===92||h===93?(e.consume(h),n++,f):f(h)}function p(h){return h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),i.includes(o)||i.push(o),ee(e,g,"gfmFootnoteDefinitionWhitespace")):t(h)}function g(h){return r(h)}}function Ri(e,r,t){return e.check(Mi,r,e.attempt(Ii,r,t))}function Di(e){e.exit("gfmFootnoteDefinition")}function _i(e,r,t){const a=this;return ee(e,i,"gfmFootnoteDefinitionIndent",5);function i(o){const n=a.events[a.events.length-1];return n&&n[1].type==="gfmFootnoteDefinitionIndent"&&n[2].sliceSerialize(n[1],!0).length===4?r(o):t(o)}}function Fi(e){let t=(e||{}).singleTilde;const a={name:"strikethrough",tokenize:o,resolveAll:i};return t==null&&(t=!0),{text:{126:a},insideSpan:{null:[a]},attentionMarkers:{null:[126]}};function i(n,c){let s=-1;for(;++s<n.length;)if(n[s][0]==="enter"&&n[s][1].type==="strikethroughSequenceTemporary"&&n[s][1]._close){let d=s;for(;d--;)if(n[d][0]==="exit"&&n[d][1].type==="strikethroughSequenceTemporary"&&n[d][1]._open&&n[s][1].end.offset-n[s][1].start.offset===n[d][1].end.offset-n[d][1].start.offset){n[s][1].type="strikethroughSequence",n[d][1].type="strikethroughSequence";const f={type:"strikethrough",start:Object.assign({},n[d][1].start),end:Object.assign({},n[s][1].end)},l={type:"strikethroughText",start:Object.assign({},n[d][1].end),end:Object.assign({},n[s][1].start)},p=[["enter",f,c],["enter",n[d][1],c],["exit",n[d][1],c],["enter",l,c]],g=c.parser.constructs.insideSpan.null;g&&Se(p,p.length,0,Ti(g,n.slice(d+1,s),c)),Se(p,p.length,0,[["exit",l,c],["enter",n[s][1],c],["exit",n[s][1],c],["exit",f,c]]),Se(n,d-1,s-d+3,p),s=d+p.length-2;break}}for(s=-1;++s<n.length;)n[s][1].type==="strikethroughSequenceTemporary"&&(n[s][1].type="data");return n}function o(n,c,s){const d=this.previous,f=this.events;let l=0;return p;function p(h){return d===126&&f[f.length-1][1].type!=="characterEscape"?s(h):(n.enter("strikethroughSequenceTemporary"),g(h))}function g(h){const y=Ee(d);if(h===126)return l>1?s(h):(n.consume(h),l++,g);if(l<2&&!t)return s(h);const b=n.exit("strikethroughSequenceTemporary"),w=Ee(h);return b._open=!w||w===2&&!!y,b._close=!y||y===2&&!!w,c(h)}}}class zi{constructor(){this.map=[]}add(r,t,a){Ui(this,r,t,a)}consume(r){if(this.map.sort(function(o,n){return o[0]-n[0]}),this.map.length===0)return;let t=this.map.length;const a=[];for(;t>0;)t-=1,a.push(r.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),r.length=this.map[t][0];a.push(r.slice()),r.length=0;let i=a.pop();for(;i;){for(const o of i)r.push(o);i=a.pop()}this.map.length=0}}function Ui(e,r,t,a){let i=0;if(!(t===0&&a.length===0)){for(;i<e.map.length;){if(e.map[i][0]===r){e.map[i][1]+=t,e.map[i][2].push(...a);return}i+=1}e.map.push([r,t,a])}}function $i(e,r){let t=!1;const a=[];for(;r<e.length;){const i=e[r];if(t){if(i[0]==="enter")i[1].type==="tableContent"&&a.push(e[r+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[r-1][1].type==="tableDelimiterMarker"){const o=a.length-1;a[o]=a[o]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(t=!0);r+=1}return a}function Oi(){return{flow:{null:{name:"table",tokenize:Bi,resolveAll:Wi}}}}function Bi(e,r,t){const a=this;let i=0,o=0,n;return c;function c(m){let $=a.events.length-1;for(;$>-1;){const H=a.events[$][1].type;if(H==="lineEnding"||H==="linePrefix")$--;else break}const z=$>-1?a.events[$][1].type:null,V=z==="tableHead"||z==="tableRow"?I:s;return V===I&&a.parser.lazy[a.now().line]?t(m):V(m)}function s(m){return e.enter("tableHead"),e.enter("tableRow"),d(m)}function d(m){return m===124||(n=!0,o+=1),f(m)}function f(m){return m===null?t(m):de(m)?o>1?(o=0,a.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),g):t(m):J(m)?ee(e,f,"whitespace")(m):(o+=1,n&&(n=!1,i+=1),m===124?(e.enter("tableCellDivider"),e.consume(m),e.exit("tableCellDivider"),n=!0,f):(e.enter("data"),l(m)))}function l(m){return m===null||m===124||q(m)?(e.exit("data"),f(m)):(e.consume(m),m===92?p:l)}function p(m){return m===92||m===124?(e.consume(m),l):l(m)}function g(m){return a.interrupt=!1,a.parser.lazy[a.now().line]?t(m):(e.enter("tableDelimiterRow"),n=!1,J(m)?ee(e,h,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(m):h(m))}function h(m){return m===45||m===58?b(m):m===124?(n=!0,e.enter("tableCellDivider"),e.consume(m),e.exit("tableCellDivider"),y):P(m)}function y(m){return J(m)?ee(e,b,"whitespace")(m):b(m)}function b(m){return m===58?(o+=1,n=!0,e.enter("tableDelimiterMarker"),e.consume(m),e.exit("tableDelimiterMarker"),w):m===45?(o+=1,w(m)):m===null||de(m)?E(m):P(m)}function w(m){return m===45?(e.enter("tableDelimiterFiller"),k(m)):P(m)}function k(m){return m===45?(e.consume(m),k):m===58?(n=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(m),e.exit("tableDelimiterMarker"),C):(e.exit("tableDelimiterFiller"),C(m))}function C(m){return J(m)?ee(e,E,"whitespace")(m):E(m)}function E(m){return m===124?h(m):m===null||de(m)?!n||i!==o?P(m):(e.exit("tableDelimiterRow"),e.exit("tableHead"),r(m)):P(m)}function P(m){return t(m)}function I(m){return e.enter("tableRow"),M(m)}function M(m){return m===124?(e.enter("tableCellDivider"),e.consume(m),e.exit("tableCellDivider"),M):m===null||de(m)?(e.exit("tableRow"),r(m)):J(m)?ee(e,M,"whitespace")(m):(e.enter("data"),D(m))}function D(m){return m===null||m===124||q(m)?(e.exit("data"),M(m)):(e.consume(m),m===92?A:D)}function A(m){return m===92||m===124?(e.consume(m),D):D(m)}}function Wi(e,r){let t=-1,a=!0,i=0,o=[0,0,0,0],n=[0,0,0,0],c=!1,s=0,d,f,l;const p=new zi;for(;++t<e.length;){const g=e[t],h=g[1];g[0]==="enter"?h.type==="tableHead"?(c=!1,s!==0&&(Mt(p,r,s,d,f),f=void 0,s=0),d={type:"table",start:Object.assign({},h.start),end:Object.assign({},h.end)},p.add(t,0,[["enter",d,r]])):h.type==="tableRow"||h.type==="tableDelimiterRow"?(a=!0,l=void 0,o=[0,0,0,0],n=[0,t+1,0,0],c&&(c=!1,f={type:"tableBody",start:Object.assign({},h.start),end:Object.assign({},h.end)},p.add(t,0,[["enter",f,r]])),i=h.type==="tableDelimiterRow"?2:f?3:1):i&&(h.type==="data"||h.type==="tableDelimiterMarker"||h.type==="tableDelimiterFiller")?(a=!1,n[2]===0&&(o[1]!==0&&(n[0]=n[1],l=Ie(p,r,o,i,void 0,l),o=[0,0,0,0]),n[2]=t)):h.type==="tableCellDivider"&&(a?a=!1:(o[1]!==0&&(n[0]=n[1],l=Ie(p,r,o,i,void 0,l)),o=n,n=[o[1],t,0,0])):h.type==="tableHead"?(c=!0,s=t):h.type==="tableRow"||h.type==="tableDelimiterRow"?(s=t,o[1]!==0?(n[0]=n[1],l=Ie(p,r,o,i,t,l)):n[1]!==0&&(l=Ie(p,r,n,i,t,l)),i=0):i&&(h.type==="data"||h.type==="tableDelimiterMarker"||h.type==="tableDelimiterFiller")&&(n[3]=t)}for(s!==0&&Mt(p,r,s,d,f),p.consume(r.events),t=-1;++t<r.events.length;){const g=r.events[t];g[0]==="enter"&&g[1].type==="table"&&(g[1]._align=$i(r.events,t))}return e}function Ie(e,r,t,a,i,o){const n=a===1?"tableHeader":a===2?"tableDelimiter":"tableData",c="tableContent";t[0]!==0&&(o.end=Object.assign({},le(r.events,t[0])),e.add(t[0],0,[["exit",o,r]]));const s=le(r.events,t[1]);if(o={type:n,start:Object.assign({},s),end:Object.assign({},s)},e.add(t[1],0,[["enter",o,r]]),t[2]!==0){const d=le(r.events,t[2]),f=le(r.events,t[3]),l={type:c,start:Object.assign({},d),end:Object.assign({},f)};if(e.add(t[2],0,[["enter",l,r]]),a!==2){const p=r.events[t[2]],g=r.events[t[3]];if(p[1].end=Object.assign({},g[1].end),p[1].type="chunkText",p[1].contentType="text",t[3]>t[2]+1){const h=t[2]+1,y=t[3]-t[2]-1;e.add(h,y,[])}}e.add(t[3]+1,0,[["exit",l,r]])}return i!==void 0&&(o.end=Object.assign({},le(r.events,i)),e.add(i,0,[["exit",o,r]]),o=void 0),o}function Mt(e,r,t,a,i){const o=[],n=le(r.events,t);i&&(i.end=Object.assign({},n),o.push(["exit",i,r])),a.end=Object.assign({},n),o.push(["exit",a,r]),e.add(t+1,0,o)}function le(e,r){const t=e[r],a=t[0]==="enter"?"start":"end";return t[1][a]}const qi={name:"tasklistCheck",tokenize:Vi};function Hi(){return{text:{91:qi}}}function Vi(e,r,t){const a=this;return i;function i(s){return a.previous!==null||!a._gfmTasklistFirstContentOfListItem?t(s):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(s),e.exit("taskListCheckMarker"),o)}function o(s){return q(s)?(e.enter("taskListCheckValueUnchecked"),e.consume(s),e.exit("taskListCheckValueUnchecked"),n):s===88||s===120?(e.enter("taskListCheckValueChecked"),e.consume(s),e.exit("taskListCheckValueChecked"),n):t(s)}function n(s){return s===93?(e.enter("taskListCheckMarker"),e.consume(s),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),c):t(s)}function c(s){return de(s)?r(s):J(s)?e.check({tokenize:Xi},r,t)(s):t(s)}}function Xi(e,r,t){return ee(e,a,"whitespace");function a(i){return i===null?t(i):r(i)}}function Ki(e){return di([gi(),Si(),Fi(e),Oi(),Hi()])}const Qi={};function Gi(e){const r=this,t=e||Qi,a=r.data(),i=a.micromarkExtensions||(a.micromarkExtensions=[]),o=a.fromMarkdownExtensions||(a.fromMarkdownExtensions=[]),n=a.toMarkdownExtensions||(a.toMarkdownExtensions=[]);i.push(Ki(t)),o.push(ui()),n.push(li(t))}function U(...e){return e.filter(Boolean).join(" ")}const Yi=({content:e})=>u.jsx(Ve.MarkdownTextPrimitive,{remarkPlugins:[Gi],className:"cuadra-aui-md",components:eo,children:e}),at=x.memo(Yi),Zi=({language:e,code:r})=>{const{isCopied:t,copyToClipboard:a}=Ji(),i=()=>{!r||t||a(r)};return u.jsxs("div",{className:"cuadra-flex cuadra-items-center cuadra-justify-between cuadra-gap-4 cuadra-mt-4 cuadra-rounded-t-lg cuadra-bg-muted/50 cuadra-border-b cuadra-border-border cuadra-px-4 cuadra-py-2 cuadra-text-sm cuadra-font-normal cuadra-text-foreground cuadra-font-brand",children:[u.jsx("span",{className:"cuadra-lowercase [&>span]:cuadra-text-xs cuadra-font-brand",children:e}),u.jsxs("button",{onClick:i,className:"cuadra-p-1 cuadra-rounded hover:cuadra-bg-muted cuadra-transition-colors","aria-label":"Copy code",children:[!t&&u.jsx($r,{className:"cuadra-h-4 cuadra-w-4"}),t&&u.jsx(Dr,{className:"cuadra-h-4 cuadra-w-4"})]})]})},Ji=({copiedDuration:e=3e3}={})=>{const[r,t]=x.useState(!1);return{isCopied:r,copyToClipboard:i=>{i&&navigator.clipboard.writeText(i).then(()=>{t(!0),setTimeout(()=>t(!1),e)})}}},eo=Ve.unstable_memoizeMarkdownComponents({h1:({className:e,...r})=>u.jsx("h1",{className:U("cuadra-mb-6 cuadra-scroll-m-20 cuadra-text-2xl cuadra-font-normal cuadra-tracking-tight last:cuadra-mb-0 font-brand",e),...r}),h2:({className:e,...r})=>u.jsx("h2",{className:U("cuadra-mb-4 cuadra-mt-6 cuadra-scroll-m-20 cuadra-text-xl cuadra-font-normal cuadra-tracking-tight first:cuadra-mt-0 last:cuadra-mb-0 font-brand",e),...r}),h3:({className:e,...r})=>u.jsx("h3",{className:U("cuadra-mb-3 cuadra-mt-5 cuadra-scroll-m-20 cuadra-text-lg cuadra-font-normal cuadra-tracking-tight first:cuadra-mt-0 last:cuadra-mb-0 font-brand",e),...r}),h4:({className:e,...r})=>u.jsx("h4",{className:U("cuadra-mb-4 cuadra-mt-6 cuadra-scroll-m-20 cuadra-text-xl cuadra-font-normal cuadra-tracking-tight first:cuadra-mt-0 last:cuadra-mb-0 font-brand",e),...r}),h5:({className:e,...r})=>u.jsx("h5",{className:U("cuadra-my-4 cuadra-text-lg cuadra-font-normal first:cuadra-mt-0 last:cuadra-mb-0 font-brand",e),...r}),h6:({className:e,...r})=>u.jsx("h6",{className:U("cuadra-my-4 cuadra-font-normal first:cuadra-mb-0 font-brand",e),...r}),p:({className:e,...r})=>u.jsx("p",{className:U("cuadra-mb-5 cuadra-mt-5 cuadra-leading-7 first:cuadra-mt-0 last:cuadra-mb-0 font-brand",e),...r}),a:({className:e,...r})=>u.jsx("a",{className:U("cuadra-text-primary cuadra-font-medium cuadra-underline cuadra-underline-offset-4 font-brand",e),...r}),blockquote:({className:e,...r})=>u.jsx("blockquote",{className:U("cuadra-border-l-2 cuadra-pl-6 cuadra-italic font-brand",e),...r}),ul:({className:e,...r})=>u.jsx("ul",{className:U("cuadra-my-5 cuadra-ml-6 cuadra-list-disc [&>li]:cuadra-mt-2 font-brand",e),...r}),ol:({className:e,...r})=>u.jsx("ol",{className:U("cuadra-my-5 cuadra-ml-6 cuadra-list-decimal [&>li]:cuadra-mt-2 font-brand",e),...r}),hr:({className:e,...r})=>u.jsx("hr",{className:U("cuadra-my-5 cuadra-border-b",e),...r}),table:({className:e,...r})=>u.jsx("table",{className:U("cuadra-my-5 cuadra-w-full cuadra-border-separate cuadra-border-spacing-0 cuadra-overflow-y-auto font-brand",e),...r}),th:({className:e,...r})=>u.jsx("th",{className:U("cuadra-bg-muted cuadra-px-4 cuadra-py-2 cuadra-text-left cuadra-font-normal first:cuadra-rounded-tl-lg last:cuadra-rounded-tr-lg [&[align=center]]:cuadra-text-center [&[align=right]]:cuadra-text-right font-brand",e),...r}),td:({className:e,...r})=>u.jsx("td",{className:U("cuadra-border-b cuadra-border-l cuadra-px-4 cuadra-py-2 cuadra-text-left last:cuadra-border-r [&[align=center]]:cuadra-text-center [&[align=right]]:cuadra-text-right font-brand",e),...r}),tr:({className:e,...r})=>u.jsx("tr",{className:U("cuadra-m-0 cuadra-border-b cuadra-p-0 first:cuadra-border-t [&:last-child>td:first-child]:cuadra-rounded-bl-lg [&:last-child>td:last-child]:cuadra-rounded-br-lg",e),...r}),sup:({className:e,...r})=>u.jsx("sup",{className:U("[&>a]:cuadra-text-xs [&>a]:cuadra-no-underline font-brand",e),...r}),pre:({className:e,...r})=>u.jsx("pre",{className:U("cuadra-overflow-x-auto cuadra-whitespace-pre-wrap cuadra-break-words cuadra-rounded-b-lg !cuadra-rounded-t-none cuadra-bg-muted cuadra-p-4 cuadra-text-foreground font-brand",e),...r}),code:function({className:r,...t}){const a=Ve.useIsMarkdownCodeBlock();return u.jsx("code",{className:U(!a&&"cuadra-bg-muted cuadra-rounded cuadra-border cuadra-font-normal font-brand",r),...t})},CodeHeader:Zi});function nt({className:e="",variant:r="default",...t}){const a="cuadra-inline-flex cuadra-items-center cuadra-rounded-md cuadra-px-3 cuadra-py-1.5 cuadra-text-xs cuadra-font-medium font-brand",i={default:"cuadra-border cuadra-border-border cuadra-bg-muted cuadra-text-muted-foreground",subtle:"cuadra-border cuadra-border-border/50 cuadra-bg-muted/50 cuadra-text-muted-foreground",outline:"cuadra-border cuadra-border-border cuadra-bg-background cuadra-text-foreground",ghost:"cuadra-text-muted-foreground"};return u.jsx("div",{className:`${a} ${i[r]||i.default} ${e}`,...t})}function to(e){const r=new Map;for(const t of e){const a=r.get(t.filename);(!a||t.score>a.score)&&r.set(t.filename,t)}return Array.from(r.values()).sort((t,a)=>a.score-t.score)}function dr({sources:e,maxVisible:r=3}){if(!e||e.length===0)return null;const t=to(e),a=t.slice(0,r),i=t.length-r;return u.jsxs("div",{className:"cuadra-mt-4 cuadra-pt-3 cuadra-border-t cuadra-border-border",children:[u.jsxs("div",{className:"cuadra-flex cuadra-items-center cuadra-gap-1.5 cuadra-mb-2.5",children:[u.jsx(Et,{className:"cuadra-h-3.5 cuadra-w-3.5 cuadra-text-muted-foreground"}),u.jsx("span",{className:"cuadra-text-xs cuadra-font-medium cuadra-text-muted-foreground font-brand",children:"Sources"})]}),u.jsxs("div",{className:"cuadra-flex cuadra-flex-wrap cuadra-gap-2",children:[a.map((o,n)=>u.jsx(ao,{source:o},o.sourceId||n)),i>0&&u.jsxs(nt,{variant:"subtle",children:["+",i," more"]})]})]})}function ro(e){switch(e.split(".").pop()?.toLowerCase()){case"csv":case"xlsx":case"xls":return qr;case"md":case"txt":return Xr;default:return Et}}function ao({source:e}){const{filename:r,score:t}=e,a=ro(r);return u.jsxs(nt,{className:"cuadra-gap-2 cuadra-cursor-default",title:t<1?`${Math.round(t*100)}% relevant`:void 0,children:[u.jsx(a,{className:"cuadra-h-3.5 cuadra-w-3.5 cuadra-shrink-0 cuadra-opacity-60"}),u.jsx("span",{className:"cuadra-truncate cuadra-max-w-[180px]",children:r}),t<1&&t>0&&u.jsxs("span",{className:"cuadra-opacity-50 cuadra-text-[10px] cuadra-tabular-nums",children:[Math.round(t*100),"%"]})]})}const At=x.forwardRef(function({welcomeTitle:r="Hi, how can I help you today?",welcomeSubtitle:t="Start exploring our platform and discover what you can build.",extraTopPadding:a,suggestions:i,inputPlaceholder:o="Type your message...",enableAttachments:n=!1,preMadeResponseDelay:c=1e3,streamingSpeed:s=50,safeArea:d=!1},f){const l=T.useThreadRuntime(),p=T.useAssistantApi(),[g,h]=x.useState(!1),[y,b]=x.useState(null),[w,k]=x.useState(!1),C=x.useCallback((M,D,A)=>{if(!w)try{const m=A?.streamingSpeed??s,$=A?.delay??c;_t(M,D,m,$),p.composer().setText(M),setTimeout(()=>{p.composer().send()},10)}catch{}},[w,s,c,p]),E=x.useCallback(M=>{try{p.composer().setText(M),setTimeout(()=>{p.composer().send()},10)}catch{}},[p]),P=x.useCallback(async M=>{if(!(w||!l))try{if(M.response){const D=M.responseDelay??c;await C(M.prompt,M.response,{delay:D,streamingSpeed:s})}else E(M.prompt)}catch{}},[l,w,c,s,C,E]),I=x.useCallback(()=>{try{const M=window.__cuadraThreadListRuntime;M?.switchToNewThread&&M.switchToNewThread()}catch{}},[]);return x.useImperativeHandle(f,()=>({sendMessage:E,sendPreMadeQA:C,clearChat:I}),[E,C,I]),x.useEffect(()=>{if(!l){h(!1);return}try{const M=l?.store;if(!M){h(!1);return}const D=M.subscribe?.(m=>{const $=m?.threadId,z=m?.messages||[],V=m?.isLoadingHistory||!1,H=z.length;$&&$!==y&&b($),h(V&&H===0)}),A=M.getState?.();if(A){const m=A?.threadId,$=A?.messages||[],z=A?.isLoadingHistory||!1,V=$.length;m&&m!==y&&b(m),h(z&&V===0)}return()=>{D&&D()}}catch{h(!1)}},[l,y]),u.jsxs(T.ThreadPrimitive.Root,{className:"cuadra-bg-inherit cuadra-flex cuadra-flex-col cuadra-w-full cuadra-h-full",children:[u.jsx(T.ThreadPrimitive.Viewport,{className:"cuadra-w-full cuadra-bg-inherit cuadra-px-4 cuadra-flex-1 cuadra-min-h-0 cuadra-overflow-y-auto cuadra-relative scrollbar-thin cuadra-pt-4",style:a?{paddingTop:a}:void 0,children:g?u.jsx("div",{className:"cuadra-absolute cuadra-inset-0 cuadra-flex cuadra-items-center cuadra-justify-center",children:u.jsxs("div",{className:"cuadra-flex cuadra-flex-col cuadra-items-center cuadra-gap-2",children:[u.jsx(Pt,{className:"cuadra-h-6 cuadra-w-6 cuadra-animate-spin cuadra-text-muted-foreground"}),u.jsx("p",{className:"cuadra-text-sm cuadra-text-muted-foreground font-brand",children:"Loading messages..."})]})}):u.jsxs(u.Fragment,{children:[u.jsx(T.ThreadPrimitive.Empty,{children:u.jsx(no,{title:r,subtitle:t,suggestions:i,onSuggestionClick:P,isProcessing:w})}),u.jsx(T.ThreadPrimitive.Messages,{components:{UserMessage:io,AssistantMessage:co}})]})}),u.jsxs("div",{className:"cuadra-w-full cuadra-mt-3 cuadra-border-t cuadra-border-border cuadra-pt-4",style:d?{paddingBottom:"env(safe-area-inset-bottom)"}:void 0,children:[n&&u.jsx(T.ComposerPrimitive.Attachments,{components:{Attachment:()=>{const M=T.useAssistantState(({attachment:D})=>D);return M?u.jsxs("div",{className:"cuadra-relative cuadra-inline-flex cuadra-items-center cuadra-gap-2 cuadra-mb-2 cuadra-px-2 cuadra-py-1 cuadra-rounded-md cuadra-bg-muted cuadra-border cuadra-border-border",children:[u.jsx("span",{className:"cuadra-text-xs cuadra-text-muted-foreground font-brand",children:M.name||"Attachment"}),u.jsx(T.AttachmentPrimitive.Remove,{asChild:!0,children:u.jsx("button",{type:"button",className:"cuadra-flex cuadra-items-center cuadra-justify-center cuadra-size-4 cuadra-rounded hover:cuadra-bg-background cuadra-transition-colors","aria-label":"Remove attachment",children:u.jsx(Ye,{className:"cuadra-h-3 cuadra-w-3 cuadra-text-muted-foreground"})})})]}):null}}}),u.jsxs(T.ComposerPrimitive.Root,{className:"cuadra-relative !cuadra-relative cuadra-flex-1 cuadra-w-full",children:[u.jsx(T.ComposerPrimitive.Input,{asChild:!0,children:u.jsx("textarea",{rows:3,placeholder:o,className:"cuadra-flex cuadra-min-h-[80px] cuadra-w-full cuadra-rounded-md cuadra-border cuadra-border-border cuadra-bg-background cuadra-px-3 cuadra-py-2 cuadra-text-base cuadra-text-foreground placeholder:cuadra-text-muted-foreground focus-visible:cuadra-outline-none disabled:cuadra-cursor-not-allowed disabled:cuadra-opacity-50 cuadra-resize-none font-brand",style:{paddingRight:n?"5rem":"3rem",fontSize:"1rem",borderWidth:"1px"}})}),n&&u.jsx(T.ComposerPrimitive.AddAttachment,{multiple:!0,asChild:!0,children:u.jsx("button",{type:"button",className:"!cuadra-absolute !cuadra-bottom-2 !cuadra-right-12 cuadra-size-8 cuadra-rounded-md hover:cuadra-bg-muted cuadra-transition-colors cuadra-flex cuadra-items-center cuadra-justify-center cuadra-border cuadra-border-border",style:{position:"absolute",bottom:"0.5rem",right:"3rem"},"aria-label":"Attach file",children:u.jsx(Lt,{className:"cuadra-h-4 cuadra-w-4 cuadra-text-muted-foreground",strokeWidth:1.5})})}),u.jsx(T.ComposerPrimitive.Send,{asChild:!0,children:u.jsx("button",{className:"!cuadra-absolute !cuadra-bottom-2 !cuadra-right-2 cuadra-size-8 cuadra-rounded-md cuadra-shadow-sm hover:cuadra-opacity-90 disabled:cuadra-opacity-50 disabled:cuadra-cursor-not-allowed cuadra-flex cuadra-items-center cuadra-justify-center",style:{position:"absolute",bottom:"0.5rem",right:"0.5rem",backgroundColor:"var(--cuadra-primary)",color:"hsl(var(--cuadra-primary-foreground))"},"aria-label":"Send message",type:"button",children:u.jsx(Lr,{className:"cuadra-h-4 cuadra-w-4"})})})]})]})]})});function no({title:e,subtitle:r,suggestions:t,onSuggestionClick:a,isProcessing:i}){return u.jsx("div",{className:"cuadra-flex cuadra-flex-col cuadra-items-center cuadra-h-full cuadra-py-12 cuadra-px-4 cuadra-overflow-y-auto scrollbar-hide",children:u.jsxs("div",{className:"cuadra-text-center cuadra-max-w-3xl cuadra-w-full cuadra-flex cuadra-flex-col cuadra-items-center cuadra-justify-center cuadra-min-h-full",children:[u.jsxs("div",{className:"cuadra-flex cuadra-flex-col cuadra-items-center cuadra-justify-center cuadra-mb-8",children:[u.jsx("h2",{className:"cuadra-text-lg cuadra-font-normal cuadra-text-foreground cuadra-mb-2 font-brand",children:e}),u.jsx("p",{className:"cuadra-text-muted-foreground font-brand",children:r})]}),t&&t.length>0&&u.jsx("div",{className:"cuadra-grid cuadra-grid-cols-2 cuadra-gap-2 cuadra-pb-4 cuadra-w-full cuadra-max-w-2xl",children:t.map((o,n)=>u.jsx("button",{type:"button",onClick:()=>a(o),disabled:i,className:"cuadra-w-full cuadra-text-center cuadra-px-4 cuadra-py-3 cuadra-rounded-lg cuadra-border cuadra-border-border cuadra-bg-background cuadra-text-sm cuadra-text-foreground font-brand cuadra-cursor-pointer focus:cuadra-outline-none focus:cuadra-ring-0 disabled:cuadra-opacity-50 disabled:cuadra-cursor-not-allowed",style:{borderWidth:"1px"},children:o.prompt},`suggestion-${n}`))})]})})}function io(){return u.jsxs(T.MessagePrimitive.Root,{className:"cuadra-grid cuadra-w-full cuadra-auto-rows-auto cuadra-grid-cols-[minmax(72px,1fr)_auto] cuadra-gap-y-2 cuadra-py-3 [&:where(>*)]:cuadra-col-start-2",children:[u.jsx(T.MessagePrimitive.Attachments,{components:{Attachment:()=>{const e=T.useAssistantState(({attachment:o})=>o);if(!e)return null;const r=e.type==="image",t=e.file,a=e.content?.find(o=>o.type==="image"),i=t?URL.createObjectURL(t):a?.image;return u.jsx("div",{className:"cuadra-col-start-2 cuadra-row-start-1 cuadra-mb-2 cuadra-max-w-[calc(42rem*0.8)]",children:r&&i?u.jsx("img",{src:i,alt:e.name||"Attachment",className:"cuadra-rounded-lg cuadra-border cuadra-border-border cuadra-max-h-64 cuadra-max-w-full cuadra-object-contain",style:{borderWidth:"1px"}}):u.jsxs("div",{className:"cuadra-flex cuadra-items-center cuadra-gap-2 cuadra-rounded-lg cuadra-border cuadra-border-border cuadra-bg-muted cuadra-px-3 cuadra-py-2",children:[u.jsx(Lt,{className:"cuadra-h-4 cuadra-w-4 cuadra-text-muted-foreground"}),u.jsx("span",{className:"cuadra-text-sm cuadra-text-foreground font-brand",children:e.name||"Attachment"})]})})}}}),u.jsx("div",{className:"cuadra-bg-muted cuadra-text-foreground cuadra-col-start-2 cuadra-row-start-2 cuadra-max-w-[calc(42rem*0.8)] cuadra-break-words cuadra-rounded-3xl cuadra-border cuadra-border-border cuadra-px-5 cuadra-py-2.5 font-brand",style:{maxWidth:"calc(42rem * 0.8)",borderRadius:"1.5rem",backgroundColor:"var(--cuadra-muted)",color:"hsl(var(--cuadra-foreground))",paddingLeft:"1.25rem",paddingRight:"1.25rem",paddingTop:"0.625rem",paddingBottom:"0.625rem",wordBreak:"break-word",borderWidth:"1px"},children:u.jsx(T.MessagePrimitive.Parts,{components:{Text:({text:e})=>u.jsx(at,{content:e||""})}})})]})}function oo({text:e}){const[r,t]=x.useState(!1),a=T.useAssistantState(({message:i})=>i?.status?.type==="running");return e?a?u.jsx("div",{className:"cuadra-mb-3 cuadra-py-1",children:u.jsx("div",{className:"cuadra-text-sm cuadra-text-muted-foreground cuadra-leading-relaxed font-brand cuadra-animate-text-shimmer",children:e})}):u.jsxs("div",{className:"cuadra-mb-3",children:[u.jsxs("button",{type:"button",onClick:()=>t(!r),className:"cuadra-flex cuadra-items-center cuadra-gap-1.5 cuadra-py-1 cuadra-text-sm cuadra-text-muted-foreground hover:cuadra-text-foreground cuadra-transition-colors font-brand",children:[u.jsx(Xe,{className:`cuadra-h-3.5 cuadra-w-3.5 cuadra-shrink-0 cuadra-transition-transform cuadra-duration-200 ${r?"":"cuadra--rotate-90"}`}),u.jsx("span",{children:"Reasoning"})]}),u.jsx("div",{className:`cuadra-overflow-hidden cuadra-transition-all cuadra-duration-200 cuadra-ease-out ${r?"cuadra-max-h-[2000px] cuadra-opacity-100":"cuadra-max-h-0 cuadra-opacity-0"}`,children:u.jsx("div",{className:"cuadra-pl-5 cuadra-pt-2 cuadra-text-sm cuadra-text-muted-foreground cuadra-leading-relaxed font-brand",children:u.jsx(at,{content:e})})})]}):null}function so(){return u.jsxs("div",{className:"cuadra-flex cuadra-items-center cuadra-gap-2 cuadra-text-muted-foreground cuadra-text-sm font-brand cuadra-py-2",children:[u.jsxs("div",{className:"cuadra-flex cuadra-items-center cuadra-gap-1",children:[u.jsx("span",{className:"cuadra-inline-block cuadra-w-1.5 cuadra-h-1.5 cuadra-bg-current cuadra-rounded-full cuadra-animate-bounce",style:{animationDelay:"0ms"}}),u.jsx("span",{className:"cuadra-inline-block cuadra-w-1.5 cuadra-h-1.5 cuadra-bg-current cuadra-rounded-full cuadra-animate-bounce",style:{animationDelay:"150ms"}}),u.jsx("span",{className:"cuadra-inline-block cuadra-w-1.5 cuadra-h-1.5 cuadra-bg-current cuadra-rounded-full cuadra-animate-bounce",style:{animationDelay:"300ms"}})]}),u.jsx("span",{children:"Thinking..."})]})}function co(){const e=T.useAssistantState(({message:n})=>n?.status?.type==="running"),r=T.useAssistantState(({message:n})=>{const c=n?.content;return!c||!Array.isArray(c)?!1:c.some(s=>!!(s.type==="text"&&s.text&&s.text.length>0||s.type==="reasoning"&&s.text&&s.text.length>0))}),t=x.useRef(!1),[a,i]=x.useState(null);x.useEffect(()=>{if(e&&r&&!t.current){const n=Z.getCurrentMessageId();n&&(t.current=!0,i(n))}},[e,r]);const o=x.useSyncExternalStore(n=>Z.subscribe(n),()=>{if(a){const n=Z.getForMessage(a);return n.sources?.length?n.sources:null}if(e&&r){const n=Z.getCurrentMessageId();if(n){const c=Z.getForMessage(n);return c.sources?.length?c.sources:null}}return null},()=>null);return u.jsx(T.MessagePrimitive.Root,{className:"cuadra-relative cuadra-grid cuadra-w-full cuadra-grid-cols-[auto_auto_1fr] cuadra-grid-rows-[auto_1fr] cuadra-py-3",children:u.jsxs("div",{className:"cuadra-text-foreground cuadra-col-span-2 cuadra-col-start-2 cuadra-row-start-1 cuadra-my-1.5 cuadra-max-w-[90%] cuadra-break-words cuadra-leading-7 font-brand",style:{maxWidth:"90%",marginTop:"0.375rem",marginBottom:"0.375rem"},children:[u.jsx(T.MessagePrimitive.Parts,{components:{Text:({text:n})=>u.jsx(at,{content:n||""}),Reasoning:({text:n})=>u.jsx(oo,{text:n||""})}}),e&&!r&&u.jsx(so,{}),o&&o.length>0&&u.jsx(dr,{sources:o})]})})}const fr=({className:e="",theme:r="system"})=>{const t=()=>{if(typeof window>"u")return"light";if(r==="system"){const n=localStorage.getItem("theme");return n||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")}return r},[a,i]=x.useState(t);x.useEffect(()=>{r!=="system"&&i(r)},[r]),x.useEffect(()=>{const n=document.documentElement;n.classList.remove("light","dark"),n.classList.add(a),r==="system"&&localStorage.setItem("theme",a)},[a,r]);const o=()=>{r==="system"&&i(n=>n==="light"?"dark":"light")};return u.jsx("button",{type:"button","aria-label":"Toggle theme",onClick:o,disabled:r!=="system",className:`cuadra-flex cuadra-items-center cuadra-justify-center cuadra-h-8 cuadra-w-8 cuadra-rounded-full cuadra-bg-muted hover:cuadra-bg-muted/80 cuadra-transition-colors disabled:cuadra-opacity-50 disabled:cuadra-cursor-not-allowed ${e}`,children:u.jsx(zr,{className:`cuadra-h-4 cuadra-w-4 cuadra-transition-colors ${a==="dark"?"cuadra-text-primary":"cuadra-text-gray-400"}`})})};function uo({onThreadSelect:e}){const r=T.useThreadListItem(),t=T.useThread(b=>b.threadId),[a,i]=x.useState(null),o=r?.id===t,n=a===r?.id,[c,s]=x.useState(!1),[d,f]=x.useState(r?.title||""),[l,p]=x.useState(!1),[g,h]=x.useState(!1),y=async()=>{if(!r?.remoteId||!d||d===r.title){s(!1);return}try{h(!0);const b=window.__cuadraThreadListAdapter;b&&typeof b.rename=="function"&&await b.rename(r.remoteId,d),s(!1),p(!1)}catch{s(!1),p(!1)}finally{h(!1)}};return x.useEffect(()=>{r?.title&&!c&&f(r.title)},[r?.title,c]),r?u.jsxs(T.ThreadListItemPrimitive.Root,{className:`group cuadra-relative cuadra-flex cuadra-items-center cuadra-rounded-lg cuadra-transition-colors cuadra-cursor-pointer cuadra-border cuadra-mb-2 ${o?"cuadra-bg-muted cuadra-border-border":"cuadra-border-transparent hover:cuadra-bg-muted hover:cuadra-border-border"}`,style:{marginBottom:"0.5rem"},onMouseEnter:()=>i(r.id),onMouseLeave:()=>i(null),children:[u.jsx(T.ThreadListItemPrimitive.Trigger,{className:"cuadra-p-3 cuadra-flex-1 cuadra-flex cuadra-items-center cuadra-min-w-0 cuadra-cursor-pointer",onClick:()=>e?.(),children:u.jsx("div",{className:"cuadra-flex cuadra-flex-col cuadra-min-w-0 cuadra-flex-1 cuadra-items-start cuadra-text-left",children:c?u.jsx("input",{className:"cuadra-flex cuadra-w-full cuadra-rounded-md cuadra-border cuadra-border-input cuadra-bg-background cuadra-px-3 cuadra-py-2 cuadra-text-sm placeholder:cuadra-text-muted-foreground focus-visible:cuadra-outline-none disabled:cuadra-cursor-not-allowed disabled:cuadra-opacity-50 font-brand",value:d,onChange:b=>f(b.target.value),onKeyDown:b=>{b.key==="Enter"&&y(),b.key==="Escape"&&(s(!1),f(r.title||""))},disabled:g,autoFocus:!0,onClick:b=>b.stopPropagation()}):u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"cuadra-text-sm cuadra-font-normal cuadra-text-foreground cuadra-truncate font-brand",children:(r.title?.length||0)>60?`${r.title?.slice(0,60)}…`:r.title||"Chat"}),r.updatedAt&&u.jsx("span",{className:"cuadra-text-xs cuadra-text-muted-foreground cuadra-mt-1 font-brand",children:new Date(r.updatedAt).toLocaleDateString()})]})})}),u.jsx("div",{className:"cuadra-mr-2 cuadra-flex-shrink-0 cuadra-w-6 cuadra-h-6 cuadra-flex cuadra-items-center cuadra-justify-center",children:(n||o||l)&&u.jsxs("div",{className:"cuadra-relative",children:[u.jsx("button",{type:"button",className:"cuadra-p-1 cuadra-rounded hover:cuadra-bg-background/50 cuadra-transition-colors",onClick:b=>{b.stopPropagation(),p(!l)},"aria-label":"Thread options",children:u.jsx(Br,{className:"cuadra-h-4 cuadra-w-4 cuadra-text-muted-foreground"})}),l&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"cuadra-fixed cuadra-inset-0 cuadra-z-40",onClick:()=>p(!1)}),u.jsx("div",{className:"cuadra-absolute cuadra-right-0 cuadra-top-8 cuadra-z-50 cuadra-bg-background cuadra-border cuadra-border-border cuadra-rounded-lg cuadra-shadow-lg cuadra-min-w-[120px] cuadra-overflow-hidden",children:c?u.jsx("button",{type:"button",className:"cuadra-w-full cuadra-px-3 cuadra-py-2 cuadra-text-sm cuadra-text-left hover:cuadra-bg-muted cuadra-transition-colors font-brand",onClick:b=>{b.stopPropagation(),y()},disabled:g,children:"Save"}):u.jsxs(u.Fragment,{children:[u.jsx("button",{type:"button",className:"cuadra-w-full cuadra-px-3 cuadra-py-2 cuadra-text-sm cuadra-text-left hover:cuadra-bg-muted cuadra-transition-colors font-brand",onClick:b=>{b.stopPropagation(),s(!0),f(r.title||""),p(!1)},children:"Rename"}),u.jsx("div",{className:"cuadra-border-t cuadra-border-border"}),u.jsx(T.ThreadListItemPrimitive.Delete,{asChild:!0,children:u.jsx("button",{type:"button",className:"cuadra-w-full cuadra-px-3 cuadra-py-2 cuadra-text-sm cuadra-text-left cuadra-text-destructive hover:cuadra-bg-muted cuadra-transition-colors font-brand",onClick:b=>{b.stopPropagation(),p(!1)},children:"Delete"})})]})})]})]})})]}):null}function It({onThreadSelect:e,showThemeToggle:r,theme:t,onLogout:a,safeArea:i=!1,orgName:o,primaryColor:n}){return u.jsxs(T.ThreadListPrimitive.Root,{className:"!cuadra-border-r cuadra-border-border cuadra-flex cuadra-flex-col cuadra-bg-background cuadra-transition-all cuadra-duration-300 cuadra-ease-in-out cuadra-h-full cuadra-w-80",style:{borderRightWidth:"1px"},children:[u.jsxs("div",{className:"cuadra-border-b cuadra-border-border cuadra-flex cuadra-items-center cuadra-justify-between cuadra-transition-all cuadra-duration-300 cuadra-min-h-16 cuadra-px-4 cuadra-py-4",style:i?{paddingTop:"calc(env(safe-area-inset-top) + 1rem)",paddingLeft:"calc(env(safe-area-inset-left) + 0.5rem)"}:void 0,children:[o?u.jsxs("div",{className:"cuadra-flex cuadra-items-center cuadra-gap-2 cuadra-flex-1 cuadra-min-w-0",children:[u.jsx("div",{className:"cuadra-w-8 cuadra-h-8 cuadra-rounded-full cuadra-flex cuadra-items-center cuadra-justify-center cuadra-text-white cuadra-font-bold cuadra-text-sm cuadra-flex-shrink-0",style:{backgroundColor:n||"hsl(var(--primary))"},children:o.charAt(0).toUpperCase()}),u.jsx("span",{className:"cuadra-font-medium cuadra-text-sm cuadra-text-foreground cuadra-truncate font-brand",children:o})]}):u.jsx("div",{className:"cuadra-flex-1"}),u.jsx("button",{type:"button",onClick:e,className:"cuadra-flex md:cuadra-hidden cuadra-items-center cuadra-justify-center cuadra-h-8 cuadra-w-8 cuadra-rounded-full cuadra-bg-muted hover:cuadra-bg-muted/80 cuadra-transition-colors cuadra-flex-shrink-0","aria-label":"Close",children:u.jsx(Ye,{className:"cuadra-h-4 cuadra-w-4 cuadra-text-foreground"})})]}),u.jsxs("div",{className:"cuadra-flex-1 cuadra-overflow-y-auto cuadra-p-2 cuadra-pl-4 scrollbar-thin",style:i?{paddingLeft:"calc(env(safe-area-inset-left) + 1rem)"}:void 0,children:[u.jsx(T.ThreadListPrimitive.New,{className:"group cuadra-relative cuadra-flex cuadra-items-center cuadra-gap-3 cuadra-p-3 cuadra-rounded-lg cuadra-cursor-pointer cuadra-transition-colors cuadra-border cuadra-border-transparent hover:cuadra-bg-muted hover:cuadra-border-border",onClick:()=>e?.(),children:u.jsx("div",{className:"cuadra-flex-1 cuadra-min-w-0",children:u.jsxs("div",{className:"cuadra-flex cuadra-items-center cuadra-gap-2",children:[u.jsx(ta,{className:"cuadra-h-4 cuadra-w-4 cuadra-text-muted-foreground"}),u.jsx("h4",{className:"cuadra-text-sm cuadra-font-normal cuadra-text-foreground font-brand",children:"New Chat"})]})})}),u.jsx("div",{className:"cuadra-my-2 cuadra-border-t cuadra-border-border"}),u.jsx(T.ThreadListPrimitive.Items,{components:{ThreadListItem:c=>u.jsx(uo,{...c,onThreadSelect:e})}})]}),(r||a)&&u.jsxs("div",{className:"cuadra-border-t cuadra-border-border cuadra-flex md:cuadra-hidden cuadra-items-center cuadra-justify-between cuadra-px-4 cuadra-py-4",style:i?{paddingBottom:"calc(env(safe-area-inset-bottom) + 0.5rem)",paddingLeft:"calc(env(safe-area-inset-left) + 0.5rem)"}:void 0,children:[a&&u.jsx("button",{type:"button",onClick:a,className:"cuadra-flex cuadra-items-center cuadra-justify-center cuadra-h-8 cuadra-w-8 cuadra-rounded-full cuadra-bg-muted hover:cuadra-bg-muted/80 cuadra-transition-colors","aria-label":"Logout",children:u.jsx(Gr,{className:"cuadra-h-4 cuadra-w-4 cuadra-text-foreground"})}),r&&u.jsx(fr,{theme:t})]})]})}const lo=`
20
+ `))}function s(g,h,y,b){const w=y.enter("tableCell"),k=y.enter("phrasing"),C=y.containerPhrasing(g,{...b,before:o,after:o});return k(),w(),C}function d(g,h){return pn(g,{align:h,alignDelimiters:a,padding:t,stringLength:i})}function f(g,h,y){const b=g.children;let w=-1;const k=[],C=h.enter("table");for(;++w<b.length;)k[w]=l(b[w],h,y);return C(),k}function l(g,h,y){const b=g.children;let w=-1;const k=[],C=h.enter("tableRow");for(;++w<b.length;)k[w]=s(b[w],g,h,y);return C(),k}function p(g,h,y){let b=rr.inlineCode(g,h,y);return y.stack.includes("tableCell")&&(b=b.replace(/\|/g,"\\$&")),b}}function ii(){return{exit:{taskListCheckValueChecked:jt,taskListCheckValueUnchecked:jt,paragraph:si}}}function oi(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:ci}}}function jt(e){const r=this.stack[this.stack.length-2];r.type,r.checked=e.type==="taskListCheckValueChecked"}function si(e){const r=this.stack[this.stack.length-2];if(r&&r.type==="listItem"&&typeof r.checked=="boolean"){const t=this.stack[this.stack.length-1];t.type;const a=t.children[0];if(a&&a.type==="text"){const i=r.children;let o=-1,n;for(;++o<i.length;){const c=i[o];if(c.type==="paragraph"){n=c;break}}n===t&&(a.value=a.value.slice(1),a.value.length===0?t.children.shift():t.position&&a.position&&typeof a.position.start.offset=="number"&&(a.position.start.column++,a.position.start.offset++,t.position.start=Object.assign({},a.position.start)))}}this.exit(e)}function ci(e,r,t,a){const i=e.children[0],o=typeof e.checked=="boolean"&&i&&i.type==="paragraph",n="["+(e.checked?"x":" ")+"] ",c=t.createTracker(a);o&&c.move(n);let s=rr.listItem(e,r,t,{...a,...c.current()});return o&&(s=s.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,d)),s;function d(f){return f+n}}function ui(){return[Fa(),nn(),un(),Zn(),ii()]}function li(e){return{extensions:[za(),on(e),ln(),ni(e),oi()]}}function Se(e,r,t,a){const i=e.length;let o=0,n;if(r<0?r=-r>i?0:i+r:r=r>i?i:r,t=t>0?t:0,a.length<1e4)n=Array.from(a),n.unshift(r,t),e.splice(...n);else for(t&&e.splice(r,t);o<a.length;)n=a.slice(o,o+1e4),n.unshift(r,0),e.splice(...n),o+=1e4,r+=1e4}const Tt={}.hasOwnProperty;function di(e){const r={};let t=-1;for(;++t<e.length;)fi(r,e[t]);return r}function fi(e,r){let t;for(t in r){const i=(Tt.call(e,t)?e[t]:void 0)||(e[t]={}),o=r[t];let n;if(o)for(n in o){Tt.call(i,n)||(i[n]=[]);const c=o[n];hi(i[n],Array.isArray(c)?c:c?[c]:[])}}}function hi(e,r){let t=-1;const a=[];for(;++t<r.length;)(r[t].add==="after"?e:a).push(r[t]);Se(e,0,0,a)}const mi={tokenize:wi,partial:!0},ar={tokenize:ki,partial:!0},nr={tokenize:Ci,partial:!0},ir={tokenize:vi,partial:!0},pi={tokenize:ji,partial:!0},or={name:"wwwAutolink",tokenize:bi,previous:cr},sr={name:"protocolAutolink",tokenize:yi,previous:ur},te={name:"emailAutolink",tokenize:xi,previous:lr},K={};function gi(){return{text:K}}let ne=48;for(;ne<123;)K[ne]=te,ne++,ne===58?ne=65:ne===91&&(ne=97);K[43]=te;K[45]=te;K[46]=te;K[95]=te;K[72]=[te,sr];K[104]=[te,sr];K[87]=[te,or];K[119]=[te,or];function xi(e,r,t){const a=this;let i,o;return n;function n(l){return!Ge(l)||!lr.call(a,a.previous)||rt(a.events)?t(l):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),c(l))}function c(l){return Ge(l)?(e.consume(l),c):l===64?(e.consume(l),s):t(l)}function s(l){return l===46?e.check(pi,f,d)(l):l===45||l===95||Je(l)?(o=!0,e.consume(l),s):f(l)}function d(l){return e.consume(l),i=!0,s}function f(l){return o&&i&&we(a.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),r(l)):t(l)}}function bi(e,r,t){const a=this;return i;function i(n){return n!==87&&n!==119||!cr.call(a,a.previous)||rt(a.events)?t(n):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(mi,e.attempt(ar,e.attempt(nr,o),t),t)(n))}function o(n){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),r(n)}}function yi(e,r,t){const a=this;let i="",o=!1;return n;function n(l){return(l===72||l===104)&&ur.call(a,a.previous)&&!rt(a.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),i+=String.fromCodePoint(l),e.consume(l),c):t(l)}function c(l){if(we(l)&&i.length<5)return i+=String.fromCodePoint(l),e.consume(l),c;if(l===58){const p=i.toLowerCase();if(p==="http"||p==="https")return e.consume(l),s}return t(l)}function s(l){return l===47?(e.consume(l),o?d:(o=!0,s)):t(l)}function d(l){return l===null||va(l)||q(l)||ie(l)||Le(l)?t(l):e.attempt(ar,e.attempt(nr,f),t)(l)}function f(l){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),r(l)}}function wi(e,r,t){let a=0;return i;function i(n){return(n===87||n===119)&&a<3?(a++,e.consume(n),i):n===46&&a===3?(e.consume(n),o):t(n)}function o(n){return n===null?t(n):r(n)}}function ki(e,r,t){let a,i,o;return n;function n(d){return d===46||d===95?e.check(ir,s,c)(d):d===null||q(d)||ie(d)||d!==45&&Le(d)?s(d):(o=!0,e.consume(d),n)}function c(d){return d===95?a=!0:(i=a,a=void 0),e.consume(d),n}function s(d){return i||a||!o?t(d):r(d)}}function Ci(e,r){let t=0,a=0;return i;function i(n){return n===40?(t++,e.consume(n),i):n===41&&a<t?o(n):n===33||n===34||n===38||n===39||n===41||n===42||n===44||n===46||n===58||n===59||n===60||n===63||n===93||n===95||n===126?e.check(ir,r,o)(n):n===null||q(n)||ie(n)?r(n):(e.consume(n),i)}function o(n){return n===41&&a++,e.consume(n),i}}function vi(e,r,t){return a;function a(c){return c===33||c===34||c===39||c===41||c===42||c===44||c===46||c===58||c===59||c===63||c===95||c===126?(e.consume(c),a):c===38?(e.consume(c),o):c===93?(e.consume(c),i):c===60||c===null||q(c)||ie(c)?r(c):t(c)}function i(c){return c===null||c===40||c===91||q(c)||ie(c)?r(c):a(c)}function o(c){return we(c)?n(c):t(c)}function n(c){return c===59?(e.consume(c),a):we(c)?(e.consume(c),n):t(c)}}function ji(e,r,t){return a;function a(o){return e.consume(o),i}function i(o){return Je(o)?t(o):r(o)}}function cr(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||q(e)}function ur(e){return!we(e)}function lr(e){return!(e===47||Ge(e))}function Ge(e){return e===43||e===45||e===46||e===95||Je(e)}function rt(e){let r=e.length,t=!1;for(;r--;){const a=e[r][1];if((a.type==="labelLink"||a.type==="labelImage")&&!a._balanced){t=!0;break}if(a._gfmAutolinkLiteralWalkedInto){t=!1;break}}return e.length>0&&!t&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),t}function Ti(e,r,t){const a=[];let i=-1;for(;++i<e.length;){const o=e[i].resolveAll;o&&!a.includes(o)&&(r=o(r,t),a.push(o))}return r}function ee(e,r,t,a){const i=a?a-1:Number.POSITIVE_INFINITY;let o=0;return n;function n(s){return J(s)?(e.enter(t),c(s)):r(s)}function c(s){return J(s)&&o++<i?(e.consume(s),c):(e.exit(t),r(s))}}const Mi={partial:!0,tokenize:Ai};function Ai(e,r,t){return a;function a(o){return J(o)?ee(e,i,"linePrefix")(o):i(o)}function i(o){return o===null||de(o)?r(o):t(o)}}const Ii={tokenize:_i,partial:!0};function Si(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Li,continuation:{tokenize:Ri},exit:Di}},text:{91:{name:"gfmFootnoteCall",tokenize:Pi},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:Ni,resolveTo:Ei}}}}function Ni(e,r,t){const a=this;let i=a.events.length;const o=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let n;for(;i--;){const s=a.events[i][1];if(s.type==="labelImage"){n=s;break}if(s.type==="gfmFootnoteCall"||s.type==="labelLink"||s.type==="label"||s.type==="image"||s.type==="link")break}return c;function c(s){if(!n||!n._balanced)return t(s);const d=Ce(a.sliceSerialize({start:n.end,end:a.now()}));return d.codePointAt(0)!==94||!o.includes(d.slice(1))?t(s):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(s),e.exit("gfmFootnoteCallLabelMarker"),r(s))}}function Ei(e,r){let t=e.length;for(;t--;)if(e[t][1].type==="labelImage"&&e[t][0]==="enter"){e[t][1];break}e[t+1][1].type="data",e[t+3][1].type="gfmFootnoteCallLabelMarker";const a={type:"gfmFootnoteCall",start:Object.assign({},e[t+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},e[t+3][1].end),end:Object.assign({},e[t+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const o={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},n={type:"chunkString",contentType:"string",start:Object.assign({},o.start),end:Object.assign({},o.end)},c=[e[t+1],e[t+2],["enter",a,r],e[t+3],e[t+4],["enter",i,r],["exit",i,r],["enter",o,r],["enter",n,r],["exit",n,r],["exit",o,r],e[e.length-2],e[e.length-1],["exit",a,r]];return e.splice(t,e.length-t+1,...c),e}function Pi(e,r,t){const a=this,i=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let o=0,n;return c;function c(l){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),s}function s(l){return l!==94?t(l):(e.enter("gfmFootnoteCallMarker"),e.consume(l),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",d)}function d(l){if(o>999||l===93&&!n||l===null||l===91||q(l))return t(l);if(l===93){e.exit("chunkString");const p=e.exit("gfmFootnoteCallString");return i.includes(Ce(a.sliceSerialize(p)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(l),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),r):t(l)}return q(l)||(n=!0),o++,e.consume(l),l===92?f:d}function f(l){return l===91||l===92||l===93?(e.consume(l),o++,d):d(l)}}function Li(e,r,t){const a=this,i=a.parser.gfmFootnotes||(a.parser.gfmFootnotes=[]);let o,n=0,c;return s;function s(h){return e.enter("gfmFootnoteDefinition")._container=!0,e.enter("gfmFootnoteDefinitionLabel"),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(h),e.exit("gfmFootnoteDefinitionLabelMarker"),d}function d(h){return h===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(h),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",f):t(h)}function f(h){if(n>999||h===93&&!c||h===null||h===91||q(h))return t(h);if(h===93){e.exit("chunkString");const y=e.exit("gfmFootnoteDefinitionLabelString");return o=Ce(a.sliceSerialize(y)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(h),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),p}return q(h)||(c=!0),n++,e.consume(h),h===92?l:f}function l(h){return h===91||h===92||h===93?(e.consume(h),n++,f):f(h)}function p(h){return h===58?(e.enter("definitionMarker"),e.consume(h),e.exit("definitionMarker"),i.includes(o)||i.push(o),ee(e,g,"gfmFootnoteDefinitionWhitespace")):t(h)}function g(h){return r(h)}}function Ri(e,r,t){return e.check(Mi,r,e.attempt(Ii,r,t))}function Di(e){e.exit("gfmFootnoteDefinition")}function _i(e,r,t){const a=this;return ee(e,i,"gfmFootnoteDefinitionIndent",5);function i(o){const n=a.events[a.events.length-1];return n&&n[1].type==="gfmFootnoteDefinitionIndent"&&n[2].sliceSerialize(n[1],!0).length===4?r(o):t(o)}}function Fi(e){let t=(e||{}).singleTilde;const a={name:"strikethrough",tokenize:o,resolveAll:i};return t==null&&(t=!0),{text:{126:a},insideSpan:{null:[a]},attentionMarkers:{null:[126]}};function i(n,c){let s=-1;for(;++s<n.length;)if(n[s][0]==="enter"&&n[s][1].type==="strikethroughSequenceTemporary"&&n[s][1]._close){let d=s;for(;d--;)if(n[d][0]==="exit"&&n[d][1].type==="strikethroughSequenceTemporary"&&n[d][1]._open&&n[s][1].end.offset-n[s][1].start.offset===n[d][1].end.offset-n[d][1].start.offset){n[s][1].type="strikethroughSequence",n[d][1].type="strikethroughSequence";const f={type:"strikethrough",start:Object.assign({},n[d][1].start),end:Object.assign({},n[s][1].end)},l={type:"strikethroughText",start:Object.assign({},n[d][1].end),end:Object.assign({},n[s][1].start)},p=[["enter",f,c],["enter",n[d][1],c],["exit",n[d][1],c],["enter",l,c]],g=c.parser.constructs.insideSpan.null;g&&Se(p,p.length,0,Ti(g,n.slice(d+1,s),c)),Se(p,p.length,0,[["exit",l,c],["enter",n[s][1],c],["exit",n[s][1],c],["exit",f,c]]),Se(n,d-1,s-d+3,p),s=d+p.length-2;break}}for(s=-1;++s<n.length;)n[s][1].type==="strikethroughSequenceTemporary"&&(n[s][1].type="data");return n}function o(n,c,s){const d=this.previous,f=this.events;let l=0;return p;function p(h){return d===126&&f[f.length-1][1].type!=="characterEscape"?s(h):(n.enter("strikethroughSequenceTemporary"),g(h))}function g(h){const y=Ee(d);if(h===126)return l>1?s(h):(n.consume(h),l++,g);if(l<2&&!t)return s(h);const b=n.exit("strikethroughSequenceTemporary"),w=Ee(h);return b._open=!w||w===2&&!!y,b._close=!y||y===2&&!!w,c(h)}}}class zi{constructor(){this.map=[]}add(r,t,a){Ui(this,r,t,a)}consume(r){if(this.map.sort(function(o,n){return o[0]-n[0]}),this.map.length===0)return;let t=this.map.length;const a=[];for(;t>0;)t-=1,a.push(r.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),r.length=this.map[t][0];a.push(r.slice()),r.length=0;let i=a.pop();for(;i;){for(const o of i)r.push(o);i=a.pop()}this.map.length=0}}function Ui(e,r,t,a){let i=0;if(!(t===0&&a.length===0)){for(;i<e.map.length;){if(e.map[i][0]===r){e.map[i][1]+=t,e.map[i][2].push(...a);return}i+=1}e.map.push([r,t,a])}}function $i(e,r){let t=!1;const a=[];for(;r<e.length;){const i=e[r];if(t){if(i[0]==="enter")i[1].type==="tableContent"&&a.push(e[r+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(e[r-1][1].type==="tableDelimiterMarker"){const o=a.length-1;a[o]=a[o]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(t=!0);r+=1}return a}function Oi(){return{flow:{null:{name:"table",tokenize:Bi,resolveAll:Wi}}}}function Bi(e,r,t){const a=this;let i=0,o=0,n;return c;function c(m){let $=a.events.length-1;for(;$>-1;){const H=a.events[$][1].type;if(H==="lineEnding"||H==="linePrefix")$--;else break}const z=$>-1?a.events[$][1].type:null,V=z==="tableHead"||z==="tableRow"?I:s;return V===I&&a.parser.lazy[a.now().line]?t(m):V(m)}function s(m){return e.enter("tableHead"),e.enter("tableRow"),d(m)}function d(m){return m===124||(n=!0,o+=1),f(m)}function f(m){return m===null?t(m):de(m)?o>1?(o=0,a.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),g):t(m):J(m)?ee(e,f,"whitespace")(m):(o+=1,n&&(n=!1,i+=1),m===124?(e.enter("tableCellDivider"),e.consume(m),e.exit("tableCellDivider"),n=!0,f):(e.enter("data"),l(m)))}function l(m){return m===null||m===124||q(m)?(e.exit("data"),f(m)):(e.consume(m),m===92?p:l)}function p(m){return m===92||m===124?(e.consume(m),l):l(m)}function g(m){return a.interrupt=!1,a.parser.lazy[a.now().line]?t(m):(e.enter("tableDelimiterRow"),n=!1,J(m)?ee(e,h,"linePrefix",a.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(m):h(m))}function h(m){return m===45||m===58?b(m):m===124?(n=!0,e.enter("tableCellDivider"),e.consume(m),e.exit("tableCellDivider"),y):P(m)}function y(m){return J(m)?ee(e,b,"whitespace")(m):b(m)}function b(m){return m===58?(o+=1,n=!0,e.enter("tableDelimiterMarker"),e.consume(m),e.exit("tableDelimiterMarker"),w):m===45?(o+=1,w(m)):m===null||de(m)?E(m):P(m)}function w(m){return m===45?(e.enter("tableDelimiterFiller"),k(m)):P(m)}function k(m){return m===45?(e.consume(m),k):m===58?(n=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(m),e.exit("tableDelimiterMarker"),C):(e.exit("tableDelimiterFiller"),C(m))}function C(m){return J(m)?ee(e,E,"whitespace")(m):E(m)}function E(m){return m===124?h(m):m===null||de(m)?!n||i!==o?P(m):(e.exit("tableDelimiterRow"),e.exit("tableHead"),r(m)):P(m)}function P(m){return t(m)}function I(m){return e.enter("tableRow"),M(m)}function M(m){return m===124?(e.enter("tableCellDivider"),e.consume(m),e.exit("tableCellDivider"),M):m===null||de(m)?(e.exit("tableRow"),r(m)):J(m)?ee(e,M,"whitespace")(m):(e.enter("data"),D(m))}function D(m){return m===null||m===124||q(m)?(e.exit("data"),M(m)):(e.consume(m),m===92?A:D)}function A(m){return m===92||m===124?(e.consume(m),D):D(m)}}function Wi(e,r){let t=-1,a=!0,i=0,o=[0,0,0,0],n=[0,0,0,0],c=!1,s=0,d,f,l;const p=new zi;for(;++t<e.length;){const g=e[t],h=g[1];g[0]==="enter"?h.type==="tableHead"?(c=!1,s!==0&&(Mt(p,r,s,d,f),f=void 0,s=0),d={type:"table",start:Object.assign({},h.start),end:Object.assign({},h.end)},p.add(t,0,[["enter",d,r]])):h.type==="tableRow"||h.type==="tableDelimiterRow"?(a=!0,l=void 0,o=[0,0,0,0],n=[0,t+1,0,0],c&&(c=!1,f={type:"tableBody",start:Object.assign({},h.start),end:Object.assign({},h.end)},p.add(t,0,[["enter",f,r]])),i=h.type==="tableDelimiterRow"?2:f?3:1):i&&(h.type==="data"||h.type==="tableDelimiterMarker"||h.type==="tableDelimiterFiller")?(a=!1,n[2]===0&&(o[1]!==0&&(n[0]=n[1],l=Ie(p,r,o,i,void 0,l),o=[0,0,0,0]),n[2]=t)):h.type==="tableCellDivider"&&(a?a=!1:(o[1]!==0&&(n[0]=n[1],l=Ie(p,r,o,i,void 0,l)),o=n,n=[o[1],t,0,0])):h.type==="tableHead"?(c=!0,s=t):h.type==="tableRow"||h.type==="tableDelimiterRow"?(s=t,o[1]!==0?(n[0]=n[1],l=Ie(p,r,o,i,t,l)):n[1]!==0&&(l=Ie(p,r,n,i,t,l)),i=0):i&&(h.type==="data"||h.type==="tableDelimiterMarker"||h.type==="tableDelimiterFiller")&&(n[3]=t)}for(s!==0&&Mt(p,r,s,d,f),p.consume(r.events),t=-1;++t<r.events.length;){const g=r.events[t];g[0]==="enter"&&g[1].type==="table"&&(g[1]._align=$i(r.events,t))}return e}function Ie(e,r,t,a,i,o){const n=a===1?"tableHeader":a===2?"tableDelimiter":"tableData",c="tableContent";t[0]!==0&&(o.end=Object.assign({},le(r.events,t[0])),e.add(t[0],0,[["exit",o,r]]));const s=le(r.events,t[1]);if(o={type:n,start:Object.assign({},s),end:Object.assign({},s)},e.add(t[1],0,[["enter",o,r]]),t[2]!==0){const d=le(r.events,t[2]),f=le(r.events,t[3]),l={type:c,start:Object.assign({},d),end:Object.assign({},f)};if(e.add(t[2],0,[["enter",l,r]]),a!==2){const p=r.events[t[2]],g=r.events[t[3]];if(p[1].end=Object.assign({},g[1].end),p[1].type="chunkText",p[1].contentType="text",t[3]>t[2]+1){const h=t[2]+1,y=t[3]-t[2]-1;e.add(h,y,[])}}e.add(t[3]+1,0,[["exit",l,r]])}return i!==void 0&&(o.end=Object.assign({},le(r.events,i)),e.add(i,0,[["exit",o,r]]),o=void 0),o}function Mt(e,r,t,a,i){const o=[],n=le(r.events,t);i&&(i.end=Object.assign({},n),o.push(["exit",i,r])),a.end=Object.assign({},n),o.push(["exit",a,r]),e.add(t+1,0,o)}function le(e,r){const t=e[r],a=t[0]==="enter"?"start":"end";return t[1][a]}const qi={name:"tasklistCheck",tokenize:Vi};function Hi(){return{text:{91:qi}}}function Vi(e,r,t){const a=this;return i;function i(s){return a.previous!==null||!a._gfmTasklistFirstContentOfListItem?t(s):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(s),e.exit("taskListCheckMarker"),o)}function o(s){return q(s)?(e.enter("taskListCheckValueUnchecked"),e.consume(s),e.exit("taskListCheckValueUnchecked"),n):s===88||s===120?(e.enter("taskListCheckValueChecked"),e.consume(s),e.exit("taskListCheckValueChecked"),n):t(s)}function n(s){return s===93?(e.enter("taskListCheckMarker"),e.consume(s),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),c):t(s)}function c(s){return de(s)?r(s):J(s)?e.check({tokenize:Xi},r,t)(s):t(s)}}function Xi(e,r,t){return ee(e,a,"whitespace");function a(i){return i===null?t(i):r(i)}}function Ki(e){return di([gi(),Si(),Fi(e),Oi(),Hi()])}const Qi={};function Gi(e){const r=this,t=e||Qi,a=r.data(),i=a.micromarkExtensions||(a.micromarkExtensions=[]),o=a.fromMarkdownExtensions||(a.fromMarkdownExtensions=[]),n=a.toMarkdownExtensions||(a.toMarkdownExtensions=[]);i.push(Ki(t)),o.push(ui()),n.push(li(t))}function U(...e){return e.filter(Boolean).join(" ")}const Yi=({content:e})=>u.jsx(Ve.MarkdownTextPrimitive,{remarkPlugins:[Gi],className:"cuadra-aui-md",components:eo,children:e}),at=x.memo(Yi),Zi=({language:e,code:r})=>{const{isCopied:t,copyToClipboard:a}=Ji(),i=()=>{!r||t||a(r)};return u.jsxs("div",{className:"cuadra-flex cuadra-items-center cuadra-justify-between cuadra-gap-4 cuadra-mt-4 cuadra-rounded-t-lg cuadra-bg-muted/50 cuadra-border-b cuadra-border-border cuadra-px-4 cuadra-py-2 cuadra-text-sm cuadra-font-normal cuadra-text-foreground cuadra-font-brand",children:[u.jsx("span",{className:"cuadra-lowercase [&>span]:cuadra-text-xs cuadra-font-brand",children:e}),u.jsxs("button",{onClick:i,className:"cuadra-p-1 cuadra-rounded hover:cuadra-bg-muted cuadra-transition-colors","aria-label":"Copy code",children:[!t&&u.jsx($r,{className:"cuadra-h-4 cuadra-w-4"}),t&&u.jsx(Dr,{className:"cuadra-h-4 cuadra-w-4"})]})]})},Ji=({copiedDuration:e=3e3}={})=>{const[r,t]=x.useState(!1);return{isCopied:r,copyToClipboard:i=>{i&&navigator.clipboard.writeText(i).then(()=>{t(!0),setTimeout(()=>t(!1),e)})}}},eo=Ve.unstable_memoizeMarkdownComponents({h1:({className:e,...r})=>u.jsx("h1",{className:U("cuadra-mb-6 cuadra-scroll-m-20 cuadra-text-2xl cuadra-font-normal cuadra-tracking-tight last:cuadra-mb-0 font-brand",e),...r}),h2:({className:e,...r})=>u.jsx("h2",{className:U("cuadra-mb-4 cuadra-mt-6 cuadra-scroll-m-20 cuadra-text-xl cuadra-font-normal cuadra-tracking-tight first:cuadra-mt-0 last:cuadra-mb-0 font-brand",e),...r}),h3:({className:e,...r})=>u.jsx("h3",{className:U("cuadra-mb-3 cuadra-mt-5 cuadra-scroll-m-20 cuadra-text-lg cuadra-font-normal cuadra-tracking-tight first:cuadra-mt-0 last:cuadra-mb-0 font-brand",e),...r}),h4:({className:e,...r})=>u.jsx("h4",{className:U("cuadra-mb-4 cuadra-mt-6 cuadra-scroll-m-20 cuadra-text-xl cuadra-font-normal cuadra-tracking-tight first:cuadra-mt-0 last:cuadra-mb-0 font-brand",e),...r}),h5:({className:e,...r})=>u.jsx("h5",{className:U("cuadra-my-4 cuadra-text-lg cuadra-font-normal first:cuadra-mt-0 last:cuadra-mb-0 font-brand",e),...r}),h6:({className:e,...r})=>u.jsx("h6",{className:U("cuadra-my-4 cuadra-font-normal first:cuadra-mb-0 font-brand",e),...r}),p:({className:e,...r})=>u.jsx("p",{className:U("cuadra-mb-5 cuadra-mt-5 cuadra-leading-7 first:cuadra-mt-0 last:cuadra-mb-0 font-brand",e),...r}),a:({className:e,...r})=>u.jsx("a",{className:U("cuadra-text-primary cuadra-font-medium cuadra-underline cuadra-underline-offset-4 font-brand",e),...r}),blockquote:({className:e,...r})=>u.jsx("blockquote",{className:U("cuadra-border-l-2 cuadra-pl-6 cuadra-italic font-brand",e),...r}),ul:({className:e,...r})=>u.jsx("ul",{className:U("cuadra-my-5 cuadra-ml-6 cuadra-list-disc [&>li]:cuadra-mt-2 font-brand",e),...r}),ol:({className:e,...r})=>u.jsx("ol",{className:U("cuadra-my-5 cuadra-ml-6 cuadra-list-decimal [&>li]:cuadra-mt-2 font-brand",e),...r}),hr:({className:e,...r})=>u.jsx("hr",{className:U("cuadra-my-5 cuadra-border-b",e),...r}),table:({className:e,...r})=>u.jsx("table",{className:U("cuadra-my-5 cuadra-w-full cuadra-border-separate cuadra-border-spacing-0 cuadra-overflow-y-auto font-brand",e),...r}),th:({className:e,...r})=>u.jsx("th",{className:U("cuadra-bg-muted cuadra-px-4 cuadra-py-2 cuadra-text-left cuadra-font-normal first:cuadra-rounded-tl-lg last:cuadra-rounded-tr-lg [&[align=center]]:cuadra-text-center [&[align=right]]:cuadra-text-right font-brand",e),...r}),td:({className:e,...r})=>u.jsx("td",{className:U("cuadra-border-b cuadra-border-l cuadra-px-4 cuadra-py-2 cuadra-text-left last:cuadra-border-r [&[align=center]]:cuadra-text-center [&[align=right]]:cuadra-text-right font-brand",e),...r}),tr:({className:e,...r})=>u.jsx("tr",{className:U("cuadra-m-0 cuadra-border-b cuadra-p-0 first:cuadra-border-t [&:last-child>td:first-child]:cuadra-rounded-bl-lg [&:last-child>td:last-child]:cuadra-rounded-br-lg",e),...r}),sup:({className:e,...r})=>u.jsx("sup",{className:U("[&>a]:cuadra-text-xs [&>a]:cuadra-no-underline font-brand",e),...r}),pre:({className:e,...r})=>u.jsx("pre",{className:U("cuadra-overflow-x-auto cuadra-whitespace-pre-wrap cuadra-break-words cuadra-rounded-b-lg !cuadra-rounded-t-none cuadra-bg-muted cuadra-p-4 cuadra-text-foreground font-brand",e),...r}),code:function({className:r,...t}){const a=Ve.useIsMarkdownCodeBlock();return u.jsx("code",{className:U(!a&&"cuadra-bg-muted cuadra-rounded cuadra-border cuadra-font-normal font-brand",r),...t})},CodeHeader:Zi});function nt({className:e="",variant:r="default",...t}){const a="cuadra-inline-flex cuadra-items-center cuadra-rounded-md cuadra-px-3 cuadra-py-1.5 cuadra-text-xs cuadra-font-medium font-brand",i={default:"cuadra-border cuadra-border-border cuadra-bg-muted cuadra-text-muted-foreground",subtle:"cuadra-border cuadra-border-border/50 cuadra-bg-muted/50 cuadra-text-muted-foreground",outline:"cuadra-border cuadra-border-border cuadra-bg-background cuadra-text-foreground",ghost:"cuadra-text-muted-foreground"};return u.jsx("div",{className:`${a} ${i[r]||i.default} ${e}`,...t})}function to(e){const r=new Map;for(const t of e){const a=r.get(t.filename);(!a||t.score>a.score)&&r.set(t.filename,t)}return Array.from(r.values()).sort((t,a)=>a.score-t.score)}function dr({sources:e,maxVisible:r=3}){if(!e||e.length===0)return null;const t=to(e),a=t.slice(0,r),i=t.length-r;return u.jsxs("div",{className:"cuadra-mt-4 cuadra-pt-3 cuadra-border-t cuadra-border-border",children:[u.jsxs("div",{className:"cuadra-flex cuadra-items-center cuadra-gap-1.5 cuadra-mb-2.5",children:[u.jsx(Et,{className:"cuadra-h-3.5 cuadra-w-3.5 cuadra-text-muted-foreground"}),u.jsx("span",{className:"cuadra-text-xs cuadra-font-medium cuadra-text-muted-foreground font-brand",children:"Sources"})]}),u.jsxs("div",{className:"cuadra-flex cuadra-flex-wrap cuadra-gap-2",children:[a.map((o,n)=>u.jsx(ao,{source:o},o.sourceId||n)),i>0&&u.jsxs(nt,{variant:"subtle",children:["+",i," more"]})]})]})}function ro(e){switch(e.split(".").pop()?.toLowerCase()){case"csv":case"xlsx":case"xls":return qr;case"md":case"txt":return Xr;default:return Et}}function ao({source:e}){const{filename:r,score:t}=e,a=ro(r);return u.jsxs(nt,{className:"cuadra-gap-2 cuadra-cursor-default",title:t<1?`${Math.round(t*100)}% relevant`:void 0,children:[u.jsx(a,{className:"cuadra-h-3.5 cuadra-w-3.5 cuadra-shrink-0 cuadra-opacity-60"}),u.jsx("span",{className:"cuadra-truncate cuadra-max-w-[180px]",children:r}),t<1&&t>0&&u.jsxs("span",{className:"cuadra-opacity-50 cuadra-text-[10px] cuadra-tabular-nums",children:[Math.round(t*100),"%"]})]})}const At=x.forwardRef(function({welcomeTitle:r="Hi, how can I help you today?",welcomeSubtitle:t="Start exploring our platform and discover what you can build.",extraTopPadding:a,suggestions:i,inputPlaceholder:o="Type your message...",enableAttachments:n=!1,preMadeResponseDelay:c=1e3,streamingSpeed:s=50,safeArea:d=!1},f){const l=T.useThreadRuntime(),p=T.useAssistantApi(),[g,h]=x.useState(!1),[y,b]=x.useState(null),[w,k]=x.useState(!1),C=x.useCallback((M,D,A)=>{if(!w)try{const m=A?.streamingSpeed??s,$=A?.delay??c;_t(M,D,m,$),p.composer().setText(M),setTimeout(()=>{p.composer().send()},10)}catch{}},[w,s,c,p]),E=x.useCallback(M=>{try{p.composer().setText(M),setTimeout(()=>{p.composer().send()},10)}catch{}},[p]),P=x.useCallback(async M=>{if(!(w||!l))try{if(M.response){const D=M.responseDelay??c;await C(M.prompt,M.response,{delay:D,streamingSpeed:s})}else E(M.prompt)}catch{}},[l,w,c,s,C,E]),I=x.useCallback(()=>{try{const M=window.__cuadraThreadListRuntime;M?.switchToNewThread&&M.switchToNewThread()}catch{}},[]);return x.useImperativeHandle(f,()=>({sendMessage:E,sendPreMadeQA:C,clearChat:I}),[E,C,I]),x.useEffect(()=>{if(!l){h(!1);return}try{const M=l?.store;if(!M){h(!1);return}const D=M.subscribe?.(m=>{const $=m?.threadId,z=m?.messages||[],V=m?.isLoadingHistory||!1,H=z.length;$&&$!==y&&b($),h(V&&H===0)}),A=M.getState?.();if(A){const m=A?.threadId,$=A?.messages||[],z=A?.isLoadingHistory||!1,V=$.length;m&&m!==y&&b(m),h(z&&V===0)}return()=>{D&&D()}}catch{h(!1)}},[l,y]),u.jsxs(T.ThreadPrimitive.Root,{className:"cuadra-bg-inherit cuadra-flex cuadra-flex-col cuadra-w-full cuadra-h-full",children:[u.jsx(T.ThreadPrimitive.Viewport,{className:"cuadra-w-full cuadra-bg-inherit cuadra-px-4 cuadra-flex-1 cuadra-min-h-0 cuadra-overflow-y-auto cuadra-relative scrollbar-thin cuadra-pt-4",style:a?{paddingTop:a}:void 0,children:g?u.jsx("div",{className:"cuadra-absolute cuadra-inset-0 cuadra-flex cuadra-items-center cuadra-justify-center",children:u.jsxs("div",{className:"cuadra-flex cuadra-flex-col cuadra-items-center cuadra-gap-2",children:[u.jsx(Pt,{className:"cuadra-h-6 cuadra-w-6 cuadra-animate-spin cuadra-text-muted-foreground"}),u.jsx("p",{className:"cuadra-text-sm cuadra-text-muted-foreground font-brand",children:"Loading messages..."})]})}):u.jsxs(u.Fragment,{children:[u.jsx(T.ThreadPrimitive.Empty,{children:u.jsx(no,{title:r,subtitle:t,suggestions:i,onSuggestionClick:P,isProcessing:w})}),u.jsx(T.ThreadPrimitive.Messages,{components:{UserMessage:io,AssistantMessage:co}})]})}),u.jsxs("div",{className:"cuadra-w-full cuadra-mt-3 cuadra-border-t cuadra-border-border cuadra-pt-4",style:d?{paddingBottom:"env(safe-area-inset-bottom)"}:void 0,children:[n&&u.jsx(T.ComposerPrimitive.Attachments,{components:{Attachment:()=>{const M=T.useAssistantState(({attachment:D})=>D);return M?u.jsxs("div",{className:"cuadra-relative cuadra-inline-flex cuadra-items-center cuadra-gap-2 cuadra-mb-2 cuadra-px-2 cuadra-py-1 cuadra-rounded-md cuadra-bg-muted cuadra-border cuadra-border-border",children:[u.jsx("span",{className:"cuadra-text-xs cuadra-text-muted-foreground font-brand",children:M.name||"Attachment"}),u.jsx(T.AttachmentPrimitive.Remove,{asChild:!0,children:u.jsx("button",{type:"button",className:"cuadra-flex cuadra-items-center cuadra-justify-center cuadra-size-4 cuadra-rounded hover:cuadra-bg-background cuadra-transition-colors","aria-label":"Remove attachment",children:u.jsx(Ye,{className:"cuadra-h-3 cuadra-w-3 cuadra-text-muted-foreground"})})})]}):null}}}),u.jsxs(T.ComposerPrimitive.Root,{className:"cuadra-relative !cuadra-relative cuadra-flex-1 cuadra-w-full",children:[u.jsx(T.ComposerPrimitive.Input,{asChild:!0,children:u.jsx("textarea",{rows:3,placeholder:o,className:"cuadra-flex cuadra-min-h-[80px] cuadra-w-full cuadra-rounded-md cuadra-border cuadra-border-border cuadra-bg-background cuadra-px-3 cuadra-py-2 cuadra-text-base cuadra-text-foreground placeholder:cuadra-text-muted-foreground focus-visible:cuadra-outline-none disabled:cuadra-cursor-not-allowed disabled:cuadra-opacity-50 cuadra-resize-none font-brand",style:{paddingRight:n?"5rem":"3rem",fontSize:"1rem",borderWidth:"1px"}})}),n&&u.jsx(T.ComposerPrimitive.AddAttachment,{multiple:!0,asChild:!0,children:u.jsx("button",{type:"button",className:"!cuadra-absolute !cuadra-bottom-2 !cuadra-right-12 cuadra-size-8 cuadra-rounded-md hover:cuadra-bg-muted cuadra-transition-colors cuadra-flex cuadra-items-center cuadra-justify-center cuadra-border cuadra-border-border",style:{position:"absolute",bottom:"0.5rem",right:"3rem"},"aria-label":"Attach file",children:u.jsx(Lt,{className:"cuadra-h-4 cuadra-w-4 cuadra-text-muted-foreground",strokeWidth:1.5})})}),u.jsx(T.ComposerPrimitive.Send,{asChild:!0,children:u.jsx("button",{className:"!cuadra-absolute !cuadra-bottom-2 !cuadra-right-2 cuadra-size-8 cuadra-rounded-md cuadra-shadow-sm hover:cuadra-opacity-90 disabled:cuadra-opacity-50 disabled:cuadra-cursor-not-allowed cuadra-flex cuadra-items-center cuadra-justify-center",style:{position:"absolute",bottom:"0.5rem",right:"0.5rem",backgroundColor:"var(--cuadra-primary)",color:"hsl(var(--cuadra-primary-foreground))"},"aria-label":"Send message",type:"button",children:u.jsx(Lr,{className:"cuadra-h-4 cuadra-w-4"})})})]})]})]})});function no({title:e,subtitle:r,suggestions:t,onSuggestionClick:a,isProcessing:i}){return u.jsx("div",{className:"cuadra-flex cuadra-flex-col cuadra-items-center cuadra-h-full cuadra-py-12 cuadra-px-4 cuadra-overflow-y-auto scrollbar-hide",children:u.jsxs("div",{className:"cuadra-text-center cuadra-max-w-3xl cuadra-w-full cuadra-flex cuadra-flex-col cuadra-items-center cuadra-justify-center cuadra-min-h-full",children:[u.jsxs("div",{className:"cuadra-flex cuadra-flex-col cuadra-items-center cuadra-justify-center cuadra-mb-8",children:[u.jsx("h2",{className:"cuadra-text-xl cuadra-font-normal cuadra-text-foreground cuadra-mb-2 font-brand",children:e}),u.jsx("p",{className:"cuadra-text-muted-foreground font-brand",children:r})]}),t&&t.length>0&&u.jsx("div",{className:"cuadra-grid cuadra-grid-cols-2 cuadra-gap-2 cuadra-pb-4 cuadra-w-full cuadra-max-w-2xl",children:t.map((o,n)=>u.jsx("button",{type:"button",onClick:()=>a(o),disabled:i,className:"cuadra-w-full cuadra-text-center cuadra-px-4 cuadra-py-3 cuadra-rounded-lg cuadra-border cuadra-border-border cuadra-bg-background cuadra-text-base cuadra-text-foreground font-brand cuadra-cursor-pointer focus:cuadra-outline-none focus:cuadra-ring-0 disabled:cuadra-opacity-50 disabled:cuadra-cursor-not-allowed",style:{borderWidth:"1px"},children:o.prompt},`suggestion-${n}`))})]})})}function io(){return u.jsxs(T.MessagePrimitive.Root,{className:"cuadra-grid cuadra-w-full cuadra-auto-rows-auto cuadra-grid-cols-[minmax(72px,1fr)_auto] cuadra-gap-y-2 cuadra-py-3 [&:where(>*)]:cuadra-col-start-2",children:[u.jsx(T.MessagePrimitive.Attachments,{components:{Attachment:()=>{const e=T.useAssistantState(({attachment:o})=>o);if(!e)return null;const r=e.type==="image",t=e.file,a=e.content?.find(o=>o.type==="image"),i=t?URL.createObjectURL(t):a?.image;return u.jsx("div",{className:"cuadra-col-start-2 cuadra-row-start-1 cuadra-mb-2 cuadra-max-w-[calc(42rem*0.8)]",children:r&&i?u.jsx("img",{src:i,alt:e.name||"Attachment",className:"cuadra-rounded-lg cuadra-border cuadra-border-border cuadra-max-h-64 cuadra-max-w-full cuadra-object-contain",style:{borderWidth:"1px"}}):u.jsxs("div",{className:"cuadra-flex cuadra-items-center cuadra-gap-2 cuadra-rounded-lg cuadra-border cuadra-border-border cuadra-bg-muted cuadra-px-3 cuadra-py-2",children:[u.jsx(Lt,{className:"cuadra-h-4 cuadra-w-4 cuadra-text-muted-foreground"}),u.jsx("span",{className:"cuadra-text-sm cuadra-text-foreground font-brand",children:e.name||"Attachment"})]})})}}}),u.jsx("div",{className:"cuadra-bg-muted cuadra-text-foreground cuadra-col-start-2 cuadra-row-start-2 cuadra-max-w-[calc(42rem*0.8)] cuadra-break-words cuadra-rounded-3xl cuadra-border cuadra-border-border cuadra-px-5 cuadra-py-2.5 font-brand",style:{maxWidth:"calc(42rem * 0.8)",borderRadius:"1.5rem",backgroundColor:"var(--cuadra-muted)",color:"hsl(var(--cuadra-foreground))",paddingLeft:"1.25rem",paddingRight:"1.25rem",paddingTop:"0.625rem",paddingBottom:"0.625rem",wordBreak:"break-word",borderWidth:"1px"},children:u.jsx(T.MessagePrimitive.Parts,{components:{Text:({text:e})=>u.jsx(at,{content:e||""})}})})]})}function oo({text:e}){const[r,t]=x.useState(!1),a=T.useAssistantState(({message:i})=>i?.status?.type==="running");return e?a?u.jsx("div",{className:"cuadra-mb-3 cuadra-py-1",children:u.jsx("div",{className:"cuadra-text-sm cuadra-text-muted-foreground cuadra-leading-relaxed font-brand cuadra-animate-text-shimmer",children:e})}):u.jsxs("div",{className:"cuadra-mb-3",children:[u.jsxs("button",{type:"button",onClick:()=>t(!r),className:"cuadra-flex cuadra-items-center cuadra-gap-1.5 cuadra-py-1 cuadra-text-sm cuadra-text-muted-foreground hover:cuadra-text-foreground cuadra-transition-colors font-brand",children:[u.jsx(Xe,{className:`cuadra-h-3.5 cuadra-w-3.5 cuadra-shrink-0 cuadra-transition-transform cuadra-duration-200 ${r?"":"cuadra--rotate-90"}`}),u.jsx("span",{children:"Reasoning"})]}),u.jsx("div",{className:`cuadra-overflow-hidden cuadra-transition-all cuadra-duration-200 cuadra-ease-out ${r?"cuadra-max-h-[2000px] cuadra-opacity-100":"cuadra-max-h-0 cuadra-opacity-0"}`,children:u.jsx("div",{className:"cuadra-pl-5 cuadra-pt-2 cuadra-text-sm cuadra-text-muted-foreground cuadra-leading-relaxed font-brand",children:u.jsx(at,{content:e})})})]}):null}function so(){return u.jsxs("div",{className:"cuadra-flex cuadra-items-center cuadra-gap-2 cuadra-text-muted-foreground cuadra-text-sm font-brand cuadra-py-2",children:[u.jsxs("div",{className:"cuadra-flex cuadra-items-center cuadra-gap-1",children:[u.jsx("span",{className:"cuadra-inline-block cuadra-w-1.5 cuadra-h-1.5 cuadra-bg-current cuadra-rounded-full cuadra-animate-bounce",style:{animationDelay:"0ms"}}),u.jsx("span",{className:"cuadra-inline-block cuadra-w-1.5 cuadra-h-1.5 cuadra-bg-current cuadra-rounded-full cuadra-animate-bounce",style:{animationDelay:"150ms"}}),u.jsx("span",{className:"cuadra-inline-block cuadra-w-1.5 cuadra-h-1.5 cuadra-bg-current cuadra-rounded-full cuadra-animate-bounce",style:{animationDelay:"300ms"}})]}),u.jsx("span",{children:"Thinking..."})]})}function co(){const e=T.useAssistantState(({message:n})=>n?.status?.type==="running"),r=T.useAssistantState(({message:n})=>{const c=n?.content;return!c||!Array.isArray(c)?!1:c.some(s=>!!(s.type==="text"&&s.text&&s.text.length>0||s.type==="reasoning"&&s.text&&s.text.length>0))}),t=x.useRef(!1),[a,i]=x.useState(null);x.useEffect(()=>{if(e&&r&&!t.current){const n=Z.getCurrentMessageId();n&&(t.current=!0,i(n))}},[e,r]);const o=x.useSyncExternalStore(n=>Z.subscribe(n),()=>{if(a){const n=Z.getForMessage(a);return n.sources?.length?n.sources:null}if(e&&r){const n=Z.getCurrentMessageId();if(n){const c=Z.getForMessage(n);return c.sources?.length?c.sources:null}}return null},()=>null);return u.jsx(T.MessagePrimitive.Root,{className:"cuadra-relative cuadra-grid cuadra-w-full cuadra-grid-cols-[auto_auto_1fr] cuadra-grid-rows-[auto_1fr] cuadra-py-3",children:u.jsxs("div",{className:"cuadra-text-foreground cuadra-col-span-2 cuadra-col-start-2 cuadra-row-start-1 cuadra-my-1.5 cuadra-max-w-[90%] cuadra-break-words cuadra-leading-7 font-brand",style:{maxWidth:"90%",marginTop:"0.375rem",marginBottom:"0.375rem"},children:[u.jsx(T.MessagePrimitive.Parts,{components:{Text:({text:n})=>u.jsx(at,{content:n||""}),Reasoning:({text:n})=>u.jsx(oo,{text:n||""})}}),e&&!r&&u.jsx(so,{}),o&&o.length>0&&u.jsx(dr,{sources:o})]})})}const fr=({className:e="",theme:r="system"})=>{const t=()=>{if(typeof window>"u")return"light";if(r==="system"){const n=localStorage.getItem("theme");return n||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")}return r},[a,i]=x.useState(t);x.useEffect(()=>{r!=="system"&&i(r)},[r]),x.useEffect(()=>{const n=document.documentElement;n.classList.remove("light","dark"),n.classList.add(a),r==="system"&&localStorage.setItem("theme",a)},[a,r]);const o=()=>{r==="system"&&i(n=>n==="light"?"dark":"light")};return u.jsx("button",{type:"button","aria-label":"Toggle theme",onClick:o,disabled:r!=="system",className:`cuadra-flex cuadra-items-center cuadra-justify-center cuadra-h-8 cuadra-w-8 cuadra-rounded-full cuadra-bg-muted hover:cuadra-bg-muted/80 cuadra-transition-colors disabled:cuadra-opacity-50 disabled:cuadra-cursor-not-allowed ${e}`,children:u.jsx(zr,{className:`cuadra-h-4 cuadra-w-4 cuadra-transition-colors ${a==="dark"?"cuadra-text-primary":"cuadra-text-gray-400"}`})})};function uo({onThreadSelect:e}){const r=T.useThreadListItem(),t=T.useThread(b=>b.threadId),[a,i]=x.useState(null),o=r?.id===t,n=a===r?.id,[c,s]=x.useState(!1),[d,f]=x.useState(r?.title||""),[l,p]=x.useState(!1),[g,h]=x.useState(!1),y=async()=>{if(!r?.remoteId||!d||d===r.title){s(!1);return}try{h(!0);const b=window.__cuadraThreadListAdapter;b&&typeof b.rename=="function"&&await b.rename(r.remoteId,d),s(!1),p(!1)}catch{s(!1),p(!1)}finally{h(!1)}};return x.useEffect(()=>{r?.title&&!c&&f(r.title)},[r?.title,c]),r?u.jsxs(T.ThreadListItemPrimitive.Root,{className:`group cuadra-relative cuadra-flex cuadra-items-center cuadra-rounded-lg cuadra-transition-colors cuadra-cursor-pointer cuadra-border cuadra-mb-2 ${o?"cuadra-bg-muted cuadra-border-border":"cuadra-border-transparent hover:cuadra-bg-muted hover:cuadra-border-border"}`,style:{marginBottom:"0.5rem"},onMouseEnter:()=>i(r.id),onMouseLeave:()=>i(null),children:[u.jsx(T.ThreadListItemPrimitive.Trigger,{className:"cuadra-p-3 cuadra-flex-1 cuadra-flex cuadra-items-center cuadra-min-w-0 cuadra-cursor-pointer",onClick:()=>e?.(),children:u.jsx("div",{className:"cuadra-flex cuadra-flex-col cuadra-min-w-0 cuadra-flex-1 cuadra-items-start cuadra-text-left",children:c?u.jsx("input",{className:"cuadra-flex cuadra-w-full cuadra-rounded-md cuadra-border cuadra-border-input cuadra-bg-background cuadra-px-3 cuadra-py-2 cuadra-text-sm placeholder:cuadra-text-muted-foreground focus-visible:cuadra-outline-none disabled:cuadra-cursor-not-allowed disabled:cuadra-opacity-50 font-brand",value:d,onChange:b=>f(b.target.value),onKeyDown:b=>{b.key==="Enter"&&y(),b.key==="Escape"&&(s(!1),f(r.title||""))},disabled:g,autoFocus:!0,onClick:b=>b.stopPropagation()}):u.jsxs(u.Fragment,{children:[u.jsx("span",{className:"cuadra-text-sm cuadra-font-normal cuadra-text-foreground cuadra-truncate font-brand",children:(r.title?.length||0)>60?`${r.title?.slice(0,60)}…`:r.title||"Chat"}),r.updatedAt&&u.jsx("span",{className:"cuadra-text-xs cuadra-text-muted-foreground cuadra-mt-1 font-brand",children:new Date(r.updatedAt).toLocaleDateString()})]})})}),u.jsx("div",{className:"cuadra-mr-2 cuadra-flex-shrink-0 cuadra-w-6 cuadra-h-6 cuadra-flex cuadra-items-center cuadra-justify-center",children:(n||o||l)&&u.jsxs("div",{className:"cuadra-relative",children:[u.jsx("button",{type:"button",className:"cuadra-p-1 cuadra-rounded hover:cuadra-bg-background/50 cuadra-transition-colors",onClick:b=>{b.stopPropagation(),p(!l)},"aria-label":"Thread options",children:u.jsx(Br,{className:"cuadra-h-4 cuadra-w-4 cuadra-text-muted-foreground"})}),l&&u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"cuadra-fixed cuadra-inset-0 cuadra-z-40",onClick:()=>p(!1)}),u.jsx("div",{className:"cuadra-absolute cuadra-right-0 cuadra-top-8 cuadra-z-50 cuadra-bg-background cuadra-border cuadra-border-border cuadra-rounded-lg cuadra-shadow-lg cuadra-min-w-[120px] cuadra-overflow-hidden",children:c?u.jsx("button",{type:"button",className:"cuadra-w-full cuadra-px-3 cuadra-py-2 cuadra-text-sm cuadra-text-left hover:cuadra-bg-muted cuadra-transition-colors font-brand",onClick:b=>{b.stopPropagation(),y()},disabled:g,children:"Save"}):u.jsxs(u.Fragment,{children:[u.jsx("button",{type:"button",className:"cuadra-w-full cuadra-px-3 cuadra-py-2 cuadra-text-sm cuadra-text-left hover:cuadra-bg-muted cuadra-transition-colors font-brand",onClick:b=>{b.stopPropagation(),s(!0),f(r.title||""),p(!1)},children:"Rename"}),u.jsx("div",{className:"cuadra-border-t cuadra-border-border"}),u.jsx(T.ThreadListItemPrimitive.Delete,{asChild:!0,children:u.jsx("button",{type:"button",className:"cuadra-w-full cuadra-px-3 cuadra-py-2 cuadra-text-sm cuadra-text-left cuadra-text-destructive hover:cuadra-bg-muted cuadra-transition-colors font-brand",onClick:b=>{b.stopPropagation(),p(!1)},children:"Delete"})})]})})]})]})})]}):null}function It({onThreadSelect:e,showThemeToggle:r,theme:t,onLogout:a,safeArea:i=!1,orgName:o,primaryColor:n}){return u.jsxs(T.ThreadListPrimitive.Root,{className:"!cuadra-border-r cuadra-border-border cuadra-flex cuadra-flex-col cuadra-bg-background cuadra-transition-all cuadra-duration-300 cuadra-ease-in-out cuadra-h-full cuadra-w-80",style:{borderRightWidth:"1px"},children:[u.jsxs("div",{className:"cuadra-border-b cuadra-border-border cuadra-flex cuadra-items-center cuadra-justify-between cuadra-transition-all cuadra-duration-300 cuadra-min-h-16 cuadra-px-4 cuadra-py-4",style:i?{paddingTop:"calc(env(safe-area-inset-top) + 1rem)",paddingLeft:"calc(env(safe-area-inset-left) + 0.5rem)"}:void 0,children:[o?u.jsxs("div",{className:"cuadra-flex cuadra-items-center cuadra-gap-2 cuadra-flex-1 cuadra-min-w-0",children:[u.jsx("div",{className:"cuadra-w-8 cuadra-h-8 cuadra-rounded-full cuadra-flex cuadra-items-center cuadra-justify-center cuadra-text-white cuadra-font-bold cuadra-text-sm cuadra-flex-shrink-0",style:{backgroundColor:n||"hsl(var(--primary))"},children:o.charAt(0).toUpperCase()}),u.jsx("span",{className:"cuadra-font-medium cuadra-text-sm cuadra-text-foreground cuadra-truncate font-brand",children:o})]}):u.jsx("div",{className:"cuadra-flex-1"}),u.jsx("button",{type:"button",onClick:e,className:"cuadra-flex md:cuadra-hidden cuadra-items-center cuadra-justify-center cuadra-h-8 cuadra-w-8 cuadra-rounded-full cuadra-bg-muted hover:cuadra-bg-muted/80 cuadra-transition-colors cuadra-flex-shrink-0","aria-label":"Close",children:u.jsx(Ye,{className:"cuadra-h-4 cuadra-w-4 cuadra-text-foreground"})})]}),u.jsxs("div",{className:"cuadra-flex-1 cuadra-overflow-y-auto cuadra-p-2 cuadra-pl-4 scrollbar-thin",style:i?{paddingLeft:"calc(env(safe-area-inset-left) + 1rem)"}:void 0,children:[u.jsx(T.ThreadListPrimitive.New,{className:"group cuadra-relative cuadra-flex cuadra-items-center cuadra-gap-3 cuadra-p-3 cuadra-rounded-lg cuadra-cursor-pointer cuadra-transition-colors cuadra-border cuadra-border-transparent hover:cuadra-bg-muted hover:cuadra-border-border",onClick:()=>e?.(),children:u.jsx("div",{className:"cuadra-flex-1 cuadra-min-w-0",children:u.jsxs("div",{className:"cuadra-flex cuadra-items-center cuadra-gap-2",children:[u.jsx(ta,{className:"cuadra-h-4 cuadra-w-4 cuadra-text-muted-foreground"}),u.jsx("h4",{className:"cuadra-text-sm cuadra-font-normal cuadra-text-foreground font-brand",children:"New Chat"})]})})}),u.jsx("div",{className:"cuadra-my-2 cuadra-border-t cuadra-border-border"}),u.jsx(T.ThreadListPrimitive.Items,{components:{ThreadListItem:c=>u.jsx(uo,{...c,onThreadSelect:e})}})]}),(r||a)&&u.jsxs("div",{className:"cuadra-border-t cuadra-border-border cuadra-flex md:cuadra-hidden cuadra-items-center cuadra-justify-between cuadra-px-4 cuadra-py-4",style:i?{paddingBottom:"calc(env(safe-area-inset-bottom) + 0.5rem)",paddingLeft:"calc(env(safe-area-inset-left) + 0.5rem)"}:void 0,children:[a&&u.jsx("button",{type:"button",onClick:a,className:"cuadra-flex cuadra-items-center cuadra-justify-center cuadra-h-8 cuadra-w-8 cuadra-rounded-full cuadra-bg-muted hover:cuadra-bg-muted/80 cuadra-transition-colors","aria-label":"Logout",children:u.jsx(Gr,{className:"cuadra-h-4 cuadra-w-4 cuadra-text-foreground"})}),r&&u.jsx(fr,{theme:t})]})]})}const lo=`
21
21
  @keyframes rotate {
22
22
  100% { transform: rotate(1turn); }
23
23
  }