@fabrika/builder 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/BUILD-CONTRACT.md +8 -0
  2. package/README.md +9 -0
  3. package/cli/src/bin.ts +35 -2
  4. package/cli/src/build-status.ts +7 -15
  5. package/cli/src/commands/advance.ts +3 -2
  6. package/cli/src/commands/ensure-daemon.ts +3 -3
  7. package/cli/src/commands/gate.ts +4 -10
  8. package/cli/src/commands/init.ts +44 -7
  9. package/cli/src/commands/next.ts +3 -3
  10. package/cli/src/commands/platform.ts +81 -0
  11. package/cli/src/config.ts +1 -9
  12. package/cli/src/context.ts +4 -1
  13. package/cli/src/daemon-client.ts +36 -185
  14. package/cli/src/daemon-lifecycle.ts +63 -142
  15. package/cli/src/derive.ts +4 -8
  16. package/cli/src/errors.ts +1 -0
  17. package/cli/src/index.ts +2 -3
  18. package/cli/src/inject-skills.ts +8 -31
  19. package/cli/src/layout.ts +8 -18
  20. package/cli/src/packet.ts +18 -17
  21. package/cli/src/platform-client.ts +40 -0
  22. package/daemon/src/admission.ts +19 -0
  23. package/daemon/src/bin.ts +7 -9
  24. package/daemon/src/handlers.ts +82 -79
  25. package/daemon/src/index.ts +14 -5
  26. package/daemon/src/paths.ts +5 -6
  27. package/daemon/src/phases.ts +27 -126
  28. package/daemon/src/platform-compiler.ts +21 -0
  29. package/daemon/src/platform-remote.ts +146 -0
  30. package/daemon/src/platform-routes.ts +46 -0
  31. package/daemon/src/platform-source.ts +147 -0
  32. package/daemon/src/platform-storage.ts +222 -0
  33. package/daemon/src/platform.ts +481 -0
  34. package/decisions/README.md +4 -0
  35. package/decisions/patterns/zerops-control-deploy.md +49 -0
  36. package/decisions/patterns/zerops-local-app.md +57 -0
  37. package/decisions/patterns/zerops-postgres-seeds.md +37 -0
  38. package/decisions/technologies/zerops-fabrika-auth.md +53 -0
  39. package/decisions/technologies/zerops-platform.md +64 -0
  40. package/package.json +13 -5
  41. package/shared/index.ts +365 -0
  42. package/{cli/src → shared}/phases.ts +42 -50
  43. package/shared/urls.ts +41 -0
  44. package/skill/SKILL.md +34 -0
  45. package/stacks/README.md +2 -0
  46. package/stacks/zerops-app.md +66 -0
  47. package/ui/dist/assets/client.2fkhreps.js +214 -0
  48. package/ui/dist/assets/client.css +1 -1
  49. package/ui/dist/assets/components.js +57 -57
  50. package/ui/dist/index.html +1 -1
  51. package/ui/dist/assets/client.fhjppkvr.js +0 -214
