agent-canvas 0.1.44 → 0.1.45

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.
Files changed (110) hide show
  1. package/bin/lib/commands/daemon.ts +3 -6
  2. package/bin/lib/commands/push.ts +1 -1
  3. package/bin/lib/daemon-lifecycle.ts +65 -72
  4. package/bin/lib/helpers.test.ts +1 -0
  5. package/bin/lib/helpers.ts +30 -74
  6. package/daemon/build.ts +16 -13
  7. package/daemon/client/App.tsx +32 -61
  8. package/daemon/client/CompareView.tsx +4 -4
  9. package/daemon/client/FileBrowser.tsx +4 -4
  10. package/daemon/client/FileViewer.tsx +4 -4
  11. package/daemon/client/OverviewView.tsx +2 -2
  12. package/daemon/client/RevisionSelect.tsx +1 -1
  13. package/daemon/client/clientApi.ts +18 -0
  14. package/daemon/client/components/index.ts +3 -16
  15. package/daemon/client/styles.css +4 -457
  16. package/daemon/dist/client.css +1 -1
  17. package/daemon/dist/client.js +76 -76
  18. package/daemon/dist/components.js +29 -29
  19. package/daemon/dist/runtime.js +1 -1
  20. package/daemon/src/components.ts +13 -0
  21. package/daemon/src/handlers/api.ts +14 -9
  22. package/daemon/src/handlers/files.ts +1 -3
  23. package/daemon/src/handlers/static.ts +1 -1
  24. package/daemon/src/handlers/uploads.ts +1 -3
  25. package/daemon/src/paths.ts +10 -24
  26. package/daemon/src/remote-feedback.test.ts +1 -1
  27. package/daemon/src/remote-feedback.ts +1 -1
  28. package/daemon/src/secrets-api.test.ts +1 -2
  29. package/daemon/src/server.ts +13 -10
  30. package/daemon/src/share-e2e.test.ts +1 -1
  31. package/daemon/src/share.test.ts +1 -1
  32. package/daemon/src/share.ts +1 -1
  33. package/daemon/tsconfig.json +1 -3
  34. package/package.json +10 -2
  35. package/.github/dark.png +0 -0
  36. package/.github/light.png +0 -0
  37. package/.github/workflows/ci.yml +0 -48
  38. package/.github/workflows/deploy-worker-prod.yml +0 -19
  39. package/.github/workflows/deploy-worker-stage.yml +0 -21
  40. package/.github/workflows/deploy-worker.yml +0 -72
  41. package/.github/workflows/release.yml +0 -36
  42. package/CLAUDE.md +0 -86
  43. package/bun.lock +0 -377
  44. package/daemon/client/AnnotationEditor.tsx +0 -315
  45. package/daemon/client/AnnotationProvider.tsx +0 -195
  46. package/daemon/client/AnnotationSidebar.tsx +0 -627
  47. package/daemon/client/FileIcon.tsx +0 -76
  48. package/daemon/client/PlanRenderer.tsx +0 -614
  49. package/daemon/client/Popover.tsx +0 -350
  50. package/daemon/client/RenderErrorContext.ts +0 -11
  51. package/daemon/client/ResponsePreview.tsx +0 -186
  52. package/daemon/client/SessionContext.tsx +0 -3
  53. package/daemon/client/annotationContext.ts +0 -114
  54. package/daemon/client/annotationDom.ts +0 -104
  55. package/daemon/client/annotationDraft.test.ts +0 -188
  56. package/daemon/client/annotationDraft.ts +0 -130
  57. package/daemon/client/compat/preact-all.ts +0 -4
  58. package/daemon/client/components/Callout.tsx +0 -26
  59. package/daemon/client/components/Checklist.tsx +0 -37
  60. package/daemon/client/components/Choice.tsx +0 -176
  61. package/daemon/client/components/CodeBlock.tsx +0 -35
  62. package/daemon/client/components/Diff.tsx +0 -65
  63. package/daemon/client/components/FilePreview.tsx +0 -88
  64. package/daemon/client/components/Image.tsx +0 -45
  65. package/daemon/client/components/Markdown.tsx +0 -44
  66. package/daemon/client/components/Mermaid.tsx +0 -565
  67. package/daemon/client/components/Note.tsx +0 -14
  68. package/daemon/client/components/Priority.tsx +0 -19
  69. package/daemon/client/components/ResponseNote.tsx +0 -19
  70. package/daemon/client/components/Section.tsx +0 -33
  71. package/daemon/client/components/Table.tsx +0 -35
  72. package/daemon/client/components/Task.tsx +0 -76
  73. package/daemon/client/components/UserInput.tsx +0 -174
  74. package/daemon/client/components/renderMarkdownChildren.tsx +0 -97
  75. package/daemon/client/generateMarkdown.ts +0 -273
  76. package/daemon/client/highlightRange.ts +0 -224
  77. package/daemon/client/popoverPosition.ts +0 -31
  78. package/daemon/client/runtime.ts +0 -123
  79. package/daemon/client/theme.css +0 -66
  80. package/daemon/client/useTextAnnotation.tsx +0 -188
  81. package/daemon/client/utils.ts +0 -13
  82. package/daemon/src/compiler.test.ts +0 -57
  83. package/daemon/src/compiler.ts +0 -360
  84. package/daemon/src/handlers/utils.ts +0 -14
  85. package/daemon/src/router.ts +0 -16
  86. package/daemon/src/session-secrets.test.ts +0 -83
  87. package/daemon/src/session.ts +0 -612
  88. package/daemon/src/watcher.ts +0 -71
  89. package/daemon/src/websocket.test.ts +0 -99
  90. package/daemon/src/websocket.ts +0 -211
  91. package/tsconfig.json +0 -14
  92. package/workers/canvas-share/README.md +0 -159
  93. package/workers/canvas-share/oblaka.ts +0 -56
  94. package/workers/canvas-share/package.json +0 -25
  95. package/workers/canvas-share/public/assets/.gitkeep +0 -0
  96. package/workers/canvas-share/public/assets/client.css +0 -2
  97. package/workers/canvas-share/public/assets/client.js +0 -91
  98. package/workers/canvas-share/public/assets/components.js +0 -65
  99. package/workers/canvas-share/public/assets/jsx-runtime.js +0 -3
  100. package/workers/canvas-share/public/assets/preact-compat.js +0 -1
  101. package/workers/canvas-share/public/assets/runtime.js +0 -1
  102. package/workers/canvas-share/public/index.html +0 -385
  103. package/workers/canvas-share/public/screenshot-dark.png +0 -0
  104. package/workers/canvas-share/public/screenshot-light.png +0 -0
  105. package/workers/canvas-share/src/index.test.ts +0 -209
  106. package/workers/canvas-share/src/index.ts +0 -518
  107. package/workers/canvas-share/src/types.ts +0 -119
  108. package/workers/canvas-share/src/util.ts +0 -156
  109. package/workers/canvas-share/src/validation.ts +0 -160
  110. package/workers/canvas-share/tsconfig.json +0 -16
