agent-canvas 0.9.0-dev.13 → 0.9.0-dev.15

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 (65) hide show
  1. package/README.md +28 -0
  2. package/bin/agent-canvas.ts +8 -1
  3. package/bin/lib/cli-auth.ts +31 -0
  4. package/bin/lib/commands/daemon.ts +2 -1
  5. package/bin/lib/commands/exec.ts +5 -4
  6. package/bin/lib/commands/fetch.ts +4 -4
  7. package/bin/lib/commands/push.ts +3 -2
  8. package/bin/lib/commands/reply.ts +45 -0
  9. package/bin/lib/commands/review.ts +4 -2
  10. package/bin/lib/commands/watch.ts +100 -5
  11. package/bin/lib/helpers.ts +121 -43
  12. package/bin/lib/instructions/component-download.md +28 -0
  13. package/bin/lib/instructions/component-filedrop.md +50 -0
  14. package/bin/lib/instructions/overview.md +41 -1
  15. package/bin/lib/instructions/template-dashboard.md +177 -0
  16. package/bin/lib/instructions/template-slides.md +196 -0
  17. package/bin/lib/instructions/theming.md +25 -0
  18. package/daemon/client/App.tsx +17 -5
  19. package/daemon/client/clientApi.ts +64 -5
  20. package/daemon/client/components/Download.tsx +28 -0
  21. package/daemon/client/components/FileDrop.tsx +164 -0
  22. package/daemon/client/components/index.ts +3 -1
  23. package/daemon/client/threadStore.ts +70 -0
  24. package/daemon/dist/annotations-runtime.js +1 -1
  25. package/daemon/dist/client.css +2 -2
  26. package/daemon/dist/client.js +74 -73
  27. package/daemon/dist/components.js +62 -59
  28. package/daemon/dist/preact-compat.js +1 -1
  29. package/daemon/dist/review.js +3 -3
  30. package/daemon/dist/runtime.js +1 -1
  31. package/daemon/src/admission.ts +102 -0
  32. package/daemon/src/assets.ts +16 -0
  33. package/daemon/src/components.ts +6 -1
  34. package/daemon/src/handlers/api.ts +7 -4
  35. package/daemon/src/handlers/assets.ts +126 -0
  36. package/daemon/src/handlers/files.ts +124 -19
  37. package/daemon/src/handlers/static.ts +65 -1
  38. package/daemon/src/handlers/theme.ts +150 -0
  39. package/daemon/src/handlers/threads.ts +93 -0
  40. package/daemon/src/review/server.ts +1 -1
  41. package/daemon/src/server.ts +81 -47
  42. package/daemon/src/threads.ts +132 -0
  43. package/package.json +4 -4
  44. package/skills/canvas/SKILL.md +5 -0
  45. package/types/bin/lib/cli-auth.d.ts +9 -0
  46. package/types/bin/lib/commands/reply.d.ts +2 -0
  47. package/types/bin/lib/commands/watch.d.ts +3 -1
  48. package/types/bin/lib/helpers.d.ts +102 -0
  49. package/types/daemon/client/clientApi.d.ts +14 -1
  50. package/types/daemon/client/components/Download.d.ts +9 -0
  51. package/types/daemon/client/components/FileDrop.d.ts +12 -0
  52. package/types/daemon/client/components/index.d.ts +2 -0
  53. package/types/daemon/client/threadStore.d.ts +15 -0
  54. package/types/daemon/src/admission.d.ts +24 -0
  55. package/types/daemon/src/assets.d.ts +23 -0
  56. package/types/daemon/src/components.d.ts +3 -1
  57. package/types/daemon/src/handlers/assets.d.ts +14 -0
  58. package/types/daemon/src/handlers/files.d.ts +8 -2
  59. package/types/daemon/src/handlers/static.d.ts +16 -0
  60. package/types/daemon/src/handlers/theme.d.ts +18 -0
  61. package/types/daemon/src/handlers/threads.d.ts +19 -0
  62. package/types/daemon/src/review/model.d.ts +24 -24
  63. package/types/daemon/src/review/remote.d.ts +8 -8
  64. package/types/daemon/src/review/server.d.ts +2 -0
  65. package/types/daemon/src/threads.d.ts +109 -0