@@ -1,63 +1,63 @@
1
- import{useFeedback as j$}from"#canvas/runtime";function n0(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var U0=n0();function b5(Q){U0=Q}var H0={exec:()=>null};function O(Q,$=""){let Y=typeof Q=="string"?Q:Q.source,B={replace:(J,W)=>{let K=typeof W=="string"?W:W.source;return K=K.replace(E.caret,"$1"),Y=Y.replace(J,K),B},getRegex:()=>new RegExp(Y,$)};return B}var T1=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),E={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:(Q)=>new RegExp(`^( {0,3}${Q})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:(Q)=>new RegExp(`^ {0,${Math.min(3,Q-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:(Q)=>new RegExp(`^ {0,${Math.min(3,Q-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:(Q)=>new RegExp(`^ {0,${Math.min(3,Q-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:(Q)=>new RegExp(`^ {0,${Math.min(3,Q-1)}}#`),htmlBeginRegex:(Q)=>new RegExp(`^ {0,${Math.min(3,Q-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:(Q)=>new RegExp(`^ {0,${Math.min(3,Q-1)}}>`)},O1=/^(?:[ \t]*(?:\n|$))+/,w1=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,A1=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,w0=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,S1=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,e0=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,I5=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,R5=O(I5).replace(/bull/g,e0).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(),C1=O(I5).replace(/bull/g,e0).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(),$5=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,k1=/^[^\n]+/,Q5=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,f1=O(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",Q5).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),v1=O(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,e0).getRegex(),j0="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",Y5=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,b1=O("^ {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",Y5).replace("tag",j0).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),V5=O($5).replace("hr",w0).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",j0).getRegex(),I1=O(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",V5).getRegex(),J5={blockquote:I1,code:w1,def:f1,fences:A1,heading:S1,hr:w0,html:b1,lheading:R5,list:v1,newline:O1,paragraph:V5,table:H0,text:k1},A5=O("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",w0).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",j0).getRegex(),R1={...J5,lheading:C1,table:A5,paragraph:O($5).replace("hr",w0).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",A5).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",j0).getRegex()},V1={...J5,html:O(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Y5).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:H0,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:O($5).replace("hr",w0).replace("heading",` *#{1,6} *[^
2
- ]`).replace("lheading",R5).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},m1=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,j1=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,m5=/^( {2,}|\\)\n(?!\s*$)/,D1=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,N0=/[\p{P}\p{S}]/u,D0=/[\s\p{P}\p{S}]/u,B5=/[^\s\p{P}\p{S}]/u,E1=O(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,D0).getRegex(),j5=/(?!~)[\p{P}\p{S}]/u,h1=/(?!~)[\s\p{P}\p{S}]/u,x1=/(?:[^\s\p{P}\p{S}]|~)/u,g1=O(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",T1?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),D5=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,u1=O(D5,"u").replace(/punct/g,N0).getRegex(),p1=O(D5,"u").replace(/punct/g,j5).getRegex(),E5="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",c1=O(E5,"gu").replace(/notPunctSpace/g,B5).replace(/punctSpace/g,D0).replace(/punct/g,N0).getRegex(),d1=O(E5,"gu").replace(/notPunctSpace/g,x1).replace(/punctSpace/g,h1).replace(/punct/g,j5).getRegex(),r1=O("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,B5).replace(/punctSpace/g,D0).replace(/punct/g,N0).getRegex(),l1=O(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,N0).getRegex(),i1="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",o1=O(i1,"gu").replace(/notPunctSpace/g,B5).replace(/punctSpace/g,D0).replace(/punct/g,N0).getRegex(),s1=O(/\\(punct)/,"gu").replace(/punct/g,N0).getRegex(),a1=O(/^<(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(),t1=O(Y5).replace("(?:-->|$)","-->").getRegex(),n1=O("^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",t1).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),R0=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,e1=O(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",R0).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),h5=O(/^!?\[(label)\]\[(ref)\]/).replace("label",R0).replace("ref",Q5).getRegex(),x5=O(/^!?\[(ref)\](?:\[\])?/).replace("ref",Q5).getRegex(),$2=O("reflink|nolink(?!\\()","g").replace("reflink",h5).replace("nolink",x5).getRegex(),S5=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,W5={_backpedal:H0,anyPunctuation:s1,autolink:a1,blockSkip:g1,br:m5,code:j1,del:H0,delLDelim:H0,delRDelim:H0,emStrongLDelim:u1,emStrongRDelimAst:c1,emStrongRDelimUnd:r1,escape:m1,link:e1,nolink:x5,punctuation:E1,reflink:h5,reflinkSearch:$2,tag:n1,text:D1,url:H0},Q2={...W5,link:O(/^!?\[(label)\]\((.*?)\)/).replace("label",R0).getRegex(),reflink:O(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",R0).getRegex()},t0={...W5,emStrongRDelimAst:d1,emStrongLDelim:p1,delLDelim:l1,delRDelim:o1,url:O(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",S5).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:O(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",S5).getRegex()},Y2={...t0,br:O(m5).replace("{2,}","*").getRegex(),text:O(t0.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},I0={normal:J5,gfm:R1,pedantic:V1},z0={normal:W5,gfm:t0,breaks:Y2,pedantic:Q2},J2={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},C5=(Q)=>J2[Q];function n(Q,$){if($){if(E.escapeTest.test(Q))return Q.replace(E.escapeReplace,C5)}else if(E.escapeTestNoEncode.test(Q))return Q.replace(E.escapeReplaceNoEncode,C5);return Q}function k5(Q){try{Q=encodeURI(Q).replace(E.percentDecode,"%")}catch{return null}return Q}function f5(Q,$){let Y=Q.replace(E.findPipe,(W,K,q)=>{let X=!1,H=K;for(;--H>=0&&q[H]==="\\";)X=!X;return X?"|":" |"}),B=Y.split(E.splitPipe),J=0;if(B[0].trim()||B.shift(),B.length>0&&!B.at(-1)?.trim()&&B.pop(),$)if(B.length>$)B.splice($);else for(;B.length<$;)B.push("");for(;J<B.length;J++)B[J]=B[J].trim().replace(E.slashPipe,"|");return B}function T0(Q,$,Y){let B=Q.length;if(B===0)return"";let J=0;for(;J<B;){let W=Q.charAt(B-J-1);if(W===$&&!Y)J++;else if(W!==$&&Y)J++;else break}return Q.slice(0,B-J)}function B2(Q,$){if(Q.indexOf($[1])===-1)return-1;let Y=0;for(let B=0;B<Q.length;B++)if(Q[B]==="\\")B++;else if(Q[B]===$[0])Y++;else if(Q[B]===$[1]&&(Y--,Y<0))return B;return Y>0?-2:-1}function W2(Q,$=0){let Y=$,B="";for(let J of Q)if(J==="\t"){let W=4-Y%4;B+=" ".repeat(W),Y+=W}else B+=J,Y++;return B}function v5(Q,$,Y,B,J){let W=$.href,K=$.title||null,q=Q[1].replace(J.other.outputLinkReplace,"$1");B.state.inLink=!0;let X={type:Q[0].charAt(0)==="!"?"image":"link",raw:Y,href:W,title:K,text:q,tokens:B.inlineTokens(q)};return B.state.inLink=!1,X}function K2(Q,$,Y){let B=Q.match(Y.other.indentCodeCompensation);if(B===null)return $;let J=B[1];return $.split(`
3
- `).map((W)=>{let K=W.match(Y.other.beginningSpace);if(K===null)return W;let[q]=K;return q.length>=J.length?W.slice(J.length):W}).join(`
4
- `)}var V0=class{options;rules;lexer;constructor(Q){this.options=Q||U0}space(Q){let $=this.rules.block.newline.exec(Q);if($&&$[0].length>0)return{type:"space",raw:$[0]}}code(Q){let $=this.rules.block.code.exec(Q);if($){let Y=$[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:$[0],codeBlockStyle:"indented",text:this.options.pedantic?Y:T0(Y,`
5
- `)}}}fences(Q){let $=this.rules.block.fences.exec(Q);if($){let Y=$[0],B=K2(Y,$[3]||"",this.rules);return{type:"code",raw:Y,lang:$[2]?$[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):$[2],text:B}}}heading(Q){let $=this.rules.block.heading.exec(Q);if($){let Y=$[2].trim();if(this.rules.other.endingHash.test(Y)){let B=T0(Y,"#");(this.options.pedantic||!B||this.rules.other.endingSpaceChar.test(B))&&(Y=B.trim())}return{type:"heading",raw:$[0],depth:$[1].length,text:Y,tokens:this.lexer.inline(Y)}}}hr(Q){let $=this.rules.block.hr.exec(Q);if($)return{type:"hr",raw:T0($[0],`
6
- `)}}blockquote(Q){let $=this.rules.block.blockquote.exec(Q);if($){let Y=T0($[0],`
1
+ var o5=Object.defineProperty;var n5=($)=>$;function a5($,J){this[$]=n5.bind(null,J)}var s5=($,J)=>{for(var Q in J)o5($,Q,{get:J[Q],enumerable:!0,configurable:!0,set:a5.bind(J,Q)})};import{useFeedback as wQ}from"#canvas/runtime";function X1(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var u$=X1();function l1($){u$=$}var Z$={exec:()=>null};function E($,J=""){let Q=typeof $=="string"?$:$.source,q={replace:(W,Y)=>{let X=typeof Y=="string"?Y:Y.source;return X=X.replace(a.caret,"$1"),Q=Q.replace(W,X),q},getRegex:()=>new RegExp(Q,J)};return q}var t5=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),a={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:($)=>new RegExp(`^( {0,3}${$})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}#`),htmlBeginRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:($)=>new RegExp(`^ {0,${Math.min(3,$-1)}}>`)},e5=/^(?:[ \t]*(?:\n|$))+/,$2=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,J2=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,F0=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Q2=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,H1=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,c1=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,p1=E(c1).replace(/bull/g,H1).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(),W2=E(c1).replace(/bull/g,H1).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(),G1=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,q2=/^[^\n]+/,B1=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,Y2=E(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",B1).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),X2=E(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,H1).getRegex(),m0="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",_1=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,H2=E("^ {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",_1).replace("tag",m0).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),d1=E(G1).replace("hr",F0).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",m0).getRegex(),G2=E(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",d1).getRegex(),M1={blockquote:G2,code:$2,def:Y2,fences:J2,heading:Q2,hr:F0,html:H2,lheading:p1,list:X2,newline:e5,paragraph:d1,table:Z$,text:q2},g1=E("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",F0).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",m0).getRegex(),B2={...M1,lheading:W2,table:g1,paragraph:E(G1).replace("hr",F0).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",g1).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",m0).getRegex()},_2={...M1,html:E(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",_1).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:Z$,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:E(G1).replace("hr",F0).replace("heading",` *#{1,6} *[^
2
+ ]`).replace("lheading",p1).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},M2=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,U2=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,r1=/^( {2,}|\\)\n(?!\s*$)/,w2=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,n$=/[\p{P}\p{S}]/u,Z0=/[\s\p{P}\p{S}]/u,U1=/[^\s\p{P}\p{S}]/u,z2=E(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Z0).getRegex(),i1=/(?!~)[\p{P}\p{S}]/u,N2=/(?!~)[\s\p{P}\p{S}]/u,K2=/(?:[^\s\p{P}\p{S}]|~)/u,O2=E(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",t5?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),o1=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,L2=E(o1,"u").replace(/punct/g,n$).getRegex(),F2=E(o1,"u").replace(/punct/g,i1).getRegex(),n1="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",S2=E(n1,"gu").replace(/notPunctSpace/g,U1).replace(/punctSpace/g,Z0).replace(/punct/g,n$).getRegex(),A2=E(n1,"gu").replace(/notPunctSpace/g,K2).replace(/punctSpace/g,N2).replace(/punct/g,i1).getRegex(),b2=E("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,U1).replace(/punctSpace/g,Z0).replace(/punct/g,n$).getRegex(),f2=E(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,n$).getRegex(),v2="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",R2=E(v2,"gu").replace(/notPunctSpace/g,U1).replace(/punctSpace/g,Z0).replace(/punct/g,n$).getRegex(),j2=E(/\\(punct)/,"gu").replace(/punct/g,n$).getRegex(),V2=E(/^<(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(),P2=E(_1).replace("(?:-->|$)","-->").getRegex(),D2=E("^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",P2).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),y0=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,C2=E(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",y0).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),a1=E(/^!?\[(label)\]\[(ref)\]/).replace("label",y0).replace("ref",B1).getRegex(),s1=E(/^!?\[(ref)\](?:\[\])?/).replace("ref",B1).getRegex(),k2=E("reflink|nolink(?!\\()","g").replace("reflink",a1).replace("nolink",s1).getRegex(),h1=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,w1={_backpedal:Z$,anyPunctuation:j2,autolink:V2,blockSkip:O2,br:r1,code:U2,del:Z$,delLDelim:Z$,delRDelim:Z$,emStrongLDelim:L2,emStrongRDelimAst:S2,emStrongRDelimUnd:b2,escape:M2,link:C2,nolink:s1,punctuation:z2,reflink:a1,reflinkSearch:k2,tag:D2,text:w2,url:Z$},E2={...w1,link:E(/^!?\[(label)\]\((.*?)\)/).replace("label",y0).getRegex(),reflink:E(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",y0).getRegex()},Y1={...w1,emStrongRDelimAst:A2,emStrongLDelim:F2,delLDelim:f2,delRDelim:R2,url:E(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",h1).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:E(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",h1).getRegex()},T2={...Y1,br:E(r1).replace("{2,}","*").getRegex(),text:E(Y1.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},I0={normal:M1,gfm:B2,pedantic:_2},K0={normal:w1,gfm:Y1,breaks:T2,pedantic:E2},I2={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},m1=($)=>I2[$];function O$($,J){if(J){if(a.escapeTest.test($))return $.replace(a.escapeReplace,m1)}else if(a.escapeTestNoEncode.test($))return $.replace(a.escapeReplaceNoEncode,m1);return $}function Z1($){try{$=encodeURI($).replace(a.percentDecode,"%")}catch{return null}return $}function x1($,J){let Q=$.replace(a.findPipe,(Y,X,G)=>{let H=!1,B=X;for(;--B>=0&&G[B]==="\\";)H=!H;return H?"|":" |"}),q=Q.split(a.splitPipe),W=0;if(q[0].trim()||q.shift(),q.length>0&&!q.at(-1)?.trim()&&q.pop(),J)if(q.length>J)q.splice(J);else for(;q.length<J;)q.push("");for(;W<q.length;W++)q[W]=q[W].trim().replace(a.slashPipe,"|");return q}function O0($,J,Q){let q=$.length;if(q===0)return"";let W=0;for(;W<q;){let Y=$.charAt(q-W-1);if(Y===J&&!Q)W++;else if(Y!==J&&Q)W++;else break}return $.slice(0,q-W)}function y2($,J){if($.indexOf(J[1])===-1)return-1;let Q=0;for(let q=0;q<$.length;q++)if($[q]==="\\")q++;else if($[q]===J[0])Q++;else if($[q]===J[1]&&(Q--,Q<0))return q;return Q>0?-2:-1}function g2($,J=0){let Q=J,q="";for(let W of $)if(W==="\t"){let Y=4-Q%4;q+=" ".repeat(Y),Q+=Y}else q+=W,Q++;return q}function u1($,J,Q,q,W){let Y=J.href,X=J.title||null,G=$[1].replace(W.other.outputLinkReplace,"$1");q.state.inLink=!0;let H={type:$[0].charAt(0)==="!"?"image":"link",raw:Q,href:Y,title:X,text:G,tokens:q.inlineTokens(G)};return q.state.inLink=!1,H}function h2($,J,Q){let q=$.match(Q.other.indentCodeCompensation);if(q===null)return J;let W=q[1];return J.split(`
3
+ `).map((Y)=>{let X=Y.match(Q.other.beginningSpace);if(X===null)return Y;let[G]=X;return G.length>=W.length?Y.slice(W.length):Y}).join(`
4
+ `)}var g0=class{options;rules;lexer;constructor($){this.options=$||u$}space($){let J=this.rules.block.newline.exec($);if(J&&J[0].length>0)return{type:"space",raw:J[0]}}code($){let J=this.rules.block.code.exec($);if(J){let Q=J[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:J[0],codeBlockStyle:"indented",text:this.options.pedantic?Q:O0(Q,`
5
+ `)}}}fences($){let J=this.rules.block.fences.exec($);if(J){let Q=J[0],q=h2(Q,J[3]||"",this.rules);return{type:"code",raw:Q,lang:J[2]?J[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):J[2],text:q}}}heading($){let J=this.rules.block.heading.exec($);if(J){let Q=J[2].trim();if(this.rules.other.endingHash.test(Q)){let q=O0(Q,"#");(this.options.pedantic||!q||this.rules.other.endingSpaceChar.test(q))&&(Q=q.trim())}return{type:"heading",raw:J[0],depth:J[1].length,text:Q,tokens:this.lexer.inline(Q)}}}hr($){let J=this.rules.block.hr.exec($);if(J)return{type:"hr",raw:O0(J[0],`
6
+ `)}}blockquote($){let J=this.rules.block.blockquote.exec($);if(J){let Q=O0(J[0],`
7
7
  `).split(`
8
- `),B="",J="",W=[];for(;Y.length>0;){let K=!1,q=[],X;for(X=0;X<Y.length;X++)if(this.rules.other.blockquoteStart.test(Y[X]))q.push(Y[X]),K=!0;else if(!K)q.push(Y[X]);else break;Y=Y.slice(X);let H=q.join(`
9
- `),G=H.replace(this.rules.other.blockquoteSetextReplace,`
10
- $1`).replace(this.rules.other.blockquoteSetextReplace2,"");B=B?`${B}
11
- ${H}`:H,J=J?`${J}
12
- ${G}`:G;let Z=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(G,W,!0),this.lexer.state.top=Z,Y.length===0)break;let _=W.at(-1);if(_?.type==="code")break;if(_?.type==="blockquote"){let N=_,U=N.raw+`
13
- `+Y.join(`
14
- `),y=this.blockquote(U);W[W.length-1]=y,B=B.substring(0,B.length-N.raw.length)+y.raw,J=J.substring(0,J.length-N.text.length)+y.text;break}else if(_?.type==="list"){let N=_,U=N.raw+`
15
- `+Y.join(`
16
- `),y=this.list(U);W[W.length-1]=y,B=B.substring(0,B.length-_.raw.length)+y.raw,J=J.substring(0,J.length-N.raw.length)+y.raw,Y=U.substring(W.at(-1).raw.length).split(`
17
- `);continue}}return{type:"blockquote",raw:B,tokens:W,text:J}}}list(Q){let $=this.rules.block.list.exec(Q);if($){let Y=$[1].trim(),B=Y.length>1,J={type:"list",raw:"",ordered:B,start:B?+Y.slice(0,-1):"",loose:!1,items:[]};Y=B?`\\d{1,9}\\${Y.slice(-1)}`:`\\${Y}`,this.options.pedantic&&(Y=B?Y:"[*+-]");let W=this.rules.other.listItemRegex(Y),K=!1;for(;Q;){let X=!1,H="",G="";if(!($=W.exec(Q))||this.rules.block.hr.test(Q))break;H=$[0],Q=Q.substring(H.length);let Z=W2($[2].split(`
18
- `,1)[0],$[1].length),_=Q.split(`
19
- `,1)[0],N=!Z.trim(),U=0;if(this.options.pedantic?(U=2,G=Z.trimStart()):N?U=$[1].length+1:(U=Z.search(this.rules.other.nonSpaceChar),U=U>4?1:U,G=Z.slice(U),U+=$[1].length),N&&this.rules.other.blankLine.test(_)&&(H+=_+`
20
- `,Q=Q.substring(_.length+1),X=!0),!X){let y=this.rules.other.nextBulletRegex(U),P=this.rules.other.hrRegex(U),L=this.rules.other.fencesBeginRegex(U),w=this.rules.other.headingBeginRegex(U),A=this.rules.other.htmlBeginRegex(U),I=this.rules.other.blockquoteBeginRegex(U);for(;Q;){let v=Q.split(`
21
- `,1)[0],b;if(_=v,this.options.pedantic?(_=_.replace(this.rules.other.listReplaceNesting," "),b=_):b=_.replace(this.rules.other.tabCharGlobal," "),L.test(_)||w.test(_)||A.test(_)||I.test(_)||y.test(_)||P.test(_))break;if(b.search(this.rules.other.nonSpaceChar)>=U||!_.trim())G+=`
22
- `+b.slice(U);else{if(N||Z.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||L.test(Z)||w.test(Z)||P.test(Z))break;G+=`
23
- `+_}N=!_.trim(),H+=v+`
24
- `,Q=Q.substring(v.length+1),Z=b.slice(U)}}J.loose||(K?J.loose=!0:this.rules.other.doubleBlankLine.test(H)&&(K=!0)),J.items.push({type:"list_item",raw:H,task:!!this.options.gfm&&this.rules.other.listIsTask.test(G),loose:!1,text:G,tokens:[]}),J.raw+=H}let q=J.items.at(-1);if(q)q.raw=q.raw.trimEnd(),q.text=q.text.trimEnd();else return;J.raw=J.raw.trimEnd();for(let X of J.items){if(this.lexer.state.top=!1,X.tokens=this.lexer.blockTokens(X.text,[]),X.task){if(X.text=X.text.replace(this.rules.other.listReplaceTask,""),X.tokens[0]?.type==="text"||X.tokens[0]?.type==="paragraph"){X.tokens[0].raw=X.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),X.tokens[0].text=X.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let G=this.lexer.inlineQueue.length-1;G>=0;G--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[G].src)){this.lexer.inlineQueue[G].src=this.lexer.inlineQueue[G].src.replace(this.rules.other.listReplaceTask,"");break}}let H=this.rules.other.listTaskCheckbox.exec(X.raw);if(H){let G={type:"checkbox",raw:H[0]+" ",checked:H[0]!=="[ ]"};X.checked=G.checked,J.loose?X.tokens[0]&&["paragraph","text"].includes(X.tokens[0].type)&&"tokens"in X.tokens[0]&&X.tokens[0].tokens?(X.tokens[0].raw=G.raw+X.tokens[0].raw,X.tokens[0].text=G.raw+X.tokens[0].text,X.tokens[0].tokens.unshift(G)):X.tokens.unshift({type:"paragraph",raw:G.raw,text:G.raw,tokens:[G]}):X.tokens.unshift(G)}}if(!J.loose){let H=X.tokens.filter((Z)=>Z.type==="space"),G=H.length>0&&H.some((Z)=>this.rules.other.anyLine.test(Z.raw));J.loose=G}}if(J.loose)for(let X of J.items){X.loose=!0;for(let H of X.tokens)H.type==="text"&&(H.type="paragraph")}return J}}html(Q){let $=this.rules.block.html.exec(Q);if($)return{type:"html",block:!0,raw:$[0],pre:$[1]==="pre"||$[1]==="script"||$[1]==="style",text:$[0]}}def(Q){let $=this.rules.block.def.exec(Q);if($){let Y=$[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),B=$[2]?$[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",J=$[3]?$[3].substring(1,$[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):$[3];return{type:"def",tag:Y,raw:$[0],href:B,title:J}}}table(Q){let $=this.rules.block.table.exec(Q);if(!$||!this.rules.other.tableDelimiter.test($[2]))return;let Y=f5($[1]),B=$[2].replace(this.rules.other.tableAlignChars,"").split("|"),J=$[3]?.trim()?$[3].replace(this.rules.other.tableRowBlankLine,"").split(`
25
- `):[],W={type:"table",raw:$[0],header:[],align:[],rows:[]};if(Y.length===B.length){for(let K of B)this.rules.other.tableAlignRight.test(K)?W.align.push("right"):this.rules.other.tableAlignCenter.test(K)?W.align.push("center"):this.rules.other.tableAlignLeft.test(K)?W.align.push("left"):W.align.push(null);for(let K=0;K<Y.length;K++)W.header.push({text:Y[K],tokens:this.lexer.inline(Y[K]),header:!0,align:W.align[K]});for(let K of J)W.rows.push(f5(K,W.header.length).map((q,X)=>({text:q,tokens:this.lexer.inline(q),header:!1,align:W.align[X]})));return W}}lheading(Q){let $=this.rules.block.lheading.exec(Q);if($){let Y=$[1].trim();return{type:"heading",raw:$[0],depth:$[2].charAt(0)==="="?1:2,text:Y,tokens:this.lexer.inline(Y)}}}paragraph(Q){let $=this.rules.block.paragraph.exec(Q);if($){let Y=$[1].charAt($[1].length-1)===`
26
- `?$[1].slice(0,-1):$[1];return{type:"paragraph",raw:$[0],text:Y,tokens:this.lexer.inline(Y)}}}text(Q){let $=this.rules.block.text.exec(Q);if($)return{type:"text",raw:$[0],text:$[0],tokens:this.lexer.inline($[0])}}escape(Q){let $=this.rules.inline.escape.exec(Q);if($)return{type:"escape",raw:$[0],text:$[1]}}tag(Q){let $=this.rules.inline.tag.exec(Q);if($)return!this.lexer.state.inLink&&this.rules.other.startATag.test($[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test($[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test($[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test($[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:$[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:$[0]}}link(Q){let $=this.rules.inline.link.exec(Q);if($){let Y=$[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(Y)){if(!this.rules.other.endAngleBracket.test(Y))return;let W=T0(Y.slice(0,-1),"\\");if((Y.length-W.length)%2===0)return}else{let W=B2($[2],"()");if(W===-2)return;if(W>-1){let K=($[0].indexOf("!")===0?5:4)+$[1].length+W;$[2]=$[2].substring(0,W),$[0]=$[0].substring(0,K).trim(),$[3]=""}}let B=$[2],J="";if(this.options.pedantic){let W=this.rules.other.pedanticHrefTitle.exec(B);W&&(B=W[1],J=W[3])}else J=$[3]?$[3].slice(1,-1):"";return B=B.trim(),this.rules.other.startAngleBracket.test(B)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(Y)?B=B.slice(1):B=B.slice(1,-1)),v5($,{href:B&&B.replace(this.rules.inline.anyPunctuation,"$1"),title:J&&J.replace(this.rules.inline.anyPunctuation,"$1")},$[0],this.lexer,this.rules)}}reflink(Q,$){let Y;if((Y=this.rules.inline.reflink.exec(Q))||(Y=this.rules.inline.nolink.exec(Q))){let B=(Y[2]||Y[1]).replace(this.rules.other.multipleSpaceGlobal," "),J=$[B.toLowerCase()];if(!J){let W=Y[0].charAt(0);return{type:"text",raw:W,text:W}}return v5(Y,J,Y[0],this.lexer,this.rules)}}emStrong(Q,$,Y=""){let B=this.rules.inline.emStrongLDelim.exec(Q);if(!B||!B[1]&&!B[2]&&!B[3]&&!B[4]||B[4]&&Y.match(this.rules.other.unicodeAlphaNumeric))return;if(!(B[1]||B[3])||!Y||this.rules.inline.punctuation.exec(Y)){let J=[...B[0]].length-1,W,K,q=J,X=0,H=B[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(H.lastIndex=0,$=$.slice(-1*Q.length+J);(B=H.exec($))!==null;){if(W=B[1]||B[2]||B[3]||B[4]||B[5]||B[6],!W)continue;if(K=[...W].length,B[3]||B[4]){q+=K;continue}else if((B[5]||B[6])&&J%3&&!((J+K)%3)){X+=K;continue}if(q-=K,q>0)continue;K=Math.min(K,K+q+X);let G=[...B[0]][0].length,Z=Q.slice(0,J+B.index+G+K);if(Math.min(J,K)%2){let N=Z.slice(1,-1);return{type:"em",raw:Z,text:N,tokens:this.lexer.inlineTokens(N)}}let _=Z.slice(2,-2);return{type:"strong",raw:Z,text:_,tokens:this.lexer.inlineTokens(_)}}}}codespan(Q){let $=this.rules.inline.code.exec(Q);if($){let Y=$[2].replace(this.rules.other.newLineCharGlobal," "),B=this.rules.other.nonSpaceChar.test(Y),J=this.rules.other.startingSpaceChar.test(Y)&&this.rules.other.endingSpaceChar.test(Y);return B&&J&&(Y=Y.substring(1,Y.length-1)),{type:"codespan",raw:$[0],text:Y}}}br(Q){let $=this.rules.inline.br.exec(Q);if($)return{type:"br",raw:$[0]}}del(Q,$,Y=""){let B=this.rules.inline.delLDelim.exec(Q);if(!B)return;if(!B[1]||!Y||this.rules.inline.punctuation.exec(Y)){let J=[...B[0]].length-1,W,K,q=J,X=this.rules.inline.delRDelim;for(X.lastIndex=0,$=$.slice(-1*Q.length+J);(B=X.exec($))!==null;){if(W=B[1]||B[2]||B[3]||B[4]||B[5]||B[6],!W||(K=[...W].length,K!==J))continue;if(B[3]||B[4]){q+=K;continue}if(q-=K,q>0)continue;K=Math.min(K,K+q);let H=[...B[0]][0].length,G=Q.slice(0,J+B.index+H+K),Z=G.slice(J,-J);return{type:"del",raw:G,text:Z,tokens:this.lexer.inlineTokens(Z)}}}}autolink(Q){let $=this.rules.inline.autolink.exec(Q);if($){let Y,B;return $[2]==="@"?(Y=$[1],B="mailto:"+Y):(Y=$[1],B=Y),{type:"link",raw:$[0],text:Y,href:B,tokens:[{type:"text",raw:Y,text:Y}]}}}url(Q){let $;if($=this.rules.inline.url.exec(Q)){let Y,B;if($[2]==="@")Y=$[0],B="mailto:"+Y;else{let J;do J=$[0],$[0]=this.rules.inline._backpedal.exec($[0])?.[0]??"";while(J!==$[0]);Y=$[0],$[1]==="www."?B="http://"+$[0]:B=$[0]}return{type:"link",raw:$[0],text:Y,href:B,tokens:[{type:"text",raw:Y,text:Y}]}}}inlineText(Q){let $=this.rules.inline.text.exec(Q);if($){let Y=this.lexer.state.inRawBlock;return{type:"text",raw:$[0],text:$[0],escaped:Y}}}},r=class Q{tokens;options;state;inlineQueue;tokenizer;constructor($){this.tokens=[],this.tokens.links=Object.create(null),this.options=$||U0,this.options.tokenizer=this.options.tokenizer||new V0,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let Y={other:E,block:I0.normal,inline:z0.normal};this.options.pedantic?(Y.block=I0.pedantic,Y.inline=z0.pedantic):this.options.gfm&&(Y.block=I0.gfm,this.options.breaks?Y.inline=z0.breaks:Y.inline=z0.gfm),this.tokenizer.rules=Y}static get rules(){return{block:I0,inline:z0}}static lex($,Y){return new Q(Y).lex($)}static lexInline($,Y){return new Q(Y).inlineTokens($)}lex($){$=$.replace(E.carriageReturn,`
27
- `),this.blockTokens($,this.tokens);for(let Y=0;Y<this.inlineQueue.length;Y++){let B=this.inlineQueue[Y];this.inlineTokens(B.src,B.tokens)}return this.inlineQueue=[],this.tokens}blockTokens($,Y=[],B=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&($=$.replace(E.tabCharGlobal," ").replace(E.spaceLine,""));$;){let J;if(this.options.extensions?.block?.some((K)=>(J=K.call({lexer:this},$,Y))?($=$.substring(J.raw.length),Y.push(J),!0):!1))continue;if(J=this.tokenizer.space($)){$=$.substring(J.raw.length);let K=Y.at(-1);J.raw.length===1&&K!==void 0?K.raw+=`
28
- `:Y.push(J);continue}if(J=this.tokenizer.code($)){$=$.substring(J.raw.length);let K=Y.at(-1);K?.type==="paragraph"||K?.type==="text"?(K.raw+=(K.raw.endsWith(`
8
+ `),q="",W="",Y=[];for(;Q.length>0;){let X=!1,G=[],H;for(H=0;H<Q.length;H++)if(this.rules.other.blockquoteStart.test(Q[H]))G.push(Q[H]),X=!0;else if(!X)G.push(Q[H]);else break;Q=Q.slice(H);let B=G.join(`
9
+ `),_=B.replace(this.rules.other.blockquoteSetextReplace,`
10
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");q=q?`${q}
11
+ ${B}`:B,W=W?`${W}
12
+ ${_}`:_;let w=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(_,Y,!0),this.lexer.state.top=w,Q.length===0)break;let L=Y.at(-1);if(L?.type==="code")break;if(L?.type==="blockquote"){let F=L,U=F.raw+`
13
+ `+Q.join(`
14
+ `),K=this.blockquote(U);Y[Y.length-1]=K,q=q.substring(0,q.length-F.raw.length)+K.raw,W=W.substring(0,W.length-F.text.length)+K.text;break}else if(L?.type==="list"){let F=L,U=F.raw+`
15
+ `+Q.join(`
16
+ `),K=this.list(U);Y[Y.length-1]=K,q=q.substring(0,q.length-L.raw.length)+K.raw,W=W.substring(0,W.length-F.raw.length)+K.raw,Q=U.substring(Y.at(-1).raw.length).split(`
17
+ `);continue}}return{type:"blockquote",raw:q,tokens:Y,text:W}}}list($){let J=this.rules.block.list.exec($);if(J){let Q=J[1].trim(),q=Q.length>1,W={type:"list",raw:"",ordered:q,start:q?+Q.slice(0,-1):"",loose:!1,items:[]};Q=q?`\\d{1,9}\\${Q.slice(-1)}`:`\\${Q}`,this.options.pedantic&&(Q=q?Q:"[*+-]");let Y=this.rules.other.listItemRegex(Q),X=!1;for(;$;){let H=!1,B="",_="";if(!(J=Y.exec($))||this.rules.block.hr.test($))break;B=J[0],$=$.substring(B.length);let w=g2(J[2].split(`
18
+ `,1)[0],J[1].length),L=$.split(`
19
+ `,1)[0],F=!w.trim(),U=0;if(this.options.pedantic?(U=2,_=w.trimStart()):F?U=J[1].length+1:(U=w.search(this.rules.other.nonSpaceChar),U=U>4?1:U,_=w.slice(U),U+=J[1].length),F&&this.rules.other.blankLine.test(L)&&(B+=L+`
20
+ `,$=$.substring(L.length+1),H=!0),!H){let K=this.rules.other.nextBulletRegex(U),O=this.rules.other.hrRegex(U),R=this.rules.other.fencesBeginRegex(U),T=this.rules.other.headingBeginRegex(U),I=this.rules.other.htmlBeginRegex(U),l=this.rules.other.blockquoteBeginRegex(U);for(;$;){let x=$.split(`
21
+ `,1)[0],u;if(L=x,this.options.pedantic?(L=L.replace(this.rules.other.listReplaceNesting," "),u=L):u=L.replace(this.rules.other.tabCharGlobal," "),R.test(L)||T.test(L)||I.test(L)||l.test(L)||K.test(L)||O.test(L))break;if(u.search(this.rules.other.nonSpaceChar)>=U||!L.trim())_+=`
22
+ `+u.slice(U);else{if(F||w.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||R.test(w)||T.test(w)||O.test(w))break;_+=`
23
+ `+L}F=!L.trim(),B+=x+`
24
+ `,$=$.substring(x.length+1),w=u.slice(U)}}W.loose||(X?W.loose=!0:this.rules.other.doubleBlankLine.test(B)&&(X=!0)),W.items.push({type:"list_item",raw:B,task:!!this.options.gfm&&this.rules.other.listIsTask.test(_),loose:!1,text:_,tokens:[]}),W.raw+=B}let G=W.items.at(-1);if(G)G.raw=G.raw.trimEnd(),G.text=G.text.trimEnd();else return;W.raw=W.raw.trimEnd();for(let H of W.items){if(this.lexer.state.top=!1,H.tokens=this.lexer.blockTokens(H.text,[]),H.task){if(H.text=H.text.replace(this.rules.other.listReplaceTask,""),H.tokens[0]?.type==="text"||H.tokens[0]?.type==="paragraph"){H.tokens[0].raw=H.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),H.tokens[0].text=H.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let _=this.lexer.inlineQueue.length-1;_>=0;_--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[_].src)){this.lexer.inlineQueue[_].src=this.lexer.inlineQueue[_].src.replace(this.rules.other.listReplaceTask,"");break}}let B=this.rules.other.listTaskCheckbox.exec(H.raw);if(B){let _={type:"checkbox",raw:B[0]+" ",checked:B[0]!=="[ ]"};H.checked=_.checked,W.loose?H.tokens[0]&&["paragraph","text"].includes(H.tokens[0].type)&&"tokens"in H.tokens[0]&&H.tokens[0].tokens?(H.tokens[0].raw=_.raw+H.tokens[0].raw,H.tokens[0].text=_.raw+H.tokens[0].text,H.tokens[0].tokens.unshift(_)):H.tokens.unshift({type:"paragraph",raw:_.raw,text:_.raw,tokens:[_]}):H.tokens.unshift(_)}}if(!W.loose){let B=H.tokens.filter((w)=>w.type==="space"),_=B.length>0&&B.some((w)=>this.rules.other.anyLine.test(w.raw));W.loose=_}}if(W.loose)for(let H of W.items){H.loose=!0;for(let B of H.tokens)B.type==="text"&&(B.type="paragraph")}return W}}html($){let J=this.rules.block.html.exec($);if(J)return{type:"html",block:!0,raw:J[0],pre:J[1]==="pre"||J[1]==="script"||J[1]==="style",text:J[0]}}def($){let J=this.rules.block.def.exec($);if(J){let Q=J[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),q=J[2]?J[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",W=J[3]?J[3].substring(1,J[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):J[3];return{type:"def",tag:Q,raw:J[0],href:q,title:W}}}table($){let J=this.rules.block.table.exec($);if(!J||!this.rules.other.tableDelimiter.test(J[2]))return;let Q=x1(J[1]),q=J[2].replace(this.rules.other.tableAlignChars,"").split("|"),W=J[3]?.trim()?J[3].replace(this.rules.other.tableRowBlankLine,"").split(`
25
+ `):[],Y={type:"table",raw:J[0],header:[],align:[],rows:[]};if(Q.length===q.length){for(let X of q)this.rules.other.tableAlignRight.test(X)?Y.align.push("right"):this.rules.other.tableAlignCenter.test(X)?Y.align.push("center"):this.rules.other.tableAlignLeft.test(X)?Y.align.push("left"):Y.align.push(null);for(let X=0;X<Q.length;X++)Y.header.push({text:Q[X],tokens:this.lexer.inline(Q[X]),header:!0,align:Y.align[X]});for(let X of W)Y.rows.push(x1(X,Y.header.length).map((G,H)=>({text:G,tokens:this.lexer.inline(G),header:!1,align:Y.align[H]})));return Y}}lheading($){let J=this.rules.block.lheading.exec($);if(J){let Q=J[1].trim();return{type:"heading",raw:J[0],depth:J[2].charAt(0)==="="?1:2,text:Q,tokens:this.lexer.inline(Q)}}}paragraph($){let J=this.rules.block.paragraph.exec($);if(J){let Q=J[1].charAt(J[1].length-1)===`
26
+ `?J[1].slice(0,-1):J[1];return{type:"paragraph",raw:J[0],text:Q,tokens:this.lexer.inline(Q)}}}text($){let J=this.rules.block.text.exec($);if(J)return{type:"text",raw:J[0],text:J[0],tokens:this.lexer.inline(J[0])}}escape($){let J=this.rules.inline.escape.exec($);if(J)return{type:"escape",raw:J[0],text:J[1]}}tag($){let J=this.rules.inline.tag.exec($);if(J)return!this.lexer.state.inLink&&this.rules.other.startATag.test(J[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(J[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(J[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(J[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:J[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:J[0]}}link($){let J=this.rules.inline.link.exec($);if(J){let Q=J[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(Q)){if(!this.rules.other.endAngleBracket.test(Q))return;let Y=O0(Q.slice(0,-1),"\\");if((Q.length-Y.length)%2===0)return}else{let Y=y2(J[2],"()");if(Y===-2)return;if(Y>-1){let X=(J[0].indexOf("!")===0?5:4)+J[1].length+Y;J[2]=J[2].substring(0,Y),J[0]=J[0].substring(0,X).trim(),J[3]=""}}let q=J[2],W="";if(this.options.pedantic){let Y=this.rules.other.pedanticHrefTitle.exec(q);Y&&(q=Y[1],W=Y[3])}else W=J[3]?J[3].slice(1,-1):"";return q=q.trim(),this.rules.other.startAngleBracket.test(q)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(Q)?q=q.slice(1):q=q.slice(1,-1)),u1(J,{href:q&&q.replace(this.rules.inline.anyPunctuation,"$1"),title:W&&W.replace(this.rules.inline.anyPunctuation,"$1")},J[0],this.lexer,this.rules)}}reflink($,J){let Q;if((Q=this.rules.inline.reflink.exec($))||(Q=this.rules.inline.nolink.exec($))){let q=(Q[2]||Q[1]).replace(this.rules.other.multipleSpaceGlobal," "),W=J[q.toLowerCase()];if(!W){let Y=Q[0].charAt(0);return{type:"text",raw:Y,text:Y}}return u1(Q,W,Q[0],this.lexer,this.rules)}}emStrong($,J,Q=""){let q=this.rules.inline.emStrongLDelim.exec($);if(!q||!q[1]&&!q[2]&&!q[3]&&!q[4]||q[4]&&Q.match(this.rules.other.unicodeAlphaNumeric))return;if(!(q[1]||q[3])||!Q||this.rules.inline.punctuation.exec(Q)){let W=[...q[0]].length-1,Y,X,G=W,H=0,B=q[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(B.lastIndex=0,J=J.slice(-1*$.length+W);(q=B.exec(J))!==null;){if(Y=q[1]||q[2]||q[3]||q[4]||q[5]||q[6],!Y)continue;if(X=[...Y].length,q[3]||q[4]){G+=X;continue}else if((q[5]||q[6])&&W%3&&!((W+X)%3)){H+=X;continue}if(G-=X,G>0)continue;X=Math.min(X,X+G+H);let _=[...q[0]][0].length,w=$.slice(0,W+q.index+_+X);if(Math.min(W,X)%2){let F=w.slice(1,-1);return{type:"em",raw:w,text:F,tokens:this.lexer.inlineTokens(F)}}let L=w.slice(2,-2);return{type:"strong",raw:w,text:L,tokens:this.lexer.inlineTokens(L)}}}}codespan($){let J=this.rules.inline.code.exec($);if(J){let Q=J[2].replace(this.rules.other.newLineCharGlobal," "),q=this.rules.other.nonSpaceChar.test(Q),W=this.rules.other.startingSpaceChar.test(Q)&&this.rules.other.endingSpaceChar.test(Q);return q&&W&&(Q=Q.substring(1,Q.length-1)),{type:"codespan",raw:J[0],text:Q}}}br($){let J=this.rules.inline.br.exec($);if(J)return{type:"br",raw:J[0]}}del($,J,Q=""){let q=this.rules.inline.delLDelim.exec($);if(!q)return;if(!q[1]||!Q||this.rules.inline.punctuation.exec(Q)){let W=[...q[0]].length-1,Y,X,G=W,H=this.rules.inline.delRDelim;for(H.lastIndex=0,J=J.slice(-1*$.length+W);(q=H.exec(J))!==null;){if(Y=q[1]||q[2]||q[3]||q[4]||q[5]||q[6],!Y||(X=[...Y].length,X!==W))continue;if(q[3]||q[4]){G+=X;continue}if(G-=X,G>0)continue;X=Math.min(X,X+G);let B=[...q[0]][0].length,_=$.slice(0,W+q.index+B+X),w=_.slice(W,-W);return{type:"del",raw:_,text:w,tokens:this.lexer.inlineTokens(w)}}}}autolink($){let J=this.rules.inline.autolink.exec($);if(J){let Q,q;return J[2]==="@"?(Q=J[1],q="mailto:"+Q):(Q=J[1],q=Q),{type:"link",raw:J[0],text:Q,href:q,tokens:[{type:"text",raw:Q,text:Q}]}}}url($){let J;if(J=this.rules.inline.url.exec($)){let Q,q;if(J[2]==="@")Q=J[0],q="mailto:"+Q;else{let W;do W=J[0],J[0]=this.rules.inline._backpedal.exec(J[0])?.[0]??"";while(W!==J[0]);Q=J[0],J[1]==="www."?q="http://"+J[0]:q=J[0]}return{type:"link",raw:J[0],text:Q,href:q,tokens:[{type:"text",raw:Q,text:Q}]}}}inlineText($){let J=this.rules.inline.text.exec($);if(J){let Q=this.lexer.state.inRawBlock;return{type:"text",raw:J[0],text:J[0],escaped:Q}}}},Y$=class ${tokens;options;state;inlineQueue;tokenizer;constructor(J){this.tokens=[],this.tokens.links=Object.create(null),this.options=J||u$,this.options.tokenizer=this.options.tokenizer||new g0,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 Q={other:a,block:I0.normal,inline:K0.normal};this.options.pedantic?(Q.block=I0.pedantic,Q.inline=K0.pedantic):this.options.gfm&&(Q.block=I0.gfm,this.options.breaks?Q.inline=K0.breaks:Q.inline=K0.gfm),this.tokenizer.rules=Q}static get rules(){return{block:I0,inline:K0}}static lex(J,Q){return new $(Q).lex(J)}static lexInline(J,Q){return new $(Q).inlineTokens(J)}lex(J){J=J.replace(a.carriageReturn,`
27
+ `),this.blockTokens(J,this.tokens);for(let Q=0;Q<this.inlineQueue.length;Q++){let q=this.inlineQueue[Q];this.inlineTokens(q.src,q.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(J,Q=[],q=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(J=J.replace(a.tabCharGlobal," ").replace(a.spaceLine,""));J;){let W;if(this.options.extensions?.block?.some((X)=>(W=X.call({lexer:this},J,Q))?(J=J.substring(W.raw.length),Q.push(W),!0):!1))continue;if(W=this.tokenizer.space(J)){J=J.substring(W.raw.length);let X=Q.at(-1);W.raw.length===1&&X!==void 0?X.raw+=`
28
+ `:Q.push(W);continue}if(W=this.tokenizer.code(J)){J=J.substring(W.raw.length);let X=Q.at(-1);X?.type==="paragraph"||X?.type==="text"?(X.raw+=(X.raw.endsWith(`
29
29
  `)?"":`
30
- `)+J.raw,K.text+=`
31
- `+J.text,this.inlineQueue.at(-1).src=K.text):Y.push(J);continue}if(J=this.tokenizer.fences($)){$=$.substring(J.raw.length),Y.push(J);continue}if(J=this.tokenizer.heading($)){$=$.substring(J.raw.length),Y.push(J);continue}if(J=this.tokenizer.hr($)){$=$.substring(J.raw.length),Y.push(J);continue}if(J=this.tokenizer.blockquote($)){$=$.substring(J.raw.length),Y.push(J);continue}if(J=this.tokenizer.list($)){$=$.substring(J.raw.length),Y.push(J);continue}if(J=this.tokenizer.html($)){$=$.substring(J.raw.length),Y.push(J);continue}if(J=this.tokenizer.def($)){$=$.substring(J.raw.length);let K=Y.at(-1);K?.type==="paragraph"||K?.type==="text"?(K.raw+=(K.raw.endsWith(`
30
+ `)+W.raw,X.text+=`
31
+ `+W.text,this.inlineQueue.at(-1).src=X.text):Q.push(W);continue}if(W=this.tokenizer.fences(J)){J=J.substring(W.raw.length),Q.push(W);continue}if(W=this.tokenizer.heading(J)){J=J.substring(W.raw.length),Q.push(W);continue}if(W=this.tokenizer.hr(J)){J=J.substring(W.raw.length),Q.push(W);continue}if(W=this.tokenizer.blockquote(J)){J=J.substring(W.raw.length),Q.push(W);continue}if(W=this.tokenizer.list(J)){J=J.substring(W.raw.length),Q.push(W);continue}if(W=this.tokenizer.html(J)){J=J.substring(W.raw.length),Q.push(W);continue}if(W=this.tokenizer.def(J)){J=J.substring(W.raw.length);let X=Q.at(-1);X?.type==="paragraph"||X?.type==="text"?(X.raw+=(X.raw.endsWith(`
32
32
  `)?"":`
33
- `)+J.raw,K.text+=`
34
- `+J.raw,this.inlineQueue.at(-1).src=K.text):this.tokens.links[J.tag]||(this.tokens.links[J.tag]={href:J.href,title:J.title},Y.push(J));continue}if(J=this.tokenizer.table($)){$=$.substring(J.raw.length),Y.push(J);continue}if(J=this.tokenizer.lheading($)){$=$.substring(J.raw.length),Y.push(J);continue}let W=$;if(this.options.extensions?.startBlock){let K=1/0,q=$.slice(1),X;this.options.extensions.startBlock.forEach((H)=>{X=H.call({lexer:this},q),typeof X=="number"&&X>=0&&(K=Math.min(K,X))}),K<1/0&&K>=0&&(W=$.substring(0,K+1))}if(this.state.top&&(J=this.tokenizer.paragraph(W))){let K=Y.at(-1);B&&K?.type==="paragraph"?(K.raw+=(K.raw.endsWith(`
33
+ `)+W.raw,X.text+=`
34
+ `+W.raw,this.inlineQueue.at(-1).src=X.text):this.tokens.links[W.tag]||(this.tokens.links[W.tag]={href:W.href,title:W.title},Q.push(W));continue}if(W=this.tokenizer.table(J)){J=J.substring(W.raw.length),Q.push(W);continue}if(W=this.tokenizer.lheading(J)){J=J.substring(W.raw.length),Q.push(W);continue}let Y=J;if(this.options.extensions?.startBlock){let X=1/0,G=J.slice(1),H;this.options.extensions.startBlock.forEach((B)=>{H=B.call({lexer:this},G),typeof H=="number"&&H>=0&&(X=Math.min(X,H))}),X<1/0&&X>=0&&(Y=J.substring(0,X+1))}if(this.state.top&&(W=this.tokenizer.paragraph(Y))){let X=Q.at(-1);q&&X?.type==="paragraph"?(X.raw+=(X.raw.endsWith(`
35
35
  `)?"":`
36
- `)+J.raw,K.text+=`
37
- `+J.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=K.text):Y.push(J),B=W.length!==$.length,$=$.substring(J.raw.length);continue}if(J=this.tokenizer.text($)){$=$.substring(J.raw.length);let K=Y.at(-1);K?.type==="text"?(K.raw+=(K.raw.endsWith(`
36
+ `)+W.raw,X.text+=`
37
+ `+W.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=X.text):Q.push(W),q=Y.length!==J.length,J=J.substring(W.raw.length);continue}if(W=this.tokenizer.text(J)){J=J.substring(W.raw.length);let X=Q.at(-1);X?.type==="text"?(X.raw+=(X.raw.endsWith(`
38
38
  `)?"":`
39
- `)+J.raw,K.text+=`
40
- `+J.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=K.text):Y.push(J);continue}if($){let K="Infinite loop on byte: "+$.charCodeAt(0);if(this.options.silent){console.error(K);break}else throw Error(K)}}return this.state.top=!0,Y}inline($,Y=[]){return this.inlineQueue.push({src:$,tokens:Y}),Y}inlineTokens($,Y=[]){this.tokenizer.lexer=this;let B=$,J=null;if(this.tokens.links){let X=Object.keys(this.tokens.links);if(X.length>0)for(;(J=this.tokenizer.rules.inline.reflinkSearch.exec(B))!==null;)X.includes(J[0].slice(J[0].lastIndexOf("[")+1,-1))&&(B=B.slice(0,J.index)+"["+"a".repeat(J[0].length-2)+"]"+B.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(J=this.tokenizer.rules.inline.anyPunctuation.exec(B))!==null;)B=B.slice(0,J.index)+"++"+B.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let W;for(;(J=this.tokenizer.rules.inline.blockSkip.exec(B))!==null;)W=J[2]?J[2].length:0,B=B.slice(0,J.index+W)+"["+"a".repeat(J[0].length-W-2)+"]"+B.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);B=this.options.hooks?.emStrongMask?.call({lexer:this},B)??B;let K=!1,q="";for(;$;){K||(q=""),K=!1;let X;if(this.options.extensions?.inline?.some((G)=>(X=G.call({lexer:this},$,Y))?($=$.substring(X.raw.length),Y.push(X),!0):!1))continue;if(X=this.tokenizer.escape($)){$=$.substring(X.raw.length),Y.push(X);continue}if(X=this.tokenizer.tag($)){$=$.substring(X.raw.length),Y.push(X);continue}if(X=this.tokenizer.link($)){$=$.substring(X.raw.length),Y.push(X);continue}if(X=this.tokenizer.reflink($,this.tokens.links)){$=$.substring(X.raw.length);let G=Y.at(-1);X.type==="text"&&G?.type==="text"?(G.raw+=X.raw,G.text+=X.text):Y.push(X);continue}if(X=this.tokenizer.emStrong($,B,q)){$=$.substring(X.raw.length),Y.push(X);continue}if(X=this.tokenizer.codespan($)){$=$.substring(X.raw.length),Y.push(X);continue}if(X=this.tokenizer.br($)){$=$.substring(X.raw.length),Y.push(X);continue}if(X=this.tokenizer.del($,B,q)){$=$.substring(X.raw.length),Y.push(X);continue}if(X=this.tokenizer.autolink($)){$=$.substring(X.raw.length),Y.push(X);continue}if(!this.state.inLink&&(X=this.tokenizer.url($))){$=$.substring(X.raw.length),Y.push(X);continue}let H=$;if(this.options.extensions?.startInline){let G=1/0,Z=$.slice(1),_;this.options.extensions.startInline.forEach((N)=>{_=N.call({lexer:this},Z),typeof _=="number"&&_>=0&&(G=Math.min(G,_))}),G<1/0&&G>=0&&(H=$.substring(0,G+1))}if(X=this.tokenizer.inlineText(H)){$=$.substring(X.raw.length),X.raw.slice(-1)!=="_"&&(q=X.raw.slice(-1)),K=!0;let G=Y.at(-1);G?.type==="text"?(G.raw+=X.raw,G.text+=X.text):Y.push(X);continue}if($){let G="Infinite loop on byte: "+$.charCodeAt(0);if(this.options.silent){console.error(G);break}else throw Error(G)}}return Y}},m0=class{options;parser;constructor(Q){this.options=Q||U0}space(Q){return""}code({text:Q,lang:$,escaped:Y}){let B=($||"").match(E.notSpaceStart)?.[0],J=Q.replace(E.endingNewline,"")+`
41
- `;return B?'<pre><code class="language-'+n(B)+'">'+(Y?J:n(J,!0))+`</code></pre>
42
- `:"<pre><code>"+(Y?J:n(J,!0))+`</code></pre>
43
- `}blockquote({tokens:Q}){return`<blockquote>
44
- ${this.parser.parse(Q)}</blockquote>
45
- `}html({text:Q}){return Q}def(Q){return""}heading({tokens:Q,depth:$}){return`<h${$}>${this.parser.parseInline(Q)}</h${$}>
46
- `}hr(Q){return`<hr>
47
- `}list(Q){let{ordered:$,start:Y}=Q,B="";for(let K=0;K<Q.items.length;K++){let q=Q.items[K];B+=this.listitem(q)}let J=$?"ol":"ul",W=$&&Y!==1?' start="'+Y+'"':"";return"<"+J+W+`>
48
- `+B+"</"+J+`>
49
- `}listitem(Q){return`<li>${this.parser.parse(Q.tokens)}</li>
50
- `}checkbox({checked:Q}){return"<input "+(Q?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:Q}){return`<p>${this.parser.parseInline(Q)}</p>
51
- `}table(Q){let $="",Y="";for(let J=0;J<Q.header.length;J++)Y+=this.tablecell(Q.header[J]);$+=this.tablerow({text:Y});let B="";for(let J=0;J<Q.rows.length;J++){let W=Q.rows[J];Y="";for(let K=0;K<W.length;K++)Y+=this.tablecell(W[K]);B+=this.tablerow({text:Y})}return B&&(B=`<tbody>${B}</tbody>`),`<table>
39
+ `)+W.raw,X.text+=`
40
+ `+W.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=X.text):Q.push(W);continue}if(J){let X="Infinite loop on byte: "+J.charCodeAt(0);if(this.options.silent){console.error(X);break}else throw Error(X)}}return this.state.top=!0,Q}inline(J,Q=[]){return this.inlineQueue.push({src:J,tokens:Q}),Q}inlineTokens(J,Q=[]){this.tokenizer.lexer=this;let q=J,W=null;if(this.tokens.links){let H=Object.keys(this.tokens.links);if(H.length>0)for(;(W=this.tokenizer.rules.inline.reflinkSearch.exec(q))!==null;)H.includes(W[0].slice(W[0].lastIndexOf("[")+1,-1))&&(q=q.slice(0,W.index)+"["+"a".repeat(W[0].length-2)+"]"+q.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(W=this.tokenizer.rules.inline.anyPunctuation.exec(q))!==null;)q=q.slice(0,W.index)+"++"+q.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let Y;for(;(W=this.tokenizer.rules.inline.blockSkip.exec(q))!==null;)Y=W[2]?W[2].length:0,q=q.slice(0,W.index+Y)+"["+"a".repeat(W[0].length-Y-2)+"]"+q.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);q=this.options.hooks?.emStrongMask?.call({lexer:this},q)??q;let X=!1,G="";for(;J;){X||(G=""),X=!1;let H;if(this.options.extensions?.inline?.some((_)=>(H=_.call({lexer:this},J,Q))?(J=J.substring(H.raw.length),Q.push(H),!0):!1))continue;if(H=this.tokenizer.escape(J)){J=J.substring(H.raw.length),Q.push(H);continue}if(H=this.tokenizer.tag(J)){J=J.substring(H.raw.length),Q.push(H);continue}if(H=this.tokenizer.link(J)){J=J.substring(H.raw.length),Q.push(H);continue}if(H=this.tokenizer.reflink(J,this.tokens.links)){J=J.substring(H.raw.length);let _=Q.at(-1);H.type==="text"&&_?.type==="text"?(_.raw+=H.raw,_.text+=H.text):Q.push(H);continue}if(H=this.tokenizer.emStrong(J,q,G)){J=J.substring(H.raw.length),Q.push(H);continue}if(H=this.tokenizer.codespan(J)){J=J.substring(H.raw.length),Q.push(H);continue}if(H=this.tokenizer.br(J)){J=J.substring(H.raw.length),Q.push(H);continue}if(H=this.tokenizer.del(J,q,G)){J=J.substring(H.raw.length),Q.push(H);continue}if(H=this.tokenizer.autolink(J)){J=J.substring(H.raw.length),Q.push(H);continue}if(!this.state.inLink&&(H=this.tokenizer.url(J))){J=J.substring(H.raw.length),Q.push(H);continue}let B=J;if(this.options.extensions?.startInline){let _=1/0,w=J.slice(1),L;this.options.extensions.startInline.forEach((F)=>{L=F.call({lexer:this},w),typeof L=="number"&&L>=0&&(_=Math.min(_,L))}),_<1/0&&_>=0&&(B=J.substring(0,_+1))}if(H=this.tokenizer.inlineText(B)){J=J.substring(H.raw.length),H.raw.slice(-1)!=="_"&&(G=H.raw.slice(-1)),X=!0;let _=Q.at(-1);_?.type==="text"?(_.raw+=H.raw,_.text+=H.text):Q.push(H);continue}if(J){let _="Infinite loop on byte: "+J.charCodeAt(0);if(this.options.silent){console.error(_);break}else throw Error(_)}}return Q}},h0=class{options;parser;constructor($){this.options=$||u$}space($){return""}code({text:$,lang:J,escaped:Q}){let q=(J||"").match(a.notSpaceStart)?.[0],W=$.replace(a.endingNewline,"")+`
41
+ `;return q?'<pre><code class="language-'+O$(q)+'">'+(Q?W:O$(W,!0))+`</code></pre>
42
+ `:"<pre><code>"+(Q?W:O$(W,!0))+`</code></pre>
43
+ `}blockquote({tokens:$}){return`<blockquote>
44
+ ${this.parser.parse($)}</blockquote>
45
+ `}html({text:$}){return $}def($){return""}heading({tokens:$,depth:J}){return`<h${J}>${this.parser.parseInline($)}</h${J}>
46
+ `}hr($){return`<hr>
47
+ `}list($){let{ordered:J,start:Q}=$,q="";for(let X=0;X<$.items.length;X++){let G=$.items[X];q+=this.listitem(G)}let W=J?"ol":"ul",Y=J&&Q!==1?' start="'+Q+'"':"";return"<"+W+Y+`>
48
+ `+q+"</"+W+`>
49
+ `}listitem($){return`<li>${this.parser.parse($.tokens)}</li>
50
+ `}checkbox({checked:$}){return"<input "+($?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:$}){return`<p>${this.parser.parseInline($)}</p>
51
+ `}table($){let J="",Q="";for(let W=0;W<$.header.length;W++)Q+=this.tablecell($.header[W]);J+=this.tablerow({text:Q});let q="";for(let W=0;W<$.rows.length;W++){let Y=$.rows[W];Q="";for(let X=0;X<Y.length;X++)Q+=this.tablecell(Y[X]);q+=this.tablerow({text:Q})}return q&&(q=`<tbody>${q}</tbody>`),`<table>
52
52
  <thead>
53
- `+$+`</thead>
54
- `+B+`</table>
55
- `}tablerow({text:Q}){return`<tr>
56
- ${Q}</tr>
57
- `}tablecell(Q){let $=this.parser.parseInline(Q.tokens),Y=Q.header?"th":"td";return(Q.align?`<${Y} align="${Q.align}">`:`<${Y}>`)+$+`</${Y}>
58
- `}strong({tokens:Q}){return`<strong>${this.parser.parseInline(Q)}</strong>`}em({tokens:Q}){return`<em>${this.parser.parseInline(Q)}</em>`}codespan({text:Q}){return`<code>${n(Q,!0)}</code>`}br(Q){return"<br>"}del({tokens:Q}){return`<del>${this.parser.parseInline(Q)}</del>`}link({href:Q,title:$,tokens:Y}){let B=this.parser.parseInline(Y),J=k5(Q);if(J===null)return B;Q=J;let W='<a href="'+Q+'"';return $&&(W+=' title="'+n($)+'"'),W+=">"+B+"</a>",W}image({href:Q,title:$,text:Y,tokens:B}){B&&(Y=this.parser.parseInline(B,this.parser.textRenderer));let J=k5(Q);if(J===null)return n(Y);Q=J;let W=`<img src="${Q}" alt="${n(Y)}"`;return $&&(W+=` title="${n($)}"`),W+=">",W}text(Q){return"tokens"in Q&&Q.tokens?this.parser.parseInline(Q.tokens):("escaped"in Q)&&Q.escaped?Q.text:n(Q.text)}},K5=class{strong({text:Q}){return Q}em({text:Q}){return Q}codespan({text:Q}){return Q}del({text:Q}){return Q}html({text:Q}){return Q}text({text:Q}){return Q}link({text:Q}){return""+Q}image({text:Q}){return""+Q}br(){return""}checkbox({raw:Q}){return Q}},l=class Q{options;renderer;textRenderer;constructor($){this.options=$||U0,this.options.renderer=this.options.renderer||new m0,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new K5}static parse($,Y){return new Q(Y).parse($)}static parseInline($,Y){return new Q(Y).parseInline($)}parse($){this.renderer.parser=this;let Y="";for(let B=0;B<$.length;B++){let J=$[B];if(this.options.extensions?.renderers?.[J.type]){let K=J,q=this.options.extensions.renderers[K.type].call({parser:this},K);if(q!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(K.type)){Y+=q||"";continue}}let W=J;switch(W.type){case"space":{Y+=this.renderer.space(W);break}case"hr":{Y+=this.renderer.hr(W);break}case"heading":{Y+=this.renderer.heading(W);break}case"code":{Y+=this.renderer.code(W);break}case"table":{Y+=this.renderer.table(W);break}case"blockquote":{Y+=this.renderer.blockquote(W);break}case"list":{Y+=this.renderer.list(W);break}case"checkbox":{Y+=this.renderer.checkbox(W);break}case"html":{Y+=this.renderer.html(W);break}case"def":{Y+=this.renderer.def(W);break}case"paragraph":{Y+=this.renderer.paragraph(W);break}case"text":{Y+=this.renderer.text(W);break}default:{let K='Token with "'+W.type+'" type was not found.';if(this.options.silent)return console.error(K),"";throw Error(K)}}}return Y}parseInline($,Y=this.renderer){this.renderer.parser=this;let B="";for(let J=0;J<$.length;J++){let W=$[J];if(this.options.extensions?.renderers?.[W.type]){let q=this.options.extensions.renderers[W.type].call({parser:this},W);if(q!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(W.type)){B+=q||"";continue}}let K=W;switch(K.type){case"escape":{B+=Y.text(K);break}case"html":{B+=Y.html(K);break}case"link":{B+=Y.link(K);break}case"image":{B+=Y.image(K);break}case"checkbox":{B+=Y.checkbox(K);break}case"strong":{B+=Y.strong(K);break}case"em":{B+=Y.em(K);break}case"codespan":{B+=Y.codespan(K);break}case"br":{B+=Y.br(K);break}case"del":{B+=Y.del(K);break}case"text":{B+=Y.text(K);break}default:{let q='Token with "'+K.type+'" type was not found.';if(this.options.silent)return console.error(q),"";throw Error(q)}}}return B}},O0=class{options;block;constructor(Q){this.options=Q||U0}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(Q){return Q}postprocess(Q){return Q}processAllTokens(Q){return Q}emStrongMask(Q){return Q}provideLexer(Q=this.block){return Q?r.lex:r.lexInline}provideParser(Q=this.block){return Q?l.parse:l.parseInline}},X2=class{defaults=n0();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=l;Renderer=m0;TextRenderer=K5;Lexer=r;Tokenizer=V0;Hooks=O0;constructor(...Q){this.use(...Q)}walkTokens(Q,$){let Y=[];for(let B of Q)switch(Y=Y.concat($.call(this,B)),B.type){case"table":{let J=B;for(let W of J.header)Y=Y.concat(this.walkTokens(W.tokens,$));for(let W of J.rows)for(let K of W)Y=Y.concat(this.walkTokens(K.tokens,$));break}case"list":{let J=B;Y=Y.concat(this.walkTokens(J.items,$));break}default:{let J=B;this.defaults.extensions?.childTokens?.[J.type]?this.defaults.extensions.childTokens[J.type].forEach((W)=>{let K=J[W].flat(1/0);Y=Y.concat(this.walkTokens(K,$))}):J.tokens&&(Y=Y.concat(this.walkTokens(J.tokens,$)))}}return Y}use(...Q){let $=this.defaults.extensions||{renderers:{},childTokens:{}};return Q.forEach((Y)=>{let B={...Y};if(B.async=this.defaults.async||B.async||!1,Y.extensions&&(Y.extensions.forEach((J)=>{if(!J.name)throw Error("extension name required");if("renderer"in J){let W=$.renderers[J.name];W?$.renderers[J.name]=function(...K){let q=J.renderer.apply(this,K);return q===!1&&(q=W.apply(this,K)),q}:$.renderers[J.name]=J.renderer}if("tokenizer"in J){if(!J.level||J.level!=="block"&&J.level!=="inline")throw Error("extension level must be 'block' or 'inline'");let W=$[J.level];W?W.unshift(J.tokenizer):$[J.level]=[J.tokenizer],J.start&&(J.level==="block"?$.startBlock?$.startBlock.push(J.start):$.startBlock=[J.start]:J.level==="inline"&&($.startInline?$.startInline.push(J.start):$.startInline=[J.start]))}"childTokens"in J&&J.childTokens&&($.childTokens[J.name]=J.childTokens)}),B.extensions=$),Y.renderer){let J=this.defaults.renderer||new m0(this.defaults);for(let W in Y.renderer){if(!(W in J))throw Error(`renderer '${W}' does not exist`);if(["options","parser"].includes(W))continue;let K=W,q=Y.renderer[K],X=J[K];J[K]=(...H)=>{let G=q.apply(J,H);return G===!1&&(G=X.apply(J,H)),G||""}}B.renderer=J}if(Y.tokenizer){let J=this.defaults.tokenizer||new V0(this.defaults);for(let W in Y.tokenizer){if(!(W in J))throw Error(`tokenizer '${W}' does not exist`);if(["options","rules","lexer"].includes(W))continue;let K=W,q=Y.tokenizer[K],X=J[K];J[K]=(...H)=>{let G=q.apply(J,H);return G===!1&&(G=X.apply(J,H)),G}}B.tokenizer=J}if(Y.hooks){let J=this.defaults.hooks||new O0;for(let W in Y.hooks){if(!(W in J))throw Error(`hook '${W}' does not exist`);if(["options","block"].includes(W))continue;let K=W,q=Y.hooks[K],X=J[K];O0.passThroughHooks.has(W)?J[K]=(H)=>{if(this.defaults.async&&O0.passThroughHooksRespectAsync.has(W))return(async()=>{let Z=await q.call(J,H);return X.call(J,Z)})();let G=q.call(J,H);return X.call(J,G)}:J[K]=(...H)=>{if(this.defaults.async)return(async()=>{let Z=await q.apply(J,H);return Z===!1&&(Z=await X.apply(J,H)),Z})();let G=q.apply(J,H);return G===!1&&(G=X.apply(J,H)),G}}B.hooks=J}if(Y.walkTokens){let J=this.defaults.walkTokens,W=Y.walkTokens;B.walkTokens=function(K){let q=[];return q.push(W.call(this,K)),J&&(q=q.concat(J.call(this,K))),q}}this.defaults={...this.defaults,...B}}),this}setOptions(Q){return this.defaults={...this.defaults,...Q},this}lexer(Q,$){return r.lex(Q,$??this.defaults)}parser(Q,$){return l.parse(Q,$??this.defaults)}parseMarkdown(Q){return($,Y)=>{let B={...Y},J={...this.defaults,...B},W=this.onError(!!J.silent,!!J.async);if(this.defaults.async===!0&&B.async===!1)return W(Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof $>"u"||$===null)return W(Error("marked(): input parameter is undefined or null"));if(typeof $!="string")return W(Error("marked(): input parameter is of type "+Object.prototype.toString.call($)+", string expected"));if(J.hooks&&(J.hooks.options=J,J.hooks.block=Q),J.async)return(async()=>{let K=J.hooks?await J.hooks.preprocess($):$,q=await(J.hooks?await J.hooks.provideLexer(Q):Q?r.lex:r.lexInline)(K,J),X=J.hooks?await J.hooks.processAllTokens(q):q;J.walkTokens&&await Promise.all(this.walkTokens(X,J.walkTokens));let H=await(J.hooks?await J.hooks.provideParser(Q):Q?l.parse:l.parseInline)(X,J);return J.hooks?await J.hooks.postprocess(H):H})().catch(W);try{J.hooks&&($=J.hooks.preprocess($));let K=(J.hooks?J.hooks.provideLexer(Q):Q?r.lex:r.lexInline)($,J);J.hooks&&(K=J.hooks.processAllTokens(K)),J.walkTokens&&this.walkTokens(K,J.walkTokens);let q=(J.hooks?J.hooks.provideParser(Q):Q?l.parse:l.parseInline)(K,J);return J.hooks&&(q=J.hooks.postprocess(q)),q}catch(K){return W(K)}}}onError(Q,$){return(Y)=>{if(Y.message+=`
59
- Please report this to https://github.com/markedjs/marked.`,Q){let B="<p>An error occurred:</p><pre>"+n(Y.message+"",!0)+"</pre>";return $?Promise.resolve(B):B}if($)return Promise.reject(Y);throw Y}}},G0=new X2;function T(Q,$){return G0.parse(Q,$)}T.options=T.setOptions=function(Q){return G0.setOptions(Q),T.defaults=G0.defaults,b5(T.defaults),T};T.getDefaults=n0;T.defaults=U0;T.use=function(...Q){return G0.use(...Q),T.defaults=G0.defaults,b5(T.defaults),T};T.walkTokens=function(Q,$){return G0.walkTokens(Q,$)};T.parseInline=G0.parseInline;T.Parser=l;T.parser=l.parse;T.Renderer=m0;T.TextRenderer=K5;T.Lexer=r;T.lexer=r.lex;T.Tokenizer=V0;T.Hooks=O0;T.parse=T;var{options:v4,setOptions:b4,use:I4,walkTokens:R4,parseInline:V4}=T;var m4=l.parse,j4=r.lex;import g5 from"react";import{jsxDEV as X5}from"react/jsx-dev-runtime";T.setOptions({gfm:!0,breaks:!1});var q2=new Set(["a","abbr","b","br","code","del","em","i","kbd","mark","q","s","small","span","strong","sub","sup","time","u"]),H2=new Set(["Priority"]);function G2(Q){if(typeof Q==="string"||typeof Q==="number")return!0;if(!g5.isValidElement(Q))return!1;if(typeof Q!=="object"||Q===null||!("type"in Q))return!1;let $=Q.type;if(typeof $==="string")return q2.has($);if(typeof $==="function"){let Y="displayName"in $&&typeof $.displayName==="string"?$.displayName:$.name;return Y?H2.has(Y):!1}return!1}function U2(Q,$){let Y=Q.trim();if(!Y)return null;let B=T.parse(Y,{async:!1});return X5("div",{className:"prose-canvas","data-md":"markdown","data-md-source":Y,dangerouslySetInnerHTML:{__html:B}},$,!1,void 0,this)}function Z2(Q,$){return X5("div",{className:"prose-canvas",children:Q.map((Y,B)=>{if(typeof Y==="string"||typeof Y==="number"){let J=T.parseInline(String(Y),{async:!1});return X5("span",{dangerouslySetInnerHTML:{__html:J}},B,!1,void 0,this)}return Y})},$,!1,void 0,this)}function J0(Q){let $=g5.Children.toArray(Q);if($.length===0)return null;let Y=[],B=[],J=0,W=()=>{if(B.length===0)return;if(B.some((q)=>typeof q!=="string"&&typeof q!=="number"))Y.push(Z2(B,`md-${J++}`));else{let q=U2(B.join(""),`md-${J++}`);if(q)Y.push(q)}B=[]};for(let K of $)if(G2(K))B.push(K);else W(),Y.push(K);return W(),Y}import{jsxDEV as q5}from"react/jsx-dev-runtime";var y2={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 N2({type:Q="info",children:$}){let Y=y2[Q];return q5("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:[q5("span",{"aria-hidden":"true",className:`${Y.iconColor} opacity-70 text-base leading-relaxed flex-shrink-0 mt-px`,children:Y.icon},void 0,!1,void 0,this),q5("div",{className:"text-body text-text-secondary leading-relaxed",children:J0($)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as P0}from"react/jsx-dev-runtime";function P2({items:Q}){return P0("ul",{className:"space-y-1 mt-3","data-md":"checklist",children:Q.map(($,Y)=>P0("li",{"data-md":"checklist-item","data-md-label":$.label,className:"relative flex items-start gap-2.5 py-1",children:[P0("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&&P0("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:P0("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),P0("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{useAnnotations as Y1,useResponseRegistration as J1}from"#canvas/runtime";import{useEffect as B1,useMemo as W1,useRef as K1,useState as X1}from"react";import{AnnotationCtx as B7,AnnotationHostContext as W7,SessionContext as K7,useAnnotationHost as X7,useAnnotations as q7}from"@fabrika/annotations/runtime";function H5(Q,$){let Y=[],B=_2(Q);for(let J of B){let W=document.createRange();if(W.selectNodeContents(J),J===Q.startContainer)W.setStart(J,Q.startOffset);if(J===Q.endContainer)W.setEnd(J,Q.endOffset);let K=W.toString();if(!K||!K.trim())continue;let q=document.createElement("mark");q.setAttribute("data-annotation-id",$);try{W.surroundContents(q)}catch{let X=W.extractContents();q.appendChild(X),W.insertNode(q)}Y.push(q)}return Y}function G5(Q){let $=Q.parentElement;if($?.classList.contains("select-none"))return!1;if($?.closest("[data-annotation-id]"))return!1;return!0}function _2(Q){let $=[],Y=Q.commonAncestorContainer;if(Y.nodeType===Node.TEXT_NODE)return $.push(Y),$;let B=document.createTreeWalker(Y,NodeFilter.SHOW_TEXT),J;while(J=B.nextNode()){if(!G5(J))continue;if(Q.intersectsNode(J))$.push(J)}return $}function U5(Q,$){for(let Y of $){if(Q.querySelector(`[data-annotation-id="${Y.id}"]`))continue;let B=Y.snippet;if(!B)continue;let{fullText:J,textNodes:W}=F2(Q),K=[],q=0;while(!0){let U=J.indexOf(B,q);if(U===-1)break;K.push(U),q=U+1}let[X]=K;if(X===void 0)continue;let H=X;if(K.length>1&&Y.context){let U=-1;for(let y of K){let P=0;if(Y.context.before){let L=J.slice(Math.max(0,y-80),y);if(L.includes(Y.context.before))P+=2;else if(Y.context.before.length>10&&L.includes(Y.context.before.slice(-10)))P+=1}if(Y.context.after){let L=J.slice(y+B.length,y+B.length+80);if(L.includes(Y.context.after))P+=2;else if(Y.context.after.length>10&&L.includes(Y.context.after.slice(0,10)))P+=1}if(P>U)U=P,H=y}}let G=H,Z=H+B.length,_=u5(W,G),N=u5(W,Z);if(!_||!N)continue;try{let U=document.createRange();U.setStart(_.node,_.offset),U.setEnd(N.node,N.offset),H5(U,Y.id)}catch{}}}function F2(Q){let $=[],Y="",B=document.createTreeWalker(Q,NodeFilter.SHOW_TEXT),J;while(J=B.nextNode()){if(!G5(J))continue;$.push({node:J,start:Y.length}),Y+=J.textContent||""}return{fullText:Y,textNodes:$}}function u5(Q,$){for(let Y=Q.length-1;Y>=0;Y--){let B=Q[Y];if(!B||B.start>$)continue;let J=$-B.start,W=B.node.textContent?.length??0;if(J<=W)return{node:B.node,offset:J}}return null}function A0(Q){return{kind:Q.kind,owns:($)=>Q.parse($)!==null,find:($,Y)=>{let B=Q.parse($);return B===null?null:Q.find(B,Y)},restore:($,Y)=>{let B=Q.parse(Y.snippet);if(B===null)return;Q.restore?.(B,$,Y)},describe:($)=>{let Y=Q.parse($);if(Y===null||!Q.describe)return null;return Q.describe(Y)}}}function p5(Q){let $=document.createTreeWalker(Q,NodeFilter.SHOW_TEXT),Y="";for(let B=$.nextNode();B;B=$.nextNode()){let J=B.parentElement?.closest("[aria-hidden='true']");if(J&&Q.contains(J))continue;Y+=B.textContent??""}return Y.trim()}function E0(Q,$,Y){return{selector:Q,snippet:(B)=>{let J=B.getAttribute(Y);return J?`${$} ${J}`:null}}}var Z5=[E0("[data-md='item']","[Item]","data-md-label"),E0("[data-md='section']","[Section]","data-md-title"),E0("[data-md='checklist-item']","[Checklist]","data-md-label"),E0("[data-md='image']","[Image]","data-md-src"),{selector:"[data-md='callout']",snippet:(Q)=>{return`[Callout:${Q.getAttribute("data-md-type")||"info"}] ${p5(Q).slice(0,60)||"Callout"}`}},{selector:"[data-md='note']",snippet:(Q)=>`[Note] ${p5(Q).slice(0,60)||"Note"}`},{selector:"[data-md='table'] tbody tr",snippet:(Q)=>{let $=Array.from(Q.querySelectorAll("td")).map((Y)=>Y.textContent?.trim()).filter(Boolean);return $.length?`[Row] ${$.join(" | ")}`:null}}],L2=["[data-md='choice-option']","[data-md='multichoice-option']","[data-md='userinput']","[data-md='rangeinput']"],y5=Z5.map((Q)=>Q.selector).join(", "),c5=[...Z5.map((Q)=>Q.selector),...L2].join(", ");function N5(Q){for(let $ of Z5)if(Q.matches($.selector))return $.snippet(Q);return null}var P5={kind:"block",parse:(Q)=>Q.startsWith("[")?{snippet:Q}:null,format:(Q)=>Q.snippet,find:(Q,$)=>{for(let Y of $.querySelectorAll(y5)){if(!(Y instanceof HTMLElement))continue;if(N5(Y)===Q.snippet)return Y}return null}};var M2=/^\[Region:(rect|ellipse)\] ([\s\S]+) @(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*)$/;function z2(Q){if(Q==="rect")return"rect";if(Q==="ellipse")return"ellipse";return null}function h0(Q){if(Q===void 0)return null;let $=Number(Q);if(!Number.isInteger($)||$<0||$>1e4)return null;return $}function d5(Q){return{left:`${Q.x/100}%`,top:`${Q.y/100}%`,width:`${Q.w/100}%`,height:`${Q.h/100}%`}}function x0(Q){return`${(Q/100).toFixed(1).replace(/\.0$/,"")}%`}function F5(Q){let $=`${x0(Q.x)}-${x0(Q.x+Q.w)}`,Y=`${x0(Q.y)}-${x0(Q.y+Q.h)}`;return`[Region] ${Q.src} — ${Q.shape} x ${$}, y ${Y} of the image`}function _5(Q,$){for(let Y of $.querySelectorAll("[data-md='image']")){if(!(Y instanceof HTMLElement))continue;if(Y.getAttribute("data-md-src")!==Q)continue;let B=Y.querySelector("[data-annotation-image]");if(B instanceof HTMLElement)return B}return null}function r5(Q,$){let Y=d5($);Q.style.left=Y.left,Q.style.top=Y.top,Q.style.width=Y.width,Q.style.height=Y.height}function L5(Q,$,Y){let B=document.createElement("div");return B.className="ann-region",B.setAttribute("data-annotation-id",Y),B.setAttribute("data-annotation-region",$),r5(B,Q),B}var g0={kind:"region",parse:(Q)=>{let $=M2.exec(Q);if(!$)return null;let Y=z2($[1]),B=$[2],J=h0($[3]),W=h0($[4]),K=h0($[5]),q=h0($[6]);if(Y===null||B===void 0)return null;if(J===null||W===null||K===null||q===null)return null;if(K<1||q<1)return null;return{src:B,shape:Y,x:J,y:W,w:K,h:q}},format:(Q)=>`[Region:${Q.shape}] ${Q.src} @${Q.x},${Q.y},${Q.w},${Q.h}`,find:(Q,$)=>_5(Q.src,$),restore:(Q,$,Y)=>{if($.querySelector(`[data-annotation-id="${Y.id}"]`))return;let B=_5(Q.src,$);if(!B)return;B.appendChild(L5(Q,Q.shape,Y.id))},describe:F5};var M5={kind:"text",parse:(Q)=>Q?{text:Q}:null,format:(Q)=>Q.text,find:()=>null,restore:(Q,$,Y)=>{U5($,[Y])}};var T2=[A0(g0),A0(P5),A0(M5)];import{AnnotationCtx as M3,SessionContext as z3,useAnnotationHost as T3}from"@fabrika/annotations/runtime";import{useEffect as A3,useState as S3}from"react";import{useCallback as y3,useMemo as N3,useState as P3}from"react";function S0(Q){return Q.uploadUrl!==null}function Q0(Q,$){Q.style.height="auto",Q.style.height=($?Math.max($,Q.scrollHeight):Q.scrollHeight)+"px"}import{useAnnotations as u0}from"@fabrika/annotations/runtime";import{jsxDEV as v3}from"react/jsx-dev-runtime";import{jsxDEV as j3,Fragment as m3}from"react/jsx-dev-runtime";import{useAnnotationHost as w2}from"@fabrika/annotations/runtime";import{useCallback as Y0,useEffect as A2,useRef as T5,useState as O5}from"react";import{jsxDEV as h}from"react/jsx-dev-runtime";function l5(Q){if(Q.startsWith("/s/")||Q.startsWith("http://")||Q.startsWith("https://"))return Q;return`/api/uploads/${Q.split("/").pop()}`}async function S2(Q,$){let Y=Q.uploadUrl;if(!Y)return null;let B=new FormData;B.append("image",$);try{let W=await(await fetch(Y(),{method:"POST",body:B})).json();if(Q.isShared)return W.url||null;return W.path||null}catch{return null}}function p0({note:Q,onNoteChange:$,images:Y,onAddImage:B,onRemoveImage:J,sessionId:W,placeholder:K="Add your note...",autoFocus:q=!1,autoResize:X=!1,readOnly:H=!1,onKeyDown:G,onTextareaClick:Z,textareaRef:_,textareaClassName:N,textareaStyle:U,minHeight:y,attachButton:P="always",openFilePickerRef:L}){let w=w2(),A=!H&&S0(w),[I,v]=O5(!1),[b,x]=O5(!1),[u,i]=O5(!1),k=T5(0),R=T5(null),g=T5(null),j=Y0(()=>g.current?.click(),[]);if(L)L.current=j;let o=Y0((M)=>{if(R.current=M,_)_.current=M;if(M&&X)Q0(M,y)},[_,X,y]);A2(()=>{if(q&&R.current){let M=R.current;if(M.focus(),M.value)M.setSelectionRange(M.value.length,M.value.length)}},[q]);let p=Y0(async(M)=>{if(!M.type.startsWith("image/"))return;x(!0);try{let D=await S2(w,M);if(D)B(D)}finally{x(!1)}},[w,B]),K0=Y0((M)=>{for(let D of M.clipboardData?.items??[])if(D.type.startsWith("image/")){M.preventDefault();let y0=D.getAsFile();if(y0)p(y0);return}},[p]),c=Y0((M)=>{if(M.preventDefault(),k.current++,k.current===1)v(!0)},[]),d=Y0((M)=>{M.preventDefault()},[]),s=Y0((M)=>{if(M.preventDefault(),k.current--,k.current===0)v(!1)},[]),a=Y0((M)=>{M.preventDefault(),k.current=0,v(!1);for(let D of M.dataTransfer?.files??[])if(D.type.startsWith("image/"))p(D)},[p]),X0=Y0((M)=>{if($(M.currentTarget.value),X)M.currentTarget.style.height="auto",M.currentTarget.style.height=(y?Math.max(y,M.currentTarget.scrollHeight):M.currentTarget.scrollHeight)+"px"},[$,X,y]),q0="w-full bg-transparent text-[13px] font-body text-text-primary resize-none focus:outline-none leading-relaxed p-0 border-none",a0={width:"100%",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",outline:"none",...X?{resize:"none",overflow:"hidden"}:{resize:"vertical"}},b0=A&&(P==="always"||P==="on-focus"&&u);return h("div",{style:{position:"relative"},onDragEnter:A?c:void 0,onDragOver:A?d:void 0,onDragLeave:A?s:void 0,onDrop:A?a:void 0,children:[h("textarea",{ref:o,value:Q,onChange:H?void 0:X0,onPaste:A?K0:void 0,onKeyDown:G,onClick:Z,onFocus:()=>i(!0),onBlur:()=>{setTimeout(()=>i(!1),150)},readOnly:H,placeholder:K,className:N??q0,style:U??a0,rows:X?1:void 0},void 0,!1,void 0,this),A&&h("input",{ref:g,type:"file",accept:"image/*",multiple:!0,style:{display:"none"},onChange:(M)=>{let D=M.currentTarget.files;if(D)for(let y0 of D)p(y0);M.currentTarget.value=""}},void 0,!1,void 0,this),(Y.length>0||b0)&&h("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px",alignItems:"center"},children:[Y.map((M)=>h("div",{style:{position:"relative",width:"56px",height:"56px",borderRadius:"6px",overflow:"hidden",border:"1px solid var(--color-border-subtle)",flexShrink:0},children:[h("img",{src:l5(M),alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}},void 0,!1,void 0,this),!H&&h("button",{onClick:(D)=>{D.stopPropagation(),J(M)},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)]},M,!0,void 0,this)),b0&&h(c0,{onClick:j},void 0,!1,void 0,this)]},void 0,!0,void 0,this),b&&h("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:"Uploading..."},void 0,!1,void 0,this),I&&h("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 c0({onClick:Q,size:$=16}){return h("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:h("svg",{width:$,height:$,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[h("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},void 0,!1,void 0,this),h("circle",{cx:"8.5",cy:"8.5",r:"1.5"},void 0,!1,void 0,this),h("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 d3}from"@fabrika/annotations/runtime";import{useContext as l3,useEffect as i3,useRef as o3}from"react";import{jsxDEV as $6,Fragment as Q6}from"react/jsx-dev-runtime";import{SessionContext as v2,useAnnotationHost as b2}from"@fabrika/annotations/runtime";import{useCallback as d0,useContext as I2,useEffect as R2,useMemo as a5,useRef as r0,useState as _0}from"react";import{createPortal as V2}from"react-dom";function o5(Q){let $=/^(\d+(?:\.\d+)?)px$/.exec(Q.trim());return $?Number($[1]):void 0}function s5(Q,$,Y=280){let J=$||document.body,W=Q.getBoundingClientRect(),K=J.getBoundingClientRect(),q=J===document.body?0:J.scrollTop,X=W.bottom-K.top+q+8,H=Math.max(0,Math.min(W.left-K.left,K.width-Y-12));return J.style.position="relative",{style:{position:"absolute",top:`${X}px`,left:`${H}px`},parent:J}}import{jsxDEV as m,Fragment as m2}from"react/jsx-dev-runtime";function n5({anchorEl:Q,scrollContainer:$,onClose:Y,ignoreSelector:B,zIndex:J="50",padding:W="12px",width:K="280px",children:q}){let X=r0(null),H=r0(Y);H.current=Y;let{style:G,parent:Z}=s5(Q,$,o5(K));return R2(()=>{let _=setTimeout(()=>{let N=(U)=>{if(X.current&&!X.current.contains(U.target)){if(B&&U.target.closest?.(B))return;H.current(),document.removeEventListener("mousedown",N)}};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},0);return()=>clearTimeout(_)},[B]),V2(m("div",{ref:X,style:{...G,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:W,fontFamily:"'Inter', sans-serif"},children:q},void 0,!1,void 0,this),Z)}var e5=[{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"]}],t5=e5.flatMap((Q)=>Q.items);function $1({anchorEl:Q,scrollContainer:$,snippet:Y,truncateAt:B=100,header:J,initialNote:W="",initialImages:K,onConfirm:q,onCancel:X,onDelete:H}){let G=I2(v2),Z=b2(),_=S0(Z),N=W!==""||!!H,[U,y]=_0(W),[P,L]=_0(K||[]),[w,A]=_0(null),[I,v]=_0(N),[b,x]=_0(!1),u=r0(null),i=r0(null),k=d0(()=>{if(U.trim()||P.length>0)q(U.trim(),P);else if(N&&H)H();else X()},[U,P,q,X,N,H]),R=d0(()=>{if(N){if(!U.trim()&&P.length===0&&H){H(),X();return}q(U,P);return}X()},[U,P,N,q,X,H]),g=!N,j=U.trim().length>0?t5.filter((F)=>F.toLowerCase().startsWith(U.trim().toLowerCase())):t5,o=!g||I?[]:j.length===1&&j[0]?.toLowerCase()===U.trim().toLowerCase()?[]:j,p=new Set(o),K0=e5.map((F)=>({label:F.label,items:F.items.filter((C)=>p.has(C))})).filter((F)=>F.items.length>0),c=K0.map((F)=>F.items),d=(F)=>c[F]?.length??0,s=c.flat(),a=a5(()=>{if(w===null)return 0;let F=0;for(let C=0;C<c.length;C++){if(w<F+d(C))return C;F+=d(C)}return 0},[w,c]),X0=a5(()=>{if(w===null)return 0;let F=0;for(let C=0;C<a;C++)F+=d(C);return w-F},[w,a,c]),q0=(F,C)=>{let V=0;for(let t=0;t<F;t++)V+=d(t);return V+C},[a0,b0]=_0(U);if(U!==a0)b0(U),A(null),v(N);let M=d0((F)=>{y(F)},[]),D=Y.length>B?Y.slice(0,B)+"...":Y,y0=d0((F)=>{if(s.length>0&&(F.key==="ArrowDown"||F.key==="ArrowUp"||F.key==="ArrowLeft"||F.key==="ArrowRight")){if(F.preventDefault(),w===null){A(0);return}if(F.key==="ArrowDown"){let V=Math.min(X0+1,d(a)-1);A(q0(a,V))}else if(F.key==="ArrowUp"){let V=Math.max(X0-1,0);A(q0(a,V))}else if(F.key==="ArrowRight"){let V=Math.min(a+1,c.length-1),t=Math.min(X0,d(V)-1);A(q0(V,t))}else if(F.key==="ArrowLeft"){let V=Math.max(a-1,0),t=Math.min(X0,d(V)-1);A(q0(V,t))}return}let C=w===null?void 0:s[w];if(C!==void 0){if(F.key==="Tab"){F.preventDefault(),M(C);return}if(F.key==="Enter"&&!F.shiftKey){F.preventDefault(),q(C,P);return}}if(F.key==="Enter"&&!F.shiftKey){F.preventDefault(),k();return}if(F.key==="Escape")if(s.length>0&&!I)v(!0);else if(N)R();else X()},[s,w,X0,a,c,q0,M,q,P,k,I,N,R,X]);return m(n5,{anchorEl:Q,scrollContainer:$,onClose:N?R:X,ignoreSelector:N?"[data-annotation-id]":void 0,zIndex:N?"60":"50",padding:N?"10px 12px":"12px",width:"420px",children:[!N&&(J??m("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:["“",D,"”"]},void 0,!0,void 0,this)),m(p0,{note:U,onNoteChange:y,images:P,onAddImage:(F)=>L((C)=>[...C,F]),onRemoveImage:(F)=>L((C)=>C.filter((V)=>V!==F)),sessionId:G,autoFocus:!0,autoResize:N,textareaRef:u,onKeyDown:y0,attachButton:"none",openFilePickerRef:i,textareaStyle:N?{width:"100%",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",resize:"none",outline:"none",overflow:"hidden"}:{width:"100%",minHeight:"60px",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",resize:"vertical",outline:"none"},placeholder:"Add your note..."},void 0,!1,void 0,this),m("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:N?"6px":"8px"},children:[_&&m(c0,{onClick:()=>i.current?.(),size:14},void 0,!1,void 0,this),m("div",{style:{flex:1}},void 0,!1,void 0,this),N?m("button",{onClick:()=>{if(H)H();X()},onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),style:{fontSize:"11px",color:b?"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):m(m2,{children:[m("button",{onClick:X,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),m("button",{onClick:k,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),s.length>0&&m("div",{style:{marginTop:"6px",borderTop:"1px solid var(--color-border-subtle)",paddingTop:"8px",display:"flex",gap:"4px"},children:K0.map((F)=>m("div",{style:{flex:1},children:[m("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((C)=>{let V=s.indexOf(C);return m("div",{onMouseDown:(t)=>{t.preventDefault(),t.stopPropagation(),M(C)},onMouseEnter:()=>A(V),style:{padding:"3px 6px",fontSize:"12px",borderRadius:"4px",fontFamily:"'Inter', sans-serif",color:V===w?"var(--color-text-primary)":"var(--color-text-secondary)",background:V===w?"var(--color-highlight-selected)":"transparent",cursor:"pointer"},children:[m("span",{style:{fontWeight:500},children:C.slice(0,U.trim().length)},void 0,!1,void 0,this),C.slice(U.trim().length)]},C,!0,void 0,this)})]},F.label,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function C0({anchorEl:Q,scrollContainer:$,snippet:Y,truncateAt:B,header:J,onAdd:W,onCancel:K}){return m($1,{anchorEl:Q,scrollContainer:$,snippet:Y,truncateAt:B,header:J,onConfirm:(q,X)=>W(q,X),onCancel:K},void 0,!1,void 0,this)}import{useEffect as L6,useRef as M6,useState as z6}from"react";import{jsxDEV as C6}from"react/jsx-dev-runtime";import{useCallback as I6,useEffect as R6,useRef as V6,useState as m6}from"react";import{jsxDEV as p6,Fragment as u6}from"react/jsx-dev-runtime";import{jsxDEV as Q1}from"react/jsx-dev-runtime";function F0({note:Q,onChange:$}){return Q1("div",{className:"mt-1.5",children:Q1("textarea",{value:Q,onChange:(Y)=>$(Y.currentTarget.value),className:"w-full bg-transparent text-[12px] font-body text-text-primary resize-none focus:outline-none border-none placeholder:text-text-disabled transition-colors min-h-[20px] p-0 leading-relaxed",placeholder:"Add a note...",rows:1,onInput:(Y)=>Q0(Y.currentTarget),ref:(Y)=>{if(Y)Q0(Y)}},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as f}from"react/jsx-dev-runtime";function q1(Q){return Q.map(($)=>typeof $==="string"?{value:$,label:$}:{value:$.value,label:$.label??$.value})}function d2({id:Q,label:$,options:Y,required:B}){let{responses:J,setResponse:W}=Y1();J1(Q);let K=W1(()=>q1(Y),[Y]),q=J.get(Q),X=q?.value,H=q?.note||"",[G,Z]=X1(!1),_=K1(null);if(!J.has(Q))W(Q,{id:Q,type:"radio",label:$,value:null,options:K.map((y)=>y.value),required:B});let N=(y)=>{W(Q,{...q,value:y})};B1(()=>{let y=_.current;if(!y)return;let P=(L)=>{let A=L.target.closest("[data-md-label]")?.getAttribute("data-md-label"),I=K.find((v)=>v.label===A);if(I)N(I.value)};return y.addEventListener("kb-select",P),()=>y.removeEventListener("kb-select",P)},[K,N]);let U=q?.required&&!X;return f("div",{ref:_,"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:[f("div",{className:"flex items-baseline gap-2 mb-2",children:[f("span",{className:"text-[13px] font-body font-medium text-text-primary",children:$},void 0,!1,void 0,this),B&&f("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),f("div",{className:"space-y-1",children:K.map(({value:y,label:P})=>f("label",{"data-md":"choice-option","data-md-label":P,onClick:()=>N(y),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${X===y?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[f("span",{className:`w-4 h-4 rounded-full border-[1.5px] flex items-center justify-center flex-shrink-0 transition-all ${X===y?"border-accent-amber bg-accent-amber":"border-border-strong"}`,children:X===y&&f("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),f("span",{className:"text-[13px] font-body text-text-secondary",children:P},void 0,!1,void 0,this)]},y,!0,void 0,this))},void 0,!1,void 0,this),f(F0,{show:G,note:H,onToggle:()=>Z(!G),onChange:(y)=>W(Q,{...q,note:y})},void 0,!1,void 0,this),U&&f("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"Please select an option."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function r2({id:Q,label:$,options:Y,required:B}){let{responses:J,setResponse:W}=Y1();J1(Q);let K=W1(()=>q1(Y),[Y]),q=J.get(Q),X=q?.value||[],H=q?.note||"",[G,Z]=X1(!1),_=K1(null);if(!J.has(Q))W(Q,{id:Q,type:"checkbox",label:$,value:[],options:K.map((y)=>y.value),required:B});let N=(y)=>{let P=X.includes(y)?X.filter((L)=>L!==y):[...X,y];W(Q,{...q,value:P})};B1(()=>{let y=_.current;if(!y)return;let P=(L)=>{let A=L.target.closest("[data-md-label]")?.getAttribute("data-md-label"),I=K.find((v)=>v.label===A);if(I)N(I.value)};return y.addEventListener("kb-select",P),()=>y.removeEventListener("kb-select",P)},[K,N]);let U=q?.required&&X.length===0;return f("div",{ref:_,"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:[f("div",{className:"flex items-baseline gap-2 mb-2",children:[f("span",{className:"text-[13px] font-body font-medium text-text-primary",children:$},void 0,!1,void 0,this),B&&f("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),f("div",{className:"space-y-1",children:K.map(({value:y,label:P})=>{let L=X.includes(y);return f("label",{"data-md":"multichoice-option","data-md-label":P,onClick:()=>N(y),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${L?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[f("span",{className:`w-4 h-4 rounded flex items-center justify-center flex-shrink-0 transition-all ${L?"bg-accent-amber":"border-[1.5px] border-border-strong"}`,children:L&&f("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:f("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),f("span",{className:"text-[13px] font-body text-text-secondary",children:P},void 0,!1,void 0,this)]},y,!0,void 0,this)})},void 0,!1,void 0,this),f(F0,{show:G,note:H,onToggle:()=>Z(!G),onChange:(y)=>W(Q,{...q,note:y})},void 0,!1,void 0,this),U&&f("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 l2,useRef as i2}from"react";import{jsxDEV as l0}from"react/jsx-dev-runtime";function o2({language:Q,children:$}){let Y=typeof $==="string"?$:String($??""),B=i2(null);return l2(()=>{let J=B.current,W=window.hljs;if(!J||!W)return;J.removeAttribute("data-highlighted"),J.className=Q?`language-${Q}`:"",J.textContent=Y,W.highlightElement(J)},[Y,Q]),l0("div",{className:"relative mt-3 group/code","data-md":"codeblock","data-md-language":Q||"",children:[Q&&l0("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),l0("pre",{className:"bg-bg-code rounded-md p-4 overflow-x-auto text-code font-mono leading-relaxed",children:l0("code",{ref:B,className:Q?`language-${Q}`:"",children:Y},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function H1(Q,$){let Y=Q.split(`
60
- `),B=$.split(`
61
- `),J=s2(Y,B),W=[],K=0,q=0,X=0;while(K<Y.length||q<B.length){let H=Y[K],G=B[q];if(X<J.length&&H!==void 0&&G!==void 0&&H===J[X]&&G===J[X])W.push({type:"same",line:H}),K++,q++,X++;else if(H!==void 0&&(X>=J.length||H!==J[X]))W.push({type:"removed",line:H}),K++;else if(G!==void 0)W.push({type:"added",line:G}),q++}return W}function s2(Q,$){let Y=Q.length,B=$.length,J=Array.from({length:Y+1},()=>Array(B+1).fill(0));for(let X=1;X<=Y;X++){let H=J[X]??[],G=J[X-1]??[];for(let Z=1;Z<=B;Z++)H[Z]=Q[X-1]===$[Z-1]?(G[Z-1]??0)+1:Math.max(G[Z]??0,H[Z-1]??0)}let W=[],K=Y,q=B;while(K>0&&q>0){let X=Q[K-1];if(X!==void 0&&X===$[q-1])W.unshift(X),K--,q--;else if((J[K-1]?.[q]??0)>(J[K]?.[q-1]??0))K--;else q--}return W}import{jsxDEV as k0}from"react/jsx-dev-runtime";function a2({before:Q,after:$,language:Y}){let B=H1(Q,$);return k0("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden group/diff","data-md":"diff","data-md-language":Y||"",children:[Y&&k0("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),k0("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono",children:B.map((J,W)=>k0("div",{className:J.type==="removed"?"bg-accent-red-muted text-accent-red":J.type==="added"?"bg-accent-green-muted text-accent-green":"text-text-tertiary",children:[k0("span",{className:"select-none w-6 inline-block text-center opacity-60",children:J.type==="removed"?"-":J.type==="added"?"+":" "},void 0,!1,void 0,this),J.line]},W,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{ActiveViewCtx as t2,SessionContext as n2}from"#canvas/runtime";import{useContext as G1,useEffect as U1,useRef as e2,useState as i0}from"react";import{jsxDEV as B0}from"react/jsx-dev-runtime";var $4={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 Q4({path:Q,lines:$,__content:Y}){let B=G1(n2),{setActiveView:J}=G1(t2),[W,K]=i0(Y??null),[q,X]=i0(()=>{let U=Q.split(".").pop()||"";return $4[U]||"text"}),[H,G]=i0(null),[Z,_]=i0(!Y),N=e2(null);if(U1(()=>{if(Y!==void 0)return;_(!0),G(null),fetch(`/api/file?session=${B}&path=${encodeURIComponent(Q)}`).then((U)=>U.json()).then((U)=>{if(U.error)G(U.error);else{let y=U.content;if($)y=y.split(`
62
- `).slice($[0]-1,$[1]).join(`
63
- `);K(y),X(U.language||"text")}}).catch(()=>G("Failed to fetch file")).finally(()=>_(!1))},[B,Q,$?.[0],$?.[1],Y]),U1(()=>{let U=N.current,y=window.hljs;if(!U||!y||!W)return;U.removeAttribute("data-highlighted"),U.className=q?`language-${q}`:"",U.textContent=W,y.highlightElement(U)},[W,q]),Z)return B0("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(H)return B0("div",{className:"text-accent-red text-body mt-3 bg-accent-red-muted rounded-md p-4",children:[Q,": ",H]},void 0,!0,void 0,this);return B0("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden","data-md":"filepreview","data-md-path":Q,...$?{"data-md-lines":`${$[0]}-${$[1]}`}:{},children:[B0("div",{className:"px-4 py-2 flex items-center justify-between",children:[B0("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),$&&B0("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),B0("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono !bg-transparent",style:{background:"transparent"},children:B0("code",{ref:N,className:q?`language-${q}`:"",children:W},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{SessionContext as Y4}from"#canvas/runtime";import{useContext as J4,useState as B4}from"react";import{jsxDEV as f0}from"react/jsx-dev-runtime";function W4({src:Q,alt:$,caption:Y,width:B,height:J}){let W=J4(Y4),[K,q]=B4(!1),X=`/api/image?session=${encodeURIComponent(W)}&path=${encodeURIComponent(Q)}`;if(K)return f0("div",{className:"mt-3 text-accent-red text-body bg-accent-red-muted rounded-md p-4",children:[Q,": Failed to load image"]},void 0,!0,void 0,this);return f0("figure",{className:"mt-3 relative","data-md":"image","data-md-src":Q,children:[f0("div",{"data-annotation-image":!0,className:"rounded-md overflow-hidden border border-border-subtle bg-bg-code inline-block",children:f0("img",{src:X,alt:$||Q,onError:()=>q(!0),draggable:!1,className:"block max-w-full h-auto",...B?{width:B}:{},...J?{height:J}:{}},void 0,!1,void 0,this)},void 0,!1,void 0,this),Y&&f0("figcaption",{className:"mt-1.5 text-meta text-text-tertiary font-body",children:Y},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useMemo as K4}from"react";import{jsxDEV as Z1}from"react/jsx-dev-runtime";T.setOptions({gfm:!0,breaks:!1});function X4({children:Q,file:$,__content:Y}){let B=Y??(typeof Q==="string"?Q:String(Q??"")),J=K4(()=>{if(!B)return"";return T.parse(B,{async:!1})},[B]);if(!B)return Z1("div",{className:"text-text-tertiary text-tiny mt-3",children:$?`Could not load: ${$}`:"No markdown content"},void 0,!1,void 0,this);return Z1("div",{className:"mt-3 prose-canvas","data-md":"markdown",...$?{"data-md-file":$}:{},"data-md-source":B,dangerouslySetInnerHTML:{__html:J}},void 0,!1,void 0,this)}import{useAnnotations as q4,useCanvasFile as H4}from"#canvas/runtime";import{useCallback as e,useEffect as w5,useRef as v0,useState as L0}from"react";import G4 from"react-dom";import{jsxDEV as z,Fragment as _1}from"react/jsx-dev-runtime";var M0=0.2,o0=0.25,s0=4;function N1({zoom:Q,onZoomIn:$,onZoomOut:Y,onZoomReset:B,onFullscreen:J}){return z("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:[z("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<=o0,children:z("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:z("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),z("button",{className:"px-1.5 h-7 rounded hover:bg-bg-elevated text-text-tertiary hover:text-text-primary transition-colors tabular-nums",onClick:B,title:"Reset zoom",children:[Math.round(Q*100),"%"]},void 0,!0,void 0,this),z("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>=s0,children:z("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[z("line",{x1:"12",y1:"5",x2:"12",y2:"19"},void 0,!1,void 0,this),z("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&&z(_1,{children:[z("div",{className:"w-px h-4 bg-border-subtle mx-0.5"},void 0,!1,void 0,this),z("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:z("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[z("polyline",{points:"15 3 21 3 21 9"},void 0,!1,void 0,this),z("polyline",{points:"9 21 3 21 3 15"},void 0,!1,void 0,this),z("line",{x1:"21",y1:"3",x2:"14",y2:"10"},void 0,!1,void 0,this),z("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 P1(Q=1){let[$,Y]=L0(Q),B=e(()=>Y((K)=>Math.min(s0,+(K+M0).toFixed(2))),[]),J=e(()=>Y((K)=>Math.max(o0,+(K-M0).toFixed(2))),[]),W=e(()=>Y(1),[]);return{zoom:$,zoomIn:B,zoomOut:J,zoomReset:W,setZoom:Y}}function U4({svgHtml:Q,source:$,onClose:Y}){let B=v0(null),{zoom:J,zoomIn:W,zoomOut:K,zoomReset:q,setZoom:X}=P1(1),[H,G]=L0({x:0,y:0}),Z=v0(null);w5(()=>{let L=(w)=>{if(w.key==="Escape")Y()};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[Y]);let _=e((L)=>{L.preventDefault();let w=L.deltaY>0?-M0:M0;X((A)=>Math.max(o0,Math.min(s0,+(A+w).toFixed(2))))},[X]),N=e((L)=>{if(L.button!==0)return;Z.current={startX:L.clientX,startY:L.clientY,panX:H.x,panY:H.y},L.preventDefault()},[H]),U=e((L)=>{if(!Z.current)return;G({x:Z.current.panX+(L.clientX-Z.current.startX),y:Z.current.panY+(L.clientY-Z.current.startY)})},[]),y=e(()=>{Z.current=null},[]),P=e(()=>{q(),G({x:0,y:0})},[q]);return G4.createPortal(z("div",{style:{position:"fixed",inset:0,zIndex:9999,background:"var(--color-bg-base)",display:"flex",flexDirection:"column"},onMouseMove:U,onMouseUp:y,onMouseLeave:y,children:[z("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:[z("span",{className:"text-body text-text-secondary",style:{fontSize:"13px"},children:"Mermaid Diagram"},void 0,!1,void 0,this),z("div",{className:"flex items-center gap-2",children:[z(N1,{zoom:J,onZoomIn:W,onZoomOut:K,onZoomReset:P},void 0,!1,void 0,this),z("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:z("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[z("line",{x1:"18",y1:"6",x2:"6",y2:"18"},void 0,!1,void 0,this),z("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),z("div",{style:{flex:1,overflow:"hidden",cursor:Z.current?"grabbing":"grab"},onWheel:_,onMouseDown:N,children:z("div",{ref:B,style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",transform:`translate(${H.x}px, ${H.y}px) scale(${J})`,transformOrigin:"center center",transition:Z.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 Z4({children:Q}){let $=v0(null),[Y,B]=L0(null),[J,W]=L0(!1),[K,q]=L0(""),X=typeof Q==="string"?Q:String(Q??""),{annotations:H,addAnnotationWithId:G,activeAnnotationId:Z,setActiveAnnotationId:_}=q4(),N=H4(),[U,y]=L0(null),{zoom:P,zoomIn:L,zoomOut:w,zoomReset:A,setZoom:I}=P1(1),v=v0(H);v.current=H;let b=e((k,R,g)=>{let j=`[Diagram ${g.toLowerCase()}] ${R}`,o=v.current.find((p)=>p.snippet===j);if(o)_(o.id);else y({anchorEl:k,snippet:R,prefix:g})},[_]),x=v0(b);x.current=b,w5(()=>{let k=!1,R=async()=>{try{let j=window.mermaid;if(!j){B("Mermaid library not loaded");return}let o=document.documentElement.dataset.theme==="light"?"default":"dark";j.initialize({startOnLoad:!1,theme:o});let p=`mermaid-${Math.random().toString(36).slice(2)}`,{svg:K0}=await j.render(p,X.trim());if(!k&&$.current)$.current.innerHTML=K0,q(K0),y4($.current,(c,d,s)=>x.current(c,d,s)),y1($.current,v.current);B(null)}catch(j){if(!k)B(j.message||"Invalid diagram")}};R();let g=new MutationObserver((j)=>{for(let o of j)if(o.attributeName==="data-theme")R()});return g.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{k=!0,g.disconnect()}},[X]),w5(()=>{if($.current)y1($.current,H,Z)},[H,Z]);let u=e((k)=>{if(!k.ctrlKey&&!k.metaKey)return;k.preventDefault();let R=k.deltaY>0?-M0:M0;I((g)=>Math.max(o0,Math.min(s0,+(g+R).toFixed(2))))},[I]);if(Y)return z("div",{className:"bg-accent-red-muted rounded-md p-4 mt-3 text-body text-accent-red",children:["Mermaid error: ",Y,z("pre",{className:"mt-2 text-tiny text-text-tertiary whitespace-pre-wrap",children:X},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let i=$.current?.closest("#plan-scroll-container");return z(_1,{children:[z("div",{className:"mt-3 mermaid-container","data-md":"mermaid","data-md-source":X.trim(),children:[z("div",{className:"flex justify-end mb-1",children:z(N1,{zoom:P,onZoomIn:L,onZoomOut:w,onZoomReset:A,onFullscreen:()=>W(!0)},void 0,!1,void 0,this)},void 0,!1,void 0,this),z("div",{style:{overflow:"auto",maxHeight:"70vh"},onWheel:u,children:z("div",{ref:$,className:"flex justify-center",style:{transform:`scale(${P})`,transformOrigin:"top center",transition:"transform 0.1s ease-out",minHeight:P<1?void 0:void 0}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U&&z(C0,{anchorEl:U.anchorEl,scrollContainer:i,snippet:U.snippet,header:z("div",{style:{fontSize:"12px",color:"var(--color-text-tertiary)",marginBottom:"8px",lineHeight:"1.4",display:"flex",alignItems:"center",gap:"6px"},children:[z("span",{style:{width:"8px",height:"8px",borderRadius:"50%",background:"var(--color-accent-amber)",flexShrink:0}},void 0,!1,void 0,this),U.snippet]},void 0,!0,void 0,this),onAdd:(k,R)=>{let g=`ann-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;G(g,`[Diagram ${U.prefix.toLowerCase()}] ${U.snippet}`,k,void 0,void 0,R,N||void 0),y(null)},onCancel:()=>y(null)},void 0,!1,void 0,this),J&&K&&z(U4,{svgHtml:K,source:X,onClose:()=>W(!1)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function y4(Q,$){let Y=(B,J,W)=>{B.style.cursor="pointer",B.addEventListener("mouseenter",()=>{B.style.filter="brightness(1.2)"}),B.addEventListener("mouseleave",()=>{B.style.filter=""}),B.addEventListener("click",(K)=>{K.stopPropagation(),K.preventDefault(),$(B,J(),W)})};for(let B of Q.querySelectorAll(".node"))Y(B,()=>{return(B.querySelector(".nodeLabel")||B.querySelector("foreignObject span")||B.querySelector("text"))?.textContent?.trim()||"Node"},"Node");for(let B of Q.querySelectorAll(".edgePath")){let J=B,W=J.querySelector("path");if(W){W.style.strokeWidth=Math.max(parseFloat(W.style.strokeWidth||"1"),8)+"px",W.style.strokeOpacity="0";let q=W.cloneNode(!0);q.style.strokeWidth="",q.style.strokeOpacity="",J.insertBefore(q,W)}let K=J.id||"";Y(J,()=>{let q=Q.querySelectorAll(".edgeLabel");for(let X of q)if(X.id&&K&&X.id.replace("label","").includes(K.replace("L-","").replace("edge",""))){let H=X.textContent?.trim();if(H)return H}return"Connection"},"Edge")}for(let B of Q.querySelectorAll(".edgeLabel")){let J=B.textContent?.trim();if(!J)continue;Y(B,()=>J,"Edge")}for(let B of Q.querySelectorAll(".actor")){let J=B.closest("g")?.querySelector("text")||B.parentElement?.querySelector("text");if(!J)continue;let W=B.closest("g");if(!W||W.hasAttribute("data-clickable"))continue;W.setAttribute("data-clickable","true"),Y(W,()=>J.textContent?.trim()||"Participant","Node")}for(let B of Q.querySelectorAll(".messageText")){let J=B.textContent?.trim();if(!J)continue;Y(B,()=>J,"Edge")}for(let B of Q.querySelectorAll(".entityBox")){let J=B.closest("g");if(!J||J.hasAttribute("data-clickable"))continue;let W=J.querySelector(".entityLabel");if(!W)continue;J.setAttribute("data-clickable","true"),Y(J,()=>W.textContent?.trim()||"Entity","Node")}for(let B of Q.querySelectorAll(".relationshipLabel")){let J=B.textContent?.trim();if(!J)continue;let K=B.closest("g")||B;if(K.hasAttribute("data-clickable"))continue;K.setAttribute("data-clickable","true"),Y(K,()=>J,"Edge")}for(let B of Q.querySelectorAll(".classGroup")){let J=B;if(J.hasAttribute("data-clickable"))continue;let W=J.querySelector(".classTitle, .classTitleText, text");if(!W)continue;J.setAttribute("data-clickable","true"),Y(J,()=>W.textContent?.trim()||"Class","Node")}for(let B of Q.querySelectorAll(".statediagram-state")){let J=B;if(J.hasAttribute("data-clickable"))continue;let W=J.querySelector(".state-title, text");if(!W)continue;J.setAttribute("data-clickable","true"),Y(J,()=>W.textContent?.trim()||"State","Node")}for(let B of Q.querySelectorAll(".mindmap-node")){let J=B;if(J.hasAttribute("data-clickable"))continue;let W=J.querySelector(".mindmap-node-label, text");if(!W)continue;J.setAttribute("data-clickable","true"),Y(J,()=>W.textContent?.trim()||"Node","Node")}}function y1(Q,$,Y){let B=new Map;for(let W of $){let K=W.snippet.match(/^\[Diagram (?:node|edge)\] (.+)$/)?.[1];if(K)B.set(K,W.id)}for(let W of Q.querySelectorAll("[data-annotated]"))W.style.outline="",W.style.outlineOffset="",W.style.borderRadius="",W.removeAttribute("data-annotated");if(B.size===0)return;for(let W of Q.querySelectorAll(".node")){let q=(W.querySelector(".nodeLabel")||W.querySelector("foreignObject span")||W.querySelector("text"))?.textContent?.trim();if(!q||!B.has(q))continue;let X=B.get(q),H=W;H.setAttribute("data-annotated",X);let G=X===Y;H.style.outline=G?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",H.style.outlineOffset="2px",H.style.borderRadius="4px"}for(let W of Q.querySelectorAll(".edgeLabel")){let K=W.textContent?.trim();if(!K||!B.has(K))continue;let q=B.get(K),X=W;X.setAttribute("data-annotated",q);let H=q===Y;X.style.outline=H?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",X.style.outlineOffset="2px",X.style.borderRadius="4px"}for(let W of Q.querySelectorAll(".actor")){let K=W.closest("g");if(!K)continue;let X=K.querySelector("text")?.textContent?.trim();if(!X||!B.has(X))continue;if(K.hasAttribute("data-annotated"))continue;let H=B.get(X);K.setAttribute("data-annotated",H);let G=H===Y,Z=K.querySelector("rect");if(Z)Z.style.outline=G?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",Z.style.outlineOffset="2px",Z.style.borderRadius="4px"}for(let W of Q.querySelectorAll(".messageText")){let K=W.textContent?.trim();if(!K||!B.has(K))continue;let q=B.get(K),X=W;X.setAttribute("data-annotated",q);let H=q===Y;X.style.outline=H?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",X.style.outlineOffset="2px",X.style.borderRadius="4px"}let J=(W,K,q)=>{for(let X of Q.querySelectorAll(W)){let H=q(X);if(!H||H.hasAttribute("data-annotated"))continue;let Z=H.querySelector(K)?.textContent?.trim();if(!Z||!B.has(Z))continue;let _=B.get(Z);H.setAttribute("data-annotated",_);let N=_===Y,U=H.querySelector("rect, circle, ellipse, polygon")||H;U.style.outline=N?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",U.style.outlineOffset="2px",U.style.borderRadius="4px"}};J(".entityBox",".entityLabel",(W)=>W.closest("g"));for(let W of Q.querySelectorAll(".relationshipLabel")){let q=W.closest("g")||W;if(q.hasAttribute("data-annotated"))continue;let X=W.textContent?.trim();if(!X||!B.has(X))continue;let H=B.get(X);q.setAttribute("data-annotated",H);let G=H===Y;q.style.outline=G?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",q.style.outlineOffset="2px",q.style.borderRadius="4px"}J(".classGroup",".classTitle, .classTitleText, text",(W)=>W),J(".statediagram-state",".state-title, text",(W)=>W),J(".mindmap-node",".mindmap-node-label, text",(W)=>W)}import{jsxDEV as P4}from"react/jsx-dev-runtime";function N4({children:Q}){return P4("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:J0(Q)},void 0,!1,void 0,this)}import{jsxDEV as L4}from"react/jsx-dev-runtime";var _4={high:"text-accent-red bg-accent-red-muted",medium:"text-accent-amber bg-accent-amber-muted",low:"text-text-tertiary bg-border-subtle"};function F4({level:Q}){return L4("span",{className:`inline text-tiny font-medium font-body ml-2 px-1.5 py-0.5 rounded ${_4[Q]}`,"data-md":"priority","data-md-level":Q,children:Q},void 0,!1,void 0,this)}import{useState as M4}from"react";import{jsxDEV as Z0}from"react/jsx-dev-runtime";function z4({title:Q,children:$}){let[Y,B]=M4(!1);return Z0("div",{className:"relative mb-8 p-4 group/section","data-md":"section","data-md-title":Q,children:[Z0("div",{className:"relative mb-2",children:[Z0("button",{onClick:()=>B(!Y),className:`absolute -left-8 top-1/2 -translate-y-1/2 text-text-tertiary opacity-0 group-hover/section:opacity-50 hover:!opacity-100 transition-all duration-150 p-0.5 ${Y?"-rotate-90":""}`,children:Z0("svg",{width:"14",height:"14",viewBox:"0 0 12 12",fill:"none",children:Z0("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Z0("h2",{className:"font-heading text-section text-text-primary",style:{fontWeight:400},children:Q},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z0("div",{className:Y?"mt-6 hidden":"mt-6",children:J0($)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as W0}from"react/jsx-dev-runtime";function T4({headers:Q,rows:$}){return W0("div",{className:"overflow-x-auto mt-3","data-md":"table",children:W0("table",{className:"w-full text-body",children:[W0("thead",{children:W0("tr",{className:"border-b border-border-subtle",children:Q.map((Y,B)=>W0("th",{className:"text-left px-4 py-2.5 text-meta font-medium uppercase tracking-wider text-text-tertiary font-body",children:Y},B,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),W0("tbody",{children:$.map((Y,B)=>W0("tr",{className:`relative border-b border-border-subtle last:border-b-0 transition-colors hover:bg-bg-surface/50 ${B%2===1?"bg-bg-surface/30":""}`,children:Y.map((J,W)=>W0("td",{className:"px-4 py-2.5 text-text-secondary font-body",children:J},W,!1,void 0,this))},B,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as $0}from"react/jsx-dev-runtime";var O4={todo:"bg-border-hover",done:"bg-accent-green",blocked:"bg-accent-red","in-progress":"bg-accent-blue"},w4={todo:"Todo",done:"Done",blocked:"Blocked","in-progress":"In progress"},A4={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 F1({id:Q,label:$,status:Y,badge:B,badgeVariant:J="neutral",children:W}){return $0("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}:{},...B?{"data-md-badge":B}:{},children:$0("div",{className:"flex items-start gap-3",children:[Y&&$0("span",{className:`w-2 h-2 rounded-full mt-[7px] flex-shrink-0 ${O4[Y]}`},void 0,!1,void 0,this),$0("div",{className:"flex-1 min-w-0",children:[$0("div",{className:"flex items-baseline gap-2",children:[$0("span",{className:"font-body text-task-label font-semibold text-text-primary",children:$},void 0,!1,void 0,this),Y&&$0("span",{className:"font-body text-tiny uppercase tracking-wider text-text-tertiary opacity-0 group-hover/task:opacity-100 transition-opacity duration-150",children:w4[Y]},void 0,!1,void 0,this),B&&$0("span",{className:`font-body text-tiny font-medium px-1.5 py-px rounded-full ${A4[J]}`,children:B},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W&&$0("div",{className:"text-body text-text-secondary mt-1 leading-relaxed",children:J0(W)},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 S4(Q){return $0(F1,{...Q},void 0,!1,void 0,this)}import{useAnnotations as L1,useResponseRegistration as M1}from"#canvas/runtime";import{useRef as C4,useState as z1}from"react";import{jsxDEV as S}from"react/jsx-dev-runtime";function k4({id:Q,label:$,placeholder:Y,multiline:B,required:J}){let{responses:W,setResponse:K}=L1();M1(Q);let q=W.get(Q),X=q?.value??"",H=q?.note||"",[G,Z]=z1(!1),_=C4(null);if(!W.has(Q))K(Q,{id:Q,type:"text",label:$,value:"",required:J});let N=(P)=>{K(Q,{...q,value:P})},U=(P)=>Q0(P,B?60:32),y=q?.required&&!X.trim();return S("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:[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),J&&S("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),S("textarea",{ref:_,value:X,onChange:(P)=>{N(P.currentTarget.value),U(P.currentTarget)},placeholder:Y||"Type your response...",rows:B?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:(P)=>U(P.currentTarget),onFocus:(P)=>U(P.currentTarget)},void 0,!1,void 0,this),S(F0,{show:G,note:H,onToggle:()=>Z(!G),onChange:(P)=>K(Q,{...q,note:P})},void 0,!1,void 0,this),y&&S("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 f4({id:Q,label:$,min:Y=1,max:B=10,step:J=1,required:W,minLabel:K,maxLabel:q}){let{responses:X,setResponse:H}=L1();M1(Q);let G=X.get(Q),Z=G?.value,_=G?.note||"",[N,U]=z1(!1);if(!X.has(Q))H(Q,{id:Q,type:"range",label:$,value:null,required:W});let y=(b)=>{H(Q,{...G,value:b})},P=Z!==null&&Z!==void 0,L=P?Z:Math.round((Y+B)/2),w=(L-Y)/(B-Y)*100,A=Math.round((B-Y)/J),I=A<=20,v=G?.required&&!P;return S("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:[S("div",{className:"flex items-baseline justify-between mb-1",children:[S("div",{className:"flex items-baseline gap-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("span",{className:"flex items-center gap-1.5",children:[S("span",{className:`text-[13px] font-mono ${P?"text-accent-amber":"text-text-disabled"}`,children:P?Z:"—"},void 0,!1,void 0,this),P&&S("button",{onClick:()=>H(Q,{...G,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),S("div",{className:"relative h-6 flex items-center",children:[S("div",{className:"absolute left-0 right-0 h-1.5 rounded-full bg-border-medium",children:P&&S("div",{className:"h-full rounded-full bg-accent-amber transition-all duration-150",style:{width:`${w}%`}},void 0,!1,void 0,this)},void 0,!1,void 0,this),I&&Array.from({length:A+1},(b,x)=>{let u=Y+x*J,i=(u-Y)/(B-Y)*100,k=P&&u<=Z;return S("div",{className:`absolute rounded-full pointer-events-none transition-all duration-150 ${P&&u===Z?"w-2.5 h-2.5 bg-accent-amber":k?"w-1.5 h-1.5 bg-accent-amber":"w-1.5 h-1.5 bg-border-hover"}`,style:{left:`${i}%`,transform:"translate(-50%, -50%)",top:"50%"}},x,!1,void 0,this)}),P?S("div",{className:"absolute h-5 w-5 rounded-full bg-accent-amber shadow-md pointer-events-none transition-all duration-150",style:{left:`calc(${w}% - 10px)`,borderWidth:"2px",borderStyle:"solid",borderColor:"var(--color-bg-base)"}},void 0,!1,void 0,this):S("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),S("input",{type:"range",min:Y,max:B,step:J,value:L,onChange:(b)=>y(Number(b.currentTarget.value)),className:"absolute inset-0 w-full opacity-0 cursor-pointer"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),I&&A<=10?S("div",{className:"flex justify-between -mt-0.5 px-0",children:Array.from({length:A+1},(b,x)=>{let u=Y+x*J;return S("span",{className:`text-[10px] font-mono transition-colors ${P&&u===Z?"text-accent-amber font-medium":"text-text-disabled"}`,style:{minWidth:"1ch",textAlign:"center"},children:u},x,!1,void 0,this)})},void 0,!1,void 0,this):S("div",{className:"flex justify-between -mt-0.5",children:[S("span",{className:"text-[11px] text-text-tertiary font-body",children:K||Y},void 0,!1,void 0,this),S("span",{className:"text-[11px] text-text-tertiary font-body",children:q||B},void 0,!1,void 0,this)]},void 0,!0,void 0,this),S(F0,{show:N,note:_,onToggle:()=>U(!N),onChange:(b)=>H(Q,{...G,note:b})},void 0,!1,void 0,this),v&&S("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)}export{j$ as useFeedback,k4 as UserInput,S4 as Task,T4 as Table,z4 as Section,f4 as RangeInput,F4 as Priority,N4 as Note,r2 as MultiChoice,Z4 as Mermaid,X4 as Markdown,F1 as Item,W4 as ImageView,Q4 as FilePreview,a2 as Diff,o2 as CodeBlock,d2 as Choice,P2 as Checklist,N2 as Callout};
53
+ `+J+`</thead>
54
+ `+q+`</table>
55
+ `}tablerow({text:$}){return`<tr>
56
+ ${$}</tr>
57
+ `}tablecell($){let J=this.parser.parseInline($.tokens),Q=$.header?"th":"td";return($.align?`<${Q} align="${$.align}">`:`<${Q}>`)+J+`</${Q}>
58
+ `}strong({tokens:$}){return`<strong>${this.parser.parseInline($)}</strong>`}em({tokens:$}){return`<em>${this.parser.parseInline($)}</em>`}codespan({text:$}){return`<code>${O$($,!0)}</code>`}br($){return"<br>"}del({tokens:$}){return`<del>${this.parser.parseInline($)}</del>`}link({href:$,title:J,tokens:Q}){let q=this.parser.parseInline(Q),W=Z1($);if(W===null)return q;$=W;let Y='<a href="'+$+'"';return J&&(Y+=' title="'+O$(J)+'"'),Y+=">"+q+"</a>",Y}image({href:$,title:J,text:Q,tokens:q}){q&&(Q=this.parser.parseInline(q,this.parser.textRenderer));let W=Z1($);if(W===null)return O$(Q);$=W;let Y=`<img src="${$}" alt="${O$(Q)}"`;return J&&(Y+=` title="${O$(J)}"`),Y+=">",Y}text($){return"tokens"in $&&$.tokens?this.parser.parseInline($.tokens):("escaped"in $)&&$.escaped?$.text:O$($.text)}},z1=class{strong({text:$}){return $}em({text:$}){return $}codespan({text:$}){return $}del({text:$}){return $}html({text:$}){return $}text({text:$}){return $}link({text:$}){return""+$}image({text:$}){return""+$}br(){return""}checkbox({raw:$}){return $}},X$=class ${options;renderer;textRenderer;constructor(J){this.options=J||u$,this.options.renderer=this.options.renderer||new h0,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new z1}static parse(J,Q){return new $(Q).parse(J)}static parseInline(J,Q){return new $(Q).parseInline(J)}parse(J){this.renderer.parser=this;let Q="";for(let q=0;q<J.length;q++){let W=J[q];if(this.options.extensions?.renderers?.[W.type]){let X=W,G=this.options.extensions.renderers[X.type].call({parser:this},X);if(G!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(X.type)){Q+=G||"";continue}}let Y=W;switch(Y.type){case"space":{Q+=this.renderer.space(Y);break}case"hr":{Q+=this.renderer.hr(Y);break}case"heading":{Q+=this.renderer.heading(Y);break}case"code":{Q+=this.renderer.code(Y);break}case"table":{Q+=this.renderer.table(Y);break}case"blockquote":{Q+=this.renderer.blockquote(Y);break}case"list":{Q+=this.renderer.list(Y);break}case"checkbox":{Q+=this.renderer.checkbox(Y);break}case"html":{Q+=this.renderer.html(Y);break}case"def":{Q+=this.renderer.def(Y);break}case"paragraph":{Q+=this.renderer.paragraph(Y);break}case"text":{Q+=this.renderer.text(Y);break}default:{let X='Token with "'+Y.type+'" type was not found.';if(this.options.silent)return console.error(X),"";throw Error(X)}}}return Q}parseInline(J,Q=this.renderer){this.renderer.parser=this;let q="";for(let W=0;W<J.length;W++){let Y=J[W];if(this.options.extensions?.renderers?.[Y.type]){let G=this.options.extensions.renderers[Y.type].call({parser:this},Y);if(G!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(Y.type)){q+=G||"";continue}}let X=Y;switch(X.type){case"escape":{q+=Q.text(X);break}case"html":{q+=Q.html(X);break}case"link":{q+=Q.link(X);break}case"image":{q+=Q.image(X);break}case"checkbox":{q+=Q.checkbox(X);break}case"strong":{q+=Q.strong(X);break}case"em":{q+=Q.em(X);break}case"codespan":{q+=Q.codespan(X);break}case"br":{q+=Q.br(X);break}case"del":{q+=Q.del(X);break}case"text":{q+=Q.text(X);break}default:{let G='Token with "'+X.type+'" type was not found.';if(this.options.silent)return console.error(G),"";throw Error(G)}}}return q}},L0=class{options;block;constructor($){this.options=$||u$}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess($){return $}postprocess($){return $}processAllTokens($){return $}emStrongMask($){return $}provideLexer($=this.block){return $?Y$.lex:Y$.lexInline}provideParser($=this.block){return $?X$.parse:X$.parseInline}},m2=class{defaults=X1();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=X$;Renderer=h0;TextRenderer=z1;Lexer=Y$;Tokenizer=g0;Hooks=L0;constructor(...$){this.use(...$)}walkTokens($,J){let Q=[];for(let q of $)switch(Q=Q.concat(J.call(this,q)),q.type){case"table":{let W=q;for(let Y of W.header)Q=Q.concat(this.walkTokens(Y.tokens,J));for(let Y of W.rows)for(let X of Y)Q=Q.concat(this.walkTokens(X.tokens,J));break}case"list":{let W=q;Q=Q.concat(this.walkTokens(W.items,J));break}default:{let W=q;this.defaults.extensions?.childTokens?.[W.type]?this.defaults.extensions.childTokens[W.type].forEach((Y)=>{let X=W[Y].flat(1/0);Q=Q.concat(this.walkTokens(X,J))}):W.tokens&&(Q=Q.concat(this.walkTokens(W.tokens,J)))}}return Q}use(...$){let J=this.defaults.extensions||{renderers:{},childTokens:{}};return $.forEach((Q)=>{let q={...Q};if(q.async=this.defaults.async||q.async||!1,Q.extensions&&(Q.extensions.forEach((W)=>{if(!W.name)throw Error("extension name required");if("renderer"in W){let Y=J.renderers[W.name];Y?J.renderers[W.name]=function(...X){let G=W.renderer.apply(this,X);return G===!1&&(G=Y.apply(this,X)),G}:J.renderers[W.name]=W.renderer}if("tokenizer"in W){if(!W.level||W.level!=="block"&&W.level!=="inline")throw Error("extension level must be 'block' or 'inline'");let Y=J[W.level];Y?Y.unshift(W.tokenizer):J[W.level]=[W.tokenizer],W.start&&(W.level==="block"?J.startBlock?J.startBlock.push(W.start):J.startBlock=[W.start]:W.level==="inline"&&(J.startInline?J.startInline.push(W.start):J.startInline=[W.start]))}"childTokens"in W&&W.childTokens&&(J.childTokens[W.name]=W.childTokens)}),q.extensions=J),Q.renderer){let W=this.defaults.renderer||new h0(this.defaults);for(let Y in Q.renderer){if(!(Y in W))throw Error(`renderer '${Y}' does not exist`);if(["options","parser"].includes(Y))continue;let X=Y,G=Q.renderer[X],H=W[X];W[X]=(...B)=>{let _=G.apply(W,B);return _===!1&&(_=H.apply(W,B)),_||""}}q.renderer=W}if(Q.tokenizer){let W=this.defaults.tokenizer||new g0(this.defaults);for(let Y in Q.tokenizer){if(!(Y in W))throw Error(`tokenizer '${Y}' does not exist`);if(["options","rules","lexer"].includes(Y))continue;let X=Y,G=Q.tokenizer[X],H=W[X];W[X]=(...B)=>{let _=G.apply(W,B);return _===!1&&(_=H.apply(W,B)),_}}q.tokenizer=W}if(Q.hooks){let W=this.defaults.hooks||new L0;for(let Y in Q.hooks){if(!(Y in W))throw Error(`hook '${Y}' does not exist`);if(["options","block"].includes(Y))continue;let X=Y,G=Q.hooks[X],H=W[X];L0.passThroughHooks.has(Y)?W[X]=(B)=>{if(this.defaults.async&&L0.passThroughHooksRespectAsync.has(Y))return(async()=>{let w=await G.call(W,B);return H.call(W,w)})();let _=G.call(W,B);return H.call(W,_)}:W[X]=(...B)=>{if(this.defaults.async)return(async()=>{let w=await G.apply(W,B);return w===!1&&(w=await H.apply(W,B)),w})();let _=G.apply(W,B);return _===!1&&(_=H.apply(W,B)),_}}q.hooks=W}if(Q.walkTokens){let W=this.defaults.walkTokens,Y=Q.walkTokens;q.walkTokens=function(X){let G=[];return G.push(Y.call(this,X)),W&&(G=G.concat(W.call(this,X))),G}}this.defaults={...this.defaults,...q}}),this}setOptions($){return this.defaults={...this.defaults,...$},this}lexer($,J){return Y$.lex($,J??this.defaults)}parser($,J){return X$.parse($,J??this.defaults)}parseMarkdown($){return(J,Q)=>{let q={...Q},W={...this.defaults,...q},Y=this.onError(!!W.silent,!!W.async);if(this.defaults.async===!0&&q.async===!1)return Y(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 J>"u"||J===null)return Y(Error("marked(): input parameter is undefined or null"));if(typeof J!="string")return Y(Error("marked(): input parameter is of type "+Object.prototype.toString.call(J)+", string expected"));if(W.hooks&&(W.hooks.options=W,W.hooks.block=$),W.async)return(async()=>{let X=W.hooks?await W.hooks.preprocess(J):J,G=await(W.hooks?await W.hooks.provideLexer($):$?Y$.lex:Y$.lexInline)(X,W),H=W.hooks?await W.hooks.processAllTokens(G):G;W.walkTokens&&await Promise.all(this.walkTokens(H,W.walkTokens));let B=await(W.hooks?await W.hooks.provideParser($):$?X$.parse:X$.parseInline)(H,W);return W.hooks?await W.hooks.postprocess(B):B})().catch(Y);try{W.hooks&&(J=W.hooks.preprocess(J));let X=(W.hooks?W.hooks.provideLexer($):$?Y$.lex:Y$.lexInline)(J,W);W.hooks&&(X=W.hooks.processAllTokens(X)),W.walkTokens&&this.walkTokens(X,W.walkTokens);let G=(W.hooks?W.hooks.provideParser($):$?X$.parse:X$.parseInline)(X,W);return W.hooks&&(G=W.hooks.postprocess(G)),G}catch(X){return Y(X)}}}onError($,J){return(Q)=>{if(Q.message+=`
59
+ Please report this to https://github.com/markedjs/marked.`,$){let q="<p>An error occurred:</p><pre>"+O$(Q.message+"",!0)+"</pre>";return J?Promise.resolve(q):q}if(J)return Promise.reject(Q);throw Q}}},x$=new m2;function k($,J){return x$.parse($,J)}k.options=k.setOptions=function($){return x$.setOptions($),k.defaults=x$.defaults,l1(k.defaults),k};k.getDefaults=X1;k.defaults=u$;k.use=function(...$){return x$.use(...$),k.defaults=x$.defaults,l1(k.defaults),k};k.walkTokens=function($,J){return x$.walkTokens($,J)};k.parseInline=x$.parseInline;k.Parser=X$;k.parser=X$.parse;k.Renderer=h0;k.TextRenderer=z1;k.Lexer=Y$;k.lexer=Y$.lex;k.Tokenizer=g0;k.Hooks=L0;k.parse=k;var{options:v6,setOptions:R6,use:j6,walkTokens:V6,parseInline:P6}=k;var D6=X$.parse,C6=Y$.lex;import t1 from"react";import{jsxDEV as N1}from"react/jsx-dev-runtime";k.setOptions({gfm:!0,breaks:!1});var Z2=new Set(["a","abbr","b","br","code","del","em","i","kbd","mark","q","s","small","span","strong","sub","sup","time","u"]),x2=new Set(["Priority"]);function u2($){if(typeof $==="string"||typeof $==="number")return!0;if(!t1.isValidElement($))return!1;if(typeof $!=="object"||$===null||!("type"in $))return!1;let J=$.type;if(typeof J==="string")return Z2.has(J);if(typeof J==="function"){let Q="displayName"in J&&typeof J.displayName==="string"?J.displayName:J.name;return Q?x2.has(Q):!1}return!1}function l2($,J){let Q=$.trim();if(!Q)return null;let q=k.parse(Q,{async:!1});return N1("div",{className:"prose-canvas","data-md":"markdown","data-md-source":Q,dangerouslySetInnerHTML:{__html:q}},J,!1,void 0,this)}function c2($,J){return N1("div",{className:"prose-canvas",children:$.map((Q,q)=>{if(typeof Q==="string"||typeof Q==="number"){let W=k.parseInline(String(Q),{async:!1});return N1("span",{dangerouslySetInnerHTML:{__html:W}},q,!1,void 0,this)}return Q})},J,!1,void 0,this)}function P$($){let J=t1.Children.toArray($);if(J.length===0)return null;let Q=[],q=[],W=0,Y=()=>{if(q.length===0)return;if(q.some((G)=>typeof G!=="string"&&typeof G!=="number"))Q.push(c2(q,`md-${W++}`));else{let G=l2(q.join(""),`md-${W++}`);if(G)Q.push(G)}q=[]};for(let X of J)if(u2(X))q.push(X);else Y(),Q.push(X);return Y(),Q}import{jsxDEV as K1}from"react/jsx-dev-runtime";var p2={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 d2({type:$="info",children:J}){let Q=p2[$];return K1("div",{className:`${Q.bg} relative rounded-lg px-5 py-4 mt-3 flex gap-3 items-start`,"data-md":"callout","data-md-type":$,children:[K1("span",{"aria-hidden":"true",className:`${Q.iconColor} opacity-70 text-base leading-relaxed flex-shrink-0 mt-px`,children:Q.icon},void 0,!1,void 0,this),K1("div",{className:"text-body text-text-secondary leading-relaxed",children:P$(J)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as a$}from"react/jsx-dev-runtime";function r2({items:$}){return a$("ul",{className:"space-y-1 mt-3","data-md":"checklist",children:$.map((J,Q)=>a$("li",{"data-md":"checklist-item","data-md-label":J.label,className:"relative flex items-start gap-2.5 py-1",children:[a$("span",{className:`w-4 h-4 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5 transition-all ${J.checked?"bg-accent-green":"border-[1.5px] border-border-hover"}`,children:J.checked&&a$("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:a$("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),a$("span",{className:`text-body font-body ${J.checked?"text-text-tertiary line-through decoration-border-hover":"text-text-secondary"}`,children:J.label},void 0,!1,void 0,this)]},Q,!0,void 0,this))},void 0,!1,void 0,this)}import{useAnnotations as V5,useResponseRegistration as P5}from"#canvas/runtime";import{useEffect as D5,useMemo as C5,useRef as k5,useState as E5}from"react";import{AnnotationCtx as C7,AnnotationHostContext as k7,SessionContext as E7,useAnnotationHost as T7,useAnnotations as I7}from"@fabrika/annotations/runtime";function O1($,J){let Q=[],q=i2($);for(let W of q){let Y=document.createRange();if(Y.selectNodeContents(W),W===$.startContainer)Y.setStart(W,$.startOffset);if(W===$.endContainer)Y.setEnd(W,$.endOffset);let X=Y.toString();if(!X||!X.trim())continue;let G=document.createElement("mark");G.setAttribute("data-annotation-id",J);try{Y.surroundContents(G)}catch{let H=Y.extractContents();G.appendChild(H),Y.insertNode(G)}Q.push(G)}return Q}function L1($){let J=$.parentElement;if(J?.classList.contains("select-none"))return!1;if(J?.closest("[data-annotation-id]"))return!1;return!0}function i2($){let J=[],Q=$.commonAncestorContainer;if(Q.nodeType===Node.TEXT_NODE)return J.push(Q),J;let q=document.createTreeWalker(Q,NodeFilter.SHOW_TEXT),W;while(W=q.nextNode()){if(!L1(W))continue;if($.intersectsNode(W))J.push(W)}return J}function F1($,J){for(let Q of J){if($.querySelector(`[data-annotation-id="${Q.id}"]`))continue;let q=Q.snippet;if(!q)continue;let{fullText:W,textNodes:Y}=o2($),X=[],G=0;while(!0){let U=W.indexOf(q,G);if(U===-1)break;X.push(U),G=U+1}let[H]=X;if(H===void 0)continue;let B=H;if(X.length>1&&Q.context){let U=-1;for(let K of X){let O=0;if(Q.context.before){let R=W.slice(Math.max(0,K-80),K);if(R.includes(Q.context.before))O+=2;else if(Q.context.before.length>10&&R.includes(Q.context.before.slice(-10)))O+=1}if(Q.context.after){let R=W.slice(K+q.length,K+q.length+80);if(R.includes(Q.context.after))O+=2;else if(Q.context.after.length>10&&R.includes(Q.context.after.slice(0,10)))O+=1}if(O>U)U=O,B=K}}let _=B,w=B+q.length,L=e1(Y,_),F=e1(Y,w);if(!L||!F)continue;try{let U=document.createRange();U.setStart(L.node,L.offset),U.setEnd(F.node,F.offset),O1(U,Q.id)}catch{}}}function o2($){let J=[],Q="",q=document.createTreeWalker($,NodeFilter.SHOW_TEXT),W;while(W=q.nextNode()){if(!L1(W))continue;J.push({node:W,start:Q.length}),Q+=W.textContent||""}return{fullText:Q,textNodes:J}}function e1($,J){for(let Q=$.length-1;Q>=0;Q--){let q=$[Q];if(!q||q.start>J)continue;let W=J-q.start,Y=q.node.textContent?.length??0;if(W<=Y)return{node:q.node,offset:W}}return null}function S0($){return{kind:$.kind,owns:(J)=>$.parse(J)!==null,find:(J,Q)=>{let q=$.parse(J);return q===null?null:$.find(q,Q)},restore:(J,Q)=>{let q=$.parse(Q.snippet);if(q===null)return;$.restore?.(q,J,Q)},describe:(J)=>{let Q=$.parse(J);if(Q===null||!$.describe)return null;return $.describe(Q)}}}function $5($){let J=document.createTreeWalker($,NodeFilter.SHOW_TEXT),Q="";for(let q=J.nextNode();q;q=J.nextNode()){let W=q.parentElement?.closest("[aria-hidden='true']");if(W&&$.contains(W))continue;Q+=q.textContent??""}return Q.trim()}function x0($,J,Q){return{selector:$,snippet:(q)=>{let W=q.getAttribute(Q);return W?`${J} ${W}`:null}}}var S1=[x0("[data-md='item']","[Item]","data-md-label"),x0("[data-md='section']","[Section]","data-md-title"),x0("[data-md='checklist-item']","[Checklist]","data-md-label"),x0("[data-md='image']","[Image]","data-md-src"),{selector:"[data-md='callout']",snippet:($)=>{return`[Callout:${$.getAttribute("data-md-type")||"info"}] ${$5($).slice(0,60)||"Callout"}`}},{selector:"[data-md='note']",snippet:($)=>`[Note] ${$5($).slice(0,60)||"Note"}`},{selector:"[data-md='table'] tbody tr",snippet:($)=>{let J=Array.from($.querySelectorAll("td")).map((Q)=>Q.textContent?.trim()).filter(Boolean);return J.length?`[Row] ${J.join(" | ")}`:null}}],n2=["[data-md='choice-option']","[data-md='multichoice-option']","[data-md='userinput']","[data-md='rangeinput']"],A1=S1.map(($)=>$.selector).join(", "),J5=[...S1.map(($)=>$.selector),...n2].join(", ");function b1($){for(let J of S1)if($.matches(J.selector))return J.snippet($);return null}var f1={kind:"block",parse:($)=>$.startsWith("[")?{snippet:$}:null,format:($)=>$.snippet,find:($,J)=>{for(let Q of J.querySelectorAll(A1)){if(!(Q instanceof HTMLElement))continue;if(b1(Q)===$.snippet)return Q}return null}};var a2=/^\[Region:(rect|ellipse)\] ([\s\S]+) @(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*)$/;function s2($){if($==="rect")return"rect";if($==="ellipse")return"ellipse";return null}function u0($){if($===void 0)return null;let J=Number($);if(!Number.isInteger(J)||J<0||J>1e4)return null;return J}function Q5($){return{left:`${$.x/100}%`,top:`${$.y/100}%`,width:`${$.w/100}%`,height:`${$.h/100}%`}}function l0($){return`${($/100).toFixed(1).replace(/\.0$/,"")}%`}function R1($){let J=`${l0($.x)}-${l0($.x+$.w)}`,Q=`${l0($.y)}-${l0($.y+$.h)}`;return`[Region] ${$.src} — ${$.shape} x ${J}, y ${Q} of the image`}function v1($,J){for(let Q of J.querySelectorAll("[data-md='image']")){if(!(Q instanceof HTMLElement))continue;if(Q.getAttribute("data-md-src")!==$)continue;let q=Q.querySelector("[data-annotation-image]");if(q instanceof HTMLElement)return q}return null}function W5($,J){let Q=Q5(J);$.style.left=Q.left,$.style.top=Q.top,$.style.width=Q.width,$.style.height=Q.height}function j1($,J,Q){let q=document.createElement("div");return q.className="ann-region",q.setAttribute("data-annotation-id",Q),q.setAttribute("data-annotation-region",J),W5(q,$),q}var c0={kind:"region",parse:($)=>{let J=a2.exec($);if(!J)return null;let Q=s2(J[1]),q=J[2],W=u0(J[3]),Y=u0(J[4]),X=u0(J[5]),G=u0(J[6]);if(Q===null||q===void 0)return null;if(W===null||Y===null||X===null||G===null)return null;if(X<1||G<1)return null;return{src:q,shape:Q,x:W,y:Y,w:X,h:G}},format:($)=>`[Region:${$.shape}] ${$.src} @${$.x},${$.y},${$.w},${$.h}`,find:($,J)=>v1($.src,J),restore:($,J,Q)=>{if(J.querySelector(`[data-annotation-id="${Q.id}"]`))return;let q=v1($.src,J);if(!q)return;q.appendChild(j1($,$.shape,Q.id))},describe:R1};var V1={kind:"text",parse:($)=>$?{text:$}:null,format:($)=>$.text,find:()=>null,restore:($,J,Q)=>{F1(J,[Q])}};var t2=[S0(c0),S0(f1),S0(V1)];import{AnnotationCtx as l8,SessionContext as c8,useAnnotationHost as p8}from"@fabrika/annotations/runtime";import{useEffect as i8,useRef as o8,useState as n8}from"react";var S={};s5(S,{void:()=>g4,util:()=>C,unknown:()=>I4,union:()=>x4,undefined:()=>k4,tuple:()=>c4,transformer:()=>e4,symbol:()=>C4,string:()=>U5,strictObject:()=>Z4,setErrorMap:()=>J4,set:()=>r4,record:()=>p4,quotelessJson:()=>e2,promise:()=>t4,preprocess:()=>Q3,pipeline:()=>W3,ostring:()=>q3,optional:()=>$3,onumber:()=>Y3,oboolean:()=>X3,objectUtil:()=>P1,object:()=>m4,number:()=>w5,nullable:()=>J3,null:()=>E4,never:()=>y4,nativeEnum:()=>s4,nan:()=>V4,map:()=>d4,makeIssue:()=>A0,literal:()=>n4,lazy:()=>o4,late:()=>R4,isValid:()=>D$,isDirty:()=>d0,isAsync:()=>t$,isAborted:()=>p0,intersection:()=>l4,instanceof:()=>j4,getParsedType:()=>L$,getErrorMap:()=>s$,function:()=>i4,enum:()=>a4,effect:()=>e4,discriminatedUnion:()=>u4,defaultErrorMap:()=>f$,datetimeRegex:()=>B5,date:()=>D4,custom:()=>M5,coerce:()=>H3,boolean:()=>z5,bigint:()=>P4,array:()=>h4,any:()=>T4,addIssueToContext:()=>N,ZodVoid:()=>f0,ZodUnknown:()=>C$,ZodUnion:()=>q0,ZodUndefined:()=>Q0,ZodType:()=>D,ZodTuple:()=>S$,ZodTransformer:()=>M$,ZodSymbol:()=>b0,ZodString:()=>H$,ZodSet:()=>d$,ZodSchema:()=>D,ZodRecord:()=>v0,ZodReadonly:()=>M0,ZodPromise:()=>r$,ZodPipeline:()=>V0,ZodParsedType:()=>z,ZodOptional:()=>B$,ZodObject:()=>m,ZodNumber:()=>k$,ZodNullable:()=>R$,ZodNull:()=>W0,ZodNever:()=>F$,ZodNativeEnum:()=>G0,ZodNaN:()=>j0,ZodMap:()=>R0,ZodLiteral:()=>H0,ZodLazy:()=>X0,ZodIssueCode:()=>M,ZodIntersection:()=>Y0,ZodFunction:()=>$0,ZodFirstPartyTypeKind:()=>f,ZodError:()=>$$,ZodEnum:()=>T$,ZodEffects:()=>M$,ZodDiscriminatedUnion:()=>r0,ZodDefault:()=>B0,ZodDate:()=>c$,ZodCatch:()=>_0,ZodBranded:()=>i0,ZodBoolean:()=>J0,ZodBigInt:()=>E$,ZodArray:()=>G$,ZodAny:()=>p$,Schema:()=>D,ParseStatus:()=>r,OK:()=>o,NEVER:()=>G3,INVALID:()=>b,EMPTY_PATH:()=>Q4,DIRTY:()=>l$,BRAND:()=>v4});var C;(function($){$.assertEqual=(W)=>{};function J(W){}$.assertIs=J;function Q(W){throw Error()}$.assertNever=Q,$.arrayToEnum=(W)=>{let Y={};for(let X of W)Y[X]=X;return Y},$.getValidEnumValues=(W)=>{let Y=$.objectKeys(W).filter((G)=>typeof W[W[G]]!=="number"),X={};for(let G of Y)X[G]=W[G];return $.objectValues(X)},$.objectValues=(W)=>{return $.objectKeys(W).map(function(Y){return W[Y]})},$.objectKeys=typeof Object.keys==="function"?(W)=>Object.keys(W):(W)=>{let Y=[];for(let X in W)if(Object.prototype.hasOwnProperty.call(W,X))Y.push(X);return Y},$.find=(W,Y)=>{for(let X of W)if(Y(X))return X;return},$.isInteger=typeof Number.isInteger==="function"?(W)=>Number.isInteger(W):(W)=>typeof W==="number"&&Number.isFinite(W)&&Math.floor(W)===W;function q(W,Y=" | "){return W.map((X)=>typeof X==="string"?`'${X}'`:X).join(Y)}$.joinValues=q,$.jsonStringifyReplacer=(W,Y)=>{if(typeof Y==="bigint")return Y.toString();return Y}})(C||(C={}));var P1;(function($){$.mergeShapes=(J,Q)=>{return{...J,...Q}}})(P1||(P1={}));var z=C.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),L$=($)=>{switch(typeof $){case"undefined":return z.undefined;case"string":return z.string;case"number":return Number.isNaN($)?z.nan:z.number;case"boolean":return z.boolean;case"function":return z.function;case"bigint":return z.bigint;case"symbol":return z.symbol;case"object":if(Array.isArray($))return z.array;if($===null)return z.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return z.promise;if(typeof Map<"u"&&$ instanceof Map)return z.map;if(typeof Set<"u"&&$ instanceof Set)return z.set;if(typeof Date<"u"&&$ instanceof Date)return z.date;return z.object;default:return z.unknown}};var M=C.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),e2=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class $$ extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(Q)=>{this.issues=[...this.issues,Q]},this.addIssues=(Q=[])=>{this.issues=[...this.issues,...Q]};let J=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,J);else this.__proto__=J;this.name="ZodError",this.issues=$}format($){let J=$||function(W){return W.message},Q={_errors:[]},q=(W)=>{for(let Y of W.issues)if(Y.code==="invalid_union")Y.unionErrors.map(q);else if(Y.code==="invalid_return_type")q(Y.returnTypeError);else if(Y.code==="invalid_arguments")q(Y.argumentsError);else if(Y.path.length===0)Q._errors.push(J(Y));else{let X=Q,G=0;while(G<Y.path.length){let H=Y.path[G];if(G!==Y.path.length-1)X[H]=X[H]||{_errors:[]};else X[H]=X[H]||{_errors:[]},X[H]._errors.push(J(Y));X=X[H],G++}}};return q(this),Q}static assert($){if(!($ instanceof $$))throw Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,C.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(J)=>J.message){let J={},Q=[];for(let q of this.issues)if(q.path.length>0){let W=q.path[0];J[W]=J[W]||[],J[W].push($(q))}else Q.push($(q));return{formErrors:Q,fieldErrors:J}}get formErrors(){return this.flatten()}}$$.create=($)=>{return new $$($)};var $4=($,J)=>{let Q;switch($.code){case M.invalid_type:if($.received===z.undefined)Q="Required";else Q=`Expected ${$.expected}, received ${$.received}`;break;case M.invalid_literal:Q=`Invalid literal value, expected ${JSON.stringify($.expected,C.jsonStringifyReplacer)}`;break;case M.unrecognized_keys:Q=`Unrecognized key(s) in object: ${C.joinValues($.keys,", ")}`;break;case M.invalid_union:Q="Invalid input";break;case M.invalid_union_discriminator:Q=`Invalid discriminator value. Expected ${C.joinValues($.options)}`;break;case M.invalid_enum_value:Q=`Invalid enum value. Expected ${C.joinValues($.options)}, received '${$.received}'`;break;case M.invalid_arguments:Q="Invalid function arguments";break;case M.invalid_return_type:Q="Invalid function return type";break;case M.invalid_date:Q="Invalid date";break;case M.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(Q=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")Q=`${Q} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)Q=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)Q=`Invalid input: must end with "${$.validation.endsWith}"`;else C.assertNever($.validation);else if($.validation!=="regex")Q=`Invalid ${$.validation}`;else Q="Invalid";break;case M.too_small:if($.type==="array")Q=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")Q=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")Q=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="bigint")Q=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")Q=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else Q="Invalid input";break;case M.too_big:if($.type==="array")Q=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")Q=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")Q=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")Q=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")Q=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else Q="Invalid input";break;case M.custom:Q="Invalid input";break;case M.invalid_intersection_types:Q="Intersection results could not be merged";break;case M.not_multiple_of:Q=`Number must be a multiple of ${$.multipleOf}`;break;case M.not_finite:Q="Number must be finite";break;default:Q=J.defaultError,C.assertNever($)}return{message:Q}},f$=$4;var q5=f$;function J4($){q5=$}function s$(){return q5}var A0=($)=>{let{data:J,path:Q,errorMaps:q,issueData:W}=$,Y=[...Q,...W.path||[]],X={...W,path:Y};if(W.message!==void 0)return{...W,path:Y,message:W.message};let G="",H=q.filter((B)=>!!B).slice().reverse();for(let B of H)G=B(X,{data:J,defaultError:G}).message;return{...W,path:Y,message:G}},Q4=[];function N($,J){let Q=s$(),q=A0({issueData:J,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,Q,Q===f$?void 0:f$].filter((W)=>!!W)});$.common.issues.push(q)}class r{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,J){let Q=[];for(let q of J){if(q.status==="aborted")return b;if(q.status==="dirty")$.dirty();Q.push(q.value)}return{status:$.value,value:Q}}static async mergeObjectAsync($,J){let Q=[];for(let q of J){let W=await q.key,Y=await q.value;Q.push({key:W,value:Y})}return r.mergeObjectSync($,Q)}static mergeObjectSync($,J){let Q={};for(let q of J){let{key:W,value:Y}=q;if(W.status==="aborted")return b;if(Y.status==="aborted")return b;if(W.status==="dirty")$.dirty();if(Y.status==="dirty")$.dirty();if(W.value!=="__proto__"&&(typeof Y.value<"u"||q.alwaysSet))Q[W.value]=Y.value}return{status:$.value,value:Q}}}var b=Object.freeze({status:"aborted"}),l$=($)=>({status:"dirty",value:$}),o=($)=>({status:"valid",value:$}),p0=($)=>$.status==="aborted",d0=($)=>$.status==="dirty",D$=($)=>$.status==="valid",t$=($)=>typeof Promise<"u"&&$ instanceof Promise;var A;(function($){$.errToObj=(J)=>typeof J==="string"?{message:J}:J||{},$.toString=(J)=>typeof J==="string"?J:J?.message})(A||(A={}));class _${constructor($,J,Q,q){this._cachedPath=[],this.parent=$,this.data=J,this._path=Q,this._key=q}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var Y5=($,J)=>{if(D$(J))return{success:!0,data:J.value};else{if(!$.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let Q=new $$($.common.issues);return this._error=Q,this._error}}}};function V($){if(!$)return{};let{errorMap:J,invalid_type_error:Q,required_error:q,description:W}=$;if(J&&(Q||q))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(J)return{errorMap:J,description:W};return{errorMap:(X,G)=>{let{message:H}=$;if(X.code==="invalid_enum_value")return{message:H??G.defaultError};if(typeof G.data>"u")return{message:H??q??G.defaultError};if(X.code!=="invalid_type")return{message:G.defaultError};return{message:H??Q??G.defaultError}},description:W}}class D{get description(){return this._def.description}_getType($){return L$($.data)}_getOrReturnCtx($,J){return J||{common:$.parent.common,data:$.data,parsedType:L$($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new r,ctx:{common:$.parent.common,data:$.data,parsedType:L$($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let J=this._parse($);if(t$(J))throw Error("Synchronous parse encountered promise.");return J}_parseAsync($){let J=this._parse($);return Promise.resolve(J)}parse($,J){let Q=this.safeParse($,J);if(Q.success)return Q.data;throw Q.error}safeParse($,J){let Q={common:{issues:[],async:J?.async??!1,contextualErrorMap:J?.errorMap},path:J?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:L$($)},q=this._parseSync({data:$,path:Q.path,parent:Q});return Y5(Q,q)}"~validate"($){let J={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:L$($)};if(!this["~standard"].async)try{let Q=this._parseSync({data:$,path:[],parent:J});return D$(Q)?{value:Q.value}:{issues:J.common.issues}}catch(Q){if(Q?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;J.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:J}).then((Q)=>D$(Q)?{value:Q.value}:{issues:J.common.issues})}async parseAsync($,J){let Q=await this.safeParseAsync($,J);if(Q.success)return Q.data;throw Q.error}async safeParseAsync($,J){let Q={common:{issues:[],contextualErrorMap:J?.errorMap,async:!0},path:J?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:L$($)},q=this._parse({data:$,path:Q.path,parent:Q}),W=await(t$(q)?q:Promise.resolve(q));return Y5(Q,W)}refine($,J){let Q=(q)=>{if(typeof J==="string"||typeof J>"u")return{message:J};else if(typeof J==="function")return J(q);else return J};return this._refinement((q,W)=>{let Y=$(q),X=()=>W.addIssue({code:M.custom,...Q(q)});if(typeof Promise<"u"&&Y instanceof Promise)return Y.then((G)=>{if(!G)return X(),!1;else return!0});if(!Y)return X(),!1;else return!0})}refinement($,J){return this._refinement((Q,q)=>{if(!$(Q))return q.addIssue(typeof J==="function"?J(Q,q):J),!1;else return!0})}_refinement($){return new M$({schema:this,typeName:f.ZodEffects,effect:{type:"refinement",refinement:$}})}superRefine($){return this._refinement($)}constructor($){this.spa=this.safeParseAsync,this._def=$,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(J)=>this["~validate"](J)}}optional(){return B$.create(this,this._def)}nullable(){return R$.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return G$.create(this)}promise(){return r$.create(this,this._def)}or($){return q0.create([this,$],this._def)}and($){return Y0.create(this,$,this._def)}transform($){return new M$({...V(this._def),schema:this,typeName:f.ZodEffects,effect:{type:"transform",transform:$}})}default($){let J=typeof $==="function"?$:()=>$;return new B0({...V(this._def),innerType:this,defaultValue:J,typeName:f.ZodDefault})}brand(){return new i0({typeName:f.ZodBranded,type:this,...V(this._def)})}catch($){let J=typeof $==="function"?$:()=>$;return new _0({...V(this._def),innerType:this,catchValue:J,typeName:f.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return V0.create(this,$)}readonly(){return M0.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var W4=/^c[^\s-]{8,}$/i,q4=/^[0-9a-z]+$/,Y4=/^[0-9A-HJKMNP-TV-Z]{26}$/i,X4=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,H4=/^[a-z0-9_-]{21}$/i,G4=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,B4=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,_4=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,M4="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",D1,U4=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,w4=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,z4=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,N4=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,K4=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,O4=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,H5="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",L4=new RegExp(`^${H5}$`);function G5($){let J="[0-5]\\d";if($.precision)J=`${J}\\.\\d{${$.precision}}`;else if($.precision==null)J=`${J}(\\.\\d+)?`;let Q=$.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${J})${Q}`}function F4($){return new RegExp(`^${G5($)}$`)}function B5($){let J=`${H5}T${G5($)}`,Q=[];if(Q.push($.local?"Z?":"Z"),$.offset)Q.push("([+-]\\d{2}:?\\d{2})");return J=`${J}(${Q.join("|")})`,new RegExp(`^${J}$`)}function S4($,J){if((J==="v4"||!J)&&U4.test($))return!0;if((J==="v6"||!J)&&z4.test($))return!0;return!1}function A4($,J){if(!G4.test($))return!1;try{let[Q]=$.split(".");if(!Q)return!1;let q=Q.replace(/-/g,"+").replace(/_/g,"/").padEnd(Q.length+(4-Q.length%4)%4,"="),W=JSON.parse(atob(q));if(typeof W!=="object"||W===null)return!1;if("typ"in W&&W?.typ!=="JWT")return!1;if(!W.alg)return!1;if(J&&W.alg!==J)return!1;return!0}catch{return!1}}function b4($,J){if((J==="v4"||!J)&&w4.test($))return!0;if((J==="v6"||!J)&&N4.test($))return!0;return!1}class H$ extends D{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==z.string){let W=this._getOrReturnCtx($);return N(W,{code:M.invalid_type,expected:z.string,received:W.parsedType}),b}let Q=new r,q=void 0;for(let W of this._def.checks)if(W.kind==="min"){if($.data.length<W.value)q=this._getOrReturnCtx($,q),N(q,{code:M.too_small,minimum:W.value,type:"string",inclusive:!0,exact:!1,message:W.message}),Q.dirty()}else if(W.kind==="max"){if($.data.length>W.value)q=this._getOrReturnCtx($,q),N(q,{code:M.too_big,maximum:W.value,type:"string",inclusive:!0,exact:!1,message:W.message}),Q.dirty()}else if(W.kind==="length"){let Y=$.data.length>W.value,X=$.data.length<W.value;if(Y||X){if(q=this._getOrReturnCtx($,q),Y)N(q,{code:M.too_big,maximum:W.value,type:"string",inclusive:!0,exact:!0,message:W.message});else if(X)N(q,{code:M.too_small,minimum:W.value,type:"string",inclusive:!0,exact:!0,message:W.message});Q.dirty()}}else if(W.kind==="email"){if(!_4.test($.data))q=this._getOrReturnCtx($,q),N(q,{validation:"email",code:M.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="emoji"){if(!D1)D1=new RegExp(M4,"u");if(!D1.test($.data))q=this._getOrReturnCtx($,q),N(q,{validation:"emoji",code:M.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="uuid"){if(!X4.test($.data))q=this._getOrReturnCtx($,q),N(q,{validation:"uuid",code:M.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="nanoid"){if(!H4.test($.data))q=this._getOrReturnCtx($,q),N(q,{validation:"nanoid",code:M.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="cuid"){if(!W4.test($.data))q=this._getOrReturnCtx($,q),N(q,{validation:"cuid",code:M.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="cuid2"){if(!q4.test($.data))q=this._getOrReturnCtx($,q),N(q,{validation:"cuid2",code:M.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="ulid"){if(!Y4.test($.data))q=this._getOrReturnCtx($,q),N(q,{validation:"ulid",code:M.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="url")try{new URL($.data)}catch{q=this._getOrReturnCtx($,q),N(q,{validation:"url",code:M.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="regex"){if(W.regex.lastIndex=0,!W.regex.test($.data))q=this._getOrReturnCtx($,q),N(q,{validation:"regex",code:M.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="trim")$.data=$.data.trim();else if(W.kind==="includes"){if(!$.data.includes(W.value,W.position))q=this._getOrReturnCtx($,q),N(q,{code:M.invalid_string,validation:{includes:W.value,position:W.position},message:W.message}),Q.dirty()}else if(W.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(W.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(W.kind==="startsWith"){if(!$.data.startsWith(W.value))q=this._getOrReturnCtx($,q),N(q,{code:M.invalid_string,validation:{startsWith:W.value},message:W.message}),Q.dirty()}else if(W.kind==="endsWith"){if(!$.data.endsWith(W.value))q=this._getOrReturnCtx($,q),N(q,{code:M.invalid_string,validation:{endsWith:W.value},message:W.message}),Q.dirty()}else if(W.kind==="datetime"){if(!B5(W).test($.data))q=this._getOrReturnCtx($,q),N(q,{code:M.invalid_string,validation:"datetime",message:W.message}),Q.dirty()}else if(W.kind==="date"){if(!L4.test($.data))q=this._getOrReturnCtx($,q),N(q,{code:M.invalid_string,validation:"date",message:W.message}),Q.dirty()}else if(W.kind==="time"){if(!F4(W).test($.data))q=this._getOrReturnCtx($,q),N(q,{code:M.invalid_string,validation:"time",message:W.message}),Q.dirty()}else if(W.kind==="duration"){if(!B4.test($.data))q=this._getOrReturnCtx($,q),N(q,{validation:"duration",code:M.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="ip"){if(!S4($.data,W.version))q=this._getOrReturnCtx($,q),N(q,{validation:"ip",code:M.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="jwt"){if(!A4($.data,W.alg))q=this._getOrReturnCtx($,q),N(q,{validation:"jwt",code:M.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="cidr"){if(!b4($.data,W.version))q=this._getOrReturnCtx($,q),N(q,{validation:"cidr",code:M.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="base64"){if(!K4.test($.data))q=this._getOrReturnCtx($,q),N(q,{validation:"base64",code:M.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="base64url"){if(!O4.test($.data))q=this._getOrReturnCtx($,q),N(q,{validation:"base64url",code:M.invalid_string,message:W.message}),Q.dirty()}else C.assertNever(W);return{status:Q.value,value:$.data}}_regex($,J,Q){return this.refinement((q)=>$.test(q),{validation:J,code:M.invalid_string,...A.errToObj(Q)})}_addCheck($){return new H$({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...A.errToObj($)})}url($){return this._addCheck({kind:"url",...A.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...A.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...A.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...A.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...A.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...A.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...A.errToObj($)})}base64($){return this._addCheck({kind:"base64",...A.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...A.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...A.errToObj($)})}ip($){return this._addCheck({kind:"ip",...A.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...A.errToObj($)})}datetime($){if(typeof $==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:$});return this._addCheck({kind:"datetime",precision:typeof $?.precision>"u"?null:$?.precision,offset:$?.offset??!1,local:$?.local??!1,...A.errToObj($?.message)})}date($){return this._addCheck({kind:"date",message:$})}time($){if(typeof $==="string")return this._addCheck({kind:"time",precision:null,message:$});return this._addCheck({kind:"time",precision:typeof $?.precision>"u"?null:$?.precision,...A.errToObj($?.message)})}duration($){return this._addCheck({kind:"duration",...A.errToObj($)})}regex($,J){return this._addCheck({kind:"regex",regex:$,...A.errToObj(J)})}includes($,J){return this._addCheck({kind:"includes",value:$,position:J?.position,...A.errToObj(J?.message)})}startsWith($,J){return this._addCheck({kind:"startsWith",value:$,...A.errToObj(J)})}endsWith($,J){return this._addCheck({kind:"endsWith",value:$,...A.errToObj(J)})}min($,J){return this._addCheck({kind:"min",value:$,...A.errToObj(J)})}max($,J){return this._addCheck({kind:"max",value:$,...A.errToObj(J)})}length($,J){return this._addCheck({kind:"length",value:$,...A.errToObj(J)})}nonempty($){return this.min(1,A.errToObj($))}trim(){return new H$({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new H$({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new H$({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(($)=>$.kind==="datetime")}get isDate(){return!!this._def.checks.find(($)=>$.kind==="date")}get isTime(){return!!this._def.checks.find(($)=>$.kind==="time")}get isDuration(){return!!this._def.checks.find(($)=>$.kind==="duration")}get isEmail(){return!!this._def.checks.find(($)=>$.kind==="email")}get isURL(){return!!this._def.checks.find(($)=>$.kind==="url")}get isEmoji(){return!!this._def.checks.find(($)=>$.kind==="emoji")}get isUUID(){return!!this._def.checks.find(($)=>$.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(($)=>$.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(($)=>$.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(($)=>$.kind==="cuid2")}get isULID(){return!!this._def.checks.find(($)=>$.kind==="ulid")}get isIP(){return!!this._def.checks.find(($)=>$.kind==="ip")}get isCIDR(){return!!this._def.checks.find(($)=>$.kind==="cidr")}get isBase64(){return!!this._def.checks.find(($)=>$.kind==="base64")}get isBase64url(){return!!this._def.checks.find(($)=>$.kind==="base64url")}get minLength(){let $=null;for(let J of this._def.checks)if(J.kind==="min"){if($===null||J.value>$)$=J.value}return $}get maxLength(){let $=null;for(let J of this._def.checks)if(J.kind==="max"){if($===null||J.value<$)$=J.value}return $}}H$.create=($)=>{return new H$({checks:[],typeName:f.ZodString,coerce:$?.coerce??!1,...V($)})};function f4($,J){let Q=($.toString().split(".")[1]||"").length,q=(J.toString().split(".")[1]||"").length,W=Q>q?Q:q,Y=Number.parseInt($.toFixed(W).replace(".","")),X=Number.parseInt(J.toFixed(W).replace(".",""));return Y%X/10**W}class k$ extends D{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse($){if(this._def.coerce)$.data=Number($.data);if(this._getType($)!==z.number){let W=this._getOrReturnCtx($);return N(W,{code:M.invalid_type,expected:z.number,received:W.parsedType}),b}let Q=void 0,q=new r;for(let W of this._def.checks)if(W.kind==="int"){if(!C.isInteger($.data))Q=this._getOrReturnCtx($,Q),N(Q,{code:M.invalid_type,expected:"integer",received:"float",message:W.message}),q.dirty()}else if(W.kind==="min"){if(W.inclusive?$.data<W.value:$.data<=W.value)Q=this._getOrReturnCtx($,Q),N(Q,{code:M.too_small,minimum:W.value,type:"number",inclusive:W.inclusive,exact:!1,message:W.message}),q.dirty()}else if(W.kind==="max"){if(W.inclusive?$.data>W.value:$.data>=W.value)Q=this._getOrReturnCtx($,Q),N(Q,{code:M.too_big,maximum:W.value,type:"number",inclusive:W.inclusive,exact:!1,message:W.message}),q.dirty()}else if(W.kind==="multipleOf"){if(f4($.data,W.value)!==0)Q=this._getOrReturnCtx($,Q),N(Q,{code:M.not_multiple_of,multipleOf:W.value,message:W.message}),q.dirty()}else if(W.kind==="finite"){if(!Number.isFinite($.data))Q=this._getOrReturnCtx($,Q),N(Q,{code:M.not_finite,message:W.message}),q.dirty()}else C.assertNever(W);return{status:q.value,value:$.data}}gte($,J){return this.setLimit("min",$,!0,A.toString(J))}gt($,J){return this.setLimit("min",$,!1,A.toString(J))}lte($,J){return this.setLimit("max",$,!0,A.toString(J))}lt($,J){return this.setLimit("max",$,!1,A.toString(J))}setLimit($,J,Q,q){return new k$({...this._def,checks:[...this._def.checks,{kind:$,value:J,inclusive:Q,message:A.toString(q)}]})}_addCheck($){return new k$({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:A.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:A.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:A.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:A.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:A.toString($)})}multipleOf($,J){return this._addCheck({kind:"multipleOf",value:$,message:A.toString(J)})}finite($){return this._addCheck({kind:"finite",message:A.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:A.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:A.toString($)})}get minValue(){let $=null;for(let J of this._def.checks)if(J.kind==="min"){if($===null||J.value>$)$=J.value}return $}get maxValue(){let $=null;for(let J of this._def.checks)if(J.kind==="max"){if($===null||J.value<$)$=J.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&C.isInteger($.value))}get isFinite(){let $=null,J=null;for(let Q of this._def.checks)if(Q.kind==="finite"||Q.kind==="int"||Q.kind==="multipleOf")return!0;else if(Q.kind==="min"){if(J===null||Q.value>J)J=Q.value}else if(Q.kind==="max"){if($===null||Q.value<$)$=Q.value}return Number.isFinite(J)&&Number.isFinite($)}}k$.create=($)=>{return new k$({checks:[],typeName:f.ZodNumber,coerce:$?.coerce||!1,...V($)})};class E$ extends D{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse($){if(this._def.coerce)try{$.data=BigInt($.data)}catch{return this._getInvalidInput($)}if(this._getType($)!==z.bigint)return this._getInvalidInput($);let Q=void 0,q=new r;for(let W of this._def.checks)if(W.kind==="min"){if(W.inclusive?$.data<W.value:$.data<=W.value)Q=this._getOrReturnCtx($,Q),N(Q,{code:M.too_small,type:"bigint",minimum:W.value,inclusive:W.inclusive,message:W.message}),q.dirty()}else if(W.kind==="max"){if(W.inclusive?$.data>W.value:$.data>=W.value)Q=this._getOrReturnCtx($,Q),N(Q,{code:M.too_big,type:"bigint",maximum:W.value,inclusive:W.inclusive,message:W.message}),q.dirty()}else if(W.kind==="multipleOf"){if($.data%W.value!==BigInt(0))Q=this._getOrReturnCtx($,Q),N(Q,{code:M.not_multiple_of,multipleOf:W.value,message:W.message}),q.dirty()}else C.assertNever(W);return{status:q.value,value:$.data}}_getInvalidInput($){let J=this._getOrReturnCtx($);return N(J,{code:M.invalid_type,expected:z.bigint,received:J.parsedType}),b}gte($,J){return this.setLimit("min",$,!0,A.toString(J))}gt($,J){return this.setLimit("min",$,!1,A.toString(J))}lte($,J){return this.setLimit("max",$,!0,A.toString(J))}lt($,J){return this.setLimit("max",$,!1,A.toString(J))}setLimit($,J,Q,q){return new E$({...this._def,checks:[...this._def.checks,{kind:$,value:J,inclusive:Q,message:A.toString(q)}]})}_addCheck($){return new E$({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:A.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:A.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:A.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:A.toString($)})}multipleOf($,J){return this._addCheck({kind:"multipleOf",value:$,message:A.toString(J)})}get minValue(){let $=null;for(let J of this._def.checks)if(J.kind==="min"){if($===null||J.value>$)$=J.value}return $}get maxValue(){let $=null;for(let J of this._def.checks)if(J.kind==="max"){if($===null||J.value<$)$=J.value}return $}}E$.create=($)=>{return new E$({checks:[],typeName:f.ZodBigInt,coerce:$?.coerce??!1,...V($)})};class J0 extends D{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==z.boolean){let Q=this._getOrReturnCtx($);return N(Q,{code:M.invalid_type,expected:z.boolean,received:Q.parsedType}),b}return o($.data)}}J0.create=($)=>{return new J0({typeName:f.ZodBoolean,coerce:$?.coerce||!1,...V($)})};class c$ extends D{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==z.date){let W=this._getOrReturnCtx($);return N(W,{code:M.invalid_type,expected:z.date,received:W.parsedType}),b}if(Number.isNaN($.data.getTime())){let W=this._getOrReturnCtx($);return N(W,{code:M.invalid_date}),b}let Q=new r,q=void 0;for(let W of this._def.checks)if(W.kind==="min"){if($.data.getTime()<W.value)q=this._getOrReturnCtx($,q),N(q,{code:M.too_small,message:W.message,inclusive:!0,exact:!1,minimum:W.value,type:"date"}),Q.dirty()}else if(W.kind==="max"){if($.data.getTime()>W.value)q=this._getOrReturnCtx($,q),N(q,{code:M.too_big,message:W.message,inclusive:!0,exact:!1,maximum:W.value,type:"date"}),Q.dirty()}else C.assertNever(W);return{status:Q.value,value:new Date($.data.getTime())}}_addCheck($){return new c$({...this._def,checks:[...this._def.checks,$]})}min($,J){return this._addCheck({kind:"min",value:$.getTime(),message:A.toString(J)})}max($,J){return this._addCheck({kind:"max",value:$.getTime(),message:A.toString(J)})}get minDate(){let $=null;for(let J of this._def.checks)if(J.kind==="min"){if($===null||J.value>$)$=J.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let J of this._def.checks)if(J.kind==="max"){if($===null||J.value<$)$=J.value}return $!=null?new Date($):null}}c$.create=($)=>{return new c$({checks:[],coerce:$?.coerce||!1,typeName:f.ZodDate,...V($)})};class b0 extends D{_parse($){if(this._getType($)!==z.symbol){let Q=this._getOrReturnCtx($);return N(Q,{code:M.invalid_type,expected:z.symbol,received:Q.parsedType}),b}return o($.data)}}b0.create=($)=>{return new b0({typeName:f.ZodSymbol,...V($)})};class Q0 extends D{_parse($){if(this._getType($)!==z.undefined){let Q=this._getOrReturnCtx($);return N(Q,{code:M.invalid_type,expected:z.undefined,received:Q.parsedType}),b}return o($.data)}}Q0.create=($)=>{return new Q0({typeName:f.ZodUndefined,...V($)})};class W0 extends D{_parse($){if(this._getType($)!==z.null){let Q=this._getOrReturnCtx($);return N(Q,{code:M.invalid_type,expected:z.null,received:Q.parsedType}),b}return o($.data)}}W0.create=($)=>{return new W0({typeName:f.ZodNull,...V($)})};class p$ extends D{constructor(){super(...arguments);this._any=!0}_parse($){return o($.data)}}p$.create=($)=>{return new p$({typeName:f.ZodAny,...V($)})};class C$ extends D{constructor(){super(...arguments);this._unknown=!0}_parse($){return o($.data)}}C$.create=($)=>{return new C$({typeName:f.ZodUnknown,...V($)})};class F$ extends D{_parse($){let J=this._getOrReturnCtx($);return N(J,{code:M.invalid_type,expected:z.never,received:J.parsedType}),b}}F$.create=($)=>{return new F$({typeName:f.ZodNever,...V($)})};class f0 extends D{_parse($){if(this._getType($)!==z.undefined){let Q=this._getOrReturnCtx($);return N(Q,{code:M.invalid_type,expected:z.void,received:Q.parsedType}),b}return o($.data)}}f0.create=($)=>{return new f0({typeName:f.ZodVoid,...V($)})};class G$ extends D{_parse($){let{ctx:J,status:Q}=this._processInputParams($),q=this._def;if(J.parsedType!==z.array)return N(J,{code:M.invalid_type,expected:z.array,received:J.parsedType}),b;if(q.exactLength!==null){let Y=J.data.length>q.exactLength.value,X=J.data.length<q.exactLength.value;if(Y||X)N(J,{code:Y?M.too_big:M.too_small,minimum:X?q.exactLength.value:void 0,maximum:Y?q.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:q.exactLength.message}),Q.dirty()}if(q.minLength!==null){if(J.data.length<q.minLength.value)N(J,{code:M.too_small,minimum:q.minLength.value,type:"array",inclusive:!0,exact:!1,message:q.minLength.message}),Q.dirty()}if(q.maxLength!==null){if(J.data.length>q.maxLength.value)N(J,{code:M.too_big,maximum:q.maxLength.value,type:"array",inclusive:!0,exact:!1,message:q.maxLength.message}),Q.dirty()}if(J.common.async)return Promise.all([...J.data].map((Y,X)=>{return q.type._parseAsync(new _$(J,Y,J.path,X))})).then((Y)=>{return r.mergeArray(Q,Y)});let W=[...J.data].map((Y,X)=>{return q.type._parseSync(new _$(J,Y,J.path,X))});return r.mergeArray(Q,W)}get element(){return this._def.type}min($,J){return new G$({...this._def,minLength:{value:$,message:A.toString(J)}})}max($,J){return new G$({...this._def,maxLength:{value:$,message:A.toString(J)}})}length($,J){return new G$({...this._def,exactLength:{value:$,message:A.toString(J)}})}nonempty($){return this.min(1,$)}}G$.create=($,J)=>{return new G$({type:$,minLength:null,maxLength:null,exactLength:null,typeName:f.ZodArray,...V(J)})};function e$($){if($ instanceof m){let J={};for(let Q in $.shape){let q=$.shape[Q];J[Q]=B$.create(e$(q))}return new m({...$._def,shape:()=>J})}else if($ instanceof G$)return new G$({...$._def,type:e$($.element)});else if($ instanceof B$)return B$.create(e$($.unwrap()));else if($ instanceof R$)return R$.create(e$($.unwrap()));else if($ instanceof S$)return S$.create($.items.map((J)=>e$(J)));else return $}class m extends D{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let $=this._def.shape(),J=C.objectKeys($);return this._cached={shape:$,keys:J},this._cached}_parse($){if(this._getType($)!==z.object){let H=this._getOrReturnCtx($);return N(H,{code:M.invalid_type,expected:z.object,received:H.parsedType}),b}let{status:Q,ctx:q}=this._processInputParams($),{shape:W,keys:Y}=this._getCached(),X=[];if(!(this._def.catchall instanceof F$&&this._def.unknownKeys==="strip")){for(let H in q.data)if(!Y.includes(H))X.push(H)}let G=[];for(let H of Y){let B=W[H],_=q.data[H];G.push({key:{status:"valid",value:H},value:B._parse(new _$(q,_,q.path,H)),alwaysSet:H in q.data})}if(this._def.catchall instanceof F$){let H=this._def.unknownKeys;if(H==="passthrough")for(let B of X)G.push({key:{status:"valid",value:B},value:{status:"valid",value:q.data[B]}});else if(H==="strict"){if(X.length>0)N(q,{code:M.unrecognized_keys,keys:X}),Q.dirty()}else if(H==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let H=this._def.catchall;for(let B of X){let _=q.data[B];G.push({key:{status:"valid",value:B},value:H._parse(new _$(q,_,q.path,B)),alwaysSet:B in q.data})}}if(q.common.async)return Promise.resolve().then(async()=>{let H=[];for(let B of G){let _=await B.key,w=await B.value;H.push({key:_,value:w,alwaysSet:B.alwaysSet})}return H}).then((H)=>{return r.mergeObjectSync(Q,H)});else return r.mergeObjectSync(Q,G)}get shape(){return this._def.shape()}strict($){return A.errToObj,new m({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(J,Q)=>{let q=this._def.errorMap?.(J,Q).message??Q.defaultError;if(J.code==="unrecognized_keys")return{message:A.errToObj($).message??q};return{message:q}}}:{}})}strip(){return new m({...this._def,unknownKeys:"strip"})}passthrough(){return new m({...this._def,unknownKeys:"passthrough"})}extend($){return new m({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new m({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:f.ZodObject})}setKey($,J){return this.augment({[$]:J})}catchall($){return new m({...this._def,catchall:$})}pick($){let J={};for(let Q of C.objectKeys($))if($[Q]&&this.shape[Q])J[Q]=this.shape[Q];return new m({...this._def,shape:()=>J})}omit($){let J={};for(let Q of C.objectKeys(this.shape))if(!$[Q])J[Q]=this.shape[Q];return new m({...this._def,shape:()=>J})}deepPartial(){return e$(this)}partial($){let J={};for(let Q of C.objectKeys(this.shape)){let q=this.shape[Q];if($&&!$[Q])J[Q]=q;else J[Q]=q.optional()}return new m({...this._def,shape:()=>J})}required($){let J={};for(let Q of C.objectKeys(this.shape))if($&&!$[Q])J[Q]=this.shape[Q];else{let W=this.shape[Q];while(W instanceof B$)W=W._def.innerType;J[Q]=W}return new m({...this._def,shape:()=>J})}keyof(){return _5(C.objectKeys(this.shape))}}m.create=($,J)=>{return new m({shape:()=>$,unknownKeys:"strip",catchall:F$.create(),typeName:f.ZodObject,...V(J)})};m.strictCreate=($,J)=>{return new m({shape:()=>$,unknownKeys:"strict",catchall:F$.create(),typeName:f.ZodObject,...V(J)})};m.lazycreate=($,J)=>{return new m({shape:$,unknownKeys:"strip",catchall:F$.create(),typeName:f.ZodObject,...V(J)})};class q0 extends D{_parse($){let{ctx:J}=this._processInputParams($),Q=this._def.options;function q(W){for(let X of W)if(X.result.status==="valid")return X.result;for(let X of W)if(X.result.status==="dirty")return J.common.issues.push(...X.ctx.common.issues),X.result;let Y=W.map((X)=>new $$(X.ctx.common.issues));return N(J,{code:M.invalid_union,unionErrors:Y}),b}if(J.common.async)return Promise.all(Q.map(async(W)=>{let Y={...J,common:{...J.common,issues:[]},parent:null};return{result:await W._parseAsync({data:J.data,path:J.path,parent:Y}),ctx:Y}})).then(q);else{let W=void 0,Y=[];for(let G of Q){let H={...J,common:{...J.common,issues:[]},parent:null},B=G._parseSync({data:J.data,path:J.path,parent:H});if(B.status==="valid")return B;else if(B.status==="dirty"&&!W)W={result:B,ctx:H};if(H.common.issues.length)Y.push(H.common.issues)}if(W)return J.common.issues.push(...W.ctx.common.issues),W.result;let X=Y.map((G)=>new $$(G));return N(J,{code:M.invalid_union,unionErrors:X}),b}}get options(){return this._def.options}}q0.create=($,J)=>{return new q0({options:$,typeName:f.ZodUnion,...V(J)})};var v$=($)=>{if($ instanceof X0)return v$($.schema);else if($ instanceof M$)return v$($.innerType());else if($ instanceof H0)return[$.value];else if($ instanceof T$)return $.options;else if($ instanceof G0)return C.objectValues($.enum);else if($ instanceof B0)return v$($._def.innerType);else if($ instanceof Q0)return[void 0];else if($ instanceof W0)return[null];else if($ instanceof B$)return[void 0,...v$($.unwrap())];else if($ instanceof R$)return[null,...v$($.unwrap())];else if($ instanceof i0)return v$($.unwrap());else if($ instanceof M0)return v$($.unwrap());else if($ instanceof _0)return v$($._def.innerType);else return[]};class r0 extends D{_parse($){let{ctx:J}=this._processInputParams($);if(J.parsedType!==z.object)return N(J,{code:M.invalid_type,expected:z.object,received:J.parsedType}),b;let Q=this.discriminator,q=J.data[Q],W=this.optionsMap.get(q);if(!W)return N(J,{code:M.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[Q]}),b;if(J.common.async)return W._parseAsync({data:J.data,path:J.path,parent:J});else return W._parseSync({data:J.data,path:J.path,parent:J})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,J,Q){let q=new Map;for(let W of J){let Y=v$(W.shape[$]);if(!Y.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let X of Y){if(q.has(X))throw Error(`Discriminator property ${String($)} has duplicate value ${String(X)}`);q.set(X,W)}}return new r0({typeName:f.ZodDiscriminatedUnion,discriminator:$,options:J,optionsMap:q,...V(Q)})}}function C1($,J){let Q=L$($),q=L$(J);if($===J)return{valid:!0,data:$};else if(Q===z.object&&q===z.object){let W=C.objectKeys(J),Y=C.objectKeys($).filter((G)=>W.indexOf(G)!==-1),X={...$,...J};for(let G of Y){let H=C1($[G],J[G]);if(!H.valid)return{valid:!1};X[G]=H.data}return{valid:!0,data:X}}else if(Q===z.array&&q===z.array){if($.length!==J.length)return{valid:!1};let W=[];for(let Y=0;Y<$.length;Y++){let X=$[Y],G=J[Y],H=C1(X,G);if(!H.valid)return{valid:!1};W.push(H.data)}return{valid:!0,data:W}}else if(Q===z.date&&q===z.date&&+$===+J)return{valid:!0,data:$};else return{valid:!1}}class Y0 extends D{_parse($){let{status:J,ctx:Q}=this._processInputParams($),q=(W,Y)=>{if(p0(W)||p0(Y))return b;let X=C1(W.value,Y.value);if(!X.valid)return N(Q,{code:M.invalid_intersection_types}),b;if(d0(W)||d0(Y))J.dirty();return{status:J.value,value:X.data}};if(Q.common.async)return Promise.all([this._def.left._parseAsync({data:Q.data,path:Q.path,parent:Q}),this._def.right._parseAsync({data:Q.data,path:Q.path,parent:Q})]).then(([W,Y])=>q(W,Y));else return q(this._def.left._parseSync({data:Q.data,path:Q.path,parent:Q}),this._def.right._parseSync({data:Q.data,path:Q.path,parent:Q}))}}Y0.create=($,J,Q)=>{return new Y0({left:$,right:J,typeName:f.ZodIntersection,...V(Q)})};class S$ extends D{_parse($){let{status:J,ctx:Q}=this._processInputParams($);if(Q.parsedType!==z.array)return N(Q,{code:M.invalid_type,expected:z.array,received:Q.parsedType}),b;if(Q.data.length<this._def.items.length)return N(Q,{code:M.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),b;if(!this._def.rest&&Q.data.length>this._def.items.length)N(Q,{code:M.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),J.dirty();let W=[...Q.data].map((Y,X)=>{let G=this._def.items[X]||this._def.rest;if(!G)return null;return G._parse(new _$(Q,Y,Q.path,X))}).filter((Y)=>!!Y);if(Q.common.async)return Promise.all(W).then((Y)=>{return r.mergeArray(J,Y)});else return r.mergeArray(J,W)}get items(){return this._def.items}rest($){return new S$({...this._def,rest:$})}}S$.create=($,J)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new S$({items:$,typeName:f.ZodTuple,rest:null,...V(J)})};class v0 extends D{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:J,ctx:Q}=this._processInputParams($);if(Q.parsedType!==z.object)return N(Q,{code:M.invalid_type,expected:z.object,received:Q.parsedType}),b;let q=[],W=this._def.keyType,Y=this._def.valueType;for(let X in Q.data)q.push({key:W._parse(new _$(Q,X,Q.path,X)),value:Y._parse(new _$(Q,Q.data[X],Q.path,X)),alwaysSet:X in Q.data});if(Q.common.async)return r.mergeObjectAsync(J,q);else return r.mergeObjectSync(J,q)}get element(){return this._def.valueType}static create($,J,Q){if(J instanceof D)return new v0({keyType:$,valueType:J,typeName:f.ZodRecord,...V(Q)});return new v0({keyType:H$.create(),valueType:$,typeName:f.ZodRecord,...V(J)})}}class R0 extends D{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:J,ctx:Q}=this._processInputParams($);if(Q.parsedType!==z.map)return N(Q,{code:M.invalid_type,expected:z.map,received:Q.parsedType}),b;let q=this._def.keyType,W=this._def.valueType,Y=[...Q.data.entries()].map(([X,G],H)=>{return{key:q._parse(new _$(Q,X,Q.path,[H,"key"])),value:W._parse(new _$(Q,G,Q.path,[H,"value"]))}});if(Q.common.async){let X=new Map;return Promise.resolve().then(async()=>{for(let G of Y){let H=await G.key,B=await G.value;if(H.status==="aborted"||B.status==="aborted")return b;if(H.status==="dirty"||B.status==="dirty")J.dirty();X.set(H.value,B.value)}return{status:J.value,value:X}})}else{let X=new Map;for(let G of Y){let{key:H,value:B}=G;if(H.status==="aborted"||B.status==="aborted")return b;if(H.status==="dirty"||B.status==="dirty")J.dirty();X.set(H.value,B.value)}return{status:J.value,value:X}}}}R0.create=($,J,Q)=>{return new R0({valueType:J,keyType:$,typeName:f.ZodMap,...V(Q)})};class d$ extends D{_parse($){let{status:J,ctx:Q}=this._processInputParams($);if(Q.parsedType!==z.set)return N(Q,{code:M.invalid_type,expected:z.set,received:Q.parsedType}),b;let q=this._def;if(q.minSize!==null){if(Q.data.size<q.minSize.value)N(Q,{code:M.too_small,minimum:q.minSize.value,type:"set",inclusive:!0,exact:!1,message:q.minSize.message}),J.dirty()}if(q.maxSize!==null){if(Q.data.size>q.maxSize.value)N(Q,{code:M.too_big,maximum:q.maxSize.value,type:"set",inclusive:!0,exact:!1,message:q.maxSize.message}),J.dirty()}let W=this._def.valueType;function Y(G){let H=new Set;for(let B of G){if(B.status==="aborted")return b;if(B.status==="dirty")J.dirty();H.add(B.value)}return{status:J.value,value:H}}let X=[...Q.data.values()].map((G,H)=>W._parse(new _$(Q,G,Q.path,H)));if(Q.common.async)return Promise.all(X).then((G)=>Y(G));else return Y(X)}min($,J){return new d$({...this._def,minSize:{value:$,message:A.toString(J)}})}max($,J){return new d$({...this._def,maxSize:{value:$,message:A.toString(J)}})}size($,J){return this.min($,J).max($,J)}nonempty($){return this.min(1,$)}}d$.create=($,J)=>{return new d$({valueType:$,minSize:null,maxSize:null,typeName:f.ZodSet,...V(J)})};class $0 extends D{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:J}=this._processInputParams($);if(J.parsedType!==z.function)return N(J,{code:M.invalid_type,expected:z.function,received:J.parsedType}),b;function Q(X,G){return A0({data:X,path:J.path,errorMaps:[J.common.contextualErrorMap,J.schemaErrorMap,s$(),f$].filter((H)=>!!H),issueData:{code:M.invalid_arguments,argumentsError:G}})}function q(X,G){return A0({data:X,path:J.path,errorMaps:[J.common.contextualErrorMap,J.schemaErrorMap,s$(),f$].filter((H)=>!!H),issueData:{code:M.invalid_return_type,returnTypeError:G}})}let W={errorMap:J.common.contextualErrorMap},Y=J.data;if(this._def.returns instanceof r$){let X=this;return o(async function(...G){let H=new $$([]),B=await X._def.args.parseAsync(G,W).catch((L)=>{throw H.addIssue(Q(G,L)),H}),_=await Reflect.apply(Y,this,B);return await X._def.returns._def.type.parseAsync(_,W).catch((L)=>{throw H.addIssue(q(_,L)),H})})}else{let X=this;return o(function(...G){let H=X._def.args.safeParse(G,W);if(!H.success)throw new $$([Q(G,H.error)]);let B=Reflect.apply(Y,this,H.data),_=X._def.returns.safeParse(B,W);if(!_.success)throw new $$([q(B,_.error)]);return _.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new $0({...this._def,args:S$.create($).rest(C$.create())})}returns($){return new $0({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,J,Q){return new $0({args:$?$:S$.create([]).rest(C$.create()),returns:J||C$.create(),typeName:f.ZodFunction,...V(Q)})}}class X0 extends D{get schema(){return this._def.getter()}_parse($){let{ctx:J}=this._processInputParams($);return this._def.getter()._parse({data:J.data,path:J.path,parent:J})}}X0.create=($,J)=>{return new X0({getter:$,typeName:f.ZodLazy,...V(J)})};class H0 extends D{_parse($){if($.data!==this._def.value){let J=this._getOrReturnCtx($);return N(J,{received:J.data,code:M.invalid_literal,expected:this._def.value}),b}return{status:"valid",value:$.data}}get value(){return this._def.value}}H0.create=($,J)=>{return new H0({value:$,typeName:f.ZodLiteral,...V(J)})};function _5($,J){return new T$({values:$,typeName:f.ZodEnum,...V(J)})}class T$ extends D{_parse($){if(typeof $.data!=="string"){let J=this._getOrReturnCtx($),Q=this._def.values;return N(J,{expected:C.joinValues(Q),received:J.parsedType,code:M.invalid_type}),b}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has($.data)){let J=this._getOrReturnCtx($),Q=this._def.values;return N(J,{received:J.data,code:M.invalid_enum_value,options:Q}),b}return o($.data)}get options(){return this._def.values}get enum(){let $={};for(let J of this._def.values)$[J]=J;return $}get Values(){let $={};for(let J of this._def.values)$[J]=J;return $}get Enum(){let $={};for(let J of this._def.values)$[J]=J;return $}extract($,J=this._def){return T$.create($,{...this._def,...J})}exclude($,J=this._def){return T$.create(this.options.filter((Q)=>!$.includes(Q)),{...this._def,...J})}}T$.create=_5;class G0 extends D{_parse($){let J=C.getValidEnumValues(this._def.values),Q=this._getOrReturnCtx($);if(Q.parsedType!==z.string&&Q.parsedType!==z.number){let q=C.objectValues(J);return N(Q,{expected:C.joinValues(q),received:Q.parsedType,code:M.invalid_type}),b}if(!this._cache)this._cache=new Set(C.getValidEnumValues(this._def.values));if(!this._cache.has($.data)){let q=C.objectValues(J);return N(Q,{received:Q.data,code:M.invalid_enum_value,options:q}),b}return o($.data)}get enum(){return this._def.values}}G0.create=($,J)=>{return new G0({values:$,typeName:f.ZodNativeEnum,...V(J)})};class r$ extends D{unwrap(){return this._def.type}_parse($){let{ctx:J}=this._processInputParams($);if(J.parsedType!==z.promise&&J.common.async===!1)return N(J,{code:M.invalid_type,expected:z.promise,received:J.parsedType}),b;let Q=J.parsedType===z.promise?J.data:Promise.resolve(J.data);return o(Q.then((q)=>{return this._def.type.parseAsync(q,{path:J.path,errorMap:J.common.contextualErrorMap})}))}}r$.create=($,J)=>{return new r$({type:$,typeName:f.ZodPromise,...V(J)})};class M$ extends D{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===f.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:J,ctx:Q}=this._processInputParams($),q=this._def.effect||null,W={addIssue:(Y)=>{if(N(Q,Y),Y.fatal)J.abort();else J.dirty()},get path(){return Q.path}};if(W.addIssue=W.addIssue.bind(W),q.type==="preprocess"){let Y=q.transform(Q.data,W);if(Q.common.async)return Promise.resolve(Y).then(async(X)=>{if(J.value==="aborted")return b;let G=await this._def.schema._parseAsync({data:X,path:Q.path,parent:Q});if(G.status==="aborted")return b;if(G.status==="dirty")return l$(G.value);if(J.value==="dirty")return l$(G.value);return G});else{if(J.value==="aborted")return b;let X=this._def.schema._parseSync({data:Y,path:Q.path,parent:Q});if(X.status==="aborted")return b;if(X.status==="dirty")return l$(X.value);if(J.value==="dirty")return l$(X.value);return X}}if(q.type==="refinement"){let Y=(X)=>{let G=q.refinement(X,W);if(Q.common.async)return Promise.resolve(G);if(G instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return X};if(Q.common.async===!1){let X=this._def.schema._parseSync({data:Q.data,path:Q.path,parent:Q});if(X.status==="aborted")return b;if(X.status==="dirty")J.dirty();return Y(X.value),{status:J.value,value:X.value}}else return this._def.schema._parseAsync({data:Q.data,path:Q.path,parent:Q}).then((X)=>{if(X.status==="aborted")return b;if(X.status==="dirty")J.dirty();return Y(X.value).then(()=>{return{status:J.value,value:X.value}})})}if(q.type==="transform")if(Q.common.async===!1){let Y=this._def.schema._parseSync({data:Q.data,path:Q.path,parent:Q});if(!D$(Y))return b;let X=q.transform(Y.value,W);if(X instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:J.value,value:X}}else return this._def.schema._parseAsync({data:Q.data,path:Q.path,parent:Q}).then((Y)=>{if(!D$(Y))return b;return Promise.resolve(q.transform(Y.value,W)).then((X)=>({status:J.value,value:X}))});C.assertNever(q)}}M$.create=($,J,Q)=>{return new M$({schema:$,typeName:f.ZodEffects,effect:J,...V(Q)})};M$.createWithPreprocess=($,J,Q)=>{return new M$({schema:J,effect:{type:"preprocess",transform:$},typeName:f.ZodEffects,...V(Q)})};class B$ extends D{_parse($){if(this._getType($)===z.undefined)return o(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}B$.create=($,J)=>{return new B$({innerType:$,typeName:f.ZodOptional,...V(J)})};class R$ extends D{_parse($){if(this._getType($)===z.null)return o(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}R$.create=($,J)=>{return new R$({innerType:$,typeName:f.ZodNullable,...V(J)})};class B0 extends D{_parse($){let{ctx:J}=this._processInputParams($),Q=J.data;if(J.parsedType===z.undefined)Q=this._def.defaultValue();return this._def.innerType._parse({data:Q,path:J.path,parent:J})}removeDefault(){return this._def.innerType}}B0.create=($,J)=>{return new B0({innerType:$,typeName:f.ZodDefault,defaultValue:typeof J.default==="function"?J.default:()=>J.default,...V(J)})};class _0 extends D{_parse($){let{ctx:J}=this._processInputParams($),Q={...J,common:{...J.common,issues:[]}},q=this._def.innerType._parse({data:Q.data,path:Q.path,parent:{...Q}});if(t$(q))return q.then((W)=>{return{status:"valid",value:W.status==="valid"?W.value:this._def.catchValue({get error(){return new $$(Q.common.issues)},input:Q.data})}});else return{status:"valid",value:q.status==="valid"?q.value:this._def.catchValue({get error(){return new $$(Q.common.issues)},input:Q.data})}}removeCatch(){return this._def.innerType}}_0.create=($,J)=>{return new _0({innerType:$,typeName:f.ZodCatch,catchValue:typeof J.catch==="function"?J.catch:()=>J.catch,...V(J)})};class j0 extends D{_parse($){if(this._getType($)!==z.nan){let Q=this._getOrReturnCtx($);return N(Q,{code:M.invalid_type,expected:z.nan,received:Q.parsedType}),b}return{status:"valid",value:$.data}}}j0.create=($)=>{return new j0({typeName:f.ZodNaN,...V($)})};var v4=Symbol("zod_brand");class i0 extends D{_parse($){let{ctx:J}=this._processInputParams($),Q=J.data;return this._def.type._parse({data:Q,path:J.path,parent:J})}unwrap(){return this._def.type}}class V0 extends D{_parse($){let{status:J,ctx:Q}=this._processInputParams($);if(Q.common.async)return(async()=>{let W=await this._def.in._parseAsync({data:Q.data,path:Q.path,parent:Q});if(W.status==="aborted")return b;if(W.status==="dirty")return J.dirty(),l$(W.value);else return this._def.out._parseAsync({data:W.value,path:Q.path,parent:Q})})();else{let q=this._def.in._parseSync({data:Q.data,path:Q.path,parent:Q});if(q.status==="aborted")return b;if(q.status==="dirty")return J.dirty(),{status:"dirty",value:q.value};else return this._def.out._parseSync({data:q.value,path:Q.path,parent:Q})}}static create($,J){return new V0({in:$,out:J,typeName:f.ZodPipeline})}}class M0 extends D{_parse($){let J=this._def.innerType._parse($),Q=(q)=>{if(D$(q))q.value=Object.freeze(q.value);return q};return t$(J)?J.then((q)=>Q(q)):Q(J)}unwrap(){return this._def.innerType}}M0.create=($,J)=>{return new M0({innerType:$,typeName:f.ZodReadonly,...V(J)})};function X5($,J){let Q=typeof $==="function"?$(J):typeof $==="string"?{message:$}:$;return typeof Q==="string"?{message:Q}:Q}function M5($,J={},Q){if($)return p$.create().superRefine((q,W)=>{let Y=$(q);if(Y instanceof Promise)return Y.then((X)=>{if(!X){let G=X5(J,q),H=G.fatal??Q??!0;W.addIssue({code:"custom",...G,fatal:H})}});if(!Y){let X=X5(J,q),G=X.fatal??Q??!0;W.addIssue({code:"custom",...X,fatal:G})}return});return p$.create()}var R4={object:m.lazycreate},f;(function($){$.ZodString="ZodString",$.ZodNumber="ZodNumber",$.ZodNaN="ZodNaN",$.ZodBigInt="ZodBigInt",$.ZodBoolean="ZodBoolean",$.ZodDate="ZodDate",$.ZodSymbol="ZodSymbol",$.ZodUndefined="ZodUndefined",$.ZodNull="ZodNull",$.ZodAny="ZodAny",$.ZodUnknown="ZodUnknown",$.ZodNever="ZodNever",$.ZodVoid="ZodVoid",$.ZodArray="ZodArray",$.ZodObject="ZodObject",$.ZodUnion="ZodUnion",$.ZodDiscriminatedUnion="ZodDiscriminatedUnion",$.ZodIntersection="ZodIntersection",$.ZodTuple="ZodTuple",$.ZodRecord="ZodRecord",$.ZodMap="ZodMap",$.ZodSet="ZodSet",$.ZodFunction="ZodFunction",$.ZodLazy="ZodLazy",$.ZodLiteral="ZodLiteral",$.ZodEnum="ZodEnum",$.ZodEffects="ZodEffects",$.ZodNativeEnum="ZodNativeEnum",$.ZodOptional="ZodOptional",$.ZodNullable="ZodNullable",$.ZodDefault="ZodDefault",$.ZodCatch="ZodCatch",$.ZodPromise="ZodPromise",$.ZodBranded="ZodBranded",$.ZodPipeline="ZodPipeline",$.ZodReadonly="ZodReadonly"})(f||(f={}));var j4=($,J={message:`Input not instance of ${$.name}`})=>M5((Q)=>Q instanceof $,J),U5=H$.create,w5=k$.create,V4=j0.create,P4=E$.create,z5=J0.create,D4=c$.create,C4=b0.create,k4=Q0.create,E4=W0.create,T4=p$.create,I4=C$.create,y4=F$.create,g4=f0.create,h4=G$.create,m4=m.create,Z4=m.strictCreate,x4=q0.create,u4=r0.create,l4=Y0.create,c4=S$.create,p4=v0.create,d4=R0.create,r4=d$.create,i4=$0.create,o4=X0.create,n4=H0.create,a4=T$.create,s4=G0.create,t4=r$.create,e4=M$.create,$3=B$.create,J3=R$.create,Q3=M$.createWithPreprocess,W3=V0.create,q3=()=>U5().optional(),Y3=()=>w5().optional(),X3=()=>z5().optional(),H3={string:($)=>H$.create({...$,coerce:!0}),number:($)=>k$.create({...$,coerce:!0}),boolean:($)=>J0.create({...$,coerce:!0}),bigint:($)=>E$.create({...$,coerce:!0}),date:($)=>c$.create({...$,coerce:!0})};var G3=b;var B3=S.object({before:S.string(),after:S.string(),hierarchy:S.array(S.string()),lineStart:S.number().optional(),lineEnd:S.number().optional()}).passthrough(),_3=S.object({id:S.string(),name:S.string()}).passthrough(),M3=S.object({url:S.string(),mime:S.string().optional()}).passthrough(),U3=S.object({id:S.string(),snippet:S.string(),note:S.string(),createdAt:S.string(),filePath:S.string().optional(),canvasFile:S.string().optional(),context:B3.optional(),images:S.array(S.string()).optional(),attachments:S.array(M3).optional(),source:S.enum(["local","remote"]).optional(),author:_3.optional()}).passthrough(),w3=S.array(U3.optional().catch(void 0)).transform(($)=>$.filter((J)=>J!==void 0)).catch([]),k1=S.object({annotations:w3,generalNote:S.string().catch("")}).passthrough(),N5=S.object({path:S.string()}),K5=S.object({url:S.string()});import{useCallback as g8,useMemo as h8,useState as m8}from"react";function P0($){return $.uploadUrl!==null}function j$($,J){$.style.height="auto",$.style.height=(J?Math.max(J,$.scrollHeight):$.scrollHeight)+"px"}import{useAnnotations as o0}from"@fabrika/annotations/runtime";import{jsxDEV as $9}from"react/jsx-dev-runtime";import{jsxDEV as X9,Fragment as Y9}from"react/jsx-dev-runtime";import{useAnnotationHost as N3}from"@fabrika/annotations/runtime";import{useCallback as V$,useEffect as K3,useRef as T1,useState as I1}from"react";import{jsxDEV as s}from"react/jsx-dev-runtime";function O5($){if($.startsWith("/s/")||$.startsWith("http://")||$.startsWith("https://"))return $;return`/api/uploads/${$.split("/").pop()}`}async function O3($,J){let Q=$.uploadUrl;if(!Q)return null;let q=new FormData;q.append("image",J);try{let Y=await(await fetch(Q(),{method:"POST",body:q})).json();if($.isShared)return K5.parse(Y).url||null;return N5.parse(Y).path||null}catch{return null}}function n0({note:$,onNoteChange:J,images:Q,onAddImage:q,onRemoveImage:W,sessionId:Y,placeholder:X="Add your note...",autoFocus:G=!1,autoResize:H=!1,readOnly:B=!1,onKeyDown:_,onTextareaClick:w,textareaRef:L,textareaClassName:F,textareaStyle:U,minHeight:K,attachButton:O="always",openFilePickerRef:R}){let T=N3(),I=!B&&P0(T),[l,x]=I1(!1),[u,t]=I1(!1),[J$,U$]=I1(!1),h=T1(0),c=T1(null),e=T1(null),d=V$(()=>e.current?.click(),[]);if(R)R.current=d;let w$=V$((j)=>{if(c.current=j,L)L.current=j;if(j&&H)j$(j,K)},[L,H,K]);K3(()=>{if(G&&c.current){let j=c.current;if(j.focus(),j.value)j.setSelectionRange(j.value.length,j.value.length)}},[G]);let Q$=V$(async(j)=>{if(!j.type.startsWith("image/"))return;t(!0);try{let n=await O3(T,j);if(n)q(n)}finally{t(!1)}},[T,q]),g$=V$((j)=>{for(let n of j.clipboardData?.items??[])if(n.type.startsWith("image/")){j.preventDefault();let o$=n.getAsFile();if(o$)Q$(o$);return}},[Q$]),W$=V$((j)=>{if(j.preventDefault(),h.current++,h.current===1)x(!0)},[]),q$=V$((j)=>{j.preventDefault()},[]),z$=V$((j)=>{if(j.preventDefault(),h.current--,h.current===0)x(!1)},[]),N$=V$((j)=>{j.preventDefault(),h.current=0,x(!1);for(let n of j.dataTransfer?.files??[])if(n.type.startsWith("image/"))Q$(n)},[Q$]),h$=V$((j)=>{if(J(j.currentTarget.value),H)j.currentTarget.style.height="auto",j.currentTarget.style.height=(K?Math.max(K,j.currentTarget.scrollHeight):j.currentTarget.scrollHeight)+"px"},[J,H,K]),m$="w-full bg-transparent text-[13px] font-body text-text-primary resize-none focus:outline-none leading-relaxed p-0 border-none",q1={width:"100%",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",outline:"none",...H?{resize:"none",overflow:"hidden"}:{resize:"vertical"}},T0=I&&(O==="always"||O==="on-focus"&&J$);return s("div",{style:{position:"relative"},onDragEnter:I?W$:void 0,onDragOver:I?q$:void 0,onDragLeave:I?z$:void 0,onDrop:I?N$:void 0,children:[s("textarea",{ref:w$,value:$,onChange:B?void 0:h$,onPaste:I?g$:void 0,onKeyDown:_,onClick:w,onFocus:()=>U$(!0),onBlur:()=>{setTimeout(()=>U$(!1),150)},readOnly:B,placeholder:X,className:F??m$,style:U??q1,rows:H?1:void 0},void 0,!1,void 0,this),I&&s("input",{ref:e,type:"file",accept:"image/*",multiple:!0,style:{display:"none"},onChange:(j)=>{let n=j.currentTarget.files;if(n)for(let o$ of n)Q$(o$);j.currentTarget.value=""}},void 0,!1,void 0,this),(Q.length>0||T0)&&s("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px",alignItems:"center"},children:[Q.map((j)=>s("div",{style:{position:"relative",width:"56px",height:"56px",borderRadius:"6px",overflow:"hidden",border:"1px solid var(--color-border-subtle)",flexShrink:0},children:[s("img",{src:O5(j),alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}},void 0,!1,void 0,this),!B&&s("button",{onClick:(n)=>{n.stopPropagation(),W(j)},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)]},j,!0,void 0,this)),T0&&s(a0,{onClick:d},void 0,!1,void 0,this)]},void 0,!0,void 0,this),u&&s("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:"Uploading..."},void 0,!1,void 0,this),l&&s("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 a0({onClick:$,size:J=16}){return s("button",{onClick:(Q)=>{Q.stopPropagation(),$()},style:{width:`${J*2}px`,height:`${J*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:(Q)=>{Q.currentTarget.style.color="var(--color-text-secondary)"},onMouseLeave:(Q)=>{Q.currentTarget.style.color="var(--color-text-tertiary)"},children:s("svg",{width:J,height:J,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},void 0,!1,void 0,this),s("circle",{cx:"8.5",cy:"8.5",r:"1.5"},void 0,!1,void 0,this),s("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 K9}from"@fabrika/annotations/runtime";import{useContext as L9,useEffect as F9,useRef as S9}from"react";import{jsxDEV as j9,Fragment as V9}from"react/jsx-dev-runtime";import{SessionContext as A3,useAnnotationHost as b3}from"@fabrika/annotations/runtime";import{useCallback as s0,useContext as f3,useEffect as v3,useMemo as A5,useRef as t0,useState as U0}from"react";import{createPortal as R3}from"react-dom";function F5($){let J=/^(\d+(?:\.\d+)?)px$/.exec($.trim());return J?Number(J[1]):void 0}function S5($,J,Q=280){let W=J||document.body,Y=$.getBoundingClientRect(),X=W.getBoundingClientRect(),G=W===document.body?0:W.scrollTop,H=Y.bottom-X.top+G+8,B=Math.max(0,Math.min(Y.left-X.left,X.width-Q-12));return W.style.position="relative",{style:{position:"absolute",top:`${H}px`,left:`${B}px`},parent:W}}import{jsxDEV as i,Fragment as j3}from"react/jsx-dev-runtime";function f5({anchorEl:$,scrollContainer:J,onClose:Q,ignoreSelector:q,zIndex:W="50",padding:Y="12px",width:X="280px",children:G}){let H=t0(null),B=t0(Q);B.current=Q;let{style:_,parent:w}=S5($,J,F5(X));return v3(()=>{let L=setTimeout(()=>{let F=(U)=>{if(H.current&&!H.current.contains(U.target)){if(q&&U.target.closest?.(q))return;B.current(),document.removeEventListener("mousedown",F)}};return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},0);return()=>clearTimeout(L)},[q]),R3(i("div",{ref:H,style:{..._,zIndex:W,width:X,background:"var(--color-bg-elevated)",border:"1px solid var(--color-border-hover)",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",padding:Y,fontFamily:"'Inter', sans-serif"},children:G},void 0,!1,void 0,this),w)}var v5=[{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"]}],b5=v5.flatMap(($)=>$.items);function R5({anchorEl:$,scrollContainer:J,snippet:Q,truncateAt:q=100,header:W,initialNote:Y="",initialImages:X,onConfirm:G,onCancel:H,onDelete:B}){let _=f3(A3),w=b3(),L=P0(w),F=Y!==""||!!B,[U,K]=U0(Y),[O,R]=U0(X||[]),[T,I]=U0(null),[l,x]=U0(F),[u,t]=U0(!1),J$=t0(null),U$=t0(null),h=s0(()=>{if(U.trim()||O.length>0)G(U.trim(),O);else if(F&&B)B();else H()},[U,O,G,H,F,B]),c=s0(()=>{if(F){if(!U.trim()&&O.length===0&&B){B(),H();return}G(U,O);return}H()},[U,O,F,G,H,B]),e=!F,d=U.trim().length>0?b5.filter((v)=>v.toLowerCase().startsWith(U.trim().toLowerCase())):b5,w$=!e||l?[]:d.length===1&&d[0]?.toLowerCase()===U.trim().toLowerCase()?[]:d,Q$=new Set(w$),g$=v5.map((v)=>({label:v.label,items:v.items.filter((g)=>Q$.has(g))})).filter((v)=>v.items.length>0),W$=g$.map((v)=>v.items),q$=(v)=>W$[v]?.length??0,z$=W$.flat(),N$=A5(()=>{if(T===null)return 0;let v=0;for(let g=0;g<W$.length;g++){if(T<v+q$(g))return g;v+=q$(g)}return 0},[T,W$]),h$=A5(()=>{if(T===null)return 0;let v=0;for(let g=0;g<N$;g++)v+=q$(g);return T-v},[T,N$,W$]),m$=(v,g)=>{let p=0;for(let K$=0;K$<v;K$++)p+=q$(K$);return p+g},[q1,T0]=U0(U);if(U!==q1)T0(U),I(null),x(F);let j=s0((v)=>{K(v)},[]),n=Q.length>q?Q.slice(0,q)+"...":Q,o$=s0((v)=>{if(z$.length>0&&(v.key==="ArrowDown"||v.key==="ArrowUp"||v.key==="ArrowLeft"||v.key==="ArrowRight")){if(v.preventDefault(),T===null){I(0);return}if(v.key==="ArrowDown"){let p=Math.min(h$+1,q$(N$)-1);I(m$(N$,p))}else if(v.key==="ArrowUp"){let p=Math.max(h$-1,0);I(m$(N$,p))}else if(v.key==="ArrowRight"){let p=Math.min(N$+1,W$.length-1),K$=Math.min(h$,q$(p)-1);I(m$(p,K$))}else if(v.key==="ArrowLeft"){let p=Math.max(N$-1,0),K$=Math.min(h$,q$(p)-1);I(m$(p,K$))}return}let g=T===null?void 0:z$[T];if(g!==void 0){if(v.key==="Tab"){v.preventDefault(),j(g);return}if(v.key==="Enter"&&!v.shiftKey){v.preventDefault(),G(g,O);return}}if(v.key==="Enter"&&!v.shiftKey){v.preventDefault(),h();return}if(v.key==="Escape")if(z$.length>0&&!l)x(!0);else if(F)c();else H()},[z$,T,h$,N$,W$,m$,j,G,O,h,l,F,c,H]);return i(f5,{anchorEl:$,scrollContainer:J,onClose:F?c:H,ignoreSelector:F?"[data-annotation-id]":void 0,zIndex:F?"60":"50",padding:F?"10px 12px":"12px",width:"420px",children:[!F&&(W??i("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:["“",n,"”"]},void 0,!0,void 0,this)),i(n0,{note:U,onNoteChange:K,images:O,onAddImage:(v)=>R((g)=>[...g,v]),onRemoveImage:(v)=>R((g)=>g.filter((p)=>p!==v)),sessionId:_,autoFocus:!0,autoResize:F,textareaRef:J$,onKeyDown:o$,attachButton:"none",openFilePickerRef:U$,textareaStyle:F?{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),i("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:F?"6px":"8px"},children:[L&&i(a0,{onClick:()=>U$.current?.(),size:14},void 0,!1,void 0,this),i("div",{style:{flex:1}},void 0,!1,void 0,this),F?i("button",{onClick:()=>{if(B)B();H()},onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),style:{fontSize:"11px",color:u?"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):i(j3,{children:[i("button",{onClick:H,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),i("button",{onClick:h,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),z$.length>0&&i("div",{style:{marginTop:"6px",borderTop:"1px solid var(--color-border-subtle)",paddingTop:"8px",display:"flex",gap:"4px"},children:g$.map((v)=>i("div",{style:{flex:1},children:[i("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:v.label},void 0,!1,void 0,this),v.items.map((g)=>{let p=z$.indexOf(g);return i("div",{onMouseDown:(K$)=>{K$.preventDefault(),K$.stopPropagation(),j(g)},onMouseEnter:()=>I(p),style:{padding:"3px 6px",fontSize:"12px",borderRadius:"4px",fontFamily:"'Inter', sans-serif",color:p===T?"var(--color-text-primary)":"var(--color-text-secondary)",background:p===T?"var(--color-highlight-selected)":"transparent",cursor:"pointer"},children:[i("span",{style:{fontWeight:500},children:g.slice(0,U.trim().length)},void 0,!1,void 0,this),g.slice(U.trim().length)]},g,!0,void 0,this)})]},v.label,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function D0({anchorEl:$,scrollContainer:J,snippet:Q,truncateAt:q,header:W,onAdd:Y,onCancel:X}){return i(R5,{anchorEl:$,scrollContainer:J,snippet:Q,truncateAt:q,header:W,onConfirm:(G,H)=>Y(G,H),onCancel:X},void 0,!1,void 0,this)}import{useEffect as p9,useRef as d9,useState as r9}from"react";import{jsxDEV as t9}from"react/jsx-dev-runtime";import{useCallback as W7,useEffect as q7,useRef as Y7,useState as X7}from"react";import{jsxDEV as z7,Fragment as w7}from"react/jsx-dev-runtime";import{jsxDEV as j5}from"react/jsx-dev-runtime";function w0({note:$,onChange:J}){return j5("div",{className:"mt-1.5",children:j5("textarea",{value:$,onChange:(Q)=>J(Q.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:(Q)=>j$(Q.currentTarget),ref:(Q)=>{if(Q)j$(Q)}},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as Z}from"react/jsx-dev-runtime";function T5($){return $.map((J)=>typeof J==="string"?{value:J,label:J}:{value:J.value,label:J.label??J.value})}function g3({id:$,label:J,options:Q,required:q}){let{responses:W,setResponse:Y}=V5();P5($);let X=C5(()=>T5(Q),[Q]),G=W.get($),H=G?.value,B=G?.note||"",[_,w]=E5(!1),L=k5(null);if(!W.has($))Y($,{id:$,type:"radio",label:J,value:null,options:X.map((K)=>K.value),required:q});let F=(K)=>{Y($,{...G,value:K})};D5(()=>{let K=L.current;if(!K)return;let O=(R)=>{let I=R.target.closest("[data-md-label]")?.getAttribute("data-md-label"),l=X.find((x)=>x.label===I);if(l)F(l.value)};return K.addEventListener("kb-select",O),()=>K.removeEventListener("kb-select",O)},[X,F]);let U=G?.required&&!H;return Z("div",{ref:L,"data-md":"choice","data-md-label":J,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[Z("div",{className:"flex items-baseline gap-2 mb-2",children:[Z("span",{className:"text-[13px] font-body font-medium text-text-primary",children:J},void 0,!1,void 0,this),q&&Z("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z("div",{className:"space-y-1",children:X.map(({value:K,label:O})=>Z("label",{"data-md":"choice-option","data-md-label":O,onClick:()=>F(K),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${H===K?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[Z("span",{className:`w-4 h-4 rounded-full border-[1.5px] flex items-center justify-center flex-shrink-0 transition-all ${H===K?"border-accent-amber bg-accent-amber":"border-border-strong"}`,children:H===K&&Z("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),Z("span",{className:"text-[13px] font-body text-text-secondary",children:O},void 0,!1,void 0,this)]},K,!0,void 0,this))},void 0,!1,void 0,this),Z(w0,{show:_,note:B,onToggle:()=>w(!_),onChange:(K)=>Y($,{...G,note:K})},void 0,!1,void 0,this),U&&Z("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 h3({id:$,label:J,options:Q,required:q}){let{responses:W,setResponse:Y}=V5();P5($);let X=C5(()=>T5(Q),[Q]),G=W.get($),H=G?.value||[],B=G?.note||"",[_,w]=E5(!1),L=k5(null);if(!W.has($))Y($,{id:$,type:"checkbox",label:J,value:[],options:X.map((K)=>K.value),required:q});let F=(K)=>{let O=H.includes(K)?H.filter((R)=>R!==K):[...H,K];Y($,{...G,value:O})};D5(()=>{let K=L.current;if(!K)return;let O=(R)=>{let I=R.target.closest("[data-md-label]")?.getAttribute("data-md-label"),l=X.find((x)=>x.label===I);if(l)F(l.value)};return K.addEventListener("kb-select",O),()=>K.removeEventListener("kb-select",O)},[X,F]);let U=G?.required&&H.length===0;return Z("div",{ref:L,"data-md":"multichoice","data-md-label":J,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[Z("div",{className:"flex items-baseline gap-2 mb-2",children:[Z("span",{className:"text-[13px] font-body font-medium text-text-primary",children:J},void 0,!1,void 0,this),q&&Z("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z("div",{className:"space-y-1",children:X.map(({value:K,label:O})=>{let R=H.includes(K);return Z("label",{"data-md":"multichoice-option","data-md-label":O,onClick:()=>F(K),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${R?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[Z("span",{className:`w-4 h-4 rounded flex items-center justify-center flex-shrink-0 transition-all ${R?"bg-accent-amber":"border-[1.5px] border-border-strong"}`,children:R&&Z("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:Z("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),Z("span",{className:"text-[13px] font-body text-text-secondary",children:O},void 0,!1,void 0,this)]},K,!0,void 0,this)})},void 0,!1,void 0,this),Z(w0,{show:_,note:B,onToggle:()=>w(!_),onChange:(K)=>Y($,{...G,note:K})},void 0,!1,void 0,this),U&&Z("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 m3,useRef as Z3}from"react";function e0(){return window.hljs}function I5(){return window.mermaid}import{jsxDEV as $1}from"react/jsx-dev-runtime";function x3({language:$,children:J}){let Q=typeof J==="string"?J:String(J??""),q=Z3(null);return m3(()=>{let W=q.current,Y=e0();if(!W||!Y)return;W.removeAttribute("data-highlighted"),W.className=$?`language-${$}`:"",W.textContent=Q,Y.highlightElement(W)},[Q,$]),$1("div",{className:"relative mt-3 group/code","data-md":"codeblock","data-md-language":$||"",children:[$&&$1("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:$},void 0,!1,void 0,this),$1("pre",{className:"bg-bg-code rounded-md p-4 overflow-x-auto text-code font-mono leading-relaxed",children:$1("code",{ref:q,className:$?`language-${$}`:"",children:Q},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function y5($,J){let Q=$.split(`
60
+ `),q=J.split(`
61
+ `),W=u3(Q,q),Y=[],X=0,G=0,H=0;while(X<Q.length||G<q.length){let B=Q[X],_=q[G];if(H<W.length&&B!==void 0&&_!==void 0&&B===W[H]&&_===W[H])Y.push({type:"same",line:B}),X++,G++,H++;else if(B!==void 0&&(H>=W.length||B!==W[H]))Y.push({type:"removed",line:B}),X++;else if(_!==void 0)Y.push({type:"added",line:_}),G++}return Y}function u3($,J){let Q=$.length,q=J.length,W=Array.from({length:Q+1},()=>Array(q+1).fill(0));for(let H=1;H<=Q;H++){let B=W[H]??[],_=W[H-1]??[];for(let w=1;w<=q;w++)B[w]=$[H-1]===J[w-1]?(_[w-1]??0)+1:Math.max(_[w]??0,B[w-1]??0)}let Y=[],X=Q,G=q;while(X>0&&G>0){let H=$[X-1];if(H!==void 0&&H===J[G-1])Y.unshift(H),X--,G--;else if((W[X-1]?.[G]??0)>(W[X]?.[G-1]??0))X--;else G--}return Y}import{jsxDEV as C0}from"react/jsx-dev-runtime";function l3({before:$,after:J,language:Q}){let q=y5($,J);return C0("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden group/diff","data-md":"diff","data-md-language":Q||"",children:[Q&&C0("div",{className:"px-4 py-2 text-meta font-mono text-text-tertiary opacity-0 group-hover/diff:opacity-60 transition-opacity",children:["diff (",Q,")"]},void 0,!0,void 0,this),C0("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono",children:q.map((W,Y)=>C0("div",{className:W.type==="removed"?"bg-accent-red-muted text-accent-red":W.type==="added"?"bg-accent-green-muted text-accent-green":"text-text-tertiary",children:[C0("span",{className:"select-none w-6 inline-block text-center opacity-60",children:W.type==="removed"?"-":W.type==="added"?"+":" "},void 0,!1,void 0,this),W.line]},Y,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{ActiveViewCtx as d3,SessionContext as r3}from"#canvas/runtime";import{useContext as h5,useEffect as m5,useRef as i3,useState as J1}from"react";var c3=S.object({id:S.string(),type:S.enum(["select","radio","checkbox","text","range"]),label:S.string(),value:S.unknown(),options:S.array(S.string()).optional(),required:S.boolean().optional(),note:S.string().optional()}).passthrough().transform(($)=>({...$,value:$.value})),p3=S.object({id:S.string(),markdown:S.string(),label:S.string().optional(),required:S.boolean().optional()}).passthrough(),LJ=k1.extend({responses:S.array(S.tuple([S.string(),c3]).optional().catch(void 0)).transform(($)=>$.filter((J)=>J!==void 0)).catch([]),feedbackEntries:S.array(S.tuple([S.string(),p3]).optional().catch(void 0)).transform(($)=>$.filter((J)=>J!==void 0)).optional().catch([])});var FJ=S.object({feedback:S.string().nullish()}),g5=S.union([S.object({error:S.string().min(1)}),S.object({content:S.string(),language:S.string().nullish()})]);import{jsxDEV as I$}from"react/jsx-dev-runtime";var o3={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 n3({path:$,lines:J,__content:Q}){let q=h5(r3),{setActiveView:W}=h5(d3),[Y,X]=J1(Q??null),[G,H]=J1(()=>{let U=$.split(".").pop()||"";return o3[U]||"text"}),[B,_]=J1(null),[w,L]=J1(!Q),F=i3(null);if(m5(()=>{if(Q!==void 0)return;L(!0),_(null),fetch(`/api/file?session=${q}&path=${encodeURIComponent($)}`).then((U)=>U.json()).then((U)=>{let K=g5.parse(U);if("error"in K)_(K.error);else{let O=K.content;if(J)O=O.split(`
62
+ `).slice(J[0]-1,J[1]).join(`
63
+ `);X(O),H(K.language||"text")}}).catch(()=>_("Failed to fetch file")).finally(()=>L(!1))},[q,$,J?.[0],J?.[1],Q]),m5(()=>{let U=F.current,K=e0();if(!U||!K||!Y)return;U.removeAttribute("data-highlighted"),U.className=G?`language-${G}`:"",U.textContent=Y,K.highlightElement(U)},[Y,G]),w)return I$("div",{className:"text-text-tertiary text-body mt-3 bg-bg-code rounded-md p-4",children:["Loading ",$,"..."]},void 0,!0,void 0,this);if(B)return I$("div",{className:"text-accent-red text-body mt-3 bg-accent-red-muted rounded-md p-4",children:[$,": ",B]},void 0,!0,void 0,this);return I$("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden","data-md":"filepreview","data-md-path":$,...J?{"data-md-lines":`${J[0]}-${J[1]}`}:{},children:[I$("div",{className:"px-4 py-2 flex items-center justify-between",children:[I$("button",{className:"font-mono text-meta text-text-tertiary hover:text-text-secondary hover:underline cursor-pointer text-left",onClick:()=>W({type:"file",path:$}),title:`Open ${$}`,children:$},void 0,!1,void 0,this),J&&I$("span",{className:"font-mono text-meta text-text-tertiary opacity-60",children:["L",J[0],"–",J[1]]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),I$("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono !bg-transparent",style:{background:"transparent"},children:I$("code",{ref:F,className:G?`language-${G}`:"",children:Y},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{SessionContext as a3}from"#canvas/runtime";import{useContext as s3,useState as t3}from"react";import{jsxDEV as k0}from"react/jsx-dev-runtime";function e3({src:$,alt:J,caption:Q,width:q,height:W}){let Y=s3(a3),[X,G]=t3(!1),H=`/api/image?session=${encodeURIComponent(Y)}&path=${encodeURIComponent($)}`;if(X)return k0("div",{className:"mt-3 text-accent-red text-body bg-accent-red-muted rounded-md p-4",children:[$,": Failed to load image"]},void 0,!0,void 0,this);return k0("figure",{className:"mt-3 relative","data-md":"image","data-md-src":$,children:[k0("div",{"data-annotation-image":!0,className:"rounded-md overflow-hidden border border-border-subtle bg-bg-code inline-block",children:k0("img",{src:H,alt:J||$,onError:()=>G(!0),draggable:!1,className:"block max-w-full h-auto",...q?{width:q}:{},...W?{height:W}:{}},void 0,!1,void 0,this)},void 0,!1,void 0,this),Q&&k0("figcaption",{className:"mt-1.5 text-meta text-text-tertiary font-body",children:Q},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useMemo as $6}from"react";import{jsxDEV as Z5}from"react/jsx-dev-runtime";k.setOptions({gfm:!0,breaks:!1});function J6({children:$,file:J,__content:Q}){let q=Q??(typeof $==="string"?$:String($??"")),W=$6(()=>{if(!q)return"";return k.parse(q,{async:!1})},[q]);if(!q)return Z5("div",{className:"text-text-tertiary text-tiny mt-3",children:J?`Could not load: ${J}`:"No markdown content"},void 0,!1,void 0,this);return Z5("div",{className:"mt-3 prose-canvas","data-md":"markdown",...J?{"data-md-file":J}:{},"data-md-source":q,dangerouslySetInnerHTML:{__html:W}},void 0,!1,void 0,this)}import{useAnnotations as Q6,useCanvasFile as W6}from"#canvas/runtime";import{useCallback as A$,useEffect as y1,useRef as E0,useState as z0}from"react";import q6 from"react-dom";import{jsxDEV as P,Fragment as c5}from"react/jsx-dev-runtime";var N0=0.2,Q1=0.25,W1=4;function u5({zoom:$,onZoomIn:J,onZoomOut:Q,onZoomReset:q,onFullscreen:W}){return P("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:[P("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:Q,title:"Zoom out",disabled:$<=Q1,children:P("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:P("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),P("button",{className:"px-1.5 h-7 rounded hover:bg-bg-elevated text-text-tertiary hover:text-text-primary transition-colors tabular-nums",onClick:q,title:"Reset zoom",children:[Math.round($*100),"%"]},void 0,!0,void 0,this),P("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:"Zoom in",disabled:$>=W1,children:P("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[P("line",{x1:"12",y1:"5",x2:"12",y2:"19"},void 0,!1,void 0,this),P("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),W&&P(c5,{children:[P("div",{className:"w-px h-4 bg-border-subtle mx-0.5"},void 0,!1,void 0,this),P("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:W,title:"Fullscreen",children:P("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[P("polyline",{points:"15 3 21 3 21 9"},void 0,!1,void 0,this),P("polyline",{points:"9 21 3 21 3 15"},void 0,!1,void 0,this),P("line",{x1:"21",y1:"3",x2:"14",y2:"10"},void 0,!1,void 0,this),P("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 l5($=1){let[J,Q]=z0($),q=A$(()=>Q((X)=>Math.min(W1,+(X+N0).toFixed(2))),[]),W=A$(()=>Q((X)=>Math.max(Q1,+(X-N0).toFixed(2))),[]),Y=A$(()=>Q(1),[]);return{zoom:J,zoomIn:q,zoomOut:W,zoomReset:Y,setZoom:Q}}function Y6({svgHtml:$,source:J,onClose:Q}){let q=E0(null),{zoom:W,zoomIn:Y,zoomOut:X,zoomReset:G,setZoom:H}=l5(1),[B,_]=z0({x:0,y:0}),w=E0(null);y1(()=>{let R=(T)=>{if(T.key==="Escape")Q()};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[Q]);let L=A$((R)=>{R.preventDefault();let T=R.deltaY>0?-N0:N0;H((I)=>Math.max(Q1,Math.min(W1,+(I+T).toFixed(2))))},[H]),F=A$((R)=>{if(R.button!==0)return;w.current={startX:R.clientX,startY:R.clientY,panX:B.x,panY:B.y},R.preventDefault()},[B]),U=A$((R)=>{if(!w.current)return;_({x:w.current.panX+(R.clientX-w.current.startX),y:w.current.panY+(R.clientY-w.current.startY)})},[]),K=A$(()=>{w.current=null},[]),O=A$(()=>{G(),_({x:0,y:0})},[G]);return q6.createPortal(P("div",{style:{position:"fixed",inset:0,zIndex:9999,background:"var(--color-bg-base)",display:"flex",flexDirection:"column"},onMouseMove:U,onMouseUp:K,onMouseLeave:K,children:[P("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:[P("span",{className:"text-body text-text-secondary",style:{fontSize:"13px"},children:"Mermaid Diagram"},void 0,!1,void 0,this),P("div",{className:"flex items-center gap-2",children:[P(u5,{zoom:W,onZoomIn:Y,onZoomOut:X,onZoomReset:O},void 0,!1,void 0,this),P("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:Q,title:"Close (Esc)",children:P("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[P("line",{x1:"18",y1:"6",x2:"6",y2:"18"},void 0,!1,void 0,this),P("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),P("div",{style:{flex:1,overflow:"hidden",cursor:w.current?"grabbing":"grab"},onWheel:L,onMouseDown:F,children:P("div",{ref:q,style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",transform:`translate(${B.x}px, ${B.y}px) scale(${W})`,transformOrigin:"center center",transition:w.current?"none":"transform 0.1s ease-out"},dangerouslySetInnerHTML:{__html:$}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),document.body)}function X6({children:$}){let J=E0(null),[Q,q]=z0(null),[W,Y]=z0(!1),[X,G]=z0(""),H=typeof $==="string"?$:String($??""),{annotations:B,addAnnotationWithId:_,activeAnnotationId:w,setActiveAnnotationId:L}=Q6(),F=W6(),[U,K]=z0(null),{zoom:O,zoomIn:R,zoomOut:T,zoomReset:I,setZoom:l}=l5(1),x=E0(B);x.current=B;let u=A$((h,c,e)=>{let d=`[Diagram ${e.toLowerCase()}] ${c}`,w$=x.current.find((Q$)=>Q$.snippet===d);if(w$)L(w$.id);else K({anchorEl:h,snippet:c,prefix:e})},[L]),t=E0(u);t.current=u,y1(()=>{let h=!1,c=async()=>{try{let d=I5();if(!d){q("Mermaid library not loaded");return}let w$=document.documentElement.dataset.theme==="light"?"default":"dark";d.initialize({startOnLoad:!1,theme:w$});let Q$=`mermaid-${Math.random().toString(36).slice(2)}`,{svg:g$}=await d.render(Q$,H.trim());if(!h&&J.current)J.current.innerHTML=g$,G(g$),H6(J.current,(W$,q$,z$)=>t.current(W$,q$,z$)),x5(J.current,x.current);q(null)}catch(d){if(!h)q(d instanceof Error&&d.message||"Invalid diagram")}};c();let e=new MutationObserver((d)=>{for(let w$ of d)if(w$.attributeName==="data-theme")c()});return e.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{h=!0,e.disconnect()}},[H]),y1(()=>{if(J.current)x5(J.current,B,w)},[B,w]);let J$=A$((h)=>{if(!h.ctrlKey&&!h.metaKey)return;h.preventDefault();let c=h.deltaY>0?-N0:N0;l((e)=>Math.max(Q1,Math.min(W1,+(e+c).toFixed(2))))},[l]);if(Q)return P("div",{className:"bg-accent-red-muted rounded-md p-4 mt-3 text-body text-accent-red",children:["Mermaid error: ",Q,P("pre",{className:"mt-2 text-tiny text-text-tertiary whitespace-pre-wrap",children:H},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let U$=J.current?.closest("#plan-scroll-container");return P(c5,{children:[P("div",{className:"mt-3 mermaid-container","data-md":"mermaid","data-md-source":H.trim(),children:[P("div",{className:"flex justify-end mb-1",children:P(u5,{zoom:O,onZoomIn:R,onZoomOut:T,onZoomReset:I,onFullscreen:()=>Y(!0)},void 0,!1,void 0,this)},void 0,!1,void 0,this),P("div",{style:{overflow:"auto",maxHeight:"70vh"},onWheel:J$,children:P("div",{ref:J,className:"flex justify-center",style:{transform:`scale(${O})`,transformOrigin:"top center",transition:"transform 0.1s ease-out",minHeight:O<1?void 0:void 0}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U&&P(D0,{anchorEl:U.anchorEl,scrollContainer:U$,snippet:U.snippet,header:P("div",{style:{fontSize:"12px",color:"var(--color-text-tertiary)",marginBottom:"8px",lineHeight:"1.4",display:"flex",alignItems:"center",gap:"6px"},children:[P("span",{style:{width:"8px",height:"8px",borderRadius:"50%",background:"var(--color-accent-amber)",flexShrink:0}},void 0,!1,void 0,this),U.snippet]},void 0,!0,void 0,this),onAdd:(h,c)=>{let e=`ann-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;_(e,`[Diagram ${U.prefix.toLowerCase()}] ${U.snippet}`,h,void 0,void 0,c,F||void 0),K(null)},onCancel:()=>K(null)},void 0,!1,void 0,this),W&&X&&P(Y6,{svgHtml:X,source:H,onClose:()=>Y(!1)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function H6($,J){let Q=(q,W,Y)=>{q.style.cursor="pointer",q.addEventListener("mouseenter",()=>{q.style.filter="brightness(1.2)"}),q.addEventListener("mouseleave",()=>{q.style.filter=""}),q.addEventListener("click",(X)=>{X.stopPropagation(),X.preventDefault(),J(q,W(),Y)})};for(let q of $.querySelectorAll(".node"))Q(q,()=>{return(q.querySelector(".nodeLabel")||q.querySelector("foreignObject span")||q.querySelector("text"))?.textContent?.trim()||"Node"},"Node");for(let q of $.querySelectorAll(".edgePath")){let W=q,Y=W.querySelector("path");if(Y){Y.style.strokeWidth=Math.max(parseFloat(Y.style.strokeWidth||"1"),8)+"px",Y.style.strokeOpacity="0";let G=Y.cloneNode(!0);G.style.strokeWidth="",G.style.strokeOpacity="",W.insertBefore(G,Y)}let X=W.id||"";Q(W,()=>{let G=$.querySelectorAll(".edgeLabel");for(let H of G)if(H.id&&X&&H.id.replace("label","").includes(X.replace("L-","").replace("edge",""))){let B=H.textContent?.trim();if(B)return B}return"Connection"},"Edge")}for(let q of $.querySelectorAll(".edgeLabel")){let W=q.textContent?.trim();if(!W)continue;Q(q,()=>W,"Edge")}for(let q of $.querySelectorAll(".actor")){let W=q.closest("g")?.querySelector("text")||q.parentElement?.querySelector("text");if(!W)continue;let Y=q.closest("g");if(!Y||Y.hasAttribute("data-clickable"))continue;Y.setAttribute("data-clickable","true"),Q(Y,()=>W.textContent?.trim()||"Participant","Node")}for(let q of $.querySelectorAll(".messageText")){let W=q.textContent?.trim();if(!W)continue;Q(q,()=>W,"Edge")}for(let q of $.querySelectorAll(".entityBox")){let W=q.closest("g");if(!W||W.hasAttribute("data-clickable"))continue;let Y=W.querySelector(".entityLabel");if(!Y)continue;W.setAttribute("data-clickable","true"),Q(W,()=>Y.textContent?.trim()||"Entity","Node")}for(let q of $.querySelectorAll(".relationshipLabel")){let W=q.textContent?.trim();if(!W)continue;let X=q.closest("g")||q;if(X.hasAttribute("data-clickable"))continue;X.setAttribute("data-clickable","true"),Q(X,()=>W,"Edge")}for(let q of $.querySelectorAll(".classGroup")){let W=q;if(W.hasAttribute("data-clickable"))continue;let Y=W.querySelector(".classTitle, .classTitleText, text");if(!Y)continue;W.setAttribute("data-clickable","true"),Q(W,()=>Y.textContent?.trim()||"Class","Node")}for(let q of $.querySelectorAll(".statediagram-state")){let W=q;if(W.hasAttribute("data-clickable"))continue;let Y=W.querySelector(".state-title, text");if(!Y)continue;W.setAttribute("data-clickable","true"),Q(W,()=>Y.textContent?.trim()||"State","Node")}for(let q of $.querySelectorAll(".mindmap-node")){let W=q;if(W.hasAttribute("data-clickable"))continue;let Y=W.querySelector(".mindmap-node-label, text");if(!Y)continue;W.setAttribute("data-clickable","true"),Q(W,()=>Y.textContent?.trim()||"Node","Node")}}function x5($,J,Q){let q=new Map;for(let Y of J){let X=Y.snippet.match(/^\[Diagram (?:node|edge)\] (.+)$/)?.[1];if(X)q.set(X,Y.id)}for(let Y of $.querySelectorAll("[data-annotated]"))Y.style.outline="",Y.style.outlineOffset="",Y.style.borderRadius="",Y.removeAttribute("data-annotated");if(q.size===0)return;for(let Y of $.querySelectorAll(".node")){let G=(Y.querySelector(".nodeLabel")||Y.querySelector("foreignObject span")||Y.querySelector("text"))?.textContent?.trim();if(!G||!q.has(G))continue;let H=q.get(G),B=Y;B.setAttribute("data-annotated",H);let _=H===Q;B.style.outline=_?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",B.style.outlineOffset="2px",B.style.borderRadius="4px"}for(let Y of $.querySelectorAll(".edgeLabel")){let X=Y.textContent?.trim();if(!X||!q.has(X))continue;let G=q.get(X),H=Y;H.setAttribute("data-annotated",G);let B=G===Q;H.style.outline=B?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",H.style.outlineOffset="2px",H.style.borderRadius="4px"}for(let Y of $.querySelectorAll(".actor")){let X=Y.closest("g");if(!X)continue;let H=X.querySelector("text")?.textContent?.trim();if(!H||!q.has(H))continue;if(X.hasAttribute("data-annotated"))continue;let B=q.get(H);X.setAttribute("data-annotated",B);let _=B===Q,w=X.querySelector("rect");if(w)w.style.outline=_?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",w.style.outlineOffset="2px",w.style.borderRadius="4px"}for(let Y of $.querySelectorAll(".messageText")){let X=Y.textContent?.trim();if(!X||!q.has(X))continue;let G=q.get(X),H=Y;H.setAttribute("data-annotated",G);let B=G===Q;H.style.outline=B?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",H.style.outlineOffset="2px",H.style.borderRadius="4px"}let W=(Y,X,G)=>{for(let H of $.querySelectorAll(Y)){let B=G(H);if(!B||B.hasAttribute("data-annotated"))continue;let w=B.querySelector(X)?.textContent?.trim();if(!w||!q.has(w))continue;let L=q.get(w);B.setAttribute("data-annotated",L);let F=L===Q,U=B.querySelector("rect, circle, ellipse, polygon")||B;U.style.outline=F?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",U.style.outlineOffset="2px",U.style.borderRadius="4px"}};W(".entityBox",".entityLabel",(Y)=>Y.closest("g"));for(let Y of $.querySelectorAll(".relationshipLabel")){let G=Y.closest("g")||Y;if(G.hasAttribute("data-annotated"))continue;let H=Y.textContent?.trim();if(!H||!q.has(H))continue;let B=q.get(H);G.setAttribute("data-annotated",B);let _=B===Q;G.style.outline=_?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",G.style.outlineOffset="2px",G.style.borderRadius="4px"}W(".classGroup",".classTitle, .classTitleText, text",(Y)=>Y),W(".statediagram-state",".state-title, text",(Y)=>Y),W(".mindmap-node",".mindmap-node-label, text",(Y)=>Y)}import{jsxDEV as B6}from"react/jsx-dev-runtime";function G6({children:$}){return B6("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:P$($)},void 0,!1,void 0,this)}import{jsxDEV as U6}from"react/jsx-dev-runtime";var _6={high:"text-accent-red bg-accent-red-muted",medium:"text-accent-amber bg-accent-amber-muted",low:"text-text-tertiary bg-border-subtle"};function M6({level:$}){return U6("span",{className:`inline text-tiny font-medium font-body ml-2 px-1.5 py-0.5 rounded ${_6[$]}`,"data-md":"priority","data-md-level":$,children:$},void 0,!1,void 0,this)}import{useState as w6}from"react";import{jsxDEV as i$}from"react/jsx-dev-runtime";function z6({title:$,children:J}){let[Q,q]=w6(!1);return i$("div",{className:"relative mb-8 p-4 group/section","data-md":"section","data-md-title":$,children:[i$("div",{className:"relative mb-2",children:[i$("button",{onClick:()=>q(!Q),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 ${Q?"-rotate-90":""}`,children:i$("svg",{width:"14",height:"14",viewBox:"0 0 12 12",fill:"none",children:i$("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),i$("h2",{className:"font-heading text-section text-text-primary",style:{fontWeight:400},children:$},void 0,!1,void 0,this)]},void 0,!0,void 0,this),i$("div",{className:Q?"mt-6 hidden":"mt-6",children:P$(J)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as y$}from"react/jsx-dev-runtime";function N6({headers:$,rows:J}){return y$("div",{className:"overflow-x-auto mt-3","data-md":"table",children:y$("table",{className:"w-full text-body",children:[y$("thead",{children:y$("tr",{className:"border-b border-border-subtle",children:$.map((Q,q)=>y$("th",{className:"text-left px-4 py-2.5 text-meta font-medium uppercase tracking-wider text-text-tertiary font-body",children:Q},q,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),y$("tbody",{children:J.map((Q,q)=>y$("tr",{className:`relative border-b border-border-subtle last:border-b-0 transition-colors hover:bg-bg-surface/50 ${q%2===1?"bg-bg-surface/30":""}`,children:Q.map((W,Y)=>y$("td",{className:"px-4 py-2.5 text-text-secondary font-body",children:W},Y,!1,void 0,this))},q,!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 b$}from"react/jsx-dev-runtime";var K6={todo:"bg-border-hover",done:"bg-accent-green",blocked:"bg-accent-red","in-progress":"bg-accent-blue"},O6={todo:"Todo",done:"Done",blocked:"Blocked","in-progress":"In progress"},L6={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 p5({id:$,label:J,status:Q,badge:q,badgeVariant:W="neutral",children:Y}){return b$("div",{className:"group/task relative -mx-4 px-4 py-3 rounded-md transition-colors duration-150 hover:bg-bg-input","data-task-id":$,"data-md":"item","data-md-label":J,...Q?{"data-md-status":Q}:{},...q?{"data-md-badge":q}:{},children:b$("div",{className:"flex items-start gap-3",children:[Q&&b$("span",{className:`w-2 h-2 rounded-full mt-[7px] flex-shrink-0 ${K6[Q]}`},void 0,!1,void 0,this),b$("div",{className:"flex-1 min-w-0",children:[b$("div",{className:"flex items-baseline gap-2",children:[b$("span",{className:"font-body text-task-label font-semibold text-text-primary",children:J},void 0,!1,void 0,this),Q&&b$("span",{className:"font-body text-tiny uppercase tracking-wider text-text-tertiary opacity-0 group-hover/task:opacity-100 transition-opacity duration-150",children:O6[Q]},void 0,!1,void 0,this),q&&b$("span",{className:`font-body text-tiny font-medium px-1.5 py-px rounded-full ${L6[W]}`,children:q},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Y&&b$("div",{className:"text-body text-text-secondary mt-1 leading-relaxed",children:P$(Y)},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 F6($){return b$(p5,{...$},void 0,!1,void 0,this)}import{useAnnotations as d5,useResponseRegistration as r5}from"#canvas/runtime";import{useRef as S6,useState as i5}from"react";import{jsxDEV as y}from"react/jsx-dev-runtime";function A6({id:$,label:J,placeholder:Q,multiline:q,required:W}){let{responses:Y,setResponse:X}=d5();r5($);let G=Y.get($),H=G?.value??"",B=G?.note||"",[_,w]=i5(!1),L=S6(null);if(!Y.has($))X($,{id:$,type:"text",label:J,value:"",required:W});let F=(O)=>{X($,{...G,value:O})},U=(O)=>j$(O,q?60:32),K=G?.required&&!H.trim();return y("div",{"data-md":"userinput","data-md-label":J,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[y("div",{className:"flex items-baseline gap-2 mb-2",children:[y("span",{className:"text-[13px] font-body font-medium text-text-primary",children:J},void 0,!1,void 0,this),W&&y("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),y("textarea",{ref:L,value:H,onChange:(O)=>{F(O.currentTarget.value),U(O.currentTarget)},placeholder:Q||"Type your response...",rows:q?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:(O)=>U(O.currentTarget),onFocus:(O)=>U(O.currentTarget)},void 0,!1,void 0,this),y(w0,{show:_,note:B,onToggle:()=>w(!_),onChange:(O)=>X($,{...G,note:O})},void 0,!1,void 0,this),K&&y("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 b6({id:$,label:J,min:Q=1,max:q=10,step:W=1,required:Y,minLabel:X,maxLabel:G}){let{responses:H,setResponse:B}=d5();r5($);let _=H.get($),w=_?.value,L=_?.note||"",[F,U]=i5(!1);if(!H.has($))B($,{id:$,type:"range",label:J,value:null,required:Y});let K=(u)=>{B($,{..._,value:u})},O=w!==null&&w!==void 0,R=O?w:Math.round((Q+q)/2),T=(R-Q)/(q-Q)*100,I=Math.round((q-Q)/W),l=I<=20,x=_?.required&&!O;return y("div",{"data-md":"rangeinput","data-md-label":J,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[y("div",{className:"flex items-baseline justify-between mb-1",children:[y("div",{className:"flex items-baseline gap-2",children:[y("span",{className:"text-[13px] font-body font-medium text-text-primary",children:J},void 0,!1,void 0,this),Y&&y("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),y("span",{className:"flex items-center gap-1.5",children:[y("span",{className:`text-[13px] font-mono ${O?"text-accent-amber":"text-text-disabled"}`,children:O?w:"—"},void 0,!1,void 0,this),O&&y("button",{onClick:()=>B($,{..._,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),y("div",{className:"relative h-6 flex items-center",children:[y("div",{className:"absolute left-0 right-0 h-1.5 rounded-full bg-border-medium",children:O&&y("div",{className:"h-full rounded-full bg-accent-amber transition-all duration-150",style:{width:`${T}%`}},void 0,!1,void 0,this)},void 0,!1,void 0,this),l&&Array.from({length:I+1},(u,t)=>{let J$=Q+t*W,U$=(J$-Q)/(q-Q)*100,h=O&&J$<=w;return y("div",{className:`absolute rounded-full pointer-events-none transition-all duration-150 ${O&&J$===w?"w-2.5 h-2.5 bg-accent-amber":h?"w-1.5 h-1.5 bg-accent-amber":"w-1.5 h-1.5 bg-border-hover"}`,style:{left:`${U$}%`,transform:"translate(-50%, -50%)",top:"50%"}},t,!1,void 0,this)}),O?y("div",{className:"absolute h-5 w-5 rounded-full bg-accent-amber shadow-md pointer-events-none transition-all duration-150",style:{left:`calc(${T}% - 10px)`,borderWidth:"2px",borderStyle:"solid",borderColor:"var(--color-bg-base)"}},void 0,!1,void 0,this):y("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),y("input",{type:"range",min:Q,max:q,step:W,value:R,onChange:(u)=>K(Number(u.currentTarget.value)),className:"absolute inset-0 w-full opacity-0 cursor-pointer"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),l&&I<=10?y("div",{className:"flex justify-between -mt-0.5 px-0",children:Array.from({length:I+1},(u,t)=>{let J$=Q+t*W;return y("span",{className:`text-[10px] font-mono transition-colors ${O&&J$===w?"text-accent-amber font-medium":"text-text-disabled"}`,style:{minWidth:"1ch",textAlign:"center"},children:J$},t,!1,void 0,this)})},void 0,!1,void 0,this):y("div",{className:"flex justify-between -mt-0.5",children:[y("span",{className:"text-[11px] text-text-tertiary font-body",children:X||Q},void 0,!1,void 0,this),y("span",{className:"text-[11px] text-text-tertiary font-body",children:G||q},void 0,!1,void 0,this)]},void 0,!0,void 0,this),y(w0,{show:F,note:L,onToggle:()=>U(!F),onChange:(u)=>B($,{..._,note:u})},void 0,!1,void 0,this),x&&y("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)}export{wQ as useFeedback,A6 as UserInput,F6 as Task,N6 as Table,z6 as Section,b6 as RangeInput,M6 as Priority,G6 as Note,h3 as MultiChoice,X6 as Mermaid,J6 as Markdown,p5 as Item,e3 as ImageView,n3 as FilePreview,l3 as Diff,x3 as CodeBlock,g3 as Choice,r2 as Checklist,d2 as Callout};