agent-canvas 0.9.0-dev.12 → 0.9.0-dev.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -0
- package/bin/agent-canvas.ts +8 -1
- package/bin/lib/cli-auth.ts +31 -0
- package/bin/lib/commands/daemon.ts +2 -1
- package/bin/lib/commands/exec.ts +5 -4
- package/bin/lib/commands/fetch.ts +4 -4
- package/bin/lib/commands/push.ts +3 -2
- package/bin/lib/commands/reply.ts +45 -0
- package/bin/lib/commands/review.ts +4 -2
- package/bin/lib/commands/watch.ts +100 -5
- package/bin/lib/helpers.ts +121 -43
- package/bin/lib/instructions/component-download.md +28 -0
- package/bin/lib/instructions/component-filedrop.md +50 -0
- package/bin/lib/instructions/overview.md +41 -1
- package/bin/lib/instructions/template-dashboard.md +177 -0
- package/bin/lib/instructions/template-slides.md +196 -0
- package/bin/lib/instructions/theming.md +25 -0
- package/daemon/client/App.tsx +17 -5
- package/daemon/client/clientApi.ts +64 -5
- package/daemon/client/components/Download.tsx +28 -0
- package/daemon/client/components/FileDrop.tsx +164 -0
- package/daemon/client/components/index.ts +3 -1
- package/daemon/client/threadStore.ts +70 -0
- package/daemon/dist/client.css +1 -1
- package/daemon/dist/client.js +57 -56
- package/daemon/dist/components.js +52 -49
- package/daemon/src/admission.ts +102 -0
- package/daemon/src/assets.ts +16 -0
- package/daemon/src/components.ts +6 -1
- package/daemon/src/handlers/api.ts +7 -4
- package/daemon/src/handlers/assets.ts +126 -0
- package/daemon/src/handlers/files.ts +124 -19
- package/daemon/src/handlers/static.ts +65 -1
- package/daemon/src/handlers/theme.ts +150 -0
- package/daemon/src/handlers/threads.ts +93 -0
- package/daemon/src/review/server.ts +1 -1
- package/daemon/src/server.ts +81 -47
- package/daemon/src/threads.ts +132 -0
- package/package.json +4 -4
- package/skills/canvas/SKILL.md +5 -0
- package/types/bin/lib/cli-auth.d.ts +9 -0
- package/types/bin/lib/commands/reply.d.ts +2 -0
- package/types/bin/lib/commands/watch.d.ts +3 -1
- package/types/bin/lib/helpers.d.ts +102 -0
- package/types/daemon/client/clientApi.d.ts +14 -1
- package/types/daemon/client/components/Download.d.ts +9 -0
- package/types/daemon/client/components/FileDrop.d.ts +12 -0
- package/types/daemon/client/components/index.d.ts +2 -0
- package/types/daemon/client/threadStore.d.ts +15 -0
- package/types/daemon/src/admission.d.ts +24 -0
- package/types/daemon/src/assets.d.ts +23 -0
- package/types/daemon/src/components.d.ts +3 -1
- package/types/daemon/src/handlers/assets.d.ts +14 -0
- package/types/daemon/src/handlers/files.d.ts +8 -2
- package/types/daemon/src/handlers/static.d.ts +16 -0
- package/types/daemon/src/handlers/theme.d.ts +18 -0
- package/types/daemon/src/handlers/threads.d.ts +19 -0
- package/types/daemon/src/review/model.d.ts +24 -24
- package/types/daemon/src/review/remote.d.ts +8 -8
- package/types/daemon/src/review/server.d.ts +2 -0
- package/types/daemon/src/threads.d.ts +109 -0
|
@@ -1,65 +1,68 @@
|
|
|
1
|
-
var
|
|
2
|
-
]`).replace("lheading",
|
|
3
|
-
`).map((
|
|
4
|
-
`)}var
|
|
5
|
-
`)}}}fences($){let
|
|
6
|
-
`)}}blockquote($){let
|
|
1
|
+
var E4=Object.defineProperty;var I4=($)=>$;function Z4($,Q){this[$]=I4.bind(null,Q)}var g4=($,Q)=>{for(var J in Q)E4($,J,{get:Q[J],enumerable:!0,configurable:!0,set:Z4.bind(Q,J)})};import{useFeedback as vW}from"#canvas/runtime";function w1(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var l$=w1();function G2($){l$=$}var p$={exec:()=>null};function y($,Q=""){let J=typeof $=="string"?$:$.source,q={replace:(W,Y)=>{let X=typeof Y=="string"?Y:Y.source;return X=X.replace(Q$.caret,"$1"),J=J.replace(W,X),q},getRegex:()=>new RegExp(J,Q)};return q}var y4=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),Q$={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)}}>`)},m4=/^(?:[ \t]*(?:\n|$))+/,h4=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,x4=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,j0=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,u4=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,L1=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,B2=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,_2=y(B2).replace(/bull/g,L1).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(),p4=y(B2).replace(/bull/g,L1).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(),O1=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,c4=/^[^\n]+/,F1=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,l4=y(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",F1).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),d4=y(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,L1).getRegex(),c0="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",A1=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,i4=y("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",A1).replace("tag",c0).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),M2=y(O1).replace("hr",j0).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",c0).getRegex(),r4=y(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",M2).getRegex(),S1={blockquote:r4,code:h4,def:l4,fences:x4,heading:u4,hr:j0,html:i4,lheading:_2,list:d4,newline:m4,paragraph:M2,table:p$,text:c4},J2=y("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",j0).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",c0).getRegex(),o4={...S1,lheading:p4,table:J2,paragraph:y(O1).replace("hr",j0).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",J2).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",c0).getRegex()},n4={...S1,html:y(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",A1).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:p$,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:y(O1).replace("hr",j0).replace("heading",` *#{1,6} *[^
|
|
2
|
+
]`).replace("lheading",_2).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},a4=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,s4=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,U2=/^( {2,}|\\)\n(?!\s*$)/,t4=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,s$=/[\p{P}\p{S}]/u,l0=/[\s\p{P}\p{S}]/u,z1=/[^\s\p{P}\p{S}]/u,e4=y(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,l0).getRegex(),K2=/(?!~)[\p{P}\p{S}]/u,$3=/(?!~)[\s\p{P}\p{S}]/u,Q3=/(?:[^\s\p{P}\p{S}]|~)/u,J3=y(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",y4?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),N2=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,W3=y(N2,"u").replace(/punct/g,s$).getRegex(),q3=y(N2,"u").replace(/punct/g,K2).getRegex(),w2="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Y3=y(w2,"gu").replace(/notPunctSpace/g,z1).replace(/punctSpace/g,l0).replace(/punct/g,s$).getRegex(),X3=y(w2,"gu").replace(/notPunctSpace/g,Q3).replace(/punctSpace/g,$3).replace(/punct/g,K2).getRegex(),H3=y("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,z1).replace(/punctSpace/g,l0).replace(/punct/g,s$).getRegex(),G3=y(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,s$).getRegex(),B3="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",_3=y(B3,"gu").replace(/notPunctSpace/g,z1).replace(/punctSpace/g,l0).replace(/punct/g,s$).getRegex(),M3=y(/\\(punct)/,"gu").replace(/punct/g,s$).getRegex(),U3=y(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),K3=y(A1).replace("(?:-->|$)","-->").getRegex(),N3=y("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",K3).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),x0=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,w3=y(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",x0).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),L2=y(/^!?\[(label)\]\[(ref)\]/).replace("label",x0).replace("ref",F1).getRegex(),O2=y(/^!?\[(ref)\](?:\[\])?/).replace("ref",F1).getRegex(),L3=y("reflink|nolink(?!\\()","g").replace("reflink",L2).replace("nolink",O2).getRegex(),W2=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,R1={_backpedal:p$,anyPunctuation:M3,autolink:U3,blockSkip:J3,br:U2,code:s4,del:p$,delLDelim:p$,delRDelim:p$,emStrongLDelim:W3,emStrongRDelimAst:Y3,emStrongRDelimUnd:H3,escape:a4,link:w3,nolink:O2,punctuation:e4,reflink:L2,reflinkSearch:L3,tag:N3,text:t4,url:p$},O3={...R1,link:y(/^!?\[(label)\]\((.*?)\)/).replace("label",x0).getRegex(),reflink:y(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",x0).getRegex()},N1={...R1,emStrongRDelimAst:X3,emStrongLDelim:q3,delLDelim:G3,delRDelim:_3,url:y(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",W2).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:y(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",W2).getRegex()},F3={...N1,br:y(U2).replace("{2,}","*").getRegex(),text:y(N1.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},h0={normal:S1,gfm:o4,pedantic:n4},S0={normal:R1,gfm:N1,breaks:F3,pedantic:O3},A3={"&":"&","<":"<",">":">",'"':""","'":"'"},q2=($)=>A3[$];function F$($,Q){if(Q){if(Q$.escapeTest.test($))return $.replace(Q$.escapeReplace,q2)}else if(Q$.escapeTestNoEncode.test($))return $.replace(Q$.escapeReplaceNoEncode,q2);return $}function Y2($){try{$=encodeURI($).replace(Q$.percentDecode,"%")}catch{return null}return $}function X2($,Q){let J=$.replace(Q$.findPipe,(Y,X,G)=>{let H=!1,_=X;for(;--_>=0&&G[_]==="\\";)H=!H;return H?"|":" |"}),q=J.split(Q$.splitPipe),W=0;if(q[0].trim()||q.shift(),q.length>0&&!q.at(-1)?.trim()&&q.pop(),Q)if(q.length>Q)q.splice(Q);else for(;q.length<Q;)q.push("");for(;W<q.length;W++)q[W]=q[W].trim().replace(Q$.slashPipe,"|");return q}function z0($,Q,J){let q=$.length;if(q===0)return"";let W=0;for(;W<q;){let Y=$.charAt(q-W-1);if(Y===Q&&!J)W++;else if(Y!==Q&&J)W++;else break}return $.slice(0,q-W)}function S3($,Q){if($.indexOf(Q[1])===-1)return-1;let J=0;for(let q=0;q<$.length;q++)if($[q]==="\\")q++;else if($[q]===Q[0])J++;else if($[q]===Q[1]&&(J--,J<0))return q;return J>0?-2:-1}function z3($,Q=0){let J=Q,q="";for(let W of $)if(W==="\t"){let Y=4-J%4;q+=" ".repeat(Y),J+=Y}else q+=W,J++;return q}function H2($,Q,J,q,W){let Y=Q.href,X=Q.title||null,G=$[1].replace(W.other.outputLinkReplace,"$1");q.state.inLink=!0;let H={type:$[0].charAt(0)==="!"?"image":"link",raw:J,href:Y,title:X,text:G,tokens:q.inlineTokens(G)};return q.state.inLink=!1,H}function R3($,Q,J){let q=$.match(J.other.indentCodeCompensation);if(q===null)return Q;let W=q[1];return Q.split(`
|
|
3
|
+
`).map((Y)=>{let X=Y.match(J.other.beginningSpace);if(X===null)return Y;let[G]=X;return G.length>=W.length?Y.slice(W.length):Y}).join(`
|
|
4
|
+
`)}var u0=class{options;rules;lexer;constructor($){this.options=$||l$}space($){let Q=this.rules.block.newline.exec($);if(Q&&Q[0].length>0)return{type:"space",raw:Q[0]}}code($){let Q=this.rules.block.code.exec($);if(Q){let J=Q[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:Q[0],codeBlockStyle:"indented",text:this.options.pedantic?J:z0(J,`
|
|
5
|
+
`)}}}fences($){let Q=this.rules.block.fences.exec($);if(Q){let J=Q[0],q=R3(J,Q[3]||"",this.rules);return{type:"code",raw:J,lang:Q[2]?Q[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):Q[2],text:q}}}heading($){let Q=this.rules.block.heading.exec($);if(Q){let J=Q[2].trim();if(this.rules.other.endingHash.test(J)){let q=z0(J,"#");(this.options.pedantic||!q||this.rules.other.endingSpaceChar.test(q))&&(J=q.trim())}return{type:"heading",raw:Q[0],depth:Q[1].length,text:J,tokens:this.lexer.inline(J)}}}hr($){let Q=this.rules.block.hr.exec($);if(Q)return{type:"hr",raw:z0(Q[0],`
|
|
6
|
+
`)}}blockquote($){let Q=this.rules.block.blockquote.exec($);if(Q){let J=z0(Q[0],`
|
|
7
7
|
`).split(`
|
|
8
|
-
`),q="",W="",
|
|
9
|
-
`),_
|
|
8
|
+
`),q="",W="",Y=[];for(;J.length>0;){let X=!1,G=[],H;for(H=0;H<J.length;H++)if(this.rules.other.blockquoteStart.test(J[H]))G.push(J[H]),X=!0;else if(!X)G.push(J[H]);else break;J=J.slice(H);let _=G.join(`
|
|
9
|
+
`),M=_.replace(this.rules.other.blockquoteSetextReplace,`
|
|
10
10
|
$1`).replace(this.rules.other.blockquoteSetextReplace2,"");q=q?`${q}
|
|
11
|
-
${
|
|
12
|
-
${
|
|
13
|
-
`+
|
|
14
|
-
`),
|
|
15
|
-
`+
|
|
16
|
-
`),
|
|
17
|
-
`);continue}}return{type:"blockquote",raw:q,tokens:
|
|
18
|
-
`,1)[0],
|
|
19
|
-
`,1)[0],
|
|
20
|
-
`,$=$.substring(
|
|
21
|
-
`,1)[0],
|
|
22
|
-
`+
|
|
23
|
-
`+F
|
|
24
|
-
`,$=$.substring(
|
|
25
|
-
`):[],
|
|
26
|
-
`?
|
|
27
|
-
`),this.blockTokens(
|
|
28
|
-
`:
|
|
11
|
+
${_}`:_,W=W?`${W}
|
|
12
|
+
${M}`:M;let N=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(M,Y,!0),this.lexer.state.top=N,J.length===0)break;let O=Y.at(-1);if(O?.type==="code")break;if(O?.type==="blockquote"){let F=O,U=F.raw+`
|
|
13
|
+
`+J.join(`
|
|
14
|
+
`),w=this.blockquote(U);Y[Y.length-1]=w,q=q.substring(0,q.length-F.raw.length)+w.raw,W=W.substring(0,W.length-F.text.length)+w.text;break}else if(O?.type==="list"){let F=O,U=F.raw+`
|
|
15
|
+
`+J.join(`
|
|
16
|
+
`),w=this.list(U);Y[Y.length-1]=w,q=q.substring(0,q.length-O.raw.length)+w.raw,W=W.substring(0,W.length-F.raw.length)+w.raw,J=U.substring(Y.at(-1).raw.length).split(`
|
|
17
|
+
`);continue}}return{type:"blockquote",raw:q,tokens:Y,text:W}}}list($){let Q=this.rules.block.list.exec($);if(Q){let J=Q[1].trim(),q=J.length>1,W={type:"list",raw:"",ordered:q,start:q?+J.slice(0,-1):"",loose:!1,items:[]};J=q?`\\d{1,9}\\${J.slice(-1)}`:`\\${J}`,this.options.pedantic&&(J=q?J:"[*+-]");let Y=this.rules.other.listItemRegex(J),X=!1;for(;$;){let H=!1,_="",M="";if(!(Q=Y.exec($))||this.rules.block.hr.test($))break;_=Q[0],$=$.substring(_.length);let N=z3(Q[2].split(`
|
|
18
|
+
`,1)[0],Q[1].length),O=$.split(`
|
|
19
|
+
`,1)[0],F=!N.trim(),U=0;if(this.options.pedantic?(U=2,M=N.trimStart()):F?U=Q[1].length+1:(U=N.search(this.rules.other.nonSpaceChar),U=U>4?1:U,M=N.slice(U),U+=Q[1].length),F&&this.rules.other.blankLine.test(O)&&(_+=O+`
|
|
20
|
+
`,$=$.substring(O.length+1),H=!0),!H){let w=this.rules.other.nextBulletRegex(U),S=this.rules.other.hrRegex(U),P=this.rules.other.fencesBeginRegex(U),I=this.rules.other.headingBeginRegex(U),T=this.rules.other.htmlBeginRegex(U),D=this.rules.other.blockquoteBeginRegex(U);for(;$;){let j=$.split(`
|
|
21
|
+
`,1)[0],Z;if(O=j,this.options.pedantic?(O=O.replace(this.rules.other.listReplaceNesting," "),Z=O):Z=O.replace(this.rules.other.tabCharGlobal," "),P.test(O)||I.test(O)||T.test(O)||D.test(O)||w.test(O)||S.test(O))break;if(Z.search(this.rules.other.nonSpaceChar)>=U||!O.trim())M+=`
|
|
22
|
+
`+Z.slice(U);else{if(F||N.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||P.test(N)||I.test(N)||S.test(N))break;M+=`
|
|
23
|
+
`+O}F=!O.trim(),_+=j+`
|
|
24
|
+
`,$=$.substring(j.length+1),N=Z.slice(U)}}W.loose||(X?W.loose=!0:this.rules.other.doubleBlankLine.test(_)&&(X=!0)),W.items.push({type:"list_item",raw:_,task:!!this.options.gfm&&this.rules.other.listIsTask.test(M),loose:!1,text:M,tokens:[]}),W.raw+=_}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 M=this.lexer.inlineQueue.length-1;M>=0;M--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[M].src)){this.lexer.inlineQueue[M].src=this.lexer.inlineQueue[M].src.replace(this.rules.other.listReplaceTask,"");break}}let _=this.rules.other.listTaskCheckbox.exec(H.raw);if(_){let M={type:"checkbox",raw:_[0]+" ",checked:_[0]!=="[ ]"};H.checked=M.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=M.raw+H.tokens[0].raw,H.tokens[0].text=M.raw+H.tokens[0].text,H.tokens[0].tokens.unshift(M)):H.tokens.unshift({type:"paragraph",raw:M.raw,text:M.raw,tokens:[M]}):H.tokens.unshift(M)}}if(!W.loose){let _=H.tokens.filter((N)=>N.type==="space"),M=_.length>0&&_.some((N)=>this.rules.other.anyLine.test(N.raw));W.loose=M}}if(W.loose)for(let H of W.items){H.loose=!0;for(let _ of H.tokens)_.type==="text"&&(_.type="paragraph")}return W}}html($){let Q=this.rules.block.html.exec($);if(Q)return{type:"html",block:!0,raw:Q[0],pre:Q[1]==="pre"||Q[1]==="script"||Q[1]==="style",text:Q[0]}}def($){let Q=this.rules.block.def.exec($);if(Q){let J=Q[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),q=Q[2]?Q[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",W=Q[3]?Q[3].substring(1,Q[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):Q[3];return{type:"def",tag:J,raw:Q[0],href:q,title:W}}}table($){let Q=this.rules.block.table.exec($);if(!Q||!this.rules.other.tableDelimiter.test(Q[2]))return;let J=X2(Q[1]),q=Q[2].replace(this.rules.other.tableAlignChars,"").split("|"),W=Q[3]?.trim()?Q[3].replace(this.rules.other.tableRowBlankLine,"").split(`
|
|
25
|
+
`):[],Y={type:"table",raw:Q[0],header:[],align:[],rows:[]};if(J.length===q.length){for(let X of q)this.rules.other.tableAlignRight.test(X)?Y.align.push("right"):this.rules.other.tableAlignCenter.test(X)?Y.align.push("center"):this.rules.other.tableAlignLeft.test(X)?Y.align.push("left"):Y.align.push(null);for(let X=0;X<J.length;X++)Y.header.push({text:J[X],tokens:this.lexer.inline(J[X]),header:!0,align:Y.align[X]});for(let X of W)Y.rows.push(X2(X,Y.header.length).map((G,H)=>({text:G,tokens:this.lexer.inline(G),header:!1,align:Y.align[H]})));return Y}}lheading($){let Q=this.rules.block.lheading.exec($);if(Q){let J=Q[1].trim();return{type:"heading",raw:Q[0],depth:Q[2].charAt(0)==="="?1:2,text:J,tokens:this.lexer.inline(J)}}}paragraph($){let Q=this.rules.block.paragraph.exec($);if(Q){let J=Q[1].charAt(Q[1].length-1)===`
|
|
26
|
+
`?Q[1].slice(0,-1):Q[1];return{type:"paragraph",raw:Q[0],text:J,tokens:this.lexer.inline(J)}}}text($){let Q=this.rules.block.text.exec($);if(Q)return{type:"text",raw:Q[0],text:Q[0],tokens:this.lexer.inline(Q[0])}}escape($){let Q=this.rules.inline.escape.exec($);if(Q)return{type:"escape",raw:Q[0],text:Q[1]}}tag($){let Q=this.rules.inline.tag.exec($);if(Q)return!this.lexer.state.inLink&&this.rules.other.startATag.test(Q[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(Q[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(Q[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(Q[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:Q[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:Q[0]}}link($){let Q=this.rules.inline.link.exec($);if(Q){let J=Q[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(J)){if(!this.rules.other.endAngleBracket.test(J))return;let Y=z0(J.slice(0,-1),"\\");if((J.length-Y.length)%2===0)return}else{let Y=S3(Q[2],"()");if(Y===-2)return;if(Y>-1){let X=(Q[0].indexOf("!")===0?5:4)+Q[1].length+Y;Q[2]=Q[2].substring(0,Y),Q[0]=Q[0].substring(0,X).trim(),Q[3]=""}}let q=Q[2],W="";if(this.options.pedantic){let Y=this.rules.other.pedanticHrefTitle.exec(q);Y&&(q=Y[1],W=Y[3])}else W=Q[3]?Q[3].slice(1,-1):"";return q=q.trim(),this.rules.other.startAngleBracket.test(q)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(J)?q=q.slice(1):q=q.slice(1,-1)),H2(Q,{href:q&&q.replace(this.rules.inline.anyPunctuation,"$1"),title:W&&W.replace(this.rules.inline.anyPunctuation,"$1")},Q[0],this.lexer,this.rules)}}reflink($,Q){let J;if((J=this.rules.inline.reflink.exec($))||(J=this.rules.inline.nolink.exec($))){let q=(J[2]||J[1]).replace(this.rules.other.multipleSpaceGlobal," "),W=Q[q.toLowerCase()];if(!W){let Y=J[0].charAt(0);return{type:"text",raw:Y,text:Y}}return H2(J,W,J[0],this.lexer,this.rules)}}emStrong($,Q,J=""){let q=this.rules.inline.emStrongLDelim.exec($);if(!q||!q[1]&&!q[2]&&!q[3]&&!q[4]||q[4]&&J.match(this.rules.other.unicodeAlphaNumeric))return;if(!(q[1]||q[3])||!J||this.rules.inline.punctuation.exec(J)){let W=[...q[0]].length-1,Y,X,G=W,H=0,_=q[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(_.lastIndex=0,Q=Q.slice(-1*$.length+W);(q=_.exec(Q))!==null;){if(Y=q[1]||q[2]||q[3]||q[4]||q[5]||q[6],!Y)continue;if(X=[...Y].length,q[3]||q[4]){G+=X;continue}else if((q[5]||q[6])&&W%3&&!((W+X)%3)){H+=X;continue}if(G-=X,G>0)continue;X=Math.min(X,X+G+H);let M=[...q[0]][0].length,N=$.slice(0,W+q.index+M+X);if(Math.min(W,X)%2){let F=N.slice(1,-1);return{type:"em",raw:N,text:F,tokens:this.lexer.inlineTokens(F)}}let O=N.slice(2,-2);return{type:"strong",raw:N,text:O,tokens:this.lexer.inlineTokens(O)}}}}codespan($){let Q=this.rules.inline.code.exec($);if(Q){let J=Q[2].replace(this.rules.other.newLineCharGlobal," "),q=this.rules.other.nonSpaceChar.test(J),W=this.rules.other.startingSpaceChar.test(J)&&this.rules.other.endingSpaceChar.test(J);return q&&W&&(J=J.substring(1,J.length-1)),{type:"codespan",raw:Q[0],text:J}}}br($){let Q=this.rules.inline.br.exec($);if(Q)return{type:"br",raw:Q[0]}}del($,Q,J=""){let q=this.rules.inline.delLDelim.exec($);if(!q)return;if(!q[1]||!J||this.rules.inline.punctuation.exec(J)){let W=[...q[0]].length-1,Y,X,G=W,H=this.rules.inline.delRDelim;for(H.lastIndex=0,Q=Q.slice(-1*$.length+W);(q=H.exec(Q))!==null;){if(Y=q[1]||q[2]||q[3]||q[4]||q[5]||q[6],!Y||(X=[...Y].length,X!==W))continue;if(q[3]||q[4]){G+=X;continue}if(G-=X,G>0)continue;X=Math.min(X,X+G);let _=[...q[0]][0].length,M=$.slice(0,W+q.index+_+X),N=M.slice(W,-W);return{type:"del",raw:M,text:N,tokens:this.lexer.inlineTokens(N)}}}}autolink($){let Q=this.rules.inline.autolink.exec($);if(Q){let J,q;return Q[2]==="@"?(J=Q[1],q="mailto:"+J):(J=Q[1],q=J),{type:"link",raw:Q[0],text:J,href:q,tokens:[{type:"text",raw:J,text:J}]}}}url($){let Q;if(Q=this.rules.inline.url.exec($)){let J,q;if(Q[2]==="@")J=Q[0],q="mailto:"+J;else{let W;do W=Q[0],Q[0]=this.rules.inline._backpedal.exec(Q[0])?.[0]??"";while(W!==Q[0]);J=Q[0],Q[1]==="www."?q="http://"+Q[0]:q=Q[0]}return{type:"link",raw:Q[0],text:J,href:q,tokens:[{type:"text",raw:J,text:J}]}}}inlineText($){let Q=this.rules.inline.text.exec($);if(Q){let J=this.lexer.state.inRawBlock;return{type:"text",raw:Q[0],text:Q[0],escaped:J}}}},G$=class ${tokens;options;state;inlineQueue;tokenizer;constructor(Q){this.tokens=[],this.tokens.links=Object.create(null),this.options=Q||l$,this.options.tokenizer=this.options.tokenizer||new u0,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 J={other:Q$,block:h0.normal,inline:S0.normal};this.options.pedantic?(J.block=h0.pedantic,J.inline=S0.pedantic):this.options.gfm&&(J.block=h0.gfm,this.options.breaks?J.inline=S0.breaks:J.inline=S0.gfm),this.tokenizer.rules=J}static get rules(){return{block:h0,inline:S0}}static lex(Q,J){return new $(J).lex(Q)}static lexInline(Q,J){return new $(J).inlineTokens(Q)}lex(Q){Q=Q.replace(Q$.carriageReturn,`
|
|
27
|
+
`),this.blockTokens(Q,this.tokens);for(let J=0;J<this.inlineQueue.length;J++){let q=this.inlineQueue[J];this.inlineTokens(q.src,q.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(Q,J=[],q=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(Q=Q.replace(Q$.tabCharGlobal," ").replace(Q$.spaceLine,""));Q;){let W;if(this.options.extensions?.block?.some((X)=>(W=X.call({lexer:this},Q,J))?(Q=Q.substring(W.raw.length),J.push(W),!0):!1))continue;if(W=this.tokenizer.space(Q)){Q=Q.substring(W.raw.length);let X=J.at(-1);W.raw.length===1&&X!==void 0?X.raw+=`
|
|
28
|
+
`:J.push(W);continue}if(W=this.tokenizer.code(Q)){Q=Q.substring(W.raw.length);let X=J.at(-1);X?.type==="paragraph"||X?.type==="text"?(X.raw+=(X.raw.endsWith(`
|
|
29
29
|
`)?"":`
|
|
30
|
-
`)+W.raw,
|
|
31
|
-
`+W.text,this.inlineQueue.at(-1).src=
|
|
30
|
+
`)+W.raw,X.text+=`
|
|
31
|
+
`+W.text,this.inlineQueue.at(-1).src=X.text):J.push(W);continue}if(W=this.tokenizer.fences(Q)){Q=Q.substring(W.raw.length),J.push(W);continue}if(W=this.tokenizer.heading(Q)){Q=Q.substring(W.raw.length),J.push(W);continue}if(W=this.tokenizer.hr(Q)){Q=Q.substring(W.raw.length),J.push(W);continue}if(W=this.tokenizer.blockquote(Q)){Q=Q.substring(W.raw.length),J.push(W);continue}if(W=this.tokenizer.list(Q)){Q=Q.substring(W.raw.length),J.push(W);continue}if(W=this.tokenizer.html(Q)){Q=Q.substring(W.raw.length),J.push(W);continue}if(W=this.tokenizer.def(Q)){Q=Q.substring(W.raw.length);let X=J.at(-1);X?.type==="paragraph"||X?.type==="text"?(X.raw+=(X.raw.endsWith(`
|
|
32
32
|
`)?"":`
|
|
33
|
-
`)+W.raw,
|
|
34
|
-
`+W.raw,this.inlineQueue.at(-1).src=
|
|
33
|
+
`)+W.raw,X.text+=`
|
|
34
|
+
`+W.raw,this.inlineQueue.at(-1).src=X.text):this.tokens.links[W.tag]||(this.tokens.links[W.tag]={href:W.href,title:W.title},J.push(W));continue}if(W=this.tokenizer.table(Q)){Q=Q.substring(W.raw.length),J.push(W);continue}if(W=this.tokenizer.lheading(Q)){Q=Q.substring(W.raw.length),J.push(W);continue}let Y=Q;if(this.options.extensions?.startBlock){let X=1/0,G=Q.slice(1),H;this.options.extensions.startBlock.forEach((_)=>{H=_.call({lexer:this},G),typeof H=="number"&&H>=0&&(X=Math.min(X,H))}),X<1/0&&X>=0&&(Y=Q.substring(0,X+1))}if(this.state.top&&(W=this.tokenizer.paragraph(Y))){let X=J.at(-1);q&&X?.type==="paragraph"?(X.raw+=(X.raw.endsWith(`
|
|
35
35
|
`)?"":`
|
|
36
|
-
`)+W.raw,
|
|
37
|
-
`+W.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=
|
|
36
|
+
`)+W.raw,X.text+=`
|
|
37
|
+
`+W.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=X.text):J.push(W),q=Y.length!==Q.length,Q=Q.substring(W.raw.length);continue}if(W=this.tokenizer.text(Q)){Q=Q.substring(W.raw.length);let X=J.at(-1);X?.type==="text"?(X.raw+=(X.raw.endsWith(`
|
|
38
38
|
`)?"":`
|
|
39
|
-
`)+W.raw,
|
|
40
|
-
`+W.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=
|
|
41
|
-
`;return q?'<pre><code class="language-'+
|
|
42
|
-
`:"<pre><code>"+(
|
|
39
|
+
`)+W.raw,X.text+=`
|
|
40
|
+
`+W.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=X.text):J.push(W);continue}if(Q){let X="Infinite loop on byte: "+Q.charCodeAt(0);if(this.options.silent){console.error(X);break}else throw Error(X)}}return this.state.top=!0,J}inline(Q,J=[]){return this.inlineQueue.push({src:Q,tokens:J}),J}inlineTokens(Q,J=[]){this.tokenizer.lexer=this;let q=Q,W=null;if(this.tokens.links){let H=Object.keys(this.tokens.links);if(H.length>0)for(;(W=this.tokenizer.rules.inline.reflinkSearch.exec(q))!==null;)H.includes(W[0].slice(W[0].lastIndexOf("[")+1,-1))&&(q=q.slice(0,W.index)+"["+"a".repeat(W[0].length-2)+"]"+q.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(W=this.tokenizer.rules.inline.anyPunctuation.exec(q))!==null;)q=q.slice(0,W.index)+"++"+q.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let Y;for(;(W=this.tokenizer.rules.inline.blockSkip.exec(q))!==null;)Y=W[2]?W[2].length:0,q=q.slice(0,W.index+Y)+"["+"a".repeat(W[0].length-Y-2)+"]"+q.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);q=this.options.hooks?.emStrongMask?.call({lexer:this},q)??q;let X=!1,G="";for(;Q;){X||(G=""),X=!1;let H;if(this.options.extensions?.inline?.some((M)=>(H=M.call({lexer:this},Q,J))?(Q=Q.substring(H.raw.length),J.push(H),!0):!1))continue;if(H=this.tokenizer.escape(Q)){Q=Q.substring(H.raw.length),J.push(H);continue}if(H=this.tokenizer.tag(Q)){Q=Q.substring(H.raw.length),J.push(H);continue}if(H=this.tokenizer.link(Q)){Q=Q.substring(H.raw.length),J.push(H);continue}if(H=this.tokenizer.reflink(Q,this.tokens.links)){Q=Q.substring(H.raw.length);let M=J.at(-1);H.type==="text"&&M?.type==="text"?(M.raw+=H.raw,M.text+=H.text):J.push(H);continue}if(H=this.tokenizer.emStrong(Q,q,G)){Q=Q.substring(H.raw.length),J.push(H);continue}if(H=this.tokenizer.codespan(Q)){Q=Q.substring(H.raw.length),J.push(H);continue}if(H=this.tokenizer.br(Q)){Q=Q.substring(H.raw.length),J.push(H);continue}if(H=this.tokenizer.del(Q,q,G)){Q=Q.substring(H.raw.length),J.push(H);continue}if(H=this.tokenizer.autolink(Q)){Q=Q.substring(H.raw.length),J.push(H);continue}if(!this.state.inLink&&(H=this.tokenizer.url(Q))){Q=Q.substring(H.raw.length),J.push(H);continue}let _=Q;if(this.options.extensions?.startInline){let M=1/0,N=Q.slice(1),O;this.options.extensions.startInline.forEach((F)=>{O=F.call({lexer:this},N),typeof O=="number"&&O>=0&&(M=Math.min(M,O))}),M<1/0&&M>=0&&(_=Q.substring(0,M+1))}if(H=this.tokenizer.inlineText(_)){Q=Q.substring(H.raw.length),H.raw.slice(-1)!=="_"&&(G=H.raw.slice(-1)),X=!0;let M=J.at(-1);M?.type==="text"?(M.raw+=H.raw,M.text+=H.text):J.push(H);continue}if(Q){let M="Infinite loop on byte: "+Q.charCodeAt(0);if(this.options.silent){console.error(M);break}else throw Error(M)}}return J}},p0=class{options;parser;constructor($){this.options=$||l$}space($){return""}code({text:$,lang:Q,escaped:J}){let q=(Q||"").match(Q$.notSpaceStart)?.[0],W=$.replace(Q$.endingNewline,"")+`
|
|
41
|
+
`;return q?'<pre><code class="language-'+F$(q)+'">'+(J?W:F$(W,!0))+`</code></pre>
|
|
42
|
+
`:"<pre><code>"+(J?W:F$(W,!0))+`</code></pre>
|
|
43
43
|
`}blockquote({tokens:$}){return`<blockquote>
|
|
44
44
|
${this.parser.parse($)}</blockquote>
|
|
45
|
-
`}html({text:$}){return $}def($){return""}heading({tokens:$,depth:
|
|
45
|
+
`}html({text:$}){return $}def($){return""}heading({tokens:$,depth:Q}){return`<h${Q}>${this.parser.parseInline($)}</h${Q}>
|
|
46
46
|
`}hr($){return`<hr>
|
|
47
|
-
`}list($){let{ordered:
|
|
47
|
+
`}list($){let{ordered:Q,start:J}=$,q="";for(let X=0;X<$.items.length;X++){let G=$.items[X];q+=this.listitem(G)}let W=Q?"ol":"ul",Y=Q&&J!==1?' start="'+J+'"':"";return"<"+W+Y+`>
|
|
48
48
|
`+q+"</"+W+`>
|
|
49
49
|
`}listitem($){return`<li>${this.parser.parse($.tokens)}</li>
|
|
50
50
|
`}checkbox({checked:$}){return"<input "+($?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:$}){return`<p>${this.parser.parseInline($)}</p>
|
|
51
|
-
`}table($){let
|
|
51
|
+
`}table($){let Q="",J="";for(let W=0;W<$.header.length;W++)J+=this.tablecell($.header[W]);Q+=this.tablerow({text:J});let q="";for(let W=0;W<$.rows.length;W++){let Y=$.rows[W];J="";for(let X=0;X<Y.length;X++)J+=this.tablecell(Y[X]);q+=this.tablerow({text:J})}return q&&(q=`<tbody>${q}</tbody>`),`<table>
|
|
52
52
|
<thead>
|
|
53
|
-
`+
|
|
53
|
+
`+Q+`</thead>
|
|
54
54
|
`+q+`</table>
|
|
55
55
|
`}tablerow({text:$}){return`<tr>
|
|
56
56
|
${$}</tr>
|
|
57
|
-
`}tablecell($){let
|
|
58
|
-
`}strong({tokens:$}){return`<strong>${this.parser.parseInline($)}</strong>`}em({tokens:$}){return`<em>${this.parser.parseInline($)}</em>`}codespan({text:$}){return`<code>${
|
|
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=
|
|
61
|
-
`),W=
|
|
62
|
-
`).slice(
|
|
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
|
-
|
|
65
|
-
|
|
57
|
+
`}tablecell($){let Q=this.parser.parseInline($.tokens),J=$.header?"th":"td";return($.align?`<${J} align="${$.align}">`:`<${J}>`)+Q+`</${J}>
|
|
58
|
+
`}strong({tokens:$}){return`<strong>${this.parser.parseInline($)}</strong>`}em({tokens:$}){return`<em>${this.parser.parseInline($)}</em>`}codespan({text:$}){return`<code>${F$($,!0)}</code>`}br($){return"<br>"}del({tokens:$}){return`<del>${this.parser.parseInline($)}</del>`}link({href:$,title:Q,tokens:J}){let q=this.parser.parseInline(J),W=Y2($);if(W===null)return q;$=W;let Y='<a href="'+$+'"';return Q&&(Y+=' title="'+F$(Q)+'"'),Y+=">"+q+"</a>",Y}image({href:$,title:Q,text:J,tokens:q}){q&&(J=this.parser.parseInline(q,this.parser.textRenderer));let W=Y2($);if(W===null)return F$(J);$=W;let Y=`<img src="${$}" alt="${F$(J)}"`;return Q&&(Y+=` title="${F$(Q)}"`),Y+=">",Y}text($){return"tokens"in $&&$.tokens?this.parser.parseInline($.tokens):("escaped"in $)&&$.escaped?$.text:F$($.text)}},j1=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 $}},B$=class ${options;renderer;textRenderer;constructor(Q){this.options=Q||l$,this.options.renderer=this.options.renderer||new p0,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new j1}static parse(Q,J){return new $(J).parse(Q)}static parseInline(Q,J){return new $(J).parseInline(Q)}parse(Q){this.renderer.parser=this;let J="";for(let q=0;q<Q.length;q++){let W=Q[q];if(this.options.extensions?.renderers?.[W.type]){let X=W,G=this.options.extensions.renderers[X.type].call({parser:this},X);if(G!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(X.type)){J+=G||"";continue}}let Y=W;switch(Y.type){case"space":{J+=this.renderer.space(Y);break}case"hr":{J+=this.renderer.hr(Y);break}case"heading":{J+=this.renderer.heading(Y);break}case"code":{J+=this.renderer.code(Y);break}case"table":{J+=this.renderer.table(Y);break}case"blockquote":{J+=this.renderer.blockquote(Y);break}case"list":{J+=this.renderer.list(Y);break}case"checkbox":{J+=this.renderer.checkbox(Y);break}case"html":{J+=this.renderer.html(Y);break}case"def":{J+=this.renderer.def(Y);break}case"paragraph":{J+=this.renderer.paragraph(Y);break}case"text":{J+=this.renderer.text(Y);break}default:{let X='Token with "'+Y.type+'" type was not found.';if(this.options.silent)return console.error(X),"";throw Error(X)}}}return J}parseInline(Q,J=this.renderer){this.renderer.parser=this;let q="";for(let W=0;W<Q.length;W++){let Y=Q[W];if(this.options.extensions?.renderers?.[Y.type]){let G=this.options.extensions.renderers[Y.type].call({parser:this},Y);if(G!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(Y.type)){q+=G||"";continue}}let X=Y;switch(X.type){case"escape":{q+=J.text(X);break}case"html":{q+=J.html(X);break}case"link":{q+=J.link(X);break}case"image":{q+=J.image(X);break}case"checkbox":{q+=J.checkbox(X);break}case"strong":{q+=J.strong(X);break}case"em":{q+=J.em(X);break}case"codespan":{q+=J.codespan(X);break}case"br":{q+=J.br(X);break}case"del":{q+=J.del(X);break}case"text":{q+=J.text(X);break}default:{let G='Token with "'+X.type+'" type was not found.';if(this.options.silent)return console.error(G),"";throw Error(G)}}}return q}},R0=class{options;block;constructor($){this.options=$||l$}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 $?G$.lex:G$.lexInline}provideParser($=this.block){return $?B$.parse:B$.parseInline}},j3=class{defaults=w1();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=B$;Renderer=p0;TextRenderer=j1;Lexer=G$;Tokenizer=u0;Hooks=R0;constructor(...$){this.use(...$)}walkTokens($,Q){let J=[];for(let q of $)switch(J=J.concat(Q.call(this,q)),q.type){case"table":{let W=q;for(let Y of W.header)J=J.concat(this.walkTokens(Y.tokens,Q));for(let Y of W.rows)for(let X of Y)J=J.concat(this.walkTokens(X.tokens,Q));break}case"list":{let W=q;J=J.concat(this.walkTokens(W.items,Q));break}default:{let W=q;this.defaults.extensions?.childTokens?.[W.type]?this.defaults.extensions.childTokens[W.type].forEach((Y)=>{let X=W[Y].flat(1/0);J=J.concat(this.walkTokens(X,Q))}):W.tokens&&(J=J.concat(this.walkTokens(W.tokens,Q)))}}return J}use(...$){let Q=this.defaults.extensions||{renderers:{},childTokens:{}};return $.forEach((J)=>{let q={...J};if(q.async=this.defaults.async||q.async||!1,J.extensions&&(J.extensions.forEach((W)=>{if(!W.name)throw Error("extension name required");if("renderer"in W){let Y=Q.renderers[W.name];Y?Q.renderers[W.name]=function(...X){let G=W.renderer.apply(this,X);return G===!1&&(G=Y.apply(this,X)),G}:Q.renderers[W.name]=W.renderer}if("tokenizer"in W){if(!W.level||W.level!=="block"&&W.level!=="inline")throw Error("extension level must be 'block' or 'inline'");let Y=Q[W.level];Y?Y.unshift(W.tokenizer):Q[W.level]=[W.tokenizer],W.start&&(W.level==="block"?Q.startBlock?Q.startBlock.push(W.start):Q.startBlock=[W.start]:W.level==="inline"&&(Q.startInline?Q.startInline.push(W.start):Q.startInline=[W.start]))}"childTokens"in W&&W.childTokens&&(Q.childTokens[W.name]=W.childTokens)}),q.extensions=Q),J.renderer){let W=this.defaults.renderer||new p0(this.defaults);for(let Y in J.renderer){if(!(Y in W))throw Error(`renderer '${Y}' does not exist`);if(["options","parser"].includes(Y))continue;let X=Y,G=J.renderer[X],H=W[X];W[X]=(..._)=>{let M=G.apply(W,_);return M===!1&&(M=H.apply(W,_)),M||""}}q.renderer=W}if(J.tokenizer){let W=this.defaults.tokenizer||new u0(this.defaults);for(let Y in J.tokenizer){if(!(Y in W))throw Error(`tokenizer '${Y}' does not exist`);if(["options","rules","lexer"].includes(Y))continue;let X=Y,G=J.tokenizer[X],H=W[X];W[X]=(..._)=>{let M=G.apply(W,_);return M===!1&&(M=H.apply(W,_)),M}}q.tokenizer=W}if(J.hooks){let W=this.defaults.hooks||new R0;for(let Y in J.hooks){if(!(Y in W))throw Error(`hook '${Y}' does not exist`);if(["options","block"].includes(Y))continue;let X=Y,G=J.hooks[X],H=W[X];R0.passThroughHooks.has(Y)?W[X]=(_)=>{if(this.defaults.async&&R0.passThroughHooksRespectAsync.has(Y))return(async()=>{let N=await G.call(W,_);return H.call(W,N)})();let M=G.call(W,_);return H.call(W,M)}:W[X]=(..._)=>{if(this.defaults.async)return(async()=>{let N=await G.apply(W,_);return N===!1&&(N=await H.apply(W,_)),N})();let M=G.apply(W,_);return M===!1&&(M=H.apply(W,_)),M}}q.hooks=W}if(J.walkTokens){let W=this.defaults.walkTokens,Y=J.walkTokens;q.walkTokens=function(X){let G=[];return G.push(Y.call(this,X)),W&&(G=G.concat(W.call(this,X))),G}}this.defaults={...this.defaults,...q}}),this}setOptions($){return this.defaults={...this.defaults,...$},this}lexer($,Q){return G$.lex($,Q??this.defaults)}parser($,Q){return B$.parse($,Q??this.defaults)}parseMarkdown($){return(Q,J)=>{let q={...J},W={...this.defaults,...q},Y=this.onError(!!W.silent,!!W.async);if(this.defaults.async===!0&&q.async===!1)return Y(Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof Q>"u"||Q===null)return Y(Error("marked(): input parameter is undefined or null"));if(typeof Q!="string")return Y(Error("marked(): input parameter is of type "+Object.prototype.toString.call(Q)+", string expected"));if(W.hooks&&(W.hooks.options=W,W.hooks.block=$),W.async)return(async()=>{let X=W.hooks?await W.hooks.preprocess(Q):Q,G=await(W.hooks?await W.hooks.provideLexer($):$?G$.lex:G$.lexInline)(X,W),H=W.hooks?await W.hooks.processAllTokens(G):G;W.walkTokens&&await Promise.all(this.walkTokens(H,W.walkTokens));let _=await(W.hooks?await W.hooks.provideParser($):$?B$.parse:B$.parseInline)(H,W);return W.hooks?await W.hooks.postprocess(_):_})().catch(Y);try{W.hooks&&(Q=W.hooks.preprocess(Q));let X=(W.hooks?W.hooks.provideLexer($):$?G$.lex:G$.lexInline)(Q,W);W.hooks&&(X=W.hooks.processAllTokens(X)),W.walkTokens&&this.walkTokens(X,W.walkTokens);let G=(W.hooks?W.hooks.provideParser($):$?B$.parse:B$.parseInline)(X,W);return W.hooks&&(G=W.hooks.postprocess(G)),G}catch(X){return Y(X)}}}onError($,Q){return(J)=>{if(J.message+=`
|
|
59
|
+
Please report this to https://github.com/markedjs/marked.`,$){let q="<p>An error occurred:</p><pre>"+F$(J.message+"",!0)+"</pre>";return Q?Promise.resolve(q):q}if(Q)return Promise.reject(J);throw J}}},c$=new j3;function g($,Q){return c$.parse($,Q)}g.options=g.setOptions=function($){return c$.setOptions($),g.defaults=c$.defaults,G2(g.defaults),g};g.getDefaults=w1;g.defaults=l$;g.use=function(...$){return c$.use(...$),g.defaults=c$.defaults,G2(g.defaults),g};g.walkTokens=function($,Q){return c$.walkTokens($,Q)};g.parseInline=c$.parseInline;g.Parser=B$;g.parser=B$.parse;g.Renderer=p0;g.TextRenderer=j1;g.Lexer=G$;g.lexer=G$.lex;g.Tokenizer=u0;g.Hooks=R0;g.parse=g;var{options:x8,setOptions:u8,use:p8,walkTokens:c8,parseInline:l8}=g;var d8=B$.parse,i8=G$.lex;import F2 from"react";import{jsxDEV as f1}from"react/jsx-dev-runtime";g.setOptions({gfm:!0,breaks:!1});var f3=new Set(["a","abbr","b","br","code","del","em","i","kbd","mark","q","s","small","span","strong","sub","sup","time","u"]),P3=new Set(["Priority"]);function V3($){if(typeof $==="string"||typeof $==="number")return!0;if(!F2.isValidElement($))return!1;if(typeof $!=="object"||$===null||!("type"in $))return!1;let Q=$.type;if(typeof Q==="string")return f3.has(Q);if(typeof Q==="function"){let J="displayName"in Q&&typeof Q.displayName==="string"?Q.displayName:Q.name;return J?P3.has(J):!1}return!1}function b3($,Q){let J=$.trim();if(!J)return null;let q=g.parse(J,{async:!1});return f1("div",{className:"prose-canvas","data-md":"markdown","data-md-source":J,dangerouslySetInnerHTML:{__html:q}},Q,!1,void 0,this)}function C3($,Q){return f1("div",{className:"prose-canvas",children:$.map((J,q)=>{if(typeof J==="string"||typeof J==="number"){let W=g.parseInline(String(J),{async:!1});return f1("span",{dangerouslySetInnerHTML:{__html:W}},q,!1,void 0,this)}return J})},Q,!1,void 0,this)}function k$($){let Q=F2.Children.toArray($);if(Q.length===0)return null;let J=[],q=[],W=0,Y=()=>{if(q.length===0)return;if(q.some((G)=>typeof G!=="string"&&typeof G!=="number"))J.push(C3(q,`md-${W++}`));else{let G=b3(q.join(""),`md-${W++}`);if(G)J.push(G)}q=[]};for(let X of Q)if(V3(X))q.push(X);else Y(),J.push(X);return Y(),J}import{jsxDEV as P1}from"react/jsx-dev-runtime";var v3={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 k3({type:$="info",children:Q}){let J=v3[$];return P1("div",{className:`${J.bg} relative rounded-lg px-5 py-4 mt-3 flex gap-3 items-start`,"data-md":"callout","data-md-type":$,children:[P1("span",{"aria-hidden":"true",className:`${J.iconColor} opacity-70 text-base leading-relaxed flex-shrink-0 mt-px`,children:J.icon},void 0,!1,void 0,this),P1("div",{className:"text-body text-text-secondary leading-relaxed",children:k$(Q)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as t$}from"react/jsx-dev-runtime";function D3({items:$}){return t$("ul",{className:"space-y-1 mt-3","data-md":"checklist",children:$.map((Q,J)=>t$("li",{"data-md":"checklist-item","data-md-label":Q.label,className:"relative flex items-start gap-2.5 py-1",children:[t$("span",{className:`w-4 h-4 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5 transition-all ${Q.checked?"bg-accent-green":"border-[1.5px] border-border-hover"}`,children:Q.checked&&t$("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:t$("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),t$("span",{className:`text-body font-body ${Q.checked?"text-text-tertiary line-through decoration-border-hover":"text-text-secondary"}`,children:Q.label},void 0,!1,void 0,this)]},J,!0,void 0,this))},void 0,!1,void 0,this)}import{useAnnotations as n2,useResponseRegistration as a2}from"#canvas/runtime";import{useEffect as s2,useMemo as t2,useRef as e2,useState as $4}from"react";import{AnnotationCtx as iJ,AnnotationHostContext as rJ,SessionContext as oJ,useAnnotationHost as nJ,useAnnotations as aJ}from"@fabrika/annotations/runtime";function V1($,Q){let J=[],q=T3($);for(let W of q){let Y=document.createRange();if(Y.selectNodeContents(W),W===$.startContainer)Y.setStart(W,$.startOffset);if(W===$.endContainer)Y.setEnd(W,$.endOffset);let X=Y.toString();if(!X||!X.trim())continue;let G=document.createElement("mark");G.setAttribute("data-annotation-id",Q);try{Y.surroundContents(G)}catch{let H=Y.extractContents();G.appendChild(H),Y.insertNode(G)}J.push(G)}return J}function b1($){let Q=$.parentElement;if(Q?.classList.contains("select-none"))return!1;if(Q?.closest("[data-annotation-id]"))return!1;return!0}function T3($){let Q=[],J=$.commonAncestorContainer;if(J.nodeType===Node.TEXT_NODE)return Q.push(J),Q;let q=document.createTreeWalker(J,NodeFilter.SHOW_TEXT),W;while(W=q.nextNode()){if(!b1(W))continue;if($.intersectsNode(W))Q.push(W)}return Q}function C1($,Q){for(let J of Q){if($.querySelector(`[data-annotation-id="${J.id}"]`))continue;let q=J.snippet;if(!q)continue;let{fullText:W,textNodes:Y}=E3($),X=[],G=0;while(!0){let U=W.indexOf(q,G);if(U===-1)break;X.push(U),G=U+1}let[H]=X;if(H===void 0)continue;let _=H;if(X.length>1&&J.context){let U=-1;for(let w of X){let S=0;if(J.context.before){let P=W.slice(Math.max(0,w-80),w);if(P.includes(J.context.before))S+=2;else if(J.context.before.length>10&&P.includes(J.context.before.slice(-10)))S+=1}if(J.context.after){let P=W.slice(w+q.length,w+q.length+80);if(P.includes(J.context.after))S+=2;else if(J.context.after.length>10&&P.includes(J.context.after.slice(0,10)))S+=1}if(S>U)U=S,_=w}}let M=_,N=_+q.length,O=A2(Y,M),F=A2(Y,N);if(!O||!F)continue;try{let U=document.createRange();U.setStart(O.node,O.offset),U.setEnd(F.node,F.offset),V1(U,J.id)}catch{}}}function E3($){let Q=[],J="",q=document.createTreeWalker($,NodeFilter.SHOW_TEXT),W;while(W=q.nextNode()){if(!b1(W))continue;Q.push({node:W,start:J.length}),J+=W.textContent||""}return{fullText:J,textNodes:Q}}function A2($,Q){for(let J=$.length-1;J>=0;J--){let q=$[J];if(!q||q.start>Q)continue;let W=Q-q.start,Y=q.node.textContent?.length??0;if(W<=Y)return{node:q.node,offset:W}}return null}function f0($){return{kind:$.kind,owns:(Q)=>$.parse(Q)!==null,find:(Q,J)=>{let q=$.parse(Q);return q===null?null:$.find(q,J)},restore:(Q,J)=>{let q=$.parse(J.snippet);if(q===null)return;$.restore?.(q,Q,J)},describe:(Q)=>{let J=$.parse(Q);if(J===null||!$.describe)return null;return $.describe(J)}}}function S2($){let Q=document.createTreeWalker($,NodeFilter.SHOW_TEXT),J="";for(let q=Q.nextNode();q;q=Q.nextNode()){let W=q.parentElement?.closest("[aria-hidden='true']");if(W&&$.contains(W))continue;J+=q.textContent??""}return J.trim()}function d0($,Q,J){return{selector:$,snippet:(q)=>{let W=q.getAttribute(J);return W?`${Q} ${W}`:null}}}var v1=[d0("[data-md='item']","[Item]","data-md-label"),d0("[data-md='section']","[Section]","data-md-title"),d0("[data-md='checklist-item']","[Checklist]","data-md-label"),d0("[data-md='image']","[Image]","data-md-src"),{selector:"[data-md='callout']",snippet:($)=>{return`[Callout:${$.getAttribute("data-md-type")||"info"}] ${S2($).slice(0,60)||"Callout"}`}},{selector:"[data-md='note']",snippet:($)=>`[Note] ${S2($).slice(0,60)||"Note"}`},{selector:"[data-md='table'] tbody tr",snippet:($)=>{let Q=Array.from($.querySelectorAll("td")).map((J)=>J.textContent?.trim()).filter(Boolean);return Q.length?`[Row] ${Q.join(" | ")}`:null}}],I3=["[data-md='choice-option']","[data-md='multichoice-option']","[data-md='userinput']","[data-md='rangeinput']"],k1=v1.map(($)=>$.selector).join(", "),z2=[...v1.map(($)=>$.selector),...I3].join(", ");function D1($){for(let Q of v1)if($.matches(Q.selector))return Q.snippet($);return null}var T1={kind:"block",parse:($)=>$.startsWith("[")?{snippet:$}:null,format:($)=>$.snippet,find:($,Q)=>{for(let J of Q.querySelectorAll(k1)){if(!(J instanceof HTMLElement))continue;if(D1(J)===$.snippet)return J}return null}};var Z3=/^\[Region:(rect|ellipse)\] ([\s\S]+) @(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*)$/;function g3($){if($==="rect")return"rect";if($==="ellipse")return"ellipse";return null}function i0($){if($===void 0)return null;let Q=Number($);if(!Number.isInteger(Q)||Q<0||Q>1e4)return null;return Q}function R2($){return{left:`${$.x/100}%`,top:`${$.y/100}%`,width:`${$.w/100}%`,height:`${$.h/100}%`}}function r0($){return`${($/100).toFixed(1).replace(/\.0$/,"")}%`}function I1($){let Q=`${r0($.x)}-${r0($.x+$.w)}`,J=`${r0($.y)}-${r0($.y+$.h)}`;return`[Region] ${$.src} — ${$.shape} x ${Q}, y ${J} of the image`}function E1($,Q){for(let J of Q.querySelectorAll("[data-md='image']")){if(!(J instanceof HTMLElement))continue;if(J.getAttribute("data-md-src")!==$)continue;let q=J.querySelector("[data-annotation-image]");if(q instanceof HTMLElement)return q}return null}function j2($,Q){let J=R2(Q);$.style.left=J.left,$.style.top=J.top,$.style.width=J.width,$.style.height=J.height}function Z1($,Q,J){let q=document.createElement("div");return q.className="ann-region",q.setAttribute("data-annotation-id",J),q.setAttribute("data-annotation-region",Q),j2(q,$),q}var o0={kind:"region",parse:($)=>{let Q=Z3.exec($);if(!Q)return null;let J=g3(Q[1]),q=Q[2],W=i0(Q[3]),Y=i0(Q[4]),X=i0(Q[5]),G=i0(Q[6]);if(J===null||q===void 0)return null;if(W===null||Y===null||X===null||G===null)return null;if(X<1||G<1)return null;return{src:q,shape:J,x:W,y:Y,w:X,h:G}},format:($)=>`[Region:${$.shape}] ${$.src} @${$.x},${$.y},${$.w},${$.h}`,find:($,Q)=>E1($.src,Q),restore:($,Q,J)=>{if(Q.querySelector(`[data-annotation-id="${J.id}"]`))return;let q=E1($.src,Q);if(!q)return;q.appendChild(Z1($,$.shape,J.id))},describe:I1};var g1={kind:"text",parse:($)=>$?{text:$}:null,format:($)=>$.text,find:()=>null,restore:($,Q,J)=>{C1(Q,[J])}};var y3=[f0(o0),f0(T1),f0(g1)];import{AnnotationCtx as qQ,SessionContext as YQ,useAnnotationHost as XQ}from"@fabrika/annotations/runtime";import{useEffect as BQ,useRef as _Q,useState as MQ}from"react";var B={};g4(B,{void:()=>z5,util:()=>E,unknown:()=>A5,union:()=>P5,undefined:()=>L5,tuple:()=>C5,transformer:()=>m5,symbol:()=>w5,string:()=>T2,strictObject:()=>f5,setErrorMap:()=>x3,set:()=>D5,record:()=>v5,quotelessJson:()=>m3,promise:()=>y5,preprocess:()=>u5,pipeline:()=>p5,ostring:()=>c5,optional:()=>h5,onumber:()=>l5,oboolean:()=>d5,objectUtil:()=>y1,object:()=>j5,number:()=>E2,nullable:()=>x5,null:()=>O5,never:()=>S5,nativeEnum:()=>g5,nan:()=>U5,map:()=>k5,makeIssue:()=>P0,literal:()=>I5,lazy:()=>E5,late:()=>_5,isValid:()=>D$,isDirty:()=>a0,isAsync:()=>$0,isAborted:()=>n0,intersection:()=>b5,instanceof:()=>M5,getParsedType:()=>A$,getErrorMap:()=>e$,function:()=>T5,enum:()=>Z5,effect:()=>m5,discriminatedUnion:()=>V5,defaultErrorMap:()=>f$,datetimeRegex:()=>v2,date:()=>N5,custom:()=>D2,coerce:()=>i5,boolean:()=>I2,bigint:()=>K5,array:()=>R5,any:()=>F5,addIssueToContext:()=>A,ZodVoid:()=>b0,ZodUnknown:()=>T$,ZodUnion:()=>X0,ZodUndefined:()=>q0,ZodType:()=>k,ZodTuple:()=>z$,ZodTransformer:()=>N$,ZodSymbol:()=>V0,ZodString:()=>_$,ZodSet:()=>o$,ZodSchema:()=>k,ZodRecord:()=>C0,ZodReadonly:()=>K0,ZodPromise:()=>n$,ZodPipeline:()=>D0,ZodParsedType:()=>L,ZodOptional:()=>U$,ZodObject:()=>p,ZodNumber:()=>E$,ZodNullable:()=>V$,ZodNull:()=>Y0,ZodNever:()=>S$,ZodNativeEnum:()=>_0,ZodNaN:()=>k0,ZodMap:()=>v0,ZodLiteral:()=>B0,ZodLazy:()=>G0,ZodIssueCode:()=>K,ZodIntersection:()=>H0,ZodFunction:()=>J0,ZodFirstPartyTypeKind:()=>V,ZodError:()=>q$,ZodEnum:()=>Z$,ZodEffects:()=>N$,ZodDiscriminatedUnion:()=>s0,ZodDefault:()=>M0,ZodDate:()=>i$,ZodCatch:()=>U0,ZodBranded:()=>t0,ZodBoolean:()=>W0,ZodBigInt:()=>I$,ZodArray:()=>M$,ZodAny:()=>r$,Schema:()=>k,ParseStatus:()=>n,OK:()=>s,NEVER:()=>r5,INVALID:()=>f,EMPTY_PATH:()=>u3,DIRTY:()=>d$,BRAND:()=>B5});var E;(function($){$.assertEqual=(W)=>{};function Q(W){}$.assertIs=Q;function J(W){throw Error()}$.assertNever=J,$.arrayToEnum=(W)=>{let Y={};for(let X of W)Y[X]=X;return Y},$.getValidEnumValues=(W)=>{let Y=$.objectKeys(W).filter((G)=>typeof W[W[G]]!=="number"),X={};for(let G of Y)X[G]=W[G];return $.objectValues(X)},$.objectValues=(W)=>{return $.objectKeys(W).map(function(Y){return W[Y]})},$.objectKeys=typeof Object.keys==="function"?(W)=>Object.keys(W):(W)=>{let Y=[];for(let X in W)if(Object.prototype.hasOwnProperty.call(W,X))Y.push(X);return Y},$.find=(W,Y)=>{for(let X of W)if(Y(X))return X;return},$.isInteger=typeof Number.isInteger==="function"?(W)=>Number.isInteger(W):(W)=>typeof W==="number"&&Number.isFinite(W)&&Math.floor(W)===W;function q(W,Y=" | "){return W.map((X)=>typeof X==="string"?`'${X}'`:X).join(Y)}$.joinValues=q,$.jsonStringifyReplacer=(W,Y)=>{if(typeof Y==="bigint")return Y.toString();return Y}})(E||(E={}));var y1;(function($){$.mergeShapes=(Q,J)=>{return{...Q,...J}}})(y1||(y1={}));var L=E.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),A$=($)=>{switch(typeof $){case"undefined":return L.undefined;case"string":return L.string;case"number":return Number.isNaN($)?L.nan:L.number;case"boolean":return L.boolean;case"function":return L.function;case"bigint":return L.bigint;case"symbol":return L.symbol;case"object":if(Array.isArray($))return L.array;if($===null)return L.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return L.promise;if(typeof Map<"u"&&$ instanceof Map)return L.map;if(typeof Set<"u"&&$ instanceof Set)return L.set;if(typeof Date<"u"&&$ instanceof Date)return L.date;return L.object;default:return L.unknown}};var K=E.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"]),m3=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class q$ extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(J)=>{this.issues=[...this.issues,J]},this.addIssues=(J=[])=>{this.issues=[...this.issues,...J]};let Q=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,Q);else this.__proto__=Q;this.name="ZodError",this.issues=$}format($){let Q=$||function(W){return W.message},J={_errors:[]},q=(W)=>{for(let Y of W.issues)if(Y.code==="invalid_union")Y.unionErrors.map(q);else if(Y.code==="invalid_return_type")q(Y.returnTypeError);else if(Y.code==="invalid_arguments")q(Y.argumentsError);else if(Y.path.length===0)J._errors.push(Q(Y));else{let X=J,G=0;while(G<Y.path.length){let H=Y.path[G];if(G!==Y.path.length-1)X[H]=X[H]||{_errors:[]};else X[H]=X[H]||{_errors:[]},X[H]._errors.push(Q(Y));X=X[H],G++}}};return q(this),J}static assert($){if(!($ instanceof q$))throw Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,E.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(Q)=>Q.message){let Q={},J=[];for(let q of this.issues)if(q.path.length>0){let W=q.path[0];Q[W]=Q[W]||[],Q[W].push($(q))}else J.push($(q));return{formErrors:J,fieldErrors:Q}}get formErrors(){return this.flatten()}}q$.create=($)=>{return new q$($)};var h3=($,Q)=>{let J;switch($.code){case K.invalid_type:if($.received===L.undefined)J="Required";else J=`Expected ${$.expected}, received ${$.received}`;break;case K.invalid_literal:J=`Invalid literal value, expected ${JSON.stringify($.expected,E.jsonStringifyReplacer)}`;break;case K.unrecognized_keys:J=`Unrecognized key(s) in object: ${E.joinValues($.keys,", ")}`;break;case K.invalid_union:J="Invalid input";break;case K.invalid_union_discriminator:J=`Invalid discriminator value. Expected ${E.joinValues($.options)}`;break;case K.invalid_enum_value:J=`Invalid enum value. Expected ${E.joinValues($.options)}, received '${$.received}'`;break;case K.invalid_arguments:J="Invalid function arguments";break;case K.invalid_return_type:J="Invalid function return type";break;case K.invalid_date:J="Invalid date";break;case K.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(J=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")J=`${J} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)J=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)J=`Invalid input: must end with "${$.validation.endsWith}"`;else E.assertNever($.validation);else if($.validation!=="regex")J=`Invalid ${$.validation}`;else J="Invalid";break;case K.too_small:if($.type==="array")J=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")J=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")J=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="bigint")J=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")J=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else J="Invalid input";break;case K.too_big:if($.type==="array")J=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")J=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")J=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")J=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")J=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else J="Invalid input";break;case K.custom:J="Invalid input";break;case K.invalid_intersection_types:J="Intersection results could not be merged";break;case K.not_multiple_of:J=`Number must be a multiple of ${$.multipleOf}`;break;case K.not_finite:J="Number must be finite";break;default:J=Q.defaultError,E.assertNever($)}return{message:J}},f$=h3;var f2=f$;function x3($){f2=$}function e$(){return f2}var P0=($)=>{let{data:Q,path:J,errorMaps:q,issueData:W}=$,Y=[...J,...W.path||[]],X={...W,path:Y};if(W.message!==void 0)return{...W,path:Y,message:W.message};let G="",H=q.filter((_)=>!!_).slice().reverse();for(let _ of H)G=_(X,{data:Q,defaultError:G}).message;return{...W,path:Y,message:G}},u3=[];function A($,Q){let J=e$(),q=P0({issueData:Q,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,J,J===f$?void 0:f$].filter((W)=>!!W)});$.common.issues.push(q)}class n{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,Q){let J=[];for(let q of Q){if(q.status==="aborted")return f;if(q.status==="dirty")$.dirty();J.push(q.value)}return{status:$.value,value:J}}static async mergeObjectAsync($,Q){let J=[];for(let q of Q){let W=await q.key,Y=await q.value;J.push({key:W,value:Y})}return n.mergeObjectSync($,J)}static mergeObjectSync($,Q){let J={};for(let q of Q){let{key:W,value:Y}=q;if(W.status==="aborted")return f;if(Y.status==="aborted")return f;if(W.status==="dirty")$.dirty();if(Y.status==="dirty")$.dirty();if(W.value!=="__proto__"&&(typeof Y.value<"u"||q.alwaysSet))J[W.value]=Y.value}return{status:$.value,value:J}}}var f=Object.freeze({status:"aborted"}),d$=($)=>({status:"dirty",value:$}),s=($)=>({status:"valid",value:$}),n0=($)=>$.status==="aborted",a0=($)=>$.status==="dirty",D$=($)=>$.status==="valid",$0=($)=>typeof Promise<"u"&&$ instanceof Promise;var R;(function($){$.errToObj=(Q)=>typeof Q==="string"?{message:Q}:Q||{},$.toString=(Q)=>typeof Q==="string"?Q:Q?.message})(R||(R={}));class K${constructor($,Q,J,q){this._cachedPath=[],this.parent=$,this.data=Q,this._path=J,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 P2=($,Q)=>{if(D$(Q))return{success:!0,data:Q.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 J=new q$($.common.issues);return this._error=J,this._error}}}};function b($){if(!$)return{};let{errorMap:Q,invalid_type_error:J,required_error:q,description:W}=$;if(Q&&(J||q))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(Q)return{errorMap:Q,description:W};return{errorMap:(X,G)=>{let{message:H}=$;if(X.code==="invalid_enum_value")return{message:H??G.defaultError};if(typeof G.data>"u")return{message:H??q??G.defaultError};if(X.code!=="invalid_type")return{message:G.defaultError};return{message:H??J??G.defaultError}},description:W}}class k{get description(){return this._def.description}_getType($){return A$($.data)}_getOrReturnCtx($,Q){return Q||{common:$.parent.common,data:$.data,parsedType:A$($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new n,ctx:{common:$.parent.common,data:$.data,parsedType:A$($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let Q=this._parse($);if($0(Q))throw Error("Synchronous parse encountered promise.");return Q}_parseAsync($){let Q=this._parse($);return Promise.resolve(Q)}parse($,Q){let J=this.safeParse($,Q);if(J.success)return J.data;throw J.error}safeParse($,Q){let J={common:{issues:[],async:Q?.async??!1,contextualErrorMap:Q?.errorMap},path:Q?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:A$($)},q=this._parseSync({data:$,path:J.path,parent:J});return P2(J,q)}"~validate"($){let Q={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:A$($)};if(!this["~standard"].async)try{let J=this._parseSync({data:$,path:[],parent:Q});return D$(J)?{value:J.value}:{issues:Q.common.issues}}catch(J){if(J?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;Q.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:Q}).then((J)=>D$(J)?{value:J.value}:{issues:Q.common.issues})}async parseAsync($,Q){let J=await this.safeParseAsync($,Q);if(J.success)return J.data;throw J.error}async safeParseAsync($,Q){let J={common:{issues:[],contextualErrorMap:Q?.errorMap,async:!0},path:Q?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:A$($)},q=this._parse({data:$,path:J.path,parent:J}),W=await($0(q)?q:Promise.resolve(q));return P2(J,W)}refine($,Q){let J=(q)=>{if(typeof Q==="string"||typeof Q>"u")return{message:Q};else if(typeof Q==="function")return Q(q);else return Q};return this._refinement((q,W)=>{let Y=$(q),X=()=>W.addIssue({code:K.custom,...J(q)});if(typeof Promise<"u"&&Y instanceof Promise)return Y.then((G)=>{if(!G)return X(),!1;else return!0});if(!Y)return X(),!1;else return!0})}refinement($,Q){return this._refinement((J,q)=>{if(!$(J))return q.addIssue(typeof Q==="function"?Q(J,q):Q),!1;else return!0})}_refinement($){return new N$({schema:this,typeName:V.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:(Q)=>this["~validate"](Q)}}optional(){return U$.create(this,this._def)}nullable(){return V$.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return M$.create(this)}promise(){return n$.create(this,this._def)}or($){return X0.create([this,$],this._def)}and($){return H0.create(this,$,this._def)}transform($){return new N$({...b(this._def),schema:this,typeName:V.ZodEffects,effect:{type:"transform",transform:$}})}default($){let Q=typeof $==="function"?$:()=>$;return new M0({...b(this._def),innerType:this,defaultValue:Q,typeName:V.ZodDefault})}brand(){return new t0({typeName:V.ZodBranded,type:this,...b(this._def)})}catch($){let Q=typeof $==="function"?$:()=>$;return new U0({...b(this._def),innerType:this,catchValue:Q,typeName:V.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return D0.create(this,$)}readonly(){return K0.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var p3=/^c[^\s-]{8,}$/i,c3=/^[0-9a-z]+$/,l3=/^[0-9A-HJKMNP-TV-Z]{26}$/i,d3=/^[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,i3=/^[a-z0-9_-]{21}$/i,r3=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,o3=/^[-+]?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)?)??$/,n3=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,a3="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",m1,s3=/^(?:(?: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])$/,t3=/^(?:(?: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])$/,e3=/^(([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]))$/,$5=/^(([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])$/,Q5=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,J5=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,b2="((\\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])))",W5=new RegExp(`^${b2}$`);function C2($){let Q="[0-5]\\d";if($.precision)Q=`${Q}\\.\\d{${$.precision}}`;else if($.precision==null)Q=`${Q}(\\.\\d+)?`;let J=$.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${Q})${J}`}function q5($){return new RegExp(`^${C2($)}$`)}function v2($){let Q=`${b2}T${C2($)}`,J=[];if(J.push($.local?"Z?":"Z"),$.offset)J.push("([+-]\\d{2}:?\\d{2})");return Q=`${Q}(${J.join("|")})`,new RegExp(`^${Q}$`)}function Y5($,Q){if((Q==="v4"||!Q)&&s3.test($))return!0;if((Q==="v6"||!Q)&&e3.test($))return!0;return!1}function X5($,Q){if(!r3.test($))return!1;try{let[J]=$.split(".");if(!J)return!1;let q=J.replace(/-/g,"+").replace(/_/g,"/").padEnd(J.length+(4-J.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(Q&&W.alg!==Q)return!1;return!0}catch{return!1}}function H5($,Q){if((Q==="v4"||!Q)&&t3.test($))return!0;if((Q==="v6"||!Q)&&$5.test($))return!0;return!1}class _$ extends k{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==L.string){let W=this._getOrReturnCtx($);return A(W,{code:K.invalid_type,expected:L.string,received:W.parsedType}),f}let J=new n,q=void 0;for(let W of this._def.checks)if(W.kind==="min"){if($.data.length<W.value)q=this._getOrReturnCtx($,q),A(q,{code:K.too_small,minimum:W.value,type:"string",inclusive:!0,exact:!1,message:W.message}),J.dirty()}else if(W.kind==="max"){if($.data.length>W.value)q=this._getOrReturnCtx($,q),A(q,{code:K.too_big,maximum:W.value,type:"string",inclusive:!0,exact:!1,message:W.message}),J.dirty()}else if(W.kind==="length"){let Y=$.data.length>W.value,X=$.data.length<W.value;if(Y||X){if(q=this._getOrReturnCtx($,q),Y)A(q,{code:K.too_big,maximum:W.value,type:"string",inclusive:!0,exact:!0,message:W.message});else if(X)A(q,{code:K.too_small,minimum:W.value,type:"string",inclusive:!0,exact:!0,message:W.message});J.dirty()}}else if(W.kind==="email"){if(!n3.test($.data))q=this._getOrReturnCtx($,q),A(q,{validation:"email",code:K.invalid_string,message:W.message}),J.dirty()}else if(W.kind==="emoji"){if(!m1)m1=new RegExp(a3,"u");if(!m1.test($.data))q=this._getOrReturnCtx($,q),A(q,{validation:"emoji",code:K.invalid_string,message:W.message}),J.dirty()}else if(W.kind==="uuid"){if(!d3.test($.data))q=this._getOrReturnCtx($,q),A(q,{validation:"uuid",code:K.invalid_string,message:W.message}),J.dirty()}else if(W.kind==="nanoid"){if(!i3.test($.data))q=this._getOrReturnCtx($,q),A(q,{validation:"nanoid",code:K.invalid_string,message:W.message}),J.dirty()}else if(W.kind==="cuid"){if(!p3.test($.data))q=this._getOrReturnCtx($,q),A(q,{validation:"cuid",code:K.invalid_string,message:W.message}),J.dirty()}else if(W.kind==="cuid2"){if(!c3.test($.data))q=this._getOrReturnCtx($,q),A(q,{validation:"cuid2",code:K.invalid_string,message:W.message}),J.dirty()}else if(W.kind==="ulid"){if(!l3.test($.data))q=this._getOrReturnCtx($,q),A(q,{validation:"ulid",code:K.invalid_string,message:W.message}),J.dirty()}else if(W.kind==="url")try{new URL($.data)}catch{q=this._getOrReturnCtx($,q),A(q,{validation:"url",code:K.invalid_string,message:W.message}),J.dirty()}else if(W.kind==="regex"){if(W.regex.lastIndex=0,!W.regex.test($.data))q=this._getOrReturnCtx($,q),A(q,{validation:"regex",code:K.invalid_string,message:W.message}),J.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),A(q,{code:K.invalid_string,validation:{includes:W.value,position:W.position},message:W.message}),J.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),A(q,{code:K.invalid_string,validation:{startsWith:W.value},message:W.message}),J.dirty()}else if(W.kind==="endsWith"){if(!$.data.endsWith(W.value))q=this._getOrReturnCtx($,q),A(q,{code:K.invalid_string,validation:{endsWith:W.value},message:W.message}),J.dirty()}else if(W.kind==="datetime"){if(!v2(W).test($.data))q=this._getOrReturnCtx($,q),A(q,{code:K.invalid_string,validation:"datetime",message:W.message}),J.dirty()}else if(W.kind==="date"){if(!W5.test($.data))q=this._getOrReturnCtx($,q),A(q,{code:K.invalid_string,validation:"date",message:W.message}),J.dirty()}else if(W.kind==="time"){if(!q5(W).test($.data))q=this._getOrReturnCtx($,q),A(q,{code:K.invalid_string,validation:"time",message:W.message}),J.dirty()}else if(W.kind==="duration"){if(!o3.test($.data))q=this._getOrReturnCtx($,q),A(q,{validation:"duration",code:K.invalid_string,message:W.message}),J.dirty()}else if(W.kind==="ip"){if(!Y5($.data,W.version))q=this._getOrReturnCtx($,q),A(q,{validation:"ip",code:K.invalid_string,message:W.message}),J.dirty()}else if(W.kind==="jwt"){if(!X5($.data,W.alg))q=this._getOrReturnCtx($,q),A(q,{validation:"jwt",code:K.invalid_string,message:W.message}),J.dirty()}else if(W.kind==="cidr"){if(!H5($.data,W.version))q=this._getOrReturnCtx($,q),A(q,{validation:"cidr",code:K.invalid_string,message:W.message}),J.dirty()}else if(W.kind==="base64"){if(!Q5.test($.data))q=this._getOrReturnCtx($,q),A(q,{validation:"base64",code:K.invalid_string,message:W.message}),J.dirty()}else if(W.kind==="base64url"){if(!J5.test($.data))q=this._getOrReturnCtx($,q),A(q,{validation:"base64url",code:K.invalid_string,message:W.message}),J.dirty()}else E.assertNever(W);return{status:J.value,value:$.data}}_regex($,Q,J){return this.refinement((q)=>$.test(q),{validation:Q,code:K.invalid_string,...R.errToObj(J)})}_addCheck($){return new _$({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...R.errToObj($)})}url($){return this._addCheck({kind:"url",...R.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...R.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...R.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...R.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...R.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...R.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...R.errToObj($)})}base64($){return this._addCheck({kind:"base64",...R.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...R.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...R.errToObj($)})}ip($){return this._addCheck({kind:"ip",...R.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...R.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,...R.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,...R.errToObj($?.message)})}duration($){return this._addCheck({kind:"duration",...R.errToObj($)})}regex($,Q){return this._addCheck({kind:"regex",regex:$,...R.errToObj(Q)})}includes($,Q){return this._addCheck({kind:"includes",value:$,position:Q?.position,...R.errToObj(Q?.message)})}startsWith($,Q){return this._addCheck({kind:"startsWith",value:$,...R.errToObj(Q)})}endsWith($,Q){return this._addCheck({kind:"endsWith",value:$,...R.errToObj(Q)})}min($,Q){return this._addCheck({kind:"min",value:$,...R.errToObj(Q)})}max($,Q){return this._addCheck({kind:"max",value:$,...R.errToObj(Q)})}length($,Q){return this._addCheck({kind:"length",value:$,...R.errToObj(Q)})}nonempty($){return this.min(1,R.errToObj($))}trim(){return new _$({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new _$({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new _$({...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 Q of this._def.checks)if(Q.kind==="min"){if($===null||Q.value>$)$=Q.value}return $}get maxLength(){let $=null;for(let Q of this._def.checks)if(Q.kind==="max"){if($===null||Q.value<$)$=Q.value}return $}}_$.create=($)=>{return new _$({checks:[],typeName:V.ZodString,coerce:$?.coerce??!1,...b($)})};function G5($,Q){let J=($.toString().split(".")[1]||"").length,q=(Q.toString().split(".")[1]||"").length,W=J>q?J:q,Y=Number.parseInt($.toFixed(W).replace(".","")),X=Number.parseInt(Q.toFixed(W).replace(".",""));return Y%X/10**W}class E$ extends k{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($)!==L.number){let W=this._getOrReturnCtx($);return A(W,{code:K.invalid_type,expected:L.number,received:W.parsedType}),f}let J=void 0,q=new n;for(let W of this._def.checks)if(W.kind==="int"){if(!E.isInteger($.data))J=this._getOrReturnCtx($,J),A(J,{code:K.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)J=this._getOrReturnCtx($,J),A(J,{code:K.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)J=this._getOrReturnCtx($,J),A(J,{code:K.too_big,maximum:W.value,type:"number",inclusive:W.inclusive,exact:!1,message:W.message}),q.dirty()}else if(W.kind==="multipleOf"){if(G5($.data,W.value)!==0)J=this._getOrReturnCtx($,J),A(J,{code:K.not_multiple_of,multipleOf:W.value,message:W.message}),q.dirty()}else if(W.kind==="finite"){if(!Number.isFinite($.data))J=this._getOrReturnCtx($,J),A(J,{code:K.not_finite,message:W.message}),q.dirty()}else E.assertNever(W);return{status:q.value,value:$.data}}gte($,Q){return this.setLimit("min",$,!0,R.toString(Q))}gt($,Q){return this.setLimit("min",$,!1,R.toString(Q))}lte($,Q){return this.setLimit("max",$,!0,R.toString(Q))}lt($,Q){return this.setLimit("max",$,!1,R.toString(Q))}setLimit($,Q,J,q){return new E$({...this._def,checks:[...this._def.checks,{kind:$,value:Q,inclusive:J,message:R.toString(q)}]})}_addCheck($){return new E$({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:R.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:R.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:R.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:R.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:R.toString($)})}multipleOf($,Q){return this._addCheck({kind:"multipleOf",value:$,message:R.toString(Q)})}finite($){return this._addCheck({kind:"finite",message:R.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:R.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:R.toString($)})}get minValue(){let $=null;for(let Q of this._def.checks)if(Q.kind==="min"){if($===null||Q.value>$)$=Q.value}return $}get maxValue(){let $=null;for(let Q of this._def.checks)if(Q.kind==="max"){if($===null||Q.value<$)$=Q.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&E.isInteger($.value))}get isFinite(){let $=null,Q=null;for(let J of this._def.checks)if(J.kind==="finite"||J.kind==="int"||J.kind==="multipleOf")return!0;else if(J.kind==="min"){if(Q===null||J.value>Q)Q=J.value}else if(J.kind==="max"){if($===null||J.value<$)$=J.value}return Number.isFinite(Q)&&Number.isFinite($)}}E$.create=($)=>{return new E$({checks:[],typeName:V.ZodNumber,coerce:$?.coerce||!1,...b($)})};class I$ extends k{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($)!==L.bigint)return this._getInvalidInput($);let J=void 0,q=new n;for(let W of this._def.checks)if(W.kind==="min"){if(W.inclusive?$.data<W.value:$.data<=W.value)J=this._getOrReturnCtx($,J),A(J,{code:K.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)J=this._getOrReturnCtx($,J),A(J,{code:K.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))J=this._getOrReturnCtx($,J),A(J,{code:K.not_multiple_of,multipleOf:W.value,message:W.message}),q.dirty()}else E.assertNever(W);return{status:q.value,value:$.data}}_getInvalidInput($){let Q=this._getOrReturnCtx($);return A(Q,{code:K.invalid_type,expected:L.bigint,received:Q.parsedType}),f}gte($,Q){return this.setLimit("min",$,!0,R.toString(Q))}gt($,Q){return this.setLimit("min",$,!1,R.toString(Q))}lte($,Q){return this.setLimit("max",$,!0,R.toString(Q))}lt($,Q){return this.setLimit("max",$,!1,R.toString(Q))}setLimit($,Q,J,q){return new I$({...this._def,checks:[...this._def.checks,{kind:$,value:Q,inclusive:J,message:R.toString(q)}]})}_addCheck($){return new I$({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:R.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:R.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:R.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:R.toString($)})}multipleOf($,Q){return this._addCheck({kind:"multipleOf",value:$,message:R.toString(Q)})}get minValue(){let $=null;for(let Q of this._def.checks)if(Q.kind==="min"){if($===null||Q.value>$)$=Q.value}return $}get maxValue(){let $=null;for(let Q of this._def.checks)if(Q.kind==="max"){if($===null||Q.value<$)$=Q.value}return $}}I$.create=($)=>{return new I$({checks:[],typeName:V.ZodBigInt,coerce:$?.coerce??!1,...b($)})};class W0 extends k{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==L.boolean){let J=this._getOrReturnCtx($);return A(J,{code:K.invalid_type,expected:L.boolean,received:J.parsedType}),f}return s($.data)}}W0.create=($)=>{return new W0({typeName:V.ZodBoolean,coerce:$?.coerce||!1,...b($)})};class i$ extends k{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==L.date){let W=this._getOrReturnCtx($);return A(W,{code:K.invalid_type,expected:L.date,received:W.parsedType}),f}if(Number.isNaN($.data.getTime())){let W=this._getOrReturnCtx($);return A(W,{code:K.invalid_date}),f}let J=new n,q=void 0;for(let W of this._def.checks)if(W.kind==="min"){if($.data.getTime()<W.value)q=this._getOrReturnCtx($,q),A(q,{code:K.too_small,message:W.message,inclusive:!0,exact:!1,minimum:W.value,type:"date"}),J.dirty()}else if(W.kind==="max"){if($.data.getTime()>W.value)q=this._getOrReturnCtx($,q),A(q,{code:K.too_big,message:W.message,inclusive:!0,exact:!1,maximum:W.value,type:"date"}),J.dirty()}else E.assertNever(W);return{status:J.value,value:new Date($.data.getTime())}}_addCheck($){return new i$({...this._def,checks:[...this._def.checks,$]})}min($,Q){return this._addCheck({kind:"min",value:$.getTime(),message:R.toString(Q)})}max($,Q){return this._addCheck({kind:"max",value:$.getTime(),message:R.toString(Q)})}get minDate(){let $=null;for(let Q of this._def.checks)if(Q.kind==="min"){if($===null||Q.value>$)$=Q.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let Q of this._def.checks)if(Q.kind==="max"){if($===null||Q.value<$)$=Q.value}return $!=null?new Date($):null}}i$.create=($)=>{return new i$({checks:[],coerce:$?.coerce||!1,typeName:V.ZodDate,...b($)})};class V0 extends k{_parse($){if(this._getType($)!==L.symbol){let J=this._getOrReturnCtx($);return A(J,{code:K.invalid_type,expected:L.symbol,received:J.parsedType}),f}return s($.data)}}V0.create=($)=>{return new V0({typeName:V.ZodSymbol,...b($)})};class q0 extends k{_parse($){if(this._getType($)!==L.undefined){let J=this._getOrReturnCtx($);return A(J,{code:K.invalid_type,expected:L.undefined,received:J.parsedType}),f}return s($.data)}}q0.create=($)=>{return new q0({typeName:V.ZodUndefined,...b($)})};class Y0 extends k{_parse($){if(this._getType($)!==L.null){let J=this._getOrReturnCtx($);return A(J,{code:K.invalid_type,expected:L.null,received:J.parsedType}),f}return s($.data)}}Y0.create=($)=>{return new Y0({typeName:V.ZodNull,...b($)})};class r$ extends k{constructor(){super(...arguments);this._any=!0}_parse($){return s($.data)}}r$.create=($)=>{return new r$({typeName:V.ZodAny,...b($)})};class T$ extends k{constructor(){super(...arguments);this._unknown=!0}_parse($){return s($.data)}}T$.create=($)=>{return new T$({typeName:V.ZodUnknown,...b($)})};class S$ extends k{_parse($){let Q=this._getOrReturnCtx($);return A(Q,{code:K.invalid_type,expected:L.never,received:Q.parsedType}),f}}S$.create=($)=>{return new S$({typeName:V.ZodNever,...b($)})};class b0 extends k{_parse($){if(this._getType($)!==L.undefined){let J=this._getOrReturnCtx($);return A(J,{code:K.invalid_type,expected:L.void,received:J.parsedType}),f}return s($.data)}}b0.create=($)=>{return new b0({typeName:V.ZodVoid,...b($)})};class M$ extends k{_parse($){let{ctx:Q,status:J}=this._processInputParams($),q=this._def;if(Q.parsedType!==L.array)return A(Q,{code:K.invalid_type,expected:L.array,received:Q.parsedType}),f;if(q.exactLength!==null){let Y=Q.data.length>q.exactLength.value,X=Q.data.length<q.exactLength.value;if(Y||X)A(Q,{code:Y?K.too_big:K.too_small,minimum:X?q.exactLength.value:void 0,maximum:Y?q.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:q.exactLength.message}),J.dirty()}if(q.minLength!==null){if(Q.data.length<q.minLength.value)A(Q,{code:K.too_small,minimum:q.minLength.value,type:"array",inclusive:!0,exact:!1,message:q.minLength.message}),J.dirty()}if(q.maxLength!==null){if(Q.data.length>q.maxLength.value)A(Q,{code:K.too_big,maximum:q.maxLength.value,type:"array",inclusive:!0,exact:!1,message:q.maxLength.message}),J.dirty()}if(Q.common.async)return Promise.all([...Q.data].map((Y,X)=>{return q.type._parseAsync(new K$(Q,Y,Q.path,X))})).then((Y)=>{return n.mergeArray(J,Y)});let W=[...Q.data].map((Y,X)=>{return q.type._parseSync(new K$(Q,Y,Q.path,X))});return n.mergeArray(J,W)}get element(){return this._def.type}min($,Q){return new M$({...this._def,minLength:{value:$,message:R.toString(Q)}})}max($,Q){return new M$({...this._def,maxLength:{value:$,message:R.toString(Q)}})}length($,Q){return new M$({...this._def,exactLength:{value:$,message:R.toString(Q)}})}nonempty($){return this.min(1,$)}}M$.create=($,Q)=>{return new M$({type:$,minLength:null,maxLength:null,exactLength:null,typeName:V.ZodArray,...b(Q)})};function Q0($){if($ instanceof p){let Q={};for(let J in $.shape){let q=$.shape[J];Q[J]=U$.create(Q0(q))}return new p({...$._def,shape:()=>Q})}else if($ instanceof M$)return new M$({...$._def,type:Q0($.element)});else if($ instanceof U$)return U$.create(Q0($.unwrap()));else if($ instanceof V$)return V$.create(Q0($.unwrap()));else if($ instanceof z$)return z$.create($.items.map((Q)=>Q0(Q)));else return $}class p extends k{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(),Q=E.objectKeys($);return this._cached={shape:$,keys:Q},this._cached}_parse($){if(this._getType($)!==L.object){let H=this._getOrReturnCtx($);return A(H,{code:K.invalid_type,expected:L.object,received:H.parsedType}),f}let{status:J,ctx:q}=this._processInputParams($),{shape:W,keys:Y}=this._getCached(),X=[];if(!(this._def.catchall instanceof S$&&this._def.unknownKeys==="strip")){for(let H in q.data)if(!Y.includes(H))X.push(H)}let G=[];for(let H of Y){let _=W[H],M=q.data[H];G.push({key:{status:"valid",value:H},value:_._parse(new K$(q,M,q.path,H)),alwaysSet:H in q.data})}if(this._def.catchall instanceof S$){let H=this._def.unknownKeys;if(H==="passthrough")for(let _ of X)G.push({key:{status:"valid",value:_},value:{status:"valid",value:q.data[_]}});else if(H==="strict"){if(X.length>0)A(q,{code:K.unrecognized_keys,keys:X}),J.dirty()}else if(H==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let H=this._def.catchall;for(let _ of X){let M=q.data[_];G.push({key:{status:"valid",value:_},value:H._parse(new K$(q,M,q.path,_)),alwaysSet:_ in q.data})}}if(q.common.async)return Promise.resolve().then(async()=>{let H=[];for(let _ of G){let M=await _.key,N=await _.value;H.push({key:M,value:N,alwaysSet:_.alwaysSet})}return H}).then((H)=>{return n.mergeObjectSync(J,H)});else return n.mergeObjectSync(J,G)}get shape(){return this._def.shape()}strict($){return R.errToObj,new p({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(Q,J)=>{let q=this._def.errorMap?.(Q,J).message??J.defaultError;if(Q.code==="unrecognized_keys")return{message:R.errToObj($).message??q};return{message:q}}}:{}})}strip(){return new p({...this._def,unknownKeys:"strip"})}passthrough(){return new p({...this._def,unknownKeys:"passthrough"})}extend($){return new p({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new p({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:V.ZodObject})}setKey($,Q){return this.augment({[$]:Q})}catchall($){return new p({...this._def,catchall:$})}pick($){let Q={};for(let J of E.objectKeys($))if($[J]&&this.shape[J])Q[J]=this.shape[J];return new p({...this._def,shape:()=>Q})}omit($){let Q={};for(let J of E.objectKeys(this.shape))if(!$[J])Q[J]=this.shape[J];return new p({...this._def,shape:()=>Q})}deepPartial(){return Q0(this)}partial($){let Q={};for(let J of E.objectKeys(this.shape)){let q=this.shape[J];if($&&!$[J])Q[J]=q;else Q[J]=q.optional()}return new p({...this._def,shape:()=>Q})}required($){let Q={};for(let J of E.objectKeys(this.shape))if($&&!$[J])Q[J]=this.shape[J];else{let W=this.shape[J];while(W instanceof U$)W=W._def.innerType;Q[J]=W}return new p({...this._def,shape:()=>Q})}keyof(){return k2(E.objectKeys(this.shape))}}p.create=($,Q)=>{return new p({shape:()=>$,unknownKeys:"strip",catchall:S$.create(),typeName:V.ZodObject,...b(Q)})};p.strictCreate=($,Q)=>{return new p({shape:()=>$,unknownKeys:"strict",catchall:S$.create(),typeName:V.ZodObject,...b(Q)})};p.lazycreate=($,Q)=>{return new p({shape:$,unknownKeys:"strip",catchall:S$.create(),typeName:V.ZodObject,...b(Q)})};class X0 extends k{_parse($){let{ctx:Q}=this._processInputParams($),J=this._def.options;function q(W){for(let X of W)if(X.result.status==="valid")return X.result;for(let X of W)if(X.result.status==="dirty")return Q.common.issues.push(...X.ctx.common.issues),X.result;let Y=W.map((X)=>new q$(X.ctx.common.issues));return A(Q,{code:K.invalid_union,unionErrors:Y}),f}if(Q.common.async)return Promise.all(J.map(async(W)=>{let Y={...Q,common:{...Q.common,issues:[]},parent:null};return{result:await W._parseAsync({data:Q.data,path:Q.path,parent:Y}),ctx:Y}})).then(q);else{let W=void 0,Y=[];for(let G of J){let H={...Q,common:{...Q.common,issues:[]},parent:null},_=G._parseSync({data:Q.data,path:Q.path,parent:H});if(_.status==="valid")return _;else if(_.status==="dirty"&&!W)W={result:_,ctx:H};if(H.common.issues.length)Y.push(H.common.issues)}if(W)return Q.common.issues.push(...W.ctx.common.issues),W.result;let X=Y.map((G)=>new q$(G));return A(Q,{code:K.invalid_union,unionErrors:X}),f}}get options(){return this._def.options}}X0.create=($,Q)=>{return new X0({options:$,typeName:V.ZodUnion,...b(Q)})};var P$=($)=>{if($ instanceof G0)return P$($.schema);else if($ instanceof N$)return P$($.innerType());else if($ instanceof B0)return[$.value];else if($ instanceof Z$)return $.options;else if($ instanceof _0)return E.objectValues($.enum);else if($ instanceof M0)return P$($._def.innerType);else if($ instanceof q0)return[void 0];else if($ instanceof Y0)return[null];else if($ instanceof U$)return[void 0,...P$($.unwrap())];else if($ instanceof V$)return[null,...P$($.unwrap())];else if($ instanceof t0)return P$($.unwrap());else if($ instanceof K0)return P$($.unwrap());else if($ instanceof U0)return P$($._def.innerType);else return[]};class s0 extends k{_parse($){let{ctx:Q}=this._processInputParams($);if(Q.parsedType!==L.object)return A(Q,{code:K.invalid_type,expected:L.object,received:Q.parsedType}),f;let J=this.discriminator,q=Q.data[J],W=this.optionsMap.get(q);if(!W)return A(Q,{code:K.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[J]}),f;if(Q.common.async)return W._parseAsync({data:Q.data,path:Q.path,parent:Q});else return W._parseSync({data:Q.data,path:Q.path,parent:Q})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,Q,J){let q=new Map;for(let W of Q){let Y=P$(W.shape[$]);if(!Y.length)throw Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let X of Y){if(q.has(X))throw Error(`Discriminator property ${String($)} has duplicate value ${String(X)}`);q.set(X,W)}}return new s0({typeName:V.ZodDiscriminatedUnion,discriminator:$,options:Q,optionsMap:q,...b(J)})}}function h1($,Q){let J=A$($),q=A$(Q);if($===Q)return{valid:!0,data:$};else if(J===L.object&&q===L.object){let W=E.objectKeys(Q),Y=E.objectKeys($).filter((G)=>W.indexOf(G)!==-1),X={...$,...Q};for(let G of Y){let H=h1($[G],Q[G]);if(!H.valid)return{valid:!1};X[G]=H.data}return{valid:!0,data:X}}else if(J===L.array&&q===L.array){if($.length!==Q.length)return{valid:!1};let W=[];for(let Y=0;Y<$.length;Y++){let X=$[Y],G=Q[Y],H=h1(X,G);if(!H.valid)return{valid:!1};W.push(H.data)}return{valid:!0,data:W}}else if(J===L.date&&q===L.date&&+$===+Q)return{valid:!0,data:$};else return{valid:!1}}class H0 extends k{_parse($){let{status:Q,ctx:J}=this._processInputParams($),q=(W,Y)=>{if(n0(W)||n0(Y))return f;let X=h1(W.value,Y.value);if(!X.valid)return A(J,{code:K.invalid_intersection_types}),f;if(a0(W)||a0(Y))Q.dirty();return{status:Q.value,value:X.data}};if(J.common.async)return Promise.all([this._def.left._parseAsync({data:J.data,path:J.path,parent:J}),this._def.right._parseAsync({data:J.data,path:J.path,parent:J})]).then(([W,Y])=>q(W,Y));else return q(this._def.left._parseSync({data:J.data,path:J.path,parent:J}),this._def.right._parseSync({data:J.data,path:J.path,parent:J}))}}H0.create=($,Q,J)=>{return new H0({left:$,right:Q,typeName:V.ZodIntersection,...b(J)})};class z$ extends k{_parse($){let{status:Q,ctx:J}=this._processInputParams($);if(J.parsedType!==L.array)return A(J,{code:K.invalid_type,expected:L.array,received:J.parsedType}),f;if(J.data.length<this._def.items.length)return A(J,{code:K.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),f;if(!this._def.rest&&J.data.length>this._def.items.length)A(J,{code:K.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),Q.dirty();let W=[...J.data].map((Y,X)=>{let G=this._def.items[X]||this._def.rest;if(!G)return null;return G._parse(new K$(J,Y,J.path,X))}).filter((Y)=>!!Y);if(J.common.async)return Promise.all(W).then((Y)=>{return n.mergeArray(Q,Y)});else return n.mergeArray(Q,W)}get items(){return this._def.items}rest($){return new z$({...this._def,rest:$})}}z$.create=($,Q)=>{if(!Array.isArray($))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new z$({items:$,typeName:V.ZodTuple,rest:null,...b(Q)})};class C0 extends k{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:Q,ctx:J}=this._processInputParams($);if(J.parsedType!==L.object)return A(J,{code:K.invalid_type,expected:L.object,received:J.parsedType}),f;let q=[],W=this._def.keyType,Y=this._def.valueType;for(let X in J.data)q.push({key:W._parse(new K$(J,X,J.path,X)),value:Y._parse(new K$(J,J.data[X],J.path,X)),alwaysSet:X in J.data});if(J.common.async)return n.mergeObjectAsync(Q,q);else return n.mergeObjectSync(Q,q)}get element(){return this._def.valueType}static create($,Q,J){if(Q instanceof k)return new C0({keyType:$,valueType:Q,typeName:V.ZodRecord,...b(J)});return new C0({keyType:_$.create(),valueType:$,typeName:V.ZodRecord,...b(Q)})}}class v0 extends k{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:Q,ctx:J}=this._processInputParams($);if(J.parsedType!==L.map)return A(J,{code:K.invalid_type,expected:L.map,received:J.parsedType}),f;let q=this._def.keyType,W=this._def.valueType,Y=[...J.data.entries()].map(([X,G],H)=>{return{key:q._parse(new K$(J,X,J.path,[H,"key"])),value:W._parse(new K$(J,G,J.path,[H,"value"]))}});if(J.common.async){let X=new Map;return Promise.resolve().then(async()=>{for(let G of Y){let H=await G.key,_=await G.value;if(H.status==="aborted"||_.status==="aborted")return f;if(H.status==="dirty"||_.status==="dirty")Q.dirty();X.set(H.value,_.value)}return{status:Q.value,value:X}})}else{let X=new Map;for(let G of Y){let{key:H,value:_}=G;if(H.status==="aborted"||_.status==="aborted")return f;if(H.status==="dirty"||_.status==="dirty")Q.dirty();X.set(H.value,_.value)}return{status:Q.value,value:X}}}}v0.create=($,Q,J)=>{return new v0({valueType:Q,keyType:$,typeName:V.ZodMap,...b(J)})};class o$ extends k{_parse($){let{status:Q,ctx:J}=this._processInputParams($);if(J.parsedType!==L.set)return A(J,{code:K.invalid_type,expected:L.set,received:J.parsedType}),f;let q=this._def;if(q.minSize!==null){if(J.data.size<q.minSize.value)A(J,{code:K.too_small,minimum:q.minSize.value,type:"set",inclusive:!0,exact:!1,message:q.minSize.message}),Q.dirty()}if(q.maxSize!==null){if(J.data.size>q.maxSize.value)A(J,{code:K.too_big,maximum:q.maxSize.value,type:"set",inclusive:!0,exact:!1,message:q.maxSize.message}),Q.dirty()}let W=this._def.valueType;function Y(G){let H=new Set;for(let _ of G){if(_.status==="aborted")return f;if(_.status==="dirty")Q.dirty();H.add(_.value)}return{status:Q.value,value:H}}let X=[...J.data.values()].map((G,H)=>W._parse(new K$(J,G,J.path,H)));if(J.common.async)return Promise.all(X).then((G)=>Y(G));else return Y(X)}min($,Q){return new o$({...this._def,minSize:{value:$,message:R.toString(Q)}})}max($,Q){return new o$({...this._def,maxSize:{value:$,message:R.toString(Q)}})}size($,Q){return this.min($,Q).max($,Q)}nonempty($){return this.min(1,$)}}o$.create=($,Q)=>{return new o$({valueType:$,minSize:null,maxSize:null,typeName:V.ZodSet,...b(Q)})};class J0 extends k{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:Q}=this._processInputParams($);if(Q.parsedType!==L.function)return A(Q,{code:K.invalid_type,expected:L.function,received:Q.parsedType}),f;function J(X,G){return P0({data:X,path:Q.path,errorMaps:[Q.common.contextualErrorMap,Q.schemaErrorMap,e$(),f$].filter((H)=>!!H),issueData:{code:K.invalid_arguments,argumentsError:G}})}function q(X,G){return P0({data:X,path:Q.path,errorMaps:[Q.common.contextualErrorMap,Q.schemaErrorMap,e$(),f$].filter((H)=>!!H),issueData:{code:K.invalid_return_type,returnTypeError:G}})}let W={errorMap:Q.common.contextualErrorMap},Y=Q.data;if(this._def.returns instanceof n$){let X=this;return s(async function(...G){let H=new q$([]),_=await X._def.args.parseAsync(G,W).catch((O)=>{throw H.addIssue(J(G,O)),H}),M=await Reflect.apply(Y,this,_);return await X._def.returns._def.type.parseAsync(M,W).catch((O)=>{throw H.addIssue(q(M,O)),H})})}else{let X=this;return s(function(...G){let H=X._def.args.safeParse(G,W);if(!H.success)throw new q$([J(G,H.error)]);let _=Reflect.apply(Y,this,H.data),M=X._def.returns.safeParse(_,W);if(!M.success)throw new q$([q(_,M.error)]);return M.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new J0({...this._def,args:z$.create($).rest(T$.create())})}returns($){return new J0({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,Q,J){return new J0({args:$?$:z$.create([]).rest(T$.create()),returns:Q||T$.create(),typeName:V.ZodFunction,...b(J)})}}class G0 extends k{get schema(){return this._def.getter()}_parse($){let{ctx:Q}=this._processInputParams($);return this._def.getter()._parse({data:Q.data,path:Q.path,parent:Q})}}G0.create=($,Q)=>{return new G0({getter:$,typeName:V.ZodLazy,...b(Q)})};class B0 extends k{_parse($){if($.data!==this._def.value){let Q=this._getOrReturnCtx($);return A(Q,{received:Q.data,code:K.invalid_literal,expected:this._def.value}),f}return{status:"valid",value:$.data}}get value(){return this._def.value}}B0.create=($,Q)=>{return new B0({value:$,typeName:V.ZodLiteral,...b(Q)})};function k2($,Q){return new Z$({values:$,typeName:V.ZodEnum,...b(Q)})}class Z$ extends k{_parse($){if(typeof $.data!=="string"){let Q=this._getOrReturnCtx($),J=this._def.values;return A(Q,{expected:E.joinValues(J),received:Q.parsedType,code:K.invalid_type}),f}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has($.data)){let Q=this._getOrReturnCtx($),J=this._def.values;return A(Q,{received:Q.data,code:K.invalid_enum_value,options:J}),f}return s($.data)}get options(){return this._def.values}get enum(){let $={};for(let Q of this._def.values)$[Q]=Q;return $}get Values(){let $={};for(let Q of this._def.values)$[Q]=Q;return $}get Enum(){let $={};for(let Q of this._def.values)$[Q]=Q;return $}extract($,Q=this._def){return Z$.create($,{...this._def,...Q})}exclude($,Q=this._def){return Z$.create(this.options.filter((J)=>!$.includes(J)),{...this._def,...Q})}}Z$.create=k2;class _0 extends k{_parse($){let Q=E.getValidEnumValues(this._def.values),J=this._getOrReturnCtx($);if(J.parsedType!==L.string&&J.parsedType!==L.number){let q=E.objectValues(Q);return A(J,{expected:E.joinValues(q),received:J.parsedType,code:K.invalid_type}),f}if(!this._cache)this._cache=new Set(E.getValidEnumValues(this._def.values));if(!this._cache.has($.data)){let q=E.objectValues(Q);return A(J,{received:J.data,code:K.invalid_enum_value,options:q}),f}return s($.data)}get enum(){return this._def.values}}_0.create=($,Q)=>{return new _0({values:$,typeName:V.ZodNativeEnum,...b(Q)})};class n$ extends k{unwrap(){return this._def.type}_parse($){let{ctx:Q}=this._processInputParams($);if(Q.parsedType!==L.promise&&Q.common.async===!1)return A(Q,{code:K.invalid_type,expected:L.promise,received:Q.parsedType}),f;let J=Q.parsedType===L.promise?Q.data:Promise.resolve(Q.data);return s(J.then((q)=>{return this._def.type.parseAsync(q,{path:Q.path,errorMap:Q.common.contextualErrorMap})}))}}n$.create=($,Q)=>{return new n$({type:$,typeName:V.ZodPromise,...b(Q)})};class N$ extends k{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===V.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:Q,ctx:J}=this._processInputParams($),q=this._def.effect||null,W={addIssue:(Y)=>{if(A(J,Y),Y.fatal)Q.abort();else Q.dirty()},get path(){return J.path}};if(W.addIssue=W.addIssue.bind(W),q.type==="preprocess"){let Y=q.transform(J.data,W);if(J.common.async)return Promise.resolve(Y).then(async(X)=>{if(Q.value==="aborted")return f;let G=await this._def.schema._parseAsync({data:X,path:J.path,parent:J});if(G.status==="aborted")return f;if(G.status==="dirty")return d$(G.value);if(Q.value==="dirty")return d$(G.value);return G});else{if(Q.value==="aborted")return f;let X=this._def.schema._parseSync({data:Y,path:J.path,parent:J});if(X.status==="aborted")return f;if(X.status==="dirty")return d$(X.value);if(Q.value==="dirty")return d$(X.value);return X}}if(q.type==="refinement"){let Y=(X)=>{let G=q.refinement(X,W);if(J.common.async)return Promise.resolve(G);if(G instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return X};if(J.common.async===!1){let X=this._def.schema._parseSync({data:J.data,path:J.path,parent:J});if(X.status==="aborted")return f;if(X.status==="dirty")Q.dirty();return Y(X.value),{status:Q.value,value:X.value}}else return this._def.schema._parseAsync({data:J.data,path:J.path,parent:J}).then((X)=>{if(X.status==="aborted")return f;if(X.status==="dirty")Q.dirty();return Y(X.value).then(()=>{return{status:Q.value,value:X.value}})})}if(q.type==="transform")if(J.common.async===!1){let Y=this._def.schema._parseSync({data:J.data,path:J.path,parent:J});if(!D$(Y))return f;let X=q.transform(Y.value,W);if(X instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:Q.value,value:X}}else return this._def.schema._parseAsync({data:J.data,path:J.path,parent:J}).then((Y)=>{if(!D$(Y))return f;return Promise.resolve(q.transform(Y.value,W)).then((X)=>({status:Q.value,value:X}))});E.assertNever(q)}}N$.create=($,Q,J)=>{return new N$({schema:$,typeName:V.ZodEffects,effect:Q,...b(J)})};N$.createWithPreprocess=($,Q,J)=>{return new N$({schema:Q,effect:{type:"preprocess",transform:$},typeName:V.ZodEffects,...b(J)})};class U$ extends k{_parse($){if(this._getType($)===L.undefined)return s(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}U$.create=($,Q)=>{return new U$({innerType:$,typeName:V.ZodOptional,...b(Q)})};class V$ extends k{_parse($){if(this._getType($)===L.null)return s(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}V$.create=($,Q)=>{return new V$({innerType:$,typeName:V.ZodNullable,...b(Q)})};class M0 extends k{_parse($){let{ctx:Q}=this._processInputParams($),J=Q.data;if(Q.parsedType===L.undefined)J=this._def.defaultValue();return this._def.innerType._parse({data:J,path:Q.path,parent:Q})}removeDefault(){return this._def.innerType}}M0.create=($,Q)=>{return new M0({innerType:$,typeName:V.ZodDefault,defaultValue:typeof Q.default==="function"?Q.default:()=>Q.default,...b(Q)})};class U0 extends k{_parse($){let{ctx:Q}=this._processInputParams($),J={...Q,common:{...Q.common,issues:[]}},q=this._def.innerType._parse({data:J.data,path:J.path,parent:{...J}});if($0(q))return q.then((W)=>{return{status:"valid",value:W.status==="valid"?W.value:this._def.catchValue({get error(){return new q$(J.common.issues)},input:J.data})}});else return{status:"valid",value:q.status==="valid"?q.value:this._def.catchValue({get error(){return new q$(J.common.issues)},input:J.data})}}removeCatch(){return this._def.innerType}}U0.create=($,Q)=>{return new U0({innerType:$,typeName:V.ZodCatch,catchValue:typeof Q.catch==="function"?Q.catch:()=>Q.catch,...b(Q)})};class k0 extends k{_parse($){if(this._getType($)!==L.nan){let J=this._getOrReturnCtx($);return A(J,{code:K.invalid_type,expected:L.nan,received:J.parsedType}),f}return{status:"valid",value:$.data}}}k0.create=($)=>{return new k0({typeName:V.ZodNaN,...b($)})};var B5=Symbol("zod_brand");class t0 extends k{_parse($){let{ctx:Q}=this._processInputParams($),J=Q.data;return this._def.type._parse({data:J,path:Q.path,parent:Q})}unwrap(){return this._def.type}}class D0 extends k{_parse($){let{status:Q,ctx:J}=this._processInputParams($);if(J.common.async)return(async()=>{let W=await this._def.in._parseAsync({data:J.data,path:J.path,parent:J});if(W.status==="aborted")return f;if(W.status==="dirty")return Q.dirty(),d$(W.value);else return this._def.out._parseAsync({data:W.value,path:J.path,parent:J})})();else{let q=this._def.in._parseSync({data:J.data,path:J.path,parent:J});if(q.status==="aborted")return f;if(q.status==="dirty")return Q.dirty(),{status:"dirty",value:q.value};else return this._def.out._parseSync({data:q.value,path:J.path,parent:J})}}static create($,Q){return new D0({in:$,out:Q,typeName:V.ZodPipeline})}}class K0 extends k{_parse($){let Q=this._def.innerType._parse($),J=(q)=>{if(D$(q))q.value=Object.freeze(q.value);return q};return $0(Q)?Q.then((q)=>J(q)):J(Q)}unwrap(){return this._def.innerType}}K0.create=($,Q)=>{return new K0({innerType:$,typeName:V.ZodReadonly,...b(Q)})};function V2($,Q){let J=typeof $==="function"?$(Q):typeof $==="string"?{message:$}:$;return typeof J==="string"?{message:J}:J}function D2($,Q={},J){if($)return r$.create().superRefine((q,W)=>{let Y=$(q);if(Y instanceof Promise)return Y.then((X)=>{if(!X){let G=V2(Q,q),H=G.fatal??J??!0;W.addIssue({code:"custom",...G,fatal:H})}});if(!Y){let X=V2(Q,q),G=X.fatal??J??!0;W.addIssue({code:"custom",...X,fatal:G})}return});return r$.create()}var _5={object:p.lazycreate},V;(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"})(V||(V={}));var M5=($,Q={message:`Input not instance of ${$.name}`})=>D2((J)=>J instanceof $,Q),T2=_$.create,E2=E$.create,U5=k0.create,K5=I$.create,I2=W0.create,N5=i$.create,w5=V0.create,L5=q0.create,O5=Y0.create,F5=r$.create,A5=T$.create,S5=S$.create,z5=b0.create,R5=M$.create,j5=p.create,f5=p.strictCreate,P5=X0.create,V5=s0.create,b5=H0.create,C5=z$.create,v5=C0.create,k5=v0.create,D5=o$.create,T5=J0.create,E5=G0.create,I5=B0.create,Z5=Z$.create,g5=_0.create,y5=n$.create,m5=N$.create,h5=U$.create,x5=V$.create,u5=N$.createWithPreprocess,p5=D0.create,c5=()=>T2().optional(),l5=()=>E2().optional(),d5=()=>I2().optional(),i5={string:($)=>_$.create({...$,coerce:!0}),number:($)=>E$.create({...$,coerce:!0}),boolean:($)=>W0.create({...$,coerce:!0}),bigint:($)=>I$.create({...$,coerce:!0}),date:($)=>i$.create({...$,coerce:!0})};var r5=f;var o5=B.object({before:B.string(),after:B.string(),hierarchy:B.array(B.string()),lineStart:B.number().optional(),lineEnd:B.number().optional()}).passthrough(),x1=B.object({id:B.string(),name:B.string()}).passthrough(),n5=B.object({url:B.string(),mime:B.string().optional()}).passthrough(),u1=B.object({id:B.string(),snippet:B.string(),note:B.string(),createdAt:B.string(),filePath:B.string().optional(),canvasFile:B.string().optional(),context:o5.optional(),images:B.array(B.string()).optional(),attachments:B.array(n5).optional(),source:B.enum(["local","remote"]).optional(),author:x1.optional()}).passthrough(),a5=B.array(u1.optional().catch(void 0)).transform(($)=>$.filter((Q)=>Q!==void 0)).catch([]),p1=B.object({annotations:a5,generalNote:B.string().catch("")}).passthrough(),Z2=B.object({path:B.string()}),g2=B.object({url:B.string()}),y2=B.object({error:B.string()});import{useCallback as t9,useMemo as e9,useState as $Q}from"react";function T0($){return $.uploadUrl!==null}var c1=["image/png","image/jpeg","image/gif","image/webp"],m2="Only PNG, JPEG, GIF and WebP images can be attached";function b$($,Q){$.style.height="auto",$.style.height=(Q?Math.max(Q,$.scrollHeight):$.scrollHeight)+"px"}import{useAnnotations as e0}from"@fabrika/annotations/runtime";import{jsxDEV as LQ}from"react/jsx-dev-runtime";import{jsxDEV as RQ,Fragment as zQ}from"react/jsx-dev-runtime";import{useAnnotationHost as t5}from"@fabrika/annotations/runtime";import{useCallback as C$,useEffect as e5,useRef as d1,useState as $1}from"react";import{jsxDEV as t}from"react/jsx-dev-runtime";function h2($){if($.startsWith("/s/")||$.startsWith("http://")||$.startsWith("https://"))return $;return`/api/uploads/${$.split("/").pop()}`}async function $6($,Q){let J=$.uploadUrl;if(!J)return{error:"Uploads are not available here"};let q=new FormData;q.append("image",Q);try{let W=await fetch(J(),{method:"POST",body:q}),Y=await W.json();if(!W.ok){let X=y2.safeParse(Y);return{error:X.success?X.data.error:`Upload failed (HTTP ${W.status})`}}return{path:$.isShared?g2.parse(Y).url:Z2.parse(Y).path}}catch{return{error:"Upload failed"}}}function Q1({note:$,onNoteChange:Q,images:J,onAddImage:q,onRemoveImage:W,sessionId:Y,placeholder:X="Add your note...",autoFocus:G=!1,autoResize:H=!1,readOnly:_=!1,onKeyDown:M,onTextareaClick:N,textareaRef:O,textareaClassName:F,textareaStyle:U,minHeight:w,attachButton:S="always",openFilePickerRef:P}){let I=t5(),T=!_&&T0(I),[D,j]=$1(!1),[Z,u]=$1(!1),[e,Y$]=$1(null),[l,r]=$1(!1),o=d1(0),d=d1(null),X$=d1(null),v$=C$(()=>X$.current?.click(),[]);if(P)P.current=v$;let h$=C$((C)=>{if(d.current=C,O)O.current=C;if(C&&H)b$(C,w)},[O,H,w]);e5(()=>{if(G&&d.current){let C=d.current;if(C.focus(),C.value)C.setSelectionRange(C.value.length,C.value.length)}},[G]);let $$=C$(async(C)=>{if(!c1.includes(C.type)){Y$(m2);return}Y$(null),u(!0);try{let z=await $6(I,C);if("path"in z)q(z.path);else Y$(z.error)}finally{u(!1)}},[I,q]),H$=C$((C)=>{for(let z of C.clipboardData?.items??[])if(z.type.startsWith("image/")){C.preventDefault();let m=z.getAsFile();if(m)$$(m);return}},[$$]),w$=C$((C)=>{if(C.preventDefault(),o.current++,o.current===1)j(!0)},[]),L$=C$((C)=>{C.preventDefault()},[]),x$=C$((C)=>{if(C.preventDefault(),o.current--,o.current===0)j(!1)},[]),u$=C$((C)=>{C.preventDefault(),o.current=0,j(!1);for(let z of C.dataTransfer?.files??[])if(z.type.startsWith("image/"))$$(z)},[$$]),U1=C$((C)=>{if(Q(C.currentTarget.value),H)C.currentTarget.style.height="auto",C.currentTarget.style.height=(w?Math.max(w,C.currentTarget.scrollHeight):C.currentTarget.scrollHeight)+"px"},[Q,H,w]),K1="w-full bg-transparent text-[13px] font-body text-text-primary resize-none focus:outline-none leading-relaxed p-0 border-none",A0={width:"100%",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",outline:"none",...H?{resize:"none",overflow:"hidden"}:{resize:"vertical"}},m0=T&&(S==="always"||S==="on-focus"&&l);return t("div",{style:{position:"relative"},onDragEnter:T?w$:void 0,onDragOver:T?L$:void 0,onDragLeave:T?x$:void 0,onDrop:T?u$:void 0,children:[t("textarea",{ref:h$,value:$,onChange:_?void 0:U1,onPaste:T?H$:void 0,onKeyDown:M,onClick:N,onFocus:()=>r(!0),onBlur:()=>{setTimeout(()=>r(!1),150)},readOnly:_,placeholder:X,className:F??K1,style:U??A0,rows:H?1:void 0},void 0,!1,void 0,this),T&&t("input",{ref:X$,type:"file",accept:c1.join(","),multiple:!0,style:{display:"none"},onChange:(C)=>{let z=C.currentTarget.files;if(z)for(let m of z)$$(m);C.currentTarget.value=""}},void 0,!1,void 0,this),(J.length>0||m0)&&t("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px",alignItems:"center"},children:[J.map((C)=>t("div",{style:{position:"relative",width:"56px",height:"56px",borderRadius:"6px",overflow:"hidden",border:"1px solid var(--color-border-subtle)",flexShrink:0},children:[t("img",{src:h2(C),alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}},void 0,!1,void 0,this),!_&&t("button",{onClick:(z)=>{z.stopPropagation(),W(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)),m0&&t(J1,{onClick:v$},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Z&&t("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:"Uploading..."},void 0,!1,void 0,this),e&&t("div",{role:"alert",style:{fontSize:"11px",color:"var(--color-accent-red)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:e},void 0,!1,void 0,this),D&&t("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 J1({onClick:$,size:Q=16}){return t("button",{onClick:(J)=>{J.stopPropagation(),$()},style:{width:`${Q*2}px`,height:`${Q*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:(J)=>{J.currentTarget.style.color="var(--color-text-secondary)"},onMouseLeave:(J)=>{J.currentTarget.style.color="var(--color-text-tertiary)"},children:t("svg",{width:Q,height:Q,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[t("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},void 0,!1,void 0,this),t("circle",{cx:"8.5",cy:"8.5",r:"1.5"},void 0,!1,void 0,this),t("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 TQ}from"@fabrika/annotations/runtime";import{useContext as IQ,useEffect as ZQ,useRef as gQ}from"react";import{jsxDEV as pQ,Fragment as cQ}from"react/jsx-dev-runtime";import{SessionContext as q6,useAnnotationHost as Y6}from"@fabrika/annotations/runtime";import{useCallback as W1,useContext as X6,useEffect as H6,useMemo as c2,useRef as q1,useState as N0}from"react";import{createPortal as G6}from"react-dom";function u2($){let Q=/^(\d+(?:\.\d+)?)px$/.exec($.trim());return Q?Number(Q[1]):void 0}function p2($,Q,J=280){let W=Q||document.body,Y=$.getBoundingClientRect(),X=W.getBoundingClientRect(),G=W===document.body?0:W.scrollTop,H=Y.bottom-X.top+G+8,_=Math.max(0,Math.min(Y.left-X.left,X.width-J-12));return W.style.position="relative",{style:{position:"absolute",top:`${H}px`,left:`${_}px`},parent:W}}import{jsxDEV as a,Fragment as B6}from"react/jsx-dev-runtime";function d2({anchorEl:$,scrollContainer:Q,onClose:J,ignoreSelector:q,zIndex:W="50",padding:Y="12px",width:X="280px",children:G}){let H=q1(null),_=q1(J);_.current=J;let{style:M,parent:N}=p2($,Q,u2(X));return H6(()=>{let O=setTimeout(()=>{let F=(U)=>{if(H.current&&!H.current.contains(U.target)){if(q&&U.target.closest?.(q))return;_.current(),document.removeEventListener("mousedown",F)}};return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},0);return()=>clearTimeout(O)},[q]),G6(a("div",{ref:H,style:{...M,zIndex:W,width:X,background:"var(--color-bg-elevated)",border:"1px solid var(--color-border-hover)",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",padding:Y,fontFamily:"'Inter', sans-serif"},children:G},void 0,!1,void 0,this),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"]}],l2=i2.flatMap(($)=>$.items);function r2({anchorEl:$,scrollContainer:Q,snippet:J,truncateAt:q=100,header:W,initialNote:Y="",initialImages:X,onConfirm:G,onCancel:H,onDelete:_}){let M=X6(q6),N=Y6(),O=T0(N),F=Y!==""||!!_,[U,w]=N0(Y),[S,P]=N0(X||[]),[I,T]=N0(null),[D,j]=N0(F),[Z,u]=N0(!1),e=q1(null),Y$=q1(null),l=W1(()=>{if(U.trim()||S.length>0)G(U.trim(),S);else if(F&&_)_();else H()},[U,S,G,H,F,_]),r=W1(()=>{if(F){if(!U.trim()&&S.length===0&&_){_(),H();return}G(U,S);return}H()},[U,S,F,G,H,_]),o=!F,d=U.trim().length>0?l2.filter((z)=>z.toLowerCase().startsWith(U.trim().toLowerCase())):l2,X$=!o||D?[]:d.length===1&&d[0]?.toLowerCase()===U.trim().toLowerCase()?[]:d,v$=new Set(X$),h$=i2.map((z)=>({label:z.label,items:z.items.filter((m)=>v$.has(m))})).filter((z)=>z.items.length>0),$$=h$.map((z)=>z.items),H$=(z)=>$$[z]?.length??0,w$=$$.flat(),L$=c2(()=>{if(I===null)return 0;let z=0;for(let m=0;m<$$.length;m++){if(I<z+H$(m))return m;z+=H$(m)}return 0},[I,$$]),x$=c2(()=>{if(I===null)return 0;let z=0;for(let m=0;m<L$;m++)z+=H$(m);return I-z},[I,L$,$$]),u$=(z,m)=>{let i=0;for(let O$=0;O$<z;O$++)i+=H$(O$);return i+m},[U1,K1]=N0(U);if(U!==U1)K1(U),T(null),j(F);let A0=W1((z)=>{w(z)},[]),m0=J.length>q?J.slice(0,q)+"...":J,C=W1((z)=>{if(w$.length>0&&(z.key==="ArrowDown"||z.key==="ArrowUp"||z.key==="ArrowLeft"||z.key==="ArrowRight")){if(z.preventDefault(),I===null){T(0);return}if(z.key==="ArrowDown"){let i=Math.min(x$+1,H$(L$)-1);T(u$(L$,i))}else if(z.key==="ArrowUp"){let i=Math.max(x$-1,0);T(u$(L$,i))}else if(z.key==="ArrowRight"){let i=Math.min(L$+1,$$.length-1),O$=Math.min(x$,H$(i)-1);T(u$(i,O$))}else if(z.key==="ArrowLeft"){let i=Math.max(L$-1,0),O$=Math.min(x$,H$(i)-1);T(u$(i,O$))}return}let m=I===null?void 0:w$[I];if(m!==void 0){if(z.key==="Tab"){z.preventDefault(),A0(m);return}if(z.key==="Enter"&&!z.shiftKey){z.preventDefault(),G(m,S);return}}if(z.key==="Enter"&&!z.shiftKey){z.preventDefault(),l();return}if(z.key==="Escape")if(w$.length>0&&!D)j(!0);else if(F)r();else H()},[w$,I,x$,L$,$$,u$,A0,G,S,l,D,F,r,H]);return a(d2,{anchorEl:$,scrollContainer:Q,onClose:F?r:H,ignoreSelector:F?"[data-annotation-id]":void 0,zIndex:F?"60":"50",padding:F?"10px 12px":"12px",width:"420px",children:[!F&&(W??a("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:["“",m0,"”"]},void 0,!0,void 0,this)),a(Q1,{note:U,onNoteChange:w,images:S,onAddImage:(z)=>P((m)=>[...m,z]),onRemoveImage:(z)=>P((m)=>m.filter((i)=>i!==z)),sessionId:M,autoFocus:!0,autoResize:F,textareaRef:e,onKeyDown:C,attachButton:"none",openFilePickerRef:Y$,textareaStyle:F?{width:"100%",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",resize:"none",outline:"none",overflow:"hidden"}:{width:"100%",minHeight:"60px",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",resize:"vertical",outline:"none"},placeholder:"Add your note..."},void 0,!1,void 0,this),a("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:F?"6px":"8px"},children:[O&&a(J1,{onClick:()=>Y$.current?.(),size:14},void 0,!1,void 0,this),a("div",{style:{flex:1}},void 0,!1,void 0,this),F?a("button",{onClick:()=>{if(_)_();H()},onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),style:{fontSize:"11px",color:Z?"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):a(B6,{children:[a("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),a("button",{onClick:l,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),w$.length>0&&a("div",{style:{marginTop:"6px",borderTop:"1px solid var(--color-border-subtle)",paddingTop:"8px",display:"flex",gap:"4px"},children:h$.map((z)=>a("div",{style:{flex:1},children:[a("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:z.label},void 0,!1,void 0,this),z.items.map((m)=>{let i=w$.indexOf(m);return a("div",{onMouseDown:(O$)=>{O$.preventDefault(),O$.stopPropagation(),A0(m)},onMouseEnter:()=>T(i),style:{padding:"3px 6px",fontSize:"12px",borderRadius:"4px",fontFamily:"'Inter', sans-serif",color:i===I?"var(--color-text-primary)":"var(--color-text-secondary)",background:i===I?"var(--color-highlight-selected)":"transparent",cursor:"pointer"},children:[a("span",{style:{fontWeight:500},children:m.slice(0,U.trim().length)},void 0,!1,void 0,this),m.slice(U.trim().length)]},m,!0,void 0,this)})]},z.label,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function E0({anchorEl:$,scrollContainer:Q,snippet:J,truncateAt:q,header:W,onAdd:Y,onCancel:X}){return a(r2,{anchorEl:$,scrollContainer:Q,snippet:J,truncateAt:q,header:W,onConfirm:(G,H)=>Y(G,H),onCancel:X},void 0,!1,void 0,this)}import{useEffect as XJ,useRef as HJ,useState as GJ}from"react";import{jsxDEV as NJ}from"react/jsx-dev-runtime";import{useCallback as AJ,useEffect as SJ,useRef as zJ,useState as RJ}from"react";import{jsxDEV as kJ,Fragment as vJ}from"react/jsx-dev-runtime";import{jsxDEV as o2}from"react/jsx-dev-runtime";function w0({note:$,onChange:Q}){return o2("div",{className:"mt-1.5",children:o2("textarea",{value:$,onChange:(J)=>Q(J.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:(J)=>b$(J.currentTarget),ref:(J)=>{if(J)b$(J)}},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as c}from"react/jsx-dev-runtime";function Q4($){return $.map((Q)=>typeof Q==="string"?{value:Q,label:Q}:{value:Q.value,label:Q.label??Q.value})}function A6({id:$,label:Q,options:J,required:q}){let{responses:W,setResponse:Y}=n2();a2($);let X=t2(()=>Q4(J),[J]),G=W.get($),H=G?.value,_=G?.note||"",[M,N]=$4(!1),O=e2(null);if(!W.has($))Y($,{id:$,type:"radio",label:Q,value:null,options:X.map((w)=>w.value),required:q});let F=(w)=>{Y($,{...G,value:w})};s2(()=>{let w=O.current;if(!w)return;let S=(P)=>{let T=P.target.closest("[data-md-label]")?.getAttribute("data-md-label"),D=X.find((j)=>j.label===T);if(D)F(D.value)};return w.addEventListener("kb-select",S),()=>w.removeEventListener("kb-select",S)},[X,F]);let U=G?.required&&!H;return c("div",{ref:O,"data-md":"choice","data-md-label":Q,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[c("div",{className:"flex items-baseline gap-2 mb-2",children:[c("span",{className:"text-[13px] font-body font-medium text-text-primary",children:Q},void 0,!1,void 0,this),q&&c("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),c("div",{className:"space-y-1",children:X.map(({value:w,label:S})=>c("label",{"data-md":"choice-option","data-md-label":S,onClick:()=>F(w),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${H===w?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[c("span",{className:`w-4 h-4 rounded-full border-[1.5px] flex items-center justify-center flex-shrink-0 transition-all ${H===w?"border-accent-amber bg-accent-amber":"border-border-strong"}`,children:H===w&&c("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),c("span",{className:"text-[13px] font-body text-text-secondary",children:S},void 0,!1,void 0,this)]},w,!0,void 0,this))},void 0,!1,void 0,this),c(w0,{show:M,note:_,onToggle:()=>N(!M),onChange:(w)=>Y($,{...G,note:w})},void 0,!1,void 0,this),U&&c("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 S6({id:$,label:Q,options:J,required:q}){let{responses:W,setResponse:Y}=n2();a2($);let X=t2(()=>Q4(J),[J]),G=W.get($),H=G?.value||[],_=G?.note||"",[M,N]=$4(!1),O=e2(null);if(!W.has($))Y($,{id:$,type:"checkbox",label:Q,value:[],options:X.map((w)=>w.value),required:q});let F=(w)=>{let S=H.includes(w)?H.filter((P)=>P!==w):[...H,w];Y($,{...G,value:S})};s2(()=>{let w=O.current;if(!w)return;let S=(P)=>{let T=P.target.closest("[data-md-label]")?.getAttribute("data-md-label"),D=X.find((j)=>j.label===T);if(D)F(D.value)};return w.addEventListener("kb-select",S),()=>w.removeEventListener("kb-select",S)},[X,F]);let U=G?.required&&H.length===0;return c("div",{ref:O,"data-md":"multichoice","data-md-label":Q,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[c("div",{className:"flex items-baseline gap-2 mb-2",children:[c("span",{className:"text-[13px] font-body font-medium text-text-primary",children:Q},void 0,!1,void 0,this),q&&c("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),c("div",{className:"space-y-1",children:X.map(({value:w,label:S})=>{let P=H.includes(w);return c("label",{"data-md":"multichoice-option","data-md-label":S,onClick:()=>F(w),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${P?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[c("span",{className:`w-4 h-4 rounded flex items-center justify-center flex-shrink-0 transition-all ${P?"bg-accent-amber":"border-[1.5px] border-border-strong"}`,children:P&&c("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:c("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),c("span",{className:"text-[13px] font-body text-text-secondary",children:S},void 0,!1,void 0,this)]},w,!0,void 0,this)})},void 0,!1,void 0,this),c(w0,{show:M,note:_,onToggle:()=>N(!M),onChange:(w)=>Y($,{...G,note:w})},void 0,!1,void 0,this),U&&c("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 z6,useRef as R6}from"react";function Y1(){return window.hljs}function J4(){return window.mermaid}import{jsxDEV as X1}from"react/jsx-dev-runtime";function j6({language:$,children:Q}){let J=typeof Q==="string"?Q:String(Q??""),q=R6(null);return z6(()=>{let W=q.current,Y=Y1();if(!W||!Y)return;W.removeAttribute("data-highlighted"),W.className=$?`language-${$}`:"",W.textContent=J,Y.highlightElement(W)},[J,$]),X1("div",{className:"relative mt-3 group/code","data-md":"codeblock","data-md-language":$||"",children:[$&&X1("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),X1("pre",{className:"bg-bg-code rounded-md p-4 overflow-x-auto text-code font-mono leading-relaxed",children:X1("code",{ref:q,className:$?`language-${$}`:"",children:J},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function W4($,Q){let J=$.split(`
|
|
60
|
+
`),q=Q.split(`
|
|
61
|
+
`),W=f6(J,q),Y=[],X=0,G=0,H=0;while(X<J.length||G<q.length){let _=J[X],M=q[G];if(H<W.length&&_!==void 0&&M!==void 0&&_===W[H]&&M===W[H])Y.push({type:"same",line:_}),X++,G++,H++;else if(_!==void 0&&(H>=W.length||_!==W[H]))Y.push({type:"removed",line:_}),X++;else if(M!==void 0)Y.push({type:"added",line:M}),G++}return Y}function f6($,Q){let J=$.length,q=Q.length,W=Array.from({length:J+1},()=>Array(q+1).fill(0));for(let H=1;H<=J;H++){let _=W[H]??[],M=W[H-1]??[];for(let N=1;N<=q;N++)_[N]=$[H-1]===Q[N-1]?(M[N-1]??0)+1:Math.max(M[N]??0,_[N-1]??0)}let Y=[],X=J,G=q;while(X>0&&G>0){let H=$[X-1];if(H!==void 0&&H===Q[G-1])Y.unshift(H),X--,G--;else if((W[X-1]?.[G]??0)>(W[X]?.[G-1]??0))X--;else G--}return Y}import{jsxDEV as I0}from"react/jsx-dev-runtime";function P6({before:$,after:Q,language:J}){let q=W4($,Q);return I0("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden group/diff","data-md":"diff","data-md-language":J||"",children:[J&&I0("div",{className:"px-4 py-2 text-meta font-mono text-text-tertiary opacity-0 group-hover/diff:opacity-60 transition-opacity",children:["diff (",J,")"]},void 0,!0,void 0,this),I0("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono",children:q.map((W,Y)=>I0("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:[I0("span",{className:"select-none w-6 inline-block text-center opacity-60",children:W.type==="removed"?"-":W.type==="added"?"+":" "},void 0,!1,void 0,this),W.line]},Y,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{ActiveViewCtx as C6,SessionContext as v6}from"#canvas/runtime";import{useContext as Y4,useEffect as X4,useRef as k6,useState as H1}from"react";var V6=B.object({id:B.string(),type:B.enum(["select","radio","checkbox","text","range"]),label:B.string(),value:B.unknown(),options:B.array(B.string()).optional(),required:B.boolean().optional(),note:B.string().optional()}).passthrough().transform(($)=>({...$,value:$.value})),b6=B.object({id:B.string(),markdown:B.string(),label:B.string().optional(),required:B.boolean().optional()}).passthrough(),I7=p1.extend({responses:B.array(B.tuple([B.string(),V6]).optional().catch(void 0)).transform(($)=>$.filter((Q)=>Q!==void 0)).catch([]),feedbackEntries:B.array(B.tuple([B.string(),b6]).optional().catch(void 0)).transform(($)=>$.filter((Q)=>Q!==void 0)).optional().catch([])});var Z7=B.object({feedback:B.string().nullish()}),q4=B.union([B.object({error:B.string().min(1)}),B.object({content:B.string(),language:B.string().nullish()})]);import{jsxDEV as g$}from"react/jsx-dev-runtime";var D6={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 T6({path:$,lines:Q,__content:J}){let q=Y4(v6),{setActiveView:W}=Y4(C6),[Y,X]=H1(J??null),[G,H]=H1(()=>{let U=$.split(".").pop()||"";return D6[U]||"text"}),[_,M]=H1(null),[N,O]=H1(!J),F=k6(null);if(X4(()=>{if(J!==void 0)return;O(!0),M(null),fetch(`/api/file?session=${q}&path=${encodeURIComponent($)}`).then((U)=>U.json()).then((U)=>{let w=q4.parse(U);if("error"in w)M(w.error);else{let S=w.content;if(Q)S=S.split(`
|
|
62
|
+
`).slice(Q[0]-1,Q[1]).join(`
|
|
63
|
+
`);X(S),H(w.language||"text")}}).catch(()=>M("Failed to fetch file")).finally(()=>O(!1))},[q,$,Q?.[0],Q?.[1],J]),X4(()=>{let U=F.current,w=Y1();if(!U||!w||!Y)return;U.removeAttribute("data-highlighted"),U.className=G?`language-${G}`:"",U.textContent=Y,w.highlightElement(U)},[Y,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(_)return g$("div",{className:"text-accent-red text-body mt-3 bg-accent-red-muted rounded-md p-4",children:[$,": ",_]},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":$,...Q?{"data-md-lines":`${Q[0]}-${Q[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),Q&&g$("span",{className:"font-mono text-meta text-text-tertiary opacity-60",children:["L",Q[0],"–",Q[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:F,className:G?`language-${G}`:"",children:Y},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{SessionContext as E6}from"#canvas/runtime";import{useContext as I6,useState as Z6}from"react";import{jsxDEV as Z0}from"react/jsx-dev-runtime";function g6({src:$,alt:Q,caption:J,width:q,height:W}){let Y=I6(E6),[X,G]=Z6(!1),H=`/api/image?session=${encodeURIComponent(Y)}&path=${encodeURIComponent($)}`;if(X)return Z0("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 Z0("figure",{className:"mt-3 relative","data-md":"image","data-md-src":$,children:[Z0("div",{"data-annotation-image":!0,className:"rounded-md overflow-hidden border border-border-subtle bg-bg-code inline-block",children:Z0("img",{src:H,alt:Q||$,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),J&&Z0("figcaption",{className:"mt-1.5 text-meta text-text-tertiary font-body",children:J},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useMemo as y6}from"react";import{jsxDEV as H4}from"react/jsx-dev-runtime";g.setOptions({gfm:!0,breaks:!1});function m6({children:$,file:Q,__content:J}){let q=J??(typeof $==="string"?$:String($??"")),W=y6(()=>{if(!q)return"";return g.parse(q,{async:!1})},[q]);if(!q)return H4("div",{className:"text-text-tertiary text-tiny mt-3",children:Q?`Could not load: ${Q}`:"No markdown content"},void 0,!1,void 0,this);return H4("div",{className:"mt-3 prose-canvas","data-md":"markdown",...Q?{"data-md-file":Q}:{},"data-md-source":q,dangerouslySetInnerHTML:{__html:W}},void 0,!1,void 0,this)}import{useAnnotations as h6,useCanvasFile as x6}from"#canvas/runtime";import{useCallback as R$,useEffect as i1,useRef as g0,useState as L0}from"react";import u6 from"react-dom";import{jsxDEV as v,Fragment as M4}from"react/jsx-dev-runtime";var O0=0.2,G1=0.25,B1=4;function B4({zoom:$,onZoomIn:Q,onZoomOut:J,onZoomReset:q,onFullscreen:W}){return v("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:[v("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 out",disabled:$<=G1,children:v("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:v("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),v("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),v("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 in",disabled:$>=B1,children:v("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[v("line",{x1:"12",y1:"5",x2:"12",y2:"19"},void 0,!1,void 0,this),v("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&&v(M4,{children:[v("div",{className:"w-px h-4 bg-border-subtle mx-0.5"},void 0,!1,void 0,this),v("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:v("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[v("polyline",{points:"15 3 21 3 21 9"},void 0,!1,void 0,this),v("polyline",{points:"9 21 3 21 3 15"},void 0,!1,void 0,this),v("line",{x1:"21",y1:"3",x2:"14",y2:"10"},void 0,!1,void 0,this),v("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 _4($=1){let[Q,J]=L0($),q=R$(()=>J((X)=>Math.min(B1,+(X+O0).toFixed(2))),[]),W=R$(()=>J((X)=>Math.max(G1,+(X-O0).toFixed(2))),[]),Y=R$(()=>J(1),[]);return{zoom:Q,zoomIn:q,zoomOut:W,zoomReset:Y,setZoom:J}}function p6({svgHtml:$,source:Q,onClose:J}){let q=g0(null),{zoom:W,zoomIn:Y,zoomOut:X,zoomReset:G,setZoom:H}=_4(1),[_,M]=L0({x:0,y:0}),N=g0(null);i1(()=>{let P=(I)=>{if(I.key==="Escape")J()};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[J]);let O=R$((P)=>{P.preventDefault();let I=P.deltaY>0?-O0:O0;H((T)=>Math.max(G1,Math.min(B1,+(T+I).toFixed(2))))},[H]),F=R$((P)=>{if(P.button!==0)return;N.current={startX:P.clientX,startY:P.clientY,panX:_.x,panY:_.y},P.preventDefault()},[_]),U=R$((P)=>{if(!N.current)return;M({x:N.current.panX+(P.clientX-N.current.startX),y:N.current.panY+(P.clientY-N.current.startY)})},[]),w=R$(()=>{N.current=null},[]),S=R$(()=>{G(),M({x:0,y:0})},[G]);return u6.createPortal(v("div",{style:{position:"fixed",inset:0,zIndex:9999,background:"var(--color-bg-base)",display:"flex",flexDirection:"column"},onMouseMove:U,onMouseUp:w,onMouseLeave:w,children:[v("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:[v("span",{className:"text-body text-text-secondary",style:{fontSize:"13px"},children:"Mermaid Diagram"},void 0,!1,void 0,this),v("div",{className:"flex items-center gap-2",children:[v(B4,{zoom:W,onZoomIn:Y,onZoomOut:X,onZoomReset:S},void 0,!1,void 0,this),v("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:J,title:"Close (Esc)",children:v("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[v("line",{x1:"18",y1:"6",x2:"6",y2:"18"},void 0,!1,void 0,this),v("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),v("div",{style:{flex:1,overflow:"hidden",cursor:N.current?"grabbing":"grab"},onWheel:O,onMouseDown:F,children:v("div",{ref:q,style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",transform:`translate(${_.x}px, ${_.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 c6({children:$}){let Q=g0(null),[J,q]=L0(null),[W,Y]=L0(!1),[X,G]=L0(""),H=typeof $==="string"?$:String($??""),{annotations:_,addAnnotationWithId:M,activeAnnotationId:N,setActiveAnnotationId:O}=h6(),F=x6(),[U,w]=L0(null),{zoom:S,zoomIn:P,zoomOut:I,zoomReset:T,setZoom:D}=_4(1),j=g0(_);j.current=_;let Z=R$((l,r,o)=>{let d=`[Diagram ${o.toLowerCase()}] ${r}`,X$=j.current.find((v$)=>v$.snippet===d);if(X$)O(X$.id);else w({anchorEl:l,snippet:r,prefix:o})},[O]),u=g0(Z);u.current=Z,i1(()=>{let l=!1,r=async()=>{try{let d=J4();if(!d){q("Mermaid library not loaded");return}let X$=document.documentElement.dataset.theme==="light"?"default":"dark";d.initialize({startOnLoad:!1,theme:X$});let v$=`mermaid-${Math.random().toString(36).slice(2)}`,{svg:h$}=await d.render(v$,H.trim());if(!l&&Q.current)Q.current.innerHTML=h$,G(h$),l6(Q.current,($$,H$,w$)=>u.current($$,H$,w$)),G4(Q.current,j.current);q(null)}catch(d){if(!l)q(d instanceof Error&&d.message||"Invalid diagram")}};r();let o=new MutationObserver((d)=>{for(let X$ of d)if(X$.attributeName==="data-theme")r()});return o.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{l=!0,o.disconnect()}},[H]),i1(()=>{if(Q.current)G4(Q.current,_,N)},[_,N]);let e=R$((l)=>{if(!l.ctrlKey&&!l.metaKey)return;l.preventDefault();let r=l.deltaY>0?-O0:O0;D((o)=>Math.max(G1,Math.min(B1,+(o+r).toFixed(2))))},[D]);if(J)return v("div",{className:"bg-accent-red-muted rounded-md p-4 mt-3 text-body text-accent-red",children:["Mermaid error: ",J,v("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 Y$=Q.current?.closest("#plan-scroll-container");return v(M4,{children:[v("div",{className:"mt-3 mermaid-container","data-md":"mermaid","data-md-source":H.trim(),children:[v("div",{className:"flex justify-end mb-1",children:v(B4,{zoom:S,onZoomIn:P,onZoomOut:I,onZoomReset:T,onFullscreen:()=>Y(!0)},void 0,!1,void 0,this)},void 0,!1,void 0,this),v("div",{style:{overflow:"auto",maxHeight:"70vh"},onWheel:e,children:v("div",{ref:Q,className:"flex justify-center",style:{transform:`scale(${S})`,transformOrigin:"top center",transition:"transform 0.1s ease-out",minHeight:S<1?void 0:void 0}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),U&&v(E0,{anchorEl:U.anchorEl,scrollContainer:Y$,snippet:U.snippet,header:v("div",{style:{fontSize:"12px",color:"var(--color-text-tertiary)",marginBottom:"8px",lineHeight:"1.4",display:"flex",alignItems:"center",gap:"6px"},children:[v("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:(l,r)=>{let o=`ann-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;M(o,`[Diagram ${U.prefix.toLowerCase()}] ${U.snippet}`,l,void 0,void 0,r,F||void 0),w(null)},onCancel:()=>w(null)},void 0,!1,void 0,this),W&&X&&v(p6,{svgHtml:X,source:H,onClose:()=>Y(!1)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function l6($,Q){let J=(q,W,Y)=>{q.style.cursor="pointer",q.addEventListener("mouseenter",()=>{q.style.filter="brightness(1.2)"}),q.addEventListener("mouseleave",()=>{q.style.filter=""}),q.addEventListener("click",(X)=>{X.stopPropagation(),X.preventDefault(),Q(q,W(),Y)})};for(let q of $.querySelectorAll(".node"))J(q,()=>{return(q.querySelector(".nodeLabel")||q.querySelector("foreignObject span")||q.querySelector("text"))?.textContent?.trim()||"Node"},"Node");for(let q of $.querySelectorAll(".edgePath")){let W=q,Y=W.querySelector("path");if(Y){Y.style.strokeWidth=Math.max(parseFloat(Y.style.strokeWidth||"1"),8)+"px",Y.style.strokeOpacity="0";let G=Y.cloneNode(!0);G.style.strokeWidth="",G.style.strokeOpacity="",W.insertBefore(G,Y)}let X=W.id||"";J(W,()=>{let G=$.querySelectorAll(".edgeLabel");for(let H of G)if(H.id&&X&&H.id.replace("label","").includes(X.replace("L-","").replace("edge",""))){let _=H.textContent?.trim();if(_)return _}return"Connection"},"Edge")}for(let q of $.querySelectorAll(".edgeLabel")){let W=q.textContent?.trim();if(!W)continue;J(q,()=>W,"Edge")}for(let q of $.querySelectorAll(".actor")){let W=q.closest("g")?.querySelector("text")||q.parentElement?.querySelector("text");if(!W)continue;let Y=q.closest("g");if(!Y||Y.hasAttribute("data-clickable"))continue;Y.setAttribute("data-clickable","true"),J(Y,()=>W.textContent?.trim()||"Participant","Node")}for(let q of $.querySelectorAll(".messageText")){let W=q.textContent?.trim();if(!W)continue;J(q,()=>W,"Edge")}for(let q of $.querySelectorAll(".entityBox")){let W=q.closest("g");if(!W||W.hasAttribute("data-clickable"))continue;let Y=W.querySelector(".entityLabel");if(!Y)continue;W.setAttribute("data-clickable","true"),J(W,()=>Y.textContent?.trim()||"Entity","Node")}for(let q of $.querySelectorAll(".relationshipLabel")){let W=q.textContent?.trim();if(!W)continue;let X=q.closest("g")||q;if(X.hasAttribute("data-clickable"))continue;X.setAttribute("data-clickable","true"),J(X,()=>W,"Edge")}for(let q of $.querySelectorAll(".classGroup")){let W=q;if(W.hasAttribute("data-clickable"))continue;let Y=W.querySelector(".classTitle, .classTitleText, text");if(!Y)continue;W.setAttribute("data-clickable","true"),J(W,()=>Y.textContent?.trim()||"Class","Node")}for(let q of $.querySelectorAll(".statediagram-state")){let W=q;if(W.hasAttribute("data-clickable"))continue;let Y=W.querySelector(".state-title, text");if(!Y)continue;W.setAttribute("data-clickable","true"),J(W,()=>Y.textContent?.trim()||"State","Node")}for(let q of $.querySelectorAll(".mindmap-node")){let W=q;if(W.hasAttribute("data-clickable"))continue;let Y=W.querySelector(".mindmap-node-label, text");if(!Y)continue;W.setAttribute("data-clickable","true"),J(W,()=>Y.textContent?.trim()||"Node","Node")}}function G4($,Q,J){let q=new Map;for(let Y of Q){let X=Y.snippet.match(/^\[Diagram (?:node|edge)\] (.+)$/)?.[1];if(X)q.set(X,Y.id)}for(let Y of $.querySelectorAll("[data-annotated]"))Y.style.outline="",Y.style.outlineOffset="",Y.style.borderRadius="",Y.removeAttribute("data-annotated");if(q.size===0)return;for(let Y of $.querySelectorAll(".node")){let G=(Y.querySelector(".nodeLabel")||Y.querySelector("foreignObject span")||Y.querySelector("text"))?.textContent?.trim();if(!G||!q.has(G))continue;let H=q.get(G),_=Y;_.setAttribute("data-annotated",H);let M=H===J;_.style.outline=M?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",_.style.outlineOffset="2px",_.style.borderRadius="4px"}for(let Y of $.querySelectorAll(".edgeLabel")){let X=Y.textContent?.trim();if(!X||!q.has(X))continue;let G=q.get(X),H=Y;H.setAttribute("data-annotated",G);let _=G===J;H.style.outline=_?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",H.style.outlineOffset="2px",H.style.borderRadius="4px"}for(let Y of $.querySelectorAll(".actor")){let X=Y.closest("g");if(!X)continue;let H=X.querySelector("text")?.textContent?.trim();if(!H||!q.has(H))continue;if(X.hasAttribute("data-annotated"))continue;let _=q.get(H);X.setAttribute("data-annotated",_);let M=_===J,N=X.querySelector("rect");if(N)N.style.outline=M?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",N.style.outlineOffset="2px",N.style.borderRadius="4px"}for(let Y of $.querySelectorAll(".messageText")){let X=Y.textContent?.trim();if(!X||!q.has(X))continue;let G=q.get(X),H=Y;H.setAttribute("data-annotated",G);let _=G===J;H.style.outline=_?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",H.style.outlineOffset="2px",H.style.borderRadius="4px"}let W=(Y,X,G)=>{for(let H of $.querySelectorAll(Y)){let _=G(H);if(!_||_.hasAttribute("data-annotated"))continue;let N=_.querySelector(X)?.textContent?.trim();if(!N||!q.has(N))continue;let O=q.get(N);_.setAttribute("data-annotated",O);let F=O===J,U=_.querySelector("rect, circle, ellipse, polygon")||_;U.style.outline=F?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",U.style.outlineOffset="2px",U.style.borderRadius="4px"}};W(".entityBox",".entityLabel",(Y)=>Y.closest("g"));for(let Y of $.querySelectorAll(".relationshipLabel")){let G=Y.closest("g")||Y;if(G.hasAttribute("data-annotated"))continue;let H=Y.textContent?.trim();if(!H||!q.has(H))continue;let _=q.get(H);G.setAttribute("data-annotated",_);let M=_===J;G.style.outline=M?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",G.style.outlineOffset="2px",G.style.borderRadius="4px"}W(".classGroup",".classTitle, .classTitleText, text",(Y)=>Y),W(".statediagram-state",".state-title, text",(Y)=>Y),W(".mindmap-node",".mindmap-node-label, text",(Y)=>Y)}import{jsxDEV as i6}from"react/jsx-dev-runtime";function d6({children:$}){return i6("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:k$($)},void 0,!1,void 0,this)}import{jsxDEV as n6}from"react/jsx-dev-runtime";var r6={high:"text-accent-red bg-accent-red-muted",medium:"text-accent-amber bg-accent-amber-muted",low:"text-text-tertiary bg-border-subtle"};function o6({level:$}){return n6("span",{className:`inline text-tiny font-medium font-body ml-2 px-1.5 py-0.5 rounded ${r6[$]}`,"data-md":"priority","data-md-level":$,children:$},void 0,!1,void 0,this)}import{useState as a6}from"react";import{jsxDEV as a$}from"react/jsx-dev-runtime";function s6({title:$,children:Q}){let[J,q]=a6(!1);return a$("div",{className:"relative mb-8 p-4 group/section","data-md":"section","data-md-title":$,children:[a$("div",{className:"relative mb-2",children:[a$("button",{onClick:()=>q(!J),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 ${J?"-rotate-90":""}`,children:a$("svg",{width:"14",height:"14",viewBox:"0 0 12 12",fill:"none",children:a$("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),a$("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),a$("div",{className:J?"mt-6 hidden":"mt-6",children:k$(Q)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as y$}from"react/jsx-dev-runtime";function t6({headers:$,rows:Q}){return y$("div",{className:"overflow-x-auto mt-3","data-md":"table",children:y$("table",{className:"w-full text-body",children:[y$("thead",{children:y$("tr",{className:"border-b border-border-subtle",children:$.map((J,q)=>y$("th",{className:"text-left px-4 py-2.5 text-meta font-medium uppercase tracking-wider text-text-tertiary font-body",children:J},q,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),y$("tbody",{children:Q.map((J,q)=>y$("tr",{className:`relative border-b border-border-subtle last:border-b-0 transition-colors hover:bg-bg-surface/50 ${q%2===1?"bg-bg-surface/30":""}`,children:J.map((W,Y)=>y$("td",{className:"px-4 py-2.5 text-text-secondary font-body",children:W},Y,!1,void 0,this))},q,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as j$}from"react/jsx-dev-runtime";var e6={todo:"bg-border-hover",done:"bg-accent-green",blocked:"bg-accent-red","in-progress":"bg-accent-blue"},$8={todo:"Todo",done:"Done",blocked:"Blocked","in-progress":"In progress"},Q8={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 U4({id:$,label:Q,status:J,badge:q,badgeVariant:W="neutral",children:Y}){return j$("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":Q,...J?{"data-md-status":J}:{},...q?{"data-md-badge":q}:{},children:j$("div",{className:"flex items-start gap-3",children:[J&&j$("span",{className:`w-2 h-2 rounded-full mt-[7px] flex-shrink-0 ${e6[J]}`},void 0,!1,void 0,this),j$("div",{className:"flex-1 min-w-0",children:[j$("div",{className:"flex items-baseline gap-2",children:[j$("span",{className:"font-body text-task-label font-semibold text-text-primary",children:Q},void 0,!1,void 0,this),J&&j$("span",{className:"font-body text-tiny uppercase tracking-wider text-text-tertiary opacity-0 group-hover/task:opacity-100 transition-opacity duration-150",children:$8[J]},void 0,!1,void 0,this),q&&j$("span",{className:`font-body text-tiny font-medium px-1.5 py-px rounded-full ${Q8[W]}`,children:q},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Y&&j$("div",{className:"text-body text-text-secondary mt-1 leading-relaxed",children:k$(Y)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function J8($){return j$(U4,{...$},void 0,!1,void 0,this)}import{useAnnotations as K4,useResponseRegistration as N4}from"#canvas/runtime";import{useRef as W8,useState as w4}from"react";import{jsxDEV as x}from"react/jsx-dev-runtime";function q8({id:$,label:Q,placeholder:J,multiline:q,required:W}){let{responses:Y,setResponse:X}=K4();N4($);let G=Y.get($),H=G?.value??"",_=G?.note||"",[M,N]=w4(!1),O=W8(null);if(!Y.has($))X($,{id:$,type:"text",label:Q,value:"",required:W});let F=(S)=>{X($,{...G,value:S})},U=(S)=>b$(S,q?60:32),w=G?.required&&!H.trim();return x("div",{"data-md":"userinput","data-md-label":Q,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:Q},void 0,!1,void 0,this),W&&x("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),x("textarea",{ref:O,value:H,onChange:(S)=>{F(S.currentTarget.value),U(S.currentTarget)},placeholder:J||"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:(S)=>U(S.currentTarget),onFocus:(S)=>U(S.currentTarget)},void 0,!1,void 0,this),x(w0,{show:M,note:_,onToggle:()=>N(!M),onChange:(S)=>X($,{...G,note:S})},void 0,!1,void 0,this),w&&x("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 Y8({id:$,label:Q,min:J=1,max:q=10,step:W=1,required:Y,minLabel:X,maxLabel:G}){let{responses:H,setResponse:_}=K4();N4($);let M=H.get($),N=M?.value,O=M?.note||"",[F,U]=w4(!1);if(!H.has($))_($,{id:$,type:"range",label:Q,value:null,required:Y});let w=(Z)=>{_($,{...M,value:Z})},S=N!==null&&N!==void 0,P=S?N:Math.round((J+q)/2),I=(P-J)/(q-J)*100,T=Math.round((q-J)/W),D=T<=20,j=M?.required&&!S;return x("div",{"data-md":"rangeinput","data-md-label":Q,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 justify-between mb-1",children:[x("div",{className:"flex items-baseline gap-2",children:[x("span",{className:"text-[13px] font-body font-medium text-text-primary",children:Q},void 0,!1,void 0,this),Y&&x("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),x("span",{className:"flex items-center gap-1.5",children:[x("span",{className:`text-[13px] font-mono ${S?"text-accent-amber":"text-text-disabled"}`,children:S?N:"—"},void 0,!1,void 0,this),S&&x("button",{onClick:()=>_($,{...M,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),x("div",{className:"relative h-6 flex items-center",children:[x("div",{className:"absolute left-0 right-0 h-1.5 rounded-full bg-border-medium",children:S&&x("div",{className:"h-full rounded-full bg-accent-amber transition-all duration-150",style:{width:`${I}%`}},void 0,!1,void 0,this)},void 0,!1,void 0,this),D&&Array.from({length:T+1},(Z,u)=>{let e=J+u*W,Y$=(e-J)/(q-J)*100,l=S&&e<=N;return x("div",{className:`absolute rounded-full pointer-events-none transition-all duration-150 ${S&&e===N?"w-2.5 h-2.5 bg-accent-amber":l?"w-1.5 h-1.5 bg-accent-amber":"w-1.5 h-1.5 bg-border-hover"}`,style:{left:`${Y$}%`,transform:"translate(-50%, -50%)",top:"50%"}},u,!1,void 0,this)}),S?x("div",{className:"absolute h-5 w-5 rounded-full bg-accent-amber shadow-md pointer-events-none transition-all duration-150",style:{left:`calc(${I}% - 10px)`,borderWidth:"2px",borderStyle:"solid",borderColor:"var(--color-bg-base)"}},void 0,!1,void 0,this):x("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),x("input",{type:"range",min:J,max:q,step:W,value:P,onChange:(Z)=>w(Number(Z.currentTarget.value)),className:"absolute inset-0 w-full opacity-0 cursor-pointer"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),D&&T<=10?x("div",{className:"flex justify-between -mt-0.5 px-0",children:Array.from({length:T+1},(Z,u)=>{let e=J+u*W;return x("span",{className:`text-[10px] font-mono transition-colors ${S&&e===N?"text-accent-amber font-medium":"text-text-disabled"}`,style:{minWidth:"1ch",textAlign:"center"},children:e},u,!1,void 0,this)})},void 0,!1,void 0,this):x("div",{className:"flex justify-between -mt-0.5",children:[x("span",{className:"text-[11px] text-text-tertiary font-body",children:X||J},void 0,!1,void 0,this),x("span",{className:"text-[11px] text-text-tertiary font-body",children:G||q},void 0,!1,void 0,this)]},void 0,!0,void 0,this),x(w0,{show:F,note:O,onToggle:()=>U(!F),onChange:(Z)=>_($,{...M,note:Z})},void 0,!1,void 0,this),j&&x("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 r1=26214400,L4=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/,o1=B.object({id:B.string(),name:B.string(),path:B.string(),size:B.number().int()});var O4=B.object({shareId:B.string(),url:B.string(),revision:B.number(),createdAt:B.string(),ownerToken:B.string().optional(),expiresAt:B.string().optional(),lastFeedbackAt:B.string().optional(),encryptionKey:B.string().optional()}),X8=B.object({revision:B.number(),label:B.string().optional(),canvasFiles:B.array(B.object({filename:B.string(),diffStats:B.object({added:B.number(),removed:B.number()}).optional()})),createdAt:B.string(),hasFeedback:B.boolean(),feedbackConsumed:B.boolean(),response:B.string().optional()}).passthrough(),H8=B.object({encryption:B.object({alg:B.literal("AES-GCM"),v:B.literal(1)}).optional(),origin:B.object({sessionId:B.string().optional(),label:B.string().optional(),revision:B.number().optional(),createdAt:B.string().optional()}).optional(),currentRevision:B.number().optional(),revisions:B.array(X8).optional(),canvasFiles:B.array(B.string()).optional(),projectRoot:B.string().optional(),shares:B.array(O4).optional(),shareEnabled:B.boolean().optional()}).passthrough(),nW=B.object({entries:B.array(B.object({name:B.string(),type:B.enum(["file","dir"])}))}),G8=B.object({id:B.string(),shareId:B.string(),revision:B.number(),submittedAt:B.string(),author:x1,annotations:B.array(u1.omit({source:!0,author:!0})),generalNote:B.string().optional()}),aW=B.object({entries:B.array(G8)}),sW=B.union([B.object({ok:B.literal(!0),share:O4}),B.object({ok:B.literal(!1).optional(),error:B.string().optional()})]),tW=B.union([B.object({ok:B.literal(!0)}),B.object({ok:B.literal(!1).optional(),error:B.string().optional()})]);async function F4($){let Q=B8($);return crypto.subtle.importKey("raw",Q,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}async function A4($,Q){let J=S4(Q);if(J.byteLength<28)throw Error("Ciphertext too short");let q=J.subarray(0,12),W=J.subarray(12),Y=await crypto.subtle.decrypt({name:"AES-GCM",iv:q},$,W);return new TextDecoder().decode(Y)}function S4($){let Q=atob($),J=new Uint8Array(Q.length);for(let q=0;q<Q.length;q++)J[q]=Q.charCodeAt(q);return J}function B8($){let Q=$.replace(/-/g,"+").replace(/_/g,"/")+"===".slice(($.length+3)%4);return S4(Q)}function _8($){let Q;try{Q=new URL($)}catch{return!1}if(Q.protocol!=="http:"&&Q.protocol!=="https:")return!1;return Q.hostname==="localhost"||Q.hostname==="127.0.0.1"||Q.hostname==="[::1]"||Q.hostname.endsWith(".localhost")}var m$=B.string().max(500),M8=4000,U8=1000,K8=1000,N8=B.object({label:m$,file:B.string().max(U8),line:B.number().int().positive(),column:B.number().int().nonnegative()}),R4=B.object({url:B.string().min(1).max(2000),selector:B.string().max(2000),role:m$.optional(),name:m$.optional(),text:m$.optional(),components:B.array(B.string().max(200)).max(20).optional(),sources:B.array(N8).max(10).optional(),context:m$.optional(),browser:B.object({name:m$,viewport:B.object({width:B.number().int().nonnegative(),height:B.number().int().nonnegative(),scale:B.number().positive()}),colorScheme:B.enum(["light","dark"])}).optional(),style:B.string().max(K8).optional(),html:B.string().max(M8).optional(),quote:B.object({exact:B.string().min(1).max(2000),before:m$,after:m$}).optional()}),w8=B.enum(["user","agent"]),n1=B.object({id:B.string(),author:w8,body:B.string().min(1).max(20000),createdAt:B.string()}),a1=B.enum(["open","queued","working","resolved"]),L8=B.object({id:B.string(),anchor:R4,state:a1,comments:B.array(n1).min(1),screenshot:B.string().optional(),createdAt:B.string(),updatedAt:B.string()}),Jq=B.object({threads:B.array(L8)}),s1=B.string().trim().min(1).max(20000),z4="data:image/png;base64,",O8=B.string().startsWith(z4).max(8000000).transform(($)=>Uint8Array.from(atob($.slice(z4.length)),(Q)=>Q.charCodeAt(0))),Wq=B.object({anchor:R4,body:s1,send:B.boolean(),screenshot:O8.optional()}),qq=B.object({body:s1,send:B.boolean()}),Yq=B.object({body:s1,resolve:B.boolean()}),j4=B.string().url().refine(($)=>_8($),"must be an http(s) URL on localhost"),Xq=B.object({target:j4}),Hq=B.object({target:j4,port:B.number().int().min(1).max(65535)});var y0=B.object({id:B.string(),state:a1,revision:B.number().int(),snippet:B.string(),canvasFile:B.string().optional(),filePath:B.string().optional(),comments:B.array(n1),createdAt:B.string(),updatedAt:B.string()}),Fq=B.object({threads:B.array(y0)}),f4=B.string().trim().min(1).max(20000),Aq=B.object({body:f4,resolve:B.boolean()}),Sq=B.object({body:f4}),zq=B.object({resolved:B.boolean()});var F8=B.object({threads:B.array(y0)}),A8=B.object({thread:y0});async function P4($){let Q=await $.json().catch(()=>null),J=B.object({error:B.string()}).safeParse(Q);return Error(J.success?J.data.error:`Thread request failed with status ${$.status}`)}function S8($,Q){let J=new Map(Q.map((Y)=>[Y.id,Y])),q=$.map((Y)=>{let X=J.get(Y.id);return X!==void 0&&X.updatedAt>=Y.updatedAt?X:Y}),W=new Set($.map((Y)=>Y.id));return[...q,...Q.filter((Y)=>!W.has(Y.id))]}function V4($){let Q=[],J=new Set,q=`/api/session/${encodeURIComponent($)}/threads`,W=(X)=>{Q=S8(Q,X);for(let G of J)G()},Y=async(X,G)=>{let H=await fetch(`${q}/${X}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(G)});if(!H.ok)throw await P4(H);W([A8.parse(await H.json()).thread])};return{subscribe(X){return J.add(X),()=>J.delete(X)},current:()=>Q,async load(){let X=await fetch(q,{cache:"no-store"});if(!X.ok)throw await P4(X);W(F8.parse(await X.json()).threads)},receive(X){let G=B.array(y0).safeParse(X);if(G.success)W(G.data)},reply:(X,G)=>Y(`${encodeURIComponent(X)}/comments`,{body:G}),setResolved:(X,G)=>Y(`${encodeURIComponent(X)}/resolved`,{resolved:G})}}function z8(){if(typeof window>"u")return null;let $=window.location.hash.replace(/^#/,"");if(!$)return null;for(let Q of $.split("&")){let[J,q]=Q.split("=");if(J==="k"&&q)return decodeURIComponent(q)}return null}function R8(){if(typeof window<"u"&&window.__CANVAS_SHARE__?.shareId){let Q=z8();return{isShared:!0,shareId:window.__CANVAS_SHARE__.shareId,encryptionKey:Q?F4(Q):null}}return{isShared:!1,sessionId:typeof window<"u"?window.location.pathname.replace("/s/",""):""}}var h=R8();function j8(){return h.isShared&&h.encryptionKey!==null}function f8(){return h.isShared?h.shareId:h.sessionId}function P8($,Q){let J=$.replace(/\.jsx$/,".js");if(h.isShared)return`/s/${h.shareId}/canvas/${encodeURIComponent(J)}`;let q=Q?`?rev=${Q}&t=${Date.now()}`:`?t=${Date.now()}`;return`/api/session/${h.sessionId}/canvas/${encodeURIComponent(J)}${q}`}function V8(){if(h.isShared)return`/s/${h.shareId}/upload`;return`/api/session/${h.sessionId}/upload`}function t1($,Q){if(h.isShared)throw Error("Secret inputs are available only on the local canvas daemon");return`/api/session/${encodeURIComponent(h.sessionId)}/secrets/${encodeURIComponent($)}/${Q}`}async function F0($){let Q=await $.json().catch(()=>null);if(typeof Q==="object"&&Q!==null&&"error"in Q&&typeof Q.error==="string")return Error(Q.error);return Error(`Request failed with status ${$.status}`)}function e1($,Q){if(h.isShared)throw Error("File drops are available only on the local canvas daemon");let J=`/api/session/${encodeURIComponent(h.sessionId)}/assets/${encodeURIComponent($)}`;return Q===void 0?J:`${J}/${encodeURIComponent(Q)}`}async function b4($){let Q=await fetch(e1($),{cache:"no-store"});if(!Q.ok)throw await F0(Q);return B.object({files:B.array(o1)}).parse(await Q.json()).files}async function C4($,Q){let J=new FormData;J.append("file",Q);let q=await fetch(e1($),{method:"POST",body:J});if(!q.ok)throw await F0(q);return B.object({file:o1}).parse(await q.json()).file}async function v4($,Q){let J=await fetch(e1($,Q),{method:"DELETE"});if(!J.ok)throw await F0(J)}async function k4($){let Q=await fetch(t1($,"status"),{cache:"no-store"});if(!Q.ok)throw await F0(Q);let J=await Q.json();return typeof J==="object"&&J!==null&&"ready"in J&&J.ready===!0}async function D4($,Q){let J=await fetch(t1($,"value"),{method:"POST",headers:{"Content-Type":"application/json"},cache:"no-store",body:JSON.stringify({value:Q})});if(!J.ok)throw await F0(J)}async function T4($){let Q=await fetch(t1($,"value"),{method:"DELETE",cache:"no-store"});if(!Q.ok)throw await F0(Q)}var b8=async($,Q)=>{let J=P8($,Q);if(!j8())return import(J);let q=await fetch(J);if(!q.ok)throw Error(`canvas ${q.status}`);let W=await q.text(),Y=await h.encryptionKey,X=await A4(Y,W),G=new Blob([X],{type:"application/javascript"}),H=URL.createObjectURL(G);try{return await import(H)}finally{setTimeout(()=>URL.revokeObjectURL(H),0)}};var C8=!h.isShared,Eq=!h.isShared,v8=h.isShared?null:V4(h.sessionId),Iq={get sessionId(){return f8()},isShared:h.isShared,fsAvailable:C8,uploadUrl:V8,loadCanvasModule:b8,threads:v8};import{jsxDEV as $2}from"react/jsx-dev-runtime";function k8({path:$,label:Q}){let J=$.split("/").pop()||"download";if(h.isShared)return $2("p",{className:"text-[13px] font-body text-text-tertiary my-2",children:[Q||J," (download available only on the canvas author's machine)"]},void 0,!0,void 0,this);let q=`/api/download?session=${encodeURIComponent(h.sessionId)}&path=${encodeURIComponent($)}`;return $2("a",{href:q,download:J,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:[$2("span",{"aria-hidden":"true",children:"↓"},void 0,!1,void 0,this),Q||J]},void 0,!0,void 0,this)}import{useFeedback as D8}from"#canvas/runtime";import{useEffect as T8,useState as _1}from"react";import{jsxDEV as J$}from"react/jsx-dev-runtime";function Q2($){if($<1024)return`${$} B`;if($<1048576)return`${($/1024).toFixed(1)} KB`;return`${($/1024/1024).toFixed(1)} MB`}function E8({id:$,label:Q,accept:J,maxBytes:q,required:W}){let[Y,X]=_1([]),[G,H]=_1(!h.isShared),[_,M]=_1(null),[N,O]=_1(!1),F=L4.test($),U=!h.isShared,w=W===!0&&U&&F,S=Math.min(q??r1,r1);T8(()=>{if(!U||!F){H(!1);return}let j=!0;return b4($).then((Z)=>{if(j)X(Z)}).catch((Z)=>{if(j)M(Z instanceof Error?Z.message:"Could not read the files")}).finally(()=>{if(j)H(!1)}),()=>{j=!1}},[$,U,F]);let P=Y.length===0?"":`**${Q}**
|
|
64
|
+
${Y.map((j)=>`- \`${j.path}\` (${j.name}, ${Q2(j.size)})`).join(`
|
|
65
|
+
`)}
|
|
66
|
+
`;D8(`files:${$}`,P,{label:Q,required:w});let I=async(j)=>{if(j.length===0)return;if(G){M("Wait until the current upload finishes");return}let Z=j.filter((u)=>u.size>S);if(Z.length>0){M(`${Z.map((u)=>u.name).join(", ")}: larger than ${Q2(S)}`);return}H(!0),M(null);try{for(let u of j){let e=await C4($,u);X((Y$)=>[...Y$,e])}}catch(u){M(u instanceof Error?u.message:"Could not upload the file")}finally{H(!1)}},T=async(j)=>{H(!0),M(null);try{await v4($,j.id),X((Z)=>Z.filter((u)=>u.id!==j.id))}catch(Z){M(Z instanceof Error?Z.message:"Could not remove the file")}finally{H(!1)}},D=`file-drop-${$}`;return J$("div",{"data-md":"filedrop","data-md-label":Q,className:"-mx-4 px-4 py-3 my-1 rounded-lg",children:[J$("div",{className:"flex items-baseline gap-2 mb-2",children:[J$("label",{htmlFor:D,className:"text-[13px] font-body font-medium text-text-primary",children:Q},void 0,!1,void 0,this),w&&J$("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!F&&J$("p",{className:"text-[12px] text-accent-red font-body",children:"Invalid field ID."},void 0,!1,void 0,this),!U&&J$("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&&F&&J$("div",{onDragOver:(j)=>{j.preventDefault(),O(!0)},onDragLeave:(j)=>{if(j.relatedTarget instanceof Node&&j.currentTarget.contains(j.relatedTarget))return;O(!1)},onDrop:(j)=>{j.preventDefault(),O(!1),I([...j.dataTransfer?.files??[]])},className:`rounded-lg border border-dashed px-3 py-4 text-center text-[13px] font-body ${N?"border-accent-blue bg-accent-blue-muted":"border-border-medium bg-bg-input"}`,children:[J$("span",{className:"text-text-secondary",children:"Drop files here or"},void 0,!1,void 0,this)," ",J$("input",{id:D,type:"file",multiple:!0,accept:J,disabled:G,onChange:(j)=>{let Z=[...j.currentTarget.files??[]];j.currentTarget.value="",I(Z)},className:"text-[12px] text-text-secondary"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Y.length>0&&J$("ul",{className:"mt-2 space-y-1",children:Y.map((j)=>J$("li",{className:"flex items-center justify-between gap-2 text-[13px] font-body text-text-primary",children:[J$("span",{className:"truncate",title:j.path,children:[j.name," · ",Q2(j.size)]},void 0,!0,void 0,this),J$("button",{type:"button",disabled:G,onClick:()=>void T(j),className:"text-[12px] text-text-tertiary hover:text-text-secondary",children:"Remove"},void 0,!1,void 0,this)]},j.id,!0,void 0,this))},void 0,!1,void 0,this),_&&J$("p",{role:"alert",className:"text-[12px] text-accent-red font-body mt-1",children:_},void 0,!1,void 0,this),w&&Y.length===0&&J$("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 I8}from"#canvas/runtime";import{useEffect as Z8,useState as M1}from"react";import{jsxDEV as W$}from"react/jsx-dev-runtime";var g8=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/,y8=/^[A-Za-z_][A-Za-z0-9_]*$/;function m8({id:$,label:Q,env:J,placeholder:q,required:W}){let[Y,X]=M1(""),[G,H]=M1(!1),[_,M]=M1(!h.isShared),[N,O]=M1(null),F=g8.test($),U=y8.test(J),w=!h.isShared;Z8(()=>{if(!w||!F){M(!1);return}let D=!0;return k4($).then((j)=>{if(D)H(j)}).catch((j)=>{if(D)O(j instanceof Error?j.message:"Could not read secret status")}).finally(()=>{if(D)M(!1)}),()=>{D=!1}},[$,w,F]);let S=G?`**${Q}**
|
|
67
|
+
Secret is ready. Field: \`${$}\`. Environment variable: \`${J}\`.
|
|
68
|
+
`:"";I8(`secret:${$}`,S,{label:Q,required:W&&w});let P=async()=>{if(!Y||!F||!U)return;M(!0),O(null);try{await D4($,Y),X(""),H(!0)}catch(D){O(D instanceof Error?D.message:"Could not store secret")}finally{M(!1)}},I=async()=>{M(!0),O(null);try{await T4($),H(!1)}catch(D){O(D instanceof Error?D.message:"Could not clear secret")}finally{M(!1)}};if(!w)return W$("div",{"data-md":"secretinput","data-md-label":Q,className:"-mx-4 px-4 py-3 my-1 rounded-lg bg-accent-amber-muted",children:[W$("div",{className:"text-[13px] font-body font-medium text-text-primary",children:Q},void 0,!1,void 0,this),W$("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 T=!F?"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 W$("div",{"data-md":"secretinput","data-md-label":Q,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[W$("div",{className:"flex items-baseline justify-between gap-3 mb-2",children:[W$("div",{className:"flex items-baseline gap-2",children:[W$("span",{className:"text-[13px] font-body font-medium text-text-primary",children:Q},void 0,!1,void 0,this),W&&W$("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W$("span",{className:`text-[11px] font-body ${G?"text-accent-green":"text-text-tertiary"}`,children:_?"Working…":G?"Ready in memory":"Not stored"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),W$("div",{className:"flex gap-2",children:[W$("input",{type:"password",value:Y,onChange:(D)=>X(D.target.value),onKeyDown:(D)=>{if(D.key==="Enter")D.preventDefault(),P()},placeholder:q||"Paste secret value",autoComplete:"off",spellCheck:!1,disabled:_||!!T,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),W$("button",{type:"button",onClick:()=>void P(),disabled:_||!Y||!!T,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&&W$("button",{type:"button",onClick:()=>void I(),disabled:_,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),W$("p",{className:"text-[11px] font-body text-text-tertiary mt-1.5",children:["Stored only in daemon memory. The agent receives field ",$," for ",J,", not the value."]},void 0,!0,void 0,this),(T||N)&&W$("p",{className:"text-[11px] text-accent-red font-body mt-1",children:T||N},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}export{vW as useFeedback,q8 as UserInput,J8 as Task,t6 as Table,s6 as Section,m8 as SecretInput,Y8 as RangeInput,o6 as Priority,d6 as Note,S6 as MultiChoice,c6 as Mermaid,m6 as Markdown,U4 as Item,g6 as ImageView,T6 as FilePreview,E8 as FileDrop,k8 as Download,P6 as Diff,j6 as CodeBlock,A6 as Choice,D3 as Checklist,k3 as Callout};
|