@@ -1,65 +1,68 @@
1
- var M4=Object.defineProperty;var U4=($)=>$;function w4($,J){this[$]=U4.bind(null,J)}var N4=($,J)=>{for(var Q in J)M4($,Q,{get:J[Q],enumerable:!0,configurable:!0,set:w4.bind(J,Q)})};import{useFeedback as d7}from"#canvas/runtime";function _1(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var p$=_1();function a1($){p$=$}var x$={exec:()=>null};function I($,J=""){let Q=typeof $=="string"?$:$.source,q={replace:(W,X)=>{let Y=typeof X=="string"?X:X.source;return Y=Y.replace(e.caret,"$1"),Q=Q.replace(W,Y),q},getRegex:()=>new RegExp(Q,J)};return q}var K4=(()=>{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:($)=>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)}}>`)},L4=/^(?:[ \t]*(?:\n|$))+/,O4=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,F4=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,A0=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,z4=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,M1=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,s1=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,t1=I(s1).replace(/bull/g,M1).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(),A4=I(s1).replace(/bull/g,M1).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(),U1=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,S4=/^[^\n]+/,w1=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,f4=I(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",w1).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),R4=I(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,M1).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",N1=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,b4=I("^ {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",N1).replace("tag",m0).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),e1=I(U1).replace("hr",A0).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(),j4=I(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",e1).getRegex(),K1={blockquote:j4,code:O4,def:f4,fences:F4,heading:z4,hr:A0,html:b4,lheading:t1,list:R4,newline:L4,paragraph:e1,table:x$,text:S4},c1=I("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",A0).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(),V4={...K1,lheading:A4,table:c1,paragraph:I(U1).replace("hr",A0).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",c1).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()},v4={...K1,html:I(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",N1).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:x$,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:I(U1).replace("hr",A0).replace("heading",` *#{1,6} *[^
2
- ]`).replace("lheading",t1).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},P4=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,C4=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,$2=/^( {2,}|\\)\n(?!\s*$)/,D4=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,n$=/[\p{P}\p{S}]/u,x0=/[\s\p{P}\p{S}]/u,L1=/[^\s\p{P}\p{S}]/u,k4=I(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,x0).getRegex(),J2=/(?!~)[\p{P}\p{S}]/u,T4=/(?!~)[\s\p{P}\p{S}]/u,E4=/(?:[^\s\p{P}\p{S}]|~)/u,I4=I(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",K4?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Q2=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,g4=I(Q2,"u").replace(/punct/g,n$).getRegex(),h4=I(Q2,"u").replace(/punct/g,J2).getRegex(),W2="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Z4=I(W2,"gu").replace(/notPunctSpace/g,L1).replace(/punctSpace/g,x0).replace(/punct/g,n$).getRegex(),y4=I(W2,"gu").replace(/notPunctSpace/g,E4).replace(/punctSpace/g,T4).replace(/punct/g,J2).getRegex(),m4=I("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,L1).replace(/punctSpace/g,x0).replace(/punct/g,n$).getRegex(),x4=I(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,n$).getRegex(),u4="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",p4=I(u4,"gu").replace(/notPunctSpace/g,L1).replace(/punctSpace/g,x0).replace(/punct/g,n$).getRegex(),l4=I(/\\(punct)/,"gu").replace(/punct/g,n$).getRegex(),c4=I(/^<(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(),d4=I(N1).replace("(?:-->|$)","-->").getRegex(),i4=I("^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",d4).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),h0=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,r4=I(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",h0).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),q2=I(/^!?\[(label)\]\[(ref)\]/).replace("label",h0).replace("ref",w1).getRegex(),X2=I(/^!?\[(ref)\](?:\[\])?/).replace("ref",w1).getRegex(),o4=I("reflink|nolink(?!\\()","g").replace("reflink",q2).replace("nolink",X2).getRegex(),d1=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,O1={_backpedal:x$,anyPunctuation:l4,autolink:c4,blockSkip:I4,br:$2,code:C4,del:x$,delLDelim:x$,delRDelim:x$,emStrongLDelim:g4,emStrongRDelimAst:Z4,emStrongRDelimUnd:m4,escape:P4,link:r4,nolink:X2,punctuation:k4,reflink:q2,reflinkSearch:o4,tag:i4,text:D4,url:x$},n4={...O1,link:I(/^!?\[(label)\]\((.*?)\)/).replace("label",h0).getRegex(),reflink:I(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",h0).getRegex()},B1={...O1,emStrongRDelimAst:y4,emStrongLDelim:h4,delLDelim:x4,delRDelim:p4,url:I(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",d1).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:I(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",d1).getRegex()},a4={...B1,br:I($2).replace("{2,}","*").getRegex(),text:I(B1.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},g0={normal:K1,gfm:V4,pedantic:v4},O0={normal:O1,gfm:B1,breaks:a4,pedantic:n4},s4={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},i1=($)=>s4[$];function O$($,J){if(J){if(e.escapeTest.test($))return $.replace(e.escapeReplace,i1)}else if(e.escapeTestNoEncode.test($))return $.replace(e.escapeReplaceNoEncode,i1);return $}function r1($){try{$=encodeURI($).replace(e.percentDecode,"%")}catch{return null}return $}function o1($,J){let Q=$.replace(e.findPipe,(X,Y,G)=>{let H=!1,B=Y;for(;--B>=0&&G[B]==="\\";)H=!H;return H?"|":" |"}),q=Q.split(e.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(e.slashPipe,"|");return q}function F0($,J,Q){let q=$.length;if(q===0)return"";let W=0;for(;W<q;){let X=$.charAt(q-W-1);if(X===J&&!Q)W++;else if(X!==J&&Q)W++;else break}return $.slice(0,q-W)}function t4($,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 e4($,J=0){let Q=J,q="";for(let W of $)if(W==="\t"){let X=4-Q%4;q+=" ".repeat(X),Q+=X}else q+=W,Q++;return q}function n1($,J,Q,q,W){let X=J.href,Y=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:X,title:Y,text:G,tokens:q.inlineTokens(G)};return q.state.inLink=!1,H}function $3($,J,Q){let q=$.match(Q.other.indentCodeCompensation);if(q===null)return J;let W=q[1];return J.split(`
3
- `).map((X)=>{let Y=X.match(Q.other.beginningSpace);if(Y===null)return X;let[G]=Y;return G.length>=W.length?X.slice(W.length):X}).join(`
4
- `)}var Z0=class{options;rules;lexer;constructor($){this.options=$||p$}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:F0(Q,`
5
- `)}}}fences($){let J=this.rules.block.fences.exec($);if(J){let Q=J[0],q=$3(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=F0(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:F0(J[0],`
6
- `)}}blockquote($){let J=this.rules.block.blockquote.exec($);if(J){let Q=F0(J[0],`
1
+ import{useFeedback as Xp}from"#canvas/runtime";function vn(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ve=vn();function xr(e){Ve=e}var Ue={exec:()=>null};function z(e,t=""){let n=typeof e=="string"?e:e.source,s={replace:(r,o)=>{let a=typeof o=="string"?o:o.source;return a=a.replace(se.caret,"$1"),n=n.replace(r,a),s},getRegex:()=>new RegExp(n,t)};return s}var js=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),se={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:(e)=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:(e)=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:(e)=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:(e)=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:(e)=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:(e)=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:(e)=>new RegExp(`^ {0,${Math.min(3,e-1)}}>`)},Ds=/^(?:[ \t]*(?:\n|$))+/,zs=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Hs=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,mt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Bs=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,kn=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,yr=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,br=z(yr).replace(/bull/g,kn).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(),Fs=z(yr).replace(/bull/g,kn).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(),wn=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Us=/^[^\n]+/,_n=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,qs=z(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",_n).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Vs=z(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,kn).getRegex(),Ft="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",Sn=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Ws=z("^ {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",Sn).replace("tag",Ft).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),vr=z(wn).replace("hr",mt).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",Ft).getRegex(),Gs=z(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",vr).getRegex(),Tn={blockquote:Gs,code:zs,def:qs,fences:Hs,heading:Bs,hr:mt,html:Ws,lheading:br,list:Vs,newline:Ds,paragraph:vr,table:Ue,text:Us},ur=z("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",mt).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",Ft).getRegex(),Ks={...Tn,lheading:Fs,table:ur,paragraph:z(wn).replace("hr",mt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ur).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",Ft).getRegex()},Ys={...Tn,html:z(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Sn).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:Ue,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:z(wn).replace("hr",mt).replace("heading",` *#{1,6} *[^
2
+ ]`).replace("lheading",br).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Js=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Xs=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,kr=/^( {2,}|\\)\n(?!\s*$)/,Qs=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Je=/[\p{P}\p{S}]/u,Ut=/[\s\p{P}\p{S}]/u,An=/[^\s\p{P}\p{S}]/u,Zs=z(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Ut).getRegex(),wr=/(?!~)[\p{P}\p{S}]/u,eo=/(?!~)[\s\p{P}\p{S}]/u,to=/(?:[^\s\p{P}\p{S}]|~)/u,no=z(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",js?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),_r=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,ro=z(_r,"u").replace(/punct/g,Je).getRegex(),so=z(_r,"u").replace(/punct/g,wr).getRegex(),Sr="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",oo=z(Sr,"gu").replace(/notPunctSpace/g,An).replace(/punctSpace/g,Ut).replace(/punct/g,Je).getRegex(),ao=z(Sr,"gu").replace(/notPunctSpace/g,to).replace(/punctSpace/g,eo).replace(/punct/g,wr).getRegex(),io=z("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,An).replace(/punctSpace/g,Ut).replace(/punct/g,Je).getRegex(),lo=z(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Je).getRegex(),co="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",uo=z(co,"gu").replace(/notPunctSpace/g,An).replace(/punctSpace/g,Ut).replace(/punct/g,Je).getRegex(),po=z(/\\(punct)/,"gu").replace(/punct/g,Je).getRegex(),fo=z(/^<(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(),ho=z(Sn).replace("(?:-->|$)","-->").getRegex(),mo=z("^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",ho).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),zt=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,go=z(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",zt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Tr=z(/^!?\[(label)\]\[(ref)\]/).replace("label",zt).replace("ref",_n).getRegex(),Ar=z(/^!?\[(ref)\](?:\[\])?/).replace("ref",_n).getRegex(),xo=z("reflink|nolink(?!\\()","g").replace("reflink",Tr).replace("nolink",Ar).getRegex(),pr=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Rn={_backpedal:Ue,anyPunctuation:po,autolink:fo,blockSkip:no,br:kr,code:Xs,del:Ue,delLDelim:Ue,delRDelim:Ue,emStrongLDelim:ro,emStrongRDelimAst:oo,emStrongRDelimUnd:io,escape:Js,link:go,nolink:Ar,punctuation:Zs,reflink:Tr,reflinkSearch:xo,tag:mo,text:Qs,url:Ue},yo={...Rn,link:z(/^!?\[(label)\]\((.*?)\)/).replace("label",zt).getRegex(),reflink:z(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",zt).getRegex()},bn={...Rn,emStrongRDelimAst:ao,emStrongLDelim:so,delLDelim:lo,delRDelim:uo,url:z(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",pr).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:z(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",pr).getRegex()},bo={...bn,br:z(kr).replace("{2,}","*").getRegex(),text:z(bn.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Dt={normal:Tn,gfm:Ks,pedantic:Ys},pt={normal:Rn,gfm:bn,breaks:bo,pedantic:yo},vo={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},fr=(e)=>vo[e];function ye(e,t){if(t){if(se.escapeTest.test(e))return e.replace(se.escapeReplace,fr)}else if(se.escapeTestNoEncode.test(e))return e.replace(se.escapeReplaceNoEncode,fr);return e}function hr(e){try{e=encodeURI(e).replace(se.percentDecode,"%")}catch{return null}return e}function mr(e,t){let n=e.replace(se.findPipe,(o,a,l)=>{let i=!1,c=a;for(;--c>=0&&l[c]==="\\";)i=!i;return i?"|":" |"}),s=n.split(se.splitPipe),r=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),t)if(s.length>t)s.splice(t);else for(;s.length<t;)s.push("");for(;r<s.length;r++)s[r]=s[r].trim().replace(se.slashPipe,"|");return s}function ft(e,t,n){let s=e.length;if(s===0)return"";let r=0;for(;r<s;){let o=e.charAt(s-r-1);if(o===t&&!n)r++;else if(o!==t&&n)r++;else break}return e.slice(0,s-r)}function ko(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let s=0;s<e.length;s++)if(e[s]==="\\")s++;else if(e[s]===t[0])n++;else if(e[s]===t[1]&&(n--,n<0))return s;return n>0?-2:-1}function wo(e,t=0){let n=t,s="";for(let r of e)if(r==="\t"){let o=4-n%4;s+=" ".repeat(o),n+=o}else s+=r,n++;return s}function gr(e,t,n,s,r){let o=t.href,a=t.title||null,l=e[1].replace(r.other.outputLinkReplace,"$1");s.state.inLink=!0;let i={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:a,text:l,tokens:s.inlineTokens(l)};return s.state.inLink=!1,i}function _o(e,t,n){let s=e.match(n.other.indentCodeCompensation);if(s===null)return t;let r=s[1];return t.split(`
3
+ `).map((o)=>{let a=o.match(n.other.beginningSpace);if(a===null)return o;let[l]=a;return l.length>=r.length?o.slice(r.length):o}).join(`
4
+ `)}var Ht=class{options;rules;lexer;constructor(e){this.options=e||Ve}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:ft(n,`
5
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],s=_o(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:s}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let s=ft(n,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(n=s.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:ft(t[0],`
6
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=ft(t[0],`
7
7
  `).split(`
8
- `),q="",W="",X=[];for(;Q.length>0;){let Y=!1,G=[],H;for(H=0;H<Q.length;H++)if(this.rules.other.blockquoteStart.test(Q[H]))G.push(Q[H]),Y=!0;else if(!Y)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 N=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(_,X,!0),this.lexer.state.top=N,Q.length===0)break;let F=X.at(-1);if(F?.type==="code")break;if(F?.type==="blockquote"){let z=F,w=z.raw+`
13
- `+Q.join(`
14
- `),L=this.blockquote(w);X[X.length-1]=L,q=q.substring(0,q.length-z.raw.length)+L.raw,W=W.substring(0,W.length-z.text.length)+L.text;break}else if(F?.type==="list"){let z=F,w=z.raw+`
15
- `+Q.join(`
16
- `),L=this.list(w);X[X.length-1]=L,q=q.substring(0,q.length-F.raw.length)+L.raw,W=W.substring(0,W.length-z.raw.length)+L.raw,Q=w.substring(X.at(-1).raw.length).split(`
17
- `);continue}}return{type:"blockquote",raw:q,tokens:X,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 X=this.rules.other.listItemRegex(Q),Y=!1;for(;$;){let H=!1,B="",_="";if(!(J=X.exec($))||this.rules.block.hr.test($))break;B=J[0],$=$.substring(B.length);let N=e4(J[2].split(`
18
- `,1)[0],J[1].length),F=$.split(`
19
- `,1)[0],z=!N.trim(),w=0;if(this.options.pedantic?(w=2,_=N.trimStart()):z?w=J[1].length+1:(w=N.search(this.rules.other.nonSpaceChar),w=w>4?1:w,_=N.slice(w),w+=J[1].length),z&&this.rules.other.blankLine.test(F)&&(B+=F+`
20
- `,$=$.substring(F.length+1),H=!0),!H){let L=this.rules.other.nextBulletRegex(w),A=this.rules.other.hrRegex(w),j=this.rules.other.fencesBeginRegex(w),g=this.rules.other.headingBeginRegex(w),k=this.rules.other.htmlBeginRegex(w),T=this.rules.other.blockquoteBeginRegex(w);for(;$;){let y=$.split(`
21
- `,1)[0],u;if(F=y,this.options.pedantic?(F=F.replace(this.rules.other.listReplaceNesting," "),u=F):u=F.replace(this.rules.other.tabCharGlobal," "),j.test(F)||g.test(F)||k.test(F)||T.test(F)||L.test(F)||A.test(F))break;if(u.search(this.rules.other.nonSpaceChar)>=w||!F.trim())_+=`
22
- `+u.slice(w);else{if(z||N.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||j.test(N)||g.test(N)||A.test(N))break;_+=`
23
- `+F}z=!F.trim(),B+=y+`
24
- `,$=$.substring(y.length+1),N=u.slice(w)}}W.loose||(Y?W.loose=!0:this.rules.other.doubleBlankLine.test(B)&&(Y=!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((N)=>N.type==="space"),_=B.length>0&&B.some((N)=>this.rules.other.anyLine.test(N.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=o1(J[1]),q=J[2].replace(this.rules.other.tableAlignChars,"").split("|"),W=J[3]?.trim()?J[3].replace(this.rules.other.tableRowBlankLine,"").split(`
25
- `):[],X={type:"table",raw:J[0],header:[],align:[],rows:[]};if(Q.length===q.length){for(let Y of q)this.rules.other.tableAlignRight.test(Y)?X.align.push("right"):this.rules.other.tableAlignCenter.test(Y)?X.align.push("center"):this.rules.other.tableAlignLeft.test(Y)?X.align.push("left"):X.align.push(null);for(let Y=0;Y<Q.length;Y++)X.header.push({text:Q[Y],tokens:this.lexer.inline(Q[Y]),header:!0,align:X.align[Y]});for(let Y of W)X.rows.push(o1(Y,X.header.length).map((G,H)=>({text:G,tokens:this.lexer.inline(G),header:!1,align:X.align[H]})));return X}}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 X=F0(Q.slice(0,-1),"\\");if((Q.length-X.length)%2===0)return}else{let X=t4(J[2],"()");if(X===-2)return;if(X>-1){let Y=(J[0].indexOf("!")===0?5:4)+J[1].length+X;J[2]=J[2].substring(0,X),J[0]=J[0].substring(0,Y).trim(),J[3]=""}}let q=J[2],W="";if(this.options.pedantic){let X=this.rules.other.pedanticHrefTitle.exec(q);X&&(q=X[1],W=X[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)),n1(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 X=Q[0].charAt(0);return{type:"text",raw:X,text:X}}return n1(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,X,Y,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(X=q[1]||q[2]||q[3]||q[4]||q[5]||q[6],!X)continue;if(Y=[...X].length,q[3]||q[4]){G+=Y;continue}else if((q[5]||q[6])&&W%3&&!((W+Y)%3)){H+=Y;continue}if(G-=Y,G>0)continue;Y=Math.min(Y,Y+G+H);let _=[...q[0]][0].length,N=$.slice(0,W+q.index+_+Y);if(Math.min(W,Y)%2){let z=N.slice(1,-1);return{type:"em",raw:N,text:z,tokens:this.lexer.inlineTokens(z)}}let F=N.slice(2,-2);return{type:"strong",raw:N,text:F,tokens:this.lexer.inlineTokens(F)}}}}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,X,Y,G=W,H=this.rules.inline.delRDelim;for(H.lastIndex=0,J=J.slice(-1*$.length+W);(q=H.exec(J))!==null;){if(X=q[1]||q[2]||q[3]||q[4]||q[5]||q[6],!X||(Y=[...X].length,Y!==W))continue;if(q[3]||q[4]){G+=Y;continue}if(G-=Y,G>0)continue;Y=Math.min(Y,Y+G);let B=[...q[0]][0].length,_=$.slice(0,W+q.index+B+Y),N=_.slice(W,-W);return{type:"del",raw:_,text:N,tokens:this.lexer.inlineTokens(N)}}}}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}}}},H$=class ${tokens;options;state;inlineQueue;tokenizer;constructor(J){this.tokens=[],this.tokens.links=Object.create(null),this.options=J||p$,this.options.tokenizer=this.options.tokenizer||new Z0,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:e,block:g0.normal,inline:O0.normal};this.options.pedantic?(Q.block=g0.pedantic,Q.inline=O0.pedantic):this.options.gfm&&(Q.block=g0.gfm,this.options.breaks?Q.inline=O0.breaks:Q.inline=O0.gfm),this.tokenizer.rules=Q}static get rules(){return{block:g0,inline:O0}}static lex(J,Q){return new $(Q).lex(J)}static lexInline(J,Q){return new $(Q).inlineTokens(J)}lex(J){J=J.replace(e.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(e.tabCharGlobal," ").replace(e.spaceLine,""));J;){let W;if(this.options.extensions?.block?.some((Y)=>(W=Y.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 Y=Q.at(-1);W.raw.length===1&&Y!==void 0?Y.raw+=`
28
- `:Q.push(W);continue}if(W=this.tokenizer.code(J)){J=J.substring(W.raw.length);let Y=Q.at(-1);Y?.type==="paragraph"||Y?.type==="text"?(Y.raw+=(Y.raw.endsWith(`
8
+ `),s="",r="",o=[];for(;n.length>0;){let a=!1,l=[],i;for(i=0;i<n.length;i++)if(this.rules.other.blockquoteStart.test(n[i]))l.push(n[i]),a=!0;else if(!a)l.push(n[i]);else break;n=n.slice(i);let c=l.join(`
9
+ `),d=c.replace(this.rules.other.blockquoteSetextReplace,`
10
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
11
+ ${c}`:c,r=r?`${r}
12
+ ${d}`:d;let f=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(d,o,!0),this.lexer.state.top=f,n.length===0)break;let g=o.at(-1);if(g?.type==="code")break;if(g?.type==="blockquote"){let x=g,u=x.raw+`
13
+ `+n.join(`
14
+ `),h=this.blockquote(u);o[o.length-1]=h,s=s.substring(0,s.length-x.raw.length)+h.raw,r=r.substring(0,r.length-x.text.length)+h.text;break}else if(g?.type==="list"){let x=g,u=x.raw+`
15
+ `+n.join(`
16
+ `),h=this.list(u);o[o.length-1]=h,s=s.substring(0,s.length-g.raw.length)+h.raw,r=r.substring(0,r.length-x.raw.length)+h.raw,n=u.substring(o.at(-1).raw.length).split(`
17
+ `);continue}}return{type:"blockquote",raw:s,tokens:o,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),s=n.length>1,r={type:"list",raw:"",ordered:s,start:s?+n.slice(0,-1):"",loose:!1,items:[]};n=s?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=s?n:"[*+-]");let o=this.rules.other.listItemRegex(n),a=!1;for(;e;){let i=!1,c="",d="";if(!(t=o.exec(e))||this.rules.block.hr.test(e))break;c=t[0],e=e.substring(c.length);let f=wo(t[2].split(`
18
+ `,1)[0],t[1].length),g=e.split(`
19
+ `,1)[0],x=!f.trim(),u=0;if(this.options.pedantic?(u=2,d=f.trimStart()):x?u=t[1].length+1:(u=f.search(this.rules.other.nonSpaceChar),u=u>4?1:u,d=f.slice(u),u+=t[1].length),x&&this.rules.other.blankLine.test(g)&&(c+=g+`
20
+ `,e=e.substring(g.length+1),i=!0),!i){let h=this.rules.other.nextBulletRegex(u),y=this.rules.other.hrRegex(u),T=this.rules.other.fencesBeginRegex(u),O=this.rules.other.headingBeginRegex(u),M=this.rules.other.htmlBeginRegex(u),I=this.rules.other.blockquoteBeginRegex(u);for(;e;){let _=e.split(`
21
+ `,1)[0],j;if(g=_,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),j=g):j=g.replace(this.rules.other.tabCharGlobal," "),T.test(g)||O.test(g)||M.test(g)||I.test(g)||h.test(g)||y.test(g))break;if(j.search(this.rules.other.nonSpaceChar)>=u||!g.trim())d+=`
22
+ `+j.slice(u);else{if(x||f.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||T.test(f)||O.test(f)||y.test(f))break;d+=`
23
+ `+g}x=!g.trim(),c+=_+`
24
+ `,e=e.substring(_.length+1),f=j.slice(u)}}r.loose||(a?r.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(a=!0)),r.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(d),loose:!1,text:d,tokens:[]}),r.raw+=c}let l=r.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let i of r.items){if(this.lexer.state.top=!1,i.tokens=this.lexer.blockTokens(i.text,[]),i.task){if(i.text=i.text.replace(this.rules.other.listReplaceTask,""),i.tokens[0]?.type==="text"||i.tokens[0]?.type==="paragraph"){i.tokens[0].raw=i.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),i.tokens[0].text=i.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let d=this.lexer.inlineQueue.length-1;d>=0;d--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[d].src)){this.lexer.inlineQueue[d].src=this.lexer.inlineQueue[d].src.replace(this.rules.other.listReplaceTask,"");break}}let c=this.rules.other.listTaskCheckbox.exec(i.raw);if(c){let d={type:"checkbox",raw:c[0]+" ",checked:c[0]!=="[ ]"};i.checked=d.checked,r.loose?i.tokens[0]&&["paragraph","text"].includes(i.tokens[0].type)&&"tokens"in i.tokens[0]&&i.tokens[0].tokens?(i.tokens[0].raw=d.raw+i.tokens[0].raw,i.tokens[0].text=d.raw+i.tokens[0].text,i.tokens[0].tokens.unshift(d)):i.tokens.unshift({type:"paragraph",raw:d.raw,text:d.raw,tokens:[d]}):i.tokens.unshift(d)}}if(!r.loose){let c=i.tokens.filter((f)=>f.type==="space"),d=c.length>0&&c.some((f)=>this.rules.other.anyLine.test(f.raw));r.loose=d}}if(r.loose)for(let i of r.items){i.loose=!0;for(let c of i.tokens)c.type==="text"&&(c.type="paragraph")}return r}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:s,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=mr(t[1]),s=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
25
+ `):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===s.length){for(let a of s)this.rules.other.tableAlignRight.test(a)?o.align.push("right"):this.rules.other.tableAlignCenter.test(a)?o.align.push("center"):this.rules.other.tableAlignLeft.test(a)?o.align.push("left"):o.align.push(null);for(let a=0;a<n.length;a++)o.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:o.align[a]});for(let a of r)o.rows.push(mr(a,o.header.length).map((l,i)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:o.align[i]})));return o}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
26
+ `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let o=ft(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=ko(t[2],"()");if(o===-2)return;if(o>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,a).trim(),t[3]=""}}let s=t[2],r="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(s);o&&(s=o[1],r=o[3])}else r=t[3]?t[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?s=s.slice(1):s=s.slice(1,-1)),gr(t,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let s=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=t[s.toLowerCase()];if(!r){let o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return gr(n,r,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!s||!s[1]&&!s[2]&&!s[3]&&!s[4]||s[4]&&n.match(this.rules.other.unicodeAlphaNumeric))return;if(!(s[1]||s[3])||!n||this.rules.inline.punctuation.exec(n)){let r=[...s[0]].length-1,o,a,l=r,i=0,c=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+r);(s=c.exec(t))!==null;){if(o=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!o)continue;if(a=[...o].length,s[3]||s[4]){l+=a;continue}else if((s[5]||s[6])&&r%3&&!((r+a)%3)){i+=a;continue}if(l-=a,l>0)continue;a=Math.min(a,a+l+i);let d=[...s[0]][0].length,f=e.slice(0,r+s.index+d+a);if(Math.min(r,a)%2){let x=f.slice(1,-1);return{type:"em",raw:f,text:x,tokens:this.lexer.inlineTokens(x)}}let g=f.slice(2,-2);return{type:"strong",raw:f,text:g,tokens:this.lexer.inlineTokens(g)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(n),r=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return s&&r&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let s=this.rules.inline.delLDelim.exec(e);if(!s)return;if(!s[1]||!n||this.rules.inline.punctuation.exec(n)){let r=[...s[0]].length-1,o,a,l=r,i=this.rules.inline.delRDelim;for(i.lastIndex=0,t=t.slice(-1*e.length+r);(s=i.exec(t))!==null;){if(o=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!o||(a=[...o].length,a!==r))continue;if(s[3]||s[4]){l+=a;continue}if(l-=a,l>0)continue;a=Math.min(a,a+l);let c=[...s[0]][0].length,d=e.slice(0,r+s.index+c+a),f=d.slice(r,-r);return{type:"del",raw:d,text:f,tokens:this.lexer.inlineTokens(f)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,s;return t[2]==="@"?(n=t[1],s="mailto:"+n):(n=t[1],s=n),{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,s;if(t[2]==="@")n=t[0],s="mailto:"+n;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(r!==t[0]);n=t[0],t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},pe=class e{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Ve,this.options.tokenizer=this.options.tokenizer||new Ht,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:se,block:Dt.normal,inline:pt.normal};this.options.pedantic?(n.block=Dt.pedantic,n.inline=pt.pedantic):this.options.gfm&&(n.block=Dt.gfm,this.options.breaks?n.inline=pt.breaks:n.inline=pt.gfm),this.tokenizer.rules=n}static get rules(){return{block:Dt,inline:pt}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(t){t=t.replace(se.carriageReturn,`
27
+ `),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let s=this.inlineQueue[n];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],s=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(se.tabCharGlobal," ").replace(se.spaceLine,""));t;){let r;if(this.options.extensions?.block?.some((a)=>(r=a.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))continue;if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length);let a=n.at(-1);r.raw.length===1&&a!==void 0?a.raw+=`
28
+ `:n.push(r);continue}if(r=this.tokenizer.code(t)){t=t.substring(r.raw.length);let a=n.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
29
29
  `)?"":`
30
- `)+W.raw,Y.text+=`
31
- `+W.text,this.inlineQueue.at(-1).src=Y.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 Y=Q.at(-1);Y?.type==="paragraph"||Y?.type==="text"?(Y.raw+=(Y.raw.endsWith(`
30
+ `)+r.raw,a.text+=`
31
+ `+r.text,this.inlineQueue.at(-1).src=a.text):n.push(r);continue}if(r=this.tokenizer.fences(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.heading(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.hr(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.blockquote(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.list(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.html(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.def(t)){t=t.substring(r.raw.length);let a=n.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
32
32
  `)?"":`
33
- `)+W.raw,Y.text+=`
34
- `+W.raw,this.inlineQueue.at(-1).src=Y.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 X=J;if(this.options.extensions?.startBlock){let Y=1/0,G=J.slice(1),H;this.options.extensions.startBlock.forEach((B)=>{H=B.call({lexer:this},G),typeof H=="number"&&H>=0&&(Y=Math.min(Y,H))}),Y<1/0&&Y>=0&&(X=J.substring(0,Y+1))}if(this.state.top&&(W=this.tokenizer.paragraph(X))){let Y=Q.at(-1);q&&Y?.type==="paragraph"?(Y.raw+=(Y.raw.endsWith(`
33
+ `)+r.raw,a.text+=`
34
+ `+r.raw,this.inlineQueue.at(-1).src=a.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},n.push(r));continue}if(r=this.tokenizer.table(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.lheading(t)){t=t.substring(r.raw.length),n.push(r);continue}let o=t;if(this.options.extensions?.startBlock){let a=1/0,l=t.slice(1),i;this.options.extensions.startBlock.forEach((c)=>{i=c.call({lexer:this},l),typeof i=="number"&&i>=0&&(a=Math.min(a,i))}),a<1/0&&a>=0&&(o=t.substring(0,a+1))}if(this.state.top&&(r=this.tokenizer.paragraph(o))){let a=n.at(-1);s&&a?.type==="paragraph"?(a.raw+=(a.raw.endsWith(`
35
35
  `)?"":`
36
- `)+W.raw,Y.text+=`
37
- `+W.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=Y.text):Q.push(W),q=X.length!==J.length,J=J.substring(W.raw.length);continue}if(W=this.tokenizer.text(J)){J=J.substring(W.raw.length);let Y=Q.at(-1);Y?.type==="text"?(Y.raw+=(Y.raw.endsWith(`
36
+ `)+r.raw,a.text+=`
37
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):n.push(r),s=o.length!==t.length,t=t.substring(r.raw.length);continue}if(r=this.tokenizer.text(t)){t=t.substring(r.raw.length);let a=n.at(-1);a?.type==="text"?(a.raw+=(a.raw.endsWith(`
38
38
  `)?"":`
39
- `)+W.raw,Y.text+=`
40
- `+W.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=Y.text):Q.push(W);continue}if(J){let Y="Infinite loop on byte: "+J.charCodeAt(0);if(this.options.silent){console.error(Y);break}else throw Error(Y)}}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 X;for(;(W=this.tokenizer.rules.inline.blockSkip.exec(q))!==null;)X=W[2]?W[2].length:0,q=q.slice(0,W.index+X)+"["+"a".repeat(W[0].length-X-2)+"]"+q.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);q=this.options.hooks?.emStrongMask?.call({lexer:this},q)??q;let Y=!1,G="";for(;J;){Y||(G=""),Y=!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,N=J.slice(1),F;this.options.extensions.startInline.forEach((z)=>{F=z.call({lexer:this},N),typeof F=="number"&&F>=0&&(_=Math.min(_,F))}),_<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)),Y=!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}},y0=class{options;parser;constructor($){this.options=$||p$}space($){return""}code({text:$,lang:J,escaped:Q}){let q=(J||"").match(e.notSpaceStart)?.[0],W=$.replace(e.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 Y=0;Y<$.items.length;Y++){let G=$.items[Y];q+=this.listitem(G)}let W=J?"ol":"ul",X=J&&Q!==1?' start="'+Q+'"':"";return"<"+W+X+`>
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 X=$.rows[W];Q="";for(let Y=0;Y<X.length;Y++)Q+=this.tablecell(X[Y]);q+=this.tablerow({text:Q})}return q&&(q=`<tbody>${q}</tbody>`),`<table>
39
+ `)+r.raw,a.text+=`
40
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):n.push(r);continue}if(t){let a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){this.tokenizer.lexer=this;let s=t,r=null;if(this.tokens.links){let i=Object.keys(this.tokens.links);if(i.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(s))!==null;)i.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(s))!==null;)s=s.slice(0,r.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let o;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(s))!==null;)o=r[2]?r[2].length:0,s=s.slice(0,r.index+o)+"["+"a".repeat(r[0].length-o-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);s=this.options.hooks?.emStrongMask?.call({lexer:this},s)??s;let a=!1,l="";for(;t;){a||(l=""),a=!1;let i;if(this.options.extensions?.inline?.some((d)=>(i=d.call({lexer:this},t,n))?(t=t.substring(i.raw.length),n.push(i),!0):!1))continue;if(i=this.tokenizer.escape(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.tag(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.link(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(i.raw.length);let d=n.at(-1);i.type==="text"&&d?.type==="text"?(d.raw+=i.raw,d.text+=i.text):n.push(i);continue}if(i=this.tokenizer.emStrong(t,s,l)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.codespan(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.br(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.del(t,s,l)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.autolink(t)){t=t.substring(i.raw.length),n.push(i);continue}if(!this.state.inLink&&(i=this.tokenizer.url(t))){t=t.substring(i.raw.length),n.push(i);continue}let c=t;if(this.options.extensions?.startInline){let d=1/0,f=t.slice(1),g;this.options.extensions.startInline.forEach((x)=>{g=x.call({lexer:this},f),typeof g=="number"&&g>=0&&(d=Math.min(d,g))}),d<1/0&&d>=0&&(c=t.substring(0,d+1))}if(i=this.tokenizer.inlineText(c)){t=t.substring(i.raw.length),i.raw.slice(-1)!=="_"&&(l=i.raw.slice(-1)),a=!0;let d=n.at(-1);d?.type==="text"?(d.raw+=i.raw,d.text+=i.text):n.push(i);continue}if(t){let d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw Error(d)}}return n}},Bt=class{options;parser;constructor(e){this.options=e||Ve}space(e){return""}code({text:e,lang:t,escaped:n}){let s=(t||"").match(se.notSpaceStart)?.[0],r=e.replace(se.endingNewline,"")+`
41
+ `;return s?'<pre><code class="language-'+ye(s)+'">'+(n?r:ye(r,!0))+`</code></pre>
42
+ `:"<pre><code>"+(n?r:ye(r,!0))+`</code></pre>
43
+ `}blockquote({tokens:e}){return`<blockquote>
44
+ ${this.parser.parse(e)}</blockquote>
45
+ `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
46
+ `}hr(e){return`<hr>
47
+ `}list(e){let{ordered:t,start:n}=e,s="";for(let a=0;a<e.items.length;a++){let l=e.items[a];s+=this.listitem(l)}let r=t?"ol":"ul",o=t&&n!==1?' start="'+n+'"':"";return"<"+r+o+`>
48
+ `+s+"</"+r+`>
49
+ `}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
50
+ `}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
51
+ `}table(e){let t="",n="";for(let r=0;r<e.header.length;r++)n+=this.tablecell(e.header[r]);t+=this.tablerow({text:n});let s="";for(let r=0;r<e.rows.length;r++){let o=e.rows[r];n="";for(let a=0;a<o.length;a++)n+=this.tablecell(o[a]);s+=this.tablerow({text:n})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
52
52
  <thead>
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=r1($);if(W===null)return q;$=W;let X='<a href="'+$+'"';return J&&(X+=' title="'+O$(J)+'"'),X+=">"+q+"</a>",X}image({href:$,title:J,text:Q,tokens:q}){q&&(Q=this.parser.parseInline(q,this.parser.textRenderer));let W=r1($);if(W===null)return O$(Q);$=W;let X=`<img src="${$}" alt="${O$(Q)}"`;return J&&(X+=` title="${O$(J)}"`),X+=">",X}text($){return"tokens"in $&&$.tokens?this.parser.parseInline($.tokens):("escaped"in $)&&$.escaped?$.text:O$($.text)}},F1=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 $}},G$=class ${options;renderer;textRenderer;constructor(J){this.options=J||p$,this.options.renderer=this.options.renderer||new y0,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new F1}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 Y=W,G=this.options.extensions.renderers[Y.type].call({parser:this},Y);if(G!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(Y.type)){Q+=G||"";continue}}let X=W;switch(X.type){case"space":{Q+=this.renderer.space(X);break}case"hr":{Q+=this.renderer.hr(X);break}case"heading":{Q+=this.renderer.heading(X);break}case"code":{Q+=this.renderer.code(X);break}case"table":{Q+=this.renderer.table(X);break}case"blockquote":{Q+=this.renderer.blockquote(X);break}case"list":{Q+=this.renderer.list(X);break}case"checkbox":{Q+=this.renderer.checkbox(X);break}case"html":{Q+=this.renderer.html(X);break}case"def":{Q+=this.renderer.def(X);break}case"paragraph":{Q+=this.renderer.paragraph(X);break}case"text":{Q+=this.renderer.text(X);break}default:{let Y='Token with "'+X.type+'" type was not found.';if(this.options.silent)return console.error(Y),"";throw Error(Y)}}}return Q}parseInline(J,Q=this.renderer){this.renderer.parser=this;let q="";for(let W=0;W<J.length;W++){let X=J[W];if(this.options.extensions?.renderers?.[X.type]){let G=this.options.extensions.renderers[X.type].call({parser:this},X);if(G!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(X.type)){q+=G||"";continue}}let Y=X;switch(Y.type){case"escape":{q+=Q.text(Y);break}case"html":{q+=Q.html(Y);break}case"link":{q+=Q.link(Y);break}case"image":{q+=Q.image(Y);break}case"checkbox":{q+=Q.checkbox(Y);break}case"strong":{q+=Q.strong(Y);break}case"em":{q+=Q.em(Y);break}case"codespan":{q+=Q.codespan(Y);break}case"br":{q+=Q.br(Y);break}case"del":{q+=Q.del(Y);break}case"text":{q+=Q.text(Y);break}default:{let G='Token with "'+Y.type+'" type was not found.';if(this.options.silent)return console.error(G),"";throw Error(G)}}}return q}},z0=class{options;block;constructor($){this.options=$||p$}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 $?H$.lex:H$.lexInline}provideParser($=this.block){return $?G$.parse:G$.parseInline}},J3=class{defaults=_1();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=G$;Renderer=y0;TextRenderer=F1;Lexer=H$;Tokenizer=Z0;Hooks=z0;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 X of W.header)Q=Q.concat(this.walkTokens(X.tokens,J));for(let X of W.rows)for(let Y of X)Q=Q.concat(this.walkTokens(Y.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((X)=>{let Y=W[X].flat(1/0);Q=Q.concat(this.walkTokens(Y,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 X=J.renderers[W.name];X?J.renderers[W.name]=function(...Y){let G=W.renderer.apply(this,Y);return G===!1&&(G=X.apply(this,Y)),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 X=J[W.level];X?X.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 y0(this.defaults);for(let X in Q.renderer){if(!(X in W))throw Error(`renderer '${X}' does not exist`);if(["options","parser"].includes(X))continue;let Y=X,G=Q.renderer[Y],H=W[Y];W[Y]=(...B)=>{let _=G.apply(W,B);return _===!1&&(_=H.apply(W,B)),_||""}}q.renderer=W}if(Q.tokenizer){let W=this.defaults.tokenizer||new Z0(this.defaults);for(let X in Q.tokenizer){if(!(X in W))throw Error(`tokenizer '${X}' does not exist`);if(["options","rules","lexer"].includes(X))continue;let Y=X,G=Q.tokenizer[Y],H=W[Y];W[Y]=(...B)=>{let _=G.apply(W,B);return _===!1&&(_=H.apply(W,B)),_}}q.tokenizer=W}if(Q.hooks){let W=this.defaults.hooks||new z0;for(let X in Q.hooks){if(!(X in W))throw Error(`hook '${X}' does not exist`);if(["options","block"].includes(X))continue;let Y=X,G=Q.hooks[Y],H=W[Y];z0.passThroughHooks.has(X)?W[Y]=(B)=>{if(this.defaults.async&&z0.passThroughHooksRespectAsync.has(X))return(async()=>{let N=await G.call(W,B);return H.call(W,N)})();let _=G.call(W,B);return H.call(W,_)}:W[Y]=(...B)=>{if(this.defaults.async)return(async()=>{let N=await G.apply(W,B);return N===!1&&(N=await H.apply(W,B)),N})();let _=G.apply(W,B);return _===!1&&(_=H.apply(W,B)),_}}q.hooks=W}if(Q.walkTokens){let W=this.defaults.walkTokens,X=Q.walkTokens;q.walkTokens=function(Y){let G=[];return G.push(X.call(this,Y)),W&&(G=G.concat(W.call(this,Y))),G}}this.defaults={...this.defaults,...q}}),this}setOptions($){return this.defaults={...this.defaults,...$},this}lexer($,J){return H$.lex($,J??this.defaults)}parser($,J){return G$.parse($,J??this.defaults)}parseMarkdown($){return(J,Q)=>{let q={...Q},W={...this.defaults,...q},X=this.onError(!!W.silent,!!W.async);if(this.defaults.async===!0&&q.async===!1)return X(Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof J>"u"||J===null)return X(Error("marked(): input parameter is undefined or null"));if(typeof J!="string")return X(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 Y=W.hooks?await W.hooks.preprocess(J):J,G=await(W.hooks?await W.hooks.provideLexer($):$?H$.lex:H$.lexInline)(Y,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($):$?G$.parse:G$.parseInline)(H,W);return W.hooks?await W.hooks.postprocess(B):B})().catch(X);try{W.hooks&&(J=W.hooks.preprocess(J));let Y=(W.hooks?W.hooks.provideLexer($):$?H$.lex:H$.lexInline)(J,W);W.hooks&&(Y=W.hooks.processAllTokens(Y)),W.walkTokens&&this.walkTokens(Y,W.walkTokens);let G=(W.hooks?W.hooks.provideParser($):$?G$.parse:G$.parseInline)(Y,W);return W.hooks&&(G=W.hooks.postprocess(G)),G}catch(Y){return X(Y)}}}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}}},u$=new J3;function E($,J){return u$.parse($,J)}E.options=E.setOptions=function($){return u$.setOptions($),E.defaults=u$.defaults,a1(E.defaults),E};E.getDefaults=_1;E.defaults=p$;E.use=function(...$){return u$.use(...$),E.defaults=u$.defaults,a1(E.defaults),E};E.walkTokens=function($,J){return u$.walkTokens($,J)};E.parseInline=u$.parseInline;E.Parser=G$;E.parser=G$.parse;E.Renderer=y0;E.TextRenderer=F1;E.Lexer=H$;E.lexer=H$.lex;E.Tokenizer=Z0;E.Hooks=z0;E.parse=E;var{options:Q8,setOptions:W8,use:q8,walkTokens:X8,parseInline:Y8}=E;var H8=G$.parse,G8=H$.lex;import Y2 from"react";import{jsxDEV as z1}from"react/jsx-dev-runtime";E.setOptions({gfm:!0,breaks:!1});var Q3=new Set(["a","abbr","b","br","code","del","em","i","kbd","mark","q","s","small","span","strong","sub","sup","time","u"]),W3=new Set(["Priority"]);function q3($){if(typeof $==="string"||typeof $==="number")return!0;if(!Y2.isValidElement($))return!1;if(typeof $!=="object"||$===null||!("type"in $))return!1;let J=$.type;if(typeof J==="string")return Q3.has(J);if(typeof J==="function"){let Q="displayName"in J&&typeof J.displayName==="string"?J.displayName:J.name;return Q?W3.has(Q):!1}return!1}function X3($,J){let Q=$.trim();if(!Q)return null;let q=E.parse(Q,{async:!1});return z1("div",{className:"prose-canvas","data-md":"markdown","data-md-source":Q,dangerouslySetInnerHTML:{__html:q}},J,!1,void 0,this)}function Y3($,J){return z1("div",{className:"prose-canvas",children:$.map((Q,q)=>{if(typeof Q==="string"||typeof Q==="number"){let W=E.parseInline(String(Q),{async:!1});return z1("span",{dangerouslySetInnerHTML:{__html:W}},q,!1,void 0,this)}return Q})},J,!1,void 0,this)}function C$($){let J=Y2.Children.toArray($);if(J.length===0)return null;let Q=[],q=[],W=0,X=()=>{if(q.length===0)return;if(q.some((G)=>typeof G!=="string"&&typeof G!=="number"))Q.push(Y3(q,`md-${W++}`));else{let G=X3(q.join(""),`md-${W++}`);if(G)Q.push(G)}q=[]};for(let Y of J)if(q3(Y))q.push(Y);else X(),Q.push(Y);return X(),Q}import{jsxDEV as A1}from"react/jsx-dev-runtime";var H3={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 G3({type:$="info",children:J}){let Q=H3[$];return A1("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:[A1("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),A1("div",{className:"text-body text-text-secondary leading-relaxed",children:C$(J)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as a$}from"react/jsx-dev-runtime";function B3({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 Z2,useResponseRegistration as y2}from"#canvas/runtime";import{useEffect as m2,useMemo as x2,useRef as u2,useState as p2}from"react";import{AnnotationCtx as GQ,AnnotationHostContext as BQ,SessionContext as _Q,useAnnotationHost as MQ,useAnnotations as UQ}from"@fabrika/annotations/runtime";function S1($,J){let Q=[],q=_3($);for(let W of q){let X=document.createRange();if(X.selectNodeContents(W),W===$.startContainer)X.setStart(W,$.startOffset);if(W===$.endContainer)X.setEnd(W,$.endOffset);let Y=X.toString();if(!Y||!Y.trim())continue;let G=document.createElement("mark");G.setAttribute("data-annotation-id",J);try{X.surroundContents(G)}catch{let H=X.extractContents();G.appendChild(H),X.insertNode(G)}Q.push(G)}return Q}function f1($){let J=$.parentElement;if(J?.classList.contains("select-none"))return!1;if(J?.closest("[data-annotation-id]"))return!1;return!0}function _3($){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(!f1(W))continue;if($.intersectsNode(W))J.push(W)}return J}function R1($,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:X}=M3($),Y=[],G=0;while(!0){let w=W.indexOf(q,G);if(w===-1)break;Y.push(w),G=w+1}let[H]=Y;if(H===void 0)continue;let B=H;if(Y.length>1&&Q.context){let w=-1;for(let L of Y){let A=0;if(Q.context.before){let j=W.slice(Math.max(0,L-80),L);if(j.includes(Q.context.before))A+=2;else if(Q.context.before.length>10&&j.includes(Q.context.before.slice(-10)))A+=1}if(Q.context.after){let j=W.slice(L+q.length,L+q.length+80);if(j.includes(Q.context.after))A+=2;else if(Q.context.after.length>10&&j.includes(Q.context.after.slice(0,10)))A+=1}if(A>w)w=A,B=L}}let _=B,N=B+q.length,F=H2(X,_),z=H2(X,N);if(!F||!z)continue;try{let w=document.createRange();w.setStart(F.node,F.offset),w.setEnd(z.node,z.offset),S1(w,Q.id)}catch{}}}function M3($){let J=[],Q="",q=document.createTreeWalker($,NodeFilter.SHOW_TEXT),W;while(W=q.nextNode()){if(!f1(W))continue;J.push({node:W,start:Q.length}),Q+=W.textContent||""}return{fullText:Q,textNodes:J}}function H2($,J){for(let Q=$.length-1;Q>=0;Q--){let q=$[Q];if(!q||q.start>J)continue;let W=J-q.start,X=q.node.textContent?.length??0;if(W<=X)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 G2($){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 u0($,J,Q){return{selector:$,snippet:(q)=>{let W=q.getAttribute(Q);return W?`${J} ${W}`:null}}}var b1=[u0("[data-md='item']","[Item]","data-md-label"),u0("[data-md='section']","[Section]","data-md-title"),u0("[data-md='checklist-item']","[Checklist]","data-md-label"),u0("[data-md='image']","[Image]","data-md-src"),{selector:"[data-md='callout']",snippet:($)=>{return`[Callout:${$.getAttribute("data-md-type")||"info"}] ${G2($).slice(0,60)||"Callout"}`}},{selector:"[data-md='note']",snippet:($)=>`[Note] ${G2($).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}}],U3=["[data-md='choice-option']","[data-md='multichoice-option']","[data-md='userinput']","[data-md='rangeinput']"],j1=b1.map(($)=>$.selector).join(", "),B2=[...b1.map(($)=>$.selector),...U3].join(", ");function V1($){for(let J of b1)if($.matches(J.selector))return J.snippet($);return null}var v1={kind:"block",parse:($)=>$.startsWith("[")?{snippet:$}:null,format:($)=>$.snippet,find:($,J)=>{for(let Q of J.querySelectorAll(j1)){if(!(Q instanceof HTMLElement))continue;if(V1(Q)===$.snippet)return Q}return null}};var w3=/^\[Region:(rect|ellipse)\] ([\s\S]+) @(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*)$/;function N3($){if($==="rect")return"rect";if($==="ellipse")return"ellipse";return null}function p0($){if($===void 0)return null;let J=Number($);if(!Number.isInteger(J)||J<0||J>1e4)return null;return J}function _2($){return{left:`${$.x/100}%`,top:`${$.y/100}%`,width:`${$.w/100}%`,height:`${$.h/100}%`}}function l0($){return`${($/100).toFixed(1).replace(/\.0$/,"")}%`}function C1($){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 P1($,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 M2($,J){let Q=_2(J);$.style.left=Q.left,$.style.top=Q.top,$.style.width=Q.width,$.style.height=Q.height}function D1($,J,Q){let q=document.createElement("div");return q.className="ann-region",q.setAttribute("data-annotation-id",Q),q.setAttribute("data-annotation-region",J),M2(q,$),q}var c0={kind:"region",parse:($)=>{let J=w3.exec($);if(!J)return null;let Q=N3(J[1]),q=J[2],W=p0(J[3]),X=p0(J[4]),Y=p0(J[5]),G=p0(J[6]);if(Q===null||q===void 0)return null;if(W===null||X===null||Y===null||G===null)return null;if(Y<1||G<1)return null;return{src:q,shape:Q,x:W,y:X,w:Y,h:G}},format:($)=>`[Region:${$.shape}] ${$.src} @${$.x},${$.y},${$.w},${$.h}`,find:($,J)=>P1($.src,J),restore:($,J,Q)=>{if(J.querySelector(`[data-annotation-id="${Q.id}"]`))return;let q=P1($.src,J);if(!q)return;q.appendChild(D1($,$.shape,Q.id))},describe:C1};var k1={kind:"text",parse:($)=>$?{text:$}:null,format:($)=>$.text,find:()=>null,restore:($,J,Q)=>{R1(J,[Q])}};var K3=[S0(c0),S0(v1),S0(k1)];import{AnnotationCtx as A9,SessionContext as S9,useAnnotationHost as f9}from"@fabrika/annotations/runtime";import{useEffect as j9,useRef as V9,useState as v9}from"react";var M={};N4(M,{void:()=>e3,util:()=>D,unknown:()=>s3,union:()=>W5,undefined:()=>o3,tuple:()=>Y5,transformer:()=>L5,symbol:()=>r3,string:()=>A2,strictObject:()=>Q5,setErrorMap:()=>F3,set:()=>B5,record:()=>H5,quotelessJson:()=>L3,promise:()=>K5,preprocess:()=>z5,pipeline:()=>A5,ostring:()=>S5,optional:()=>O5,onumber:()=>f5,oboolean:()=>R5,objectUtil:()=>T1,object:()=>J5,number:()=>S2,nullable:()=>F5,null:()=>n3,never:()=>t3,nativeEnum:()=>N5,nan:()=>c3,map:()=>G5,makeIssue:()=>f0,literal:()=>U5,lazy:()=>M5,late:()=>p3,isValid:()=>D$,isDirty:()=>i0,isAsync:()=>t$,isAborted:()=>d0,intersection:()=>X5,instanceof:()=>l3,getParsedType:()=>F$,getErrorMap:()=>s$,function:()=>_5,enum:()=>w5,effect:()=>L5,discriminatedUnion:()=>q5,defaultErrorMap:()=>R$,datetimeRegex:()=>O2,date:()=>i3,custom:()=>z2,coerce:()=>b5,boolean:()=>f2,bigint:()=>d3,array:()=>$5,any:()=>a3,addIssueToContext:()=>O,ZodVoid:()=>b0,ZodUnknown:()=>k$,ZodUnion:()=>q0,ZodUndefined:()=>Q0,ZodType:()=>C,ZodTuple:()=>A$,ZodTransformer:()=>w$,ZodSymbol:()=>R0,ZodString:()=>B$,ZodSet:()=>i$,ZodSchema:()=>C,ZodRecord:()=>j0,ZodReadonly:()=>M0,ZodPromise:()=>r$,ZodPipeline:()=>P0,ZodParsedType:()=>K,ZodOptional:()=>M$,ZodObject:()=>m,ZodNumber:()=>T$,ZodNullable:()=>j$,ZodNull:()=>W0,ZodNever:()=>z$,ZodNativeEnum:()=>G0,ZodNaN:()=>v0,ZodMap:()=>V0,ZodLiteral:()=>H0,ZodLazy:()=>Y0,ZodIssueCode:()=>U,ZodIntersection:()=>X0,ZodFunction:()=>$0,ZodFirstPartyTypeKind:()=>b,ZodError:()=>Q$,ZodEnum:()=>I$,ZodEffects:()=>w$,ZodDiscriminatedUnion:()=>r0,ZodDefault:()=>B0,ZodDate:()=>c$,ZodCatch:()=>_0,ZodBranded:()=>o0,ZodBoolean:()=>J0,ZodBigInt:()=>E$,ZodArray:()=>_$,ZodAny:()=>d$,Schema:()=>C,ParseStatus:()=>o,OK:()=>a,NEVER:()=>j5,INVALID:()=>R,EMPTY_PATH:()=>z3,DIRTY:()=>l$,BRAND:()=>u3});var D;(function($){$.assertEqual=(W)=>{};function J(W){}$.assertIs=J;function Q(W){throw Error()}$.assertNever=Q,$.arrayToEnum=(W)=>{let X={};for(let Y of W)X[Y]=Y;return X},$.getValidEnumValues=(W)=>{let X=$.objectKeys(W).filter((G)=>typeof W[W[G]]!=="number"),Y={};for(let G of X)Y[G]=W[G];return $.objectValues(Y)},$.objectValues=(W)=>{return $.objectKeys(W).map(function(X){return W[X]})},$.objectKeys=typeof Object.keys==="function"?(W)=>Object.keys(W):(W)=>{let X=[];for(let Y in W)if(Object.prototype.hasOwnProperty.call(W,Y))X.push(Y);return X},$.find=(W,X)=>{for(let Y of W)if(X(Y))return Y;return},$.isInteger=typeof Number.isInteger==="function"?(W)=>Number.isInteger(W):(W)=>typeof W==="number"&&Number.isFinite(W)&&Math.floor(W)===W;function q(W,X=" | "){return W.map((Y)=>typeof Y==="string"?`'${Y}'`:Y).join(X)}$.joinValues=q,$.jsonStringifyReplacer=(W,X)=>{if(typeof X==="bigint")return X.toString();return X}})(D||(D={}));var T1;(function($){$.mergeShapes=(J,Q)=>{return{...J,...Q}}})(T1||(T1={}));var K=D.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),F$=($)=>{switch(typeof $){case"undefined":return K.undefined;case"string":return K.string;case"number":return Number.isNaN($)?K.nan:K.number;case"boolean":return K.boolean;case"function":return K.function;case"bigint":return K.bigint;case"symbol":return K.symbol;case"object":if(Array.isArray($))return K.array;if($===null)return K.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return K.promise;if(typeof Map<"u"&&$ instanceof Map)return K.map;if(typeof Set<"u"&&$ instanceof Set)return K.set;if(typeof Date<"u"&&$ instanceof Date)return K.date;return K.object;default:return K.unknown}};var U=D.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"]),L3=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class Q$ 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 X of W.issues)if(X.code==="invalid_union")X.unionErrors.map(q);else if(X.code==="invalid_return_type")q(X.returnTypeError);else if(X.code==="invalid_arguments")q(X.argumentsError);else if(X.path.length===0)Q._errors.push(J(X));else{let Y=Q,G=0;while(G<X.path.length){let H=X.path[G];if(G!==X.path.length-1)Y[H]=Y[H]||{_errors:[]};else Y[H]=Y[H]||{_errors:[]},Y[H]._errors.push(J(X));Y=Y[H],G++}}};return q(this),Q}static assert($){if(!($ instanceof Q$))throw Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,D.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()}}Q$.create=($)=>{return new Q$($)};var O3=($,J)=>{let Q;switch($.code){case U.invalid_type:if($.received===K.undefined)Q="Required";else Q=`Expected ${$.expected}, received ${$.received}`;break;case U.invalid_literal:Q=`Invalid literal value, expected ${JSON.stringify($.expected,D.jsonStringifyReplacer)}`;break;case U.unrecognized_keys:Q=`Unrecognized key(s) in object: ${D.joinValues($.keys,", ")}`;break;case U.invalid_union:Q="Invalid input";break;case U.invalid_union_discriminator:Q=`Invalid discriminator value. Expected ${D.joinValues($.options)}`;break;case U.invalid_enum_value:Q=`Invalid enum value. Expected ${D.joinValues($.options)}, received '${$.received}'`;break;case U.invalid_arguments:Q="Invalid function arguments";break;case U.invalid_return_type:Q="Invalid function return type";break;case U.invalid_date:Q="Invalid date";break;case U.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 D.assertNever($.validation);else if($.validation!=="regex")Q=`Invalid ${$.validation}`;else Q="Invalid";break;case U.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 U.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 U.custom:Q="Invalid input";break;case U.invalid_intersection_types:Q="Intersection results could not be merged";break;case U.not_multiple_of:Q=`Number must be a multiple of ${$.multipleOf}`;break;case U.not_finite:Q="Number must be finite";break;default:Q=J.defaultError,D.assertNever($)}return{message:Q}},R$=O3;var U2=R$;function F3($){U2=$}function s$(){return U2}var f0=($)=>{let{data:J,path:Q,errorMaps:q,issueData:W}=$,X=[...Q,...W.path||[]],Y={...W,path:X};if(W.message!==void 0)return{...W,path:X,message:W.message};let G="",H=q.filter((B)=>!!B).slice().reverse();for(let B of H)G=B(Y,{data:J,defaultError:G}).message;return{...W,path:X,message:G}},z3=[];function O($,J){let Q=s$(),q=f0({issueData:J,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,Q,Q===R$?void 0:R$].filter((W)=>!!W)});$.common.issues.push(q)}class o{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 R;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,X=await q.value;Q.push({key:W,value:X})}return o.mergeObjectSync($,Q)}static mergeObjectSync($,J){let Q={};for(let q of J){let{key:W,value:X}=q;if(W.status==="aborted")return R;if(X.status==="aborted")return R;if(W.status==="dirty")$.dirty();if(X.status==="dirty")$.dirty();if(W.value!=="__proto__"&&(typeof X.value<"u"||q.alwaysSet))Q[W.value]=X.value}return{status:$.value,value:Q}}}var R=Object.freeze({status:"aborted"}),l$=($)=>({status:"dirty",value:$}),a=($)=>({status:"valid",value:$}),d0=($)=>$.status==="aborted",i0=($)=>$.status==="dirty",D$=($)=>$.status==="valid",t$=($)=>typeof Promise<"u"&&$ instanceof Promise;var f;(function($){$.errToObj=(J)=>typeof J==="string"?{message:J}:J||{},$.toString=(J)=>typeof J==="string"?J:J?.message})(f||(f={}));class U${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 w2=($,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 Q$($.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:(Y,G)=>{let{message:H}=$;if(Y.code==="invalid_enum_value")return{message:H??G.defaultError};if(typeof G.data>"u")return{message:H??q??G.defaultError};if(Y.code!=="invalid_type")return{message:G.defaultError};return{message:H??Q??G.defaultError}},description:W}}class C{get description(){return this._def.description}_getType($){return F$($.data)}_getOrReturnCtx($,J){return J||{common:$.parent.common,data:$.data,parsedType:F$($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new o,ctx:{common:$.parent.common,data:$.data,parsedType:F$($.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:F$($)},q=this._parseSync({data:$,path:Q.path,parent:Q});return w2(Q,q)}"~validate"($){let J={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:F$($)};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:F$($)},q=this._parse({data:$,path:Q.path,parent:Q}),W=await(t$(q)?q:Promise.resolve(q));return w2(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 X=$(q),Y=()=>W.addIssue({code:U.custom,...Q(q)});if(typeof Promise<"u"&&X instanceof Promise)return X.then((G)=>{if(!G)return Y(),!1;else return!0});if(!X)return Y(),!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 w$({schema:this,typeName:b.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 M$.create(this,this._def)}nullable(){return j$.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return _$.create(this)}promise(){return r$.create(this,this._def)}or($){return q0.create([this,$],this._def)}and($){return X0.create(this,$,this._def)}transform($){return new w$({...V(this._def),schema:this,typeName:b.ZodEffects,effect:{type:"transform",transform:$}})}default($){let J=typeof $==="function"?$:()=>$;return new B0({...V(this._def),innerType:this,defaultValue:J,typeName:b.ZodDefault})}brand(){return new o0({typeName:b.ZodBranded,type:this,...V(this._def)})}catch($){let J=typeof $==="function"?$:()=>$;return new _0({...V(this._def),innerType:this,catchValue:J,typeName:b.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return P0.create(this,$)}readonly(){return M0.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var A3=/^c[^\s-]{8,}$/i,S3=/^[0-9a-z]+$/,f3=/^[0-9A-HJKMNP-TV-Z]{26}$/i,R3=/^[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,b3=/^[a-z0-9_-]{21}$/i,j3=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,V3=/^[-+]?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)?)??$/,v3=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,P3="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",E1,C3=/^(?:(?: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])$/,D3=/^(?:(?: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])$/,k3=/^(([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]))$/,T3=/^(([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])$/,E3=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,I3=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,K2="((\\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])))",g3=new RegExp(`^${K2}$`);function L2($){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 h3($){return new RegExp(`^${L2($)}$`)}function O2($){let J=`${K2}T${L2($)}`,Q=[];if(Q.push($.local?"Z?":"Z"),$.offset)Q.push("([+-]\\d{2}:?\\d{2})");return J=`${J}(${Q.join("|")})`,new RegExp(`^${J}$`)}function Z3($,J){if((J==="v4"||!J)&&C3.test($))return!0;if((J==="v6"||!J)&&k3.test($))return!0;return!1}function y3($,J){if(!j3.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 m3($,J){if((J==="v4"||!J)&&D3.test($))return!0;if((J==="v6"||!J)&&T3.test($))return!0;return!1}class B$ extends C{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==K.string){let W=this._getOrReturnCtx($);return O(W,{code:U.invalid_type,expected:K.string,received:W.parsedType}),R}let Q=new o,q=void 0;for(let W of this._def.checks)if(W.kind==="min"){if($.data.length<W.value)q=this._getOrReturnCtx($,q),O(q,{code:U.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),O(q,{code:U.too_big,maximum:W.value,type:"string",inclusive:!0,exact:!1,message:W.message}),Q.dirty()}else if(W.kind==="length"){let X=$.data.length>W.value,Y=$.data.length<W.value;if(X||Y){if(q=this._getOrReturnCtx($,q),X)O(q,{code:U.too_big,maximum:W.value,type:"string",inclusive:!0,exact:!0,message:W.message});else if(Y)O(q,{code:U.too_small,minimum:W.value,type:"string",inclusive:!0,exact:!0,message:W.message});Q.dirty()}}else if(W.kind==="email"){if(!v3.test($.data))q=this._getOrReturnCtx($,q),O(q,{validation:"email",code:U.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="emoji"){if(!E1)E1=new RegExp(P3,"u");if(!E1.test($.data))q=this._getOrReturnCtx($,q),O(q,{validation:"emoji",code:U.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="uuid"){if(!R3.test($.data))q=this._getOrReturnCtx($,q),O(q,{validation:"uuid",code:U.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="nanoid"){if(!b3.test($.data))q=this._getOrReturnCtx($,q),O(q,{validation:"nanoid",code:U.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="cuid"){if(!A3.test($.data))q=this._getOrReturnCtx($,q),O(q,{validation:"cuid",code:U.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="cuid2"){if(!S3.test($.data))q=this._getOrReturnCtx($,q),O(q,{validation:"cuid2",code:U.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="ulid"){if(!f3.test($.data))q=this._getOrReturnCtx($,q),O(q,{validation:"ulid",code:U.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="url")try{new URL($.data)}catch{q=this._getOrReturnCtx($,q),O(q,{validation:"url",code:U.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),O(q,{validation:"regex",code:U.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),O(q,{code:U.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),O(q,{code:U.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),O(q,{code:U.invalid_string,validation:{endsWith:W.value},message:W.message}),Q.dirty()}else if(W.kind==="datetime"){if(!O2(W).test($.data))q=this._getOrReturnCtx($,q),O(q,{code:U.invalid_string,validation:"datetime",message:W.message}),Q.dirty()}else if(W.kind==="date"){if(!g3.test($.data))q=this._getOrReturnCtx($,q),O(q,{code:U.invalid_string,validation:"date",message:W.message}),Q.dirty()}else if(W.kind==="time"){if(!h3(W).test($.data))q=this._getOrReturnCtx($,q),O(q,{code:U.invalid_string,validation:"time",message:W.message}),Q.dirty()}else if(W.kind==="duration"){if(!V3.test($.data))q=this._getOrReturnCtx($,q),O(q,{validation:"duration",code:U.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="ip"){if(!Z3($.data,W.version))q=this._getOrReturnCtx($,q),O(q,{validation:"ip",code:U.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="jwt"){if(!y3($.data,W.alg))q=this._getOrReturnCtx($,q),O(q,{validation:"jwt",code:U.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="cidr"){if(!m3($.data,W.version))q=this._getOrReturnCtx($,q),O(q,{validation:"cidr",code:U.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="base64"){if(!E3.test($.data))q=this._getOrReturnCtx($,q),O(q,{validation:"base64",code:U.invalid_string,message:W.message}),Q.dirty()}else if(W.kind==="base64url"){if(!I3.test($.data))q=this._getOrReturnCtx($,q),O(q,{validation:"base64url",code:U.invalid_string,message:W.message}),Q.dirty()}else D.assertNever(W);return{status:Q.value,value:$.data}}_regex($,J,Q){return this.refinement((q)=>$.test(q),{validation:J,code:U.invalid_string,...f.errToObj(Q)})}_addCheck($){return new B$({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...f.errToObj($)})}url($){return this._addCheck({kind:"url",...f.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...f.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...f.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...f.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...f.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...f.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...f.errToObj($)})}base64($){return this._addCheck({kind:"base64",...f.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...f.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...f.errToObj($)})}ip($){return this._addCheck({kind:"ip",...f.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...f.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,...f.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,...f.errToObj($?.message)})}duration($){return this._addCheck({kind:"duration",...f.errToObj($)})}regex($,J){return this._addCheck({kind:"regex",regex:$,...f.errToObj(J)})}includes($,J){return this._addCheck({kind:"includes",value:$,position:J?.position,...f.errToObj(J?.message)})}startsWith($,J){return this._addCheck({kind:"startsWith",value:$,...f.errToObj(J)})}endsWith($,J){return this._addCheck({kind:"endsWith",value:$,...f.errToObj(J)})}min($,J){return this._addCheck({kind:"min",value:$,...f.errToObj(J)})}max($,J){return this._addCheck({kind:"max",value:$,...f.errToObj(J)})}length($,J){return this._addCheck({kind:"length",value:$,...f.errToObj(J)})}nonempty($){return this.min(1,f.errToObj($))}trim(){return new B$({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new B$({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new B$({...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 $}}B$.create=($)=>{return new B$({checks:[],typeName:b.ZodString,coerce:$?.coerce??!1,...V($)})};function x3($,J){let Q=($.toString().split(".")[1]||"").length,q=(J.toString().split(".")[1]||"").length,W=Q>q?Q:q,X=Number.parseInt($.toFixed(W).replace(".","")),Y=Number.parseInt(J.toFixed(W).replace(".",""));return X%Y/10**W}class T$ extends C{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($)!==K.number){let W=this._getOrReturnCtx($);return O(W,{code:U.invalid_type,expected:K.number,received:W.parsedType}),R}let Q=void 0,q=new o;for(let W of this._def.checks)if(W.kind==="int"){if(!D.isInteger($.data))Q=this._getOrReturnCtx($,Q),O(Q,{code:U.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),O(Q,{code:U.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),O(Q,{code:U.too_big,maximum:W.value,type:"number",inclusive:W.inclusive,exact:!1,message:W.message}),q.dirty()}else if(W.kind==="multipleOf"){if(x3($.data,W.value)!==0)Q=this._getOrReturnCtx($,Q),O(Q,{code:U.not_multiple_of,multipleOf:W.value,message:W.message}),q.dirty()}else if(W.kind==="finite"){if(!Number.isFinite($.data))Q=this._getOrReturnCtx($,Q),O(Q,{code:U.not_finite,message:W.message}),q.dirty()}else D.assertNever(W);return{status:q.value,value:$.data}}gte($,J){return this.setLimit("min",$,!0,f.toString(J))}gt($,J){return this.setLimit("min",$,!1,f.toString(J))}lte($,J){return this.setLimit("max",$,!0,f.toString(J))}lt($,J){return this.setLimit("max",$,!1,f.toString(J))}setLimit($,J,Q,q){return new T$({...this._def,checks:[...this._def.checks,{kind:$,value:J,inclusive:Q,message:f.toString(q)}]})}_addCheck($){return new T$({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:f.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:f.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:f.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:f.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:f.toString($)})}multipleOf($,J){return this._addCheck({kind:"multipleOf",value:$,message:f.toString(J)})}finite($){return this._addCheck({kind:"finite",message:f.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:f.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:f.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"&&D.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($)}}T$.create=($)=>{return new T$({checks:[],typeName:b.ZodNumber,coerce:$?.coerce||!1,...V($)})};class E$ extends C{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($)!==K.bigint)return this._getInvalidInput($);let Q=void 0,q=new o;for(let W of this._def.checks)if(W.kind==="min"){if(W.inclusive?$.data<W.value:$.data<=W.value)Q=this._getOrReturnCtx($,Q),O(Q,{code:U.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),O(Q,{code:U.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),O(Q,{code:U.not_multiple_of,multipleOf:W.value,message:W.message}),q.dirty()}else D.assertNever(W);return{status:q.value,value:$.data}}_getInvalidInput($){let J=this._getOrReturnCtx($);return O(J,{code:U.invalid_type,expected:K.bigint,received:J.parsedType}),R}gte($,J){return this.setLimit("min",$,!0,f.toString(J))}gt($,J){return this.setLimit("min",$,!1,f.toString(J))}lte($,J){return this.setLimit("max",$,!0,f.toString(J))}lt($,J){return this.setLimit("max",$,!1,f.toString(J))}setLimit($,J,Q,q){return new E$({...this._def,checks:[...this._def.checks,{kind:$,value:J,inclusive:Q,message:f.toString(q)}]})}_addCheck($){return new E$({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:f.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:f.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:f.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:f.toString($)})}multipleOf($,J){return this._addCheck({kind:"multipleOf",value:$,message:f.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:b.ZodBigInt,coerce:$?.coerce??!1,...V($)})};class J0 extends C{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==K.boolean){let Q=this._getOrReturnCtx($);return O(Q,{code:U.invalid_type,expected:K.boolean,received:Q.parsedType}),R}return a($.data)}}J0.create=($)=>{return new J0({typeName:b.ZodBoolean,coerce:$?.coerce||!1,...V($)})};class c$ extends C{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==K.date){let W=this._getOrReturnCtx($);return O(W,{code:U.invalid_type,expected:K.date,received:W.parsedType}),R}if(Number.isNaN($.data.getTime())){let W=this._getOrReturnCtx($);return O(W,{code:U.invalid_date}),R}let Q=new o,q=void 0;for(let W of this._def.checks)if(W.kind==="min"){if($.data.getTime()<W.value)q=this._getOrReturnCtx($,q),O(q,{code:U.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),O(q,{code:U.too_big,message:W.message,inclusive:!0,exact:!1,maximum:W.value,type:"date"}),Q.dirty()}else D.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:f.toString(J)})}max($,J){return this._addCheck({kind:"max",value:$.getTime(),message:f.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:b.ZodDate,...V($)})};class R0 extends C{_parse($){if(this._getType($)!==K.symbol){let Q=this._getOrReturnCtx($);return O(Q,{code:U.invalid_type,expected:K.symbol,received:Q.parsedType}),R}return a($.data)}}R0.create=($)=>{return new R0({typeName:b.ZodSymbol,...V($)})};class Q0 extends C{_parse($){if(this._getType($)!==K.undefined){let Q=this._getOrReturnCtx($);return O(Q,{code:U.invalid_type,expected:K.undefined,received:Q.parsedType}),R}return a($.data)}}Q0.create=($)=>{return new Q0({typeName:b.ZodUndefined,...V($)})};class W0 extends C{_parse($){if(this._getType($)!==K.null){let Q=this._getOrReturnCtx($);return O(Q,{code:U.invalid_type,expected:K.null,received:Q.parsedType}),R}return a($.data)}}W0.create=($)=>{return new W0({typeName:b.ZodNull,...V($)})};class d$ extends C{constructor(){super(...arguments);this._any=!0}_parse($){return a($.data)}}d$.create=($)=>{return new d$({typeName:b.ZodAny,...V($)})};class k$ extends C{constructor(){super(...arguments);this._unknown=!0}_parse($){return a($.data)}}k$.create=($)=>{return new k$({typeName:b.ZodUnknown,...V($)})};class z$ extends C{_parse($){let J=this._getOrReturnCtx($);return O(J,{code:U.invalid_type,expected:K.never,received:J.parsedType}),R}}z$.create=($)=>{return new z$({typeName:b.ZodNever,...V($)})};class b0 extends C{_parse($){if(this._getType($)!==K.undefined){let Q=this._getOrReturnCtx($);return O(Q,{code:U.invalid_type,expected:K.void,received:Q.parsedType}),R}return a($.data)}}b0.create=($)=>{return new b0({typeName:b.ZodVoid,...V($)})};class _$ extends C{_parse($){let{ctx:J,status:Q}=this._processInputParams($),q=this._def;if(J.parsedType!==K.array)return O(J,{code:U.invalid_type,expected:K.array,received:J.parsedType}),R;if(q.exactLength!==null){let X=J.data.length>q.exactLength.value,Y=J.data.length<q.exactLength.value;if(X||Y)O(J,{code:X?U.too_big:U.too_small,minimum:Y?q.exactLength.value:void 0,maximum:X?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)O(J,{code:U.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)O(J,{code:U.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((X,Y)=>{return q.type._parseAsync(new U$(J,X,J.path,Y))})).then((X)=>{return o.mergeArray(Q,X)});let W=[...J.data].map((X,Y)=>{return q.type._parseSync(new U$(J,X,J.path,Y))});return o.mergeArray(Q,W)}get element(){return this._def.type}min($,J){return new _$({...this._def,minLength:{value:$,message:f.toString(J)}})}max($,J){return new _$({...this._def,maxLength:{value:$,message:f.toString(J)}})}length($,J){return new _$({...this._def,exactLength:{value:$,message:f.toString(J)}})}nonempty($){return this.min(1,$)}}_$.create=($,J)=>{return new _$({type:$,minLength:null,maxLength:null,exactLength:null,typeName:b.ZodArray,...V(J)})};function e$($){if($ instanceof m){let J={};for(let Q in $.shape){let q=$.shape[Q];J[Q]=M$.create(e$(q))}return new m({...$._def,shape:()=>J})}else if($ instanceof _$)return new _$({...$._def,type:e$($.element)});else if($ instanceof M$)return M$.create(e$($.unwrap()));else if($ instanceof j$)return j$.create(e$($.unwrap()));else if($ instanceof A$)return A$.create($.items.map((J)=>e$(J)));else return $}class m extends C{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=D.objectKeys($);return this._cached={shape:$,keys:J},this._cached}_parse($){if(this._getType($)!==K.object){let H=this._getOrReturnCtx($);return O(H,{code:U.invalid_type,expected:K.object,received:H.parsedType}),R}let{status:Q,ctx:q}=this._processInputParams($),{shape:W,keys:X}=this._getCached(),Y=[];if(!(this._def.catchall instanceof z$&&this._def.unknownKeys==="strip")){for(let H in q.data)if(!X.includes(H))Y.push(H)}let G=[];for(let H of X){let B=W[H],_=q.data[H];G.push({key:{status:"valid",value:H},value:B._parse(new U$(q,_,q.path,H)),alwaysSet:H in q.data})}if(this._def.catchall instanceof z$){let H=this._def.unknownKeys;if(H==="passthrough")for(let B of Y)G.push({key:{status:"valid",value:B},value:{status:"valid",value:q.data[B]}});else if(H==="strict"){if(Y.length>0)O(q,{code:U.unrecognized_keys,keys:Y}),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 Y){let _=q.data[B];G.push({key:{status:"valid",value:B},value:H._parse(new U$(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,N=await B.value;H.push({key:_,value:N,alwaysSet:B.alwaysSet})}return H}).then((H)=>{return o.mergeObjectSync(Q,H)});else return o.mergeObjectSync(Q,G)}get shape(){return this._def.shape()}strict($){return f.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:f.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:b.ZodObject})}setKey($,J){return this.augment({[$]:J})}catchall($){return new m({...this._def,catchall:$})}pick($){let J={};for(let Q of D.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 D.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 D.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 D.objectKeys(this.shape))if($&&!$[Q])J[Q]=this.shape[Q];else{let W=this.shape[Q];while(W instanceof M$)W=W._def.innerType;J[Q]=W}return new m({...this._def,shape:()=>J})}keyof(){return F2(D.objectKeys(this.shape))}}m.create=($,J)=>{return new m({shape:()=>$,unknownKeys:"strip",catchall:z$.create(),typeName:b.ZodObject,...V(J)})};m.strictCreate=($,J)=>{return new m({shape:()=>$,unknownKeys:"strict",catchall:z$.create(),typeName:b.ZodObject,...V(J)})};m.lazycreate=($,J)=>{return new m({shape:$,unknownKeys:"strip",catchall:z$.create(),typeName:b.ZodObject,...V(J)})};class q0 extends C{_parse($){let{ctx:J}=this._processInputParams($),Q=this._def.options;function q(W){for(let Y of W)if(Y.result.status==="valid")return Y.result;for(let Y of W)if(Y.result.status==="dirty")return J.common.issues.push(...Y.ctx.common.issues),Y.result;let X=W.map((Y)=>new Q$(Y.ctx.common.issues));return O(J,{code:U.invalid_union,unionErrors:X}),R}if(J.common.async)return Promise.all(Q.map(async(W)=>{let X={...J,common:{...J.common,issues:[]},parent:null};return{result:await W._parseAsync({data:J.data,path:J.path,parent:X}),ctx:X}})).then(q);else{let W=void 0,X=[];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)X.push(H.common.issues)}if(W)return J.common.issues.push(...W.ctx.common.issues),W.result;let Y=X.map((G)=>new Q$(G));return O(J,{code:U.invalid_union,unionErrors:Y}),R}}get options(){return this._def.options}}q0.create=($,J)=>{return new q0({options:$,typeName:b.ZodUnion,...V(J)})};var b$=($)=>{if($ instanceof Y0)return b$($.schema);else if($ instanceof w$)return b$($.innerType());else if($ instanceof H0)return[$.value];else if($ instanceof I$)return $.options;else if($ instanceof G0)return D.objectValues($.enum);else if($ instanceof B0)return b$($._def.innerType);else if($ instanceof Q0)return[void 0];else if($ instanceof W0)return[null];else if($ instanceof M$)return[void 0,...b$($.unwrap())];else if($ instanceof j$)return[null,...b$($.unwrap())];else if($ instanceof o0)return b$($.unwrap());else if($ instanceof M0)return b$($.unwrap());else if($ instanceof _0)return b$($._def.innerType);else return[]};class r0 extends C{_parse($){let{ctx:J}=this._processInputParams($);if(J.parsedType!==K.object)return O(J,{code:U.invalid_type,expected:K.object,received:J.parsedType}),R;let Q=this.discriminator,q=J.data[Q],W=this.optionsMap.get(q);if(!W)return O(J,{code:U.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[Q]}),R;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 X=b$(W.shape[$]);if(!X.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let Y of X){if(q.has(Y))throw Error(`Discriminator property ${String($)} has duplicate value ${String(Y)}`);q.set(Y,W)}}return new r0({typeName:b.ZodDiscriminatedUnion,discriminator:$,options:J,optionsMap:q,...V(Q)})}}function I1($,J){let Q=F$($),q=F$(J);if($===J)return{valid:!0,data:$};else if(Q===K.object&&q===K.object){let W=D.objectKeys(J),X=D.objectKeys($).filter((G)=>W.indexOf(G)!==-1),Y={...$,...J};for(let G of X){let H=I1($[G],J[G]);if(!H.valid)return{valid:!1};Y[G]=H.data}return{valid:!0,data:Y}}else if(Q===K.array&&q===K.array){if($.length!==J.length)return{valid:!1};let W=[];for(let X=0;X<$.length;X++){let Y=$[X],G=J[X],H=I1(Y,G);if(!H.valid)return{valid:!1};W.push(H.data)}return{valid:!0,data:W}}else if(Q===K.date&&q===K.date&&+$===+J)return{valid:!0,data:$};else return{valid:!1}}class X0 extends C{_parse($){let{status:J,ctx:Q}=this._processInputParams($),q=(W,X)=>{if(d0(W)||d0(X))return R;let Y=I1(W.value,X.value);if(!Y.valid)return O(Q,{code:U.invalid_intersection_types}),R;if(i0(W)||i0(X))J.dirty();return{status:J.value,value:Y.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,X])=>q(W,X));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}))}}X0.create=($,J,Q)=>{return new X0({left:$,right:J,typeName:b.ZodIntersection,...V(Q)})};class A$ extends C{_parse($){let{status:J,ctx:Q}=this._processInputParams($);if(Q.parsedType!==K.array)return O(Q,{code:U.invalid_type,expected:K.array,received:Q.parsedType}),R;if(Q.data.length<this._def.items.length)return O(Q,{code:U.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),R;if(!this._def.rest&&Q.data.length>this._def.items.length)O(Q,{code:U.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),J.dirty();let W=[...Q.data].map((X,Y)=>{let G=this._def.items[Y]||this._def.rest;if(!G)return null;return G._parse(new U$(Q,X,Q.path,Y))}).filter((X)=>!!X);if(Q.common.async)return Promise.all(W).then((X)=>{return o.mergeArray(J,X)});else return o.mergeArray(J,W)}get items(){return this._def.items}rest($){return new A$({...this._def,rest:$})}}A$.create=($,J)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new A$({items:$,typeName:b.ZodTuple,rest:null,...V(J)})};class j0 extends C{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:J,ctx:Q}=this._processInputParams($);if(Q.parsedType!==K.object)return O(Q,{code:U.invalid_type,expected:K.object,received:Q.parsedType}),R;let q=[],W=this._def.keyType,X=this._def.valueType;for(let Y in Q.data)q.push({key:W._parse(new U$(Q,Y,Q.path,Y)),value:X._parse(new U$(Q,Q.data[Y],Q.path,Y)),alwaysSet:Y in Q.data});if(Q.common.async)return o.mergeObjectAsync(J,q);else return o.mergeObjectSync(J,q)}get element(){return this._def.valueType}static create($,J,Q){if(J instanceof C)return new j0({keyType:$,valueType:J,typeName:b.ZodRecord,...V(Q)});return new j0({keyType:B$.create(),valueType:$,typeName:b.ZodRecord,...V(J)})}}class V0 extends C{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:J,ctx:Q}=this._processInputParams($);if(Q.parsedType!==K.map)return O(Q,{code:U.invalid_type,expected:K.map,received:Q.parsedType}),R;let q=this._def.keyType,W=this._def.valueType,X=[...Q.data.entries()].map(([Y,G],H)=>{return{key:q._parse(new U$(Q,Y,Q.path,[H,"key"])),value:W._parse(new U$(Q,G,Q.path,[H,"value"]))}});if(Q.common.async){let Y=new Map;return Promise.resolve().then(async()=>{for(let G of X){let H=await G.key,B=await G.value;if(H.status==="aborted"||B.status==="aborted")return R;if(H.status==="dirty"||B.status==="dirty")J.dirty();Y.set(H.value,B.value)}return{status:J.value,value:Y}})}else{let Y=new Map;for(let G of X){let{key:H,value:B}=G;if(H.status==="aborted"||B.status==="aborted")return R;if(H.status==="dirty"||B.status==="dirty")J.dirty();Y.set(H.value,B.value)}return{status:J.value,value:Y}}}}V0.create=($,J,Q)=>{return new V0({valueType:J,keyType:$,typeName:b.ZodMap,...V(Q)})};class i$ extends C{_parse($){let{status:J,ctx:Q}=this._processInputParams($);if(Q.parsedType!==K.set)return O(Q,{code:U.invalid_type,expected:K.set,received:Q.parsedType}),R;let q=this._def;if(q.minSize!==null){if(Q.data.size<q.minSize.value)O(Q,{code:U.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)O(Q,{code:U.too_big,maximum:q.maxSize.value,type:"set",inclusive:!0,exact:!1,message:q.maxSize.message}),J.dirty()}let W=this._def.valueType;function X(G){let H=new Set;for(let B of G){if(B.status==="aborted")return R;if(B.status==="dirty")J.dirty();H.add(B.value)}return{status:J.value,value:H}}let Y=[...Q.data.values()].map((G,H)=>W._parse(new U$(Q,G,Q.path,H)));if(Q.common.async)return Promise.all(Y).then((G)=>X(G));else return X(Y)}min($,J){return new i$({...this._def,minSize:{value:$,message:f.toString(J)}})}max($,J){return new i$({...this._def,maxSize:{value:$,message:f.toString(J)}})}size($,J){return this.min($,J).max($,J)}nonempty($){return this.min(1,$)}}i$.create=($,J)=>{return new i$({valueType:$,minSize:null,maxSize:null,typeName:b.ZodSet,...V(J)})};class $0 extends C{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:J}=this._processInputParams($);if(J.parsedType!==K.function)return O(J,{code:U.invalid_type,expected:K.function,received:J.parsedType}),R;function Q(Y,G){return f0({data:Y,path:J.path,errorMaps:[J.common.contextualErrorMap,J.schemaErrorMap,s$(),R$].filter((H)=>!!H),issueData:{code:U.invalid_arguments,argumentsError:G}})}function q(Y,G){return f0({data:Y,path:J.path,errorMaps:[J.common.contextualErrorMap,J.schemaErrorMap,s$(),R$].filter((H)=>!!H),issueData:{code:U.invalid_return_type,returnTypeError:G}})}let W={errorMap:J.common.contextualErrorMap},X=J.data;if(this._def.returns instanceof r$){let Y=this;return a(async function(...G){let H=new Q$([]),B=await Y._def.args.parseAsync(G,W).catch((F)=>{throw H.addIssue(Q(G,F)),H}),_=await Reflect.apply(X,this,B);return await Y._def.returns._def.type.parseAsync(_,W).catch((F)=>{throw H.addIssue(q(_,F)),H})})}else{let Y=this;return a(function(...G){let H=Y._def.args.safeParse(G,W);if(!H.success)throw new Q$([Q(G,H.error)]);let B=Reflect.apply(X,this,H.data),_=Y._def.returns.safeParse(B,W);if(!_.success)throw new Q$([q(B,_.error)]);return _.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new $0({...this._def,args:A$.create($).rest(k$.create())})}returns($){return new $0({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,J,Q){return new $0({args:$?$:A$.create([]).rest(k$.create()),returns:J||k$.create(),typeName:b.ZodFunction,...V(Q)})}}class Y0 extends C{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})}}Y0.create=($,J)=>{return new Y0({getter:$,typeName:b.ZodLazy,...V(J)})};class H0 extends C{_parse($){if($.data!==this._def.value){let J=this._getOrReturnCtx($);return O(J,{received:J.data,code:U.invalid_literal,expected:this._def.value}),R}return{status:"valid",value:$.data}}get value(){return this._def.value}}H0.create=($,J)=>{return new H0({value:$,typeName:b.ZodLiteral,...V(J)})};function F2($,J){return new I$({values:$,typeName:b.ZodEnum,...V(J)})}class I$ extends C{_parse($){if(typeof $.data!=="string"){let J=this._getOrReturnCtx($),Q=this._def.values;return O(J,{expected:D.joinValues(Q),received:J.parsedType,code:U.invalid_type}),R}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has($.data)){let J=this._getOrReturnCtx($),Q=this._def.values;return O(J,{received:J.data,code:U.invalid_enum_value,options:Q}),R}return a($.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 I$.create($,{...this._def,...J})}exclude($,J=this._def){return I$.create(this.options.filter((Q)=>!$.includes(Q)),{...this._def,...J})}}I$.create=F2;class G0 extends C{_parse($){let J=D.getValidEnumValues(this._def.values),Q=this._getOrReturnCtx($);if(Q.parsedType!==K.string&&Q.parsedType!==K.number){let q=D.objectValues(J);return O(Q,{expected:D.joinValues(q),received:Q.parsedType,code:U.invalid_type}),R}if(!this._cache)this._cache=new Set(D.getValidEnumValues(this._def.values));if(!this._cache.has($.data)){let q=D.objectValues(J);return O(Q,{received:Q.data,code:U.invalid_enum_value,options:q}),R}return a($.data)}get enum(){return this._def.values}}G0.create=($,J)=>{return new G0({values:$,typeName:b.ZodNativeEnum,...V(J)})};class r$ extends C{unwrap(){return this._def.type}_parse($){let{ctx:J}=this._processInputParams($);if(J.parsedType!==K.promise&&J.common.async===!1)return O(J,{code:U.invalid_type,expected:K.promise,received:J.parsedType}),R;let Q=J.parsedType===K.promise?J.data:Promise.resolve(J.data);return a(Q.then((q)=>{return this._def.type.parseAsync(q,{path:J.path,errorMap:J.common.contextualErrorMap})}))}}r$.create=($,J)=>{return new r$({type:$,typeName:b.ZodPromise,...V(J)})};class w$ extends C{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===b.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:J,ctx:Q}=this._processInputParams($),q=this._def.effect||null,W={addIssue:(X)=>{if(O(Q,X),X.fatal)J.abort();else J.dirty()},get path(){return Q.path}};if(W.addIssue=W.addIssue.bind(W),q.type==="preprocess"){let X=q.transform(Q.data,W);if(Q.common.async)return Promise.resolve(X).then(async(Y)=>{if(J.value==="aborted")return R;let G=await this._def.schema._parseAsync({data:Y,path:Q.path,parent:Q});if(G.status==="aborted")return R;if(G.status==="dirty")return l$(G.value);if(J.value==="dirty")return l$(G.value);return G});else{if(J.value==="aborted")return R;let Y=this._def.schema._parseSync({data:X,path:Q.path,parent:Q});if(Y.status==="aborted")return R;if(Y.status==="dirty")return l$(Y.value);if(J.value==="dirty")return l$(Y.value);return Y}}if(q.type==="refinement"){let X=(Y)=>{let G=q.refinement(Y,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 Y};if(Q.common.async===!1){let Y=this._def.schema._parseSync({data:Q.data,path:Q.path,parent:Q});if(Y.status==="aborted")return R;if(Y.status==="dirty")J.dirty();return X(Y.value),{status:J.value,value:Y.value}}else return this._def.schema._parseAsync({data:Q.data,path:Q.path,parent:Q}).then((Y)=>{if(Y.status==="aborted")return R;if(Y.status==="dirty")J.dirty();return X(Y.value).then(()=>{return{status:J.value,value:Y.value}})})}if(q.type==="transform")if(Q.common.async===!1){let X=this._def.schema._parseSync({data:Q.data,path:Q.path,parent:Q});if(!D$(X))return R;let Y=q.transform(X.value,W);if(Y instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:J.value,value:Y}}else return this._def.schema._parseAsync({data:Q.data,path:Q.path,parent:Q}).then((X)=>{if(!D$(X))return R;return Promise.resolve(q.transform(X.value,W)).then((Y)=>({status:J.value,value:Y}))});D.assertNever(q)}}w$.create=($,J,Q)=>{return new w$({schema:$,typeName:b.ZodEffects,effect:J,...V(Q)})};w$.createWithPreprocess=($,J,Q)=>{return new w$({schema:J,effect:{type:"preprocess",transform:$},typeName:b.ZodEffects,...V(Q)})};class M$ extends C{_parse($){if(this._getType($)===K.undefined)return a(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}M$.create=($,J)=>{return new M$({innerType:$,typeName:b.ZodOptional,...V(J)})};class j$ extends C{_parse($){if(this._getType($)===K.null)return a(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}j$.create=($,J)=>{return new j$({innerType:$,typeName:b.ZodNullable,...V(J)})};class B0 extends C{_parse($){let{ctx:J}=this._processInputParams($),Q=J.data;if(J.parsedType===K.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:b.ZodDefault,defaultValue:typeof J.default==="function"?J.default:()=>J.default,...V(J)})};class _0 extends C{_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$(Q.common.issues)},input:Q.data})}});else return{status:"valid",value:q.status==="valid"?q.value:this._def.catchValue({get error(){return new Q$(Q.common.issues)},input:Q.data})}}removeCatch(){return this._def.innerType}}_0.create=($,J)=>{return new _0({innerType:$,typeName:b.ZodCatch,catchValue:typeof J.catch==="function"?J.catch:()=>J.catch,...V(J)})};class v0 extends C{_parse($){if(this._getType($)!==K.nan){let Q=this._getOrReturnCtx($);return O(Q,{code:U.invalid_type,expected:K.nan,received:Q.parsedType}),R}return{status:"valid",value:$.data}}}v0.create=($)=>{return new v0({typeName:b.ZodNaN,...V($)})};var u3=Symbol("zod_brand");class o0 extends C{_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 P0 extends C{_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 R;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 R;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 P0({in:$,out:J,typeName:b.ZodPipeline})}}class M0 extends C{_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:b.ZodReadonly,...V(J)})};function N2($,J){let Q=typeof $==="function"?$(J):typeof $==="string"?{message:$}:$;return typeof Q==="string"?{message:Q}:Q}function z2($,J={},Q){if($)return d$.create().superRefine((q,W)=>{let X=$(q);if(X instanceof Promise)return X.then((Y)=>{if(!Y){let G=N2(J,q),H=G.fatal??Q??!0;W.addIssue({code:"custom",...G,fatal:H})}});if(!X){let Y=N2(J,q),G=Y.fatal??Q??!0;W.addIssue({code:"custom",...Y,fatal:G})}return});return d$.create()}var p3={object:m.lazycreate},b;(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"})(b||(b={}));var l3=($,J={message:`Input not instance of ${$.name}`})=>z2((Q)=>Q instanceof $,J),A2=B$.create,S2=T$.create,c3=v0.create,d3=E$.create,f2=J0.create,i3=c$.create,r3=R0.create,o3=Q0.create,n3=W0.create,a3=d$.create,s3=k$.create,t3=z$.create,e3=b0.create,$5=_$.create,J5=m.create,Q5=m.strictCreate,W5=q0.create,q5=r0.create,X5=X0.create,Y5=A$.create,H5=j0.create,G5=V0.create,B5=i$.create,_5=$0.create,M5=Y0.create,U5=H0.create,w5=I$.create,N5=G0.create,K5=r$.create,L5=w$.create,O5=M$.create,F5=j$.create,z5=w$.createWithPreprocess,A5=P0.create,S5=()=>A2().optional(),f5=()=>S2().optional(),R5=()=>f2().optional(),b5={string:($)=>B$.create({...$,coerce:!0}),number:($)=>T$.create({...$,coerce:!0}),boolean:($)=>J0.create({...$,coerce:!0}),bigint:($)=>E$.create({...$,coerce:!0}),date:($)=>c$.create({...$,coerce:!0})};var j5=R;var V5=M.object({before:M.string(),after:M.string(),hierarchy:M.array(M.string()),lineStart:M.number().optional(),lineEnd:M.number().optional()}).passthrough(),g1=M.object({id:M.string(),name:M.string()}).passthrough(),v5=M.object({url:M.string(),mime:M.string().optional()}).passthrough(),h1=M.object({id:M.string(),snippet:M.string(),note:M.string(),createdAt:M.string(),filePath:M.string().optional(),canvasFile:M.string().optional(),context:V5.optional(),images:M.array(M.string()).optional(),attachments:M.array(v5).optional(),source:M.enum(["local","remote"]).optional(),author:g1.optional()}).passthrough(),P5=M.array(h1.optional().catch(void 0)).transform(($)=>$.filter((J)=>J!==void 0)).catch([]),Z1=M.object({annotations:P5,generalNote:M.string().catch("")}).passthrough(),R2=M.object({path:M.string()}),b2=M.object({url:M.string()}),j2=M.object({error:M.string()});import{useCallback as N9,useMemo as K9,useState as L9}from"react";function C0($){return $.uploadUrl!==null}var y1=["image/png","image/jpeg","image/gif","image/webp"],V2="Only PNG, JPEG, GIF and WebP images can be attached";function V$($,J){$.style.height="auto",$.style.height=(J?Math.max(J,$.scrollHeight):$.scrollHeight)+"px"}import{useAnnotations as n0}from"@fabrika/annotations/runtime";import{jsxDEV as T9}from"react/jsx-dev-runtime";import{jsxDEV as y9,Fragment as Z9}from"react/jsx-dev-runtime";import{useAnnotationHost as D5}from"@fabrika/annotations/runtime";import{useCallback as v$,useEffect as k5,useRef as x1,useState as a0}from"react";import{jsxDEV as s}from"react/jsx-dev-runtime";function v2($){if($.startsWith("/s/")||$.startsWith("http://")||$.startsWith("https://"))return $;return`/api/uploads/${$.split("/").pop()}`}async function T5($,J){let Q=$.uploadUrl;if(!Q)return{error:"Uploads are not available here"};let q=new FormData;q.append("image",J);try{let W=await fetch(Q(),{method:"POST",body:q}),X=await W.json();if(!W.ok){let Y=j2.safeParse(X);return{error:Y.success?Y.data.error:`Upload failed (HTTP ${W.status})`}}return{path:$.isShared?b2.parse(X).url:R2.parse(X).path}}catch{return{error:"Upload failed"}}}function s0({note:$,onNoteChange:J,images:Q,onAddImage:q,onRemoveImage:W,sessionId:X,placeholder:Y="Add your note...",autoFocus:G=!1,autoResize:H=!1,readOnly:B=!1,onKeyDown:_,onTextareaClick:N,textareaRef:F,textareaClassName:z,textareaStyle:w,minHeight:L,attachButton:A="always",openFilePickerRef:j}){let g=D5(),k=!B&&C0(g),[T,y]=a0(!1),[u,J$]=a0(!1),[W$,q$]=a0(null),[p,i]=a0(!1),r=x1(0),c=x1(null),X$=x1(null),P$=v$(()=>X$.current?.click(),[]);if(j)j.current=P$;let Z$=v$((v)=>{if(c.current=v,F)F.current=v;if(v&&H)V$(v,L)},[F,H,L]);k5(()=>{if(G&&c.current){let v=c.current;if(v.focus(),v.value)v.setSelectionRange(v.value.length,v.value.length)}},[G]);let t=v$(async(v)=>{if(!y1.includes(v.type)){q$(V2);return}q$(null),J$(!0);try{let S=await T5(g,v);if("path"in S)q(S.path);else q$(S.error)}finally{J$(!1)}},[g,q]),Y$=v$((v)=>{for(let S of v.clipboardData?.items??[])if(S.type.startsWith("image/")){v.preventDefault();let h=S.getAsFile();if(h)t(h);return}},[t]),N$=v$((v)=>{if(v.preventDefault(),r.current++,r.current===1)y(!0)},[]),K$=v$((v)=>{v.preventDefault()},[]),y$=v$((v)=>{if(v.preventDefault(),r.current--,r.current===0)y(!1)},[]),m$=v$((v)=>{v.preventDefault(),r.current=0,y(!1);for(let S of v.dataTransfer?.files??[])if(S.type.startsWith("image/"))t(S)},[t]),H1=v$((v)=>{if(J(v.currentTarget.value),H)v.currentTarget.style.height="auto",v.currentTarget.style.height=(L?Math.max(L,v.currentTarget.scrollHeight):v.currentTarget.scrollHeight)+"px"},[J,H,L]),G1="w-full bg-transparent text-[13px] font-body text-text-primary resize-none focus:outline-none leading-relaxed p-0 border-none",L0={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"}},I0=k&&(A==="always"||A==="on-focus"&&p);return s("div",{style:{position:"relative"},onDragEnter:k?N$:void 0,onDragOver:k?K$:void 0,onDragLeave:k?y$:void 0,onDrop:k?m$:void 0,children:[s("textarea",{ref:Z$,value:$,onChange:B?void 0:H1,onPaste:k?Y$:void 0,onKeyDown:_,onClick:N,onFocus:()=>i(!0),onBlur:()=>{setTimeout(()=>i(!1),150)},readOnly:B,placeholder:Y,className:z??G1,style:w??L0,rows:H?1:void 0},void 0,!1,void 0,this),k&&s("input",{ref:X$,type:"file",accept:y1.join(","),multiple:!0,style:{display:"none"},onChange:(v)=>{let S=v.currentTarget.files;if(S)for(let h of S)t(h);v.currentTarget.value=""}},void 0,!1,void 0,this),(Q.length>0||I0)&&s("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px",alignItems:"center"},children:[Q.map((v)=>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:v2(v),alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}},void 0,!1,void 0,this),!B&&s("button",{onClick:(S)=>{S.stopPropagation(),W(v)},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)]},v,!0,void 0,this)),I0&&s(t0,{onClick:P$},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),W$&&s("div",{role:"alert",style:{fontSize:"11px",color:"var(--color-accent-red)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:W$},void 0,!1,void 0,this),T&&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 t0({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 o9}from"@fabrika/annotations/runtime";import{useContext as a9,useEffect as s9,useRef as t9}from"react";import{jsxDEV as qJ,Fragment as XJ}from"react/jsx-dev-runtime";import{SessionContext as h5,useAnnotationHost as Z5}from"@fabrika/annotations/runtime";import{useCallback as e0,useContext as y5,useEffect as m5,useMemo as k2,useRef as $1,useState as U0}from"react";import{createPortal as x5}from"react-dom";function C2($){let J=/^(\d+(?:\.\d+)?)px$/.exec($.trim());return J?Number(J[1]):void 0}function D2($,J,Q=280){let W=J||document.body,X=$.getBoundingClientRect(),Y=W.getBoundingClientRect(),G=W===document.body?0:W.scrollTop,H=X.bottom-Y.top+G+8,B=Math.max(0,Math.min(X.left-Y.left,Y.width-Q-12));return W.style.position="relative",{style:{position:"absolute",top:`${H}px`,left:`${B}px`},parent:W}}import{jsxDEV as n,Fragment as u5}from"react/jsx-dev-runtime";function E2({anchorEl:$,scrollContainer:J,onClose:Q,ignoreSelector:q,zIndex:W="50",padding:X="12px",width:Y="280px",children:G}){let H=$1(null),B=$1(Q);B.current=Q;let{style:_,parent:N}=D2($,J,C2(Y));return m5(()=>{let F=setTimeout(()=>{let z=(w)=>{if(H.current&&!H.current.contains(w.target)){if(q&&w.target.closest?.(q))return;B.current(),document.removeEventListener("mousedown",z)}};return document.addEventListener("mousedown",z),()=>document.removeEventListener("mousedown",z)},0);return()=>clearTimeout(F)},[q]),x5(n("div",{ref:H,style:{..._,zIndex:W,width:Y,background:"var(--color-bg-elevated)",border:"1px solid var(--color-border-hover)",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",padding:X,fontFamily:"'Inter', sans-serif"},children:G},void 0,!1,void 0,this),N)}var I2=[{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"]}],T2=I2.flatMap(($)=>$.items);function g2({anchorEl:$,scrollContainer:J,snippet:Q,truncateAt:q=100,header:W,initialNote:X="",initialImages:Y,onConfirm:G,onCancel:H,onDelete:B}){let _=y5(h5),N=Z5(),F=C0(N),z=X!==""||!!B,[w,L]=U0(X),[A,j]=U0(Y||[]),[g,k]=U0(null),[T,y]=U0(z),[u,J$]=U0(!1),W$=$1(null),q$=$1(null),p=e0(()=>{if(w.trim()||A.length>0)G(w.trim(),A);else if(z&&B)B();else H()},[w,A,G,H,z,B]),i=e0(()=>{if(z){if(!w.trim()&&A.length===0&&B){B(),H();return}G(w,A);return}H()},[w,A,z,G,H,B]),r=!z,c=w.trim().length>0?T2.filter((S)=>S.toLowerCase().startsWith(w.trim().toLowerCase())):T2,X$=!r||T?[]:c.length===1&&c[0]?.toLowerCase()===w.trim().toLowerCase()?[]:c,P$=new Set(X$),Z$=I2.map((S)=>({label:S.label,items:S.items.filter((h)=>P$.has(h))})).filter((S)=>S.items.length>0),t=Z$.map((S)=>S.items),Y$=(S)=>t[S]?.length??0,N$=t.flat(),K$=k2(()=>{if(g===null)return 0;let S=0;for(let h=0;h<t.length;h++){if(g<S+Y$(h))return h;S+=Y$(h)}return 0},[g,t]),y$=k2(()=>{if(g===null)return 0;let S=0;for(let h=0;h<K$;h++)S+=Y$(h);return g-S},[g,K$,t]),m$=(S,h)=>{let d=0;for(let L$=0;L$<S;L$++)d+=Y$(L$);return d+h},[H1,G1]=U0(w);if(w!==H1)G1(w),k(null),y(z);let L0=e0((S)=>{L(S)},[]),I0=Q.length>q?Q.slice(0,q)+"...":Q,v=e0((S)=>{if(N$.length>0&&(S.key==="ArrowDown"||S.key==="ArrowUp"||S.key==="ArrowLeft"||S.key==="ArrowRight")){if(S.preventDefault(),g===null){k(0);return}if(S.key==="ArrowDown"){let d=Math.min(y$+1,Y$(K$)-1);k(m$(K$,d))}else if(S.key==="ArrowUp"){let d=Math.max(y$-1,0);k(m$(K$,d))}else if(S.key==="ArrowRight"){let d=Math.min(K$+1,t.length-1),L$=Math.min(y$,Y$(d)-1);k(m$(d,L$))}else if(S.key==="ArrowLeft"){let d=Math.max(K$-1,0),L$=Math.min(y$,Y$(d)-1);k(m$(d,L$))}return}let h=g===null?void 0:N$[g];if(h!==void 0){if(S.key==="Tab"){S.preventDefault(),L0(h);return}if(S.key==="Enter"&&!S.shiftKey){S.preventDefault(),G(h,A);return}}if(S.key==="Enter"&&!S.shiftKey){S.preventDefault(),p();return}if(S.key==="Escape")if(N$.length>0&&!T)y(!0);else if(z)i();else H()},[N$,g,y$,K$,t,m$,L0,G,A,p,T,z,i,H]);return n(E2,{anchorEl:$,scrollContainer:J,onClose:z?i:H,ignoreSelector:z?"[data-annotation-id]":void 0,zIndex:z?"60":"50",padding:z?"10px 12px":"12px",width:"420px",children:[!z&&(W??n("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:["“",I0,"”"]},void 0,!0,void 0,this)),n(s0,{note:w,onNoteChange:L,images:A,onAddImage:(S)=>j((h)=>[...h,S]),onRemoveImage:(S)=>j((h)=>h.filter((d)=>d!==S)),sessionId:_,autoFocus:!0,autoResize:z,textareaRef:W$,onKeyDown:v,attachButton:"none",openFilePickerRef:q$,textareaStyle:z?{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),n("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:z?"6px":"8px"},children:[F&&n(t0,{onClick:()=>q$.current?.(),size:14},void 0,!1,void 0,this),n("div",{style:{flex:1}},void 0,!1,void 0,this),z?n("button",{onClick:()=>{if(B)B();H()},onMouseEnter:()=>J$(!0),onMouseLeave:()=>J$(!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):n(u5,{children:[n("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),n("button",{onClick:p,style:{fontSize:"11px",fontWeight:500,padding:"4px 12px",borderRadius:"6px",background:"var(--color-highlight-bg)",color:"var(--color-text-primary)",border:"1px solid var(--color-highlight-border)",cursor:"pointer",fontFamily:"'Inter', sans-serif"},children:"Add"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),N$.length>0&&n("div",{style:{marginTop:"6px",borderTop:"1px solid var(--color-border-subtle)",paddingTop:"8px",display:"flex",gap:"4px"},children:Z$.map((S)=>n("div",{style:{flex:1},children:[n("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:S.label},void 0,!1,void 0,this),S.items.map((h)=>{let d=N$.indexOf(h);return n("div",{onMouseDown:(L$)=>{L$.preventDefault(),L$.stopPropagation(),L0(h)},onMouseEnter:()=>k(d),style:{padding:"3px 6px",fontSize:"12px",borderRadius:"4px",fontFamily:"'Inter', sans-serif",color:d===g?"var(--color-text-primary)":"var(--color-text-secondary)",background:d===g?"var(--color-highlight-selected)":"transparent",cursor:"pointer"},children:[n("span",{style:{fontWeight:500},children:h.slice(0,w.trim().length)},void 0,!1,void 0,this),h.slice(w.trim().length)]},h,!0,void 0,this)})]},S.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:X,onCancel:Y}){return n(g2,{anchorEl:$,scrollContainer:J,snippet:Q,truncateAt:q,header:W,onConfirm:(G,H)=>X(G,H),onCancel:Y},void 0,!1,void 0,this)}import{useEffect as fJ,useRef as RJ,useState as bJ}from"react";import{jsxDEV as DJ}from"react/jsx-dev-runtime";import{useCallback as gJ,useEffect as hJ,useRef as ZJ,useState as yJ}from"react";import{jsxDEV as iJ,Fragment as dJ}from"react/jsx-dev-runtime";import{jsxDEV as h2}from"react/jsx-dev-runtime";function w0({note:$,onChange:J}){return h2("div",{className:"mt-1.5",children:h2("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)=>V$(Q.currentTarget),ref:(Q)=>{if(Q)V$(Q)}},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as x}from"react/jsx-dev-runtime";function l2($){return $.map((J)=>typeof J==="string"?{value:J,label:J}:{value:J.value,label:J.label??J.value})}function s5({id:$,label:J,options:Q,required:q}){let{responses:W,setResponse:X}=Z2();y2($);let Y=x2(()=>l2(Q),[Q]),G=W.get($),H=G?.value,B=G?.note||"",[_,N]=p2(!1),F=u2(null);if(!W.has($))X($,{id:$,type:"radio",label:J,value:null,options:Y.map((L)=>L.value),required:q});let z=(L)=>{X($,{...G,value:L})};m2(()=>{let L=F.current;if(!L)return;let A=(j)=>{let k=j.target.closest("[data-md-label]")?.getAttribute("data-md-label"),T=Y.find((y)=>y.label===k);if(T)z(T.value)};return L.addEventListener("kb-select",A),()=>L.removeEventListener("kb-select",A)},[Y,z]);let w=G?.required&&!H;return x("div",{ref:F,"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:[x("div",{className:"flex items-baseline gap-2 mb-2",children:[x("span",{className:"text-[13px] font-body font-medium text-text-primary",children:J},void 0,!1,void 0,this),q&&x("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),x("div",{className:"space-y-1",children:Y.map(({value:L,label:A})=>x("label",{"data-md":"choice-option","data-md-label":A,onClick:()=>z(L),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${H===L?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[x("span",{className:`w-4 h-4 rounded-full border-[1.5px] flex items-center justify-center flex-shrink-0 transition-all ${H===L?"border-accent-amber bg-accent-amber":"border-border-strong"}`,children:H===L&&x("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),x("span",{className:"text-[13px] font-body text-text-secondary",children:A},void 0,!1,void 0,this)]},L,!0,void 0,this))},void 0,!1,void 0,this),x(w0,{show:_,note:B,onToggle:()=>N(!_),onChange:(L)=>X($,{...G,note:L})},void 0,!1,void 0,this),w&&x("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 t5({id:$,label:J,options:Q,required:q}){let{responses:W,setResponse:X}=Z2();y2($);let Y=x2(()=>l2(Q),[Q]),G=W.get($),H=G?.value||[],B=G?.note||"",[_,N]=p2(!1),F=u2(null);if(!W.has($))X($,{id:$,type:"checkbox",label:J,value:[],options:Y.map((L)=>L.value),required:q});let z=(L)=>{let A=H.includes(L)?H.filter((j)=>j!==L):[...H,L];X($,{...G,value:A})};m2(()=>{let L=F.current;if(!L)return;let A=(j)=>{let k=j.target.closest("[data-md-label]")?.getAttribute("data-md-label"),T=Y.find((y)=>y.label===k);if(T)z(T.value)};return L.addEventListener("kb-select",A),()=>L.removeEventListener("kb-select",A)},[Y,z]);let w=G?.required&&H.length===0;return x("div",{ref:F,"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:[x("div",{className:"flex items-baseline gap-2 mb-2",children:[x("span",{className:"text-[13px] font-body font-medium text-text-primary",children:J},void 0,!1,void 0,this),q&&x("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),x("div",{className:"space-y-1",children:Y.map(({value:L,label:A})=>{let j=H.includes(L);return x("label",{"data-md":"multichoice-option","data-md-label":A,onClick:()=>z(L),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${j?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[x("span",{className:`w-4 h-4 rounded flex items-center justify-center flex-shrink-0 transition-all ${j?"bg-accent-amber":"border-[1.5px] border-border-strong"}`,children:j&&x("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:x("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),x("span",{className:"text-[13px] font-body text-text-secondary",children:A},void 0,!1,void 0,this)]},L,!0,void 0,this)})},void 0,!1,void 0,this),x(w0,{show:_,note:B,onToggle:()=>N(!_),onChange:(L)=>X($,{...G,note:L})},void 0,!1,void 0,this),w&&x("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 e5,useRef as $6}from"react";function J1(){return window.hljs}function c2(){return window.mermaid}import{jsxDEV as Q1}from"react/jsx-dev-runtime";function J6({language:$,children:J}){let Q=typeof J==="string"?J:String(J??""),q=$6(null);return e5(()=>{let W=q.current,X=J1();if(!W||!X)return;W.removeAttribute("data-highlighted"),W.className=$?`language-${$}`:"",W.textContent=Q,X.highlightElement(W)},[Q,$]),Q1("div",{className:"relative mt-3 group/code","data-md":"codeblock","data-md-language":$||"",children:[$&&Q1("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),Q1("pre",{className:"bg-bg-code rounded-md p-4 overflow-x-auto text-code font-mono leading-relaxed",children:Q1("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 d2($,J){let Q=$.split(`
60
- `),q=J.split(`
61
- `),W=Q6(Q,q),X=[],Y=0,G=0,H=0;while(Y<Q.length||G<q.length){let B=Q[Y],_=q[G];if(H<W.length&&B!==void 0&&_!==void 0&&B===W[H]&&_===W[H])X.push({type:"same",line:B}),Y++,G++,H++;else if(B!==void 0&&(H>=W.length||B!==W[H]))X.push({type:"removed",line:B}),Y++;else if(_!==void 0)X.push({type:"added",line:_}),G++}return X}function Q6($,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 N=1;N<=q;N++)B[N]=$[H-1]===J[N-1]?(_[N-1]??0)+1:Math.max(_[N]??0,B[N-1]??0)}let X=[],Y=Q,G=q;while(Y>0&&G>0){let H=$[Y-1];if(H!==void 0&&H===J[G-1])X.unshift(H),Y--,G--;else if((W[Y-1]?.[G]??0)>(W[Y]?.[G-1]??0))Y--;else G--}return X}import{jsxDEV as k0}from"react/jsx-dev-runtime";function W6({before:$,after:J,language:Q}){let q=d2($,J);return k0("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden group/diff","data-md":"diff","data-md-language":Q||"",children:[Q&&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 (",Q,")"]},void 0,!0,void 0,this),k0("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono",children:q.map((W,X)=>k0("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:[k0("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]},X,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{ActiveViewCtx as Y6,SessionContext as H6}from"#canvas/runtime";import{useContext as r2,useEffect as o2,useRef as G6,useState as W1}from"react";var q6=M.object({id:M.string(),type:M.enum(["select","radio","checkbox","text","range"]),label:M.string(),value:M.unknown(),options:M.array(M.string()).optional(),required:M.boolean().optional(),note:M.string().optional()}).passthrough().transform(($)=>({...$,value:$.value})),X6=M.object({id:M.string(),markdown:M.string(),label:M.string().optional(),required:M.boolean().optional()}).passthrough(),aQ=Z1.extend({responses:M.array(M.tuple([M.string(),q6]).optional().catch(void 0)).transform(($)=>$.filter((J)=>J!==void 0)).catch([]),feedbackEntries:M.array(M.tuple([M.string(),X6]).optional().catch(void 0)).transform(($)=>$.filter((J)=>J!==void 0)).optional().catch([])});var sQ=M.object({feedback:M.string().nullish()}),i2=M.union([M.object({error:M.string().min(1)}),M.object({content:M.string(),language:M.string().nullish()})]);import{jsxDEV as g$}from"react/jsx-dev-runtime";var B6={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 _6({path:$,lines:J,__content:Q}){let q=r2(H6),{setActiveView:W}=r2(Y6),[X,Y]=W1(Q??null),[G,H]=W1(()=>{let w=$.split(".").pop()||"";return B6[w]||"text"}),[B,_]=W1(null),[N,F]=W1(!Q),z=G6(null);if(o2(()=>{if(Q!==void 0)return;F(!0),_(null),fetch(`/api/file?session=${q}&path=${encodeURIComponent($)}`).then((w)=>w.json()).then((w)=>{let L=i2.parse(w);if("error"in L)_(L.error);else{let A=L.content;if(J)A=A.split(`
62
- `).slice(J[0]-1,J[1]).join(`
63
- `);Y(A),H(L.language||"text")}}).catch(()=>_("Failed to fetch file")).finally(()=>F(!1))},[q,$,J?.[0],J?.[1],Q]),o2(()=>{let w=z.current,L=J1();if(!w||!L||!X)return;w.removeAttribute("data-highlighted"),w.className=G?`language-${G}`:"",w.textContent=X,L.highlightElement(w)},[X,G]),N)return g$("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 g$("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 g$("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:[g$("div",{className:"px-4 py-2 flex items-center justify-between",children:[g$("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&&g$("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),g$("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono !bg-transparent",style:{background:"transparent"},children:g$("code",{ref:z,className:G?`language-${G}`:"",children:X},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{SessionContext as M6}from"#canvas/runtime";import{useContext as U6,useState as w6}from"react";import{jsxDEV as T0}from"react/jsx-dev-runtime";function N6({src:$,alt:J,caption:Q,width:q,height:W}){let X=U6(M6),[Y,G]=w6(!1),H=`/api/image?session=${encodeURIComponent(X)}&path=${encodeURIComponent($)}`;if(Y)return T0("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 T0("figure",{className:"mt-3 relative","data-md":"image","data-md-src":$,children:[T0("div",{"data-annotation-image":!0,className:"rounded-md overflow-hidden border border-border-subtle bg-bg-code inline-block",children:T0("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&&T0("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 K6}from"react";import{jsxDEV as n2}from"react/jsx-dev-runtime";E.setOptions({gfm:!0,breaks:!1});function L6({children:$,file:J,__content:Q}){let q=Q??(typeof $==="string"?$:String($??"")),W=K6(()=>{if(!q)return"";return E.parse(q,{async:!1})},[q]);if(!q)return n2("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 n2("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 O6,useCanvasFile as F6}from"#canvas/runtime";import{useCallback as S$,useEffect as u1,useRef as E0,useState as N0}from"react";import z6 from"react-dom";import{jsxDEV as P,Fragment as e2}from"react/jsx-dev-runtime";var K0=0.2,q1=0.25,X1=4;function s2({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:$>=X1,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(e2,{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 t2($=1){let[J,Q]=N0($),q=S$(()=>Q((Y)=>Math.min(X1,+(Y+K0).toFixed(2))),[]),W=S$(()=>Q((Y)=>Math.max(q1,+(Y-K0).toFixed(2))),[]),X=S$(()=>Q(1),[]);return{zoom:J,zoomIn:q,zoomOut:W,zoomReset:X,setZoom:Q}}function A6({svgHtml:$,source:J,onClose:Q}){let q=E0(null),{zoom:W,zoomIn:X,zoomOut:Y,zoomReset:G,setZoom:H}=t2(1),[B,_]=N0({x:0,y:0}),N=E0(null);u1(()=>{let j=(g)=>{if(g.key==="Escape")Q()};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[Q]);let F=S$((j)=>{j.preventDefault();let g=j.deltaY>0?-K0:K0;H((k)=>Math.max(q1,Math.min(X1,+(k+g).toFixed(2))))},[H]),z=S$((j)=>{if(j.button!==0)return;N.current={startX:j.clientX,startY:j.clientY,panX:B.x,panY:B.y},j.preventDefault()},[B]),w=S$((j)=>{if(!N.current)return;_({x:N.current.panX+(j.clientX-N.current.startX),y:N.current.panY+(j.clientY-N.current.startY)})},[]),L=S$(()=>{N.current=null},[]),A=S$(()=>{G(),_({x:0,y:0})},[G]);return z6.createPortal(P("div",{style:{position:"fixed",inset:0,zIndex:9999,background:"var(--color-bg-base)",display:"flex",flexDirection:"column"},onMouseMove:w,onMouseUp:L,onMouseLeave:L,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(s2,{zoom:W,onZoomIn:X,onZoomOut:Y,onZoomReset:A},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:N.current?"grabbing":"grab"},onWheel:F,onMouseDown:z,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:N.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 S6({children:$}){let J=E0(null),[Q,q]=N0(null),[W,X]=N0(!1),[Y,G]=N0(""),H=typeof $==="string"?$:String($??""),{annotations:B,addAnnotationWithId:_,activeAnnotationId:N,setActiveAnnotationId:F}=O6(),z=F6(),[w,L]=N0(null),{zoom:A,zoomIn:j,zoomOut:g,zoomReset:k,setZoom:T}=t2(1),y=E0(B);y.current=B;let u=S$((p,i,r)=>{let c=`[Diagram ${r.toLowerCase()}] ${i}`,X$=y.current.find((P$)=>P$.snippet===c);if(X$)F(X$.id);else L({anchorEl:p,snippet:i,prefix:r})},[F]),J$=E0(u);J$.current=u,u1(()=>{let p=!1,i=async()=>{try{let c=c2();if(!c){q("Mermaid library not loaded");return}let X$=document.documentElement.dataset.theme==="light"?"default":"dark";c.initialize({startOnLoad:!1,theme:X$});let P$=`mermaid-${Math.random().toString(36).slice(2)}`,{svg:Z$}=await c.render(P$,H.trim());if(!p&&J.current)J.current.innerHTML=Z$,G(Z$),f6(J.current,(t,Y$,N$)=>J$.current(t,Y$,N$)),a2(J.current,y.current);q(null)}catch(c){if(!p)q(c instanceof Error&&c.message||"Invalid diagram")}};i();let r=new MutationObserver((c)=>{for(let X$ of c)if(X$.attributeName==="data-theme")i()});return r.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{p=!0,r.disconnect()}},[H]),u1(()=>{if(J.current)a2(J.current,B,N)},[B,N]);let W$=S$((p)=>{if(!p.ctrlKey&&!p.metaKey)return;p.preventDefault();let i=p.deltaY>0?-K0:K0;T((r)=>Math.max(q1,Math.min(X1,+(r+i).toFixed(2))))},[T]);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 q$=J.current?.closest("#plan-scroll-container");return P(e2,{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(s2,{zoom:A,onZoomIn:j,onZoomOut:g,onZoomReset:k,onFullscreen:()=>X(!0)},void 0,!1,void 0,this)},void 0,!1,void 0,this),P("div",{style:{overflow:"auto",maxHeight:"70vh"},onWheel:W$,children:P("div",{ref:J,className:"flex justify-center",style:{transform:`scale(${A})`,transformOrigin:"top center",transition:"transform 0.1s ease-out",minHeight:A<1?void 0:void 0}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),w&&P(D0,{anchorEl:w.anchorEl,scrollContainer:q$,snippet:w.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),w.snippet]},void 0,!0,void 0,this),onAdd:(p,i)=>{let r=`ann-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;_(r,`[Diagram ${w.prefix.toLowerCase()}] ${w.snippet}`,p,void 0,void 0,i,z||void 0),L(null)},onCancel:()=>L(null)},void 0,!1,void 0,this),W&&Y&&P(A6,{svgHtml:Y,source:H,onClose:()=>X(!1)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function f6($,J){let Q=(q,W,X)=>{q.style.cursor="pointer",q.addEventListener("mouseenter",()=>{q.style.filter="brightness(1.2)"}),q.addEventListener("mouseleave",()=>{q.style.filter=""}),q.addEventListener("click",(Y)=>{Y.stopPropagation(),Y.preventDefault(),J(q,W(),X)})};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,X=W.querySelector("path");if(X){X.style.strokeWidth=Math.max(parseFloat(X.style.strokeWidth||"1"),8)+"px",X.style.strokeOpacity="0";let G=X.cloneNode(!0);G.style.strokeWidth="",G.style.strokeOpacity="",W.insertBefore(G,X)}let Y=W.id||"";Q(W,()=>{let G=$.querySelectorAll(".edgeLabel");for(let H of G)if(H.id&&Y&&H.id.replace("label","").includes(Y.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 X=q.closest("g");if(!X||X.hasAttribute("data-clickable"))continue;X.setAttribute("data-clickable","true"),Q(X,()=>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 X=W.querySelector(".entityLabel");if(!X)continue;W.setAttribute("data-clickable","true"),Q(W,()=>X.textContent?.trim()||"Entity","Node")}for(let q of $.querySelectorAll(".relationshipLabel")){let W=q.textContent?.trim();if(!W)continue;let Y=q.closest("g")||q;if(Y.hasAttribute("data-clickable"))continue;Y.setAttribute("data-clickable","true"),Q(Y,()=>W,"Edge")}for(let q of $.querySelectorAll(".classGroup")){let W=q;if(W.hasAttribute("data-clickable"))continue;let X=W.querySelector(".classTitle, .classTitleText, text");if(!X)continue;W.setAttribute("data-clickable","true"),Q(W,()=>X.textContent?.trim()||"Class","Node")}for(let q of $.querySelectorAll(".statediagram-state")){let W=q;if(W.hasAttribute("data-clickable"))continue;let X=W.querySelector(".state-title, text");if(!X)continue;W.setAttribute("data-clickable","true"),Q(W,()=>X.textContent?.trim()||"State","Node")}for(let q of $.querySelectorAll(".mindmap-node")){let W=q;if(W.hasAttribute("data-clickable"))continue;let X=W.querySelector(".mindmap-node-label, text");if(!X)continue;W.setAttribute("data-clickable","true"),Q(W,()=>X.textContent?.trim()||"Node","Node")}}function a2($,J,Q){let q=new Map;for(let X of J){let Y=X.snippet.match(/^\[Diagram (?:node|edge)\] (.+)$/)?.[1];if(Y)q.set(Y,X.id)}for(let X of $.querySelectorAll("[data-annotated]"))X.style.outline="",X.style.outlineOffset="",X.style.borderRadius="",X.removeAttribute("data-annotated");if(q.size===0)return;for(let X of $.querySelectorAll(".node")){let G=(X.querySelector(".nodeLabel")||X.querySelector("foreignObject span")||X.querySelector("text"))?.textContent?.trim();if(!G||!q.has(G))continue;let H=q.get(G),B=X;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 X of $.querySelectorAll(".edgeLabel")){let Y=X.textContent?.trim();if(!Y||!q.has(Y))continue;let G=q.get(Y),H=X;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 X of $.querySelectorAll(".actor")){let Y=X.closest("g");if(!Y)continue;let H=Y.querySelector("text")?.textContent?.trim();if(!H||!q.has(H))continue;if(Y.hasAttribute("data-annotated"))continue;let B=q.get(H);Y.setAttribute("data-annotated",B);let _=B===Q,N=Y.querySelector("rect");if(N)N.style.outline=_?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",N.style.outlineOffset="2px",N.style.borderRadius="4px"}for(let X of $.querySelectorAll(".messageText")){let Y=X.textContent?.trim();if(!Y||!q.has(Y))continue;let G=q.get(Y),H=X;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=(X,Y,G)=>{for(let H of $.querySelectorAll(X)){let B=G(H);if(!B||B.hasAttribute("data-annotated"))continue;let N=B.querySelector(Y)?.textContent?.trim();if(!N||!q.has(N))continue;let F=q.get(N);B.setAttribute("data-annotated",F);let z=F===Q,w=B.querySelector("rect, circle, ellipse, polygon")||B;w.style.outline=z?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",w.style.outlineOffset="2px",w.style.borderRadius="4px"}};W(".entityBox",".entityLabel",(X)=>X.closest("g"));for(let X of $.querySelectorAll(".relationshipLabel")){let G=X.closest("g")||X;if(G.hasAttribute("data-annotated"))continue;let H=X.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",(X)=>X),W(".statediagram-state",".state-title, text",(X)=>X),W(".mindmap-node",".mindmap-node-label, text",(X)=>X)}import{jsxDEV as b6}from"react/jsx-dev-runtime";function R6({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:C$($)},void 0,!1,void 0,this)}import{jsxDEV as v6}from"react/jsx-dev-runtime";var j6={high:"text-accent-red bg-accent-red-muted",medium:"text-accent-amber bg-accent-amber-muted",low:"text-text-tertiary bg-border-subtle"};function V6({level:$}){return v6("span",{className:`inline text-tiny font-medium font-body ml-2 px-1.5 py-0.5 rounded ${j6[$]}`,"data-md":"priority","data-md-level":$,children:$},void 0,!1,void 0,this)}import{useState as P6}from"react";import{jsxDEV as o$}from"react/jsx-dev-runtime";function C6({title:$,children:J}){let[Q,q]=P6(!1);return o$("div",{className:"relative mb-8 p-4 group/section","data-md":"section","data-md-title":$,children:[o$("div",{className:"relative mb-2",children:[o$("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:o$("svg",{width:"14",height:"14",viewBox:"0 0 12 12",fill:"none",children:o$("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),o$("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),o$("div",{className:Q?"mt-6 hidden":"mt-6",children:C$(J)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as h$}from"react/jsx-dev-runtime";function D6({headers:$,rows:J}){return h$("div",{className:"overflow-x-auto mt-3","data-md":"table",children:h$("table",{className:"w-full text-body",children:[h$("thead",{children:h$("tr",{className:"border-b border-border-subtle",children:$.map((Q,q)=>h$("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),h$("tbody",{children:J.map((Q,q)=>h$("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,X)=>h$("td",{className:"px-4 py-2.5 text-text-secondary font-body",children:W},X,!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 f$}from"react/jsx-dev-runtime";var k6={todo:"bg-border-hover",done:"bg-accent-green",blocked:"bg-accent-red","in-progress":"bg-accent-blue"},T6={todo:"Todo",done:"Done",blocked:"Blocked","in-progress":"In progress"},E6={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 $4({id:$,label:J,status:Q,badge:q,badgeVariant:W="neutral",children:X}){return f$("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:f$("div",{className:"flex items-start gap-3",children:[Q&&f$("span",{className:`w-2 h-2 rounded-full mt-[7px] flex-shrink-0 ${k6[Q]}`},void 0,!1,void 0,this),f$("div",{className:"flex-1 min-w-0",children:[f$("div",{className:"flex items-baseline gap-2",children:[f$("span",{className:"font-body text-task-label font-semibold text-text-primary",children:J},void 0,!1,void 0,this),Q&&f$("span",{className:"font-body text-tiny uppercase tracking-wider text-text-tertiary opacity-0 group-hover/task:opacity-100 transition-opacity duration-150",children:T6[Q]},void 0,!1,void 0,this),q&&f$("span",{className:`font-body text-tiny font-medium px-1.5 py-px rounded-full ${E6[W]}`,children:q},void 0,!1,void 0,this)]},void 0,!0,void 0,this),X&&f$("div",{className:"text-body text-text-secondary mt-1 leading-relaxed",children:C$(X)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function I6($){return f$($4,{...$},void 0,!1,void 0,this)}import{useAnnotations as J4,useResponseRegistration as Q4}from"#canvas/runtime";import{useRef as g6,useState as W4}from"react";import{jsxDEV as Z}from"react/jsx-dev-runtime";function h6({id:$,label:J,placeholder:Q,multiline:q,required:W}){let{responses:X,setResponse:Y}=J4();Q4($);let G=X.get($),H=G?.value??"",B=G?.note||"",[_,N]=W4(!1),F=g6(null);if(!X.has($))Y($,{id:$,type:"text",label:J,value:"",required:W});let z=(A)=>{Y($,{...G,value:A})},w=(A)=>V$(A,q?60:32),L=G?.required&&!H.trim();return Z("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:[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),W&&Z("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z("textarea",{ref:F,value:H,onChange:(A)=>{z(A.currentTarget.value),w(A.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:(A)=>w(A.currentTarget),onFocus:(A)=>w(A.currentTarget)},void 0,!1,void 0,this),Z(w0,{show:_,note:B,onToggle:()=>N(!_),onChange:(A)=>Y($,{...G,note:A})},void 0,!1,void 0,this),L&&Z("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 Z6({id:$,label:J,min:Q=1,max:q=10,step:W=1,required:X,minLabel:Y,maxLabel:G}){let{responses:H,setResponse:B}=J4();Q4($);let _=H.get($),N=_?.value,F=_?.note||"",[z,w]=W4(!1);if(!H.has($))B($,{id:$,type:"range",label:J,value:null,required:X});let L=(u)=>{B($,{..._,value:u})},A=N!==null&&N!==void 0,j=A?N:Math.round((Q+q)/2),g=(j-Q)/(q-Q)*100,k=Math.round((q-Q)/W),T=k<=20,y=_?.required&&!A;return Z("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:[Z("div",{className:"flex items-baseline justify-between mb-1",children:[Z("div",{className:"flex items-baseline gap-2",children:[Z("span",{className:"text-[13px] font-body font-medium text-text-primary",children:J},void 0,!1,void 0,this),X&&Z("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z("span",{className:"flex items-center gap-1.5",children:[Z("span",{className:`text-[13px] font-mono ${A?"text-accent-amber":"text-text-disabled"}`,children:A?N:"—"},void 0,!1,void 0,this),A&&Z("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),Z("div",{className:"relative h-6 flex items-center",children:[Z("div",{className:"absolute left-0 right-0 h-1.5 rounded-full bg-border-medium",children:A&&Z("div",{className:"h-full rounded-full bg-accent-amber transition-all duration-150",style:{width:`${g}%`}},void 0,!1,void 0,this)},void 0,!1,void 0,this),T&&Array.from({length:k+1},(u,J$)=>{let W$=Q+J$*W,q$=(W$-Q)/(q-Q)*100,p=A&&W$<=N;return Z("div",{className:`absolute rounded-full pointer-events-none transition-all duration-150 ${A&&W$===N?"w-2.5 h-2.5 bg-accent-amber":p?"w-1.5 h-1.5 bg-accent-amber":"w-1.5 h-1.5 bg-border-hover"}`,style:{left:`${q$}%`,transform:"translate(-50%, -50%)",top:"50%"}},J$,!1,void 0,this)}),A?Z("div",{className:"absolute h-5 w-5 rounded-full bg-accent-amber shadow-md pointer-events-none transition-all duration-150",style:{left:`calc(${g}% - 10px)`,borderWidth:"2px",borderStyle:"solid",borderColor:"var(--color-bg-base)"}},void 0,!1,void 0,this):Z("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),Z("input",{type:"range",min:Q,max:q,step:W,value:j,onChange:(u)=>L(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),T&&k<=10?Z("div",{className:"flex justify-between -mt-0.5 px-0",children:Array.from({length:k+1},(u,J$)=>{let W$=Q+J$*W;return Z("span",{className:`text-[10px] font-mono transition-colors ${A&&W$===N?"text-accent-amber font-medium":"text-text-disabled"}`,style:{minWidth:"1ch",textAlign:"center"},children:W$},J$,!1,void 0,this)})},void 0,!1,void 0,this):Z("div",{className:"flex justify-between -mt-0.5",children:[Z("span",{className:"text-[11px] text-text-tertiary font-body",children:Y||Q},void 0,!1,void 0,this),Z("span",{className:"text-[11px] text-text-tertiary font-body",children:G||q},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z(w0,{show:z,note:F,onToggle:()=>w(!z),onChange:(u)=>B($,{..._,note:u})},void 0,!1,void 0,this),y&&Z("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"Please select a value."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useFeedback as a6}from"#canvas/runtime";import{useEffect as s6,useState as Y1}from"react";var q4=M.object({shareId:M.string(),url:M.string(),revision:M.number(),createdAt:M.string(),ownerToken:M.string().optional(),expiresAt:M.string().optional(),lastFeedbackAt:M.string().optional(),encryptionKey:M.string().optional()}),y6=M.object({revision:M.number(),label:M.string().optional(),canvasFiles:M.array(M.object({filename:M.string(),diffStats:M.object({added:M.number(),removed:M.number()}).optional()})),createdAt:M.string(),hasFeedback:M.boolean(),feedbackConsumed:M.boolean(),response:M.string().optional()}).passthrough(),m6=M.object({encryption:M.object({alg:M.literal("AES-GCM"),v:M.literal(1)}).optional(),origin:M.object({sessionId:M.string().optional(),label:M.string().optional(),revision:M.number().optional(),createdAt:M.string().optional()}).optional(),currentRevision:M.number().optional(),revisions:M.array(y6).optional(),canvasFiles:M.array(M.string()).optional(),projectRoot:M.string().optional(),shares:M.array(q4).optional(),shareEnabled:M.boolean().optional()}).passthrough(),BW=M.object({entries:M.array(M.object({name:M.string(),type:M.enum(["file","dir"])}))}),x6=M.object({id:M.string(),shareId:M.string(),revision:M.number(),submittedAt:M.string(),author:g1,annotations:M.array(h1.omit({source:!0,author:!0})),generalNote:M.string().optional()}),_W=M.object({entries:M.array(x6)}),MW=M.union([M.object({ok:M.literal(!0),share:q4}),M.object({ok:M.literal(!1).optional(),error:M.string().optional()})]),UW=M.union([M.object({ok:M.literal(!0)}),M.object({ok:M.literal(!1).optional(),error:M.string().optional()})]);async function X4($){let J=u6($);return crypto.subtle.importKey("raw",J,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}async function Y4($,J){let Q=H4(J);if(Q.byteLength<28)throw Error("Ciphertext too short");let q=Q.subarray(0,12),W=Q.subarray(12),X=await crypto.subtle.decrypt({name:"AES-GCM",iv:q},$,W);return new TextDecoder().decode(X)}function H4($){let J=atob($),Q=new Uint8Array(J.length);for(let q=0;q<J.length;q++)Q[q]=J.charCodeAt(q);return Q}function u6($){let J=$.replace(/-/g,"+").replace(/_/g,"/")+"===".slice(($.length+3)%4);return H4(J)}function p6(){if(typeof window>"u")return null;let $=window.location.hash.replace(/^#/,"");if(!$)return null;for(let J of $.split("&")){let[Q,q]=J.split("=");if(Q==="k"&&q)return decodeURIComponent(q)}return null}function l6(){if(typeof window<"u"&&window.__CANVAS_SHARE__?.shareId){let J=p6();return{isShared:!0,shareId:window.__CANVAS_SHARE__.shareId,encryptionKey:J?X4(J):null}}return{isShared:!1,sessionId:typeof window<"u"?window.location.pathname.replace("/s/",""):""}}var l=l6();function c6(){return l.isShared&&l.encryptionKey!==null}function d6(){return l.isShared?l.shareId:l.sessionId}function i6($,J){let Q=$.replace(/\.jsx$/,".js");if(l.isShared)return`/s/${l.shareId}/canvas/${encodeURIComponent(Q)}`;let q=J?`?rev=${J}&t=${Date.now()}`:`?t=${Date.now()}`;return`/api/session/${l.sessionId}/canvas/${encodeURIComponent(Q)}${q}`}function r6(){if(l.isShared)return`/s/${l.shareId}/upload`;return`/api/session/${l.sessionId}/upload`}function p1($,J){if(l.isShared)throw Error("Secret inputs are available only on the local canvas daemon");return`/api/session/${encodeURIComponent(l.sessionId)}/secrets/${encodeURIComponent($)}/${J}`}async function l1($){let J=await $.json().catch(()=>null);if(typeof J==="object"&&J!==null&&"error"in J&&typeof J.error==="string")return Error(J.error);return Error(`Secret API request failed with status ${$.status}`)}async function G4($){let J=await fetch(p1($,"status"),{cache:"no-store"});if(!J.ok)throw await l1(J);let Q=await J.json();return typeof Q==="object"&&Q!==null&&"ready"in Q&&Q.ready===!0}async function B4($,J){let Q=await fetch(p1($,"value"),{method:"POST",headers:{"Content-Type":"application/json"},cache:"no-store",body:JSON.stringify({value:J})});if(!Q.ok)throw await l1(Q)}async function _4($){let J=await fetch(p1($,"value"),{method:"DELETE",cache:"no-store"});if(!J.ok)throw await l1(J)}var o6=async($,J)=>{let Q=i6($,J);if(!c6())return import(Q);let q=await fetch(Q);if(!q.ok)throw Error(`canvas ${q.status}`);let W=await q.text(),X=await l.encryptionKey,Y=await Y4(X,W),G=new Blob([Y],{type:"application/javascript"}),H=URL.createObjectURL(G);try{return await import(H)}finally{setTimeout(()=>URL.revokeObjectURL(H),0)}};var n6=!l.isShared,zW=!l.isShared,AW={get sessionId(){return d6()},isShared:l.isShared,fsAvailable:n6,uploadUrl:r6,loadCanvasModule:o6};import{jsxDEV as $$}from"react/jsx-dev-runtime";var t6=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/,e6=/^[A-Za-z_][A-Za-z0-9_]*$/;function $8({id:$,label:J,env:Q,placeholder:q,required:W}){let[X,Y]=Y1(""),[G,H]=Y1(!1),[B,_]=Y1(!l.isShared),[N,F]=Y1(null),z=t6.test($),w=e6.test(Q),L=!l.isShared;s6(()=>{if(!L||!z){_(!1);return}let T=!0;return G4($).then((y)=>{if(T)H(y)}).catch((y)=>{if(T)F(y instanceof Error?y.message:"Could not read secret status")}).finally(()=>{if(T)_(!1)}),()=>{T=!1}},[$,L,z]);let A=G?`**${J}**
64
- Secret is ready. Field: \`${$}\`. Environment variable: \`${Q}\`.
65
- `:"";a6(`secret:${$}`,A,{label:J,required:W&&L});let j=async()=>{if(!X||!z||!w)return;_(!0),F(null);try{await B4($,X),Y(""),H(!0)}catch(T){F(T instanceof Error?T.message:"Could not store secret")}finally{_(!1)}},g=async()=>{_(!0),F(null);try{await _4($),H(!1)}catch(T){F(T instanceof Error?T.message:"Could not clear secret")}finally{_(!1)}};if(!L)return $$("div",{"data-md":"secretinput","data-md-label":J,className:"-mx-4 px-4 py-3 my-1 rounded-lg bg-accent-amber-muted",children:[$$("div",{className:"text-[13px] font-body font-medium text-text-primary",children:J},void 0,!1,void 0,this),$$("p",{className:"text-[12px] font-body text-text-secondary mt-1",children:"Secret input is unavailable in shared canvases. Open this runbook on the author's local canvas daemon."},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let k=!z?"Secret field IDs may contain letters, numbers, dots, underscores, and hyphens.":!w?"Environment variable names must use letters, numbers, and underscores and may not start with a number.":null;return $$("div",{"data-md":"secretinput","data-md-label":J,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[$$("div",{className:"flex items-baseline justify-between gap-3 mb-2",children:[$$("div",{className:"flex items-baseline gap-2",children:[$$("span",{className:"text-[13px] font-body font-medium text-text-primary",children:J},void 0,!1,void 0,this),W&&$$("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$$("span",{className:`text-[11px] font-body ${G?"text-accent-green":"text-text-tertiary"}`,children:B?"Working…":G?"Ready in memory":"Not stored"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$$("div",{className:"flex gap-2",children:[$$("input",{type:"password",value:X,onChange:(T)=>Y(T.target.value),onKeyDown:(T)=>{if(T.key==="Enter")T.preventDefault(),j()},placeholder:q||"Paste secret value",autoComplete:"off",spellCheck:!1,disabled:B||!!k,className:"min-w-0 flex-1 bg-bg-input text-[13px] font-mono text-text-primary rounded-lg px-3 py-2 focus:outline-none border border-border-subtle focus:border-border-hover placeholder:text-text-tertiary disabled:opacity-50 transition-colors"},void 0,!1,void 0,this),$$("button",{type:"button",onClick:()=>void j(),disabled:B||!X||!!k,className:"px-3 py-2 rounded-lg bg-btn-primary text-btn-primary-text text-[12px] font-body font-medium disabled:opacity-40 disabled:cursor-default",children:G?"Replace":"Store"},void 0,!1,void 0,this),G&&$$("button",{type:"button",onClick:()=>void g(),disabled:B,className:"px-3 py-2 rounded-lg border border-border-subtle text-text-secondary text-[12px] font-body font-medium hover:border-border-hover disabled:opacity-40",children:"Clear"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),$$("p",{className:"text-[11px] font-body text-text-tertiary mt-1.5",children:["Stored only in daemon memory. The agent receives field ",$," for ",Q,", not the value."]},void 0,!0,void 0,this),(k||N)&&$$("p",{className:"text-[11px] text-accent-red font-body mt-1",children:k||N},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}export{d7 as useFeedback,h6 as UserInput,I6 as Task,D6 as Table,C6 as Section,$8 as SecretInput,Z6 as RangeInput,V6 as Priority,R6 as Note,t5 as MultiChoice,S6 as Mermaid,L6 as Markdown,$4 as Item,N6 as ImageView,_6 as FilePreview,W6 as Diff,J6 as CodeBlock,s5 as Choice,B3 as Checklist,G3 as Callout};
53
+ `+t+`</thead>
54
+ `+s+`</table>
55
+ `}tablerow({text:e}){return`<tr>
56
+ ${e}</tr>
57
+ `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
58
+ `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${ye(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let s=this.parser.parseInline(n),r=hr(e);if(r===null)return s;e=r;let o='<a href="'+e+'"';return t&&(o+=' title="'+ye(t)+'"'),o+=">"+s+"</a>",o}image({href:e,title:t,text:n,tokens:s}){s&&(n=this.parser.parseInline(s,this.parser.textRenderer));let r=hr(e);if(r===null)return ye(n);e=r;let o=`<img src="${e}" alt="${ye(n)}"`;return t&&(o+=` title="${ye(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):("escaped"in e)&&e.escaped?e.text:ye(e.text)}},En=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},fe=class e{options;renderer;textRenderer;constructor(t){this.options=t||Ve,this.options.renderer=this.options.renderer||new Bt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new En}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(t){this.renderer.parser=this;let n="";for(let s=0;s<t.length;s++){let r=t[s];if(this.options.extensions?.renderers?.[r.type]){let a=r,l=this.options.extensions.renderers[a.type].call({parser:this},a);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(a.type)){n+=l||"";continue}}let o=r;switch(o.type){case"space":{n+=this.renderer.space(o);break}case"hr":{n+=this.renderer.hr(o);break}case"heading":{n+=this.renderer.heading(o);break}case"code":{n+=this.renderer.code(o);break}case"table":{n+=this.renderer.table(o);break}case"blockquote":{n+=this.renderer.blockquote(o);break}case"list":{n+=this.renderer.list(o);break}case"checkbox":{n+=this.renderer.checkbox(o);break}case"html":{n+=this.renderer.html(o);break}case"def":{n+=this.renderer.def(o);break}case"paragraph":{n+=this.renderer.paragraph(o);break}case"text":{n+=this.renderer.text(o);break}default:{let a='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw Error(a)}}}return n}parseInline(t,n=this.renderer){this.renderer.parser=this;let s="";for(let r=0;r<t.length;r++){let o=t[r];if(this.options.extensions?.renderers?.[o.type]){let l=this.options.extensions.renderers[o.type].call({parser:this},o);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(o.type)){s+=l||"";continue}}let a=o;switch(a.type){case"escape":{s+=n.text(a);break}case"html":{s+=n.html(a);break}case"link":{s+=n.link(a);break}case"image":{s+=n.image(a);break}case"checkbox":{s+=n.checkbox(a);break}case"strong":{s+=n.strong(a);break}case"em":{s+=n.em(a);break}case"codespan":{s+=n.codespan(a);break}case"br":{s+=n.br(a);break}case"del":{s+=n.del(a);break}case"text":{s+=n.text(a);break}default:{let l='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw Error(l)}}}return s}},ht=class{options;block;constructor(e){this.options=e||Ve}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?pe.lex:pe.lexInline}provideParser(e=this.block){return e?fe.parse:fe.parseInline}},So=class{defaults=vn();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=fe;Renderer=Bt;TextRenderer=En;Lexer=pe;Tokenizer=Ht;Hooks=ht;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let s of e)switch(n=n.concat(t.call(this,s)),s.type){case"table":{let r=s;for(let o of r.header)n=n.concat(this.walkTokens(o.tokens,t));for(let o of r.rows)for(let a of o)n=n.concat(this.walkTokens(a.tokens,t));break}case"list":{let r=s;n=n.concat(this.walkTokens(r.items,t));break}default:{let r=s;this.defaults.extensions?.childTokens?.[r.type]?this.defaults.extensions.childTokens[r.type].forEach((o)=>{let a=r[o].flat(1/0);n=n.concat(this.walkTokens(a,t))}):r.tokens&&(n=n.concat(this.walkTokens(r.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach((n)=>{let s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach((r)=>{if(!r.name)throw Error("extension name required");if("renderer"in r){let o=t.renderers[r.name];o?t.renderers[r.name]=function(...a){let l=r.renderer.apply(this,a);return l===!1&&(l=o.apply(this,a)),l}:t.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw Error("extension level must be 'block' or 'inline'");let o=t[r.level];o?o.unshift(r.tokenizer):t[r.level]=[r.tokenizer],r.start&&(r.level==="block"?t.startBlock?t.startBlock.push(r.start):t.startBlock=[r.start]:r.level==="inline"&&(t.startInline?t.startInline.push(r.start):t.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(t.childTokens[r.name]=r.childTokens)}),s.extensions=t),n.renderer){let r=this.defaults.renderer||new Bt(this.defaults);for(let o in n.renderer){if(!(o in r))throw Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let a=o,l=n.renderer[a],i=r[a];r[a]=(...c)=>{let d=l.apply(r,c);return d===!1&&(d=i.apply(r,c)),d||""}}s.renderer=r}if(n.tokenizer){let r=this.defaults.tokenizer||new Ht(this.defaults);for(let o in n.tokenizer){if(!(o in r))throw Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let a=o,l=n.tokenizer[a],i=r[a];r[a]=(...c)=>{let d=l.apply(r,c);return d===!1&&(d=i.apply(r,c)),d}}s.tokenizer=r}if(n.hooks){let r=this.defaults.hooks||new ht;for(let o in n.hooks){if(!(o in r))throw Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let a=o,l=n.hooks[a],i=r[a];ht.passThroughHooks.has(o)?r[a]=(c)=>{if(this.defaults.async&&ht.passThroughHooksRespectAsync.has(o))return(async()=>{let f=await l.call(r,c);return i.call(r,f)})();let d=l.call(r,c);return i.call(r,d)}:r[a]=(...c)=>{if(this.defaults.async)return(async()=>{let f=await l.apply(r,c);return f===!1&&(f=await i.apply(r,c)),f})();let d=l.apply(r,c);return d===!1&&(d=i.apply(r,c)),d}}s.hooks=r}if(n.walkTokens){let r=this.defaults.walkTokens,o=n.walkTokens;s.walkTokens=function(a){let l=[];return l.push(o.call(this,a)),r&&(l=l.concat(r.call(this,a))),l}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return pe.lex(e,t??this.defaults)}parser(e,t){return fe.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let s={...n},r={...this.defaults,...s},o=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&s.async===!1)return o(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 t>"u"||t===null)return o(Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return o(Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=e),r.async)return(async()=>{let a=r.hooks?await r.hooks.preprocess(t):t,l=await(r.hooks?await r.hooks.provideLexer(e):e?pe.lex:pe.lexInline)(a,r),i=r.hooks?await r.hooks.processAllTokens(l):l;r.walkTokens&&await Promise.all(this.walkTokens(i,r.walkTokens));let c=await(r.hooks?await r.hooks.provideParser(e):e?fe.parse:fe.parseInline)(i,r);return r.hooks?await r.hooks.postprocess(c):c})().catch(o);try{r.hooks&&(t=r.hooks.preprocess(t));let a=(r.hooks?r.hooks.provideLexer(e):e?pe.lex:pe.lexInline)(t,r);r.hooks&&(a=r.hooks.processAllTokens(a)),r.walkTokens&&this.walkTokens(a,r.walkTokens);let l=(r.hooks?r.hooks.provideParser(e):e?fe.parse:fe.parseInline)(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return o(a)}}}onError(e,t){return(n)=>{if(n.message+=`
59
+ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error occurred:</p><pre>"+ye(n.message+"",!0)+"</pre>";return t?Promise.resolve(s):s}if(t)return Promise.reject(n);throw n}}},qe=new So;function D(e,t){return qe.parse(e,t)}D.options=D.setOptions=function(e){return qe.setOptions(e),D.defaults=qe.defaults,xr(D.defaults),D};D.getDefaults=vn;D.defaults=Ve;D.use=function(...e){return qe.use(...e),D.defaults=qe.defaults,xr(D.defaults),D};D.walkTokens=function(e,t){return qe.walkTokens(e,t)};D.parseInline=qe.parseInline;D.Parser=fe;D.parser=fe.parse;D.Renderer=Bt;D.TextRenderer=En;D.Lexer=pe;D.lexer=pe.lex;D.Tokenizer=Ht;D.Hooks=ht;D.parse=D;var{options:tl,setOptions:nl,use:rl,walkTokens:sl,parseInline:ol}=D;var al=fe.parse,il=pe.lex;import Rr from"react";import{jsxDEV as Cn}from"react/jsx-dev-runtime";D.setOptions({gfm:!0,breaks:!1});var To=new Set(["a","abbr","b","br","code","del","em","i","kbd","mark","q","s","small","span","strong","sub","sup","time","u"]),Ao=new Set(["Priority"]);function Ro(e){if(typeof e==="string"||typeof e==="number")return!0;if(!Rr.isValidElement(e))return!1;if(typeof e!=="object"||e===null||!("type"in e))return!1;let t=e.type;if(typeof t==="string")return To.has(t);if(typeof t==="function"){let n="displayName"in t&&typeof t.displayName==="string"?t.displayName:t.name;return n?Ao.has(n):!1}return!1}function Eo(e,t){let n=e.trim();if(!n)return null;let s=D.parse(n,{async:!1});return Cn("div",{className:"prose-canvas","data-md":"markdown","data-md-source":n,dangerouslySetInnerHTML:{__html:s}},t,!1,void 0,this)}function Co(e,t){return Cn("div",{className:"prose-canvas",children:e.map((n,s)=>{if(typeof n==="string"||typeof n==="number"){let r=D.parseInline(String(n),{async:!1});return Cn("span",{dangerouslySetInnerHTML:{__html:r}},s,!1,void 0,this)}return n})},t,!1,void 0,this)}function Me(e){let t=Rr.Children.toArray(e);if(t.length===0)return null;let n=[],s=[],r=0,o=()=>{if(s.length===0)return;if(s.some((l)=>typeof l!=="string"&&typeof l!=="number"))n.push(Co(s,`md-${r++}`));else{let l=Eo(s.join(""),`md-${r++}`);if(l)n.push(l)}s=[]};for(let a of t)if(Ro(a))s.push(a);else o(),n.push(a);return o(),n}import{jsxDEV as Nn}from"react/jsx-dev-runtime";var No={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 Io({type:e="info",children:t}){let n=No[e];return Nn("div",{className:`${n.bg} relative rounded-lg px-5 py-4 mt-3 flex gap-3 items-start`,"data-md":"callout","data-md-type":e,children:[Nn("span",{"aria-hidden":"true",className:`${n.iconColor} opacity-70 text-base leading-relaxed flex-shrink-0 mt-px`,children:n.icon},void 0,!1,void 0,this),Nn("div",{className:"text-body text-text-secondary leading-relaxed",children:Me(t)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as Xe}from"react/jsx-dev-runtime";function Lo({items:e}){return Xe("ul",{className:"space-y-1 mt-3","data-md":"checklist",children:e.map((t,n)=>Xe("li",{"data-md":"checklist-item","data-md-label":t.label,className:"relative flex items-start gap-2.5 py-1",children:[Xe("span",{className:`w-4 h-4 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5 transition-all ${t.checked?"bg-accent-green":"border-[1.5px] border-border-hover"}`,children:t.checked&&Xe("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:Xe("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),Xe("span",{className:`text-body font-body ${t.checked?"text-text-tertiary line-through decoration-border-hover":"text-text-secondary"}`,children:t.label},void 0,!1,void 0,this)]},n,!0,void 0,this))},void 0,!1,void 0,this)}import{useAnnotations as Zr,useResponseRegistration as es}from"#canvas/runtime";import{useEffect as ts,useMemo as ns,useRef as rs,useState as ss}from"react";import{AnnotationCtx as hu,AnnotationHostContext as mu,SessionContext as gu,useAnnotationHost as xu,useAnnotations as yu}from"@fabrika/annotations/runtime";function In(e,t){let n=[],s=Mo(e);for(let r of s){let o=document.createRange();if(o.selectNodeContents(r),r===e.startContainer)o.setStart(r,e.startOffset);if(r===e.endContainer)o.setEnd(r,e.endOffset);let a=o.toString();if(!a||!a.trim())continue;let l=document.createElement("mark");l.setAttribute("data-annotation-id",t);try{o.surroundContents(l)}catch{let i=o.extractContents();l.appendChild(i),o.insertNode(l)}n.push(l)}return n}function Ln(e){let t=e.parentElement;if(t?.classList.contains("select-none"))return!1;if(t?.closest("[data-annotation-id]"))return!1;return!0}function Mo(e){let t=[],n=e.commonAncestorContainer;if(n.nodeType===Node.TEXT_NODE)return t.push(n),t;let s=document.createTreeWalker(n,NodeFilter.SHOW_TEXT),r;while(r=s.nextNode()){if(!Ln(r))continue;if(e.intersectsNode(r))t.push(r)}return t}function Mn(e,t){for(let n of t){if(e.querySelector(`[data-annotation-id="${n.id}"]`))continue;let s=n.snippet;if(!s)continue;let{fullText:r,textNodes:o}=$o(e),a=[],l=0;while(!0){let u=r.indexOf(s,l);if(u===-1)break;a.push(u),l=u+1}let[i]=a;if(i===void 0)continue;let c=i;if(a.length>1&&n.context){let u=-1;for(let h of a){let y=0;if(n.context.before){let T=r.slice(Math.max(0,h-80),h);if(T.includes(n.context.before))y+=2;else if(n.context.before.length>10&&T.includes(n.context.before.slice(-10)))y+=1}if(n.context.after){let T=r.slice(h+s.length,h+s.length+80);if(T.includes(n.context.after))y+=2;else if(n.context.after.length>10&&T.includes(n.context.after.slice(0,10)))y+=1}if(y>u)u=y,c=h}}let d=c,f=c+s.length,g=Er(o,d),x=Er(o,f);if(!g||!x)continue;try{let u=document.createRange();u.setStart(g.node,g.offset),u.setEnd(x.node,x.offset),In(u,n.id)}catch{}}}function $o(e){let t=[],n="",s=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),r;while(r=s.nextNode()){if(!Ln(r))continue;t.push({node:r,start:n.length}),n+=r.textContent||""}return{fullText:n,textNodes:t}}function Er(e,t){for(let n=e.length-1;n>=0;n--){let s=e[n];if(!s||s.start>t)continue;let r=t-s.start,o=s.node.textContent?.length??0;if(r<=o)return{node:s.node,offset:r}}return null}function gt(e){return{kind:e.kind,owns:(t)=>e.parse(t)!==null,find:(t,n)=>{let s=e.parse(t);return s===null?null:e.find(s,n)},restore:(t,n)=>{let s=e.parse(n.snippet);if(s===null)return;e.restore?.(s,t,n)},describe:(t)=>{let n=e.parse(t);if(n===null||!e.describe)return null;return e.describe(n)}}}function Cr(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),n="";for(let s=t.nextNode();s;s=t.nextNode()){let r=s.parentElement?.closest("[aria-hidden='true']");if(r&&e.contains(r))continue;n+=s.textContent??""}return n.trim()}function qt(e,t,n){return{selector:e,snippet:(s)=>{let r=s.getAttribute(n);return r?`${t} ${r}`:null}}}var $n=[qt("[data-md='item']","[Item]","data-md-label"),qt("[data-md='section']","[Section]","data-md-title"),qt("[data-md='checklist-item']","[Checklist]","data-md-label"),qt("[data-md='image']","[Image]","data-md-src"),{selector:"[data-md='callout']",snippet:(e)=>`[Callout:${e.getAttribute("data-md-type")||"info"}] ${Cr(e).slice(0,60)||"Callout"}`},{selector:"[data-md='note']",snippet:(e)=>`[Note] ${Cr(e).slice(0,60)||"Note"}`},{selector:"[data-md='table'] tbody tr",snippet:(e)=>{let t=Array.from(e.querySelectorAll("td")).map((n)=>n.textContent?.trim()).filter(Boolean);return t.length?`[Row] ${t.join(" | ")}`:null}}],Po=["[data-md='choice-option']","[data-md='multichoice-option']","[data-md='userinput']","[data-md='rangeinput']"],Pn=$n.map((e)=>e.selector).join(", "),Nr=[...$n.map((e)=>e.selector),...Po].join(", ");function On(e){for(let t of $n)if(e.matches(t.selector))return t.snippet(e);return null}var jn={kind:"block",parse:(e)=>e.startsWith("[")?{snippet:e}:null,format:(e)=>e.snippet,find:(e,t)=>{for(let n of t.querySelectorAll(Pn)){if(!(n instanceof HTMLElement))continue;if(On(n)===e.snippet)return n}return null}};var Oo=/^\[Region:(rect|ellipse)\] ([\s\S]+) @(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*)$/;function jo(e){if(e==="rect")return"rect";if(e==="ellipse")return"ellipse";return null}function Vt(e){if(e===void 0)return null;let t=Number(e);if(!Number.isInteger(t)||t<0||t>1e4)return null;return t}function Ir(e){return{left:`${e.x/100}%`,top:`${e.y/100}%`,width:`${e.w/100}%`,height:`${e.h/100}%`}}function Wt(e){return`${(e/100).toFixed(1).replace(/\.0$/,"")}%`}function zn(e){let t=`${Wt(e.x)}-${Wt(e.x+e.w)}`,n=`${Wt(e.y)}-${Wt(e.y+e.h)}`;return`[Region] ${e.src} — ${e.shape} x ${t}, y ${n} of the image`}function Dn(e,t){for(let n of t.querySelectorAll("[data-md='image']")){if(!(n instanceof HTMLElement))continue;if(n.getAttribute("data-md-src")!==e)continue;let s=n.querySelector("[data-annotation-image]");if(s instanceof HTMLElement)return s}return null}function Lr(e,t){let n=Ir(t);e.style.left=n.left,e.style.top=n.top,e.style.width=n.width,e.style.height=n.height}function Hn(e,t,n){let s=document.createElement("div");return s.className="ann-region",s.setAttribute("data-annotation-id",n),s.setAttribute("data-annotation-region",t),Lr(s,e),s}var Gt={kind:"region",parse:(e)=>{let t=Oo.exec(e);if(!t)return null;let n=jo(t[1]),s=t[2],r=Vt(t[3]),o=Vt(t[4]),a=Vt(t[5]),l=Vt(t[6]);if(n===null||s===void 0)return null;if(r===null||o===null||a===null||l===null)return null;if(a<1||l<1)return null;return{src:s,shape:n,x:r,y:o,w:a,h:l}},format:(e)=>`[Region:${e.shape}] ${e.src} @${e.x},${e.y},${e.w},${e.h}`,find:(e,t)=>Dn(e.src,t),restore:(e,t,n)=>{if(t.querySelector(`[data-annotation-id="${n.id}"]`))return;let s=Dn(e.src,t);if(!s)return;s.appendChild(Hn(e,e.shape,n.id))},describe:zn};var Bn={kind:"text",parse:(e)=>e?{text:e}:null,format:(e)=>e.text,find:()=>null,restore:(e,t,n)=>{Mn(t,[n])}};var Do=[gt(Gt),gt(jn),gt(Bn)];import{AnnotationCtx as zc,SessionContext as Hc,useAnnotationHost as Bc}from"@fabrika/annotations/runtime";import{useEffect as qc,useRef as Vc,useState as Wc}from"react";var P;(function(e){e.assertEqual=(r)=>{};function t(r){}e.assertIs=t;function n(r){throw Error()}e.assertNever=n,e.arrayToEnum=(r)=>{let o={};for(let a of r)o[a]=a;return o},e.getValidEnumValues=(r)=>{let o=e.objectKeys(r).filter((l)=>typeof r[r[l]]!=="number"),a={};for(let l of o)a[l]=r[l];return e.objectValues(a)},e.objectValues=(r)=>e.objectKeys(r).map(function(o){return r[o]}),e.objectKeys=typeof Object.keys==="function"?(r)=>Object.keys(r):(r)=>{let o=[];for(let a in r)if(Object.prototype.hasOwnProperty.call(r,a))o.push(a);return o},e.find=(r,o)=>{for(let a of r)if(o(a))return a;return},e.isInteger=typeof Number.isInteger==="function"?(r)=>Number.isInteger(r):(r)=>typeof r==="number"&&Number.isFinite(r)&&Math.floor(r)===r;function s(r,o=" | "){return r.map((a)=>typeof a==="string"?`'${a}'`:a).join(o)}e.joinValues=s,e.jsonStringifyReplacer=(r,o)=>{if(typeof o==="bigint")return o.toString();return o}})(P||(P={}));var Mr;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(Mr||(Mr={}));var v=P.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Te=(e)=>{switch(typeof e){case"undefined":return v.undefined;case"string":return v.string;case"number":return Number.isNaN(e)?v.nan:v.number;case"boolean":return v.boolean;case"function":return v.function;case"bigint":return v.bigint;case"symbol":return v.symbol;case"object":if(Array.isArray(e))return v.array;if(e===null)return v.null;if(e.then&&typeof e.then==="function"&&e.catch&&typeof e.catch==="function")return v.promise;if(typeof Map<"u"&&e instanceof Map)return v.map;if(typeof Set<"u"&&e instanceof Set)return v.set;if(typeof Date<"u"&&e instanceof Date)return v.date;return v.object;default:return v.unknown}};var p=P.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"]);class ce extends Error{get errors(){return this.issues}constructor(e){super();this.issues=[],this.addIssue=(n)=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let t=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,t);else this.__proto__=t;this.name="ZodError",this.issues=e}format(e){let t=e||function(r){return r.message},n={_errors:[]},s=(r)=>{for(let o of r.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)n._errors.push(t(o));else{let a=n,l=0;while(l<o.path.length){let i=o.path[l];if(l!==o.path.length-1)a[i]=a[i]||{_errors:[]};else a[i]=a[i]||{_errors:[]},a[i]._errors.push(t(o));a=a[i],l++}}};return s(this),n}static assert(e){if(!(e instanceof ce))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,P.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=(t)=>t.message){let t={},n=[];for(let s of this.issues)if(s.path.length>0){let r=s.path[0];t[r]=t[r]||[],t[r].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}ce.create=(e)=>new ce(e);var zo=(e,t)=>{let n;switch(e.code){case p.invalid_type:if(e.received===v.undefined)n="Required";else n=`Expected ${e.expected}, received ${e.received}`;break;case p.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,P.jsonStringifyReplacer)}`;break;case p.unrecognized_keys:n=`Unrecognized key(s) in object: ${P.joinValues(e.keys,", ")}`;break;case p.invalid_union:n="Invalid input";break;case p.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${P.joinValues(e.options)}`;break;case p.invalid_enum_value:n=`Invalid enum value. Expected ${P.joinValues(e.options)}, received '${e.received}'`;break;case p.invalid_arguments:n="Invalid function arguments";break;case p.invalid_return_type:n="Invalid function return type";break;case p.invalid_date:n="Invalid date";break;case p.invalid_string:if(typeof e.validation==="object")if("includes"in e.validation){if(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==="number")n=`${n} at one or more positions greater than or equal to ${e.validation.position}`}else if("startsWith"in e.validation)n=`Invalid input: must start with "${e.validation.startsWith}"`;else if("endsWith"in e.validation)n=`Invalid input: must end with "${e.validation.endsWith}"`;else P.assertNever(e.validation);else if(e.validation!=="regex")n=`Invalid ${e.validation}`;else n="Invalid";break;case p.too_small:if(e.type==="array")n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`;else if(e.type==="string")n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`;else if(e.type==="number")n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`;else if(e.type==="bigint")n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`;else if(e.type==="date")n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`;else n="Invalid input";break;case p.too_big:if(e.type==="array")n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`;else if(e.type==="string")n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`;else if(e.type==="number")n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`;else if(e.type==="bigint")n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`;else if(e.type==="date")n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`;else n="Invalid input";break;case p.custom:n="Invalid input";break;case p.invalid_intersection_types:n="Intersection results could not be merged";break;case p.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case p.not_finite:n="Number must be finite";break;default:n=t.defaultError,P.assertNever(e)}return{message:n}},$e=zo;var Ho=$e;function xt(){return Ho}var Kt=(e)=>{let{data:t,path:n,errorMaps:s,issueData:r}=e,o=[...n,...r.path||[]],a={...r,path:o};if(r.message!==void 0)return{...r,path:o,message:r.message};let l="",i=s.filter((c)=>!!c).slice().reverse();for(let c of i)l=c(a,{data:t,defaultError:l}).message;return{...r,path:o,message:l}};function b(e,t){let n=xt(),s=Kt({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===$e?void 0:$e].filter((r)=>!!r)});e.common.issues.push(s)}class ee{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray(e,t){let n=[];for(let s of t){if(s.status==="aborted")return A;if(s.status==="dirty")e.dirty();n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){let n=[];for(let s of t){let r=await s.key,o=await s.value;n.push({key:r,value:o})}return ee.mergeObjectSync(e,n)}static mergeObjectSync(e,t){let n={};for(let s of t){let{key:r,value:o}=s;if(r.status==="aborted")return A;if(o.status==="aborted")return A;if(r.status==="dirty")e.dirty();if(o.status==="dirty")e.dirty();if(r.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet))n[r.value]=o.value}return{status:e.value,value:n}}}var A=Object.freeze({status:"aborted"}),Qe=(e)=>({status:"dirty",value:e}),oe=(e)=>({status:"valid",value:e}),Fn=(e)=>e.status==="aborted",Un=(e)=>e.status==="dirty",We=(e)=>e.status==="valid",yt=(e)=>typeof Promise<"u"&&e instanceof Promise;var w;(function(e){e.errToObj=(t)=>typeof t==="string"?{message:t}:t||{},e.toString=(t)=>typeof t==="string"?t:t?.message})(w||(w={}));class he{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}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 $r=(e,t)=>{if(We(t))return{success:!0,data:t.value};else{if(!e.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new ce(e.common.issues);return this._error=n,this._error}}}};function E(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:s,description:r}=e;if(t&&(n||s))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(t)return{errorMap:t,description:r};return{errorMap:(a,l)=>{let{message:i}=e;if(a.code==="invalid_enum_value")return{message:i??l.defaultError};if(typeof l.data>"u")return{message:i??s??l.defaultError};if(a.code!=="invalid_type")return{message:l.defaultError};return{message:i??n??l.defaultError}},description:r}}class L{get description(){return this._def.description}_getType(e){return Te(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Te(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ee,ctx:{common:e.parent.common,data:e.data,parsedType:Te(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(yt(t))throw Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Te(e)},s=this._parseSync({data:e,path:n.path,parent:n});return $r(n,s)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Te(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:t});return We(n)?{value:n.value}:{issues:t.common.issues}}catch(n){if(n?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then((n)=>We(n)?{value:n.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Te(e)},s=this._parse({data:e,path:n.path,parent:n}),r=await(yt(s)?s:Promise.resolve(s));return $r(n,r)}refine(e,t){let n=(s)=>{if(typeof t==="string"||typeof t>"u")return{message:t};else if(typeof t==="function")return t(s);else return t};return this._refinement((s,r)=>{let o=e(s),a=()=>r.addIssue({code:p.custom,...n(s)});if(typeof Promise<"u"&&o instanceof Promise)return o.then((l)=>{if(!l)return a(),!1;else return!0});if(!o)return a(),!1;else return!0})}refinement(e,t){return this._refinement((n,s)=>{if(!e(n))return s.addIssue(typeof t==="function"?t(n,s):t),!1;else return!0})}_refinement(e){return new ke({schema:this,typeName:R.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,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:(t)=>this["~validate"](t)}}optional(){return ve.create(this,this._def)}nullable(){return Pe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return be.create(this)}promise(){return rt.create(this,this._def)}or(e){return _t.create([this,e],this._def)}and(e){return St.create(this,e,this._def)}transform(e){return new ke({...E(this._def),schema:this,typeName:R.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e==="function"?e:()=>e;return new Et({...E(this._def),innerType:this,defaultValue:t,typeName:R.ZodDefault})}brand(){return new Gn({typeName:R.ZodBranded,type:this,...E(this._def)})}catch(e){let t=typeof e==="function"?e:()=>e;return new Ct({...E(this._def),innerType:this,catchValue:t,typeName:R.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return nn.create(this,e)}readonly(){return Nt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var Bo=/^c[^\s-]{8,}$/i,Fo=/^[0-9a-z]+$/,Uo=/^[0-9A-HJKMNP-TV-Z]{26}$/i,qo=/^[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,Vo=/^[a-z0-9_-]{21}$/i,Wo=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Go=/^[-+]?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)?)??$/,Ko=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Yo="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",qn,Jo=/^(?:(?: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])$/,Xo=/^(?:(?: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])$/,Qo=/^(([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]))$/,Zo=/^(([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])$/,ea=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ta=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Pr="((\\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])))",na=new RegExp(`^${Pr}$`);function Or(e){let t="[0-5]\\d";if(e.precision)t=`${t}\\.\\d{${e.precision}}`;else if(e.precision==null)t=`${t}(\\.\\d+)?`;let n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function ra(e){return new RegExp(`^${Or(e)}$`)}function sa(e){let t=`${Pr}T${Or(e)}`,n=[];if(n.push(e.local?"Z?":"Z"),e.offset)n.push("([+-]\\d{2}:?\\d{2})");return t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function oa(e,t){if((t==="v4"||!t)&&Jo.test(e))return!0;if((t==="v6"||!t)&&Qo.test(e))return!0;return!1}function aa(e,t){if(!Wo.test(e))return!1;try{let[n]=e.split(".");if(!n)return!1;let s=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),r=JSON.parse(atob(s));if(typeof r!=="object"||r===null)return!1;if("typ"in r&&r?.typ!=="JWT")return!1;if(!r.alg)return!1;if(t&&r.alg!==t)return!1;return!0}catch{return!1}}function ia(e,t){if((t==="v4"||!t)&&Xo.test(e))return!0;if((t==="v6"||!t)&&Zo.test(e))return!0;return!1}class Re extends L{_parse(e){if(this._def.coerce)e.data=String(e.data);if(this._getType(e)!==v.string){let r=this._getOrReturnCtx(e);return b(r,{code:p.invalid_type,expected:v.string,received:r.parsedType}),A}let n=new ee,s=void 0;for(let r of this._def.checks)if(r.kind==="min"){if(e.data.length<r.value)s=this._getOrReturnCtx(e,s),b(s,{code:p.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),n.dirty()}else if(r.kind==="max"){if(e.data.length>r.value)s=this._getOrReturnCtx(e,s),b(s,{code:p.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),n.dirty()}else if(r.kind==="length"){let o=e.data.length>r.value,a=e.data.length<r.value;if(o||a){if(s=this._getOrReturnCtx(e,s),o)b(s,{code:p.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message});else if(a)b(s,{code:p.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message});n.dirty()}}else if(r.kind==="email"){if(!Ko.test(e.data))s=this._getOrReturnCtx(e,s),b(s,{validation:"email",code:p.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="emoji"){if(!qn)qn=new RegExp(Yo,"u");if(!qn.test(e.data))s=this._getOrReturnCtx(e,s),b(s,{validation:"emoji",code:p.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="uuid"){if(!qo.test(e.data))s=this._getOrReturnCtx(e,s),b(s,{validation:"uuid",code:p.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="nanoid"){if(!Vo.test(e.data))s=this._getOrReturnCtx(e,s),b(s,{validation:"nanoid",code:p.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="cuid"){if(!Bo.test(e.data))s=this._getOrReturnCtx(e,s),b(s,{validation:"cuid",code:p.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="cuid2"){if(!Fo.test(e.data))s=this._getOrReturnCtx(e,s),b(s,{validation:"cuid2",code:p.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="ulid"){if(!Uo.test(e.data))s=this._getOrReturnCtx(e,s),b(s,{validation:"ulid",code:p.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),b(s,{validation:"url",code:p.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="regex"){if(r.regex.lastIndex=0,!r.regex.test(e.data))s=this._getOrReturnCtx(e,s),b(s,{validation:"regex",code:p.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="trim")e.data=e.data.trim();else if(r.kind==="includes"){if(!e.data.includes(r.value,r.position))s=this._getOrReturnCtx(e,s),b(s,{code:p.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),n.dirty()}else if(r.kind==="toLowerCase")e.data=e.data.toLowerCase();else if(r.kind==="toUpperCase")e.data=e.data.toUpperCase();else if(r.kind==="startsWith"){if(!e.data.startsWith(r.value))s=this._getOrReturnCtx(e,s),b(s,{code:p.invalid_string,validation:{startsWith:r.value},message:r.message}),n.dirty()}else if(r.kind==="endsWith"){if(!e.data.endsWith(r.value))s=this._getOrReturnCtx(e,s),b(s,{code:p.invalid_string,validation:{endsWith:r.value},message:r.message}),n.dirty()}else if(r.kind==="datetime"){if(!sa(r).test(e.data))s=this._getOrReturnCtx(e,s),b(s,{code:p.invalid_string,validation:"datetime",message:r.message}),n.dirty()}else if(r.kind==="date"){if(!na.test(e.data))s=this._getOrReturnCtx(e,s),b(s,{code:p.invalid_string,validation:"date",message:r.message}),n.dirty()}else if(r.kind==="time"){if(!ra(r).test(e.data))s=this._getOrReturnCtx(e,s),b(s,{code:p.invalid_string,validation:"time",message:r.message}),n.dirty()}else if(r.kind==="duration"){if(!Go.test(e.data))s=this._getOrReturnCtx(e,s),b(s,{validation:"duration",code:p.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="ip"){if(!oa(e.data,r.version))s=this._getOrReturnCtx(e,s),b(s,{validation:"ip",code:p.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="jwt"){if(!aa(e.data,r.alg))s=this._getOrReturnCtx(e,s),b(s,{validation:"jwt",code:p.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="cidr"){if(!ia(e.data,r.version))s=this._getOrReturnCtx(e,s),b(s,{validation:"cidr",code:p.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="base64"){if(!ea.test(e.data))s=this._getOrReturnCtx(e,s),b(s,{validation:"base64",code:p.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="base64url"){if(!ta.test(e.data))s=this._getOrReturnCtx(e,s),b(s,{validation:"base64url",code:p.invalid_string,message:r.message}),n.dirty()}else P.assertNever(r);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement((s)=>e.test(s),{validation:t,code:p.invalid_string,...w.errToObj(n)})}_addCheck(e){return new Re({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...w.errToObj(e)})}url(e){return this._addCheck({kind:"url",...w.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...w.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...w.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...w.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...w.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...w.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...w.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...w.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...w.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...w.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...w.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...w.errToObj(e)})}datetime(e){if(typeof e==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e});return this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...w.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){if(typeof e==="string")return this._addCheck({kind:"time",precision:null,message:e});return this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...w.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...w.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...w.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...w.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...w.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...w.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...w.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...w.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...w.errToObj(t)})}nonempty(e){return this.min(1,w.errToObj(e))}trim(){return new Re({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Re({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Re({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e)=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find((e)=>e.kind==="date")}get isTime(){return!!this._def.checks.find((e)=>e.kind==="time")}get isDuration(){return!!this._def.checks.find((e)=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find((e)=>e.kind==="email")}get isURL(){return!!this._def.checks.find((e)=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find((e)=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find((e)=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find((e)=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find((e)=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find((e)=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find((e)=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find((e)=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find((e)=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find((e)=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find((e)=>e.kind==="base64url")}get minLength(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e}get maxLength(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e}}Re.create=(e)=>new Re({checks:[],typeName:R.ZodString,coerce:e?.coerce??!1,...E(e)});function la(e,t){let n=(e.toString().split(".")[1]||"").length,s=(t.toString().split(".")[1]||"").length,r=n>s?n:s,o=Number.parseInt(e.toFixed(r).replace(".","")),a=Number.parseInt(t.toFixed(r).replace(".",""));return o%a/10**r}class et extends L{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce)e.data=Number(e.data);if(this._getType(e)!==v.number){let r=this._getOrReturnCtx(e);return b(r,{code:p.invalid_type,expected:v.number,received:r.parsedType}),A}let n=void 0,s=new ee;for(let r of this._def.checks)if(r.kind==="int"){if(!P.isInteger(e.data))n=this._getOrReturnCtx(e,n),b(n,{code:p.invalid_type,expected:"integer",received:"float",message:r.message}),s.dirty()}else if(r.kind==="min"){if(r.inclusive?e.data<r.value:e.data<=r.value)n=this._getOrReturnCtx(e,n),b(n,{code:p.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),s.dirty()}else if(r.kind==="max"){if(r.inclusive?e.data>r.value:e.data>=r.value)n=this._getOrReturnCtx(e,n),b(n,{code:p.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),s.dirty()}else if(r.kind==="multipleOf"){if(la(e.data,r.value)!==0)n=this._getOrReturnCtx(e,n),b(n,{code:p.not_multiple_of,multipleOf:r.value,message:r.message}),s.dirty()}else if(r.kind==="finite"){if(!Number.isFinite(e.data))n=this._getOrReturnCtx(e,n),b(n,{code:p.not_finite,message:r.message}),s.dirty()}else P.assertNever(r);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,n,s){return new et({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:w.toString(s)}]})}_addCheck(e){return new et({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:w.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:w.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:w.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:w.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e}get maxValue(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e}get isInt(){return!!this._def.checks.find((e)=>e.kind==="int"||e.kind==="multipleOf"&&P.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;else if(n.kind==="min"){if(t===null||n.value>t)t=n.value}else if(n.kind==="max"){if(e===null||n.value<e)e=n.value}return Number.isFinite(t)&&Number.isFinite(e)}}et.create=(e)=>new et({checks:[],typeName:R.ZodNumber,coerce:e?.coerce||!1,...E(e)});class tt extends L{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==v.bigint)return this._getInvalidInput(e);let n=void 0,s=new ee;for(let r of this._def.checks)if(r.kind==="min"){if(r.inclusive?e.data<r.value:e.data<=r.value)n=this._getOrReturnCtx(e,n),b(n,{code:p.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),s.dirty()}else if(r.kind==="max"){if(r.inclusive?e.data>r.value:e.data>=r.value)n=this._getOrReturnCtx(e,n),b(n,{code:p.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),s.dirty()}else if(r.kind==="multipleOf"){if(e.data%r.value!==BigInt(0))n=this._getOrReturnCtx(e,n),b(n,{code:p.not_multiple_of,multipleOf:r.value,message:r.message}),s.dirty()}else P.assertNever(r);return{status:s.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return b(t,{code:p.invalid_type,expected:v.bigint,received:t.parsedType}),A}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,n,s){return new tt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:w.toString(s)}]})}_addCheck(e){return new tt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e}get maxValue(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e}}tt.create=(e)=>new tt({checks:[],typeName:R.ZodBigInt,coerce:e?.coerce??!1,...E(e)});class Yt extends L{_parse(e){if(this._def.coerce)e.data=Boolean(e.data);if(this._getType(e)!==v.boolean){let n=this._getOrReturnCtx(e);return b(n,{code:p.invalid_type,expected:v.boolean,received:n.parsedType}),A}return oe(e.data)}}Yt.create=(e)=>new Yt({typeName:R.ZodBoolean,coerce:e?.coerce||!1,...E(e)});class vt extends L{_parse(e){if(this._def.coerce)e.data=new Date(e.data);if(this._getType(e)!==v.date){let r=this._getOrReturnCtx(e);return b(r,{code:p.invalid_type,expected:v.date,received:r.parsedType}),A}if(Number.isNaN(e.data.getTime())){let r=this._getOrReturnCtx(e);return b(r,{code:p.invalid_date}),A}let n=new ee,s=void 0;for(let r of this._def.checks)if(r.kind==="min"){if(e.data.getTime()<r.value)s=this._getOrReturnCtx(e,s),b(s,{code:p.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),n.dirty()}else if(r.kind==="max"){if(e.data.getTime()>r.value)s=this._getOrReturnCtx(e,s),b(s,{code:p.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),n.dirty()}else P.assertNever(r);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new vt({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:w.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:w.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e!=null?new Date(e):null}}vt.create=(e)=>new vt({checks:[],coerce:e?.coerce||!1,typeName:R.ZodDate,...E(e)});class Jt extends L{_parse(e){if(this._getType(e)!==v.symbol){let n=this._getOrReturnCtx(e);return b(n,{code:p.invalid_type,expected:v.symbol,received:n.parsedType}),A}return oe(e.data)}}Jt.create=(e)=>new Jt({typeName:R.ZodSymbol,...E(e)});class kt extends L{_parse(e){if(this._getType(e)!==v.undefined){let n=this._getOrReturnCtx(e);return b(n,{code:p.invalid_type,expected:v.undefined,received:n.parsedType}),A}return oe(e.data)}}kt.create=(e)=>new kt({typeName:R.ZodUndefined,...E(e)});class wt extends L{_parse(e){if(this._getType(e)!==v.null){let n=this._getOrReturnCtx(e);return b(n,{code:p.invalid_type,expected:v.null,received:n.parsedType}),A}return oe(e.data)}}wt.create=(e)=>new wt({typeName:R.ZodNull,...E(e)});class Xt extends L{constructor(){super(...arguments);this._any=!0}_parse(e){return oe(e.data)}}Xt.create=(e)=>new Xt({typeName:R.ZodAny,...E(e)});class Ge extends L{constructor(){super(...arguments);this._unknown=!0}_parse(e){return oe(e.data)}}Ge.create=(e)=>new Ge({typeName:R.ZodUnknown,...E(e)});class Ee extends L{_parse(e){let t=this._getOrReturnCtx(e);return b(t,{code:p.invalid_type,expected:v.never,received:t.parsedType}),A}}Ee.create=(e)=>new Ee({typeName:R.ZodNever,...E(e)});class Qt extends L{_parse(e){if(this._getType(e)!==v.undefined){let n=this._getOrReturnCtx(e);return b(n,{code:p.invalid_type,expected:v.void,received:n.parsedType}),A}return oe(e.data)}}Qt.create=(e)=>new Qt({typeName:R.ZodVoid,...E(e)});class be extends L{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==v.array)return b(t,{code:p.invalid_type,expected:v.array,received:t.parsedType}),A;if(s.exactLength!==null){let o=t.data.length>s.exactLength.value,a=t.data.length<s.exactLength.value;if(o||a)b(t,{code:o?p.too_big:p.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty()}if(s.minLength!==null){if(t.data.length<s.minLength.value)b(t,{code:p.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()}if(s.maxLength!==null){if(t.data.length>s.maxLength.value)b(t,{code:p.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()}if(t.common.async)return Promise.all([...t.data].map((o,a)=>s.type._parseAsync(new he(t,o,t.path,a)))).then((o)=>ee.mergeArray(n,o));let r=[...t.data].map((o,a)=>s.type._parseSync(new he(t,o,t.path,a)));return ee.mergeArray(n,r)}get element(){return this._def.type}min(e,t){return new be({...this._def,minLength:{value:e,message:w.toString(t)}})}max(e,t){return new be({...this._def,maxLength:{value:e,message:w.toString(t)}})}length(e,t){return new be({...this._def,exactLength:{value:e,message:w.toString(t)}})}nonempty(e){return this.min(1,e)}}be.create=(e,t)=>new be({type:e,minLength:null,maxLength:null,exactLength:null,typeName:R.ZodArray,...E(t)});function Ze(e){if(e instanceof W){let t={};for(let n in e.shape){let s=e.shape[n];t[n]=ve.create(Ze(s))}return new W({...e._def,shape:()=>t})}else if(e instanceof be)return new be({...e._def,type:Ze(e.element)});else if(e instanceof ve)return ve.create(Ze(e.unwrap()));else if(e instanceof Pe)return Pe.create(Ze(e.unwrap()));else if(e instanceof Ce)return Ce.create(e.items.map((t)=>Ze(t)));else return e}class W extends L{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=P.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==v.object){let i=this._getOrReturnCtx(e);return b(i,{code:p.invalid_type,expected:v.object,received:i.parsedType}),A}let{status:n,ctx:s}=this._processInputParams(e),{shape:r,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Ee&&this._def.unknownKeys==="strip")){for(let i in s.data)if(!o.includes(i))a.push(i)}let l=[];for(let i of o){let c=r[i],d=s.data[i];l.push({key:{status:"valid",value:i},value:c._parse(new he(s,d,s.path,i)),alwaysSet:i in s.data})}if(this._def.catchall instanceof Ee){let i=this._def.unknownKeys;if(i==="passthrough")for(let c of a)l.push({key:{status:"valid",value:c},value:{status:"valid",value:s.data[c]}});else if(i==="strict"){if(a.length>0)b(s,{code:p.unrecognized_keys,keys:a}),n.dirty()}else if(i==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let i=this._def.catchall;for(let c of a){let d=s.data[c];l.push({key:{status:"valid",value:c},value:i._parse(new he(s,d,s.path,c)),alwaysSet:c in s.data})}}if(s.common.async)return Promise.resolve().then(async()=>{let i=[];for(let c of l){let d=await c.key,f=await c.value;i.push({key:d,value:f,alwaysSet:c.alwaysSet})}return i}).then((i)=>ee.mergeObjectSync(n,i));else return ee.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(e){return w.errToObj,new W({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{let s=this._def.errorMap?.(t,n).message??n.defaultError;if(t.code==="unrecognized_keys")return{message:w.errToObj(e).message??s};return{message:s}}}:{}})}strip(){return new W({...this._def,unknownKeys:"strip"})}passthrough(){return new W({...this._def,unknownKeys:"passthrough"})}extend(e){return new W({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new W({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:R.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new W({...this._def,catchall:e})}pick(e){let t={};for(let n of P.objectKeys(e))if(e[n]&&this.shape[n])t[n]=this.shape[n];return new W({...this._def,shape:()=>t})}omit(e){let t={};for(let n of P.objectKeys(this.shape))if(!e[n])t[n]=this.shape[n];return new W({...this._def,shape:()=>t})}deepPartial(){return Ze(this)}partial(e){let t={};for(let n of P.objectKeys(this.shape)){let s=this.shape[n];if(e&&!e[n])t[n]=s;else t[n]=s.optional()}return new W({...this._def,shape:()=>t})}required(e){let t={};for(let n of P.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let r=this.shape[n];while(r instanceof ve)r=r._def.innerType;t[n]=r}return new W({...this._def,shape:()=>t})}keyof(){return jr(P.objectKeys(this.shape))}}W.create=(e,t)=>new W({shape:()=>e,unknownKeys:"strip",catchall:Ee.create(),typeName:R.ZodObject,...E(t)});W.strictCreate=(e,t)=>new W({shape:()=>e,unknownKeys:"strict",catchall:Ee.create(),typeName:R.ZodObject,...E(t)});W.lazycreate=(e,t)=>new W({shape:e,unknownKeys:"strip",catchall:Ee.create(),typeName:R.ZodObject,...E(t)});class _t extends L{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function s(r){for(let a of r)if(a.result.status==="valid")return a.result;for(let a of r)if(a.result.status==="dirty")return t.common.issues.push(...a.ctx.common.issues),a.result;let o=r.map((a)=>new ce(a.ctx.common.issues));return b(t,{code:p.invalid_union,unionErrors:o}),A}if(t.common.async)return Promise.all(n.map(async(r)=>{let o={...t,common:{...t.common,issues:[]},parent:null};return{result:await r._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(s);else{let r=void 0,o=[];for(let l of n){let i={...t,common:{...t.common,issues:[]},parent:null},c=l._parseSync({data:t.data,path:t.path,parent:i});if(c.status==="valid")return c;else if(c.status==="dirty"&&!r)r={result:c,ctx:i};if(i.common.issues.length)o.push(i.common.issues)}if(r)return t.common.issues.push(...r.ctx.common.issues),r.result;let a=o.map((l)=>new ce(l));return b(t,{code:p.invalid_union,unionErrors:a}),A}}get options(){return this._def.options}}_t.create=(e,t)=>new _t({options:e,typeName:R.ZodUnion,...E(t)});var Ae=(e)=>{if(e instanceof Tt)return Ae(e.schema);else if(e instanceof ke)return Ae(e.innerType());else if(e instanceof At)return[e.value];else if(e instanceof Ke)return e.options;else if(e instanceof Rt)return P.objectValues(e.enum);else if(e instanceof Et)return Ae(e._def.innerType);else if(e instanceof kt)return[void 0];else if(e instanceof wt)return[null];else if(e instanceof ve)return[void 0,...Ae(e.unwrap())];else if(e instanceof Pe)return[null,...Ae(e.unwrap())];else if(e instanceof Gn)return Ae(e.unwrap());else if(e instanceof Nt)return Ae(e.unwrap());else if(e instanceof Ct)return Ae(e._def.innerType);else return[]};class Wn extends L{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.object)return b(t,{code:p.invalid_type,expected:v.object,received:t.parsedType}),A;let n=this.discriminator,s=t.data[n],r=this.optionsMap.get(s);if(!r)return b(t,{code:p.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),A;if(t.common.async)return r._parseAsync({data:t.data,path:t.path,parent:t});else return r._parseSync({data:t.data,path:t.path,parent:t})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){let s=new Map;for(let r of t){let o=Ae(r.shape[e]);if(!o.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of o){if(s.has(a))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,r)}}return new Wn({typeName:R.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...E(n)})}}function Vn(e,t){let n=Te(e),s=Te(t);if(e===t)return{valid:!0,data:e};else if(n===v.object&&s===v.object){let r=P.objectKeys(t),o=P.objectKeys(e).filter((l)=>r.indexOf(l)!==-1),a={...e,...t};for(let l of o){let i=Vn(e[l],t[l]);if(!i.valid)return{valid:!1};a[l]=i.data}return{valid:!0,data:a}}else if(n===v.array&&s===v.array){if(e.length!==t.length)return{valid:!1};let r=[];for(let o=0;o<e.length;o++){let a=e[o],l=t[o],i=Vn(a,l);if(!i.valid)return{valid:!1};r.push(i.data)}return{valid:!0,data:r}}else if(n===v.date&&s===v.date&&+e===+t)return{valid:!0,data:e};else return{valid:!1}}class St extends L{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),s=(r,o)=>{if(Fn(r)||Fn(o))return A;let a=Vn(r.value,o.value);if(!a.valid)return b(n,{code:p.invalid_intersection_types}),A;if(Un(r)||Un(o))t.dirty();return{status:t.value,value:a.data}};if(n.common.async)return Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([r,o])=>s(r,o));else return s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}St.create=(e,t,n)=>new St({left:e,right:t,typeName:R.ZodIntersection,...E(n)});class Ce extends L{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==v.array)return b(n,{code:p.invalid_type,expected:v.array,received:n.parsedType}),A;if(n.data.length<this._def.items.length)return b(n,{code:p.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),A;if(!this._def.rest&&n.data.length>this._def.items.length)b(n,{code:p.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty();let r=[...n.data].map((o,a)=>{let l=this._def.items[a]||this._def.rest;if(!l)return null;return l._parse(new he(n,o,n.path,a))}).filter((o)=>!!o);if(n.common.async)return Promise.all(r).then((o)=>ee.mergeArray(t,o));else return ee.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new Ce({...this._def,rest:e})}}Ce.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ce({items:e,typeName:R.ZodTuple,rest:null,...E(t)})};class Zt extends L{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==v.object)return b(n,{code:p.invalid_type,expected:v.object,received:n.parsedType}),A;let s=[],r=this._def.keyType,o=this._def.valueType;for(let a in n.data)s.push({key:r._parse(new he(n,a,n.path,a)),value:o._parse(new he(n,n.data[a],n.path,a)),alwaysSet:a in n.data});if(n.common.async)return ee.mergeObjectAsync(t,s);else return ee.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){if(t instanceof L)return new Zt({keyType:e,valueType:t,typeName:R.ZodRecord,...E(n)});return new Zt({keyType:Re.create(),valueType:e,typeName:R.ZodRecord,...E(t)})}}class en extends L{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==v.map)return b(n,{code:p.invalid_type,expected:v.map,received:n.parsedType}),A;let s=this._def.keyType,r=this._def.valueType,o=[...n.data.entries()].map(([a,l],i)=>({key:s._parse(new he(n,a,n.path,[i,"key"])),value:r._parse(new he(n,l,n.path,[i,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let l of o){let i=await l.key,c=await l.value;if(i.status==="aborted"||c.status==="aborted")return A;if(i.status==="dirty"||c.status==="dirty")t.dirty();a.set(i.value,c.value)}return{status:t.value,value:a}})}else{let a=new Map;for(let l of o){let{key:i,value:c}=l;if(i.status==="aborted"||c.status==="aborted")return A;if(i.status==="dirty"||c.status==="dirty")t.dirty();a.set(i.value,c.value)}return{status:t.value,value:a}}}}en.create=(e,t,n)=>new en({valueType:t,keyType:e,typeName:R.ZodMap,...E(n)});class nt extends L{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==v.set)return b(n,{code:p.invalid_type,expected:v.set,received:n.parsedType}),A;let s=this._def;if(s.minSize!==null){if(n.data.size<s.minSize.value)b(n,{code:p.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()}if(s.maxSize!==null){if(n.data.size>s.maxSize.value)b(n,{code:p.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty()}let r=this._def.valueType;function o(l){let i=new Set;for(let c of l){if(c.status==="aborted")return A;if(c.status==="dirty")t.dirty();i.add(c.value)}return{status:t.value,value:i}}let a=[...n.data.values()].map((l,i)=>r._parse(new he(n,l,n.path,i)));if(n.common.async)return Promise.all(a).then((l)=>o(l));else return o(a)}min(e,t){return new nt({...this._def,minSize:{value:e,message:w.toString(t)}})}max(e,t){return new nt({...this._def,maxSize:{value:e,message:w.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}nt.create=(e,t)=>new nt({valueType:e,minSize:null,maxSize:null,typeName:R.ZodSet,...E(t)});class bt extends L{constructor(){super(...arguments);this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.function)return b(t,{code:p.invalid_type,expected:v.function,received:t.parsedType}),A;function n(a,l){return Kt({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xt(),$e].filter((i)=>!!i),issueData:{code:p.invalid_arguments,argumentsError:l}})}function s(a,l){return Kt({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xt(),$e].filter((i)=>!!i),issueData:{code:p.invalid_return_type,returnTypeError:l}})}let r={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof rt){let a=this;return oe(async function(...l){let i=new ce([]),c=await a._def.args.parseAsync(l,r).catch((g)=>{throw i.addIssue(n(l,g)),i}),d=await Reflect.apply(o,this,c);return await a._def.returns._def.type.parseAsync(d,r).catch((g)=>{throw i.addIssue(s(d,g)),i})})}else{let a=this;return oe(function(...l){let i=a._def.args.safeParse(l,r);if(!i.success)throw new ce([n(l,i.error)]);let c=Reflect.apply(o,this,i.data),d=a._def.returns.safeParse(c,r);if(!d.success)throw new ce([s(c,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new bt({...this._def,args:Ce.create(e).rest(Ge.create())})}returns(e){return new bt({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new bt({args:e?e:Ce.create([]).rest(Ge.create()),returns:t||Ge.create(),typeName:R.ZodFunction,...E(n)})}}class Tt extends L{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Tt.create=(e,t)=>new Tt({getter:e,typeName:R.ZodLazy,...E(t)});class At extends L{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return b(t,{received:t.data,code:p.invalid_literal,expected:this._def.value}),A}return{status:"valid",value:e.data}}get value(){return this._def.value}}At.create=(e,t)=>new At({value:e,typeName:R.ZodLiteral,...E(t)});function jr(e,t){return new Ke({values:e,typeName:R.ZodEnum,...E(t)})}class Ke extends L{_parse(e){if(typeof e.data!=="string"){let t=this._getOrReturnCtx(e),n=this._def.values;return b(t,{expected:P.joinValues(n),received:t.parsedType,code:p.invalid_type}),A}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return b(t,{received:t.data,code:p.invalid_enum_value,options:n}),A}return oe(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return Ke.create(e,{...this._def,...t})}exclude(e,t=this._def){return Ke.create(this.options.filter((n)=>!e.includes(n)),{...this._def,...t})}}Ke.create=jr;class Rt extends L{_parse(e){let t=P.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==v.string&&n.parsedType!==v.number){let s=P.objectValues(t);return b(n,{expected:P.joinValues(s),received:n.parsedType,code:p.invalid_type}),A}if(!this._cache)this._cache=new Set(P.getValidEnumValues(this._def.values));if(!this._cache.has(e.data)){let s=P.objectValues(t);return b(n,{received:n.data,code:p.invalid_enum_value,options:s}),A}return oe(e.data)}get enum(){return this._def.values}}Rt.create=(e,t)=>new Rt({values:e,typeName:R.ZodNativeEnum,...E(t)});class rt extends L{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.promise&&t.common.async===!1)return b(t,{code:p.invalid_type,expected:v.promise,received:t.parsedType}),A;let n=t.parsedType===v.promise?t.data:Promise.resolve(t.data);return oe(n.then((s)=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}rt.create=(e,t)=>new rt({type:e,typeName:R.ZodPromise,...E(t)});class ke extends L{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===R.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,r={addIssue:(o)=>{if(b(n,o),o.fatal)t.abort();else t.dirty()},get path(){return n.path}};if(r.addIssue=r.addIssue.bind(r),s.type==="preprocess"){let o=s.transform(n.data,r);if(n.common.async)return Promise.resolve(o).then(async(a)=>{if(t.value==="aborted")return A;let l=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});if(l.status==="aborted")return A;if(l.status==="dirty")return Qe(l.value);if(t.value==="dirty")return Qe(l.value);return l});else{if(t.value==="aborted")return A;let a=this._def.schema._parseSync({data:o,path:n.path,parent:n});if(a.status==="aborted")return A;if(a.status==="dirty")return Qe(a.value);if(t.value==="dirty")return Qe(a.value);return a}}if(s.type==="refinement"){let o=(a)=>{let l=s.refinement(a,r);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(a.status==="aborted")return A;if(a.status==="dirty")t.dirty();return o(a.value),{status:t.value,value:a.value}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then((a)=>{if(a.status==="aborted")return A;if(a.status==="dirty")t.dirty();return o(a.value).then(()=>({status:t.value,value:a.value}))})}if(s.type==="transform")if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!We(o))return A;let a=s.transform(o.value,r);if(a instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then((o)=>{if(!We(o))return A;return Promise.resolve(s.transform(o.value,r)).then((a)=>({status:t.value,value:a}))});P.assertNever(s)}}ke.create=(e,t,n)=>new ke({schema:e,typeName:R.ZodEffects,effect:t,...E(n)});ke.createWithPreprocess=(e,t,n)=>new ke({schema:t,effect:{type:"preprocess",transform:e},typeName:R.ZodEffects,...E(n)});class ve extends L{_parse(e){if(this._getType(e)===v.undefined)return oe(void 0);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ve.create=(e,t)=>new ve({innerType:e,typeName:R.ZodOptional,...E(t)});class Pe extends L{_parse(e){if(this._getType(e)===v.null)return oe(null);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Pe.create=(e,t)=>new Pe({innerType:e,typeName:R.ZodNullable,...E(t)});class Et extends L{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;if(t.parsedType===v.undefined)n=this._def.defaultValue();return this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Et.create=(e,t)=>new Et({innerType:e,typeName:R.ZodDefault,defaultValue:typeof t.default==="function"?t.default:()=>t.default,...E(t)});class Ct extends L{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});if(yt(s))return s.then((r)=>({status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new ce(n.common.issues)},input:n.data})}));else return{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new ce(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Ct.create=(e,t)=>new Ct({innerType:e,typeName:R.ZodCatch,catchValue:typeof t.catch==="function"?t.catch:()=>t.catch,...E(t)});class tn extends L{_parse(e){if(this._getType(e)!==v.nan){let n=this._getOrReturnCtx(e);return b(n,{code:p.invalid_type,expected:v.nan,received:n.parsedType}),A}return{status:"valid",value:e.data}}}tn.create=(e)=>new tn({typeName:R.ZodNaN,...E(e)});var ec=Symbol("zod_brand");class Gn extends L{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class nn extends L{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let r=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});if(r.status==="aborted")return A;if(r.status==="dirty")return t.dirty(),Qe(r.value);else return this._def.out._parseAsync({data:r.value,path:n.path,parent:n})})();else{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});if(s.status==="aborted")return A;if(s.status==="dirty")return t.dirty(),{status:"dirty",value:s.value};else return this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new nn({in:e,out:t,typeName:R.ZodPipeline})}}class Nt extends L{_parse(e){let t=this._def.innerType._parse(e),n=(s)=>{if(We(s))s.value=Object.freeze(s.value);return s};return yt(t)?t.then((s)=>n(s)):n(t)}unwrap(){return this._def.innerType}}Nt.create=(e,t)=>new Nt({innerType:e,typeName:R.ZodReadonly,...E(t)});var tc={object:W.lazycreate},R;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(R||(R={}));var m=Re.create,Q=et.create,nc=tn.create,rc=tt.create,we=Yt.create,sc=vt.create,oc=Jt.create,ac=kt.create,ic=wt.create,lc=Xt.create,ca=Ge.create,cc=Ee.create,dc=Qt.create,q=be.create,{create:S,strictCreate:uc}=W,Kn=_t.create,pc=Wn.create,fc=St.create,Dr=Ce.create,hc=Zt.create,mc=en.create,gc=nt.create,xc=bt.create,yc=Tt.create,st=At.create,ot=Ke.create,bc=Rt.create,vc=rt.create,kc=ke.create,wc=ve.create,_c=Pe.create,Sc=ke.createWithPreprocess,Tc=nn.create;var da=S({before:m(),after:m(),hierarchy:q(m()),lineStart:Q().optional(),lineEnd:Q().optional()}).passthrough(),Yn=S({id:m(),name:m()}).passthrough(),ua=S({url:m(),mime:m().optional()}).passthrough(),Jn=S({id:m(),snippet:m(),note:m(),createdAt:m(),filePath:m().optional(),canvasFile:m().optional(),context:da.optional(),images:q(m()).optional(),attachments:q(ua).optional(),source:ot(["local","remote"]).optional(),author:Yn.optional()}).passthrough(),pa=q(Jn.optional().catch(void 0)).transform((e)=>e.filter((t)=>t!==void 0)).catch([]),Xn=S({annotations:pa,generalNote:m().catch("")}).passthrough(),zr=S({path:m()}),Hr=S({url:m()}),Br=S({error:m()});import{useCallback as Mc,useMemo as $c,useState as Pc}from"react";function It(e){return e.uploadUrl!==null}var Qn=["image/png","image/jpeg","image/gif","image/webp"],Fr="Only PNG, JPEG, GIF and WebP images can be attached";function Ne(e,t){e.style.height="auto",e.style.height=(t?Math.max(t,e.scrollHeight):e.scrollHeight)+"px"}import{useAnnotations as rn}from"@fabrika/annotations/runtime";import{useAnnotationHost as ha}from"@fabrika/annotations/runtime";import{useCallback as Ie,useEffect as ma,useRef as er,useState as sn}from"react";import{jsxDEV as te}from"react/jsx-dev-runtime";function Ur(e){if(e.startsWith("/s/")||e.startsWith("http://")||e.startsWith("https://"))return e;return`/api/uploads/${e.split("/").pop()}`}async function ga(e,t){let n=e.uploadUrl;if(!n)return{error:"Uploads are not available here"};let s=new FormData;s.append("image",t);try{let r=await fetch(n(),{method:"POST",body:s}),o=await r.json();if(!r.ok){let a=Br.safeParse(o);return{error:a.success?a.data.error:`Upload failed (HTTP ${r.status})`}}return{path:e.isShared?Hr.parse(o).url:zr.parse(o).path}}catch{return{error:"Upload failed"}}}function on({note:e,onNoteChange:t,images:n,onAddImage:s,onRemoveImage:r,sessionId:o,placeholder:a="Add your note...",autoFocus:l=!1,autoResize:i=!1,readOnly:c=!1,onKeyDown:d,onTextareaClick:f,textareaRef:g,textareaClassName:x,textareaStyle:u,minHeight:h,attachButton:y="always",openFilePickerRef:T}){let O=ha(),M=!c&&It(O),[I,_]=sn(!1),[j,U]=sn(!1),[ne,le]=sn(null),[G,J]=sn(!1),X=er(0),K=er(null),de=er(null),Le=Ie(()=>de.current?.click(),[]);if(T)T.current=Le;let He=Ie((C)=>{if(K.current=C,g)g.current=C;if(C&&i)Ne(C,h)},[g,i,h]);ma(()=>{if(l&&K.current){let C=K.current;if(C.focus(),C.value)C.setSelectionRange(C.value.length,C.value.length)}},[l]);let re=Ie(async(C)=>{if(!Qn.includes(C.type)){le(Fr);return}le(null),U(!0);try{let k=await ga(O,C);if("path"in k)s(k.path);else le(k.error)}finally{U(!1)}},[O,s]),ue=Ie((C)=>{for(let k of C.clipboardData?.items??[])if(k.type.startsWith("image/")){C.preventDefault();let H=k.getAsFile();if(H)re(H);return}},[re]),me=Ie((C)=>{if(C.preventDefault(),X.current++,X.current===1)_(!0)},[]),ge=Ie((C)=>{C.preventDefault()},[]),Be=Ie((C)=>{if(C.preventDefault(),X.current--,X.current===0)_(!1)},[]),Fe=Ie((C)=>{C.preventDefault(),X.current=0,_(!1);for(let k of C.dataTransfer?.files??[])if(k.type.startsWith("image/"))re(k)},[re]),xn=Ie((C)=>{if(t(C.currentTarget.value),i)C.currentTarget.style.height="auto",C.currentTarget.style.height=(h?Math.max(h,C.currentTarget.scrollHeight):C.currentTarget.scrollHeight)+"px"},[t,i,h]),yn="w-full bg-transparent text-[13px] font-body text-text-primary resize-none focus:outline-none leading-relaxed p-0 border-none",ut={width:"100%",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",outline:"none",...i?{resize:"none",overflow:"hidden"}:{resize:"vertical"}},jt=M&&(y==="always"||y==="on-focus"&&G);return te("div",{style:{position:"relative"},onDragEnter:M?me:void 0,onDragOver:M?ge:void 0,onDragLeave:M?Be:void 0,onDrop:M?Fe:void 0,children:[te("textarea",{ref:He,value:e,onChange:c?void 0:xn,onPaste:M?ue:void 0,onKeyDown:d,onClick:f,onFocus:()=>J(!0),onBlur:()=>{setTimeout(()=>J(!1),150)},readOnly:c,placeholder:a,className:x??yn,style:u??ut,rows:i?1:void 0},void 0,!1,void 0,this),M&&te("input",{ref:de,type:"file",accept:Qn.join(","),multiple:!0,style:{display:"none"},onChange:(C)=>{let k=C.currentTarget.files;if(k)for(let H of k)re(H);C.currentTarget.value=""}},void 0,!1,void 0,this),(n.length>0||jt)&&te("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px",alignItems:"center"},children:[n.map((C)=>te("div",{style:{position:"relative",width:"56px",height:"56px",borderRadius:"6px",overflow:"hidden",border:"1px solid var(--color-border-subtle)",flexShrink:0},children:[te("img",{src:Ur(C),alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}},void 0,!1,void 0,this),!c&&te("button",{onClick:(k)=>{k.stopPropagation(),r(C)},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)]},C,!0,void 0,this)),jt&&te(an,{onClick:Le},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j&&te("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:"Uploading..."},void 0,!1,void 0,this),ne&&te("div",{role:"alert",style:{fontSize:"11px",color:"var(--color-accent-red)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:ne},void 0,!1,void 0,this),I&&te("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 an({onClick:e,size:t=16}){return te("button",{onClick:(n)=>{n.stopPropagation(),e()},style:{width:`${t*2}px`,height:`${t*2}px`,borderRadius:"6px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--color-text-tertiary)",flexShrink:0,transition:"color 0.15s"},title:"Attach image",onMouseEnter:(n)=>{n.currentTarget.style.color="var(--color-text-secondary)"},onMouseLeave:(n)=>{n.currentTarget.style.color="var(--color-text-tertiary)"},children:te("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[te("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},void 0,!1,void 0,this),te("circle",{cx:"8.5",cy:"8.5",r:"1.5"},void 0,!1,void 0,this),te("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 ld}from"@fabrika/annotations/runtime";import{useContext as dd,useEffect as ud,useRef as pd}from"react";import{SessionContext as va,useAnnotationHost as ka}from"@fabrika/annotations/runtime";import{useCallback as ln,useContext as wa,useEffect as _a,useMemo as Gr,useRef as cn,useState as at}from"react";import{createPortal as Sa}from"react-dom";function Vr(e){let t=/^(\d+(?:\.\d+)?)px$/.exec(e.trim());return t?Number(t[1]):void 0}function Wr(e,t,n=280){let r=t||document.body,o=e.getBoundingClientRect(),a=r.getBoundingClientRect(),l=r===document.body?0:r.scrollTop,i=o.bottom-a.top+l+8,c=Math.max(0,Math.min(o.left-a.left,a.width-n-12));return r.style.position="relative",{style:{position:"absolute",top:`${i}px`,left:`${c}px`},parent:r}}import{jsxDEV as Z,Fragment as Ta}from"react/jsx-dev-runtime";function Yr({anchorEl:e,scrollContainer:t,onClose:n,ignoreSelector:s,zIndex:r="50",padding:o="12px",width:a="280px",children:l}){let i=cn(null),c=cn(n);c.current=n;let{style:d,parent:f}=Wr(e,t,Vr(a));return _a(()=>{let g=setTimeout(()=>{let x=(u)=>{if(i.current&&!i.current.contains(u.target)){if(s&&u.target.closest?.(s))return;c.current(),document.removeEventListener("mousedown",x)}};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},0);return()=>clearTimeout(g)},[s]),Sa(Z("div",{ref:i,style:{...d,zIndex:r,width:a,background:"var(--color-bg-elevated)",border:"1px solid var(--color-border-hover)",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",padding:o,fontFamily:"'Inter', sans-serif"},children:l},void 0,!1,void 0,this),f)}var Jr=[{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"]}],Kr=Jr.flatMap((e)=>e.items);function Xr({anchorEl:e,scrollContainer:t,snippet:n,truncateAt:s=100,header:r,initialNote:o="",initialImages:a,onConfirm:l,onCancel:i,onDelete:c}){let d=wa(va),f=ka(),g=It(f),x=o!==""||!!c,[u,h]=at(o),[y,T]=at(a||[]),[O,M]=at(null),[I,_]=at(x),[j,U]=at(!1),ne=cn(null),le=cn(null),G=ln(()=>{if(u.trim()||y.length>0)l(u.trim(),y);else if(x&&c)c();else i()},[u,y,l,i,x,c]),J=ln(()=>{if(x){if(!u.trim()&&y.length===0&&c){c(),i();return}l(u,y);return}i()},[u,y,x,l,i,c]),X=!x,K=u.trim().length>0?Kr.filter((k)=>k.toLowerCase().startsWith(u.trim().toLowerCase())):Kr,de=!X||I?[]:K.length===1&&K[0]?.toLowerCase()===u.trim().toLowerCase()?[]:K,Le=new Set(de),He=Jr.map((k)=>({label:k.label,items:k.items.filter((H)=>Le.has(H))})).filter((k)=>k.items.length>0),re=He.map((k)=>k.items),ue=(k)=>re[k]?.length??0,me=re.flat(),ge=Gr(()=>{if(O===null)return 0;let k=0;for(let H=0;H<re.length;H++){if(O<k+ue(H))return H;k+=ue(H)}return 0},[O,re]),Be=Gr(()=>{if(O===null)return 0;let k=0;for(let H=0;H<ge;H++)k+=ue(H);return O-k},[O,ge,re]),Fe=(k,H)=>{let Y=0;for(let xe=0;xe<k;xe++)Y+=ue(xe);return Y+H},[xn,yn]=at(u);if(u!==xn)yn(u),M(null),_(x);let ut=ln((k)=>{h(k)},[]),jt=n.length>s?n.slice(0,s)+"...":n,C=ln((k)=>{if(me.length>0&&(k.key==="ArrowDown"||k.key==="ArrowUp"||k.key==="ArrowLeft"||k.key==="ArrowRight")){if(k.preventDefault(),O===null){M(0);return}if(k.key==="ArrowDown"){let Y=Math.min(Be+1,ue(ge)-1);M(Fe(ge,Y))}else if(k.key==="ArrowUp"){let Y=Math.max(Be-1,0);M(Fe(ge,Y))}else if(k.key==="ArrowRight"){let Y=Math.min(ge+1,re.length-1),xe=Math.min(Be,ue(Y)-1);M(Fe(Y,xe))}else if(k.key==="ArrowLeft"){let Y=Math.max(ge-1,0),xe=Math.min(Be,ue(Y)-1);M(Fe(Y,xe))}return}let H=O===null?void 0:me[O];if(H!==void 0){if(k.key==="Tab"){k.preventDefault(),ut(H);return}if(k.key==="Enter"&&!k.shiftKey){k.preventDefault(),l(H,y);return}}if(k.key==="Enter"&&!k.shiftKey){k.preventDefault(),G();return}if(k.key==="Escape")if(me.length>0&&!I)_(!0);else if(x)J();else i()},[me,O,Be,ge,re,Fe,ut,l,y,G,I,x,J,i]);return Z(Yr,{anchorEl:e,scrollContainer:t,onClose:x?J:i,ignoreSelector:x?"[data-annotation-id]":void 0,zIndex:x?"60":"50",padding:x?"10px 12px":"12px",width:"420px",children:[!x&&(r??Z("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:["“",jt,"”"]},void 0,!0,void 0,this)),Z(on,{note:u,onNoteChange:h,images:y,onAddImage:(k)=>T((H)=>[...H,k]),onRemoveImage:(k)=>T((H)=>H.filter((Y)=>Y!==k)),sessionId:d,autoFocus:!0,autoResize:x,textareaRef:ne,onKeyDown:C,attachButton:"none",openFilePickerRef:le,textareaStyle:x?{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),Z("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:x?"6px":"8px"},children:[g&&Z(an,{onClick:()=>le.current?.(),size:14},void 0,!1,void 0,this),Z("div",{style:{flex:1}},void 0,!1,void 0,this),x?Z("button",{onClick:()=>{if(c)c();i()},onMouseEnter:()=>U(!0),onMouseLeave:()=>U(!1),style:{fontSize:"11px",color:j?"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):Z(Ta,{children:[Z("button",{onClick:i,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),Z("button",{onClick:G,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),me.length>0&&Z("div",{style:{marginTop:"6px",borderTop:"1px solid var(--color-border-subtle)",paddingTop:"8px",display:"flex",gap:"4px"},children:He.map((k)=>Z("div",{style:{flex:1},children:[Z("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:k.label},void 0,!1,void 0,this),k.items.map((H)=>{let Y=me.indexOf(H);return Z("div",{onMouseDown:(xe)=>{xe.preventDefault(),xe.stopPropagation(),ut(H)},onMouseEnter:()=>M(Y),style:{padding:"3px 6px",fontSize:"12px",borderRadius:"4px",fontFamily:"'Inter', sans-serif",color:Y===O?"var(--color-text-primary)":"var(--color-text-secondary)",background:Y===O?"var(--color-highlight-selected)":"transparent",cursor:"pointer"},children:[Z("span",{style:{fontWeight:500},children:H.slice(0,u.trim().length)},void 0,!1,void 0,this),H.slice(u.trim().length)]},H,!0,void 0,this)})]},k.label,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Lt({anchorEl:e,scrollContainer:t,snippet:n,truncateAt:s,header:r,onAdd:o,onCancel:a}){return Z(Xr,{anchorEl:e,scrollContainer:t,snippet:n,truncateAt:s,header:r,onConfirm:(l,i)=>o(l,i),onCancel:a},void 0,!1,void 0,this)}import{useEffect as Md,useRef as $d,useState as Pd}from"react";import{useCallback as qd,useEffect as Vd,useRef as Wd,useState as Gd}from"react";import{jsxDEV as Qr}from"react/jsx-dev-runtime";function it({note:e,onChange:t}){return Qr("div",{className:"mt-1.5",children:Qr("textarea",{value:e,onChange:(n)=>t(n.currentTarget.value),className:"w-full bg-transparent text-[12px] font-body text-text-primary resize-none focus:outline-none border-none placeholder:text-text-disabled transition-colors min-h-[20px] p-0 leading-relaxed",placeholder:"Add a note...",rows:1,onInput:(n)=>Ne(n.currentTarget),ref:(n)=>{if(n)Ne(n)}},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as V}from"react/jsx-dev-runtime";function os(e){return e.map((t)=>typeof t==="string"?{value:t,label:t}:{value:t.value,label:t.label??t.value})}function Pa({id:e,label:t,options:n,required:s}){let{responses:r,setResponse:o}=Zr();es(e);let a=ns(()=>os(n),[n]),l=r.get(e),i=l?.value,c=l?.note||"",[d,f]=ss(!1),g=rs(null);if(!r.has(e))o(e,{id:e,type:"radio",label:t,value:null,options:a.map((h)=>h.value),required:s});let x=(h)=>{o(e,{...l,value:h})};ts(()=>{let h=g.current;if(!h)return;let y=(T)=>{let M=T.target.closest("[data-md-label]")?.getAttribute("data-md-label"),I=a.find((_)=>_.label===M);if(I)x(I.value)};return h.addEventListener("kb-select",y),()=>h.removeEventListener("kb-select",y)},[a,x]);let u=l?.required&&!i;return V("div",{ref:g,"data-md":"choice","data-md-label":t,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[V("div",{className:"flex items-baseline gap-2 mb-2",children:[V("span",{className:"text-[13px] font-body font-medium text-text-primary",children:t},void 0,!1,void 0,this),s&&V("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),V("div",{className:"space-y-1",children:a.map(({value:h,label:y})=>V("label",{"data-md":"choice-option","data-md-label":y,onClick:()=>x(h),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${i===h?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[V("span",{className:`w-4 h-4 rounded-full border-[1.5px] flex items-center justify-center flex-shrink-0 transition-all ${i===h?"border-accent-amber bg-accent-amber":"border-border-strong"}`,children:i===h&&V("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),V("span",{className:"text-[13px] font-body text-text-secondary",children:y},void 0,!1,void 0,this)]},h,!0,void 0,this))},void 0,!1,void 0,this),V(it,{show:d,note:c,onToggle:()=>f(!d),onChange:(h)=>o(e,{...l,note:h})},void 0,!1,void 0,this),u&&V("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 Oa({id:e,label:t,options:n,required:s}){let{responses:r,setResponse:o}=Zr();es(e);let a=ns(()=>os(n),[n]),l=r.get(e),i=l?.value||[],c=l?.note||"",[d,f]=ss(!1),g=rs(null);if(!r.has(e))o(e,{id:e,type:"checkbox",label:t,value:[],options:a.map((h)=>h.value),required:s});let x=(h)=>{let y=i.includes(h)?i.filter((T)=>T!==h):[...i,h];o(e,{...l,value:y})};ts(()=>{let h=g.current;if(!h)return;let y=(T)=>{let M=T.target.closest("[data-md-label]")?.getAttribute("data-md-label"),I=a.find((_)=>_.label===M);if(I)x(I.value)};return h.addEventListener("kb-select",y),()=>h.removeEventListener("kb-select",y)},[a,x]);let u=l?.required&&i.length===0;return V("div",{ref:g,"data-md":"multichoice","data-md-label":t,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[V("div",{className:"flex items-baseline gap-2 mb-2",children:[V("span",{className:"text-[13px] font-body font-medium text-text-primary",children:t},void 0,!1,void 0,this),s&&V("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),V("div",{className:"space-y-1",children:a.map(({value:h,label:y})=>{let T=i.includes(h);return V("label",{"data-md":"multichoice-option","data-md-label":y,onClick:()=>x(h),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${T?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[V("span",{className:`w-4 h-4 rounded flex items-center justify-center flex-shrink-0 transition-all ${T?"bg-accent-amber":"border-[1.5px] border-border-strong"}`,children:T&&V("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:V("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),V("span",{className:"text-[13px] font-body text-text-secondary",children:y},void 0,!1,void 0,this)]},h,!0,void 0,this)})},void 0,!1,void 0,this),V(it,{show:d,note:c,onToggle:()=>f(!d),onChange:(h)=>o(e,{...l,note:h})},void 0,!1,void 0,this),u&&V("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 ja,useRef as Da}from"react";function dn(){return window.hljs}function as(){return window.mermaid}import{jsxDEV as un}from"react/jsx-dev-runtime";function za({language:e,children:t}){let n=typeof t==="string"?t:String(t??""),s=Da(null);return ja(()=>{let r=s.current,o=dn();if(!r||!o)return;r.removeAttribute("data-highlighted"),r.className=e?`language-${e}`:"",r.textContent=n,o.highlightElement(r)},[n,e]),un("div",{className:"relative mt-3 group/code","data-md":"codeblock","data-md-language":e||"",children:[e&&un("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:e},void 0,!1,void 0,this),un("pre",{className:"bg-bg-code rounded-md p-4 overflow-x-auto text-code font-mono leading-relaxed",children:un("code",{ref:s,className:e?`language-${e}`:"",children:n},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function is(e,t){let n=e.split(`
60
+ `),s=t.split(`
61
+ `),r=Ha(n,s),o=[],a=0,l=0,i=0;while(a<n.length||l<s.length){let c=n[a],d=s[l];if(i<r.length&&c!==void 0&&d!==void 0&&c===r[i]&&d===r[i])o.push({type:"same",line:c}),a++,l++,i++;else if(c!==void 0&&(i>=r.length||c!==r[i]))o.push({type:"removed",line:c}),a++;else if(d!==void 0)o.push({type:"added",line:d}),l++}return o}function Ha(e,t){let n=e.length,s=t.length,r=Array.from({length:n+1},()=>Array(s+1).fill(0));for(let i=1;i<=n;i++){let c=r[i]??[],d=r[i-1]??[];for(let f=1;f<=s;f++)c[f]=e[i-1]===t[f-1]?(d[f-1]??0)+1:Math.max(d[f]??0,c[f-1]??0)}let o=[],a=n,l=s;while(a>0&&l>0){let i=e[a-1];if(i!==void 0&&i===t[l-1])o.unshift(i),a--,l--;else if((r[a-1]?.[l]??0)>(r[a]?.[l-1]??0))a--;else l--}return o}import{jsxDEV as Mt}from"react/jsx-dev-runtime";function Ba({before:e,after:t,language:n}){let s=is(e,t);return Mt("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden group/diff","data-md":"diff","data-md-language":n||"",children:[n&&Mt("div",{className:"px-4 py-2 text-meta font-mono text-text-tertiary opacity-0 group-hover/diff:opacity-60 transition-opacity",children:["diff (",n,")"]},void 0,!0,void 0,this),Mt("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono",children:s.map((r,o)=>Mt("div",{className:r.type==="removed"?"bg-accent-red-muted text-accent-red":r.type==="added"?"bg-accent-green-muted text-accent-green":"text-text-tertiary",children:[Mt("span",{className:"select-none w-6 inline-block text-center opacity-60",children:r.type==="removed"?"-":r.type==="added"?"+":" "},void 0,!1,void 0,this),r.line]},o,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{ActiveViewCtx as qa,SessionContext as Va}from"#canvas/runtime";import{useContext as cs,useEffect as ds,useRef as Wa,useState as pn}from"react";var Fa=S({id:m(),type:ot(["select","radio","checkbox","text","range"]),label:m(),value:ca(),options:q(m()).optional(),required:we().optional(),note:m().optional()}).passthrough().transform((e)=>({...e,value:e.value})),Ua=S({id:m(),markdown:m(),label:m().optional(),required:we().optional()}).passthrough(),np=Xn.extend({responses:q(Dr([m(),Fa]).optional().catch(void 0)).transform((e)=>e.filter((t)=>t!==void 0)).catch([]),feedbackEntries:q(Dr([m(),Ua]).optional().catch(void 0)).transform((e)=>e.filter((t)=>t!==void 0)).optional().catch([])});var rp=S({feedback:m().nullish()}),ls=Kn([S({error:m().min(1)}),S({content:m(),language:m().nullish()})]);import{jsxDEV as je}from"react/jsx-dev-runtime";var Ga={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 Ka({path:e,lines:t,__content:n}){let s=cs(Va),{setActiveView:r}=cs(qa),[o,a]=pn(n??null),[l,i]=pn(()=>{let u=e.split(".").pop()||"";return Ga[u]||"text"}),[c,d]=pn(null),[f,g]=pn(!n),x=Wa(null);if(ds(()=>{if(n!==void 0)return;g(!0),d(null),fetch(`/api/file?session=${s}&path=${encodeURIComponent(e)}`).then((u)=>u.json()).then((u)=>{let h=ls.parse(u);if("error"in h)d(h.error);else{let y=h.content;if(t)y=y.split(`
62
+ `).slice(t[0]-1,t[1]).join(`
63
+ `);a(y),i(h.language||"text")}}).catch(()=>d("Failed to fetch file")).finally(()=>g(!1))},[s,e,t?.[0],t?.[1],n]),ds(()=>{let u=x.current,h=dn();if(!u||!h||!o)return;u.removeAttribute("data-highlighted"),u.className=l?`language-${l}`:"",u.textContent=o,h.highlightElement(u)},[o,l]),f)return je("div",{className:"text-text-tertiary text-body mt-3 bg-bg-code rounded-md p-4",children:["Loading ",e,"..."]},void 0,!0,void 0,this);if(c)return je("div",{className:"text-accent-red text-body mt-3 bg-accent-red-muted rounded-md p-4",children:[e,": ",c]},void 0,!0,void 0,this);return je("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden","data-md":"filepreview","data-md-path":e,...t?{"data-md-lines":`${t[0]}-${t[1]}`}:{},children:[je("div",{className:"px-4 py-2 flex items-center justify-between",children:[je("button",{className:"font-mono text-meta text-text-tertiary hover:text-text-secondary hover:underline cursor-pointer text-left",onClick:()=>r({type:"file",path:e}),title:`Open ${e}`,children:e},void 0,!1,void 0,this),t&&je("span",{className:"font-mono text-meta text-text-tertiary opacity-60",children:["L",t[0],"–",t[1]]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),je("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono !bg-transparent",style:{background:"transparent"},children:je("code",{ref:x,className:l?`language-${l}`:"",children:o},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{SessionContext as Ya}from"#canvas/runtime";import{useContext as Ja,useState as Xa}from"react";import{jsxDEV as $t}from"react/jsx-dev-runtime";function Qa({src:e,alt:t,caption:n,width:s,height:r}){let o=Ja(Ya),[a,l]=Xa(!1),i=`/api/image?session=${encodeURIComponent(o)}&path=${encodeURIComponent(e)}`;if(a)return $t("div",{className:"mt-3 text-accent-red text-body bg-accent-red-muted rounded-md p-4",children:[e,": Failed to load image"]},void 0,!0,void 0,this);return $t("figure",{className:"mt-3 relative","data-md":"image","data-md-src":e,children:[$t("div",{"data-annotation-image":!0,className:"rounded-md overflow-hidden border border-border-subtle bg-bg-code inline-block",children:$t("img",{src:i,alt:t||e,onError:()=>l(!0),draggable:!1,className:"block max-w-full h-auto",...s?{width:s}:{},...r?{height:r}:{}},void 0,!1,void 0,this)},void 0,!1,void 0,this),n&&$t("figcaption",{className:"mt-1.5 text-meta text-text-tertiary font-body",children:n},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useMemo as Za}from"react";import{jsxDEV as us}from"react/jsx-dev-runtime";D.setOptions({gfm:!0,breaks:!1});function ei({children:e,file:t,__content:n}){let s=n??(typeof e==="string"?e:String(e??"")),r=Za(()=>{if(!s)return"";return D.parse(s,{async:!1})},[s]);if(!s)return us("div",{className:"text-text-tertiary text-tiny mt-3",children:t?`Could not load: ${t}`:"No markdown content"},void 0,!1,void 0,this);return us("div",{className:"mt-3 prose-canvas","data-md":"markdown",...t?{"data-md-file":t}:{},"data-md-source":s,dangerouslySetInnerHTML:{__html:r}},void 0,!1,void 0,this)}import{useAnnotations as ti,useCanvasFile as ni}from"#canvas/runtime";import{useCallback as _e,useEffect as tr,useRef as Pt,useState as lt}from"react";import ri from"react-dom";import{jsxDEV as N,Fragment as ms}from"react/jsx-dev-runtime";var ct=0.2,fn=0.25,hn=4;function fs({zoom:e,onZoomIn:t,onZoomOut:n,onZoomReset:s,onFullscreen:r}){return N("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:[N("button",{className:"flex items-center justify-center w-7 h-7 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:n,title:"Zoom out",disabled:e<=fn,children:N("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:N("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),N("button",{className:"px-1.5 h-7 rounded hover:bg-bg-elevated text-text-tertiary hover:text-text-primary transition-colors tabular-nums",onClick:s,title:"Reset zoom",children:[Math.round(e*100),"%"]},void 0,!0,void 0,this),N("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:t,title:"Zoom in",disabled:e>=hn,children:N("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[N("line",{x1:"12",y1:"5",x2:"12",y2:"19"},void 0,!1,void 0,this),N("line",{x1:"5",y1:"12",x2:"19",y2:"12"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),r&&N(ms,{children:[N("div",{className:"w-px h-4 bg-border-subtle mx-0.5"},void 0,!1,void 0,this),N("button",{className:"flex items-center justify-center w-7 h-7 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:r,title:"Fullscreen",children:N("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[N("polyline",{points:"15 3 21 3 21 9"},void 0,!1,void 0,this),N("polyline",{points:"9 21 3 21 3 15"},void 0,!1,void 0,this),N("line",{x1:"21",y1:"3",x2:"14",y2:"10"},void 0,!1,void 0,this),N("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 hs(e=1){let[t,n]=lt(e),s=_e(()=>n((a)=>Math.min(hn,+(a+ct).toFixed(2))),[]),r=_e(()=>n((a)=>Math.max(fn,+(a-ct).toFixed(2))),[]),o=_e(()=>n(1),[]);return{zoom:t,zoomIn:s,zoomOut:r,zoomReset:o,setZoom:n}}function si({svgHtml:e,source:t,onClose:n}){let s=Pt(null),{zoom:r,zoomIn:o,zoomOut:a,zoomReset:l,setZoom:i}=hs(1),[c,d]=lt({x:0,y:0}),f=Pt(null);tr(()=>{let T=(O)=>{if(O.key==="Escape")n()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[n]);let g=_e((T)=>{T.preventDefault();let O=T.deltaY>0?-ct:ct;i((M)=>Math.max(fn,Math.min(hn,+(M+O).toFixed(2))))},[i]),x=_e((T)=>{if(T.button!==0)return;f.current={startX:T.clientX,startY:T.clientY,panX:c.x,panY:c.y},T.preventDefault()},[c]),u=_e((T)=>{if(!f.current)return;d({x:f.current.panX+(T.clientX-f.current.startX),y:f.current.panY+(T.clientY-f.current.startY)})},[]),h=_e(()=>{f.current=null},[]),y=_e(()=>{l(),d({x:0,y:0})},[l]);return ri.createPortal(N("div",{style:{position:"fixed",inset:0,zIndex:9999,background:"var(--color-bg-base)",display:"flex",flexDirection:"column"},onMouseMove:u,onMouseUp:h,onMouseLeave:h,children:[N("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:[N("span",{className:"text-body text-text-secondary",style:{fontSize:"13px"},children:"Mermaid Diagram"},void 0,!1,void 0,this),N("div",{className:"flex items-center gap-2",children:[N(fs,{zoom:r,onZoomIn:o,onZoomOut:a,onZoomReset:y},void 0,!1,void 0,this),N("button",{className:"flex items-center justify-center w-8 h-8 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:n,title:"Close (Esc)",children:N("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[N("line",{x1:"18",y1:"6",x2:"6",y2:"18"},void 0,!1,void 0,this),N("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),N("div",{style:{flex:1,overflow:"hidden",cursor:f.current?"grabbing":"grab"},onWheel:g,onMouseDown:x,children:N("div",{ref:s,style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",transform:`translate(${c.x}px, ${c.y}px) scale(${r})`,transformOrigin:"center center",transition:f.current?"none":"transform 0.1s ease-out"},dangerouslySetInnerHTML:{__html:e}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),document.body)}function oi({children:e}){let t=Pt(null),[n,s]=lt(null),[r,o]=lt(!1),[a,l]=lt(""),i=typeof e==="string"?e:String(e??""),{annotations:c,addAnnotationWithId:d,activeAnnotationId:f,setActiveAnnotationId:g}=ti(),x=ni(),[u,h]=lt(null),{zoom:y,zoomIn:T,zoomOut:O,zoomReset:M,setZoom:I}=hs(1),_=Pt(c);_.current=c;let j=_e((G,J,X)=>{let K=`[Diagram ${X.toLowerCase()}] ${J}`,de=_.current.find((Le)=>Le.snippet===K);if(de)g(de.id);else h({anchorEl:G,snippet:J,prefix:X})},[g]),U=Pt(j);U.current=j,tr(()=>{let G=!1,J=async()=>{try{let K=as();if(!K){s("Mermaid library not loaded");return}let de=document.documentElement.dataset.theme==="light"?"default":"dark";K.initialize({startOnLoad:!1,theme:de});let Le=`mermaid-${Math.random().toString(36).slice(2)}`,{svg:He}=await K.render(Le,i.trim());if(!G&&t.current)t.current.innerHTML=He,l(He),ai(t.current,(re,ue,me)=>U.current(re,ue,me)),ps(t.current,_.current);s(null)}catch(K){if(!G)s(K instanceof Error&&K.message||"Invalid diagram")}};J();let X=new MutationObserver((K)=>{for(let de of K)if(de.attributeName==="data-theme")J()});return X.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{G=!0,X.disconnect()}},[i]),tr(()=>{if(t.current)ps(t.current,c,f)},[c,f]);let ne=_e((G)=>{if(!G.ctrlKey&&!G.metaKey)return;G.preventDefault();let J=G.deltaY>0?-ct:ct;I((X)=>Math.max(fn,Math.min(hn,+(X+J).toFixed(2))))},[I]);if(n)return N("div",{className:"bg-accent-red-muted rounded-md p-4 mt-3 text-body text-accent-red",children:["Mermaid error: ",n,N("pre",{className:"mt-2 text-tiny text-text-tertiary whitespace-pre-wrap",children:i},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let le=t.current?.closest("#plan-scroll-container");return N(ms,{children:[N("div",{className:"mt-3 mermaid-container","data-md":"mermaid","data-md-source":i.trim(),children:[N("div",{className:"flex justify-end mb-1",children:N(fs,{zoom:y,onZoomIn:T,onZoomOut:O,onZoomReset:M,onFullscreen:()=>o(!0)},void 0,!1,void 0,this)},void 0,!1,void 0,this),N("div",{style:{overflow:"auto",maxHeight:"70vh"},onWheel:ne,children:N("div",{ref:t,className:"flex justify-center",style:{transform:`scale(${y})`,transformOrigin:"top center",transition:"transform 0.1s ease-out",minHeight:y<1?void 0:void 0}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),u&&N(Lt,{anchorEl:u.anchorEl,scrollContainer:le,snippet:u.snippet,header:N("div",{style:{fontSize:"12px",color:"var(--color-text-tertiary)",marginBottom:"8px",lineHeight:"1.4",display:"flex",alignItems:"center",gap:"6px"},children:[N("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:(G,J)=>{let X=`ann-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;d(X,`[Diagram ${u.prefix.toLowerCase()}] ${u.snippet}`,G,void 0,void 0,J,x||void 0),h(null)},onCancel:()=>h(null)},void 0,!1,void 0,this),r&&a&&N(si,{svgHtml:a,source:i,onClose:()=>o(!1)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function ai(e,t){let n=(s,r,o)=>{s.style.cursor="pointer",s.addEventListener("mouseenter",()=>{s.style.filter="brightness(1.2)"}),s.addEventListener("mouseleave",()=>{s.style.filter=""}),s.addEventListener("click",(a)=>{a.stopPropagation(),a.preventDefault(),t(s,r(),o)})};for(let s of e.querySelectorAll(".node"))n(s,()=>(s.querySelector(".nodeLabel")||s.querySelector("foreignObject span")||s.querySelector("text"))?.textContent?.trim()||"Node","Node");for(let s of e.querySelectorAll(".edgePath")){let r=s,o=r.querySelector("path");if(o){o.style.strokeWidth=Math.max(parseFloat(o.style.strokeWidth||"1"),8)+"px",o.style.strokeOpacity="0";let l=o.cloneNode(!0);l.style.strokeWidth="",l.style.strokeOpacity="",r.insertBefore(l,o)}let a=r.id||"";n(r,()=>{let l=e.querySelectorAll(".edgeLabel");for(let i of l)if(i.id&&a&&i.id.replace("label","").includes(a.replace("L-","").replace("edge",""))){let c=i.textContent?.trim();if(c)return c}return"Connection"},"Edge")}for(let s of e.querySelectorAll(".edgeLabel")){let r=s.textContent?.trim();if(!r)continue;n(s,()=>r,"Edge")}for(let s of e.querySelectorAll(".actor")){let r=s.closest("g")?.querySelector("text")||s.parentElement?.querySelector("text");if(!r)continue;let o=s.closest("g");if(!o||o.hasAttribute("data-clickable"))continue;o.setAttribute("data-clickable","true"),n(o,()=>r.textContent?.trim()||"Participant","Node")}for(let s of e.querySelectorAll(".messageText")){let r=s.textContent?.trim();if(!r)continue;n(s,()=>r,"Edge")}for(let s of e.querySelectorAll(".entityBox")){let r=s.closest("g");if(!r||r.hasAttribute("data-clickable"))continue;let o=r.querySelector(".entityLabel");if(!o)continue;r.setAttribute("data-clickable","true"),n(r,()=>o.textContent?.trim()||"Entity","Node")}for(let s of e.querySelectorAll(".relationshipLabel")){let r=s.textContent?.trim();if(!r)continue;let a=s.closest("g")||s;if(a.hasAttribute("data-clickable"))continue;a.setAttribute("data-clickable","true"),n(a,()=>r,"Edge")}for(let s of e.querySelectorAll(".classGroup")){let r=s;if(r.hasAttribute("data-clickable"))continue;let o=r.querySelector(".classTitle, .classTitleText, text");if(!o)continue;r.setAttribute("data-clickable","true"),n(r,()=>o.textContent?.trim()||"Class","Node")}for(let s of e.querySelectorAll(".statediagram-state")){let r=s;if(r.hasAttribute("data-clickable"))continue;let o=r.querySelector(".state-title, text");if(!o)continue;r.setAttribute("data-clickable","true"),n(r,()=>o.textContent?.trim()||"State","Node")}for(let s of e.querySelectorAll(".mindmap-node")){let r=s;if(r.hasAttribute("data-clickable"))continue;let o=r.querySelector(".mindmap-node-label, text");if(!o)continue;r.setAttribute("data-clickable","true"),n(r,()=>o.textContent?.trim()||"Node","Node")}}function ps(e,t,n){let s=new Map;for(let o of t){let a=o.snippet.match(/^\[Diagram (?:node|edge)\] (.+)$/)?.[1];if(a)s.set(a,o.id)}for(let o of e.querySelectorAll("[data-annotated]"))o.style.outline="",o.style.outlineOffset="",o.style.borderRadius="",o.removeAttribute("data-annotated");if(s.size===0)return;for(let o of e.querySelectorAll(".node")){let l=(o.querySelector(".nodeLabel")||o.querySelector("foreignObject span")||o.querySelector("text"))?.textContent?.trim();if(!l||!s.has(l))continue;let i=s.get(l),c=o;c.setAttribute("data-annotated",i);let d=i===n;c.style.outline=d?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",c.style.outlineOffset="2px",c.style.borderRadius="4px"}for(let o of e.querySelectorAll(".edgeLabel")){let a=o.textContent?.trim();if(!a||!s.has(a))continue;let l=s.get(a),i=o;i.setAttribute("data-annotated",l);let c=l===n;i.style.outline=c?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",i.style.outlineOffset="2px",i.style.borderRadius="4px"}for(let o of e.querySelectorAll(".actor")){let a=o.closest("g");if(!a)continue;let i=a.querySelector("text")?.textContent?.trim();if(!i||!s.has(i))continue;if(a.hasAttribute("data-annotated"))continue;let c=s.get(i);a.setAttribute("data-annotated",c);let d=c===n,f=a.querySelector("rect");if(f)f.style.outline=d?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",f.style.outlineOffset="2px",f.style.borderRadius="4px"}for(let o of e.querySelectorAll(".messageText")){let a=o.textContent?.trim();if(!a||!s.has(a))continue;let l=s.get(a),i=o;i.setAttribute("data-annotated",l);let c=l===n;i.style.outline=c?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",i.style.outlineOffset="2px",i.style.borderRadius="4px"}let r=(o,a,l)=>{for(let i of e.querySelectorAll(o)){let c=l(i);if(!c||c.hasAttribute("data-annotated"))continue;let f=c.querySelector(a)?.textContent?.trim();if(!f||!s.has(f))continue;let g=s.get(f);c.setAttribute("data-annotated",g);let x=g===n,u=c.querySelector("rect, circle, ellipse, polygon")||c;u.style.outline=x?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",u.style.outlineOffset="2px",u.style.borderRadius="4px"}};r(".entityBox",".entityLabel",(o)=>o.closest("g"));for(let o of e.querySelectorAll(".relationshipLabel")){let l=o.closest("g")||o;if(l.hasAttribute("data-annotated"))continue;let i=o.textContent?.trim();if(!i||!s.has(i))continue;let c=s.get(i);l.setAttribute("data-annotated",c);let d=c===n;l.style.outline=d?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",l.style.outlineOffset="2px",l.style.borderRadius="4px"}r(".classGroup",".classTitle, .classTitleText, text",(o)=>o),r(".statediagram-state",".state-title, text",(o)=>o),r(".mindmap-node",".mindmap-node-label, text",(o)=>o)}import{jsxDEV as li}from"react/jsx-dev-runtime";function ii({children:e}){return li("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:Me(e)},void 0,!1,void 0,this)}import{jsxDEV as ui}from"react/jsx-dev-runtime";var ci={high:"text-accent-red bg-accent-red-muted",medium:"text-accent-amber bg-accent-amber-muted",low:"text-text-tertiary bg-border-subtle"};function di({level:e}){return ui("span",{className:`inline text-tiny font-medium font-body ml-2 px-1.5 py-0.5 rounded ${ci[e]}`,"data-md":"priority","data-md-level":e,children:e},void 0,!1,void 0,this)}import{useState as pi}from"react";import{jsxDEV as Ye}from"react/jsx-dev-runtime";function fi({title:e,children:t}){let[n,s]=pi(!1);return Ye("div",{className:"relative mb-8 p-4 group/section","data-md":"section","data-md-title":e,children:[Ye("div",{className:"relative mb-2",children:[Ye("button",{onClick:()=>s(!n),className:`absolute -left-8 top-1/2 -translate-y-1/2 text-text-tertiary opacity-0 group-hover/section:opacity-50 hover:!opacity-100 transition-all duration-150 p-0.5 ${n?"-rotate-90":""}`,children:Ye("svg",{width:"14",height:"14",viewBox:"0 0 12 12",fill:"none",children:Ye("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),Ye("h2",{className:"font-heading text-section text-text-primary",style:{fontWeight:400},children:e},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Ye("div",{className:n?"mt-6 hidden":"mt-6",children:Me(t)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as De}from"react/jsx-dev-runtime";function hi({headers:e,rows:t}){return De("div",{className:"overflow-x-auto mt-3","data-md":"table",children:De("table",{className:"w-full text-body",children:[De("thead",{children:De("tr",{className:"border-b border-border-subtle",children:e.map((n,s)=>De("th",{className:"text-left px-4 py-2.5 text-meta font-medium uppercase tracking-wider text-text-tertiary font-body",children:n},s,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),De("tbody",{children:t.map((n,s)=>De("tr",{className:`relative border-b border-border-subtle last:border-b-0 transition-colors hover:bg-bg-surface/50 ${s%2===1?"bg-bg-surface/30":""}`,children:n.map((r,o)=>De("td",{className:"px-4 py-2.5 text-text-secondary font-body",children:r},o,!1,void 0,this))},s,!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 Se}from"react/jsx-dev-runtime";var mi={todo:"bg-border-hover",done:"bg-accent-green",blocked:"bg-accent-red","in-progress":"bg-accent-blue"},gi={todo:"Todo",done:"Done",blocked:"Blocked","in-progress":"In progress"},xi={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 gs({id:e,label:t,status:n,badge:s,badgeVariant:r="neutral",children:o}){return Se("div",{className:"group/task relative -mx-4 px-4 py-3 rounded-md transition-colors duration-150 hover:bg-bg-input","data-task-id":e,"data-md":"item","data-md-label":t,...n?{"data-md-status":n}:{},...s?{"data-md-badge":s}:{},children:Se("div",{className:"flex items-start gap-3",children:[n&&Se("span",{className:`w-2 h-2 rounded-full mt-[7px] flex-shrink-0 ${mi[n]}`},void 0,!1,void 0,this),Se("div",{className:"flex-1 min-w-0",children:[Se("div",{className:"flex items-baseline gap-2",children:[Se("span",{className:"font-body text-task-label font-semibold text-text-primary",children:t},void 0,!1,void 0,this),n&&Se("span",{className:"font-body text-tiny uppercase tracking-wider text-text-tertiary opacity-0 group-hover/task:opacity-100 transition-opacity duration-150",children:gi[n]},void 0,!1,void 0,this),s&&Se("span",{className:`font-body text-tiny font-medium px-1.5 py-px rounded-full ${xi[r]}`,children:s},void 0,!1,void 0,this)]},void 0,!0,void 0,this),o&&Se("div",{className:"text-body text-text-secondary mt-1 leading-relaxed",children:Me(o)},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 yi(e){return Se(gs,{...e},void 0,!1,void 0,this)}import{useAnnotations as xs,useResponseRegistration as ys}from"#canvas/runtime";import{useRef as bi,useState as bs}from"react";import{jsxDEV as F}from"react/jsx-dev-runtime";function vi({id:e,label:t,placeholder:n,multiline:s,required:r}){let{responses:o,setResponse:a}=xs();ys(e);let l=o.get(e),i=l?.value??"",c=l?.note||"",[d,f]=bs(!1),g=bi(null);if(!o.has(e))a(e,{id:e,type:"text",label:t,value:"",required:r});let x=(y)=>{a(e,{...l,value:y})},u=(y)=>Ne(y,s?60:32),h=l?.required&&!i.trim();return F("div",{"data-md":"userinput","data-md-label":t,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:t},void 0,!1,void 0,this),r&&F("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F("textarea",{ref:g,value:i,onChange:(y)=>{x(y.currentTarget.value),u(y.currentTarget)},placeholder:n||"Type your response...",rows:s?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:(y)=>u(y.currentTarget),onFocus:(y)=>u(y.currentTarget)},void 0,!1,void 0,this),F(it,{show:d,note:c,onToggle:()=>f(!d),onChange:(y)=>a(e,{...l,note:y})},void 0,!1,void 0,this),h&&F("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 ki({id:e,label:t,min:n=1,max:s=10,step:r=1,required:o,minLabel:a,maxLabel:l}){let{responses:i,setResponse:c}=xs();ys(e);let d=i.get(e),f=d?.value,g=d?.note||"",[x,u]=bs(!1);if(!i.has(e))c(e,{id:e,type:"range",label:t,value:null,required:o});let h=(j)=>{c(e,{...d,value:j})},y=f!==null&&f!==void 0,T=y?f:Math.round((n+s)/2),O=(T-n)/(s-n)*100,M=Math.round((s-n)/r),I=M<=20,_=d?.required&&!y;return F("div",{"data-md":"rangeinput","data-md-label":t,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 justify-between mb-1",children:[F("div",{className:"flex items-baseline gap-2",children:[F("span",{className:"text-[13px] font-body font-medium text-text-primary",children:t},void 0,!1,void 0,this),o&&F("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F("span",{className:"flex items-center gap-1.5",children:[F("span",{className:`text-[13px] font-mono ${y?"text-accent-amber":"text-text-disabled"}`,children:y?f:"—"},void 0,!1,void 0,this),y&&F("button",{onClick:()=>c(e,{...d,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),F("div",{className:"relative h-6 flex items-center",children:[F("div",{className:"absolute left-0 right-0 h-1.5 rounded-full bg-border-medium",children:y&&F("div",{className:"h-full rounded-full bg-accent-amber transition-all duration-150",style:{width:`${O}%`}},void 0,!1,void 0,this)},void 0,!1,void 0,this),I&&Array.from({length:M+1},(j,U)=>{let ne=n+U*r,le=(ne-n)/(s-n)*100,G=y&&ne<=f;return F("div",{className:`absolute rounded-full pointer-events-none transition-all duration-150 ${y&&ne===f?"w-2.5 h-2.5 bg-accent-amber":G?"w-1.5 h-1.5 bg-accent-amber":"w-1.5 h-1.5 bg-border-hover"}`,style:{left:`${le}%`,transform:"translate(-50%, -50%)",top:"50%"}},U,!1,void 0,this)}),y?F("div",{className:"absolute h-5 w-5 rounded-full bg-accent-amber shadow-md pointer-events-none transition-all duration-150",style:{left:`calc(${O}% - 10px)`,borderWidth:"2px",borderStyle:"solid",borderColor:"var(--color-bg-base)"}},void 0,!1,void 0,this):F("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),F("input",{type:"range",min:n,max:s,step:r,value:T,onChange:(j)=>h(Number(j.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&&M<=10?F("div",{className:"flex justify-between -mt-0.5 px-0",children:Array.from({length:M+1},(j,U)=>{let ne=n+U*r;return F("span",{className:`text-[10px] font-mono transition-colors ${y&&ne===f?"text-accent-amber font-medium":"text-text-disabled"}`,style:{minWidth:"1ch",textAlign:"center"},children:ne},U,!1,void 0,this)})},void 0,!1,void 0,this):F("div",{className:"flex justify-between -mt-0.5",children:[F("span",{className:"text-[11px] text-text-tertiary font-body",children:a||n},void 0,!1,void 0,this),F("span",{className:"text-[11px] text-text-tertiary font-body",children:l||s},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F(it,{show:x,note:g,onToggle:()=>u(!x),onChange:(j)=>c(e,{...d,note:j})},void 0,!1,void 0,this),_&&F("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)}var nr=26214400,vs=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/,rr=S({id:m(),name:m(),path:m(),size:Q().int()});var ks=S({shareId:m(),url:m(),revision:Q(),createdAt:m(),ownerToken:m().optional(),expiresAt:m().optional(),lastFeedbackAt:m().optional(),encryptionKey:m().optional()}),wi=S({revision:Q(),label:m().optional(),canvasFiles:q(S({filename:m(),diffStats:S({added:Q(),removed:Q()}).optional()})),createdAt:m(),hasFeedback:we(),feedbackConsumed:we(),response:m().optional()}).passthrough(),_i=S({encryption:S({alg:st("AES-GCM"),v:st(1)}).optional(),origin:S({sessionId:m().optional(),label:m().optional(),revision:Q().optional(),createdAt:m().optional()}).optional(),currentRevision:Q().optional(),revisions:q(wi).optional(),canvasFiles:q(m()).optional(),projectRoot:m().optional(),shares:q(ks).optional(),shareEnabled:we().optional()}).passthrough(),yf=S({entries:q(S({name:m(),type:ot(["file","dir"])}))}),Si=S({id:m(),shareId:m(),revision:Q(),submittedAt:m(),author:Yn,annotations:q(Jn.omit({source:!0,author:!0})),generalNote:m().optional()}),bf=S({entries:q(Si)}),vf=Kn([S({ok:st(!0),share:ks}),S({ok:st(!1).optional(),error:m().optional()})]),kf=Kn([S({ok:st(!0)}),S({ok:st(!1).optional(),error:m().optional()})]);async function ws(e){let t=Ti(e);return crypto.subtle.importKey("raw",t,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}async function _s(e,t){let n=Ss(t);if(n.byteLength<28)throw Error("Ciphertext too short");let s=n.subarray(0,12),r=n.subarray(12),o=await crypto.subtle.decrypt({name:"AES-GCM",iv:s},e,r);return new TextDecoder().decode(o)}function Ss(e){let t=atob(e),n=new Uint8Array(t.length);for(let s=0;s<t.length;s++)n[s]=t.charCodeAt(s);return n}function Ti(e){let t=e.replace(/-/g,"+").replace(/_/g,"/")+"===".slice((e.length+3)%4);return Ss(t)}function Ai(e){let t;try{t=new URL(e)}catch{return!1}if(t.protocol!=="http:"&&t.protocol!=="https:")return!1;return t.hostname==="localhost"||t.hostname==="127.0.0.1"||t.hostname==="[::1]"||t.hostname.endsWith(".localhost")}var ze=m().max(500),Ri=4000,Ei=1000,Ci=1000,Ni=S({label:ze,file:m().max(Ei),line:Q().int().positive(),column:Q().int().nonnegative()}),As=S({url:m().min(1).max(2000),selector:m().max(2000),role:ze.optional(),name:ze.optional(),text:ze.optional(),components:q(m().max(200)).max(20).optional(),sources:q(Ni).max(10).optional(),context:ze.optional(),browser:S({name:ze,viewport:S({width:Q().int().nonnegative(),height:Q().int().nonnegative(),scale:Q().positive()}),colorScheme:ot(["light","dark"])}).optional(),style:m().max(Ci).optional(),html:m().max(Ri).optional(),quote:S({exact:m().min(1).max(2000),before:ze,after:ze}).optional()}),Ii=ot(["user","agent"]),sr=S({id:m(),author:Ii,body:m().min(1).max(20000),createdAt:m()}),or=ot(["open","queued","working","resolved"]),Li=S({id:m(),anchor:As,state:or,comments:q(sr).min(1),screenshot:m().optional(),createdAt:m(),updatedAt:m()}),Tf=S({threads:q(Li)}),ar=m().trim().min(1).max(20000),Ts="data:image/png;base64,",Mi=m().startsWith(Ts).max(8000000).transform((e)=>Uint8Array.from(atob(e.slice(Ts.length)),(t)=>t.charCodeAt(0))),Af=S({anchor:As,body:ar,send:we(),screenshot:Mi.optional()}),Rf=S({body:ar,send:we()}),Ef=S({body:ar,resolve:we()}),Rs=m().url().refine((e)=>Ai(e),"must be an http(s) URL on localhost"),Cf=S({target:Rs}),Nf=S({target:Rs,port:Q().int().min(1).max(65535)});var Ot=S({id:m(),state:or,revision:Q().int(),snippet:m(),canvasFile:m().optional(),filePath:m().optional(),comments:q(sr),createdAt:m(),updatedAt:m()}),Bf=S({threads:q(Ot)}),Es=m().trim().min(1).max(20000),Ff=S({body:Es,resolve:we()}),Uf=S({body:Es}),qf=S({resolved:we()});var $i=S({threads:q(Ot)}),Pi=S({thread:Ot});async function Cs(e){let t=await e.json().catch(()=>null),n=S({error:m()}).safeParse(t);return Error(n.success?n.data.error:`Thread request failed with status ${e.status}`)}function Oi(e,t){let n=new Map(t.map((o)=>[o.id,o])),s=e.map((o)=>{let a=n.get(o.id);return a!==void 0&&a.updatedAt>=o.updatedAt?a:o}),r=new Set(e.map((o)=>o.id));return[...s,...t.filter((o)=>!r.has(o.id))]}function Ns(e){let t=[],n=new Set,s=`/api/session/${encodeURIComponent(e)}/threads`,r=(a)=>{t=Oi(t,a);for(let l of n)l()},o=async(a,l)=>{let i=await fetch(`${s}/${a}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!i.ok)throw await Cs(i);r([Pi.parse(await i.json()).thread])};return{subscribe(a){return n.add(a),()=>n.delete(a)},current:()=>t,async load(){let a=await fetch(s,{cache:"no-store"});if(!a.ok)throw await Cs(a);r($i.parse(await a.json()).threads)},receive(a){let l=q(Ot).safeParse(a);if(l.success)r(l.data)},reply:(a,l)=>o(`${encodeURIComponent(a)}/comments`,{body:l}),setResolved:(a,l)=>o(`${encodeURIComponent(a)}/resolved`,{resolved:l})}}function ji(){if(typeof window>"u")return null;let e=window.location.hash.replace(/^#/,"");if(!e)return null;for(let t of e.split("&")){let[n,s]=t.split("=");if(n==="k"&&s)return decodeURIComponent(s)}return null}function Di(){if(typeof window<"u"&&window.__CANVAS_SHARE__?.shareId){let t=ji();return{isShared:!0,shareId:window.__CANVAS_SHARE__.shareId,encryptionKey:t?ws(t):null}}return{isShared:!1,sessionId:typeof window<"u"?window.location.pathname.replace("/s/",""):""}}var B=Di();function zi(){return B.isShared&&B.encryptionKey!==null}function Hi(){return B.isShared?B.shareId:B.sessionId}function Bi(e,t){let n=e.replace(/\.jsx$/,".js");if(B.isShared)return`/s/${B.shareId}/canvas/${encodeURIComponent(n)}`;let s=t?`?rev=${t}&t=${Date.now()}`:`?t=${Date.now()}`;return`/api/session/${B.sessionId}/canvas/${encodeURIComponent(n)}${s}`}function Fi(){if(B.isShared)return`/s/${B.shareId}/upload`;return`/api/session/${B.sessionId}/upload`}function ir(e,t){if(B.isShared)throw Error("Secret inputs are available only on the local canvas daemon");return`/api/session/${encodeURIComponent(B.sessionId)}/secrets/${encodeURIComponent(e)}/${t}`}async function dt(e){let t=await e.json().catch(()=>null);if(typeof t==="object"&&t!==null&&"error"in t&&typeof t.error==="string")return Error(t.error);return Error(`Request failed with status ${e.status}`)}function lr(e,t){if(B.isShared)throw Error("File drops are available only on the local canvas daemon");let n=`/api/session/${encodeURIComponent(B.sessionId)}/assets/${encodeURIComponent(e)}`;return t===void 0?n:`${n}/${encodeURIComponent(t)}`}async function Is(e){let t=await fetch(lr(e),{cache:"no-store"});if(!t.ok)throw await dt(t);return S({files:q(rr)}).parse(await t.json()).files}async function Ls(e,t){let n=new FormData;n.append("file",t);let s=await fetch(lr(e),{method:"POST",body:n});if(!s.ok)throw await dt(s);return S({file:rr}).parse(await s.json()).file}async function Ms(e,t){let n=await fetch(lr(e,t),{method:"DELETE"});if(!n.ok)throw await dt(n)}async function $s(e){let t=await fetch(ir(e,"status"),{cache:"no-store"});if(!t.ok)throw await dt(t);let n=await t.json();return typeof n==="object"&&n!==null&&"ready"in n&&n.ready===!0}async function Ps(e,t){let n=await fetch(ir(e,"value"),{method:"POST",headers:{"Content-Type":"application/json"},cache:"no-store",body:JSON.stringify({value:t})});if(!n.ok)throw await dt(n)}async function Os(e){let t=await fetch(ir(e,"value"),{method:"DELETE",cache:"no-store"});if(!t.ok)throw await dt(t)}var Ui=async(e,t)=>{let n=Bi(e,t);if(!zi())return import(n);let s=await fetch(n);if(!s.ok)throw Error(`canvas ${s.status}`);let r=await s.text(),o=await B.encryptionKey,a=await _s(o,r),l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l);try{return await import(i)}finally{setTimeout(()=>URL.revokeObjectURL(i),0)}};var qi=!B.isShared,nh=!B.isShared,Vi=B.isShared?null:Ns(B.sessionId),rh={get sessionId(){return Hi()},isShared:B.isShared,fsAvailable:qi,uploadUrl:Fi,loadCanvasModule:Ui,threads:Vi};import{jsxDEV as cr}from"react/jsx-dev-runtime";function Wi({path:e,label:t}){let n=e.split("/").pop()||"download";if(B.isShared)return cr("p",{className:"text-[13px] font-body text-text-tertiary my-2",children:[t||n," (download available only on the canvas author's machine)"]},void 0,!0,void 0,this);let s=`/api/download?session=${encodeURIComponent(B.sessionId)}&path=${encodeURIComponent(e)}`;return cr("a",{href:s,download:n,className:"inline-flex items-center gap-2 my-2 px-3 py-1.5 rounded-lg border border-border-subtle bg-bg-input text-[13px] font-body text-text-primary hover:border-border-hover",children:[cr("span",{"aria-hidden":"true",children:"↓"},void 0,!1,void 0,this),t||n]},void 0,!0,void 0,this)}import{useFeedback as Gi}from"#canvas/runtime";import{useEffect as Ki,useState as mn}from"react";import{jsxDEV as ae}from"react/jsx-dev-runtime";function dr(e){if(e<1024)return`${e} B`;if(e<1048576)return`${(e/1024).toFixed(1)} KB`;return`${(e/1024/1024).toFixed(1)} MB`}function Yi({id:e,label:t,accept:n,maxBytes:s,required:r}){let[o,a]=mn([]),[l,i]=mn(!B.isShared),[c,d]=mn(null),[f,g]=mn(!1),x=vs.test(e),u=!B.isShared,h=r===!0&&u&&x,y=Math.min(s??nr,nr);Ki(()=>{if(!u||!x){i(!1);return}let _=!0;return Is(e).then((j)=>{if(_)a(j)}).catch((j)=>{if(_)d(j instanceof Error?j.message:"Could not read the files")}).finally(()=>{if(_)i(!1)}),()=>{_=!1}},[e,u,x]);let T=o.length===0?"":`**${t}**
64
+ ${o.map((_)=>`- \`${_.path}\` (${_.name}, ${dr(_.size)})`).join(`
65
+ `)}
66
+ `;Gi(`files:${e}`,T,{label:t,required:h});let O=async(_)=>{if(_.length===0)return;if(l){d("Wait until the current upload finishes");return}let j=_.filter((U)=>U.size>y);if(j.length>0){d(`${j.map((U)=>U.name).join(", ")}: larger than ${dr(y)}`);return}i(!0),d(null);try{for(let U of _){let ne=await Ls(e,U);a((le)=>[...le,ne])}}catch(U){d(U instanceof Error?U.message:"Could not upload the file")}finally{i(!1)}},M=async(_)=>{i(!0),d(null);try{await Ms(e,_.id),a((j)=>j.filter((U)=>U.id!==_.id))}catch(j){d(j instanceof Error?j.message:"Could not remove the file")}finally{i(!1)}},I=`file-drop-${e}`;return ae("div",{"data-md":"filedrop","data-md-label":t,className:"-mx-4 px-4 py-3 my-1 rounded-lg",children:[ae("div",{className:"flex items-baseline gap-2 mb-2",children:[ae("label",{htmlFor:I,className:"text-[13px] font-body font-medium text-text-primary",children:t},void 0,!1,void 0,this),h&&ae("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!x&&ae("p",{className:"text-[12px] text-accent-red font-body",children:"Invalid field ID."},void 0,!1,void 0,this),!u&&ae("p",{className:"text-[12px] text-text-tertiary font-body",children:"Files can be added only on the canvas author's machine."},void 0,!1,void 0,this),u&&x&&ae("div",{onDragOver:(_)=>{_.preventDefault(),g(!0)},onDragLeave:(_)=>{if(_.relatedTarget instanceof Node&&_.currentTarget.contains(_.relatedTarget))return;g(!1)},onDrop:(_)=>{_.preventDefault(),g(!1),O([..._.dataTransfer?.files??[]])},className:`rounded-lg border border-dashed px-3 py-4 text-center text-[13px] font-body ${f?"border-accent-blue bg-accent-blue-muted":"border-border-medium bg-bg-input"}`,children:[ae("span",{className:"text-text-secondary",children:"Drop files here or"},void 0,!1,void 0,this)," ",ae("input",{id:I,type:"file",multiple:!0,accept:n,disabled:l,onChange:(_)=>{let j=[..._.currentTarget.files??[]];_.currentTarget.value="",O(j)},className:"text-[12px] text-text-secondary"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),o.length>0&&ae("ul",{className:"mt-2 space-y-1",children:o.map((_)=>ae("li",{className:"flex items-center justify-between gap-2 text-[13px] font-body text-text-primary",children:[ae("span",{className:"truncate",title:_.path,children:[_.name," · ",dr(_.size)]},void 0,!0,void 0,this),ae("button",{type:"button",disabled:l,onClick:()=>void M(_),className:"text-[12px] text-text-tertiary hover:text-text-secondary",children:"Remove"},void 0,!1,void 0,this)]},_.id,!0,void 0,this))},void 0,!1,void 0,this),c&&ae("p",{role:"alert",className:"text-[12px] text-accent-red font-body mt-1",children:c},void 0,!1,void 0,this),h&&o.length===0&&ae("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)}import{useFeedback as Ji}from"#canvas/runtime";import{useEffect as Xi,useState as gn}from"react";import{jsxDEV as ie}from"react/jsx-dev-runtime";var Qi=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/,Zi=/^[A-Za-z_][A-Za-z0-9_]*$/;function el({id:e,label:t,env:n,placeholder:s,required:r}){let[o,a]=gn(""),[l,i]=gn(!1),[c,d]=gn(!B.isShared),[f,g]=gn(null),x=Qi.test(e),u=Zi.test(n),h=!B.isShared;Xi(()=>{if(!h||!x){d(!1);return}let I=!0;return $s(e).then((_)=>{if(I)i(_)}).catch((_)=>{if(I)g(_ instanceof Error?_.message:"Could not read secret status")}).finally(()=>{if(I)d(!1)}),()=>{I=!1}},[e,h,x]);let y=l?`**${t}**
67
+ Secret is ready. Field: \`${e}\`. Environment variable: \`${n}\`.
68
+ `:"";Ji(`secret:${e}`,y,{label:t,required:r&&h});let T=async()=>{if(!o||!x||!u)return;d(!0),g(null);try{await Ps(e,o),a(""),i(!0)}catch(I){g(I instanceof Error?I.message:"Could not store secret")}finally{d(!1)}},O=async()=>{d(!0),g(null);try{await Os(e),i(!1)}catch(I){g(I instanceof Error?I.message:"Could not clear secret")}finally{d(!1)}};if(!h)return ie("div",{"data-md":"secretinput","data-md-label":t,className:"-mx-4 px-4 py-3 my-1 rounded-lg bg-accent-amber-muted",children:[ie("div",{className:"text-[13px] font-body font-medium text-text-primary",children:t},void 0,!1,void 0,this),ie("p",{className:"text-[12px] font-body text-text-secondary mt-1",children:"Secret input is unavailable in shared canvases. Open this runbook on the author's local canvas daemon."},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let M=!x?"Secret field IDs may contain letters, numbers, dots, underscores, and hyphens.":!u?"Environment variable names must use letters, numbers, and underscores and may not start with a number.":null;return ie("div",{"data-md":"secretinput","data-md-label":t,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[ie("div",{className:"flex items-baseline justify-between gap-3 mb-2",children:[ie("div",{className:"flex items-baseline gap-2",children:[ie("span",{className:"text-[13px] font-body font-medium text-text-primary",children:t},void 0,!1,void 0,this),r&&ie("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ie("span",{className:`text-[11px] font-body ${l?"text-accent-green":"text-text-tertiary"}`,children:c?"Working…":l?"Ready in memory":"Not stored"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ie("div",{className:"flex gap-2",children:[ie("input",{type:"password",value:o,onChange:(I)=>a(I.target.value),onKeyDown:(I)=>{if(I.key==="Enter")I.preventDefault(),T()},placeholder:s||"Paste secret value",autoComplete:"off",spellCheck:!1,disabled:c||!!M,className:"min-w-0 flex-1 bg-bg-input text-[13px] font-mono text-text-primary rounded-lg px-3 py-2 focus:outline-none border border-border-subtle focus:border-border-hover placeholder:text-text-tertiary disabled:opacity-50 transition-colors"},void 0,!1,void 0,this),ie("button",{type:"button",onClick:()=>void T(),disabled:c||!o||!!M,className:"px-3 py-2 rounded-lg bg-btn-primary text-btn-primary-text text-[12px] font-body font-medium disabled:opacity-40 disabled:cursor-default",children:l?"Replace":"Store"},void 0,!1,void 0,this),l&&ie("button",{type:"button",onClick:()=>void O(),disabled:c,className:"px-3 py-2 rounded-lg border border-border-subtle text-text-secondary text-[12px] font-body font-medium hover:border-border-hover disabled:opacity-40",children:"Clear"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ie("p",{className:"text-[11px] font-body text-text-tertiary mt-1.5",children:["Stored only in daemon memory. The agent receives field ",e," for ",n,", not the value."]},void 0,!0,void 0,this),(M||f)&&ie("p",{className:"text-[11px] text-accent-red font-body mt-1",children:M||f},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}export{Io as Callout,Lo as Checklist,Pa as Choice,za as CodeBlock,Ba as Diff,Wi as Download,Yi as FileDrop,Ka as FilePreview,Qa as ImageView,gs as Item,ei as Markdown,oi as Mermaid,Oa as MultiChoice,ii as Note,di as Priority,ki as RangeInput,el as SecretInput,fi as Section,hi as Table,yi as Task,vi as UserInput,Xp as useFeedback};