@@ -1,30 +1,30 @@
1
- import{useState as c5}from"react";import z0 from"react";function c1(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var G1=c1();function P0(Q){G1=Q}var K1={exec:()=>null};function M(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(V.caret,"$1"),Y=Y.replace(J,K),W},getRegex:()=>new RegExp(Y,$)};return W}var s0=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),V={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)}}>`)},n0=/^(?:[ \t]*(?:\n|$))+/,t0=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,e0=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,f1=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,$5=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,u1=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,H0=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,N0=M(H0).replace(/bull/g,u1).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(),Q5=M(H0).replace(/bull/g,u1).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(),d1=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Y5=/^[^\n]+/,r1=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,J5=M(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",r1).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),W5=M(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,u1).getRegex(),I1="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",i1=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,X5=M("^ {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",i1).replace("tag",I1).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),U0=M(d1).replace("hr",f1).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",I1).getRegex(),K5=M(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",U0).getRegex(),l1={blockquote:K5,code:t0,def:J5,fences:e0,heading:$5,hr:f1,html:X5,lheading:N0,list:W5,newline:n0,paragraph:U0,table:K1,text:Y5},X0=M("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",f1).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",I1).getRegex(),B5={...l1,lheading:Q5,table:X0,paragraph:M(d1).replace("hr",f1).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",X0).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",I1).getRegex()},G5={...l1,html:M(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",i1).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:K1,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:M(d1).replace("hr",f1).replace("heading",` *#{1,6} *[^
2
- ]`).replace("lheading",N0).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},q5=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,L5=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Z0=/^( {2,}|\\)\n(?!\s*$)/,P5=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,N1=/[\p{P}\p{S}]/u,v1=/[\s\p{P}\p{S}]/u,o1=/[^\s\p{P}\p{S}]/u,H5=M(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,v1).getRegex(),T0=/(?!~)[\p{P}\p{S}]/u,N5=/(?!~)[\s\p{P}\p{S}]/u,U5=/(?:[^\s\p{P}\p{S}]|~)/u,Z5=M(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",s0?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),F0=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,T5=M(F0,"u").replace(/punct/g,N1).getRegex(),F5=M(F0,"u").replace(/punct/g,T0).getRegex(),_0="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",_5=M(_0,"gu").replace(/notPunctSpace/g,o1).replace(/punctSpace/g,v1).replace(/punct/g,N1).getRegex(),A5=M(_0,"gu").replace(/notPunctSpace/g,U5).replace(/punctSpace/g,N5).replace(/punct/g,T0).getRegex(),w5=M("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,o1).replace(/punctSpace/g,v1).replace(/punct/g,N1).getRegex(),z5=M(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,N1).getRegex(),f5="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",M5=M(f5,"gu").replace(/notPunctSpace/g,o1).replace(/punctSpace/g,v1).replace(/punct/g,N1).getRegex(),y5=M(/\\(punct)/,"gu").replace(/punct/g,N1).getRegex(),b5=M(/^<(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(),O5=M(i1).replace("(?:-->|$)","-->").getRegex(),k5=M("^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",O5).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),k1=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,S5=M(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",k1).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),A0=M(/^!?\[(label)\]\[(ref)\]/).replace("label",k1).replace("ref",r1).getRegex(),w0=M(/^!?\[(ref)\](?:\[\])?/).replace("ref",r1).getRegex(),C5=M("reflink|nolink(?!\\()","g").replace("reflink",A0).replace("nolink",w0).getRegex(),K0=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,a1={_backpedal:K1,anyPunctuation:y5,autolink:b5,blockSkip:Z5,br:Z0,code:L5,del:K1,delLDelim:K1,delRDelim:K1,emStrongLDelim:T5,emStrongRDelimAst:_5,emStrongRDelimUnd:w5,escape:q5,link:S5,nolink:w0,punctuation:H5,reflink:A0,reflinkSearch:C5,tag:k5,text:P5,url:K1},I5={...a1,link:M(/^!?\[(label)\]\((.*?)\)/).replace("label",k1).getRegex(),reflink:M(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",k1).getRegex()},E1={...a1,emStrongRDelimAst:A5,emStrongLDelim:F5,delLDelim:z5,delRDelim:M5,url:M(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",K0).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:M(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",K0).getRegex()},v5={...E1,br:M(Z0).replace("{2,}","*").getRegex(),text:M(E1.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},O1={normal:l1,gfm:B5,pedantic:G5},A1={normal:a1,gfm:E1,breaks:v5,pedantic:I5},R5={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},B0=(Q)=>R5[Q];function n(Q,$){if($){if(V.escapeTest.test(Q))return Q.replace(V.escapeReplace,B0)}else if(V.escapeTestNoEncode.test(Q))return Q.replace(V.escapeReplaceNoEncode,B0);return Q}function G0(Q){try{Q=encodeURI(Q).replace(V.percentDecode,"%")}catch{return null}return Q}function q0(Q,$){let Y=Q.replace(V.findPipe,(X,K,G)=>{let B=!1,q=K;for(;--q>=0&&G[q]==="\\";)B=!B;return B?"|":" |"}),W=Y.split(V.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(V.slashPipe,"|");return W}function w1(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 m5(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 h5(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 L0(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 g5(Q,$,Y){let W=Q.match(Y.other.indentCodeCompensation);if(W===null)return $;let J=W[1];return $.split(`
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
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 S1=class{options;rules;lexer;constructor(Q){this.options=Q||G1}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:w1(Y,`
5
- `)}}}fences(Q){let $=this.rules.block.fences.exec(Q);if($){let Y=$[0],W=g5(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=w1(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:w1($[0],`
6
- `)}}blockquote(Q){let $=this.rules.block.blockquote.exec(Q);if($){let Y=w1($[0],`
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],`
7
7
  `).split(`
8
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
- `),L=q.replace(this.rules.other.blockquoteSetextReplace,`
9
+ `),P=q.replace(this.rules.other.blockquoteSetextReplace,`
10
10
  $1`).replace(this.rules.other.blockquoteSetextReplace2,"");W=W?`${W}
11
11
  ${q}`:q,J=J?`${J}
12
- ${L}`:L;let P=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(L,X,!0),this.lexer.state.top=P,Y.length===0)break;let H=X.at(-1);if(H?.type==="code")break;if(H?.type==="blockquote"){let T=H,N=T.raw+`
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
13
  `+Y.join(`
14
- `),U=this.blockquote(N);X[X.length-1]=U,W=W.substring(0,W.length-T.raw.length)+U.raw,J=J.substring(0,J.length-T.text.length)+U.text;break}else if(H?.type==="list"){let T=H,N=T.raw+`
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
15
  `+Y.join(`
16
- `),U=this.list(N);X[X.length-1]=U,W=W.substring(0,W.length-H.raw.length)+U.raw,J=J.substring(0,J.length-T.raw.length)+U.raw,Y=N.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="",L="";if(!($=X.exec(Q))||this.rules.block.hr.test(Q))break;q=$[0],Q=Q.substring(q.length);let P=h5($[2].split(`
18
- `,1)[0],$[1].length),H=Q.split(`
19
- `,1)[0],T=!P.trim(),N=0;if(this.options.pedantic?(N=2,L=P.trimStart()):T?N=$[1].length+1:(N=P.search(this.rules.other.nonSpaceChar),N=N>4?1:N,L=P.slice(N),N+=$[1].length),T&&this.rules.other.blankLine.test(H)&&(q+=H+`
20
- `,Q=Q.substring(H.length+1),B=!0),!B){let U=this.rules.other.nextBulletRegex(N),Z=this.rules.other.hrRegex(N),_=this.rules.other.fencesBeginRegex(N),C=this.rules.other.headingBeginRegex(N),O=this.rules.other.htmlBeginRegex(N),y=this.rules.other.blockquoteBeginRegex(N);for(;Q;){let k=Q.split(`
21
- `,1)[0],I;if(H=k,this.options.pedantic?(H=H.replace(this.rules.other.listReplaceNesting," "),I=H):I=H.replace(this.rules.other.tabCharGlobal," "),_.test(H)||C.test(H)||O.test(H)||y.test(H)||U.test(H)||Z.test(H))break;if(I.search(this.rules.other.nonSpaceChar)>=N||!H.trim())L+=`
22
- `+I.slice(N);else{if(T||P.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||_.test(P)||C.test(P)||Z.test(P))break;L+=`
23
- `+H}T=!H.trim(),q+=k+`
24
- `,Q=Q.substring(k.length+1),P=I.slice(N)}}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(L),loose:!1,text:L,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 L=this.lexer.inlineQueue.length-1;L>=0;L--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[L].src)){this.lexer.inlineQueue[L].src=this.lexer.inlineQueue[L].src.replace(this.rules.other.listReplaceTask,"");break}}let q=this.rules.other.listTaskCheckbox.exec(B.raw);if(q){let L={type:"checkbox",raw:q[0]+" ",checked:q[0]!=="[ ]"};B.checked=L.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=L.raw+B.tokens[0].raw,B.tokens[0].text=L.raw+B.tokens[0].text,B.tokens[0].tokens.unshift(L)):B.tokens.unshift({type:"paragraph",raw:L.raw,text:L.raw,tokens:[L]}):B.tokens.unshift(L)}}if(!J.loose){let q=B.tokens.filter((P)=>P.type==="space"),L=q.length>0&&q.some((P)=>this.rules.other.anyLine.test(P.raw));J.loose=L}}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=q0($[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(q0(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=w1(Y.slice(0,-1),"\\");if((Y.length-X.length)%2===0)return}else{let X=m5($[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)),L0($,{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 L0(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 L=[...W[0]][0].length,P=Q.slice(0,J+W.index+L+K);if(Math.min(J,K)%2){let T=P.slice(1,-1);return{type:"em",raw:P,text:T,tokens:this.lexer.inlineTokens(T)}}let H=P.slice(2,-2);return{type:"strong",raw:P,text:H,tokens:this.lexer.inlineTokens(H)}}}}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,L=Q.slice(0,J+W.index+q+K),P=L.slice(J,-J);return{type:"del",raw:L,text:P,tokens:this.lexer.inlineTokens(P)}}}}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}}}},a=class Q{tokens;options;state;inlineQueue;tokenizer;constructor($){this.tokens=[],this.tokens.links=Object.create(null),this.options=$||G1,this.options.tokenizer=this.options.tokenizer||new S1,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:V,block:O1.normal,inline:A1.normal};this.options.pedantic?(Y.block=O1.pedantic,Y.inline=A1.pedantic):this.options.gfm&&(Y.block=O1.gfm,this.options.breaks?Y.inline=A1.breaks:Y.inline=A1.gfm),this.tokenizer.rules=Y}static get rules(){return{block:O1,inline:A1}}static lex($,Y){return new Q(Y).lex($)}static lexInline($,Y){return new Q(Y).inlineTokens($)}lex($){$=$.replace(V.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(V.tabCharGlobal," ").replace(V.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+=`
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
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(`
29
29
  `)?"":`
30
30
  `)+J.raw,K.text+=`
@@ -37,9 +37,9 @@ ${L}`:L;let P=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
37
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(`
38
38
  `)?"":`
39
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((L)=>(B=L.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 L=Y.at(-1);B.type==="text"&&L?.type==="text"?(L.raw+=B.raw,L.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 L=1/0,P=$.slice(1),H;this.options.extensions.startInline.forEach((T)=>{H=T.call({lexer:this},P),typeof H=="number"&&H>=0&&(L=Math.min(L,H))}),L<1/0&&L>=0&&(q=$.substring(0,L+1))}if(B=this.tokenizer.inlineText(q)){$=$.substring(B.raw.length),B.raw.slice(-1)!=="_"&&(G=B.raw.slice(-1)),K=!0;let L=Y.at(-1);L?.type==="text"?(L.raw+=B.raw,L.text+=B.text):Y.push(B);continue}if($){let L="Infinite loop on byte: "+$.charCodeAt(0);if(this.options.silent){console.error(L);break}else throw Error(L)}}return Y}},C1=class{options;parser;constructor(Q){this.options=Q||G1}space(Q){return""}code({text:Q,lang:$,escaped:Y}){let W=($||"").match(V.notSpaceStart)?.[0],J=Q.replace(V.endingNewline,"")+`
41
- `;return W?'<pre><code class="language-'+n(W)+'">'+(Y?J:n(J,!0))+`</code></pre>
42
- `:"<pre><code>"+(Y?J:n(J,!0))+`</code></pre>
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
43
  `}blockquote({tokens:Q}){return`<blockquote>
44
44
  ${this.parser.parse(Q)}</blockquote>
45
45
  `}html({text:Q}){return Q}def(Q){return""}heading({tokens:Q,depth:$}){return`<h${$}>${this.parser.parseInline(Q)}</h${$}>
@@ -55,11 +55,11 @@ ${this.parser.parse(Q)}</blockquote>
55
55
  `}tablerow({text:Q}){return`<tr>
56
56
  ${Q}</tr>
57
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>${n(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=G0(Q);if(J===null)return W;Q=J;let X='<a href="'+Q+'"';return $&&(X+=' title="'+n($)+'"'),X+=">"+W+"</a>",X}image({href:Q,title:$,text:Y,tokens:W}){W&&(Y=this.parser.parseInline(W,this.parser.textRenderer));let J=G0(Q);if(J===null)return n(Y);Q=J;let X=`<img src="${Q}" alt="${n(Y)}"`;return $&&(X+=` title="${n($)}"`),X+=">",X}text(Q){return"tokens"in Q&&Q.tokens?this.parser.parseInline(Q.tokens):("escaped"in Q)&&Q.escaped?Q.text:n(Q.text)}},s1=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}},s=class Q{options;renderer;textRenderer;constructor($){this.options=$||G1,this.options.renderer=this.options.renderer||new C1,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new s1}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}},z1=class{options;block;constructor(Q){this.options=Q||G1}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?a.lex:a.lexInline}provideParser(Q=this.block){return Q?s.parse:s.parseInline}},j5=class{defaults=c1();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=s;Renderer=C1;TextRenderer=s1;Lexer=a;Tokenizer=S1;Hooks=z1;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 C1(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 L=G.apply(J,q);return L===!1&&(L=B.apply(J,q)),L||""}}W.renderer=J}if(Y.tokenizer){let J=this.defaults.tokenizer||new S1(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 L=G.apply(J,q);return L===!1&&(L=B.apply(J,q)),L}}W.tokenizer=J}if(Y.hooks){let J=this.defaults.hooks||new z1;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];z1.passThroughHooks.has(X)?J[K]=(q)=>{if(this.defaults.async&&z1.passThroughHooksRespectAsync.has(X))return(async()=>{let P=await G.call(J,q);return B.call(J,P)})();let L=G.call(J,q);return B.call(J,L)}:J[K]=(...q)=>{if(this.defaults.async)return(async()=>{let P=await G.apply(J,q);return P===!1&&(P=await B.apply(J,q)),P})();let L=G.apply(J,q);return L===!1&&(L=B.apply(J,q)),L}}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 a.lex(Q,$??this.defaults)}parser(Q,$){return s.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?a.lex:a.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?s.parse:s.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?a.lex:a.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?s.parse:s.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>"+n(Y.message+"",!0)+"</pre>";return $?Promise.resolve(W):W}if($)return Promise.reject(Y);throw Y}}},B1=new j5;function f(Q,$){return B1.parse(Q,$)}f.options=f.setOptions=function(Q){return B1.setOptions(Q),f.defaults=B1.defaults,P0(f.defaults),f};f.getDefaults=c1;f.defaults=G1;f.use=function(...Q){return B1.use(...Q),f.defaults=B1.defaults,P0(f.defaults),f};f.walkTokens=function(Q,$){return B1.walkTokens(Q,$)};f.parseInline=B1.parseInline;f.Parser=s;f.parser=s.parse;f.Renderer=C1;f.TextRenderer=s1;f.Lexer=a;f.lexer=a.lex;f.Tokenizer=S1;f.Hooks=z1;f.parse=f;var{options:a2,setOptions:s2,use:n2,walkTokens:t2,parseInline:e2}=f;var $4=s.parse,Q4=a.lex;import{jsxDEV as n1}from"react/jsx-dev-runtime";f.setOptions({gfm:!0,breaks:!1});var V5=new Set(["a","abbr","b","br","code","del","em","i","kbd","mark","q","s","small","span","strong","sub","sup","time","u"]),x5=new Set(["Priority"]);function D5(Q){if(typeof Q==="string"||typeof Q==="number")return!0;if(!z0.isValidElement(Q))return!1;let $=Q.type;if(typeof $==="string")return V5.has($);if(typeof $==="function"){let Y=$.displayName??$.name;return Y?x5.has(Y):!1}return!1}function p5(Q,$){let Y=Q.trim();if(!Y)return null;let W=f.parse(Y,{async:!1});return n1("div",{className:"prose-canvas","data-md":"markdown","data-md-source":Y,dangerouslySetInnerHTML:{__html:W}},$,!1,void 0,this)}function E5(Q,$){return n1("div",{className:"prose-canvas",children:Q.map((Y,W)=>{if(typeof Y==="string"||typeof Y==="number"){let J=f.parseInline(String(Y),{async:!1});return n1("span",{dangerouslySetInnerHTML:{__html:J}},W,!1,void 0,this)}return Y})},$,!1,void 0,this)}function J1(Q){let $=z0.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(E5(W,`md-${J++}`));else{let G=p5(W.join(""),`md-${J++}`);if(G)Y.push(G)}W=[]};for(let K of $)if(D5(K))W.push(K);else X(),Y.push(K);return X(),Y}import{jsxDEV as q1}from"react/jsx-dev-runtime";function u5({title:Q,children:$}){let[Y,W]=c5(!1);return q1("div",{className:"relative mb-8 p-4 group/section","data-md":"section","data-md-title":Q,children:[q1("div",{className:"relative mb-2",children:[q1("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:q1("svg",{width:"14",height:"14",viewBox:"0 0 12 12",fill:"none",children:q1("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),q1("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),q1("div",{className:Y?"mt-6 hidden":"mt-6",children:J1($)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as t}from"react/jsx-dev-runtime";var d5={todo:"bg-border-hover",done:"bg-accent-green",blocked:"bg-accent-red","in-progress":"bg-accent-blue"},r5={todo:"Todo",done:"Done",blocked:"Blocked","in-progress":"In progress"},i5={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 f0({id:Q,label:$,status:Y,badge:W,badgeVariant:J="neutral",children:X}){return t("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:t("div",{className:"flex items-start gap-3",children:[Y&&t("span",{className:`w-2 h-2 rounded-full mt-[7px] flex-shrink-0 ${d5[Y]}`},void 0,!1,void 0,this),t("div",{className:"flex-1 min-w-0",children:[t("div",{className:"flex items-baseline gap-2",children:[t("span",{className:"font-body text-task-label font-semibold text-text-primary",children:$},void 0,!1,void 0,this),Y&&t("span",{className:"font-body text-tiny uppercase tracking-wider text-text-tertiary opacity-0 group-hover/task:opacity-100 transition-opacity duration-150",children:r5[Y]},void 0,!1,void 0,this),W&&t("span",{className:`font-body text-tiny font-medium px-1.5 py-px rounded-full ${i5[J]}`,children:W},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X&&t("div",{className:"text-body text-text-secondary mt-1 leading-relaxed",children:J1(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 l5(Q){return t(f0,{...Q},void 0,!1,void 0,this)}import{useEffect as o5,useRef as a5}from"react";import{jsxDEV as R1}from"react/jsx-dev-runtime";function s5({language:Q,children:$}){let Y=typeof $==="string"?$:String($??""),W=a5(null);return o5(()=>{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]),R1("div",{className:"relative mt-3 group/code","data-md":"codeblock","data-md-language":Q||"",children:[Q&&R1("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),R1("pre",{className:"bg-bg-code rounded-md p-4 overflow-x-auto text-code font-mono leading-relaxed",children:R1("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 t1}from"react/jsx-dev-runtime";var n5={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 t5({type:Q="info",children:$}){let Y=n5[Q];return t1("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:[t1("span",{className:`${Y.iconColor} opacity-70 text-base leading-relaxed flex-shrink-0 mt-px`,children:Y.icon},void 0,!1,void 0,this),t1("div",{className:"text-body text-text-secondary leading-relaxed",children:J1($)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as $2}from"react/jsx-dev-runtime";function e5({children:Q}){return $2("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:J1(Q)},void 0,!1,void 0,this)}import{jsxDEV as W1}from"react/jsx-dev-runtime";function Q2({headers:Q,rows:$}){return W1("div",{className:"overflow-x-auto mt-3","data-md":"table",children:W1("table",{className:"w-full text-body",children:[W1("thead",{children:W1("tr",{className:"border-b border-border-subtle",children:Q.map((Y,W)=>W1("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),W1("tbody",{children:$.map((Y,W)=>W1("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)=>W1("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 U1}from"react/jsx-dev-runtime";function Y2({items:Q}){return U1("ul",{className:"space-y-1 mt-3","data-md":"checklist",children:Q.map(($,Y)=>U1("li",{"data-md":"checklist-item","data-md-label":$.label,className:"relative flex items-start gap-2.5 py-1",children:[U1("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&&U1("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:U1("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),U1("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 X2}from"react/jsx-dev-runtime";var J2={high:"text-accent-red bg-accent-red-muted",medium:"text-accent-amber bg-accent-amber-muted",low:"text-text-tertiary bg-border-subtle"};function W2({level:Q}){return X2("span",{className:`inline text-tiny font-medium font-body ml-2 px-1.5 py-0.5 rounded ${J2[Q]}`,"data-md":"priority","data-md-level":Q,children:Q},void 0,!1,void 0,this)}import{useEffect as M0,useState as m1,useContext as y0,useRef as K2}from"react";import{SessionContext as B2,ActiveViewCtx as G2}from"#canvas/runtime";import{jsxDEV as X1}from"react/jsx-dev-runtime";var q2={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 L2({path:Q,lines:$,__content:Y}){let W=y0(B2),{setActiveView:J}=y0(G2),[X,K]=m1(Y??null),[G,B]=m1(()=>{let N=Q.split(".").pop()||"";return q2[N]||"text"}),[q,L]=m1(null),[P,H]=m1(!Y),T=K2(null);if(M0(()=>{if(Y!==void 0)return;H(!0),L(null),fetch(`/api/file?session=${W}&path=${encodeURIComponent(Q)}`).then((N)=>N.json()).then((N)=>{if(N.error)L(N.error);else{let U=N.content;if($)U=U.split(`
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
60
  `).slice($[0]-1,$[1]).join(`
61
- `);K(U),B(N.language||"text")}}).catch(()=>L("Failed to fetch file")).finally(()=>H(!1))},[W,Q,$?.[0],$?.[1],Y]),M0(()=>{let N=T.current,U=window.hljs;if(!N||!U||!X)return;N.removeAttribute("data-highlighted"),N.className=G?`language-${G}`:"",N.textContent=X,U.highlightElement(N)},[X,G]),P)return X1("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 X1("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 X1("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden","data-md":"filepreview","data-md-path":Q,...$?{"data-md-lines":`${$[0]}-${$[1]}`}:{},children:[X1("div",{className:"px-4 py-2 flex items-center justify-between",children:[X1("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),$&&X1("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),X1("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono !bg-transparent",style:{background:"transparent"},children:X1("code",{ref:T,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 W0,useRef as M1,useState as T1,useCallback as e}from"react";import b2 from"react-dom";import{useAnnotations as O2,useCanvasFile as k2}from"#canvas/runtime";import{useEffect as _2,useRef as g1,useState as Z1,useCallback as h1,useMemo as R0,useContext as A2}from"react";import{createPortal as w2}from"react-dom";function b0(Q,$){let J=$||document.body,X=Q.getBoundingClientRect(),K=J.getBoundingClientRect(),G=J===document.body?window.scrollY:J.scrollTop,B=X.bottom-K.top+G+8,q=Math.max(0,Math.min(X.left-K.left,K.width-280-12));return J.style.position="relative",{style:{position:"absolute",top:`${B}px`,left:`${q}px`},parent:J}}import{useState as Q0,useRef as Y0,useCallback as Y1,useEffect as Z2}from"react";function L1(Q,$){Q.style.height="auto",Q.style.height=($?Math.max($,Q.scrollHeight):Q.scrollHeight)+"px"}async function O0(Q){let $=H2(Q);return crypto.subtle.importKey("raw",$,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}function P2(Q){let $=atob(Q),Y=new Uint8Array($.length);for(let W=0;W<$.length;W++)Y[W]=$.charCodeAt(W);return Y}function H2(Q){let $=Q.replace(/-/g,"+").replace(/_/g,"/")+"===".slice((Q.length+3)%4);return P2($)}function N2(){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 U2(){if(typeof window<"u"&&window.__CANVAS_SHARE__?.shareId){let $=N2();return{isShared:!0,shareId:window.__CANVAS_SHARE__.shareId,encryptionKey:$?O0($):null}}return{isShared:!1,sessionId:typeof window<"u"?window.location.pathname.replace("/s/",""):""}}var l=U2();function k0(){if(l.isShared)return`/s/${l.shareId}/upload`;return`/api/session/${l.sessionId}/upload`}function e1(Q,$){if(l.isShared)throw Error("Secret inputs are available only on the local canvas daemon");return`/api/session/${encodeURIComponent(l.sessionId)}/secrets/${encodeURIComponent(Q)}/${$}`}async function $0(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 S0(Q){let $=await fetch(e1(Q,"status"),{cache:"no-store"});if(!$.ok)throw await $0($);let Y=await $.json();return typeof Y==="object"&&Y!==null&&"ready"in Y&&Y.ready===!0}async function C0(Q,$){let Y=await fetch(e1(Q,"value"),{method:"POST",headers:{"Content-Type":"application/json"},cache:"no-store",body:JSON.stringify({value:$})});if(!Y.ok)throw await $0(Y)}async function I0(Q){let $=await fetch(e1(Q,"value"),{method:"DELETE",cache:"no-store"});if(!$.ok)throw await $0($)}var o4=!l.isShared,a4=!l.isShared;import{jsxDEV as x}from"react/jsx-dev-runtime";function T2(Q){if(Q.startsWith("/s/")||Q.startsWith("http://")||Q.startsWith("https://"))return Q;return`/api/uploads/${Q.split("/").pop()}`}async function F2(Q,$){let Y=new FormData;Y.append("image",$);try{let J=await(await fetch(k0(),{method:"POST",body:Y})).json();if(l.isShared)return J.url||null;return J.path||null}catch{return null}}function v0({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:L,onTextareaClick:P,textareaRef:H,textareaClassName:T,textareaStyle:N,minHeight:U,attachButton:Z="always",openFilePickerRef:_}){let[C,O]=Q0(!1),[y,k]=Q0(!1),[I,p]=Q0(!1),m=Y0(0),d=Y0(null),v=Y0(null),h=Y1(()=>v.current?.click(),[]);if(_)_.current=h;let c=Y1((A)=>{if(d.current=A,H)H.current=A;if(A&&B)L1(A,U)},[H,B,U]);Z2(()=>{if(G&&d.current){let A=d.current;if(A.focus(),A.value)A.setSelectionRange(A.value.length,A.value.length)}},[G]);let g=Y1(async(A)=>{if(!A.type.startsWith("image/"))return;k(!0);try{let E=await F2(X,A);if(E)W(E)}finally{k(!1)}},[X,W]),o=Y1((A)=>{let E=A.clipboardData.items;for(let F of E)if(F.type.startsWith("image/")){A.preventDefault();let z=F.getAsFile();if(z)g(z);return}},[g]),R=Y1((A)=>{if(A.preventDefault(),m.current++,m.current===1)O(!0)},[]),u=Y1((A)=>{A.preventDefault()},[]),r=Y1((A)=>{if(A.preventDefault(),m.current--,m.current===0)O(!1)},[]),$1=Y1((A)=>{A.preventDefault(),m.current=0,O(!1);for(let E of A.dataTransfer.files)if(E.type.startsWith("image/"))g(E)},[g]),Q1=Y1((A)=>{if($(A.target.value),B)A.target.style.height="auto",A.target.style.height=(U?Math.max(U,A.target.scrollHeight):A.target.scrollHeight)+"px"},[$,B,U]),D1="w-full bg-transparent text-[13px] font-body text-text-primary resize-none focus:outline-none leading-relaxed p-0 border-none",p1={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"}},P1=!q&&(Z==="always"||Z==="on-focus"&&I);return x("div",{style:{position:"relative"},onDragEnter:q?void 0:R,onDragOver:q?void 0:u,onDragLeave:q?void 0:r,onDrop:q?void 0:$1,children:[x("textarea",{ref:c,value:Q,onChange:q?void 0:Q1,onPaste:q?void 0:o,onKeyDown:L,onClick:P,onFocus:()=>p(!0),onBlur:()=>{setTimeout(()=>p(!1),150)},readOnly:q,placeholder:K,className:T??D1,style:N??p1,rows:B?1:void 0},void 0,!1,void 0,this),!q&&x("input",{ref:v,type:"file",accept:"image/*",multiple:!0,style:{display:"none"},onChange:(A)=>{let E=A.target.files;if(E)for(let F of E)g(F);A.target.value=""}},void 0,!1,void 0,this),(Y.length>0||P1)&&x("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px",alignItems:"center"},children:[Y.map((A)=>x("div",{style:{position:"relative",width:"56px",height:"56px",borderRadius:"6px",overflow:"hidden",border:"1px solid var(--color-border-subtle)",flexShrink:0},children:[x("img",{src:T2(A),alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}},void 0,!1,void 0,this),!q&&x("button",{onClick:(E)=>{E.stopPropagation(),J(A)},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)]},A,!0,void 0,this)),P1&&x(J0,{onClick:h},void 0,!1,void 0,this)]},void 0,!0,void 0,this),y&&x("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:"Uploading..."},void 0,!1,void 0,this),C&&x("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 J0({onClick:Q,size:$=16}){return x("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:x("svg",{width:$,height:$,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[x("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},void 0,!1,void 0,this),x("circle",{cx:"8.5",cy:"8.5",r:"1.5"},void 0,!1,void 0,this),x("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 z2}from"#canvas/runtime";import{jsxDEV as j,Fragment as y2}from"react/jsx-dev-runtime";function f2({anchorEl:Q,scrollContainer:$,onClose:Y,ignoreSelector:W,zIndex:J="50",padding:X="12px",width:K="280px",children:G}){let B=g1(null),q=g1(Y);q.current=Y;let{style:L,parent:P}=b0(Q,$);return _2(()=>{let H=setTimeout(()=>{let T=(N)=>{if(B.current&&!B.current.contains(N.target)){if(W&&N.target.closest?.(W))return;q.current(),document.removeEventListener("mousedown",T)}};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},0);return()=>clearTimeout(H)},[W]),w2(j("div",{ref:B,style:{...L,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),P)}var h0=[{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"]}],m0=h0.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 L=A2(z2),P=X!==""||!!q,[H,T]=Z1(X),[N,U]=Z1(K||[]),[Z,_]=Z1(null),[C,O]=Z1(P),[y,k]=Z1(!1),I=g1(null),p=g1(null),m=h1(()=>{if(H.trim()||N.length>0)G(H.trim(),N);else if(P&&q)q();else B()},[H,N,G,B,P,q]),d=h1(()=>{if(P){if(!H.trim()&&N.length===0&&q){q(),B();return}G(H,N);return}B()},[H,N,P,G,B,q]),v=!P,h=H.trim().length>0?m0.filter((F)=>F.toLowerCase().startsWith(H.trim().toLowerCase())):m0,c=!v||C?[]:h.length===1&&h[0].toLowerCase()===H.trim().toLowerCase()?[]:h,g=new Set(c),o=h0.map((F)=>({label:F.label,items:F.items.filter((z)=>g.has(z))})).filter((F)=>F.items.length>0),R=o.map((F)=>F.items),u=R.flat(),r=R0(()=>{if(Z===null)return 0;let F=0;for(let z=0;z<R.length;z++){if(Z<F+R[z].length)return z;F+=R[z].length}return 0},[Z,R]),$1=R0(()=>{if(Z===null)return 0;let F=0;for(let z=0;z<r;z++)F+=R[z].length;return Z-F},[Z,r,R]),Q1=(F,z)=>{let i=0;for(let H1=0;H1<F;H1++)i+=R[H1].length;return i+z},[D1,p1]=Z1(H);if(H!==D1)p1(H),_(null),O(P);let P1=h1((F)=>{T(F)},[]),A=Y.length>W?Y.slice(0,W)+"...":Y,E=h1((F)=>{if(u.length>0&&(F.key==="ArrowDown"||F.key==="ArrowUp"||F.key==="ArrowLeft"||F.key==="ArrowRight")){if(F.preventDefault(),Z===null){_(0);return}if(F.key==="ArrowDown"){let z=Math.min($1+1,R[r].length-1);_(Q1(r,z))}else if(F.key==="ArrowUp"){let z=Math.max($1-1,0);_(Q1(r,z))}else if(F.key==="ArrowRight"){let z=Math.min(r+1,R.length-1),i=Math.min($1,R[z].length-1);_(Q1(z,i))}else if(F.key==="ArrowLeft"){let z=Math.max(r-1,0),i=Math.min($1,R[z].length-1);_(Q1(z,i))}return}if(Z!==null&&u.length>0){if(F.key==="Tab"){F.preventDefault(),P1(u[Z]);return}if(F.key==="Enter"&&!F.shiftKey){F.preventDefault(),G(u[Z],N);return}}if(F.key==="Enter"&&!F.shiftKey){F.preventDefault(),m();return}if(F.key==="Escape")if(u.length>0&&!C)O(!0);else if(P)d();else B()},[u,Z,$1,r,R,Q1,P1,G,N,m,C,P,d,B]);return j(f2,{anchorEl:Q,scrollContainer:$,onClose:P?d:B,ignoreSelector:P?"[data-annotation-id]":void 0,zIndex:P?"60":"50",padding:P?"10px 12px":"12px",width:"420px",children:[!P&&(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:["“",A,"”"]},void 0,!0,void 0,this)),j(v0,{note:H,onNoteChange:T,images:N,onAddImage:(F)=>U((z)=>[...z,F]),onRemoveImage:(F)=>U((z)=>z.filter((i)=>i!==F)),sessionId:L,autoFocus:!0,autoResize:P,textareaRef:I,onKeyDown:E,attachButton:"none",openFilePickerRef:p,textareaStyle:P?{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:P?"6px":"8px"},children:[j(J0,{onClick:()=>p.current?.(),size:14},void 0,!1,void 0,this),j("div",{style:{flex:1}},void 0,!1,void 0,this),P?j("button",{onClick:()=>{if(q)q();B()},onMouseEnter:()=>k(!0),onMouseLeave:()=>k(!1),style:{fontSize:"11px",color:y?"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(y2,{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:m,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),u.length>0&&j("div",{style:{marginTop:"6px",borderTop:"1px solid var(--color-border-subtle)",paddingTop:"8px",display:"flex",gap:"4px"},children:o.map((F)=>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:F.label},void 0,!1,void 0,this),F.items.map((z)=>{let i=u.indexOf(z);return j("div",{onMouseDown:(H1)=>{H1.preventDefault(),H1.stopPropagation(),P1(z)},onMouseEnter:()=>_(i),style:{padding:"3px 6px",fontSize:"12px",borderRadius:"4px",fontFamily:"'Inter', sans-serif",color:i===Z?"var(--color-text-primary)":"var(--color-text-secondary)",background:i===Z?"var(--color-highlight-selected)":"transparent",cursor:"pointer"},children:[j("span",{style:{fontWeight:500},children:z.slice(0,H.trim().length)},void 0,!1,void 0,this),z.slice(H.trim().length)]},z,!0,void 0,this)})]},F.label,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function g0({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 w,Fragment as D0}from"react/jsx-dev-runtime";var F1=0.2,j1=0.25,V1=4;function V0({zoom:Q,onZoomIn:$,onZoomOut:Y,onZoomReset:W,onFullscreen:J}){return w("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:[w("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<=j1,children:w("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:w("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),w("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),w("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>=V1,children:w("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[w("line",{x1:"12",y1:"5",x2:"12",y2:"19"},void 0,!1,void 0,this),w("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&&w(D0,{children:[w("div",{className:"w-px h-4 bg-border-subtle mx-0.5"},void 0,!1,void 0,this),w("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:w("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[w("polyline",{points:"15 3 21 3 21 9"},void 0,!1,void 0,this),w("polyline",{points:"9 21 3 21 3 15"},void 0,!1,void 0,this),w("line",{x1:"21",y1:"3",x2:"14",y2:"10"},void 0,!1,void 0,this),w("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 x0(Q=1){let[$,Y]=T1(Q),W=e(()=>Y((K)=>Math.min(V1,+(K+F1).toFixed(2))),[]),J=e(()=>Y((K)=>Math.max(j1,+(K-F1).toFixed(2))),[]),X=e(()=>Y(1),[]);return{zoom:$,zoomIn:W,zoomOut:J,zoomReset:X,setZoom:Y}}function S2({svgHtml:Q,source:$,onClose:Y}){let W=M1(null),{zoom:J,zoomIn:X,zoomOut:K,zoomReset:G,setZoom:B}=x0(1),[q,L]=T1({x:0,y:0}),P=M1(null);W0(()=>{let _=(C)=>{if(C.key==="Escape")Y()};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[Y]);let H=e((_)=>{_.preventDefault();let C=_.deltaY>0?-F1:F1;B((O)=>Math.max(j1,Math.min(V1,+(O+C).toFixed(2))))},[B]),T=e((_)=>{if(_.button!==0)return;P.current={startX:_.clientX,startY:_.clientY,panX:q.x,panY:q.y},_.preventDefault()},[q]),N=e((_)=>{if(!P.current)return;L({x:P.current.panX+(_.clientX-P.current.startX),y:P.current.panY+(_.clientY-P.current.startY)})},[]),U=e(()=>{P.current=null},[]),Z=e(()=>{G(),L({x:0,y:0})},[G]);return b2.createPortal(w("div",{style:{position:"fixed",inset:0,zIndex:9999,background:"var(--color-bg-base)",display:"flex",flexDirection:"column"},onMouseMove:N,onMouseUp:U,onMouseLeave:U,children:[w("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:[w("span",{className:"text-body text-text-secondary",style:{fontSize:"13px"},children:"Mermaid Diagram"},void 0,!1,void 0,this),w("div",{className:"flex items-center gap-2",children:[w(V0,{zoom:J,onZoomIn:X,onZoomOut:K,onZoomReset:Z},void 0,!1,void 0,this),w("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:w("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[w("line",{x1:"18",y1:"6",x2:"6",y2:"18"},void 0,!1,void 0,this),w("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),w("div",{style:{flex:1,overflow:"hidden",cursor:P.current?"grabbing":"grab"},onWheel:H,onMouseDown:T,children:w("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:P.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 C2({children:Q}){let $=M1(null),[Y,W]=T1(null),[J,X]=T1(!1),[K,G]=T1(""),B=typeof Q==="string"?Q:String(Q??""),{annotations:q,addAnnotationWithId:L,activeAnnotationId:P,setActiveAnnotationId:H}=O2(),T=k2(),[N,U]=T1(null),{zoom:Z,zoomIn:_,zoomOut:C,zoomReset:O,setZoom:y}=x0(1),k=M1(q);k.current=q;let I=e((v,h,c)=>{let g=`[Diagram ${c.toLowerCase()}] ${h}`,o=k.current.find((R)=>R.snippet===g);if(o)H(o.id);else U({anchorEl:v,snippet:h,prefix:c})},[H]),p=M1(I);p.current=I,W0(()=>{let v=!1,h=async()=>{try{let g=window.mermaid;if(!g){W("Mermaid library not loaded");return}let o=document.documentElement.dataset.theme==="light"?"default":"dark";g.initialize({startOnLoad:!1,theme:o});let R=`mermaid-${Math.random().toString(36).slice(2)}`,{svg:u}=await g.render(R,B.trim());if(!v&&$.current)$.current.innerHTML=u,G(u),I2($.current,(r,$1,Q1)=>p.current(r,$1,Q1)),j0($.current,k.current);W(null)}catch(g){if(!v)W(g.message||"Invalid diagram")}};h();let c=new MutationObserver((g)=>{for(let o of g)if(o.attributeName==="data-theme")h()});return c.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{v=!0,c.disconnect()}},[B]),W0(()=>{if($.current)j0($.current,q,P)},[q,P]);let m=e((v)=>{if(!v.ctrlKey&&!v.metaKey)return;v.preventDefault();let h=v.deltaY>0?-F1:F1;y((c)=>Math.max(j1,Math.min(V1,+(c+h).toFixed(2))))},[y]);if(Y)return w("div",{className:"bg-accent-red-muted rounded-md p-4 mt-3 text-body text-accent-red",children:["Mermaid error: ",Y,w("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 d=$.current?.closest("#plan-scroll-container");return w(D0,{children:[w("div",{className:"mt-3 mermaid-container","data-md":"mermaid","data-md-source":B.trim(),children:[w("div",{className:"flex justify-end mb-1",children:w(V0,{zoom:Z,onZoomIn:_,onZoomOut:C,onZoomReset:O,onFullscreen:()=>X(!0)},void 0,!1,void 0,this)},void 0,!1,void 0,this),w("div",{style:{overflow:"auto",maxHeight:"70vh"},onWheel:m,children:w("div",{ref:$,className:"flex justify-center",style:{transform:`scale(${Z})`,transformOrigin:"top center",transition:"transform 0.1s ease-out",minHeight:Z<1?void 0:void 0}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),N&&w(g0,{anchorEl:N.anchorEl,scrollContainer:d,snippet:N.snippet,header:w("div",{style:{fontSize:"12px",color:"var(--color-text-tertiary)",marginBottom:"8px",lineHeight:"1.4",display:"flex",alignItems:"center",gap:"6px"},children:[w("span",{style:{width:"8px",height:"8px",borderRadius:"50%",background:"var(--color-accent-amber)",flexShrink:0}},void 0,!1,void 0,this),N.snippet]},void 0,!0,void 0,this),onAdd:(v,h)=>{let c=`ann-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;L(c,`[Diagram ${N.prefix.toLowerCase()}] ${N.snippet}`,v,void 0,void 0,h,T||void 0),U(null)},onCancel:()=>U(null)},void 0,!1,void 0,this),J&&K&&w(S2,{svgHtml:K,source:B,onClose:()=>X(!1)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function I2(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 j0(Q,$,Y){let W=new Map;for(let X of $){let K=X.snippet.match(/^\[Diagram (?:node|edge)\] (.+)$/);if(K)W.set(K[1],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 L=B===Y;q.style.outline=L?"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 L=q===Y,P=K.querySelector("rect");if(P)P.style.outline=L?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",P.style.outlineOffset="2px",P.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 P=q.querySelector(K)?.textContent?.trim();if(!P||!W.has(P))continue;let H=W.get(P);q.setAttribute("data-annotated",H);let T=H===Y,N=q.querySelector("rect, circle, ellipse, polygon")||q;N.style.outline=T?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",N.style.outlineOffset="2px",N.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 L=q===Y;G.style.outline=L?"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)}import{jsxDEV as y1}from"react/jsx-dev-runtime";function v2({before:Q,after:$,language:Y}){let W=Q.split(`
62
- `),J=$.split(`
63
- `),X=R2(W,J),K=[],G=0,B=0,q=0;while(G<W.length||B<J.length)if(q<X.length&&G<W.length&&B<J.length&&W[G]===X[q]&&J[B]===X[q])K.push({type:"same",line:W[G]}),G++,B++,q++;else if(G<W.length&&(q>=X.length||W[G]!==X[q]))K.push({type:"removed",line:W[G]}),G++;else if(B<J.length)K.push({type:"added",line:J[B]}),B++;return y1("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden group/diff","data-md":"diff","data-md-language":Y||"",children:[Y&&y1("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),y1("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono",children:K.map((L,P)=>y1("div",{className:L.type==="removed"?"bg-accent-red-muted text-accent-red":L.type==="added"?"bg-accent-green-muted text-accent-green":"text-text-tertiary",children:[y1("span",{className:"select-none w-6 inline-block text-center opacity-60",children:L.type==="removed"?"-":L.type==="added"?"+":" "},void 0,!1,void 0,this),L.line]},P,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function R2(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++)for(let q=1;q<=W;q++)J[B][q]=Q[B-1]===$[q-1]?J[B-1][q-1]+1:Math.max(J[B-1][q],J[B][q-1]);let X=[],K=Y,G=W;while(K>0&&G>0)if(Q[K-1]===$[G-1])X.unshift(Q[K-1]),K--,G--;else if(J[K-1][G]>J[K][G-1])K--;else G--;return X}import{useEffect as E0,useMemo as c0,useRef as u0,useState as d0}from"react";import{useAnnotations as r0}from"#canvas/runtime";import{jsxDEV as p0}from"react/jsx-dev-runtime";function _1({note:Q,onChange:$}){return p0("div",{className:"mt-1.5",children:p0("textarea",{value:Q,onChange:(Y)=>$(Y.target.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)=>L1(Y.target),ref:(Y)=>{if(Y)L1(Y)}},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as S}from"react/jsx-dev-runtime";function i0(Q){return Q.map(($)=>typeof $==="string"?{value:$,label:$}:{value:$.value,label:$.label??$.value})}function m2({id:Q,label:$,options:Y,required:W}){let{responses:J,setResponse:X}=r0(),K=c0(()=>i0(Y),[Y]),G=J.get(Q),B=G?.value,q=G?.note||"",[L,P]=d0(!1),H=u0(null);if(!J.has(Q))X(Q,{id:Q,type:"radio",label:$,value:null,options:K.map((U)=>U.value),required:W});let T=(U)=>{X(Q,{...G,value:U})};E0(()=>{let U=H.current;if(!U)return;let Z=(_)=>{let O=_.target.closest("[data-md-label]")?.getAttribute("data-md-label"),y=K.find((k)=>k.label===O);if(y)T(y.value)};return U.addEventListener("kb-select",Z),()=>U.removeEventListener("kb-select",Z)},[K,T]);let N=G?.required&&!B;return S("div",{ref:H,"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:[S("div",{className:"flex items-baseline gap-2 mb-2",children:[S("span",{className:"text-[13px] font-body font-medium text-text-primary",children:$},void 0,!1,void 0,this),W&&S("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),S("div",{className:"space-y-1",children:K.map(({value:U,label:Z})=>S("label",{"data-md":"choice-option","data-md-label":Z,onClick:()=>T(U),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${B===U?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[S("span",{className:`w-4 h-4 rounded-full border-[1.5px] flex items-center justify-center flex-shrink-0 transition-all ${B===U?"border-accent-amber bg-accent-amber":"border-border-strong"}`,children:B===U&&S("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),S("span",{className:"text-[13px] font-body text-text-secondary",children:Z},void 0,!1,void 0,this)]},U,!0,void 0,this))},void 0,!1,void 0,this),S(_1,{show:L,note:q,onToggle:()=>P(!L),onChange:(U)=>X(Q,{...G,note:U})},void 0,!1,void 0,this),N&&S("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 h2({id:Q,label:$,options:Y,required:W}){let{responses:J,setResponse:X}=r0(),K=c0(()=>i0(Y),[Y]),G=J.get(Q),B=G?.value||[],q=G?.note||"",[L,P]=d0(!1),H=u0(null);if(!J.has(Q))X(Q,{id:Q,type:"checkbox",label:$,value:[],options:K.map((U)=>U.value),required:W});let T=(U)=>{let Z=B.includes(U)?B.filter((_)=>_!==U):[...B,U];X(Q,{...G,value:Z})};E0(()=>{let U=H.current;if(!U)return;let Z=(_)=>{let O=_.target.closest("[data-md-label]")?.getAttribute("data-md-label"),y=K.find((k)=>k.label===O);if(y)T(y.value)};return U.addEventListener("kb-select",Z),()=>U.removeEventListener("kb-select",Z)},[K,T]);let N=G?.required&&B.length===0;return S("div",{ref:H,"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:[S("div",{className:"flex items-baseline gap-2 mb-2",children:[S("span",{className:"text-[13px] font-body font-medium text-text-primary",children:$},void 0,!1,void 0,this),W&&S("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),S("div",{className:"space-y-1",children:K.map(({value:U,label:Z})=>{let _=B.includes(U);return S("label",{"data-md":"multichoice-option","data-md-label":Z,onClick:()=>T(U),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${_?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[S("span",{className:`w-4 h-4 rounded flex items-center justify-center flex-shrink-0 transition-all ${_?"bg-accent-amber":"border-[1.5px] border-border-strong"}`,children:_&&S("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:S("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),S("span",{className:"text-[13px] font-body text-text-secondary",children:Z},void 0,!1,void 0,this)]},U,!0,void 0,this)})},void 0,!1,void 0,this),S(_1,{show:L,note:q,onToggle:()=>P(!L),onChange:(U)=>X(Q,{...G,note:U})},void 0,!1,void 0,this),N&&S("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 g2,useState as l0}from"react";import{useAnnotations as o0}from"#canvas/runtime";import{jsxDEV as b}from"react/jsx-dev-runtime";function j2({id:Q,label:$,placeholder:Y,multiline:W,required:J}){let{responses:X,setResponse:K}=o0(),G=X.get(Q),B=G?.value??"",q=G?.note||"",[L,P]=l0(!1),H=g2(null);if(!X.has(Q))K(Q,{id:Q,type:"text",label:$,value:"",required:J});let T=(Z)=>{K(Q,{...G,value:Z})},N=(Z)=>L1(Z,W?60:32),U=G?.required&&!B.trim();return b("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:[b("div",{className:"flex items-baseline gap-2 mb-2",children:[b("span",{className:"text-[13px] font-body font-medium text-text-primary",children:$},void 0,!1,void 0,this),J&&b("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),b("textarea",{ref:H,value:B,onChange:(Z)=>{T(Z.target.value),N(Z.target)},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:(Z)=>N(Z.target),onFocus:(Z)=>N(Z.target)},void 0,!1,void 0,this),b(_1,{show:L,note:q,onToggle:()=>P(!L),onChange:(Z)=>K(Q,{...G,note:Z})},void 0,!1,void 0,this),U&&b("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 V2({id:Q,label:$,min:Y=1,max:W=10,step:J=1,required:X,minLabel:K,maxLabel:G}){let{responses:B,setResponse:q}=o0(),L=B.get(Q),P=L?.value,H=L?.note||"",[T,N]=l0(!1);if(!B.has(Q))q(Q,{id:Q,type:"range",label:$,value:null,required:X});let U=(I)=>{q(Q,{...L,value:I})},Z=P!==null&&P!==void 0,_=Z?P:Math.round((Y+W)/2),C=(_-Y)/(W-Y)*100,O=Math.round((W-Y)/J),y=O<=20,k=L?.required&&!Z;return b("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:[b("div",{className:"flex items-baseline justify-between mb-1",children:[b("div",{className:"flex items-baseline gap-2",children:[b("span",{className:"text-[13px] font-body font-medium text-text-primary",children:$},void 0,!1,void 0,this),X&&b("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),b("span",{className:"flex items-center gap-1.5",children:[b("span",{className:`text-[13px] font-mono ${Z?"text-accent-amber":"text-text-disabled"}`,children:Z?P:"—"},void 0,!1,void 0,this),Z&&b("button",{onClick:()=>q(Q,{...L,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),b("div",{className:"relative h-6 flex items-center",children:[b("div",{className:"absolute left-0 right-0 h-1.5 rounded-full bg-border-medium",children:Z&&b("div",{className:"h-full rounded-full bg-accent-amber transition-all duration-150",style:{width:`${C}%`}},void 0,!1,void 0,this)},void 0,!1,void 0,this),y&&Array.from({length:O+1},(I,p)=>{let m=Y+p*J,d=(m-Y)/(W-Y)*100,v=Z&&m<=P;return b("div",{className:`absolute rounded-full pointer-events-none transition-all duration-150 ${Z&&m===P?"w-2.5 h-2.5 bg-accent-amber":v?"w-1.5 h-1.5 bg-accent-amber":"w-1.5 h-1.5 bg-border-hover"}`,style:{left:`${d}%`,transform:"translate(-50%, -50%)",top:"50%"}},p,!1,void 0,this)}),Z?b("div",{className:"absolute h-5 w-5 rounded-full bg-accent-amber shadow-md pointer-events-none transition-all duration-150",style:{left:`calc(${C}% - 10px)`,borderWidth:"2px",borderStyle:"solid",borderColor:"var(--color-bg-base)"}},void 0,!1,void 0,this):b("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),b("input",{type:"range",min:Y,max:W,step:J,value:_,onChange:(I)=>U(Number(I.target.value)),className:"absolute inset-0 w-full opacity-0 cursor-pointer"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),y&&O<=10?b("div",{className:"flex justify-between -mt-0.5 px-0",children:Array.from({length:O+1},(I,p)=>{let m=Y+p*J;return b("span",{className:`text-[10px] font-mono transition-colors ${Z&&m===P?"text-accent-amber font-medium":"text-text-disabled"}`,style:{minWidth:"1ch",textAlign:"center"},children:m},p,!1,void 0,this)})},void 0,!1,void 0,this):b("div",{className:"flex justify-between -mt-0.5",children:[b("span",{className:"text-[11px] text-text-tertiary font-body",children:K||Y},void 0,!1,void 0,this),b("span",{className:"text-[11px] text-text-tertiary font-body",children:G||W},void 0,!1,void 0,this)]},void 0,!0,void 0,this),b(_1,{show:T,note:H,onToggle:()=>N(!T),onChange:(I)=>q(Q,{...L,note:I})},void 0,!1,void 0,this),k&&b("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 x2,useState as x1}from"react";import{useFeedback as D2}from"#canvas/runtime";import{jsxDEV as D}from"react/jsx-dev-runtime";var p2=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/,E2=/^[A-Za-z_][A-Za-z0-9_]*$/;function c2({id:Q,label:$,env:Y,placeholder:W,required:J}){let[X,K]=x1(""),[G,B]=x1(!1),[q,L]=x1(!l.isShared),[P,H]=x1(null),T=p2.test(Q),N=E2.test(Y),U=!l.isShared;x2(()=>{if(!U||!T){L(!1);return}let y=!0;return S0(Q).then((k)=>{if(y)B(k)}).catch((k)=>{if(y)H(k instanceof Error?k.message:"Could not read secret status")}).finally(()=>{if(y)L(!1)}),()=>{y=!1}},[Q,U,T]);let Z=G?`**${$}**
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
64
  Secret is ready. Field: \`${Q}\`. Environment variable: \`${Y}\`.
65
- `:"";D2(`secret:${Q}`,Z,{label:$,required:J&&U});let _=async()=>{if(!X||!T||!N)return;L(!0),H(null);try{await C0(Q,X),K(""),B(!0)}catch(y){H(y instanceof Error?y.message:"Could not store secret")}finally{L(!1)}},C=async()=>{L(!0),H(null);try{await I0(Q),B(!1)}catch(y){H(y instanceof Error?y.message:"Could not clear secret")}finally{L(!1)}};if(!U)return D("div",{"data-md":"secretinput","data-md-label":$,className:"-mx-4 px-4 py-3 my-1 rounded-lg bg-accent-amber-muted",children:[D("div",{className:"text-[13px] font-body font-medium text-text-primary",children:$},void 0,!1,void 0,this),D("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 O=!T?"Secret field IDs may contain letters, numbers, dots, underscores, and hyphens.":!N?"Environment variable names must use letters, numbers, and underscores and may not start with a number.":null;return D("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:[D("div",{className:"flex items-baseline justify-between gap-3 mb-2",children:[D("div",{className:"flex items-baseline gap-2",children:[D("span",{className:"text-[13px] font-body font-medium text-text-primary",children:$},void 0,!1,void 0,this),J&&D("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),D("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),D("div",{className:"flex gap-2",children:[D("input",{type:"password",value:X,onChange:(y)=>K(y.target.value),onKeyDown:(y)=>{if(y.key==="Enter")y.preventDefault(),_()},placeholder:W||"Paste secret value",autoComplete:"off",spellCheck:!1,disabled:q||!!O,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),D("button",{type:"button",onClick:()=>void _(),disabled:q||!X||!!O,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&&D("button",{type:"button",onClick:()=>void C(),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),D("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),(O||P)&&D("p",{className:"text-[11px] text-accent-red font-body mt-1",children:O||P},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useContext as u2,useState as d2}from"react";import{SessionContext as r2}from"#canvas/runtime";import{jsxDEV as b1}from"react/jsx-dev-runtime";function i2({src:Q,alt:$,caption:Y,width:W,height:J}){let X=u2(r2),[K,G]=d2(!1),B=`/api/image?session=${encodeURIComponent(X)}&path=${encodeURIComponent(Q)}`;if(K)return b1("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 b1("figure",{className:"mt-3 relative","data-md":"image","data-md-src":Q,children:[b1("div",{className:"rounded-md overflow-hidden border border-border-subtle bg-bg-code inline-block",children:b1("img",{src:B,alt:$||Q,onError:()=>G(!0),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&&b1("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 l2}from"react";import{jsxDEV as a0}from"react/jsx-dev-runtime";f.setOptions({gfm:!0,breaks:!1});function o2({children:Q,file:$,__content:Y}){let W=Y??(typeof Q==="string"?Q:String(Q??"")),J=l2(()=>{if(!W)return"";return f.parse(W,{async:!1})},[W]);if(!W)return a0("div",{className:"text-text-tertiary text-tiny mt-3",children:$?`Could not load: ${$}`:"No markdown content"},void 0,!1,void 0,this);return a0("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 F6}from"#canvas/runtime";export{F6 as useFeedback,j2 as UserInput,l5 as Task,Q2 as Table,u5 as Section,c2 as SecretInput,V2 as RangeInput,W2 as Priority,e5 as Note,h2 as MultiChoice,C2 as Mermaid,o2 as Markdown,f0 as Item,i2 as ImageView,L2 as FilePreview,v2 as Diff,s5 as CodeBlock,m2 as Choice,Y2 as Checklist,t5 as Callout};
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};