agent-canvas 0.1.45 → 0.2.0

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.
@@ -1,65 +1,65 @@
1
- import{useState as e5}from"react";import I1 from"react";function i0(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var U0=i0();function F1(Q){U0=Q}var P0={exec:()=>null};function y(Q,$=""){let Y=typeof Q=="string"?Q:Q.source,W={replace:(J,X)=>{let K=typeof X=="string"?X:X.source;return K=K.replace(x.caret,"$1"),Y=Y.replace(J,K),W},getRegex:()=>new RegExp(Y,$)};return W}var B5=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),x={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:(Q)=>new RegExp(`^( {0,3}${Q})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:(Q)=>new RegExp(`^ {0,${Math.min(3,Q-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:(Q)=>new RegExp(`^ {0,${Math.min(3,Q-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:(Q)=>new RegExp(`^ {0,${Math.min(3,Q-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:(Q)=>new RegExp(`^ {0,${Math.min(3,Q-1)}}#`),htmlBeginRegex:(Q)=>new RegExp(`^ {0,${Math.min(3,Q-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:(Q)=>new RegExp(`^ {0,${Math.min(3,Q-1)}}>`)},G5=/^(?:[ \t]*(?:\n|$))+/,q5=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,P5=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,k0=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,H5=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,o0=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,_1=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,L1=y(_1).replace(/bull/g,o0).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),U5=y(_1).replace(/bull/g,o0).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),a0=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Z5=/^[^\n]+/,s0=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,N5=y(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",s0).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),T5=y(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,o0).getRegex(),m0="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",n0=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,F5=y("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",n0).replace("tag",m0).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),z1=y(a0).replace("hr",k0).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",m0).getRegex(),_5=y(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",z1).getRegex(),t0={blockquote:_5,code:q5,def:N5,fences:P5,heading:H5,hr:k0,html:F5,lheading:L1,list:T5,newline:G5,paragraph:z1,table:P0,text:Z5},P1=y("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",k0).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",m0).getRegex(),L5={...t0,lheading:U5,table:P1,paragraph:y(a0).replace("hr",k0).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",P1).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",m0).getRegex()},z5={...t0,html:y(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",n0).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:P0,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:y(a0).replace("hr",k0).replace("heading",` *#{1,6} *[^
2
- ]`).replace("lheading",L1).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},A5=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,M5=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,A1=/^( {2,}|\\)\n(?!\s*$)/,w5=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,F0=/[\p{P}\p{S}]/u,j0=/[\s\p{P}\p{S}]/u,e0=/[^\s\p{P}\p{S}]/u,O5=y(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,j0).getRegex(),M1=/(?!~)[\p{P}\p{S}]/u,y5=/(?!~)[\s\p{P}\p{S}]/u,k5=/(?:[^\s\p{P}\p{S}]|~)/u,I5=y(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",B5?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),w1=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,S5=y(w1,"u").replace(/punct/g,F0).getRegex(),b5=y(w1,"u").replace(/punct/g,M1).getRegex(),O1="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",f5=y(O1,"gu").replace(/notPunctSpace/g,e0).replace(/punctSpace/g,j0).replace(/punct/g,F0).getRegex(),R5=y(O1,"gu").replace(/notPunctSpace/g,k5).replace(/punctSpace/g,y5).replace(/punct/g,M1).getRegex(),C5=y("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,e0).replace(/punctSpace/g,j0).replace(/punct/g,F0).getRegex(),v5=y(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,F0).getRegex(),V5="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",m5=y(V5,"gu").replace(/notPunctSpace/g,e0).replace(/punctSpace/g,j0).replace(/punct/g,F0).getRegex(),j5=y(/\\(punct)/,"gu").replace(/punct/g,F0).getRegex(),D5=y(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),h5=y(n0).replace("(?:-->|$)","-->").getRegex(),x5=y("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",h5).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),C0=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,g5=y(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",C0).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),y1=y(/^!?\[(label)\]\[(ref)\]/).replace("label",C0).replace("ref",s0).getRegex(),k1=y(/^!?\[(ref)\](?:\[\])?/).replace("ref",s0).getRegex(),E5=y("reflink|nolink(?!\\()","g").replace("reflink",y1).replace("nolink",k1).getRegex(),H1=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,$1={_backpedal:P0,anyPunctuation:j5,autolink:D5,blockSkip:I5,br:A1,code:M5,del:P0,delLDelim:P0,delRDelim:P0,emStrongLDelim:S5,emStrongRDelimAst:f5,emStrongRDelimUnd:C5,escape:A5,link:g5,nolink:k1,punctuation:O5,reflink:y1,reflinkSearch:E5,tag:x5,text:w5,url:P0},p5={...$1,link:y(/^!?\[(label)\]\((.*?)\)/).replace("label",C0).getRegex(),reflink:y(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",C0).getRegex()},l0={...$1,emStrongRDelimAst:R5,emStrongLDelim:b5,delLDelim:v5,delRDelim:m5,url:y(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",H1).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:y(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",H1).getRegex()},u5={...l0,br:y(A1).replace("{2,}","*").getRegex(),text:y(l0.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},R0={normal:t0,gfm:L5,pedantic:z5},w0={normal:$1,gfm:l0,breaks:u5,pedantic:p5},c5={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},U1=(Q)=>c5[Q];function $0(Q,$){if($){if(x.escapeTest.test(Q))return Q.replace(x.escapeReplace,U1)}else if(x.escapeTestNoEncode.test(Q))return Q.replace(x.escapeReplaceNoEncode,U1);return Q}function Z1(Q){try{Q=encodeURI(Q).replace(x.percentDecode,"%")}catch{return null}return Q}function N1(Q,$){let Y=Q.replace(x.findPipe,(X,K,G)=>{let B=!1,q=K;for(;--q>=0&&G[q]==="\\";)B=!B;return B?"|":" |"}),W=Y.split(x.splitPipe),J=0;if(W[0].trim()||W.shift(),W.length>0&&!W.at(-1)?.trim()&&W.pop(),$)if(W.length>$)W.splice($);else for(;W.length<$;)W.push("");for(;J<W.length;J++)W[J]=W[J].trim().replace(x.slashPipe,"|");return W}function O0(Q,$,Y){let W=Q.length;if(W===0)return"";let J=0;for(;J<W;){let X=Q.charAt(W-J-1);if(X===$&&!Y)J++;else if(X!==$&&Y)J++;else break}return Q.slice(0,W-J)}function d5(Q,$){if(Q.indexOf($[1])===-1)return-1;let Y=0;for(let W=0;W<Q.length;W++)if(Q[W]==="\\")W++;else if(Q[W]===$[0])Y++;else if(Q[W]===$[1]&&(Y--,Y<0))return W;return Y>0?-2:-1}function r5(Q,$=0){let Y=$,W="";for(let J of Q)if(J==="\t"){let X=4-Y%4;W+=" ".repeat(X),Y+=X}else W+=J,Y++;return W}function T1(Q,$,Y,W,J){let X=$.href,K=$.title||null,G=Q[1].replace(J.other.outputLinkReplace,"$1");W.state.inLink=!0;let B={type:Q[0].charAt(0)==="!"?"image":"link",raw:Y,href:X,title:K,text:G,tokens:W.inlineTokens(G)};return W.state.inLink=!1,B}function l5(Q,$,Y){let W=Q.match(Y.other.indentCodeCompensation);if(W===null)return $;let J=W[1];return $.split(`
3
- `).map((X)=>{let K=X.match(Y.other.beginningSpace);if(K===null)return X;let[G]=K;return G.length>=J.length?X.slice(J.length):X}).join(`
4
- `)}var v0=class{options;rules;lexer;constructor(Q){this.options=Q||U0}space(Q){let $=this.rules.block.newline.exec(Q);if($&&$[0].length>0)return{type:"space",raw:$[0]}}code(Q){let $=this.rules.block.code.exec(Q);if($){let Y=$[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:$[0],codeBlockStyle:"indented",text:this.options.pedantic?Y:O0(Y,`
5
- `)}}}fences(Q){let $=this.rules.block.fences.exec(Q);if($){let Y=$[0],W=l5(Y,$[3]||"",this.rules);return{type:"code",raw:Y,lang:$[2]?$[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):$[2],text:W}}}heading(Q){let $=this.rules.block.heading.exec(Q);if($){let Y=$[2].trim();if(this.rules.other.endingHash.test(Y)){let W=O0(Y,"#");(this.options.pedantic||!W||this.rules.other.endingSpaceChar.test(W))&&(Y=W.trim())}return{type:"heading",raw:$[0],depth:$[1].length,text:Y,tokens:this.lexer.inline(Y)}}}hr(Q){let $=this.rules.block.hr.exec(Q);if($)return{type:"hr",raw:O0($[0],`
6
- `)}}blockquote(Q){let $=this.rules.block.blockquote.exec(Q);if($){let Y=O0($[0],`
1
+ import{useFeedback as Yl}from"#canvas/runtime";function nt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var he=nt();function _t(t){he=t}var pe={exec:()=>null};function A(t,e=""){let n=typeof t=="string"?t:t.source,o={replace:(r,s)=>{let i=typeof s=="string"?s:s.source;return i=i.replace(D.caret,"$1"),n=n.replace(r,i),o},getRegex:()=>new RegExp(n,e)};return o}var $n=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),D={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:(t)=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:(t)=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:(t)=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:(t)=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:(t)=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:(t)=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:(t)=>new RegExp(`^ {0,${Math.min(3,t-1)}}>`)},On=/^(?:[ \t]*(?:\n|$))+/,_n=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Hn=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Te=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,zn=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,rt=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Ht=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,zt=A(Ht).replace(/bull/g,rt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Dn=A(Ht).replace(/bull/g,rt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),ot=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Bn=/^[^\n]+/,st=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,qn=A(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",st).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Fn=A(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,rt).getRegex(),ze="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",it=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Gn=A("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",it).replace("tag",ze).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Dt=A(ot).replace("hr",Te).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ze).getRegex(),Un=A(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Dt).getRegex(),at={blockquote:Un,code:_n,def:qn,fences:Hn,heading:zn,hr:Te,html:Gn,lheading:zt,list:Fn,newline:On,paragraph:Dt,table:pe,text:Bn},It=A("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Te).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ze).getRegex(),Wn={...at,lheading:Dn,table:It,paragraph:A(ot).replace("hr",Te).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",It).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ze).getRegex()},Vn={...at,html:A(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",it).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:pe,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:A(ot).replace("hr",Te).replace("heading",` *#{1,6} *[^
2
+ ]`).replace("lheading",zt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},jn=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Kn=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Bt=/^( {2,}|\\)\n(?!\s*$)/,Zn=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,xe=/[\p{P}\p{S}]/u,De=/[\s\p{P}\p{S}]/u,lt=/[^\s\p{P}\p{S}]/u,Yn=A(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,De).getRegex(),qt=/(?!~)[\p{P}\p{S}]/u,Xn=/(?!~)[\s\p{P}\p{S}]/u,Qn=/(?:[^\s\p{P}\p{S}]|~)/u,Jn=A(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",$n?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Ft=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,er=A(Ft,"u").replace(/punct/g,xe).getRegex(),tr=A(Ft,"u").replace(/punct/g,qt).getRegex(),Gt="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",nr=A(Gt,"gu").replace(/notPunctSpace/g,lt).replace(/punctSpace/g,De).replace(/punct/g,xe).getRegex(),rr=A(Gt,"gu").replace(/notPunctSpace/g,Qn).replace(/punctSpace/g,Xn).replace(/punct/g,qt).getRegex(),or=A("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,lt).replace(/punctSpace/g,De).replace(/punct/g,xe).getRegex(),sr=A(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,xe).getRegex(),ir="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",ar=A(ir,"gu").replace(/notPunctSpace/g,lt).replace(/punctSpace/g,De).replace(/punct/g,xe).getRegex(),lr=A(/\\(punct)/,"gu").replace(/punct/g,xe).getRegex(),cr=A(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),ur=A(it).replace("(?:-->|$)","-->").getRegex(),dr=A("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",ur).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Oe=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,pr=A(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Oe).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ut=A(/^!?\[(label)\]\[(ref)\]/).replace("label",Oe).replace("ref",st).getRegex(),Wt=A(/^!?\[(ref)\](?:\[\])?/).replace("ref",st).getRegex(),fr=A("reflink|nolink(?!\\()","g").replace("reflink",Ut).replace("nolink",Wt).getRegex(),Lt=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,ct={_backpedal:pe,anyPunctuation:lr,autolink:cr,blockSkip:Jn,br:Bt,code:Kn,del:pe,delLDelim:pe,delRDelim:pe,emStrongLDelim:er,emStrongRDelimAst:nr,emStrongRDelimUnd:or,escape:jn,link:pr,nolink:Wt,punctuation:Yn,reflink:Ut,reflinkSearch:fr,tag:dr,text:Zn,url:pe},hr={...ct,link:A(/^!?\[(label)\]\((.*?)\)/).replace("label",Oe).getRegex(),reflink:A(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Oe).getRegex()},tt={...ct,emStrongRDelimAst:rr,emStrongLDelim:tr,delLDelim:sr,delRDelim:ar,url:A(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Lt).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:A(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Lt).getRegex()},gr={...tt,br:A(Bt).replace("{2,}","*").getRegex(),text:A(tt.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},$e={normal:at,gfm:Wn,pedantic:Vn},Se={normal:ct,gfm:tt,breaks:gr,pedantic:hr},mr={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},Pt=(t)=>mr[t];function te(t,e){if(e){if(D.escapeTest.test(t))return t.replace(D.escapeReplace,Pt)}else if(D.escapeTestNoEncode.test(t))return t.replace(D.escapeReplaceNoEncode,Pt);return t}function Mt(t){try{t=encodeURI(t).replace(D.percentDecode,"%")}catch{return null}return t}function $t(t,e){let n=t.replace(D.findPipe,(s,i,l)=>{let a=!1,c=i;for(;--c>=0&&l[c]==="\\";)a=!a;return a?"|":" |"}),o=n.split(D.splitPipe),r=0;if(o[0].trim()||o.shift(),o.length>0&&!o.at(-1)?.trim()&&o.pop(),e)if(o.length>e)o.splice(e);else for(;o.length<e;)o.push("");for(;r<o.length;r++)o[r]=o[r].trim().replace(D.slashPipe,"|");return o}function Ae(t,e,n){let o=t.length;if(o===0)return"";let r=0;for(;r<o;){let s=t.charAt(o-r-1);if(s===e&&!n)r++;else if(s!==e&&n)r++;else break}return t.slice(0,o-r)}function xr(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let o=0;o<t.length;o++)if(t[o]==="\\")o++;else if(t[o]===e[0])n++;else if(t[o]===e[1]&&(n--,n<0))return o;return n>0?-2:-1}function br(t,e=0){let n=e,o="";for(let r of t)if(r==="\t"){let s=4-n%4;o+=" ".repeat(s),n+=s}else o+=r,n++;return o}function Ot(t,e,n,o,r){let s=e.href,i=e.title||null,l=t[1].replace(r.other.outputLinkReplace,"$1");o.state.inLink=!0;let a={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:s,title:i,text:l,tokens:o.inlineTokens(l)};return o.state.inLink=!1,a}function yr(t,e,n){let o=t.match(n.other.indentCodeCompensation);if(o===null)return e;let r=o[1];return e.split(`
3
+ `).map((s)=>{let i=s.match(n.other.beginningSpace);if(i===null)return s;let[l]=i;return l.length>=r.length?s.slice(r.length):s}).join(`
4
+ `)}var _e=class{options;rules;lexer;constructor(t){this.options=t||he}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:Ae(n,`
5
+ `)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],o=yr(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:o}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let o=Ae(n,"#");(this.options.pedantic||!o||this.rules.other.endingSpaceChar.test(o))&&(n=o.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:Ae(e[0],`
6
+ `)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=Ae(e[0],`
7
7
  `).split(`
8
- `),W="",J="",X=[];for(;Y.length>0;){let K=!1,G=[],B;for(B=0;B<Y.length;B++)if(this.rules.other.blockquoteStart.test(Y[B]))G.push(Y[B]),K=!0;else if(!K)G.push(Y[B]);else break;Y=Y.slice(B);let q=G.join(`
9
- `),P=q.replace(this.rules.other.blockquoteSetextReplace,`
10
- $1`).replace(this.rules.other.blockquoteSetextReplace2,"");W=W?`${W}
11
- ${q}`:q,J=J?`${J}
12
- ${P}`:P;let H=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(P,X,!0),this.lexer.state.top=H,Y.length===0)break;let T=X.at(-1);if(T?.type==="code")break;if(T?.type==="blockquote"){let N=T,U=N.raw+`
13
- `+Y.join(`
14
- `),Z=this.blockquote(U);X[X.length-1]=Z,W=W.substring(0,W.length-N.raw.length)+Z.raw,J=J.substring(0,J.length-N.text.length)+Z.text;break}else if(T?.type==="list"){let N=T,U=N.raw+`
15
- `+Y.join(`
16
- `),Z=this.list(U);X[X.length-1]=Z,W=W.substring(0,W.length-T.raw.length)+Z.raw,J=J.substring(0,J.length-N.raw.length)+Z.raw,Y=U.substring(X.at(-1).raw.length).split(`
17
- `);continue}}return{type:"blockquote",raw:W,tokens:X,text:J}}}list(Q){let $=this.rules.block.list.exec(Q);if($){let Y=$[1].trim(),W=Y.length>1,J={type:"list",raw:"",ordered:W,start:W?+Y.slice(0,-1):"",loose:!1,items:[]};Y=W?`\\d{1,9}\\${Y.slice(-1)}`:`\\${Y}`,this.options.pedantic&&(Y=W?Y:"[*+-]");let X=this.rules.other.listItemRegex(Y),K=!1;for(;Q;){let B=!1,q="",P="";if(!($=X.exec(Q))||this.rules.block.hr.test(Q))break;q=$[0],Q=Q.substring(q.length);let H=r5($[2].split(`
18
- `,1)[0],$[1].length),T=Q.split(`
19
- `,1)[0],N=!H.trim(),U=0;if(this.options.pedantic?(U=2,P=H.trimStart()):N?U=$[1].length+1:(U=H.search(this.rules.other.nonSpaceChar),U=U>4?1:U,P=H.slice(U),U+=$[1].length),N&&this.rules.other.blankLine.test(T)&&(q+=T+`
20
- `,Q=Q.substring(T.length+1),B=!0),!B){let Z=this.rules.other.nextBulletRegex(U),F=this.rules.other.hrRegex(U),z=this.rules.other.fencesBeginRegex(U),k=this.rules.other.headingBeginRegex(U),M=this.rules.other.htmlBeginRegex(U),w=this.rules.other.blockquoteBeginRegex(U);for(;Q;){let b=Q.split(`
21
- `,1)[0],C;if(T=b,this.options.pedantic?(T=T.replace(this.rules.other.listReplaceNesting," "),C=T):C=T.replace(this.rules.other.tabCharGlobal," "),z.test(T)||k.test(T)||M.test(T)||w.test(T)||Z.test(T)||F.test(T))break;if(C.search(this.rules.other.nonSpaceChar)>=U||!T.trim())P+=`
22
- `+C.slice(U);else{if(N||H.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||z.test(H)||k.test(H)||F.test(H))break;P+=`
23
- `+T}N=!T.trim(),q+=b+`
24
- `,Q=Q.substring(b.length+1),H=C.slice(U)}}J.loose||(K?J.loose=!0:this.rules.other.doubleBlankLine.test(q)&&(K=!0)),J.items.push({type:"list_item",raw:q,task:!!this.options.gfm&&this.rules.other.listIsTask.test(P),loose:!1,text:P,tokens:[]}),J.raw+=q}let G=J.items.at(-1);if(G)G.raw=G.raw.trimEnd(),G.text=G.text.trimEnd();else return;J.raw=J.raw.trimEnd();for(let B of J.items){if(this.lexer.state.top=!1,B.tokens=this.lexer.blockTokens(B.text,[]),B.task){if(B.text=B.text.replace(this.rules.other.listReplaceTask,""),B.tokens[0]?.type==="text"||B.tokens[0]?.type==="paragraph"){B.tokens[0].raw=B.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),B.tokens[0].text=B.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let P=this.lexer.inlineQueue.length-1;P>=0;P--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[P].src)){this.lexer.inlineQueue[P].src=this.lexer.inlineQueue[P].src.replace(this.rules.other.listReplaceTask,"");break}}let q=this.rules.other.listTaskCheckbox.exec(B.raw);if(q){let P={type:"checkbox",raw:q[0]+" ",checked:q[0]!=="[ ]"};B.checked=P.checked,J.loose?B.tokens[0]&&["paragraph","text"].includes(B.tokens[0].type)&&"tokens"in B.tokens[0]&&B.tokens[0].tokens?(B.tokens[0].raw=P.raw+B.tokens[0].raw,B.tokens[0].text=P.raw+B.tokens[0].text,B.tokens[0].tokens.unshift(P)):B.tokens.unshift({type:"paragraph",raw:P.raw,text:P.raw,tokens:[P]}):B.tokens.unshift(P)}}if(!J.loose){let q=B.tokens.filter((H)=>H.type==="space"),P=q.length>0&&q.some((H)=>this.rules.other.anyLine.test(H.raw));J.loose=P}}if(J.loose)for(let B of J.items){B.loose=!0;for(let q of B.tokens)q.type==="text"&&(q.type="paragraph")}return J}}html(Q){let $=this.rules.block.html.exec(Q);if($)return{type:"html",block:!0,raw:$[0],pre:$[1]==="pre"||$[1]==="script"||$[1]==="style",text:$[0]}}def(Q){let $=this.rules.block.def.exec(Q);if($){let Y=$[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),W=$[2]?$[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",J=$[3]?$[3].substring(1,$[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):$[3];return{type:"def",tag:Y,raw:$[0],href:W,title:J}}}table(Q){let $=this.rules.block.table.exec(Q);if(!$||!this.rules.other.tableDelimiter.test($[2]))return;let Y=N1($[1]),W=$[2].replace(this.rules.other.tableAlignChars,"").split("|"),J=$[3]?.trim()?$[3].replace(this.rules.other.tableRowBlankLine,"").split(`
25
- `):[],X={type:"table",raw:$[0],header:[],align:[],rows:[]};if(Y.length===W.length){for(let K of W)this.rules.other.tableAlignRight.test(K)?X.align.push("right"):this.rules.other.tableAlignCenter.test(K)?X.align.push("center"):this.rules.other.tableAlignLeft.test(K)?X.align.push("left"):X.align.push(null);for(let K=0;K<Y.length;K++)X.header.push({text:Y[K],tokens:this.lexer.inline(Y[K]),header:!0,align:X.align[K]});for(let K of J)X.rows.push(N1(K,X.header.length).map((G,B)=>({text:G,tokens:this.lexer.inline(G),header:!1,align:X.align[B]})));return X}}lheading(Q){let $=this.rules.block.lheading.exec(Q);if($){let Y=$[1].trim();return{type:"heading",raw:$[0],depth:$[2].charAt(0)==="="?1:2,text:Y,tokens:this.lexer.inline(Y)}}}paragraph(Q){let $=this.rules.block.paragraph.exec(Q);if($){let Y=$[1].charAt($[1].length-1)===`
26
- `?$[1].slice(0,-1):$[1];return{type:"paragraph",raw:$[0],text:Y,tokens:this.lexer.inline(Y)}}}text(Q){let $=this.rules.block.text.exec(Q);if($)return{type:"text",raw:$[0],text:$[0],tokens:this.lexer.inline($[0])}}escape(Q){let $=this.rules.inline.escape.exec(Q);if($)return{type:"escape",raw:$[0],text:$[1]}}tag(Q){let $=this.rules.inline.tag.exec(Q);if($)return!this.lexer.state.inLink&&this.rules.other.startATag.test($[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test($[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test($[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test($[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:$[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:$[0]}}link(Q){let $=this.rules.inline.link.exec(Q);if($){let Y=$[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(Y)){if(!this.rules.other.endAngleBracket.test(Y))return;let X=O0(Y.slice(0,-1),"\\");if((Y.length-X.length)%2===0)return}else{let X=d5($[2],"()");if(X===-2)return;if(X>-1){let K=($[0].indexOf("!")===0?5:4)+$[1].length+X;$[2]=$[2].substring(0,X),$[0]=$[0].substring(0,K).trim(),$[3]=""}}let W=$[2],J="";if(this.options.pedantic){let X=this.rules.other.pedanticHrefTitle.exec(W);X&&(W=X[1],J=X[3])}else J=$[3]?$[3].slice(1,-1):"";return W=W.trim(),this.rules.other.startAngleBracket.test(W)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(Y)?W=W.slice(1):W=W.slice(1,-1)),T1($,{href:W&&W.replace(this.rules.inline.anyPunctuation,"$1"),title:J&&J.replace(this.rules.inline.anyPunctuation,"$1")},$[0],this.lexer,this.rules)}}reflink(Q,$){let Y;if((Y=this.rules.inline.reflink.exec(Q))||(Y=this.rules.inline.nolink.exec(Q))){let W=(Y[2]||Y[1]).replace(this.rules.other.multipleSpaceGlobal," "),J=$[W.toLowerCase()];if(!J){let X=Y[0].charAt(0);return{type:"text",raw:X,text:X}}return T1(Y,J,Y[0],this.lexer,this.rules)}}emStrong(Q,$,Y=""){let W=this.rules.inline.emStrongLDelim.exec(Q);if(!W||!W[1]&&!W[2]&&!W[3]&&!W[4]||W[4]&&Y.match(this.rules.other.unicodeAlphaNumeric))return;if(!(W[1]||W[3])||!Y||this.rules.inline.punctuation.exec(Y)){let J=[...W[0]].length-1,X,K,G=J,B=0,q=W[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(q.lastIndex=0,$=$.slice(-1*Q.length+J);(W=q.exec($))!==null;){if(X=W[1]||W[2]||W[3]||W[4]||W[5]||W[6],!X)continue;if(K=[...X].length,W[3]||W[4]){G+=K;continue}else if((W[5]||W[6])&&J%3&&!((J+K)%3)){B+=K;continue}if(G-=K,G>0)continue;K=Math.min(K,K+G+B);let P=[...W[0]][0].length,H=Q.slice(0,J+W.index+P+K);if(Math.min(J,K)%2){let N=H.slice(1,-1);return{type:"em",raw:H,text:N,tokens:this.lexer.inlineTokens(N)}}let T=H.slice(2,-2);return{type:"strong",raw:H,text:T,tokens:this.lexer.inlineTokens(T)}}}}codespan(Q){let $=this.rules.inline.code.exec(Q);if($){let Y=$[2].replace(this.rules.other.newLineCharGlobal," "),W=this.rules.other.nonSpaceChar.test(Y),J=this.rules.other.startingSpaceChar.test(Y)&&this.rules.other.endingSpaceChar.test(Y);return W&&J&&(Y=Y.substring(1,Y.length-1)),{type:"codespan",raw:$[0],text:Y}}}br(Q){let $=this.rules.inline.br.exec(Q);if($)return{type:"br",raw:$[0]}}del(Q,$,Y=""){let W=this.rules.inline.delLDelim.exec(Q);if(!W)return;if(!W[1]||!Y||this.rules.inline.punctuation.exec(Y)){let J=[...W[0]].length-1,X,K,G=J,B=this.rules.inline.delRDelim;for(B.lastIndex=0,$=$.slice(-1*Q.length+J);(W=B.exec($))!==null;){if(X=W[1]||W[2]||W[3]||W[4]||W[5]||W[6],!X||(K=[...X].length,K!==J))continue;if(W[3]||W[4]){G+=K;continue}if(G-=K,G>0)continue;K=Math.min(K,K+G);let q=[...W[0]][0].length,P=Q.slice(0,J+W.index+q+K),H=P.slice(J,-J);return{type:"del",raw:P,text:H,tokens:this.lexer.inlineTokens(H)}}}}autolink(Q){let $=this.rules.inline.autolink.exec(Q);if($){let Y,W;return $[2]==="@"?(Y=$[1],W="mailto:"+Y):(Y=$[1],W=Y),{type:"link",raw:$[0],text:Y,href:W,tokens:[{type:"text",raw:Y,text:Y}]}}}url(Q){let $;if($=this.rules.inline.url.exec(Q)){let Y,W;if($[2]==="@")Y=$[0],W="mailto:"+Y;else{let J;do J=$[0],$[0]=this.rules.inline._backpedal.exec($[0])?.[0]??"";while(J!==$[0]);Y=$[0],$[1]==="www."?W="http://"+$[0]:W=$[0]}return{type:"link",raw:$[0],text:Y,href:W,tokens:[{type:"text",raw:Y,text:Y}]}}}inlineText(Q){let $=this.rules.inline.text.exec(Q);if($){let Y=this.lexer.state.inRawBlock;return{type:"text",raw:$[0],text:$[0],escaped:Y}}}},i=class Q{tokens;options;state;inlineQueue;tokenizer;constructor($){this.tokens=[],this.tokens.links=Object.create(null),this.options=$||U0,this.options.tokenizer=this.options.tokenizer||new v0,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let Y={other:x,block:R0.normal,inline:w0.normal};this.options.pedantic?(Y.block=R0.pedantic,Y.inline=w0.pedantic):this.options.gfm&&(Y.block=R0.gfm,this.options.breaks?Y.inline=w0.breaks:Y.inline=w0.gfm),this.tokenizer.rules=Y}static get rules(){return{block:R0,inline:w0}}static lex($,Y){return new Q(Y).lex($)}static lexInline($,Y){return new Q(Y).inlineTokens($)}lex($){$=$.replace(x.carriageReturn,`
27
- `),this.blockTokens($,this.tokens);for(let Y=0;Y<this.inlineQueue.length;Y++){let W=this.inlineQueue[Y];this.inlineTokens(W.src,W.tokens)}return this.inlineQueue=[],this.tokens}blockTokens($,Y=[],W=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&($=$.replace(x.tabCharGlobal," ").replace(x.spaceLine,""));$;){let J;if(this.options.extensions?.block?.some((K)=>(J=K.call({lexer:this},$,Y))?($=$.substring(J.raw.length),Y.push(J),!0):!1))continue;if(J=this.tokenizer.space($)){$=$.substring(J.raw.length);let K=Y.at(-1);J.raw.length===1&&K!==void 0?K.raw+=`
28
- `:Y.push(J);continue}if(J=this.tokenizer.code($)){$=$.substring(J.raw.length);let K=Y.at(-1);K?.type==="paragraph"||K?.type==="text"?(K.raw+=(K.raw.endsWith(`
8
+ `),o="",r="",s=[];for(;n.length>0;){let i=!1,l=[],a;for(a=0;a<n.length;a++)if(this.rules.other.blockquoteStart.test(n[a]))l.push(n[a]),i=!0;else if(!i)l.push(n[a]);else break;n=n.slice(a);let c=l.join(`
9
+ `),u=c.replace(this.rules.other.blockquoteSetextReplace,`
10
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");o=o?`${o}
11
+ ${c}`:c,r=r?`${r}
12
+ ${u}`:u;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,s,!0),this.lexer.state.top=p,n.length===0)break;let g=s.at(-1);if(g?.type==="code")break;if(g?.type==="blockquote"){let h=g,d=h.raw+`
13
+ `+n.join(`
14
+ `),f=this.blockquote(d);s[s.length-1]=f,o=o.substring(0,o.length-h.raw.length)+f.raw,r=r.substring(0,r.length-h.text.length)+f.text;break}else if(g?.type==="list"){let h=g,d=h.raw+`
15
+ `+n.join(`
16
+ `),f=this.list(d);s[s.length-1]=f,o=o.substring(0,o.length-g.raw.length)+f.raw,r=r.substring(0,r.length-h.raw.length)+f.raw,n=d.substring(s.at(-1).raw.length).split(`
17
+ `);continue}}return{type:"blockquote",raw:o,tokens:s,text:r}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim(),o=n.length>1,r={type:"list",raw:"",ordered:o,start:o?+n.slice(0,-1):"",loose:!1,items:[]};n=o?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=o?n:"[*+-]");let s=this.rules.other.listItemRegex(n),i=!1;for(;t;){let a=!1,c="",u="";if(!(e=s.exec(t))||this.rules.block.hr.test(t))break;c=e[0],t=t.substring(c.length);let p=br(e[2].split(`
18
+ `,1)[0],e[1].length),g=t.split(`
19
+ `,1)[0],h=!p.trim(),d=0;if(this.options.pedantic?(d=2,u=p.trimStart()):h?d=e[1].length+1:(d=p.search(this.rules.other.nonSpaceChar),d=d>4?1:d,u=p.slice(d),d+=e[1].length),h&&this.rules.other.blankLine.test(g)&&(c+=g+`
20
+ `,t=t.substring(g.length+1),a=!0),!a){let f=this.rules.other.nextBulletRegex(d),m=this.rules.other.hrRegex(d),b=this.rules.other.fencesBeginRegex(d),R=this.rules.other.headingBeginRegex(d),v=this.rules.other.htmlBeginRegex(d),w=this.rules.other.blockquoteBeginRegex(d);for(;t;){let N=t.split(`
21
+ `,1)[0],L;if(g=N,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),L=g):L=g.replace(this.rules.other.tabCharGlobal," "),b.test(g)||R.test(g)||v.test(g)||w.test(g)||f.test(g)||m.test(g))break;if(L.search(this.rules.other.nonSpaceChar)>=d||!g.trim())u+=`
22
+ `+L.slice(d);else{if(h||p.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||b.test(p)||R.test(p)||m.test(p))break;u+=`
23
+ `+g}h=!g.trim(),c+=N+`
24
+ `,t=t.substring(N.length+1),p=L.slice(d)}}r.loose||(i?r.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(i=!0)),r.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(u),loose:!1,text:u,tokens:[]}),r.raw+=c}let l=r.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let a of r.items){if(this.lexer.state.top=!1,a.tokens=this.lexer.blockTokens(a.text,[]),a.task){if(a.text=a.text.replace(this.rules.other.listReplaceTask,""),a.tokens[0]?.type==="text"||a.tokens[0]?.type==="paragraph"){a.tokens[0].raw=a.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),a.tokens[0].text=a.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let u=this.lexer.inlineQueue.length-1;u>=0;u--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[u].src)){this.lexer.inlineQueue[u].src=this.lexer.inlineQueue[u].src.replace(this.rules.other.listReplaceTask,"");break}}let c=this.rules.other.listTaskCheckbox.exec(a.raw);if(c){let u={type:"checkbox",raw:c[0]+" ",checked:c[0]!=="[ ]"};a.checked=u.checked,r.loose?a.tokens[0]&&["paragraph","text"].includes(a.tokens[0].type)&&"tokens"in a.tokens[0]&&a.tokens[0].tokens?(a.tokens[0].raw=u.raw+a.tokens[0].raw,a.tokens[0].text=u.raw+a.tokens[0].text,a.tokens[0].tokens.unshift(u)):a.tokens.unshift({type:"paragraph",raw:u.raw,text:u.raw,tokens:[u]}):a.tokens.unshift(u)}}if(!r.loose){let c=a.tokens.filter((p)=>p.type==="space"),u=c.length>0&&c.some((p)=>this.rules.other.anyLine.test(p.raw));r.loose=u}}if(r.loose)for(let a of r.items){a.loose=!0;for(let c of a.tokens)c.type==="text"&&(c.type="paragraph")}return r}}html(t){let e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),o=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:e[0],href:o,title:r}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=$t(e[1]),o=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
25
+ `):[],s={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.length===o.length){for(let i of o)this.rules.other.tableAlignRight.test(i)?s.align.push("right"):this.rules.other.tableAlignCenter.test(i)?s.align.push("center"):this.rules.other.tableAlignLeft.test(i)?s.align.push("left"):s.align.push(null);for(let i=0;i<n.length;i++)s.header.push({text:n[i],tokens:this.lexer.inline(n[i]),header:!0,align:s.align[i]});for(let i of r)s.rows.push($t(i,s.header.length).map((l,a)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:s.align[a]})));return s}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let n=e[1].trim();return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===`
26
+ `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let s=Ae(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else{let s=xr(e[2],"()");if(s===-2)return;if(s>-1){let i=(e[0].indexOf("!")===0?5:4)+e[1].length+s;e[2]=e[2].substring(0,s),e[0]=e[0].substring(0,i).trim(),e[3]=""}}let o=e[2],r="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(o);s&&(o=s[1],r=s[3])}else r=e[3]?e[3].slice(1,-1):"";return o=o.trim(),this.rules.other.startAngleBracket.test(o)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?o=o.slice(1):o=o.slice(1,-1)),Ot(e,{href:o&&o.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let o=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=e[o.toLowerCase()];if(!r){let s=n[0].charAt(0);return{type:"text",raw:s,text:s}}return Ot(n,r,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let o=this.rules.inline.emStrongLDelim.exec(t);if(!o||!o[1]&&!o[2]&&!o[3]&&!o[4]||o[4]&&n.match(this.rules.other.unicodeAlphaNumeric))return;if(!(o[1]||o[3])||!n||this.rules.inline.punctuation.exec(n)){let r=[...o[0]].length-1,s,i,l=r,a=0,c=o[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,e=e.slice(-1*t.length+r);(o=c.exec(e))!==null;){if(s=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!s)continue;if(i=[...s].length,o[3]||o[4]){l+=i;continue}else if((o[5]||o[6])&&r%3&&!((r+i)%3)){a+=i;continue}if(l-=i,l>0)continue;i=Math.min(i,i+l+a);let u=[...o[0]][0].length,p=t.slice(0,r+o.index+u+i);if(Math.min(r,i)%2){let h=p.slice(1,-1);return{type:"em",raw:p,text:h,tokens:this.lexer.inlineTokens(h)}}let g=p.slice(2,-2);return{type:"strong",raw:p,text:g,tokens:this.lexer.inlineTokens(g)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," "),o=this.rules.other.nonSpaceChar.test(n),r=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return o&&r&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,n=""){let o=this.rules.inline.delLDelim.exec(t);if(!o)return;if(!o[1]||!n||this.rules.inline.punctuation.exec(n)){let r=[...o[0]].length-1,s,i,l=r,a=this.rules.inline.delRDelim;for(a.lastIndex=0,e=e.slice(-1*t.length+r);(o=a.exec(e))!==null;){if(s=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!s||(i=[...s].length,i!==r))continue;if(o[3]||o[4]){l+=i;continue}if(l-=i,l>0)continue;i=Math.min(i,i+l);let c=[...o[0]][0].length,u=t.slice(0,r+o.index+c+i),p=u.slice(r,-r);return{type:"del",raw:u,text:p,tokens:this.lexer.inlineTokens(p)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,o;return e[2]==="@"?(n=e[1],o="mailto:"+n):(n=e[1],o=n),{type:"link",raw:e[0],text:n,href:o,tokens:[{type:"text",raw:n,text:n}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let n,o;if(e[2]==="@")n=e[0],o="mailto:"+n;else{let r;do r=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(r!==e[0]);n=e[0],e[1]==="www."?o="http://"+e[0]:o=e[0]}return{type:"link",raw:e[0],text:n,href:o,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},K=class t{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||he,this.options.tokenizer=this.options.tokenizer||new _e,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:D,block:$e.normal,inline:Se.normal};this.options.pedantic?(n.block=$e.pedantic,n.inline=Se.pedantic):this.options.gfm&&(n.block=$e.gfm,this.options.breaks?n.inline=Se.breaks:n.inline=Se.gfm),this.tokenizer.rules=n}static get rules(){return{block:$e,inline:Se}}static lex(e,n){return new t(n).lex(e)}static lexInline(e,n){return new t(n).inlineTokens(e)}lex(e){e=e.replace(D.carriageReturn,`
27
+ `),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let o=this.inlineQueue[n];this.inlineTokens(o.src,o.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],o=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(D.tabCharGlobal," ").replace(D.spaceLine,""));e;){let r;if(this.options.extensions?.block?.some((i)=>(r=i.call({lexer:this},e,n))?(e=e.substring(r.raw.length),n.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let i=n.at(-1);r.raw.length===1&&i!==void 0?i.raw+=`
28
+ `:n.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let i=n.at(-1);i?.type==="paragraph"||i?.type==="text"?(i.raw+=(i.raw.endsWith(`
29
29
  `)?"":`
30
- `)+J.raw,K.text+=`
31
- `+J.text,this.inlineQueue.at(-1).src=K.text):Y.push(J);continue}if(J=this.tokenizer.fences($)){$=$.substring(J.raw.length),Y.push(J);continue}if(J=this.tokenizer.heading($)){$=$.substring(J.raw.length),Y.push(J);continue}if(J=this.tokenizer.hr($)){$=$.substring(J.raw.length),Y.push(J);continue}if(J=this.tokenizer.blockquote($)){$=$.substring(J.raw.length),Y.push(J);continue}if(J=this.tokenizer.list($)){$=$.substring(J.raw.length),Y.push(J);continue}if(J=this.tokenizer.html($)){$=$.substring(J.raw.length),Y.push(J);continue}if(J=this.tokenizer.def($)){$=$.substring(J.raw.length);let K=Y.at(-1);K?.type==="paragraph"||K?.type==="text"?(K.raw+=(K.raw.endsWith(`
30
+ `)+r.raw,i.text+=`
31
+ `+r.text,this.inlineQueue.at(-1).src=i.text):n.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let i=n.at(-1);i?.type==="paragraph"||i?.type==="text"?(i.raw+=(i.raw.endsWith(`
32
32
  `)?"":`
33
- `)+J.raw,K.text+=`
34
- `+J.raw,this.inlineQueue.at(-1).src=K.text):this.tokens.links[J.tag]||(this.tokens.links[J.tag]={href:J.href,title:J.title},Y.push(J));continue}if(J=this.tokenizer.table($)){$=$.substring(J.raw.length),Y.push(J);continue}if(J=this.tokenizer.lheading($)){$=$.substring(J.raw.length),Y.push(J);continue}let X=$;if(this.options.extensions?.startBlock){let K=1/0,G=$.slice(1),B;this.options.extensions.startBlock.forEach((q)=>{B=q.call({lexer:this},G),typeof B=="number"&&B>=0&&(K=Math.min(K,B))}),K<1/0&&K>=0&&(X=$.substring(0,K+1))}if(this.state.top&&(J=this.tokenizer.paragraph(X))){let K=Y.at(-1);W&&K?.type==="paragraph"?(K.raw+=(K.raw.endsWith(`
33
+ `)+r.raw,i.text+=`
34
+ `+r.raw,this.inlineQueue.at(-1).src=i.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},n.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),n.push(r);continue}let s=e;if(this.options.extensions?.startBlock){let i=1/0,l=e.slice(1),a;this.options.extensions.startBlock.forEach((c)=>{a=c.call({lexer:this},l),typeof a=="number"&&a>=0&&(i=Math.min(i,a))}),i<1/0&&i>=0&&(s=e.substring(0,i+1))}if(this.state.top&&(r=this.tokenizer.paragraph(s))){let i=n.at(-1);o&&i?.type==="paragraph"?(i.raw+=(i.raw.endsWith(`
35
35
  `)?"":`
36
- `)+J.raw,K.text+=`
37
- `+J.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=K.text):Y.push(J),W=X.length!==$.length,$=$.substring(J.raw.length);continue}if(J=this.tokenizer.text($)){$=$.substring(J.raw.length);let K=Y.at(-1);K?.type==="text"?(K.raw+=(K.raw.endsWith(`
36
+ `)+r.raw,i.text+=`
37
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):n.push(r),o=s.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let i=n.at(-1);i?.type==="text"?(i.raw+=(i.raw.endsWith(`
38
38
  `)?"":`
39
- `)+J.raw,K.text+=`
40
- `+J.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=K.text):Y.push(J);continue}if($){let K="Infinite loop on byte: "+$.charCodeAt(0);if(this.options.silent){console.error(K);break}else throw Error(K)}}return this.state.top=!0,Y}inline($,Y=[]){return this.inlineQueue.push({src:$,tokens:Y}),Y}inlineTokens($,Y=[]){this.tokenizer.lexer=this;let W=$,J=null;if(this.tokens.links){let B=Object.keys(this.tokens.links);if(B.length>0)for(;(J=this.tokenizer.rules.inline.reflinkSearch.exec(W))!==null;)B.includes(J[0].slice(J[0].lastIndexOf("[")+1,-1))&&(W=W.slice(0,J.index)+"["+"a".repeat(J[0].length-2)+"]"+W.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(J=this.tokenizer.rules.inline.anyPunctuation.exec(W))!==null;)W=W.slice(0,J.index)+"++"+W.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let X;for(;(J=this.tokenizer.rules.inline.blockSkip.exec(W))!==null;)X=J[2]?J[2].length:0,W=W.slice(0,J.index+X)+"["+"a".repeat(J[0].length-X-2)+"]"+W.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);W=this.options.hooks?.emStrongMask?.call({lexer:this},W)??W;let K=!1,G="";for(;$;){K||(G=""),K=!1;let B;if(this.options.extensions?.inline?.some((P)=>(B=P.call({lexer:this},$,Y))?($=$.substring(B.raw.length),Y.push(B),!0):!1))continue;if(B=this.tokenizer.escape($)){$=$.substring(B.raw.length),Y.push(B);continue}if(B=this.tokenizer.tag($)){$=$.substring(B.raw.length),Y.push(B);continue}if(B=this.tokenizer.link($)){$=$.substring(B.raw.length),Y.push(B);continue}if(B=this.tokenizer.reflink($,this.tokens.links)){$=$.substring(B.raw.length);let P=Y.at(-1);B.type==="text"&&P?.type==="text"?(P.raw+=B.raw,P.text+=B.text):Y.push(B);continue}if(B=this.tokenizer.emStrong($,W,G)){$=$.substring(B.raw.length),Y.push(B);continue}if(B=this.tokenizer.codespan($)){$=$.substring(B.raw.length),Y.push(B);continue}if(B=this.tokenizer.br($)){$=$.substring(B.raw.length),Y.push(B);continue}if(B=this.tokenizer.del($,W,G)){$=$.substring(B.raw.length),Y.push(B);continue}if(B=this.tokenizer.autolink($)){$=$.substring(B.raw.length),Y.push(B);continue}if(!this.state.inLink&&(B=this.tokenizer.url($))){$=$.substring(B.raw.length),Y.push(B);continue}let q=$;if(this.options.extensions?.startInline){let P=1/0,H=$.slice(1),T;this.options.extensions.startInline.forEach((N)=>{T=N.call({lexer:this},H),typeof T=="number"&&T>=0&&(P=Math.min(P,T))}),P<1/0&&P>=0&&(q=$.substring(0,P+1))}if(B=this.tokenizer.inlineText(q)){$=$.substring(B.raw.length),B.raw.slice(-1)!=="_"&&(G=B.raw.slice(-1)),K=!0;let P=Y.at(-1);P?.type==="text"?(P.raw+=B.raw,P.text+=B.text):Y.push(B);continue}if($){let P="Infinite loop on byte: "+$.charCodeAt(0);if(this.options.silent){console.error(P);break}else throw Error(P)}}return Y}},V0=class{options;parser;constructor(Q){this.options=Q||U0}space(Q){return""}code({text:Q,lang:$,escaped:Y}){let W=($||"").match(x.notSpaceStart)?.[0],J=Q.replace(x.endingNewline,"")+`
41
- `;return W?'<pre><code class="language-'+$0(W)+'">'+(Y?J:$0(J,!0))+`</code></pre>
42
- `:"<pre><code>"+(Y?J:$0(J,!0))+`</code></pre>
43
- `}blockquote({tokens:Q}){return`<blockquote>
44
- ${this.parser.parse(Q)}</blockquote>
45
- `}html({text:Q}){return Q}def(Q){return""}heading({tokens:Q,depth:$}){return`<h${$}>${this.parser.parseInline(Q)}</h${$}>
46
- `}hr(Q){return`<hr>
47
- `}list(Q){let{ordered:$,start:Y}=Q,W="";for(let K=0;K<Q.items.length;K++){let G=Q.items[K];W+=this.listitem(G)}let J=$?"ol":"ul",X=$&&Y!==1?' start="'+Y+'"':"";return"<"+J+X+`>
48
- `+W+"</"+J+`>
49
- `}listitem(Q){return`<li>${this.parser.parse(Q.tokens)}</li>
50
- `}checkbox({checked:Q}){return"<input "+(Q?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:Q}){return`<p>${this.parser.parseInline(Q)}</p>
51
- `}table(Q){let $="",Y="";for(let J=0;J<Q.header.length;J++)Y+=this.tablecell(Q.header[J]);$+=this.tablerow({text:Y});let W="";for(let J=0;J<Q.rows.length;J++){let X=Q.rows[J];Y="";for(let K=0;K<X.length;K++)Y+=this.tablecell(X[K]);W+=this.tablerow({text:Y})}return W&&(W=`<tbody>${W}</tbody>`),`<table>
39
+ `)+r.raw,i.text+=`
40
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):n.push(r);continue}if(e){let i="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(i);break}else throw Error(i)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){this.tokenizer.lexer=this;let o=e,r=null;if(this.tokens.links){let a=Object.keys(this.tokens.links);if(a.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(o))!==null;)a.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(o=o.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(o))!==null;)o=o.slice(0,r.index)+"++"+o.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(o))!==null;)s=r[2]?r[2].length:0,o=o.slice(0,r.index+s)+"["+"a".repeat(r[0].length-s-2)+"]"+o.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);o=this.options.hooks?.emStrongMask?.call({lexer:this},o)??o;let i=!1,l="";for(;e;){i||(l=""),i=!1;let a;if(this.options.extensions?.inline?.some((u)=>(a=u.call({lexer:this},e,n))?(e=e.substring(a.raw.length),n.push(a),!0):!1))continue;if(a=this.tokenizer.escape(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.tag(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.link(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(a.raw.length);let u=n.at(-1);a.type==="text"&&u?.type==="text"?(u.raw+=a.raw,u.text+=a.text):n.push(a);continue}if(a=this.tokenizer.emStrong(e,o,l)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.codespan(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.br(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.del(e,o,l)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.autolink(e)){e=e.substring(a.raw.length),n.push(a);continue}if(!this.state.inLink&&(a=this.tokenizer.url(e))){e=e.substring(a.raw.length),n.push(a);continue}let c=e;if(this.options.extensions?.startInline){let u=1/0,p=e.slice(1),g;this.options.extensions.startInline.forEach((h)=>{g=h.call({lexer:this},p),typeof g=="number"&&g>=0&&(u=Math.min(u,g))}),u<1/0&&u>=0&&(c=e.substring(0,u+1))}if(a=this.tokenizer.inlineText(c)){e=e.substring(a.raw.length),a.raw.slice(-1)!=="_"&&(l=a.raw.slice(-1)),i=!0;let u=n.at(-1);u?.type==="text"?(u.raw+=a.raw,u.text+=a.text):n.push(a);continue}if(e){let u="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw Error(u)}}return n}},He=class{options;parser;constructor(t){this.options=t||he}space(t){return""}code({text:t,lang:e,escaped:n}){let o=(e||"").match(D.notSpaceStart)?.[0],r=t.replace(D.endingNewline,"")+`
41
+ `;return o?'<pre><code class="language-'+te(o)+'">'+(n?r:te(r,!0))+`</code></pre>
42
+ `:"<pre><code>"+(n?r:te(r,!0))+`</code></pre>
43
+ `}blockquote({tokens:t}){return`<blockquote>
44
+ ${this.parser.parse(t)}</blockquote>
45
+ `}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
46
+ `}hr(t){return`<hr>
47
+ `}list(t){let{ordered:e,start:n}=t,o="";for(let i=0;i<t.items.length;i++){let l=t.items[i];o+=this.listitem(l)}let r=e?"ol":"ul",s=e&&n!==1?' start="'+n+'"':"";return"<"+r+s+`>
48
+ `+o+"</"+r+`>
49
+ `}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>
50
+ `}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
51
+ `}table(t){let e="",n="";for(let r=0;r<t.header.length;r++)n+=this.tablecell(t.header[r]);e+=this.tablerow({text:n});let o="";for(let r=0;r<t.rows.length;r++){let s=t.rows[r];n="";for(let i=0;i<s.length;i++)n+=this.tablecell(s[i]);o+=this.tablerow({text:n})}return o&&(o=`<tbody>${o}</tbody>`),`<table>
52
52
  <thead>
53
- `+$+`</thead>
54
- `+W+`</table>
55
- `}tablerow({text:Q}){return`<tr>
56
- ${Q}</tr>
57
- `}tablecell(Q){let $=this.parser.parseInline(Q.tokens),Y=Q.header?"th":"td";return(Q.align?`<${Y} align="${Q.align}">`:`<${Y}>`)+$+`</${Y}>
58
- `}strong({tokens:Q}){return`<strong>${this.parser.parseInline(Q)}</strong>`}em({tokens:Q}){return`<em>${this.parser.parseInline(Q)}</em>`}codespan({text:Q}){return`<code>${$0(Q,!0)}</code>`}br(Q){return"<br>"}del({tokens:Q}){return`<del>${this.parser.parseInline(Q)}</del>`}link({href:Q,title:$,tokens:Y}){let W=this.parser.parseInline(Y),J=Z1(Q);if(J===null)return W;Q=J;let X='<a href="'+Q+'"';return $&&(X+=' title="'+$0($)+'"'),X+=">"+W+"</a>",X}image({href:Q,title:$,text:Y,tokens:W}){W&&(Y=this.parser.parseInline(W,this.parser.textRenderer));let J=Z1(Q);if(J===null)return $0(Y);Q=J;let X=`<img src="${Q}" alt="${$0(Y)}"`;return $&&(X+=` title="${$0($)}"`),X+=">",X}text(Q){return"tokens"in Q&&Q.tokens?this.parser.parseInline(Q.tokens):("escaped"in Q)&&Q.escaped?Q.text:$0(Q.text)}},Q1=class{strong({text:Q}){return Q}em({text:Q}){return Q}codespan({text:Q}){return Q}del({text:Q}){return Q}html({text:Q}){return Q}text({text:Q}){return Q}link({text:Q}){return""+Q}image({text:Q}){return""+Q}br(){return""}checkbox({raw:Q}){return Q}},o=class Q{options;renderer;textRenderer;constructor($){this.options=$||U0,this.options.renderer=this.options.renderer||new V0,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Q1}static parse($,Y){return new Q(Y).parse($)}static parseInline($,Y){return new Q(Y).parseInline($)}parse($){this.renderer.parser=this;let Y="";for(let W=0;W<$.length;W++){let J=$[W];if(this.options.extensions?.renderers?.[J.type]){let K=J,G=this.options.extensions.renderers[K.type].call({parser:this},K);if(G!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(K.type)){Y+=G||"";continue}}let X=J;switch(X.type){case"space":{Y+=this.renderer.space(X);break}case"hr":{Y+=this.renderer.hr(X);break}case"heading":{Y+=this.renderer.heading(X);break}case"code":{Y+=this.renderer.code(X);break}case"table":{Y+=this.renderer.table(X);break}case"blockquote":{Y+=this.renderer.blockquote(X);break}case"list":{Y+=this.renderer.list(X);break}case"checkbox":{Y+=this.renderer.checkbox(X);break}case"html":{Y+=this.renderer.html(X);break}case"def":{Y+=this.renderer.def(X);break}case"paragraph":{Y+=this.renderer.paragraph(X);break}case"text":{Y+=this.renderer.text(X);break}default:{let K='Token with "'+X.type+'" type was not found.';if(this.options.silent)return console.error(K),"";throw Error(K)}}}return Y}parseInline($,Y=this.renderer){this.renderer.parser=this;let W="";for(let J=0;J<$.length;J++){let X=$[J];if(this.options.extensions?.renderers?.[X.type]){let G=this.options.extensions.renderers[X.type].call({parser:this},X);if(G!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(X.type)){W+=G||"";continue}}let K=X;switch(K.type){case"escape":{W+=Y.text(K);break}case"html":{W+=Y.html(K);break}case"link":{W+=Y.link(K);break}case"image":{W+=Y.image(K);break}case"checkbox":{W+=Y.checkbox(K);break}case"strong":{W+=Y.strong(K);break}case"em":{W+=Y.em(K);break}case"codespan":{W+=Y.codespan(K);break}case"br":{W+=Y.br(K);break}case"del":{W+=Y.del(K);break}case"text":{W+=Y.text(K);break}default:{let G='Token with "'+K.type+'" type was not found.';if(this.options.silent)return console.error(G),"";throw Error(G)}}}return W}},y0=class{options;block;constructor(Q){this.options=Q||U0}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(Q){return Q}postprocess(Q){return Q}processAllTokens(Q){return Q}emStrongMask(Q){return Q}provideLexer(Q=this.block){return Q?i.lex:i.lexInline}provideParser(Q=this.block){return Q?o.parse:o.parseInline}},i5=class{defaults=i0();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=o;Renderer=V0;TextRenderer=Q1;Lexer=i;Tokenizer=v0;Hooks=y0;constructor(...Q){this.use(...Q)}walkTokens(Q,$){let Y=[];for(let W of Q)switch(Y=Y.concat($.call(this,W)),W.type){case"table":{let J=W;for(let X of J.header)Y=Y.concat(this.walkTokens(X.tokens,$));for(let X of J.rows)for(let K of X)Y=Y.concat(this.walkTokens(K.tokens,$));break}case"list":{let J=W;Y=Y.concat(this.walkTokens(J.items,$));break}default:{let J=W;this.defaults.extensions?.childTokens?.[J.type]?this.defaults.extensions.childTokens[J.type].forEach((X)=>{let K=J[X].flat(1/0);Y=Y.concat(this.walkTokens(K,$))}):J.tokens&&(Y=Y.concat(this.walkTokens(J.tokens,$)))}}return Y}use(...Q){let $=this.defaults.extensions||{renderers:{},childTokens:{}};return Q.forEach((Y)=>{let W={...Y};if(W.async=this.defaults.async||W.async||!1,Y.extensions&&(Y.extensions.forEach((J)=>{if(!J.name)throw Error("extension name required");if("renderer"in J){let X=$.renderers[J.name];X?$.renderers[J.name]=function(...K){let G=J.renderer.apply(this,K);return G===!1&&(G=X.apply(this,K)),G}:$.renderers[J.name]=J.renderer}if("tokenizer"in J){if(!J.level||J.level!=="block"&&J.level!=="inline")throw Error("extension level must be 'block' or 'inline'");let X=$[J.level];X?X.unshift(J.tokenizer):$[J.level]=[J.tokenizer],J.start&&(J.level==="block"?$.startBlock?$.startBlock.push(J.start):$.startBlock=[J.start]:J.level==="inline"&&($.startInline?$.startInline.push(J.start):$.startInline=[J.start]))}"childTokens"in J&&J.childTokens&&($.childTokens[J.name]=J.childTokens)}),W.extensions=$),Y.renderer){let J=this.defaults.renderer||new V0(this.defaults);for(let X in Y.renderer){if(!(X in J))throw Error(`renderer '${X}' does not exist`);if(["options","parser"].includes(X))continue;let K=X,G=Y.renderer[K],B=J[K];J[K]=(...q)=>{let P=G.apply(J,q);return P===!1&&(P=B.apply(J,q)),P||""}}W.renderer=J}if(Y.tokenizer){let J=this.defaults.tokenizer||new v0(this.defaults);for(let X in Y.tokenizer){if(!(X in J))throw Error(`tokenizer '${X}' does not exist`);if(["options","rules","lexer"].includes(X))continue;let K=X,G=Y.tokenizer[K],B=J[K];J[K]=(...q)=>{let P=G.apply(J,q);return P===!1&&(P=B.apply(J,q)),P}}W.tokenizer=J}if(Y.hooks){let J=this.defaults.hooks||new y0;for(let X in Y.hooks){if(!(X in J))throw Error(`hook '${X}' does not exist`);if(["options","block"].includes(X))continue;let K=X,G=Y.hooks[K],B=J[K];y0.passThroughHooks.has(X)?J[K]=(q)=>{if(this.defaults.async&&y0.passThroughHooksRespectAsync.has(X))return(async()=>{let H=await G.call(J,q);return B.call(J,H)})();let P=G.call(J,q);return B.call(J,P)}:J[K]=(...q)=>{if(this.defaults.async)return(async()=>{let H=await G.apply(J,q);return H===!1&&(H=await B.apply(J,q)),H})();let P=G.apply(J,q);return P===!1&&(P=B.apply(J,q)),P}}W.hooks=J}if(Y.walkTokens){let J=this.defaults.walkTokens,X=Y.walkTokens;W.walkTokens=function(K){let G=[];return G.push(X.call(this,K)),J&&(G=G.concat(J.call(this,K))),G}}this.defaults={...this.defaults,...W}}),this}setOptions(Q){return this.defaults={...this.defaults,...Q},this}lexer(Q,$){return i.lex(Q,$??this.defaults)}parser(Q,$){return o.parse(Q,$??this.defaults)}parseMarkdown(Q){return($,Y)=>{let W={...Y},J={...this.defaults,...W},X=this.onError(!!J.silent,!!J.async);if(this.defaults.async===!0&&W.async===!1)return X(Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof $>"u"||$===null)return X(Error("marked(): input parameter is undefined or null"));if(typeof $!="string")return X(Error("marked(): input parameter is of type "+Object.prototype.toString.call($)+", string expected"));if(J.hooks&&(J.hooks.options=J,J.hooks.block=Q),J.async)return(async()=>{let K=J.hooks?await J.hooks.preprocess($):$,G=await(J.hooks?await J.hooks.provideLexer(Q):Q?i.lex:i.lexInline)(K,J),B=J.hooks?await J.hooks.processAllTokens(G):G;J.walkTokens&&await Promise.all(this.walkTokens(B,J.walkTokens));let q=await(J.hooks?await J.hooks.provideParser(Q):Q?o.parse:o.parseInline)(B,J);return J.hooks?await J.hooks.postprocess(q):q})().catch(X);try{J.hooks&&($=J.hooks.preprocess($));let K=(J.hooks?J.hooks.provideLexer(Q):Q?i.lex:i.lexInline)($,J);J.hooks&&(K=J.hooks.processAllTokens(K)),J.walkTokens&&this.walkTokens(K,J.walkTokens);let G=(J.hooks?J.hooks.provideParser(Q):Q?o.parse:o.parseInline)(K,J);return J.hooks&&(G=J.hooks.postprocess(G)),G}catch(K){return X(K)}}}onError(Q,$){return(Y)=>{if(Y.message+=`
59
- Please report this to https://github.com/markedjs/marked.`,Q){let W="<p>An error occurred:</p><pre>"+$0(Y.message+"",!0)+"</pre>";return $?Promise.resolve(W):W}if($)return Promise.reject(Y);throw Y}}},H0=new i5;function O(Q,$){return H0.parse(Q,$)}O.options=O.setOptions=function(Q){return H0.setOptions(Q),O.defaults=H0.defaults,F1(O.defaults),O};O.getDefaults=i0;O.defaults=U0;O.use=function(...Q){return H0.use(...Q),O.defaults=H0.defaults,F1(O.defaults),O};O.walkTokens=function(Q,$){return H0.walkTokens(Q,$)};O.parseInline=H0.parseInline;O.Parser=o;O.parser=o.parse;O.Renderer=V0;O.TextRenderer=Q1;O.Lexer=i;O.lexer=i.lex;O.Tokenizer=v0;O.Hooks=y0;O.parse=O;var{options:T4,setOptions:F4,use:_4,walkTokens:L4,parseInline:z4}=O;var A4=o.parse,M4=i.lex;import{jsxDEV as Y1}from"react/jsx-dev-runtime";O.setOptions({gfm:!0,breaks:!1});var o5=new Set(["a","abbr","b","br","code","del","em","i","kbd","mark","q","s","small","span","strong","sub","sup","time","u"]),a5=new Set(["Priority"]);function s5(Q){if(typeof Q==="string"||typeof Q==="number")return!0;if(!I1.isValidElement(Q))return!1;if(typeof Q!=="object"||Q===null||!("type"in Q))return!1;let $=Q.type;if(typeof $==="string")return o5.has($);if(typeof $==="function"){let Y="displayName"in $&&typeof $.displayName==="string"?$.displayName:$.name;return Y?a5.has(Y):!1}return!1}function n5(Q,$){let Y=Q.trim();if(!Y)return null;let W=O.parse(Y,{async:!1});return Y1("div",{className:"prose-canvas","data-md":"markdown","data-md-source":Y,dangerouslySetInnerHTML:{__html:W}},$,!1,void 0,this)}function t5(Q,$){return Y1("div",{className:"prose-canvas",children:Q.map((Y,W)=>{if(typeof Y==="string"||typeof Y==="number"){let J=O.parseInline(String(Y),{async:!1});return Y1("span",{dangerouslySetInnerHTML:{__html:J}},W,!1,void 0,this)}return Y})},$,!1,void 0,this)}function W0(Q){let $=I1.Children.toArray(Q);if($.length===0)return null;let Y=[],W=[],J=0,X=()=>{if(W.length===0)return;if(W.some((G)=>typeof G!=="string"&&typeof G!=="number"))Y.push(t5(W,`md-${J++}`));else{let G=n5(W.join(""),`md-${J++}`);if(G)Y.push(G)}W=[]};for(let K of $)if(s5(K))W.push(K);else X(),Y.push(K);return X(),Y}import{jsxDEV as Z0}from"react/jsx-dev-runtime";function $2({title:Q,children:$}){let[Y,W]=e5(!1);return Z0("div",{className:"relative mb-8 p-4 group/section","data-md":"section","data-md-title":Q,children:[Z0("div",{className:"relative mb-2",children:[Z0("button",{onClick:()=>W(!Y),className:`absolute -left-8 top-1/2 -translate-y-1/2 text-text-tertiary opacity-0 group-hover/section:opacity-50 hover:!opacity-100 transition-all duration-150 p-0.5 ${Y?"-rotate-90":""}`,children:Z0("svg",{width:"14",height:"14",viewBox:"0 0 12 12",fill:"none",children:Z0("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Z0("h2",{className:"font-heading text-section text-text-primary",style:{fontWeight:400},children:Q},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z0("div",{className:Y?"mt-6 hidden":"mt-6",children:W0($)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as Q0}from"react/jsx-dev-runtime";var Q2={todo:"bg-border-hover",done:"bg-accent-green",blocked:"bg-accent-red","in-progress":"bg-accent-blue"},Y2={todo:"Todo",done:"Done",blocked:"Blocked","in-progress":"In progress"},J2={info:"bg-accent-blue-muted text-accent-blue",success:"bg-accent-green-muted text-accent-green",warning:"bg-accent-amber-muted text-accent-amber",danger:"bg-accent-red-muted text-accent-red",neutral:"bg-border-subtle text-text-tertiary"};function S1({id:Q,label:$,status:Y,badge:W,badgeVariant:J="neutral",children:X}){return Q0("div",{className:"group/task relative -mx-4 px-4 py-3 rounded-md transition-colors duration-150 hover:bg-bg-input","data-task-id":Q,"data-md":"item","data-md-label":$,...Y?{"data-md-status":Y}:{},...W?{"data-md-badge":W}:{},children:Q0("div",{className:"flex items-start gap-3",children:[Y&&Q0("span",{className:`w-2 h-2 rounded-full mt-[7px] flex-shrink-0 ${Q2[Y]}`},void 0,!1,void 0,this),Q0("div",{className:"flex-1 min-w-0",children:[Q0("div",{className:"flex items-baseline gap-2",children:[Q0("span",{className:"font-body text-task-label font-semibold text-text-primary",children:$},void 0,!1,void 0,this),Y&&Q0("span",{className:"font-body text-tiny uppercase tracking-wider text-text-tertiary opacity-0 group-hover/task:opacity-100 transition-opacity duration-150",children:Y2[Y]},void 0,!1,void 0,this),W&&Q0("span",{className:`font-body text-tiny font-medium px-1.5 py-px rounded-full ${J2[J]}`,children:W},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X&&Q0("div",{className:"text-body text-text-secondary mt-1 leading-relaxed",children:W0(X)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function W2(Q){return Q0(S1,{...Q},void 0,!1,void 0,this)}import{useEffect as X2,useRef as K2}from"react";import{jsxDEV as D0}from"react/jsx-dev-runtime";function B2({language:Q,children:$}){let Y=typeof $==="string"?$:String($??""),W=K2(null);return X2(()=>{let J=W.current,X=window.hljs;if(!J||!X)return;J.removeAttribute("data-highlighted"),J.className=Q?`language-${Q}`:"",J.textContent=Y,X.highlightElement(J)},[Y,Q]),D0("div",{className:"relative mt-3 group/code","data-md":"codeblock","data-md-language":Q||"",children:[Q&&D0("span",{className:"absolute top-2 right-3 text-tiny text-text-tertiary opacity-0 group-hover/code:opacity-60 transition-opacity duration-150 z-10 font-mono",children:Q},void 0,!1,void 0,this),D0("pre",{className:"bg-bg-code rounded-md p-4 overflow-x-auto text-code font-mono leading-relaxed",children:D0("code",{ref:W,className:Q?`language-${Q}`:"",children:Y},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as J1}from"react/jsx-dev-runtime";var G2={info:{bg:"bg-accent-blue-muted",icon:"i",iconColor:"text-accent-blue"},warning:{bg:"bg-accent-amber-muted",icon:"!",iconColor:"text-accent-amber"},danger:{bg:"bg-accent-red-muted",icon:"✕",iconColor:"text-accent-red"},tip:{bg:"bg-accent-green-muted",icon:"✓",iconColor:"text-accent-green"}};function q2({type:Q="info",children:$}){let Y=G2[Q];return J1("div",{className:`${Y.bg} relative rounded-lg px-5 py-4 mt-3 flex gap-3 items-start`,"data-md":"callout","data-md-type":Q,children:[J1("span",{"aria-hidden":"true",className:`${Y.iconColor} opacity-70 text-base leading-relaxed flex-shrink-0 mt-px`,children:Y.icon},void 0,!1,void 0,this),J1("div",{className:"text-body text-text-secondary leading-relaxed",children:W0($)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as H2}from"react/jsx-dev-runtime";function P2({children:Q}){return H2("div",{className:"relative bg-bg-elevated rounded-lg px-5 py-4 mt-3 text-body text-text-secondary italic leading-relaxed","data-md":"note",children:W0(Q)},void 0,!1,void 0,this)}import{jsxDEV as X0}from"react/jsx-dev-runtime";function U2({headers:Q,rows:$}){return X0("div",{className:"overflow-x-auto mt-3","data-md":"table",children:X0("table",{className:"w-full text-body",children:[X0("thead",{children:X0("tr",{className:"border-b border-border-subtle",children:Q.map((Y,W)=>X0("th",{className:"text-left px-4 py-2.5 text-meta font-medium uppercase tracking-wider text-text-tertiary font-body",children:Y},W,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),X0("tbody",{children:$.map((Y,W)=>X0("tr",{className:`relative border-b border-border-subtle last:border-b-0 transition-colors hover:bg-bg-surface/50 ${W%2===1?"bg-bg-surface/30":""}`,children:Y.map((J,X)=>X0("td",{className:"px-4 py-2.5 text-text-secondary font-body",children:J},X,!1,void 0,this))},W,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as _0}from"react/jsx-dev-runtime";function Z2({items:Q}){return _0("ul",{className:"space-y-1 mt-3","data-md":"checklist",children:Q.map(($,Y)=>_0("li",{"data-md":"checklist-item","data-md-label":$.label,className:"relative flex items-start gap-2.5 py-1",children:[_0("span",{className:`w-4 h-4 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5 transition-all ${$.checked?"bg-accent-green":"border-[1.5px] border-border-hover"}`,children:$.checked&&_0("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:_0("path",{d:"M2.5 5L4.5 7L7.5 3",style:{stroke:"var(--color-text-inverse)"},strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),_0("span",{className:`text-body font-body ${$.checked?"text-text-tertiary line-through decoration-border-hover":"text-text-secondary"}`,children:$.label},void 0,!1,void 0,this)]},Y,!0,void 0,this))},void 0,!1,void 0,this)}import{jsxDEV as F2}from"react/jsx-dev-runtime";var N2={high:"text-accent-red bg-accent-red-muted",medium:"text-accent-amber bg-accent-amber-muted",low:"text-text-tertiary bg-border-subtle"};function T2({level:Q}){return F2("span",{className:`inline text-tiny font-medium font-body ml-2 px-1.5 py-0.5 rounded ${N2[Q]}`,"data-md":"priority","data-md-level":Q,children:Q},void 0,!1,void 0,this)}import{useEffect as b1,useState as h0,useContext as f1,useRef as _2}from"react";import{SessionContext as L2,ActiveViewCtx as z2}from"#canvas/runtime";import{jsxDEV as K0}from"react/jsx-dev-runtime";var A2={ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",py:"python",rs:"rust",go:"go",rb:"ruby",java:"java",json:"json",yaml:"yaml",yml:"yaml",md:"markdown",css:"css",html:"html",sh:"bash",bash:"bash",toml:"toml",sql:"sql",xml:"xml",c:"c",cpp:"cpp",h:"c"};function M2({path:Q,lines:$,__content:Y}){let W=f1(L2),{setActiveView:J}=f1(z2),[X,K]=h0(Y??null),[G,B]=h0(()=>{let U=Q.split(".").pop()||"";return A2[U]||"text"}),[q,P]=h0(null),[H,T]=h0(!Y),N=_2(null);if(b1(()=>{if(Y!==void 0)return;T(!0),P(null),fetch(`/api/file?session=${W}&path=${encodeURIComponent(Q)}`).then((U)=>U.json()).then((U)=>{if(U.error)P(U.error);else{let Z=U.content;if($)Z=Z.split(`
60
- `).slice($[0]-1,$[1]).join(`
61
- `);K(Z),B(U.language||"text")}}).catch(()=>P("Failed to fetch file")).finally(()=>T(!1))},[W,Q,$?.[0],$?.[1],Y]),b1(()=>{let U=N.current,Z=window.hljs;if(!U||!Z||!X)return;U.removeAttribute("data-highlighted"),U.className=G?`language-${G}`:"",U.textContent=X,Z.highlightElement(U)},[X,G]),H)return K0("div",{className:"text-text-tertiary text-body mt-3 bg-bg-code rounded-md p-4",children:["Loading ",Q,"..."]},void 0,!0,void 0,this);if(q)return K0("div",{className:"text-accent-red text-body mt-3 bg-accent-red-muted rounded-md p-4",children:[Q,": ",q]},void 0,!0,void 0,this);return K0("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden","data-md":"filepreview","data-md-path":Q,...$?{"data-md-lines":`${$[0]}-${$[1]}`}:{},children:[K0("div",{className:"px-4 py-2 flex items-center justify-between",children:[K0("button",{className:"font-mono text-meta text-text-tertiary hover:text-text-secondary hover:underline cursor-pointer text-left",onClick:()=>J({type:"file",path:Q}),title:`Open ${Q}`,children:Q},void 0,!1,void 0,this),$&&K0("span",{className:"font-mono text-meta text-text-tertiary opacity-60",children:["L",$[0],"–",$[1]]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),K0("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono !bg-transparent",style:{background:"transparent"},children:K0("code",{ref:N,className:G?`language-${G}`:"",children:X},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as B1,useRef as I0,useState as z0,useCallback as Y0}from"react";import D2 from"react-dom";import{useAnnotations as h2,useCanvasFile as x2}from"#canvas/runtime";import{useEffect as f2,useRef as p0,useState as L0,useCallback as E0,useMemo as m1,useContext as R2}from"react";import{createPortal as C2}from"react-dom";function R1(Q){let $=/^(\d+(?:\.\d+)?)px$/.exec(Q.trim());return $?Number($[1]):void 0}function C1(Q,$,Y=280){let J=$||document.body,X=Q.getBoundingClientRect(),K=J.getBoundingClientRect(),G=J===document.body?0:J.scrollTop,B=X.bottom-K.top+G+8,q=Math.max(0,Math.min(X.left-K.left,K.width-Y-12));return J.style.position="relative",{style:{position:"absolute",top:`${B}px`,left:`${q}px`},parent:J}}import{useState as W1,useRef as X1,useCallback as J0,useEffect as I2}from"react";function x0(Q){return Q.uploadUrl!==null}function N0(Q,$){Q.style.height="auto",Q.style.height=($?Math.max($,Q.scrollHeight):Q.scrollHeight)+"px"}import{createContext as w2,useContext as O2}from"react";function v1(){if(typeof window>"u")return"";return window.location.pathname.replace("/s/","")}var y2={get sessionId(){return v1()},isShared:!1,fsAvailable:!0,uploadUrl:null,loadCanvasModule:(Q,$)=>{let Y=Q.replace(/\.jsx$/,".js"),W=$?`?rev=${$}&t=${Date.now()}`:`?t=${Date.now()}`;return import(`/api/session/${v1()}/canvas/${encodeURIComponent(Y)}${W}`)}},k2=w2(y2);function g0(){return O2(k2)}import{jsxDEV as g}from"react/jsx-dev-runtime";function S2(Q){if(Q.startsWith("/s/")||Q.startsWith("http://")||Q.startsWith("https://"))return Q;return`/api/uploads/${Q.split("/").pop()}`}async function b2(Q,$){let Y=Q.uploadUrl;if(!Y)return null;let W=new FormData;W.append("image",$);try{let X=await(await fetch(Y(),{method:"POST",body:W})).json();if(Q.isShared)return X.url||null;return X.path||null}catch{return null}}function V1({note:Q,onNoteChange:$,images:Y,onAddImage:W,onRemoveImage:J,sessionId:X,placeholder:K="Add your note...",autoFocus:G=!1,autoResize:B=!1,readOnly:q=!1,onKeyDown:P,onTextareaClick:H,textareaRef:T,textareaClassName:N,textareaStyle:U,minHeight:Z,attachButton:F="always",openFilePickerRef:z}){let k=g0(),M=!q&&x0(k),[w,b]=W1(!1),[C,p]=W1(!1),[c,a]=W1(!1),f=X1(0),V=X1(null),u=X1(null),D=J0(()=>u.current?.click(),[]);if(z)z.current=D;let s=J0((L)=>{if(V.current=L,T)T.current=L;if(L&&B)N0(L,Z)},[T,B,Z]);I2(()=>{if(G&&V.current){let L=V.current;if(L.focus(),L.value)L.setSelectionRange(L.value.length,L.value.length)}},[G]);let d=J0(async(L)=>{if(!L.type.startsWith("image/"))return;p(!0);try{let h=await b2(k,L);if(h)W(h)}finally{p(!1)}},[k,W]),B0=J0((L)=>{for(let h of L.clipboardData?.items??[])if(h.type.startsWith("image/")){L.preventDefault();let T0=h.getAsFile();if(T0)d(T0);return}},[d]),r=J0((L)=>{if(L.preventDefault(),f.current++,f.current===1)b(!0)},[]),l=J0((L)=>{L.preventDefault()},[]),n=J0((L)=>{if(L.preventDefault(),f.current--,f.current===0)b(!1)},[]),t=J0((L)=>{L.preventDefault(),f.current=0,b(!1);for(let h of L.dataTransfer?.files??[])if(h.type.startsWith("image/"))d(h)},[d]),G0=J0((L)=>{if($(L.currentTarget.value),B)L.currentTarget.style.height="auto",L.currentTarget.style.height=(Z?Math.max(Z,L.currentTarget.scrollHeight):L.currentTarget.scrollHeight)+"px"},[$,B,Z]),q0="w-full bg-transparent text-[13px] font-body text-text-primary resize-none focus:outline-none leading-relaxed p-0 border-none",r0={width:"100%",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",outline:"none",...B?{resize:"none",overflow:"hidden"}:{resize:"vertical"}},f0=M&&(F==="always"||F==="on-focus"&&c);return g("div",{style:{position:"relative"},onDragEnter:M?r:void 0,onDragOver:M?l:void 0,onDragLeave:M?n:void 0,onDrop:M?t:void 0,children:[g("textarea",{ref:s,value:Q,onChange:q?void 0:G0,onPaste:M?B0:void 0,onKeyDown:P,onClick:H,onFocus:()=>a(!0),onBlur:()=>{setTimeout(()=>a(!1),150)},readOnly:q,placeholder:K,className:N??q0,style:U??r0,rows:B?1:void 0},void 0,!1,void 0,this),M&&g("input",{ref:u,type:"file",accept:"image/*",multiple:!0,style:{display:"none"},onChange:(L)=>{let h=L.currentTarget.files;if(h)for(let T0 of h)d(T0);L.currentTarget.value=""}},void 0,!1,void 0,this),(Y.length>0||f0)&&g("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px",alignItems:"center"},children:[Y.map((L)=>g("div",{style:{position:"relative",width:"56px",height:"56px",borderRadius:"6px",overflow:"hidden",border:"1px solid var(--color-border-subtle)",flexShrink:0},children:[g("img",{src:S2(L),alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}},void 0,!1,void 0,this),!q&&g("button",{onClick:(h)=>{h.stopPropagation(),J(L)},style:{position:"absolute",top:"2px",right:"2px",width:"16px",height:"16px",borderRadius:"50%",background:"rgba(0,0,0,0.6)",color:"white",border:"none",cursor:"pointer",fontSize:"11px",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:0},title:"Remove image",children:"×"},void 0,!1,void 0,this)]},L,!0,void 0,this)),f0&&g(K1,{onClick:D},void 0,!1,void 0,this)]},void 0,!0,void 0,this),C&&g("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:"Uploading..."},void 0,!1,void 0,this),w&&g("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-highlight-bg)",opacity:0.9,border:"2px dashed var(--color-highlight-border)",borderRadius:"6px",zIndex:10,pointerEvents:"none",fontSize:"12px",fontFamily:"'Inter', sans-serif",color:"var(--color-text-secondary)"},children:"Drop image"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function K1({onClick:Q,size:$=16}){return g("button",{onClick:(Y)=>{Y.stopPropagation(),Q()},style:{width:`${$*2}px`,height:`${$*2}px`,borderRadius:"6px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--color-text-tertiary)",flexShrink:0,transition:"color 0.15s"},title:"Attach image",onMouseEnter:(Y)=>{Y.currentTarget.style.color="var(--color-text-secondary)"},onMouseLeave:(Y)=>{Y.currentTarget.style.color="var(--color-text-tertiary)"},children:g("svg",{width:$,height:$,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[g("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},void 0,!1,void 0,this),g("circle",{cx:"8.5",cy:"8.5",r:"1.5"},void 0,!1,void 0,this),g("polyline",{points:"21 15 16 10 5 21"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}import{SessionContext as v2}from"#canvas/runtime";import{jsxDEV as j,Fragment as j2}from"react/jsx-dev-runtime";function V2({anchorEl:Q,scrollContainer:$,onClose:Y,ignoreSelector:W,zIndex:J="50",padding:X="12px",width:K="280px",children:G}){let B=p0(null),q=p0(Y);q.current=Y;let{style:P,parent:H}=C1(Q,$,R1(K));return f2(()=>{let T=setTimeout(()=>{let N=(U)=>{if(B.current&&!B.current.contains(U.target)){if(W&&U.target.closest?.(W))return;q.current(),document.removeEventListener("mousedown",N)}};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},0);return()=>clearTimeout(T)},[W]),C2(j("div",{ref:B,style:{...P,zIndex:J,width:K,background:"var(--color-bg-elevated)",border:"1px solid var(--color-border-hover)",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",padding:X,fontFamily:"'Inter', sans-serif"},children:G},void 0,!1,void 0,this),H)}var D1=[{label:"Clarity",items:["Unclear","Why?","Needs example","Missing context"]},{label:"Scope",items:["Overkill","Out of scope","Important","Risky"]},{label:"Action",items:["Simplify","Rethink","Expand on this","Skip this"]}],j1=D1.flatMap((Q)=>Q.items);function m2({anchorEl:Q,scrollContainer:$,snippet:Y,truncateAt:W=100,header:J,initialNote:X="",initialImages:K,onConfirm:G,onCancel:B,onDelete:q}){let P=R2(v2),H=g0(),T=x0(H),N=X!==""||!!q,[U,Z]=L0(X),[F,z]=L0(K||[]),[k,M]=L0(null),[w,b]=L0(N),[C,p]=L0(!1),c=p0(null),a=p0(null),f=E0(()=>{if(U.trim()||F.length>0)G(U.trim(),F);else if(N&&q)q();else B()},[U,F,G,B,N,q]),V=E0(()=>{if(N){if(!U.trim()&&F.length===0&&q){q(),B();return}G(U,F);return}B()},[U,F,N,G,B,q]),u=!N,D=U.trim().length>0?j1.filter((_)=>_.toLowerCase().startsWith(U.trim().toLowerCase())):j1,s=!u||w?[]:D.length===1&&D[0]?.toLowerCase()===U.trim().toLowerCase()?[]:D,d=new Set(s),B0=D1.map((_)=>({label:_.label,items:_.items.filter((S)=>d.has(S))})).filter((_)=>_.items.length>0),r=B0.map((_)=>_.items),l=(_)=>r[_]?.length??0,n=r.flat(),t=m1(()=>{if(k===null)return 0;let _=0;for(let S=0;S<r.length;S++){if(k<_+l(S))return S;_+=l(S)}return 0},[k,r]),G0=m1(()=>{if(k===null)return 0;let _=0;for(let S=0;S<t;S++)_+=l(S);return k-_},[k,t,r]),q0=(_,S)=>{let m=0;for(let e=0;e<_;e++)m+=l(e);return m+S},[r0,f0]=L0(U);if(U!==r0)f0(U),M(null),b(N);let L=E0((_)=>{Z(_)},[]),h=Y.length>W?Y.slice(0,W)+"...":Y,T0=E0((_)=>{if(n.length>0&&(_.key==="ArrowDown"||_.key==="ArrowUp"||_.key==="ArrowLeft"||_.key==="ArrowRight")){if(_.preventDefault(),k===null){M(0);return}if(_.key==="ArrowDown"){let m=Math.min(G0+1,l(t)-1);M(q0(t,m))}else if(_.key==="ArrowUp"){let m=Math.max(G0-1,0);M(q0(t,m))}else if(_.key==="ArrowRight"){let m=Math.min(t+1,r.length-1),e=Math.min(G0,l(m)-1);M(q0(m,e))}else if(_.key==="ArrowLeft"){let m=Math.max(t-1,0),e=Math.min(G0,l(m)-1);M(q0(m,e))}return}let S=k===null?void 0:n[k];if(S!==void 0){if(_.key==="Tab"){_.preventDefault(),L(S);return}if(_.key==="Enter"&&!_.shiftKey){_.preventDefault(),G(S,F);return}}if(_.key==="Enter"&&!_.shiftKey){_.preventDefault(),f();return}if(_.key==="Escape")if(n.length>0&&!w)b(!0);else if(N)V();else B()},[n,k,G0,t,r,q0,L,G,F,f,w,N,V,B]);return j(V2,{anchorEl:Q,scrollContainer:$,onClose:N?V:B,ignoreSelector:N?"[data-annotation-id]":void 0,zIndex:N?"60":"50",padding:N?"10px 12px":"12px",width:"420px",children:[!N&&(J??j("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontStyle:"italic",marginBottom:"8px",lineHeight:"1.4",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:["“",h,"”"]},void 0,!0,void 0,this)),j(V1,{note:U,onNoteChange:Z,images:F,onAddImage:(_)=>z((S)=>[...S,_]),onRemoveImage:(_)=>z((S)=>S.filter((m)=>m!==_)),sessionId:P,autoFocus:!0,autoResize:N,textareaRef:c,onKeyDown:T0,attachButton:"none",openFilePickerRef:a,textareaStyle:N?{width:"100%",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",resize:"none",outline:"none",overflow:"hidden"}:{width:"100%",minHeight:"60px",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",resize:"vertical",outline:"none"},placeholder:"Add your note..."},void 0,!1,void 0,this),j("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:N?"6px":"8px"},children:[T&&j(K1,{onClick:()=>a.current?.(),size:14},void 0,!1,void 0,this),j("div",{style:{flex:1}},void 0,!1,void 0,this),N?j("button",{onClick:()=>{if(q)q();B()},onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),style:{fontSize:"11px",color:C?"var(--color-accent-red)":"var(--color-text-tertiary)",background:"none",border:"none",cursor:"pointer",padding:"2px 0",fontFamily:"'Inter', sans-serif"},children:"Delete"},void 0,!1,void 0,this):j(j2,{children:[j("button",{onClick:B,style:{fontSize:"11px",color:"var(--color-text-tertiary)",background:"none",border:"none",cursor:"pointer",padding:"4px 12px",fontFamily:"'Inter', sans-serif"},children:"Cancel"},void 0,!1,void 0,this),j("button",{onClick:f,style:{fontSize:"11px",fontWeight:500,padding:"4px 12px",borderRadius:"6px",background:"var(--color-highlight-bg)",color:"var(--color-text-primary)",border:"1px solid var(--color-highlight-border)",cursor:"pointer",fontFamily:"'Inter', sans-serif"},children:"Add"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),n.length>0&&j("div",{style:{marginTop:"6px",borderTop:"1px solid var(--color-border-subtle)",paddingTop:"8px",display:"flex",gap:"4px"},children:B0.map((_)=>j("div",{style:{flex:1},children:[j("div",{style:{fontSize:"10px",fontWeight:600,color:"var(--color-text-disabled)",textTransform:"uppercase",letterSpacing:"0.05em",padding:"2px 6px",marginBottom:"2px",fontFamily:"'Inter', sans-serif"},children:_.label},void 0,!1,void 0,this),_.items.map((S)=>{let m=n.indexOf(S);return j("div",{onMouseDown:(e)=>{e.preventDefault(),e.stopPropagation(),L(S)},onMouseEnter:()=>M(m),style:{padding:"3px 6px",fontSize:"12px",borderRadius:"4px",fontFamily:"'Inter', sans-serif",color:m===k?"var(--color-text-primary)":"var(--color-text-secondary)",background:m===k?"var(--color-highlight-selected)":"transparent",cursor:"pointer"},children:[j("span",{style:{fontWeight:500},children:S.slice(0,U.trim().length)},void 0,!1,void 0,this),S.slice(U.trim().length)]},S,!0,void 0,this)})]},_.label,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function h1({anchorEl:Q,scrollContainer:$,snippet:Y,truncateAt:W,header:J,onAdd:X,onCancel:K}){return j(m2,{anchorEl:Q,scrollContainer:$,snippet:Y,truncateAt:W,header:J,onConfirm:(G,B)=>X(G,B),onCancel:K},void 0,!1,void 0,this)}import{jsxDEV as A,Fragment as p1}from"react/jsx-dev-runtime";var A0=0.2,u0=0.25,c0=4;function g1({zoom:Q,onZoomIn:$,onZoomOut:Y,onZoomReset:W,onFullscreen:J}){return A("div",{className:"flex items-center gap-0.5 bg-bg-surface border border-border-subtle rounded-md px-1 py-0.5",style:{fontSize:"12px"},children:[A("button",{className:"flex items-center justify-center w-7 h-7 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:Y,title:"Zoom out",disabled:Q<=u0,children:A("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:A("line",{x1:"5",y1:"12",x2:"19",y2:"12"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),A("button",{className:"px-1.5 h-7 rounded hover:bg-bg-elevated text-text-tertiary hover:text-text-primary transition-colors tabular-nums",onClick:W,title:"Reset zoom",children:[Math.round(Q*100),"%"]},void 0,!0,void 0,this),A("button",{className:"flex items-center justify-center w-7 h-7 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:$,title:"Zoom in",disabled:Q>=c0,children:A("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[A("line",{x1:"12",y1:"5",x2:"12",y2:"19"},void 0,!1,void 0,this),A("line",{x1:"5",y1:"12",x2:"19",y2:"12"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),J&&A(p1,{children:[A("div",{className:"w-px h-4 bg-border-subtle mx-0.5"},void 0,!1,void 0,this),A("button",{className:"flex items-center justify-center w-7 h-7 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:J,title:"Fullscreen",children:A("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[A("polyline",{points:"15 3 21 3 21 9"},void 0,!1,void 0,this),A("polyline",{points:"9 21 3 21 3 15"},void 0,!1,void 0,this),A("line",{x1:"21",y1:"3",x2:"14",y2:"10"},void 0,!1,void 0,this),A("line",{x1:"3",y1:"21",x2:"10",y2:"14"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function E1(Q=1){let[$,Y]=z0(Q),W=Y0(()=>Y((K)=>Math.min(c0,+(K+A0).toFixed(2))),[]),J=Y0(()=>Y((K)=>Math.max(u0,+(K-A0).toFixed(2))),[]),X=Y0(()=>Y(1),[]);return{zoom:$,zoomIn:W,zoomOut:J,zoomReset:X,setZoom:Y}}function g2({svgHtml:Q,source:$,onClose:Y}){let W=I0(null),{zoom:J,zoomIn:X,zoomOut:K,zoomReset:G,setZoom:B}=E1(1),[q,P]=z0({x:0,y:0}),H=I0(null);B1(()=>{let z=(k)=>{if(k.key==="Escape")Y()};return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[Y]);let T=Y0((z)=>{z.preventDefault();let k=z.deltaY>0?-A0:A0;B((M)=>Math.max(u0,Math.min(c0,+(M+k).toFixed(2))))},[B]),N=Y0((z)=>{if(z.button!==0)return;H.current={startX:z.clientX,startY:z.clientY,panX:q.x,panY:q.y},z.preventDefault()},[q]),U=Y0((z)=>{if(!H.current)return;P({x:H.current.panX+(z.clientX-H.current.startX),y:H.current.panY+(z.clientY-H.current.startY)})},[]),Z=Y0(()=>{H.current=null},[]),F=Y0(()=>{G(),P({x:0,y:0})},[G]);return D2.createPortal(A("div",{style:{position:"fixed",inset:0,zIndex:9999,background:"var(--color-bg-base)",display:"flex",flexDirection:"column"},onMouseMove:U,onMouseUp:Z,onMouseLeave:Z,children:[A("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border-subtle",style:{flexShrink:0,background:"var(--color-bg-surface)"},children:[A("span",{className:"text-body text-text-secondary",style:{fontSize:"13px"},children:"Mermaid Diagram"},void 0,!1,void 0,this),A("div",{className:"flex items-center gap-2",children:[A(g1,{zoom:J,onZoomIn:X,onZoomOut:K,onZoomReset:F},void 0,!1,void 0,this),A("button",{className:"flex items-center justify-center w-8 h-8 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:Y,title:"Close (Esc)",children:A("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[A("line",{x1:"18",y1:"6",x2:"6",y2:"18"},void 0,!1,void 0,this),A("line",{x1:"6",y1:"6",x2:"18",y2:"18"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),A("div",{style:{flex:1,overflow:"hidden",cursor:H.current?"grabbing":"grab"},onWheel:T,onMouseDown:N,children:A("div",{ref:W,style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",transform:`translate(${q.x}px, ${q.y}px) scale(${J})`,transformOrigin:"center center",transition:H.current?"none":"transform 0.1s ease-out"},dangerouslySetInnerHTML:{__html:Q}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),document.body)}function E2({children:Q}){let $=I0(null),[Y,W]=z0(null),[J,X]=z0(!1),[K,G]=z0(""),B=typeof Q==="string"?Q:String(Q??""),{annotations:q,addAnnotationWithId:P,activeAnnotationId:H,setActiveAnnotationId:T}=h2(),N=x2(),[U,Z]=z0(null),{zoom:F,zoomIn:z,zoomOut:k,zoomReset:M,setZoom:w}=E1(1),b=I0(q);b.current=q;let C=Y0((f,V,u)=>{let D=`[Diagram ${u.toLowerCase()}] ${V}`,s=b.current.find((d)=>d.snippet===D);if(s)T(s.id);else Z({anchorEl:f,snippet:V,prefix:u})},[T]),p=I0(C);p.current=C,B1(()=>{let f=!1,V=async()=>{try{let D=window.mermaid;if(!D){W("Mermaid library not loaded");return}let s=document.documentElement.dataset.theme==="light"?"default":"dark";D.initialize({startOnLoad:!1,theme:s});let d=`mermaid-${Math.random().toString(36).slice(2)}`,{svg:B0}=await D.render(d,B.trim());if(!f&&$.current)$.current.innerHTML=B0,G(B0),p2($.current,(r,l,n)=>p.current(r,l,n)),x1($.current,b.current);W(null)}catch(D){if(!f)W(D.message||"Invalid diagram")}};V();let u=new MutationObserver((D)=>{for(let s of D)if(s.attributeName==="data-theme")V()});return u.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{f=!0,u.disconnect()}},[B]),B1(()=>{if($.current)x1($.current,q,H)},[q,H]);let c=Y0((f)=>{if(!f.ctrlKey&&!f.metaKey)return;f.preventDefault();let V=f.deltaY>0?-A0:A0;w((u)=>Math.max(u0,Math.min(c0,+(u+V).toFixed(2))))},[w]);if(Y)return A("div",{className:"bg-accent-red-muted rounded-md p-4 mt-3 text-body text-accent-red",children:["Mermaid error: ",Y,A("pre",{className:"mt-2 text-tiny text-text-tertiary whitespace-pre-wrap",children:B},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let a=$.current?.closest("#plan-scroll-container");return A(p1,{children:[A("div",{className:"mt-3 mermaid-container","data-md":"mermaid","data-md-source":B.trim(),children:[A("div",{className:"flex justify-end mb-1",children:A(g1,{zoom:F,onZoomIn:z,onZoomOut:k,onZoomReset:M,onFullscreen:()=>X(!0)},void 0,!1,void 0,this)},void 0,!1,void 0,this),A("div",{style:{overflow:"auto",maxHeight:"70vh"},onWheel:c,children:A("div",{ref:$,className:"flex justify-center",style:{transform:`scale(${F})`,transformOrigin:"top center",transition:"transform 0.1s ease-out",minHeight:F<1?void 0:void 0}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U&&A(h1,{anchorEl:U.anchorEl,scrollContainer:a,snippet:U.snippet,header:A("div",{style:{fontSize:"12px",color:"var(--color-text-tertiary)",marginBottom:"8px",lineHeight:"1.4",display:"flex",alignItems:"center",gap:"6px"},children:[A("span",{style:{width:"8px",height:"8px",borderRadius:"50%",background:"var(--color-accent-amber)",flexShrink:0}},void 0,!1,void 0,this),U.snippet]},void 0,!0,void 0,this),onAdd:(f,V)=>{let u=`ann-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;P(u,`[Diagram ${U.prefix.toLowerCase()}] ${U.snippet}`,f,void 0,void 0,V,N||void 0),Z(null)},onCancel:()=>Z(null)},void 0,!1,void 0,this),J&&K&&A(g2,{svgHtml:K,source:B,onClose:()=>X(!1)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function p2(Q,$){let Y=(W,J,X)=>{W.style.cursor="pointer",W.addEventListener("mouseenter",()=>{W.style.filter="brightness(1.2)"}),W.addEventListener("mouseleave",()=>{W.style.filter=""}),W.addEventListener("click",(K)=>{K.stopPropagation(),K.preventDefault(),$(W,J(),X)})};for(let W of Q.querySelectorAll(".node"))Y(W,()=>{return(W.querySelector(".nodeLabel")||W.querySelector("foreignObject span")||W.querySelector("text"))?.textContent?.trim()||"Node"},"Node");for(let W of Q.querySelectorAll(".edgePath")){let J=W,X=J.querySelector("path");if(X){X.style.strokeWidth=Math.max(parseFloat(X.style.strokeWidth||"1"),8)+"px",X.style.strokeOpacity="0";let G=X.cloneNode(!0);G.style.strokeWidth="",G.style.strokeOpacity="",J.insertBefore(G,X)}let K=J.id||"";Y(J,()=>{let G=Q.querySelectorAll(".edgeLabel");for(let B of G)if(B.id&&K&&B.id.replace("label","").includes(K.replace("L-","").replace("edge",""))){let q=B.textContent?.trim();if(q)return q}return"Connection"},"Edge")}for(let W of Q.querySelectorAll(".edgeLabel")){let J=W.textContent?.trim();if(!J)continue;Y(W,()=>J,"Edge")}for(let W of Q.querySelectorAll(".actor")){let J=W.closest("g")?.querySelector("text")||W.parentElement?.querySelector("text");if(!J)continue;let X=W.closest("g");if(!X||X.hasAttribute("data-clickable"))continue;X.setAttribute("data-clickable","true"),Y(X,()=>J.textContent?.trim()||"Participant","Node")}for(let W of Q.querySelectorAll(".messageText")){let J=W.textContent?.trim();if(!J)continue;Y(W,()=>J,"Edge")}for(let W of Q.querySelectorAll(".entityBox")){let J=W.closest("g");if(!J||J.hasAttribute("data-clickable"))continue;let X=J.querySelector(".entityLabel");if(!X)continue;J.setAttribute("data-clickable","true"),Y(J,()=>X.textContent?.trim()||"Entity","Node")}for(let W of Q.querySelectorAll(".relationshipLabel")){let J=W.textContent?.trim();if(!J)continue;let K=W.closest("g")||W;if(K.hasAttribute("data-clickable"))continue;K.setAttribute("data-clickable","true"),Y(K,()=>J,"Edge")}for(let W of Q.querySelectorAll(".classGroup")){let J=W;if(J.hasAttribute("data-clickable"))continue;let X=J.querySelector(".classTitle, .classTitleText, text");if(!X)continue;J.setAttribute("data-clickable","true"),Y(J,()=>X.textContent?.trim()||"Class","Node")}for(let W of Q.querySelectorAll(".statediagram-state")){let J=W;if(J.hasAttribute("data-clickable"))continue;let X=J.querySelector(".state-title, text");if(!X)continue;J.setAttribute("data-clickable","true"),Y(J,()=>X.textContent?.trim()||"State","Node")}for(let W of Q.querySelectorAll(".mindmap-node")){let J=W;if(J.hasAttribute("data-clickable"))continue;let X=J.querySelector(".mindmap-node-label, text");if(!X)continue;J.setAttribute("data-clickable","true"),Y(J,()=>X.textContent?.trim()||"Node","Node")}}function x1(Q,$,Y){let W=new Map;for(let X of $){let K=X.snippet.match(/^\[Diagram (?:node|edge)\] (.+)$/)?.[1];if(K)W.set(K,X.id)}for(let X of Q.querySelectorAll("[data-annotated]"))X.style.outline="",X.style.outlineOffset="",X.style.borderRadius="",X.removeAttribute("data-annotated");if(W.size===0)return;for(let X of Q.querySelectorAll(".node")){let G=(X.querySelector(".nodeLabel")||X.querySelector("foreignObject span")||X.querySelector("text"))?.textContent?.trim();if(!G||!W.has(G))continue;let B=W.get(G),q=X;q.setAttribute("data-annotated",B);let P=B===Y;q.style.outline=P?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",q.style.outlineOffset="2px",q.style.borderRadius="4px"}for(let X of Q.querySelectorAll(".edgeLabel")){let K=X.textContent?.trim();if(!K||!W.has(K))continue;let G=W.get(K),B=X;B.setAttribute("data-annotated",G);let q=G===Y;B.style.outline=q?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",B.style.outlineOffset="2px",B.style.borderRadius="4px"}for(let X of Q.querySelectorAll(".actor")){let K=X.closest("g");if(!K)continue;let B=K.querySelector("text")?.textContent?.trim();if(!B||!W.has(B))continue;if(K.hasAttribute("data-annotated"))continue;let q=W.get(B);K.setAttribute("data-annotated",q);let P=q===Y,H=K.querySelector("rect");if(H)H.style.outline=P?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",H.style.outlineOffset="2px",H.style.borderRadius="4px"}for(let X of Q.querySelectorAll(".messageText")){let K=X.textContent?.trim();if(!K||!W.has(K))continue;let G=W.get(K),B=X;B.setAttribute("data-annotated",G);let q=G===Y;B.style.outline=q?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",B.style.outlineOffset="2px",B.style.borderRadius="4px"}let J=(X,K,G)=>{for(let B of Q.querySelectorAll(X)){let q=G(B);if(!q||q.hasAttribute("data-annotated"))continue;let H=q.querySelector(K)?.textContent?.trim();if(!H||!W.has(H))continue;let T=W.get(H);q.setAttribute("data-annotated",T);let N=T===Y,U=q.querySelector("rect, circle, ellipse, polygon")||q;U.style.outline=N?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",U.style.outlineOffset="2px",U.style.borderRadius="4px"}};J(".entityBox",".entityLabel",(X)=>X.closest("g"));for(let X of Q.querySelectorAll(".relationshipLabel")){let G=X.closest("g")||X;if(G.hasAttribute("data-annotated"))continue;let B=X.textContent?.trim();if(!B||!W.has(B))continue;let q=W.get(B);G.setAttribute("data-annotated",q);let P=q===Y;G.style.outline=P?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",G.style.outlineOffset="2px",G.style.borderRadius="4px"}J(".classGroup",".classTitle, .classTitleText, text",(X)=>X),J(".statediagram-state",".state-title, text",(X)=>X),J(".mindmap-node",".mindmap-node-label, text",(X)=>X)}function u1(Q,$){let Y=Q.split(`
62
- `),W=$.split(`
63
- `),J=u2(Y,W),X=[],K=0,G=0,B=0;while(K<Y.length||G<W.length){let q=Y[K],P=W[G];if(B<J.length&&q!==void 0&&P!==void 0&&q===J[B]&&P===J[B])X.push({type:"same",line:q}),K++,G++,B++;else if(q!==void 0&&(B>=J.length||q!==J[B]))X.push({type:"removed",line:q}),K++;else if(P!==void 0)X.push({type:"added",line:P}),G++}return X}function u2(Q,$){let Y=Q.length,W=$.length,J=Array.from({length:Y+1},()=>Array(W+1).fill(0));for(let B=1;B<=Y;B++){let q=J[B]??[],P=J[B-1]??[];for(let H=1;H<=W;H++)q[H]=Q[B-1]===$[H-1]?(P[H-1]??0)+1:Math.max(P[H]??0,q[H-1]??0)}let X=[],K=Y,G=W;while(K>0&&G>0){let B=Q[K-1];if(B!==void 0&&B===$[G-1])X.unshift(B),K--,G--;else if((J[K-1]?.[G]??0)>(J[K]?.[G-1]??0))K--;else G--}return X}import{jsxDEV as S0}from"react/jsx-dev-runtime";function c2({before:Q,after:$,language:Y}){let W=u1(Q,$);return S0("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden group/diff","data-md":"diff","data-md-language":Y||"",children:[Y&&S0("div",{className:"px-4 py-2 text-meta font-mono text-text-tertiary opacity-0 group-hover/diff:opacity-60 transition-opacity",children:["diff (",Y,")"]},void 0,!0,void 0,this),S0("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono",children:W.map((J,X)=>S0("div",{className:J.type==="removed"?"bg-accent-red-muted text-accent-red":J.type==="added"?"bg-accent-green-muted text-accent-green":"text-text-tertiary",children:[S0("span",{className:"select-none w-6 inline-block text-center opacity-60",children:J.type==="removed"?"-":J.type==="added"?"+":" "},void 0,!1,void 0,this),J.line]},X,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as d1,useMemo as r1,useRef as l1,useState as i1}from"react";import{useAnnotations as o1,useResponseRegistration as a1}from"#canvas/runtime";import{jsxDEV as c1}from"react/jsx-dev-runtime";function M0({note:Q,onChange:$}){return c1("div",{className:"mt-1.5",children:c1("textarea",{value:Q,onChange:(Y)=>$(Y.currentTarget.value),className:"w-full bg-transparent text-[12px] font-body text-text-primary resize-none focus:outline-none border-none placeholder:text-text-disabled transition-colors min-h-[20px] p-0 leading-relaxed",placeholder:"Add a note...",rows:1,onInput:(Y)=>N0(Y.currentTarget),ref:(Y)=>{if(Y)N0(Y)}},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as R}from"react/jsx-dev-runtime";function s1(Q){return Q.map(($)=>typeof $==="string"?{value:$,label:$}:{value:$.value,label:$.label??$.value})}function d2({id:Q,label:$,options:Y,required:W}){let{responses:J,setResponse:X}=o1();a1(Q);let K=r1(()=>s1(Y),[Y]),G=J.get(Q),B=G?.value,q=G?.note||"",[P,H]=i1(!1),T=l1(null);if(!J.has(Q))X(Q,{id:Q,type:"radio",label:$,value:null,options:K.map((Z)=>Z.value),required:W});let N=(Z)=>{X(Q,{...G,value:Z})};d1(()=>{let Z=T.current;if(!Z)return;let F=(z)=>{let M=z.target.closest("[data-md-label]")?.getAttribute("data-md-label"),w=K.find((b)=>b.label===M);if(w)N(w.value)};return Z.addEventListener("kb-select",F),()=>Z.removeEventListener("kb-select",F)},[K,N]);let U=G?.required&&!B;return R("div",{ref:T,"data-md":"choice","data-md-label":$,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[R("div",{className:"flex items-baseline gap-2 mb-2",children:[R("span",{className:"text-[13px] font-body font-medium text-text-primary",children:$},void 0,!1,void 0,this),W&&R("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),R("div",{className:"space-y-1",children:K.map(({value:Z,label:F})=>R("label",{"data-md":"choice-option","data-md-label":F,onClick:()=>N(Z),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${B===Z?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[R("span",{className:`w-4 h-4 rounded-full border-[1.5px] flex items-center justify-center flex-shrink-0 transition-all ${B===Z?"border-accent-amber bg-accent-amber":"border-border-strong"}`,children:B===Z&&R("span",{className:"w-1.5 h-1.5 rounded-full bg-text-inverse"},void 0,!1,void 0,this)},void 0,!1,void 0,this),R("span",{className:"text-[13px] font-body text-text-secondary",children:F},void 0,!1,void 0,this)]},Z,!0,void 0,this))},void 0,!1,void 0,this),R(M0,{show:P,note:q,onToggle:()=>H(!P),onChange:(Z)=>X(Q,{...G,note:Z})},void 0,!1,void 0,this),U&&R("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"Please select an option."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function r2({id:Q,label:$,options:Y,required:W}){let{responses:J,setResponse:X}=o1();a1(Q);let K=r1(()=>s1(Y),[Y]),G=J.get(Q),B=G?.value||[],q=G?.note||"",[P,H]=i1(!1),T=l1(null);if(!J.has(Q))X(Q,{id:Q,type:"checkbox",label:$,value:[],options:K.map((Z)=>Z.value),required:W});let N=(Z)=>{let F=B.includes(Z)?B.filter((z)=>z!==Z):[...B,Z];X(Q,{...G,value:F})};d1(()=>{let Z=T.current;if(!Z)return;let F=(z)=>{let M=z.target.closest("[data-md-label]")?.getAttribute("data-md-label"),w=K.find((b)=>b.label===M);if(w)N(w.value)};return Z.addEventListener("kb-select",F),()=>Z.removeEventListener("kb-select",F)},[K,N]);let U=G?.required&&B.length===0;return R("div",{ref:T,"data-md":"multichoice","data-md-label":$,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[R("div",{className:"flex items-baseline gap-2 mb-2",children:[R("span",{className:"text-[13px] font-body font-medium text-text-primary",children:$},void 0,!1,void 0,this),W&&R("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),R("div",{className:"space-y-1",children:K.map(({value:Z,label:F})=>{let z=B.includes(Z);return R("label",{"data-md":"multichoice-option","data-md-label":F,onClick:()=>N(Z),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${z?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[R("span",{className:`w-4 h-4 rounded flex items-center justify-center flex-shrink-0 transition-all ${z?"bg-accent-amber":"border-[1.5px] border-border-strong"}`,children:z&&R("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:R("path",{d:"M2.5 5L4.5 7L7.5 3",style:{stroke:"var(--color-text-inverse)"},strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),R("span",{className:"text-[13px] font-body text-text-secondary",children:F},void 0,!1,void 0,this)]},Z,!0,void 0,this)})},void 0,!1,void 0,this),R(M0,{show:P,note:q,onToggle:()=>H(!P),onChange:(Z)=>X(Q,{...G,note:Z})},void 0,!1,void 0,this),U&&R("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"Please select at least one option."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useRef as l2,useState as n1}from"react";import{useAnnotations as t1,useResponseRegistration as e1}from"#canvas/runtime";import{jsxDEV as I}from"react/jsx-dev-runtime";function i2({id:Q,label:$,placeholder:Y,multiline:W,required:J}){let{responses:X,setResponse:K}=t1();e1(Q);let G=X.get(Q),B=G?.value??"",q=G?.note||"",[P,H]=n1(!1),T=l2(null);if(!X.has(Q))K(Q,{id:Q,type:"text",label:$,value:"",required:J});let N=(F)=>{K(Q,{...G,value:F})},U=(F)=>N0(F,W?60:32),Z=G?.required&&!B.trim();return I("div",{"data-md":"userinput","data-md-label":$,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[I("div",{className:"flex items-baseline gap-2 mb-2",children:[I("span",{className:"text-[13px] font-body font-medium text-text-primary",children:$},void 0,!1,void 0,this),J&&I("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),I("textarea",{ref:T,value:B,onChange:(F)=>{N(F.currentTarget.value),U(F.currentTarget)},placeholder:Y||"Type your response...",rows:W?3:1,className:"w-full bg-bg-input text-[13px] font-body text-text-primary rounded-lg px-3 py-2 resize-none focus:outline-none border border-border-subtle focus:border-border-hover placeholder:text-text-tertiary transition-colors",onInput:(F)=>U(F.currentTarget),onFocus:(F)=>U(F.currentTarget)},void 0,!1,void 0,this),I(M0,{show:P,note:q,onToggle:()=>H(!P),onChange:(F)=>K(Q,{...G,note:F})},void 0,!1,void 0,this),Z&&I("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"This field is required."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function o2({id:Q,label:$,min:Y=1,max:W=10,step:J=1,required:X,minLabel:K,maxLabel:G}){let{responses:B,setResponse:q}=t1();e1(Q);let P=B.get(Q),H=P?.value,T=P?.note||"",[N,U]=n1(!1);if(!B.has(Q))q(Q,{id:Q,type:"range",label:$,value:null,required:X});let Z=(C)=>{q(Q,{...P,value:C})},F=H!==null&&H!==void 0,z=F?H:Math.round((Y+W)/2),k=(z-Y)/(W-Y)*100,M=Math.round((W-Y)/J),w=M<=20,b=P?.required&&!F;return I("div",{"data-md":"rangeinput","data-md-label":$,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[I("div",{className:"flex items-baseline justify-between mb-1",children:[I("div",{className:"flex items-baseline gap-2",children:[I("span",{className:"text-[13px] font-body font-medium text-text-primary",children:$},void 0,!1,void 0,this),X&&I("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),I("span",{className:"flex items-center gap-1.5",children:[I("span",{className:`text-[13px] font-mono ${F?"text-accent-amber":"text-text-disabled"}`,children:F?H:"—"},void 0,!1,void 0,this),F&&I("button",{onClick:()=>q(Q,{...P,value:null}),className:"text-text-disabled hover:text-text-tertiary transition-colors text-[10px] leading-none",title:"Clear",children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),I("div",{className:"relative h-6 flex items-center",children:[I("div",{className:"absolute left-0 right-0 h-1.5 rounded-full bg-border-medium",children:F&&I("div",{className:"h-full rounded-full bg-accent-amber transition-all duration-150",style:{width:`${k}%`}},void 0,!1,void 0,this)},void 0,!1,void 0,this),w&&Array.from({length:M+1},(C,p)=>{let c=Y+p*J,a=(c-Y)/(W-Y)*100,f=F&&c<=H;return I("div",{className:`absolute rounded-full pointer-events-none transition-all duration-150 ${F&&c===H?"w-2.5 h-2.5 bg-accent-amber":f?"w-1.5 h-1.5 bg-accent-amber":"w-1.5 h-1.5 bg-border-hover"}`,style:{left:`${a}%`,transform:"translate(-50%, -50%)",top:"50%"}},p,!1,void 0,this)}),F?I("div",{className:"absolute h-5 w-5 rounded-full bg-accent-amber shadow-md pointer-events-none transition-all duration-150",style:{left:`calc(${k}% - 10px)`,borderWidth:"2px",borderStyle:"solid",borderColor:"var(--color-bg-base)"}},void 0,!1,void 0,this):I("div",{className:"absolute h-4 w-4 rounded-full bg-border-hover pointer-events-none opacity-50",style:{left:"calc(50% - 8px)",borderWidth:"2px",borderStyle:"solid",borderColor:"var(--color-bg-base)"}},void 0,!1,void 0,this),I("input",{type:"range",min:Y,max:W,step:J,value:z,onChange:(C)=>Z(Number(C.currentTarget.value)),className:"absolute inset-0 w-full opacity-0 cursor-pointer"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w&&M<=10?I("div",{className:"flex justify-between -mt-0.5 px-0",children:Array.from({length:M+1},(C,p)=>{let c=Y+p*J;return I("span",{className:`text-[10px] font-mono transition-colors ${F&&c===H?"text-accent-amber font-medium":"text-text-disabled"}`,style:{minWidth:"1ch",textAlign:"center"},children:c},p,!1,void 0,this)})},void 0,!1,void 0,this):I("div",{className:"flex justify-between -mt-0.5",children:[I("span",{className:"text-[11px] text-text-tertiary font-body",children:K||Y},void 0,!1,void 0,this),I("span",{className:"text-[11px] text-text-tertiary font-body",children:G||W},void 0,!1,void 0,this)]},void 0,!0,void 0,this),I(M0,{show:N,note:T,onToggle:()=>U(!N),onChange:(C)=>q(Q,{...P,note:C})},void 0,!1,void 0,this),b&&I("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"Please select a value."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useContext as a2,useState as s2}from"react";import{SessionContext as n2}from"#canvas/runtime";import{jsxDEV as b0}from"react/jsx-dev-runtime";function t2({src:Q,alt:$,caption:Y,width:W,height:J}){let X=a2(n2),[K,G]=s2(!1),B=`/api/image?session=${encodeURIComponent(X)}&path=${encodeURIComponent(Q)}`;if(K)return b0("div",{className:"mt-3 text-accent-red text-body bg-accent-red-muted rounded-md p-4",children:[Q,": Failed to load image"]},void 0,!0,void 0,this);return b0("figure",{className:"mt-3 relative","data-md":"image","data-md-src":Q,children:[b0("div",{"data-annotation-image":!0,className:"rounded-md overflow-hidden border border-border-subtle bg-bg-code inline-block",children:b0("img",{src:B,alt:$||Q,onError:()=>G(!0),draggable:!1,className:"block max-w-full h-auto",...W?{width:W}:{},...J?{height:J}:{}},void 0,!1,void 0,this)},void 0,!1,void 0,this),Y&&b0("figcaption",{className:"mt-1.5 text-meta text-text-tertiary font-body",children:Y},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useMemo as e2}from"react";import{jsxDEV as $5}from"react/jsx-dev-runtime";O.setOptions({gfm:!0,breaks:!1});function $4({children:Q,file:$,__content:Y}){let W=Y??(typeof Q==="string"?Q:String(Q??"")),J=e2(()=>{if(!W)return"";return O.parse(W,{async:!1})},[W]);if(!W)return $5("div",{className:"text-text-tertiary text-tiny mt-3",children:$?`Could not load: ${$}`:"No markdown content"},void 0,!1,void 0,this);return $5("div",{className:"mt-3 prose-canvas","data-md":"markdown",...$?{"data-md-file":$}:{},"data-md-source":W,dangerouslySetInnerHTML:{__html:J}},void 0,!1,void 0,this)}import{useFeedback as S6}from"#canvas/runtime";import{useEffect as P4,useState as d0}from"react";import{useFeedback as H4}from"#canvas/runtime";async function Q5(Q){let $=Q4(Q);return crypto.subtle.importKey("raw",$,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}async function Y5(Q,$){let Y=J5($);if(Y.byteLength<28)throw Error("Ciphertext too short");let W=Y.subarray(0,12),J=Y.subarray(12),X=await crypto.subtle.decrypt({name:"AES-GCM",iv:W},Q,J);return new TextDecoder().decode(X)}function J5(Q){let $=atob(Q),Y=new Uint8Array($.length);for(let W=0;W<$.length;W++)Y[W]=$.charCodeAt(W);return Y}function Q4(Q){let $=Q.replace(/-/g,"+").replace(/_/g,"/")+"===".slice((Q.length+3)%4);return J5($)}function Y4(){if(typeof window>"u")return null;let Q=window.location.hash.replace(/^#/,"");if(!Q)return null;for(let $ of Q.split("&")){let[Y,W]=$.split("=");if(Y==="k"&&W)return decodeURIComponent(W)}return null}function J4(){if(typeof window<"u"&&window.__CANVAS_SHARE__?.shareId){let $=Y4();return{isShared:!0,shareId:window.__CANVAS_SHARE__.shareId,encryptionKey:$?Q5($):null}}return{isShared:!1,sessionId:typeof window<"u"?window.location.pathname.replace("/s/",""):""}}var v=J4();function W4(){return v.isShared&&v.encryptionKey!==null}function X4(){return v.isShared?v.shareId:v.sessionId}function K4(Q,$){let Y=Q.replace(/\.jsx$/,".js");if(v.isShared)return`/s/${v.shareId}/canvas/${encodeURIComponent(Y)}`;let W=$?`?rev=${$}&t=${Date.now()}`:`?t=${Date.now()}`;return`/api/session/${v.sessionId}/canvas/${encodeURIComponent(Y)}${W}`}function B4(){if(v.isShared)return`/s/${v.shareId}/upload`;return`/api/session/${v.sessionId}/upload`}function G1(Q,$){if(v.isShared)throw Error("Secret inputs are available only on the local canvas daemon");return`/api/session/${encodeURIComponent(v.sessionId)}/secrets/${encodeURIComponent(Q)}/${$}`}async function q1(Q){let $=await Q.json().catch(()=>null);if(typeof $==="object"&&$!==null&&"error"in $&&typeof $.error==="string")return Error($.error);return Error(`Secret API request failed with status ${Q.status}`)}async function W5(Q){let $=await fetch(G1(Q,"status"),{cache:"no-store"});if(!$.ok)throw await q1($);let Y=await $.json();return typeof Y==="object"&&Y!==null&&"ready"in Y&&Y.ready===!0}async function X5(Q,$){let Y=await fetch(G1(Q,"value"),{method:"POST",headers:{"Content-Type":"application/json"},cache:"no-store",body:JSON.stringify({value:$})});if(!Y.ok)throw await q1(Y)}async function K5(Q){let $=await fetch(G1(Q,"value"),{method:"DELETE",cache:"no-store"});if(!$.ok)throw await q1($)}async function G4(Q,$){let Y=K4(Q,$);if(!W4())return import(Y);let W=await fetch(Y);if(!W.ok)throw Error(`canvas ${W.status}`);let J=await W.text(),X=await v.encryptionKey,K=await Y5(X,J),G=new Blob([K],{type:"application/javascript"}),B=URL.createObjectURL(G);try{return await import(B)}finally{setTimeout(()=>URL.revokeObjectURL(B),0)}}var q4=!v.isShared,v6=!v.isShared,V6={get sessionId(){return X4()},isShared:v.isShared,fsAvailable:q4,uploadUrl:B4,loadCanvasModule:G4};import{jsxDEV as E}from"react/jsx-dev-runtime";var U4=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/,Z4=/^[A-Za-z_][A-Za-z0-9_]*$/;function N4({id:Q,label:$,env:Y,placeholder:W,required:J}){let[X,K]=d0(""),[G,B]=d0(!1),[q,P]=d0(!v.isShared),[H,T]=d0(null),N=U4.test(Q),U=Z4.test(Y),Z=!v.isShared;P4(()=>{if(!Z||!N){P(!1);return}let w=!0;return W5(Q).then((b)=>{if(w)B(b)}).catch((b)=>{if(w)T(b instanceof Error?b.message:"Could not read secret status")}).finally(()=>{if(w)P(!1)}),()=>{w=!1}},[Q,Z,N]);let F=G?`**${$}**
64
- Secret is ready. Field: \`${Q}\`. Environment variable: \`${Y}\`.
65
- `:"";H4(`secret:${Q}`,F,{label:$,required:J&&Z});let z=async()=>{if(!X||!N||!U)return;P(!0),T(null);try{await X5(Q,X),K(""),B(!0)}catch(w){T(w instanceof Error?w.message:"Could not store secret")}finally{P(!1)}},k=async()=>{P(!0),T(null);try{await K5(Q),B(!1)}catch(w){T(w instanceof Error?w.message:"Could not clear secret")}finally{P(!1)}};if(!Z)return E("div",{"data-md":"secretinput","data-md-label":$,className:"-mx-4 px-4 py-3 my-1 rounded-lg bg-accent-amber-muted",children:[E("div",{className:"text-[13px] font-body font-medium text-text-primary",children:$},void 0,!1,void 0,this),E("p",{className:"text-[12px] font-body text-text-secondary mt-1",children:"Secret input is unavailable in shared canvases. Open this runbook on the author's local canvas daemon."},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let M=!N?"Secret field IDs may contain letters, numbers, dots, underscores, and hyphens.":!U?"Environment variable names must use letters, numbers, and underscores and may not start with a number.":null;return E("div",{"data-md":"secretinput","data-md-label":$,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[E("div",{className:"flex items-baseline justify-between gap-3 mb-2",children:[E("div",{className:"flex items-baseline gap-2",children:[E("span",{className:"text-[13px] font-body font-medium text-text-primary",children:$},void 0,!1,void 0,this),J&&E("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),E("span",{className:`text-[11px] font-body ${G?"text-accent-green":"text-text-tertiary"}`,children:q?"Working…":G?"Ready in memory":"Not stored"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),E("div",{className:"flex gap-2",children:[E("input",{type:"password",value:X,onChange:(w)=>K(w.target.value),onKeyDown:(w)=>{if(w.key==="Enter")w.preventDefault(),z()},placeholder:W||"Paste secret value",autoComplete:"off",spellCheck:!1,disabled:q||!!M,className:"min-w-0 flex-1 bg-bg-input text-[13px] font-mono text-text-primary rounded-lg px-3 py-2 focus:outline-none border border-border-subtle focus:border-border-hover placeholder:text-text-tertiary disabled:opacity-50 transition-colors"},void 0,!1,void 0,this),E("button",{type:"button",onClick:()=>void z(),disabled:q||!X||!!M,className:"px-3 py-2 rounded-lg bg-btn-primary text-btn-primary-text text-[12px] font-body font-medium disabled:opacity-40 disabled:cursor-default",children:G?"Replace":"Store"},void 0,!1,void 0,this),G&&E("button",{type:"button",onClick:()=>void k(),disabled:q,className:"px-3 py-2 rounded-lg border border-border-subtle text-text-secondary text-[12px] font-body font-medium hover:border-border-hover disabled:opacity-40",children:"Clear"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),E("p",{className:"text-[11px] font-body text-text-tertiary mt-1.5",children:["Stored only in daemon memory. The agent receives field ",Q," for ",Y,", not the value."]},void 0,!0,void 0,this),(M||H)&&E("p",{className:"text-[11px] text-accent-red font-body mt-1",children:M||H},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}export{S6 as useFeedback,i2 as UserInput,W2 as Task,U2 as Table,$2 as Section,N4 as SecretInput,o2 as RangeInput,T2 as Priority,P2 as Note,r2 as MultiChoice,E2 as Mermaid,$4 as Markdown,S1 as Item,t2 as ImageView,M2 as FilePreview,c2 as Diff,B2 as CodeBlock,d2 as Choice,Z2 as Checklist,q2 as Callout};
53
+ `+e+`</thead>
54
+ `+o+`</table>
55
+ `}tablerow({text:t}){return`<tr>
56
+ ${t}</tr>
57
+ `}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
58
+ `}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${te(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let o=this.parser.parseInline(n),r=Mt(t);if(r===null)return o;t=r;let s='<a href="'+t+'"';return e&&(s+=' title="'+te(e)+'"'),s+=">"+o+"</a>",s}image({href:t,title:e,text:n,tokens:o}){o&&(n=this.parser.parseInline(o,this.parser.textRenderer));let r=Mt(t);if(r===null)return te(n);t=r;let s=`<img src="${t}" alt="${te(n)}"`;return e&&(s+=` title="${te(e)}"`),s+=">",s}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):("escaped"in t)&&t.escaped?t.text:te(t.text)}},ut=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},Z=class t{options;renderer;textRenderer;constructor(e){this.options=e||he,this.options.renderer=this.options.renderer||new He,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ut}static parse(e,n){return new t(n).parse(e)}static parseInline(e,n){return new t(n).parseInline(e)}parse(e){this.renderer.parser=this;let n="";for(let o=0;o<e.length;o++){let r=e[o];if(this.options.extensions?.renderers?.[r.type]){let i=r,l=this.options.extensions.renderers[i.type].call({parser:this},i);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(i.type)){n+=l||"";continue}}let s=r;switch(s.type){case"space":{n+=this.renderer.space(s);break}case"hr":{n+=this.renderer.hr(s);break}case"heading":{n+=this.renderer.heading(s);break}case"code":{n+=this.renderer.code(s);break}case"table":{n+=this.renderer.table(s);break}case"blockquote":{n+=this.renderer.blockquote(s);break}case"list":{n+=this.renderer.list(s);break}case"checkbox":{n+=this.renderer.checkbox(s);break}case"html":{n+=this.renderer.html(s);break}case"def":{n+=this.renderer.def(s);break}case"paragraph":{n+=this.renderer.paragraph(s);break}case"text":{n+=this.renderer.text(s);break}default:{let i='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(i),"";throw Error(i)}}}return n}parseInline(e,n=this.renderer){this.renderer.parser=this;let o="";for(let r=0;r<e.length;r++){let s=e[r];if(this.options.extensions?.renderers?.[s.type]){let l=this.options.extensions.renderers[s.type].call({parser:this},s);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){o+=l||"";continue}}let i=s;switch(i.type){case"escape":{o+=n.text(i);break}case"html":{o+=n.html(i);break}case"link":{o+=n.link(i);break}case"image":{o+=n.image(i);break}case"checkbox":{o+=n.checkbox(i);break}case"strong":{o+=n.strong(i);break}case"em":{o+=n.em(i);break}case"codespan":{o+=n.codespan(i);break}case"br":{o+=n.br(i);break}case"del":{o+=n.del(i);break}case"text":{o+=n.text(i);break}default:{let l='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw Error(l)}}}return o}},Re=class{options;block;constructor(t){this.options=t||he}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(t=this.block){return t?K.lex:K.lexInline}provideParser(t=this.block){return t?Z.parse:Z.parseInline}},kr=class{defaults=nt();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Z;Renderer=He;TextRenderer=ut;Lexer=K;Tokenizer=_e;Hooks=Re;constructor(...t){this.use(...t)}walkTokens(t,e){let n=[];for(let o of t)switch(n=n.concat(e.call(this,o)),o.type){case"table":{let r=o;for(let s of r.header)n=n.concat(this.walkTokens(s.tokens,e));for(let s of r.rows)for(let i of s)n=n.concat(this.walkTokens(i.tokens,e));break}case"list":{let r=o;n=n.concat(this.walkTokens(r.items,e));break}default:{let r=o;this.defaults.extensions?.childTokens?.[r.type]?this.defaults.extensions.childTokens[r.type].forEach((s)=>{let i=r[s].flat(1/0);n=n.concat(this.walkTokens(i,e))}):r.tokens&&(n=n.concat(this.walkTokens(r.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach((n)=>{let o={...n};if(o.async=this.defaults.async||o.async||!1,n.extensions&&(n.extensions.forEach((r)=>{if(!r.name)throw Error("extension name required");if("renderer"in r){let s=e.renderers[r.name];s?e.renderers[r.name]=function(...i){let l=r.renderer.apply(this,i);return l===!1&&(l=s.apply(this,i)),l}:e.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw Error("extension level must be 'block' or 'inline'");let s=e[r.level];s?s.unshift(r.tokenizer):e[r.level]=[r.tokenizer],r.start&&(r.level==="block"?e.startBlock?e.startBlock.push(r.start):e.startBlock=[r.start]:r.level==="inline"&&(e.startInline?e.startInline.push(r.start):e.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(e.childTokens[r.name]=r.childTokens)}),o.extensions=e),n.renderer){let r=this.defaults.renderer||new He(this.defaults);for(let s in n.renderer){if(!(s in r))throw Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let i=s,l=n.renderer[i],a=r[i];r[i]=(...c)=>{let u=l.apply(r,c);return u===!1&&(u=a.apply(r,c)),u||""}}o.renderer=r}if(n.tokenizer){let r=this.defaults.tokenizer||new _e(this.defaults);for(let s in n.tokenizer){if(!(s in r))throw Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let i=s,l=n.tokenizer[i],a=r[i];r[i]=(...c)=>{let u=l.apply(r,c);return u===!1&&(u=a.apply(r,c)),u}}o.tokenizer=r}if(n.hooks){let r=this.defaults.hooks||new Re;for(let s in n.hooks){if(!(s in r))throw Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let i=s,l=n.hooks[i],a=r[i];Re.passThroughHooks.has(s)?r[i]=(c)=>{if(this.defaults.async&&Re.passThroughHooksRespectAsync.has(s))return(async()=>{let p=await l.call(r,c);return a.call(r,p)})();let u=l.call(r,c);return a.call(r,u)}:r[i]=(...c)=>{if(this.defaults.async)return(async()=>{let p=await l.apply(r,c);return p===!1&&(p=await a.apply(r,c)),p})();let u=l.apply(r,c);return u===!1&&(u=a.apply(r,c)),u}}o.hooks=r}if(n.walkTokens){let r=this.defaults.walkTokens,s=n.walkTokens;o.walkTokens=function(i){let l=[];return l.push(s.call(this,i)),r&&(l=l.concat(r.call(this,i))),l}}this.defaults={...this.defaults,...o}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return K.lex(t,e??this.defaults)}parser(t,e){return Z.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let o={...n},r={...this.defaults,...o},s=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&o.async===!1)return s(Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return s(Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return s(Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=t),r.async)return(async()=>{let i=r.hooks?await r.hooks.preprocess(e):e,l=await(r.hooks?await r.hooks.provideLexer(t):t?K.lex:K.lexInline)(i,r),a=r.hooks?await r.hooks.processAllTokens(l):l;r.walkTokens&&await Promise.all(this.walkTokens(a,r.walkTokens));let c=await(r.hooks?await r.hooks.provideParser(t):t?Z.parse:Z.parseInline)(a,r);return r.hooks?await r.hooks.postprocess(c):c})().catch(s);try{r.hooks&&(e=r.hooks.preprocess(e));let i=(r.hooks?r.hooks.provideLexer(t):t?K.lex:K.lexInline)(e,r);r.hooks&&(i=r.hooks.processAllTokens(i)),r.walkTokens&&this.walkTokens(i,r.walkTokens);let l=(r.hooks?r.hooks.provideParser(t):t?Z.parse:Z.parseInline)(i,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(i){return s(i)}}}onError(t,e){return(n)=>{if(n.message+=`
59
+ Please report this to https://github.com/markedjs/marked.`,t){let o="<p>An error occurred:</p><pre>"+te(n.message+"",!0)+"</pre>";return e?Promise.resolve(o):o}if(e)return Promise.reject(n);throw n}}},fe=new kr;function S(t,e){return fe.parse(t,e)}S.options=S.setOptions=function(t){return fe.setOptions(t),S.defaults=fe.defaults,_t(S.defaults),S};S.getDefaults=nt;S.defaults=he;S.use=function(...t){return fe.use(...t),S.defaults=fe.defaults,_t(S.defaults),S};S.walkTokens=function(t,e){return fe.walkTokens(t,e)};S.parseInline=fe.parseInline;S.Parser=Z;S.parser=Z.parse;S.Renderer=He;S.TextRenderer=ut;S.Lexer=K;S.lexer=K.lex;S.Tokenizer=_e;S.Hooks=Re;S.parse=S;var{options:rs,setOptions:os,use:ss,walkTokens:is,parseInline:as}=S;var ls=Z.parse,cs=K.lex;import Vt from"react";import{jsxDEV as dt}from"react/jsx-dev-runtime";S.setOptions({gfm:!0,breaks:!1});var vr=new Set(["a","abbr","b","br","code","del","em","i","kbd","mark","q","s","small","span","strong","sub","sup","time","u"]),wr=new Set(["Priority"]);function Sr(t){if(typeof t==="string"||typeof t==="number")return!0;if(!Vt.isValidElement(t))return!1;if(typeof t!=="object"||t===null||!("type"in t))return!1;let e=t.type;if(typeof e==="string")return vr.has(e);if(typeof e==="function"){let n="displayName"in e&&typeof e.displayName==="string"?e.displayName:e.name;return n?wr.has(n):!1}return!1}function Ar(t,e){let n=t.trim();if(!n)return null;let o=S.parse(n,{async:!1});return dt("div",{className:"prose-canvas","data-md":"markdown","data-md-source":n,dangerouslySetInnerHTML:{__html:o}},e,!1,void 0,this)}function Rr(t,e){return dt("div",{className:"prose-canvas",children:t.map((n,o)=>{if(typeof n==="string"||typeof n==="number"){let r=S.parseInline(String(n),{async:!1});return dt("span",{dangerouslySetInnerHTML:{__html:r}},o,!1,void 0,this)}return n})},e,!1,void 0,this)}function ie(t){let e=Vt.Children.toArray(t);if(e.length===0)return null;let n=[],o=[],r=0,s=()=>{if(o.length===0)return;if(o.some((l)=>typeof l!=="string"&&typeof l!=="number"))n.push(Rr(o,`md-${r++}`));else{let l=Ar(o.join(""),`md-${r++}`);if(l)n.push(l)}o=[]};for(let i of e)if(Sr(i))o.push(i);else s(),n.push(i);return s(),n}import{jsxDEV as pt}from"react/jsx-dev-runtime";var Tr={info:{bg:"bg-accent-blue-muted",icon:"i",iconColor:"text-accent-blue"},warning:{bg:"bg-accent-amber-muted",icon:"!",iconColor:"text-accent-amber"},danger:{bg:"bg-accent-red-muted",icon:"✕",iconColor:"text-accent-red"},tip:{bg:"bg-accent-green-muted",icon:"✓",iconColor:"text-accent-green"}};function Er({type:t="info",children:e}){let n=Tr[t];return pt("div",{className:`${n.bg} relative rounded-lg px-5 py-4 mt-3 flex gap-3 items-start`,"data-md":"callout","data-md-type":t,children:[pt("span",{"aria-hidden":"true",className:`${n.iconColor} opacity-70 text-base leading-relaxed flex-shrink-0 mt-px`,children:n.icon},void 0,!1,void 0,this),pt("div",{className:"text-body text-text-secondary leading-relaxed",children:ie(e)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as be}from"react/jsx-dev-runtime";function Nr({items:t}){return be("ul",{className:"space-y-1 mt-3","data-md":"checklist",children:t.map((e,n)=>be("li",{"data-md":"checklist-item","data-md-label":e.label,className:"relative flex items-start gap-2.5 py-1",children:[be("span",{className:`w-4 h-4 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5 transition-all ${e.checked?"bg-accent-green":"border-[1.5px] border-border-hover"}`,children:e.checked&&be("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:be("path",{d:"M2.5 5L4.5 7L7.5 3",style:{stroke:"var(--color-text-inverse)"},strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),be("span",{className:`text-body font-body ${e.checked?"text-text-tertiary line-through decoration-border-hover":"text-text-secondary"}`,children:e.label},void 0,!1,void 0,this)]},n,!0,void 0,this))},void 0,!1,void 0,this)}import{useAnnotations as cn,useResponseRegistration as un}from"#canvas/runtime";import{useEffect as dn,useMemo as pn,useRef as fn,useState as hn}from"react";import{AnnotationCtx as ya,AnnotationHostContext as ka,SessionContext as va,useAnnotationHost as wa,useAnnotations as Sa}from"@fabrika/annotations/runtime";function ft(t,e){let n=[],o=Cr(t);for(let r of o){let s=document.createRange();if(s.selectNodeContents(r),r===t.startContainer)s.setStart(r,t.startOffset);if(r===t.endContainer)s.setEnd(r,t.endOffset);let i=s.toString();if(!i||!i.trim())continue;let l=document.createElement("mark");l.setAttribute("data-annotation-id",e);try{s.surroundContents(l)}catch{let a=s.extractContents();l.appendChild(a),s.insertNode(l)}n.push(l)}return n}function ht(t){let e=t.parentElement;if(e?.classList.contains("select-none"))return!1;if(e?.closest("[data-annotation-id]"))return!1;return!0}function Cr(t){let e=[],n=t.commonAncestorContainer;if(n.nodeType===Node.TEXT_NODE)return e.push(n),e;let o=document.createTreeWalker(n,NodeFilter.SHOW_TEXT),r;while(r=o.nextNode()){if(!ht(r))continue;if(t.intersectsNode(r))e.push(r)}return e}function gt(t,e){for(let n of e){if(t.querySelector(`[data-annotation-id="${n.id}"]`))continue;let o=n.snippet;if(!o)continue;let{fullText:r,textNodes:s}=Ir(t),i=[],l=0;while(!0){let d=r.indexOf(o,l);if(d===-1)break;i.push(d),l=d+1}let[a]=i;if(a===void 0)continue;let c=a;if(i.length>1&&n.context){let d=-1;for(let f of i){let m=0;if(n.context.before){let b=r.slice(Math.max(0,f-80),f);if(b.includes(n.context.before))m+=2;else if(n.context.before.length>10&&b.includes(n.context.before.slice(-10)))m+=1}if(n.context.after){let b=r.slice(f+o.length,f+o.length+80);if(b.includes(n.context.after))m+=2;else if(n.context.after.length>10&&b.includes(n.context.after.slice(0,10)))m+=1}if(m>d)d=m,c=f}}let u=c,p=c+o.length,g=jt(s,u),h=jt(s,p);if(!g||!h)continue;try{let d=document.createRange();d.setStart(g.node,g.offset),d.setEnd(h.node,h.offset),ft(d,n.id)}catch{}}}function Ir(t){let e=[],n="",o=document.createTreeWalker(t,NodeFilter.SHOW_TEXT),r;while(r=o.nextNode()){if(!ht(r))continue;e.push({node:r,start:n.length}),n+=r.textContent||""}return{fullText:n,textNodes:e}}function jt(t,e){for(let n=t.length-1;n>=0;n--){let o=t[n];if(!o||o.start>e)continue;let r=e-o.start,s=o.node.textContent?.length??0;if(r<=s)return{node:o.node,offset:r}}return null}function Ee(t){return{kind:t.kind,owns:(e)=>t.parse(e)!==null,find:(e,n)=>{let o=t.parse(e);return o===null?null:t.find(o,n)},restore:(e,n)=>{let o=t.parse(n.snippet);if(o===null)return;t.restore?.(o,e,n)},describe:(e)=>{let n=t.parse(e);if(n===null||!t.describe)return null;return t.describe(n)}}}function Kt(t){let e=document.createTreeWalker(t,NodeFilter.SHOW_TEXT),n="";for(let o=e.nextNode();o;o=e.nextNode()){let r=o.parentElement?.closest("[aria-hidden='true']");if(r&&t.contains(r))continue;n+=o.textContent??""}return n.trim()}function Be(t,e,n){return{selector:t,snippet:(o)=>{let r=o.getAttribute(n);return r?`${e} ${r}`:null}}}var mt=[Be("[data-md='item']","[Item]","data-md-label"),Be("[data-md='section']","[Section]","data-md-title"),Be("[data-md='checklist-item']","[Checklist]","data-md-label"),Be("[data-md='image']","[Image]","data-md-src"),{selector:"[data-md='callout']",snippet:(t)=>`[Callout:${t.getAttribute("data-md-type")||"info"}] ${Kt(t).slice(0,60)||"Callout"}`},{selector:"[data-md='note']",snippet:(t)=>`[Note] ${Kt(t).slice(0,60)||"Note"}`},{selector:"[data-md='table'] tbody tr",snippet:(t)=>{let e=Array.from(t.querySelectorAll("td")).map((n)=>n.textContent?.trim()).filter(Boolean);return e.length?`[Row] ${e.join(" | ")}`:null}}],Lr=["[data-md='choice-option']","[data-md='multichoice-option']","[data-md='userinput']","[data-md='rangeinput']"],xt=mt.map((t)=>t.selector).join(", "),Zt=[...mt.map((t)=>t.selector),...Lr].join(", ");function bt(t){for(let e of mt)if(t.matches(e.selector))return e.snippet(t);return null}var yt={kind:"block",parse:(t)=>t.startsWith("[")?{snippet:t}:null,format:(t)=>t.snippet,find:(t,e)=>{for(let n of e.querySelectorAll(xt)){if(!(n instanceof HTMLElement))continue;if(bt(n)===t.snippet)return n}return null}};var Pr=/^\[Region:(rect|ellipse)\] ([\s\S]+) @(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*)$/;function Mr(t){if(t==="rect")return"rect";if(t==="ellipse")return"ellipse";return null}function qe(t){if(t===void 0)return null;let e=Number(t);if(!Number.isInteger(e)||e<0||e>1e4)return null;return e}function Yt(t){return{left:`${t.x/100}%`,top:`${t.y/100}%`,width:`${t.w/100}%`,height:`${t.h/100}%`}}function Fe(t){return`${(t/100).toFixed(1).replace(/\.0$/,"")}%`}function vt(t){let e=`${Fe(t.x)}-${Fe(t.x+t.w)}`,n=`${Fe(t.y)}-${Fe(t.y+t.h)}`;return`[Region] ${t.src} — ${t.shape} x ${e}, y ${n} of the image`}function kt(t,e){for(let n of e.querySelectorAll("[data-md='image']")){if(!(n instanceof HTMLElement))continue;if(n.getAttribute("data-md-src")!==t)continue;let o=n.querySelector("[data-annotation-image]");if(o instanceof HTMLElement)return o}return null}function Xt(t,e){let n=Yt(e);t.style.left=n.left,t.style.top=n.top,t.style.width=n.width,t.style.height=n.height}function wt(t,e,n){let o=document.createElement("div");return o.className="ann-region",o.setAttribute("data-annotation-id",n),o.setAttribute("data-annotation-region",e),Xt(o,t),o}var Ge={kind:"region",parse:(t)=>{let e=Pr.exec(t);if(!e)return null;let n=Mr(e[1]),o=e[2],r=qe(e[3]),s=qe(e[4]),i=qe(e[5]),l=qe(e[6]);if(n===null||o===void 0)return null;if(r===null||s===null||i===null||l===null)return null;if(i<1||l<1)return null;return{src:o,shape:n,x:r,y:s,w:i,h:l}},format:(t)=>`[Region:${t.shape}] ${t.src} @${t.x},${t.y},${t.w},${t.h}`,find:(t,e)=>kt(t.src,e),restore:(t,e,n)=>{if(e.querySelector(`[data-annotation-id="${n.id}"]`))return;let o=kt(t.src,e);if(!o)return;o.appendChild(wt(t,t.shape,n.id))},describe:vt};var St={kind:"text",parse:(t)=>t?{text:t}:null,format:(t)=>t.text,find:()=>null,restore:(t,e,n)=>{gt(e,[n])}};var $r=[Ee(Ge),Ee(yt),Ee(St)];import{AnnotationCtx as js,SessionContext as Ks,useAnnotationHost as Zs}from"@fabrika/annotations/runtime";import{useEffect as Qs,useState as Js}from"react";import{useCallback as qs,useMemo as Fs,useState as Gs}from"react";function Ne(t){return t.uploadUrl!==null}function oe(t,e){t.style.height="auto",t.style.height=(e?Math.max(e,t.scrollHeight):t.scrollHeight)+"px"}import{useAnnotations as Ue}from"@fabrika/annotations/runtime";import{useAnnotationHost as _r}from"@fabrika/annotations/runtime";import{useCallback as se,useEffect as Hr,useRef as Rt,useState as Tt}from"react";import{jsxDEV as B}from"react/jsx-dev-runtime";function Qt(t){if(t.startsWith("/s/")||t.startsWith("http://")||t.startsWith("https://"))return t;return`/api/uploads/${t.split("/").pop()}`}async function zr(t,e){let n=t.uploadUrl;if(!n)return null;let o=new FormData;o.append("image",e);try{let s=await(await fetch(n(),{method:"POST",body:o})).json();if(t.isShared)return s.url||null;return s.path||null}catch{return null}}function We({note:t,onNoteChange:e,images:n,onAddImage:o,onRemoveImage:r,sessionId:s,placeholder:i="Add your note...",autoFocus:l=!1,autoResize:a=!1,readOnly:c=!1,onKeyDown:u,onTextareaClick:p,textareaRef:g,textareaClassName:h,textareaStyle:d,minHeight:f,attachButton:m="always",openFilePickerRef:b}){let R=_r(),v=!c&&Ne(R),[w,N]=Tt(!1),[L,F]=Tt(!1),[U,Y]=Tt(!1),C=Rt(0),M=Rt(null),G=Rt(null),H=se(()=>G.current?.click(),[]);if(b)b.current=H;let X=se((y)=>{if(M.current=y,g)g.current=y;if(y&&a)oe(y,f)},[g,a,f]);Hr(()=>{if(l&&M.current){let y=M.current;if(y.focus(),y.value)y.setSelectionRange(y.value.length,y.value.length)}},[l]);let W=se(async(y)=>{if(!y.type.startsWith("image/"))return;F(!0);try{let z=await zr(R,y);if(z)o(z)}finally{F(!1)}},[R,o]),ce=se((y)=>{for(let z of y.clipboardData?.items??[])if(z.type.startsWith("image/")){y.preventDefault();let me=z.getAsFile();if(me)W(me);return}},[W]),V=se((y)=>{if(y.preventDefault(),C.current++,C.current===1)N(!0)},[]),j=se((y)=>{y.preventDefault()},[]),Q=se((y)=>{if(y.preventDefault(),C.current--,C.current===0)N(!1)},[]),J=se((y)=>{y.preventDefault(),C.current=0,N(!1);for(let z of y.dataTransfer?.files??[])if(z.type.startsWith("image/"))W(z)},[W]),ue=se((y)=>{if(e(y.currentTarget.value),a)y.currentTarget.style.height="auto",y.currentTarget.style.height=(f?Math.max(f,y.currentTarget.scrollHeight):y.currentTarget.scrollHeight)+"px"},[e,a,f]),de="w-full bg-transparent text-[13px] font-body text-text-primary resize-none focus:outline-none leading-relaxed p-0 border-none",et={width:"100%",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",outline:"none",...a?{resize:"none",overflow:"hidden"}:{resize:"vertical"}},Me=v&&(m==="always"||m==="on-focus"&&U);return B("div",{style:{position:"relative"},onDragEnter:v?V:void 0,onDragOver:v?j:void 0,onDragLeave:v?Q:void 0,onDrop:v?J:void 0,children:[B("textarea",{ref:X,value:t,onChange:c?void 0:ue,onPaste:v?ce:void 0,onKeyDown:u,onClick:p,onFocus:()=>Y(!0),onBlur:()=>{setTimeout(()=>Y(!1),150)},readOnly:c,placeholder:i,className:h??de,style:d??et,rows:a?1:void 0},void 0,!1,void 0,this),v&&B("input",{ref:G,type:"file",accept:"image/*",multiple:!0,style:{display:"none"},onChange:(y)=>{let z=y.currentTarget.files;if(z)for(let me of z)W(me);y.currentTarget.value=""}},void 0,!1,void 0,this),(n.length>0||Me)&&B("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px",alignItems:"center"},children:[n.map((y)=>B("div",{style:{position:"relative",width:"56px",height:"56px",borderRadius:"6px",overflow:"hidden",border:"1px solid var(--color-border-subtle)",flexShrink:0},children:[B("img",{src:Qt(y),alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}},void 0,!1,void 0,this),!c&&B("button",{onClick:(z)=>{z.stopPropagation(),r(y)},style:{position:"absolute",top:"2px",right:"2px",width:"16px",height:"16px",borderRadius:"50%",background:"rgba(0,0,0,0.6)",color:"white",border:"none",cursor:"pointer",fontSize:"11px",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:0},title:"Remove image",children:"×"},void 0,!1,void 0,this)]},y,!0,void 0,this)),Me&&B(Ve,{onClick:H},void 0,!1,void 0,this)]},void 0,!0,void 0,this),L&&B("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:"Uploading..."},void 0,!1,void 0,this),w&&B("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-highlight-bg)",opacity:0.9,border:"2px dashed var(--color-highlight-border)",borderRadius:"6px",zIndex:10,pointerEvents:"none",fontSize:"12px",fontFamily:"'Inter', sans-serif",color:"var(--color-text-secondary)"},children:"Drop image"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Ve({onClick:t,size:e=16}){return B("button",{onClick:(n)=>{n.stopPropagation(),t()},style:{width:`${e*2}px`,height:`${e*2}px`,borderRadius:"6px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--color-text-tertiary)",flexShrink:0,transition:"color 0.15s"},title:"Attach image",onMouseEnter:(n)=>{n.currentTarget.style.color="var(--color-text-secondary)"},onMouseLeave:(n)=>{n.currentTarget.style.color="var(--color-text-tertiary)"},children:B("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[B("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},void 0,!1,void 0,this),B("circle",{cx:"8.5",cy:"8.5",r:"1.5"},void 0,!1,void 0,this),B("polyline",{points:"21 15 16 10 5 21"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}import{SessionContext as fi}from"@fabrika/annotations/runtime";import{useContext as gi,useEffect as mi,useRef as xi}from"react";import{SessionContext as Fr,useAnnotationHost as Gr}from"@fabrika/annotations/runtime";import{useCallback as je,useContext as Ur,useEffect as Wr,useMemo as nn,useRef as Ke,useState as ye}from"react";import{createPortal as Vr}from"react-dom";function en(t){let e=/^(\d+(?:\.\d+)?)px$/.exec(t.trim());return e?Number(e[1]):void 0}function tn(t,e,n=280){let r=e||document.body,s=t.getBoundingClientRect(),i=r.getBoundingClientRect(),l=r===document.body?0:r.scrollTop,a=s.bottom-i.top+l+8,c=Math.max(0,Math.min(s.left-i.left,i.width-n-12));return r.style.position="relative",{style:{position:"absolute",top:`${a}px`,left:`${c}px`},parent:r}}import{jsxDEV as _,Fragment as jr}from"react/jsx-dev-runtime";function on({anchorEl:t,scrollContainer:e,onClose:n,ignoreSelector:o,zIndex:r="50",padding:s="12px",width:i="280px",children:l}){let a=Ke(null),c=Ke(n);c.current=n;let{style:u,parent:p}=tn(t,e,en(i));return Wr(()=>{let g=setTimeout(()=>{let h=(d)=>{if(a.current&&!a.current.contains(d.target)){if(o&&d.target.closest?.(o))return;c.current(),document.removeEventListener("mousedown",h)}};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},0);return()=>clearTimeout(g)},[o]),Vr(_("div",{ref:a,style:{...u,zIndex:r,width:i,background:"var(--color-bg-elevated)",border:"1px solid var(--color-border-hover)",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",padding:s,fontFamily:"'Inter', sans-serif"},children:l},void 0,!1,void 0,this),p)}var sn=[{label:"Clarity",items:["Unclear","Why?","Needs example","Missing context"]},{label:"Scope",items:["Overkill","Out of scope","Important","Risky"]},{label:"Action",items:["Simplify","Rethink","Expand on this","Skip this"]}],rn=sn.flatMap((t)=>t.items);function an({anchorEl:t,scrollContainer:e,snippet:n,truncateAt:o=100,header:r,initialNote:s="",initialImages:i,onConfirm:l,onCancel:a,onDelete:c}){let u=Ur(Fr),p=Gr(),g=Ne(p),h=s!==""||!!c,[d,f]=ye(s),[m,b]=ye(i||[]),[R,v]=ye(null),[w,N]=ye(h),[L,F]=ye(!1),U=Ke(null),Y=Ke(null),C=je(()=>{if(d.trim()||m.length>0)l(d.trim(),m);else if(h&&c)c();else a()},[d,m,l,a,h,c]),M=je(()=>{if(h){if(!d.trim()&&m.length===0&&c){c(),a();return}l(d,m);return}a()},[d,m,h,l,a,c]),G=!h,H=d.trim().length>0?rn.filter((x)=>x.toLowerCase().startsWith(d.trim().toLowerCase())):rn,X=!G||w?[]:H.length===1&&H[0]?.toLowerCase()===d.trim().toLowerCase()?[]:H,W=new Set(X),ce=sn.map((x)=>({label:x.label,items:x.items.filter((E)=>W.has(E))})).filter((x)=>x.items.length>0),V=ce.map((x)=>x.items),j=(x)=>V[x]?.length??0,Q=V.flat(),J=nn(()=>{if(R===null)return 0;let x=0;for(let E=0;E<V.length;E++){if(R<x+j(E))return E;x+=j(E)}return 0},[R,V]),ue=nn(()=>{if(R===null)return 0;let x=0;for(let E=0;E<J;E++)x+=j(E);return R-x},[R,J,V]),de=(x,E)=>{let O=0;for(let ee=0;ee<x;ee++)O+=j(ee);return O+E},[et,Me]=ye(d);if(d!==et)Me(d),v(null),N(h);let y=je((x)=>{f(x)},[]),z=n.length>o?n.slice(0,o)+"...":n,me=je((x)=>{if(Q.length>0&&(x.key==="ArrowDown"||x.key==="ArrowUp"||x.key==="ArrowLeft"||x.key==="ArrowRight")){if(x.preventDefault(),R===null){v(0);return}if(x.key==="ArrowDown"){let O=Math.min(ue+1,j(J)-1);v(de(J,O))}else if(x.key==="ArrowUp"){let O=Math.max(ue-1,0);v(de(J,O))}else if(x.key==="ArrowRight"){let O=Math.min(J+1,V.length-1),ee=Math.min(ue,j(O)-1);v(de(O,ee))}else if(x.key==="ArrowLeft"){let O=Math.max(J-1,0),ee=Math.min(ue,j(O)-1);v(de(O,ee))}return}let E=R===null?void 0:Q[R];if(E!==void 0){if(x.key==="Tab"){x.preventDefault(),y(E);return}if(x.key==="Enter"&&!x.shiftKey){x.preventDefault(),l(E,m);return}}if(x.key==="Enter"&&!x.shiftKey){x.preventDefault(),C();return}if(x.key==="Escape")if(Q.length>0&&!w)N(!0);else if(h)M();else a()},[Q,R,ue,J,V,de,y,l,m,C,w,h,M,a]);return _(on,{anchorEl:t,scrollContainer:e,onClose:h?M:a,ignoreSelector:h?"[data-annotation-id]":void 0,zIndex:h?"60":"50",padding:h?"10px 12px":"12px",width:"420px",children:[!h&&(r??_("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontStyle:"italic",marginBottom:"8px",lineHeight:"1.4",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:["“",z,"”"]},void 0,!0,void 0,this)),_(We,{note:d,onNoteChange:f,images:m,onAddImage:(x)=>b((E)=>[...E,x]),onRemoveImage:(x)=>b((E)=>E.filter((O)=>O!==x)),sessionId:u,autoFocus:!0,autoResize:h,textareaRef:U,onKeyDown:me,attachButton:"none",openFilePickerRef:Y,textareaStyle:h?{width:"100%",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",resize:"none",outline:"none",overflow:"hidden"}:{width:"100%",minHeight:"60px",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",resize:"vertical",outline:"none"},placeholder:"Add your note..."},void 0,!1,void 0,this),_("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:h?"6px":"8px"},children:[g&&_(Ve,{onClick:()=>Y.current?.(),size:14},void 0,!1,void 0,this),_("div",{style:{flex:1}},void 0,!1,void 0,this),h?_("button",{onClick:()=>{if(c)c();a()},onMouseEnter:()=>F(!0),onMouseLeave:()=>F(!1),style:{fontSize:"11px",color:L?"var(--color-accent-red)":"var(--color-text-tertiary)",background:"none",border:"none",cursor:"pointer",padding:"2px 0",fontFamily:"'Inter', sans-serif"},children:"Delete"},void 0,!1,void 0,this):_(jr,{children:[_("button",{onClick:a,style:{fontSize:"11px",color:"var(--color-text-tertiary)",background:"none",border:"none",cursor:"pointer",padding:"4px 12px",fontFamily:"'Inter', sans-serif"},children:"Cancel"},void 0,!1,void 0,this),_("button",{onClick:C,style:{fontSize:"11px",fontWeight:500,padding:"4px 12px",borderRadius:"6px",background:"var(--color-highlight-bg)",color:"var(--color-text-primary)",border:"1px solid var(--color-highlight-border)",cursor:"pointer",fontFamily:"'Inter', sans-serif"},children:"Add"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Q.length>0&&_("div",{style:{marginTop:"6px",borderTop:"1px solid var(--color-border-subtle)",paddingTop:"8px",display:"flex",gap:"4px"},children:ce.map((x)=>_("div",{style:{flex:1},children:[_("div",{style:{fontSize:"10px",fontWeight:600,color:"var(--color-text-disabled)",textTransform:"uppercase",letterSpacing:"0.05em",padding:"2px 6px",marginBottom:"2px",fontFamily:"'Inter', sans-serif"},children:x.label},void 0,!1,void 0,this),x.items.map((E)=>{let O=Q.indexOf(E);return _("div",{onMouseDown:(ee)=>{ee.preventDefault(),ee.stopPropagation(),y(E)},onMouseEnter:()=>v(O),style:{padding:"3px 6px",fontSize:"12px",borderRadius:"4px",fontFamily:"'Inter', sans-serif",color:O===R?"var(--color-text-primary)":"var(--color-text-secondary)",background:O===R?"var(--color-highlight-selected)":"transparent",cursor:"pointer"},children:[_("span",{style:{fontWeight:500},children:E.slice(0,d.trim().length)},void 0,!1,void 0,this),E.slice(d.trim().length)]},E,!0,void 0,this)})]},x.label,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Ce({anchorEl:t,scrollContainer:e,snippet:n,truncateAt:o,header:r,onAdd:s,onCancel:i}){return _(an,{anchorEl:t,scrollContainer:e,snippet:n,truncateAt:o,header:r,onConfirm:(l,a)=>s(l,a),onCancel:i},void 0,!1,void 0,this)}import{useEffect as zi,useRef as Di,useState as Bi}from"react";import{useCallback as Zi,useEffect as Yi,useRef as Xi,useState as Qi}from"react";import{jsxDEV as ln}from"react/jsx-dev-runtime";function ke({note:t,onChange:e}){return ln("div",{className:"mt-1.5",children:ln("textarea",{value:t,onChange:(n)=>e(n.currentTarget.value),className:"w-full bg-transparent text-[12px] font-body text-text-primary resize-none focus:outline-none border-none placeholder:text-text-disabled transition-colors min-h-[20px] p-0 leading-relaxed",placeholder:"Add a note...",rows:1,onInput:(n)=>oe(n.currentTarget),ref:(n)=>{if(n)oe(n)}},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as I}from"react/jsx-dev-runtime";function gn(t){return t.map((e)=>typeof e==="string"?{value:e,label:e}:{value:e.value,label:e.label??e.value})}function ro({id:t,label:e,options:n,required:o}){let{responses:r,setResponse:s}=cn();un(t);let i=pn(()=>gn(n),[n]),l=r.get(t),a=l?.value,c=l?.note||"",[u,p]=hn(!1),g=fn(null);if(!r.has(t))s(t,{id:t,type:"radio",label:e,value:null,options:i.map((f)=>f.value),required:o});let h=(f)=>{s(t,{...l,value:f})};dn(()=>{let f=g.current;if(!f)return;let m=(b)=>{let v=b.target.closest("[data-md-label]")?.getAttribute("data-md-label"),w=i.find((N)=>N.label===v);if(w)h(w.value)};return f.addEventListener("kb-select",m),()=>f.removeEventListener("kb-select",m)},[i,h]);let d=l?.required&&!a;return I("div",{ref:g,"data-md":"choice","data-md-label":e,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[I("div",{className:"flex items-baseline gap-2 mb-2",children:[I("span",{className:"text-[13px] font-body font-medium text-text-primary",children:e},void 0,!1,void 0,this),o&&I("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),I("div",{className:"space-y-1",children:i.map(({value:f,label:m})=>I("label",{"data-md":"choice-option","data-md-label":m,onClick:()=>h(f),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${a===f?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[I("span",{className:`w-4 h-4 rounded-full border-[1.5px] flex items-center justify-center flex-shrink-0 transition-all ${a===f?"border-accent-amber bg-accent-amber":"border-border-strong"}`,children:a===f&&I("span",{className:"w-1.5 h-1.5 rounded-full bg-text-inverse"},void 0,!1,void 0,this)},void 0,!1,void 0,this),I("span",{className:"text-[13px] font-body text-text-secondary",children:m},void 0,!1,void 0,this)]},f,!0,void 0,this))},void 0,!1,void 0,this),I(ke,{show:u,note:c,onToggle:()=>p(!u),onChange:(f)=>s(t,{...l,note:f})},void 0,!1,void 0,this),d&&I("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"Please select an option."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function oo({id:t,label:e,options:n,required:o}){let{responses:r,setResponse:s}=cn();un(t);let i=pn(()=>gn(n),[n]),l=r.get(t),a=l?.value||[],c=l?.note||"",[u,p]=hn(!1),g=fn(null);if(!r.has(t))s(t,{id:t,type:"checkbox",label:e,value:[],options:i.map((f)=>f.value),required:o});let h=(f)=>{let m=a.includes(f)?a.filter((b)=>b!==f):[...a,f];s(t,{...l,value:m})};dn(()=>{let f=g.current;if(!f)return;let m=(b)=>{let v=b.target.closest("[data-md-label]")?.getAttribute("data-md-label"),w=i.find((N)=>N.label===v);if(w)h(w.value)};return f.addEventListener("kb-select",m),()=>f.removeEventListener("kb-select",m)},[i,h]);let d=l?.required&&a.length===0;return I("div",{ref:g,"data-md":"multichoice","data-md-label":e,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[I("div",{className:"flex items-baseline gap-2 mb-2",children:[I("span",{className:"text-[13px] font-body font-medium text-text-primary",children:e},void 0,!1,void 0,this),o&&I("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),I("div",{className:"space-y-1",children:i.map(({value:f,label:m})=>{let b=a.includes(f);return I("label",{"data-md":"multichoice-option","data-md-label":m,onClick:()=>h(f),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${b?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[I("span",{className:`w-4 h-4 rounded flex items-center justify-center flex-shrink-0 transition-all ${b?"bg-accent-amber":"border-[1.5px] border-border-strong"}`,children:b&&I("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:I("path",{d:"M2.5 5L4.5 7L7.5 3",style:{stroke:"var(--color-text-inverse)"},strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),I("span",{className:"text-[13px] font-body text-text-secondary",children:m},void 0,!1,void 0,this)]},f,!0,void 0,this)})},void 0,!1,void 0,this),I(ke,{show:u,note:c,onToggle:()=>p(!u),onChange:(f)=>s(t,{...l,note:f})},void 0,!1,void 0,this),d&&I("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"Please select at least one option."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as so,useRef as io}from"react";import{jsxDEV as Ze}from"react/jsx-dev-runtime";function ao({language:t,children:e}){let n=typeof e==="string"?e:String(e??""),o=io(null);return so(()=>{let r=o.current,s=window.hljs;if(!r||!s)return;r.removeAttribute("data-highlighted"),r.className=t?`language-${t}`:"",r.textContent=n,s.highlightElement(r)},[n,t]),Ze("div",{className:"relative mt-3 group/code","data-md":"codeblock","data-md-language":t||"",children:[t&&Ze("span",{className:"absolute top-2 right-3 text-tiny text-text-tertiary opacity-0 group-hover/code:opacity-60 transition-opacity duration-150 z-10 font-mono",children:t},void 0,!1,void 0,this),Ze("pre",{className:"bg-bg-code rounded-md p-4 overflow-x-auto text-code font-mono leading-relaxed",children:Ze("code",{ref:o,className:t?`language-${t}`:"",children:n},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function mn(t,e){let n=t.split(`
60
+ `),o=e.split(`
61
+ `),r=lo(n,o),s=[],i=0,l=0,a=0;while(i<n.length||l<o.length){let c=n[i],u=o[l];if(a<r.length&&c!==void 0&&u!==void 0&&c===r[a]&&u===r[a])s.push({type:"same",line:c}),i++,l++,a++;else if(c!==void 0&&(a>=r.length||c!==r[a]))s.push({type:"removed",line:c}),i++;else if(u!==void 0)s.push({type:"added",line:u}),l++}return s}function lo(t,e){let n=t.length,o=e.length,r=Array.from({length:n+1},()=>Array(o+1).fill(0));for(let a=1;a<=n;a++){let c=r[a]??[],u=r[a-1]??[];for(let p=1;p<=o;p++)c[p]=t[a-1]===e[p-1]?(u[p-1]??0)+1:Math.max(u[p]??0,c[p-1]??0)}let s=[],i=n,l=o;while(i>0&&l>0){let a=t[i-1];if(a!==void 0&&a===e[l-1])s.unshift(a),i--,l--;else if((r[i-1]?.[l]??0)>(r[i]?.[l-1]??0))i--;else l--}return s}import{jsxDEV as Ie}from"react/jsx-dev-runtime";function co({before:t,after:e,language:n}){let o=mn(t,e);return Ie("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden group/diff","data-md":"diff","data-md-language":n||"",children:[n&&Ie("div",{className:"px-4 py-2 text-meta font-mono text-text-tertiary opacity-0 group-hover/diff:opacity-60 transition-opacity",children:["diff (",n,")"]},void 0,!0,void 0,this),Ie("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono",children:o.map((r,s)=>Ie("div",{className:r.type==="removed"?"bg-accent-red-muted text-accent-red":r.type==="added"?"bg-accent-green-muted text-accent-green":"text-text-tertiary",children:[Ie("span",{className:"select-none w-6 inline-block text-center opacity-60",children:r.type==="removed"?"-":r.type==="added"?"+":" "},void 0,!1,void 0,this),r.line]},s,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{ActiveViewCtx as uo,SessionContext as po}from"#canvas/runtime";import{useContext as xn,useEffect as bn,useRef as fo,useState as Ye}from"react";import{jsxDEV as ae}from"react/jsx-dev-runtime";var ho={ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",py:"python",rs:"rust",go:"go",rb:"ruby",java:"java",json:"json",yaml:"yaml",yml:"yaml",md:"markdown",css:"css",html:"html",sh:"bash",bash:"bash",toml:"toml",sql:"sql",xml:"xml",c:"c",cpp:"cpp",h:"c"};function go({path:t,lines:e,__content:n}){let o=xn(po),{setActiveView:r}=xn(uo),[s,i]=Ye(n??null),[l,a]=Ye(()=>{let d=t.split(".").pop()||"";return ho[d]||"text"}),[c,u]=Ye(null),[p,g]=Ye(!n),h=fo(null);if(bn(()=>{if(n!==void 0)return;g(!0),u(null),fetch(`/api/file?session=${o}&path=${encodeURIComponent(t)}`).then((d)=>d.json()).then((d)=>{if(d.error)u(d.error);else{let f=d.content;if(e)f=f.split(`
62
+ `).slice(e[0]-1,e[1]).join(`
63
+ `);i(f),a(d.language||"text")}}).catch(()=>u("Failed to fetch file")).finally(()=>g(!1))},[o,t,e?.[0],e?.[1],n]),bn(()=>{let d=h.current,f=window.hljs;if(!d||!f||!s)return;d.removeAttribute("data-highlighted"),d.className=l?`language-${l}`:"",d.textContent=s,f.highlightElement(d)},[s,l]),p)return ae("div",{className:"text-text-tertiary text-body mt-3 bg-bg-code rounded-md p-4",children:["Loading ",t,"..."]},void 0,!0,void 0,this);if(c)return ae("div",{className:"text-accent-red text-body mt-3 bg-accent-red-muted rounded-md p-4",children:[t,": ",c]},void 0,!0,void 0,this);return ae("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden","data-md":"filepreview","data-md-path":t,...e?{"data-md-lines":`${e[0]}-${e[1]}`}:{},children:[ae("div",{className:"px-4 py-2 flex items-center justify-between",children:[ae("button",{className:"font-mono text-meta text-text-tertiary hover:text-text-secondary hover:underline cursor-pointer text-left",onClick:()=>r({type:"file",path:t}),title:`Open ${t}`,children:t},void 0,!1,void 0,this),e&&ae("span",{className:"font-mono text-meta text-text-tertiary opacity-60",children:["L",e[0],"–",e[1]]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),ae("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono !bg-transparent",style:{background:"transparent"},children:ae("code",{ref:h,className:l?`language-${l}`:"",children:s},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{SessionContext as mo}from"#canvas/runtime";import{useContext as xo,useState as bo}from"react";import{jsxDEV as Le}from"react/jsx-dev-runtime";function yo({src:t,alt:e,caption:n,width:o,height:r}){let s=xo(mo),[i,l]=bo(!1),a=`/api/image?session=${encodeURIComponent(s)}&path=${encodeURIComponent(t)}`;if(i)return Le("div",{className:"mt-3 text-accent-red text-body bg-accent-red-muted rounded-md p-4",children:[t,": Failed to load image"]},void 0,!0,void 0,this);return Le("figure",{className:"mt-3 relative","data-md":"image","data-md-src":t,children:[Le("div",{"data-annotation-image":!0,className:"rounded-md overflow-hidden border border-border-subtle bg-bg-code inline-block",children:Le("img",{src:a,alt:e||t,onError:()=>l(!0),draggable:!1,className:"block max-w-full h-auto",...o?{width:o}:{},...r?{height:r}:{}},void 0,!1,void 0,this)},void 0,!1,void 0,this),n&&Le("figcaption",{className:"mt-1.5 text-meta text-text-tertiary font-body",children:n},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useMemo as ko}from"react";import{jsxDEV as yn}from"react/jsx-dev-runtime";S.setOptions({gfm:!0,breaks:!1});function vo({children:t,file:e,__content:n}){let o=n??(typeof t==="string"?t:String(t??"")),r=ko(()=>{if(!o)return"";return S.parse(o,{async:!1})},[o]);if(!o)return yn("div",{className:"text-text-tertiary text-tiny mt-3",children:e?`Could not load: ${e}`:"No markdown content"},void 0,!1,void 0,this);return yn("div",{className:"mt-3 prose-canvas","data-md":"markdown",...e?{"data-md-file":e}:{},"data-md-source":o,dangerouslySetInnerHTML:{__html:r}},void 0,!1,void 0,this)}import{useAnnotations as wo,useCanvasFile as So}from"#canvas/runtime";import{useCallback as ne,useEffect as Et,useRef as Pe,useState as ve}from"react";import Ao from"react-dom";import{jsxDEV as k,Fragment as Sn}from"react/jsx-dev-runtime";var we=0.2,Xe=0.25,Qe=4;function vn({zoom:t,onZoomIn:e,onZoomOut:n,onZoomReset:o,onFullscreen:r}){return k("div",{className:"flex items-center gap-0.5 bg-bg-surface border border-border-subtle rounded-md px-1 py-0.5",style:{fontSize:"12px"},children:[k("button",{className:"flex items-center justify-center w-7 h-7 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:n,title:"Zoom out",disabled:t<=Xe,children:k("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:k("line",{x1:"5",y1:"12",x2:"19",y2:"12"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),k("button",{className:"px-1.5 h-7 rounded hover:bg-bg-elevated text-text-tertiary hover:text-text-primary transition-colors tabular-nums",onClick:o,title:"Reset zoom",children:[Math.round(t*100),"%"]},void 0,!0,void 0,this),k("button",{className:"flex items-center justify-center w-7 h-7 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:e,title:"Zoom in",disabled:t>=Qe,children:k("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[k("line",{x1:"12",y1:"5",x2:"12",y2:"19"},void 0,!1,void 0,this),k("line",{x1:"5",y1:"12",x2:"19",y2:"12"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),r&&k(Sn,{children:[k("div",{className:"w-px h-4 bg-border-subtle mx-0.5"},void 0,!1,void 0,this),k("button",{className:"flex items-center justify-center w-7 h-7 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:r,title:"Fullscreen",children:k("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[k("polyline",{points:"15 3 21 3 21 9"},void 0,!1,void 0,this),k("polyline",{points:"9 21 3 21 3 15"},void 0,!1,void 0,this),k("line",{x1:"21",y1:"3",x2:"14",y2:"10"},void 0,!1,void 0,this),k("line",{x1:"3",y1:"21",x2:"10",y2:"14"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function wn(t=1){let[e,n]=ve(t),o=ne(()=>n((i)=>Math.min(Qe,+(i+we).toFixed(2))),[]),r=ne(()=>n((i)=>Math.max(Xe,+(i-we).toFixed(2))),[]),s=ne(()=>n(1),[]);return{zoom:e,zoomIn:o,zoomOut:r,zoomReset:s,setZoom:n}}function Ro({svgHtml:t,source:e,onClose:n}){let o=Pe(null),{zoom:r,zoomIn:s,zoomOut:i,zoomReset:l,setZoom:a}=wn(1),[c,u]=ve({x:0,y:0}),p=Pe(null);Et(()=>{let b=(R)=>{if(R.key==="Escape")n()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[n]);let g=ne((b)=>{b.preventDefault();let R=b.deltaY>0?-we:we;a((v)=>Math.max(Xe,Math.min(Qe,+(v+R).toFixed(2))))},[a]),h=ne((b)=>{if(b.button!==0)return;p.current={startX:b.clientX,startY:b.clientY,panX:c.x,panY:c.y},b.preventDefault()},[c]),d=ne((b)=>{if(!p.current)return;u({x:p.current.panX+(b.clientX-p.current.startX),y:p.current.panY+(b.clientY-p.current.startY)})},[]),f=ne(()=>{p.current=null},[]),m=ne(()=>{l(),u({x:0,y:0})},[l]);return Ao.createPortal(k("div",{style:{position:"fixed",inset:0,zIndex:9999,background:"var(--color-bg-base)",display:"flex",flexDirection:"column"},onMouseMove:d,onMouseUp:f,onMouseLeave:f,children:[k("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border-subtle",style:{flexShrink:0,background:"var(--color-bg-surface)"},children:[k("span",{className:"text-body text-text-secondary",style:{fontSize:"13px"},children:"Mermaid Diagram"},void 0,!1,void 0,this),k("div",{className:"flex items-center gap-2",children:[k(vn,{zoom:r,onZoomIn:s,onZoomOut:i,onZoomReset:m},void 0,!1,void 0,this),k("button",{className:"flex items-center justify-center w-8 h-8 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:n,title:"Close (Esc)",children:k("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[k("line",{x1:"18",y1:"6",x2:"6",y2:"18"},void 0,!1,void 0,this),k("line",{x1:"6",y1:"6",x2:"18",y2:"18"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),k("div",{style:{flex:1,overflow:"hidden",cursor:p.current?"grabbing":"grab"},onWheel:g,onMouseDown:h,children:k("div",{ref:o,style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",transform:`translate(${c.x}px, ${c.y}px) scale(${r})`,transformOrigin:"center center",transition:p.current?"none":"transform 0.1s ease-out"},dangerouslySetInnerHTML:{__html:t}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),document.body)}function To({children:t}){let e=Pe(null),[n,o]=ve(null),[r,s]=ve(!1),[i,l]=ve(""),a=typeof t==="string"?t:String(t??""),{annotations:c,addAnnotationWithId:u,activeAnnotationId:p,setActiveAnnotationId:g}=wo(),h=So(),[d,f]=ve(null),{zoom:m,zoomIn:b,zoomOut:R,zoomReset:v,setZoom:w}=wn(1),N=Pe(c);N.current=c;let L=ne((C,M,G)=>{let H=`[Diagram ${G.toLowerCase()}] ${M}`,X=N.current.find((W)=>W.snippet===H);if(X)g(X.id);else f({anchorEl:C,snippet:M,prefix:G})},[g]),F=Pe(L);F.current=L,Et(()=>{let C=!1,M=async()=>{try{let H=window.mermaid;if(!H){o("Mermaid library not loaded");return}let X=document.documentElement.dataset.theme==="light"?"default":"dark";H.initialize({startOnLoad:!1,theme:X});let W=`mermaid-${Math.random().toString(36).slice(2)}`,{svg:ce}=await H.render(W,a.trim());if(!C&&e.current)e.current.innerHTML=ce,l(ce),Eo(e.current,(V,j,Q)=>F.current(V,j,Q)),kn(e.current,N.current);o(null)}catch(H){if(!C)o(H.message||"Invalid diagram")}};M();let G=new MutationObserver((H)=>{for(let X of H)if(X.attributeName==="data-theme")M()});return G.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{C=!0,G.disconnect()}},[a]),Et(()=>{if(e.current)kn(e.current,c,p)},[c,p]);let U=ne((C)=>{if(!C.ctrlKey&&!C.metaKey)return;C.preventDefault();let M=C.deltaY>0?-we:we;w((G)=>Math.max(Xe,Math.min(Qe,+(G+M).toFixed(2))))},[w]);if(n)return k("div",{className:"bg-accent-red-muted rounded-md p-4 mt-3 text-body text-accent-red",children:["Mermaid error: ",n,k("pre",{className:"mt-2 text-tiny text-text-tertiary whitespace-pre-wrap",children:a},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let Y=e.current?.closest("#plan-scroll-container");return k(Sn,{children:[k("div",{className:"mt-3 mermaid-container","data-md":"mermaid","data-md-source":a.trim(),children:[k("div",{className:"flex justify-end mb-1",children:k(vn,{zoom:m,onZoomIn:b,onZoomOut:R,onZoomReset:v,onFullscreen:()=>s(!0)},void 0,!1,void 0,this)},void 0,!1,void 0,this),k("div",{style:{overflow:"auto",maxHeight:"70vh"},onWheel:U,children:k("div",{ref:e,className:"flex justify-center",style:{transform:`scale(${m})`,transformOrigin:"top center",transition:"transform 0.1s ease-out",minHeight:m<1?void 0:void 0}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),d&&k(Ce,{anchorEl:d.anchorEl,scrollContainer:Y,snippet:d.snippet,header:k("div",{style:{fontSize:"12px",color:"var(--color-text-tertiary)",marginBottom:"8px",lineHeight:"1.4",display:"flex",alignItems:"center",gap:"6px"},children:[k("span",{style:{width:"8px",height:"8px",borderRadius:"50%",background:"var(--color-accent-amber)",flexShrink:0}},void 0,!1,void 0,this),d.snippet]},void 0,!0,void 0,this),onAdd:(C,M)=>{let G=`ann-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;u(G,`[Diagram ${d.prefix.toLowerCase()}] ${d.snippet}`,C,void 0,void 0,M,h||void 0),f(null)},onCancel:()=>f(null)},void 0,!1,void 0,this),r&&i&&k(Ro,{svgHtml:i,source:a,onClose:()=>s(!1)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Eo(t,e){let n=(o,r,s)=>{o.style.cursor="pointer",o.addEventListener("mouseenter",()=>{o.style.filter="brightness(1.2)"}),o.addEventListener("mouseleave",()=>{o.style.filter=""}),o.addEventListener("click",(i)=>{i.stopPropagation(),i.preventDefault(),e(o,r(),s)})};for(let o of t.querySelectorAll(".node"))n(o,()=>(o.querySelector(".nodeLabel")||o.querySelector("foreignObject span")||o.querySelector("text"))?.textContent?.trim()||"Node","Node");for(let o of t.querySelectorAll(".edgePath")){let r=o,s=r.querySelector("path");if(s){s.style.strokeWidth=Math.max(parseFloat(s.style.strokeWidth||"1"),8)+"px",s.style.strokeOpacity="0";let l=s.cloneNode(!0);l.style.strokeWidth="",l.style.strokeOpacity="",r.insertBefore(l,s)}let i=r.id||"";n(r,()=>{let l=t.querySelectorAll(".edgeLabel");for(let a of l)if(a.id&&i&&a.id.replace("label","").includes(i.replace("L-","").replace("edge",""))){let c=a.textContent?.trim();if(c)return c}return"Connection"},"Edge")}for(let o of t.querySelectorAll(".edgeLabel")){let r=o.textContent?.trim();if(!r)continue;n(o,()=>r,"Edge")}for(let o of t.querySelectorAll(".actor")){let r=o.closest("g")?.querySelector("text")||o.parentElement?.querySelector("text");if(!r)continue;let s=o.closest("g");if(!s||s.hasAttribute("data-clickable"))continue;s.setAttribute("data-clickable","true"),n(s,()=>r.textContent?.trim()||"Participant","Node")}for(let o of t.querySelectorAll(".messageText")){let r=o.textContent?.trim();if(!r)continue;n(o,()=>r,"Edge")}for(let o of t.querySelectorAll(".entityBox")){let r=o.closest("g");if(!r||r.hasAttribute("data-clickable"))continue;let s=r.querySelector(".entityLabel");if(!s)continue;r.setAttribute("data-clickable","true"),n(r,()=>s.textContent?.trim()||"Entity","Node")}for(let o of t.querySelectorAll(".relationshipLabel")){let r=o.textContent?.trim();if(!r)continue;let i=o.closest("g")||o;if(i.hasAttribute("data-clickable"))continue;i.setAttribute("data-clickable","true"),n(i,()=>r,"Edge")}for(let o of t.querySelectorAll(".classGroup")){let r=o;if(r.hasAttribute("data-clickable"))continue;let s=r.querySelector(".classTitle, .classTitleText, text");if(!s)continue;r.setAttribute("data-clickable","true"),n(r,()=>s.textContent?.trim()||"Class","Node")}for(let o of t.querySelectorAll(".statediagram-state")){let r=o;if(r.hasAttribute("data-clickable"))continue;let s=r.querySelector(".state-title, text");if(!s)continue;r.setAttribute("data-clickable","true"),n(r,()=>s.textContent?.trim()||"State","Node")}for(let o of t.querySelectorAll(".mindmap-node")){let r=o;if(r.hasAttribute("data-clickable"))continue;let s=r.querySelector(".mindmap-node-label, text");if(!s)continue;r.setAttribute("data-clickable","true"),n(r,()=>s.textContent?.trim()||"Node","Node")}}function kn(t,e,n){let o=new Map;for(let s of e){let i=s.snippet.match(/^\[Diagram (?:node|edge)\] (.+)$/)?.[1];if(i)o.set(i,s.id)}for(let s of t.querySelectorAll("[data-annotated]"))s.style.outline="",s.style.outlineOffset="",s.style.borderRadius="",s.removeAttribute("data-annotated");if(o.size===0)return;for(let s of t.querySelectorAll(".node")){let l=(s.querySelector(".nodeLabel")||s.querySelector("foreignObject span")||s.querySelector("text"))?.textContent?.trim();if(!l||!o.has(l))continue;let a=o.get(l),c=s;c.setAttribute("data-annotated",a);let u=a===n;c.style.outline=u?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",c.style.outlineOffset="2px",c.style.borderRadius="4px"}for(let s of t.querySelectorAll(".edgeLabel")){let i=s.textContent?.trim();if(!i||!o.has(i))continue;let l=o.get(i),a=s;a.setAttribute("data-annotated",l);let c=l===n;a.style.outline=c?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",a.style.outlineOffset="2px",a.style.borderRadius="4px"}for(let s of t.querySelectorAll(".actor")){let i=s.closest("g");if(!i)continue;let a=i.querySelector("text")?.textContent?.trim();if(!a||!o.has(a))continue;if(i.hasAttribute("data-annotated"))continue;let c=o.get(a);i.setAttribute("data-annotated",c);let u=c===n,p=i.querySelector("rect");if(p)p.style.outline=u?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",p.style.outlineOffset="2px",p.style.borderRadius="4px"}for(let s of t.querySelectorAll(".messageText")){let i=s.textContent?.trim();if(!i||!o.has(i))continue;let l=o.get(i),a=s;a.setAttribute("data-annotated",l);let c=l===n;a.style.outline=c?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",a.style.outlineOffset="2px",a.style.borderRadius="4px"}let r=(s,i,l)=>{for(let a of t.querySelectorAll(s)){let c=l(a);if(!c||c.hasAttribute("data-annotated"))continue;let p=c.querySelector(i)?.textContent?.trim();if(!p||!o.has(p))continue;let g=o.get(p);c.setAttribute("data-annotated",g);let h=g===n,d=c.querySelector("rect, circle, ellipse, polygon")||c;d.style.outline=h?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",d.style.outlineOffset="2px",d.style.borderRadius="4px"}};r(".entityBox",".entityLabel",(s)=>s.closest("g"));for(let s of t.querySelectorAll(".relationshipLabel")){let l=s.closest("g")||s;if(l.hasAttribute("data-annotated"))continue;let a=s.textContent?.trim();if(!a||!o.has(a))continue;let c=o.get(a);l.setAttribute("data-annotated",c);let u=c===n;l.style.outline=u?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",l.style.outlineOffset="2px",l.style.borderRadius="4px"}r(".classGroup",".classTitle, .classTitleText, text",(s)=>s),r(".statediagram-state",".state-title, text",(s)=>s),r(".mindmap-node",".mindmap-node-label, text",(s)=>s)}import{jsxDEV as Co}from"react/jsx-dev-runtime";function No({children:t}){return Co("div",{className:"relative bg-bg-elevated rounded-lg px-5 py-4 mt-3 text-body text-text-secondary italic leading-relaxed","data-md":"note",children:ie(t)},void 0,!1,void 0,this)}import{jsxDEV as Po}from"react/jsx-dev-runtime";var Io={high:"text-accent-red bg-accent-red-muted",medium:"text-accent-amber bg-accent-amber-muted",low:"text-text-tertiary bg-border-subtle"};function Lo({level:t}){return Po("span",{className:`inline text-tiny font-medium font-body ml-2 px-1.5 py-0.5 rounded ${Io[t]}`,"data-md":"priority","data-md-level":t,children:t},void 0,!1,void 0,this)}import{useState as Mo}from"react";import{jsxDEV as ge}from"react/jsx-dev-runtime";function $o({title:t,children:e}){let[n,o]=Mo(!1);return ge("div",{className:"relative mb-8 p-4 group/section","data-md":"section","data-md-title":t,children:[ge("div",{className:"relative mb-2",children:[ge("button",{onClick:()=>o(!n),className:`absolute -left-8 top-1/2 -translate-y-1/2 text-text-tertiary opacity-0 group-hover/section:opacity-50 hover:!opacity-100 transition-all duration-150 p-0.5 ${n?"-rotate-90":""}`,children:ge("svg",{width:"14",height:"14",viewBox:"0 0 12 12",fill:"none",children:ge("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),ge("h2",{className:"font-heading text-section text-text-primary",style:{fontWeight:400},children:t},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ge("div",{className:n?"mt-6 hidden":"mt-6",children:ie(e)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as le}from"react/jsx-dev-runtime";function Oo({headers:t,rows:e}){return le("div",{className:"overflow-x-auto mt-3","data-md":"table",children:le("table",{className:"w-full text-body",children:[le("thead",{children:le("tr",{className:"border-b border-border-subtle",children:t.map((n,o)=>le("th",{className:"text-left px-4 py-2.5 text-meta font-medium uppercase tracking-wider text-text-tertiary font-body",children:n},o,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),le("tbody",{children:e.map((n,o)=>le("tr",{className:`relative border-b border-border-subtle last:border-b-0 transition-colors hover:bg-bg-surface/50 ${o%2===1?"bg-bg-surface/30":""}`,children:n.map((r,s)=>le("td",{className:"px-4 py-2.5 text-text-secondary font-body",children:r},s,!1,void 0,this))},o,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as re}from"react/jsx-dev-runtime";var _o={todo:"bg-border-hover",done:"bg-accent-green",blocked:"bg-accent-red","in-progress":"bg-accent-blue"},Ho={todo:"Todo",done:"Done",blocked:"Blocked","in-progress":"In progress"},zo={info:"bg-accent-blue-muted text-accent-blue",success:"bg-accent-green-muted text-accent-green",warning:"bg-accent-amber-muted text-accent-amber",danger:"bg-accent-red-muted text-accent-red",neutral:"bg-border-subtle text-text-tertiary"};function An({id:t,label:e,status:n,badge:o,badgeVariant:r="neutral",children:s}){return re("div",{className:"group/task relative -mx-4 px-4 py-3 rounded-md transition-colors duration-150 hover:bg-bg-input","data-task-id":t,"data-md":"item","data-md-label":e,...n?{"data-md-status":n}:{},...o?{"data-md-badge":o}:{},children:re("div",{className:"flex items-start gap-3",children:[n&&re("span",{className:`w-2 h-2 rounded-full mt-[7px] flex-shrink-0 ${_o[n]}`},void 0,!1,void 0,this),re("div",{className:"flex-1 min-w-0",children:[re("div",{className:"flex items-baseline gap-2",children:[re("span",{className:"font-body text-task-label font-semibold text-text-primary",children:e},void 0,!1,void 0,this),n&&re("span",{className:"font-body text-tiny uppercase tracking-wider text-text-tertiary opacity-0 group-hover/task:opacity-100 transition-opacity duration-150",children:Ho[n]},void 0,!1,void 0,this),o&&re("span",{className:`font-body text-tiny font-medium px-1.5 py-px rounded-full ${zo[r]}`,children:o},void 0,!1,void 0,this)]},void 0,!0,void 0,this),s&&re("div",{className:"text-body text-text-secondary mt-1 leading-relaxed",children:ie(s)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function Do(t){return re(An,{...t},void 0,!1,void 0,this)}import{useAnnotations as Rn,useResponseRegistration as Tn}from"#canvas/runtime";import{useRef as Bo,useState as En}from"react";import{jsxDEV as T}from"react/jsx-dev-runtime";function qo({id:t,label:e,placeholder:n,multiline:o,required:r}){let{responses:s,setResponse:i}=Rn();Tn(t);let l=s.get(t),a=l?.value??"",c=l?.note||"",[u,p]=En(!1),g=Bo(null);if(!s.has(t))i(t,{id:t,type:"text",label:e,value:"",required:r});let h=(m)=>{i(t,{...l,value:m})},d=(m)=>oe(m,o?60:32),f=l?.required&&!a.trim();return T("div",{"data-md":"userinput","data-md-label":e,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[T("div",{className:"flex items-baseline gap-2 mb-2",children:[T("span",{className:"text-[13px] font-body font-medium text-text-primary",children:e},void 0,!1,void 0,this),r&&T("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),T("textarea",{ref:g,value:a,onChange:(m)=>{h(m.currentTarget.value),d(m.currentTarget)},placeholder:n||"Type your response...",rows:o?3:1,className:"w-full bg-bg-input text-[13px] font-body text-text-primary rounded-lg px-3 py-2 resize-none focus:outline-none border border-border-subtle focus:border-border-hover placeholder:text-text-tertiary transition-colors",onInput:(m)=>d(m.currentTarget),onFocus:(m)=>d(m.currentTarget)},void 0,!1,void 0,this),T(ke,{show:u,note:c,onToggle:()=>p(!u),onChange:(m)=>i(t,{...l,note:m})},void 0,!1,void 0,this),f&&T("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"This field is required."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Fo({id:t,label:e,min:n=1,max:o=10,step:r=1,required:s,minLabel:i,maxLabel:l}){let{responses:a,setResponse:c}=Rn();Tn(t);let u=a.get(t),p=u?.value,g=u?.note||"",[h,d]=En(!1);if(!a.has(t))c(t,{id:t,type:"range",label:e,value:null,required:s});let f=(L)=>{c(t,{...u,value:L})},m=p!==null&&p!==void 0,b=m?p:Math.round((n+o)/2),R=(b-n)/(o-n)*100,v=Math.round((o-n)/r),w=v<=20,N=u?.required&&!m;return T("div",{"data-md":"rangeinput","data-md-label":e,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[T("div",{className:"flex items-baseline justify-between mb-1",children:[T("div",{className:"flex items-baseline gap-2",children:[T("span",{className:"text-[13px] font-body font-medium text-text-primary",children:e},void 0,!1,void 0,this),s&&T("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),T("span",{className:"flex items-center gap-1.5",children:[T("span",{className:`text-[13px] font-mono ${m?"text-accent-amber":"text-text-disabled"}`,children:m?p:"—"},void 0,!1,void 0,this),m&&T("button",{onClick:()=>c(t,{...u,value:null}),className:"text-text-disabled hover:text-text-tertiary transition-colors text-[10px] leading-none",title:"Clear",children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),T("div",{className:"relative h-6 flex items-center",children:[T("div",{className:"absolute left-0 right-0 h-1.5 rounded-full bg-border-medium",children:m&&T("div",{className:"h-full rounded-full bg-accent-amber transition-all duration-150",style:{width:`${R}%`}},void 0,!1,void 0,this)},void 0,!1,void 0,this),w&&Array.from({length:v+1},(L,F)=>{let U=n+F*r,Y=(U-n)/(o-n)*100,C=m&&U<=p;return T("div",{className:`absolute rounded-full pointer-events-none transition-all duration-150 ${m&&U===p?"w-2.5 h-2.5 bg-accent-amber":C?"w-1.5 h-1.5 bg-accent-amber":"w-1.5 h-1.5 bg-border-hover"}`,style:{left:`${Y}%`,transform:"translate(-50%, -50%)",top:"50%"}},F,!1,void 0,this)}),m?T("div",{className:"absolute h-5 w-5 rounded-full bg-accent-amber shadow-md pointer-events-none transition-all duration-150",style:{left:`calc(${R}% - 10px)`,borderWidth:"2px",borderStyle:"solid",borderColor:"var(--color-bg-base)"}},void 0,!1,void 0,this):T("div",{className:"absolute h-4 w-4 rounded-full bg-border-hover pointer-events-none opacity-50",style:{left:"calc(50% - 8px)",borderWidth:"2px",borderStyle:"solid",borderColor:"var(--color-bg-base)"}},void 0,!1,void 0,this),T("input",{type:"range",min:n,max:o,step:r,value:b,onChange:(L)=>f(Number(L.currentTarget.value)),className:"absolute inset-0 w-full opacity-0 cursor-pointer"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w&&v<=10?T("div",{className:"flex justify-between -mt-0.5 px-0",children:Array.from({length:v+1},(L,F)=>{let U=n+F*r;return T("span",{className:`text-[10px] font-mono transition-colors ${m&&U===p?"text-accent-amber font-medium":"text-text-disabled"}`,style:{minWidth:"1ch",textAlign:"center"},children:U},F,!1,void 0,this)})},void 0,!1,void 0,this):T("div",{className:"flex justify-between -mt-0.5",children:[T("span",{className:"text-[11px] text-text-tertiary font-body",children:i||n},void 0,!1,void 0,this),T("span",{className:"text-[11px] text-text-tertiary font-body",children:l||o},void 0,!1,void 0,this)]},void 0,!0,void 0,this),T(ke,{show:h,note:g,onToggle:()=>d(!h),onChange:(L)=>c(t,{...u,note:L})},void 0,!1,void 0,this),N&&T("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"Please select a value."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as Qo,useState as Je}from"react";import{useFeedback as Jo}from"#canvas/runtime";async function Nn(t){let e=Go(t);return crypto.subtle.importKey("raw",e,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}async function Cn(t,e){let n=In(e);if(n.byteLength<28)throw Error("Ciphertext too short");let o=n.subarray(0,12),r=n.subarray(12),s=await crypto.subtle.decrypt({name:"AES-GCM",iv:o},t,r);return new TextDecoder().decode(s)}function In(t){let e=atob(t),n=new Uint8Array(e.length);for(let o=0;o<e.length;o++)n[o]=e.charCodeAt(o);return n}function Go(t){let e=t.replace(/-/g,"+").replace(/_/g,"/")+"===".slice((t.length+3)%4);return In(e)}function Uo(){if(typeof window>"u")return null;let t=window.location.hash.replace(/^#/,"");if(!t)return null;for(let e of t.split("&")){let[n,o]=e.split("=");if(n==="k"&&o)return decodeURIComponent(o)}return null}function Wo(){if(typeof window<"u"&&window.__CANVAS_SHARE__?.shareId){let e=Uo();return{isShared:!0,shareId:window.__CANVAS_SHARE__.shareId,encryptionKey:e?Nn(e):null}}return{isShared:!1,sessionId:typeof window<"u"?window.location.pathname.replace("/s/",""):""}}var P=Wo();function Vo(){return P.isShared&&P.encryptionKey!==null}function jo(){return P.isShared?P.shareId:P.sessionId}function Ko(t,e){let n=t.replace(/\.jsx$/,".js");if(P.isShared)return`/s/${P.shareId}/canvas/${encodeURIComponent(n)}`;let o=e?`?rev=${e}&t=${Date.now()}`:`?t=${Date.now()}`;return`/api/session/${P.sessionId}/canvas/${encodeURIComponent(n)}${o}`}function Zo(){if(P.isShared)return`/s/${P.shareId}/upload`;return`/api/session/${P.sessionId}/upload`}function Nt(t,e){if(P.isShared)throw Error("Secret inputs are available only on the local canvas daemon");return`/api/session/${encodeURIComponent(P.sessionId)}/secrets/${encodeURIComponent(t)}/${e}`}async function Ct(t){let e=await t.json().catch(()=>null);if(typeof e==="object"&&e!==null&&"error"in e&&typeof e.error==="string")return Error(e.error);return Error(`Secret API request failed with status ${t.status}`)}async function Ln(t){let e=await fetch(Nt(t,"status"),{cache:"no-store"});if(!e.ok)throw await Ct(e);let n=await e.json();return typeof n==="object"&&n!==null&&"ready"in n&&n.ready===!0}async function Pn(t,e){let n=await fetch(Nt(t,"value"),{method:"POST",headers:{"Content-Type":"application/json"},cache:"no-store",body:JSON.stringify({value:e})});if(!n.ok)throw await Ct(n)}async function Mn(t){let e=await fetch(Nt(t,"value"),{method:"DELETE",cache:"no-store"});if(!e.ok)throw await Ct(e)}async function Yo(t,e){let n=Ko(t,e);if(!Vo())return import(n);let o=await fetch(n);if(!o.ok)throw Error(`canvas ${o.status}`);let r=await o.text(),s=await P.encryptionKey,i=await Cn(s,r),l=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(l);try{return await import(a)}finally{setTimeout(()=>URL.revokeObjectURL(a),0)}}var Xo=!P.isShared,mc=!P.isShared,xc={get sessionId(){return jo()},isShared:P.isShared,fsAvailable:Xo,uploadUrl:Zo,loadCanvasModule:Yo};import{jsxDEV as q}from"react/jsx-dev-runtime";var es=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/,ts=/^[A-Za-z_][A-Za-z0-9_]*$/;function ns({id:t,label:e,env:n,placeholder:o,required:r}){let[s,i]=Je(""),[l,a]=Je(!1),[c,u]=Je(!P.isShared),[p,g]=Je(null),h=es.test(t),d=ts.test(n),f=!P.isShared;Qo(()=>{if(!f||!h){u(!1);return}let w=!0;return Ln(t).then((N)=>{if(w)a(N)}).catch((N)=>{if(w)g(N instanceof Error?N.message:"Could not read secret status")}).finally(()=>{if(w)u(!1)}),()=>{w=!1}},[t,f,h]);let m=l?`**${e}**
64
+ Secret is ready. Field: \`${t}\`. Environment variable: \`${n}\`.
65
+ `:"";Jo(`secret:${t}`,m,{label:e,required:r&&f});let b=async()=>{if(!s||!h||!d)return;u(!0),g(null);try{await Pn(t,s),i(""),a(!0)}catch(w){g(w instanceof Error?w.message:"Could not store secret")}finally{u(!1)}},R=async()=>{u(!0),g(null);try{await Mn(t),a(!1)}catch(w){g(w instanceof Error?w.message:"Could not clear secret")}finally{u(!1)}};if(!f)return q("div",{"data-md":"secretinput","data-md-label":e,className:"-mx-4 px-4 py-3 my-1 rounded-lg bg-accent-amber-muted",children:[q("div",{className:"text-[13px] font-body font-medium text-text-primary",children:e},void 0,!1,void 0,this),q("p",{className:"text-[12px] font-body text-text-secondary mt-1",children:"Secret input is unavailable in shared canvases. Open this runbook on the author's local canvas daemon."},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let v=!h?"Secret field IDs may contain letters, numbers, dots, underscores, and hyphens.":!d?"Environment variable names must use letters, numbers, and underscores and may not start with a number.":null;return q("div",{"data-md":"secretinput","data-md-label":e,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[q("div",{className:"flex items-baseline justify-between gap-3 mb-2",children:[q("div",{className:"flex items-baseline gap-2",children:[q("span",{className:"text-[13px] font-body font-medium text-text-primary",children:e},void 0,!1,void 0,this),r&&q("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q("span",{className:`text-[11px] font-body ${l?"text-accent-green":"text-text-tertiary"}`,children:c?"Working…":l?"Ready in memory":"Not stored"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q("div",{className:"flex gap-2",children:[q("input",{type:"password",value:s,onChange:(w)=>i(w.target.value),onKeyDown:(w)=>{if(w.key==="Enter")w.preventDefault(),b()},placeholder:o||"Paste secret value",autoComplete:"off",spellCheck:!1,disabled:c||!!v,className:"min-w-0 flex-1 bg-bg-input text-[13px] font-mono text-text-primary rounded-lg px-3 py-2 focus:outline-none border border-border-subtle focus:border-border-hover placeholder:text-text-tertiary disabled:opacity-50 transition-colors"},void 0,!1,void 0,this),q("button",{type:"button",onClick:()=>void b(),disabled:c||!s||!!v,className:"px-3 py-2 rounded-lg bg-btn-primary text-btn-primary-text text-[12px] font-body font-medium disabled:opacity-40 disabled:cursor-default",children:l?"Replace":"Store"},void 0,!1,void 0,this),l&&q("button",{type:"button",onClick:()=>void R(),disabled:c,className:"px-3 py-2 rounded-lg border border-border-subtle text-text-secondary text-[12px] font-body font-medium hover:border-border-hover disabled:opacity-40",children:"Clear"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q("p",{className:"text-[11px] font-body text-text-tertiary mt-1.5",children:["Stored only in daemon memory. The agent receives field ",t," for ",n,", not the value."]},void 0,!0,void 0,this),(v||p)&&q("p",{className:"text-[11px] text-accent-red font-body mt-1",children:v||p},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}export{Er as Callout,Nr as Checklist,ro as Choice,ao as CodeBlock,co as Diff,go as FilePreview,yo as ImageView,An as Item,vo as Markdown,To as Mermaid,oo as MultiChoice,No as Note,Lo as Priority,Fo as RangeInput,ns as SecretInput,$o as Section,Oo as Table,Do as Task,qo as UserInput,Yl as useFeedback};