agent-canvas 0.1.44 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/bin/lib/commands/daemon.ts +3 -6
- package/bin/lib/commands/push.ts +1 -1
- package/bin/lib/daemon-lifecycle.ts +65 -72
- package/bin/lib/helpers.test.ts +1 -0
- package/bin/lib/helpers.ts +30 -74
- package/daemon/build.ts +37 -16
- package/daemon/client/App.tsx +27 -61
- package/daemon/client/CompareView.tsx +4 -4
- package/daemon/client/FileBrowser.tsx +4 -4
- package/daemon/client/FileViewer.tsx +4 -4
- package/daemon/client/OverviewView.tsx +2 -2
- package/daemon/client/RevisionSelect.tsx +1 -1
- package/daemon/client/canvas-runtime.ts +1 -0
- package/daemon/client/clientApi.ts +18 -0
- package/daemon/client/components/index.ts +3 -16
- package/daemon/client/styles.css +4 -457
- package/daemon/dist/annotations-runtime.js +1 -0
- package/daemon/dist/client.css +1 -1
- package/daemon/dist/client.js +76 -76
- package/daemon/dist/components.js +59 -59
- package/daemon/dist/index.html +1 -0
- package/daemon/dist/preact-compat.js +1 -1
- package/daemon/dist/runtime.js +1 -1
- package/daemon/src/components.ts +13 -0
- package/daemon/src/handlers/api.ts +13 -9
- package/daemon/src/handlers/files.ts +2 -3
- package/daemon/src/handlers/static.ts +1 -1
- package/daemon/src/handlers/uploads.ts +2 -3
- package/daemon/src/paths.ts +10 -24
- package/daemon/src/remote-feedback.test.ts +1 -1
- package/daemon/src/remote-feedback.ts +1 -1
- package/daemon/src/secrets-api.test.ts +2 -2
- package/daemon/src/server.ts +11 -10
- package/daemon/src/share-e2e.test.ts +1 -1
- package/daemon/src/share.test.ts +1 -1
- package/daemon/src/share.ts +1 -1
- package/daemon/tsconfig.json +1 -3
- package/package.json +11 -4
- package/.github/dark.png +0 -0
- package/.github/light.png +0 -0
- package/.github/workflows/ci.yml +0 -48
- package/.github/workflows/deploy-worker-prod.yml +0 -19
- package/.github/workflows/deploy-worker-stage.yml +0 -21
- package/.github/workflows/deploy-worker.yml +0 -72
- package/.github/workflows/release.yml +0 -36
- package/CLAUDE.md +0 -86
- package/bun.lock +0 -377
- package/daemon/client/AnnotationEditor.tsx +0 -315
- package/daemon/client/AnnotationProvider.tsx +0 -195
- package/daemon/client/AnnotationSidebar.tsx +0 -627
- package/daemon/client/FileIcon.tsx +0 -76
- package/daemon/client/PlanRenderer.tsx +0 -614
- package/daemon/client/Popover.tsx +0 -350
- package/daemon/client/RenderErrorContext.ts +0 -11
- package/daemon/client/ResponsePreview.tsx +0 -186
- package/daemon/client/SessionContext.tsx +0 -3
- package/daemon/client/annotationContext.ts +0 -114
- package/daemon/client/annotationDom.ts +0 -104
- package/daemon/client/annotationDraft.test.ts +0 -188
- package/daemon/client/annotationDraft.ts +0 -130
- package/daemon/client/compat/preact-all.ts +0 -4
- package/daemon/client/components/Callout.tsx +0 -26
- package/daemon/client/components/Checklist.tsx +0 -37
- package/daemon/client/components/Choice.tsx +0 -176
- package/daemon/client/components/CodeBlock.tsx +0 -35
- package/daemon/client/components/Diff.tsx +0 -65
- package/daemon/client/components/FilePreview.tsx +0 -88
- package/daemon/client/components/Image.tsx +0 -45
- package/daemon/client/components/Markdown.tsx +0 -44
- package/daemon/client/components/Mermaid.tsx +0 -565
- package/daemon/client/components/Note.tsx +0 -14
- package/daemon/client/components/Priority.tsx +0 -19
- package/daemon/client/components/ResponseNote.tsx +0 -19
- package/daemon/client/components/Section.tsx +0 -33
- package/daemon/client/components/Table.tsx +0 -35
- package/daemon/client/components/Task.tsx +0 -76
- package/daemon/client/components/UserInput.tsx +0 -174
- package/daemon/client/components/renderMarkdownChildren.tsx +0 -97
- package/daemon/client/generateMarkdown.ts +0 -273
- package/daemon/client/highlightRange.ts +0 -224
- package/daemon/client/popoverPosition.ts +0 -31
- package/daemon/client/runtime.ts +0 -123
- package/daemon/client/theme.css +0 -66
- package/daemon/client/useTextAnnotation.tsx +0 -188
- package/daemon/client/utils.ts +0 -13
- package/daemon/src/compiler.test.ts +0 -57
- package/daemon/src/compiler.ts +0 -360
- package/daemon/src/handlers/utils.ts +0 -14
- package/daemon/src/router.ts +0 -16
- package/daemon/src/session-secrets.test.ts +0 -83
- package/daemon/src/session.ts +0 -612
- package/daemon/src/watcher.ts +0 -71
- package/daemon/src/websocket.test.ts +0 -99
- package/daemon/src/websocket.ts +0 -211
- package/tsconfig.json +0 -14
- package/workers/canvas-share/README.md +0 -159
- package/workers/canvas-share/oblaka.ts +0 -56
- package/workers/canvas-share/package.json +0 -25
- package/workers/canvas-share/public/assets/.gitkeep +0 -0
- package/workers/canvas-share/public/assets/client.css +0 -2
- package/workers/canvas-share/public/assets/client.js +0 -91
- package/workers/canvas-share/public/assets/components.js +0 -65
- package/workers/canvas-share/public/assets/jsx-runtime.js +0 -3
- package/workers/canvas-share/public/assets/preact-compat.js +0 -1
- package/workers/canvas-share/public/assets/runtime.js +0 -1
- package/workers/canvas-share/public/index.html +0 -385
- package/workers/canvas-share/public/screenshot-dark.png +0 -0
- package/workers/canvas-share/public/screenshot-light.png +0 -0
- package/workers/canvas-share/src/index.test.ts +0 -209
- package/workers/canvas-share/src/index.ts +0 -518
- package/workers/canvas-share/src/types.ts +0 -119
- package/workers/canvas-share/src/util.ts +0 -156
- package/workers/canvas-share/src/validation.ts +0 -160
- package/workers/canvas-share/tsconfig.json +0 -16
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
import{
|
|
2
|
-
]`).replace("lheading",
|
|
3
|
-
`).map((
|
|
4
|
-
`)}var
|
|
5
|
-
`)}}}fences(
|
|
6
|
-
`)}}blockquote(
|
|
1
|
+
import{useFeedback as Yl}from"#canvas/runtime";function nt(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var he=nt();function _t(t){he=t}var pe={exec:()=>null};function A(t,e=""){let n=typeof t=="string"?t:t.source,o={replace:(r,s)=>{let i=typeof s=="string"?s:s.source;return i=i.replace(D.caret,"$1"),n=n.replace(r,i),o},getRegex:()=>new RegExp(n,e)};return o}var $n=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),D={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:(t)=>new RegExp(`^( {0,3}${t})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:(t)=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:(t)=>new RegExp(`^ {0,${Math.min(3,t-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:(t)=>new RegExp(`^ {0,${Math.min(3,t-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:(t)=>new RegExp(`^ {0,${Math.min(3,t-1)}}#`),htmlBeginRegex:(t)=>new RegExp(`^ {0,${Math.min(3,t-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:(t)=>new RegExp(`^ {0,${Math.min(3,t-1)}}>`)},On=/^(?:[ \t]*(?:\n|$))+/,_n=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Hn=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,Te=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,zn=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,rt=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,Ht=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,zt=A(Ht).replace(/bull/g,rt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Dn=A(Ht).replace(/bull/g,rt).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),ot=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Bn=/^[^\n]+/,st=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,qn=A(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",st).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Fn=A(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,rt).getRegex(),ze="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",it=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Gn=A("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",it).replace("tag",ze).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),Dt=A(ot).replace("hr",Te).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ze).getRegex(),Un=A(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",Dt).getRegex(),at={blockquote:Un,code:_n,def:qn,fences:Hn,heading:zn,hr:Te,html:Gn,lheading:zt,list:Fn,newline:On,paragraph:Dt,table:pe,text:Bn},It=A("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",Te).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ze).getRegex(),Wn={...at,lheading:Dn,table:It,paragraph:A(ot).replace("hr",Te).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",It).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",ze).getRegex()},Vn={...at,html:A(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",it).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:pe,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:A(ot).replace("hr",Te).replace("heading",` *#{1,6} *[^
|
|
2
|
+
]`).replace("lheading",zt).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},jn=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Kn=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,Bt=/^( {2,}|\\)\n(?!\s*$)/,Zn=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,xe=/[\p{P}\p{S}]/u,De=/[\s\p{P}\p{S}]/u,lt=/[^\s\p{P}\p{S}]/u,Yn=A(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,De).getRegex(),qt=/(?!~)[\p{P}\p{S}]/u,Xn=/(?!~)[\s\p{P}\p{S}]/u,Qn=/(?:[^\s\p{P}\p{S}]|~)/u,Jn=A(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",$n?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Ft=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,er=A(Ft,"u").replace(/punct/g,xe).getRegex(),tr=A(Ft,"u").replace(/punct/g,qt).getRegex(),Gt="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",nr=A(Gt,"gu").replace(/notPunctSpace/g,lt).replace(/punctSpace/g,De).replace(/punct/g,xe).getRegex(),rr=A(Gt,"gu").replace(/notPunctSpace/g,Qn).replace(/punctSpace/g,Xn).replace(/punct/g,qt).getRegex(),or=A("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,lt).replace(/punctSpace/g,De).replace(/punct/g,xe).getRegex(),sr=A(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,xe).getRegex(),ir="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",ar=A(ir,"gu").replace(/notPunctSpace/g,lt).replace(/punctSpace/g,De).replace(/punct/g,xe).getRegex(),lr=A(/\\(punct)/,"gu").replace(/punct/g,xe).getRegex(),cr=A(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),ur=A(it).replace("(?:-->|$)","-->").getRegex(),dr=A("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",ur).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),Oe=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,pr=A(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",Oe).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Ut=A(/^!?\[(label)\]\[(ref)\]/).replace("label",Oe).replace("ref",st).getRegex(),Wt=A(/^!?\[(ref)\](?:\[\])?/).replace("ref",st).getRegex(),fr=A("reflink|nolink(?!\\()","g").replace("reflink",Ut).replace("nolink",Wt).getRegex(),Lt=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,ct={_backpedal:pe,anyPunctuation:lr,autolink:cr,blockSkip:Jn,br:Bt,code:Kn,del:pe,delLDelim:pe,delRDelim:pe,emStrongLDelim:er,emStrongRDelimAst:nr,emStrongRDelimUnd:or,escape:jn,link:pr,nolink:Wt,punctuation:Yn,reflink:Ut,reflinkSearch:fr,tag:dr,text:Zn,url:pe},hr={...ct,link:A(/^!?\[(label)\]\((.*?)\)/).replace("label",Oe).getRegex(),reflink:A(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",Oe).getRegex()},tt={...ct,emStrongRDelimAst:rr,emStrongLDelim:tr,delLDelim:sr,delRDelim:ar,url:A(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",Lt).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:A(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",Lt).getRegex()},gr={...tt,br:A(Bt).replace("{2,}","*").getRegex(),text:A(tt.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},$e={normal:at,gfm:Wn,pedantic:Vn},Se={normal:ct,gfm:tt,breaks:gr,pedantic:hr},mr={"&":"&","<":"<",">":">",'"':""","'":"'"},Pt=(t)=>mr[t];function te(t,e){if(e){if(D.escapeTest.test(t))return t.replace(D.escapeReplace,Pt)}else if(D.escapeTestNoEncode.test(t))return t.replace(D.escapeReplaceNoEncode,Pt);return t}function Mt(t){try{t=encodeURI(t).replace(D.percentDecode,"%")}catch{return null}return t}function $t(t,e){let n=t.replace(D.findPipe,(s,i,l)=>{let a=!1,c=i;for(;--c>=0&&l[c]==="\\";)a=!a;return a?"|":" |"}),o=n.split(D.splitPipe),r=0;if(o[0].trim()||o.shift(),o.length>0&&!o.at(-1)?.trim()&&o.pop(),e)if(o.length>e)o.splice(e);else for(;o.length<e;)o.push("");for(;r<o.length;r++)o[r]=o[r].trim().replace(D.slashPipe,"|");return o}function Ae(t,e,n){let o=t.length;if(o===0)return"";let r=0;for(;r<o;){let s=t.charAt(o-r-1);if(s===e&&!n)r++;else if(s!==e&&n)r++;else break}return t.slice(0,o-r)}function xr(t,e){if(t.indexOf(e[1])===-1)return-1;let n=0;for(let o=0;o<t.length;o++)if(t[o]==="\\")o++;else if(t[o]===e[0])n++;else if(t[o]===e[1]&&(n--,n<0))return o;return n>0?-2:-1}function br(t,e=0){let n=e,o="";for(let r of t)if(r==="\t"){let s=4-n%4;o+=" ".repeat(s),n+=s}else o+=r,n++;return o}function Ot(t,e,n,o,r){let s=e.href,i=e.title||null,l=t[1].replace(r.other.outputLinkReplace,"$1");o.state.inLink=!0;let a={type:t[0].charAt(0)==="!"?"image":"link",raw:n,href:s,title:i,text:l,tokens:o.inlineTokens(l)};return o.state.inLink=!1,a}function yr(t,e,n){let o=t.match(n.other.indentCodeCompensation);if(o===null)return e;let r=o[1];return e.split(`
|
|
3
|
+
`).map((s)=>{let i=s.match(n.other.beginningSpace);if(i===null)return s;let[l]=i;return l.length>=r.length?s.slice(r.length):s}).join(`
|
|
4
|
+
`)}var _e=class{options;rules;lexer;constructor(t){this.options=t||he}space(t){let e=this.rules.block.newline.exec(t);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(t){let e=this.rules.block.code.exec(t);if(e){let n=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?n:Ae(n,`
|
|
5
|
+
`)}}}fences(t){let e=this.rules.block.fences.exec(t);if(e){let n=e[0],o=yr(n,e[3]||"",this.rules);return{type:"code",raw:n,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:o}}}heading(t){let e=this.rules.block.heading.exec(t);if(e){let n=e[2].trim();if(this.rules.other.endingHash.test(n)){let o=Ae(n,"#");(this.options.pedantic||!o||this.rules.other.endingSpaceChar.test(o))&&(n=o.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(t){let e=this.rules.block.hr.exec(t);if(e)return{type:"hr",raw:Ae(e[0],`
|
|
6
|
+
`)}}blockquote(t){let e=this.rules.block.blockquote.exec(t);if(e){let n=Ae(e[0],`
|
|
7
7
|
`).split(`
|
|
8
|
-
`),
|
|
9
|
-
`),
|
|
10
|
-
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");
|
|
11
|
-
${
|
|
12
|
-
${
|
|
13
|
-
`+
|
|
14
|
-
`),
|
|
15
|
-
`+
|
|
16
|
-
`),
|
|
17
|
-
`);continue}}return{type:"blockquote",raw:
|
|
18
|
-
`,1)[0]
|
|
19
|
-
`,1)[0],
|
|
20
|
-
`,
|
|
21
|
-
`,1)[0],
|
|
22
|
-
`+
|
|
23
|
-
`+
|
|
24
|
-
`,
|
|
25
|
-
`):[],
|
|
26
|
-
|
|
27
|
-
`),this.blockTokens(
|
|
28
|
-
`:
|
|
8
|
+
`),o="",r="",s=[];for(;n.length>0;){let i=!1,l=[],a;for(a=0;a<n.length;a++)if(this.rules.other.blockquoteStart.test(n[a]))l.push(n[a]),i=!0;else if(!i)l.push(n[a]);else break;n=n.slice(a);let c=l.join(`
|
|
9
|
+
`),u=c.replace(this.rules.other.blockquoteSetextReplace,`
|
|
10
|
+
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");o=o?`${o}
|
|
11
|
+
${c}`:c,r=r?`${r}
|
|
12
|
+
${u}`:u;let p=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(u,s,!0),this.lexer.state.top=p,n.length===0)break;let g=s.at(-1);if(g?.type==="code")break;if(g?.type==="blockquote"){let h=g,d=h.raw+`
|
|
13
|
+
`+n.join(`
|
|
14
|
+
`),f=this.blockquote(d);s[s.length-1]=f,o=o.substring(0,o.length-h.raw.length)+f.raw,r=r.substring(0,r.length-h.text.length)+f.text;break}else if(g?.type==="list"){let h=g,d=h.raw+`
|
|
15
|
+
`+n.join(`
|
|
16
|
+
`),f=this.list(d);s[s.length-1]=f,o=o.substring(0,o.length-g.raw.length)+f.raw,r=r.substring(0,r.length-h.raw.length)+f.raw,n=d.substring(s.at(-1).raw.length).split(`
|
|
17
|
+
`);continue}}return{type:"blockquote",raw:o,tokens:s,text:r}}}list(t){let e=this.rules.block.list.exec(t);if(e){let n=e[1].trim(),o=n.length>1,r={type:"list",raw:"",ordered:o,start:o?+n.slice(0,-1):"",loose:!1,items:[]};n=o?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=o?n:"[*+-]");let s=this.rules.other.listItemRegex(n),i=!1;for(;t;){let a=!1,c="",u="";if(!(e=s.exec(t))||this.rules.block.hr.test(t))break;c=e[0],t=t.substring(c.length);let p=br(e[2].split(`
|
|
18
|
+
`,1)[0],e[1].length),g=t.split(`
|
|
19
|
+
`,1)[0],h=!p.trim(),d=0;if(this.options.pedantic?(d=2,u=p.trimStart()):h?d=e[1].length+1:(d=p.search(this.rules.other.nonSpaceChar),d=d>4?1:d,u=p.slice(d),d+=e[1].length),h&&this.rules.other.blankLine.test(g)&&(c+=g+`
|
|
20
|
+
`,t=t.substring(g.length+1),a=!0),!a){let f=this.rules.other.nextBulletRegex(d),m=this.rules.other.hrRegex(d),b=this.rules.other.fencesBeginRegex(d),R=this.rules.other.headingBeginRegex(d),v=this.rules.other.htmlBeginRegex(d),w=this.rules.other.blockquoteBeginRegex(d);for(;t;){let N=t.split(`
|
|
21
|
+
`,1)[0],L;if(g=N,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),L=g):L=g.replace(this.rules.other.tabCharGlobal," "),b.test(g)||R.test(g)||v.test(g)||w.test(g)||f.test(g)||m.test(g))break;if(L.search(this.rules.other.nonSpaceChar)>=d||!g.trim())u+=`
|
|
22
|
+
`+L.slice(d);else{if(h||p.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||b.test(p)||R.test(p)||m.test(p))break;u+=`
|
|
23
|
+
`+g}h=!g.trim(),c+=N+`
|
|
24
|
+
`,t=t.substring(N.length+1),p=L.slice(d)}}r.loose||(i?r.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(i=!0)),r.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(u),loose:!1,text:u,tokens:[]}),r.raw+=c}let l=r.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let a of r.items){if(this.lexer.state.top=!1,a.tokens=this.lexer.blockTokens(a.text,[]),a.task){if(a.text=a.text.replace(this.rules.other.listReplaceTask,""),a.tokens[0]?.type==="text"||a.tokens[0]?.type==="paragraph"){a.tokens[0].raw=a.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),a.tokens[0].text=a.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let u=this.lexer.inlineQueue.length-1;u>=0;u--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[u].src)){this.lexer.inlineQueue[u].src=this.lexer.inlineQueue[u].src.replace(this.rules.other.listReplaceTask,"");break}}let c=this.rules.other.listTaskCheckbox.exec(a.raw);if(c){let u={type:"checkbox",raw:c[0]+" ",checked:c[0]!=="[ ]"};a.checked=u.checked,r.loose?a.tokens[0]&&["paragraph","text"].includes(a.tokens[0].type)&&"tokens"in a.tokens[0]&&a.tokens[0].tokens?(a.tokens[0].raw=u.raw+a.tokens[0].raw,a.tokens[0].text=u.raw+a.tokens[0].text,a.tokens[0].tokens.unshift(u)):a.tokens.unshift({type:"paragraph",raw:u.raw,text:u.raw,tokens:[u]}):a.tokens.unshift(u)}}if(!r.loose){let c=a.tokens.filter((p)=>p.type==="space"),u=c.length>0&&c.some((p)=>this.rules.other.anyLine.test(p.raw));r.loose=u}}if(r.loose)for(let a of r.items){a.loose=!0;for(let c of a.tokens)c.type==="text"&&(c.type="paragraph")}return r}}html(t){let e=this.rules.block.html.exec(t);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(t){let e=this.rules.block.def.exec(t);if(e){let n=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),o=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:n,raw:e[0],href:o,title:r}}}table(t){let e=this.rules.block.table.exec(t);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let n=$t(e[1]),o=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
25
|
+
`):[],s={type:"table",raw:e[0],header:[],align:[],rows:[]};if(n.length===o.length){for(let i of o)this.rules.other.tableAlignRight.test(i)?s.align.push("right"):this.rules.other.tableAlignCenter.test(i)?s.align.push("center"):this.rules.other.tableAlignLeft.test(i)?s.align.push("left"):s.align.push(null);for(let i=0;i<n.length;i++)s.header.push({text:n[i],tokens:this.lexer.inline(n[i]),header:!0,align:s.align[i]});for(let i of r)s.rows.push($t(i,s.header.length).map((l,a)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:s.align[a]})));return s}}lheading(t){let e=this.rules.block.lheading.exec(t);if(e){let n=e[1].trim();return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(t){let e=this.rules.block.paragraph.exec(t);if(e){let n=e[1].charAt(e[1].length-1)===`
|
|
26
|
+
`?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:n,tokens:this.lexer.inline(n)}}}text(t){let e=this.rules.block.text.exec(t);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(t){let e=this.rules.inline.escape.exec(t);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(t){let e=this.rules.inline.tag.exec(t);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(t){let e=this.rules.inline.link.exec(t);if(e){let n=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let s=Ae(n.slice(0,-1),"\\");if((n.length-s.length)%2===0)return}else{let s=xr(e[2],"()");if(s===-2)return;if(s>-1){let i=(e[0].indexOf("!")===0?5:4)+e[1].length+s;e[2]=e[2].substring(0,s),e[0]=e[0].substring(0,i).trim(),e[3]=""}}let o=e[2],r="";if(this.options.pedantic){let s=this.rules.other.pedanticHrefTitle.exec(o);s&&(o=s[1],r=s[3])}else r=e[3]?e[3].slice(1,-1):"";return o=o.trim(),this.rules.other.startAngleBracket.test(o)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?o=o.slice(1):o=o.slice(1,-1)),Ot(e,{href:o&&o.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(t,e){let n;if((n=this.rules.inline.reflink.exec(t))||(n=this.rules.inline.nolink.exec(t))){let o=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=e[o.toLowerCase()];if(!r){let s=n[0].charAt(0);return{type:"text",raw:s,text:s}}return Ot(n,r,n[0],this.lexer,this.rules)}}emStrong(t,e,n=""){let o=this.rules.inline.emStrongLDelim.exec(t);if(!o||!o[1]&&!o[2]&&!o[3]&&!o[4]||o[4]&&n.match(this.rules.other.unicodeAlphaNumeric))return;if(!(o[1]||o[3])||!n||this.rules.inline.punctuation.exec(n)){let r=[...o[0]].length-1,s,i,l=r,a=0,c=o[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,e=e.slice(-1*t.length+r);(o=c.exec(e))!==null;){if(s=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!s)continue;if(i=[...s].length,o[3]||o[4]){l+=i;continue}else if((o[5]||o[6])&&r%3&&!((r+i)%3)){a+=i;continue}if(l-=i,l>0)continue;i=Math.min(i,i+l+a);let u=[...o[0]][0].length,p=t.slice(0,r+o.index+u+i);if(Math.min(r,i)%2){let h=p.slice(1,-1);return{type:"em",raw:p,text:h,tokens:this.lexer.inlineTokens(h)}}let g=p.slice(2,-2);return{type:"strong",raw:p,text:g,tokens:this.lexer.inlineTokens(g)}}}}codespan(t){let e=this.rules.inline.code.exec(t);if(e){let n=e[2].replace(this.rules.other.newLineCharGlobal," "),o=this.rules.other.nonSpaceChar.test(n),r=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return o&&r&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:e[0],text:n}}}br(t){let e=this.rules.inline.br.exec(t);if(e)return{type:"br",raw:e[0]}}del(t,e,n=""){let o=this.rules.inline.delLDelim.exec(t);if(!o)return;if(!o[1]||!n||this.rules.inline.punctuation.exec(n)){let r=[...o[0]].length-1,s,i,l=r,a=this.rules.inline.delRDelim;for(a.lastIndex=0,e=e.slice(-1*t.length+r);(o=a.exec(e))!==null;){if(s=o[1]||o[2]||o[3]||o[4]||o[5]||o[6],!s||(i=[...s].length,i!==r))continue;if(o[3]||o[4]){l+=i;continue}if(l-=i,l>0)continue;i=Math.min(i,i+l);let c=[...o[0]][0].length,u=t.slice(0,r+o.index+c+i),p=u.slice(r,-r);return{type:"del",raw:u,text:p,tokens:this.lexer.inlineTokens(p)}}}}autolink(t){let e=this.rules.inline.autolink.exec(t);if(e){let n,o;return e[2]==="@"?(n=e[1],o="mailto:"+n):(n=e[1],o=n),{type:"link",raw:e[0],text:n,href:o,tokens:[{type:"text",raw:n,text:n}]}}}url(t){let e;if(e=this.rules.inline.url.exec(t)){let n,o;if(e[2]==="@")n=e[0],o="mailto:"+n;else{let r;do r=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(r!==e[0]);n=e[0],e[1]==="www."?o="http://"+e[0]:o=e[0]}return{type:"link",raw:e[0],text:n,href:o,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(t){let e=this.rules.inline.text.exec(t);if(e){let n=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:n}}}},K=class t{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||he,this.options.tokenizer=this.options.tokenizer||new _e,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:D,block:$e.normal,inline:Se.normal};this.options.pedantic?(n.block=$e.pedantic,n.inline=Se.pedantic):this.options.gfm&&(n.block=$e.gfm,this.options.breaks?n.inline=Se.breaks:n.inline=Se.gfm),this.tokenizer.rules=n}static get rules(){return{block:$e,inline:Se}}static lex(e,n){return new t(n).lex(e)}static lexInline(e,n){return new t(n).inlineTokens(e)}lex(e){e=e.replace(D.carriageReturn,`
|
|
27
|
+
`),this.blockTokens(e,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let o=this.inlineQueue[n];this.inlineTokens(o.src,o.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,n=[],o=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(D.tabCharGlobal," ").replace(D.spaceLine,""));e;){let r;if(this.options.extensions?.block?.some((i)=>(r=i.call({lexer:this},e,n))?(e=e.substring(r.raw.length),n.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let i=n.at(-1);r.raw.length===1&&i!==void 0?i.raw+=`
|
|
28
|
+
`:n.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let i=n.at(-1);i?.type==="paragraph"||i?.type==="text"?(i.raw+=(i.raw.endsWith(`
|
|
29
29
|
`)?"":`
|
|
30
|
-
`)+
|
|
31
|
-
`+
|
|
30
|
+
`)+r.raw,i.text+=`
|
|
31
|
+
`+r.text,this.inlineQueue.at(-1).src=i.text):n.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let i=n.at(-1);i?.type==="paragraph"||i?.type==="text"?(i.raw+=(i.raw.endsWith(`
|
|
32
32
|
`)?"":`
|
|
33
|
-
`)+
|
|
34
|
-
`+
|
|
33
|
+
`)+r.raw,i.text+=`
|
|
34
|
+
`+r.raw,this.inlineQueue.at(-1).src=i.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},n.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),n.push(r);continue}let s=e;if(this.options.extensions?.startBlock){let i=1/0,l=e.slice(1),a;this.options.extensions.startBlock.forEach((c)=>{a=c.call({lexer:this},l),typeof a=="number"&&a>=0&&(i=Math.min(i,a))}),i<1/0&&i>=0&&(s=e.substring(0,i+1))}if(this.state.top&&(r=this.tokenizer.paragraph(s))){let i=n.at(-1);o&&i?.type==="paragraph"?(i.raw+=(i.raw.endsWith(`
|
|
35
35
|
`)?"":`
|
|
36
|
-
`)+
|
|
37
|
-
`+
|
|
36
|
+
`)+r.raw,i.text+=`
|
|
37
|
+
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):n.push(r),o=s.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let i=n.at(-1);i?.type==="text"?(i.raw+=(i.raw.endsWith(`
|
|
38
38
|
`)?"":`
|
|
39
|
-
`)+
|
|
40
|
-
`+
|
|
41
|
-
`;return
|
|
42
|
-
`:"<pre><code>"+(
|
|
43
|
-
`}blockquote({tokens:
|
|
44
|
-
${this.parser.parse(
|
|
45
|
-
`}html({text:
|
|
46
|
-
`}hr(
|
|
47
|
-
`}list(
|
|
48
|
-
`+
|
|
49
|
-
`}listitem(
|
|
50
|
-
`}checkbox({checked:
|
|
51
|
-
`}table(
|
|
39
|
+
`)+r.raw,i.text+=`
|
|
40
|
+
`+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=i.text):n.push(r);continue}if(e){let i="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(i);break}else throw Error(i)}}return this.state.top=!0,n}inline(e,n=[]){return this.inlineQueue.push({src:e,tokens:n}),n}inlineTokens(e,n=[]){this.tokenizer.lexer=this;let o=e,r=null;if(this.tokens.links){let a=Object.keys(this.tokens.links);if(a.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(o))!==null;)a.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(o=o.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+o.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(o))!==null;)o=o.slice(0,r.index)+"++"+o.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let s;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(o))!==null;)s=r[2]?r[2].length:0,o=o.slice(0,r.index+s)+"["+"a".repeat(r[0].length-s-2)+"]"+o.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);o=this.options.hooks?.emStrongMask?.call({lexer:this},o)??o;let i=!1,l="";for(;e;){i||(l=""),i=!1;let a;if(this.options.extensions?.inline?.some((u)=>(a=u.call({lexer:this},e,n))?(e=e.substring(a.raw.length),n.push(a),!0):!1))continue;if(a=this.tokenizer.escape(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.tag(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.link(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(a.raw.length);let u=n.at(-1);a.type==="text"&&u?.type==="text"?(u.raw+=a.raw,u.text+=a.text):n.push(a);continue}if(a=this.tokenizer.emStrong(e,o,l)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.codespan(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.br(e)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.del(e,o,l)){e=e.substring(a.raw.length),n.push(a);continue}if(a=this.tokenizer.autolink(e)){e=e.substring(a.raw.length),n.push(a);continue}if(!this.state.inLink&&(a=this.tokenizer.url(e))){e=e.substring(a.raw.length),n.push(a);continue}let c=e;if(this.options.extensions?.startInline){let u=1/0,p=e.slice(1),g;this.options.extensions.startInline.forEach((h)=>{g=h.call({lexer:this},p),typeof g=="number"&&g>=0&&(u=Math.min(u,g))}),u<1/0&&u>=0&&(c=e.substring(0,u+1))}if(a=this.tokenizer.inlineText(c)){e=e.substring(a.raw.length),a.raw.slice(-1)!=="_"&&(l=a.raw.slice(-1)),i=!0;let u=n.at(-1);u?.type==="text"?(u.raw+=a.raw,u.text+=a.text):n.push(a);continue}if(e){let u="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(u);break}else throw Error(u)}}return n}},He=class{options;parser;constructor(t){this.options=t||he}space(t){return""}code({text:t,lang:e,escaped:n}){let o=(e||"").match(D.notSpaceStart)?.[0],r=t.replace(D.endingNewline,"")+`
|
|
41
|
+
`;return o?'<pre><code class="language-'+te(o)+'">'+(n?r:te(r,!0))+`</code></pre>
|
|
42
|
+
`:"<pre><code>"+(n?r:te(r,!0))+`</code></pre>
|
|
43
|
+
`}blockquote({tokens:t}){return`<blockquote>
|
|
44
|
+
${this.parser.parse(t)}</blockquote>
|
|
45
|
+
`}html({text:t}){return t}def(t){return""}heading({tokens:t,depth:e}){return`<h${e}>${this.parser.parseInline(t)}</h${e}>
|
|
46
|
+
`}hr(t){return`<hr>
|
|
47
|
+
`}list(t){let{ordered:e,start:n}=t,o="";for(let i=0;i<t.items.length;i++){let l=t.items[i];o+=this.listitem(l)}let r=e?"ol":"ul",s=e&&n!==1?' start="'+n+'"':"";return"<"+r+s+`>
|
|
48
|
+
`+o+"</"+r+`>
|
|
49
|
+
`}listitem(t){return`<li>${this.parser.parse(t.tokens)}</li>
|
|
50
|
+
`}checkbox({checked:t}){return"<input "+(t?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:t}){return`<p>${this.parser.parseInline(t)}</p>
|
|
51
|
+
`}table(t){let e="",n="";for(let r=0;r<t.header.length;r++)n+=this.tablecell(t.header[r]);e+=this.tablerow({text:n});let o="";for(let r=0;r<t.rows.length;r++){let s=t.rows[r];n="";for(let i=0;i<s.length;i++)n+=this.tablecell(s[i]);o+=this.tablerow({text:n})}return o&&(o=`<tbody>${o}</tbody>`),`<table>
|
|
52
52
|
<thead>
|
|
53
|
-
|
|
54
|
-
`+
|
|
55
|
-
`}tablerow({text:
|
|
56
|
-
${
|
|
57
|
-
`}tablecell(
|
|
58
|
-
`}strong({tokens:
|
|
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(`
|
|
60
|
-
`).
|
|
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
|
-
`),
|
|
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?`**${$}**
|
|
64
|
-
Secret is ready. Field: \`${
|
|
65
|
-
`:"";
|
|
53
|
+
`+e+`</thead>
|
|
54
|
+
`+o+`</table>
|
|
55
|
+
`}tablerow({text:t}){return`<tr>
|
|
56
|
+
${t}</tr>
|
|
57
|
+
`}tablecell(t){let e=this.parser.parseInline(t.tokens),n=t.header?"th":"td";return(t.align?`<${n} align="${t.align}">`:`<${n}>`)+e+`</${n}>
|
|
58
|
+
`}strong({tokens:t}){return`<strong>${this.parser.parseInline(t)}</strong>`}em({tokens:t}){return`<em>${this.parser.parseInline(t)}</em>`}codespan({text:t}){return`<code>${te(t,!0)}</code>`}br(t){return"<br>"}del({tokens:t}){return`<del>${this.parser.parseInline(t)}</del>`}link({href:t,title:e,tokens:n}){let o=this.parser.parseInline(n),r=Mt(t);if(r===null)return o;t=r;let s='<a href="'+t+'"';return e&&(s+=' title="'+te(e)+'"'),s+=">"+o+"</a>",s}image({href:t,title:e,text:n,tokens:o}){o&&(n=this.parser.parseInline(o,this.parser.textRenderer));let r=Mt(t);if(r===null)return te(n);t=r;let s=`<img src="${t}" alt="${te(n)}"`;return e&&(s+=` title="${te(e)}"`),s+=">",s}text(t){return"tokens"in t&&t.tokens?this.parser.parseInline(t.tokens):("escaped"in t)&&t.escaped?t.text:te(t.text)}},ut=class{strong({text:t}){return t}em({text:t}){return t}codespan({text:t}){return t}del({text:t}){return t}html({text:t}){return t}text({text:t}){return t}link({text:t}){return""+t}image({text:t}){return""+t}br(){return""}checkbox({raw:t}){return t}},Z=class t{options;renderer;textRenderer;constructor(e){this.options=e||he,this.options.renderer=this.options.renderer||new He,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new ut}static parse(e,n){return new t(n).parse(e)}static parseInline(e,n){return new t(n).parseInline(e)}parse(e){this.renderer.parser=this;let n="";for(let o=0;o<e.length;o++){let r=e[o];if(this.options.extensions?.renderers?.[r.type]){let i=r,l=this.options.extensions.renderers[i.type].call({parser:this},i);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(i.type)){n+=l||"";continue}}let s=r;switch(s.type){case"space":{n+=this.renderer.space(s);break}case"hr":{n+=this.renderer.hr(s);break}case"heading":{n+=this.renderer.heading(s);break}case"code":{n+=this.renderer.code(s);break}case"table":{n+=this.renderer.table(s);break}case"blockquote":{n+=this.renderer.blockquote(s);break}case"list":{n+=this.renderer.list(s);break}case"checkbox":{n+=this.renderer.checkbox(s);break}case"html":{n+=this.renderer.html(s);break}case"def":{n+=this.renderer.def(s);break}case"paragraph":{n+=this.renderer.paragraph(s);break}case"text":{n+=this.renderer.text(s);break}default:{let i='Token with "'+s.type+'" type was not found.';if(this.options.silent)return console.error(i),"";throw Error(i)}}}return n}parseInline(e,n=this.renderer){this.renderer.parser=this;let o="";for(let r=0;r<e.length;r++){let s=e[r];if(this.options.extensions?.renderers?.[s.type]){let l=this.options.extensions.renderers[s.type].call({parser:this},s);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(s.type)){o+=l||"";continue}}let i=s;switch(i.type){case"escape":{o+=n.text(i);break}case"html":{o+=n.html(i);break}case"link":{o+=n.link(i);break}case"image":{o+=n.image(i);break}case"checkbox":{o+=n.checkbox(i);break}case"strong":{o+=n.strong(i);break}case"em":{o+=n.em(i);break}case"codespan":{o+=n.codespan(i);break}case"br":{o+=n.br(i);break}case"del":{o+=n.del(i);break}case"text":{o+=n.text(i);break}default:{let l='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw Error(l)}}}return o}},Re=class{options;block;constructor(t){this.options=t||he}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(t){return t}postprocess(t){return t}processAllTokens(t){return t}emStrongMask(t){return t}provideLexer(t=this.block){return t?K.lex:K.lexInline}provideParser(t=this.block){return t?Z.parse:Z.parseInline}},kr=class{defaults=nt();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Z;Renderer=He;TextRenderer=ut;Lexer=K;Tokenizer=_e;Hooks=Re;constructor(...t){this.use(...t)}walkTokens(t,e){let n=[];for(let o of t)switch(n=n.concat(e.call(this,o)),o.type){case"table":{let r=o;for(let s of r.header)n=n.concat(this.walkTokens(s.tokens,e));for(let s of r.rows)for(let i of s)n=n.concat(this.walkTokens(i.tokens,e));break}case"list":{let r=o;n=n.concat(this.walkTokens(r.items,e));break}default:{let r=o;this.defaults.extensions?.childTokens?.[r.type]?this.defaults.extensions.childTokens[r.type].forEach((s)=>{let i=r[s].flat(1/0);n=n.concat(this.walkTokens(i,e))}):r.tokens&&(n=n.concat(this.walkTokens(r.tokens,e)))}}return n}use(...t){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return t.forEach((n)=>{let o={...n};if(o.async=this.defaults.async||o.async||!1,n.extensions&&(n.extensions.forEach((r)=>{if(!r.name)throw Error("extension name required");if("renderer"in r){let s=e.renderers[r.name];s?e.renderers[r.name]=function(...i){let l=r.renderer.apply(this,i);return l===!1&&(l=s.apply(this,i)),l}:e.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw Error("extension level must be 'block' or 'inline'");let s=e[r.level];s?s.unshift(r.tokenizer):e[r.level]=[r.tokenizer],r.start&&(r.level==="block"?e.startBlock?e.startBlock.push(r.start):e.startBlock=[r.start]:r.level==="inline"&&(e.startInline?e.startInline.push(r.start):e.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(e.childTokens[r.name]=r.childTokens)}),o.extensions=e),n.renderer){let r=this.defaults.renderer||new He(this.defaults);for(let s in n.renderer){if(!(s in r))throw Error(`renderer '${s}' does not exist`);if(["options","parser"].includes(s))continue;let i=s,l=n.renderer[i],a=r[i];r[i]=(...c)=>{let u=l.apply(r,c);return u===!1&&(u=a.apply(r,c)),u||""}}o.renderer=r}if(n.tokenizer){let r=this.defaults.tokenizer||new _e(this.defaults);for(let s in n.tokenizer){if(!(s in r))throw Error(`tokenizer '${s}' does not exist`);if(["options","rules","lexer"].includes(s))continue;let i=s,l=n.tokenizer[i],a=r[i];r[i]=(...c)=>{let u=l.apply(r,c);return u===!1&&(u=a.apply(r,c)),u}}o.tokenizer=r}if(n.hooks){let r=this.defaults.hooks||new Re;for(let s in n.hooks){if(!(s in r))throw Error(`hook '${s}' does not exist`);if(["options","block"].includes(s))continue;let i=s,l=n.hooks[i],a=r[i];Re.passThroughHooks.has(s)?r[i]=(c)=>{if(this.defaults.async&&Re.passThroughHooksRespectAsync.has(s))return(async()=>{let p=await l.call(r,c);return a.call(r,p)})();let u=l.call(r,c);return a.call(r,u)}:r[i]=(...c)=>{if(this.defaults.async)return(async()=>{let p=await l.apply(r,c);return p===!1&&(p=await a.apply(r,c)),p})();let u=l.apply(r,c);return u===!1&&(u=a.apply(r,c)),u}}o.hooks=r}if(n.walkTokens){let r=this.defaults.walkTokens,s=n.walkTokens;o.walkTokens=function(i){let l=[];return l.push(s.call(this,i)),r&&(l=l.concat(r.call(this,i))),l}}this.defaults={...this.defaults,...o}}),this}setOptions(t){return this.defaults={...this.defaults,...t},this}lexer(t,e){return K.lex(t,e??this.defaults)}parser(t,e){return Z.parse(t,e??this.defaults)}parseMarkdown(t){return(e,n)=>{let o={...n},r={...this.defaults,...o},s=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&o.async===!1)return s(Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return s(Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return s(Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=t),r.async)return(async()=>{let i=r.hooks?await r.hooks.preprocess(e):e,l=await(r.hooks?await r.hooks.provideLexer(t):t?K.lex:K.lexInline)(i,r),a=r.hooks?await r.hooks.processAllTokens(l):l;r.walkTokens&&await Promise.all(this.walkTokens(a,r.walkTokens));let c=await(r.hooks?await r.hooks.provideParser(t):t?Z.parse:Z.parseInline)(a,r);return r.hooks?await r.hooks.postprocess(c):c})().catch(s);try{r.hooks&&(e=r.hooks.preprocess(e));let i=(r.hooks?r.hooks.provideLexer(t):t?K.lex:K.lexInline)(e,r);r.hooks&&(i=r.hooks.processAllTokens(i)),r.walkTokens&&this.walkTokens(i,r.walkTokens);let l=(r.hooks?r.hooks.provideParser(t):t?Z.parse:Z.parseInline)(i,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(i){return s(i)}}}onError(t,e){return(n)=>{if(n.message+=`
|
|
59
|
+
Please report this to https://github.com/markedjs/marked.`,t){let o="<p>An error occurred:</p><pre>"+te(n.message+"",!0)+"</pre>";return e?Promise.resolve(o):o}if(e)return Promise.reject(n);throw n}}},fe=new kr;function S(t,e){return fe.parse(t,e)}S.options=S.setOptions=function(t){return fe.setOptions(t),S.defaults=fe.defaults,_t(S.defaults),S};S.getDefaults=nt;S.defaults=he;S.use=function(...t){return fe.use(...t),S.defaults=fe.defaults,_t(S.defaults),S};S.walkTokens=function(t,e){return fe.walkTokens(t,e)};S.parseInline=fe.parseInline;S.Parser=Z;S.parser=Z.parse;S.Renderer=He;S.TextRenderer=ut;S.Lexer=K;S.lexer=K.lex;S.Tokenizer=_e;S.Hooks=Re;S.parse=S;var{options:rs,setOptions:os,use:ss,walkTokens:is,parseInline:as}=S;var ls=Z.parse,cs=K.lex;import Vt from"react";import{jsxDEV as dt}from"react/jsx-dev-runtime";S.setOptions({gfm:!0,breaks:!1});var vr=new Set(["a","abbr","b","br","code","del","em","i","kbd","mark","q","s","small","span","strong","sub","sup","time","u"]),wr=new Set(["Priority"]);function Sr(t){if(typeof t==="string"||typeof t==="number")return!0;if(!Vt.isValidElement(t))return!1;if(typeof t!=="object"||t===null||!("type"in t))return!1;let e=t.type;if(typeof e==="string")return vr.has(e);if(typeof e==="function"){let n="displayName"in e&&typeof e.displayName==="string"?e.displayName:e.name;return n?wr.has(n):!1}return!1}function Ar(t,e){let n=t.trim();if(!n)return null;let o=S.parse(n,{async:!1});return dt("div",{className:"prose-canvas","data-md":"markdown","data-md-source":n,dangerouslySetInnerHTML:{__html:o}},e,!1,void 0,this)}function Rr(t,e){return dt("div",{className:"prose-canvas",children:t.map((n,o)=>{if(typeof n==="string"||typeof n==="number"){let r=S.parseInline(String(n),{async:!1});return dt("span",{dangerouslySetInnerHTML:{__html:r}},o,!1,void 0,this)}return n})},e,!1,void 0,this)}function ie(t){let e=Vt.Children.toArray(t);if(e.length===0)return null;let n=[],o=[],r=0,s=()=>{if(o.length===0)return;if(o.some((l)=>typeof l!=="string"&&typeof l!=="number"))n.push(Rr(o,`md-${r++}`));else{let l=Ar(o.join(""),`md-${r++}`);if(l)n.push(l)}o=[]};for(let i of e)if(Sr(i))o.push(i);else s(),n.push(i);return s(),n}import{jsxDEV as pt}from"react/jsx-dev-runtime";var Tr={info:{bg:"bg-accent-blue-muted",icon:"i",iconColor:"text-accent-blue"},warning:{bg:"bg-accent-amber-muted",icon:"!",iconColor:"text-accent-amber"},danger:{bg:"bg-accent-red-muted",icon:"✕",iconColor:"text-accent-red"},tip:{bg:"bg-accent-green-muted",icon:"✓",iconColor:"text-accent-green"}};function Er({type:t="info",children:e}){let n=Tr[t];return pt("div",{className:`${n.bg} relative rounded-lg px-5 py-4 mt-3 flex gap-3 items-start`,"data-md":"callout","data-md-type":t,children:[pt("span",{"aria-hidden":"true",className:`${n.iconColor} opacity-70 text-base leading-relaxed flex-shrink-0 mt-px`,children:n.icon},void 0,!1,void 0,this),pt("div",{className:"text-body text-text-secondary leading-relaxed",children:ie(e)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as be}from"react/jsx-dev-runtime";function Nr({items:t}){return be("ul",{className:"space-y-1 mt-3","data-md":"checklist",children:t.map((e,n)=>be("li",{"data-md":"checklist-item","data-md-label":e.label,className:"relative flex items-start gap-2.5 py-1",children:[be("span",{className:`w-4 h-4 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5 transition-all ${e.checked?"bg-accent-green":"border-[1.5px] border-border-hover"}`,children:e.checked&&be("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:be("path",{d:"M2.5 5L4.5 7L7.5 3",style:{stroke:"var(--color-text-inverse)"},strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),be("span",{className:`text-body font-body ${e.checked?"text-text-tertiary line-through decoration-border-hover":"text-text-secondary"}`,children:e.label},void 0,!1,void 0,this)]},n,!0,void 0,this))},void 0,!1,void 0,this)}import{useAnnotations as cn,useResponseRegistration as un}from"#canvas/runtime";import{useEffect as dn,useMemo as pn,useRef as fn,useState as hn}from"react";import{AnnotationCtx as ya,AnnotationHostContext as ka,SessionContext as va,useAnnotationHost as wa,useAnnotations as Sa}from"@fabrika/annotations/runtime";function ft(t,e){let n=[],o=Cr(t);for(let r of o){let s=document.createRange();if(s.selectNodeContents(r),r===t.startContainer)s.setStart(r,t.startOffset);if(r===t.endContainer)s.setEnd(r,t.endOffset);let i=s.toString();if(!i||!i.trim())continue;let l=document.createElement("mark");l.setAttribute("data-annotation-id",e);try{s.surroundContents(l)}catch{let a=s.extractContents();l.appendChild(a),s.insertNode(l)}n.push(l)}return n}function ht(t){let e=t.parentElement;if(e?.classList.contains("select-none"))return!1;if(e?.closest("[data-annotation-id]"))return!1;return!0}function Cr(t){let e=[],n=t.commonAncestorContainer;if(n.nodeType===Node.TEXT_NODE)return e.push(n),e;let o=document.createTreeWalker(n,NodeFilter.SHOW_TEXT),r;while(r=o.nextNode()){if(!ht(r))continue;if(t.intersectsNode(r))e.push(r)}return e}function gt(t,e){for(let n of e){if(t.querySelector(`[data-annotation-id="${n.id}"]`))continue;let o=n.snippet;if(!o)continue;let{fullText:r,textNodes:s}=Ir(t),i=[],l=0;while(!0){let d=r.indexOf(o,l);if(d===-1)break;i.push(d),l=d+1}let[a]=i;if(a===void 0)continue;let c=a;if(i.length>1&&n.context){let d=-1;for(let f of i){let m=0;if(n.context.before){let b=r.slice(Math.max(0,f-80),f);if(b.includes(n.context.before))m+=2;else if(n.context.before.length>10&&b.includes(n.context.before.slice(-10)))m+=1}if(n.context.after){let b=r.slice(f+o.length,f+o.length+80);if(b.includes(n.context.after))m+=2;else if(n.context.after.length>10&&b.includes(n.context.after.slice(0,10)))m+=1}if(m>d)d=m,c=f}}let u=c,p=c+o.length,g=jt(s,u),h=jt(s,p);if(!g||!h)continue;try{let d=document.createRange();d.setStart(g.node,g.offset),d.setEnd(h.node,h.offset),ft(d,n.id)}catch{}}}function Ir(t){let e=[],n="",o=document.createTreeWalker(t,NodeFilter.SHOW_TEXT),r;while(r=o.nextNode()){if(!ht(r))continue;e.push({node:r,start:n.length}),n+=r.textContent||""}return{fullText:n,textNodes:e}}function jt(t,e){for(let n=t.length-1;n>=0;n--){let o=t[n];if(!o||o.start>e)continue;let r=e-o.start,s=o.node.textContent?.length??0;if(r<=s)return{node:o.node,offset:r}}return null}function Ee(t){return{kind:t.kind,owns:(e)=>t.parse(e)!==null,find:(e,n)=>{let o=t.parse(e);return o===null?null:t.find(o,n)},restore:(e,n)=>{let o=t.parse(n.snippet);if(o===null)return;t.restore?.(o,e,n)},describe:(e)=>{let n=t.parse(e);if(n===null||!t.describe)return null;return t.describe(n)}}}function Kt(t){let e=document.createTreeWalker(t,NodeFilter.SHOW_TEXT),n="";for(let o=e.nextNode();o;o=e.nextNode()){let r=o.parentElement?.closest("[aria-hidden='true']");if(r&&t.contains(r))continue;n+=o.textContent??""}return n.trim()}function Be(t,e,n){return{selector:t,snippet:(o)=>{let r=o.getAttribute(n);return r?`${e} ${r}`:null}}}var mt=[Be("[data-md='item']","[Item]","data-md-label"),Be("[data-md='section']","[Section]","data-md-title"),Be("[data-md='checklist-item']","[Checklist]","data-md-label"),Be("[data-md='image']","[Image]","data-md-src"),{selector:"[data-md='callout']",snippet:(t)=>`[Callout:${t.getAttribute("data-md-type")||"info"}] ${Kt(t).slice(0,60)||"Callout"}`},{selector:"[data-md='note']",snippet:(t)=>`[Note] ${Kt(t).slice(0,60)||"Note"}`},{selector:"[data-md='table'] tbody tr",snippet:(t)=>{let e=Array.from(t.querySelectorAll("td")).map((n)=>n.textContent?.trim()).filter(Boolean);return e.length?`[Row] ${e.join(" | ")}`:null}}],Lr=["[data-md='choice-option']","[data-md='multichoice-option']","[data-md='userinput']","[data-md='rangeinput']"],xt=mt.map((t)=>t.selector).join(", "),Zt=[...mt.map((t)=>t.selector),...Lr].join(", ");function bt(t){for(let e of mt)if(t.matches(e.selector))return e.snippet(t);return null}var yt={kind:"block",parse:(t)=>t.startsWith("[")?{snippet:t}:null,format:(t)=>t.snippet,find:(t,e)=>{for(let n of e.querySelectorAll(xt)){if(!(n instanceof HTMLElement))continue;if(bt(n)===t.snippet)return n}return null}};var Pr=/^\[Region:(rect|ellipse)\] ([\s\S]+) @(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*)$/;function Mr(t){if(t==="rect")return"rect";if(t==="ellipse")return"ellipse";return null}function qe(t){if(t===void 0)return null;let e=Number(t);if(!Number.isInteger(e)||e<0||e>1e4)return null;return e}function Yt(t){return{left:`${t.x/100}%`,top:`${t.y/100}%`,width:`${t.w/100}%`,height:`${t.h/100}%`}}function Fe(t){return`${(t/100).toFixed(1).replace(/\.0$/,"")}%`}function vt(t){let e=`${Fe(t.x)}-${Fe(t.x+t.w)}`,n=`${Fe(t.y)}-${Fe(t.y+t.h)}`;return`[Region] ${t.src} — ${t.shape} x ${e}, y ${n} of the image`}function kt(t,e){for(let n of e.querySelectorAll("[data-md='image']")){if(!(n instanceof HTMLElement))continue;if(n.getAttribute("data-md-src")!==t)continue;let o=n.querySelector("[data-annotation-image]");if(o instanceof HTMLElement)return o}return null}function Xt(t,e){let n=Yt(e);t.style.left=n.left,t.style.top=n.top,t.style.width=n.width,t.style.height=n.height}function wt(t,e,n){let o=document.createElement("div");return o.className="ann-region",o.setAttribute("data-annotation-id",n),o.setAttribute("data-annotation-region",e),Xt(o,t),o}var Ge={kind:"region",parse:(t)=>{let e=Pr.exec(t);if(!e)return null;let n=Mr(e[1]),o=e[2],r=qe(e[3]),s=qe(e[4]),i=qe(e[5]),l=qe(e[6]);if(n===null||o===void 0)return null;if(r===null||s===null||i===null||l===null)return null;if(i<1||l<1)return null;return{src:o,shape:n,x:r,y:s,w:i,h:l}},format:(t)=>`[Region:${t.shape}] ${t.src} @${t.x},${t.y},${t.w},${t.h}`,find:(t,e)=>kt(t.src,e),restore:(t,e,n)=>{if(e.querySelector(`[data-annotation-id="${n.id}"]`))return;let o=kt(t.src,e);if(!o)return;o.appendChild(wt(t,t.shape,n.id))},describe:vt};var St={kind:"text",parse:(t)=>t?{text:t}:null,format:(t)=>t.text,find:()=>null,restore:(t,e,n)=>{gt(e,[n])}};var $r=[Ee(Ge),Ee(yt),Ee(St)];import{AnnotationCtx as js,SessionContext as Ks,useAnnotationHost as Zs}from"@fabrika/annotations/runtime";import{useEffect as Qs,useState as Js}from"react";import{useCallback as qs,useMemo as Fs,useState as Gs}from"react";function Ne(t){return t.uploadUrl!==null}function oe(t,e){t.style.height="auto",t.style.height=(e?Math.max(e,t.scrollHeight):t.scrollHeight)+"px"}import{useAnnotations as Ue}from"@fabrika/annotations/runtime";import{useAnnotationHost as _r}from"@fabrika/annotations/runtime";import{useCallback as se,useEffect as Hr,useRef as Rt,useState as Tt}from"react";import{jsxDEV as B}from"react/jsx-dev-runtime";function Qt(t){if(t.startsWith("/s/")||t.startsWith("http://")||t.startsWith("https://"))return t;return`/api/uploads/${t.split("/").pop()}`}async function zr(t,e){let n=t.uploadUrl;if(!n)return null;let o=new FormData;o.append("image",e);try{let s=await(await fetch(n(),{method:"POST",body:o})).json();if(t.isShared)return s.url||null;return s.path||null}catch{return null}}function We({note:t,onNoteChange:e,images:n,onAddImage:o,onRemoveImage:r,sessionId:s,placeholder:i="Add your note...",autoFocus:l=!1,autoResize:a=!1,readOnly:c=!1,onKeyDown:u,onTextareaClick:p,textareaRef:g,textareaClassName:h,textareaStyle:d,minHeight:f,attachButton:m="always",openFilePickerRef:b}){let R=_r(),v=!c&&Ne(R),[w,N]=Tt(!1),[L,F]=Tt(!1),[U,Y]=Tt(!1),C=Rt(0),M=Rt(null),G=Rt(null),H=se(()=>G.current?.click(),[]);if(b)b.current=H;let X=se((y)=>{if(M.current=y,g)g.current=y;if(y&&a)oe(y,f)},[g,a,f]);Hr(()=>{if(l&&M.current){let y=M.current;if(y.focus(),y.value)y.setSelectionRange(y.value.length,y.value.length)}},[l]);let W=se(async(y)=>{if(!y.type.startsWith("image/"))return;F(!0);try{let z=await zr(R,y);if(z)o(z)}finally{F(!1)}},[R,o]),ce=se((y)=>{for(let z of y.clipboardData?.items??[])if(z.type.startsWith("image/")){y.preventDefault();let me=z.getAsFile();if(me)W(me);return}},[W]),V=se((y)=>{if(y.preventDefault(),C.current++,C.current===1)N(!0)},[]),j=se((y)=>{y.preventDefault()},[]),Q=se((y)=>{if(y.preventDefault(),C.current--,C.current===0)N(!1)},[]),J=se((y)=>{y.preventDefault(),C.current=0,N(!1);for(let z of y.dataTransfer?.files??[])if(z.type.startsWith("image/"))W(z)},[W]),ue=se((y)=>{if(e(y.currentTarget.value),a)y.currentTarget.style.height="auto",y.currentTarget.style.height=(f?Math.max(f,y.currentTarget.scrollHeight):y.currentTarget.scrollHeight)+"px"},[e,a,f]),de="w-full bg-transparent text-[13px] font-body text-text-primary resize-none focus:outline-none leading-relaxed p-0 border-none",et={width:"100%",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",outline:"none",...a?{resize:"none",overflow:"hidden"}:{resize:"vertical"}},Me=v&&(m==="always"||m==="on-focus"&&U);return B("div",{style:{position:"relative"},onDragEnter:v?V:void 0,onDragOver:v?j:void 0,onDragLeave:v?Q:void 0,onDrop:v?J:void 0,children:[B("textarea",{ref:X,value:t,onChange:c?void 0:ue,onPaste:v?ce:void 0,onKeyDown:u,onClick:p,onFocus:()=>Y(!0),onBlur:()=>{setTimeout(()=>Y(!1),150)},readOnly:c,placeholder:i,className:h??de,style:d??et,rows:a?1:void 0},void 0,!1,void 0,this),v&&B("input",{ref:G,type:"file",accept:"image/*",multiple:!0,style:{display:"none"},onChange:(y)=>{let z=y.currentTarget.files;if(z)for(let me of z)W(me);y.currentTarget.value=""}},void 0,!1,void 0,this),(n.length>0||Me)&&B("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px",alignItems:"center"},children:[n.map((y)=>B("div",{style:{position:"relative",width:"56px",height:"56px",borderRadius:"6px",overflow:"hidden",border:"1px solid var(--color-border-subtle)",flexShrink:0},children:[B("img",{src:Qt(y),alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}},void 0,!1,void 0,this),!c&&B("button",{onClick:(z)=>{z.stopPropagation(),r(y)},style:{position:"absolute",top:"2px",right:"2px",width:"16px",height:"16px",borderRadius:"50%",background:"rgba(0,0,0,0.6)",color:"white",border:"none",cursor:"pointer",fontSize:"11px",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:0},title:"Remove image",children:"×"},void 0,!1,void 0,this)]},y,!0,void 0,this)),Me&&B(Ve,{onClick:H},void 0,!1,void 0,this)]},void 0,!0,void 0,this),L&&B("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:"Uploading..."},void 0,!1,void 0,this),w&&B("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-highlight-bg)",opacity:0.9,border:"2px dashed var(--color-highlight-border)",borderRadius:"6px",zIndex:10,pointerEvents:"none",fontSize:"12px",fontFamily:"'Inter', sans-serif",color:"var(--color-text-secondary)"},children:"Drop image"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Ve({onClick:t,size:e=16}){return B("button",{onClick:(n)=>{n.stopPropagation(),t()},style:{width:`${e*2}px`,height:`${e*2}px`,borderRadius:"6px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--color-text-tertiary)",flexShrink:0,transition:"color 0.15s"},title:"Attach image",onMouseEnter:(n)=>{n.currentTarget.style.color="var(--color-text-secondary)"},onMouseLeave:(n)=>{n.currentTarget.style.color="var(--color-text-tertiary)"},children:B("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[B("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},void 0,!1,void 0,this),B("circle",{cx:"8.5",cy:"8.5",r:"1.5"},void 0,!1,void 0,this),B("polyline",{points:"21 15 16 10 5 21"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}import{SessionContext as fi}from"@fabrika/annotations/runtime";import{useContext as gi,useEffect as mi,useRef as xi}from"react";import{SessionContext as Fr,useAnnotationHost as Gr}from"@fabrika/annotations/runtime";import{useCallback as je,useContext as Ur,useEffect as Wr,useMemo as nn,useRef as Ke,useState as ye}from"react";import{createPortal as Vr}from"react-dom";function en(t){let e=/^(\d+(?:\.\d+)?)px$/.exec(t.trim());return e?Number(e[1]):void 0}function tn(t,e,n=280){let r=e||document.body,s=t.getBoundingClientRect(),i=r.getBoundingClientRect(),l=r===document.body?0:r.scrollTop,a=s.bottom-i.top+l+8,c=Math.max(0,Math.min(s.left-i.left,i.width-n-12));return r.style.position="relative",{style:{position:"absolute",top:`${a}px`,left:`${c}px`},parent:r}}import{jsxDEV as _,Fragment as jr}from"react/jsx-dev-runtime";function on({anchorEl:t,scrollContainer:e,onClose:n,ignoreSelector:o,zIndex:r="50",padding:s="12px",width:i="280px",children:l}){let a=Ke(null),c=Ke(n);c.current=n;let{style:u,parent:p}=tn(t,e,en(i));return Wr(()=>{let g=setTimeout(()=>{let h=(d)=>{if(a.current&&!a.current.contains(d.target)){if(o&&d.target.closest?.(o))return;c.current(),document.removeEventListener("mousedown",h)}};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},0);return()=>clearTimeout(g)},[o]),Vr(_("div",{ref:a,style:{...u,zIndex:r,width:i,background:"var(--color-bg-elevated)",border:"1px solid var(--color-border-hover)",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",padding:s,fontFamily:"'Inter', sans-serif"},children:l},void 0,!1,void 0,this),p)}var sn=[{label:"Clarity",items:["Unclear","Why?","Needs example","Missing context"]},{label:"Scope",items:["Overkill","Out of scope","Important","Risky"]},{label:"Action",items:["Simplify","Rethink","Expand on this","Skip this"]}],rn=sn.flatMap((t)=>t.items);function an({anchorEl:t,scrollContainer:e,snippet:n,truncateAt:o=100,header:r,initialNote:s="",initialImages:i,onConfirm:l,onCancel:a,onDelete:c}){let u=Ur(Fr),p=Gr(),g=Ne(p),h=s!==""||!!c,[d,f]=ye(s),[m,b]=ye(i||[]),[R,v]=ye(null),[w,N]=ye(h),[L,F]=ye(!1),U=Ke(null),Y=Ke(null),C=je(()=>{if(d.trim()||m.length>0)l(d.trim(),m);else if(h&&c)c();else a()},[d,m,l,a,h,c]),M=je(()=>{if(h){if(!d.trim()&&m.length===0&&c){c(),a();return}l(d,m);return}a()},[d,m,h,l,a,c]),G=!h,H=d.trim().length>0?rn.filter((x)=>x.toLowerCase().startsWith(d.trim().toLowerCase())):rn,X=!G||w?[]:H.length===1&&H[0]?.toLowerCase()===d.trim().toLowerCase()?[]:H,W=new Set(X),ce=sn.map((x)=>({label:x.label,items:x.items.filter((E)=>W.has(E))})).filter((x)=>x.items.length>0),V=ce.map((x)=>x.items),j=(x)=>V[x]?.length??0,Q=V.flat(),J=nn(()=>{if(R===null)return 0;let x=0;for(let E=0;E<V.length;E++){if(R<x+j(E))return E;x+=j(E)}return 0},[R,V]),ue=nn(()=>{if(R===null)return 0;let x=0;for(let E=0;E<J;E++)x+=j(E);return R-x},[R,J,V]),de=(x,E)=>{let O=0;for(let ee=0;ee<x;ee++)O+=j(ee);return O+E},[et,Me]=ye(d);if(d!==et)Me(d),v(null),N(h);let y=je((x)=>{f(x)},[]),z=n.length>o?n.slice(0,o)+"...":n,me=je((x)=>{if(Q.length>0&&(x.key==="ArrowDown"||x.key==="ArrowUp"||x.key==="ArrowLeft"||x.key==="ArrowRight")){if(x.preventDefault(),R===null){v(0);return}if(x.key==="ArrowDown"){let O=Math.min(ue+1,j(J)-1);v(de(J,O))}else if(x.key==="ArrowUp"){let O=Math.max(ue-1,0);v(de(J,O))}else if(x.key==="ArrowRight"){let O=Math.min(J+1,V.length-1),ee=Math.min(ue,j(O)-1);v(de(O,ee))}else if(x.key==="ArrowLeft"){let O=Math.max(J-1,0),ee=Math.min(ue,j(O)-1);v(de(O,ee))}return}let E=R===null?void 0:Q[R];if(E!==void 0){if(x.key==="Tab"){x.preventDefault(),y(E);return}if(x.key==="Enter"&&!x.shiftKey){x.preventDefault(),l(E,m);return}}if(x.key==="Enter"&&!x.shiftKey){x.preventDefault(),C();return}if(x.key==="Escape")if(Q.length>0&&!w)N(!0);else if(h)M();else a()},[Q,R,ue,J,V,de,y,l,m,C,w,h,M,a]);return _(on,{anchorEl:t,scrollContainer:e,onClose:h?M:a,ignoreSelector:h?"[data-annotation-id]":void 0,zIndex:h?"60":"50",padding:h?"10px 12px":"12px",width:"420px",children:[!h&&(r??_("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontStyle:"italic",marginBottom:"8px",lineHeight:"1.4",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:["“",z,"”"]},void 0,!0,void 0,this)),_(We,{note:d,onNoteChange:f,images:m,onAddImage:(x)=>b((E)=>[...E,x]),onRemoveImage:(x)=>b((E)=>E.filter((O)=>O!==x)),sessionId:u,autoFocus:!0,autoResize:h,textareaRef:U,onKeyDown:me,attachButton:"none",openFilePickerRef:Y,textareaStyle:h?{width:"100%",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",resize:"none",outline:"none",overflow:"hidden"}:{width:"100%",minHeight:"60px",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",resize:"vertical",outline:"none"},placeholder:"Add your note..."},void 0,!1,void 0,this),_("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:h?"6px":"8px"},children:[g&&_(Ve,{onClick:()=>Y.current?.(),size:14},void 0,!1,void 0,this),_("div",{style:{flex:1}},void 0,!1,void 0,this),h?_("button",{onClick:()=>{if(c)c();a()},onMouseEnter:()=>F(!0),onMouseLeave:()=>F(!1),style:{fontSize:"11px",color:L?"var(--color-accent-red)":"var(--color-text-tertiary)",background:"none",border:"none",cursor:"pointer",padding:"2px 0",fontFamily:"'Inter', sans-serif"},children:"Delete"},void 0,!1,void 0,this):_(jr,{children:[_("button",{onClick:a,style:{fontSize:"11px",color:"var(--color-text-tertiary)",background:"none",border:"none",cursor:"pointer",padding:"4px 12px",fontFamily:"'Inter', sans-serif"},children:"Cancel"},void 0,!1,void 0,this),_("button",{onClick:C,style:{fontSize:"11px",fontWeight:500,padding:"4px 12px",borderRadius:"6px",background:"var(--color-highlight-bg)",color:"var(--color-text-primary)",border:"1px solid var(--color-highlight-border)",cursor:"pointer",fontFamily:"'Inter', sans-serif"},children:"Add"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),Q.length>0&&_("div",{style:{marginTop:"6px",borderTop:"1px solid var(--color-border-subtle)",paddingTop:"8px",display:"flex",gap:"4px"},children:ce.map((x)=>_("div",{style:{flex:1},children:[_("div",{style:{fontSize:"10px",fontWeight:600,color:"var(--color-text-disabled)",textTransform:"uppercase",letterSpacing:"0.05em",padding:"2px 6px",marginBottom:"2px",fontFamily:"'Inter', sans-serif"},children:x.label},void 0,!1,void 0,this),x.items.map((E)=>{let O=Q.indexOf(E);return _("div",{onMouseDown:(ee)=>{ee.preventDefault(),ee.stopPropagation(),y(E)},onMouseEnter:()=>v(O),style:{padding:"3px 6px",fontSize:"12px",borderRadius:"4px",fontFamily:"'Inter', sans-serif",color:O===R?"var(--color-text-primary)":"var(--color-text-secondary)",background:O===R?"var(--color-highlight-selected)":"transparent",cursor:"pointer"},children:[_("span",{style:{fontWeight:500},children:E.slice(0,d.trim().length)},void 0,!1,void 0,this),E.slice(d.trim().length)]},E,!0,void 0,this)})]},x.label,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Ce({anchorEl:t,scrollContainer:e,snippet:n,truncateAt:o,header:r,onAdd:s,onCancel:i}){return _(an,{anchorEl:t,scrollContainer:e,snippet:n,truncateAt:o,header:r,onConfirm:(l,a)=>s(l,a),onCancel:i},void 0,!1,void 0,this)}import{useEffect as zi,useRef as Di,useState as Bi}from"react";import{useCallback as Zi,useEffect as Yi,useRef as Xi,useState as Qi}from"react";import{jsxDEV as ln}from"react/jsx-dev-runtime";function ke({note:t,onChange:e}){return ln("div",{className:"mt-1.5",children:ln("textarea",{value:t,onChange:(n)=>e(n.currentTarget.value),className:"w-full bg-transparent text-[12px] font-body text-text-primary resize-none focus:outline-none border-none placeholder:text-text-disabled transition-colors min-h-[20px] p-0 leading-relaxed",placeholder:"Add a note...",rows:1,onInput:(n)=>oe(n.currentTarget),ref:(n)=>{if(n)oe(n)}},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as I}from"react/jsx-dev-runtime";function gn(t){return t.map((e)=>typeof e==="string"?{value:e,label:e}:{value:e.value,label:e.label??e.value})}function ro({id:t,label:e,options:n,required:o}){let{responses:r,setResponse:s}=cn();un(t);let i=pn(()=>gn(n),[n]),l=r.get(t),a=l?.value,c=l?.note||"",[u,p]=hn(!1),g=fn(null);if(!r.has(t))s(t,{id:t,type:"radio",label:e,value:null,options:i.map((f)=>f.value),required:o});let h=(f)=>{s(t,{...l,value:f})};dn(()=>{let f=g.current;if(!f)return;let m=(b)=>{let v=b.target.closest("[data-md-label]")?.getAttribute("data-md-label"),w=i.find((N)=>N.label===v);if(w)h(w.value)};return f.addEventListener("kb-select",m),()=>f.removeEventListener("kb-select",m)},[i,h]);let d=l?.required&&!a;return I("div",{ref:g,"data-md":"choice","data-md-label":e,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[I("div",{className:"flex items-baseline gap-2 mb-2",children:[I("span",{className:"text-[13px] font-body font-medium text-text-primary",children:e},void 0,!1,void 0,this),o&&I("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),I("div",{className:"space-y-1",children:i.map(({value:f,label:m})=>I("label",{"data-md":"choice-option","data-md-label":m,onClick:()=>h(f),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${a===f?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[I("span",{className:`w-4 h-4 rounded-full border-[1.5px] flex items-center justify-center flex-shrink-0 transition-all ${a===f?"border-accent-amber bg-accent-amber":"border-border-strong"}`,children:a===f&&I("span",{className:"w-1.5 h-1.5 rounded-full bg-text-inverse"},void 0,!1,void 0,this)},void 0,!1,void 0,this),I("span",{className:"text-[13px] font-body text-text-secondary",children:m},void 0,!1,void 0,this)]},f,!0,void 0,this))},void 0,!1,void 0,this),I(ke,{show:u,note:c,onToggle:()=>p(!u),onChange:(f)=>s(t,{...l,note:f})},void 0,!1,void 0,this),d&&I("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"Please select an option."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function oo({id:t,label:e,options:n,required:o}){let{responses:r,setResponse:s}=cn();un(t);let i=pn(()=>gn(n),[n]),l=r.get(t),a=l?.value||[],c=l?.note||"",[u,p]=hn(!1),g=fn(null);if(!r.has(t))s(t,{id:t,type:"checkbox",label:e,value:[],options:i.map((f)=>f.value),required:o});let h=(f)=>{let m=a.includes(f)?a.filter((b)=>b!==f):[...a,f];s(t,{...l,value:m})};dn(()=>{let f=g.current;if(!f)return;let m=(b)=>{let v=b.target.closest("[data-md-label]")?.getAttribute("data-md-label"),w=i.find((N)=>N.label===v);if(w)h(w.value)};return f.addEventListener("kb-select",m),()=>f.removeEventListener("kb-select",m)},[i,h]);let d=l?.required&&a.length===0;return I("div",{ref:g,"data-md":"multichoice","data-md-label":e,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[I("div",{className:"flex items-baseline gap-2 mb-2",children:[I("span",{className:"text-[13px] font-body font-medium text-text-primary",children:e},void 0,!1,void 0,this),o&&I("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),I("div",{className:"space-y-1",children:i.map(({value:f,label:m})=>{let b=a.includes(f);return I("label",{"data-md":"multichoice-option","data-md-label":m,onClick:()=>h(f),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${b?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[I("span",{className:`w-4 h-4 rounded flex items-center justify-center flex-shrink-0 transition-all ${b?"bg-accent-amber":"border-[1.5px] border-border-strong"}`,children:b&&I("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:I("path",{d:"M2.5 5L4.5 7L7.5 3",style:{stroke:"var(--color-text-inverse)"},strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),I("span",{className:"text-[13px] font-body text-text-secondary",children:m},void 0,!1,void 0,this)]},f,!0,void 0,this)})},void 0,!1,void 0,this),I(ke,{show:u,note:c,onToggle:()=>p(!u),onChange:(f)=>s(t,{...l,note:f})},void 0,!1,void 0,this),d&&I("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"Please select at least one option."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as so,useRef as io}from"react";import{jsxDEV as Ze}from"react/jsx-dev-runtime";function ao({language:t,children:e}){let n=typeof e==="string"?e:String(e??""),o=io(null);return so(()=>{let r=o.current,s=window.hljs;if(!r||!s)return;r.removeAttribute("data-highlighted"),r.className=t?`language-${t}`:"",r.textContent=n,s.highlightElement(r)},[n,t]),Ze("div",{className:"relative mt-3 group/code","data-md":"codeblock","data-md-language":t||"",children:[t&&Ze("span",{className:"absolute top-2 right-3 text-tiny text-text-tertiary opacity-0 group-hover/code:opacity-60 transition-opacity duration-150 z-10 font-mono",children:t},void 0,!1,void 0,this),Ze("pre",{className:"bg-bg-code rounded-md p-4 overflow-x-auto text-code font-mono leading-relaxed",children:Ze("code",{ref:o,className:t?`language-${t}`:"",children:n},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function mn(t,e){let n=t.split(`
|
|
60
|
+
`),o=e.split(`
|
|
61
|
+
`),r=lo(n,o),s=[],i=0,l=0,a=0;while(i<n.length||l<o.length){let c=n[i],u=o[l];if(a<r.length&&c!==void 0&&u!==void 0&&c===r[a]&&u===r[a])s.push({type:"same",line:c}),i++,l++,a++;else if(c!==void 0&&(a>=r.length||c!==r[a]))s.push({type:"removed",line:c}),i++;else if(u!==void 0)s.push({type:"added",line:u}),l++}return s}function lo(t,e){let n=t.length,o=e.length,r=Array.from({length:n+1},()=>Array(o+1).fill(0));for(let a=1;a<=n;a++){let c=r[a]??[],u=r[a-1]??[];for(let p=1;p<=o;p++)c[p]=t[a-1]===e[p-1]?(u[p-1]??0)+1:Math.max(u[p]??0,c[p-1]??0)}let s=[],i=n,l=o;while(i>0&&l>0){let a=t[i-1];if(a!==void 0&&a===e[l-1])s.unshift(a),i--,l--;else if((r[i-1]?.[l]??0)>(r[i]?.[l-1]??0))i--;else l--}return s}import{jsxDEV as Ie}from"react/jsx-dev-runtime";function co({before:t,after:e,language:n}){let o=mn(t,e);return Ie("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden group/diff","data-md":"diff","data-md-language":n||"",children:[n&&Ie("div",{className:"px-4 py-2 text-meta font-mono text-text-tertiary opacity-0 group-hover/diff:opacity-60 transition-opacity",children:["diff (",n,")"]},void 0,!0,void 0,this),Ie("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono",children:o.map((r,s)=>Ie("div",{className:r.type==="removed"?"bg-accent-red-muted text-accent-red":r.type==="added"?"bg-accent-green-muted text-accent-green":"text-text-tertiary",children:[Ie("span",{className:"select-none w-6 inline-block text-center opacity-60",children:r.type==="removed"?"-":r.type==="added"?"+":" "},void 0,!1,void 0,this),r.line]},s,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{ActiveViewCtx as uo,SessionContext as po}from"#canvas/runtime";import{useContext as xn,useEffect as bn,useRef as fo,useState as Ye}from"react";import{jsxDEV as ae}from"react/jsx-dev-runtime";var ho={ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",py:"python",rs:"rust",go:"go",rb:"ruby",java:"java",json:"json",yaml:"yaml",yml:"yaml",md:"markdown",css:"css",html:"html",sh:"bash",bash:"bash",toml:"toml",sql:"sql",xml:"xml",c:"c",cpp:"cpp",h:"c"};function go({path:t,lines:e,__content:n}){let o=xn(po),{setActiveView:r}=xn(uo),[s,i]=Ye(n??null),[l,a]=Ye(()=>{let d=t.split(".").pop()||"";return ho[d]||"text"}),[c,u]=Ye(null),[p,g]=Ye(!n),h=fo(null);if(bn(()=>{if(n!==void 0)return;g(!0),u(null),fetch(`/api/file?session=${o}&path=${encodeURIComponent(t)}`).then((d)=>d.json()).then((d)=>{if(d.error)u(d.error);else{let f=d.content;if(e)f=f.split(`
|
|
62
|
+
`).slice(e[0]-1,e[1]).join(`
|
|
63
|
+
`);i(f),a(d.language||"text")}}).catch(()=>u("Failed to fetch file")).finally(()=>g(!1))},[o,t,e?.[0],e?.[1],n]),bn(()=>{let d=h.current,f=window.hljs;if(!d||!f||!s)return;d.removeAttribute("data-highlighted"),d.className=l?`language-${l}`:"",d.textContent=s,f.highlightElement(d)},[s,l]),p)return ae("div",{className:"text-text-tertiary text-body mt-3 bg-bg-code rounded-md p-4",children:["Loading ",t,"..."]},void 0,!0,void 0,this);if(c)return ae("div",{className:"text-accent-red text-body mt-3 bg-accent-red-muted rounded-md p-4",children:[t,": ",c]},void 0,!0,void 0,this);return ae("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden","data-md":"filepreview","data-md-path":t,...e?{"data-md-lines":`${e[0]}-${e[1]}`}:{},children:[ae("div",{className:"px-4 py-2 flex items-center justify-between",children:[ae("button",{className:"font-mono text-meta text-text-tertiary hover:text-text-secondary hover:underline cursor-pointer text-left",onClick:()=>r({type:"file",path:t}),title:`Open ${t}`,children:t},void 0,!1,void 0,this),e&&ae("span",{className:"font-mono text-meta text-text-tertiary opacity-60",children:["L",e[0],"–",e[1]]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),ae("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono !bg-transparent",style:{background:"transparent"},children:ae("code",{ref:h,className:l?`language-${l}`:"",children:s},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{SessionContext as mo}from"#canvas/runtime";import{useContext as xo,useState as bo}from"react";import{jsxDEV as Le}from"react/jsx-dev-runtime";function yo({src:t,alt:e,caption:n,width:o,height:r}){let s=xo(mo),[i,l]=bo(!1),a=`/api/image?session=${encodeURIComponent(s)}&path=${encodeURIComponent(t)}`;if(i)return Le("div",{className:"mt-3 text-accent-red text-body bg-accent-red-muted rounded-md p-4",children:[t,": Failed to load image"]},void 0,!0,void 0,this);return Le("figure",{className:"mt-3 relative","data-md":"image","data-md-src":t,children:[Le("div",{"data-annotation-image":!0,className:"rounded-md overflow-hidden border border-border-subtle bg-bg-code inline-block",children:Le("img",{src:a,alt:e||t,onError:()=>l(!0),draggable:!1,className:"block max-w-full h-auto",...o?{width:o}:{},...r?{height:r}:{}},void 0,!1,void 0,this)},void 0,!1,void 0,this),n&&Le("figcaption",{className:"mt-1.5 text-meta text-text-tertiary font-body",children:n},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useMemo as ko}from"react";import{jsxDEV as yn}from"react/jsx-dev-runtime";S.setOptions({gfm:!0,breaks:!1});function vo({children:t,file:e,__content:n}){let o=n??(typeof t==="string"?t:String(t??"")),r=ko(()=>{if(!o)return"";return S.parse(o,{async:!1})},[o]);if(!o)return yn("div",{className:"text-text-tertiary text-tiny mt-3",children:e?`Could not load: ${e}`:"No markdown content"},void 0,!1,void 0,this);return yn("div",{className:"mt-3 prose-canvas","data-md":"markdown",...e?{"data-md-file":e}:{},"data-md-source":o,dangerouslySetInnerHTML:{__html:r}},void 0,!1,void 0,this)}import{useAnnotations as wo,useCanvasFile as So}from"#canvas/runtime";import{useCallback as ne,useEffect as Et,useRef as Pe,useState as ve}from"react";import Ao from"react-dom";import{jsxDEV as k,Fragment as Sn}from"react/jsx-dev-runtime";var we=0.2,Xe=0.25,Qe=4;function vn({zoom:t,onZoomIn:e,onZoomOut:n,onZoomReset:o,onFullscreen:r}){return k("div",{className:"flex items-center gap-0.5 bg-bg-surface border border-border-subtle rounded-md px-1 py-0.5",style:{fontSize:"12px"},children:[k("button",{className:"flex items-center justify-center w-7 h-7 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:n,title:"Zoom out",disabled:t<=Xe,children:k("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:k("line",{x1:"5",y1:"12",x2:"19",y2:"12"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),k("button",{className:"px-1.5 h-7 rounded hover:bg-bg-elevated text-text-tertiary hover:text-text-primary transition-colors tabular-nums",onClick:o,title:"Reset zoom",children:[Math.round(t*100),"%"]},void 0,!0,void 0,this),k("button",{className:"flex items-center justify-center w-7 h-7 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:e,title:"Zoom in",disabled:t>=Qe,children:k("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[k("line",{x1:"12",y1:"5",x2:"12",y2:"19"},void 0,!1,void 0,this),k("line",{x1:"5",y1:"12",x2:"19",y2:"12"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),r&&k(Sn,{children:[k("div",{className:"w-px h-4 bg-border-subtle mx-0.5"},void 0,!1,void 0,this),k("button",{className:"flex items-center justify-center w-7 h-7 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:r,title:"Fullscreen",children:k("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[k("polyline",{points:"15 3 21 3 21 9"},void 0,!1,void 0,this),k("polyline",{points:"9 21 3 21 3 15"},void 0,!1,void 0,this),k("line",{x1:"21",y1:"3",x2:"14",y2:"10"},void 0,!1,void 0,this),k("line",{x1:"3",y1:"21",x2:"10",y2:"14"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function wn(t=1){let[e,n]=ve(t),o=ne(()=>n((i)=>Math.min(Qe,+(i+we).toFixed(2))),[]),r=ne(()=>n((i)=>Math.max(Xe,+(i-we).toFixed(2))),[]),s=ne(()=>n(1),[]);return{zoom:e,zoomIn:o,zoomOut:r,zoomReset:s,setZoom:n}}function Ro({svgHtml:t,source:e,onClose:n}){let o=Pe(null),{zoom:r,zoomIn:s,zoomOut:i,zoomReset:l,setZoom:a}=wn(1),[c,u]=ve({x:0,y:0}),p=Pe(null);Et(()=>{let b=(R)=>{if(R.key==="Escape")n()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[n]);let g=ne((b)=>{b.preventDefault();let R=b.deltaY>0?-we:we;a((v)=>Math.max(Xe,Math.min(Qe,+(v+R).toFixed(2))))},[a]),h=ne((b)=>{if(b.button!==0)return;p.current={startX:b.clientX,startY:b.clientY,panX:c.x,panY:c.y},b.preventDefault()},[c]),d=ne((b)=>{if(!p.current)return;u({x:p.current.panX+(b.clientX-p.current.startX),y:p.current.panY+(b.clientY-p.current.startY)})},[]),f=ne(()=>{p.current=null},[]),m=ne(()=>{l(),u({x:0,y:0})},[l]);return Ao.createPortal(k("div",{style:{position:"fixed",inset:0,zIndex:9999,background:"var(--color-bg-base)",display:"flex",flexDirection:"column"},onMouseMove:d,onMouseUp:f,onMouseLeave:f,children:[k("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border-subtle",style:{flexShrink:0,background:"var(--color-bg-surface)"},children:[k("span",{className:"text-body text-text-secondary",style:{fontSize:"13px"},children:"Mermaid Diagram"},void 0,!1,void 0,this),k("div",{className:"flex items-center gap-2",children:[k(vn,{zoom:r,onZoomIn:s,onZoomOut:i,onZoomReset:m},void 0,!1,void 0,this),k("button",{className:"flex items-center justify-center w-8 h-8 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:n,title:"Close (Esc)",children:k("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[k("line",{x1:"18",y1:"6",x2:"6",y2:"18"},void 0,!1,void 0,this),k("line",{x1:"6",y1:"6",x2:"18",y2:"18"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),k("div",{style:{flex:1,overflow:"hidden",cursor:p.current?"grabbing":"grab"},onWheel:g,onMouseDown:h,children:k("div",{ref:o,style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",transform:`translate(${c.x}px, ${c.y}px) scale(${r})`,transformOrigin:"center center",transition:p.current?"none":"transform 0.1s ease-out"},dangerouslySetInnerHTML:{__html:t}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),document.body)}function To({children:t}){let e=Pe(null),[n,o]=ve(null),[r,s]=ve(!1),[i,l]=ve(""),a=typeof t==="string"?t:String(t??""),{annotations:c,addAnnotationWithId:u,activeAnnotationId:p,setActiveAnnotationId:g}=wo(),h=So(),[d,f]=ve(null),{zoom:m,zoomIn:b,zoomOut:R,zoomReset:v,setZoom:w}=wn(1),N=Pe(c);N.current=c;let L=ne((C,M,G)=>{let H=`[Diagram ${G.toLowerCase()}] ${M}`,X=N.current.find((W)=>W.snippet===H);if(X)g(X.id);else f({anchorEl:C,snippet:M,prefix:G})},[g]),F=Pe(L);F.current=L,Et(()=>{let C=!1,M=async()=>{try{let H=window.mermaid;if(!H){o("Mermaid library not loaded");return}let X=document.documentElement.dataset.theme==="light"?"default":"dark";H.initialize({startOnLoad:!1,theme:X});let W=`mermaid-${Math.random().toString(36).slice(2)}`,{svg:ce}=await H.render(W,a.trim());if(!C&&e.current)e.current.innerHTML=ce,l(ce),Eo(e.current,(V,j,Q)=>F.current(V,j,Q)),kn(e.current,N.current);o(null)}catch(H){if(!C)o(H.message||"Invalid diagram")}};M();let G=new MutationObserver((H)=>{for(let X of H)if(X.attributeName==="data-theme")M()});return G.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{C=!0,G.disconnect()}},[a]),Et(()=>{if(e.current)kn(e.current,c,p)},[c,p]);let U=ne((C)=>{if(!C.ctrlKey&&!C.metaKey)return;C.preventDefault();let M=C.deltaY>0?-we:we;w((G)=>Math.max(Xe,Math.min(Qe,+(G+M).toFixed(2))))},[w]);if(n)return k("div",{className:"bg-accent-red-muted rounded-md p-4 mt-3 text-body text-accent-red",children:["Mermaid error: ",n,k("pre",{className:"mt-2 text-tiny text-text-tertiary whitespace-pre-wrap",children:a},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let Y=e.current?.closest("#plan-scroll-container");return k(Sn,{children:[k("div",{className:"mt-3 mermaid-container","data-md":"mermaid","data-md-source":a.trim(),children:[k("div",{className:"flex justify-end mb-1",children:k(vn,{zoom:m,onZoomIn:b,onZoomOut:R,onZoomReset:v,onFullscreen:()=>s(!0)},void 0,!1,void 0,this)},void 0,!1,void 0,this),k("div",{style:{overflow:"auto",maxHeight:"70vh"},onWheel:U,children:k("div",{ref:e,className:"flex justify-center",style:{transform:`scale(${m})`,transformOrigin:"top center",transition:"transform 0.1s ease-out",minHeight:m<1?void 0:void 0}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),d&&k(Ce,{anchorEl:d.anchorEl,scrollContainer:Y,snippet:d.snippet,header:k("div",{style:{fontSize:"12px",color:"var(--color-text-tertiary)",marginBottom:"8px",lineHeight:"1.4",display:"flex",alignItems:"center",gap:"6px"},children:[k("span",{style:{width:"8px",height:"8px",borderRadius:"50%",background:"var(--color-accent-amber)",flexShrink:0}},void 0,!1,void 0,this),d.snippet]},void 0,!0,void 0,this),onAdd:(C,M)=>{let G=`ann-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;u(G,`[Diagram ${d.prefix.toLowerCase()}] ${d.snippet}`,C,void 0,void 0,M,h||void 0),f(null)},onCancel:()=>f(null)},void 0,!1,void 0,this),r&&i&&k(Ro,{svgHtml:i,source:a,onClose:()=>s(!1)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Eo(t,e){let n=(o,r,s)=>{o.style.cursor="pointer",o.addEventListener("mouseenter",()=>{o.style.filter="brightness(1.2)"}),o.addEventListener("mouseleave",()=>{o.style.filter=""}),o.addEventListener("click",(i)=>{i.stopPropagation(),i.preventDefault(),e(o,r(),s)})};for(let o of t.querySelectorAll(".node"))n(o,()=>(o.querySelector(".nodeLabel")||o.querySelector("foreignObject span")||o.querySelector("text"))?.textContent?.trim()||"Node","Node");for(let o of t.querySelectorAll(".edgePath")){let r=o,s=r.querySelector("path");if(s){s.style.strokeWidth=Math.max(parseFloat(s.style.strokeWidth||"1"),8)+"px",s.style.strokeOpacity="0";let l=s.cloneNode(!0);l.style.strokeWidth="",l.style.strokeOpacity="",r.insertBefore(l,s)}let i=r.id||"";n(r,()=>{let l=t.querySelectorAll(".edgeLabel");for(let a of l)if(a.id&&i&&a.id.replace("label","").includes(i.replace("L-","").replace("edge",""))){let c=a.textContent?.trim();if(c)return c}return"Connection"},"Edge")}for(let o of t.querySelectorAll(".edgeLabel")){let r=o.textContent?.trim();if(!r)continue;n(o,()=>r,"Edge")}for(let o of t.querySelectorAll(".actor")){let r=o.closest("g")?.querySelector("text")||o.parentElement?.querySelector("text");if(!r)continue;let s=o.closest("g");if(!s||s.hasAttribute("data-clickable"))continue;s.setAttribute("data-clickable","true"),n(s,()=>r.textContent?.trim()||"Participant","Node")}for(let o of t.querySelectorAll(".messageText")){let r=o.textContent?.trim();if(!r)continue;n(o,()=>r,"Edge")}for(let o of t.querySelectorAll(".entityBox")){let r=o.closest("g");if(!r||r.hasAttribute("data-clickable"))continue;let s=r.querySelector(".entityLabel");if(!s)continue;r.setAttribute("data-clickable","true"),n(r,()=>s.textContent?.trim()||"Entity","Node")}for(let o of t.querySelectorAll(".relationshipLabel")){let r=o.textContent?.trim();if(!r)continue;let i=o.closest("g")||o;if(i.hasAttribute("data-clickable"))continue;i.setAttribute("data-clickable","true"),n(i,()=>r,"Edge")}for(let o of t.querySelectorAll(".classGroup")){let r=o;if(r.hasAttribute("data-clickable"))continue;let s=r.querySelector(".classTitle, .classTitleText, text");if(!s)continue;r.setAttribute("data-clickable","true"),n(r,()=>s.textContent?.trim()||"Class","Node")}for(let o of t.querySelectorAll(".statediagram-state")){let r=o;if(r.hasAttribute("data-clickable"))continue;let s=r.querySelector(".state-title, text");if(!s)continue;r.setAttribute("data-clickable","true"),n(r,()=>s.textContent?.trim()||"State","Node")}for(let o of t.querySelectorAll(".mindmap-node")){let r=o;if(r.hasAttribute("data-clickable"))continue;let s=r.querySelector(".mindmap-node-label, text");if(!s)continue;r.setAttribute("data-clickable","true"),n(r,()=>s.textContent?.trim()||"Node","Node")}}function kn(t,e,n){let o=new Map;for(let s of e){let i=s.snippet.match(/^\[Diagram (?:node|edge)\] (.+)$/)?.[1];if(i)o.set(i,s.id)}for(let s of t.querySelectorAll("[data-annotated]"))s.style.outline="",s.style.outlineOffset="",s.style.borderRadius="",s.removeAttribute("data-annotated");if(o.size===0)return;for(let s of t.querySelectorAll(".node")){let l=(s.querySelector(".nodeLabel")||s.querySelector("foreignObject span")||s.querySelector("text"))?.textContent?.trim();if(!l||!o.has(l))continue;let a=o.get(l),c=s;c.setAttribute("data-annotated",a);let u=a===n;c.style.outline=u?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",c.style.outlineOffset="2px",c.style.borderRadius="4px"}for(let s of t.querySelectorAll(".edgeLabel")){let i=s.textContent?.trim();if(!i||!o.has(i))continue;let l=o.get(i),a=s;a.setAttribute("data-annotated",l);let c=l===n;a.style.outline=c?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",a.style.outlineOffset="2px",a.style.borderRadius="4px"}for(let s of t.querySelectorAll(".actor")){let i=s.closest("g");if(!i)continue;let a=i.querySelector("text")?.textContent?.trim();if(!a||!o.has(a))continue;if(i.hasAttribute("data-annotated"))continue;let c=o.get(a);i.setAttribute("data-annotated",c);let u=c===n,p=i.querySelector("rect");if(p)p.style.outline=u?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",p.style.outlineOffset="2px",p.style.borderRadius="4px"}for(let s of t.querySelectorAll(".messageText")){let i=s.textContent?.trim();if(!i||!o.has(i))continue;let l=o.get(i),a=s;a.setAttribute("data-annotated",l);let c=l===n;a.style.outline=c?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",a.style.outlineOffset="2px",a.style.borderRadius="4px"}let r=(s,i,l)=>{for(let a of t.querySelectorAll(s)){let c=l(a);if(!c||c.hasAttribute("data-annotated"))continue;let p=c.querySelector(i)?.textContent?.trim();if(!p||!o.has(p))continue;let g=o.get(p);c.setAttribute("data-annotated",g);let h=g===n,d=c.querySelector("rect, circle, ellipse, polygon")||c;d.style.outline=h?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",d.style.outlineOffset="2px",d.style.borderRadius="4px"}};r(".entityBox",".entityLabel",(s)=>s.closest("g"));for(let s of t.querySelectorAll(".relationshipLabel")){let l=s.closest("g")||s;if(l.hasAttribute("data-annotated"))continue;let a=s.textContent?.trim();if(!a||!o.has(a))continue;let c=o.get(a);l.setAttribute("data-annotated",c);let u=c===n;l.style.outline=u?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",l.style.outlineOffset="2px",l.style.borderRadius="4px"}r(".classGroup",".classTitle, .classTitleText, text",(s)=>s),r(".statediagram-state",".state-title, text",(s)=>s),r(".mindmap-node",".mindmap-node-label, text",(s)=>s)}import{jsxDEV as Co}from"react/jsx-dev-runtime";function No({children:t}){return Co("div",{className:"relative bg-bg-elevated rounded-lg px-5 py-4 mt-3 text-body text-text-secondary italic leading-relaxed","data-md":"note",children:ie(t)},void 0,!1,void 0,this)}import{jsxDEV as Po}from"react/jsx-dev-runtime";var Io={high:"text-accent-red bg-accent-red-muted",medium:"text-accent-amber bg-accent-amber-muted",low:"text-text-tertiary bg-border-subtle"};function Lo({level:t}){return Po("span",{className:`inline text-tiny font-medium font-body ml-2 px-1.5 py-0.5 rounded ${Io[t]}`,"data-md":"priority","data-md-level":t,children:t},void 0,!1,void 0,this)}import{useState as Mo}from"react";import{jsxDEV as ge}from"react/jsx-dev-runtime";function $o({title:t,children:e}){let[n,o]=Mo(!1);return ge("div",{className:"relative mb-8 p-4 group/section","data-md":"section","data-md-title":t,children:[ge("div",{className:"relative mb-2",children:[ge("button",{onClick:()=>o(!n),className:`absolute -left-8 top-1/2 -translate-y-1/2 text-text-tertiary opacity-0 group-hover/section:opacity-50 hover:!opacity-100 transition-all duration-150 p-0.5 ${n?"-rotate-90":""}`,children:ge("svg",{width:"14",height:"14",viewBox:"0 0 12 12",fill:"none",children:ge("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),ge("h2",{className:"font-heading text-section text-text-primary",style:{fontWeight:400},children:t},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ge("div",{className:n?"mt-6 hidden":"mt-6",children:ie(e)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as le}from"react/jsx-dev-runtime";function Oo({headers:t,rows:e}){return le("div",{className:"overflow-x-auto mt-3","data-md":"table",children:le("table",{className:"w-full text-body",children:[le("thead",{children:le("tr",{className:"border-b border-border-subtle",children:t.map((n,o)=>le("th",{className:"text-left px-4 py-2.5 text-meta font-medium uppercase tracking-wider text-text-tertiary font-body",children:n},o,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),le("tbody",{children:e.map((n,o)=>le("tr",{className:`relative border-b border-border-subtle last:border-b-0 transition-colors hover:bg-bg-surface/50 ${o%2===1?"bg-bg-surface/30":""}`,children:n.map((r,s)=>le("td",{className:"px-4 py-2.5 text-text-secondary font-body",children:r},s,!1,void 0,this))},o,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as re}from"react/jsx-dev-runtime";var _o={todo:"bg-border-hover",done:"bg-accent-green",blocked:"bg-accent-red","in-progress":"bg-accent-blue"},Ho={todo:"Todo",done:"Done",blocked:"Blocked","in-progress":"In progress"},zo={info:"bg-accent-blue-muted text-accent-blue",success:"bg-accent-green-muted text-accent-green",warning:"bg-accent-amber-muted text-accent-amber",danger:"bg-accent-red-muted text-accent-red",neutral:"bg-border-subtle text-text-tertiary"};function An({id:t,label:e,status:n,badge:o,badgeVariant:r="neutral",children:s}){return re("div",{className:"group/task relative -mx-4 px-4 py-3 rounded-md transition-colors duration-150 hover:bg-bg-input","data-task-id":t,"data-md":"item","data-md-label":e,...n?{"data-md-status":n}:{},...o?{"data-md-badge":o}:{},children:re("div",{className:"flex items-start gap-3",children:[n&&re("span",{className:`w-2 h-2 rounded-full mt-[7px] flex-shrink-0 ${_o[n]}`},void 0,!1,void 0,this),re("div",{className:"flex-1 min-w-0",children:[re("div",{className:"flex items-baseline gap-2",children:[re("span",{className:"font-body text-task-label font-semibold text-text-primary",children:e},void 0,!1,void 0,this),n&&re("span",{className:"font-body text-tiny uppercase tracking-wider text-text-tertiary opacity-0 group-hover/task:opacity-100 transition-opacity duration-150",children:Ho[n]},void 0,!1,void 0,this),o&&re("span",{className:`font-body text-tiny font-medium px-1.5 py-px rounded-full ${zo[r]}`,children:o},void 0,!1,void 0,this)]},void 0,!0,void 0,this),s&&re("div",{className:"text-body text-text-secondary mt-1 leading-relaxed",children:ie(s)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function Do(t){return re(An,{...t},void 0,!1,void 0,this)}import{useAnnotations as Rn,useResponseRegistration as Tn}from"#canvas/runtime";import{useRef as Bo,useState as En}from"react";import{jsxDEV as T}from"react/jsx-dev-runtime";function qo({id:t,label:e,placeholder:n,multiline:o,required:r}){let{responses:s,setResponse:i}=Rn();Tn(t);let l=s.get(t),a=l?.value??"",c=l?.note||"",[u,p]=En(!1),g=Bo(null);if(!s.has(t))i(t,{id:t,type:"text",label:e,value:"",required:r});let h=(m)=>{i(t,{...l,value:m})},d=(m)=>oe(m,o?60:32),f=l?.required&&!a.trim();return T("div",{"data-md":"userinput","data-md-label":e,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[T("div",{className:"flex items-baseline gap-2 mb-2",children:[T("span",{className:"text-[13px] font-body font-medium text-text-primary",children:e},void 0,!1,void 0,this),r&&T("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),T("textarea",{ref:g,value:a,onChange:(m)=>{h(m.currentTarget.value),d(m.currentTarget)},placeholder:n||"Type your response...",rows:o?3:1,className:"w-full bg-bg-input text-[13px] font-body text-text-primary rounded-lg px-3 py-2 resize-none focus:outline-none border border-border-subtle focus:border-border-hover placeholder:text-text-tertiary transition-colors",onInput:(m)=>d(m.currentTarget),onFocus:(m)=>d(m.currentTarget)},void 0,!1,void 0,this),T(ke,{show:u,note:c,onToggle:()=>p(!u),onChange:(m)=>i(t,{...l,note:m})},void 0,!1,void 0,this),f&&T("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"This field is required."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Fo({id:t,label:e,min:n=1,max:o=10,step:r=1,required:s,minLabel:i,maxLabel:l}){let{responses:a,setResponse:c}=Rn();Tn(t);let u=a.get(t),p=u?.value,g=u?.note||"",[h,d]=En(!1);if(!a.has(t))c(t,{id:t,type:"range",label:e,value:null,required:s});let f=(L)=>{c(t,{...u,value:L})},m=p!==null&&p!==void 0,b=m?p:Math.round((n+o)/2),R=(b-n)/(o-n)*100,v=Math.round((o-n)/r),w=v<=20,N=u?.required&&!m;return T("div",{"data-md":"rangeinput","data-md-label":e,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[T("div",{className:"flex items-baseline justify-between mb-1",children:[T("div",{className:"flex items-baseline gap-2",children:[T("span",{className:"text-[13px] font-body font-medium text-text-primary",children:e},void 0,!1,void 0,this),s&&T("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),T("span",{className:"flex items-center gap-1.5",children:[T("span",{className:`text-[13px] font-mono ${m?"text-accent-amber":"text-text-disabled"}`,children:m?p:"—"},void 0,!1,void 0,this),m&&T("button",{onClick:()=>c(t,{...u,value:null}),className:"text-text-disabled hover:text-text-tertiary transition-colors text-[10px] leading-none",title:"Clear",children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),T("div",{className:"relative h-6 flex items-center",children:[T("div",{className:"absolute left-0 right-0 h-1.5 rounded-full bg-border-medium",children:m&&T("div",{className:"h-full rounded-full bg-accent-amber transition-all duration-150",style:{width:`${R}%`}},void 0,!1,void 0,this)},void 0,!1,void 0,this),w&&Array.from({length:v+1},(L,F)=>{let U=n+F*r,Y=(U-n)/(o-n)*100,C=m&&U<=p;return T("div",{className:`absolute rounded-full pointer-events-none transition-all duration-150 ${m&&U===p?"w-2.5 h-2.5 bg-accent-amber":C?"w-1.5 h-1.5 bg-accent-amber":"w-1.5 h-1.5 bg-border-hover"}`,style:{left:`${Y}%`,transform:"translate(-50%, -50%)",top:"50%"}},F,!1,void 0,this)}),m?T("div",{className:"absolute h-5 w-5 rounded-full bg-accent-amber shadow-md pointer-events-none transition-all duration-150",style:{left:`calc(${R}% - 10px)`,borderWidth:"2px",borderStyle:"solid",borderColor:"var(--color-bg-base)"}},void 0,!1,void 0,this):T("div",{className:"absolute h-4 w-4 rounded-full bg-border-hover pointer-events-none opacity-50",style:{left:"calc(50% - 8px)",borderWidth:"2px",borderStyle:"solid",borderColor:"var(--color-bg-base)"}},void 0,!1,void 0,this),T("input",{type:"range",min:n,max:o,step:r,value:b,onChange:(L)=>f(Number(L.currentTarget.value)),className:"absolute inset-0 w-full opacity-0 cursor-pointer"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w&&v<=10?T("div",{className:"flex justify-between -mt-0.5 px-0",children:Array.from({length:v+1},(L,F)=>{let U=n+F*r;return T("span",{className:`text-[10px] font-mono transition-colors ${m&&U===p?"text-accent-amber font-medium":"text-text-disabled"}`,style:{minWidth:"1ch",textAlign:"center"},children:U},F,!1,void 0,this)})},void 0,!1,void 0,this):T("div",{className:"flex justify-between -mt-0.5",children:[T("span",{className:"text-[11px] text-text-tertiary font-body",children:i||n},void 0,!1,void 0,this),T("span",{className:"text-[11px] text-text-tertiary font-body",children:l||o},void 0,!1,void 0,this)]},void 0,!0,void 0,this),T(ke,{show:h,note:g,onToggle:()=>d(!h),onChange:(L)=>c(t,{...u,note:L})},void 0,!1,void 0,this),N&&T("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"Please select a value."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as Qo,useState as Je}from"react";import{useFeedback as Jo}from"#canvas/runtime";async function Nn(t){let e=Go(t);return crypto.subtle.importKey("raw",e,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}async function Cn(t,e){let n=In(e);if(n.byteLength<28)throw Error("Ciphertext too short");let o=n.subarray(0,12),r=n.subarray(12),s=await crypto.subtle.decrypt({name:"AES-GCM",iv:o},t,r);return new TextDecoder().decode(s)}function In(t){let e=atob(t),n=new Uint8Array(e.length);for(let o=0;o<e.length;o++)n[o]=e.charCodeAt(o);return n}function Go(t){let e=t.replace(/-/g,"+").replace(/_/g,"/")+"===".slice((t.length+3)%4);return In(e)}function Uo(){if(typeof window>"u")return null;let t=window.location.hash.replace(/^#/,"");if(!t)return null;for(let e of t.split("&")){let[n,o]=e.split("=");if(n==="k"&&o)return decodeURIComponent(o)}return null}function Wo(){if(typeof window<"u"&&window.__CANVAS_SHARE__?.shareId){let e=Uo();return{isShared:!0,shareId:window.__CANVAS_SHARE__.shareId,encryptionKey:e?Nn(e):null}}return{isShared:!1,sessionId:typeof window<"u"?window.location.pathname.replace("/s/",""):""}}var P=Wo();function Vo(){return P.isShared&&P.encryptionKey!==null}function jo(){return P.isShared?P.shareId:P.sessionId}function Ko(t,e){let n=t.replace(/\.jsx$/,".js");if(P.isShared)return`/s/${P.shareId}/canvas/${encodeURIComponent(n)}`;let o=e?`?rev=${e}&t=${Date.now()}`:`?t=${Date.now()}`;return`/api/session/${P.sessionId}/canvas/${encodeURIComponent(n)}${o}`}function Zo(){if(P.isShared)return`/s/${P.shareId}/upload`;return`/api/session/${P.sessionId}/upload`}function Nt(t,e){if(P.isShared)throw Error("Secret inputs are available only on the local canvas daemon");return`/api/session/${encodeURIComponent(P.sessionId)}/secrets/${encodeURIComponent(t)}/${e}`}async function Ct(t){let e=await t.json().catch(()=>null);if(typeof e==="object"&&e!==null&&"error"in e&&typeof e.error==="string")return Error(e.error);return Error(`Secret API request failed with status ${t.status}`)}async function Ln(t){let e=await fetch(Nt(t,"status"),{cache:"no-store"});if(!e.ok)throw await Ct(e);let n=await e.json();return typeof n==="object"&&n!==null&&"ready"in n&&n.ready===!0}async function Pn(t,e){let n=await fetch(Nt(t,"value"),{method:"POST",headers:{"Content-Type":"application/json"},cache:"no-store",body:JSON.stringify({value:e})});if(!n.ok)throw await Ct(n)}async function Mn(t){let e=await fetch(Nt(t,"value"),{method:"DELETE",cache:"no-store"});if(!e.ok)throw await Ct(e)}async function Yo(t,e){let n=Ko(t,e);if(!Vo())return import(n);let o=await fetch(n);if(!o.ok)throw Error(`canvas ${o.status}`);let r=await o.text(),s=await P.encryptionKey,i=await Cn(s,r),l=new Blob([i],{type:"application/javascript"}),a=URL.createObjectURL(l);try{return await import(a)}finally{setTimeout(()=>URL.revokeObjectURL(a),0)}}var Xo=!P.isShared,mc=!P.isShared,xc={get sessionId(){return jo()},isShared:P.isShared,fsAvailable:Xo,uploadUrl:Zo,loadCanvasModule:Yo};import{jsxDEV as q}from"react/jsx-dev-runtime";var es=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/,ts=/^[A-Za-z_][A-Za-z0-9_]*$/;function ns({id:t,label:e,env:n,placeholder:o,required:r}){let[s,i]=Je(""),[l,a]=Je(!1),[c,u]=Je(!P.isShared),[p,g]=Je(null),h=es.test(t),d=ts.test(n),f=!P.isShared;Qo(()=>{if(!f||!h){u(!1);return}let w=!0;return Ln(t).then((N)=>{if(w)a(N)}).catch((N)=>{if(w)g(N instanceof Error?N.message:"Could not read secret status")}).finally(()=>{if(w)u(!1)}),()=>{w=!1}},[t,f,h]);let m=l?`**${e}**
|
|
64
|
+
Secret is ready. Field: \`${t}\`. Environment variable: \`${n}\`.
|
|
65
|
+
`:"";Jo(`secret:${t}`,m,{label:e,required:r&&f});let b=async()=>{if(!s||!h||!d)return;u(!0),g(null);try{await Pn(t,s),i(""),a(!0)}catch(w){g(w instanceof Error?w.message:"Could not store secret")}finally{u(!1)}},R=async()=>{u(!0),g(null);try{await Mn(t),a(!1)}catch(w){g(w instanceof Error?w.message:"Could not clear secret")}finally{u(!1)}};if(!f)return q("div",{"data-md":"secretinput","data-md-label":e,className:"-mx-4 px-4 py-3 my-1 rounded-lg bg-accent-amber-muted",children:[q("div",{className:"text-[13px] font-body font-medium text-text-primary",children:e},void 0,!1,void 0,this),q("p",{className:"text-[12px] font-body text-text-secondary mt-1",children:"Secret input is unavailable in shared canvases. Open this runbook on the author's local canvas daemon."},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let v=!h?"Secret field IDs may contain letters, numbers, dots, underscores, and hyphens.":!d?"Environment variable names must use letters, numbers, and underscores and may not start with a number.":null;return q("div",{"data-md":"secretinput","data-md-label":e,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[q("div",{className:"flex items-baseline justify-between gap-3 mb-2",children:[q("div",{className:"flex items-baseline gap-2",children:[q("span",{className:"text-[13px] font-body font-medium text-text-primary",children:e},void 0,!1,void 0,this),r&&q("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q("span",{className:`text-[11px] font-body ${l?"text-accent-green":"text-text-tertiary"}`,children:c?"Working…":l?"Ready in memory":"Not stored"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q("div",{className:"flex gap-2",children:[q("input",{type:"password",value:s,onChange:(w)=>i(w.target.value),onKeyDown:(w)=>{if(w.key==="Enter")w.preventDefault(),b()},placeholder:o||"Paste secret value",autoComplete:"off",spellCheck:!1,disabled:c||!!v,className:"min-w-0 flex-1 bg-bg-input text-[13px] font-mono text-text-primary rounded-lg px-3 py-2 focus:outline-none border border-border-subtle focus:border-border-hover placeholder:text-text-tertiary disabled:opacity-50 transition-colors"},void 0,!1,void 0,this),q("button",{type:"button",onClick:()=>void b(),disabled:c||!s||!!v,className:"px-3 py-2 rounded-lg bg-btn-primary text-btn-primary-text text-[12px] font-body font-medium disabled:opacity-40 disabled:cursor-default",children:l?"Replace":"Store"},void 0,!1,void 0,this),l&&q("button",{type:"button",onClick:()=>void R(),disabled:c,className:"px-3 py-2 rounded-lg border border-border-subtle text-text-secondary text-[12px] font-body font-medium hover:border-border-hover disabled:opacity-40",children:"Clear"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),q("p",{className:"text-[11px] font-body text-text-tertiary mt-1.5",children:["Stored only in daemon memory. The agent receives field ",t," for ",n,", not the value."]},void 0,!0,void 0,this),(v||p)&&q("p",{className:"text-[11px] text-accent-red font-body mt-1",children:v||p},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}export{Er as Callout,Nr as Checklist,ro as Choice,ao as CodeBlock,co as Diff,go as FilePreview,yo as ImageView,An as Item,vo as Markdown,To as Mermaid,oo as MultiChoice,No as Note,Lo as Priority,Fo as RangeInput,ns as SecretInput,$o as Section,Oo as Table,Do as Task,qo as UserInput,Yl as useFeedback};
|