mastra 0.2.7-alpha.0 → 0.2.7-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -283,7 +283,7 @@ Please change the parent <Route path="${C}"> to <Route path="${C==="/"?"*":`${C}
283
283
  `))+1))}const o="#".repeat(i),a=n.enter("headingAtx"),l=n.enter("phrasing");s.move(o+" ");let c=n.containerPhrasing(t,{before:"# ",after:`
284
284
  `,...s.current()});return/^[\t ]/.test(c)&&(c=op(c.charCodeAt(0))+c.slice(1)),c=c?o+" "+c:o,n.options.closeAtx&&(c+=" "+o),l(),a(),c}s$.peek=Fce;function s$(t){return t.value||""}function Fce(){return"<"}o$.peek=Bce;function o$(t,e,n,r){const i=xA(n),s=i==='"'?"Quote":"Apostrophe",o=n.enter("image");let a=n.enter("label");const l=n.createTracker(r);let c=l.move("![");return c+=l.move(n.safe(t.alt,{before:c,after:"]",...l.current()})),c+=l.move("]("),a(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(a=n.enter("destinationLiteral"),c+=l.move("<"),c+=l.move(n.safe(t.url,{before:c,after:">",...l.current()})),c+=l.move(">")):(a=n.enter("destinationRaw"),c+=l.move(n.safe(t.url,{before:c,after:t.title?" ":")",...l.current()}))),a(),t.title&&(a=n.enter(`title${s}`),c+=l.move(" "+i),c+=l.move(n.safe(t.title,{before:c,after:i,...l.current()})),c+=l.move(i),a()),c+=l.move(")"),o(),c}function Bce(){return"!"}a$.peek=$ce;function a$(t,e,n,r){const i=t.referenceType,s=n.enter("imageReference");let o=n.enter("label");const a=n.createTracker(r);let l=a.move("![");const c=n.safe(t.alt,{before:l,after:"]",...a.current()});l+=a.move(c+"]["),o();const u=n.stack;n.stack=[],o=n.enter("reference");const d=n.safe(n.associationId(t),{before:l,after:"]",...a.current()});return o(),n.stack=u,s(),i==="full"||!c||c!==d?l+=a.move(d+"]"):i==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function $ce(){return"!"}l$.peek=zce;function l$(t,e,n){let r=t.value||"",i="`",s=-1;for(;new RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++s<n.unsafe.length;){const o=n.unsafe[s],a=n.compilePattern(o);let l;if(o.atBreak)for(;l=a.exec(r);){let c=l.index;r.charCodeAt(c)===10&&r.charCodeAt(c-1)===13&&c--,r=r.slice(0,c)+" "+r.slice(l.index+1)}}return i+r+i}function zce(){return"`"}function c$(t,e){const n=cA(t);return!!(!e.options.resourceLink&&t.url&&!t.title&&t.children&&t.children.length===1&&t.children[0].type==="text"&&(n===t.url||"mailto:"+n===t.url)&&/^[a-z][a-z+.-]+:/i.test(t.url)&&!/[\0- <>\u007F]/.test(t.url))}u$.peek=Vce;function u$(t,e,n,r){const i=xA(n),s=i==='"'?"Quote":"Apostrophe",o=n.createTracker(r);let a,l;if(c$(t,n)){const u=n.stack;n.stack=[],a=n.enter("autolink");let d=o.move("<");return d+=o.move(n.containerPhrasing(t,{before:d,after:">",...o.current()})),d+=o.move(">"),a(),n.stack=u,d}a=n.enter("link"),l=n.enter("label");let c=o.move("[");return c+=o.move(n.containerPhrasing(t,{before:c,after:"](",...o.current()})),c+=o.move("]("),l(),!t.url&&t.title||/[\0- \u007F]/.test(t.url)?(l=n.enter("destinationLiteral"),c+=o.move("<"),c+=o.move(n.safe(t.url,{before:c,after:">",...o.current()})),c+=o.move(">")):(l=n.enter("destinationRaw"),c+=o.move(n.safe(t.url,{before:c,after:t.title?" ":")",...o.current()}))),l(),t.title&&(l=n.enter(`title${s}`),c+=o.move(" "+i),c+=o.move(n.safe(t.title,{before:c,after:i,...o.current()})),c+=o.move(i),l()),c+=o.move(")"),a(),c}function Vce(t,e,n){return c$(t,n)?"<":"["}d$.peek=Wce;function d$(t,e,n,r){const i=t.referenceType,s=n.enter("linkReference");let o=n.enter("label");const a=n.createTracker(r);let l=a.move("[");const c=n.containerPhrasing(t,{before:l,after:"]",...a.current()});l+=a.move(c+"]["),o();const u=n.stack;n.stack=[],o=n.enter("reference");const d=n.safe(n.associationId(t),{before:l,after:"]",...a.current()});return o(),n.stack=u,s(),i==="full"||!c||c!==d?l+=a.move(d+"]"):i==="shortcut"?l=l.slice(0,-1):l+=a.move("]"),l}function Wce(){return"["}function vA(t){const e=t.options.bullet||"*";if(e!=="*"&&e!=="+"&&e!=="-")throw new Error("Cannot serialize items with `"+e+"` for `options.bullet`, expected `*`, `+`, or `-`");return e}function Hce(t){const e=vA(t),n=t.options.bulletOther;if(!n)return e==="*"?"-":"*";if(n!=="*"&&n!=="+"&&n!=="-")throw new Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===e)throw new Error("Expected `bullet` (`"+e+"`) and `bulletOther` (`"+n+"`) to be different");return n}function Uce(t){const e=t.options.bulletOrdered||".";if(e!=="."&&e!==")")throw new Error("Cannot serialize items with `"+e+"` for `options.bulletOrdered`, expected `.` or `)`");return e}function f$(t){const e=t.options.rule||"*";if(e!=="*"&&e!=="-"&&e!=="_")throw new Error("Cannot serialize rules with `"+e+"` for `options.rule`, expected `*`, `-`, or `_`");return e}function qce(t,e,n,r){const i=n.enter("list"),s=n.bulletCurrent;let o=t.ordered?Uce(n):vA(n);const a=t.ordered?o==="."?")":".":Hce(n);let l=e&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!t.ordered){const u=t.children?t.children[0]:void 0;if((o==="*"||o==="-")&&u&&(!u.children||!u.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(l=!0),f$(n)===o&&u){let d=-1;for(;++d<t.children.length;){const h=t.children[d];if(h&&h.type==="listItem"&&h.children&&h.children[0]&&h.children[0].type==="thematicBreak"){l=!0;break}}}}l&&(o=a),n.bulletCurrent=o;const c=n.containerFlow(t,r);return n.bulletLastUsed=o,n.bulletCurrent=s,i(),c}function Yce(t){const e=t.options.listItemIndent||"one";if(e!=="tab"&&e!=="one"&&e!=="mixed")throw new Error("Cannot serialize items with `"+e+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return e}function Gce(t,e,n,r){const i=Yce(n);let s=n.bulletCurrent||vA(n);e&&e.type==="list"&&e.ordered&&(s=(typeof e.start=="number"&&e.start>-1?e.start:1)+(n.options.incrementListMarker===!1?0:e.children.indexOf(t))+s);let o=s.length+1;(i==="tab"||i==="mixed"&&(e&&e.type==="list"&&e.spread||t.spread))&&(o=Math.ceil(o/4)*4);const a=n.createTracker(r);a.move(s+" ".repeat(o-s.length)),a.shift(o);const l=n.enter("listItem"),c=n.indentLines(n.containerFlow(t,a.current()),u);return l(),c;function u(d,h,m){return h?(m?"":" ".repeat(o))+d:(m?s:s+" ".repeat(o-s.length))+d}}function Kce(t,e,n,r){const i=n.enter("paragraph"),s=n.enter("phrasing"),o=n.containerPhrasing(t,r);return s(),i(),o}const Zce=xv(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function Xce(t,e,n,r){return(t.children.some(function(o){return Zce(o)})?n.containerPhrasing:n.containerFlow).call(n,t,r)}function Qce(t){const e=t.options.strong||"*";if(e!=="*"&&e!=="_")throw new Error("Cannot serialize strong with `"+e+"` for `options.strong`, expected `*`, or `_`");return e}h$.peek=Jce;function h$(t,e,n,r){const i=Qce(n),s=n.enter("strong"),o=n.createTracker(r),a=o.move(i+i);let l=o.move(n.containerPhrasing(t,{after:i,before:a,...o.current()}));const c=l.charCodeAt(0),u=V0(r.before.charCodeAt(r.before.length-1),c,i);u.inside&&(l=op(c)+l.slice(1));const d=l.charCodeAt(l.length-1),h=V0(r.after.charCodeAt(0),d,i);h.inside&&(l=l.slice(0,-1)+op(d));const m=o.move(i+i);return s(),n.attentionEncodeSurroundingInfo={after:h.outside,before:u.outside},a+l+m}function Jce(t,e,n){return n.options.strong||"*"}function eue(t,e,n,r){return n.safe(t.value,r)}function tue(t){const e=t.options.ruleRepetition||3;if(e<3)throw new Error("Cannot serialize rules with repetition `"+e+"` for `options.ruleRepetition`, expected `3` or more");return e}function nue(t,e,n){const r=(f$(n)+(n.options.ruleSpaces?" ":"")).repeat(tue(n));return n.options.ruleSpaces?r.slice(0,-1):r}const p$={blockquote:Ece,break:fD,code:Pce,definition:Rce,emphasis:i$,hardBreak:fD,heading:Lce,html:s$,image:o$,imageReference:a$,inlineCode:l$,link:u$,linkReference:d$,list:qce,listItem:Gce,paragraph:Kce,root:Xce,strong:h$,text:eue,thematicBreak:nue};function rue(){return{enter:{table:iue,tableData:hD,tableHeader:hD,tableRow:oue},exit:{codeText:aue,table:sue,tableData:ak,tableHeader:ak,tableRow:ak}}}function iue(t){const e=t._align;this.enter({type:"table",align:e.map(function(n){return n==="none"?null:n}),children:[]},t),this.data.inTable=!0}function sue(t){this.exit(t),this.data.inTable=void 0}function oue(t){this.enter({type:"tableRow",children:[]},t)}function ak(t){this.exit(t)}function hD(t){this.enter({type:"tableCell",children:[]},t)}function aue(t){let e=this.resume();this.data.inTable&&(e=e.replace(/\\([\\|])/g,lue));const n=this.stack[this.stack.length-1];n.type,n.value=e,this.exit(t)}function lue(t,e){return e==="|"?e:t}function cue(t){const e=t||{},n=e.tableCellPadding,r=e.tablePipeAlign,i=e.stringLength,s=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
285
285
  `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:h,table:o,tableCell:l,tableRow:a}};function o(m,y,v,w){return c(u(m,v,w),m.align)}function a(m,y,v,w){const b=d(m,v,w),k=c([b]);return k.slice(0,k.indexOf(`
286
- `))}function l(m,y,v,w){const b=v.enter("tableCell"),k=v.enter("phrasing"),C=v.containerPhrasing(m,{...w,before:s,after:s});return k(),b(),C}function c(m,y){return Sce(m,{align:y,alignDelimiters:r,padding:n,stringLength:i})}function u(m,y,v){const w=m.children;let b=-1;const k=[],C=y.enter("table");for(;++b<w.length;)k[b]=d(w[b],y,v);return C(),k}function d(m,y,v){const w=m.children;let b=-1;const k=[],C=y.enter("tableRow");for(;++b<w.length;)k[b]=l(w[b],m,y,v);return C(),k}function h(m,y,v){let w=p$.inlineCode(m,y,v);return v.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function uue(){return{exit:{taskListCheckValueChecked:pD,taskListCheckValueUnchecked:pD,paragraph:fue}}}function due(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:hue}}}function pD(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function fue(t){const e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=e.children;let s=-1,o;for(;++s<i.length;){const a=i[s];if(a.type==="paragraph"){o=a;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(t)}function hue(t,e,n,r){const i=t.children[0],s=typeof t.checked=="boolean"&&i&&i.type==="paragraph",o="["+(t.checked?"x":" ")+"] ",a=n.createTracker(r);s&&a.move(o);let l=p$.listItem(t,e,n,{...r,...a.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(u){return u+o}}function pue(){return[qle(),hce(),yce(),rue(),uue()]}function mue(t){return{extensions:[Yle(),pce(t),xce(),cue(t),due()]}}const gue={tokenize:kue,partial:!0},m$={tokenize:Sue,partial:!0},g$={tokenize:Cue,partial:!0},y$={tokenize:Eue,partial:!0},yue={tokenize:Tue,partial:!0},x$={name:"wwwAutolink",tokenize:wue,previous:w$},v$={name:"protocolAutolink",tokenize:bue,previous:b$},va={name:"emailAutolink",tokenize:vue,previous:k$},Mo={};function xue(){return{text:Mo}}let nc=48;for(;nc<123;)Mo[nc]=va,nc++,nc===58?nc=65:nc===91&&(nc=97);Mo[43]=va;Mo[45]=va;Mo[46]=va;Mo[95]=va;Mo[72]=[va,v$];Mo[104]=[va,v$];Mo[87]=[va,x$];Mo[119]=[va,x$];function vue(t,e,n){const r=this;let i,s;return o;function o(d){return!cE(d)||!k$.call(r,r.previous)||wA(r.events)?n(d):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),a(d))}function a(d){return cE(d)?(t.consume(d),a):d===64?(t.consume(d),l):n(d)}function l(d){return d===46?t.check(yue,u,c)(d):d===45||d===95||_r(d)?(s=!0,t.consume(d),l):u(d)}function c(d){return t.consume(d),i=!0,l}function u(d){return s&&i&&Hr(r.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(d)):n(d)}}function wue(t,e,n){const r=this;return i;function i(o){return o!==87&&o!==119||!w$.call(r,r.previous)||wA(r.events)?n(o):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(gue,t.attempt(m$,t.attempt(g$,s),n),n)(o))}function s(o){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(o)}}function bue(t,e,n){const r=this;let i="",s=!1;return o;function o(d){return(d===72||d===104)&&b$.call(r,r.previous)&&!wA(r.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),t.consume(d),a):n(d)}function a(d){if(Hr(d)&&i.length<5)return i+=String.fromCodePoint(d),t.consume(d),a;if(d===58){const h=i.toLowerCase();if(h==="http"||h==="https")return t.consume(d),l}return n(d)}function l(d){return d===47?(t.consume(d),s?c:(s=!0,l)):n(d)}function c(d){return d===null||B0(d)||Qt(d)||Cc(d)||mv(d)?n(d):t.attempt(m$,t.attempt(g$,u),n)(d)}function u(d){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(d)}}function kue(t,e,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,t.consume(o),i):o===46&&r===3?(t.consume(o),s):n(o)}function s(o){return o===null?n(o):e(o)}}function Sue(t,e,n){let r,i,s;return o;function o(c){return c===46||c===95?t.check(y$,l,a)(c):c===null||Qt(c)||Cc(c)||c!==45&&mv(c)?l(c):(s=!0,t.consume(c),o)}function a(c){return c===95?r=!0:(i=r,r=void 0),t.consume(c),o}function l(c){return i||r||!s?n(c):e(c)}}function Cue(t,e){let n=0,r=0;return i;function i(o){return o===40?(n++,t.consume(o),i):o===41&&r<n?s(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?t.check(y$,e,s)(o):o===null||Qt(o)||Cc(o)?e(o):(t.consume(o),i)}function s(o){return o===41&&r++,t.consume(o),i}}function Eue(t,e,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(t.consume(a),r):a===38?(t.consume(a),s):a===93?(t.consume(a),i):a===60||a===null||Qt(a)||Cc(a)?e(a):n(a)}function i(a){return a===null||a===40||a===91||Qt(a)||Cc(a)?e(a):r(a)}function s(a){return Hr(a)?o(a):n(a)}function o(a){return a===59?(t.consume(a),r):Hr(a)?(t.consume(a),o):n(a)}}function Tue(t,e,n){return r;function r(s){return t.consume(s),i}function i(s){return _r(s)?n(s):e(s)}}function w$(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Qt(t)}function b$(t){return!Hr(t)}function k$(t){return!(t===47||cE(t))}function cE(t){return t===43||t===45||t===46||t===95||_r(t)}function wA(t){let e=t.length,n=!1;for(;e--;){const r=t[e][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return t.length>0&&!n&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Nue={tokenize:jue,partial:!0};function Aue(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Oue,continuation:{tokenize:Rue},exit:Due}},text:{91:{name:"gfmFootnoteCall",tokenize:Pue},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:_ue,resolveTo:Mue}}}}function _ue(t,e,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return a;function a(l){if(!o||!o._balanced)return n(l);const c=Ts(r.sliceSerialize({start:o.end,end:r.now()}));return c.codePointAt(0)!==94||!s.includes(c.slice(1))?n(l):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(l),t.exit("gfmFootnoteCallLabelMarker"),e(l))}}function Mue(t,e){let n=t.length;for(;n--;)if(t[n][1].type==="labelImage"&&t[n][0]==="enter"){t[n][1];break}t[n+1][1].type="data",t[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},t[n+3][1].start),end:Object.assign({},t[t.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},t[n+3][1].end),end:Object.assign({},t[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},t[t.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[t[n+1],t[n+2],["enter",r,e],t[n+3],t[n+4],["enter",i,e],["exit",i,e],["enter",s,e],["enter",o,e],["exit",o,e],["exit",s,e],t[t.length-2],t[t.length-1],["exit",r,e]];return t.splice(n,t.length-n+1,...a),t}function Pue(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,o;return a;function a(d){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),l}function l(d){return d!==94?n(d):(t.enter("gfmFootnoteCallMarker"),t.consume(d),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",c)}function c(d){if(s>999||d===93&&!o||d===null||d===91||Qt(d))return n(d);if(d===93){t.exit("chunkString");const h=t.exit("gfmFootnoteCallString");return i.includes(Ts(r.sliceSerialize(h)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(d)}return Qt(d)||(o=!0),s++,t.consume(d),d===92?u:c}function u(d){return d===91||d===92||d===93?(t.consume(d),s++,c):c(d)}}function Oue(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,o=0,a;return l;function l(y){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(y),t.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(y){return y===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(y),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",u):n(y)}function u(y){if(o>999||y===93&&!a||y===null||y===91||Qt(y))return n(y);if(y===93){t.exit("chunkString");const v=t.exit("gfmFootnoteDefinitionLabelString");return s=Ts(r.sliceSerialize(v)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(y),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),h}return Qt(y)||(a=!0),o++,t.consume(y),y===92?d:u}function d(y){return y===91||y===92||y===93?(t.consume(y),o++,u):u(y)}function h(y){return y===58?(t.enter("definitionMarker"),t.consume(y),t.exit("definitionMarker"),i.includes(s)||i.push(s),Pt(t,m,"gfmFootnoteDefinitionWhitespace")):n(y)}function m(y){return e(y)}}function Rue(t,e,n){return t.check(fm,e,t.attempt(Nue,e,n))}function Due(t){t.exit("gfmFootnoteDefinition")}function jue(t,e,n){const r=this;return Pt(t,i,"gfmFootnoteDefinitionIndent",5);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?e(s):n(s)}}function Iue(t){let n=(t||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,a){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let c=l;for(;c--;)if(o[c][0]==="exit"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[c][1].end.offset-o[c][1].start.offset){o[l][1].type="strikethroughSequence",o[c][1].type="strikethroughSequence";const u={type:"strikethrough",start:Object.assign({},o[c][1].start),end:Object.assign({},o[l][1].end)},d={type:"strikethroughText",start:Object.assign({},o[c][1].end),end:Object.assign({},o[l][1].start)},h=[["enter",u,a],["enter",o[c][1],a],["exit",o[c][1],a],["enter",d,a]],m=a.parser.constructs.insideSpan.null;m&&Mi(h,h.length,0,gv(m,o.slice(c+1,l),a)),Mi(h,h.length,0,[["exit",d,a],["enter",o[l][1],a],["exit",o[l][1],a],["exit",u,a]]),Mi(o,c-1,l-c+3,h),l=c+h.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function s(o,a,l){const c=this.previous,u=this.events;let d=0;return h;function h(y){return c===126&&u[u.length-1][1].type!=="characterEscape"?l(y):(o.enter("strikethroughSequenceTemporary"),m(y))}function m(y){const v=pd(c);if(y===126)return d>1?l(y):(o.consume(y),d++,m);if(d<2&&!n)return l(y);const w=o.exit("strikethroughSequenceTemporary"),b=pd(y);return w._open=!b||b===2&&!!v,w._close=!v||v===2&&!!b,a(y)}}}class Lue{constructor(){this.map=[]}add(e,n,r){Fue(this,e,n,r)}consume(e){if(this.map.sort(function(s,o){return s[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(e.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),e.length=this.map[n][0];r.push(e.slice()),e.length=0;let i=r.pop();for(;i;){for(const s of i)e.push(s);i=r.pop()}this.map.length=0}}function Fue(t,e,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<t.map.length;){if(t.map[i][0]===e){t.map[i][1]+=n,t.map[i][2].push(...r);return}i+=1}t.map.push([e,n,r])}}function Bue(t,e){let n=!1;const r=[];for(;e<t.length;){const i=t[e];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);e+=1}return r}function $ue(){return{flow:{null:{name:"table",tokenize:zue,resolveAll:Vue}}}}function zue(t,e,n){const r=this;let i=0,s=0,o;return a;function a(R){let B=r.events.length-1;for(;B>-1;){const I=r.events[B][1].type;if(I==="lineEnding"||I==="linePrefix")B--;else break}const F=B>-1?r.events[B][1].type:null,W=F==="tableHead"||F==="tableRow"?A:l;return W===A&&r.parser.lazy[r.now().line]?n(R):W(R)}function l(R){return t.enter("tableHead"),t.enter("tableRow"),c(R)}function c(R){return R===124||(o=!0,s+=1),u(R)}function u(R){return R===null?n(R):st(R)?s>1?(s=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(R),t.exit("lineEnding"),m):n(R):Nt(R)?Pt(t,u,"whitespace")(R):(s+=1,o&&(o=!1,i+=1),R===124?(t.enter("tableCellDivider"),t.consume(R),t.exit("tableCellDivider"),o=!0,u):(t.enter("data"),d(R)))}function d(R){return R===null||R===124||Qt(R)?(t.exit("data"),u(R)):(t.consume(R),R===92?h:d)}function h(R){return R===92||R===124?(t.consume(R),d):d(R)}function m(R){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(R):(t.enter("tableDelimiterRow"),o=!1,Nt(R)?Pt(t,y,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):y(R))}function y(R){return R===45||R===58?w(R):R===124?(o=!0,t.enter("tableCellDivider"),t.consume(R),t.exit("tableCellDivider"),v):_(R)}function v(R){return Nt(R)?Pt(t,w,"whitespace")(R):w(R)}function w(R){return R===58?(s+=1,o=!0,t.enter("tableDelimiterMarker"),t.consume(R),t.exit("tableDelimiterMarker"),b):R===45?(s+=1,b(R)):R===null||st(R)?T(R):_(R)}function b(R){return R===45?(t.enter("tableDelimiterFiller"),k(R)):_(R)}function k(R){return R===45?(t.consume(R),k):R===58?(o=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(R),t.exit("tableDelimiterMarker"),C):(t.exit("tableDelimiterFiller"),C(R))}function C(R){return Nt(R)?Pt(t,T,"whitespace")(R):T(R)}function T(R){return R===124?y(R):R===null||st(R)?!o||i!==s?_(R):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(R)):_(R)}function _(R){return n(R)}function A(R){return t.enter("tableRow"),M(R)}function M(R){return R===124?(t.enter("tableCellDivider"),t.consume(R),t.exit("tableCellDivider"),M):R===null||st(R)?(t.exit("tableRow"),e(R)):Nt(R)?Pt(t,M,"whitespace")(R):(t.enter("data"),O(R))}function O(R){return R===null||R===124||Qt(R)?(t.exit("data"),M(R)):(t.consume(R),R===92?D:O)}function D(R){return R===92||R===124?(t.consume(R),O):O(R)}}function Vue(t,e){let n=-1,r=!0,i=0,s=[0,0,0,0],o=[0,0,0,0],a=!1,l=0,c,u,d;const h=new Lue;for(;++n<t.length;){const m=t[n],y=m[1];m[0]==="enter"?y.type==="tableHead"?(a=!1,l!==0&&(mD(h,e,l,c,u),u=void 0,l=0),c={type:"table",start:Object.assign({},y.start),end:Object.assign({},y.end)},h.add(n,0,[["enter",c,e]])):y.type==="tableRow"||y.type==="tableDelimiterRow"?(r=!0,d=void 0,s=[0,0,0,0],o=[0,n+1,0,0],a&&(a=!1,u={type:"tableBody",start:Object.assign({},y.start),end:Object.assign({},y.end)},h.add(n,0,[["enter",u,e]])),i=y.type==="tableDelimiterRow"?2:u?3:1):i&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(s[1]!==0&&(o[0]=o[1],d=dy(h,e,s,i,void 0,d),s=[0,0,0,0]),o[2]=n)):y.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(o[0]=o[1],d=dy(h,e,s,i,void 0,d)),s=o,o=[s[1],n,0,0])):y.type==="tableHead"?(a=!0,l=n):y.type==="tableRow"||y.type==="tableDelimiterRow"?(l=n,s[1]!==0?(o[0]=o[1],d=dy(h,e,s,i,n,d)):o[1]!==0&&(d=dy(h,e,o,i,n,d)),i=0):i&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&mD(h,e,l,c,u),h.consume(e.events),n=-1;++n<e.events.length;){const m=e.events[n];m[0]==="enter"&&m[1].type==="table"&&(m[1]._align=Bue(e.events,n))}return t}function dy(t,e,n,r,i,s){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},Mu(e.events,n[0])),t.add(n[0],0,[["exit",s,e]]));const l=Mu(e.events,n[1]);if(s={type:o,start:Object.assign({},l),end:Object.assign({},l)},t.add(n[1],0,[["enter",s,e]]),n[2]!==0){const c=Mu(e.events,n[2]),u=Mu(e.events,n[3]),d={type:a,start:Object.assign({},c),end:Object.assign({},u)};if(t.add(n[2],0,[["enter",d,e]]),r!==2){const h=e.events[n[2]],m=e.events[n[3]];if(h[1].end=Object.assign({},m[1].end),h[1].type="chunkText",h[1].contentType="text",n[3]>n[2]+1){const y=n[2]+1,v=n[3]-n[2]-1;t.add(y,v,[])}}t.add(n[3]+1,0,[["exit",d,e]])}return i!==void 0&&(s.end=Object.assign({},Mu(e.events,i)),t.add(i,0,[["exit",s,e]]),s=void 0),s}function mD(t,e,n,r,i){const s=[],o=Mu(e.events,n);i&&(i.end=Object.assign({},o),s.push(["exit",i,e])),r.end=Object.assign({},o),s.push(["exit",r,e]),t.add(n+1,0,s)}function Mu(t,e){const n=t[e],r=n[0]==="enter"?"start":"end";return n[1][r]}const Wue={name:"tasklistCheck",tokenize:Uue};function Hue(){return{text:{91:Wue}}}function Uue(t,e,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),s)}function s(l){return Qt(l)?(t.enter("taskListCheckValueUnchecked"),t.consume(l),t.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(t.enter("taskListCheckValueChecked"),t.consume(l),t.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),a):n(l)}function a(l){return st(l)?e(l):Nt(l)?t.check({tokenize:que},e,n)(l):n(l)}}function que(t,e,n){return Pt(t,r,"whitespace");function r(i){return i===null?n(i):e(i)}}function Yue(t){return RB([xue(),Aue(),Iue(t),$ue(),Hue()])}const Gue={};function Kue(t){const e=this,n=t||Gue,r=e.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(Yue(n)),s.push(pue()),o.push(mue(n))}const Zue="modulepreload",Xue=function(t){return"/"+t},gD={},Que=function(e,n,r){let i=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),a=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));i=Promise.allSettled(n.map(l=>{if(l=Xue(l),l in gD)return;gD[l]=!0;const c=l.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${u}`))return;const d=document.createElement("link");if(d.rel=c?"stylesheet":Zue,c||(d.as="script"),d.crossOrigin="",d.href=l,a&&d.setAttribute("nonce",a),document.head.appendChild(d),c)return new Promise((h,m)=>{d.addEventListener("load",h),d.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${l}`)))})}))}function s(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return i.then(o=>{for(const a of o||[])a.status==="rejected"&&s(a.reason);return e().catch(s)})};async function Jue(t,e){const{codeToTokens:n,bundledLanguages:r}=await Que(async()=>{const{codeToTokens:s,bundledLanguages:o}=await import("./index-DmbjVy9O.js");return{codeToTokens:s,bundledLanguages:o}},[]);if(!(e in r))return null;const{tokens:i}=await n(t,{lang:e,defaultColor:!1,themes:{light:"github-light",dark:"github-dark"}});return i}function ede({children:t}){const e=t.replace(/\\n/g,`
286
+ `))}function l(m,y,v,w){const b=v.enter("tableCell"),k=v.enter("phrasing"),C=v.containerPhrasing(m,{...w,before:s,after:s});return k(),b(),C}function c(m,y){return Sce(m,{align:y,alignDelimiters:r,padding:n,stringLength:i})}function u(m,y,v){const w=m.children;let b=-1;const k=[],C=y.enter("table");for(;++b<w.length;)k[b]=d(w[b],y,v);return C(),k}function d(m,y,v){const w=m.children;let b=-1;const k=[],C=y.enter("tableRow");for(;++b<w.length;)k[b]=l(w[b],m,y,v);return C(),k}function h(m,y,v){let w=p$.inlineCode(m,y,v);return v.stack.includes("tableCell")&&(w=w.replace(/\|/g,"\\$&")),w}}function uue(){return{exit:{taskListCheckValueChecked:pD,taskListCheckValueUnchecked:pD,paragraph:fue}}}function due(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:hue}}}function pD(t){const e=this.stack[this.stack.length-2];e.type,e.checked=t.type==="taskListCheckValueChecked"}function fue(t){const e=this.stack[this.stack.length-2];if(e&&e.type==="listItem"&&typeof e.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const i=e.children;let s=-1,o;for(;++s<i.length;){const a=i[s];if(a.type==="paragraph"){o=a;break}}o===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(t)}function hue(t,e,n,r){const i=t.children[0],s=typeof t.checked=="boolean"&&i&&i.type==="paragraph",o="["+(t.checked?"x":" ")+"] ",a=n.createTracker(r);s&&a.move(o);let l=p$.listItem(t,e,n,{...r,...a.current()});return s&&(l=l.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,c)),l;function c(u){return u+o}}function pue(){return[qle(),hce(),yce(),rue(),uue()]}function mue(t){return{extensions:[Yle(),pce(t),xce(),cue(t),due()]}}const gue={tokenize:kue,partial:!0},m$={tokenize:Sue,partial:!0},g$={tokenize:Cue,partial:!0},y$={tokenize:Eue,partial:!0},yue={tokenize:Tue,partial:!0},x$={name:"wwwAutolink",tokenize:wue,previous:w$},v$={name:"protocolAutolink",tokenize:bue,previous:b$},va={name:"emailAutolink",tokenize:vue,previous:k$},Mo={};function xue(){return{text:Mo}}let nc=48;for(;nc<123;)Mo[nc]=va,nc++,nc===58?nc=65:nc===91&&(nc=97);Mo[43]=va;Mo[45]=va;Mo[46]=va;Mo[95]=va;Mo[72]=[va,v$];Mo[104]=[va,v$];Mo[87]=[va,x$];Mo[119]=[va,x$];function vue(t,e,n){const r=this;let i,s;return o;function o(d){return!cE(d)||!k$.call(r,r.previous)||wA(r.events)?n(d):(t.enter("literalAutolink"),t.enter("literalAutolinkEmail"),a(d))}function a(d){return cE(d)?(t.consume(d),a):d===64?(t.consume(d),l):n(d)}function l(d){return d===46?t.check(yue,u,c)(d):d===45||d===95||_r(d)?(s=!0,t.consume(d),l):u(d)}function c(d){return t.consume(d),i=!0,l}function u(d){return s&&i&&Hr(r.previous)?(t.exit("literalAutolinkEmail"),t.exit("literalAutolink"),e(d)):n(d)}}function wue(t,e,n){const r=this;return i;function i(o){return o!==87&&o!==119||!w$.call(r,r.previous)||wA(r.events)?n(o):(t.enter("literalAutolink"),t.enter("literalAutolinkWww"),t.check(gue,t.attempt(m$,t.attempt(g$,s),n),n)(o))}function s(o){return t.exit("literalAutolinkWww"),t.exit("literalAutolink"),e(o)}}function bue(t,e,n){const r=this;let i="",s=!1;return o;function o(d){return(d===72||d===104)&&b$.call(r,r.previous)&&!wA(r.events)?(t.enter("literalAutolink"),t.enter("literalAutolinkHttp"),i+=String.fromCodePoint(d),t.consume(d),a):n(d)}function a(d){if(Hr(d)&&i.length<5)return i+=String.fromCodePoint(d),t.consume(d),a;if(d===58){const h=i.toLowerCase();if(h==="http"||h==="https")return t.consume(d),l}return n(d)}function l(d){return d===47?(t.consume(d),s?c:(s=!0,l)):n(d)}function c(d){return d===null||B0(d)||Qt(d)||Cc(d)||mv(d)?n(d):t.attempt(m$,t.attempt(g$,u),n)(d)}function u(d){return t.exit("literalAutolinkHttp"),t.exit("literalAutolink"),e(d)}}function kue(t,e,n){let r=0;return i;function i(o){return(o===87||o===119)&&r<3?(r++,t.consume(o),i):o===46&&r===3?(t.consume(o),s):n(o)}function s(o){return o===null?n(o):e(o)}}function Sue(t,e,n){let r,i,s;return o;function o(c){return c===46||c===95?t.check(y$,l,a)(c):c===null||Qt(c)||Cc(c)||c!==45&&mv(c)?l(c):(s=!0,t.consume(c),o)}function a(c){return c===95?r=!0:(i=r,r=void 0),t.consume(c),o}function l(c){return i||r||!s?n(c):e(c)}}function Cue(t,e){let n=0,r=0;return i;function i(o){return o===40?(n++,t.consume(o),i):o===41&&r<n?s(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?t.check(y$,e,s)(o):o===null||Qt(o)||Cc(o)?e(o):(t.consume(o),i)}function s(o){return o===41&&r++,t.consume(o),i}}function Eue(t,e,n){return r;function r(a){return a===33||a===34||a===39||a===41||a===42||a===44||a===46||a===58||a===59||a===63||a===95||a===126?(t.consume(a),r):a===38?(t.consume(a),s):a===93?(t.consume(a),i):a===60||a===null||Qt(a)||Cc(a)?e(a):n(a)}function i(a){return a===null||a===40||a===91||Qt(a)||Cc(a)?e(a):r(a)}function s(a){return Hr(a)?o(a):n(a)}function o(a){return a===59?(t.consume(a),r):Hr(a)?(t.consume(a),o):n(a)}}function Tue(t,e,n){return r;function r(s){return t.consume(s),i}function i(s){return _r(s)?n(s):e(s)}}function w$(t){return t===null||t===40||t===42||t===95||t===91||t===93||t===126||Qt(t)}function b$(t){return!Hr(t)}function k$(t){return!(t===47||cE(t))}function cE(t){return t===43||t===45||t===46||t===95||_r(t)}function wA(t){let e=t.length,n=!1;for(;e--;){const r=t[e][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return t.length>0&&!n&&(t[t.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const Nue={tokenize:jue,partial:!0};function Aue(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:Oue,continuation:{tokenize:Rue},exit:Due}},text:{91:{name:"gfmFootnoteCall",tokenize:Pue},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:_ue,resolveTo:Mue}}}}function _ue(t,e,n){const r=this;let i=r.events.length;const s=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let o;for(;i--;){const l=r.events[i][1];if(l.type==="labelImage"){o=l;break}if(l.type==="gfmFootnoteCall"||l.type==="labelLink"||l.type==="label"||l.type==="image"||l.type==="link")break}return a;function a(l){if(!o||!o._balanced)return n(l);const c=Ts(r.sliceSerialize({start:o.end,end:r.now()}));return c.codePointAt(0)!==94||!s.includes(c.slice(1))?n(l):(t.enter("gfmFootnoteCallLabelMarker"),t.consume(l),t.exit("gfmFootnoteCallLabelMarker"),e(l))}}function Mue(t,e){let n=t.length;for(;n--;)if(t[n][1].type==="labelImage"&&t[n][0]==="enter"){t[n][1];break}t[n+1][1].type="data",t[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},t[n+3][1].start),end:Object.assign({},t[t.length-1][1].end)},i={type:"gfmFootnoteCallMarker",start:Object.assign({},t[n+3][1].end),end:Object.assign({},t[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;const s={type:"gfmFootnoteCallString",start:Object.assign({},i.end),end:Object.assign({},t[t.length-1][1].start)},o={type:"chunkString",contentType:"string",start:Object.assign({},s.start),end:Object.assign({},s.end)},a=[t[n+1],t[n+2],["enter",r,e],t[n+3],t[n+4],["enter",i,e],["exit",i,e],["enter",s,e],["enter",o,e],["exit",o,e],["exit",s,e],t[t.length-2],t[t.length-1],["exit",r,e]];return t.splice(n,t.length-n+1,...a),t}function Pue(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s=0,o;return a;function a(d){return t.enter("gfmFootnoteCall"),t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),l}function l(d){return d!==94?n(d):(t.enter("gfmFootnoteCallMarker"),t.consume(d),t.exit("gfmFootnoteCallMarker"),t.enter("gfmFootnoteCallString"),t.enter("chunkString").contentType="string",c)}function c(d){if(s>999||d===93&&!o||d===null||d===91||Qt(d))return n(d);if(d===93){t.exit("chunkString");const h=t.exit("gfmFootnoteCallString");return i.includes(Ts(r.sliceSerialize(h)))?(t.enter("gfmFootnoteCallLabelMarker"),t.consume(d),t.exit("gfmFootnoteCallLabelMarker"),t.exit("gfmFootnoteCall"),e):n(d)}return Qt(d)||(o=!0),s++,t.consume(d),d===92?u:c}function u(d){return d===91||d===92||d===93?(t.consume(d),s++,c):c(d)}}function Oue(t,e,n){const r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let s,o=0,a;return l;function l(y){return t.enter("gfmFootnoteDefinition")._container=!0,t.enter("gfmFootnoteDefinitionLabel"),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(y),t.exit("gfmFootnoteDefinitionLabelMarker"),c}function c(y){return y===94?(t.enter("gfmFootnoteDefinitionMarker"),t.consume(y),t.exit("gfmFootnoteDefinitionMarker"),t.enter("gfmFootnoteDefinitionLabelString"),t.enter("chunkString").contentType="string",u):n(y)}function u(y){if(o>999||y===93&&!a||y===null||y===91||Qt(y))return n(y);if(y===93){t.exit("chunkString");const v=t.exit("gfmFootnoteDefinitionLabelString");return s=Ts(r.sliceSerialize(v)),t.enter("gfmFootnoteDefinitionLabelMarker"),t.consume(y),t.exit("gfmFootnoteDefinitionLabelMarker"),t.exit("gfmFootnoteDefinitionLabel"),h}return Qt(y)||(a=!0),o++,t.consume(y),y===92?d:u}function d(y){return y===91||y===92||y===93?(t.consume(y),o++,u):u(y)}function h(y){return y===58?(t.enter("definitionMarker"),t.consume(y),t.exit("definitionMarker"),i.includes(s)||i.push(s),Pt(t,m,"gfmFootnoteDefinitionWhitespace")):n(y)}function m(y){return e(y)}}function Rue(t,e,n){return t.check(fm,e,t.attempt(Nue,e,n))}function Due(t){t.exit("gfmFootnoteDefinition")}function jue(t,e,n){const r=this;return Pt(t,i,"gfmFootnoteDefinitionIndent",5);function i(s){const o=r.events[r.events.length-1];return o&&o[1].type==="gfmFootnoteDefinitionIndent"&&o[2].sliceSerialize(o[1],!0).length===4?e(s):n(s)}}function Iue(t){let n=(t||{}).singleTilde;const r={name:"strikethrough",tokenize:s,resolveAll:i};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},attentionMarkers:{null:[126]}};function i(o,a){let l=-1;for(;++l<o.length;)if(o[l][0]==="enter"&&o[l][1].type==="strikethroughSequenceTemporary"&&o[l][1]._close){let c=l;for(;c--;)if(o[c][0]==="exit"&&o[c][1].type==="strikethroughSequenceTemporary"&&o[c][1]._open&&o[l][1].end.offset-o[l][1].start.offset===o[c][1].end.offset-o[c][1].start.offset){o[l][1].type="strikethroughSequence",o[c][1].type="strikethroughSequence";const u={type:"strikethrough",start:Object.assign({},o[c][1].start),end:Object.assign({},o[l][1].end)},d={type:"strikethroughText",start:Object.assign({},o[c][1].end),end:Object.assign({},o[l][1].start)},h=[["enter",u,a],["enter",o[c][1],a],["exit",o[c][1],a],["enter",d,a]],m=a.parser.constructs.insideSpan.null;m&&Mi(h,h.length,0,gv(m,o.slice(c+1,l),a)),Mi(h,h.length,0,[["exit",d,a],["enter",o[l][1],a],["exit",o[l][1],a],["exit",u,a]]),Mi(o,c-1,l-c+3,h),l=c+h.length-2;break}}for(l=-1;++l<o.length;)o[l][1].type==="strikethroughSequenceTemporary"&&(o[l][1].type="data");return o}function s(o,a,l){const c=this.previous,u=this.events;let d=0;return h;function h(y){return c===126&&u[u.length-1][1].type!=="characterEscape"?l(y):(o.enter("strikethroughSequenceTemporary"),m(y))}function m(y){const v=pd(c);if(y===126)return d>1?l(y):(o.consume(y),d++,m);if(d<2&&!n)return l(y);const w=o.exit("strikethroughSequenceTemporary"),b=pd(y);return w._open=!b||b===2&&!!v,w._close=!v||v===2&&!!b,a(y)}}}class Lue{constructor(){this.map=[]}add(e,n,r){Fue(this,e,n,r)}consume(e){if(this.map.sort(function(s,o){return s[0]-o[0]}),this.map.length===0)return;let n=this.map.length;const r=[];for(;n>0;)n-=1,r.push(e.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),e.length=this.map[n][0];r.push(e.slice()),e.length=0;let i=r.pop();for(;i;){for(const s of i)e.push(s);i=r.pop()}this.map.length=0}}function Fue(t,e,n,r){let i=0;if(!(n===0&&r.length===0)){for(;i<t.map.length;){if(t.map[i][0]===e){t.map[i][1]+=n,t.map[i][2].push(...r);return}i+=1}t.map.push([e,n,r])}}function Bue(t,e){let n=!1;const r=[];for(;e<t.length;){const i=t[e];if(n){if(i[0]==="enter")i[1].type==="tableContent"&&r.push(t[e+1][1].type==="tableDelimiterMarker"?"left":"none");else if(i[1].type==="tableContent"){if(t[e-1][1].type==="tableDelimiterMarker"){const s=r.length-1;r[s]=r[s]==="left"?"center":"right"}}else if(i[1].type==="tableDelimiterRow")break}else i[0]==="enter"&&i[1].type==="tableDelimiterRow"&&(n=!0);e+=1}return r}function $ue(){return{flow:{null:{name:"table",tokenize:zue,resolveAll:Vue}}}}function zue(t,e,n){const r=this;let i=0,s=0,o;return a;function a(R){let B=r.events.length-1;for(;B>-1;){const I=r.events[B][1].type;if(I==="lineEnding"||I==="linePrefix")B--;else break}const F=B>-1?r.events[B][1].type:null,W=F==="tableHead"||F==="tableRow"?A:l;return W===A&&r.parser.lazy[r.now().line]?n(R):W(R)}function l(R){return t.enter("tableHead"),t.enter("tableRow"),c(R)}function c(R){return R===124||(o=!0,s+=1),u(R)}function u(R){return R===null?n(R):st(R)?s>1?(s=0,r.interrupt=!0,t.exit("tableRow"),t.enter("lineEnding"),t.consume(R),t.exit("lineEnding"),m):n(R):Nt(R)?Pt(t,u,"whitespace")(R):(s+=1,o&&(o=!1,i+=1),R===124?(t.enter("tableCellDivider"),t.consume(R),t.exit("tableCellDivider"),o=!0,u):(t.enter("data"),d(R)))}function d(R){return R===null||R===124||Qt(R)?(t.exit("data"),u(R)):(t.consume(R),R===92?h:d)}function h(R){return R===92||R===124?(t.consume(R),d):d(R)}function m(R){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(R):(t.enter("tableDelimiterRow"),o=!1,Nt(R)?Pt(t,y,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(R):y(R))}function y(R){return R===45||R===58?w(R):R===124?(o=!0,t.enter("tableCellDivider"),t.consume(R),t.exit("tableCellDivider"),v):_(R)}function v(R){return Nt(R)?Pt(t,w,"whitespace")(R):w(R)}function w(R){return R===58?(s+=1,o=!0,t.enter("tableDelimiterMarker"),t.consume(R),t.exit("tableDelimiterMarker"),b):R===45?(s+=1,b(R)):R===null||st(R)?T(R):_(R)}function b(R){return R===45?(t.enter("tableDelimiterFiller"),k(R)):_(R)}function k(R){return R===45?(t.consume(R),k):R===58?(o=!0,t.exit("tableDelimiterFiller"),t.enter("tableDelimiterMarker"),t.consume(R),t.exit("tableDelimiterMarker"),C):(t.exit("tableDelimiterFiller"),C(R))}function C(R){return Nt(R)?Pt(t,T,"whitespace")(R):T(R)}function T(R){return R===124?y(R):R===null||st(R)?!o||i!==s?_(R):(t.exit("tableDelimiterRow"),t.exit("tableHead"),e(R)):_(R)}function _(R){return n(R)}function A(R){return t.enter("tableRow"),M(R)}function M(R){return R===124?(t.enter("tableCellDivider"),t.consume(R),t.exit("tableCellDivider"),M):R===null||st(R)?(t.exit("tableRow"),e(R)):Nt(R)?Pt(t,M,"whitespace")(R):(t.enter("data"),O(R))}function O(R){return R===null||R===124||Qt(R)?(t.exit("data"),M(R)):(t.consume(R),R===92?D:O)}function D(R){return R===92||R===124?(t.consume(R),O):O(R)}}function Vue(t,e){let n=-1,r=!0,i=0,s=[0,0,0,0],o=[0,0,0,0],a=!1,l=0,c,u,d;const h=new Lue;for(;++n<t.length;){const m=t[n],y=m[1];m[0]==="enter"?y.type==="tableHead"?(a=!1,l!==0&&(mD(h,e,l,c,u),u=void 0,l=0),c={type:"table",start:Object.assign({},y.start),end:Object.assign({},y.end)},h.add(n,0,[["enter",c,e]])):y.type==="tableRow"||y.type==="tableDelimiterRow"?(r=!0,d=void 0,s=[0,0,0,0],o=[0,n+1,0,0],a&&(a=!1,u={type:"tableBody",start:Object.assign({},y.start),end:Object.assign({},y.end)},h.add(n,0,[["enter",u,e]])),i=y.type==="tableDelimiterRow"?2:u?3:1):i&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")?(r=!1,o[2]===0&&(s[1]!==0&&(o[0]=o[1],d=dy(h,e,s,i,void 0,d),s=[0,0,0,0]),o[2]=n)):y.type==="tableCellDivider"&&(r?r=!1:(s[1]!==0&&(o[0]=o[1],d=dy(h,e,s,i,void 0,d)),s=o,o=[s[1],n,0,0])):y.type==="tableHead"?(a=!0,l=n):y.type==="tableRow"||y.type==="tableDelimiterRow"?(l=n,s[1]!==0?(o[0]=o[1],d=dy(h,e,s,i,n,d)):o[1]!==0&&(d=dy(h,e,o,i,n,d)),i=0):i&&(y.type==="data"||y.type==="tableDelimiterMarker"||y.type==="tableDelimiterFiller")&&(o[3]=n)}for(l!==0&&mD(h,e,l,c,u),h.consume(e.events),n=-1;++n<e.events.length;){const m=e.events[n];m[0]==="enter"&&m[1].type==="table"&&(m[1]._align=Bue(e.events,n))}return t}function dy(t,e,n,r,i,s){const o=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",a="tableContent";n[0]!==0&&(s.end=Object.assign({},Mu(e.events,n[0])),t.add(n[0],0,[["exit",s,e]]));const l=Mu(e.events,n[1]);if(s={type:o,start:Object.assign({},l),end:Object.assign({},l)},t.add(n[1],0,[["enter",s,e]]),n[2]!==0){const c=Mu(e.events,n[2]),u=Mu(e.events,n[3]),d={type:a,start:Object.assign({},c),end:Object.assign({},u)};if(t.add(n[2],0,[["enter",d,e]]),r!==2){const h=e.events[n[2]],m=e.events[n[3]];if(h[1].end=Object.assign({},m[1].end),h[1].type="chunkText",h[1].contentType="text",n[3]>n[2]+1){const y=n[2]+1,v=n[3]-n[2]-1;t.add(y,v,[])}}t.add(n[3]+1,0,[["exit",d,e]])}return i!==void 0&&(s.end=Object.assign({},Mu(e.events,i)),t.add(i,0,[["exit",s,e]]),s=void 0),s}function mD(t,e,n,r,i){const s=[],o=Mu(e.events,n);i&&(i.end=Object.assign({},o),s.push(["exit",i,e])),r.end=Object.assign({},o),s.push(["exit",r,e]),t.add(n+1,0,s)}function Mu(t,e){const n=t[e],r=n[0]==="enter"?"start":"end";return n[1][r]}const Wue={name:"tasklistCheck",tokenize:Uue};function Hue(){return{text:{91:Wue}}}function Uue(t,e,n){const r=this;return i;function i(l){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(l):(t.enter("taskListCheck"),t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),s)}function s(l){return Qt(l)?(t.enter("taskListCheckValueUnchecked"),t.consume(l),t.exit("taskListCheckValueUnchecked"),o):l===88||l===120?(t.enter("taskListCheckValueChecked"),t.consume(l),t.exit("taskListCheckValueChecked"),o):n(l)}function o(l){return l===93?(t.enter("taskListCheckMarker"),t.consume(l),t.exit("taskListCheckMarker"),t.exit("taskListCheck"),a):n(l)}function a(l){return st(l)?e(l):Nt(l)?t.check({tokenize:que},e,n)(l):n(l)}}function que(t,e,n){return Pt(t,r,"whitespace");function r(i){return i===null?n(i):e(i)}}function Yue(t){return RB([xue(),Aue(),Iue(t),$ue(),Hue()])}const Gue={};function Kue(t){const e=this,n=t||Gue,r=e.data(),i=r.micromarkExtensions||(r.micromarkExtensions=[]),s=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),o=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);i.push(Yue(n)),s.push(pue()),o.push(mue(n))}const Zue="modulepreload",Xue=function(t){return"/"+t},gD={},Que=function(e,n,r){let i=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),a=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));i=Promise.allSettled(n.map(l=>{if(l=Xue(l),l in gD)return;gD[l]=!0;const c=l.endsWith(".css"),u=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${u}`))return;const d=document.createElement("link");if(d.rel=c?"stylesheet":Zue,c||(d.as="script"),d.crossOrigin="",d.href=l,a&&d.setAttribute("nonce",a),document.head.appendChild(d),c)return new Promise((h,m)=>{d.addEventListener("load",h),d.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${l}`)))})}))}function s(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return i.then(o=>{for(const a of o||[])a.status==="rejected"&&s(a.reason);return e().catch(s)})};async function Jue(t,e){const{codeToTokens:n,bundledLanguages:r}=await Que(async()=>{const{codeToTokens:s,bundledLanguages:o}=await import("./index-BfbQ83X8.js");return{codeToTokens:s,bundledLanguages:o}},[]);if(!(e in r))return null;const{tokens:i}=await n(t,{lang:e,defaultColor:!1,themes:{light:"github-light",dark:"github-dark"}});return i}function ede({children:t}){const e=t.replace(/\\n/g,`
287
287
  `);return g.jsx(Ble,{remarkPlugins:[Kue],components:nde,className:"space-y-3",children:e})}const S$=ne.memo(({children:t,language:e,...n})=>{const[r,i]=S.useState([]);return S.useEffect(()=>{Jue(t,e).then(s=>{s&&i(s)})},[t,e]),r.length?g.jsx("pre",{...n,children:g.jsx("code",{children:r.map((s,o)=>g.jsxs(g.Fragment,{children:[g.jsx("span",{children:s.map((a,l)=>{const c=typeof a.htmlStyle=="string"?void 0:a.htmlStyle;return g.jsx("span",{className:"text-shiki-light bg-shiki-light-bg dark:text-shiki-dark dark:bg-shiki-dark-bg",style:c,children:a.content},l)})},o),o!==r.length-1&&`
288
288
  `]}))})}):g.jsx("pre",{...n,children:t})});S$.displayName="HighlightedCode";const tde=({children:t,className:e,language:n,...r})=>{const i=typeof t=="string"?t:uE(t),s=ve("overflow-x-scroll rounded-md border bg-background/50 p-4 font-mono text-sm [scrollbar-width:none]",e);return g.jsxs("div",{className:"group/code relative mb-4",children:[g.jsx(S.Suspense,{fallback:g.jsx("pre",{className:s,...r,children:t}),children:g.jsx(S$,{language:n,className:s,children:i})}),g.jsx("div",{className:"invisible absolute right-2 top-2 flex space-x-1 rounded-lg p-1 opacity-0 transition-all duration-200 group-hover/code:visible group-hover/code:opacity-100",children:g.jsx(F0,{content:i,copyMessage:"Copied code to clipboard"})})]})};function uE(t){var e;if(typeof t=="string")return t;if((e=t==null?void 0:t.props)!=null&&e.children){let n=t.props.children;return Array.isArray(n)?n.map(r=>uE(r)).join(""):uE(n)}return""}const nde={h1:hr("h1","text-2xl font-semibold"),h2:hr("h2","font-semibold text-xl"),h3:hr("h3","font-semibold text-lg"),h4:hr("h4","font-semibold text-base"),h5:hr("h5","font-medium"),strong:hr("strong","font-semibold"),a:hr("a","underline underline-offset-2"),blockquote:hr("blockquote","border-l-2 border-primary pl-4"),code:({children:t,className:e,node:n,...r})=>{const i=/language-(\w+)/.exec(e||"");return i?g.jsx(tde,{className:e,language:i[1],...r,children:t}):g.jsx("code",{className:ve("font-mono [:not(pre)>&]:rounded-md [:not(pre)>&]:bg-background/50 [:not(pre)>&]:px-1 [:not(pre)>&]:py-0.5"),...r,children:t})},pre:({children:t})=>t,ol:hr("ol","list-decimal space-y-2 pl-6"),ul:hr("ul","list-disc space-y-2 pl-6"),li:hr("li","my-1.5"),table:hr("table","w-full border-collapse overflow-y-auto rounded-md border border-foreground/20"),th:hr("th","border border-foreground/20 px-4 py-2 text-left font-bold [&[align=center]]:text-center [&[align=right]]:text-right"),td:hr("td","border border-foreground/20 px-4 py-2 text-left [&[align=center]]:text-center [&[align=right]]:text-right"),tr:hr("tr","m-0 border-t p-0 even:bg-muted"),p:hr("p","whitespace-pre-wrap leading-relaxed"),hr:hr("hr","border-foreground/20")};function hr(t,e){const n=({node:r,...i})=>g.jsx(t,{className:e,...i});return n.displayName=t,n}const rde=qd("group/message relative break-words rounded-lg p-3 text-sm sm:max-w-[70%]",{variants:{isUser:{true:"bg-primary text-primary-foreground",false:"bg-muted text-foreground"},isError:{true:"bg-red-100 dark:bg-red-900/20",false:""},animation:{none:"",slide:"duration-300 animate-in fade-in-0",scale:"duration-300 animate-in fade-in-0 zoom-in-75",fade:"duration-500 animate-in fade-in-0"}},compoundVariants:[{isUser:!0,animation:"slide",class:"slide-in-from-right"},{isUser:!1,animation:"slide",class:"slide-in-from-left"},{isUser:!0,animation:"scale",class:"origin-bottom-right"},{isUser:!1,animation:"scale",class:"origin-bottom-left"}]}),ide=({role:t,content:e,createdAt:n,showTimeStamp:r=!1,animation:i="scale",actions:s,className:o,experimental_attachments:a,isError:l=!1})=>{const c=t==="user",u=S.useMemo(()=>a==null?void 0:a.map(h=>{const m=sde(h.url);return new File([m],h.name??"Unknown")}),[a]),d=n==null?void 0:n.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"});return g.jsxs("div",{className:ve("flex flex-col",c?"items-end":"items-start"),children:[u?g.jsx("div",{className:"mb-1 flex gap-2 flex-wrap",children:u.map((h,m)=>g.jsx(nA,{file:h},m))}):null,g.jsxs("div",{className:ve(rde({isUser:c,isError:l,animation:i}),o),children:[g.jsx("div",{children:g.jsx(ede,{children:e})}),t==="assistant"&&s?g.jsx("div",{className:"absolute -bottom-4 right-2 flex space-x-1 rounded-lg border bg-background p-1 opacity-0 transition-opacity group-hover/message:opacity-100 text-foreground",children:s}):null]}),r&&n?g.jsx("time",{dateTime:n.toISOString(),className:ve("mt-1 block px-1 text-xs opacity-50",i!=="none"&&"duration-500 animate-in fade-in-0"),children:d}):null]})};function sde(t){const e=t.split(",")[1],n=Buffer.from(e??"","base64");return new Uint8Array(n)}function ode(){return g.jsx("div",{className:"justify-left flex space-x-1",children:g.jsx("div",{className:"rounded-lg bg-muted p-3",children:g.jsxs("div",{className:"flex -space-x-2.5",children:[g.jsx(S1,{className:"h-5 w-5 animate-typing-dot-bounce"}),g.jsx(S1,{className:"h-5 w-5 animate-typing-dot-bounce [animation-delay:90ms]"}),g.jsx(S1,{className:"h-5 w-5 animate-typing-dot-bounce [animation-delay:180ms]"})]})})})}function ade({messages:t,showTimeStamps:e=!0,isTyping:n=!1,messageOptions:r}){return g.jsxs("div",{className:"space-y-4 overflow-visible",children:[t.map((i,s)=>{const o=typeof r=="function"?r(i):r;return i.role==="assistant"&&!i.content.trim()?null:g.jsx(ide,{showTimeStamp:e,...i,...o},s)}),n&&g.jsx(ode,{})]})}function lde({label:t,append:e,suggestions:n}){return g.jsxs("div",{className:"space-y-6",children:[g.jsx("h2",{className:"text-center text-2xl font-bold",children:t}),g.jsx("div",{className:"flex flex-col sm:flex-row gap-6 text-sm items-center justify-center",children:n.map(r=>g.jsx("button",{onClick:()=>e({role:"user",content:r}),className:"h-max rounded-xl border bg-transparent p-4 hover:bg-accent",children:g.jsx("p",{children:r})},r))})]})}const cde=50;function ude(t){const e=S.useRef(null),n=S.useRef(null),[r,i]=S.useState(!0),s=()=>{e.current&&(e.current.scrollTop=e.current.scrollHeight)},o=()=>{if(e.current){const{scrollTop:l,scrollHeight:c,clientHeight:u}=e.current;if(n.current?l<n.current:!1)i(!1);else{const h=Math.abs(c-l-u)<cde;i(h)}n.current=l}},a=()=>{i(!1)};return S.useEffect(()=>{e.current&&(n.current=e.current.scrollTop)},[]),S.useEffect(()=>{r&&s()},t),{containerRef:e,scrollToBottom:s,handleScroll:o,shouldAutoScroll:r,handleTouchStart:a}}function dde({messages:t,children:e}){const{containerRef:n,scrollToBottom:r,handleScroll:i,shouldAutoScroll:s,handleTouchStart:o}=ude([t]);return g.jsxs("div",{className:"grid overflow-y-auto pb-4 grid-cols-1",ref:n,onScroll:i,onTouchStart:o,children:[g.jsx("div",{className:"[grid-column:1/1] [grid-row:1/1] max-w-full",children:e}),g.jsx("div",{className:"flex justify-end items-end [grid-column:1/1] [grid-row:1/1] flex-1",children:!s&&g.jsx("div",{className:"sticky bottom-0 left-0 flex w-full justify-end",children:g.jsx(pt,{onClick:r,className:"h-8 w-8 rounded-full ease-in-out animate-in fade-in-0 slide-in-from-bottom-1",size:"icon",variant:"ghost",children:g.jsx(rX,{className:"h-4 w-4"})})})})]})}const C$=S.forwardRef(({className:t,...e},n)=>g.jsx("div",{ref:n,className:ve("grid max-h-full w-full grid-rows-[1fr_auto]",t),...e}));C$.displayName="ChatContainer";const E$=S.forwardRef(({children:t,handleSubmit:e,isPending:n,className:r},i)=>{const[s,o]=S.useState(null),a=l=>{if(n){l.preventDefault();return}if(!s){e(l);return}const c=fde(s);e(l,{experimental_attachments:c}),o(null)};return g.jsx("form",{ref:i,onSubmit:a,className:r,children:t({files:s,setFiles:o})})});E$.displayName="ChatForm";function fde(t){const e=new DataTransfer;for(const n of Array.from(t))e.items.add(n);return e.files}function hde({agentId:t,initialMessages:e=[],agentName:n,threadId:r,memory:i}){const[s,o]=S.useState(e),[a,l]=S.useState(""),[c,u]=S.useState(!1),{mutate:d}=JN();S.useEffect(()=>{e&&o(e)},[e]);const h=S.useCallback(C=>{l(C.target.value)},[]),m=async C=>{var M;if((M=C==null?void 0:C.preventDefault)==null||M.call(C),!a.trim()||c)return;const T=a;l(""),u(!0);const _={id:Date.now().toString(),role:"user",content:T},A={id:(Date.now()+1).toString(),role:"assistant",content:""};o(O=>[...O,_,A]);try{const O=await fetch("/api/agents/"+t+"/stream",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:[T],runId:t,...i?{threadId:r,resourceid:t}:{}})});if(!O.body)throw new Error("No response body");if(O.status!==200){const I=await O.json();throw new Error(I.message)}d(`/api/memory/threads?resourceid=${t}&agentId=${t}`);const D=O.body.getReader(),R=new TextDecoder;let B="",F="",W="";try{for(;;){const{done:I,value:Y}=await D.read();if(I)break;const V=R.decode(Y);B+=V;const G=B.matchAll(/0:"((?:\\.|(?!").)*?)"/g),H=B.matchAll(/3:"((?:\\.|(?!").)*?)"/g);if(H)for(const z of H){const L=z[1];W+=L,o(q=>[...q.slice(0,-1),{...q[q.length-1],content:W,isError:!0}])}for(const z of G){const L=z[1].replace(/\\"/g,'"');F+=L,o(q=>[...q.slice(0,-1),{...q[q.length-1],content:F}])}B=""}}catch(I){throw new Error(I.message)}finally{D.releaseLock()}}catch(O){o(D=>[...D.slice(0,-1),{...D[D.length-1],content:(O==null?void 0:O.message)||"An error occurred while processing your request.",isError:!0}])}finally{u(!1)}},y=s.at(-1),v=s.length===0,w=c&&(y==null?void 0:y.role)==="assistant"&&!(y!=null&&y.content.trim()),b=S.useCallback(C=>{l(C.content),m()},[m]),k=["What capabilities do you have?","How can you help me?","Tell me about yourself"];return g.jsxs(C$,{className:"h-full px-4 pb-3 pt-4 max-w-[1000px] mx-auto",children:[g.jsx("div",{className:"flex flex-col h-full",children:v?g.jsx("div",{className:"mx-auto max-w-2xl",children:g.jsx(lde,{label:`Chat with ${n}`,append:b,suggestions:k})}):g.jsx(zn,{className:" h-[calc(100vh-15rem)] px-4",children:g.jsx(dde,{messages:s,children:g.jsx(ade,{messages:s,isTyping:w})})})}),g.jsxs("div",{className:"flex flex-col mt-auto gap-2",children:[g.jsx(E$,{isPending:c||w,handleSubmit:m,children:({files:C,setFiles:T})=>g.jsx(yB,{value:a,onChange:h,files:C,setFiles:T,isGenerating:c,placeholder:"Enter your message..."})}),!i&&g.jsxs("div",{className:"flex items-center gap-1 text-sm text-mastra-el-5",children:[g.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-purple-400",children:[g.jsx("circle",{cx:"12",cy:"12",r:"10"}),g.jsx("path",{d:"M12 16v-4"}),g.jsx("path",{d:"M12 8h.01"})]}),g.jsxs("span",{className:"text-xs text-gray-300/60",children:["Agent will not remember previous messages. To enable memory for agent see"," ",g.jsx("a",{href:"https://mastra.ai/docs/agents/01-agent-memory",target:"_blank",rel:"noopener",className:"text-gray-300/60 hover:text-gray-100 underline",children:"docs."})]})]})]})]})}function bA(t){const e=t+"CollectionProvider",[n,r]=Ii(e),[i,s]=n(e,{collectionRef:{current:null},itemMap:new Map}),o=m=>{const{scope:y,children:v}=m,w=ne.useRef(null),b=ne.useRef(new Map).current;return g.jsx(i,{scope:y,itemMap:b,collectionRef:w,children:v})};o.displayName=e;const a=t+"CollectionSlot",l=ne.forwardRef((m,y)=>{const{scope:v,children:w}=m,b=s(a,v),k=kt(y,b.collectionRef);return g.jsx(yo,{ref:k,children:w})});l.displayName=a;const c=t+"CollectionItemSlot",u="data-radix-collection-item",d=ne.forwardRef((m,y)=>{const{scope:v,children:w,...b}=m,k=ne.useRef(null),C=kt(y,k),T=s(c,v);return ne.useEffect(()=>(T.itemMap.set(k,{ref:k,...b}),()=>void T.itemMap.delete(k))),g.jsx(yo,{[u]:"",ref:C,children:w})});d.displayName=c;function h(m){const y=s(t+"CollectionConsumer",m);return ne.useCallback(()=>{const w=y.collectionRef.current;if(!w)return[];const b=Array.from(w.querySelectorAll(`[${u}]`));return Array.from(y.itemMap.values()).sort((T,_)=>b.indexOf(T.ref.current)-b.indexOf(_.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:o,Slot:l,ItemSlot:d},h,r]}var pde=SK.useId||(()=>{}),mde=0;function Vn(t){const[e,n]=S.useState(pde());return Mr(()=>{n(r=>r??String(mde++))},[t]),e?`radix-${e}`:""}function bo({prop:t,defaultProp:e,onChange:n=()=>{}}){const[r,i]=gde({defaultProp:e,onChange:n}),s=t!==void 0,o=s?t:r,a=Fn(n),l=S.useCallback(c=>{if(s){const d=typeof c=="function"?c(t):c;d!==t&&a(d)}else i(c)},[s,t,i,a]);return[o,l]}function gde({defaultProp:t,onChange:e}){const n=S.useState(t),[r]=n,i=S.useRef(r),s=Fn(e);return S.useEffect(()=>{i.current!==r&&(s(r),i.current=r)},[r,i,s]),n}var lk="rovingFocusGroup.onEntryFocus",yde={bubbles:!1,cancelable:!0},wv="RovingFocusGroup",[dE,T$,xde]=bA(wv),[vde,bv]=Ii(wv,[xde]),[wde,bde]=vde(wv),N$=S.forwardRef((t,e)=>g.jsx(dE.Provider,{scope:t.__scopeRovingFocusGroup,children:g.jsx(dE.Slot,{scope:t.__scopeRovingFocusGroup,children:g.jsx(kde,{...t,ref:e})})}));N$.displayName=wv;var kde=S.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:o,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:c,preventScrollOnEntryFocus:u=!1,...d}=t,h=S.useRef(null),m=kt(e,h),y=im(s),[v=null,w]=bo({prop:o,defaultProp:a,onChange:l}),[b,k]=S.useState(!1),C=Fn(c),T=T$(n),_=S.useRef(!1),[A,M]=S.useState(0);return S.useEffect(()=>{const O=h.current;if(O)return O.addEventListener(lk,C),()=>O.removeEventListener(lk,C)},[C]),g.jsx(wde,{scope:n,orientation:r,dir:y,loop:i,currentTabStopId:v,onItemFocus:S.useCallback(O=>w(O),[w]),onItemShiftTab:S.useCallback(()=>k(!0),[]),onFocusableItemAdd:S.useCallback(()=>M(O=>O+1),[]),onFocusableItemRemove:S.useCallback(()=>M(O=>O-1),[]),children:g.jsx(Xe.div,{tabIndex:b||A===0?-1:0,"data-orientation":r,...d,ref:m,style:{outline:"none",...t.style},onMouseDown:Re(t.onMouseDown,()=>{_.current=!0}),onFocus:Re(t.onFocus,O=>{const D=!_.current;if(O.target===O.currentTarget&&D&&!b){const R=new CustomEvent(lk,yde);if(O.currentTarget.dispatchEvent(R),!R.defaultPrevented){const B=T().filter(V=>V.focusable),F=B.find(V=>V.active),W=B.find(V=>V.id===v),Y=[F,W,...B].filter(Boolean).map(V=>V.ref.current);M$(Y,u)}}_.current=!1}),onBlur:Re(t.onBlur,()=>k(!1))})})}),A$="RovingFocusGroupItem",_$=S.forwardRef((t,e)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,...o}=t,a=Vn(),l=s||a,c=bde(A$,n),u=c.currentTabStopId===l,d=T$(n),{onFocusableItemAdd:h,onFocusableItemRemove:m}=c;return S.useEffect(()=>{if(r)return h(),()=>m()},[r,h,m]),g.jsx(dE.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:g.jsx(Xe.span,{tabIndex:u?0:-1,"data-orientation":c.orientation,...o,ref:e,onMouseDown:Re(t.onMouseDown,y=>{r?c.onItemFocus(l):y.preventDefault()}),onFocus:Re(t.onFocus,()=>c.onItemFocus(l)),onKeyDown:Re(t.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){c.onItemShiftTab();return}if(y.target!==y.currentTarget)return;const v=Ede(y,c.orientation,c.dir);if(v!==void 0){if(y.metaKey||y.ctrlKey||y.altKey||y.shiftKey)return;y.preventDefault();let b=d().filter(k=>k.focusable).map(k=>k.ref.current);if(v==="last")b.reverse();else if(v==="prev"||v==="next"){v==="prev"&&b.reverse();const k=b.indexOf(y.currentTarget);b=c.loop?Tde(b,k+1):b.slice(k+1)}setTimeout(()=>M$(b))}})})})});_$.displayName=A$;var Sde={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function Cde(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function Ede(t,e,n){const r=Cde(t.key,n);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return Sde[r]}function M$(t,e=!1){const n=document.activeElement;for(const r of t)if(r===n||(r.focus({preventScroll:e}),document.activeElement!==n))return}function Tde(t,e){return t.map((n,r)=>t[(e+r)%t.length])}var P$=N$,O$=_$,kA="Tabs",[Nde,g4e]=Ii(kA,[bv]),R$=bv(),[Ade,SA]=Nde(kA),D$=S.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,onValueChange:i,defaultValue:s,orientation:o="horizontal",dir:a,activationMode:l="automatic",...c}=t,u=im(a),[d,h]=bo({prop:r,onChange:i,defaultProp:s});return g.jsx(Ade,{scope:n,baseId:Vn(),value:d,onValueChange:h,orientation:o,dir:u,activationMode:l,children:g.jsx(Xe.div,{dir:u,"data-orientation":o,...c,ref:e})})});D$.displayName=kA;var j$="TabsList",I$=S.forwardRef((t,e)=>{const{__scopeTabs:n,loop:r=!0,...i}=t,s=SA(j$,n),o=R$(n);return g.jsx(P$,{asChild:!0,...o,orientation:s.orientation,dir:s.dir,loop:r,children:g.jsx(Xe.div,{role:"tablist","aria-orientation":s.orientation,...i,ref:e})})});I$.displayName=j$;var L$="TabsTrigger",F$=S.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,disabled:i=!1,...s}=t,o=SA(L$,n),a=R$(n),l=z$(o.baseId,r),c=V$(o.baseId,r),u=r===o.value;return g.jsx(O$,{asChild:!0,...a,focusable:!i,active:u,children:g.jsx(Xe.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":c,"data-state":u?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:l,...s,ref:e,onMouseDown:Re(t.onMouseDown,d=>{!i&&d.button===0&&d.ctrlKey===!1?o.onValueChange(r):d.preventDefault()}),onKeyDown:Re(t.onKeyDown,d=>{[" ","Enter"].includes(d.key)&&o.onValueChange(r)}),onFocus:Re(t.onFocus,()=>{const d=o.activationMode!=="manual";!u&&!i&&d&&o.onValueChange(r)})})})});F$.displayName=L$;var B$="TabsContent",$$=S.forwardRef((t,e)=>{const{__scopeTabs:n,value:r,forceMount:i,children:s,...o}=t,a=SA(B$,n),l=z$(a.baseId,r),c=V$(a.baseId,r),u=r===a.value,d=S.useRef(u);return S.useEffect(()=>{const h=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(h)},[]),g.jsx(Rr,{present:i||u,children:({present:h})=>g.jsx(Xe.div,{"data-state":u?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":l,hidden:!h,id:c,tabIndex:0,...o,ref:e,style:{...t.style,animationDuration:d.current?"0s":void 0},children:h&&s})})});$$.displayName=B$;function z$(t,e){return`${t}-trigger-${e}`}function V$(t,e){return`${t}-content-${e}`}var _de=D$,W$=I$,H$=F$,U$=$$;const CA=_de,kv=S.forwardRef(({className:t,...e},n)=>g.jsx(W$,{ref:n,className:ve(t),...e}));kv.displayName=W$.displayName;const io=S.forwardRef(({className:t,...e},n)=>g.jsx(H$,{ref:n,className:ve(t),...e}));io.displayName=H$.displayName;const so=S.forwardRef(({className:t,...e},n)=>g.jsx(U$,{ref:n,className:ve("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",t),...e}));so.displayName=U$.displayName;function Mde({agentId:t}){var i;const{isLoading:e,agent:n}=Vc(t),r=Ao();return e?g.jsx(zn,{className:"h-[calc(100vh-126px)] pt-2 px-4 pb-4 text-xs",children:g.jsxs("div",{className:"space-y-4",children:[g.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2",children:[g.jsx(qe,{className:"h-3"}),g.jsx(qe,{className:"h-3"})]}),g.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2",children:[g.jsx(qe,{className:"h-3"}),g.jsx(qe,{className:"h-3"})]}),g.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2",children:[g.jsx(qe,{className:"h-3"}),g.jsx(qe,{className:"h-3"})]}),g.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2",children:[g.jsx(qe,{className:"h-3"}),g.jsx(qe,{className:"h-3"})]}),g.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2",children:[g.jsx(qe,{className:"h-3"}),g.jsxs("div",{className:"flex flex-col gap-2",children:[g.jsx(qe,{className:"h-3"}),g.jsx(qe,{className:"h-3"}),g.jsx(qe,{className:"h-3"})]})]})]})}):g.jsx(zn,{className:"h-[calc(100vh-126px)] pt-2 px-4 pb-4 text-xs",children:g.jsxs("div",{className:"space-y-4",children:[g.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2",children:[g.jsx("p",{className:"text-mastra-el-3",children:"Name"}),g.jsx("p",{className:"text-mastra-el-5",children:n==null?void 0:n.name})]}),g.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2",children:[g.jsx("p",{className:"text-mastra-el-3",children:"Instructions"}),g.jsx("p",{className:"text-mastra-el-5 whitespace-pre-wrap",children:n==null?void 0:n.instructions})]}),g.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2",children:[g.jsx("p",{className:"text-mastra-el-3",children:"Model"}),g.jsx("p",{className:"text-mastra-el-5",children:n==null?void 0:n.modelId})]}),g.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2",children:[g.jsx("p",{className:"text-mastra-el-3",children:"Provider"}),g.jsx("p",{className:"text-mastra-el-5",children:(i=n==null?void 0:n.provider)==null?void 0:i.split(".")[0].toUpperCase()})]}),g.jsxs("div",{className:"grid grid-cols-[100px_1fr] gap-2",children:[g.jsx("p",{className:"text-mastra-el-3",children:"Tools"}),g.jsx("div",{className:"flex flex-col gap-2 text-mastra-el-5",children:Object.entries((n==null?void 0:n.tools)??{}).map(([s,o])=>g.jsx("span",{onClick:()=>{r(`/tools/${t}/${o.id}`)},className:"no-underline",children:o.id},s))})]})]})})}function Pde({agentId:t}){return g.jsx(zn,{className:"h-[calc(100vh-126px)] pt-2 px-4 pb-4 text-xs w-[400px]",children:g.jsxs("div",{className:"space-y-4",children:[g.jsxs("div",{className:"grid grid-cols-[70px_1fr] gap-2",children:[g.jsx("p",{className:"text-mastra-el-3",children:"GET"}),g.jsx("p",{className:"text-mastra-el-5",children:"/api/agents"})]}),g.jsxs("div",{className:"grid grid-cols-[70px_1fr] gap-2",children:[g.jsx("p",{className:"text-mastra-el-3",children:"GET"}),g.jsxs("p",{className:"text-mastra-el-5",children:["/api/agents/",t]})]}),g.jsxs("div",{className:"grid grid-cols-[70px_1fr] gap-2",children:[g.jsx("p",{className:"text-mastra-el-3",children:"GET"}),g.jsxs("p",{className:"text-mastra-el-5",children:["/api/agents/",t,"/evals/ci"]})]}),g.jsxs("div",{className:"grid grid-cols-[70px_1fr] gap-2",children:[g.jsx("p",{className:"text-mastra-el-3",children:"GET"}),g.jsxs("p",{className:"text-mastra-el-5",children:["/api/agents/",t,"/evals/live"]})]}),g.jsxs("div",{className:"grid grid-cols-[70px_1fr] gap-2",children:[g.jsx("p",{className:"text-mastra-el-3",children:"POST"}),g.jsxs("p",{className:"text-mastra-el-5",children:["/api/agents/",t,"/instructions"]})]}),g.jsxs("div",{className:"grid grid-cols-[70px_1fr] gap-2",children:[g.jsx("p",{className:"text-mastra-el-3",children:"POST"}),g.jsxs("p",{className:"text-mastra-el-5",children:["/api/agents/",t,"/generate"]})]}),g.jsxs("div",{className:"grid grid-cols-[70px_1fr] gap-2",children:[g.jsx("p",{className:"text-mastra-el-3",children:"POST"}),g.jsxs("p",{className:"text-mastra-el-5",children:["/api/agents/",t,"/stream"]})]}),g.jsxs("div",{className:"grid grid-cols-[70px_1fr] gap-2",children:[g.jsx("p",{className:"text-mastra-el-3",children:"POST"}),g.jsxs("p",{className:"text-mastra-el-5",children:["/api/agents/",t,"/text-object"]})]}),g.jsxs("div",{className:"grid grid-cols-[70px_1fr] gap-2",children:[g.jsx("p",{className:"text-mastra-el-3",children:"POST"}),g.jsxs("p",{className:"text-mastra-el-5",children:["/api/agents/",t,"/stream-object"]})]})]})})}function Ode(t,e=globalThis==null?void 0:globalThis.document){const n=Fn(t);S.useEffect(()=>{const r=i=>{i.key==="Escape"&&n(i)};return e.addEventListener("keydown",r,{capture:!0}),()=>e.removeEventListener("keydown",r,{capture:!0})},[n,e])}var Rde="DismissableLayer",fE="dismissableLayer.update",Dde="dismissableLayer.pointerDownOutside",jde="dismissableLayer.focusOutside",yD,q$=S.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Xd=S.forwardRef((t,e)=>{const{disableOutsidePointerEvents:n=!1,onEscapeKeyDown:r,onPointerDownOutside:i,onFocusOutside:s,onInteractOutside:o,onDismiss:a,...l}=t,c=S.useContext(q$),[u,d]=S.useState(null),h=(u==null?void 0:u.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,m]=S.useState({}),y=kt(e,M=>d(M)),v=Array.from(c.layers),[w]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),b=v.indexOf(w),k=u?v.indexOf(u):-1,C=c.layersWithOutsidePointerEventsDisabled.size>0,T=k>=b,_=Fde(M=>{const O=M.target,D=[...c.branches].some(R=>R.contains(O));!T||D||(i==null||i(M),o==null||o(M),M.defaultPrevented||a==null||a())},h),A=Bde(M=>{const O=M.target;[...c.branches].some(R=>R.contains(O))||(s==null||s(M),o==null||o(M),M.defaultPrevented||a==null||a())},h);return Ode(M=>{k===c.layers.size-1&&(r==null||r(M),!M.defaultPrevented&&a&&(M.preventDefault(),a()))},h),S.useEffect(()=>{if(u)return n&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(yD=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(u)),c.layers.add(u),xD(),()=>{n&&c.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=yD)}},[u,h,n,c]),S.useEffect(()=>()=>{u&&(c.layers.delete(u),c.layersWithOutsidePointerEventsDisabled.delete(u),xD())},[u,c]),S.useEffect(()=>{const M=()=>m({});return document.addEventListener(fE,M),()=>document.removeEventListener(fE,M)},[]),g.jsx(Xe.div,{...l,ref:y,style:{pointerEvents:C?T?"auto":"none":void 0,...t.style},onFocusCapture:Re(t.onFocusCapture,A.onFocusCapture),onBlurCapture:Re(t.onBlurCapture,A.onBlurCapture),onPointerDownCapture:Re(t.onPointerDownCapture,_.onPointerDownCapture)})});Xd.displayName=Rde;var Ide="DismissableLayerBranch",Lde=S.forwardRef((t,e)=>{const n=S.useContext(q$),r=S.useRef(null),i=kt(e,r);return S.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),g.jsx(Xe.div,{...t,ref:i})});Lde.displayName=Ide;function Fde(t,e=globalThis==null?void 0:globalThis.document){const n=Fn(t),r=S.useRef(!1),i=S.useRef(()=>{});return S.useEffect(()=>{const s=a=>{if(a.target&&!r.current){let l=function(){Y$(Dde,n,c,{discrete:!0})};const c={originalEvent:a};a.pointerType==="touch"?(e.removeEventListener("click",i.current),i.current=l,e.addEventListener("click",i.current,{once:!0})):l()}else e.removeEventListener("click",i.current);r.current=!1},o=window.setTimeout(()=>{e.addEventListener("pointerdown",s)},0);return()=>{window.clearTimeout(o),e.removeEventListener("pointerdown",s),e.removeEventListener("click",i.current)}},[e,n]),{onPointerDownCapture:()=>r.current=!0}}function Bde(t,e=globalThis==null?void 0:globalThis.document){const n=Fn(t),r=S.useRef(!1);return S.useEffect(()=>{const i=s=>{s.target&&!r.current&&Y$(jde,n,{originalEvent:s},{discrete:!1})};return e.addEventListener("focusin",i),()=>e.removeEventListener("focusin",i)},[e,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function xD(){const t=new CustomEvent(fE);document.dispatchEvent(t)}function Y$(t,e,n,{discrete:r}){const i=n.originalEvent.target,s=new CustomEvent(t,{bubbles:!1,cancelable:!0,detail:n});e&&i.addEventListener(t,e,{once:!0}),r?pF(i,s):i.dispatchEvent(s)}var ck="focusScope.autoFocusOnMount",uk="focusScope.autoFocusOnUnmount",vD={bubbles:!1,cancelable:!0},$de="FocusScope",pm=S.forwardRef((t,e)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:s,...o}=t,[a,l]=S.useState(null),c=Fn(i),u=Fn(s),d=S.useRef(null),h=kt(e,v=>l(v)),m=S.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;S.useEffect(()=>{if(r){let v=function(C){if(m.paused||!a)return;const T=C.target;a.contains(T)?d.current=T:el(d.current,{select:!0})},w=function(C){if(m.paused||!a)return;const T=C.relatedTarget;T!==null&&(a.contains(T)||el(d.current,{select:!0}))},b=function(C){if(document.activeElement===document.body)for(const _ of C)_.removedNodes.length>0&&el(a)};document.addEventListener("focusin",v),document.addEventListener("focusout",w);const k=new MutationObserver(b);return a&&k.observe(a,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",v),document.removeEventListener("focusout",w),k.disconnect()}}},[r,a,m.paused]),S.useEffect(()=>{if(a){bD.add(m);const v=document.activeElement;if(!a.contains(v)){const b=new CustomEvent(ck,vD);a.addEventListener(ck,c),a.dispatchEvent(b),b.defaultPrevented||(zde(qde(G$(a)),{select:!0}),document.activeElement===v&&el(a))}return()=>{a.removeEventListener(ck,c),setTimeout(()=>{const b=new CustomEvent(uk,vD);a.addEventListener(uk,u),a.dispatchEvent(b),b.defaultPrevented||el(v??document.body,{select:!0}),a.removeEventListener(uk,u),bD.remove(m)},0)}}},[a,c,u,m]);const y=S.useCallback(v=>{if(!n&&!r||m.paused)return;const w=v.key==="Tab"&&!v.altKey&&!v.ctrlKey&&!v.metaKey,b=document.activeElement;if(w&&b){const k=v.currentTarget,[C,T]=Vde(k);C&&T?!v.shiftKey&&b===T?(v.preventDefault(),n&&el(C,{select:!0})):v.shiftKey&&b===C&&(v.preventDefault(),n&&el(T,{select:!0})):b===k&&v.preventDefault()}},[n,r,m.paused]);return g.jsx(Xe.div,{tabIndex:-1,...o,ref:h,onKeyDown:y})});pm.displayName=$de;function zde(t,{select:e=!1}={}){const n=document.activeElement;for(const r of t)if(el(r,{select:e}),document.activeElement!==n)return}function Vde(t){const e=G$(t),n=wD(e,t),r=wD(e.reverse(),t);return[n,r]}function G$(t){const e=[],n=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)e.push(n.currentNode);return e}function wD(t,e){for(const n of t)if(!Wde(n,{upTo:e}))return n}function Wde(t,{upTo:e}){if(getComputedStyle(t).visibility==="hidden")return!0;for(;t;){if(e!==void 0&&t===e)return!1;if(getComputedStyle(t).display==="none")return!0;t=t.parentElement}return!1}function Hde(t){return t instanceof HTMLInputElement&&"select"in t}function el(t,{select:e=!1}={}){if(t&&t.focus){const n=document.activeElement;t.focus({preventScroll:!0}),t!==n&&Hde(t)&&e&&t.select()}}var bD=Ude();function Ude(){let t=[];return{add(e){const n=t[0];e!==n&&(n==null||n.pause()),t=kD(t,e),t.unshift(e)},remove(e){var n;t=kD(t,e),(n=t[0])==null||n.resume()}}}function kD(t,e){const n=[...t],r=n.indexOf(e);return r!==-1&&n.splice(r,1),n}function qde(t){return t.filter(e=>e.tagName!=="A")}var Yde="Portal",mm=S.forwardRef((t,e)=>{var a;const{container:n,...r}=t,[i,s]=S.useState(!1);Mr(()=>s(!0),[]);const o=n||i&&((a=globalThis==null?void 0:globalThis.document)==null?void 0:a.body);return o?tF.createPortal(g.jsx(Xe.div,{...r,ref:e}),o):null});mm.displayName=Yde;var dk=0;function Sv(){S.useEffect(()=>{const t=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",t[0]??SD()),document.body.insertAdjacentElement("beforeend",t[1]??SD()),dk++,()=>{dk===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(e=>e.remove()),dk--}},[])}function SD(){const t=document.createElement("span");return t.setAttribute("data-radix-focus-guard",""),t.tabIndex=0,t.style.outline="none",t.style.opacity="0",t.style.position="fixed",t.style.pointerEvents="none",t}var Qs=function(){return Qs=Object.assign||function(e){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},Qs.apply(this,arguments)};function K$(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(t,r[i])&&(n[r[i]]=t[r[i]]);return n}function Gde(t,e,n){if(n||arguments.length===2)for(var r=0,i=e.length,s;r<i;r++)(s||!(r in e))&&(s||(s=Array.prototype.slice.call(e,0,r)),s[r]=e[r]);return t.concat(s||Array.prototype.slice.call(e))}var a0="right-scroll-bar-position",l0="width-before-scroll-bar",Kde="with-scroll-bars-hidden",Zde="--removed-body-scroll-bar-size";function fk(t,e){return typeof t=="function"?t(e):t&&(t.current=e),t}function Xde(t,e){var n=S.useState(function(){return{value:t,callback:e,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=e,n.facade}var Qde=typeof window<"u"?S.useLayoutEffect:S.useEffect,CD=new WeakMap;function Jde(t,e){var n=Xde(null,function(r){return t.forEach(function(i){return fk(i,r)})});return Qde(function(){var r=CD.get(n);if(r){var i=new Set(r),s=new Set(t),o=n.current;i.forEach(function(a){s.has(a)||fk(a,null)}),s.forEach(function(a){i.has(a)||fk(a,o)})}CD.set(n,t)},[t]),n}function efe(t){return t}function tfe(t,e){e===void 0&&(e=efe);var n=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:t},useMedium:function(s){var o=e(s,r);return n.push(o),function(){n=n.filter(function(a){return a!==o})}},assignSyncMedium:function(s){for(r=!0;n.length;){var o=n;n=[],o.forEach(s)}n={push:function(a){return s(a)},filter:function(){return n}}},assignMedium:function(s){r=!0;var o=[];if(n.length){var a=n;n=[],a.forEach(s),o=n}var l=function(){var u=o;o=[],u.forEach(s)},c=function(){return Promise.resolve().then(l)};c(),n={push:function(u){o.push(u),c()},filter:function(u){return o=o.filter(u),n}}}};return i}function nfe(t){t===void 0&&(t={});var e=tfe(null);return e.options=Qs({async:!0,ssr:!1},t),e}var Z$=function(t){var e=t.sideCar,n=K$(t,["sideCar"]);if(!e)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=e.read();if(!r)throw new Error("Sidecar medium not found");return S.createElement(r,Qs({},n))};Z$.isSideCarExport=!0;function rfe(t,e){return t.useMedium(e),Z$}var X$=nfe(),hk=function(){},Cv=S.forwardRef(function(t,e){var n=S.useRef(null),r=S.useState({onScrollCapture:hk,onWheelCapture:hk,onTouchMoveCapture:hk}),i=r[0],s=r[1],o=t.forwardProps,a=t.children,l=t.className,c=t.removeScrollBar,u=t.enabled,d=t.shards,h=t.sideCar,m=t.noIsolation,y=t.inert,v=t.allowPinchZoom,w=t.as,b=w===void 0?"div":w,k=t.gapMode,C=K$(t,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noIsolation","inert","allowPinchZoom","as","gapMode"]),T=h,_=Jde([n,e]),A=Qs(Qs({},C),i);return S.createElement(S.Fragment,null,u&&S.createElement(T,{sideCar:X$,removeScrollBar:c,shards:d,noIsolation:m,inert:y,setCallbacks:s,allowPinchZoom:!!v,lockRef:n,gapMode:k}),o?S.cloneElement(S.Children.only(a),Qs(Qs({},A),{ref:_})):S.createElement(b,Qs({},A,{className:l,ref:_}),a))});Cv.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};Cv.classNames={fullWidth:l0,zeroRight:a0};var ife=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function sfe(){if(!document)return null;var t=document.createElement("style");t.type="text/css";var e=ife();return e&&t.setAttribute("nonce",e),t}function ofe(t,e){t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}function afe(t){var e=document.head||document.getElementsByTagName("head")[0];e.appendChild(t)}var lfe=function(){var t=0,e=null;return{add:function(n){t==0&&(e=sfe())&&(ofe(e,n),afe(e)),t++},remove:function(){t--,!t&&e&&(e.parentNode&&e.parentNode.removeChild(e),e=null)}}},cfe=function(){var t=lfe();return function(e,n){S.useEffect(function(){return t.add(e),function(){t.remove()}},[e&&n])}},Q$=function(){var t=cfe(),e=function(n){var r=n.styles,i=n.dynamic;return t(r,i),null};return e},ufe={left:0,top:0,right:0,gap:0},pk=function(t){return parseInt(t||"",10)||0},dfe=function(t){var e=window.getComputedStyle(document.body),n=e[t==="padding"?"paddingLeft":"marginLeft"],r=e[t==="padding"?"paddingTop":"marginTop"],i=e[t==="padding"?"paddingRight":"marginRight"];return[pk(n),pk(r),pk(i)]},ffe=function(t){if(t===void 0&&(t="margin"),typeof window>"u")return ufe;var e=dfe(t),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:e[0],top:e[1],right:e[2],gap:Math.max(0,r-n+e[2]-e[0])}},hfe=Q$(),Zu="data-scroll-locked",pfe=function(t,e,n,r){var i=t.left,s=t.top,o=t.right,a=t.gap;return n===void 0&&(n="margin"),`
289
289
  .`.concat(Kde,` {
@@ -343,7 +343,7 @@ For more information, see https://radix-ui.com/primitives/docs/components/alert-
343
343
  ]`;continue}i+=r[c],r[c]==="\\"?s=!0:o&&r[c]==="]"?o=!1:!o&&r[c]==="["&&(o=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${e.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),t.source}return i}function A6(t,e){var r,i,s,o,a,l;if(e.target==="openAi"&&console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead."),e.target==="openApi3"&&((r=t.keyType)==null?void 0:r._def.typeName)===_e.ZodEnum)return{type:"object",required:t.keyType._def.values,properties:t.keyType._def.values.reduce((c,u)=>({...c,[u]:Wt(t.valueType._def,{...e,currentPath:[...e.currentPath,"properties",u]})??{}}),{}),additionalProperties:!1};const n={type:"object",additionalProperties:Wt(t.valueType._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??{}};if(e.target==="openApi3")return n;if(((i=t.keyType)==null?void 0:i._def.typeName)===_e.ZodString&&((s=t.keyType._def.checks)!=null&&s.length)){const{type:c,...u}=N6(t.keyType._def,e);return{...n,propertyNames:u}}else{if(((o=t.keyType)==null?void 0:o._def.typeName)===_e.ZodEnum)return{...n,propertyNames:{enum:t.keyType._def.values}};if(((a=t.keyType)==null?void 0:a._def.typeName)===_e.ZodBranded&&t.keyType._def.type._def.typeName===_e.ZodString&&((l=t.keyType._def.type._def.checks)!=null&&l.length)){const{type:c,...u}=E6(t.keyType._def,e);return{...n,propertyNames:u}}}return n}function cge(t,e){if(e.mapStrategy==="record")return A6(t,e);const n=Wt(t.keyType._def,{...e,currentPath:[...e.currentPath,"items","items","0"]})||{},r=Wt(t.valueType._def,{...e,currentPath:[...e.currentPath,"items","items","1"]})||{};return{type:"array",maxItems:125,items:{type:"array",items:[n,r],minItems:2,maxItems:2}}}function uge(t){const e=t.values,r=Object.keys(t.values).filter(s=>typeof e[e[s]]!="number").map(s=>e[s]),i=Array.from(new Set(r.map(s=>typeof s)));return{type:i.length===1?i[0]==="string"?"string":"number":["string","number"],enum:r}}function dge(){return{not:{}}}function fge(t){return t.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}const Q0={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function hge(t,e){if(e.target==="openApi3")return BD(t,e);const n=t.options instanceof Map?Array.from(t.options.values()):t.options;if(n.every(r=>r._def.typeName in Q0&&(!r._def.checks||!r._def.checks.length))){const r=n.reduce((i,s)=>{const o=Q0[s._def.typeName];return o&&!i.includes(o)?[...i,o]:i},[]);return{type:r.length>1?r:r[0]}}else if(n.every(r=>r._def.typeName==="ZodLiteral"&&!r.description)){const r=n.reduce((i,s)=>{const o=typeof s._def.value;switch(o){case"string":case"number":case"boolean":return[...i,o];case"bigint":return[...i,"integer"];case"object":if(s._def.value===null)return[...i,"null"];case"symbol":case"undefined":case"function":default:return i}},[]);if(r.length===n.length){const i=r.filter((s,o,a)=>a.indexOf(s)===o);return{type:i.length>1?i:i[0],enum:n.reduce((s,o)=>s.includes(o._def.value)?s:[...s,o._def.value],[])}}}else if(n.every(r=>r._def.typeName==="ZodEnum"))return{type:"string",enum:n.reduce((r,i)=>[...r,...i._def.values.filter(s=>!r.includes(s))],[])};return BD(t,e)}const BD=(t,e)=>{const n=(t.options instanceof Map?Array.from(t.options.values()):t.options).map((r,i)=>Wt(r._def,{...e,currentPath:[...e.currentPath,"anyOf",`${i}`]})).filter(r=>!!r&&(!e.strictUnions||typeof r=="object"&&Object.keys(r).length>0));return n.length?{anyOf:n}:void 0};function pge(t,e){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(t.innerType._def.typeName)&&(!t.innerType._def.checks||!t.innerType._def.checks.length))return e.target==="openApi3"?{type:Q0[t.innerType._def.typeName],nullable:!0}:{type:[Q0[t.innerType._def.typeName],"null"]};if(e.target==="openApi3"){const r=Wt(t.innerType._def,{...e,currentPath:[...e.currentPath]});return r&&"$ref"in r?{allOf:[r],nullable:!0}:r&&{...r,nullable:!0}}const n=Wt(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","0"]});return n&&{anyOf:[n,{type:"null"}]}}function mge(t,e){const n={type:"number"};if(!t.checks)return n;for(const r of t.checks)switch(r.kind){case"int":n.type="integer",C6(n,"type",r.message,e);break;case"min":e.target==="jsonSchema7"?r.inclusive?Yt(n,"minimum",r.value,r.message,e):Yt(n,"exclusiveMinimum",r.value,r.message,e):(r.inclusive||(n.exclusiveMinimum=!0),Yt(n,"minimum",r.value,r.message,e));break;case"max":e.target==="jsonSchema7"?r.inclusive?Yt(n,"maximum",r.value,r.message,e):Yt(n,"exclusiveMaximum",r.value,r.message,e):(r.inclusive||(n.exclusiveMaximum=!0),Yt(n,"maximum",r.value,r.message,e));break;case"multipleOf":Yt(n,"multipleOf",r.value,r.message,e);break}return n}function gge(t,e){return e.removeAdditionalStrategy==="strict"?t.catchall._def.typeName==="ZodNever"?t.unknownKeys!=="strict":Wt(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??!0:t.catchall._def.typeName==="ZodNever"?t.unknownKeys==="passthrough":Wt(t.catchall._def,{...e,currentPath:[...e.currentPath,"additionalProperties"]})??!0}function yge(t,e){const n=e.target==="openAi",r={type:"object",...Object.entries(t.shape()).reduce((i,[s,o])=>{if(o===void 0||o._def===void 0)return i;let a=o.isOptional();a&&n&&(o instanceof Ns&&(o=o._def.innerType),o.isNullable()||(o=o.nullable()),a=!1);const l=Wt(o._def,{...e,currentPath:[...e.currentPath,"properties",s],propertyPath:[...e.currentPath,"properties",s]});return l===void 0?i:{properties:{...i.properties,[s]:l},required:a?i.required:[...i.required,s]}},{properties:{},required:[]}),additionalProperties:gge(t,e)};return r.required.length||delete r.required,r}const xge=(t,e)=>{var r;if(e.currentPath.toString()===((r=e.propertyPath)==null?void 0:r.toString()))return Wt(t.innerType._def,e);const n=Wt(t.innerType._def,{...e,currentPath:[...e.currentPath,"anyOf","1"]});return n?{anyOf:[{not:{}},n]}:{}},vge=(t,e)=>{if(e.pipeStrategy==="input")return Wt(t.in._def,e);if(e.pipeStrategy==="output")return Wt(t.out._def,e);const n=Wt(t.in._def,{...e,currentPath:[...e.currentPath,"allOf","0"]}),r=Wt(t.out._def,{...e,currentPath:[...e.currentPath,"allOf",n?"1":"0"]});return{allOf:[n,r].filter(i=>i!==void 0)}};function wge(t,e){return Wt(t.type._def,e)}function bge(t,e){const r={type:"array",uniqueItems:!0,items:Wt(t.valueType._def,{...e,currentPath:[...e.currentPath,"items"]})};return t.minSize&&Yt(r,"minItems",t.minSize.value,t.minSize.message,e),t.maxSize&&Yt(r,"maxItems",t.maxSize.value,t.maxSize.message,e),r}function kge(t,e){return t.rest?{type:"array",minItems:t.items.length,items:t.items.map((n,r)=>Wt(n._def,{...e,currentPath:[...e.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[]),additionalItems:Wt(t.rest._def,{...e,currentPath:[...e.currentPath,"additionalItems"]})}:{type:"array",minItems:t.items.length,maxItems:t.items.length,items:t.items.map((n,r)=>Wt(n._def,{...e,currentPath:[...e.currentPath,"items",`${r}`]})).reduce((n,r)=>r===void 0?n:[...n,r],[])}}function Sge(){return{not:{}}}function Cge(){return{}}const Ege=(t,e)=>Wt(t.innerType._def,e);function Wt(t,e,n=!1){var o;const r=e.seen.get(t);if(e.override){const a=(o=e.override)==null?void 0:o.call(e,t,e,r,n);if(a!==Ume)return a}if(r&&!n){const a=Tge(r,e);if(a!==void 0)return a}const i={def:t,path:e.currentPath,jsonSchema:void 0};e.seen.set(t,i);const s=Age(t,t.typeName,e);return s&&_ge(t,e,s),i.jsonSchema=s,s}const Tge=(t,e)=>{switch(e.$refStrategy){case"root":return{$ref:t.path.join("/")};case"relative":return{$ref:Nge(e.currentPath,t.path)};case"none":case"seen":return t.path.length<e.currentPath.length&&t.path.every((n,r)=>e.currentPath[r]===n)?(console.warn(`Recursive reference detected at ${e.currentPath.join("/")}! Defaulting to any`),{}):e.$refStrategy==="seen"?{}:void 0}},Nge=(t,e)=>{let n=0;for(;n<t.length&&n<e.length&&t[n]===e[n];n++);return[(t.length-n).toString(),...e.slice(n)].join("/")},Age=(t,e,n)=>{switch(e){case _e.ZodString:return N6(t,n);case _e.ZodNumber:return mge(t,n);case _e.ZodObject:return yge(t,n);case _e.ZodBigInt:return Xme(t,n);case _e.ZodBoolean:return Qme();case _e.ZodDate:return T6(t,n);case _e.ZodUndefined:return Sge();case _e.ZodNull:return fge(n);case _e.ZodArray:return Zme(t,n);case _e.ZodUnion:case _e.ZodDiscriminatedUnion:return hge(t,n);case _e.ZodIntersection:return sge(t,n);case _e.ZodTuple:return kge(t,n);case _e.ZodRecord:return A6(t,n);case _e.ZodLiteral:return oge(t,n);case _e.ZodEnum:return rge(t);case _e.ZodNativeEnum:return uge(t);case _e.ZodNullable:return pge(t,n);case _e.ZodOptional:return xge(t,n);case _e.ZodMap:return cge(t,n);case _e.ZodSet:return bge(t,n);case _e.ZodLazy:return Wt(t.getter()._def,n);case _e.ZodPromise:return wge(t,n);case _e.ZodNaN:case _e.ZodNever:return dge();case _e.ZodEffects:return nge(t,n);case _e.ZodAny:return Kme();case _e.ZodUnknown:return Cge();case _e.ZodDefault:return tge(t,n);case _e.ZodBranded:return E6(t,n);case _e.ZodReadonly:return Ege(t,n);case _e.ZodCatch:return Jme(t,n);case _e.ZodPipeline:return vge(t,n);case _e.ZodFunction:case _e.ZodVoid:case _e.ZodSymbol:return;default:return(r=>{})()}},_ge=(t,e,n)=>(t.description&&(n.description=t.description,e.markdownDescription&&(n.markdownDescription=t.description)),n),$D=(t,e)=>{const n=Gme(e),r=void 0,i=e==null?void 0:e.name,s=Wt(t._def,n,!1)??{},o=i===void 0?r?{...s,[n.definitionPath]:r}:s:{$ref:[...n.$refStrategy==="relative"?[]:n.basePath,n.definitionPath,i].join("/"),[n.definitionPath]:{...r,[i]:s}};return n.target==="jsonSchema7"?o.$schema="http://json-schema.org/draft-07/schema#":(n.target==="jsonSchema2019-09"||n.target==="openAi")&&(o.$schema="https://json-schema.org/draft/2019-09/schema#"),n.target==="openAi"&&("anyOf"in o||"oneOf"in o||"allOf"in o||"type"in o&&Array.isArray(o.type))&&console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property."),o};var Jd=class{constructor(t){_n(this,"options");this.options=t}async request(t,e={}){let n=null;const{baseUrl:r,retries:i=3,backoffMs:s=100,maxBackoffMs:o=1e3,headers:a={}}=this.options;let l=s;for(let c=0;c<=i;c++)try{const u=await fetch(`${r}${t}`,{...e,headers:{"Content-Type":"application/json",...a,...e.headers},body:e.body?JSON.stringify(e.body):void 0});if(!u.ok){const h=await u.text();let m=`HTTP error! status: ${u.status}`;try{const y=JSON.parse(h);m+=` - ${JSON.stringify(y)}`}catch{h&&(m+=` - ${h}`)}throw new Error(m)}return e.stream?u:await u.json()}catch(u){if(n=u,c===i)break;await new Promise(d=>setTimeout(d,l)),l=Math.min(l*2,o)}throw n||new Error("Request failed")}},Mge=class extends Jd{constructor(e,n){super(e),this.agentId=n}details(){return this.request(`/api/agents/${this.agentId}`)}generate(e){const n={...e,output:e.output instanceof wt?$D(e.output):e.output};return this.request(`/api/agents/${this.agentId}/generate`,{method:"POST",body:n})}stream(e){const n={...e,output:e.output instanceof wt?$D(e.output):e.output};return this.request(`/api/agents/${this.agentId}/stream`,{method:"POST",body:n,stream:!0})}getTool(e){return this.request(`/api/agents/${this.agentId}/tools/${e}`)}evals(){return this.request(`/api/agents/${this.agentId}/evals/ci`)}liveEvals(){return this.request(`/api/agents/${this.agentId}/evals/live`)}},Pge=class extends Jd{constructor(t,e,n){super(t),this.threadId=e,this.agentId=n}get(){return this.request(`/api/memory/threads/${this.threadId}?agentId=${this.agentId}`)}update(t){return this.request(`/api/memory/threads/${this.threadId}?agentId=${this.agentId}`,{method:"PATCH",body:t})}delete(){return this.request(`/api/memory/threads/${this.threadId}?agentId=${this.agentId}`,{method:"DELETE"})}getMessages(){return this.request(`/api/memory/threads/${this.threadId}/messages?agentId=${this.agentId}`)}},Oge=class extends Jd{constructor(t,e){super(t),this.vectorName=e}details(t){return this.request(`/api/vector/${this.vectorName}/indexes/${t}`)}delete(t){return this.request(`/api/vector/${this.vectorName}/indexes/${t}`,{method:"DELETE"})}getIndexes(){return this.request(`/api/vector/${this.vectorName}/indexes`)}createIndex(t){return this.request(`/api/vector/${this.vectorName}/create-index`,{method:"POST",body:t})}upsert(t){return this.request(`/api/vector/${this.vectorName}/upsert`,{method:"POST",body:t})}query(t){return this.request(`/api/vector/${this.vectorName}/query`,{method:"POST",body:t})}},Rge=class extends Jd{constructor(e,n){super(e),this.workflowId=n}details(){return this.request(`/api/workflows/${this.workflowId}`)}execute(e){return this.request(`/api/workflows/${this.workflowId}/execute`,{method:"POST",body:e})}resume({stepId:e,runId:n,context:r}){return this.request(`/api/workflows/${this.workflowId}/resume`,{method:"POST",body:{stepId:e,runId:n,context:r}})}watch(){return this.request(`/api/workflows/${this.workflowId}/watch`,{stream:!0})}},Dge=class extends Jd{constructor(e,n){super(e),this.toolId=n}details(){return this.request(`/api/tools/${this.toolId}`)}execute(e){return this.request(`/api/tools/${this.toolId}/execute`,{method:"POST",body:e})}},_6=class extends Jd{constructor(t){super(t)}getAgents(){return this.request("/api/agents")}getAgent(t){return new Mge(this.options,t)}getMemoryThreads(t){return this.request(`/api/memory/threads?resourceid=${t.resourceId}&agentId=${t.agentId}`)}createMemoryThread(t){return this.request(`/api/memory/threads?agentId=${t.agentId}`,{method:"POST",body:t})}getMemoryThread(t,e){return new Pge(this.options,t,e)}saveMessageToMemory(t){return this.request(`/api/memory/save-messages?agentId=${t.agentId}`,{method:"POST",body:t})}getMemoryStatus(t){return this.request(`/api/memory/status?agentId=${t}`)}getTools(){return this.request("/api/tools")}getTool(t){return new Dge(this.options,t)}getWorkflows(){return this.request("/api/workflows")}getWorkflow(t){return new Rge(this.options,t)}getVector(t){return new Oge(this.options,t)}getLogs(t){return this.request(`/api/logs?transportId=${t.transportId}`)}getLogForRun(t){return this.request(`/api/logs/${t.runId}?transportId=${t.transportId}`)}getLogTransports(){return this.request("/api/logs/transports")}getTelemetry(t){const{name:e,scope:n,page:r,perPage:i,attribute:s}=t||{},o=s?Object.entries(s).map(([l,c])=>`${l}:${c}`):[];({...o!=null&&o.length?{attribute:o}:{}});const a=new URLSearchParams;if(e&&a.set("name",e),n&&a.set("scope",n),r&&a.set("page",String(r)),i&&a.set("perPage",String(i)),o)if(Array.isArray(o))for(const l of o)a.append("attribute",l);else a.set("attribute",o);return a.size?this.request(`/api/telemetry?${a}`):this.request("/api/telemetry")}};const M6=t=>{const[e,n]=S.useState([]),[r,i]=S.useState(!0),{transports:s,isLoading:o}=jge(),a=s[0],l=new _6({baseUrl:"http://localhost:4111"}),c=async u=>{i(!0);try{const d=await l.getLogForRun({transportId:a,runId:u??t});n(d.map(h=>({level:h.level,time:h.time,pid:h.pid,hostname:h.hostname,name:h.name,runId:h.runId,msg:h.msg})))}catch(d){n([]),console.error("Error fetching logs",d),xn.error("Error fetching logs")}finally{i(!1)}};return S.useEffect(()=>{o||!a||c(t)},[t,a]),{logs:e,isLoading:r,refetchLogs:c}},jge=()=>{const[t,e]=S.useState([]),[n,r]=S.useState(!0),i=async()=>{const s=new _6({baseUrl:"http://localhost:4111"});try{const o=await s.getLogTransports();e(o.transports)}catch(o){console.error("Error fetching logs",o),xn.error("Error fetching logs")}finally{r(!1)}};return S.useEffect(()=>{i()},[]),{transports:t,isLoading:n}};function Ige({agentId:t}){const{logs:e,isLoading:n,refetchLogs:r}=M6(t);return g.jsxs(zn,{className:"h-[calc(100vh-126px)] px-4 pb-4 text-xs w-full",children:[g.jsx("div",{className:"flex justify-end sticky top-0 bg-mastra-bg-2 py-2",children:g.jsx(pt,{variant:"outline",onClick:()=>r(),children:n?g.jsx(cd,{className:"w-4 h-4 animate-spin"}):g.jsx(cd,{className:"w-4 h-4"})})}),g.jsx("div",{className:"space-y-4",children:e.length===0?g.jsxs("p",{className:"text-gray-300/60",children:["No log drains. By default, logs are sent to the console. To configure log drains see"," ",g.jsx("a",{href:"https://mastra.ai/docs/reference/observability/create-logger#upstash-logger-remote-log-drain",target:"_blank",rel:"noopener",className:" hover:text-gray-100 underline",children:"docs."})]}):e.map((i,s)=>g.jsxs("div",{className:"space-y-2",children:[g.jsxs("div",{className:"flex gap-2 items-center",children:[g.jsxs("p",{className:"text-mastra-el-5",children:["[",fl(new Date(i.time),"yyyy-MM-dd HH:mm:ss"),"]"]}),g.jsxs("p",{className:"text-mastra-el-4",children:["[",i.level,"]"]})]}),g.jsx("p",{className:"text-mastra-el-5 whitespace-pre-wrap",children:g.jsx("code",{children:i.msg})})]},s))})]})}function J0({agentId:t}){return g.jsxs(CA,{defaultValue:"details",children:[g.jsxs(kv,{className:"flex shrink-0 border-b",children:[g.jsx(io,{value:"details",className:"group",children:g.jsx("p",{className:"text-xs p-3 text-mastra-el-3 group-data-[state=active]:text-mastra-el-5 group-data-[state=active]:border-b-2 group-data-[state=active]:pb-2.5 border-white",children:"Details"})}),g.jsx(io,{value:"instructions",className:"group",children:g.jsx("p",{className:"text-xs p-3 text-mastra-el-3 group-data-[state=active]:text-mastra-el-5 group-data-[state=active]:border-b-2 group-data-[state=active]:pb-2.5 border-white",children:"Instructions"})}),g.jsx(io,{value:"endpoints",className:"group",children:g.jsx("p",{className:"text-xs p-3 text-mastra-el-3 group-data-[state=active]:text-mastra-el-5 group-data-[state=active]:border-b-2 group-data-[state=active]:pb-2.5 border-white",children:"Endpoints"})}),g.jsx(io,{value:"logs",className:"group",children:g.jsx("p",{className:"text-xs p-3 text-mastra-el-3 group-data-[state=active]:text-mastra-el-5 group-data-[state=active]:border-b-2 group-data-[state=active]:pb-2.5 border-white",children:"Log Drains"})})]}),g.jsx(so,{value:"details",children:t?g.jsx(Mde,{agentId:t}):null}),g.jsx(so,{value:"endpoints",children:g.jsx(Pde,{agentId:t})}),g.jsx(so,{value:"logs",children:g.jsx(Ige,{agentId:t})}),g.jsx(so,{value:"instructions",children:g.jsx(uhe,{agentId:t})})]})}const Lge=["top","right","bottom","left"],bl=Math.min,Ei=Math.max,ex=Math.round,yy=Math.floor,ho=t=>({x:t,y:t}),Fge={left:"right",right:"left",bottom:"top",top:"bottom"},Bge={start:"end",end:"start"};function xE(t,e,n){return Ei(t,bl(e,n))}function fa(t,e){return typeof t=="function"?t(e):t}function ha(t){return t.split("-")[0]}function ef(t){return t.split("-")[1]}function OA(t){return t==="x"?"y":"x"}function RA(t){return t==="y"?"height":"width"}function kl(t){return["top","bottom"].includes(ha(t))?"y":"x"}function DA(t){return OA(kl(t))}function $ge(t,e,n){n===void 0&&(n=!1);const r=ef(t),i=DA(t),s=RA(i);let o=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(o=tx(o)),[o,tx(o)]}function zge(t){const e=tx(t);return[vE(t),e,vE(e)]}function vE(t){return t.replace(/start|end/g,e=>Bge[e])}function Vge(t,e,n){const r=["left","right"],i=["right","left"],s=["top","bottom"],o=["bottom","top"];switch(t){case"top":case"bottom":return n?e?i:r:e?r:i;case"left":case"right":return e?s:o;default:return[]}}function Wge(t,e,n,r){const i=ef(t);let s=Vge(ha(t),n==="start",r);return i&&(s=s.map(o=>o+"-"+i),e&&(s=s.concat(s.map(vE)))),s}function tx(t){return t.replace(/left|right|bottom|top/g,e=>Fge[e])}function Hge(t){return{top:0,right:0,bottom:0,left:0,...t}}function P6(t){return typeof t!="number"?Hge(t):{top:t,right:t,bottom:t,left:t}}function nx(t){const{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}function zD(t,e,n){let{reference:r,floating:i}=t;const s=kl(e),o=DA(e),a=RA(o),l=ha(e),c=s==="y",u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,h=r[a]/2-i[a]/2;let m;switch(l){case"top":m={x:u,y:r.y-i.height};break;case"bottom":m={x:u,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:d};break;case"left":m={x:r.x-i.width,y:d};break;default:m={x:r.x,y:r.y}}switch(ef(e)){case"start":m[o]-=h*(n&&c?-1:1);break;case"end":m[o]+=h*(n&&c?-1:1);break}return m}const Uge=async(t,e,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:o}=n,a=s.filter(Boolean),l=await(o.isRTL==null?void 0:o.isRTL(e));let c=await o.getElementRects({reference:t,floating:e,strategy:i}),{x:u,y:d}=zD(c,r,l),h=r,m={},y=0;for(let v=0;v<a.length;v++){const{name:w,fn:b}=a[v],{x:k,y:C,data:T,reset:_}=await b({x:u,y:d,initialPlacement:r,placement:h,strategy:i,middlewareData:m,rects:c,platform:o,elements:{reference:t,floating:e}});u=k??u,d=C??d,m={...m,[w]:{...m[w],...T}},_&&y<=50&&(y++,typeof _=="object"&&(_.placement&&(h=_.placement),_.rects&&(c=_.rects===!0?await o.getElementRects({reference:t,floating:e,strategy:i}):_.rects),{x:u,y:d}=zD(c,h,l)),v=-1)}return{x:u,y:d,placement:h,strategy:i,middlewareData:m}};async function vp(t,e){var n;e===void 0&&(e={});const{x:r,y:i,platform:s,rects:o,elements:a,strategy:l}=t,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:h=!1,padding:m=0}=fa(e,t),y=P6(m),w=a[h?d==="floating"?"reference":"floating":d],b=nx(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(w)))==null||n?w:w.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),k=d==="floating"?{x:r,y:i,width:o.floating.width,height:o.floating.height}:o.reference,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),T=await(s.isElement==null?void 0:s.isElement(C))?await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1}:{x:1,y:1},_=nx(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:k,offsetParent:C,strategy:l}):k);return{top:(b.top-_.top+y.top)/T.y,bottom:(_.bottom-b.bottom+y.bottom)/T.y,left:(b.left-_.left+y.left)/T.x,right:(_.right-b.right+y.right)/T.x}}const qge=t=>({name:"arrow",options:t,async fn(e){const{x:n,y:r,placement:i,rects:s,platform:o,elements:a,middlewareData:l}=e,{element:c,padding:u=0}=fa(t,e)||{};if(c==null)return{};const d=P6(u),h={x:n,y:r},m=DA(i),y=RA(m),v=await o.getDimensions(c),w=m==="y",b=w?"top":"left",k=w?"bottom":"right",C=w?"clientHeight":"clientWidth",T=s.reference[y]+s.reference[m]-h[m]-s.floating[y],_=h[m]-s.reference[m],A=await(o.getOffsetParent==null?void 0:o.getOffsetParent(c));let M=A?A[C]:0;(!M||!await(o.isElement==null?void 0:o.isElement(A)))&&(M=a.floating[C]||s.floating[y]);const O=T/2-_/2,D=M/2-v[y]/2-1,R=bl(d[b],D),B=bl(d[k],D),F=R,W=M-v[y]-B,I=M/2-v[y]/2+O,Y=xE(F,I,W),V=!l.arrow&&ef(i)!=null&&I!==Y&&s.reference[y]/2-(I<F?R:B)-v[y]/2<0,G=V?I<F?I-F:I-W:0;return{[m]:h[m]+G,data:{[m]:Y,centerOffset:I-Y-G,...V&&{alignmentOffset:G}},reset:V}}}),Yge=function(t){return t===void 0&&(t={}),{name:"flip",options:t,async fn(e){var n,r;const{placement:i,middlewareData:s,rects:o,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:h,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:v=!0,...w}=fa(t,e);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const b=ha(i),k=kl(a),C=ha(a)===a,T=await(l.isRTL==null?void 0:l.isRTL(c.floating)),_=h||(C||!v?[tx(a)]:zge(a)),A=y!=="none";!h&&A&&_.push(...Wge(a,v,y,T));const M=[a,..._],O=await vp(e,w),D=[];let R=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&D.push(O[b]),d){const I=$ge(i,o,T);D.push(O[I[0]],O[I[1]])}if(R=[...R,{placement:i,overflows:D}],!D.every(I=>I<=0)){var B,F;const I=(((B=s.flip)==null?void 0:B.index)||0)+1,Y=M[I];if(Y)return{data:{index:I,overflows:R},reset:{placement:Y}};let V=(F=R.filter(G=>G.overflows[0]<=0).sort((G,H)=>G.overflows[1]-H.overflows[1])[0])==null?void 0:F.placement;if(!V)switch(m){case"bestFit":{var W;const G=(W=R.filter(H=>{if(A){const z=kl(H.placement);return z===k||z==="y"}return!0}).map(H=>[H.placement,H.overflows.filter(z=>z>0).reduce((z,L)=>z+L,0)]).sort((H,z)=>H[1]-z[1])[0])==null?void 0:W[0];G&&(V=G);break}case"initialPlacement":V=a;break}if(i!==V)return{reset:{placement:V}}}return{}}}};function VD(t,e){return{top:t.top-e.height,right:t.right-e.width,bottom:t.bottom-e.height,left:t.left-e.width}}function WD(t){return Lge.some(e=>t[e]>=0)}const Gge=function(t){return t===void 0&&(t={}),{name:"hide",options:t,async fn(e){const{rects:n}=e,{strategy:r="referenceHidden",...i}=fa(t,e);switch(r){case"referenceHidden":{const s=await vp(e,{...i,elementContext:"reference"}),o=VD(s,n.reference);return{data:{referenceHiddenOffsets:o,referenceHidden:WD(o)}}}case"escaped":{const s=await vp(e,{...i,altBoundary:!0}),o=VD(s,n.floating);return{data:{escapedOffsets:o,escaped:WD(o)}}}default:return{}}}}};async function Kge(t,e){const{placement:n,platform:r,elements:i}=t,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=ha(n),a=ef(n),l=kl(n)==="y",c=["left","top"].includes(o)?-1:1,u=s&&l?-1:1,d=fa(e,t);let{mainAxis:h,crossAxis:m,alignmentAxis:y}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return a&&typeof y=="number"&&(m=a==="end"?y*-1:y),l?{x:m*u,y:h*c}:{x:h*c,y:m*u}}const Zge=function(t){return t===void 0&&(t=0),{name:"offset",options:t,async fn(e){var n,r;const{x:i,y:s,placement:o,middlewareData:a}=e,l=await Kge(e,t);return o===((n=a.offset)==null?void 0:n.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:i+l.x,y:s+l.y,data:{...l,placement:o}}}}},Xge=function(t){return t===void 0&&(t={}),{name:"shift",options:t,async fn(e){const{x:n,y:r,placement:i}=e,{mainAxis:s=!0,crossAxis:o=!1,limiter:a={fn:w=>{let{x:b,y:k}=w;return{x:b,y:k}}},...l}=fa(t,e),c={x:n,y:r},u=await vp(e,l),d=kl(ha(i)),h=OA(d);let m=c[h],y=c[d];if(s){const w=h==="y"?"top":"left",b=h==="y"?"bottom":"right",k=m+u[w],C=m-u[b];m=xE(k,m,C)}if(o){const w=d==="y"?"top":"left",b=d==="y"?"bottom":"right",k=y+u[w],C=y-u[b];y=xE(k,y,C)}const v=a.fn({...e,[h]:m,[d]:y});return{...v,data:{x:v.x-n,y:v.y-r,enabled:{[h]:s,[d]:o}}}}}},Qge=function(t){return t===void 0&&(t={}),{options:t,fn(e){const{x:n,y:r,placement:i,rects:s,middlewareData:o}=e,{offset:a=0,mainAxis:l=!0,crossAxis:c=!0}=fa(t,e),u={x:n,y:r},d=kl(i),h=OA(d);let m=u[h],y=u[d];const v=fa(a,e),w=typeof v=="number"?{mainAxis:v,crossAxis:0}:{mainAxis:0,crossAxis:0,...v};if(l){const C=h==="y"?"height":"width",T=s.reference[h]-s.floating[C]+w.mainAxis,_=s.reference[h]+s.reference[C]-w.mainAxis;m<T?m=T:m>_&&(m=_)}if(c){var b,k;const C=h==="y"?"width":"height",T=["top","left"].includes(ha(i)),_=s.reference[d]-s.floating[C]+(T&&((b=o.offset)==null?void 0:b[d])||0)+(T?0:w.crossAxis),A=s.reference[d]+s.reference[C]+(T?0:((k=o.offset)==null?void 0:k[d])||0)-(T?w.crossAxis:0);y<_?y=_:y>A&&(y=A)}return{[h]:m,[d]:y}}}},Jge=function(t){return t===void 0&&(t={}),{name:"size",options:t,async fn(e){var n,r;const{placement:i,rects:s,platform:o,elements:a}=e,{apply:l=()=>{},...c}=fa(t,e),u=await vp(e,c),d=ha(i),h=ef(i),m=kl(i)==="y",{width:y,height:v}=s.floating;let w,b;d==="top"||d==="bottom"?(w=d,b=h===(await(o.isRTL==null?void 0:o.isRTL(a.floating))?"start":"end")?"left":"right"):(b=d,w=h==="end"?"top":"bottom");const k=v-u.top-u.bottom,C=y-u.left-u.right,T=bl(v-u[w],k),_=bl(y-u[b],C),A=!e.middlewareData.shift;let M=T,O=_;if((n=e.middlewareData.shift)!=null&&n.enabled.x&&(O=C),(r=e.middlewareData.shift)!=null&&r.enabled.y&&(M=k),A&&!h){const R=Ei(u.left,0),B=Ei(u.right,0),F=Ei(u.top,0),W=Ei(u.bottom,0);m?O=y-2*(R!==0||B!==0?R+B:Ei(u.left,u.right)):M=v-2*(F!==0||W!==0?F+W:Ei(u.top,u.bottom))}await l({...e,availableWidth:O,availableHeight:M});const D=await o.getDimensions(a.floating);return y!==D.width||v!==D.height?{reset:{rects:!0}}:{}}}};function Av(){return typeof window<"u"}function tf(t){return O6(t)?(t.nodeName||"").toLowerCase():"#document"}function Ri(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function Po(t){var e;return(e=(O6(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function O6(t){return Av()?t instanceof Node||t instanceof Ri(t).Node:!1}function Ms(t){return Av()?t instanceof Element||t instanceof Ri(t).Element:!1}function Eo(t){return Av()?t instanceof HTMLElement||t instanceof Ri(t).HTMLElement:!1}function HD(t){return!Av()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Ri(t).ShadowRoot}function xm(t){const{overflow:e,overflowX:n,overflowY:r,display:i}=Ps(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!["inline","contents"].includes(i)}function eye(t){return["table","td","th"].includes(tf(t))}function _v(t){return[":popover-open",":modal"].some(e=>{try{return t.matches(e)}catch{return!1}})}function jA(t){const e=IA(),n=Ms(t)?Ps(t):t;return["transform","translate","scale","rotate","perspective"].some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||["transform","translate","scale","rotate","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function tye(t){let e=Sl(t);for(;Eo(e)&&!bd(e);){if(jA(e))return e;if(_v(e))return null;e=Sl(e)}return null}function IA(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function bd(t){return["html","body","#document"].includes(tf(t))}function Ps(t){return Ri(t).getComputedStyle(t)}function Mv(t){return Ms(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Sl(t){if(tf(t)==="html")return t;const e=t.assignedSlot||t.parentNode||HD(t)&&t.host||Po(t);return HD(e)?e.host:e}function R6(t){const e=Sl(t);return bd(e)?t.ownerDocument?t.ownerDocument.body:t.body:Eo(e)&&xm(e)?e:R6(e)}function wp(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const i=R6(t),s=i===((r=t.ownerDocument)==null?void 0:r.body),o=Ri(i);if(s){const a=wE(o);return e.concat(o,o.visualViewport||[],xm(i)?i:[],a&&n?wp(a):[])}return e.concat(i,wp(i,[],n))}function wE(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function D6(t){const e=Ps(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=Eo(t),s=i?t.offsetWidth:n,o=i?t.offsetHeight:r,a=ex(n)!==s||ex(r)!==o;return a&&(n=s,r=o),{width:n,height:r,$:a}}function LA(t){return Ms(t)?t:t.contextElement}function Ju(t){const e=LA(t);if(!Eo(e))return ho(1);const n=e.getBoundingClientRect(),{width:r,height:i,$:s}=D6(e);let o=(s?ex(n.width):n.width)/r,a=(s?ex(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!a||!Number.isFinite(a))&&(a=1),{x:o,y:a}}const nye=ho(0);function j6(t){const e=Ri(t);return!IA()||!e.visualViewport?nye:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function rye(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Ri(t)?!1:e}function _c(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),s=LA(t);let o=ho(1);e&&(r?Ms(r)&&(o=Ju(r)):o=Ju(t));const a=rye(s,n,r)?j6(s):ho(0);let l=(i.left+a.x)/o.x,c=(i.top+a.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(s){const h=Ri(s),m=r&&Ms(r)?Ri(r):r;let y=h,v=wE(y);for(;v&&r&&m!==y;){const w=Ju(v),b=v.getBoundingClientRect(),k=Ps(v),C=b.left+(v.clientLeft+parseFloat(k.paddingLeft))*w.x,T=b.top+(v.clientTop+parseFloat(k.paddingTop))*w.y;l*=w.x,c*=w.y,u*=w.x,d*=w.y,l+=C,c+=T,y=Ri(v),v=wE(y)}}return nx({width:u,height:d,x:l,y:c})}function FA(t,e){const n=Mv(t).scrollLeft;return e?e.left+n:_c(Po(t)).left+n}function I6(t,e,n){n===void 0&&(n=!1);const r=t.getBoundingClientRect(),i=r.left+e.scrollLeft-(n?0:FA(t,r)),s=r.top+e.scrollTop;return{x:i,y:s}}function iye(t){let{elements:e,rect:n,offsetParent:r,strategy:i}=t;const s=i==="fixed",o=Po(r),a=e?_v(e.floating):!1;if(r===o||a&&s)return n;let l={scrollLeft:0,scrollTop:0},c=ho(1);const u=ho(0),d=Eo(r);if((d||!d&&!s)&&((tf(r)!=="body"||xm(o))&&(l=Mv(r)),Eo(r))){const m=_c(r);c=Ju(r),u.x=m.x+r.clientLeft,u.y=m.y+r.clientTop}const h=o&&!d&&!s?I6(o,l,!0):ho(0);return{width:n.width*c.x,height:n.height*c.y,x:n.x*c.x-l.scrollLeft*c.x+u.x+h.x,y:n.y*c.y-l.scrollTop*c.y+u.y+h.y}}function sye(t){return Array.from(t.getClientRects())}function oye(t){const e=Po(t),n=Mv(t),r=t.ownerDocument.body,i=Ei(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=Ei(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let o=-n.scrollLeft+FA(t);const a=-n.scrollTop;return Ps(r).direction==="rtl"&&(o+=Ei(e.clientWidth,r.clientWidth)-i),{width:i,height:s,x:o,y:a}}function aye(t,e){const n=Ri(t),r=Po(t),i=n.visualViewport;let s=r.clientWidth,o=r.clientHeight,a=0,l=0;if(i){s=i.width,o=i.height;const c=IA();(!c||c&&e==="fixed")&&(a=i.offsetLeft,l=i.offsetTop)}return{width:s,height:o,x:a,y:l}}function lye(t,e){const n=_c(t,!0,e==="fixed"),r=n.top+t.clientTop,i=n.left+t.clientLeft,s=Eo(t)?Ju(t):ho(1),o=t.clientWidth*s.x,a=t.clientHeight*s.y,l=i*s.x,c=r*s.y;return{width:o,height:a,x:l,y:c}}function UD(t,e,n){let r;if(e==="viewport")r=aye(t,n);else if(e==="document")r=oye(Po(t));else if(Ms(e))r=lye(e,n);else{const i=j6(t);r={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return nx(r)}function L6(t,e){const n=Sl(t);return n===e||!Ms(n)||bd(n)?!1:Ps(n).position==="fixed"||L6(n,e)}function cye(t,e){const n=e.get(t);if(n)return n;let r=wp(t,[],!1).filter(a=>Ms(a)&&tf(a)!=="body"),i=null;const s=Ps(t).position==="fixed";let o=s?Sl(t):t;for(;Ms(o)&&!bd(o);){const a=Ps(o),l=jA(o);!l&&a.position==="fixed"&&(i=null),(s?!l&&!i:!l&&a.position==="static"&&!!i&&["absolute","fixed"].includes(i.position)||xm(o)&&!l&&L6(t,o))?r=r.filter(u=>u!==o):i=a,o=Sl(o)}return e.set(t,r),r}function uye(t){let{element:e,boundary:n,rootBoundary:r,strategy:i}=t;const o=[...n==="clippingAncestors"?_v(e)?[]:cye(e,this._c):[].concat(n),r],a=o[0],l=o.reduce((c,u)=>{const d=UD(e,u,i);return c.top=Ei(d.top,c.top),c.right=bl(d.right,c.right),c.bottom=bl(d.bottom,c.bottom),c.left=Ei(d.left,c.left),c},UD(e,a,i));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function dye(t){const{width:e,height:n}=D6(t);return{width:e,height:n}}function fye(t,e,n){const r=Eo(e),i=Po(e),s=n==="fixed",o=_c(t,!0,s,e);let a={scrollLeft:0,scrollTop:0};const l=ho(0);if(r||!r&&!s)if((tf(e)!=="body"||xm(i))&&(a=Mv(e)),r){const h=_c(e,!0,s,e);l.x=h.x+e.clientLeft,l.y=h.y+e.clientTop}else i&&(l.x=FA(i));const c=i&&!r&&!s?I6(i,a):ho(0),u=o.left+a.scrollLeft-l.x-c.x,d=o.top+a.scrollTop-l.y-c.y;return{x:u,y:d,width:o.width,height:o.height}}function wk(t){return Ps(t).position==="static"}function qD(t,e){if(!Eo(t)||Ps(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return Po(t)===n&&(n=n.ownerDocument.body),n}function F6(t,e){const n=Ri(t);if(_v(t))return n;if(!Eo(t)){let i=Sl(t);for(;i&&!bd(i);){if(Ms(i)&&!wk(i))return i;i=Sl(i)}return n}let r=qD(t,e);for(;r&&eye(r)&&wk(r);)r=qD(r,e);return r&&bd(r)&&wk(r)&&!jA(r)?n:r||tye(t)||n}const hye=async function(t){const e=this.getOffsetParent||F6,n=this.getDimensions,r=await n(t.floating);return{reference:fye(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function pye(t){return Ps(t).direction==="rtl"}const mye={convertOffsetParentRelativeRectToViewportRelativeRect:iye,getDocumentElement:Po,getClippingRect:uye,getOffsetParent:F6,getElementRects:hye,getClientRects:sye,getDimensions:dye,getScale:Ju,isElement:Ms,isRTL:pye};function B6(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function gye(t,e){let n=null,r;const i=Po(t);function s(){var a;clearTimeout(r),(a=n)==null||a.disconnect(),n=null}function o(a,l){a===void 0&&(a=!1),l===void 0&&(l=1),s();const c=t.getBoundingClientRect(),{left:u,top:d,width:h,height:m}=c;if(a||e(),!h||!m)return;const y=yy(d),v=yy(i.clientWidth-(u+h)),w=yy(i.clientHeight-(d+m)),b=yy(u),C={rootMargin:-y+"px "+-v+"px "+-w+"px "+-b+"px",threshold:Ei(0,bl(1,l))||1};let T=!0;function _(A){const M=A[0].intersectionRatio;if(M!==l){if(!T)return o();M?o(!1,M):r=setTimeout(()=>{o(!1,1e-7)},1e3)}M===1&&!B6(c,t.getBoundingClientRect())&&o(),T=!1}try{n=new IntersectionObserver(_,{...C,root:i.ownerDocument})}catch{n=new IntersectionObserver(_,C)}n.observe(t)}return o(!0),s}function yye(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:o=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=LA(t),u=i||s?[...c?wp(c):[],...wp(e)]:[];u.forEach(b=>{i&&b.addEventListener("scroll",n,{passive:!0}),s&&b.addEventListener("resize",n)});const d=c&&a?gye(c,n):null;let h=-1,m=null;o&&(m=new ResizeObserver(b=>{let[k]=b;k&&k.target===c&&m&&(m.unobserve(e),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var C;(C=m)==null||C.observe(e)})),n()}),c&&!l&&m.observe(c),m.observe(e));let y,v=l?_c(t):null;l&&w();function w(){const b=_c(t);v&&!B6(v,b)&&n(),v=b,y=requestAnimationFrame(w)}return n(),()=>{var b;u.forEach(k=>{i&&k.removeEventListener("scroll",n),s&&k.removeEventListener("resize",n)}),d==null||d(),(b=m)==null||b.disconnect(),m=null,l&&cancelAnimationFrame(y)}}const xye=Zge,vye=Xge,wye=Yge,bye=Jge,kye=Gge,YD=qge,Sye=Qge,Cye=(t,e,n)=>{const r=new Map,i={platform:mye,...n},s={...i.platform,_c:r};return Uge(t,e,{...i,platform:s})};var u0=typeof document<"u"?S.useLayoutEffect:S.useEffect;function rx(t,e){if(t===e)return!0;if(typeof t!=typeof e)return!1;if(typeof t=="function"&&t.toString()===e.toString())return!0;let n,r,i;if(t&&e&&typeof t=="object"){if(Array.isArray(t)){if(n=t.length,n!==e.length)return!1;for(r=n;r--!==0;)if(!rx(t[r],e[r]))return!1;return!0}if(i=Object.keys(t),n=i.length,n!==Object.keys(e).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(e,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&t.$$typeof)&&!rx(t[s],e[s]))return!1}return!0}return t!==t&&e!==e}function $6(t){return typeof window>"u"?1:(t.ownerDocument.defaultView||window).devicePixelRatio||1}function GD(t,e){const n=$6(t);return Math.round(e*n)/n}function bk(t){const e=S.useRef(t);return u0(()=>{e.current=t}),e}function Eye(t){t===void 0&&(t={});const{placement:e="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:o}={},transform:a=!0,whileElementsMounted:l,open:c}=t,[u,d]=S.useState({x:0,y:0,strategy:n,placement:e,middlewareData:{},isPositioned:!1}),[h,m]=S.useState(r);rx(h,r)||m(r);const[y,v]=S.useState(null),[w,b]=S.useState(null),k=S.useCallback(H=>{H!==A.current&&(A.current=H,v(H))},[]),C=S.useCallback(H=>{H!==M.current&&(M.current=H,b(H))},[]),T=s||y,_=o||w,A=S.useRef(null),M=S.useRef(null),O=S.useRef(u),D=l!=null,R=bk(l),B=bk(i),F=bk(c),W=S.useCallback(()=>{if(!A.current||!M.current)return;const H={placement:e,strategy:n,middleware:h};B.current&&(H.platform=B.current),Cye(A.current,M.current,H).then(z=>{const L={...z,isPositioned:F.current!==!1};I.current&&!rx(O.current,L)&&(O.current=L,Hd.flushSync(()=>{d(L)}))})},[h,e,n,B,F]);u0(()=>{c===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,d(H=>({...H,isPositioned:!1})))},[c]);const I=S.useRef(!1);u0(()=>(I.current=!0,()=>{I.current=!1}),[]),u0(()=>{if(T&&(A.current=T),_&&(M.current=_),T&&_){if(R.current)return R.current(T,_,W);W()}},[T,_,W,R,D]);const Y=S.useMemo(()=>({reference:A,floating:M,setReference:k,setFloating:C}),[k,C]),V=S.useMemo(()=>({reference:T,floating:_}),[T,_]),G=S.useMemo(()=>{const H={position:n,left:0,top:0};if(!V.floating)return H;const z=GD(V.floating,u.x),L=GD(V.floating,u.y);return a?{...H,transform:"translate("+z+"px, "+L+"px)",...$6(V.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:z,top:L}},[n,a,V.floating,u.x,u.y]);return S.useMemo(()=>({...u,update:W,refs:Y,elements:V,floatingStyles:G}),[u,W,Y,V,G])}const Tye=t=>{function e(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:t,fn(n){const{element:r,padding:i}=typeof t=="function"?t(n):t;return r&&e(r)?r.current!=null?YD({element:r.current,padding:i}).fn(n):{}:r?YD({element:r,padding:i}).fn(n):{}}}},Nye=(t,e)=>({...xye(t),options:[t,e]}),Aye=(t,e)=>({...vye(t),options:[t,e]}),_ye=(t,e)=>({...Sye(t),options:[t,e]}),Mye=(t,e)=>({...wye(t),options:[t,e]}),Pye=(t,e)=>({...bye(t),options:[t,e]}),Oye=(t,e)=>({...kye(t),options:[t,e]}),Rye=(t,e)=>({...Tye(t),options:[t,e]});var Dye="Arrow",z6=S.forwardRef((t,e)=>{const{children:n,width:r=10,height:i=5,...s}=t;return g.jsx(Xe.svg,{...s,ref:e,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:t.asChild?n:g.jsx("polygon",{points:"0,0 30,0 15,10"})})});z6.displayName=Dye;var jye=z6;function V6(t){const[e,n]=S.useState(void 0);return Mr(()=>{if(t){n({width:t.offsetWidth,height:t.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let o,a;if("borderBoxSize"in s){const l=s.borderBoxSize,c=Array.isArray(l)?l[0]:l;o=c.inlineSize,a=c.blockSize}else o=t.offsetWidth,a=t.offsetHeight;n({width:o,height:a})});return r.observe(t,{box:"border-box"}),()=>r.unobserve(t)}else n(void 0)},[t]),e}var BA="Popper",[W6,jl]=Ii(BA),[Iye,H6]=W6(BA),U6=t=>{const{__scopePopper:e,children:n}=t,[r,i]=S.useState(null);return g.jsx(Iye,{scope:e,anchor:r,onAnchorChange:i,children:n})};U6.displayName=BA;var q6="PopperAnchor",Y6=S.forwardRef((t,e)=>{const{__scopePopper:n,virtualRef:r,...i}=t,s=H6(q6,n),o=S.useRef(null),a=kt(e,o);return S.useEffect(()=>{s.onAnchorChange((r==null?void 0:r.current)||o.current)}),r?null:g.jsx(Xe.div,{...i,ref:a})});Y6.displayName=q6;var $A="PopperContent",[Lye,Fye]=W6($A),G6=S.forwardRef((t,e)=>{var X,oe,fe,me,Ne,xe;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:o=0,arrowPadding:a=0,avoidCollisions:l=!0,collisionBoundary:c=[],collisionPadding:u=0,sticky:d="partial",hideWhenDetached:h=!1,updatePositionStrategy:m="optimized",onPlaced:y,...v}=t,w=H6($A,n),[b,k]=S.useState(null),C=kt(e,be=>k(be)),[T,_]=S.useState(null),A=V6(T),M=(A==null?void 0:A.width)??0,O=(A==null?void 0:A.height)??0,D=r+(s!=="center"?"-"+s:""),R=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},B=Array.isArray(c)?c:[c],F=B.length>0,W={padding:R,boundary:B.filter($ye),altBoundary:F},{refs:I,floatingStyles:Y,placement:V,isPositioned:G,middlewareData:H}=Eye({strategy:"fixed",placement:D,whileElementsMounted:(...be)=>yye(...be,{animationFrame:m==="always"}),elements:{reference:w.anchor},middleware:[Nye({mainAxis:i+O,alignmentAxis:o}),l&&Aye({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?_ye():void 0,...W}),l&&Mye({...W}),Pye({...W,apply:({elements:be,rects:Oe,availableWidth:Qe,availableHeight:Je})=>{const{width:Dt,height:ee}=Oe.reference,se=be.floating.style;se.setProperty("--radix-popper-available-width",`${Qe}px`),se.setProperty("--radix-popper-available-height",`${Je}px`),se.setProperty("--radix-popper-anchor-width",`${Dt}px`),se.setProperty("--radix-popper-anchor-height",`${ee}px`)}}),T&&Rye({element:T,padding:a}),zye({arrowWidth:M,arrowHeight:O}),h&&Oye({strategy:"referenceHidden",...W})]}),[z,L]=X6(V),q=Fn(y);Mr(()=>{G&&(q==null||q())},[G,q]);const U=(X=H.arrow)==null?void 0:X.x,j=(oe=H.arrow)==null?void 0:oe.y,K=((fe=H.arrow)==null?void 0:fe.centerOffset)!==0,[Z,J]=S.useState();return Mr(()=>{b&&J(window.getComputedStyle(b).zIndex)},[b]),g.jsx("div",{ref:I.setFloating,"data-radix-popper-content-wrapper":"",style:{...Y,transform:G?Y.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Z,"--radix-popper-transform-origin":[(me=H.transformOrigin)==null?void 0:me.x,(Ne=H.transformOrigin)==null?void 0:Ne.y].join(" "),...((xe=H.hide)==null?void 0:xe.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:t.dir,children:g.jsx(Lye,{scope:n,placedSide:z,onArrowChange:_,arrowX:U,arrowY:j,shouldHideArrow:K,children:g.jsx(Xe.div,{"data-side":z,"data-align":L,...v,ref:C,style:{...v.style,animation:G?void 0:"none"}})})})});G6.displayName=$A;var K6="PopperArrow",Bye={top:"bottom",right:"left",bottom:"top",left:"right"},Z6=S.forwardRef(function(e,n){const{__scopePopper:r,...i}=e,s=Fye(K6,r),o=Bye[s.placedSide];return g.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[o]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:g.jsx(jye,{...i,ref:n,style:{...i.style,display:"block"}})})});Z6.displayName=K6;function $ye(t){return t!==null}var zye=t=>({name:"transformOrigin",options:t,fn(e){var w,b,k;const{placement:n,rects:r,middlewareData:i}=e,o=((w=i.arrow)==null?void 0:w.centerOffset)!==0,a=o?0:t.arrowWidth,l=o?0:t.arrowHeight,[c,u]=X6(n),d={start:"0%",center:"50%",end:"100%"}[u],h=(((b=i.arrow)==null?void 0:b.x)??0)+a/2,m=(((k=i.arrow)==null?void 0:k.y)??0)+l/2;let y="",v="";return c==="bottom"?(y=o?d:`${h}px`,v=`${-l}px`):c==="top"?(y=o?d:`${h}px`,v=`${r.floating.height+l}px`):c==="right"?(y=`${-l}px`,v=o?d:`${m}px`):c==="left"&&(y=`${r.floating.width+l}px`,v=o?d:`${m}px`),{data:{x:y,y:v}}}});function X6(t){const[e,n="center"]=t.split("-");return[e,n]}var vm=U6,wm=Y6,Pv=G6,Ov=Z6,bE=["Enter"," "],Vye=["ArrowDown","PageUp","Home"],Q6=["ArrowUp","PageDown","End"],Wye=[...Vye,...Q6],Hye={ltr:[...bE,"ArrowRight"],rtl:[...bE,"ArrowLeft"]},Uye={ltr:["ArrowLeft"],rtl:["ArrowRight"]},bm="Menu",[bp,qye,Yye]=bA(bm),[Uc,J6]=Ii(bm,[Yye,jl,bv]),km=jl(),eV=bv(),[tV,Il]=Uc(bm),[Gye,Sm]=Uc(bm),nV=t=>{const{__scopeMenu:e,open:n=!1,children:r,dir:i,onOpenChange:s,modal:o=!0}=t,a=km(e),[l,c]=S.useState(null),u=S.useRef(!1),d=Fn(s),h=im(i);return S.useEffect(()=>{const m=()=>{u.current=!0,document.addEventListener("pointerdown",y,{capture:!0,once:!0}),document.addEventListener("pointermove",y,{capture:!0,once:!0})},y=()=>u.current=!1;return document.addEventListener("keydown",m,{capture:!0}),()=>{document.removeEventListener("keydown",m,{capture:!0}),document.removeEventListener("pointerdown",y,{capture:!0}),document.removeEventListener("pointermove",y,{capture:!0})}},[]),g.jsx(vm,{...a,children:g.jsx(tV,{scope:e,open:n,onOpenChange:d,content:l,onContentChange:c,children:g.jsx(Gye,{scope:e,onClose:S.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:h,modal:o,children:r})})})};nV.displayName=bm;var Kye="MenuAnchor",zA=S.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t,i=km(n);return g.jsx(wm,{...i,...r,ref:e})});zA.displayName=Kye;var VA="MenuPortal",[Zye,rV]=Uc(VA,{forceMount:void 0}),iV=t=>{const{__scopeMenu:e,forceMount:n,children:r,container:i}=t,s=Il(VA,e);return g.jsx(Zye,{scope:e,forceMount:n,children:g.jsx(Rr,{present:n||s.open,children:g.jsx(mm,{asChild:!0,container:i,children:r})})})};iV.displayName=VA;var es="MenuContent",[Xye,WA]=Uc(es),sV=S.forwardRef((t,e)=>{const n=rV(es,t.__scopeMenu),{forceMount:r=n.forceMount,...i}=t,s=Il(es,t.__scopeMenu),o=Sm(es,t.__scopeMenu);return g.jsx(bp.Provider,{scope:t.__scopeMenu,children:g.jsx(Rr,{present:r||s.open,children:g.jsx(bp.Slot,{scope:t.__scopeMenu,children:o.modal?g.jsx(Qye,{...i,ref:e}):g.jsx(Jye,{...i,ref:e})})})})}),Qye=S.forwardRef((t,e)=>{const n=Il(es,t.__scopeMenu),r=S.useRef(null),i=kt(e,r);return S.useEffect(()=>{const s=r.current;if(s)return Ev(s)},[]),g.jsx(HA,{...t,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Re(t.onFocusOutside,s=>s.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Jye=S.forwardRef((t,e)=>{const n=Il(es,t.__scopeMenu);return g.jsx(HA,{...t,ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),HA=S.forwardRef((t,e)=>{const{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:s,onCloseAutoFocus:o,disableOutsidePointerEvents:a,onEntryFocus:l,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:h,onDismiss:m,disableOutsideScroll:y,...v}=t,w=Il(es,n),b=Sm(es,n),k=km(n),C=eV(n),T=qye(n),[_,A]=S.useState(null),M=S.useRef(null),O=kt(e,M,w.onContentChange),D=S.useRef(0),R=S.useRef(""),B=S.useRef(0),F=S.useRef(null),W=S.useRef("right"),I=S.useRef(0),Y=y?gm:S.Fragment,V=y?{as:yo,allowPinchZoom:!0}:void 0,G=z=>{var X,oe;const L=R.current+z,q=T().filter(fe=>!fe.disabled),U=document.activeElement,j=(X=q.find(fe=>fe.ref.current===U))==null?void 0:X.textValue,K=q.map(fe=>fe.textValue),Z=d0e(K,L,j),J=(oe=q.find(fe=>fe.textValue===Z))==null?void 0:oe.ref.current;(function fe(me){R.current=me,window.clearTimeout(D.current),me!==""&&(D.current=window.setTimeout(()=>fe(""),1e3))})(L),J&&setTimeout(()=>J.focus())};S.useEffect(()=>()=>window.clearTimeout(D.current),[]),Sv();const H=S.useCallback(z=>{var q,U;return W.current===((q=F.current)==null?void 0:q.side)&&h0e(z,(U=F.current)==null?void 0:U.area)},[]);return g.jsx(Xye,{scope:n,searchRef:R,onItemEnter:S.useCallback(z=>{H(z)&&z.preventDefault()},[H]),onItemLeave:S.useCallback(z=>{var L;H(z)||((L=M.current)==null||L.focus(),A(null))},[H]),onTriggerLeave:S.useCallback(z=>{H(z)&&z.preventDefault()},[H]),pointerGraceTimerRef:B,onPointerGraceIntentChange:S.useCallback(z=>{F.current=z},[]),children:g.jsx(Y,{...V,children:g.jsx(pm,{asChild:!0,trapped:i,onMountAutoFocus:Re(s,z=>{var L;z.preventDefault(),(L=M.current)==null||L.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:g.jsx(Xd,{asChild:!0,disableOutsidePointerEvents:a,onEscapeKeyDown:c,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:h,onDismiss:m,children:g.jsx(P$,{asChild:!0,...C,dir:b.dir,orientation:"vertical",loop:r,currentTabStopId:_,onCurrentTabStopIdChange:A,onEntryFocus:Re(l,z=>{b.isUsingKeyboardRef.current||z.preventDefault()}),preventScrollOnEntryFocus:!0,children:g.jsx(Pv,{role:"menu","aria-orientation":"vertical","data-state":kV(w.open),"data-radix-menu-content":"",dir:b.dir,...k,...v,ref:O,style:{outline:"none",...v.style},onKeyDown:Re(v.onKeyDown,z=>{const q=z.target.closest("[data-radix-menu-content]")===z.currentTarget,U=z.ctrlKey||z.altKey||z.metaKey,j=z.key.length===1;q&&(z.key==="Tab"&&z.preventDefault(),!U&&j&&G(z.key));const K=M.current;if(z.target!==K||!Wye.includes(z.key))return;z.preventDefault();const J=T().filter(X=>!X.disabled).map(X=>X.ref.current);Q6.includes(z.key)&&J.reverse(),c0e(J)}),onBlur:Re(t.onBlur,z=>{z.currentTarget.contains(z.target)||(window.clearTimeout(D.current),R.current="")}),onPointerMove:Re(t.onPointerMove,kp(z=>{const L=z.target,q=I.current!==z.clientX;if(z.currentTarget.contains(L)&&q){const U=z.clientX>I.current?"right":"left";W.current=U,I.current=z.clientX}}))})})})})})})});sV.displayName=es;var e0e="MenuGroup",UA=S.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return g.jsx(Xe.div,{role:"group",...r,ref:e})});UA.displayName=e0e;var t0e="MenuLabel",oV=S.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return g.jsx(Xe.div,{...r,ref:e})});oV.displayName=t0e;var ix="MenuItem",KD="menu.itemSelect",Rv=S.forwardRef((t,e)=>{const{disabled:n=!1,onSelect:r,...i}=t,s=S.useRef(null),o=Sm(ix,t.__scopeMenu),a=WA(ix,t.__scopeMenu),l=kt(e,s),c=S.useRef(!1),u=()=>{const d=s.current;if(!n&&d){const h=new CustomEvent(KD,{bubbles:!0,cancelable:!0});d.addEventListener(KD,m=>r==null?void 0:r(m),{once:!0}),pF(d,h),h.defaultPrevented?c.current=!1:o.onClose()}};return g.jsx(aV,{...i,ref:l,disabled:n,onClick:Re(t.onClick,u),onPointerDown:d=>{var h;(h=t.onPointerDown)==null||h.call(t,d),c.current=!0},onPointerUp:Re(t.onPointerUp,d=>{var h;c.current||(h=d.currentTarget)==null||h.click()}),onKeyDown:Re(t.onKeyDown,d=>{const h=a.searchRef.current!=="";n||h&&d.key===" "||bE.includes(d.key)&&(d.currentTarget.click(),d.preventDefault())})})});Rv.displayName=ix;var aV=S.forwardRef((t,e)=>{const{__scopeMenu:n,disabled:r=!1,textValue:i,...s}=t,o=WA(ix,n),a=eV(n),l=S.useRef(null),c=kt(e,l),[u,d]=S.useState(!1),[h,m]=S.useState("");return S.useEffect(()=>{const y=l.current;y&&m((y.textContent??"").trim())},[s.children]),g.jsx(bp.ItemSlot,{scope:n,disabled:r,textValue:i??h,children:g.jsx(O$,{asChild:!0,...a,focusable:!r,children:g.jsx(Xe.div,{role:"menuitem","data-highlighted":u?"":void 0,"aria-disabled":r||void 0,"data-disabled":r?"":void 0,...s,ref:c,onPointerMove:Re(t.onPointerMove,kp(y=>{r?o.onItemLeave(y):(o.onItemEnter(y),y.defaultPrevented||y.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Re(t.onPointerLeave,kp(y=>o.onItemLeave(y))),onFocus:Re(t.onFocus,()=>d(!0)),onBlur:Re(t.onBlur,()=>d(!1))})})})}),n0e="MenuCheckboxItem",lV=S.forwardRef((t,e)=>{const{checked:n=!1,onCheckedChange:r,...i}=t;return g.jsx(hV,{scope:t.__scopeMenu,checked:n,children:g.jsx(Rv,{role:"menuitemcheckbox","aria-checked":sx(n)?"mixed":n,...i,ref:e,"data-state":GA(n),onSelect:Re(i.onSelect,()=>r==null?void 0:r(sx(n)?!0:!n),{checkForDefaultPrevented:!1})})})});lV.displayName=n0e;var cV="MenuRadioGroup",[r0e,i0e]=Uc(cV,{value:void 0,onValueChange:()=>{}}),uV=S.forwardRef((t,e)=>{const{value:n,onValueChange:r,...i}=t,s=Fn(r);return g.jsx(r0e,{scope:t.__scopeMenu,value:n,onValueChange:s,children:g.jsx(UA,{...i,ref:e})})});uV.displayName=cV;var dV="MenuRadioItem",fV=S.forwardRef((t,e)=>{const{value:n,...r}=t,i=i0e(dV,t.__scopeMenu),s=n===i.value;return g.jsx(hV,{scope:t.__scopeMenu,checked:s,children:g.jsx(Rv,{role:"menuitemradio","aria-checked":s,...r,ref:e,"data-state":GA(s),onSelect:Re(r.onSelect,()=>{var o;return(o=i.onValueChange)==null?void 0:o.call(i,n)},{checkForDefaultPrevented:!1})})})});fV.displayName=dV;var qA="MenuItemIndicator",[hV,s0e]=Uc(qA,{checked:!1}),pV=S.forwardRef((t,e)=>{const{__scopeMenu:n,forceMount:r,...i}=t,s=s0e(qA,n);return g.jsx(Rr,{present:r||sx(s.checked)||s.checked===!0,children:g.jsx(Xe.span,{...i,ref:e,"data-state":GA(s.checked)})})});pV.displayName=qA;var o0e="MenuSeparator",mV=S.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t;return g.jsx(Xe.div,{role:"separator","aria-orientation":"horizontal",...r,ref:e})});mV.displayName=o0e;var a0e="MenuArrow",gV=S.forwardRef((t,e)=>{const{__scopeMenu:n,...r}=t,i=km(n);return g.jsx(Ov,{...i,...r,ref:e})});gV.displayName=a0e;var YA="MenuSub",[l0e,yV]=Uc(YA),xV=t=>{const{__scopeMenu:e,children:n,open:r=!1,onOpenChange:i}=t,s=Il(YA,e),o=km(e),[a,l]=S.useState(null),[c,u]=S.useState(null),d=Fn(i);return S.useEffect(()=>(s.open===!1&&d(!1),()=>d(!1)),[s.open,d]),g.jsx(vm,{...o,children:g.jsx(tV,{scope:e,open:r,onOpenChange:d,content:c,onContentChange:u,children:g.jsx(l0e,{scope:e,contentId:Vn(),triggerId:Vn(),trigger:a,onTriggerChange:l,children:n})})})};xV.displayName=YA;var yh="MenuSubTrigger",vV=S.forwardRef((t,e)=>{const n=Il(yh,t.__scopeMenu),r=Sm(yh,t.__scopeMenu),i=yV(yh,t.__scopeMenu),s=WA(yh,t.__scopeMenu),o=S.useRef(null),{pointerGraceTimerRef:a,onPointerGraceIntentChange:l}=s,c={__scopeMenu:t.__scopeMenu},u=S.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);return S.useEffect(()=>u,[u]),S.useEffect(()=>{const d=a.current;return()=>{window.clearTimeout(d),l(null)}},[a,l]),g.jsx(zA,{asChild:!0,...c,children:g.jsx(aV,{id:i.triggerId,"aria-haspopup":"menu","aria-expanded":n.open,"aria-controls":i.contentId,"data-state":kV(n.open),...t,ref:iv(e,i.onTriggerChange),onClick:d=>{var h;(h=t.onClick)==null||h.call(t,d),!(t.disabled||d.defaultPrevented)&&(d.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:Re(t.onPointerMove,kp(d=>{s.onItemEnter(d),!d.defaultPrevented&&!t.disabled&&!n.open&&!o.current&&(s.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:Re(t.onPointerLeave,kp(d=>{var m,y;u();const h=(m=n.content)==null?void 0:m.getBoundingClientRect();if(h){const v=(y=n.content)==null?void 0:y.dataset.side,w=v==="right",b=w?-5:5,k=h[w?"left":"right"],C=h[w?"right":"left"];s.onPointerGraceIntentChange({area:[{x:d.clientX+b,y:d.clientY},{x:k,y:h.top},{x:C,y:h.top},{x:C,y:h.bottom},{x:k,y:h.bottom}],side:v}),window.clearTimeout(a.current),a.current=window.setTimeout(()=>s.onPointerGraceIntentChange(null),300)}else{if(s.onTriggerLeave(d),d.defaultPrevented)return;s.onPointerGraceIntentChange(null)}})),onKeyDown:Re(t.onKeyDown,d=>{var m;const h=s.searchRef.current!=="";t.disabled||h&&d.key===" "||Hye[r.dir].includes(d.key)&&(n.onOpenChange(!0),(m=n.content)==null||m.focus(),d.preventDefault())})})})});vV.displayName=yh;var wV="MenuSubContent",bV=S.forwardRef((t,e)=>{const n=rV(es,t.__scopeMenu),{forceMount:r=n.forceMount,...i}=t,s=Il(es,t.__scopeMenu),o=Sm(es,t.__scopeMenu),a=yV(wV,t.__scopeMenu),l=S.useRef(null),c=kt(e,l);return g.jsx(bp.Provider,{scope:t.__scopeMenu,children:g.jsx(Rr,{present:r||s.open,children:g.jsx(bp.Slot,{scope:t.__scopeMenu,children:g.jsx(HA,{id:a.contentId,"aria-labelledby":a.triggerId,...i,ref:c,align:"start",side:o.dir==="rtl"?"left":"right",disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:u=>{var d;o.isUsingKeyboardRef.current&&((d=l.current)==null||d.focus()),u.preventDefault()},onCloseAutoFocus:u=>u.preventDefault(),onFocusOutside:Re(t.onFocusOutside,u=>{u.target!==a.trigger&&s.onOpenChange(!1)}),onEscapeKeyDown:Re(t.onEscapeKeyDown,u=>{o.onClose(),u.preventDefault()}),onKeyDown:Re(t.onKeyDown,u=>{var m;const d=u.currentTarget.contains(u.target),h=Uye[o.dir].includes(u.key);d&&h&&(s.onOpenChange(!1),(m=a.trigger)==null||m.focus(),u.preventDefault())})})})})})});bV.displayName=wV;function kV(t){return t?"open":"closed"}function sx(t){return t==="indeterminate"}function GA(t){return sx(t)?"indeterminate":t?"checked":"unchecked"}function c0e(t){const e=document.activeElement;for(const n of t)if(n===e||(n.focus(),document.activeElement!==e))return}function u0e(t,e){return t.map((n,r)=>t[(e+r)%t.length])}function d0e(t,e,n){const i=e.length>1&&Array.from(e).every(c=>c===e[0])?e[0]:e,s=n?t.indexOf(n):-1;let o=u0e(t,Math.max(s,0));i.length===1&&(o=o.filter(c=>c!==n));const l=o.find(c=>c.toLowerCase().startsWith(i.toLowerCase()));return l!==n?l:void 0}function f0e(t,e){const{x:n,y:r}=t;let i=!1;for(let s=0,o=e.length-1;s<e.length;o=s++){const a=e[s].x,l=e[s].y,c=e[o].x,u=e[o].y;l>r!=u>r&&n<(c-a)*(r-l)/(u-l)+a&&(i=!i)}return i}function h0e(t,e){if(!e)return!1;const n={x:t.clientX,y:t.clientY};return f0e(n,e)}function kp(t){return e=>e.pointerType==="mouse"?t(e):void 0}var p0e=nV,m0e=zA,g0e=iV,y0e=sV,x0e=UA,v0e=oV,w0e=Rv,b0e=lV,k0e=uV,S0e=fV,C0e=pV,E0e=mV,T0e=gV,N0e=xV,A0e=vV,_0e=bV,KA="DropdownMenu",[M0e,b4e]=Ii(KA,[J6]),jr=J6(),[P0e,SV]=M0e(KA),CV=t=>{const{__scopeDropdownMenu:e,children:n,dir:r,open:i,defaultOpen:s,onOpenChange:o,modal:a=!0}=t,l=jr(e),c=S.useRef(null),[u=!1,d]=bo({prop:i,defaultProp:s,onChange:o});return g.jsx(P0e,{scope:e,triggerId:Vn(),triggerRef:c,contentId:Vn(),open:u,onOpenChange:d,onOpenToggle:S.useCallback(()=>d(h=>!h),[d]),modal:a,children:g.jsx(p0e,{...l,open:u,onOpenChange:d,dir:r,modal:a,children:n})})};CV.displayName=KA;var EV="DropdownMenuTrigger",TV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,disabled:r=!1,...i}=t,s=SV(EV,n),o=jr(n);return g.jsx(m0e,{asChild:!0,...o,children:g.jsx(Xe.button,{type:"button",id:s.triggerId,"aria-haspopup":"menu","aria-expanded":s.open,"aria-controls":s.open?s.contentId:void 0,"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,disabled:r,...i,ref:iv(e,s.triggerRef),onPointerDown:Re(t.onPointerDown,a=>{!r&&a.button===0&&a.ctrlKey===!1&&(s.onOpenToggle(),s.open||a.preventDefault())}),onKeyDown:Re(t.onKeyDown,a=>{r||(["Enter"," "].includes(a.key)&&s.onOpenToggle(),a.key==="ArrowDown"&&s.onOpenChange(!0),["Enter"," ","ArrowDown"].includes(a.key)&&a.preventDefault())})})})});TV.displayName=EV;var O0e="DropdownMenuPortal",NV=t=>{const{__scopeDropdownMenu:e,...n}=t,r=jr(e);return g.jsx(g0e,{...r,...n})};NV.displayName=O0e;var AV="DropdownMenuContent",_V=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=SV(AV,n),s=jr(n),o=S.useRef(!1);return g.jsx(y0e,{id:i.contentId,"aria-labelledby":i.triggerId,...s,...r,ref:e,onCloseAutoFocus:Re(t.onCloseAutoFocus,a=>{var l;o.current||(l=i.triggerRef.current)==null||l.focus(),o.current=!1,a.preventDefault()}),onInteractOutside:Re(t.onInteractOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,u=l.button===2||c;(!i.modal||u)&&(o.current=!0)}),style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});_V.displayName=AV;var R0e="DropdownMenuGroup",MV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=jr(n);return g.jsx(x0e,{...i,...r,ref:e})});MV.displayName=R0e;var D0e="DropdownMenuLabel",PV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=jr(n);return g.jsx(v0e,{...i,...r,ref:e})});PV.displayName=D0e;var j0e="DropdownMenuItem",OV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=jr(n);return g.jsx(w0e,{...i,...r,ref:e})});OV.displayName=j0e;var I0e="DropdownMenuCheckboxItem",RV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=jr(n);return g.jsx(b0e,{...i,...r,ref:e})});RV.displayName=I0e;var L0e="DropdownMenuRadioGroup",DV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=jr(n);return g.jsx(k0e,{...i,...r,ref:e})});DV.displayName=L0e;var F0e="DropdownMenuRadioItem",jV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=jr(n);return g.jsx(S0e,{...i,...r,ref:e})});jV.displayName=F0e;var B0e="DropdownMenuItemIndicator",IV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=jr(n);return g.jsx(C0e,{...i,...r,ref:e})});IV.displayName=B0e;var $0e="DropdownMenuSeparator",LV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=jr(n);return g.jsx(E0e,{...i,...r,ref:e})});LV.displayName=$0e;var z0e="DropdownMenuArrow",V0e=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=jr(n);return g.jsx(T0e,{...i,...r,ref:e})});V0e.displayName=z0e;var W0e=t=>{const{__scopeDropdownMenu:e,children:n,open:r,onOpenChange:i,defaultOpen:s}=t,o=jr(e),[a=!1,l]=bo({prop:r,defaultProp:s,onChange:i});return g.jsx(N0e,{...o,open:a,onOpenChange:l,children:n})},H0e="DropdownMenuSubTrigger",FV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=jr(n);return g.jsx(A0e,{...i,...r,ref:e})});FV.displayName=H0e;var U0e="DropdownMenuSubContent",BV=S.forwardRef((t,e)=>{const{__scopeDropdownMenu:n,...r}=t,i=jr(n);return g.jsx(_0e,{...i,...r,ref:e,style:{...t.style,"--radix-dropdown-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-dropdown-menu-content-available-width":"var(--radix-popper-available-width)","--radix-dropdown-menu-content-available-height":"var(--radix-popper-available-height)","--radix-dropdown-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-dropdown-menu-trigger-height":"var(--radix-popper-anchor-height)"}})});BV.displayName=U0e;var q0e=CV,$V=TV,zV=NV,VV=_V,Y0e=MV,WV=PV,HV=OV,UV=RV,G0e=DV,qV=jV,YV=IV,GV=LV,K0e=W0e,KV=FV,ZV=BV;function Nu(t,e,n){let r=n.initialDeps??[],i;return()=>{var s,o,a,l;let c;n.key&&((s=n.debug)!=null&&s.call(n))&&(c=Date.now());const u=t();if(!(u.length!==r.length||u.some((m,y)=>r[y]!==m)))return i;r=u;let h;if(n.key&&((o=n.debug)!=null&&o.call(n))&&(h=Date.now()),i=e(...u),n.key&&((a=n.debug)!=null&&a.call(n))){const m=Math.round((Date.now()-c)*100)/100,y=Math.round((Date.now()-h)*100)/100,v=y/16,w=(b,k)=>{for(b=String(b);b.length<k;)b=" "+b;return b};console.info(`%c⏱ ${w(y,5)} /${w(m,5)} ms`,`
344
344
  font-size: .6rem;
345
345
  font-weight: bold;
346
- color: hsl(${Math.max(0,Math.min(120-120*v,120))}deg 100% 31%);`,n==null?void 0:n.key)}return(l=n==null?void 0:n.onChange)==null||l.call(n,i),i}}function kk(t,e){if(t===void 0)throw new Error("Unexpected undefined");return t}const Z0e=(t,e)=>Math.abs(t-e)<1,X0e=(t,e,n)=>{let r;return function(...i){t.clearTimeout(r),r=t.setTimeout(()=>e.apply(this,i),n)}},Q0e=t=>t,J0e=t=>{const e=Math.max(t.startIndex-t.overscan,0),n=Math.min(t.endIndex+t.overscan,t.count-1),r=[];for(let i=e;i<=n;i++)r.push(i);return r},exe=(t,e)=>{const n=t.scrollElement;if(!n)return;const r=t.targetWindow;if(!r)return;const i=o=>{const{width:a,height:l}=o;e({width:Math.round(a),height:Math.round(l)})};if(i(n.getBoundingClientRect()),!r.ResizeObserver)return()=>{};const s=new r.ResizeObserver(o=>{const a=()=>{const l=o[0];if(l!=null&&l.borderBoxSize){const c=l.borderBoxSize[0];if(c){i({width:c.inlineSize,height:c.blockSize});return}}i(n.getBoundingClientRect())};t.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return s.observe(n,{box:"border-box"}),()=>{s.unobserve(n)}},ZD={passive:!0},XD=typeof window>"u"?!0:"onscrollend"in window,txe=(t,e)=>{const n=t.scrollElement;if(!n)return;const r=t.targetWindow;if(!r)return;let i=0;const s=t.options.useScrollendEvent&&XD?()=>{}:X0e(r,()=>{e(i,!1)},t.options.isScrollingResetDelay),o=u=>()=>{const{horizontal:d,isRtl:h}=t.options;i=d?n.scrollLeft*(h&&-1||1):n.scrollTop,s(),e(i,u)},a=o(!0),l=o(!1);l(),n.addEventListener("scroll",a,ZD);const c=t.options.useScrollendEvent&&XD;return c&&n.addEventListener("scrollend",l,ZD),()=>{n.removeEventListener("scroll",a),c&&n.removeEventListener("scrollend",l)}},nxe=(t,e,n)=>{if(e!=null&&e.borderBoxSize){const r=e.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return Math.round(t.getBoundingClientRect()[n.options.horizontal?"width":"height"])},rxe=(t,{adjustments:e=0,behavior:n},r)=>{var i,s;const o=t+e;(s=(i=r.scrollElement)==null?void 0:i.scrollTo)==null||s.call(i,{[r.options.horizontal?"left":"top"]:o,behavior:n})};class ixe{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollToIndexTimeoutId=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.pendingMeasuredCacheIndexes=[],this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(i=>{i.forEach(s=>{const o=()=>{this._measureElement(s.target,s)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var i;(i=r())==null||i.disconnect(),n=null},observe:i=>{var s;return(s=r())==null?void 0:s.observe(i,{box:"border-box"})},unobserve:i=>{var s;return(s=r())==null?void 0:s.unobserve(i)}}})(),this.range=null,this.setOptions=n=>{Object.entries(n).forEach(([r,i])=>{typeof i>"u"&&delete n[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Q0e,rangeExtractor:J0e,onChange:()=>{},measureElement:nxe,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!0,useAnimationFrameWithResizeObserver:!1,...n}},this.notify=n=>{var r,i;(i=(r=this.options).onChange)==null||i.call(r,this,n)},this.maybeNotify=Nu(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)}),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0}),this.unsubs.push(this.options.observeElementRect(this,i=>{this.scrollRect=i,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(i,s)=>{this.scrollAdjustments=0,this.scrollDirection=s?this.getScrollOffset()<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=s,this.maybeNotify()}))}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(n,r)=>{const i=new Map,s=new Map;for(let o=r-1;o>=0;o--){const a=n[o];if(i.has(a.lane))continue;const l=s.get(a.lane);if(l==null||a.end>l.end?s.set(a.lane,a):a.end<l.end&&i.set(a.lane,!0),i.size===this.options.lanes)break}return s.size===this.options.lanes?Array.from(s.values()).sort((o,a)=>o.end===a.end?o.index-a.index:o.end-a.end)[0]:void 0},this.getMeasurementOptions=Nu(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled],(n,r,i,s,o)=>(this.pendingMeasuredCacheIndexes=[],{count:n,paddingStart:r,scrollMargin:i,getItemKey:s,enabled:o}),{key:!1}),this.getMeasurements=Nu(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:n,paddingStart:r,scrollMargin:i,getItemKey:s,enabled:o},a)=>{if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),[];this.measurementsCache.length===0&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(u=>{this.itemSizeCache.set(u.key,u.size)}));const l=this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[];const c=this.measurementsCache.slice(0,l);for(let u=l;u<n;u++){const d=s(u),h=this.options.lanes===1?c[u-1]:this.getFurthestMeasurement(c,u),m=h?h.end+this.options.gap:r+i,y=a.get(d),v=typeof y=="number"?y:this.options.estimateSize(u),w=m+v,b=h?h.lane:u%this.options.lanes;c[u]={index:u,start:m,size:v,end:w,key:d,lane:b}}return this.measurementsCache=c,c},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Nu(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset()],(n,r,i)=>this.range=n.length>0&&r>0?sxe({measurements:n,outerSize:r,scrollOffset:i}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Nu(()=>{let n=null,r=null;const i=this.calculateRange();return i&&(n=i.startIndex,r=i.endIndex),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,i,s,o)=>s===null||o===null?[]:n({startIndex:s,endIndex:o,overscan:r,count:i}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,i=n.getAttribute(r);return i?parseInt(i,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this._measureElement=(n,r)=>{const i=this.indexFromElement(n),s=this.measurementsCache[i];if(!s)return;const o=s.key,a=this.elementsCache.get(o);a!==n&&(a&&this.observer.unobserve(a),this.observer.observe(n),this.elementsCache.set(o,n)),n.isConnected&&this.resizeItem(i,this.options.measureElement(n,r,this))},this.resizeItem=(n,r)=>{const i=this.measurementsCache[n];if(!i)return;const s=this.itemSizeCache.get(i.key)??i.size,o=r-s;o!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(i,o,this):i.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(i.index),this.itemSizeCache=new Map(this.itemSizeCache.set(i.key,r)),this.notify(!1))},this.measureElement=n=>{if(!n){this.elementsCache.forEach((r,i)=>{r.isConnected||(this.observer.unobserve(r),this.elementsCache.delete(i))});return}this._measureElement(n,void 0)},this.getVirtualItems=Nu(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const i=[];for(let s=0,o=n.length;s<o;s++){const a=n[s],l=r[a];i.push(l)}return i},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length!==0)return kk(r[XV(0,r.length-1,i=>kk(r[i]).start,n)])},this.getOffsetForAlignment=(n,r)=>{const i=this.getSize(),s=this.getScrollOffset();r==="auto"&&n>=s+i&&(r="end"),r==="end"&&(n-=i);const o=this.options.horizontal?"scrollWidth":"scrollHeight",l=(this.scrollElement?"document"in this.scrollElement?this.scrollElement.document.documentElement[o]:this.scrollElement[o]:0)-i;return Math.max(Math.min(l,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const i=this.measurementsCache[n];if(!i)return;const s=this.getSize(),o=this.getScrollOffset();if(r==="auto")if(i.end>=o+s-this.options.scrollPaddingEnd)r="end";else if(i.start<=o+this.options.scrollPaddingStart)r="start";else return[o,r];const a=i.start-this.options.scrollPaddingStart+(i.size-s)/2;switch(r){case"center":return[this.getOffsetForAlignment(a,r),r];case"end":return[this.getOffsetForAlignment(i.end+this.options.scrollPaddingEnd,r),r];default:return[this.getOffsetForAlignment(i.start-this.options.scrollPaddingStart,r),r]}},this.isDynamicMode=()=>this.elementsCache.size>0,this.cancelScrollToIndex=()=>{this.scrollToIndexTimeoutId!==null&&this.targetWindow&&(this.targetWindow.clearTimeout(this.scrollToIndexTimeoutId),this.scrollToIndexTimeoutId=null)},this.scrollToOffset=(n,{align:r="start",behavior:i}={})=>{this.cancelScrollToIndex(),i==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(n,r),{adjustments:void 0,behavior:i})},this.scrollToIndex=(n,{align:r="auto",behavior:i}={})=>{n=Math.max(0,Math.min(n,this.options.count-1)),this.cancelScrollToIndex(),i==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size.");const s=this.getOffsetForIndex(n,r);if(!s)return;const[o,a]=s;this._scrollToOffset(o,{adjustments:void 0,behavior:i}),i!=="smooth"&&this.isDynamicMode()&&this.targetWindow&&(this.scrollToIndexTimeoutId=this.targetWindow.setTimeout(()=>{if(this.scrollToIndexTimeoutId=null,this.elementsCache.has(this.options.getItemKey(n))){const[c]=kk(this.getOffsetForIndex(n,a));Z0e(c,this.getScrollOffset())||this.scrollToIndex(n,{align:a,behavior:i})}else this.scrollToIndex(n,{align:a,behavior:i})}))},this.scrollBy=(n,{behavior:r}={})=>{this.cancelScrollToIndex(),r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+n,{adjustments:void 0,behavior:r})},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let i;return r.length===0?i=this.options.paddingStart:i=this.options.lanes===1?((n=r[r.length-1])==null?void 0:n.end)??0:Math.max(...r.slice(-this.options.lanes).map(s=>s.end)),Math.max(i-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(n,{adjustments:r,behavior:i})=>{this.options.scrollToFn(n,{behavior:i,adjustments:r},this)},this.measure=()=>{this.itemSizeCache=new Map,this.notify(!1)},this.setOptions(e)}}const XV=(t,e,n,r)=>{for(;t<=e;){const i=(t+e)/2|0,s=n(i);if(s<r)t=i+1;else if(s>r)e=i-1;else return i}return t>0?t-1:0};function sxe({measurements:t,outerSize:e,scrollOffset:n}){const r=t.length-1,s=XV(0,r,a=>t[a].start,n);let o=s;for(;o<r&&t[o].end<n+e;)o++;return{startIndex:s,endIndex:o}}const QD=typeof document<"u"?S.useLayoutEffect:S.useEffect;function oxe(t){const e=S.useReducer(()=>({}),{})[1],n={...t,onChange:(i,s)=>{var o;s?Hd.flushSync(e):e(),(o=t.onChange)==null||o.call(t,i,s)}},[r]=S.useState(()=>new ixe(n));return r.setOptions(n),QD(()=>r._didMount(),[]),QD(()=>r._willUpdate()),r}function axe(t){return oxe({observeElementRect:exe,observeElementOffset:txe,scrollToFn:rxe,...t})}const lxe=q0e,cxe=Y0e,uxe=zV,dxe=K0e,fxe=G0e,QV=S.forwardRef(({className:t,inset:e,children:n,...r},i)=>g.jsx($V,{ref:i,className:ve("focus-visible:ring-ring focus:outline-none focus-visible:rounded focus-visible:outline-none focus-visible:ring-1",t),...r,children:n}));QV.displayName=$V.displayName;const JV=S.forwardRef(({className:t,inset:e,children:n,...r},i)=>g.jsxs(KV,{ref:i,className:ve("focus:bg-accent data-[state=open]:bg-accent flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none",e&&"pl-8",t),...r,children:[n,g.jsx(Xh,{className:"ml-auto -rotate-90"})]}));JV.displayName=KV.displayName;const e8=S.forwardRef(({className:t,...e},n)=>g.jsx(ZV,{ref:n,className:ve("popover-backdrop-filter popover-background popover-border popover-shadow popover-foreground data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 z-50 min-w-[8rem] overflow-auto overflow-x-hidden rounded-md p-1",t),...e}));e8.displayName=ZV.displayName;const t8=S.forwardRef(({className:t,container:e,sideOffset:n=4,...r},i)=>g.jsx(zV,{container:e,children:g.jsx(VV,{ref:i,sideOffset:n,className:ve("popover-backdrop-filter bg-mastra-bg-2 popover-border popover-shadow popover-foreground data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 z-50 min-w-[8rem] overflow-auto overflow-x-hidden rounded-md p-1",t),...r})}));t8.displayName=VV.displayName;const n8=S.forwardRef(({className:t,inset:e,...n},r)=>g.jsx(HV,{ref:r,className:ve("focus:text-accent-foreground relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-[0.8125rem] outline-none transition-colors focus:bg-[#66686A]/20 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>span]:truncate",e&&"pl-8",t),...n}));n8.displayName=HV.displayName;const r8=S.forwardRef(({className:t,children:e,checked:n,...r},i)=>g.jsxs(UV,{ref:i,className:ve("focus:bg-accent focus:text-accent-foreground relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:n,...r,children:[g.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:g.jsx(YV,{children:g.jsx(lN,{className:"h-2 w-2 fill-current"})})}),e]}));r8.displayName=UV.displayName;const i8=S.forwardRef(({className:t,children:e,...n},r)=>g.jsxs(qV,{ref:r,className:ve("focus:bg-accent focus:text-accent-foreground relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...n,children:[g.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:g.jsx(YV,{children:g.jsx(aX,{className:"h-2 w-2 fill-current"})})}),e]}));i8.displayName=qV.displayName;const s8=S.forwardRef(({className:t,inset:e,...n},r)=>g.jsx(WV,{ref:r,className:ve("px-2 py-1.5 text-sm font-semibold",e&&"pl-8",t),...n}));s8.displayName=WV.displayName;const o8=S.forwardRef(({className:t,...e},n)=>g.jsx(GV,{ref:n,className:ve("popover-dividers-bg -mx-1 my-1 h-px",t),...e}));o8.displayName=GV.displayName;const a8=({className:t,...e})=>g.jsx("span",{className:ve("ml-auto text-xs tracking-widest opacity-60",t),...e});a8.displayName="DropdownMenuShortcut";function er({open:t,onOpenChange:e,children:n,modal:r}){return g.jsx(lxe,{modal:r,open:t,onOpenChange:e,children:n})}function hxe({itemsCount:t,items:e,renderItem:n,...r}){const i=S.useRef(null),s=axe({count:t,estimateSize:()=>35,getScrollElement:()=>i.current,overscan:5,measureElement:typeof window<"u"&&navigator.userAgent.indexOf("Firefox")===-1?o=>o==null?void 0:o.getBoundingClientRect().height:void 0});return g.jsx("div",{ref:i,className:"h-64 overflow-auto",children:g.jsx("div",{className:"relative w-full overflow-auto",style:{height:`${s.getTotalSize()}px`},children:s==null?void 0:s.getVirtualItems().map((o,a)=>g.jsx("button",{className:"text-accent-foreground absolute left-0 top-0 flex w-full cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-[0.8125rem] outline-none transition-colors hover:bg-[#66686A]/20 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>span]:truncate",style:{height:`${o.size}px`,transform:`translateY(${o.start}px)`},...r,children:n(e[a])},o.index))})})}er.Trigger=QV;er.Content=t8;er.Group=cxe;er.Portal=uxe;er.Item=n8;er.CheckboxItem=r8;er.RadioItem=i8;er.Label=s8;er.Separator=o8;er.Shortcut=a8;er.Sub=dxe;er.SubContent=e8;er.SubTrigger=JV;er.RadioGroup=fxe;er.VirtualizedItems=hxe;const pxe=t=>{const{data:e,isLoading:n,mutate:r}=eA(`/api/memory/status?agentId=${t}`,uN,{fallbackData:{result:!1},isPaused:()=>!t});return{memory:e,isLoading:n,mutate:r}},mxe=({resourceid:t,agentId:e})=>{const{data:n,isLoading:r,mutate:i}=eA(`/api/memory/threads?resourceid=${t}&agentId=${e}`,uN,{fallbackData:[],isPaused:()=>!t,revalidateOnFocus:!1});return S.useEffect(()=>{t&&i()},[t]),{threads:n,isLoading:r,mutate:i}},gxe=({threadId:t,memory:e,agentId:n})=>{const{data:r,isLoading:i,mutate:s}=eA(`/api/memory/threads/${t}/messages?agentId=${n}`,o=>uN(o,!0),{fallbackData:{uiMessages:[],messages:[]},revalidateOnFocus:!1,isPaused:()=>!t,shouldRetryOnError:!1});return S.useEffect(()=>{t&&e&&s()},[t,e]),{messages:r==null?void 0:r.uiMessages,isLoading:i,mutate:s}},yxe=()=>{const{mutate:t}=JN();return{deleteThread:async({threadId:n,resourceid:r,agentId:i})=>{const s=fetch(`/api/memory/threads/${n}?agentId=${i}`,{method:"DELETE",headers:{"Content-Type":"application/json"}});xn.promise(s,{loading:"Deleting chat...",success:()=>(t(`/api/memory/threads?resourceid=${r}&agentId=${i}`),"Chat deleted successfully"),error:"Failed to delete chat"})}}};function xxe({agentId:t,threadId:e}){const{threads:n,isLoading:r}=mxe({resourceid:t,agentId:t}),{deleteThread:i}=yxe(),s=Ao(),[o,a]=S.useState(null),[l,c]=S.useState(!1),u=async()=>{await i({threadId:o,resourceid:t,agentId:t}),c(!1),o===e&&s(`/agents/${t}/chat/${ro()}`)};return r?g.jsxs("div",{className:"p-4 w-full h-full space-y-2",children:[g.jsx("div",{className:"flex justify-end",children:g.jsx(qe,{className:"h-9 w-9"})}),g.jsx(qe,{className:"h-4"}),g.jsx(qe,{className:"h-4"}),g.jsx(qe,{className:"h-4"}),g.jsx(qe,{className:"h-4"}),g.jsx(qe,{className:"h-4"})]}):n!=null&&n.length?g.jsxs(zn,{className:"h-full px-4 pb-4 w-[256px]",children:[g.jsxs("div",{className:"space-y-2",children:[g.jsxs("div",{className:"flex justify-between items-center pl-2 sticky top-0 bg-mastra-bg-2 pt-4",children:[g.jsx("div",{className:"text-sm text-mastra-el-5",children:"Chat history"}),g.jsx(pt,{variant:"primary",size:"icon",onClick:()=>s(`/agents/${t}/chat/${ro()}`),children:g.jsx(Qh,{})})]}),n.map(d=>{const h=d.id===e;return g.jsxs("div",{className:ve("flex cursor-pointer w-full px-2 items-center focus-visible:outline-none transition-colors focus-visible:ring-1 focus-visible:ring-mastra-border-4 gap-3 rounded-xs group text-small hover:bg-mastra-el-6/5",h?"bg-mastra-el-6/5":""),children:[g.jsx(rm,{to:`/agents/${t}/chat/${d.id}`,className:"flex-1",children:g.jsx("p",{className:ve("py-[0.38rem] text-mastra-el-6/60 group-hover:text-mastra-el-6 transition-all capitalize ",h?"text-mastra-el-6":""),children:d.title})}),g.jsxs(er,{children:[g.jsx(er.Trigger,{asChild:!0,children:g.jsxs(pt,{variant:"ghost",size:"icon",className:"ml-auto",children:[g.jsx(uX,{}),g.jsx("span",{className:"sr-only",children:"More"})]})}),g.jsx(er.Content,{children:g.jsxs(er.Item,{className:"cursor-pointer text-destructive focus:bg-destructive/15 focus:text-destructive dark:text-red-500",onSelect:()=>{a(d.id),c(!0)},children:[g.jsx(vX,{}),g.jsx("span",{children:"Delete"})]})})]})]},d.id)})]}),g.jsx(sn,{open:l,onOpenChange:c,children:g.jsxs(sn.Content,{children:[g.jsxs(sn.Header,{children:[g.jsx(sn.Title,{children:"Are you absolutely sure?"}),g.jsx(sn.Description,{children:"This action cannot be undone. This will permanently delete your chat and remove it from our servers."})]}),g.jsxs(sn.Footer,{children:[g.jsx(sn.Cancel,{children:"Cancel"}),g.jsx(sn.Action,{onClick:u,children:"Continue"})]})]})})]}):g.jsxs("div",{className:"p-4 w-full space-y-2 h-full",children:[g.jsxs("div",{className:"flex justify-between items-center",children:[g.jsx("div",{className:"text-sm text-mastra-el-5",children:"Chat history"}),g.jsx(pt,{variant:"primary",size:"icon",onClick:()=>s(`/agents/${t}/chat/${ro()}`),children:g.jsx(Qh,{})})]}),g.jsx("div",{className:"text-small text-mastra-el-3",children:"Your conversations will appear here once you start chatting!"})]})}function JD(){const{agentId:t,threadId:e}=xa(),{agent:n,isLoading:r}=Vc(t),{memory:i}=pxe(t),s=Ao(),{messages:o,isLoading:a}=gxe({agentId:t,threadId:e,memory:!!(i!=null&&i.result)}),[l,c]=S.useState(!0);return S.useEffect(()=>{i!=null&&i.result&&!e&&s(`/agents/${t}/chat/${ro()}`)},[i==null?void 0:i.result,e]),r?g.jsxs("main",{className:"flex-1 relative grid grid-cols-[1fr_400px] divide-x",children:[g.jsx("div",{className:"p-4",children:g.jsx(qe,{className:"h-[600px]"})}),g.jsx("div",{className:"flex flex-col",children:g.jsx(J0,{agentId:t})})]}):g.jsxs("main",{className:ve("flex-1 relative grid divide-x",l&&(i!=null&&i.result)?"grid-cols-[256px_1fr_400px] overflow-y-hidden h-full":"grid-cols-[1fr_400px]"),children:[l&&(i!=null&&i.result)?g.jsx(xxe,{agentId:t,threadId:e}):null,g.jsxs("div",{className:"relative",children:[i!=null&&i.result?g.jsx(pt,{variant:"primary",size:"icon",className:"absolute top-4 left-4 z-50",onClick:()=>c(!l),children:g.jsx(pX,{})}):null,g.jsx(hde,{agentId:t,agentName:n==null?void 0:n.name,threadId:e,initialMessages:a?void 0:o,memory:i==null?void 0:i.result})]}),g.jsx("div",{className:"flex flex-col",children:g.jsx(J0,{agentId:t})})]})}const vxe=qd("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Ih({className:t,variant:e,...n}){return g.jsx("div",{className:ve(vxe({variant:e}),t),...n})}function xy({content:t,label:e,multiline:n=!1}){const r=()=>{navigator.clipboard.writeText(t)};return g.jsxs("div",{className:"group relative flex items-start gap-2",children:[g.jsx("span",{className:ve("text-sm text-mastra-el-4",n?"whitespace-pre-wrap":"truncate"),children:t}),g.jsx(pt,{variant:"ghost",size:"sm",className:"opacity-0 group-hover:opacity-100 transition-opacity shrink-0 -mt-1",onClick:i=>{i.stopPropagation(),r()},"aria-label":`Copy ${e}`,children:g.jsx(Q3,{className:"h-3 w-3"})})]})}var wxe="VisuallyHidden",ZA=S.forwardRef((t,e)=>g.jsx(Xe.span,{...t,ref:e,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...t.style}}));ZA.displayName=wxe;var bxe=ZA,[Dv,k4e]=Ii("Tooltip",[jl]),jv=jl(),l8="TooltipProvider",kxe=700,kE="tooltip.open",[Sxe,XA]=Dv(l8),c8=t=>{const{__scopeTooltip:e,delayDuration:n=kxe,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=t,[o,a]=S.useState(!0),l=S.useRef(!1),c=S.useRef(0);return S.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),g.jsx(Sxe,{scope:e,isOpenDelayed:o,delayDuration:n,onOpen:S.useCallback(()=>{window.clearTimeout(c.current),a(!1)},[]),onClose:S.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>a(!0),r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:S.useCallback(u=>{l.current=u},[]),disableHoverableContent:i,children:s})};c8.displayName=l8;var Iv="Tooltip",[Cxe,Lv]=Dv(Iv),u8=t=>{const{__scopeTooltip:e,children:n,open:r,defaultOpen:i=!1,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=t,l=XA(Iv,t.__scopeTooltip),c=jv(e),[u,d]=S.useState(null),h=Vn(),m=S.useRef(0),y=o??l.disableHoverableContent,v=a??l.delayDuration,w=S.useRef(!1),[b=!1,k]=bo({prop:r,defaultProp:i,onChange:M=>{M?(l.onOpen(),document.dispatchEvent(new CustomEvent(kE))):l.onClose(),s==null||s(M)}}),C=S.useMemo(()=>b?w.current?"delayed-open":"instant-open":"closed",[b]),T=S.useCallback(()=>{window.clearTimeout(m.current),m.current=0,w.current=!1,k(!0)},[k]),_=S.useCallback(()=>{window.clearTimeout(m.current),m.current=0,k(!1)},[k]),A=S.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{w.current=!0,k(!0),m.current=0},v)},[v,k]);return S.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),g.jsx(vm,{...c,children:g.jsx(Cxe,{scope:e,contentId:h,open:b,stateAttribute:C,trigger:u,onTriggerChange:d,onTriggerEnter:S.useCallback(()=>{l.isOpenDelayed?A():T()},[l.isOpenDelayed,A,T]),onTriggerLeave:S.useCallback(()=>{y?_():(window.clearTimeout(m.current),m.current=0)},[_,y]),onOpen:T,onClose:_,disableHoverableContent:y,children:n})})};u8.displayName=Iv;var SE="TooltipTrigger",d8=S.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,i=Lv(SE,n),s=XA(SE,n),o=jv(n),a=S.useRef(null),l=kt(e,a,i.onTriggerChange),c=S.useRef(!1),u=S.useRef(!1),d=S.useCallback(()=>c.current=!1,[]);return S.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),g.jsx(wm,{asChild:!0,...o,children:g.jsx(Xe.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:l,onPointerMove:Re(t.onPointerMove,h=>{h.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),u.current=!0)}),onPointerLeave:Re(t.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:Re(t.onPointerDown,()=>{c.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Re(t.onFocus,()=>{c.current||i.onOpen()}),onBlur:Re(t.onBlur,i.onClose),onClick:Re(t.onClick,i.onClose)})})});d8.displayName=SE;var Exe="TooltipPortal",[S4e,Txe]=Dv(Exe,{forceMount:void 0}),kd="TooltipContent",f8=S.forwardRef((t,e)=>{const n=Txe(kd,t.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=t,o=Lv(kd,t.__scopeTooltip);return g.jsx(Rr,{present:r||o.open,children:o.disableHoverableContent?g.jsx(h8,{side:i,...s,ref:e}):g.jsx(Nxe,{side:i,...s,ref:e})})}),Nxe=S.forwardRef((t,e)=>{const n=Lv(kd,t.__scopeTooltip),r=XA(kd,t.__scopeTooltip),i=S.useRef(null),s=kt(e,i),[o,a]=S.useState(null),{trigger:l,onClose:c}=n,u=i.current,{onPointerInTransitChange:d}=r,h=S.useCallback(()=>{a(null),d(!1)},[d]),m=S.useCallback((y,v)=>{const w=y.currentTarget,b={x:y.clientX,y:y.clientY},k=Pxe(b,w.getBoundingClientRect()),C=Oxe(b,k),T=Rxe(v.getBoundingClientRect()),_=jxe([...C,...T]);a(_),d(!0)},[d]);return S.useEffect(()=>()=>h(),[h]),S.useEffect(()=>{if(l&&u){const y=w=>m(w,u),v=w=>m(w,l);return l.addEventListener("pointerleave",y),u.addEventListener("pointerleave",v),()=>{l.removeEventListener("pointerleave",y),u.removeEventListener("pointerleave",v)}}},[l,u,m,h]),S.useEffect(()=>{if(o){const y=v=>{const w=v.target,b={x:v.clientX,y:v.clientY},k=(l==null?void 0:l.contains(w))||(u==null?void 0:u.contains(w)),C=!Dxe(b,o);k?h():C&&(h(),c())};return document.addEventListener("pointermove",y),()=>document.removeEventListener("pointermove",y)}},[l,u,o,c,h]),g.jsx(h8,{...t,ref:s})}),[Axe,_xe]=Dv(Iv,{isInside:!1}),h8=S.forwardRef((t,e)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=t,l=Lv(kd,n),c=jv(n),{onClose:u}=l;return S.useEffect(()=>(document.addEventListener(kE,u),()=>document.removeEventListener(kE,u)),[u]),S.useEffect(()=>{if(l.trigger){const d=h=>{const m=h.target;m!=null&&m.contains(l.trigger)&&u()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,u]),g.jsx(Xd,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:d=>d.preventDefault(),onDismiss:u,children:g.jsxs(Pv,{"data-state":l.stateAttribute,...c,...a,ref:e,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[g.jsx(dN,{children:r}),g.jsx(Axe,{scope:n,isInside:!0,children:g.jsx(bxe,{id:l.contentId,role:"tooltip",children:i||r})})]})})});f8.displayName=kd;var p8="TooltipArrow",Mxe=S.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,i=jv(n);return _xe(p8,n).isInside?null:g.jsx(Ov,{...i,...r,ref:e})});Mxe.displayName=p8;function Pxe(t,e){const n=Math.abs(e.top-t.y),r=Math.abs(e.bottom-t.y),i=Math.abs(e.right-t.x),s=Math.abs(e.left-t.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function Oxe(t,e,n=5){const r=[];switch(e){case"top":r.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":r.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":r.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":r.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return r}function Rxe(t){const{top:e,right:n,bottom:r,left:i}=t;return[{x:i,y:e},{x:n,y:e},{x:n,y:r},{x:i,y:r}]}function Dxe(t,e){const{x:n,y:r}=t;let i=!1;for(let s=0,o=e.length-1;s<e.length;o=s++){const a=e[s].x,l=e[s].y,c=e[o].x,u=e[o].y;l>r!=u>r&&n<(c-a)*(r-l)/(u-l)+a&&(i=!i)}return i}function jxe(t){const e=t.slice();return e.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),Ixe(e)}function Ixe(t){if(t.length<=1)return t.slice();const e=[];for(let r=0;r<t.length;r++){const i=t[r];for(;e.length>=2;){const s=e[e.length-1],o=e[e.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))e.pop();else break}e.push(i)}e.pop();const n=[];for(let r=t.length-1;r>=0;r--){const i=t[r];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),e.length===1&&n.length===1&&e[0].x===n[0].x&&e[0].y===n[0].y?e:e.concat(n)}var Lxe=c8,Fxe=u8,Bxe=d8,m8=f8;const $xe=Lxe,zxe=Fxe,Vxe=Bxe,g8=S.forwardRef(({className:t,sideOffset:e=4,...n},r)=>g.jsx(m8,{ref:r,sideOffset:e,className:ve("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n}));g8.displayName=m8.displayName;function Wxe({date:t}){const e={relativeTime:Npe(new Date(t),{addSuffix:!0}),fullDate:fl(new Date(t),"PPpp")};return g.jsx($xe,{children:g.jsxs(zxe,{children:[g.jsx(Vxe,{className:"text-left text-sm text-mastra-el-4",children:e.relativeTime}),g.jsx(g8,{className:"bg-mastra-bg-1 text-mastra-el-1",children:g.jsx("p",{className:"text-sm",children:e.fullDate})})]})})}const Hxe=qd("flex w-full text-mastra-el-6 rounded-sm border bg-transparent shadow-sm focus-visible:ring-ring transition-colors focus-visible:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50",{variants:{variant:{default:"border-mastra-border-1 border-border-1 placeholder:text-muted-foreground",filled:"bg-inputFill border-border-1 placeholder:text-muted-foreground",unstyled:"border-0 bg-transparent placeholder:text-muted-foreground focus-visible:ring-transparent focus-visible:outline-none"},customSize:{default:"px-[13px] text-[calc(13_/_16_*_1rem)] h-[34px]",sm:"h-[30px] px-[13px] text-xs",lg:"h-10 px-[17px] rounded-md text-[calc(13_/_16_*_1rem)]"}},defaultVariants:{variant:"default",customSize:"default"}}),Mc=S.forwardRef(({className:t,customSize:e,testId:n,variant:r,type:i,...s},o)=>g.jsx("input",{type:i,className:ve(t,Hxe({variant:r,customSize:e,className:t})),"data-testid":n,ref:o,...s}));Mc.displayName="Input";function ej({score:t}){return g.jsx(Ih,{variant:"secondary",children:t.toFixed(2)})}const tj=(t,e)=>{const[n,r]=S.useState([]),[i,s]=S.useState(!0),o=async a=>{s(!0);try{const l=await fetch(`/api/agents/${a??t}/evals/${e}`);if(!l.ok){const u=await l.json();r([]),console.error("Error fetching evals",u),xn.error((u==null?void 0:u.error)||"Error fetching evals");return}const c=await l.json();r(c.evals)}catch(l){r([]),console.error("Error fetching evals",l),xn.error("Error fetching evals")}finally{s(!1)}};return S.useEffect(()=>{o(t)},[t]),{evals:n,isLoading:i,refetchEvals:o}},y8=S.createContext({handleRefresh:()=>{},isLoading:!1}),vy=ve("relative overflow-y-auto overflow-x-hidden invisible hover:visible focus:visible","[&::-webkit-scrollbar]:w-1","[&::-webkit-scrollbar-track]:bg-transparent","[&::-webkit-scrollbar-thumb]:rounded-full","[&::-webkit-scrollbar-thumb]:bg-mastra-border/20","[&>*]:visible"),nj=ve("px-4 py-2 text-sm transition-all border-b-2 border-transparent","data-[state=active]:border-white data-[state=active]:text-white font-medium","data-[state=inactive]:text-mastra-el-4 hover:data-[state=inactive]:text-mastra-el-2","focus-visible:outline-none"),rj=ve("data-[state=inactive]:mt-0 min-h-0 h-full grid grid-rows-[1fr]");function Uxe({agentId:t}){const[e,n]=S.useState("live"),{evals:r,isLoading:i,refetchEvals:s}=tj(t,"live"),{evals:o,isLoading:a,refetchEvals:l}=tj(t,"ci"),c={handleRefresh:u,isLoading:e==="live"?i:a};return g.jsx(y8.Provider,{value:c,children:g.jsxs(CA,{value:e,onValueChange:d=>n(d),className:"grid grid-rows-[auto_1fr] h-full min-h-0 pb-2",children:[g.jsx("div",{className:"bg-mastra-bg-2 border-b border-mastra-border/10",children:g.jsxs(kv,{className:"bg-transparent border-0 h-auto mx-4 pt-5",children:[g.jsx(io,{value:"live",className:nj,children:"Live"}),g.jsx(io,{value:"ci",className:nj,children:"CI"})]})}),g.jsx(so,{value:"live",className:rj,children:g.jsx(ij,{evals:r,isCIMode:!1})}),g.jsx(so,{value:"ci",className:rj,children:g.jsx(ij,{evals:o,isCIMode:!0})})]})});function u(){e==="live"?s():l()}}function ij({evals:t,isCIMode:e=!1}){const{handleRefresh:n,isLoading:r}=S.useContext(y8),[i,s]=S.useState(new Set),[o,a]=S.useState(""),[l,c]=S.useState({field:"metricName",direction:"asc"}),[u,d]=S.useState(!1);return S.useEffect(()=>{if(r){const b=setTimeout(()=>{d(!0)},200);return()=>clearTimeout(b)}else d(!1)},[r]),g.jsxs("div",{className:"min-h-0 grid grid-rows-[auto_1fr]",children:[g.jsxs("div",{className:"flex items-center gap-4 p-4 bg-mastra-bg-2 rounded-lg",children:[g.jsxs("div",{className:"relative flex-1",children:[g.jsx(CC,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-mastra-el-3"}),g.jsx(Mc,{id:"search-input",placeholder:"Search metrics, inputs, or outputs...",value:o,onChange:b=>a(b.target.value),className:"pl-10"})]}),g.jsxs(Ih,{variant:"secondary",className:"text-xs",children:[t.length," Total Evaluations"]}),g.jsx(pt,{variant:"ghost",size:"icon",onClick:n,disabled:u,className:"h-9 w-9",children:u?g.jsx(cd,{className:"h-4 w-4 animate-spin"}):g.jsx(cd,{className:"h-4 w-4"})})]}),g.jsx("div",{className:"overflow-auto",children:g.jsxs(xo,{className:"w-full",children:[g.jsx(vo,{className:"bg-[#171717] sticky top-0 z-10",children:g.jsxs(dn,{className:"border-gray-6 border-b-[0.1px] text-[0.8125rem]",children:[g.jsx(yt,{className:"w-12"}),g.jsx(yt,{className:"min-w-[200px] max-w-[30%] text-mastra-el-3 cursor-pointer",onClick:()=>y("metricName"),children:g.jsxs("div",{className:"flex items-center",children:["Metric ",v("metricName")]})}),g.jsx(yt,{className:"flex-1 text-mastra-el-3"}),g.jsx(yt,{className:"w-48 text-mastra-el-3 cursor-pointer",onClick:()=>y("averageScore"),children:g.jsxs("div",{className:"flex items-center",children:["Average Score ",v("averageScore")]})}),g.jsx(yt,{className:"w-48 text-mastra-el-3",children:"Evaluations"})]})}),g.jsx(wo,{className:"border-b border-gray-6 relative",children:g.jsx(wN,{mode:"wait",presenceAffectsLayout:!1,children:u?Array.from({length:3}).map((b,k)=>g.jsxs(iB,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"border-b-gray-6 border-b-[0.1px] text-[0.8125rem]",children:[g.jsx(at,{className:"w-12",children:g.jsx(qe,{className:"h-8 w-8 rounded-full"})}),g.jsx(at,{className:"min-w-[200px]",children:g.jsx(qe,{className:"h-4 w-3/4"})}),g.jsx(at,{className:"flex-1",children:g.jsx(qe,{className:"h-4 w-full"})}),g.jsx(at,{className:"w-48",children:g.jsx(qe,{className:"h-4 w-20"})}),g.jsx(at,{className:"w-48",children:g.jsx(qe,{className:"h-4 w-16"})})]},k)):w(t).length===0?g.jsx(dn,{children:g.jsx(at,{colSpan:5,className:"h-32 text-center text-mastra-el-3",children:g.jsxs("div",{className:"flex flex-col items-center gap-2",children:[g.jsx(CC,{className:"h-8 w-8"}),g.jsx("p",{children:"No evaluations found"}),o&&g.jsx("p",{className:"text-sm",children:"Try adjusting your search terms"})]})})}):w(t).map(b=>g.jsxs(ne.Fragment,{children:[g.jsxs(dn,{className:"border-b-gray-6 border-b-[0.1px] text-[0.8125rem] cursor-pointer hover:bg-mastra-bg-3",onClick:()=>m(b.metricName),children:[g.jsx(at,{className:"w-12",children:g.jsx("div",{className:"h-8 w-full flex items-center justify-center",children:g.jsx("div",{className:ve("transform transition-transform duration-200",i.has(b.metricName)?"rotate-90":""),children:g.jsx(dh,{className:"h-4 w-4 text-mastra-el-5"})})})}),g.jsx(at,{className:"min-w-[200px] max-w-[30%] font-medium text-mastra-el-5",children:b.metricName}),g.jsx(at,{className:"flex-1 text-mastra-el-5"}),g.jsx(at,{className:"w-48 text-mastra-el-5",children:g.jsx(ej,{score:b.averageScore})}),g.jsx(at,{className:"w-48 text-mastra-el-5",children:g.jsx(Ih,{variant:"secondary",children:b.evals.length})})]}),i.has(b.metricName)&&g.jsx(dn,{children:g.jsx(at,{colSpan:5+(h(b.evals)?1:0)+(e?1:0),className:"p-0",children:g.jsx("div",{className:"bg-mastra-bg-3 rounded-lg m-2",children:g.jsx("div",{className:"w-full",children:g.jsxs(xo,{className:"w-full",children:[g.jsx(vo,{children:g.jsxs(dn,{className:"text-[0.7rem] text-mastra-el-3 hover:bg-transparent",children:[g.jsx(yt,{className:"pl-12 w-[120px]",children:"Timestamp"}),g.jsx(yt,{className:"w-[300px]",children:"Instructions"}),g.jsx(yt,{className:"w-[300px]",children:"Input"}),g.jsx(yt,{className:"w-[300px]",children:"Output"}),g.jsx(yt,{className:"w-[80px]",children:"Score"}),h(b.evals)&&g.jsx(yt,{className:"w-[250px]",children:"Reason"}),e&&g.jsx(yt,{className:"w-[120px]",children:"Test Name"})]})}),g.jsx(wo,{children:b.evals.map((k,C)=>{var T,_;return g.jsxs(dn,{className:"text-[0.8125rem] hover:bg-mastra-bg-2/50",children:[g.jsx(at,{className:"pl-12 text-mastra-el-4 align-top py-4",children:g.jsx(Wxe,{date:k.createdAt})}),g.jsx(at,{className:"text-mastra-el-4 align-top py-4",children:g.jsx("div",{className:ve("max-w-[300px] max-h-[200px]",vy),children:g.jsx(xy,{content:k.instructions,label:"instructions",multiline:!0})})}),g.jsx(at,{className:"text-mastra-el-4 align-top py-4",children:g.jsx("div",{className:ve("max-w-[300px] max-h-[200px]",vy),children:g.jsx(xy,{content:k.input,label:"input",multiline:!0})})}),g.jsx(at,{className:"text-mastra-el-4 align-top py-4",children:g.jsx("div",{className:ve("max-w-[300px] max-h-[200px]",vy),children:g.jsx(xy,{content:k.output,label:"output",multiline:!0})})}),g.jsx(at,{className:"text-mastra-el-4 align-top py-4",children:g.jsx(ej,{score:k.result.score})}),h(b.evals)&&g.jsx(at,{className:"text-mastra-el-4 align-top py-4",children:g.jsx("div",{className:ve("max-w-[300px] max-h-[200px]",vy),children:g.jsx(xy,{content:((T=k.result.info)==null?void 0:T.reason)||"",label:"reason",multiline:!0})})}),e&&g.jsx(at,{className:"text-mastra-el-4 align-top py-4",children:((_=k.testInfo)==null?void 0:_.testName)&&g.jsx(Ih,{variant:"secondary",className:"text-xs",children:k.testInfo.testName})})]},`${b.metricName}-${C}`)})})]})})})})})]},b.metricName))})})]})})]});function h(b){return b.some(k=>{var C;return(C=k.result.info)==null?void 0:C.reason})}function m(b){const k=new Set(i);k.has(b)?k.delete(b):k.add(b),s(k)}function y(b){c(k=>({field:b,direction:k.field===b&&k.direction==="asc"?"desc":"asc"}))}function v(b){return l.field!==b?null:l.direction==="asc"?g.jsx(iX,{className:"h-4 w-4 ml-1"}):g.jsx(nX,{className:"h-4 w-4 ml-1"})}function w(b){let k=b.reduce((C,T)=>{const _=C.find(A=>A.metricName===T.metricName);return _?(_.evals.push(T),_.averageScore=_.evals.reduce((A,M)=>A+M.result.score,0)/_.evals.length):C.push({metricName:T.metricName,averageScore:T.result.score,evals:[T]}),C},[]);return o&&(k=k.filter(C=>C.metricName.toLowerCase().includes(o.toLowerCase())||C.evals.some(T=>{var _,A,M;return((_=T.input)==null?void 0:_.toLowerCase().includes(o.toLowerCase()))||((A=T.output)==null?void 0:A.toLowerCase().includes(o.toLowerCase()))||((M=T.instructions)==null?void 0:M.toLowerCase().includes(o.toLowerCase()))}))),k.sort((C,T)=>{const _=l.direction==="asc"?1:-1;switch(l.field){case"metricName":return _*C.metricName.localeCompare(T.metricName);case"averageScore":return _*(C.averageScore-T.averageScore);default:return 0}}),k}}function qxe(){const{agentId:t}=xa();return g.jsx("main",{className:"min-h-0",children:g.jsx(Uxe,{agentId:t})})}const Ls=S.createContext({});function x8({children:t}){const[e,n]=S.useState(!1),[r,i]=S.useState(null),[s,o]=S.useState([]),[a,l]=S.useState(0),[c,u]=S.useState(null),[d,h]=S.useState(!1),m=()=>{if(a<s.length-1){const w=a+1;l(w);const b=s[w].trace;i(b);const k=b.find(C=>C.parentSpanId===null)||b[0];u(k)}},y=()=>{if(a>0){const w=a-1;l(w);const b=s[w].trace;i(b);const k=b.find(C=>C.parentSpanId===null)||b[0];u(k)}},v=()=>{n(!1),i(null),u(null),h(!1)};return g.jsx(Ls.Provider,{value:{isOpen:e,setIsOpen:n,trace:r,setTrace:i,traces:s,setTraces:o,currentTraceIndex:a,setCurrentTraceIndex:l,nextTrace:m,prevTrace:y,span:c,setSpan:u,openDetail:d,setOpenDetail:h,clearData:v},children:t})}const Fv=({defaultWidth:t,minimumWidth:e,maximumWidth:n})=>{const[r,i]=S.useState(!1),[s,o]=S.useState(t),{isOpen:a}=S.useContext(Ls),l=S.useRef(null),c=S.useRef(0),u=S.useRef(0),d=h=>{h.preventDefault(),i(!0),c.current=h.clientX,u.current=s};return S.useEffect(()=>{a||o(t)},[a]),S.useEffect(()=>{const h=y=>{if(!r||!l.current)return;const v=l.current.offsetWidth,b=(c.current-y.clientX)/v*100,k=Math.min(Math.max(u.current+b,e),n);o(k)},m=()=>{i(!1)};return r&&(window.addEventListener("mousemove",h),window.addEventListener("mouseup",m)),()=>{window.removeEventListener("mousemove",h),window.removeEventListener("mouseup",m)}},[r]),{sidebarWidth:s,isDragging:r,handleMouseDown:d,containerRef:l}};function Yxe({fetchFn:t,interval:e=3e3,enabled:n=!1,onSuccess:r,onError:i,shouldContinue:s=()=>!0}){const[o,a]=S.useState(n),[l,c]=S.useState(null),[u,d]=S.useState(null),[h,m]=S.useState(!1),[y,v]=S.useState(!1),w=S.useRef(null),b=S.useRef(!0),k=S.useCallback(()=>{console.log("cleanup"),w.current&&(clearTimeout(w.current),w.current=null)},[]),C=S.useCallback(()=>{console.log("stopPolling"),a(!1),k()},[k]),T=S.useCallback(()=>{console.log("startPolling"),a(!0),c(null)},[]),_=S.useCallback(async(A=!1)=>{if(b.current){m(!0),v(A);try{const M=await t();d(M),c(null),r==null||r(M),v(!1),s(M)?w.current=setTimeout(_,e):C()}catch(M){if(!b.current)return;c(M),i==null||i(M),C()}finally{b.current&&(v(!1),m(!1))}}},[t,e,r,i,s,C]);return S.useEffect(()=>(b.current=!0,n&&o&&_(!0),()=>{console.log("cleanup poll"),b.current=!1,k()}),[n,o,_,k]),{isPolling:o,isLoading:h,error:l,data:u,startPolling:T,stopPolling:C,firstCallLoading:y}}function QA(t,e=2){return(t/1e3).toFixed(e)}function v8(t){const e=new Date(t/1e3);return new Intl.DateTimeFormat("en-US",{month:"numeric",day:"numeric",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!0}).format(e)}function Gxe(t){const e=new Date(t/1e6);return new Intl.DateTimeFormat("en-US",{month:"numeric",day:"numeric",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!0}).format(e)}function Kxe(t){return t.includes(".argument.")?"Input":t.includes(".result")?"Output":t.split(".").join(" ").split("_")}function sj(t){return t.replace(/\\n/g,"").replace(/\n/g,"").replace(/\s+/g," ").trim()}const Zxe=(t,e=!1)=>{const n=new Set,r=o=>{var a,l,c,u;return o!=null&&o.startsWith("workflow.")&&e?(l=(a=o==null?void 0:o.split("."))==null?void 0:a.slice(2))==null?void 0:l.join("."):o!=null&&o.startsWith("agent.")&&!e?(u=(c=o==null?void 0:o.split("."))==null?void 0:c.slice(1))==null?void 0:u.join("."):o},i=t.reduce((o,a)=>{const l={...a,name:r(a.name),duration:a.endTime-a.startTime};return n.add(a.id),{...o,[a.traceId]:[...o[a.traceId]||[],l]}},{});return Object.entries(i).map(([o,a])=>{var d;const l=a.find(h=>!h.parentSpanId||!n.has(h.parentSpanId)),c=a.map(h=>({...h,parentSpanId:(l==null?void 0:l.id)===h.id?null:h==null?void 0:h.parentSpanId,relativePercentage:l?h.duration/l.duration:0})),u=(d=a.find(h=>h.status.code!==0))==null?void 0:d.status;return{traceId:o,serviceName:(l==null?void 0:l.name)||o,duration:a.reduce((h,m)=>h+m.duration,0),status:u||(l==null?void 0:l.status)||a[0].status,started:a[0].startTime,trace:c}})},Xxe=["operation.name","ai.operationId","ai.model.provider","ai.model.id","ai.prompt.format","ai.prompt.messages","ai.prompt.tools","ai.prompt.toolChoice","ai.settings.toolChoice","ai.schema","ai.settings.output","ai.response.object","ai.response.text","ai.response.timestamp","componentName","ai.usage.promptTokens","ai.usage.completionTokens"],w8=(t,e=!1)=>{const[n,r]=S.useState(null),i=S.useCallback(async()=>{try{const u=await fetch(`/api/telemetry?attribute=componentName:${t}`);if(!u.ok){const m=await u.json();throw new Error((m==null?void 0:m.error)||"Error fetching traces")}const d=await u.json();return Zxe((d==null?void 0:d.traces)||[],e)}catch(u){throw u}},[t]),s=S.useCallback(u=>{u.length>0&&r(()=>u)},[]),o=S.useCallback(u=>{xn.error(u.message)},[]),a=S.useCallback(u=>u.length>0,[]),{firstCallLoading:l,error:c}=Yxe({fetchFn:i,interval:3e3,onSuccess:s,onError:o,shouldContinue:a,enabled:!0});return{traces:n,firstCallLoading:l,error:c}};function b8({traces:t}){const{setTraces:e,trace:n}=S.useContext(Ls),r=(n==null?void 0:n.find(i=>i.parentSpanId===void 0))||(n==null?void 0:n[0]);return S.useEffect(()=>{e(t)},[t]),g.jsx("div",{className:"h-full w-[calc(100%_-_400px)]",children:g.jsx(zn,{className:"rounded-lg h-full",children:g.jsxs(xo,{children:[g.jsx(vo,{className:"bg-[#171717] sticky top-0 z-10",children:g.jsxs(dn,{className:"border-gray-6 border-b-[0.1px] text-[0.8125rem]",children:[g.jsx(yt,{className:"text-mastra-el-3",children:"Trace"}),g.jsxs(yt,{className:"text-mastra-el-3 flex items-center gap-1",children:[g.jsx(Zh,{className:"h-3 w-3"})," Trace Id"]}),g.jsx(yt,{className:"text-mastra-el-3",children:"Started"}),g.jsx(yt,{className:"text-mastra-el-3",children:"Total Duration"})]})}),g.jsx(wo,{className:"border-b border-gray-6",children:t.length?t.map((i,s)=>g.jsxs(dn,{className:ve("border-b-gray-6 border-b-[0.1px] text-[0.8125rem]",{"bg-muted/50":(r==null?void 0:r.traceId)===i.traceId}),children:[g.jsx(at,{children:g.jsx(Qxe,{trace:i.trace,name:i.serviceName,traceIndex:s,status:i.status})}),g.jsx(at,{className:"text-mastra-el-5",children:i.traceId}),g.jsx(at,{className:"text-mastra-el-5 text-sm",children:v8(i.started)}),g.jsx(at,{children:g.jsxs("span",{className:"inline-flex items-center gap-2 text-[#F1CA5E]",children:[g.jsx(lX,{className:"h-3 w-3"}),QA(i.duration,3),"ms"]})})]},i.traceId)):g.jsx(dn,{className:"border-b-gray-6 border-b-[0.1px] text-[0.8125rem]",children:g.jsx(at,{colSpan:4,className:"h-24 text-center",children:"No traces found"})})})]})})})}function Qxe({trace:t,name:e,traceIndex:n,status:r}){const{setTrace:i,isOpen:s,setIsOpen:o,trace:a,setSpan:l,setOpenDetail:c,setCurrentTraceIndex:u}=S.useContext(Ls);return g.jsxs(pt,{variant:"ghost",className:"flex h-0 items-center gap-2 p-0",onClick:()=>{var h;i(t);const d=t.find(m=>m.parentSpanId===null)||t[0];l(d),u(n),!(s&&((h=a==null?void 0:a[0])==null?void 0:h.id)!==t[0].id)&&(o(m=>!m),c(m=>!m))},children:[r.code===0?g.jsx("svg",{className:"h-3 w-3",xmlns:"http://www.w3.org/2000/svg",width:"13",height:"12",viewBox:"0 0 13 12",fill:"none",children:g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.37695 12C9.69067 12 12.377 9.31371 12.377 6C12.377 2.68629 9.69067 0 6.37695 0C3.06325 0 0.376953 2.68629 0.376953 6C0.376953 9.31371 3.06325 12 6.37695 12ZM9.62004 4.65344C9.87907 4.36036 9.8651 3.90005 9.58884 3.6253C9.3125 3.35055 8.87861 3.3654 8.61958 3.65847L5.6477 7.02105L4.08967 5.55197C3.80661 5.28508 3.37319 5.31213 3.12159 5.61237C2.87 5.91262 2.89549 6.37239 3.17854 6.63927L4.90294 8.26517C5.36588 8.70171 6.07235 8.6676 6.49598 8.18829L9.62004 4.65344Z",fill:"#6CD063"})}):g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#FF4500",width:"13",height:"12",children:g.jsx("path",{fillRule:"evenodd",d:"M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25Zm-1.72 6.97a.75.75 0 1 0-1.06 1.06L10.94 12l-1.72 1.72a.75.75 0 1 0 1.06 1.06L12 13.06l1.72 1.72a.75.75 0 1 0 1.06-1.06L13.06 12l1.72-1.72a.75.75 0 1 0-1.06-1.06L12 10.94l-1.72-1.72Z",clipRule:"evenodd"})}),g.jsx("span",{className:"truncate max-w-[150px]",children:e})]})}function k8({node:t,depth:e=0}){var d,h,m,y,v;const[n,r]=S.useState(!0),i=t.children&&t.children.length>0,{setOpenDetail:s,setSpan:o,openDetail:a,span:l}=S.useContext(Ls),c=S.useRef(null),u=Math.min(t.relativePercentage?(t==null?void 0:t.relativePercentage)*100:0,100);return g.jsxs("div",{ref:c,children:[g.jsxs(pt,{variant:"ghost",className:ve("relative flex w-full items-center justify-start gap-2 py-3 pr-1 text-sm",{"text-accent-foreground bg-accent":(l==null?void 0:l.id)===t.id}),onClick:w=>{w.preventDefault(),w.stopPropagation(),o(t),!(a&&t.id!==(l==null?void 0:l.id))&&s(!0)},style:{paddingLeft:`${e>0?e*35+28-e*3:24}px`},children:[i?g.jsx("div",{onClick:()=>r(!n),className:"relative grid h-auto flex-shrink-0 place-items-center rounded-sm bg-[#1a1a1a] p-2",children:g.jsx("svg",{className:ve("!h-2 !w-2 transition-transform",n?"":"-rotate-90"),xmlns:"http://www.w3.org/2000/svg",width:"7",height:"6",viewBox:"0 0 7 6",fill:"none",children:g.jsx("path",{d:"M3.9338 5.5C3.74135 5.83333 3.26022 5.83333 3.06777 5.5L0.469694 0.999999C0.277244 0.666666 0.517814 0.25 0.902714 0.25L6.09886 0.25C6.48376 0.25 6.72433 0.666666 6.53188 1L3.9338 5.5Z",fill:"#939393"})})}):null,g.jsxs("div",{className:"flex w-full gap-4 pr-4",children:[g.jsx("p",{className:ve("max-w-[250px] text-sm",{"text-white":((d=t==null?void 0:t.status)==null?void 0:d.code)===0,"text-[#FF4500]":((h=t==null?void 0:t.status)==null?void 0:h.code)!==0,"px-1":e===0,truncate:((m=c.current)==null?void 0:m.offsetWidth)&&((y=c.current)==null?void 0:y.offsetWidth)<450&&e>1&&((v=t.name)==null?void 0:v.length)>16}),children:t.name}),t.duration>0&&g.jsxs("div",{className:"relative w-full",children:[g.jsx("div",{className:"absolute top-[11px] h-px w-full bg-[hsl(220,14%,19%)]"}),g.jsx("div",{style:{width:`${u}%`,left:0},className:ve("absolute top-[9px] z-0 h-[5px] rounded-[5px] bg-white transition-all",t.name.includes("agent")&&"left-1/2 bg-green-500",t.name.includes("llm")&&"bg-[#5699A8]",t.name.includes("ai")&&"left-2/4 w-5 bg-[#F09A56]")}),g.jsxs("span",{className:"absolute left-0 top-3 text-[0.63rem] text-mastra-el-3",children:[QA(t.duration),"ms"]})]})]})]}),i&&n&&g.jsx(g.Fragment,{children:t.children.map(w=>g.jsx(k8,{node:w,depth:e+1},w.id))})]})}function Jxe({tree:t}){return g.jsx("ul",{children:t.map(e=>g.jsx(k8,{node:e},e.id))})}function S8(t,e=null){return t.filter(n=>n.parentSpanId===e).map(n=>({...n,children:S8(t,n.id)}))}function eve({trace:t}){const e=S8(t.concat([]).reverse());return g.jsx("div",{children:g.jsx(Jxe,{tree:e})})}function C8(){const{trace:t,currentTraceIndex:e,prevTrace:n,nextTrace:r,traces:i,clearData:s}=S.useContext(Ls);return g.jsxs("div",{children:[g.jsxs("div",{className:"flex items-center justify-between px-6 pt-[1.56rem]",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsxs("h3",{className:"text-[1.125rem]",children:["Trace Span",t!=null&&t.length&&t.length>1?"s":""]}),g.jsxs("span",{className:"text-xs text-mastra-el-3",children:[t!=null&&t.length?t.length:0," span",t!=null&&t.length&&t.length>1?"s":""]})]}),g.jsxs("div",{className:"flex items-center gap-4",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(pt,{onClick:()=>{n()},disabled:e===0,variant:"secondary",size:"icon",className:"!h-3 !w-3 rotate-180 !px-3 py-3 text-mastra-el-3 transition-colors hover:text-white",children:g.jsx(Xh,{})})," ",g.jsx(pt,{onClick:()=>{r()},disabled:e===i.length-1,variant:"secondary",size:"icon",className:"!h-3 !w-3 !px-3 py-3 text-mastra-el-3 transition-colors hover:text-white",children:g.jsx(Xh,{})})]}),g.jsx("span",{className:"bg-secondary inline-block h-5 w-px"}),g.jsx(pt,{onClick:()=>{s()},variant:"secondary",size:"icon",className:"!h-3 !w-3 !px-3 py-3 text-mastra-el-3 transition-colors hover:text-white",children:g.jsx(Pl,{})})]})]}),g.jsxs("div",{className:"p-6 px-1",children:[" ",t&&g.jsx(eve,{trace:t})]})]})}const E8=1024;let tve=0,Sk=class{constructor(e,n){this.from=e,this.to=n}};class Tt{constructor(e={}){this.id=tve++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=fi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}Tt.closedBy=new Tt({deserialize:t=>t.split(" ")});Tt.openedBy=new Tt({deserialize:t=>t.split(" ")});Tt.group=new Tt({deserialize:t=>t.split(" ")});Tt.isolate=new Tt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});Tt.contextHash=new Tt({perNode:!0});Tt.lookAhead=new Tt({perNode:!0});Tt.mounted=new Tt({perNode:!0});class ox{constructor(e,n,r){this.tree=e,this.overlay=n,this.parser=r}static get(e){return e&&e.props&&e.props[Tt.mounted.id]}}const nve=Object.create(null);class fi{constructor(e,n,r,i=0){this.name=e,this.props=n,this.id=r,this.flags=i}static define(e){let n=e.props&&e.props.length?Object.create(null):nve,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new fi(e.name||"",n,e.id,r);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(i)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[s[0].id]=s[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(Tt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let i of r.split(" "))n[i]=e[r];return r=>{for(let i=r.prop(Tt.group),s=-1;s<(i?i.length:0);s++){let o=n[s<0?r.name:i[s]];if(o)return o}}}}fi.none=new fi("",Object.create(null),0,8);class JA{constructor(e){this.types=e;for(let n=0;n<e.length;n++)if(e[n].id!=n)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let n=[];for(let r of this.types){let i=null;for(let s of e){let o=s(r);o&&(i||(i=Object.assign({},r.props)),i[o[0].id]=o[1])}n.push(i?new fi(r.name,i,r.id,r.flags):r)}return new JA(n)}}const wy=new WeakMap,oj=new WeakMap;var ar;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"})(ar||(ar={}));class Bn{constructor(e,n,r,i,s){if(this.type=e,this.children=n,this.positions=r,this.length=i,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,a]of s)this.props[typeof o=="number"?o:o.id]=a}}toString(){let e=ox.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let i=r.toString();i&&(n&&(n+=","),n+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new EE(this.topNode,e)}cursorAt(e,n=0,r=0){let i=wy.get(this)||this.topNode,s=new EE(i);return s.moveTo(e,n),wy.set(this,s._tree),s}get topNode(){return new ts(this,0,0,null)}resolve(e,n=0){let r=Sp(wy.get(this)||this.topNode,e,n,!1);return wy.set(this,r),r}resolveInner(e,n=0){let r=Sp(oj.get(this)||this.topNode,e,n,!0);return oj.set(this,r),r}resolveStack(e,n=0){return sve(this,e,n)}iterate(e){let{enter:n,leave:r,from:i=0,to:s=this.length}=e,o=e.mode||0,a=(o&ar.IncludeAnonymous)>0;for(let l=this.cursor(o|ar.IncludeAnonymous);;){let c=!1;if(l.from<=s&&l.to>=i&&(!a&&l.type.isAnonymous||n(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&r&&(a||!l.type.isAnonymous)&&r(l),!l.nextSibling();){if(!l.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:n2(fi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new Bn(this.type,n,r,i,this.propValues),e.makeTree||((n,r,i)=>new Bn(fi.none,n,r,i)))}static build(e){return ove(e)}}Bn.empty=new Bn(fi.none,[],[],0);class e2{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new e2(this.buffer,this.index)}}class Cl{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return fi.none}toString(){let e=[];for(let n=0;n<this.buffer.length;)e.push(this.childString(n)),n=this.buffer[n+3];return e.join(",")}childString(e){let n=this.buffer[e],r=this.buffer[e+3],i=this.set.types[n],s=i.name;if(/\W/.test(s)&&!i.isError&&(s=JSON.stringify(s)),e+=4,r==e)return s;let o=[];for(;e<r;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,n,r,i,s){let{buffer:o}=this,a=-1;for(let l=e;l!=n&&!(T8(s,i,o[l+1],o[l+2])&&(a=l,r>0));l=o[l+3]);return a}slice(e,n,r){let i=this.buffer,s=new Uint16Array(n-e),o=0;for(let a=e,l=0;a<n;){s[l++]=i[a++],s[l++]=i[a++]-r;let c=s[l++]=i[a++]-r;s[l++]=i[a++]-e,o=Math.max(o,c)}return new Cl(s,o,this.set)}}function T8(t,e,n,r){switch(t){case-2:return n<e;case-1:return r>=e&&n<e;case 0:return n<e&&r>e;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function Sp(t,e,n,r){for(var i;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to<e);){let o=!r&&t instanceof ts&&t.index<0?null:t.parent;if(!o)return t;t=o}let s=r?0:ar.IgnoreOverlays;if(r)for(let o=t,a=o.parent;a;o=a,a=o.parent)o instanceof ts&&o.index<0&&((i=a.enter(e,n,s))===null||i===void 0?void 0:i.from)!=o.from&&(t=a);for(;;){let o=t.enter(e,n,s);if(!o)return t;t=o}}class N8{cursor(e=0){return new EE(this,e)}getChild(e,n=null,r=null){let i=aj(this,e,n,r);return i.length?i[0]:null}getChildren(e,n=null,r=null){return aj(this,e,n,r)}resolve(e,n=0){return Sp(this,e,n,!1)}resolveInner(e,n=0){return Sp(this,e,n,!0)}matchContext(e){return CE(this.parent,e)}enterUnfinishedNodesBefore(e){let n=this.childBefore(e),r=this;for(;n;){let i=n.lastChild;if(!i||i.to!=n.to)break;i.type.isError&&i.from==i.to?(r=n,n=i.prevSibling):n=i}return r}get node(){return this}get next(){return this.parent}}class ts extends N8{constructor(e,n,r,i){super(),this._tree=e,this.from=n,this.index=r,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,n,r,i,s=0){for(let o=this;;){for(let{children:a,positions:l}=o._tree,c=n>0?a.length:-1;e!=c;e+=n){let u=a[e],d=l[e]+o.from;if(T8(i,r,d,d+u.length)){if(u instanceof Cl){if(s&ar.ExcludeBuffers)continue;let h=u.findChild(0,u.buffer.length,n,r-d,i);if(h>-1)return new ll(new rve(o,u,e,d),null,h)}else if(s&ar.IncludeAnonymous||!u.type.isAnonymous||t2(u)){let h;if(!(s&ar.IgnoreMounts)&&(h=ox.get(u))&&!h.overlay)return new ts(h.tree,d,e,o);let m=new ts(u,d,e,o);return s&ar.IncludeAnonymous||!m.type.isAnonymous?m:m.nextChild(n<0?u.children.length-1:0,n,r,i)}}}if(s&ar.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+n:e=n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,n,r=0){let i;if(!(r&ar.IgnoreOverlays)&&(i=ox.get(this._tree))&&i.overlay){let s=e-this.from;for(let{from:o,to:a}of i.overlay)if((n>0?o<=s:o<s)&&(n<0?a>=s:a>s))return new ts(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function aj(t,e,n,r){let i=t.cursor(),s=[];if(!i.firstChild())return s;if(n!=null){for(let o=!1;!o;)if(o=i.type.is(n),!i.nextSibling())return s}for(;;){if(r!=null&&i.type.is(r))return s;if(i.type.is(e)&&s.push(i.node),!i.nextSibling())return r==null?s:[]}}function CE(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class rve{constructor(e,n,r,i){this.parent=e,this.buffer=n,this.index=r,this.start=i}}class ll extends N8{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-this.context.start,r);return s<0?null:new ll(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,n,r=0){if(r&ar.ExcludeBuffers)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return s<0?null:new ll(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new ll(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new ll(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,i=this.index+4,s=r.buffer[this.index+3];if(s>i){let o=r.buffer[this.index+1];e.push(r.slice(i,s,o)),n.push(0)}return new Bn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function A8(t){if(!t.length)return null;let e=0,n=t[0];for(let s=1;s<t.length;s++){let o=t[s];(o.from>n.from||o.to<n.to)&&(n=o,e=s)}let r=n instanceof ts&&n.index<0?null:n.parent,i=t.slice();return r?i[e]=r:i.splice(e,1),new ive(i,n)}class ive{constructor(e,n){this.heads=e,this.node=n}get next(){return A8(this.heads)}}function sve(t,e,n){let r=t.resolveInner(e,n),i=null;for(let s=r instanceof ts?r:r.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(i||(i=[r])).push(o.resolve(e,n)),s=o}else{let o=ox.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let a=new ts(o.tree,o.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(Sp(a,e,n,!1))}}return i?A8(i):r}class EE{get name(){return this.type.name}constructor(e,n=0){if(this.mode=n,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof ts)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:i}=this.buffer;return this.type=n||i.set.types[i.buffer[e]],this.from=r+i.buffer[e+1],this.to=r+i.buffer[e+2],!0}yield(e){return e?e instanceof ts?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:i}=this.buffer,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-this.buffer.start,r);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,r=this.mode){return this.buffer?r&ar.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ar.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&ar.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let i=r<0?0:this.stack[r]+4;if(this.index!=i)return this.yieldBuf(n.findChild(i,this.index,-1,0,4))}else{let i=n.buffer[this.index+3];if(i<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(i)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:i}=this;if(i){if(e>0){if(this.index<i.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(i.buffer.buffer[s+3]<this.index)return!1;({index:n,parent:r}=i)}else({index:n,_parent:r}=this._tree);for(;r;{index:n,_parent:r}=r)if(n>-1)for(let s=n+e,o=e<0?-1:r._tree.children.length;s!=o;s+=e){let a=r._tree.children[s];if(this.mode&ar.IncludeAnonymous||a instanceof Cl||!a.type.isAnonymous||t2(a))return!1}return!0}move(e,n){if(n&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,n););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,n=null,r=0;if(e&&e.context==this.buffer)e:for(let i=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==i){if(i==this.index)return o;n=o,r=s+1;break e}i=this.stack[--s]}for(let i=r;i<this.stack.length;i++)n=new ll(this.buffer,n,this.stack[i]);return this.bufferNode=new ll(this.buffer,n,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,n){for(let r=0;;){let i=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){r++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&n&&n(this),i=this.type.isAnonymous,!r)return;if(this.nextSibling())break;this.parent(),r--,i=!0}}}matchContext(e){if(!this.buffer)return CE(this.node.parent,e);let{buffer:n}=this.buffer,{types:r}=n.set;for(let i=e.length-1,s=this.stack.length-1;i>=0;s--){if(s<0)return CE(this._tree,e,i);let o=r[n.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[i]&&e[i]!=o.name)return!1;i--}}return!0}}function t2(t){return t.children.some(e=>e instanceof Cl||!e.type.isAnonymous||t2(e))}function ove(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:i=E8,reused:s=[],minRepeatType:o=r.types.length}=t,a=Array.isArray(n)?new e2(n,n.length):n,l=r.types,c=0,u=0;function d(_,A,M,O,D,R){let{id:B,start:F,end:W,size:I}=a,Y=u,V=c;for(;I<0;)if(a.next(),I==-1){let q=s[B];M.push(q),O.push(F-_);return}else if(I==-3){c=B;return}else if(I==-4){u=B;return}else throw new RangeError(`Unrecognized record size: ${I}`);let G=l[B],H,z,L=F-_;if(W-F<=i&&(z=w(a.pos-A,D))){let q=new Uint16Array(z.size-z.skip),U=a.pos-z.size,j=q.length;for(;a.pos>U;)j=b(z.start,q,j);H=new Cl(q,W-z.start,r),L=z.start-_}else{let q=a.pos-I;a.next();let U=[],j=[],K=B>=o?B:-1,Z=0,J=W;for(;a.pos>q;)K>=0&&a.id==K&&a.size>=0?(a.end<=J-i&&(y(U,j,F,Z,a.end,J,K,Y,V),Z=U.length,J=a.end),a.next()):R>2500?h(F,q,U,j):d(F,q,U,j,K,R+1);if(K>=0&&Z>0&&Z<U.length&&y(U,j,F,Z,F,J,K,Y,V),U.reverse(),j.reverse(),K>-1&&Z>0){let X=m(G,V);H=n2(G,U,j,0,U.length,0,W-F,X,X)}else H=v(G,U,j,W-F,Y-W,V)}M.push(H),O.push(L)}function h(_,A,M,O){let D=[],R=0,B=-1;for(;a.pos>A;){let{id:F,start:W,end:I,size:Y}=a;if(Y>4)a.next();else{if(B>-1&&W<B)break;B<0&&(B=I-i),D.push(F,W,I),R++,a.next()}}if(R){let F=new Uint16Array(R*4),W=D[D.length-2];for(let I=D.length-3,Y=0;I>=0;I-=3)F[Y++]=D[I],F[Y++]=D[I+1]-W,F[Y++]=D[I+2]-W,F[Y++]=Y;M.push(new Cl(F,D[2]-W,r)),O.push(W-_)}}function m(_,A){return(M,O,D)=>{let R=0,B=M.length-1,F,W;if(B>=0&&(F=M[B])instanceof Bn){if(!B&&F.type==_&&F.length==D)return F;(W=F.prop(Tt.lookAhead))&&(R=O[B]+F.length+W)}return v(_,M,O,D,R,A)}}function y(_,A,M,O,D,R,B,F,W){let I=[],Y=[];for(;_.length>O;)I.push(_.pop()),Y.push(A.pop()+M-D);_.push(v(r.types[B],I,Y,R-D,F-R,W)),A.push(D-M)}function v(_,A,M,O,D,R,B){if(R){let F=[Tt.contextHash,R];B=B?[F].concat(B):[F]}if(D>25){let F=[Tt.lookAhead,D];B=B?[F].concat(B):[F]}return new Bn(_,A,M,O,B)}function w(_,A){let M=a.fork(),O=0,D=0,R=0,B=M.end-i,F={size:0,start:0,skip:0};e:for(let W=M.pos-_;M.pos>W;){let I=M.size;if(M.id==A&&I>=0){F.size=O,F.start=D,F.skip=R,R+=4,O+=4,M.next();continue}let Y=M.pos-I;if(I<0||Y<W||M.start<B)break;let V=M.id>=o?4:0,G=M.start;for(M.next();M.pos>Y;){if(M.size<0)if(M.size==-3)V+=4;else break e;else M.id>=o&&(V+=4);M.next()}D=G,O+=I,R+=V}return(A<0||O==_)&&(F.size=O,F.start=D,F.skip=R),F.size>4?F:void 0}function b(_,A,M){let{id:O,start:D,end:R,size:B}=a;if(a.next(),B>=0&&O<o){let F=M;if(B>4){let W=a.pos-(B-4);for(;a.pos>W;)M=b(_,A,M)}A[--M]=F,A[--M]=R-_,A[--M]=D-_,A[--M]=O}else B==-3?c=O:B==-4&&(u=O);return M}let k=[],C=[];for(;a.pos>0;)d(t.start||0,t.bufferStart||0,k,C,-1,0);let T=(e=t.length)!==null&&e!==void 0?e:k.length?C[0]+k[0].length:0;return new Bn(l[t.topID],k.reverse(),C.reverse(),T)}const lj=new WeakMap;function d0(t,e){if(!t.isAnonymous||e instanceof Cl||e.type!=t)return 1;let n=lj.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof Bn)){n=1;break}n+=d0(t,r)}lj.set(e,n)}return n}function n2(t,e,n,r,i,s,o,a,l){let c=0;for(let y=r;y<i;y++)c+=d0(t,e[y]);let u=Math.ceil(c*1.5/8),d=[],h=[];function m(y,v,w,b,k){for(let C=w;C<b;){let T=C,_=v[C],A=d0(t,y[C]);for(C++;C<b;C++){let M=d0(t,y[C]);if(A+M>=u)break;A+=M}if(C==T+1){if(A>u){let M=y[T];m(M.children,M.positions,0,M.children.length,v[T]+k);continue}d.push(y[T])}else{let M=v[C-1]+y[C-1].length-_;d.push(n2(t,y,v,T,C,_,M,null,l))}h.push(_+k-s)}}return m(e,n,r,i,0),(a||l)(d,h,o)}class wc{constructor(e,n,r,i,s=!1,o=!1){this.from=e,this.to=n,this.tree=r,this.offset=i,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let i=[new wc(0,e.length,e,0,!1,r)];for(let s of n)s.to>e.length&&i.push(s);return i}static applyChanges(e,n,r=128){if(!n.length)return e;let i=[],s=1,o=e.length?e[0]:null;for(let a=0,l=0,c=0;;a++){let u=a<n.length?n[a]:null,d=u?u.fromA:1e9;if(d-l>=r)for(;o&&o.from<d;){let h=o;if(l>=h.from||d<=h.to||c){let m=Math.max(h.from,l)-c,y=Math.min(h.to,d)-c;h=m>=y?null:new wc(m,y,h.tree,h.offset+c,a>0,!!u)}if(h&&i.push(h),o.to>d)break;o=s<e.length?e[s++]:null}if(!u)break;l=u.toA,c=u.toA-u.toB}return i}}class _8{startParse(e,n,r){return typeof e=="string"&&(e=new ave(e)),r=r?r.length?r.map(i=>new Sk(i.from,i.to)):[new Sk(0,0)]:[new Sk(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let i=this.startParse(e,n,r);for(;;){let s=i.advance();if(s)return s}}}class ave{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new Tt({perNode:!0});var cj={};class ax{constructor(e,n,r,i,s,o,a,l,c,u=0,d){this.p=e,this.stack=n,this.state=r,this.reducePos=i,this.pos=s,this.score=o,this.buffer=a,this.bufferBase=l,this.curContext=c,this.lookAhead=u,this.parent=d}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,r=0){let i=e.parser.context;return new ax(e,[],n,r,r,0,[],0,i?new uj(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let r=e>>19,i=e&65535,{parser:s}=this.p,o=this.reducePos<this.pos-25;o&&this.setLookAhead(this.pos);let a=s.dynamicPrecedence(i);if(a&&(this.score+=a),r==0){this.pushState(s.getGoto(this.state,i,!0),this.reducePos),i<s.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(i,this.reducePos);return}let l=this.stack.length-(r-1)*3-(e&262144?6:0),c=l?this.stack[l-2]:this.p.ranges[0].from,u=this.reducePos-c;u>=2e3&&!(!((n=this.p.parser.nodeSet.types[i])===null||n===void 0)&&n.isAnonymous)&&(c==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=u):this.p.lastBigReductionSize<u&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=c,this.p.lastBigReductionSize=u));let d=l?this.stack[l-1]:0,h=this.bufferBase+this.buffer.length-d;if(i<s.minRepeatTerm||e&131072){let m=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,c,m,h+4,!0)}if(e&262144)this.state=this.stack[l];else{let m=this.stack[l-3];this.state=s.getGoto(m,i,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(i,c)}storeNode(e,n,r,i=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,a=this.buffer.length;if(a==0&&o.parent&&(a=o.bufferBase-o.parent.bufferBase,o=o.parent),a>0&&o.buffer[a-4]==0&&o.buffer[a-1]>-1){if(n==r)return;if(o.buffer[a-2]>=n){o.buffer[a-2]=r;return}}}if(!s||this.pos==r)this.buffer.push(e,n,r,i);else{let o=this.buffer.length;if(o>0&&this.buffer[o-4]!=0){let a=!1;for(let l=o;l>0&&this.buffer[l-2]>r;l-=4)if(this.buffer[l-1]>=0){a=!0;break}if(a)for(;o>0&&this.buffer[o-2]>r;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,i>4&&(i-=4)}this.buffer[o]=e,this.buffer[o+1]=n,this.buffer[o+2]=r,this.buffer[o+3]=i}}shift(e,n,r,i){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=i,this.shiftContext(n,r),n<=this.p.parser.maxNode&&this.buffer.push(n,r,i,4);else{let s=e,{parser:o}=this.p;(i>this.pos||n<=o.maxNode)&&(this.pos=i,o.stateFlag(s,1)||(this.reducePos=i)),this.pushState(s,r),this.shiftContext(n,r),n<=o.maxNode&&this.buffer.push(n,r,i,4)}}apply(e,n,r,i){e&65536?this.reduce(e):this.shift(e,n,r,i)}useNode(e,n){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=e)&&(this.p.reused.push(e),r++);let i=this.pos;this.reducePos=this.pos=i+e.length,this.pushState(n,i),this.buffer.push(r,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,n=e.buffer.length;for(;n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let r=e.buffer.slice(n),i=e.bufferBase+n;for(;e&&i==e.bufferBase;)e=e.parent;return new ax(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let r=e<=this.p.parser.maxNode;r&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,r?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new lve(this);;){let r=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(r==0)return!1;if(!(r&65536))return!0;n.reduce(r)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let i=[];for(let s=0,o;s<n.length;s+=2)(o=n[s+1])!=this.state&&this.p.parser.hasAction(o,e)&&i.push(n[s],o);if(this.stack.length<120)for(let s=0;i.length<8&&s<n.length;s+=2){let o=n[s+1];i.some((a,l)=>l&1&&a==o)||i.push(n[s],o)}n=i}let r=[];for(let i=0;i<n.length&&r.length<4;i+=2){let s=n[i+1];if(s==this.state)continue;let o=this.split();o.pushState(s,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(n[i],this.pos),o.reducePos=this.pos,o.score-=200,r.push(o)}return r}forceReduce(){let{parser:e}=this.p,n=e.stateSlot(this.state,5);if(!(n&65536))return!1;if(!e.validAction(this.state,n)){let r=n>>19,i=n&65535,s=this.stack.length-r*3;if(s<0||e.getGoto(this.stack[s],i,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;n=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],r=(i,s)=>{if(!n.includes(i))return n.push(i),e.allActions(i,o=>{if(!(o&393216))if(o&65536){let a=(o>>19)-s;if(a>1){let l=o&65535,c=this.stack.length-a*3;if(c>=0&&e.getGoto(this.stack[c],l,!1)>=0)return a<<19|65536|l}}else{let a=r(o,s+1);if(a!=null)return a}})};return r(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let n=0;n<this.stack.length;n+=3)if(this.stack[n]!=e.stack[n])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(n)))}reduceContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(n)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let n=new uj(this.curContext.tracker,e);n.hash!=this.curContext.hash&&this.emitContext(),this.curContext=n}}setLookAhead(e){e>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class uj{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class lve{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,r=e>>19;r==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(r-1)*3;let i=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=i}}class lx{constructor(e,n,r){this.stack=e,this.pos=n,this.index=r,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new lx(e,n,n-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new lx(this.stack,this.pos,this.index)}}function by(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let r=0,i=0;r<t.length;){let s=0;for(;;){let o=t.charCodeAt(r++),a=!1;if(o==126){s=65535;break}o>=92&&o--,o>=34&&o--;let l=o-32;if(l>=46&&(l-=46,a=!0),s+=l,a)break;s*=46}n?n[i++]=s:n=new e(s)}return n}class f0{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const dj=new f0;class cve{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=dj,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let r=this.range,i=this.rangeIndex,s=this.pos+e;for(;s<r.from;){if(!i)return null;let o=this.ranges[--i];s-=r.from-o.to,r=o}for(;n<0?s>r.to:s>=r.to;){if(i==this.ranges.length-1)return null;let o=this.ranges[++i];s+=o.from-r.to,r=o}return s}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let n of this.ranges)if(n.to>e)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,r,i;if(n>=0&&n<this.chunk.length)r=this.pos+e,i=this.chunk.charCodeAt(n);else{let s=this.resolveOffset(e,1);if(s==null)return-1;if(r=s,r>=this.chunk2Pos&&r<this.chunk2Pos+this.chunk2.length)i=this.chunk2.charCodeAt(r-this.chunk2Pos);else{let o=this.rangeIndex,a=this.range;for(;a.to<=r;)a=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=r),r+this.chunk2.length>a.to&&(this.chunk2=this.chunk2.slice(0,a.to-r)),i=this.chunk2.charCodeAt(0)}}return r>=this.token.lookAhead&&(this.token.lookAhead=r+1),i}acceptToken(e,n=0){let r=n?this.resolveOffset(n,-1):this.pos;if(r==null||r<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=r}acceptTokenTo(e,n){this.token.value=e,this.token.end=n}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:n}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=n,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),n=this.pos+e.length;this.chunk=n>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=dj,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,n){if(e>=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let r="";for(let i of this.ranges){if(i.from>=n)break;i.to>e&&(r+=this.input.read(Math.max(i.from,e),Math.min(i.to,n)))}return r}}class ed{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:r}=n.p;uve(this.data,e,n,this.id,r.data,r.tokenPrecTable)}}ed.prototype.contextual=ed.prototype.fallback=ed.prototype.extend=!1;ed.prototype.fallback=ed.prototype.extend=!1;function uve(t,e,n,r,i,s){let o=0,a=1<<r,{dialect:l}=n.p.parser;e:for(;a&t[o];){let c=t[o+1];for(let m=o+3;m<c;m+=2)if((t[m+1]&a)>0){let y=t[m];if(l.allows(y)&&(e.token.value==-1||e.token.value==y||dve(y,e.token.value,i,s))){e.acceptToken(y);break}}let u=e.next,d=0,h=t[o+2];if(e.next<0&&h>d&&t[c+h*3-3]==65535){o=t[c+h*3-1];continue e}for(;d<h;){let m=d+h>>1,y=c+m+(m<<1),v=t[y],w=t[y+1]||65536;if(u<v)h=m;else if(u>=w)d=m+1;else{o=t[y+2],e.advance();continue e}}break}}function fj(t,e,n){for(let r=e,i;(i=t[r])!=65535;r++)if(i==n)return r-e;return-1}function dve(t,e,n,r){let i=fj(n,r,e);return i<0||fj(n,r,t)<i}const wi=typeof process<"u"&&cj&&/\bparse\b/.test(cj.LOG);let Ck=null;function hj(t,e,n){let r=t.cursor(ar.IncludeAnonymous);for(r.moveTo(e);;)if(!(n<0?r.childBefore(e):r.childAfter(e)))for(;;){if((n<0?r.to<e:r.from>e)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,e-25)):Math.min(t.length,Math.max(r.from+1,e+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:t.length}}class fve{constructor(e,n){this.fragments=e,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?hj(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?hj(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let n=this.trees.length-1;if(n<0)return this.nextFragment(),null;let r=this.trees[n],i=this.index[n];if(i==r.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=r.children[i],o=this.start[n]+r.positions[i];if(o>e)return this.nextStart=o,null;if(s instanceof Bn){if(o==e){if(o<this.safeFrom)return null;let a=o+s.length;if(a<=this.safeTo){let l=s.prop(Tt.lookAhead);if(!l||a+l<this.fragment.to)return s}}this.index[n]++,o+s.length>=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[n]++,this.nextStart=o+s.length}}}class hve{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new f0)}getActions(e){let n=0,r=null,{parser:i}=e.p,{tokenizers:s}=i,o=i.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,l=0;for(let c=0;c<s.length;c++){if(!(1<<c&o))continue;let u=s[c],d=this.tokens[c];if(!(r&&!u.fallback)&&((u.contextual||d.start!=e.pos||d.mask!=o||d.context!=a)&&(this.updateCachedToken(d,u,e),d.mask=o,d.context=a),d.lookAhead>d.end+25&&(l=Math.max(d.lookAhead,l)),d.value!=0)){let h=n;if(d.extended>-1&&(n=this.addActions(e,d.extended,d.end,n)),n=this.addActions(e,d.value,d.end,n),!u.extend&&(r=d,n>h))break}}for(;this.actions.length>n;)this.actions.pop();return l&&e.setLookAhead(l),!r&&e.pos==this.stream.end&&(r=new f0,r.value=e.p.parser.eofTerm,r.start=r.end=e.pos,n=this.addActions(e,r.value,r.end,n)),this.mainToken=r,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new f0,{pos:r,p:i}=e;return n.start=r,n.end=Math.min(r+1,i.stream.end),n.value=r==i.stream.end?i.parser.eofTerm:0,n}updateCachedToken(e,n,r){let i=this.stream.clipPos(r.pos);if(n.token(this.stream.reset(i,e),r),e.value>-1){let{parser:s}=r.p;for(let o=0;o<s.specialized.length;o++)if(s.specialized[o]==e.value){let a=s.specializers[o](this.stream.read(e.start,e.end),r);if(a>=0&&r.p.parser.dialect.allows(a>>1)){a&1?e.extended=a>>1:e.value=a>>1;break}}}else e.value=0,e.end=this.stream.clipPos(i+1)}putAction(e,n,r,i){for(let s=0;s<i;s+=3)if(this.actions[s]==e)return i;return this.actions[i++]=e,this.actions[i++]=n,this.actions[i++]=r,i}addActions(e,n,r,i){let{state:s}=e,{parser:o}=e.p,{data:a}=o;for(let l=0;l<2;l++)for(let c=o.stateSlot(s,l?2:1);;c+=3){if(a[c]==65535)if(a[c+1]==1)c=Zo(a,c+2);else{i==0&&a[c+1]==2&&(i=this.putAction(Zo(a,c+2),n,r,i));break}a[c]==n&&(i=this.putAction(Zo(a,c+1),n,r,i))}return i}}class pve{constructor(e,n,r,i){this.parser=e,this.input=n,this.ranges=i,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new cve(n,i),this.tokens=new hve(e,this.stream),this.topTerm=e.top[1];let{from:s}=i[0];this.stacks=[ax.start(this,e.top[0],s)],this.fragments=r.length&&this.stream.end-s>e.bufferLength*4?new fve(r,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,r=this.stacks=[],i,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let a=e[o];for(;;){if(this.tokens.mainToken=null,a.pos>n)r.push(a);else{if(this.advanceStack(a,r,e))continue;{i||(i=[],s=[]),i.push(a);let l=this.tokens.getMainToken(a);s.push(l.value,l.end)}}break}}if(!r.length){let o=i&&gve(i);if(o)return wi&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw wi&&i&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&i){let o=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,s,r);if(o)return wi&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(r.length>o)for(r.sort((a,l)=>l.score-a.score);r.length>o;)r.pop();r.some(a=>a.reducePos>n)&&this.recovering--}else if(r.length>1){e:for(let o=0;o<r.length-1;o++){let a=r[o];for(let l=o+1;l<r.length;l++){let c=r[l];if(a.sameState(c)||a.buffer.length>500&&c.buffer.length>500)if((a.score-c.score||a.buffer.length-c.buffer.length)>0)r.splice(l--,1);else{r.splice(o--,1);continue e}}}r.length>12&&r.splice(12,r.length-12)}this.minStackPos=r[0].pos;for(let o=1;o<r.length;o++)r[o].pos<this.minStackPos&&(this.minStackPos=r[o].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,n,r){let i=e.pos,{parser:s}=this,o=wi?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&i>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,u=c?e.curContext.hash:0;for(let d=this.fragments.nodeAt(i);d;){let h=this.parser.nodeSet.types[d.type.id]==d.type?s.getGoto(e.state,d.type.id):-1;if(h>-1&&d.length&&(!c||(d.prop(Tt.contextHash)||0)==u))return e.useNode(d,h),wi&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(d.type.id)})`),!0;if(!(d instanceof Bn)||d.children.length==0||d.positions[0]>0)break;let m=d.children[0];if(m instanceof Bn&&d.positions[0]==0)d=m;else break}}let a=s.stateSlot(e.state,4);if(a>0)return e.reduce(a),wi&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(a&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let c=0;c<l.length;){let u=l[c++],d=l[c++],h=l[c++],m=c==l.length||!r,y=m?e:e.split(),v=this.tokens.mainToken;if(y.apply(u,d,v?v.start:y.pos,h),wi&&console.log(o+this.stackID(y)+` (via ${u&65536?`reduce of ${s.getName(u&65535)}`:"shift"} for ${s.getName(d)} @ ${i}${y==e?"":", split"})`),m)return!0;y.pos>i?n.push(y):r.push(y)}return!1}advanceFully(e,n){let r=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>r)return pj(e,n),!0}}runRecovery(e,n,r){let i=null,s=!1;for(let o=0;o<e.length;o++){let a=e[o],l=n[o<<1],c=n[(o<<1)+1],u=wi?this.stackID(a)+" -> ":"";if(a.deadEnd&&(s||(s=!0,a.restart(),wi&&console.log(u+this.stackID(a)+" (restarted)"),this.advanceFully(a,r))))continue;let d=a.split(),h=u;for(let m=0;d.forceReduce()&&m<10&&(wi&&console.log(h+this.stackID(d)+" (via force-reduce)"),!this.advanceFully(d,r));m++)wi&&(h=this.stackID(d)+" -> ");for(let m of a.recoverByInsert(l))wi&&console.log(u+this.stackID(m)+" (via recover-insert)"),this.advanceFully(m,r);this.stream.end>a.pos?(c==a.pos&&(c++,l=0),a.recoverByDelete(l,c),wi&&console.log(u+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),pj(a,r)):(!i||i.score<a.score)&&(i=a)}return i}stackToTree(e){return e.close(),Bn.build({buffer:lx.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let n=(Ck||(Ck=new WeakMap)).get(e);return n||Ck.set(e,n=String.fromCodePoint(this.nextStackID++)),n+e}}function pj(t,e){for(let n=0;n<e.length;n++){let r=e[n];if(r.pos==t.pos&&r.sameState(t)){e[n].score<t.score&&(e[n]=t);return}}e.push(t)}class mve{constructor(e,n,r){this.source=e,this.flags=n,this.disabled=r}allows(e){return!this.disabled||this.disabled[e]==0}}class cx extends _8{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let n=e.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let a=0;a<e.repeatNodeCount;a++)n.push("");let r=Object.keys(e.topRules).map(a=>e.topRules[a][1]),i=[];for(let a=0;a<n.length;a++)i.push([]);function s(a,l,c){i[a].push([l,l.deserialize(String(c))])}if(e.nodeProps)for(let a of e.nodeProps){let l=a[0];typeof l=="string"&&(l=Tt[l]);for(let c=1;c<a.length;){let u=a[c++];if(u>=0)s(u,l,a[c++]);else{let d=a[c+-u];for(let h=-u;h>0;h--)s(a[c++],l,d);c++}}}this.nodeSet=new JA(n.map((a,l)=>fi.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:i[l],top:r.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=E8;let o=by(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;a<this.specializerSpecs.length;a++)this.specialized[a]=this.specializerSpecs[a].term;this.specializers=this.specializerSpecs.map(mj),this.states=by(e.states,Uint32Array),this.data=by(e.stateData),this.goto=by(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(a=>typeof a=="number"?new ed(o,a):a),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,n,r){let i=new pve(this,e,n,r);for(let s of this.wrappers)i=s(i,e,n,r);return i}getGoto(e,n,r=!1){let i=this.goto;if(n>=i[0])return-1;for(let s=i[n+1];;){let o=i[s++],a=o&1,l=i[s++];if(a&&r)return l;for(let c=s+(o>>1);s<c;s++)if(i[s]==e)return l;if(a)return-1}}hasAction(e,n){let r=this.data;for(let i=0;i<2;i++)for(let s=this.stateSlot(e,i?2:1),o;;s+=3){if((o=r[s])==65535)if(r[s+1]==1)o=r[s=Zo(r,s+2)];else{if(r[s+1]==2)return Zo(r,s+2);break}if(o==n||o==0)return Zo(r,s+1)}return 0}stateSlot(e,n){return this.states[e*6+n]}stateFlag(e,n){return(this.stateSlot(e,0)&n)>0}validAction(e,n){return!!this.allActions(e,r=>r==n?!0:null)}allActions(e,n){let r=this.stateSlot(e,4),i=r?n(r):void 0;for(let s=this.stateSlot(e,1);i==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=Zo(this.data,s+2);else break;i=n(Zo(this.data,s+1))}return i}nextStates(e){let n=[];for(let r=this.stateSlot(e,1);;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=Zo(this.data,r+2);else break;if(!(this.data[r+2]&1)){let i=this.data[r+1];n.some((s,o)=>o&1&&s==i)||n.push(this.data[r],i)}}return n}configure(e){let n=Object.assign(Object.create(cx.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let r=this.topRules[e.top];if(!r)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=r}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(r=>{let i=e.tokenizers.find(s=>s.from==r);return i?i.to:r})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((r,i)=>{let s=e.specializers.find(a=>a.from==r.external);if(!s)return r;let o=Object.assign(Object.assign({},r),{external:s.to});return n.specializers[i]=mj(o),o})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),r=n.map(()=>!1);if(e)for(let s of e.split(" ")){let o=n.indexOf(s);o>=0&&(r[o]=!0)}let i=null;for(let s=0;s<n.length;s++)if(!r[s])for(let o=this.dialects[n[s]],a;(a=this.data[o++])!=65535;)(i||(i=new Uint8Array(this.maxTerm+1)))[a]=1;return new mve(e,r,i)}static deserialize(e){return new cx(e)}}function Zo(t,e){return t[e]|t[e+1]<<16}function gve(t){let e=null;for(let n of t){let r=n.p.stoppedAt;(n.pos==n.p.stream.end||r!=null&&n.pos>r)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.score<n.score)&&(e=n)}return e}function mj(t){if(t.external){let e=t.extend?1:0;return(n,r)=>t.external(n,r)<<1|e}return t.get}let yve=0;class Zi{constructor(e,n,r,i){this.name=e,this.set=n,this.base=r,this.modified=i,this.id=yve++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof Zi&&(n=e),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let i=new Zi(r,[],null,[]);if(i.set.push(i),n)for(let s of n.set)i.set.push(s);return i}static defineModifier(e){let n=new ux(e);return r=>r.modified.indexOf(n)>-1?r:ux.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}}let xve=0;class ux{constructor(e){this.name=e,this.instances=[],this.id=xve++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(a=>a.base==e&&vve(n,a.modified));if(r)return r;let i=[],s=new Zi(e.name,i,e,n);for(let a of n)a.instances.push(s);let o=wve(n);for(let a of e.set)if(!a.modified.length)for(let l of o)i.push(ux.get(a,l));return s}}function vve(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function wve(t){let e=[[]];for(let n=0;n<t.length;n++)for(let r=0,i=e.length;r<i;r++)e.push(e[r].concat(t[n]));return e.sort((n,r)=>r.length-n.length)}function M8(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let i of n.split(" "))if(i){let s=[],o=2,a=i;for(let d=0;;){if(a=="..."&&d>0&&d+3==i.length){o=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!h)throw new RangeError("Invalid path: "+i);if(s.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),d+=h[0].length,d==i.length)break;let m=i[d++];if(d==i.length&&m=="!"){o=0;break}if(m!="/")throw new RangeError("Invalid path: "+i);a=i.slice(d)}let l=s.length-1,c=s[l];if(!c)throw new RangeError("Invalid path: "+i);let u=new dx(r,o,l>0?s.slice(0,l):null);e[c]=u.sort(e[c])}}return P8.add(e)}const P8=new Tt;class dx{constructor(e,n,r,i){this.tags=e,this.mode=n,this.context=r,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}dx.empty=new dx([],2,null);function O8(t,e){let n=Object.create(null);for(let s of t)if(!Array.isArray(s.tag))n[s.tag.id]=s.class;else for(let o of s.tag)n[o.id]=s.class;let{scope:r,all:i=null}=e||{};return{style:s=>{let o=i;for(let a of s)for(let l of a.set){let c=n[l.id];if(c){o=o?o+" "+c:c;break}}return o},scope:r}}function bve(t,e){let n=null;for(let r of t){let i=r.style(e);i&&(n=n?n+" "+i:i)}return n}function kve(t,e,n,r=0,i=t.length){let s=new Sve(r,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),r,i,"",s.highlighters),s.flush(i)}class Sve{constructor(e,n,r){this.at=e,this.highlighters=n,this.span=r,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,r,i,s){let{type:o,from:a,to:l}=e;if(a>=r||l<=n)return;o.isTop&&(s=this.highlighters.filter(m=>!m.scope||m.scope(o)));let c=i,u=Cve(e)||dx.empty,d=bve(s,u.tags);if(d&&(c&&(c+=" "),c+=d,u.mode==1&&(i+=(i?" ":"")+d)),this.startSpan(Math.max(n,a),c),u.opaque)return;let h=e.tree&&e.tree.prop(Tt.mounted);if(h&&h.overlay){let m=e.node.enter(h.overlay[0].from+a,1),y=this.highlighters.filter(w=>!w.scope||w.scope(h.tree.type)),v=e.firstChild();for(let w=0,b=a;;w++){let k=w<h.overlay.length?h.overlay[w]:null,C=k?k.from+a:l,T=Math.max(n,b),_=Math.min(r,C);if(T<_&&v)for(;e.from<_&&(this.highlightRange(e,T,_,i,s),this.startSpan(Math.min(_,e.to),c),!(e.to>=C||!e.nextSibling())););if(!k||C>r)break;b=k.to+a,b>n&&(this.highlightRange(m.cursor(),Math.max(n,k.from+a),Math.min(r,b),"",y),this.startSpan(Math.min(r,b),c))}v&&e.parent()}else if(e.firstChild()){h&&(i="");do if(!(e.to<=n)){if(e.from>=r)break;this.highlightRange(e,n,r,i,s),this.startSpan(Math.min(r,e.to),c)}while(e.nextSibling());e.parent()}}}function Cve(t){let e=t.type.prop(P8);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const De=Zi.define,ky=De(),tl=De(),gj=De(tl),yj=De(tl),nl=De(),Sy=De(nl),Ek=De(nl),Ks=De(),rc=De(Ks),Us=De(),qs=De(),TE=De(),eh=De(TE),Cy=De(),re={comment:ky,lineComment:De(ky),blockComment:De(ky),docComment:De(ky),name:tl,variableName:De(tl),typeName:gj,tagName:De(gj),propertyName:yj,attributeName:De(yj),className:De(tl),labelName:De(tl),namespace:De(tl),macroName:De(tl),literal:nl,string:Sy,docString:De(Sy),character:De(Sy),attributeValue:De(Sy),number:Ek,integer:De(Ek),float:De(Ek),bool:De(nl),regexp:De(nl),escape:De(nl),color:De(nl),url:De(nl),keyword:Us,self:De(Us),null:De(Us),atom:De(Us),unit:De(Us),modifier:De(Us),operatorKeyword:De(Us),controlKeyword:De(Us),definitionKeyword:De(Us),moduleKeyword:De(Us),operator:qs,derefOperator:De(qs),arithmeticOperator:De(qs),logicOperator:De(qs),bitwiseOperator:De(qs),compareOperator:De(qs),updateOperator:De(qs),definitionOperator:De(qs),typeOperator:De(qs),controlOperator:De(qs),punctuation:TE,separator:De(TE),bracket:eh,angleBracket:De(eh),squareBracket:De(eh),paren:De(eh),brace:De(eh),content:Ks,heading:rc,heading1:De(rc),heading2:De(rc),heading3:De(rc),heading4:De(rc),heading5:De(rc),heading6:De(rc),contentSeparator:De(Ks),list:De(Ks),quote:De(Ks),emphasis:De(Ks),strong:De(Ks),link:De(Ks),monospace:De(Ks),strikethrough:De(Ks),inserted:De(),deleted:De(),changed:De(),invalid:De(),meta:Cy,documentMeta:De(Cy),annotation:De(Cy),processingInstruction:De(Cy),definition:Zi.defineModifier("definition"),constant:Zi.defineModifier("constant"),function:Zi.defineModifier("function"),standard:Zi.defineModifier("standard"),local:Zi.defineModifier("local"),special:Zi.defineModifier("special")};for(let t in re){let e=re[t];e instanceof Zi&&(e.name=t)}O8([{tag:re.link,class:"tok-link"},{tag:re.heading,class:"tok-heading"},{tag:re.emphasis,class:"tok-emphasis"},{tag:re.strong,class:"tok-strong"},{tag:re.keyword,class:"tok-keyword"},{tag:re.atom,class:"tok-atom"},{tag:re.bool,class:"tok-bool"},{tag:re.url,class:"tok-url"},{tag:re.labelName,class:"tok-labelName"},{tag:re.inserted,class:"tok-inserted"},{tag:re.deleted,class:"tok-deleted"},{tag:re.literal,class:"tok-literal"},{tag:re.string,class:"tok-string"},{tag:re.number,class:"tok-number"},{tag:[re.regexp,re.escape,re.special(re.string)],class:"tok-string2"},{tag:re.variableName,class:"tok-variableName"},{tag:re.local(re.variableName),class:"tok-variableName tok-local"},{tag:re.definition(re.variableName),class:"tok-variableName tok-definition"},{tag:re.special(re.variableName),class:"tok-variableName2"},{tag:re.definition(re.propertyName),class:"tok-propertyName tok-definition"},{tag:re.typeName,class:"tok-typeName"},{tag:re.namespace,class:"tok-namespace"},{tag:re.className,class:"tok-className"},{tag:re.macroName,class:"tok-macroName"},{tag:re.propertyName,class:"tok-propertyName"},{tag:re.operator,class:"tok-operator"},{tag:re.comment,class:"tok-comment"},{tag:re.meta,class:"tok-meta"},{tag:re.invalid,class:"tok-invalid"},{tag:re.punctuation,class:"tok-punctuation"}]);const Eve=M8({String:re.string,Number:re.number,"True False":re.bool,PropertyName:re.propertyName,Null:re.null,", :":re.separator,"[ ]":re.squareBracket,"{ }":re.brace}),Tve=cx.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[Eve],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0});let NE=[],R8=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e<t.length;e++)(e%2?R8:NE).push(n=n+t[e])})();function Nve(t){if(t<768)return!1;for(let e=0,n=NE.length;;){let r=e+n>>1;if(t<NE[r])n=r;else if(t>=R8[r])e=r+1;else return!0;if(e==n)return!1}}function xj(t){return t>=127462&&t<=127487}const vj=8205;function Ave(t,e,n=!0,r=!0){return(n?D8:_ve)(t,e,r)}function D8(t,e,n){if(e==t.length)return e;e&&j8(t.charCodeAt(e))&&I8(t.charCodeAt(e-1))&&e--;let r=Tk(t,e);for(e+=wj(r);e<t.length;){let i=Tk(t,e);if(r==vj||i==vj||n&&Nve(i))e+=wj(i),r=i;else if(xj(i)){let s=0,o=e-2;for(;o>=0&&xj(Tk(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function _ve(t,e,n){for(;e>0;){let r=D8(t,e-2,n);if(r<e)return r;e--}return 0}function Tk(t,e){let n=t.charCodeAt(e);if(!I8(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return j8(r)?(n-55296<<10)+(r-56320)+65536:n}function j8(t){return t>=56320&&t<57344}function I8(t){return t>=55296&&t<56320}function wj(t){return t<65536?1:2}let Vt=class L8{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=Sd(this,e,n);let i=[];return this.decompose(0,e,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),Js.from(i,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=Sd(this,e,n);let r=[];return this.decompose(e,n,r,0),Js.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),i=new Lh(this),s=new Lh(e);for(let o=n,a=n;;){if(i.next(o),s.next(o),o=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(a+=i.value.length,i.done||a>=r)return!0}}iter(e=1){return new Lh(this,e)}iterRange(e,n=this.length){return new F8(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(e).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new B8(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?L8.empty:e.length<=32?new Pn(e):Js.from(Pn.split(e,[]))}};class Pn extends Vt{constructor(e,n=Mve(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.text[s],a=i+o.length;if((n?r:a)>=e)return new Pve(i,a,r,o);i=a+1,r++}}decompose(e,n,r,i){let s=e<=0&&n>=this.length?this:new Pn(bj(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(i&1){let o=r.pop(),a=h0(s.text,o.text.slice(),0,s.length);if(a.length<=32)r.push(new Pn(a,o.length+s.length));else{let l=a.length>>1;r.push(new Pn(a.slice(0,l)),new Pn(a.slice(l)))}}else r.push(s)}replace(e,n,r){if(!(r instanceof Pn))return super.replace(e,n,r);[e,n]=Sd(this,e,n);let i=h0(this.text,h0(r.text,bj(this.text,0,e)),n),s=this.length+r.length-(n-e);return i.length<=32?new Pn(i,s):Js.from(Pn.split(i,[]),s)}sliceString(e,n=this.length,r=`
346
+ color: hsl(${Math.max(0,Math.min(120-120*v,120))}deg 100% 31%);`,n==null?void 0:n.key)}return(l=n==null?void 0:n.onChange)==null||l.call(n,i),i}}function kk(t,e){if(t===void 0)throw new Error("Unexpected undefined");return t}const Z0e=(t,e)=>Math.abs(t-e)<1,X0e=(t,e,n)=>{let r;return function(...i){t.clearTimeout(r),r=t.setTimeout(()=>e.apply(this,i),n)}},Q0e=t=>t,J0e=t=>{const e=Math.max(t.startIndex-t.overscan,0),n=Math.min(t.endIndex+t.overscan,t.count-1),r=[];for(let i=e;i<=n;i++)r.push(i);return r},exe=(t,e)=>{const n=t.scrollElement;if(!n)return;const r=t.targetWindow;if(!r)return;const i=o=>{const{width:a,height:l}=o;e({width:Math.round(a),height:Math.round(l)})};if(i(n.getBoundingClientRect()),!r.ResizeObserver)return()=>{};const s=new r.ResizeObserver(o=>{const a=()=>{const l=o[0];if(l!=null&&l.borderBoxSize){const c=l.borderBoxSize[0];if(c){i({width:c.inlineSize,height:c.blockSize});return}}i(n.getBoundingClientRect())};t.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()});return s.observe(n,{box:"border-box"}),()=>{s.unobserve(n)}},ZD={passive:!0},XD=typeof window>"u"?!0:"onscrollend"in window,txe=(t,e)=>{const n=t.scrollElement;if(!n)return;const r=t.targetWindow;if(!r)return;let i=0;const s=t.options.useScrollendEvent&&XD?()=>{}:X0e(r,()=>{e(i,!1)},t.options.isScrollingResetDelay),o=u=>()=>{const{horizontal:d,isRtl:h}=t.options;i=d?n.scrollLeft*(h&&-1||1):n.scrollTop,s(),e(i,u)},a=o(!0),l=o(!1);l(),n.addEventListener("scroll",a,ZD);const c=t.options.useScrollendEvent&&XD;return c&&n.addEventListener("scrollend",l,ZD),()=>{n.removeEventListener("scroll",a),c&&n.removeEventListener("scrollend",l)}},nxe=(t,e,n)=>{if(e!=null&&e.borderBoxSize){const r=e.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return Math.round(t.getBoundingClientRect()[n.options.horizontal?"width":"height"])},rxe=(t,{adjustments:e=0,behavior:n},r)=>{var i,s;const o=t+e;(s=(i=r.scrollElement)==null?void 0:i.scrollTo)==null||s.call(i,{[r.options.horizontal?"left":"top"]:o,behavior:n})};class ixe{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollToIndexTimeoutId=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.pendingMeasuredCacheIndexes=[],this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(i=>{i.forEach(s=>{const o=()=>{this._measureElement(s.target,s)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()})}));return{disconnect:()=>{var i;(i=r())==null||i.disconnect(),n=null},observe:i=>{var s;return(s=r())==null?void 0:s.observe(i,{box:"border-box"})},unobserve:i=>{var s;return(s=r())==null?void 0:s.unobserve(i)}}})(),this.range=null,this.setOptions=n=>{Object.entries(n).forEach(([r,i])=>{typeof i>"u"&&delete n[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Q0e,rangeExtractor:J0e,onChange:()=>{},measureElement:nxe,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!0,useAnimationFrameWithResizeObserver:!1,...n}},this.notify=n=>{var r,i;(i=(r=this.options).onChange)==null||i.call(r,this,n)},this.maybeNotify=Nu(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(i=>{this.observer.observe(i)}),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0}),this.unsubs.push(this.options.observeElementRect(this,i=>{this.scrollRect=i,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(i,s)=>{this.scrollAdjustments=0,this.scrollDirection=s?this.getScrollOffset()<i?"forward":"backward":null,this.scrollOffset=i,this.isScrolling=s,this.maybeNotify()}))}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(n,r)=>{const i=new Map,s=new Map;for(let o=r-1;o>=0;o--){const a=n[o];if(i.has(a.lane))continue;const l=s.get(a.lane);if(l==null||a.end>l.end?s.set(a.lane,a):a.end<l.end&&i.set(a.lane,!0),i.size===this.options.lanes)break}return s.size===this.options.lanes?Array.from(s.values()).sort((o,a)=>o.end===a.end?o.index-a.index:o.end-a.end)[0]:void 0},this.getMeasurementOptions=Nu(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled],(n,r,i,s,o)=>(this.pendingMeasuredCacheIndexes=[],{count:n,paddingStart:r,scrollMargin:i,getItemKey:s,enabled:o}),{key:!1}),this.getMeasurements=Nu(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:n,paddingStart:r,scrollMargin:i,getItemKey:s,enabled:o},a)=>{if(!o)return this.measurementsCache=[],this.itemSizeCache.clear(),[];this.measurementsCache.length===0&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(u=>{this.itemSizeCache.set(u.key,u.size)}));const l=this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[];const c=this.measurementsCache.slice(0,l);for(let u=l;u<n;u++){const d=s(u),h=this.options.lanes===1?c[u-1]:this.getFurthestMeasurement(c,u),m=h?h.end+this.options.gap:r+i,y=a.get(d),v=typeof y=="number"?y:this.options.estimateSize(u),w=m+v,b=h?h.lane:u%this.options.lanes;c[u]={index:u,start:m,size:v,end:w,key:d,lane:b}}return this.measurementsCache=c,c},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Nu(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset()],(n,r,i)=>this.range=n.length>0&&r>0?sxe({measurements:n,outerSize:r,scrollOffset:i}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Nu(()=>{let n=null,r=null;const i=this.calculateRange();return i&&(n=i.startIndex,r=i.endIndex),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,i,s,o)=>s===null||o===null?[]:n({startIndex:s,endIndex:o,overscan:r,count:i}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,i=n.getAttribute(r);return i?parseInt(i,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this._measureElement=(n,r)=>{const i=this.indexFromElement(n),s=this.measurementsCache[i];if(!s)return;const o=s.key,a=this.elementsCache.get(o);a!==n&&(a&&this.observer.unobserve(a),this.observer.observe(n),this.elementsCache.set(o,n)),n.isConnected&&this.resizeItem(i,this.options.measureElement(n,r,this))},this.resizeItem=(n,r)=>{const i=this.measurementsCache[n];if(!i)return;const s=this.itemSizeCache.get(i.key)??i.size,o=r-s;o!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(i,o,this):i.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(i.index),this.itemSizeCache=new Map(this.itemSizeCache.set(i.key,r)),this.notify(!1))},this.measureElement=n=>{if(!n){this.elementsCache.forEach((r,i)=>{r.isConnected||(this.observer.unobserve(r),this.elementsCache.delete(i))});return}this._measureElement(n,void 0)},this.getVirtualItems=Nu(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const i=[];for(let s=0,o=n.length;s<o;s++){const a=n[s],l=r[a];i.push(l)}return i},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length!==0)return kk(r[XV(0,r.length-1,i=>kk(r[i]).start,n)])},this.getOffsetForAlignment=(n,r)=>{const i=this.getSize(),s=this.getScrollOffset();r==="auto"&&n>=s+i&&(r="end"),r==="end"&&(n-=i);const o=this.options.horizontal?"scrollWidth":"scrollHeight",l=(this.scrollElement?"document"in this.scrollElement?this.scrollElement.document.documentElement[o]:this.scrollElement[o]:0)-i;return Math.max(Math.min(l,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const i=this.measurementsCache[n];if(!i)return;const s=this.getSize(),o=this.getScrollOffset();if(r==="auto")if(i.end>=o+s-this.options.scrollPaddingEnd)r="end";else if(i.start<=o+this.options.scrollPaddingStart)r="start";else return[o,r];const a=i.start-this.options.scrollPaddingStart+(i.size-s)/2;switch(r){case"center":return[this.getOffsetForAlignment(a,r),r];case"end":return[this.getOffsetForAlignment(i.end+this.options.scrollPaddingEnd,r),r];default:return[this.getOffsetForAlignment(i.start-this.options.scrollPaddingStart,r),r]}},this.isDynamicMode=()=>this.elementsCache.size>0,this.cancelScrollToIndex=()=>{this.scrollToIndexTimeoutId!==null&&this.targetWindow&&(this.targetWindow.clearTimeout(this.scrollToIndexTimeoutId),this.scrollToIndexTimeoutId=null)},this.scrollToOffset=(n,{align:r="start",behavior:i}={})=>{this.cancelScrollToIndex(),i==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(n,r),{adjustments:void 0,behavior:i})},this.scrollToIndex=(n,{align:r="auto",behavior:i}={})=>{n=Math.max(0,Math.min(n,this.options.count-1)),this.cancelScrollToIndex(),i==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size.");const s=this.getOffsetForIndex(n,r);if(!s)return;const[o,a]=s;this._scrollToOffset(o,{adjustments:void 0,behavior:i}),i!=="smooth"&&this.isDynamicMode()&&this.targetWindow&&(this.scrollToIndexTimeoutId=this.targetWindow.setTimeout(()=>{if(this.scrollToIndexTimeoutId=null,this.elementsCache.has(this.options.getItemKey(n))){const[c]=kk(this.getOffsetForIndex(n,a));Z0e(c,this.getScrollOffset())||this.scrollToIndex(n,{align:a,behavior:i})}else this.scrollToIndex(n,{align:a,behavior:i})}))},this.scrollBy=(n,{behavior:r}={})=>{this.cancelScrollToIndex(),r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+n,{adjustments:void 0,behavior:r})},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let i;return r.length===0?i=this.options.paddingStart:i=this.options.lanes===1?((n=r[r.length-1])==null?void 0:n.end)??0:Math.max(...r.slice(-this.options.lanes).map(s=>s.end)),Math.max(i-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(n,{adjustments:r,behavior:i})=>{this.options.scrollToFn(n,{behavior:i,adjustments:r},this)},this.measure=()=>{this.itemSizeCache=new Map,this.notify(!1)},this.setOptions(e)}}const XV=(t,e,n,r)=>{for(;t<=e;){const i=(t+e)/2|0,s=n(i);if(s<r)t=i+1;else if(s>r)e=i-1;else return i}return t>0?t-1:0};function sxe({measurements:t,outerSize:e,scrollOffset:n}){const r=t.length-1,s=XV(0,r,a=>t[a].start,n);let o=s;for(;o<r&&t[o].end<n+e;)o++;return{startIndex:s,endIndex:o}}const QD=typeof document<"u"?S.useLayoutEffect:S.useEffect;function oxe(t){const e=S.useReducer(()=>({}),{})[1],n={...t,onChange:(i,s)=>{var o;s?Hd.flushSync(e):e(),(o=t.onChange)==null||o.call(t,i,s)}},[r]=S.useState(()=>new ixe(n));return r.setOptions(n),QD(()=>r._didMount(),[]),QD(()=>r._willUpdate()),r}function axe(t){return oxe({observeElementRect:exe,observeElementOffset:txe,scrollToFn:rxe,...t})}const lxe=q0e,cxe=Y0e,uxe=zV,dxe=K0e,fxe=G0e,QV=S.forwardRef(({className:t,inset:e,children:n,...r},i)=>g.jsx($V,{ref:i,className:ve("focus-visible:ring-ring focus:outline-none focus-visible:rounded focus-visible:outline-none focus-visible:ring-1",t),...r,children:n}));QV.displayName=$V.displayName;const JV=S.forwardRef(({className:t,inset:e,children:n,...r},i)=>g.jsxs(KV,{ref:i,className:ve("focus:bg-accent data-[state=open]:bg-accent flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none",e&&"pl-8",t),...r,children:[n,g.jsx(Xh,{className:"ml-auto -rotate-90"})]}));JV.displayName=KV.displayName;const e8=S.forwardRef(({className:t,...e},n)=>g.jsx(ZV,{ref:n,className:ve("popover-backdrop-filter popover-background popover-border popover-shadow popover-foreground data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 z-50 min-w-[8rem] overflow-auto overflow-x-hidden rounded-md p-1",t),...e}));e8.displayName=ZV.displayName;const t8=S.forwardRef(({className:t,container:e,sideOffset:n=4,...r},i)=>g.jsx(zV,{container:e,children:g.jsx(VV,{ref:i,sideOffset:n,className:ve("popover-backdrop-filter bg-mastra-bg-2 popover-border popover-shadow popover-foreground data-[state=open]:fade-in-0 data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 z-50 min-w-[8rem] overflow-auto overflow-x-hidden rounded-md p-1",t),...r})}));t8.displayName=VV.displayName;const n8=S.forwardRef(({className:t,inset:e,...n},r)=>g.jsx(HV,{ref:r,className:ve("focus:text-accent-foreground relative flex cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-[0.8125rem] outline-none transition-colors focus:bg-[#66686A]/20 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>span]:truncate",e&&"pl-8",t),...n}));n8.displayName=HV.displayName;const r8=S.forwardRef(({className:t,children:e,checked:n,...r},i)=>g.jsxs(UV,{ref:i,className:ve("focus:bg-accent focus:text-accent-foreground relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),checked:n,...r,children:[g.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:g.jsx(YV,{children:g.jsx(lN,{className:"h-2 w-2 fill-current"})})}),e]}));r8.displayName=UV.displayName;const i8=S.forwardRef(({className:t,children:e,...n},r)=>g.jsxs(qV,{ref:r,className:ve("focus:bg-accent focus:text-accent-foreground relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t),...n,children:[g.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:g.jsx(YV,{children:g.jsx(aX,{className:"h-2 w-2 fill-current"})})}),e]}));i8.displayName=qV.displayName;const s8=S.forwardRef(({className:t,inset:e,...n},r)=>g.jsx(WV,{ref:r,className:ve("px-2 py-1.5 text-sm font-semibold",e&&"pl-8",t),...n}));s8.displayName=WV.displayName;const o8=S.forwardRef(({className:t,...e},n)=>g.jsx(GV,{ref:n,className:ve("popover-dividers-bg -mx-1 my-1 h-px",t),...e}));o8.displayName=GV.displayName;const a8=({className:t,...e})=>g.jsx("span",{className:ve("ml-auto text-xs tracking-widest opacity-60",t),...e});a8.displayName="DropdownMenuShortcut";function er({open:t,onOpenChange:e,children:n,modal:r}){return g.jsx(lxe,{modal:r,open:t,onOpenChange:e,children:n})}function hxe({itemsCount:t,items:e,renderItem:n,...r}){const i=S.useRef(null),s=axe({count:t,estimateSize:()=>35,getScrollElement:()=>i.current,overscan:5,measureElement:typeof window<"u"&&navigator.userAgent.indexOf("Firefox")===-1?o=>o==null?void 0:o.getBoundingClientRect().height:void 0});return g.jsx("div",{ref:i,className:"h-64 overflow-auto",children:g.jsx("div",{className:"relative w-full overflow-auto",style:{height:`${s.getTotalSize()}px`},children:s==null?void 0:s.getVirtualItems().map((o,a)=>g.jsx("button",{className:"text-accent-foreground absolute left-0 top-0 flex w-full cursor-default select-none items-center gap-2 rounded-sm px-2 py-1.5 text-[0.8125rem] outline-none transition-colors hover:bg-[#66686A]/20 data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&>span]:truncate",style:{height:`${o.size}px`,transform:`translateY(${o.start}px)`},...r,children:n(e[a])},o.index))})})}er.Trigger=QV;er.Content=t8;er.Group=cxe;er.Portal=uxe;er.Item=n8;er.CheckboxItem=r8;er.RadioItem=i8;er.Label=s8;er.Separator=o8;er.Shortcut=a8;er.Sub=dxe;er.SubContent=e8;er.SubTrigger=JV;er.RadioGroup=fxe;er.VirtualizedItems=hxe;const pxe=t=>{const{data:e,isLoading:n,mutate:r}=eA(`/api/memory/status?agentId=${t}`,uN,{fallbackData:{result:!1},isPaused:()=>!t});return{memory:e,isLoading:n,mutate:r}},mxe=({resourceid:t,agentId:e})=>{const{data:n,isLoading:r,mutate:i}=eA(`/api/memory/threads?resourceid=${t}&agentId=${e}`,uN,{fallbackData:[],isPaused:()=>!t,revalidateOnFocus:!1});return S.useEffect(()=>{t&&i()},[t]),{threads:n,isLoading:r,mutate:i}},gxe=({threadId:t,memory:e,agentId:n})=>{const{data:r,isLoading:i,mutate:s}=eA(`/api/memory/threads/${t}/messages?agentId=${n}`,o=>uN(o,!0),{fallbackData:{uiMessages:[],messages:[]},revalidateOnFocus:!1,isPaused:()=>!t,shouldRetryOnError:!1});return S.useEffect(()=>{t&&e&&s()},[t,e]),{messages:r==null?void 0:r.uiMessages,isLoading:i,mutate:s}},yxe=()=>{const{mutate:t}=JN();return{deleteThread:async({threadId:n,resourceid:r,agentId:i})=>{const s=fetch(`/api/memory/threads/${n}?agentId=${i}`,{method:"DELETE",headers:{"Content-Type":"application/json"}});xn.promise(s,{loading:"Deleting chat...",success:()=>(t(`/api/memory/threads?resourceid=${r}&agentId=${i}`),"Chat deleted successfully"),error:"Failed to delete chat"})}}};function xxe({agentId:t,threadId:e}){const{threads:n,isLoading:r}=mxe({resourceid:t,agentId:t}),{deleteThread:i}=yxe(),s=Ao(),[o,a]=S.useState(null),[l,c]=S.useState(!1),u=async()=>{await i({threadId:o,resourceid:t,agentId:t}),c(!1),o===e&&s(`/agents/${t}/chat/${ro()}`)};return r?g.jsxs("div",{className:"p-4 w-full h-full space-y-2",children:[g.jsx("div",{className:"flex justify-end",children:g.jsx(qe,{className:"h-9 w-9"})}),g.jsx(qe,{className:"h-4"}),g.jsx(qe,{className:"h-4"}),g.jsx(qe,{className:"h-4"}),g.jsx(qe,{className:"h-4"}),g.jsx(qe,{className:"h-4"})]}):n!=null&&n.length?g.jsxs(zn,{className:"h-full px-4 pb-4 w-[256px]",children:[g.jsxs("div",{className:"space-y-2",children:[g.jsxs("div",{className:"flex justify-between items-center pl-2 sticky top-0 bg-mastra-bg-2 pt-4",children:[g.jsx("div",{className:"text-sm text-mastra-el-5",children:"Chat history"}),g.jsx(pt,{variant:"primary",size:"icon",onClick:()=>s(`/agents/${t}/chat/${ro()}`),children:g.jsx(Qh,{})})]}),n.map(d=>{const h=d.id===e;return g.jsxs("div",{className:ve("flex cursor-pointer w-full px-2 items-center focus-visible:outline-none transition-colors focus-visible:ring-1 focus-visible:ring-mastra-border-4 gap-3 rounded-xs group text-small hover:bg-mastra-el-6/5",h?"bg-mastra-el-6/5":""),children:[g.jsx(rm,{to:`/agents/${t}/chat/${d.id}`,className:"flex-1",children:g.jsx("p",{className:ve("py-[0.38rem] text-mastra-el-6/60 group-hover:text-mastra-el-6 transition-all capitalize ",h?"text-mastra-el-6":""),children:d.title})}),g.jsxs(er,{children:[g.jsx(er.Trigger,{asChild:!0,children:g.jsxs(pt,{variant:"ghost",size:"icon",className:"ml-auto",children:[g.jsx(uX,{}),g.jsx("span",{className:"sr-only",children:"More"})]})}),g.jsx(er.Content,{children:g.jsxs(er.Item,{className:"cursor-pointer text-destructive focus:bg-destructive/15 focus:text-destructive dark:text-red-500",onSelect:()=>{a(d.id),c(!0)},children:[g.jsx(vX,{}),g.jsx("span",{children:"Delete"})]})})]})]},d.id)})]}),g.jsx(sn,{open:l,onOpenChange:c,children:g.jsxs(sn.Content,{children:[g.jsxs(sn.Header,{children:[g.jsx(sn.Title,{children:"Are you absolutely sure?"}),g.jsx(sn.Description,{children:"This action cannot be undone. This will permanently delete your chat and remove it from our servers."})]}),g.jsxs(sn.Footer,{children:[g.jsx(sn.Cancel,{children:"Cancel"}),g.jsx(sn.Action,{onClick:u,children:"Continue"})]})]})})]}):g.jsxs("div",{className:"p-4 w-full space-y-2 h-full",children:[g.jsxs("div",{className:"flex justify-between items-center",children:[g.jsx("div",{className:"text-sm text-mastra-el-5",children:"Chat history"}),g.jsx(pt,{variant:"primary",size:"icon",onClick:()=>s(`/agents/${t}/chat/${ro()}`),children:g.jsx(Qh,{})})]}),g.jsx("div",{className:"text-small text-mastra-el-3",children:"Your conversations will appear here once you start chatting!"})]})}function JD(){const{agentId:t,threadId:e}=xa(),{agent:n,isLoading:r}=Vc(t),{memory:i}=pxe(t),s=Ao(),{messages:o,isLoading:a}=gxe({agentId:t,threadId:e,memory:!!(i!=null&&i.result)}),[l,c]=S.useState(!0);return S.useEffect(()=>{i!=null&&i.result&&!e&&s(`/agents/${t}/chat/${ro()}`)},[i==null?void 0:i.result,e]),r?g.jsxs("main",{className:"flex-1 relative grid grid-cols-[1fr_400px] divide-x",children:[g.jsx("div",{className:"p-4",children:g.jsx(qe,{className:"h-[600px]"})}),g.jsx("div",{className:"flex flex-col",children:g.jsx(J0,{agentId:t})})]}):g.jsxs("main",{className:ve("flex-1 relative grid divide-x",l&&(i!=null&&i.result)?"grid-cols-[256px_1fr_400px] overflow-y-hidden h-full":"grid-cols-[1fr_400px]"),children:[l&&(i!=null&&i.result)?g.jsx(xxe,{agentId:t,threadId:e}):null,g.jsxs("div",{className:"relative",children:[i!=null&&i.result?g.jsx(pt,{variant:"primary",size:"icon",className:"absolute top-4 left-4 z-50",onClick:()=>c(!l),children:g.jsx(pX,{})}):null,g.jsx(hde,{agentId:t,agentName:n==null?void 0:n.name,threadId:e,initialMessages:a?void 0:o,memory:i==null?void 0:i.result})]}),g.jsx("div",{className:"flex flex-col",children:g.jsx(J0,{agentId:t})})]})}const vxe=qd("inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground"}},defaultVariants:{variant:"default"}});function Ih({className:t,variant:e,...n}){return g.jsx("div",{className:ve(vxe({variant:e}),t),...n})}function xy({content:t,label:e,multiline:n=!1}){const r=()=>{navigator.clipboard.writeText(t)};return g.jsxs("div",{className:"group relative flex items-start gap-2",children:[g.jsx("span",{className:ve("text-sm text-mastra-el-4",n?"whitespace-pre-wrap":"truncate"),children:t}),g.jsx(pt,{variant:"ghost",size:"sm",className:"opacity-0 group-hover:opacity-100 transition-opacity shrink-0 -mt-1",onClick:i=>{i.stopPropagation(),r()},"aria-label":`Copy ${e}`,children:g.jsx(Q3,{className:"h-3 w-3"})})]})}var wxe="VisuallyHidden",ZA=S.forwardRef((t,e)=>g.jsx(Xe.span,{...t,ref:e,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...t.style}}));ZA.displayName=wxe;var bxe=ZA,[Dv,k4e]=Ii("Tooltip",[jl]),jv=jl(),l8="TooltipProvider",kxe=700,kE="tooltip.open",[Sxe,XA]=Dv(l8),c8=t=>{const{__scopeTooltip:e,delayDuration:n=kxe,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=t,[o,a]=S.useState(!0),l=S.useRef(!1),c=S.useRef(0);return S.useEffect(()=>{const u=c.current;return()=>window.clearTimeout(u)},[]),g.jsx(Sxe,{scope:e,isOpenDelayed:o,delayDuration:n,onOpen:S.useCallback(()=>{window.clearTimeout(c.current),a(!1)},[]),onClose:S.useCallback(()=>{window.clearTimeout(c.current),c.current=window.setTimeout(()=>a(!0),r)},[r]),isPointerInTransitRef:l,onPointerInTransitChange:S.useCallback(u=>{l.current=u},[]),disableHoverableContent:i,children:s})};c8.displayName=l8;var Iv="Tooltip",[Cxe,Lv]=Dv(Iv),u8=t=>{const{__scopeTooltip:e,children:n,open:r,defaultOpen:i=!1,onOpenChange:s,disableHoverableContent:o,delayDuration:a}=t,l=XA(Iv,t.__scopeTooltip),c=jv(e),[u,d]=S.useState(null),h=Vn(),m=S.useRef(0),y=o??l.disableHoverableContent,v=a??l.delayDuration,w=S.useRef(!1),[b=!1,k]=bo({prop:r,defaultProp:i,onChange:M=>{M?(l.onOpen(),document.dispatchEvent(new CustomEvent(kE))):l.onClose(),s==null||s(M)}}),C=S.useMemo(()=>b?w.current?"delayed-open":"instant-open":"closed",[b]),T=S.useCallback(()=>{window.clearTimeout(m.current),m.current=0,w.current=!1,k(!0)},[k]),_=S.useCallback(()=>{window.clearTimeout(m.current),m.current=0,k(!1)},[k]),A=S.useCallback(()=>{window.clearTimeout(m.current),m.current=window.setTimeout(()=>{w.current=!0,k(!0),m.current=0},v)},[v,k]);return S.useEffect(()=>()=>{m.current&&(window.clearTimeout(m.current),m.current=0)},[]),g.jsx(vm,{...c,children:g.jsx(Cxe,{scope:e,contentId:h,open:b,stateAttribute:C,trigger:u,onTriggerChange:d,onTriggerEnter:S.useCallback(()=>{l.isOpenDelayed?A():T()},[l.isOpenDelayed,A,T]),onTriggerLeave:S.useCallback(()=>{y?_():(window.clearTimeout(m.current),m.current=0)},[_,y]),onOpen:T,onClose:_,disableHoverableContent:y,children:n})})};u8.displayName=Iv;var SE="TooltipTrigger",d8=S.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,i=Lv(SE,n),s=XA(SE,n),o=jv(n),a=S.useRef(null),l=kt(e,a,i.onTriggerChange),c=S.useRef(!1),u=S.useRef(!1),d=S.useCallback(()=>c.current=!1,[]);return S.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),g.jsx(wm,{asChild:!0,...o,children:g.jsx(Xe.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:l,onPointerMove:Re(t.onPointerMove,h=>{h.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),u.current=!0)}),onPointerLeave:Re(t.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:Re(t.onPointerDown,()=>{c.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Re(t.onFocus,()=>{c.current||i.onOpen()}),onBlur:Re(t.onBlur,i.onClose),onClick:Re(t.onClick,i.onClose)})})});d8.displayName=SE;var Exe="TooltipPortal",[S4e,Txe]=Dv(Exe,{forceMount:void 0}),kd="TooltipContent",f8=S.forwardRef((t,e)=>{const n=Txe(kd,t.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=t,o=Lv(kd,t.__scopeTooltip);return g.jsx(Rr,{present:r||o.open,children:o.disableHoverableContent?g.jsx(h8,{side:i,...s,ref:e}):g.jsx(Nxe,{side:i,...s,ref:e})})}),Nxe=S.forwardRef((t,e)=>{const n=Lv(kd,t.__scopeTooltip),r=XA(kd,t.__scopeTooltip),i=S.useRef(null),s=kt(e,i),[o,a]=S.useState(null),{trigger:l,onClose:c}=n,u=i.current,{onPointerInTransitChange:d}=r,h=S.useCallback(()=>{a(null),d(!1)},[d]),m=S.useCallback((y,v)=>{const w=y.currentTarget,b={x:y.clientX,y:y.clientY},k=Pxe(b,w.getBoundingClientRect()),C=Oxe(b,k),T=Rxe(v.getBoundingClientRect()),_=jxe([...C,...T]);a(_),d(!0)},[d]);return S.useEffect(()=>()=>h(),[h]),S.useEffect(()=>{if(l&&u){const y=w=>m(w,u),v=w=>m(w,l);return l.addEventListener("pointerleave",y),u.addEventListener("pointerleave",v),()=>{l.removeEventListener("pointerleave",y),u.removeEventListener("pointerleave",v)}}},[l,u,m,h]),S.useEffect(()=>{if(o){const y=v=>{const w=v.target,b={x:v.clientX,y:v.clientY},k=(l==null?void 0:l.contains(w))||(u==null?void 0:u.contains(w)),C=!Dxe(b,o);k?h():C&&(h(),c())};return document.addEventListener("pointermove",y),()=>document.removeEventListener("pointermove",y)}},[l,u,o,c,h]),g.jsx(h8,{...t,ref:s})}),[Axe,_xe]=Dv(Iv,{isInside:!1}),h8=S.forwardRef((t,e)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:o,...a}=t,l=Lv(kd,n),c=jv(n),{onClose:u}=l;return S.useEffect(()=>(document.addEventListener(kE,u),()=>document.removeEventListener(kE,u)),[u]),S.useEffect(()=>{if(l.trigger){const d=h=>{const m=h.target;m!=null&&m.contains(l.trigger)&&u()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,u]),g.jsx(Xd,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:d=>d.preventDefault(),onDismiss:u,children:g.jsxs(Pv,{"data-state":l.stateAttribute,...c,...a,ref:e,style:{...a.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[g.jsx(dN,{children:r}),g.jsx(Axe,{scope:n,isInside:!0,children:g.jsx(bxe,{id:l.contentId,role:"tooltip",children:i||r})})]})})});f8.displayName=kd;var p8="TooltipArrow",Mxe=S.forwardRef((t,e)=>{const{__scopeTooltip:n,...r}=t,i=jv(n);return _xe(p8,n).isInside?null:g.jsx(Ov,{...i,...r,ref:e})});Mxe.displayName=p8;function Pxe(t,e){const n=Math.abs(e.top-t.y),r=Math.abs(e.bottom-t.y),i=Math.abs(e.right-t.x),s=Math.abs(e.left-t.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function Oxe(t,e,n=5){const r=[];switch(e){case"top":r.push({x:t.x-n,y:t.y+n},{x:t.x+n,y:t.y+n});break;case"bottom":r.push({x:t.x-n,y:t.y-n},{x:t.x+n,y:t.y-n});break;case"left":r.push({x:t.x+n,y:t.y-n},{x:t.x+n,y:t.y+n});break;case"right":r.push({x:t.x-n,y:t.y-n},{x:t.x-n,y:t.y+n});break}return r}function Rxe(t){const{top:e,right:n,bottom:r,left:i}=t;return[{x:i,y:e},{x:n,y:e},{x:n,y:r},{x:i,y:r}]}function Dxe(t,e){const{x:n,y:r}=t;let i=!1;for(let s=0,o=e.length-1;s<e.length;o=s++){const a=e[s].x,l=e[s].y,c=e[o].x,u=e[o].y;l>r!=u>r&&n<(c-a)*(r-l)/(u-l)+a&&(i=!i)}return i}function jxe(t){const e=t.slice();return e.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),Ixe(e)}function Ixe(t){if(t.length<=1)return t.slice();const e=[];for(let r=0;r<t.length;r++){const i=t[r];for(;e.length>=2;){const s=e[e.length-1],o=e[e.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))e.pop();else break}e.push(i)}e.pop();const n=[];for(let r=t.length-1;r>=0;r--){const i=t[r];for(;n.length>=2;){const s=n[n.length-1],o=n[n.length-2];if((s.x-o.x)*(i.y-o.y)>=(s.y-o.y)*(i.x-o.x))n.pop();else break}n.push(i)}return n.pop(),e.length===1&&n.length===1&&e[0].x===n[0].x&&e[0].y===n[0].y?e:e.concat(n)}var Lxe=c8,Fxe=u8,Bxe=d8,m8=f8;const $xe=Lxe,zxe=Fxe,Vxe=Bxe,g8=S.forwardRef(({className:t,sideOffset:e=4,...n},r)=>g.jsx(m8,{ref:r,sideOffset:e,className:ve("z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",t),...n}));g8.displayName=m8.displayName;function Wxe({date:t}){const e={relativeTime:Npe(new Date(t),{addSuffix:!0}),fullDate:fl(new Date(t),"PPpp")};return g.jsx($xe,{children:g.jsxs(zxe,{children:[g.jsx(Vxe,{className:"text-left text-sm text-mastra-el-4",children:e.relativeTime}),g.jsx(g8,{className:"bg-mastra-bg-1 text-mastra-el-1",children:g.jsx("p",{className:"text-sm",children:e.fullDate})})]})})}const Hxe=qd("flex w-full text-mastra-el-6 rounded-sm border bg-transparent shadow-sm focus-visible:ring-ring transition-colors focus-visible:outline-none focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50",{variants:{variant:{default:"border-mastra-border-1 border-border-1 placeholder:text-muted-foreground",filled:"bg-inputFill border-border-1 placeholder:text-muted-foreground",unstyled:"border-0 bg-transparent placeholder:text-muted-foreground focus-visible:ring-transparent focus-visible:outline-none"},customSize:{default:"px-[13px] text-[calc(13_/_16_*_1rem)] h-[34px]",sm:"h-[30px] px-[13px] text-xs",lg:"h-10 px-[17px] rounded-md text-[calc(13_/_16_*_1rem)]"}},defaultVariants:{variant:"default",customSize:"default"}}),Mc=S.forwardRef(({className:t,customSize:e,testId:n,variant:r,type:i,...s},o)=>g.jsx("input",{type:i,className:ve(t,Hxe({variant:r,customSize:e,className:t})),"data-testid":n,ref:o,...s}));Mc.displayName="Input";function ej({score:t}){return g.jsx(Ih,{variant:"secondary",children:t.toFixed(2)})}const tj=(t,e)=>{const[n,r]=S.useState([]),[i,s]=S.useState(!0),o=async a=>{s(!0);try{const l=await fetch(`/api/agents/${a??t}/evals/${e}`);if(!l.ok){const u=await l.json();r([]),console.error("Error fetching evals",u),xn.error((u==null?void 0:u.error)||"Error fetching evals");return}const c=await l.json();r(c.evals)}catch(l){r([]),console.error("Error fetching evals",l),xn.error("Error fetching evals")}finally{s(!1)}};return S.useEffect(()=>{o(t)},[t]),{evals:n,isLoading:i,refetchEvals:o}},y8=S.createContext({handleRefresh:()=>{},isLoading:!1}),vy=ve("relative overflow-y-auto overflow-x-hidden invisible hover:visible focus:visible","[&::-webkit-scrollbar]:w-1","[&::-webkit-scrollbar-track]:bg-transparent","[&::-webkit-scrollbar-thumb]:rounded-full","[&::-webkit-scrollbar-thumb]:bg-mastra-border/20","[&>*]:visible"),nj=ve("px-4 py-2 text-sm transition-all border-b-2 border-transparent","data-[state=active]:border-white data-[state=active]:text-white font-medium","data-[state=inactive]:text-mastra-el-4 hover:data-[state=inactive]:text-mastra-el-2","focus-visible:outline-none"),rj=ve("data-[state=inactive]:mt-0 min-h-0 h-full grid grid-rows-[1fr]");function Uxe({agentId:t}){const[e,n]=S.useState("live"),{evals:r,isLoading:i,refetchEvals:s}=tj(t,"live"),{evals:o,isLoading:a,refetchEvals:l}=tj(t,"ci"),c={handleRefresh:u,isLoading:e==="live"?i:a};return g.jsx(y8.Provider,{value:c,children:g.jsxs(CA,{value:e,onValueChange:d=>n(d),className:"grid grid-rows-[auto_1fr] h-full min-h-0 pb-2",children:[g.jsx("div",{className:"bg-mastra-bg-2 border-b border-mastra-border/10",children:g.jsxs(kv,{className:"bg-transparent border-0 h-auto mx-4 pt-5",children:[g.jsx(io,{value:"live",className:nj,children:"Live"}),g.jsx(io,{value:"ci",className:nj,children:"CI"})]})}),g.jsx(so,{value:"live",className:rj,children:g.jsx(ij,{evals:r,isCIMode:!1})}),g.jsx(so,{value:"ci",className:rj,children:g.jsx(ij,{evals:o,isCIMode:!0})})]})});function u(){e==="live"?s():l()}}function ij({evals:t,isCIMode:e=!1}){const{handleRefresh:n,isLoading:r}=S.useContext(y8),[i,s]=S.useState(new Set),[o,a]=S.useState(""),[l,c]=S.useState({field:"metricName",direction:"asc"}),[u,d]=S.useState(!1);return S.useEffect(()=>{if(r){const b=setTimeout(()=>{d(!0)},200);return()=>clearTimeout(b)}else d(!1)},[r]),g.jsxs("div",{className:"min-h-0 grid grid-rows-[auto_1fr]",children:[g.jsxs("div",{className:"flex items-center gap-4 p-4 bg-mastra-bg-2 rounded-lg",children:[g.jsxs("div",{className:"relative flex-1",children:[g.jsx(CC,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-mastra-el-3"}),g.jsx(Mc,{id:"search-input",placeholder:"Search metrics, inputs, or outputs...",value:o,onChange:b=>a(b.target.value),className:"pl-10"})]}),g.jsxs(Ih,{variant:"secondary",className:"text-xs",children:[t.length," Total Evaluations"]}),g.jsx(pt,{variant:"ghost",size:"icon",onClick:n,disabled:u,className:"h-9 w-9",children:u?g.jsx(cd,{className:"h-4 w-4 animate-spin"}):g.jsx(cd,{className:"h-4 w-4"})})]}),g.jsx("div",{className:"overflow-auto",children:g.jsxs(xo,{className:"w-full",children:[g.jsx(vo,{className:"bg-[#171717] sticky top-0 z-10",children:g.jsxs(dn,{className:"border-gray-6 border-b-[0.1px] text-[0.8125rem]",children:[g.jsx(yt,{className:"w-12"}),g.jsx(yt,{className:"min-w-[200px] max-w-[30%] text-mastra-el-3 cursor-pointer",onClick:()=>y("metricName"),children:g.jsxs("div",{className:"flex items-center",children:["Metric ",v("metricName")]})}),g.jsx(yt,{className:"flex-1 text-mastra-el-3"}),g.jsx(yt,{className:"w-48 text-mastra-el-3 cursor-pointer",onClick:()=>y("averageScore"),children:g.jsxs("div",{className:"flex items-center",children:["Average Score ",v("averageScore")]})}),g.jsx(yt,{className:"w-48 text-mastra-el-3",children:"Evaluations"})]})}),g.jsx(wo,{className:"border-b border-gray-6 relative",children:g.jsx(wN,{mode:"wait",presenceAffectsLayout:!1,children:u?Array.from({length:3}).map((b,k)=>g.jsxs(iB,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},transition:{duration:.2},className:"border-b-gray-6 border-b-[0.1px] text-[0.8125rem]",children:[g.jsx(at,{className:"w-12",children:g.jsx(qe,{className:"h-8 w-8 rounded-full"})}),g.jsx(at,{className:"min-w-[200px]",children:g.jsx(qe,{className:"h-4 w-3/4"})}),g.jsx(at,{className:"flex-1",children:g.jsx(qe,{className:"h-4 w-full"})}),g.jsx(at,{className:"w-48",children:g.jsx(qe,{className:"h-4 w-20"})}),g.jsx(at,{className:"w-48",children:g.jsx(qe,{className:"h-4 w-16"})})]},k)):w(t).length===0?g.jsx(dn,{children:g.jsx(at,{colSpan:5,className:"h-32 text-center text-mastra-el-3",children:g.jsxs("div",{className:"flex flex-col items-center gap-2",children:[g.jsx(CC,{className:"h-8 w-8"}),g.jsx("p",{children:"No evaluations found"}),o&&g.jsx("p",{className:"text-sm",children:"Try adjusting your search terms"})]})})}):w(t).map(b=>g.jsxs(ne.Fragment,{children:[g.jsxs(dn,{className:"border-b-gray-6 border-b-[0.1px] text-[0.8125rem] cursor-pointer hover:bg-mastra-bg-3",onClick:()=>m(b.metricName),children:[g.jsx(at,{className:"w-12",children:g.jsx("div",{className:"h-8 w-full flex items-center justify-center",children:g.jsx("div",{className:ve("transform transition-transform duration-200",i.has(b.metricName)?"rotate-90":""),children:g.jsx(dh,{className:"h-4 w-4 text-mastra-el-5"})})})}),g.jsx(at,{className:"min-w-[200px] max-w-[30%] font-medium text-mastra-el-5",children:b.metricName}),g.jsx(at,{className:"flex-1 text-mastra-el-5"}),g.jsx(at,{className:"w-48 text-mastra-el-5",children:g.jsx(ej,{score:b.averageScore})}),g.jsx(at,{className:"w-48 text-mastra-el-5",children:g.jsx(Ih,{variant:"secondary",children:b.evals.length})})]}),i.has(b.metricName)&&g.jsx(dn,{children:g.jsx(at,{colSpan:5+(h(b.evals)?1:0)+(e?1:0),className:"p-0",children:g.jsx("div",{className:"bg-mastra-bg-3 rounded-lg m-2",children:g.jsx("div",{className:"w-full",children:g.jsxs(xo,{className:"w-full",children:[g.jsx(vo,{children:g.jsxs(dn,{className:"text-[0.7rem] text-mastra-el-3 hover:bg-transparent",children:[g.jsx(yt,{className:"pl-12 w-[120px]",children:"Timestamp"}),g.jsx(yt,{className:"w-[300px]",children:"Instructions"}),g.jsx(yt,{className:"w-[300px]",children:"Input"}),g.jsx(yt,{className:"w-[300px]",children:"Output"}),g.jsx(yt,{className:"w-[80px]",children:"Score"}),h(b.evals)&&g.jsx(yt,{className:"w-[250px]",children:"Reason"}),e&&g.jsx(yt,{className:"w-[120px]",children:"Test Name"})]})}),g.jsx(wo,{children:b.evals.map((k,C)=>{var T,_;return g.jsxs(dn,{className:"text-[0.8125rem] hover:bg-mastra-bg-2/50",children:[g.jsx(at,{className:"pl-12 text-mastra-el-4 align-top py-4",children:g.jsx(Wxe,{date:k.createdAt})}),g.jsx(at,{className:"text-mastra-el-4 align-top py-4",children:g.jsx("div",{className:ve("max-w-[300px] max-h-[200px]",vy),children:g.jsx(xy,{content:k.instructions,label:"instructions",multiline:!0})})}),g.jsx(at,{className:"text-mastra-el-4 align-top py-4",children:g.jsx("div",{className:ve("max-w-[300px] max-h-[200px]",vy),children:g.jsx(xy,{content:k.input,label:"input",multiline:!0})})}),g.jsx(at,{className:"text-mastra-el-4 align-top py-4",children:g.jsx("div",{className:ve("max-w-[300px] max-h-[200px]",vy),children:g.jsx(xy,{content:k.output,label:"output",multiline:!0})})}),g.jsx(at,{className:"text-mastra-el-4 align-top py-4",children:g.jsx(ej,{score:k.result.score})}),h(b.evals)&&g.jsx(at,{className:"text-mastra-el-4 align-top py-4",children:g.jsx("div",{className:ve("max-w-[300px] max-h-[200px]",vy),children:g.jsx(xy,{content:((T=k.result.info)==null?void 0:T.reason)||"",label:"reason",multiline:!0})})}),e&&g.jsx(at,{className:"text-mastra-el-4 align-top py-4",children:((_=k.testInfo)==null?void 0:_.testName)&&g.jsx(Ih,{variant:"secondary",className:"text-xs",children:k.testInfo.testName})})]},`${b.metricName}-${C}`)})})]})})})})})]},b.metricName))})})]})})]});function h(b){return b.some(k=>{var C;return(C=k.result.info)==null?void 0:C.reason})}function m(b){const k=new Set(i);k.has(b)?k.delete(b):k.add(b),s(k)}function y(b){c(k=>({field:b,direction:k.field===b&&k.direction==="asc"?"desc":"asc"}))}function v(b){return l.field!==b?null:l.direction==="asc"?g.jsx(iX,{className:"h-4 w-4 ml-1"}):g.jsx(nX,{className:"h-4 w-4 ml-1"})}function w(b){let k=b.reduce((C,T)=>{const _=C.find(A=>A.metricName===T.metricName);return _?(_.evals.push(T),_.averageScore=_.evals.reduce((A,M)=>A+M.result.score,0)/_.evals.length):C.push({metricName:T.metricName,averageScore:T.result.score,evals:[T]}),C},[]);return o&&(k=k.filter(C=>C.metricName.toLowerCase().includes(o.toLowerCase())||C.evals.some(T=>{var _,A,M;return((_=T.input)==null?void 0:_.toLowerCase().includes(o.toLowerCase()))||((A=T.output)==null?void 0:A.toLowerCase().includes(o.toLowerCase()))||((M=T.instructions)==null?void 0:M.toLowerCase().includes(o.toLowerCase()))}))),k.sort((C,T)=>{const _=l.direction==="asc"?1:-1;switch(l.field){case"metricName":return _*C.metricName.localeCompare(T.metricName);case"averageScore":return _*(C.averageScore-T.averageScore);default:return 0}}),k}}function qxe(){const{agentId:t}=xa();return g.jsx("main",{className:"min-h-0",children:g.jsx(Uxe,{agentId:t})})}const Ls=S.createContext({});function x8({children:t}){const[e,n]=S.useState(!1),[r,i]=S.useState(null),[s,o]=S.useState([]),[a,l]=S.useState(0),[c,u]=S.useState(null),[d,h]=S.useState(!1),m=()=>{if(a<s.length-1){const w=a+1;l(w);const b=s[w].trace;i(b);const k=b.find(C=>C.parentSpanId===null)||b[0];u(k)}},y=()=>{if(a>0){const w=a-1;l(w);const b=s[w].trace;i(b);const k=b.find(C=>C.parentSpanId===null)||b[0];u(k)}},v=()=>{n(!1),i(null),u(null),h(!1)};return g.jsx(Ls.Provider,{value:{isOpen:e,setIsOpen:n,trace:r,setTrace:i,traces:s,setTraces:o,currentTraceIndex:a,setCurrentTraceIndex:l,nextTrace:m,prevTrace:y,span:c,setSpan:u,openDetail:d,setOpenDetail:h,clearData:v},children:t})}const Fv=({defaultWidth:t,minimumWidth:e,maximumWidth:n})=>{const[r,i]=S.useState(!1),[s,o]=S.useState(t),{isOpen:a}=S.useContext(Ls),l=S.useRef(null),c=S.useRef(0),u=S.useRef(0),d=h=>{h.preventDefault(),i(!0),c.current=h.clientX,u.current=s};return S.useEffect(()=>{a||o(t)},[a]),S.useEffect(()=>{const h=y=>{if(!r||!l.current)return;const v=l.current.offsetWidth,b=(c.current-y.clientX)/v*100,k=Math.min(Math.max(u.current+b,e),n);o(k)},m=()=>{i(!1)};return r&&(window.addEventListener("mousemove",h),window.addEventListener("mouseup",m)),()=>{window.removeEventListener("mousemove",h),window.removeEventListener("mouseup",m)}},[r]),{sidebarWidth:s,isDragging:r,handleMouseDown:d,containerRef:l}};function Yxe({fetchFn:t,interval:e=3e3,enabled:n=!1,onSuccess:r,onError:i,shouldContinue:s=()=>!0}){const[o,a]=S.useState(n),[l,c]=S.useState(null),[u,d]=S.useState(null),[h,m]=S.useState(!1),[y,v]=S.useState(!1),w=S.useRef(null),b=S.useRef(!0),k=S.useCallback(()=>{console.log("cleanup"),w.current&&(clearTimeout(w.current),w.current=null)},[]),C=S.useCallback(()=>{console.log("stopPolling"),a(!1),k()},[k]),T=S.useCallback(()=>{console.log("startPolling"),a(!0),c(null)},[]),_=S.useCallback(async(A=!1)=>{if(b.current){m(!0),v(A);try{const M=await t();d(M),c(null),r==null||r(M),v(!1),s(M)?w.current=setTimeout(_,e):C()}catch(M){if(!b.current)return;c(M),i==null||i(M),C()}finally{b.current&&(v(!1),m(!1))}}},[t,e,r,i,s,C]);return S.useEffect(()=>(b.current=!0,n&&o&&_(!0),()=>{console.log("cleanup poll"),b.current=!1,k()}),[n,o,_,k]),{isPolling:o,isLoading:h,error:l,data:u,startPolling:T,stopPolling:C,firstCallLoading:y}}function QA(t,e=2){return(t/1e3).toFixed(e)}function v8(t){const e=new Date(t/1e3);return new Intl.DateTimeFormat("en-US",{month:"numeric",day:"numeric",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!0}).format(e)}function Gxe(t){const e=new Date(t/1e6);return new Intl.DateTimeFormat("en-US",{month:"numeric",day:"numeric",year:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!0}).format(e)}function Kxe(t){return t.includes(".argument.")?"Input":t.includes(".result")?"Output":t.split(".").join(" ").split("_")}function sj(t){return t.replace(/\\n/g,"").replace(/\n/g,"").replace(/\s+/g," ").trim()}const Zxe=(t,e=!1)=>{const n=new Set,r=o=>{var a,l,c,u;return o!=null&&o.startsWith("workflow.")&&e?(l=(a=o==null?void 0:o.split("."))==null?void 0:a.slice(2))==null?void 0:l.join("."):o!=null&&o.startsWith("agent.")&&!e?(u=(c=o==null?void 0:o.split("."))==null?void 0:c.slice(1))==null?void 0:u.join("."):o},i=t.reduce((o,a)=>{const l={...a,name:r(a.name),duration:a.endTime-a.startTime};return n.add(a.id),{...o,[a.traceId]:[...o[a.traceId]||[],l]}},{});return Object.entries(i).map(([o,a])=>{var d;const l=a.find(h=>!h.parentSpanId||!n.has(h.parentSpanId)),c=a.map(h=>({...h,parentSpanId:(l==null?void 0:l.id)===h.id?null:h==null?void 0:h.parentSpanId,relativePercentage:l?h.duration/l.duration:0})),u=(d=a.find(h=>h.status.code!==0))==null?void 0:d.status;return{traceId:o,serviceName:(l==null?void 0:l.name)||o,duration:a.reduce((h,m)=>h+m.duration,0),status:u||(l==null?void 0:l.status)||a[0].status,started:a[0].startTime,trace:c}})},Xxe=["operation.name","ai.operationId","ai.model.provider","ai.model.id","ai.prompt.format","ai.prompt.messages","ai.prompt.tools","ai.prompt.toolChoice","ai.settings.toolChoice","ai.schema","ai.settings.output","ai.response.object","ai.response.text","ai.response.timestamp","componentName","ai.usage.promptTokens","ai.usage.completionTokens"],w8=(t,e=!1)=>{const[n,r]=S.useState(null),i=S.useCallback(async()=>{try{const u=await fetch(`/api/telemetry?attribute=componentName:${t}`);if(!u.ok){const m=await u.json();throw new Error((m==null?void 0:m.error)||"Error fetching traces")}const d=await u.json();return Zxe((d==null?void 0:d.traces)||[],e)}catch(u){throw u}},[t]),s=S.useCallback(u=>{u.length>0&&r(()=>u)},[]),o=S.useCallback(u=>{xn.error(u.message)},[]),a=S.useCallback(()=>!0,[]),{firstCallLoading:l,error:c}=Yxe({fetchFn:i,interval:3e3,onSuccess:s,onError:o,shouldContinue:a,enabled:!0});return{traces:n,firstCallLoading:l,error:c}};function b8({traces:t}){const{setTraces:e,trace:n}=S.useContext(Ls),r=(n==null?void 0:n.find(i=>i.parentSpanId===void 0))||(n==null?void 0:n[0]);return S.useEffect(()=>{e(t)},[t]),g.jsx("div",{className:"h-full w-[calc(100%_-_400px)]",children:g.jsx(zn,{className:"rounded-lg h-full",children:g.jsxs(xo,{children:[g.jsx(vo,{className:"bg-[#171717] sticky top-0 z-10",children:g.jsxs(dn,{className:"border-gray-6 border-b-[0.1px] text-[0.8125rem]",children:[g.jsx(yt,{className:"text-mastra-el-3",children:"Trace"}),g.jsxs(yt,{className:"text-mastra-el-3 flex items-center gap-1",children:[g.jsx(Zh,{className:"h-3 w-3"})," Trace Id"]}),g.jsx(yt,{className:"text-mastra-el-3",children:"Started"}),g.jsx(yt,{className:"text-mastra-el-3",children:"Total Duration"})]})}),g.jsx(wo,{className:"border-b border-gray-6",children:t.length?t.map((i,s)=>g.jsxs(dn,{className:ve("border-b-gray-6 border-b-[0.1px] text-[0.8125rem]",{"bg-muted/50":(r==null?void 0:r.traceId)===i.traceId}),children:[g.jsx(at,{children:g.jsx(Qxe,{trace:i.trace,name:i.serviceName,traceIndex:s,status:i.status})}),g.jsx(at,{className:"text-mastra-el-5",children:i.traceId}),g.jsx(at,{className:"text-mastra-el-5 text-sm",children:v8(i.started)}),g.jsx(at,{children:g.jsxs("span",{className:"inline-flex items-center gap-2 text-[#F1CA5E]",children:[g.jsx(lX,{className:"h-3 w-3"}),QA(i.duration,3),"ms"]})})]},i.traceId)):g.jsx(dn,{className:"border-b-gray-6 border-b-[0.1px] text-[0.8125rem]",children:g.jsx(at,{colSpan:4,className:"h-24 text-center",children:"No traces found"})})})]})})})}function Qxe({trace:t,name:e,traceIndex:n,status:r}){const{setTrace:i,isOpen:s,setIsOpen:o,trace:a,setSpan:l,setOpenDetail:c,setCurrentTraceIndex:u}=S.useContext(Ls);return g.jsxs(pt,{variant:"ghost",className:"flex h-0 items-center gap-2 p-0",onClick:()=>{var h;i(t);const d=t.find(m=>m.parentSpanId===null)||t[0];l(d),u(n),!(s&&((h=a==null?void 0:a[0])==null?void 0:h.id)!==t[0].id)&&(o(m=>!m),c(m=>!m))},children:[r.code===0?g.jsx("svg",{className:"h-3 w-3",xmlns:"http://www.w3.org/2000/svg",width:"13",height:"12",viewBox:"0 0 13 12",fill:"none",children:g.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M6.37695 12C9.69067 12 12.377 9.31371 12.377 6C12.377 2.68629 9.69067 0 6.37695 0C3.06325 0 0.376953 2.68629 0.376953 6C0.376953 9.31371 3.06325 12 6.37695 12ZM9.62004 4.65344C9.87907 4.36036 9.8651 3.90005 9.58884 3.6253C9.3125 3.35055 8.87861 3.3654 8.61958 3.65847L5.6477 7.02105L4.08967 5.55197C3.80661 5.28508 3.37319 5.31213 3.12159 5.61237C2.87 5.91262 2.89549 6.37239 3.17854 6.63927L4.90294 8.26517C5.36588 8.70171 6.07235 8.6676 6.49598 8.18829L9.62004 4.65344Z",fill:"#6CD063"})}):g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"#FF4500",width:"13",height:"12",children:g.jsx("path",{fillRule:"evenodd",d:"M12 2.25c-5.385 0-9.75 4.365-9.75 9.75s4.365 9.75 9.75 9.75 9.75-4.365 9.75-9.75S17.385 2.25 12 2.25Zm-1.72 6.97a.75.75 0 1 0-1.06 1.06L10.94 12l-1.72 1.72a.75.75 0 1 0 1.06 1.06L12 13.06l1.72 1.72a.75.75 0 1 0 1.06-1.06L13.06 12l1.72-1.72a.75.75 0 1 0-1.06-1.06L12 10.94l-1.72-1.72Z",clipRule:"evenodd"})}),g.jsx("span",{className:"truncate max-w-[150px]",children:e})]})}function k8({node:t,depth:e=0}){var d,h,m,y,v;const[n,r]=S.useState(!0),i=t.children&&t.children.length>0,{setOpenDetail:s,setSpan:o,openDetail:a,span:l}=S.useContext(Ls),c=S.useRef(null),u=Math.min(t.relativePercentage?(t==null?void 0:t.relativePercentage)*100:0,100);return g.jsxs("div",{ref:c,children:[g.jsxs(pt,{variant:"ghost",className:ve("relative flex w-full items-center justify-start gap-2 py-3 pr-1 text-sm",{"text-accent-foreground bg-accent":(l==null?void 0:l.id)===t.id}),onClick:w=>{w.preventDefault(),w.stopPropagation(),o(t),!(a&&t.id!==(l==null?void 0:l.id))&&s(!0)},style:{paddingLeft:`${e>0?e*35+28-e*3:24}px`},children:[i?g.jsx("div",{onClick:()=>r(!n),className:"relative grid h-auto flex-shrink-0 place-items-center rounded-sm bg-[#1a1a1a] p-2",children:g.jsx("svg",{className:ve("!h-2 !w-2 transition-transform",n?"":"-rotate-90"),xmlns:"http://www.w3.org/2000/svg",width:"7",height:"6",viewBox:"0 0 7 6",fill:"none",children:g.jsx("path",{d:"M3.9338 5.5C3.74135 5.83333 3.26022 5.83333 3.06777 5.5L0.469694 0.999999C0.277244 0.666666 0.517814 0.25 0.902714 0.25L6.09886 0.25C6.48376 0.25 6.72433 0.666666 6.53188 1L3.9338 5.5Z",fill:"#939393"})})}):null,g.jsxs("div",{className:"flex w-full gap-4 pr-4",children:[g.jsx("p",{className:ve("max-w-[250px] text-sm",{"text-white":((d=t==null?void 0:t.status)==null?void 0:d.code)===0,"text-[#FF4500]":((h=t==null?void 0:t.status)==null?void 0:h.code)!==0,"px-1":e===0,truncate:((m=c.current)==null?void 0:m.offsetWidth)&&((y=c.current)==null?void 0:y.offsetWidth)<450&&e>1&&((v=t.name)==null?void 0:v.length)>16}),children:t.name}),t.duration>0&&g.jsxs("div",{className:"relative w-full",children:[g.jsx("div",{className:"absolute top-[11px] h-px w-full bg-[hsl(220,14%,19%)]"}),g.jsx("div",{style:{width:`${u}%`,left:0},className:ve("absolute top-[9px] z-0 h-[5px] rounded-[5px] bg-white transition-all",t.name.includes("agent")&&"left-1/2 bg-green-500",t.name.includes("llm")&&"bg-[#5699A8]",t.name.includes("ai")&&"left-2/4 w-5 bg-[#F09A56]")}),g.jsxs("span",{className:"absolute left-0 top-3 text-[0.63rem] text-mastra-el-3",children:[QA(t.duration),"ms"]})]})]})]}),i&&n&&g.jsx(g.Fragment,{children:t.children.map(w=>g.jsx(k8,{node:w,depth:e+1},w.id))})]})}function Jxe({tree:t}){return g.jsx("ul",{children:t.map(e=>g.jsx(k8,{node:e},e.id))})}function S8(t,e=null){return t.filter(n=>n.parentSpanId===e).map(n=>({...n,children:S8(t,n.id)}))}function eve({trace:t}){const e=S8(t.concat([]).reverse());return g.jsx("div",{children:g.jsx(Jxe,{tree:e})})}function C8(){const{trace:t,currentTraceIndex:e,prevTrace:n,nextTrace:r,traces:i,clearData:s}=S.useContext(Ls);return g.jsxs("div",{children:[g.jsxs("div",{className:"flex items-center justify-between px-6 pt-[1.56rem]",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsxs("h3",{className:"text-[1.125rem]",children:["Trace Span",t!=null&&t.length&&t.length>1?"s":""]}),g.jsxs("span",{className:"text-xs text-mastra-el-3",children:[t!=null&&t.length?t.length:0," span",t!=null&&t.length&&t.length>1?"s":""]})]}),g.jsxs("div",{className:"flex items-center gap-4",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx(pt,{onClick:()=>{n()},disabled:e===0,variant:"secondary",size:"icon",className:"!h-3 !w-3 rotate-180 !px-3 py-3 text-mastra-el-3 transition-colors hover:text-white",children:g.jsx(Xh,{})})," ",g.jsx(pt,{onClick:()=>{r()},disabled:e===i.length-1,variant:"secondary",size:"icon",className:"!h-3 !w-3 !px-3 py-3 text-mastra-el-3 transition-colors hover:text-white",children:g.jsx(Xh,{})})]}),g.jsx("span",{className:"bg-secondary inline-block h-5 w-px"}),g.jsx(pt,{onClick:()=>{s()},variant:"secondary",size:"icon",className:"!h-3 !w-3 !px-3 py-3 text-mastra-el-3 transition-colors hover:text-white",children:g.jsx(Pl,{})})]})]}),g.jsxs("div",{className:"p-6 px-1",children:[" ",t&&g.jsx(eve,{trace:t})]})]})}const E8=1024;let tve=0,Sk=class{constructor(e,n){this.from=e,this.to=n}};class Tt{constructor(e={}){this.id=tve++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=fi.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}Tt.closedBy=new Tt({deserialize:t=>t.split(" ")});Tt.openedBy=new Tt({deserialize:t=>t.split(" ")});Tt.group=new Tt({deserialize:t=>t.split(" ")});Tt.isolate=new Tt({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}});Tt.contextHash=new Tt({perNode:!0});Tt.lookAhead=new Tt({perNode:!0});Tt.mounted=new Tt({perNode:!0});class ox{constructor(e,n,r){this.tree=e,this.overlay=n,this.parser=r}static get(e){return e&&e.props&&e.props[Tt.mounted.id]}}const nve=Object.create(null);class fi{constructor(e,n,r,i=0){this.name=e,this.props=n,this.id=r,this.flags=i}static define(e){let n=e.props&&e.props.length?Object.create(null):nve,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),i=new fi(e.name||"",n,e.id,r);if(e.props){for(let s of e.props)if(Array.isArray(s)||(s=s(i)),s){if(s[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[s[0].id]=s[1]}}return i}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(Tt.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let i of r.split(" "))n[i]=e[r];return r=>{for(let i=r.prop(Tt.group),s=-1;s<(i?i.length:0);s++){let o=n[s<0?r.name:i[s]];if(o)return o}}}}fi.none=new fi("",Object.create(null),0,8);class JA{constructor(e){this.types=e;for(let n=0;n<e.length;n++)if(e[n].id!=n)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let n=[];for(let r of this.types){let i=null;for(let s of e){let o=s(r);o&&(i||(i=Object.assign({},r.props)),i[o[0].id]=o[1])}n.push(i?new fi(r.name,i,r.id,r.flags):r)}return new JA(n)}}const wy=new WeakMap,oj=new WeakMap;var ar;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays"})(ar||(ar={}));class Bn{constructor(e,n,r,i,s){if(this.type=e,this.children=n,this.positions=r,this.length=i,this.props=null,s&&s.length){this.props=Object.create(null);for(let[o,a]of s)this.props[typeof o=="number"?o:o.id]=a}}toString(){let e=ox.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let i=r.toString();i&&(n&&(n+=","),n+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new EE(this.topNode,e)}cursorAt(e,n=0,r=0){let i=wy.get(this)||this.topNode,s=new EE(i);return s.moveTo(e,n),wy.set(this,s._tree),s}get topNode(){return new ts(this,0,0,null)}resolve(e,n=0){let r=Sp(wy.get(this)||this.topNode,e,n,!1);return wy.set(this,r),r}resolveInner(e,n=0){let r=Sp(oj.get(this)||this.topNode,e,n,!0);return oj.set(this,r),r}resolveStack(e,n=0){return sve(this,e,n)}iterate(e){let{enter:n,leave:r,from:i=0,to:s=this.length}=e,o=e.mode||0,a=(o&ar.IncludeAnonymous)>0;for(let l=this.cursor(o|ar.IncludeAnonymous);;){let c=!1;if(l.from<=s&&l.to>=i&&(!a&&l.type.isAnonymous||n(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&r&&(a||!l.type.isAnonymous)&&r(l),!l.nextSibling();){if(!l.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:n2(fi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new Bn(this.type,n,r,i,this.propValues),e.makeTree||((n,r,i)=>new Bn(fi.none,n,r,i)))}static build(e){return ove(e)}}Bn.empty=new Bn(fi.none,[],[],0);class e2{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new e2(this.buffer,this.index)}}class Cl{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return fi.none}toString(){let e=[];for(let n=0;n<this.buffer.length;)e.push(this.childString(n)),n=this.buffer[n+3];return e.join(",")}childString(e){let n=this.buffer[e],r=this.buffer[e+3],i=this.set.types[n],s=i.name;if(/\W/.test(s)&&!i.isError&&(s=JSON.stringify(s)),e+=4,r==e)return s;let o=[];for(;e<r;)o.push(this.childString(e)),e=this.buffer[e+3];return s+"("+o.join(",")+")"}findChild(e,n,r,i,s){let{buffer:o}=this,a=-1;for(let l=e;l!=n&&!(T8(s,i,o[l+1],o[l+2])&&(a=l,r>0));l=o[l+3]);return a}slice(e,n,r){let i=this.buffer,s=new Uint16Array(n-e),o=0;for(let a=e,l=0;a<n;){s[l++]=i[a++],s[l++]=i[a++]-r;let c=s[l++]=i[a++]-r;s[l++]=i[a++]-e,o=Math.max(o,c)}return new Cl(s,o,this.set)}}function T8(t,e,n,r){switch(t){case-2:return n<e;case-1:return r>=e&&n<e;case 0:return n<e&&r>e;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function Sp(t,e,n,r){for(var i;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to<e);){let o=!r&&t instanceof ts&&t.index<0?null:t.parent;if(!o)return t;t=o}let s=r?0:ar.IgnoreOverlays;if(r)for(let o=t,a=o.parent;a;o=a,a=o.parent)o instanceof ts&&o.index<0&&((i=a.enter(e,n,s))===null||i===void 0?void 0:i.from)!=o.from&&(t=a);for(;;){let o=t.enter(e,n,s);if(!o)return t;t=o}}class N8{cursor(e=0){return new EE(this,e)}getChild(e,n=null,r=null){let i=aj(this,e,n,r);return i.length?i[0]:null}getChildren(e,n=null,r=null){return aj(this,e,n,r)}resolve(e,n=0){return Sp(this,e,n,!1)}resolveInner(e,n=0){return Sp(this,e,n,!0)}matchContext(e){return CE(this.parent,e)}enterUnfinishedNodesBefore(e){let n=this.childBefore(e),r=this;for(;n;){let i=n.lastChild;if(!i||i.to!=n.to)break;i.type.isError&&i.from==i.to?(r=n,n=i.prevSibling):n=i}return r}get node(){return this}get next(){return this.parent}}class ts extends N8{constructor(e,n,r,i){super(),this._tree=e,this.from=n,this.index=r,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,n,r,i,s=0){for(let o=this;;){for(let{children:a,positions:l}=o._tree,c=n>0?a.length:-1;e!=c;e+=n){let u=a[e],d=l[e]+o.from;if(T8(i,r,d,d+u.length)){if(u instanceof Cl){if(s&ar.ExcludeBuffers)continue;let h=u.findChild(0,u.buffer.length,n,r-d,i);if(h>-1)return new ll(new rve(o,u,e,d),null,h)}else if(s&ar.IncludeAnonymous||!u.type.isAnonymous||t2(u)){let h;if(!(s&ar.IgnoreMounts)&&(h=ox.get(u))&&!h.overlay)return new ts(h.tree,d,e,o);let m=new ts(u,d,e,o);return s&ar.IncludeAnonymous||!m.type.isAnonymous?m:m.nextChild(n<0?u.children.length-1:0,n,r,i)}}}if(s&ar.IncludeAnonymous||!o.type.isAnonymous||(o.index>=0?e=o.index+n:e=n<0?-1:o._parent._tree.children.length,o=o._parent,!o))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}enter(e,n,r=0){let i;if(!(r&ar.IgnoreOverlays)&&(i=ox.get(this._tree))&&i.overlay){let s=e-this.from;for(let{from:o,to:a}of i.overlay)if((n>0?o<=s:o<s)&&(n<0?a>=s:a>s))return new ts(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function aj(t,e,n,r){let i=t.cursor(),s=[];if(!i.firstChild())return s;if(n!=null){for(let o=!1;!o;)if(o=i.type.is(n),!i.nextSibling())return s}for(;;){if(r!=null&&i.type.is(r))return s;if(i.type.is(e)&&s.push(i.node),!i.nextSibling())return r==null?s:[]}}function CE(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class rve{constructor(e,n,r,i){this.parent=e,this.buffer=n,this.index=r,this.start=i}}class ll extends N8{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-this.context.start,r);return s<0?null:new ll(this.context,this,s)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}enter(e,n,r=0){if(r&ar.ExcludeBuffers)return null;let{buffer:i}=this.context,s=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return s<0?null:new ll(this.context,this,s)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new ll(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new ll(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,i=this.index+4,s=r.buffer[this.index+3];if(s>i){let o=r.buffer[this.index+1];e.push(r.slice(i,s,o)),n.push(0)}return new Bn(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function A8(t){if(!t.length)return null;let e=0,n=t[0];for(let s=1;s<t.length;s++){let o=t[s];(o.from>n.from||o.to<n.to)&&(n=o,e=s)}let r=n instanceof ts&&n.index<0?null:n.parent,i=t.slice();return r?i[e]=r:i.splice(e,1),new ive(i,n)}class ive{constructor(e,n){this.heads=e,this.node=n}get next(){return A8(this.heads)}}function sve(t,e,n){let r=t.resolveInner(e,n),i=null;for(let s=r instanceof ts?r:r.context.parent;s;s=s.parent)if(s.index<0){let o=s.parent;(i||(i=[r])).push(o.resolve(e,n)),s=o}else{let o=ox.get(s.tree);if(o&&o.overlay&&o.overlay[0].from<=e&&o.overlay[o.overlay.length-1].to>=e){let a=new ts(o.tree,o.overlay[0].from+s.from,-1,s);(i||(i=[r])).push(Sp(a,e,n,!1))}}return i?A8(i):r}class EE{get name(){return this.type.name}constructor(e,n=0){if(this.mode=n,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof ts)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:i}=this.buffer;return this.type=n||i.set.types[i.buffer[e]],this.from=r+i.buffer[e+1],this.to=r+i.buffer[e+2],!0}yield(e){return e?e instanceof ts?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:i}=this.buffer,s=i.findChild(this.index+4,i.buffer[this.index+3],e,n-this.buffer.start,r);return s<0?!1:(this.stack.push(this.index),this.yieldBuf(s))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,r=this.mode){return this.buffer?r&ar.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ar.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&ar.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let i=r<0?0:this.stack[r]+4;if(this.index!=i)return this.yieldBuf(n.findChild(i,this.index,-1,0,4))}else{let i=n.buffer[this.index+3];if(i<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(i)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:i}=this;if(i){if(e>0){if(this.index<i.buffer.buffer.length)return!1}else for(let s=0;s<this.index;s++)if(i.buffer.buffer[s+3]<this.index)return!1;({index:n,parent:r}=i)}else({index:n,_parent:r}=this._tree);for(;r;{index:n,_parent:r}=r)if(n>-1)for(let s=n+e,o=e<0?-1:r._tree.children.length;s!=o;s+=e){let a=r._tree.children[s];if(this.mode&ar.IncludeAnonymous||a instanceof Cl||!a.type.isAnonymous||t2(a))return!1}return!0}move(e,n){if(n&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,n););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,n=null,r=0;if(e&&e.context==this.buffer)e:for(let i=this.index,s=this.stack.length;s>=0;){for(let o=e;o;o=o._parent)if(o.index==i){if(i==this.index)return o;n=o,r=s+1;break e}i=this.stack[--s]}for(let i=r;i<this.stack.length;i++)n=new ll(this.buffer,n,this.stack[i]);return this.bufferNode=new ll(this.buffer,n,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,n){for(let r=0;;){let i=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){r++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&n&&n(this),i=this.type.isAnonymous,!r)return;if(this.nextSibling())break;this.parent(),r--,i=!0}}}matchContext(e){if(!this.buffer)return CE(this.node.parent,e);let{buffer:n}=this.buffer,{types:r}=n.set;for(let i=e.length-1,s=this.stack.length-1;i>=0;s--){if(s<0)return CE(this._tree,e,i);let o=r[n.buffer[this.stack[s]]];if(!o.isAnonymous){if(e[i]&&e[i]!=o.name)return!1;i--}}return!0}}function t2(t){return t.children.some(e=>e instanceof Cl||!e.type.isAnonymous||t2(e))}function ove(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:i=E8,reused:s=[],minRepeatType:o=r.types.length}=t,a=Array.isArray(n)?new e2(n,n.length):n,l=r.types,c=0,u=0;function d(_,A,M,O,D,R){let{id:B,start:F,end:W,size:I}=a,Y=u,V=c;for(;I<0;)if(a.next(),I==-1){let q=s[B];M.push(q),O.push(F-_);return}else if(I==-3){c=B;return}else if(I==-4){u=B;return}else throw new RangeError(`Unrecognized record size: ${I}`);let G=l[B],H,z,L=F-_;if(W-F<=i&&(z=w(a.pos-A,D))){let q=new Uint16Array(z.size-z.skip),U=a.pos-z.size,j=q.length;for(;a.pos>U;)j=b(z.start,q,j);H=new Cl(q,W-z.start,r),L=z.start-_}else{let q=a.pos-I;a.next();let U=[],j=[],K=B>=o?B:-1,Z=0,J=W;for(;a.pos>q;)K>=0&&a.id==K&&a.size>=0?(a.end<=J-i&&(y(U,j,F,Z,a.end,J,K,Y,V),Z=U.length,J=a.end),a.next()):R>2500?h(F,q,U,j):d(F,q,U,j,K,R+1);if(K>=0&&Z>0&&Z<U.length&&y(U,j,F,Z,F,J,K,Y,V),U.reverse(),j.reverse(),K>-1&&Z>0){let X=m(G,V);H=n2(G,U,j,0,U.length,0,W-F,X,X)}else H=v(G,U,j,W-F,Y-W,V)}M.push(H),O.push(L)}function h(_,A,M,O){let D=[],R=0,B=-1;for(;a.pos>A;){let{id:F,start:W,end:I,size:Y}=a;if(Y>4)a.next();else{if(B>-1&&W<B)break;B<0&&(B=I-i),D.push(F,W,I),R++,a.next()}}if(R){let F=new Uint16Array(R*4),W=D[D.length-2];for(let I=D.length-3,Y=0;I>=0;I-=3)F[Y++]=D[I],F[Y++]=D[I+1]-W,F[Y++]=D[I+2]-W,F[Y++]=Y;M.push(new Cl(F,D[2]-W,r)),O.push(W-_)}}function m(_,A){return(M,O,D)=>{let R=0,B=M.length-1,F,W;if(B>=0&&(F=M[B])instanceof Bn){if(!B&&F.type==_&&F.length==D)return F;(W=F.prop(Tt.lookAhead))&&(R=O[B]+F.length+W)}return v(_,M,O,D,R,A)}}function y(_,A,M,O,D,R,B,F,W){let I=[],Y=[];for(;_.length>O;)I.push(_.pop()),Y.push(A.pop()+M-D);_.push(v(r.types[B],I,Y,R-D,F-R,W)),A.push(D-M)}function v(_,A,M,O,D,R,B){if(R){let F=[Tt.contextHash,R];B=B?[F].concat(B):[F]}if(D>25){let F=[Tt.lookAhead,D];B=B?[F].concat(B):[F]}return new Bn(_,A,M,O,B)}function w(_,A){let M=a.fork(),O=0,D=0,R=0,B=M.end-i,F={size:0,start:0,skip:0};e:for(let W=M.pos-_;M.pos>W;){let I=M.size;if(M.id==A&&I>=0){F.size=O,F.start=D,F.skip=R,R+=4,O+=4,M.next();continue}let Y=M.pos-I;if(I<0||Y<W||M.start<B)break;let V=M.id>=o?4:0,G=M.start;for(M.next();M.pos>Y;){if(M.size<0)if(M.size==-3)V+=4;else break e;else M.id>=o&&(V+=4);M.next()}D=G,O+=I,R+=V}return(A<0||O==_)&&(F.size=O,F.start=D,F.skip=R),F.size>4?F:void 0}function b(_,A,M){let{id:O,start:D,end:R,size:B}=a;if(a.next(),B>=0&&O<o){let F=M;if(B>4){let W=a.pos-(B-4);for(;a.pos>W;)M=b(_,A,M)}A[--M]=F,A[--M]=R-_,A[--M]=D-_,A[--M]=O}else B==-3?c=O:B==-4&&(u=O);return M}let k=[],C=[];for(;a.pos>0;)d(t.start||0,t.bufferStart||0,k,C,-1,0);let T=(e=t.length)!==null&&e!==void 0?e:k.length?C[0]+k[0].length:0;return new Bn(l[t.topID],k.reverse(),C.reverse(),T)}const lj=new WeakMap;function d0(t,e){if(!t.isAnonymous||e instanceof Cl||e.type!=t)return 1;let n=lj.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof Bn)){n=1;break}n+=d0(t,r)}lj.set(e,n)}return n}function n2(t,e,n,r,i,s,o,a,l){let c=0;for(let y=r;y<i;y++)c+=d0(t,e[y]);let u=Math.ceil(c*1.5/8),d=[],h=[];function m(y,v,w,b,k){for(let C=w;C<b;){let T=C,_=v[C],A=d0(t,y[C]);for(C++;C<b;C++){let M=d0(t,y[C]);if(A+M>=u)break;A+=M}if(C==T+1){if(A>u){let M=y[T];m(M.children,M.positions,0,M.children.length,v[T]+k);continue}d.push(y[T])}else{let M=v[C-1]+y[C-1].length-_;d.push(n2(t,y,v,T,C,_,M,null,l))}h.push(_+k-s)}}return m(e,n,r,i,0),(a||l)(d,h,o)}class wc{constructor(e,n,r,i,s=!1,o=!1){this.from=e,this.to=n,this.tree=r,this.offset=i,this.open=(s?1:0)|(o?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let i=[new wc(0,e.length,e,0,!1,r)];for(let s of n)s.to>e.length&&i.push(s);return i}static applyChanges(e,n,r=128){if(!n.length)return e;let i=[],s=1,o=e.length?e[0]:null;for(let a=0,l=0,c=0;;a++){let u=a<n.length?n[a]:null,d=u?u.fromA:1e9;if(d-l>=r)for(;o&&o.from<d;){let h=o;if(l>=h.from||d<=h.to||c){let m=Math.max(h.from,l)-c,y=Math.min(h.to,d)-c;h=m>=y?null:new wc(m,y,h.tree,h.offset+c,a>0,!!u)}if(h&&i.push(h),o.to>d)break;o=s<e.length?e[s++]:null}if(!u)break;l=u.toA,c=u.toA-u.toB}return i}}class _8{startParse(e,n,r){return typeof e=="string"&&(e=new ave(e)),r=r?r.length?r.map(i=>new Sk(i.from,i.to)):[new Sk(0,0)]:[new Sk(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let i=this.startParse(e,n,r);for(;;){let s=i.advance();if(s)return s}}}class ave{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new Tt({perNode:!0});var cj={};class ax{constructor(e,n,r,i,s,o,a,l,c,u=0,d){this.p=e,this.stack=n,this.state=r,this.reducePos=i,this.pos=s,this.score=o,this.buffer=a,this.bufferBase=l,this.curContext=c,this.lookAhead=u,this.parent=d}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,r=0){let i=e.parser.context;return new ax(e,[],n,r,r,0,[],0,i?new uj(i,i.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let r=e>>19,i=e&65535,{parser:s}=this.p,o=this.reducePos<this.pos-25;o&&this.setLookAhead(this.pos);let a=s.dynamicPrecedence(i);if(a&&(this.score+=a),r==0){this.pushState(s.getGoto(this.state,i,!0),this.reducePos),i<s.minRepeatTerm&&this.storeNode(i,this.reducePos,this.reducePos,o?8:4,!0),this.reduceContext(i,this.reducePos);return}let l=this.stack.length-(r-1)*3-(e&262144?6:0),c=l?this.stack[l-2]:this.p.ranges[0].from,u=this.reducePos-c;u>=2e3&&!(!((n=this.p.parser.nodeSet.types[i])===null||n===void 0)&&n.isAnonymous)&&(c==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=u):this.p.lastBigReductionSize<u&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=c,this.p.lastBigReductionSize=u));let d=l?this.stack[l-1]:0,h=this.bufferBase+this.buffer.length-d;if(i<s.minRepeatTerm||e&131072){let m=s.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(i,c,m,h+4,!0)}if(e&262144)this.state=this.stack[l];else{let m=this.stack[l-3];this.state=s.getGoto(m,i,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(i,c)}storeNode(e,n,r,i=4,s=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let o=this,a=this.buffer.length;if(a==0&&o.parent&&(a=o.bufferBase-o.parent.bufferBase,o=o.parent),a>0&&o.buffer[a-4]==0&&o.buffer[a-1]>-1){if(n==r)return;if(o.buffer[a-2]>=n){o.buffer[a-2]=r;return}}}if(!s||this.pos==r)this.buffer.push(e,n,r,i);else{let o=this.buffer.length;if(o>0&&this.buffer[o-4]!=0){let a=!1;for(let l=o;l>0&&this.buffer[l-2]>r;l-=4)if(this.buffer[l-1]>=0){a=!0;break}if(a)for(;o>0&&this.buffer[o-2]>r;)this.buffer[o]=this.buffer[o-4],this.buffer[o+1]=this.buffer[o-3],this.buffer[o+2]=this.buffer[o-2],this.buffer[o+3]=this.buffer[o-1],o-=4,i>4&&(i-=4)}this.buffer[o]=e,this.buffer[o+1]=n,this.buffer[o+2]=r,this.buffer[o+3]=i}}shift(e,n,r,i){if(e&131072)this.pushState(e&65535,this.pos);else if(e&262144)this.pos=i,this.shiftContext(n,r),n<=this.p.parser.maxNode&&this.buffer.push(n,r,i,4);else{let s=e,{parser:o}=this.p;(i>this.pos||n<=o.maxNode)&&(this.pos=i,o.stateFlag(s,1)||(this.reducePos=i)),this.pushState(s,r),this.shiftContext(n,r),n<=o.maxNode&&this.buffer.push(n,r,i,4)}}apply(e,n,r,i){e&65536?this.reduce(e):this.shift(e,n,r,i)}useNode(e,n){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=e)&&(this.p.reused.push(e),r++);let i=this.pos;this.reducePos=this.pos=i+e.length,this.pushState(n,i),this.buffer.push(r,i,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,n=e.buffer.length;for(;n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let r=e.buffer.slice(n),i=e.bufferBase+n;for(;e&&i==e.bufferBase;)e=e.parent;return new ax(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,i,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let r=e<=this.p.parser.maxNode;r&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,r?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new lve(this);;){let r=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(r==0)return!1;if(!(r&65536))return!0;n.reduce(r)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let i=[];for(let s=0,o;s<n.length;s+=2)(o=n[s+1])!=this.state&&this.p.parser.hasAction(o,e)&&i.push(n[s],o);if(this.stack.length<120)for(let s=0;i.length<8&&s<n.length;s+=2){let o=n[s+1];i.some((a,l)=>l&1&&a==o)||i.push(n[s],o)}n=i}let r=[];for(let i=0;i<n.length&&r.length<4;i+=2){let s=n[i+1];if(s==this.state)continue;let o=this.split();o.pushState(s,this.pos),o.storeNode(0,o.pos,o.pos,4,!0),o.shiftContext(n[i],this.pos),o.reducePos=this.pos,o.score-=200,r.push(o)}return r}forceReduce(){let{parser:e}=this.p,n=e.stateSlot(this.state,5);if(!(n&65536))return!1;if(!e.validAction(this.state,n)){let r=n>>19,i=n&65535,s=this.stack.length-r*3;if(s<0||e.getGoto(this.stack[s],i,!1)<0){let o=this.findForcedReduction();if(o==null)return!1;n=o}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],r=(i,s)=>{if(!n.includes(i))return n.push(i),e.allActions(i,o=>{if(!(o&393216))if(o&65536){let a=(o>>19)-s;if(a>1){let l=o&65535,c=this.stack.length-a*3;if(c>=0&&e.getGoto(this.stack[c],l,!1)>=0)return a<<19|65536|l}}else{let a=r(o,s+1);if(a!=null)return a}})};return r(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let n=0;n<this.stack.length;n+=3)if(this.stack[n]!=e.stack[n])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(n)))}reduceContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(n)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let n=new uj(this.curContext.tracker,e);n.hash!=this.curContext.hash&&this.emitContext(),this.curContext=n}}setLookAhead(e){e>this.lookAhead&&(this.emitLookAhead(),this.lookAhead=e)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class uj{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class lve{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,r=e>>19;r==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(r-1)*3;let i=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=i}}class lx{constructor(e,n,r){this.stack=e,this.pos=n,this.index=r,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new lx(e,n,n-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new lx(this.stack,this.pos,this.index)}}function by(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let r=0,i=0;r<t.length;){let s=0;for(;;){let o=t.charCodeAt(r++),a=!1;if(o==126){s=65535;break}o>=92&&o--,o>=34&&o--;let l=o-32;if(l>=46&&(l-=46,a=!0),s+=l,a)break;s*=46}n?n[i++]=s:n=new e(s)}return n}class f0{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const dj=new f0;class cve{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=dj,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let r=this.range,i=this.rangeIndex,s=this.pos+e;for(;s<r.from;){if(!i)return null;let o=this.ranges[--i];s-=r.from-o.to,r=o}for(;n<0?s>r.to:s>=r.to;){if(i==this.ranges.length-1)return null;let o=this.ranges[++i];s+=o.from-r.to,r=o}return s}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let n of this.ranges)if(n.to>e)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,r,i;if(n>=0&&n<this.chunk.length)r=this.pos+e,i=this.chunk.charCodeAt(n);else{let s=this.resolveOffset(e,1);if(s==null)return-1;if(r=s,r>=this.chunk2Pos&&r<this.chunk2Pos+this.chunk2.length)i=this.chunk2.charCodeAt(r-this.chunk2Pos);else{let o=this.rangeIndex,a=this.range;for(;a.to<=r;)a=this.ranges[++o];this.chunk2=this.input.chunk(this.chunk2Pos=r),r+this.chunk2.length>a.to&&(this.chunk2=this.chunk2.slice(0,a.to-r)),i=this.chunk2.charCodeAt(0)}}return r>=this.token.lookAhead&&(this.token.lookAhead=r+1),i}acceptToken(e,n=0){let r=n?this.resolveOffset(n,-1):this.pos;if(r==null||r<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=r}acceptTokenTo(e,n){this.token.value=e,this.token.end=n}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:n}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=n,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),n=this.pos+e.length;this.chunk=n>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=dj,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,n){if(e>=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let r="";for(let i of this.ranges){if(i.from>=n)break;i.to>e&&(r+=this.input.read(Math.max(i.from,e),Math.min(i.to,n)))}return r}}class ed{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:r}=n.p;uve(this.data,e,n,this.id,r.data,r.tokenPrecTable)}}ed.prototype.contextual=ed.prototype.fallback=ed.prototype.extend=!1;ed.prototype.fallback=ed.prototype.extend=!1;function uve(t,e,n,r,i,s){let o=0,a=1<<r,{dialect:l}=n.p.parser;e:for(;a&t[o];){let c=t[o+1];for(let m=o+3;m<c;m+=2)if((t[m+1]&a)>0){let y=t[m];if(l.allows(y)&&(e.token.value==-1||e.token.value==y||dve(y,e.token.value,i,s))){e.acceptToken(y);break}}let u=e.next,d=0,h=t[o+2];if(e.next<0&&h>d&&t[c+h*3-3]==65535){o=t[c+h*3-1];continue e}for(;d<h;){let m=d+h>>1,y=c+m+(m<<1),v=t[y],w=t[y+1]||65536;if(u<v)h=m;else if(u>=w)d=m+1;else{o=t[y+2],e.advance();continue e}}break}}function fj(t,e,n){for(let r=e,i;(i=t[r])!=65535;r++)if(i==n)return r-e;return-1}function dve(t,e,n,r){let i=fj(n,r,e);return i<0||fj(n,r,t)<i}const wi=typeof process<"u"&&cj&&/\bparse\b/.test(cj.LOG);let Ck=null;function hj(t,e,n){let r=t.cursor(ar.IncludeAnonymous);for(r.moveTo(e);;)if(!(n<0?r.childBefore(e):r.childAfter(e)))for(;;){if((n<0?r.to<e:r.from>e)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,e-25)):Math.min(t.length,Math.max(r.from+1,e+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:t.length}}class fve{constructor(e,n){this.fragments=e,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?hj(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?hj(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let n=this.trees.length-1;if(n<0)return this.nextFragment(),null;let r=this.trees[n],i=this.index[n];if(i==r.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let s=r.children[i],o=this.start[n]+r.positions[i];if(o>e)return this.nextStart=o,null;if(s instanceof Bn){if(o==e){if(o<this.safeFrom)return null;let a=o+s.length;if(a<=this.safeTo){let l=s.prop(Tt.lookAhead);if(!l||a+l<this.fragment.to)return s}}this.index[n]++,o+s.length>=Math.max(this.safeFrom,e)&&(this.trees.push(s),this.start.push(o),this.index.push(0))}else this.index[n]++,this.nextStart=o+s.length}}}class hve{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new f0)}getActions(e){let n=0,r=null,{parser:i}=e.p,{tokenizers:s}=i,o=i.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,l=0;for(let c=0;c<s.length;c++){if(!(1<<c&o))continue;let u=s[c],d=this.tokens[c];if(!(r&&!u.fallback)&&((u.contextual||d.start!=e.pos||d.mask!=o||d.context!=a)&&(this.updateCachedToken(d,u,e),d.mask=o,d.context=a),d.lookAhead>d.end+25&&(l=Math.max(d.lookAhead,l)),d.value!=0)){let h=n;if(d.extended>-1&&(n=this.addActions(e,d.extended,d.end,n)),n=this.addActions(e,d.value,d.end,n),!u.extend&&(r=d,n>h))break}}for(;this.actions.length>n;)this.actions.pop();return l&&e.setLookAhead(l),!r&&e.pos==this.stream.end&&(r=new f0,r.value=e.p.parser.eofTerm,r.start=r.end=e.pos,n=this.addActions(e,r.value,r.end,n)),this.mainToken=r,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new f0,{pos:r,p:i}=e;return n.start=r,n.end=Math.min(r+1,i.stream.end),n.value=r==i.stream.end?i.parser.eofTerm:0,n}updateCachedToken(e,n,r){let i=this.stream.clipPos(r.pos);if(n.token(this.stream.reset(i,e),r),e.value>-1){let{parser:s}=r.p;for(let o=0;o<s.specialized.length;o++)if(s.specialized[o]==e.value){let a=s.specializers[o](this.stream.read(e.start,e.end),r);if(a>=0&&r.p.parser.dialect.allows(a>>1)){a&1?e.extended=a>>1:e.value=a>>1;break}}}else e.value=0,e.end=this.stream.clipPos(i+1)}putAction(e,n,r,i){for(let s=0;s<i;s+=3)if(this.actions[s]==e)return i;return this.actions[i++]=e,this.actions[i++]=n,this.actions[i++]=r,i}addActions(e,n,r,i){let{state:s}=e,{parser:o}=e.p,{data:a}=o;for(let l=0;l<2;l++)for(let c=o.stateSlot(s,l?2:1);;c+=3){if(a[c]==65535)if(a[c+1]==1)c=Zo(a,c+2);else{i==0&&a[c+1]==2&&(i=this.putAction(Zo(a,c+2),n,r,i));break}a[c]==n&&(i=this.putAction(Zo(a,c+1),n,r,i))}return i}}class pve{constructor(e,n,r,i){this.parser=e,this.input=n,this.ranges=i,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new cve(n,i),this.tokens=new hve(e,this.stream),this.topTerm=e.top[1];let{from:s}=i[0];this.stacks=[ax.start(this,e.top[0],s)],this.fragments=r.length&&this.stream.end-s>e.bufferLength*4?new fve(r,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,r=this.stacks=[],i,s;if(this.bigReductionCount>300&&e.length==1){let[o]=e;for(;o.forceReduce()&&o.stack.length&&o.stack[o.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let o=0;o<e.length;o++){let a=e[o];for(;;){if(this.tokens.mainToken=null,a.pos>n)r.push(a);else{if(this.advanceStack(a,r,e))continue;{i||(i=[],s=[]),i.push(a);let l=this.tokens.getMainToken(a);s.push(l.value,l.end)}}break}}if(!r.length){let o=i&&gve(i);if(o)return wi&&console.log("Finish with "+this.stackID(o)),this.stackToTree(o);if(this.parser.strict)throw wi&&i&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&i){let o=this.stoppedAt!=null&&i[0].pos>this.stoppedAt?i[0]:this.runRecovery(i,s,r);if(o)return wi&&console.log("Force-finish "+this.stackID(o)),this.stackToTree(o.forceAll())}if(this.recovering){let o=this.recovering==1?1:this.recovering*3;if(r.length>o)for(r.sort((a,l)=>l.score-a.score);r.length>o;)r.pop();r.some(a=>a.reducePos>n)&&this.recovering--}else if(r.length>1){e:for(let o=0;o<r.length-1;o++){let a=r[o];for(let l=o+1;l<r.length;l++){let c=r[l];if(a.sameState(c)||a.buffer.length>500&&c.buffer.length>500)if((a.score-c.score||a.buffer.length-c.buffer.length)>0)r.splice(l--,1);else{r.splice(o--,1);continue e}}}r.length>12&&r.splice(12,r.length-12)}this.minStackPos=r[0].pos;for(let o=1;o<r.length;o++)r[o].pos<this.minStackPos&&(this.minStackPos=r[o].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,n,r){let i=e.pos,{parser:s}=this,o=wi?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&i>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,u=c?e.curContext.hash:0;for(let d=this.fragments.nodeAt(i);d;){let h=this.parser.nodeSet.types[d.type.id]==d.type?s.getGoto(e.state,d.type.id):-1;if(h>-1&&d.length&&(!c||(d.prop(Tt.contextHash)||0)==u))return e.useNode(d,h),wi&&console.log(o+this.stackID(e)+` (via reuse of ${s.getName(d.type.id)})`),!0;if(!(d instanceof Bn)||d.children.length==0||d.positions[0]>0)break;let m=d.children[0];if(m instanceof Bn&&d.positions[0]==0)d=m;else break}}let a=s.stateSlot(e.state,4);if(a>0)return e.reduce(a),wi&&console.log(o+this.stackID(e)+` (via always-reduce ${s.getName(a&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let c=0;c<l.length;){let u=l[c++],d=l[c++],h=l[c++],m=c==l.length||!r,y=m?e:e.split(),v=this.tokens.mainToken;if(y.apply(u,d,v?v.start:y.pos,h),wi&&console.log(o+this.stackID(y)+` (via ${u&65536?`reduce of ${s.getName(u&65535)}`:"shift"} for ${s.getName(d)} @ ${i}${y==e?"":", split"})`),m)return!0;y.pos>i?n.push(y):r.push(y)}return!1}advanceFully(e,n){let r=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>r)return pj(e,n),!0}}runRecovery(e,n,r){let i=null,s=!1;for(let o=0;o<e.length;o++){let a=e[o],l=n[o<<1],c=n[(o<<1)+1],u=wi?this.stackID(a)+" -> ":"";if(a.deadEnd&&(s||(s=!0,a.restart(),wi&&console.log(u+this.stackID(a)+" (restarted)"),this.advanceFully(a,r))))continue;let d=a.split(),h=u;for(let m=0;d.forceReduce()&&m<10&&(wi&&console.log(h+this.stackID(d)+" (via force-reduce)"),!this.advanceFully(d,r));m++)wi&&(h=this.stackID(d)+" -> ");for(let m of a.recoverByInsert(l))wi&&console.log(u+this.stackID(m)+" (via recover-insert)"),this.advanceFully(m,r);this.stream.end>a.pos?(c==a.pos&&(c++,l=0),a.recoverByDelete(l,c),wi&&console.log(u+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),pj(a,r)):(!i||i.score<a.score)&&(i=a)}return i}stackToTree(e){return e.close(),Bn.build({buffer:lx.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let n=(Ck||(Ck=new WeakMap)).get(e);return n||Ck.set(e,n=String.fromCodePoint(this.nextStackID++)),n+e}}function pj(t,e){for(let n=0;n<e.length;n++){let r=e[n];if(r.pos==t.pos&&r.sameState(t)){e[n].score<t.score&&(e[n]=t);return}}e.push(t)}class mve{constructor(e,n,r){this.source=e,this.flags=n,this.disabled=r}allows(e){return!this.disabled||this.disabled[e]==0}}class cx extends _8{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let n=e.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let a=0;a<e.repeatNodeCount;a++)n.push("");let r=Object.keys(e.topRules).map(a=>e.topRules[a][1]),i=[];for(let a=0;a<n.length;a++)i.push([]);function s(a,l,c){i[a].push([l,l.deserialize(String(c))])}if(e.nodeProps)for(let a of e.nodeProps){let l=a[0];typeof l=="string"&&(l=Tt[l]);for(let c=1;c<a.length;){let u=a[c++];if(u>=0)s(u,l,a[c++]);else{let d=a[c+-u];for(let h=-u;h>0;h--)s(a[c++],l,d);c++}}}this.nodeSet=new JA(n.map((a,l)=>fi.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:i[l],top:r.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=E8;let o=by(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;a<this.specializerSpecs.length;a++)this.specialized[a]=this.specializerSpecs[a].term;this.specializers=this.specializerSpecs.map(mj),this.states=by(e.states,Uint32Array),this.data=by(e.stateData),this.goto=by(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(a=>typeof a=="number"?new ed(o,a):a),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,n,r){let i=new pve(this,e,n,r);for(let s of this.wrappers)i=s(i,e,n,r);return i}getGoto(e,n,r=!1){let i=this.goto;if(n>=i[0])return-1;for(let s=i[n+1];;){let o=i[s++],a=o&1,l=i[s++];if(a&&r)return l;for(let c=s+(o>>1);s<c;s++)if(i[s]==e)return l;if(a)return-1}}hasAction(e,n){let r=this.data;for(let i=0;i<2;i++)for(let s=this.stateSlot(e,i?2:1),o;;s+=3){if((o=r[s])==65535)if(r[s+1]==1)o=r[s=Zo(r,s+2)];else{if(r[s+1]==2)return Zo(r,s+2);break}if(o==n||o==0)return Zo(r,s+1)}return 0}stateSlot(e,n){return this.states[e*6+n]}stateFlag(e,n){return(this.stateSlot(e,0)&n)>0}validAction(e,n){return!!this.allActions(e,r=>r==n?!0:null)}allActions(e,n){let r=this.stateSlot(e,4),i=r?n(r):void 0;for(let s=this.stateSlot(e,1);i==null;s+=3){if(this.data[s]==65535)if(this.data[s+1]==1)s=Zo(this.data,s+2);else break;i=n(Zo(this.data,s+1))}return i}nextStates(e){let n=[];for(let r=this.stateSlot(e,1);;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=Zo(this.data,r+2);else break;if(!(this.data[r+2]&1)){let i=this.data[r+1];n.some((s,o)=>o&1&&s==i)||n.push(this.data[r],i)}}return n}configure(e){let n=Object.assign(Object.create(cx.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let r=this.topRules[e.top];if(!r)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=r}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(r=>{let i=e.tokenizers.find(s=>s.from==r);return i?i.to:r})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((r,i)=>{let s=e.specializers.find(a=>a.from==r.external);if(!s)return r;let o=Object.assign(Object.assign({},r),{external:s.to});return n.specializers[i]=mj(o),o})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),r=n.map(()=>!1);if(e)for(let s of e.split(" ")){let o=n.indexOf(s);o>=0&&(r[o]=!0)}let i=null;for(let s=0;s<n.length;s++)if(!r[s])for(let o=this.dialects[n[s]],a;(a=this.data[o++])!=65535;)(i||(i=new Uint8Array(this.maxTerm+1)))[a]=1;return new mve(e,r,i)}static deserialize(e){return new cx(e)}}function Zo(t,e){return t[e]|t[e+1]<<16}function gve(t){let e=null;for(let n of t){let r=n.p.stoppedAt;(n.pos==n.p.stream.end||r!=null&&n.pos>r)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.score<n.score)&&(e=n)}return e}function mj(t){if(t.external){let e=t.extend?1:0;return(n,r)=>t.external(n,r)<<1|e}return t.get}let yve=0;class Zi{constructor(e,n,r,i){this.name=e,this.set=n,this.base=r,this.modified=i,this.id=yve++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof Zi&&(n=e),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let i=new Zi(r,[],null,[]);if(i.set.push(i),n)for(let s of n.set)i.set.push(s);return i}static defineModifier(e){let n=new ux(e);return r=>r.modified.indexOf(n)>-1?r:ux.get(r.base||r,r.modified.concat(n).sort((i,s)=>i.id-s.id))}}let xve=0;class ux{constructor(e){this.name=e,this.instances=[],this.id=xve++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(a=>a.base==e&&vve(n,a.modified));if(r)return r;let i=[],s=new Zi(e.name,i,e,n);for(let a of n)a.instances.push(s);let o=wve(n);for(let a of e.set)if(!a.modified.length)for(let l of o)i.push(ux.get(a,l));return s}}function vve(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function wve(t){let e=[[]];for(let n=0;n<t.length;n++)for(let r=0,i=e.length;r<i;r++)e.push(e[r].concat(t[n]));return e.sort((n,r)=>r.length-n.length)}function M8(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let i of n.split(" "))if(i){let s=[],o=2,a=i;for(let d=0;;){if(a=="..."&&d>0&&d+3==i.length){o=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!h)throw new RangeError("Invalid path: "+i);if(s.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),d+=h[0].length,d==i.length)break;let m=i[d++];if(d==i.length&&m=="!"){o=0;break}if(m!="/")throw new RangeError("Invalid path: "+i);a=i.slice(d)}let l=s.length-1,c=s[l];if(!c)throw new RangeError("Invalid path: "+i);let u=new dx(r,o,l>0?s.slice(0,l):null);e[c]=u.sort(e[c])}}return P8.add(e)}const P8=new Tt;class dx{constructor(e,n,r,i){this.tags=e,this.mode=n,this.context=r,this.next=i}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}dx.empty=new dx([],2,null);function O8(t,e){let n=Object.create(null);for(let s of t)if(!Array.isArray(s.tag))n[s.tag.id]=s.class;else for(let o of s.tag)n[o.id]=s.class;let{scope:r,all:i=null}=e||{};return{style:s=>{let o=i;for(let a of s)for(let l of a.set){let c=n[l.id];if(c){o=o?o+" "+c:c;break}}return o},scope:r}}function bve(t,e){let n=null;for(let r of t){let i=r.style(e);i&&(n=n?n+" "+i:i)}return n}function kve(t,e,n,r=0,i=t.length){let s=new Sve(r,Array.isArray(e)?e:[e],n);s.highlightRange(t.cursor(),r,i,"",s.highlighters),s.flush(i)}class Sve{constructor(e,n,r){this.at=e,this.highlighters=n,this.span=r,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,r,i,s){let{type:o,from:a,to:l}=e;if(a>=r||l<=n)return;o.isTop&&(s=this.highlighters.filter(m=>!m.scope||m.scope(o)));let c=i,u=Cve(e)||dx.empty,d=bve(s,u.tags);if(d&&(c&&(c+=" "),c+=d,u.mode==1&&(i+=(i?" ":"")+d)),this.startSpan(Math.max(n,a),c),u.opaque)return;let h=e.tree&&e.tree.prop(Tt.mounted);if(h&&h.overlay){let m=e.node.enter(h.overlay[0].from+a,1),y=this.highlighters.filter(w=>!w.scope||w.scope(h.tree.type)),v=e.firstChild();for(let w=0,b=a;;w++){let k=w<h.overlay.length?h.overlay[w]:null,C=k?k.from+a:l,T=Math.max(n,b),_=Math.min(r,C);if(T<_&&v)for(;e.from<_&&(this.highlightRange(e,T,_,i,s),this.startSpan(Math.min(_,e.to),c),!(e.to>=C||!e.nextSibling())););if(!k||C>r)break;b=k.to+a,b>n&&(this.highlightRange(m.cursor(),Math.max(n,k.from+a),Math.min(r,b),"",y),this.startSpan(Math.min(r,b),c))}v&&e.parent()}else if(e.firstChild()){h&&(i="");do if(!(e.to<=n)){if(e.from>=r)break;this.highlightRange(e,n,r,i,s),this.startSpan(Math.min(r,e.to),c)}while(e.nextSibling());e.parent()}}}function Cve(t){let e=t.type.prop(P8);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const De=Zi.define,ky=De(),tl=De(),gj=De(tl),yj=De(tl),nl=De(),Sy=De(nl),Ek=De(nl),Ks=De(),rc=De(Ks),Us=De(),qs=De(),TE=De(),eh=De(TE),Cy=De(),re={comment:ky,lineComment:De(ky),blockComment:De(ky),docComment:De(ky),name:tl,variableName:De(tl),typeName:gj,tagName:De(gj),propertyName:yj,attributeName:De(yj),className:De(tl),labelName:De(tl),namespace:De(tl),macroName:De(tl),literal:nl,string:Sy,docString:De(Sy),character:De(Sy),attributeValue:De(Sy),number:Ek,integer:De(Ek),float:De(Ek),bool:De(nl),regexp:De(nl),escape:De(nl),color:De(nl),url:De(nl),keyword:Us,self:De(Us),null:De(Us),atom:De(Us),unit:De(Us),modifier:De(Us),operatorKeyword:De(Us),controlKeyword:De(Us),definitionKeyword:De(Us),moduleKeyword:De(Us),operator:qs,derefOperator:De(qs),arithmeticOperator:De(qs),logicOperator:De(qs),bitwiseOperator:De(qs),compareOperator:De(qs),updateOperator:De(qs),definitionOperator:De(qs),typeOperator:De(qs),controlOperator:De(qs),punctuation:TE,separator:De(TE),bracket:eh,angleBracket:De(eh),squareBracket:De(eh),paren:De(eh),brace:De(eh),content:Ks,heading:rc,heading1:De(rc),heading2:De(rc),heading3:De(rc),heading4:De(rc),heading5:De(rc),heading6:De(rc),contentSeparator:De(Ks),list:De(Ks),quote:De(Ks),emphasis:De(Ks),strong:De(Ks),link:De(Ks),monospace:De(Ks),strikethrough:De(Ks),inserted:De(),deleted:De(),changed:De(),invalid:De(),meta:Cy,documentMeta:De(Cy),annotation:De(Cy),processingInstruction:De(Cy),definition:Zi.defineModifier("definition"),constant:Zi.defineModifier("constant"),function:Zi.defineModifier("function"),standard:Zi.defineModifier("standard"),local:Zi.defineModifier("local"),special:Zi.defineModifier("special")};for(let t in re){let e=re[t];e instanceof Zi&&(e.name=t)}O8([{tag:re.link,class:"tok-link"},{tag:re.heading,class:"tok-heading"},{tag:re.emphasis,class:"tok-emphasis"},{tag:re.strong,class:"tok-strong"},{tag:re.keyword,class:"tok-keyword"},{tag:re.atom,class:"tok-atom"},{tag:re.bool,class:"tok-bool"},{tag:re.url,class:"tok-url"},{tag:re.labelName,class:"tok-labelName"},{tag:re.inserted,class:"tok-inserted"},{tag:re.deleted,class:"tok-deleted"},{tag:re.literal,class:"tok-literal"},{tag:re.string,class:"tok-string"},{tag:re.number,class:"tok-number"},{tag:[re.regexp,re.escape,re.special(re.string)],class:"tok-string2"},{tag:re.variableName,class:"tok-variableName"},{tag:re.local(re.variableName),class:"tok-variableName tok-local"},{tag:re.definition(re.variableName),class:"tok-variableName tok-definition"},{tag:re.special(re.variableName),class:"tok-variableName2"},{tag:re.definition(re.propertyName),class:"tok-propertyName tok-definition"},{tag:re.typeName,class:"tok-typeName"},{tag:re.namespace,class:"tok-namespace"},{tag:re.className,class:"tok-className"},{tag:re.macroName,class:"tok-macroName"},{tag:re.propertyName,class:"tok-propertyName"},{tag:re.operator,class:"tok-operator"},{tag:re.comment,class:"tok-comment"},{tag:re.meta,class:"tok-meta"},{tag:re.invalid,class:"tok-invalid"},{tag:re.punctuation,class:"tok-punctuation"}]);const Eve=M8({String:re.string,Number:re.number,"True False":re.bool,PropertyName:re.propertyName,Null:re.null,", :":re.separator,"[ ]":re.squareBracket,"{ }":re.brace}),Tve=cx.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[Eve],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0});let NE=[],R8=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e<t.length;e++)(e%2?R8:NE).push(n=n+t[e])})();function Nve(t){if(t<768)return!1;for(let e=0,n=NE.length;;){let r=e+n>>1;if(t<NE[r])n=r;else if(t>=R8[r])e=r+1;else return!0;if(e==n)return!1}}function xj(t){return t>=127462&&t<=127487}const vj=8205;function Ave(t,e,n=!0,r=!0){return(n?D8:_ve)(t,e,r)}function D8(t,e,n){if(e==t.length)return e;e&&j8(t.charCodeAt(e))&&I8(t.charCodeAt(e-1))&&e--;let r=Tk(t,e);for(e+=wj(r);e<t.length;){let i=Tk(t,e);if(r==vj||i==vj||n&&Nve(i))e+=wj(i),r=i;else if(xj(i)){let s=0,o=e-2;for(;o>=0&&xj(Tk(t,o));)s++,o-=2;if(s%2==0)break;e+=2}else break}return e}function _ve(t,e,n){for(;e>0;){let r=D8(t,e-2,n);if(r<e)return r;e--}return 0}function Tk(t,e){let n=t.charCodeAt(e);if(!I8(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return j8(r)?(n-55296<<10)+(r-56320)+65536:n}function j8(t){return t>=56320&&t<57344}function I8(t){return t>=55296&&t<56320}function wj(t){return t<65536?1:2}let Vt=class L8{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=Sd(this,e,n);let i=[];return this.decompose(0,e,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),Js.from(i,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=Sd(this,e,n);let r=[];return this.decompose(e,n,r,0),Js.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),i=new Lh(this),s=new Lh(e);for(let o=n,a=n;;){if(i.next(o),s.next(o),o=0,i.lineBreak!=s.lineBreak||i.done!=s.done||i.value!=s.value)return!1;if(a+=i.value.length,i.done||a>=r)return!0}}iter(e=1){return new Lh(this,e)}iterRange(e,n=this.length){return new F8(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(e).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new B8(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?L8.empty:e.length<=32?new Pn(e):Js.from(Pn.split(e,[]))}};class Pn extends Vt{constructor(e,n=Mve(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.text[s],a=i+o.length;if((n?r:a)>=e)return new Pve(i,a,r,o);i=a+1,r++}}decompose(e,n,r,i){let s=e<=0&&n>=this.length?this:new Pn(bj(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(i&1){let o=r.pop(),a=h0(s.text,o.text.slice(),0,s.length);if(a.length<=32)r.push(new Pn(a,o.length+s.length));else{let l=a.length>>1;r.push(new Pn(a.slice(0,l)),new Pn(a.slice(l)))}}else r.push(s)}replace(e,n,r){if(!(r instanceof Pn))return super.replace(e,n,r);[e,n]=Sd(this,e,n);let i=h0(this.text,h0(r.text,bj(this.text,0,e)),n),s=this.length+r.length-(n-e);return i.length<=32?new Pn(i,s):Js.from(Pn.split(i,[]),s)}sliceString(e,n=this.length,r=`
347
347
  `){[e,n]=Sd(this,e,n);let i="";for(let s=0,o=0;s<=n&&o<this.text.length;o++){let a=this.text[o],l=s+a.length;s>e&&o&&(i+=r),e<l&&n>s&&(i+=a.slice(Math.max(0,e-s),n-s)),s=l+1}return i}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],i=-1;for(let s of e)r.push(s),i+=s.length+1,r.length==32&&(n.push(new Pn(r,i)),r=[],i=-1);return i>-1&&n.push(new Pn(r,i)),n}}class Js extends Vt{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,i){for(let s=0;;s++){let o=this.children[s],a=i+o.length,l=r+o.lines-1;if((n?l:a)>=e)return o.lineInner(e,n,r,i);i=a+1,r=l+1}}decompose(e,n,r,i){for(let s=0,o=0;o<=n&&s<this.children.length;s++){let a=this.children[s],l=o+a.length;if(e<=l&&n>=o){let c=i&((o<=e?1:0)|(l>=n?2:0));o>=e&&l<=n&&!c?r.push(a):a.decompose(e-o,n-o,r,c)}o=l+1}}replace(e,n,r){if([e,n]=Sd(this,e,n),r.lines<this.lines)for(let i=0,s=0;i<this.children.length;i++){let o=this.children[i],a=s+o.length;if(e>=s&&n<=a){let l=o.replace(e-s,n-s,r),c=this.lines-o.lines+l.lines;if(l.lines<c>>4&&l.lines>c>>6){let u=this.children.slice();return u[i]=l,new Js(u,this.length-(n-e)+r.length)}return super.replace(s,a,l)}s=a+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=`
348
348
  `){[e,n]=Sd(this,e,n);let i="";for(let s=0,o=0;s<this.children.length&&o<=n;s++){let a=this.children[s],l=o+a.length;o>e&&s&&(i+=r),e<l&&n>o&&(i+=a.sliceString(e-o,n-o,r)),o=l+1}return i}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Js))return 0;let r=0,[i,s,o,a]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;i+=n,s+=n){if(i==o||s==a)return r;let l=this.children[i],c=e.children[s];if(l!=c)return r+l.scanIdentical(c,n);r+=l.length+1}}static from(e,n=e.reduce((r,i)=>r+i.length+1,-1)){let r=0;for(let m of e)r+=m.lines;if(r<32){let m=[];for(let y of e)y.flatten(m);return new Pn(m,n)}let i=Math.max(32,r>>5),s=i<<1,o=i>>1,a=[],l=0,c=-1,u=[];function d(m){let y;if(m.lines>s&&m instanceof Js)for(let v of m.children)d(v);else m.lines>o&&(l>o||!l)?(h(),a.push(m)):m instanceof Pn&&l&&(y=u[u.length-1])instanceof Pn&&m.lines+y.lines<=32?(l+=m.lines,c+=m.length+1,u[u.length-1]=new Pn(y.text.concat(m.text),y.length+1+m.length)):(l+m.lines>i&&h(),l+=m.lines,c+=m.length+1,u.push(m))}function h(){l!=0&&(a.push(u.length==1?u[0]:Js.from(u,c)),c=-1,l=u.length=0)}for(let m of e)d(m);return h(),a.length==1?a[0]:new Js(a,n)}}Vt.empty=new Pn([""],0);function Mve(t){let e=-1;for(let n of t)e+=n.length+1;return e}function h0(t,e,n=0,r=1e9){for(let i=0,s=0,o=!0;s<t.length&&i<=r;s++){let a=t[s],l=i+a.length;l>=n&&(l>r&&(a=a.slice(0,r-i)),i<n&&(a=a.slice(n-i)),o?(e[e.length-1]+=a,o=!1):e.push(a)),i=l+1}return e}function bj(t,e,n){return h0(t,[""],e,n)}class Lh{constructor(e,n=1){this.dir=n,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[n>0?1:(e instanceof Pn?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,i=this.nodes[r],s=this.offsets[r],o=s>>1,a=i instanceof Pn?i.text.length:i.children.length;if(o==(n>0?a:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((s&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=`
349
349
  `,this;e--}else if(i instanceof Pn){let l=i.text[o+(n<0?-1:0)];if(this.offsets[r]+=n,l.length>Math.max(0,e))return this.value=e==0?l:n>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=i.children[o+(n<0?-1:0)];e>l.length?(e-=l.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(l),this.offsets.push(n>0?1:(l instanceof Pn?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class F8{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new Lh(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:i}=this.cursor.next(e);return this.pos+=(i.length+e)*n,this.value=i.length<=r?i:n<0?i.slice(i.length-r):i.slice(0,r),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class B8{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:i}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=i,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(Vt.prototype[Symbol.iterator]=function(){return this.iter()},Lh.prototype[Symbol.iterator]=F8.prototype[Symbol.iterator]=B8.prototype[Symbol.iterator]=function(){return this});class Pve{constructor(e,n,r,i){this.from=e,this.to=n,this.number=r,this.text=i}get length(){return this.to-this.from}}function Sd(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function yr(t,e,n=!0,r=!0){return Ave(t,e,n,r)}function Ove(t){return t>=56320&&t<57344}function Rve(t){return t>=55296&&t<56320}function si(t,e){let n=t.charCodeAt(e);if(!Rve(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return Ove(r)?(n-55296<<10)+(r-56320)+65536:n}function r2(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}function eo(t){return t<65536?1:2}const AE=/\r\n?|\n/;var Ur=function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t}(Ur||(Ur={}));class po{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;n<this.sections.length;n+=2)e+=this.sections[n];return e}get newLength(){let e=0;for(let n=0;n<this.sections.length;n+=2){let r=this.sections[n+1];e+=r<0?this.sections[n]:r}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let n=0,r=0,i=0;n<this.sections.length;){let s=this.sections[n++],o=this.sections[n++];o<0?(e(r,i,s),i+=s):i+=o,r+=s}}iterChangedRanges(e,n=!1){_E(this,e,n)}get invertedDesc(){let e=[];for(let n=0;n<this.sections.length;){let r=this.sections[n++],i=this.sections[n++];i<0?e.push(r,i):e.push(i,r)}return new po(e)}composeDesc(e){return this.empty?e:e.empty?this:$8(this,e)}mapDesc(e,n=!1){return e.empty?this:ME(this,e,n)}mapPos(e,n=-1,r=Ur.Simple){let i=0,s=0;for(let o=0;o<this.sections.length;){let a=this.sections[o++],l=this.sections[o++],c=i+a;if(l<0){if(c>e)return s+(e-i);s+=a}else{if(r!=Ur.Simple&&c>=e&&(r==Ur.TrackDel&&i<e&&c>e||r==Ur.TrackBefore&&i<e||r==Ur.TrackAfter&&c>e))return null;if(c>e||c==e&&n<0&&!a)return e==i||n<0?s:s+l;s+=l}i=c}if(e>i)throw new RangeError(`Position ${e} is out of range for changeset of length ${i}`);return s}touchesRange(e,n=e){for(let r=0,i=0;r<this.sections.length&&i<=n;){let s=this.sections[r++],o=this.sections[r++],a=i+s;if(o>=0&&i<=n&&a>=e)return i<e&&a>n?"cover":!0;i=a}return!1}toString(){let e="";for(let n=0;n<this.sections.length;){let r=this.sections[n++],i=this.sections[n++];e+=(e?" ":"")+r+(i>=0?":"+i:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new po(e)}static create(e){return new po(e)}}class Jn extends po{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return _E(this,(n,r,i,s,o)=>e=e.replace(i,i+(r-n),o),!1),e}mapDesc(e,n=!1){return ME(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let i=0,s=0;i<n.length;i+=2){let o=n[i],a=n[i+1];if(a>=0){n[i]=a,n[i+1]=o;let l=i>>1;for(;r.length<l;)r.push(Vt.empty);r.push(o?e.slice(s,s+o):Vt.empty)}s+=o}return new Jn(n,r)}compose(e){return this.empty?e:e.empty?this:$8(this,e,!0)}map(e,n=!1){return e.empty?this:ME(this,e,n,!0)}iterChanges(e,n=!1){_E(this,e,n)}get desc(){return po.create(this.sections)}filter(e){let n=[],r=[],i=[],s=new Cp(this);e:for(let o=0,a=0;;){let l=o==e.length?1e9:e[o++];for(;a<l||a==l&&s.len==0;){if(s.done)break e;let u=Math.min(s.len,l-a);Tr(i,u,-1);let d=s.ins==-1?-1:s.off==0?s.ins:0;Tr(n,u,d),d>0&&cl(r,n,s.text),s.forward(u),a+=u}let c=e[o++];for(;a<c;){if(s.done)break e;let u=Math.min(s.len,c-a);Tr(n,u,-1),Tr(i,u,s.ins==-1?-1:s.off==0?s.ins:0),s.forward(u),a+=u}}return{changes:new Jn(n,r),filtered:po.create(i)}}toJSON(){let e=[];for(let n=0;n<this.sections.length;n+=2){let r=this.sections[n],i=this.sections[n+1];i<0?e.push(r):i==0?e.push([r]):e.push([r].concat(this.inserted[n>>1].toJSON()))}return e}static of(e,n,r){let i=[],s=[],o=0,a=null;function l(u=!1){if(!u&&!i.length)return;o<n&&Tr(i,n-o,-1);let d=new Jn(i,s);a=a?a.compose(d.map(a)):d,i=[],s=[],o=0}function c(u){if(Array.isArray(u))for(let d of u)c(d);else if(u instanceof Jn){if(u.length!=n)throw new RangeError(`Mismatched change set length (got ${u.length}, expected ${n})`);l(),a=a?a.compose(u.map(a)):u}else{let{from:d,to:h=d,insert:m}=u;if(d>h||d<0||h>n)throw new RangeError(`Invalid change range ${d} to ${h} (in doc of length ${n})`);let y=m?typeof m=="string"?Vt.of(m.split(r||AE)):m:Vt.empty,v=y.length;if(d==h&&v==0)return;d<o&&l(),d>o&&Tr(i,d-o,-1),Tr(i,h-d,v),cl(s,i,y),o=h}}return c(e),l(!a),a}static empty(e){return new Jn(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let i=0;i<e.length;i++){let s=e[i];if(typeof s=="number")n.push(s,-1);else{if(!Array.isArray(s)||typeof s[0]!="number"||s.some((o,a)=>a&&typeof o!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(s.length==1)n.push(s[0],0);else{for(;r.length<i;)r.push(Vt.empty);r[i]=Vt.of(s.slice(1)),n.push(s[0],r[i].length)}}}return new Jn(n,r)}static createSet(e,n){return new Jn(e,n)}}function Tr(t,e,n,r=!1){if(e==0&&n<=0)return;let i=t.length-2;i>=0&&n<=0&&n==t[i+1]?t[i]+=e:i>=0&&e==0&&t[i]==0?t[i+1]+=n:r?(t[i]+=e,t[i+1]+=n):t.push(e,n)}function cl(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r<t.length)t[t.length-1]=t[t.length-1].append(n);else{for(;t.length<r;)t.push(Vt.empty);t.push(n)}}function _E(t,e,n){let r=t.inserted;for(let i=0,s=0,o=0;o<t.sections.length;){let a=t.sections[o++],l=t.sections[o++];if(l<0)i+=a,s+=a;else{let c=i,u=s,d=Vt.empty;for(;c+=a,u+=l,l&&r&&(d=d.append(r[o-2>>1])),!(n||o==t.sections.length||t.sections[o+1]<0);)a=t.sections[o++],l=t.sections[o++];e(i,c,s,u,d),i=c,s=u}}}function ME(t,e,n,r=!1){let i=[],s=r?[]:null,o=new Cp(t),a=new Cp(e);for(let l=-1;;){if(o.done&&a.len||a.done&&o.len)throw new Error("Mismatched change set lengths");if(o.ins==-1&&a.ins==-1){let c=Math.min(o.len,a.len);Tr(i,c,-1),o.forward(c),a.forward(c)}else if(a.ins>=0&&(o.ins<0||l==o.i||o.off==0&&(a.len<o.len||a.len==o.len&&!n))){let c=a.len;for(Tr(i,a.ins,-1);c;){let u=Math.min(o.len,c);o.ins>=0&&l<o.i&&o.len<=u&&(Tr(i,0,o.ins),s&&cl(s,i,o.text),l=o.i),o.forward(u),c-=u}a.next()}else if(o.ins>=0){let c=0,u=o.len;for(;u;)if(a.ins==-1){let d=Math.min(u,a.len);c+=d,u-=d,a.forward(d)}else if(a.ins==0&&a.len<u)u-=a.len,a.next();else break;Tr(i,c,l<o.i?o.ins:0),s&&l<o.i&&cl(s,i,o.text),l=o.i,o.forward(o.len-u)}else{if(o.done&&a.done)return s?Jn.createSet(i,s):po.create(i);throw new Error("Mismatched change set lengths")}}}function $8(t,e,n=!1){let r=[],i=n?[]:null,s=new Cp(t),o=new Cp(e);for(let a=!1;;){if(s.done&&o.done)return i?Jn.createSet(r,i):po.create(r);if(s.ins==0)Tr(r,s.len,0,a),s.next();else if(o.len==0&&!o.done)Tr(r,0,o.ins,a),i&&cl(i,r,o.text),o.next();else{if(s.done||o.done)throw new Error("Mismatched change set lengths");{let l=Math.min(s.len2,o.len),c=r.length;if(s.ins==-1){let u=o.ins==-1?-1:o.off?0:o.ins;Tr(r,l,u,a),i&&u&&cl(i,r,o.text)}else o.ins==-1?(Tr(r,s.off?0:s.len,l,a),i&&cl(i,r,s.textBit(l))):(Tr(r,s.off?0:s.len,o.off?0:o.ins,a),i&&!o.off&&cl(i,r,o.text));a=(s.ins>l||o.ins>=0&&o.len>l)&&(a||r.length>c),s.forward2(l),o.forward(l)}}}}class Cp{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,n=this.i-2>>1;return n>=e.length?Vt.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?Vt.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class hc{constructor(e,n,r){this.from=e,this.to=n,this.flags=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,n=-1){let r,i;return this.empty?r=i=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),i=e.mapPos(this.to,-1)),r==this.from&&i==this.to?this:new hc(r,i,this.flags)}extend(e,n=e){if(e<=this.anchor&&n>=this.anchor)return ge.range(e,n);let r=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ge.range(this.anchor,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return ge.range(e.anchor,e.head)}static create(e,n,r){return new hc(e,n,r)}}class ge{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ge.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;r<this.ranges.length;r++)if(!this.ranges[r].eq(e.ranges[r],n))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new ge([this.main],0)}addRange(e,n=!0){return ge.create([e].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(e,n=this.mainIndex){let r=this.ranges.slice();return r[n]=e,ge.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ge(e.ranges.map(n=>hc.fromJSON(n)),e.main)}static single(e,n=e){return new ge([ge.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,i=0;i<e.length;i++){let s=e[i];if(s.empty?s.from<=r:s.from<r)return ge.normalized(e.slice(),n);r=s.to}return new ge(e,n)}static cursor(e,n=0,r,i){return hc.create(e,e,(n==0?0:n<0?8:16)|(r==null?7:Math.min(6,r))|(i??16777215)<<6)}static range(e,n,r,i){let s=(r??16777215)<<6|(i==null?7:Math.min(6,i));return n<e?hc.create(n,e,48|s):hc.create(e,n,(n>e?8:0)|s)}static normalized(e,n=0){let r=e[n];e.sort((i,s)=>i.from-s.from),n=e.indexOf(r);for(let i=1;i<e.length;i++){let s=e[i],o=e[i-1];if(s.empty?s.from<=o.to:s.from<o.to){let a=o.from,l=Math.max(s.to,o.to);i<=n&&n--,e.splice(--i,2,s.anchor>s.head?ge.range(l,a):ge.range(a,l))}}return new ge(e,n)}}function z8(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let i2=0;class $e{constructor(e,n,r,i,s){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=i,this.id=i2++,this.default=e([]),this.extensions=typeof s=="function"?s(this):s}get reader(){return this}static define(e={}){return new $e(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:s2),!!e.static,e.enables)}of(e){return new p0([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new p0(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new p0(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function s2(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class p0{constructor(e,n,r,i){this.dependencies=e,this.facet=n,this.type=r,this.value=i,this.id=i2++}dynamicSlot(e){var n;let r=this.value,i=this.facet.compareInput,s=this.id,o=e[s]>>1,a=this.type==2,l=!1,c=!1,u=[];for(let d of this.dependencies)d=="doc"?l=!0:d=="selection"?c=!0:((n=e[d.id])!==null&&n!==void 0?n:1)&1||u.push(e[d.id]);return{create(d){return d.values[o]=r(d),1},update(d,h){if(l&&h.docChanged||c&&(h.docChanged||h.selection)||PE(d,u)){let m=r(d);if(a?!kj(m,d.values[o],i):!i(m,d.values[o]))return d.values[o]=m,1}return 0},reconfigure:(d,h)=>{let m,y=h.config.address[s];if(y!=null){let v=hx(h,y);if(this.dependencies.every(w=>w instanceof $e?h.facet(w)===d.facet(w):w instanceof xr?h.field(w,!1)==d.field(w,!1):!0)||(a?kj(m=r(d),v,i):i(m=r(d),v)))return d.values[o]=v,0}else m=r(d);return d.values[o]=m,1}}}}function kj(t,e,n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!n(t[r],e[r]))return!1;return!0}function PE(t,e){let n=!1;for(let r of e)Fh(t,r)&1&&(n=!0);return n}function Dve(t,e,n){let r=n.map(l=>t[l.id]),i=n.map(l=>l.type),s=r.filter(l=>!(l&1)),o=t[e.id]>>1;function a(l){let c=[];for(let u=0;u<r.length;u++){let d=hx(l,r[u]);if(i[u]==2)for(let h of d)c.push(h);else c.push(d)}return e.combine(c)}return{create(l){for(let c of r)Fh(l,c);return l.values[o]=a(l),1},update(l,c){if(!PE(l,s))return 0;let u=a(l);return e.compare(u,l.values[o])?0:(l.values[o]=u,1)},reconfigure(l,c){let u=PE(l,r),d=c.config.facets[e.id],h=c.facet(e);if(d&&!u&&s2(n,d))return l.values[o]=h,0;let m=a(l);return e.compare(m,h)?(l.values[o]=h,0):(l.values[o]=m,1)}}}const Ey=$e.define({static:!0});class xr{constructor(e,n,r,i,s){this.id=e,this.createF=n,this.updateF=r,this.compareF=i,this.spec=s,this.provides=void 0}static define(e){let n=new xr(i2++,e.create,e.update,e.compare||((r,i)=>r===i),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Ey).find(r=>r.field==this);return((n==null?void 0:n.create)||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,i)=>{let s=r.values[n],o=this.updateF(s,i);return this.compareF(s,o)?0:(r.values[n]=o,1)},reconfigure:(r,i)=>{let s=r.facet(Ey),o=i.facet(Ey),a;return(a=s.find(l=>l.field==this))&&a!=o.find(l=>l.field==this)?(r.values[n]=a.create(r),1):i.config.address[this.id]!=null?(r.values[n]=i.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Ey.of({field:this,create:e})]}get extension(){return this}}const lc={lowest:4,low:3,default:2,high:1,highest:0};function th(t){return e=>new V8(e,t)}const qc={highest:th(lc.highest),high:th(lc.high),default:th(lc.default),low:th(lc.low),lowest:th(lc.lowest)};class V8{constructor(e,n){this.inner=e,this.prec=n}}class Bv{of(e){return new OE(this,e)}reconfigure(e){return Bv.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class OE{constructor(e,n){this.compartment=e,this.inner=n}}class fx{constructor(e,n,r,i,s,o){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=i,this.staticValues=s,this.facets=o,this.statusTemplate=[];this.statusTemplate.length<r.length;)this.statusTemplate.push(0)}staticFacet(e){let n=this.address[e.id];return n==null?e.default:this.staticValues[n>>1]}static resolve(e,n,r){let i=[],s=Object.create(null),o=new Map;for(let h of jve(e,n,o))h instanceof xr?i.push(h):(s[h.facet.id]||(s[h.facet.id]=[])).push(h);let a=Object.create(null),l=[],c=[];for(let h of i)a[h.id]=c.length<<1,c.push(m=>h.slot(m));let u=r==null?void 0:r.config.facets;for(let h in s){let m=s[h],y=m[0].facet,v=u&&u[h]||[];if(m.every(w=>w.type==0))if(a[y.id]=l.length<<1|1,s2(v,m))l.push(r.facet(y));else{let w=y.combine(m.map(b=>b.value));l.push(r&&y.compare(w,r.facet(y))?r.facet(y):w)}else{for(let w of m)w.type==0?(a[w.id]=l.length<<1|1,l.push(w.value)):(a[w.id]=c.length<<1,c.push(b=>w.dynamicSlot(b)));a[y.id]=c.length<<1,c.push(w=>Dve(w,y,m))}}let d=c.map(h=>h(a));return new fx(e,o,d,a,l,s)}}function jve(t,e,n){let r=[[],[],[],[],[]],i=new Map;function s(o,a){let l=i.get(o);if(l!=null){if(l<=a)return;let c=r[l].indexOf(o);c>-1&&r[l].splice(c,1),o instanceof OE&&n.delete(o.compartment)}if(i.set(o,a),Array.isArray(o))for(let c of o)s(c,a);else if(o instanceof OE){if(n.has(o.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(o.compartment)||o.inner;n.set(o.compartment,c),s(c,a)}else if(o instanceof V8)s(o.inner,o.prec);else if(o instanceof xr)r[a].push(o),o.provides&&s(o.provides,a);else if(o instanceof p0)r[a].push(o),o.facet.extensions&&s(o.facet.extensions,lc.default);else{let c=o.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${o}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);s(c,a)}}return s(t,lc.default),r.reduce((o,a)=>o.concat(a))}function Fh(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let i=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|i}function hx(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const W8=$e.define(),RE=$e.define({combine:t=>t.some(e=>e),static:!0}),H8=$e.define({combine:t=>t.length?t[0]:void 0,static:!0}),U8=$e.define(),q8=$e.define(),Y8=$e.define(),G8=$e.define({combine:t=>t.length?t[0]:!1});class Oo{constructor(e,n){this.type=e,this.value=n}static define(){return new Ive}}class Ive{of(e){return new Oo(this,e)}}class Lve{constructor(e){this.map=e}of(e){return new vt(this,e)}}class vt{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new vt(this.type,n)}is(e){return this.type==e}static define(e={}){return new Lve(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let i of e){let s=i.map(n);s&&r.push(s)}return r}}vt.reconfigure=vt.define();vt.appendConfig=vt.define();class tr{constructor(e,n,r,i,s,o){this.startState=e,this.changes=n,this.selection=r,this.effects=i,this.annotations=s,this.scrollIntoView=o,this._doc=null,this._state=null,r&&z8(r,n.newLength),s.some(a=>a.type==tr.time)||(this.annotations=s.concat(tr.time.of(Date.now())))}static create(e,n,r,i,s,o){return new tr(e,n,r,i,s,o)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(tr.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}tr.time=Oo.define();tr.userEvent=Oo.define();tr.addToHistory=Oo.define();tr.remote=Oo.define();function Fve(t,e){let n=[];for(let r=0,i=0;;){let s,o;if(r<t.length&&(i==e.length||e[i]>=t[r]))s=t[r++],o=t[r++];else if(i<e.length)s=e[i++],o=e[i++];else return n;!n.length||n[n.length-1]<s?n.push(s,o):n[n.length-1]<o&&(n[n.length-1]=o)}}function K8(t,e,n){var r;let i,s,o;return n?(i=e.changes,s=Jn.empty(e.changes.length),o=t.changes.compose(e.changes)):(i=e.changes.map(t.changes),s=t.changes.mapDesc(e.changes,!0),o=t.changes.compose(i)),{changes:o,selection:e.selection?e.selection.map(s):(r=t.selection)===null||r===void 0?void 0:r.map(i),effects:vt.mapEffects(t.effects,i).concat(vt.mapEffects(e.effects,s)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function DE(t,e,n){let r=e.selection,i=td(e.annotations);return e.userEvent&&(i=i.concat(tr.userEvent.of(e.userEvent))),{changes:e.changes instanceof Jn?e.changes:Jn.of(e.changes||[],n,t.facet(H8)),selection:r&&(r instanceof ge?r:ge.single(r.anchor,r.head)),effects:td(e.effects),annotations:i,scrollIntoView:!!e.scrollIntoView}}function Z8(t,e,n){let r=DE(t,e.length?e[0]:{},t.doc.length);e.length&&e[0].filter===!1&&(n=!1);for(let s=1;s<e.length;s++){e[s].filter===!1&&(n=!1);let o=!!e[s].sequential;r=K8(r,DE(t,e[s],o?r.changes.newLength:t.doc.length),o)}let i=tr.create(t,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return $ve(n?Bve(i):i)}function Bve(t){let e=t.startState,n=!0;for(let i of e.facet(U8)){let s=i(t);if(s===!1){n=!1;break}Array.isArray(s)&&(n=n===!0?s:Fve(n,s))}if(n!==!0){let i,s;if(n===!1)s=t.changes.invertedDesc,i=Jn.empty(e.doc.length);else{let o=t.changes.filter(n);i=o.changes,s=o.filtered.mapDesc(o.changes).invertedDesc}t=tr.create(e,i,t.selection&&t.selection.map(s),vt.mapEffects(t.effects,s),t.annotations,t.scrollIntoView)}let r=e.facet(q8);for(let i=r.length-1;i>=0;i--){let s=r[i](t);s instanceof tr?t=s:Array.isArray(s)&&s.length==1&&s[0]instanceof tr?t=s[0]:t=Z8(e,td(s),!1)}return t}function $ve(t){let e=t.startState,n=e.facet(Y8),r=t;for(let i=n.length-1;i>=0;i--){let s=n[i](t);s&&Object.keys(s).length&&(r=K8(r,DE(e,s,t.changes.newLength),!0))}return r==t?t:tr.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const zve=[];function td(t){return t==null?zve:Array.isArray(t)?t:[t]}var yn=function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t}(yn||(yn={}));const Vve=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let jE;try{jE=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function Wve(t){if(jE)return jE.test(t);for(let e=0;e<t.length;e++){let n=t[e];if(/\w/.test(n)||n>"€"&&(n.toUpperCase()!=n.toLowerCase()||Vve.test(n)))return!0}return!1}function Hve(t){return e=>{if(!/\S/.test(e))return yn.Space;if(Wve(e))return yn.Word;for(let n=0;n<t.length;n++)if(e.indexOf(t[n])>-1)return yn.Word;return yn.Other}}class At{constructor(e,n,r,i,s,o){this.config=e,this.doc=n,this.selection=r,this.values=i,this.status=e.statusTemplate.slice(),this.computeSlot=s,o&&(o._state=this);for(let a=0;a<this.config.dynamicSlots.length;a++)Fh(this,a<<1);this.computeSlot=null}field(e,n=!0){let r=this.config.address[e.id];if(r==null){if(n)throw new RangeError("Field is not present in this state");return}return Fh(this,r),hx(this,r)}update(...e){return Z8(this,e,!0)}applyTransaction(e){let n=this.config,{base:r,compartments:i}=n;for(let a of e.effects)a.is(Bv.reconfigure)?(n&&(i=new Map,n.compartments.forEach((l,c)=>i.set(c,l)),n=null),i.set(a.value.compartment,a.value.extension)):a.is(vt.reconfigure)?(n=null,r=a.value):a.is(vt.appendConfig)&&(n=null,r=td(r).concat(a.value));let s;n?s=e.startState.values.slice():(n=fx.resolve(r,i,this),s=new At(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(l,c)=>c.reconfigure(l,this),null).values);let o=e.startState.facet(RE)?e.newSelection:e.newSelection.asSingle();new At(n,e.newDoc,o,s,(a,l)=>l.update(a,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:ge.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),i=this.changes(r.changes),s=[r.range],o=td(r.effects);for(let a=1;a<n.ranges.length;a++){let l=e(n.ranges[a]),c=this.changes(l.changes),u=c.map(i);for(let h=0;h<a;h++)s[h]=s[h].map(u);let d=i.mapDesc(c,!0);s.push(l.range.map(d)),i=i.compose(u),o=vt.mapEffects(o,u).concat(vt.mapEffects(td(l.effects),d))}return{changes:i,selection:ge.create(s,n.mainIndex),effects:o}}changes(e=[]){return e instanceof Jn?e:Jn.of(e,this.doc.length,this.facet(At.lineSeparator))}toText(e){return Vt.of(e.split(this.facet(At.lineSeparator)||AE))}sliceDoc(e=0,n=this.doc.length){return this.doc.sliceString(e,n,this.lineBreak)}facet(e){let n=this.config.address[e.id];return n==null?e.default:(Fh(this,n),hx(this,n))}toJSON(e){let n={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let r in e){let i=e[r];i instanceof xr&&this.config.address[i.id]!=null&&(n[r]=i.spec.toJSON(this.field(e[r]),this))}return n}static fromJSON(e,n={},r){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let i=[];if(r){for(let s in r)if(Object.prototype.hasOwnProperty.call(e,s)){let o=r[s],a=e[s];i.push(o.init(l=>o.spec.fromJSON(a,l)))}}return At.create({doc:e.doc,selection:ge.fromJSON(e.selection),extensions:n.extensions?i.concat([n.extensions]):i})}static create(e={}){let n=fx.resolve(e.extensions||[],new Map),r=e.doc instanceof Vt?e.doc:Vt.of((e.doc||"").split(n.staticFacet(At.lineSeparator)||AE)),i=e.selection?e.selection instanceof ge?e.selection:ge.single(e.selection.anchor,e.selection.head):ge.single(0);return z8(i,r.length),n.staticFacet(RE)||(i=i.asSingle()),new At(n,r,i,n.dynamicSlots.map(()=>null),(s,o)=>o.create(s),null)}get tabSize(){return this.facet(At.tabSize)}get lineBreak(){return this.facet(At.lineSeparator)||`