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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,68 +1,68 @@
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={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},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],`
1
+ import{useFeedback as Xp}from"#canvas/runtime";function vn(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var Ve=vn();function xr(e){Ve=e}var Ue={exec:()=>null};function z(e,t=""){let n=typeof e=="string"?e:e.source,s={replace:(r,o)=>{let a=typeof o=="string"?o:o.source;return a=a.replace(se.caret,"$1"),n=n.replace(r,a),s},getRegex:()=>new RegExp(n,t)};return s}var js=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),se={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:(e)=>new RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:(e)=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:(e)=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:(e)=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:(e)=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:(e)=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:(e)=>new RegExp(`^ {0,${Math.min(3,e-1)}}>`)},Ds=/^(?:[ \t]*(?:\n|$))+/,zs=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Hs=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,mt=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Bs=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,kn=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,yr=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,br=z(yr).replace(/bull/g,kn).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Fs=z(yr).replace(/bull/g,kn).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),wn=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Us=/^[^\n]+/,_n=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,qs=z(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",_n).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Vs=z(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,kn).getRegex(),Ft="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",Sn=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,Ws=z("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",Sn).replace("tag",Ft).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),vr=z(wn).replace("hr",mt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ft).getRegex(),Gs=z(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",vr).getRegex(),Tn={blockquote:Gs,code:zs,def:qs,fences:Hs,heading:Bs,hr:mt,html:Ws,lheading:br,list:Vs,newline:Ds,paragraph:vr,table:Ue,text:Us},ur=z("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",mt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ft).getRegex(),Ks={...Tn,lheading:Fs,table:ur,paragraph:z(wn).replace("hr",mt).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ur).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",Ft).getRegex()},Ys={...Tn,html:z(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",Sn).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:Ue,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:z(wn).replace("hr",mt).replace("heading",` *#{1,6} *[^
2
+ ]`).replace("lheading",br).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Js=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Xs=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,kr=/^( {2,}|\\)\n(?!\s*$)/,Qs=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,Je=/[\p{P}\p{S}]/u,Ut=/[\s\p{P}\p{S}]/u,An=/[^\s\p{P}\p{S}]/u,Zs=z(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,Ut).getRegex(),wr=/(?!~)[\p{P}\p{S}]/u,eo=/(?!~)[\s\p{P}\p{S}]/u,to=/(?:[^\s\p{P}\p{S}]|~)/u,no=z(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",js?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),_r=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,ro=z(_r,"u").replace(/punct/g,Je).getRegex(),so=z(_r,"u").replace(/punct/g,wr).getRegex(),Sr="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",oo=z(Sr,"gu").replace(/notPunctSpace/g,An).replace(/punctSpace/g,Ut).replace(/punct/g,Je).getRegex(),ao=z(Sr,"gu").replace(/notPunctSpace/g,to).replace(/punctSpace/g,eo).replace(/punct/g,wr).getRegex(),io=z("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,An).replace(/punctSpace/g,Ut).replace(/punct/g,Je).getRegex(),lo=z(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,Je).getRegex(),co="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",uo=z(co,"gu").replace(/notPunctSpace/g,An).replace(/punctSpace/g,Ut).replace(/punct/g,Je).getRegex(),po=z(/\\(punct)/,"gu").replace(/punct/g,Je).getRegex(),fo=z(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),ho=z(Sn).replace("(?:-->|$)","-->").getRegex(),mo=z("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",ho).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),zt=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,go=z(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",zt).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Tr=z(/^!?\[(label)\]\[(ref)\]/).replace("label",zt).replace("ref",_n).getRegex(),Ar=z(/^!?\[(ref)\](?:\[\])?/).replace("ref",_n).getRegex(),xo=z("reflink|nolink(?!\\()","g").replace("reflink",Tr).replace("nolink",Ar).getRegex(),pr=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Rn={_backpedal:Ue,anyPunctuation:po,autolink:fo,blockSkip:no,br:kr,code:Xs,del:Ue,delLDelim:Ue,delRDelim:Ue,emStrongLDelim:ro,emStrongRDelimAst:oo,emStrongRDelimUnd:io,escape:Js,link:go,nolink:Ar,punctuation:Zs,reflink:Tr,reflinkSearch:xo,tag:mo,text:Qs,url:Ue},yo={...Rn,link:z(/^!?\[(label)\]\((.*?)\)/).replace("label",zt).getRegex(),reflink:z(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",zt).getRegex()},bn={...Rn,emStrongRDelimAst:ao,emStrongLDelim:so,delLDelim:lo,delRDelim:uo,url:z(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",pr).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:z(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",pr).getRegex()},bo={...bn,br:z(kr).replace("{2,}","*").getRegex(),text:z(bn.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},Dt={normal:Tn,gfm:Ks,pedantic:Ys},pt={normal:Rn,gfm:bn,breaks:bo,pedantic:yo},vo={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},fr=(e)=>vo[e];function ye(e,t){if(t){if(se.escapeTest.test(e))return e.replace(se.escapeReplace,fr)}else if(se.escapeTestNoEncode.test(e))return e.replace(se.escapeReplaceNoEncode,fr);return e}function hr(e){try{e=encodeURI(e).replace(se.percentDecode,"%")}catch{return null}return e}function mr(e,t){let n=e.replace(se.findPipe,(o,a,l)=>{let i=!1,c=a;for(;--c>=0&&l[c]==="\\";)i=!i;return i?"|":" |"}),s=n.split(se.splitPipe),r=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),t)if(s.length>t)s.splice(t);else for(;s.length<t;)s.push("");for(;r<s.length;r++)s[r]=s[r].trim().replace(se.slashPipe,"|");return s}function ft(e,t,n){let s=e.length;if(s===0)return"";let r=0;for(;r<s;){let o=e.charAt(s-r-1);if(o===t&&!n)r++;else if(o!==t&&n)r++;else break}return e.slice(0,s-r)}function ko(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let s=0;s<e.length;s++)if(e[s]==="\\")s++;else if(e[s]===t[0])n++;else if(e[s]===t[1]&&(n--,n<0))return s;return n>0?-2:-1}function wo(e,t=0){let n=t,s="";for(let r of e)if(r==="\t"){let o=4-n%4;s+=" ".repeat(o),n+=o}else s+=r,n++;return s}function gr(e,t,n,s,r){let o=t.href,a=t.title||null,l=e[1].replace(r.other.outputLinkReplace,"$1");s.state.inLink=!0;let i={type:e[0].charAt(0)==="!"?"image":"link",raw:n,href:o,title:a,text:l,tokens:s.inlineTokens(l)};return s.state.inLink=!1,i}function _o(e,t,n){let s=e.match(n.other.indentCodeCompensation);if(s===null)return t;let r=s[1];return t.split(`
3
+ `).map((o)=>{let a=o.match(n.other.beginningSpace);if(a===null)return o;let[l]=a;return l.length>=r.length?o.slice(r.length):o}).join(`
4
+ `)}var Ht=class{options;rules;lexer;constructor(e){this.options=e||Ve}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:ft(n,`
5
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],s=_o(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:s}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let s=ft(n,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(n=s.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:ft(t[0],`
6
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=ft(t[0],`
7
7
  `).split(`
8
- `),q="",W="",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
- $1`).replace(this.rules.other.blockquoteSetextReplace2,"");q=q?`${q}
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(`
8
+ `),s="",r="",o=[];for(;n.length>0;){let a=!1,l=[],i;for(i=0;i<n.length;i++)if(this.rules.other.blockquoteStart.test(n[i]))l.push(n[i]),a=!0;else if(!a)l.push(n[i]);else break;n=n.slice(i);let c=l.join(`
9
+ `),d=c.replace(this.rules.other.blockquoteSetextReplace,`
10
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
11
+ ${c}`:c,r=r?`${r}
12
+ ${d}`:d;let f=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(d,o,!0),this.lexer.state.top=f,n.length===0)break;let g=o.at(-1);if(g?.type==="code")break;if(g?.type==="blockquote"){let x=g,u=x.raw+`
13
+ `+n.join(`
14
+ `),h=this.blockquote(u);o[o.length-1]=h,s=s.substring(0,s.length-x.raw.length)+h.raw,r=r.substring(0,r.length-x.text.length)+h.text;break}else if(g?.type==="list"){let x=g,u=x.raw+`
15
+ `+n.join(`
16
+ `),h=this.list(u);o[o.length-1]=h,s=s.substring(0,s.length-g.raw.length)+h.raw,r=r.substring(0,r.length-x.raw.length)+h.raw,n=u.substring(o.at(-1).raw.length).split(`
17
+ `);continue}}return{type:"blockquote",raw:s,tokens:o,text:r}}}list(e){let t=this.rules.block.list.exec(e);if(t){let n=t[1].trim(),s=n.length>1,r={type:"list",raw:"",ordered:s,start:s?+n.slice(0,-1):"",loose:!1,items:[]};n=s?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=s?n:"[*+-]");let o=this.rules.other.listItemRegex(n),a=!1;for(;e;){let i=!1,c="",d="";if(!(t=o.exec(e))||this.rules.block.hr.test(e))break;c=t[0],e=e.substring(c.length);let f=wo(t[2].split(`
18
+ `,1)[0],t[1].length),g=e.split(`
19
+ `,1)[0],x=!f.trim(),u=0;if(this.options.pedantic?(u=2,d=f.trimStart()):x?u=t[1].length+1:(u=f.search(this.rules.other.nonSpaceChar),u=u>4?1:u,d=f.slice(u),u+=t[1].length),x&&this.rules.other.blankLine.test(g)&&(c+=g+`
20
+ `,e=e.substring(g.length+1),i=!0),!i){let h=this.rules.other.nextBulletRegex(u),y=this.rules.other.hrRegex(u),T=this.rules.other.fencesBeginRegex(u),O=this.rules.other.headingBeginRegex(u),M=this.rules.other.htmlBeginRegex(u),I=this.rules.other.blockquoteBeginRegex(u);for(;e;){let _=e.split(`
21
+ `,1)[0],j;if(g=_,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),j=g):j=g.replace(this.rules.other.tabCharGlobal," "),T.test(g)||O.test(g)||M.test(g)||I.test(g)||h.test(g)||y.test(g))break;if(j.search(this.rules.other.nonSpaceChar)>=u||!g.trim())d+=`
22
+ `+j.slice(u);else{if(x||f.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||T.test(f)||O.test(f)||y.test(f))break;d+=`
23
+ `+g}x=!g.trim(),c+=_+`
24
+ `,e=e.substring(_.length+1),f=j.slice(u)}}r.loose||(a?r.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(a=!0)),r.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(d),loose:!1,text:d,tokens:[]}),r.raw+=c}let l=r.items.at(-1);if(l)l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let i of r.items){if(this.lexer.state.top=!1,i.tokens=this.lexer.blockTokens(i.text,[]),i.task){if(i.text=i.text.replace(this.rules.other.listReplaceTask,""),i.tokens[0]?.type==="text"||i.tokens[0]?.type==="paragraph"){i.tokens[0].raw=i.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),i.tokens[0].text=i.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let d=this.lexer.inlineQueue.length-1;d>=0;d--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[d].src)){this.lexer.inlineQueue[d].src=this.lexer.inlineQueue[d].src.replace(this.rules.other.listReplaceTask,"");break}}let c=this.rules.other.listTaskCheckbox.exec(i.raw);if(c){let d={type:"checkbox",raw:c[0]+" ",checked:c[0]!=="[ ]"};i.checked=d.checked,r.loose?i.tokens[0]&&["paragraph","text"].includes(i.tokens[0].type)&&"tokens"in i.tokens[0]&&i.tokens[0].tokens?(i.tokens[0].raw=d.raw+i.tokens[0].raw,i.tokens[0].text=d.raw+i.tokens[0].text,i.tokens[0].tokens.unshift(d)):i.tokens.unshift({type:"paragraph",raw:d.raw,text:d.raw,tokens:[d]}):i.tokens.unshift(d)}}if(!r.loose){let c=i.tokens.filter((f)=>f.type==="space"),d=c.length>0&&c.some((f)=>this.rules.other.anyLine.test(f.raw));r.loose=d}}if(r.loose)for(let i of r.items){i.loose=!0;for(let c of i.tokens)c.type==="text"&&(c.type="paragraph")}return r}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:"html",block:!0,raw:t[0],pre:t[1]==="pre"||t[1]==="script"||t[1]==="style",text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let n=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=t[2]?t[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):t[3];return{type:"def",tag:n,raw:t[0],href:s,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=mr(t[1]),s=t[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,"").split(`
25
+ `):[],o={type:"table",raw:t[0],header:[],align:[],rows:[]};if(n.length===s.length){for(let a of s)this.rules.other.tableAlignRight.test(a)?o.align.push("right"):this.rules.other.tableAlignCenter.test(a)?o.align.push("center"):this.rules.other.tableAlignLeft.test(a)?o.align.push("left"):o.align.push(null);for(let a=0;a<n.length;a++)o.header.push({text:n[a],tokens:this.lexer.inline(n[a]),header:!0,align:o.align[a]});for(let a of r)o.rows.push(mr(a,o.header.length).map((l,i)=>({text:l,tokens:this.lexer.inline(l),header:!1,align:o.align[i]})));return o}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t){let n=t[1].trim();return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:n,tokens:this.lexer.inline(n)}}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===`
26
+ `?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let o=ft(n.slice(0,-1),"\\");if((n.length-o.length)%2===0)return}else{let o=ko(t[2],"()");if(o===-2)return;if(o>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+o;t[2]=t[2].substring(0,o),t[0]=t[0].substring(0,a).trim(),t[3]=""}}let s=t[2],r="";if(this.options.pedantic){let o=this.rules.other.pedanticHrefTitle.exec(s);o&&(s=o[1],r=o[3])}else r=t[3]?t[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?s=s.slice(1):s=s.slice(1,-1)),gr(t,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let s=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=t[s.toLowerCase()];if(!r){let o=n[0].charAt(0);return{type:"text",raw:o,text:o}}return gr(n,r,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!s||!s[1]&&!s[2]&&!s[3]&&!s[4]||s[4]&&n.match(this.rules.other.unicodeAlphaNumeric))return;if(!(s[1]||s[3])||!n||this.rules.inline.punctuation.exec(n)){let r=[...s[0]].length-1,o,a,l=r,i=0,c=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+r);(s=c.exec(t))!==null;){if(o=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!o)continue;if(a=[...o].length,s[3]||s[4]){l+=a;continue}else if((s[5]||s[6])&&r%3&&!((r+a)%3)){i+=a;continue}if(l-=a,l>0)continue;a=Math.min(a,a+l+i);let d=[...s[0]][0].length,f=e.slice(0,r+s.index+d+a);if(Math.min(r,a)%2){let x=f.slice(1,-1);return{type:"em",raw:f,text:x,tokens:this.lexer.inlineTokens(x)}}let g=f.slice(2,-2);return{type:"strong",raw:f,text:g,tokens:this.lexer.inlineTokens(g)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(n),r=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return s&&r&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e,t,n=""){let s=this.rules.inline.delLDelim.exec(e);if(!s)return;if(!s[1]||!n||this.rules.inline.punctuation.exec(n)){let r=[...s[0]].length-1,o,a,l=r,i=this.rules.inline.delRDelim;for(i.lastIndex=0,t=t.slice(-1*e.length+r);(s=i.exec(t))!==null;){if(o=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!o||(a=[...o].length,a!==r))continue;if(s[3]||s[4]){l+=a;continue}if(l-=a,l>0)continue;a=Math.min(a,a+l);let c=[...s[0]][0].length,d=e.slice(0,r+s.index+c+a),f=d.slice(r,-r);return{type:"del",raw:d,text:f,tokens:this.lexer.inlineTokens(f)}}}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,s;return t[2]==="@"?(n=t[1],s="mailto:"+n):(n=t[1],s=n),{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,s;if(t[2]==="@")n=t[0],s="mailto:"+n;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(r!==t[0]);n=t[0],t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}},pe=class e{tokens;options;state;inlineQueue;tokenizer;constructor(t){this.tokens=[],this.tokens.links=Object.create(null),this.options=t||Ve,this.options.tokenizer=this.options.tokenizer||new Ht,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let n={other:se,block:Dt.normal,inline:pt.normal};this.options.pedantic?(n.block=Dt.pedantic,n.inline=pt.pedantic):this.options.gfm&&(n.block=Dt.gfm,this.options.breaks?n.inline=pt.breaks:n.inline=pt.gfm),this.tokenizer.rules=n}static get rules(){return{block:Dt,inline:pt}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(t){t=t.replace(se.carriageReturn,`
27
+ `),this.blockTokens(t,this.tokens);for(let n=0;n<this.inlineQueue.length;n++){let s=this.inlineQueue[n];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(t,n=[],s=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(t=t.replace(se.tabCharGlobal," ").replace(se.spaceLine,""));t;){let r;if(this.options.extensions?.block?.some((a)=>(r=a.call({lexer:this},t,n))?(t=t.substring(r.raw.length),n.push(r),!0):!1))continue;if(r=this.tokenizer.space(t)){t=t.substring(r.raw.length);let a=n.at(-1);r.raw.length===1&&a!==void 0?a.raw+=`
28
+ `:n.push(r);continue}if(r=this.tokenizer.code(t)){t=t.substring(r.raw.length);let a=n.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
29
29
  `)?"":`
30
- `)+W.raw,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(`
30
+ `)+r.raw,a.text+=`
31
+ `+r.text,this.inlineQueue.at(-1).src=a.text):n.push(r);continue}if(r=this.tokenizer.fences(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.heading(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.hr(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.blockquote(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.list(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.html(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.def(t)){t=t.substring(r.raw.length);let a=n.at(-1);a?.type==="paragraph"||a?.type==="text"?(a.raw+=(a.raw.endsWith(`
32
32
  `)?"":`
33
- `)+W.raw,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(`
33
+ `)+r.raw,a.text+=`
34
+ `+r.raw,this.inlineQueue.at(-1).src=a.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},n.push(r));continue}if(r=this.tokenizer.table(t)){t=t.substring(r.raw.length),n.push(r);continue}if(r=this.tokenizer.lheading(t)){t=t.substring(r.raw.length),n.push(r);continue}let o=t;if(this.options.extensions?.startBlock){let a=1/0,l=t.slice(1),i;this.options.extensions.startBlock.forEach((c)=>{i=c.call({lexer:this},l),typeof i=="number"&&i>=0&&(a=Math.min(a,i))}),a<1/0&&a>=0&&(o=t.substring(0,a+1))}if(this.state.top&&(r=this.tokenizer.paragraph(o))){let a=n.at(-1);s&&a?.type==="paragraph"?(a.raw+=(a.raw.endsWith(`
35
35
  `)?"":`
36
- `)+W.raw,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(`
36
+ `)+r.raw,a.text+=`
37
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):n.push(r),s=o.length!==t.length,t=t.substring(r.raw.length);continue}if(r=this.tokenizer.text(t)){t=t.substring(r.raw.length);let a=n.at(-1);a?.type==="text"?(a.raw+=(a.raw.endsWith(`
38
38
  `)?"":`
39
- `)+W.raw,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
- `}blockquote({tokens:$}){return`<blockquote>
44
- ${this.parser.parse($)}</blockquote>
45
- `}html({text:$}){return $}def($){return""}heading({tokens:$,depth:Q}){return`<h${Q}>${this.parser.parseInline($)}</h${Q}>
46
- `}hr($){return`<hr>
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
- `+q+"</"+W+`>
49
- `}listitem($){return`<li>${this.parser.parse($.tokens)}</li>
50
- `}checkbox({checked:$}){return"<input "+($?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:$}){return`<p>${this.parser.parseInline($)}</p>
51
- `}table($){let 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>
39
+ `)+r.raw,a.text+=`
40
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):n.push(r);continue}if(t){let a="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(a);break}else throw Error(a)}}return this.state.top=!0,n}inline(t,n=[]){return this.inlineQueue.push({src:t,tokens:n}),n}inlineTokens(t,n=[]){this.tokenizer.lexer=this;let s=t,r=null;if(this.tokens.links){let i=Object.keys(this.tokens.links);if(i.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(s))!==null;)i.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(s))!==null;)s=s.slice(0,r.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let o;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(s))!==null;)o=r[2]?r[2].length:0,s=s.slice(0,r.index+o)+"["+"a".repeat(r[0].length-o-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);s=this.options.hooks?.emStrongMask?.call({lexer:this},s)??s;let a=!1,l="";for(;t;){a||(l=""),a=!1;let i;if(this.options.extensions?.inline?.some((d)=>(i=d.call({lexer:this},t,n))?(t=t.substring(i.raw.length),n.push(i),!0):!1))continue;if(i=this.tokenizer.escape(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.tag(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.link(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.reflink(t,this.tokens.links)){t=t.substring(i.raw.length);let d=n.at(-1);i.type==="text"&&d?.type==="text"?(d.raw+=i.raw,d.text+=i.text):n.push(i);continue}if(i=this.tokenizer.emStrong(t,s,l)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.codespan(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.br(t)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.del(t,s,l)){t=t.substring(i.raw.length),n.push(i);continue}if(i=this.tokenizer.autolink(t)){t=t.substring(i.raw.length),n.push(i);continue}if(!this.state.inLink&&(i=this.tokenizer.url(t))){t=t.substring(i.raw.length),n.push(i);continue}let c=t;if(this.options.extensions?.startInline){let d=1/0,f=t.slice(1),g;this.options.extensions.startInline.forEach((x)=>{g=x.call({lexer:this},f),typeof g=="number"&&g>=0&&(d=Math.min(d,g))}),d<1/0&&d>=0&&(c=t.substring(0,d+1))}if(i=this.tokenizer.inlineText(c)){t=t.substring(i.raw.length),i.raw.slice(-1)!=="_"&&(l=i.raw.slice(-1)),a=!0;let d=n.at(-1);d?.type==="text"?(d.raw+=i.raw,d.text+=i.text):n.push(i);continue}if(t){let d="Infinite loop on byte: "+t.charCodeAt(0);if(this.options.silent){console.error(d);break}else throw Error(d)}}return n}},Bt=class{options;parser;constructor(e){this.options=e||Ve}space(e){return""}code({text:e,lang:t,escaped:n}){let s=(t||"").match(se.notSpaceStart)?.[0],r=e.replace(se.endingNewline,"")+`
41
+ `;return s?'<pre><code class="language-'+ye(s)+'">'+(n?r:ye(r,!0))+`</code></pre>
42
+ `:"<pre><code>"+(n?r:ye(r,!0))+`</code></pre>
43
+ `}blockquote({tokens:e}){return`<blockquote>
44
+ ${this.parser.parse(e)}</blockquote>
45
+ `}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
46
+ `}hr(e){return`<hr>
47
+ `}list(e){let{ordered:t,start:n}=e,s="";for(let a=0;a<e.items.length;a++){let l=e.items[a];s+=this.listitem(l)}let r=t?"ol":"ul",o=t&&n!==1?' start="'+n+'"':"";return"<"+r+o+`>
48
+ `+s+"</"+r+`>
49
+ `}listitem(e){return`<li>${this.parser.parse(e.tokens)}</li>
50
+ `}checkbox({checked:e}){return"<input "+(e?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
51
+ `}table(e){let t="",n="";for(let r=0;r<e.header.length;r++)n+=this.tablecell(e.header[r]);t+=this.tablerow({text:n});let s="";for(let r=0;r<e.rows.length;r++){let o=e.rows[r];n="";for(let a=0;a<o.length;a++)n+=this.tablecell(o[a]);s+=this.tablerow({text:n})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
52
52
  <thead>
53
- `+Q+`</thead>
54
- `+q+`</table>
55
- `}tablerow({text:$}){return`<tr>
56
- ${$}</tr>
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(`
53
+ `+t+`</thead>
54
+ `+s+`</table>
55
+ `}tablerow({text:e}){return`<tr>
56
+ ${e}</tr>
57
+ `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
58
+ `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${ye(e,!0)}</code>`}br(e){return"<br>"}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let s=this.parser.parseInline(n),r=hr(e);if(r===null)return s;e=r;let o='<a href="'+e+'"';return t&&(o+=' title="'+ye(t)+'"'),o+=">"+s+"</a>",o}image({href:e,title:t,text:n,tokens:s}){s&&(n=this.parser.parseInline(s,this.parser.textRenderer));let r=hr(e);if(r===null)return ye(n);e=r;let o=`<img src="${e}" alt="${ye(n)}"`;return t&&(o+=` title="${ye(t)}"`),o+=">",o}text(e){return"tokens"in e&&e.tokens?this.parser.parseInline(e.tokens):("escaped"in e)&&e.escaped?e.text:ye(e.text)}},En=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return""+e}image({text:e}){return""+e}br(){return""}checkbox({raw:e}){return e}},fe=class e{options;renderer;textRenderer;constructor(t){this.options=t||Ve,this.options.renderer=this.options.renderer||new Bt,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new En}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(t){this.renderer.parser=this;let n="";for(let s=0;s<t.length;s++){let r=t[s];if(this.options.extensions?.renderers?.[r.type]){let a=r,l=this.options.extensions.renderers[a.type].call({parser:this},a);if(l!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(a.type)){n+=l||"";continue}}let o=r;switch(o.type){case"space":{n+=this.renderer.space(o);break}case"hr":{n+=this.renderer.hr(o);break}case"heading":{n+=this.renderer.heading(o);break}case"code":{n+=this.renderer.code(o);break}case"table":{n+=this.renderer.table(o);break}case"blockquote":{n+=this.renderer.blockquote(o);break}case"list":{n+=this.renderer.list(o);break}case"checkbox":{n+=this.renderer.checkbox(o);break}case"html":{n+=this.renderer.html(o);break}case"def":{n+=this.renderer.def(o);break}case"paragraph":{n+=this.renderer.paragraph(o);break}case"text":{n+=this.renderer.text(o);break}default:{let a='Token with "'+o.type+'" type was not found.';if(this.options.silent)return console.error(a),"";throw Error(a)}}}return n}parseInline(t,n=this.renderer){this.renderer.parser=this;let s="";for(let r=0;r<t.length;r++){let o=t[r];if(this.options.extensions?.renderers?.[o.type]){let l=this.options.extensions.renderers[o.type].call({parser:this},o);if(l!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(o.type)){s+=l||"";continue}}let a=o;switch(a.type){case"escape":{s+=n.text(a);break}case"html":{s+=n.html(a);break}case"link":{s+=n.link(a);break}case"image":{s+=n.image(a);break}case"checkbox":{s+=n.checkbox(a);break}case"strong":{s+=n.strong(a);break}case"em":{s+=n.em(a);break}case"codespan":{s+=n.codespan(a);break}case"br":{s+=n.br(a);break}case"del":{s+=n.del(a);break}case"text":{s+=n.text(a);break}default:{let l='Token with "'+a.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw Error(l)}}}return s}},ht=class{options;block;constructor(e){this.options=e||Ve}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(e=this.block){return e?pe.lex:pe.lexInline}provideParser(e=this.block){return e?fe.parse:fe.parseInline}},So=class{defaults=vn();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=fe;Renderer=Bt;TextRenderer=En;Lexer=pe;Tokenizer=Ht;Hooks=ht;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let s of e)switch(n=n.concat(t.call(this,s)),s.type){case"table":{let r=s;for(let o of r.header)n=n.concat(this.walkTokens(o.tokens,t));for(let o of r.rows)for(let a of o)n=n.concat(this.walkTokens(a.tokens,t));break}case"list":{let r=s;n=n.concat(this.walkTokens(r.items,t));break}default:{let r=s;this.defaults.extensions?.childTokens?.[r.type]?this.defaults.extensions.childTokens[r.type].forEach((o)=>{let a=r[o].flat(1/0);n=n.concat(this.walkTokens(a,t))}):r.tokens&&(n=n.concat(this.walkTokens(r.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach((n)=>{let s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach((r)=>{if(!r.name)throw Error("extension name required");if("renderer"in r){let o=t.renderers[r.name];o?t.renderers[r.name]=function(...a){let l=r.renderer.apply(this,a);return l===!1&&(l=o.apply(this,a)),l}:t.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw Error("extension level must be 'block' or 'inline'");let o=t[r.level];o?o.unshift(r.tokenizer):t[r.level]=[r.tokenizer],r.start&&(r.level==="block"?t.startBlock?t.startBlock.push(r.start):t.startBlock=[r.start]:r.level==="inline"&&(t.startInline?t.startInline.push(r.start):t.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(t.childTokens[r.name]=r.childTokens)}),s.extensions=t),n.renderer){let r=this.defaults.renderer||new Bt(this.defaults);for(let o in n.renderer){if(!(o in r))throw Error(`renderer '${o}' does not exist`);if(["options","parser"].includes(o))continue;let a=o,l=n.renderer[a],i=r[a];r[a]=(...c)=>{let d=l.apply(r,c);return d===!1&&(d=i.apply(r,c)),d||""}}s.renderer=r}if(n.tokenizer){let r=this.defaults.tokenizer||new Ht(this.defaults);for(let o in n.tokenizer){if(!(o in r))throw Error(`tokenizer '${o}' does not exist`);if(["options","rules","lexer"].includes(o))continue;let a=o,l=n.tokenizer[a],i=r[a];r[a]=(...c)=>{let d=l.apply(r,c);return d===!1&&(d=i.apply(r,c)),d}}s.tokenizer=r}if(n.hooks){let r=this.defaults.hooks||new ht;for(let o in n.hooks){if(!(o in r))throw Error(`hook '${o}' does not exist`);if(["options","block"].includes(o))continue;let a=o,l=n.hooks[a],i=r[a];ht.passThroughHooks.has(o)?r[a]=(c)=>{if(this.defaults.async&&ht.passThroughHooksRespectAsync.has(o))return(async()=>{let f=await l.call(r,c);return i.call(r,f)})();let d=l.call(r,c);return i.call(r,d)}:r[a]=(...c)=>{if(this.defaults.async)return(async()=>{let f=await l.apply(r,c);return f===!1&&(f=await i.apply(r,c)),f})();let d=l.apply(r,c);return d===!1&&(d=i.apply(r,c)),d}}s.hooks=r}if(n.walkTokens){let r=this.defaults.walkTokens,o=n.walkTokens;s.walkTokens=function(a){let l=[];return l.push(o.call(this,a)),r&&(l=l.concat(r.call(this,a))),l}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return pe.lex(e,t??this.defaults)}parser(e,t){return fe.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let s={...n},r={...this.defaults,...s},o=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&s.async===!1)return o(Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||t===null)return o(Error("marked(): input parameter is undefined or null"));if(typeof t!="string")return o(Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=e),r.async)return(async()=>{let a=r.hooks?await r.hooks.preprocess(t):t,l=await(r.hooks?await r.hooks.provideLexer(e):e?pe.lex:pe.lexInline)(a,r),i=r.hooks?await r.hooks.processAllTokens(l):l;r.walkTokens&&await Promise.all(this.walkTokens(i,r.walkTokens));let c=await(r.hooks?await r.hooks.provideParser(e):e?fe.parse:fe.parseInline)(i,r);return r.hooks?await r.hooks.postprocess(c):c})().catch(o);try{r.hooks&&(t=r.hooks.preprocess(t));let a=(r.hooks?r.hooks.provideLexer(e):e?pe.lex:pe.lexInline)(t,r);r.hooks&&(a=r.hooks.processAllTokens(a)),r.walkTokens&&this.walkTokens(a,r.walkTokens);let l=(r.hooks?r.hooks.provideParser(e):e?fe.parse:fe.parseInline)(a,r);return r.hooks&&(l=r.hooks.postprocess(l)),l}catch(a){return o(a)}}}onError(e,t){return(n)=>{if(n.message+=`
59
+ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error occurred:</p><pre>"+ye(n.message+"",!0)+"</pre>";return t?Promise.resolve(s):s}if(t)return Promise.reject(n);throw n}}},qe=new So;function D(e,t){return qe.parse(e,t)}D.options=D.setOptions=function(e){return qe.setOptions(e),D.defaults=qe.defaults,xr(D.defaults),D};D.getDefaults=vn;D.defaults=Ve;D.use=function(...e){return qe.use(...e),D.defaults=qe.defaults,xr(D.defaults),D};D.walkTokens=function(e,t){return qe.walkTokens(e,t)};D.parseInline=qe.parseInline;D.Parser=fe;D.parser=fe.parse;D.Renderer=Bt;D.TextRenderer=En;D.Lexer=pe;D.lexer=pe.lex;D.Tokenizer=Ht;D.Hooks=ht;D.parse=D;var{options:tl,setOptions:nl,use:rl,walkTokens:sl,parseInline:ol}=D;var al=fe.parse,il=pe.lex;import Rr from"react";import{jsxDEV as Cn}from"react/jsx-dev-runtime";D.setOptions({gfm:!0,breaks:!1});var To=new Set(["a","abbr","b","br","code","del","em","i","kbd","mark","q","s","small","span","strong","sub","sup","time","u"]),Ao=new Set(["Priority"]);function Ro(e){if(typeof e==="string"||typeof e==="number")return!0;if(!Rr.isValidElement(e))return!1;if(typeof e!=="object"||e===null||!("type"in e))return!1;let t=e.type;if(typeof t==="string")return To.has(t);if(typeof t==="function"){let n="displayName"in t&&typeof t.displayName==="string"?t.displayName:t.name;return n?Ao.has(n):!1}return!1}function Eo(e,t){let n=e.trim();if(!n)return null;let s=D.parse(n,{async:!1});return Cn("div",{className:"prose-canvas","data-md":"markdown","data-md-source":n,dangerouslySetInnerHTML:{__html:s}},t,!1,void 0,this)}function Co(e,t){return Cn("div",{className:"prose-canvas",children:e.map((n,s)=>{if(typeof n==="string"||typeof n==="number"){let r=D.parseInline(String(n),{async:!1});return Cn("span",{dangerouslySetInnerHTML:{__html:r}},s,!1,void 0,this)}return n})},t,!1,void 0,this)}function Me(e){let t=Rr.Children.toArray(e);if(t.length===0)return null;let n=[],s=[],r=0,o=()=>{if(s.length===0)return;if(s.some((l)=>typeof l!=="string"&&typeof l!=="number"))n.push(Co(s,`md-${r++}`));else{let l=Eo(s.join(""),`md-${r++}`);if(l)n.push(l)}s=[]};for(let a of t)if(Ro(a))s.push(a);else o(),n.push(a);return o(),n}import{jsxDEV as Nn}from"react/jsx-dev-runtime";var No={info:{bg:"bg-accent-blue-muted",icon:"i",iconColor:"text-accent-blue"},warning:{bg:"bg-accent-amber-muted",icon:"!",iconColor:"text-accent-amber"},danger:{bg:"bg-accent-red-muted",icon:"✕",iconColor:"text-accent-red"},tip:{bg:"bg-accent-green-muted",icon:"✓",iconColor:"text-accent-green"}};function Io({type:e="info",children:t}){let n=No[e];return Nn("div",{className:`${n.bg} relative rounded-lg px-5 py-4 mt-3 flex gap-3 items-start`,"data-md":"callout","data-md-type":e,children:[Nn("span",{"aria-hidden":"true",className:`${n.iconColor} opacity-70 text-base leading-relaxed flex-shrink-0 mt-px`,children:n.icon},void 0,!1,void 0,this),Nn("div",{className:"text-body text-text-secondary leading-relaxed",children:Me(t)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as Xe}from"react/jsx-dev-runtime";function Lo({items:e}){return Xe("ul",{className:"space-y-1 mt-3","data-md":"checklist",children:e.map((t,n)=>Xe("li",{"data-md":"checklist-item","data-md-label":t.label,className:"relative flex items-start gap-2.5 py-1",children:[Xe("span",{className:`w-4 h-4 rounded-full flex items-center justify-center flex-shrink-0 mt-0.5 transition-all ${t.checked?"bg-accent-green":"border-[1.5px] border-border-hover"}`,children:t.checked&&Xe("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:Xe("path",{d:"M2.5 5L4.5 7L7.5 3",style:{stroke:"var(--color-text-inverse)"},strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Xe("span",{className:`text-body font-body ${t.checked?"text-text-tertiary line-through decoration-border-hover":"text-text-secondary"}`,children:t.label},void 0,!1,void 0,this)]},n,!0,void 0,this))},void 0,!1,void 0,this)}import{useAnnotations as Zr,useResponseRegistration as es}from"#canvas/runtime";import{useEffect as ts,useMemo as ns,useRef as rs,useState as ss}from"react";import{AnnotationCtx as hu,AnnotationHostContext as mu,SessionContext as gu,useAnnotationHost as xu,useAnnotations as yu}from"@fabrika/annotations/runtime";function In(e,t){let n=[],s=Mo(e);for(let r of s){let o=document.createRange();if(o.selectNodeContents(r),r===e.startContainer)o.setStart(r,e.startOffset);if(r===e.endContainer)o.setEnd(r,e.endOffset);let a=o.toString();if(!a||!a.trim())continue;let l=document.createElement("mark");l.setAttribute("data-annotation-id",t);try{o.surroundContents(l)}catch{let i=o.extractContents();l.appendChild(i),o.insertNode(l)}n.push(l)}return n}function Ln(e){let t=e.parentElement;if(t?.classList.contains("select-none"))return!1;if(t?.closest("[data-annotation-id]"))return!1;return!0}function Mo(e){let t=[],n=e.commonAncestorContainer;if(n.nodeType===Node.TEXT_NODE)return t.push(n),t;let s=document.createTreeWalker(n,NodeFilter.SHOW_TEXT),r;while(r=s.nextNode()){if(!Ln(r))continue;if(e.intersectsNode(r))t.push(r)}return t}function Mn(e,t){for(let n of t){if(e.querySelector(`[data-annotation-id="${n.id}"]`))continue;let s=n.snippet;if(!s)continue;let{fullText:r,textNodes:o}=$o(e),a=[],l=0;while(!0){let u=r.indexOf(s,l);if(u===-1)break;a.push(u),l=u+1}let[i]=a;if(i===void 0)continue;let c=i;if(a.length>1&&n.context){let u=-1;for(let h of a){let y=0;if(n.context.before){let T=r.slice(Math.max(0,h-80),h);if(T.includes(n.context.before))y+=2;else if(n.context.before.length>10&&T.includes(n.context.before.slice(-10)))y+=1}if(n.context.after){let T=r.slice(h+s.length,h+s.length+80);if(T.includes(n.context.after))y+=2;else if(n.context.after.length>10&&T.includes(n.context.after.slice(0,10)))y+=1}if(y>u)u=y,c=h}}let d=c,f=c+s.length,g=Er(o,d),x=Er(o,f);if(!g||!x)continue;try{let u=document.createRange();u.setStart(g.node,g.offset),u.setEnd(x.node,x.offset),In(u,n.id)}catch{}}}function $o(e){let t=[],n="",s=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),r;while(r=s.nextNode()){if(!Ln(r))continue;t.push({node:r,start:n.length}),n+=r.textContent||""}return{fullText:n,textNodes:t}}function Er(e,t){for(let n=e.length-1;n>=0;n--){let s=e[n];if(!s||s.start>t)continue;let r=t-s.start,o=s.node.textContent?.length??0;if(r<=o)return{node:s.node,offset:r}}return null}function gt(e){return{kind:e.kind,owns:(t)=>e.parse(t)!==null,find:(t,n)=>{let s=e.parse(t);return s===null?null:e.find(s,n)},restore:(t,n)=>{let s=e.parse(n.snippet);if(s===null)return;e.restore?.(s,t,n)},describe:(t)=>{let n=e.parse(t);if(n===null||!e.describe)return null;return e.describe(n)}}}function Cr(e){let t=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),n="";for(let s=t.nextNode();s;s=t.nextNode()){let r=s.parentElement?.closest("[aria-hidden='true']");if(r&&e.contains(r))continue;n+=s.textContent??""}return n.trim()}function qt(e,t,n){return{selector:e,snippet:(s)=>{let r=s.getAttribute(n);return r?`${t} ${r}`:null}}}var $n=[qt("[data-md='item']","[Item]","data-md-label"),qt("[data-md='section']","[Section]","data-md-title"),qt("[data-md='checklist-item']","[Checklist]","data-md-label"),qt("[data-md='image']","[Image]","data-md-src"),{selector:"[data-md='callout']",snippet:(e)=>`[Callout:${e.getAttribute("data-md-type")||"info"}] ${Cr(e).slice(0,60)||"Callout"}`},{selector:"[data-md='note']",snippet:(e)=>`[Note] ${Cr(e).slice(0,60)||"Note"}`},{selector:"[data-md='table'] tbody tr",snippet:(e)=>{let t=Array.from(e.querySelectorAll("td")).map((n)=>n.textContent?.trim()).filter(Boolean);return t.length?`[Row] ${t.join(" | ")}`:null}}],Po=["[data-md='choice-option']","[data-md='multichoice-option']","[data-md='userinput']","[data-md='rangeinput']"],Pn=$n.map((e)=>e.selector).join(", "),Nr=[...$n.map((e)=>e.selector),...Po].join(", ");function On(e){for(let t of $n)if(e.matches(t.selector))return t.snippet(e);return null}var jn={kind:"block",parse:(e)=>e.startsWith("[")?{snippet:e}:null,format:(e)=>e.snippet,find:(e,t)=>{for(let n of t.querySelectorAll(Pn)){if(!(n instanceof HTMLElement))continue;if(On(n)===e.snippet)return n}return null}};var Oo=/^\[Region:(rect|ellipse)\] ([\s\S]+) @(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*),(0|[1-9]\d*)$/;function jo(e){if(e==="rect")return"rect";if(e==="ellipse")return"ellipse";return null}function Vt(e){if(e===void 0)return null;let t=Number(e);if(!Number.isInteger(t)||t<0||t>1e4)return null;return t}function Ir(e){return{left:`${e.x/100}%`,top:`${e.y/100}%`,width:`${e.w/100}%`,height:`${e.h/100}%`}}function Wt(e){return`${(e/100).toFixed(1).replace(/\.0$/,"")}%`}function zn(e){let t=`${Wt(e.x)}-${Wt(e.x+e.w)}`,n=`${Wt(e.y)}-${Wt(e.y+e.h)}`;return`[Region] ${e.src} — ${e.shape} x ${t}, y ${n} of the image`}function Dn(e,t){for(let n of t.querySelectorAll("[data-md='image']")){if(!(n instanceof HTMLElement))continue;if(n.getAttribute("data-md-src")!==e)continue;let s=n.querySelector("[data-annotation-image]");if(s instanceof HTMLElement)return s}return null}function Lr(e,t){let n=Ir(t);e.style.left=n.left,e.style.top=n.top,e.style.width=n.width,e.style.height=n.height}function Hn(e,t,n){let s=document.createElement("div");return s.className="ann-region",s.setAttribute("data-annotation-id",n),s.setAttribute("data-annotation-region",t),Lr(s,e),s}var Gt={kind:"region",parse:(e)=>{let t=Oo.exec(e);if(!t)return null;let n=jo(t[1]),s=t[2],r=Vt(t[3]),o=Vt(t[4]),a=Vt(t[5]),l=Vt(t[6]);if(n===null||s===void 0)return null;if(r===null||o===null||a===null||l===null)return null;if(a<1||l<1)return null;return{src:s,shape:n,x:r,y:o,w:a,h:l}},format:(e)=>`[Region:${e.shape}] ${e.src} @${e.x},${e.y},${e.w},${e.h}`,find:(e,t)=>Dn(e.src,t),restore:(e,t,n)=>{if(t.querySelector(`[data-annotation-id="${n.id}"]`))return;let s=Dn(e.src,t);if(!s)return;s.appendChild(Hn(e,e.shape,n.id))},describe:zn};var Bn={kind:"text",parse:(e)=>e?{text:e}:null,format:(e)=>e.text,find:()=>null,restore:(e,t,n)=>{Mn(t,[n])}};var Do=[gt(Gt),gt(jn),gt(Bn)];import{AnnotationCtx as zc,SessionContext as Hc,useAnnotationHost as Bc}from"@fabrika/annotations/runtime";import{useEffect as qc,useRef as Vc,useState as Wc}from"react";var P;(function(e){e.assertEqual=(r)=>{};function t(r){}e.assertIs=t;function n(r){throw Error()}e.assertNever=n,e.arrayToEnum=(r)=>{let o={};for(let a of r)o[a]=a;return o},e.getValidEnumValues=(r)=>{let o=e.objectKeys(r).filter((l)=>typeof r[r[l]]!=="number"),a={};for(let l of o)a[l]=r[l];return e.objectValues(a)},e.objectValues=(r)=>e.objectKeys(r).map(function(o){return r[o]}),e.objectKeys=typeof Object.keys==="function"?(r)=>Object.keys(r):(r)=>{let o=[];for(let a in r)if(Object.prototype.hasOwnProperty.call(r,a))o.push(a);return o},e.find=(r,o)=>{for(let a of r)if(o(a))return a;return},e.isInteger=typeof Number.isInteger==="function"?(r)=>Number.isInteger(r):(r)=>typeof r==="number"&&Number.isFinite(r)&&Math.floor(r)===r;function s(r,o=" | "){return r.map((a)=>typeof a==="string"?`'${a}'`:a).join(o)}e.joinValues=s,e.jsonStringifyReplacer=(r,o)=>{if(typeof o==="bigint")return o.toString();return o}})(P||(P={}));var Mr;(function(e){e.mergeShapes=(t,n)=>({...t,...n})})(Mr||(Mr={}));var v=P.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Te=(e)=>{switch(typeof e){case"undefined":return v.undefined;case"string":return v.string;case"number":return Number.isNaN(e)?v.nan:v.number;case"boolean":return v.boolean;case"function":return v.function;case"bigint":return v.bigint;case"symbol":return v.symbol;case"object":if(Array.isArray(e))return v.array;if(e===null)return v.null;if(e.then&&typeof e.then==="function"&&e.catch&&typeof e.catch==="function")return v.promise;if(typeof Map<"u"&&e instanceof Map)return v.map;if(typeof Set<"u"&&e instanceof Set)return v.set;if(typeof Date<"u"&&e instanceof Date)return v.date;return v.object;default:return v.unknown}};var p=P.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class ce extends Error{get errors(){return this.issues}constructor(e){super();this.issues=[],this.addIssue=(n)=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let t=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,t);else this.__proto__=t;this.name="ZodError",this.issues=e}format(e){let t=e||function(r){return r.message},n={_errors:[]},s=(r)=>{for(let o of r.issues)if(o.code==="invalid_union")o.unionErrors.map(s);else if(o.code==="invalid_return_type")s(o.returnTypeError);else if(o.code==="invalid_arguments")s(o.argumentsError);else if(o.path.length===0)n._errors.push(t(o));else{let a=n,l=0;while(l<o.path.length){let i=o.path[l];if(l!==o.path.length-1)a[i]=a[i]||{_errors:[]};else a[i]=a[i]||{_errors:[]},a[i]._errors.push(t(o));a=a[i],l++}}};return s(this),n}static assert(e){if(!(e instanceof ce))throw Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,P.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=(t)=>t.message){let t={},n=[];for(let s of this.issues)if(s.path.length>0){let r=s.path[0];t[r]=t[r]||[],t[r].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}ce.create=(e)=>new ce(e);var zo=(e,t)=>{let n;switch(e.code){case p.invalid_type:if(e.received===v.undefined)n="Required";else n=`Expected ${e.expected}, received ${e.received}`;break;case p.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,P.jsonStringifyReplacer)}`;break;case p.unrecognized_keys:n=`Unrecognized key(s) in object: ${P.joinValues(e.keys,", ")}`;break;case p.invalid_union:n="Invalid input";break;case p.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${P.joinValues(e.options)}`;break;case p.invalid_enum_value:n=`Invalid enum value. Expected ${P.joinValues(e.options)}, received '${e.received}'`;break;case p.invalid_arguments:n="Invalid function arguments";break;case p.invalid_return_type:n="Invalid function return type";break;case p.invalid_date:n="Invalid date";break;case p.invalid_string:if(typeof e.validation==="object")if("includes"in e.validation){if(n=`Invalid input: must include "${e.validation.includes}"`,typeof e.validation.position==="number")n=`${n} at one or more positions greater than or equal to ${e.validation.position}`}else if("startsWith"in e.validation)n=`Invalid input: must start with "${e.validation.startsWith}"`;else if("endsWith"in e.validation)n=`Invalid input: must end with "${e.validation.endsWith}"`;else P.assertNever(e.validation);else if(e.validation!=="regex")n=`Invalid ${e.validation}`;else n="Invalid";break;case p.too_small:if(e.type==="array")n=`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`;else if(e.type==="string")n=`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`;else if(e.type==="number")n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`;else if(e.type==="bigint")n=`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`;else if(e.type==="date")n=`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`;else n="Invalid input";break;case p.too_big:if(e.type==="array")n=`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`;else if(e.type==="string")n=`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`;else if(e.type==="number")n=`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`;else if(e.type==="bigint")n=`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`;else if(e.type==="date")n=`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`;else n="Invalid input";break;case p.custom:n="Invalid input";break;case p.invalid_intersection_types:n="Intersection results could not be merged";break;case p.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case p.not_finite:n="Number must be finite";break;default:n=t.defaultError,P.assertNever(e)}return{message:n}},$e=zo;var Ho=$e;function xt(){return Ho}var Kt=(e)=>{let{data:t,path:n,errorMaps:s,issueData:r}=e,o=[...n,...r.path||[]],a={...r,path:o};if(r.message!==void 0)return{...r,path:o,message:r.message};let l="",i=s.filter((c)=>!!c).slice().reverse();for(let c of i)l=c(a,{data:t,defaultError:l}).message;return{...r,path:o,message:l}};function b(e,t){let n=xt(),s=Kt({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===$e?void 0:$e].filter((r)=>!!r)});e.common.issues.push(s)}class ee{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray(e,t){let n=[];for(let s of t){if(s.status==="aborted")return A;if(s.status==="dirty")e.dirty();n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){let n=[];for(let s of t){let r=await s.key,o=await s.value;n.push({key:r,value:o})}return ee.mergeObjectSync(e,n)}static mergeObjectSync(e,t){let n={};for(let s of t){let{key:r,value:o}=s;if(r.status==="aborted")return A;if(o.status==="aborted")return A;if(r.status==="dirty")e.dirty();if(o.status==="dirty")e.dirty();if(r.value!=="__proto__"&&(typeof o.value<"u"||s.alwaysSet))n[r.value]=o.value}return{status:e.value,value:n}}}var A=Object.freeze({status:"aborted"}),Qe=(e)=>({status:"dirty",value:e}),oe=(e)=>({status:"valid",value:e}),Fn=(e)=>e.status==="aborted",Un=(e)=>e.status==="dirty",We=(e)=>e.status==="valid",yt=(e)=>typeof Promise<"u"&&e instanceof Promise;var w;(function(e){e.errToObj=(t)=>typeof t==="string"?{message:t}:t||{},e.toString=(t)=>typeof t==="string"?t:t?.message})(w||(w={}));class he{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}var $r=(e,t)=>{if(We(t))return{success:!0,data:t.value};else{if(!e.common.issues.length)throw Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let n=new ce(e.common.issues);return this._error=n,this._error}}}};function E(e){if(!e)return{};let{errorMap:t,invalid_type_error:n,required_error:s,description:r}=e;if(t&&(n||s))throw Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(t)return{errorMap:t,description:r};return{errorMap:(a,l)=>{let{message:i}=e;if(a.code==="invalid_enum_value")return{message:i??l.defaultError};if(typeof l.data>"u")return{message:i??s??l.defaultError};if(a.code!=="invalid_type")return{message:l.defaultError};return{message:i??n??l.defaultError}},description:r}}class L{get description(){return this._def.description}_getType(e){return Te(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Te(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ee,ctx:{common:e.parent.common,data:e.data,parsedType:Te(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if(yt(t))throw Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Te(e)},s=this._parseSync({data:e,path:n.path,parent:n});return $r(n,s)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Te(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:t});return We(n)?{value:n.value}:{issues:t.common.issues}}catch(n){if(n?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then((n)=>We(n)?{value:n.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Te(e)},s=this._parse({data:e,path:n.path,parent:n}),r=await(yt(s)?s:Promise.resolve(s));return $r(n,r)}refine(e,t){let n=(s)=>{if(typeof t==="string"||typeof t>"u")return{message:t};else if(typeof t==="function")return t(s);else return t};return this._refinement((s,r)=>{let o=e(s),a=()=>r.addIssue({code:p.custom,...n(s)});if(typeof Promise<"u"&&o instanceof Promise)return o.then((l)=>{if(!l)return a(),!1;else return!0});if(!o)return a(),!1;else return!0})}refinement(e,t){return this._refinement((n,s)=>{if(!e(n))return s.addIssue(typeof t==="function"?t(n,s):t),!1;else return!0})}_refinement(e){return new ke({schema:this,typeName:R.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(t)=>this["~validate"](t)}}optional(){return ve.create(this,this._def)}nullable(){return Pe.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return be.create(this)}promise(){return rt.create(this,this._def)}or(e){return _t.create([this,e],this._def)}and(e){return St.create(this,e,this._def)}transform(e){return new ke({...E(this._def),schema:this,typeName:R.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e==="function"?e:()=>e;return new Et({...E(this._def),innerType:this,defaultValue:t,typeName:R.ZodDefault})}brand(){return new Gn({typeName:R.ZodBranded,type:this,...E(this._def)})}catch(e){let t=typeof e==="function"?e:()=>e;return new Ct({...E(this._def),innerType:this,catchValue:t,typeName:R.ZodCatch})}describe(e){return new this.constructor({...this._def,description:e})}pipe(e){return nn.create(this,e)}readonly(){return Nt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var Bo=/^c[^\s-]{8,}$/i,Fo=/^[0-9a-z]+$/,Uo=/^[0-9A-HJKMNP-TV-Z]{26}$/i,qo=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Vo=/^[a-z0-9_-]{21}$/i,Wo=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Go=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,Ko=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Yo="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",qn,Jo=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Xo=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Qo=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Zo=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ea=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ta=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Pr="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",na=new RegExp(`^${Pr}$`);function Or(e){let t="[0-5]\\d";if(e.precision)t=`${t}\\.\\d{${e.precision}}`;else if(e.precision==null)t=`${t}(\\.\\d+)?`;let n=e.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`}function ra(e){return new RegExp(`^${Or(e)}$`)}function sa(e){let t=`${Pr}T${Or(e)}`,n=[];if(n.push(e.local?"Z?":"Z"),e.offset)n.push("([+-]\\d{2}:?\\d{2})");return t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function oa(e,t){if((t==="v4"||!t)&&Jo.test(e))return!0;if((t==="v6"||!t)&&Qo.test(e))return!0;return!1}function aa(e,t){if(!Wo.test(e))return!1;try{let[n]=e.split(".");if(!n)return!1;let s=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),r=JSON.parse(atob(s));if(typeof r!=="object"||r===null)return!1;if("typ"in r&&r?.typ!=="JWT")return!1;if(!r.alg)return!1;if(t&&r.alg!==t)return!1;return!0}catch{return!1}}function ia(e,t){if((t==="v4"||!t)&&Xo.test(e))return!0;if((t==="v6"||!t)&&Zo.test(e))return!0;return!1}class Re extends L{_parse(e){if(this._def.coerce)e.data=String(e.data);if(this._getType(e)!==v.string){let r=this._getOrReturnCtx(e);return b(r,{code:p.invalid_type,expected:v.string,received:r.parsedType}),A}let n=new ee,s=void 0;for(let r of this._def.checks)if(r.kind==="min"){if(e.data.length<r.value)s=this._getOrReturnCtx(e,s),b(s,{code:p.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),n.dirty()}else if(r.kind==="max"){if(e.data.length>r.value)s=this._getOrReturnCtx(e,s),b(s,{code:p.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),n.dirty()}else if(r.kind==="length"){let o=e.data.length>r.value,a=e.data.length<r.value;if(o||a){if(s=this._getOrReturnCtx(e,s),o)b(s,{code:p.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message});else if(a)b(s,{code:p.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message});n.dirty()}}else if(r.kind==="email"){if(!Ko.test(e.data))s=this._getOrReturnCtx(e,s),b(s,{validation:"email",code:p.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="emoji"){if(!qn)qn=new RegExp(Yo,"u");if(!qn.test(e.data))s=this._getOrReturnCtx(e,s),b(s,{validation:"emoji",code:p.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="uuid"){if(!qo.test(e.data))s=this._getOrReturnCtx(e,s),b(s,{validation:"uuid",code:p.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="nanoid"){if(!Vo.test(e.data))s=this._getOrReturnCtx(e,s),b(s,{validation:"nanoid",code:p.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="cuid"){if(!Bo.test(e.data))s=this._getOrReturnCtx(e,s),b(s,{validation:"cuid",code:p.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="cuid2"){if(!Fo.test(e.data))s=this._getOrReturnCtx(e,s),b(s,{validation:"cuid2",code:p.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="ulid"){if(!Uo.test(e.data))s=this._getOrReturnCtx(e,s),b(s,{validation:"ulid",code:p.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),b(s,{validation:"url",code:p.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="regex"){if(r.regex.lastIndex=0,!r.regex.test(e.data))s=this._getOrReturnCtx(e,s),b(s,{validation:"regex",code:p.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="trim")e.data=e.data.trim();else if(r.kind==="includes"){if(!e.data.includes(r.value,r.position))s=this._getOrReturnCtx(e,s),b(s,{code:p.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),n.dirty()}else if(r.kind==="toLowerCase")e.data=e.data.toLowerCase();else if(r.kind==="toUpperCase")e.data=e.data.toUpperCase();else if(r.kind==="startsWith"){if(!e.data.startsWith(r.value))s=this._getOrReturnCtx(e,s),b(s,{code:p.invalid_string,validation:{startsWith:r.value},message:r.message}),n.dirty()}else if(r.kind==="endsWith"){if(!e.data.endsWith(r.value))s=this._getOrReturnCtx(e,s),b(s,{code:p.invalid_string,validation:{endsWith:r.value},message:r.message}),n.dirty()}else if(r.kind==="datetime"){if(!sa(r).test(e.data))s=this._getOrReturnCtx(e,s),b(s,{code:p.invalid_string,validation:"datetime",message:r.message}),n.dirty()}else if(r.kind==="date"){if(!na.test(e.data))s=this._getOrReturnCtx(e,s),b(s,{code:p.invalid_string,validation:"date",message:r.message}),n.dirty()}else if(r.kind==="time"){if(!ra(r).test(e.data))s=this._getOrReturnCtx(e,s),b(s,{code:p.invalid_string,validation:"time",message:r.message}),n.dirty()}else if(r.kind==="duration"){if(!Go.test(e.data))s=this._getOrReturnCtx(e,s),b(s,{validation:"duration",code:p.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="ip"){if(!oa(e.data,r.version))s=this._getOrReturnCtx(e,s),b(s,{validation:"ip",code:p.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="jwt"){if(!aa(e.data,r.alg))s=this._getOrReturnCtx(e,s),b(s,{validation:"jwt",code:p.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="cidr"){if(!ia(e.data,r.version))s=this._getOrReturnCtx(e,s),b(s,{validation:"cidr",code:p.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="base64"){if(!ea.test(e.data))s=this._getOrReturnCtx(e,s),b(s,{validation:"base64",code:p.invalid_string,message:r.message}),n.dirty()}else if(r.kind==="base64url"){if(!ta.test(e.data))s=this._getOrReturnCtx(e,s),b(s,{validation:"base64url",code:p.invalid_string,message:r.message}),n.dirty()}else P.assertNever(r);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement((s)=>e.test(s),{validation:t,code:p.invalid_string,...w.errToObj(n)})}_addCheck(e){return new Re({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...w.errToObj(e)})}url(e){return this._addCheck({kind:"url",...w.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...w.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...w.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...w.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...w.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...w.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...w.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...w.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...w.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...w.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...w.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...w.errToObj(e)})}datetime(e){if(typeof e==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e});return this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...w.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){if(typeof e==="string")return this._addCheck({kind:"time",precision:null,message:e});return this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...w.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...w.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...w.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...w.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...w.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...w.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...w.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...w.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...w.errToObj(t)})}nonempty(e){return this.min(1,w.errToObj(e))}trim(){return new Re({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Re({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Re({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e)=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find((e)=>e.kind==="date")}get isTime(){return!!this._def.checks.find((e)=>e.kind==="time")}get isDuration(){return!!this._def.checks.find((e)=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find((e)=>e.kind==="email")}get isURL(){return!!this._def.checks.find((e)=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find((e)=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find((e)=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find((e)=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find((e)=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find((e)=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find((e)=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find((e)=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find((e)=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find((e)=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find((e)=>e.kind==="base64url")}get minLength(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e}get maxLength(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e}}Re.create=(e)=>new Re({checks:[],typeName:R.ZodString,coerce:e?.coerce??!1,...E(e)});function la(e,t){let n=(e.toString().split(".")[1]||"").length,s=(t.toString().split(".")[1]||"").length,r=n>s?n:s,o=Number.parseInt(e.toFixed(r).replace(".","")),a=Number.parseInt(t.toFixed(r).replace(".",""));return o%a/10**r}class et extends L{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce)e.data=Number(e.data);if(this._getType(e)!==v.number){let r=this._getOrReturnCtx(e);return b(r,{code:p.invalid_type,expected:v.number,received:r.parsedType}),A}let n=void 0,s=new ee;for(let r of this._def.checks)if(r.kind==="int"){if(!P.isInteger(e.data))n=this._getOrReturnCtx(e,n),b(n,{code:p.invalid_type,expected:"integer",received:"float",message:r.message}),s.dirty()}else if(r.kind==="min"){if(r.inclusive?e.data<r.value:e.data<=r.value)n=this._getOrReturnCtx(e,n),b(n,{code:p.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),s.dirty()}else if(r.kind==="max"){if(r.inclusive?e.data>r.value:e.data>=r.value)n=this._getOrReturnCtx(e,n),b(n,{code:p.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),s.dirty()}else if(r.kind==="multipleOf"){if(la(e.data,r.value)!==0)n=this._getOrReturnCtx(e,n),b(n,{code:p.not_multiple_of,multipleOf:r.value,message:r.message}),s.dirty()}else if(r.kind==="finite"){if(!Number.isFinite(e.data))n=this._getOrReturnCtx(e,n),b(n,{code:p.not_finite,message:r.message}),s.dirty()}else P.assertNever(r);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,n,s){return new et({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:w.toString(s)}]})}_addCheck(e){return new et({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:w.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:w.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:w.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:w.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e}get maxValue(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e}get isInt(){return!!this._def.checks.find((e)=>e.kind==="int"||e.kind==="multipleOf"&&P.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks)if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;else if(n.kind==="min"){if(t===null||n.value>t)t=n.value}else if(n.kind==="max"){if(e===null||n.value<e)e=n.value}return Number.isFinite(t)&&Number.isFinite(e)}}et.create=(e)=>new et({checks:[],typeName:R.ZodNumber,coerce:e?.coerce||!1,...E(e)});class tt extends L{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==v.bigint)return this._getInvalidInput(e);let n=void 0,s=new ee;for(let r of this._def.checks)if(r.kind==="min"){if(r.inclusive?e.data<r.value:e.data<=r.value)n=this._getOrReturnCtx(e,n),b(n,{code:p.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),s.dirty()}else if(r.kind==="max"){if(r.inclusive?e.data>r.value:e.data>=r.value)n=this._getOrReturnCtx(e,n),b(n,{code:p.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),s.dirty()}else if(r.kind==="multipleOf"){if(e.data%r.value!==BigInt(0))n=this._getOrReturnCtx(e,n),b(n,{code:p.not_multiple_of,multipleOf:r.value,message:r.message}),s.dirty()}else P.assertNever(r);return{status:s.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return b(t,{code:p.invalid_type,expected:v.bigint,received:t.parsedType}),A}gte(e,t){return this.setLimit("min",e,!0,w.toString(t))}gt(e,t){return this.setLimit("min",e,!1,w.toString(t))}lte(e,t){return this.setLimit("max",e,!0,w.toString(t))}lt(e,t){return this.setLimit("max",e,!1,w.toString(t))}setLimit(e,t,n,s){return new tt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:w.toString(s)}]})}_addCheck(e){return new tt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:w.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:w.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:w.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:w.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:w.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e}get maxValue(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e}}tt.create=(e)=>new tt({checks:[],typeName:R.ZodBigInt,coerce:e?.coerce??!1,...E(e)});class Yt extends L{_parse(e){if(this._def.coerce)e.data=Boolean(e.data);if(this._getType(e)!==v.boolean){let n=this._getOrReturnCtx(e);return b(n,{code:p.invalid_type,expected:v.boolean,received:n.parsedType}),A}return oe(e.data)}}Yt.create=(e)=>new Yt({typeName:R.ZodBoolean,coerce:e?.coerce||!1,...E(e)});class vt extends L{_parse(e){if(this._def.coerce)e.data=new Date(e.data);if(this._getType(e)!==v.date){let r=this._getOrReturnCtx(e);return b(r,{code:p.invalid_type,expected:v.date,received:r.parsedType}),A}if(Number.isNaN(e.data.getTime())){let r=this._getOrReturnCtx(e);return b(r,{code:p.invalid_date}),A}let n=new ee,s=void 0;for(let r of this._def.checks)if(r.kind==="min"){if(e.data.getTime()<r.value)s=this._getOrReturnCtx(e,s),b(s,{code:p.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),n.dirty()}else if(r.kind==="max"){if(e.data.getTime()>r.value)s=this._getOrReturnCtx(e,s),b(s,{code:p.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),n.dirty()}else P.assertNever(r);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new vt({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:w.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:w.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)if(t.kind==="min"){if(e===null||t.value>e)e=t.value}return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)if(t.kind==="max"){if(e===null||t.value<e)e=t.value}return e!=null?new Date(e):null}}vt.create=(e)=>new vt({checks:[],coerce:e?.coerce||!1,typeName:R.ZodDate,...E(e)});class Jt extends L{_parse(e){if(this._getType(e)!==v.symbol){let n=this._getOrReturnCtx(e);return b(n,{code:p.invalid_type,expected:v.symbol,received:n.parsedType}),A}return oe(e.data)}}Jt.create=(e)=>new Jt({typeName:R.ZodSymbol,...E(e)});class kt extends L{_parse(e){if(this._getType(e)!==v.undefined){let n=this._getOrReturnCtx(e);return b(n,{code:p.invalid_type,expected:v.undefined,received:n.parsedType}),A}return oe(e.data)}}kt.create=(e)=>new kt({typeName:R.ZodUndefined,...E(e)});class wt extends L{_parse(e){if(this._getType(e)!==v.null){let n=this._getOrReturnCtx(e);return b(n,{code:p.invalid_type,expected:v.null,received:n.parsedType}),A}return oe(e.data)}}wt.create=(e)=>new wt({typeName:R.ZodNull,...E(e)});class Xt extends L{constructor(){super(...arguments);this._any=!0}_parse(e){return oe(e.data)}}Xt.create=(e)=>new Xt({typeName:R.ZodAny,...E(e)});class Ge extends L{constructor(){super(...arguments);this._unknown=!0}_parse(e){return oe(e.data)}}Ge.create=(e)=>new Ge({typeName:R.ZodUnknown,...E(e)});class Ee extends L{_parse(e){let t=this._getOrReturnCtx(e);return b(t,{code:p.invalid_type,expected:v.never,received:t.parsedType}),A}}Ee.create=(e)=>new Ee({typeName:R.ZodNever,...E(e)});class Qt extends L{_parse(e){if(this._getType(e)!==v.undefined){let n=this._getOrReturnCtx(e);return b(n,{code:p.invalid_type,expected:v.void,received:n.parsedType}),A}return oe(e.data)}}Qt.create=(e)=>new Qt({typeName:R.ZodVoid,...E(e)});class be extends L{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==v.array)return b(t,{code:p.invalid_type,expected:v.array,received:t.parsedType}),A;if(s.exactLength!==null){let o=t.data.length>s.exactLength.value,a=t.data.length<s.exactLength.value;if(o||a)b(t,{code:o?p.too_big:p.too_small,minimum:a?s.exactLength.value:void 0,maximum:o?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty()}if(s.minLength!==null){if(t.data.length<s.minLength.value)b(t,{code:p.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()}if(s.maxLength!==null){if(t.data.length>s.maxLength.value)b(t,{code:p.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()}if(t.common.async)return Promise.all([...t.data].map((o,a)=>s.type._parseAsync(new he(t,o,t.path,a)))).then((o)=>ee.mergeArray(n,o));let r=[...t.data].map((o,a)=>s.type._parseSync(new he(t,o,t.path,a)));return ee.mergeArray(n,r)}get element(){return this._def.type}min(e,t){return new be({...this._def,minLength:{value:e,message:w.toString(t)}})}max(e,t){return new be({...this._def,maxLength:{value:e,message:w.toString(t)}})}length(e,t){return new be({...this._def,exactLength:{value:e,message:w.toString(t)}})}nonempty(e){return this.min(1,e)}}be.create=(e,t)=>new be({type:e,minLength:null,maxLength:null,exactLength:null,typeName:R.ZodArray,...E(t)});function Ze(e){if(e instanceof W){let t={};for(let n in e.shape){let s=e.shape[n];t[n]=ve.create(Ze(s))}return new W({...e._def,shape:()=>t})}else if(e instanceof be)return new be({...e._def,type:Ze(e.element)});else if(e instanceof ve)return ve.create(Ze(e.unwrap()));else if(e instanceof Pe)return Pe.create(Ze(e.unwrap()));else if(e instanceof Ce)return Ce.create(e.items.map((t)=>Ze(t)));else return e}class W extends L{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=P.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==v.object){let i=this._getOrReturnCtx(e);return b(i,{code:p.invalid_type,expected:v.object,received:i.parsedType}),A}let{status:n,ctx:s}=this._processInputParams(e),{shape:r,keys:o}=this._getCached(),a=[];if(!(this._def.catchall instanceof Ee&&this._def.unknownKeys==="strip")){for(let i in s.data)if(!o.includes(i))a.push(i)}let l=[];for(let i of o){let c=r[i],d=s.data[i];l.push({key:{status:"valid",value:i},value:c._parse(new he(s,d,s.path,i)),alwaysSet:i in s.data})}if(this._def.catchall instanceof Ee){let i=this._def.unknownKeys;if(i==="passthrough")for(let c of a)l.push({key:{status:"valid",value:c},value:{status:"valid",value:s.data[c]}});else if(i==="strict"){if(a.length>0)b(s,{code:p.unrecognized_keys,keys:a}),n.dirty()}else if(i==="strip");else throw Error("Internal ZodObject error: invalid unknownKeys value.")}else{let i=this._def.catchall;for(let c of a){let d=s.data[c];l.push({key:{status:"valid",value:c},value:i._parse(new he(s,d,s.path,c)),alwaysSet:c in s.data})}}if(s.common.async)return Promise.resolve().then(async()=>{let i=[];for(let c of l){let d=await c.key,f=await c.value;i.push({key:d,value:f,alwaysSet:c.alwaysSet})}return i}).then((i)=>ee.mergeObjectSync(n,i));else return ee.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(e){return w.errToObj,new W({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{let s=this._def.errorMap?.(t,n).message??n.defaultError;if(t.code==="unrecognized_keys")return{message:w.errToObj(e).message??s};return{message:s}}}:{}})}strip(){return new W({...this._def,unknownKeys:"strip"})}passthrough(){return new W({...this._def,unknownKeys:"passthrough"})}extend(e){return new W({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new W({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:R.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new W({...this._def,catchall:e})}pick(e){let t={};for(let n of P.objectKeys(e))if(e[n]&&this.shape[n])t[n]=this.shape[n];return new W({...this._def,shape:()=>t})}omit(e){let t={};for(let n of P.objectKeys(this.shape))if(!e[n])t[n]=this.shape[n];return new W({...this._def,shape:()=>t})}deepPartial(){return Ze(this)}partial(e){let t={};for(let n of P.objectKeys(this.shape)){let s=this.shape[n];if(e&&!e[n])t[n]=s;else t[n]=s.optional()}return new W({...this._def,shape:()=>t})}required(e){let t={};for(let n of P.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let r=this.shape[n];while(r instanceof ve)r=r._def.innerType;t[n]=r}return new W({...this._def,shape:()=>t})}keyof(){return jr(P.objectKeys(this.shape))}}W.create=(e,t)=>new W({shape:()=>e,unknownKeys:"strip",catchall:Ee.create(),typeName:R.ZodObject,...E(t)});W.strictCreate=(e,t)=>new W({shape:()=>e,unknownKeys:"strict",catchall:Ee.create(),typeName:R.ZodObject,...E(t)});W.lazycreate=(e,t)=>new W({shape:e,unknownKeys:"strip",catchall:Ee.create(),typeName:R.ZodObject,...E(t)});class _t extends L{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function s(r){for(let a of r)if(a.result.status==="valid")return a.result;for(let a of r)if(a.result.status==="dirty")return t.common.issues.push(...a.ctx.common.issues),a.result;let o=r.map((a)=>new ce(a.ctx.common.issues));return b(t,{code:p.invalid_union,unionErrors:o}),A}if(t.common.async)return Promise.all(n.map(async(r)=>{let o={...t,common:{...t.common,issues:[]},parent:null};return{result:await r._parseAsync({data:t.data,path:t.path,parent:o}),ctx:o}})).then(s);else{let r=void 0,o=[];for(let l of n){let i={...t,common:{...t.common,issues:[]},parent:null},c=l._parseSync({data:t.data,path:t.path,parent:i});if(c.status==="valid")return c;else if(c.status==="dirty"&&!r)r={result:c,ctx:i};if(i.common.issues.length)o.push(i.common.issues)}if(r)return t.common.issues.push(...r.ctx.common.issues),r.result;let a=o.map((l)=>new ce(l));return b(t,{code:p.invalid_union,unionErrors:a}),A}}get options(){return this._def.options}}_t.create=(e,t)=>new _t({options:e,typeName:R.ZodUnion,...E(t)});var Ae=(e)=>{if(e instanceof Tt)return Ae(e.schema);else if(e instanceof ke)return Ae(e.innerType());else if(e instanceof At)return[e.value];else if(e instanceof Ke)return e.options;else if(e instanceof Rt)return P.objectValues(e.enum);else if(e instanceof Et)return Ae(e._def.innerType);else if(e instanceof kt)return[void 0];else if(e instanceof wt)return[null];else if(e instanceof ve)return[void 0,...Ae(e.unwrap())];else if(e instanceof Pe)return[null,...Ae(e.unwrap())];else if(e instanceof Gn)return Ae(e.unwrap());else if(e instanceof Nt)return Ae(e.unwrap());else if(e instanceof Ct)return Ae(e._def.innerType);else return[]};class Wn extends L{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.object)return b(t,{code:p.invalid_type,expected:v.object,received:t.parsedType}),A;let n=this.discriminator,s=t.data[n],r=this.optionsMap.get(s);if(!r)return b(t,{code:p.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),A;if(t.common.async)return r._parseAsync({data:t.data,path:t.path,parent:t});else return r._parseSync({data:t.data,path:t.path,parent:t})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){let s=new Map;for(let r of t){let o=Ae(r.shape[e]);if(!o.length)throw Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let a of o){if(s.has(a))throw Error(`Discriminator property ${String(e)} has duplicate value ${String(a)}`);s.set(a,r)}}return new Wn({typeName:R.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...E(n)})}}function Vn(e,t){let n=Te(e),s=Te(t);if(e===t)return{valid:!0,data:e};else if(n===v.object&&s===v.object){let r=P.objectKeys(t),o=P.objectKeys(e).filter((l)=>r.indexOf(l)!==-1),a={...e,...t};for(let l of o){let i=Vn(e[l],t[l]);if(!i.valid)return{valid:!1};a[l]=i.data}return{valid:!0,data:a}}else if(n===v.array&&s===v.array){if(e.length!==t.length)return{valid:!1};let r=[];for(let o=0;o<e.length;o++){let a=e[o],l=t[o],i=Vn(a,l);if(!i.valid)return{valid:!1};r.push(i.data)}return{valid:!0,data:r}}else if(n===v.date&&s===v.date&&+e===+t)return{valid:!0,data:e};else return{valid:!1}}class St extends L{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),s=(r,o)=>{if(Fn(r)||Fn(o))return A;let a=Vn(r.value,o.value);if(!a.valid)return b(n,{code:p.invalid_intersection_types}),A;if(Un(r)||Un(o))t.dirty();return{status:t.value,value:a.data}};if(n.common.async)return Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([r,o])=>s(r,o));else return s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}St.create=(e,t,n)=>new St({left:e,right:t,typeName:R.ZodIntersection,...E(n)});class Ce extends L{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==v.array)return b(n,{code:p.invalid_type,expected:v.array,received:n.parsedType}),A;if(n.data.length<this._def.items.length)return b(n,{code:p.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),A;if(!this._def.rest&&n.data.length>this._def.items.length)b(n,{code:p.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty();let r=[...n.data].map((o,a)=>{let l=this._def.items[a]||this._def.rest;if(!l)return null;return l._parse(new he(n,o,n.path,a))}).filter((o)=>!!o);if(n.common.async)return Promise.all(r).then((o)=>ee.mergeArray(t,o));else return ee.mergeArray(t,r)}get items(){return this._def.items}rest(e){return new Ce({...this._def,rest:e})}}Ce.create=(e,t)=>{if(!Array.isArray(e))throw Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ce({items:e,typeName:R.ZodTuple,rest:null,...E(t)})};class Zt extends L{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==v.object)return b(n,{code:p.invalid_type,expected:v.object,received:n.parsedType}),A;let s=[],r=this._def.keyType,o=this._def.valueType;for(let a in n.data)s.push({key:r._parse(new he(n,a,n.path,a)),value:o._parse(new he(n,n.data[a],n.path,a)),alwaysSet:a in n.data});if(n.common.async)return ee.mergeObjectAsync(t,s);else return ee.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){if(t instanceof L)return new Zt({keyType:e,valueType:t,typeName:R.ZodRecord,...E(n)});return new Zt({keyType:Re.create(),valueType:e,typeName:R.ZodRecord,...E(t)})}}class en extends L{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==v.map)return b(n,{code:p.invalid_type,expected:v.map,received:n.parsedType}),A;let s=this._def.keyType,r=this._def.valueType,o=[...n.data.entries()].map(([a,l],i)=>({key:s._parse(new he(n,a,n.path,[i,"key"])),value:r._parse(new he(n,l,n.path,[i,"value"]))}));if(n.common.async){let a=new Map;return Promise.resolve().then(async()=>{for(let l of o){let i=await l.key,c=await l.value;if(i.status==="aborted"||c.status==="aborted")return A;if(i.status==="dirty"||c.status==="dirty")t.dirty();a.set(i.value,c.value)}return{status:t.value,value:a}})}else{let a=new Map;for(let l of o){let{key:i,value:c}=l;if(i.status==="aborted"||c.status==="aborted")return A;if(i.status==="dirty"||c.status==="dirty")t.dirty();a.set(i.value,c.value)}return{status:t.value,value:a}}}}en.create=(e,t,n)=>new en({valueType:t,keyType:e,typeName:R.ZodMap,...E(n)});class nt extends L{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==v.set)return b(n,{code:p.invalid_type,expected:v.set,received:n.parsedType}),A;let s=this._def;if(s.minSize!==null){if(n.data.size<s.minSize.value)b(n,{code:p.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()}if(s.maxSize!==null){if(n.data.size>s.maxSize.value)b(n,{code:p.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty()}let r=this._def.valueType;function o(l){let i=new Set;for(let c of l){if(c.status==="aborted")return A;if(c.status==="dirty")t.dirty();i.add(c.value)}return{status:t.value,value:i}}let a=[...n.data.values()].map((l,i)=>r._parse(new he(n,l,n.path,i)));if(n.common.async)return Promise.all(a).then((l)=>o(l));else return o(a)}min(e,t){return new nt({...this._def,minSize:{value:e,message:w.toString(t)}})}max(e,t){return new nt({...this._def,maxSize:{value:e,message:w.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}nt.create=(e,t)=>new nt({valueType:e,minSize:null,maxSize:null,typeName:R.ZodSet,...E(t)});class bt extends L{constructor(){super(...arguments);this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.function)return b(t,{code:p.invalid_type,expected:v.function,received:t.parsedType}),A;function n(a,l){return Kt({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xt(),$e].filter((i)=>!!i),issueData:{code:p.invalid_arguments,argumentsError:l}})}function s(a,l){return Kt({data:a,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,xt(),$e].filter((i)=>!!i),issueData:{code:p.invalid_return_type,returnTypeError:l}})}let r={errorMap:t.common.contextualErrorMap},o=t.data;if(this._def.returns instanceof rt){let a=this;return oe(async function(...l){let i=new ce([]),c=await a._def.args.parseAsync(l,r).catch((g)=>{throw i.addIssue(n(l,g)),i}),d=await Reflect.apply(o,this,c);return await a._def.returns._def.type.parseAsync(d,r).catch((g)=>{throw i.addIssue(s(d,g)),i})})}else{let a=this;return oe(function(...l){let i=a._def.args.safeParse(l,r);if(!i.success)throw new ce([n(l,i.error)]);let c=Reflect.apply(o,this,i.data),d=a._def.returns.safeParse(c,r);if(!d.success)throw new ce([s(c,d.error)]);return d.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new bt({...this._def,args:Ce.create(e).rest(Ge.create())})}returns(e){return new bt({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new bt({args:e?e:Ce.create([]).rest(Ge.create()),returns:t||Ge.create(),typeName:R.ZodFunction,...E(n)})}}class Tt extends L{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Tt.create=(e,t)=>new Tt({getter:e,typeName:R.ZodLazy,...E(t)});class At extends L{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return b(t,{received:t.data,code:p.invalid_literal,expected:this._def.value}),A}return{status:"valid",value:e.data}}get value(){return this._def.value}}At.create=(e,t)=>new At({value:e,typeName:R.ZodLiteral,...E(t)});function jr(e,t){return new Ke({values:e,typeName:R.ZodEnum,...E(t)})}class Ke extends L{_parse(e){if(typeof e.data!=="string"){let t=this._getOrReturnCtx(e),n=this._def.values;return b(t,{expected:P.joinValues(n),received:t.parsedType,code:p.invalid_type}),A}if(!this._cache)this._cache=new Set(this._def.values);if(!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return b(t,{received:t.data,code:p.invalid_enum_value,options:n}),A}return oe(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return Ke.create(e,{...this._def,...t})}exclude(e,t=this._def){return Ke.create(this.options.filter((n)=>!e.includes(n)),{...this._def,...t})}}Ke.create=jr;class Rt extends L{_parse(e){let t=P.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==v.string&&n.parsedType!==v.number){let s=P.objectValues(t);return b(n,{expected:P.joinValues(s),received:n.parsedType,code:p.invalid_type}),A}if(!this._cache)this._cache=new Set(P.getValidEnumValues(this._def.values));if(!this._cache.has(e.data)){let s=P.objectValues(t);return b(n,{received:n.data,code:p.invalid_enum_value,options:s}),A}return oe(e.data)}get enum(){return this._def.values}}Rt.create=(e,t)=>new Rt({values:e,typeName:R.ZodNativeEnum,...E(t)});class rt extends L{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==v.promise&&t.common.async===!1)return b(t,{code:p.invalid_type,expected:v.promise,received:t.parsedType}),A;let n=t.parsedType===v.promise?t.data:Promise.resolve(t.data);return oe(n.then((s)=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}rt.create=(e,t)=>new rt({type:e,typeName:R.ZodPromise,...E(t)});class ke extends L{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===R.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,r={addIssue:(o)=>{if(b(n,o),o.fatal)t.abort();else t.dirty()},get path(){return n.path}};if(r.addIssue=r.addIssue.bind(r),s.type==="preprocess"){let o=s.transform(n.data,r);if(n.common.async)return Promise.resolve(o).then(async(a)=>{if(t.value==="aborted")return A;let l=await this._def.schema._parseAsync({data:a,path:n.path,parent:n});if(l.status==="aborted")return A;if(l.status==="dirty")return Qe(l.value);if(t.value==="dirty")return Qe(l.value);return l});else{if(t.value==="aborted")return A;let a=this._def.schema._parseSync({data:o,path:n.path,parent:n});if(a.status==="aborted")return A;if(a.status==="dirty")return Qe(a.value);if(t.value==="dirty")return Qe(a.value);return a}}if(s.type==="refinement"){let o=(a)=>{let l=s.refinement(a,r);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return a};if(n.common.async===!1){let a=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(a.status==="aborted")return A;if(a.status==="dirty")t.dirty();return o(a.value),{status:t.value,value:a.value}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then((a)=>{if(a.status==="aborted")return A;if(a.status==="dirty")t.dirty();return o(a.value).then(()=>({status:t.value,value:a.value}))})}if(s.type==="transform")if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!We(o))return A;let a=s.transform(o.value,r);if(a instanceof Promise)throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:a}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then((o)=>{if(!We(o))return A;return Promise.resolve(s.transform(o.value,r)).then((a)=>({status:t.value,value:a}))});P.assertNever(s)}}ke.create=(e,t,n)=>new ke({schema:e,typeName:R.ZodEffects,effect:t,...E(n)});ke.createWithPreprocess=(e,t,n)=>new ke({schema:t,effect:{type:"preprocess",transform:e},typeName:R.ZodEffects,...E(n)});class ve extends L{_parse(e){if(this._getType(e)===v.undefined)return oe(void 0);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ve.create=(e,t)=>new ve({innerType:e,typeName:R.ZodOptional,...E(t)});class Pe extends L{_parse(e){if(this._getType(e)===v.null)return oe(null);return this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Pe.create=(e,t)=>new Pe({innerType:e,typeName:R.ZodNullable,...E(t)});class Et extends L{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;if(t.parsedType===v.undefined)n=this._def.defaultValue();return this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Et.create=(e,t)=>new Et({innerType:e,typeName:R.ZodDefault,defaultValue:typeof t.default==="function"?t.default:()=>t.default,...E(t)});class Ct extends L{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});if(yt(s))return s.then((r)=>({status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new ce(n.common.issues)},input:n.data})}));else return{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new ce(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Ct.create=(e,t)=>new Ct({innerType:e,typeName:R.ZodCatch,catchValue:typeof t.catch==="function"?t.catch:()=>t.catch,...E(t)});class tn extends L{_parse(e){if(this._getType(e)!==v.nan){let n=this._getOrReturnCtx(e);return b(n,{code:p.invalid_type,expected:v.nan,received:n.parsedType}),A}return{status:"valid",value:e.data}}}tn.create=(e)=>new tn({typeName:R.ZodNaN,...E(e)});var ec=Symbol("zod_brand");class Gn extends L{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class nn extends L{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let r=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});if(r.status==="aborted")return A;if(r.status==="dirty")return t.dirty(),Qe(r.value);else return this._def.out._parseAsync({data:r.value,path:n.path,parent:n})})();else{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});if(s.status==="aborted")return A;if(s.status==="dirty")return t.dirty(),{status:"dirty",value:s.value};else return this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new nn({in:e,out:t,typeName:R.ZodPipeline})}}class Nt extends L{_parse(e){let t=this._def.innerType._parse(e),n=(s)=>{if(We(s))s.value=Object.freeze(s.value);return s};return yt(t)?t.then((s)=>n(s)):n(t)}unwrap(){return this._def.innerType}}Nt.create=(e,t)=>new Nt({innerType:e,typeName:R.ZodReadonly,...E(t)});var tc={object:W.lazycreate},R;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(R||(R={}));var m=Re.create,Q=et.create,nc=tn.create,rc=tt.create,we=Yt.create,sc=vt.create,oc=Jt.create,ac=kt.create,ic=wt.create,lc=Xt.create,ca=Ge.create,cc=Ee.create,dc=Qt.create,q=be.create,{create:S,strictCreate:uc}=W,Kn=_t.create,pc=Wn.create,fc=St.create,Dr=Ce.create,hc=Zt.create,mc=en.create,gc=nt.create,xc=bt.create,yc=Tt.create,st=At.create,ot=Ke.create,bc=Rt.create,vc=rt.create,kc=ke.create,wc=ve.create,_c=Pe.create,Sc=ke.createWithPreprocess,Tc=nn.create;var da=S({before:m(),after:m(),hierarchy:q(m()),lineStart:Q().optional(),lineEnd:Q().optional()}).passthrough(),Yn=S({id:m(),name:m()}).passthrough(),ua=S({url:m(),mime:m().optional()}).passthrough(),Jn=S({id:m(),snippet:m(),note:m(),createdAt:m(),filePath:m().optional(),canvasFile:m().optional(),context:da.optional(),images:q(m()).optional(),attachments:q(ua).optional(),source:ot(["local","remote"]).optional(),author:Yn.optional()}).passthrough(),pa=q(Jn.optional().catch(void 0)).transform((e)=>e.filter((t)=>t!==void 0)).catch([]),Xn=S({annotations:pa,generalNote:m().catch("")}).passthrough(),zr=S({path:m()}),Hr=S({url:m()}),Br=S({error:m()});import{useCallback as Mc,useMemo as $c,useState as Pc}from"react";function It(e){return e.uploadUrl!==null}var Qn=["image/png","image/jpeg","image/gif","image/webp"],Fr="Only PNG, JPEG, GIF and WebP images can be attached";function Ne(e,t){e.style.height="auto",e.style.height=(t?Math.max(t,e.scrollHeight):e.scrollHeight)+"px"}import{useAnnotations as rn}from"@fabrika/annotations/runtime";import{useAnnotationHost as ha}from"@fabrika/annotations/runtime";import{useCallback as Ie,useEffect as ma,useRef as er,useState as sn}from"react";import{jsxDEV as te}from"react/jsx-dev-runtime";function Ur(e){if(e.startsWith("/s/")||e.startsWith("http://")||e.startsWith("https://"))return e;return`/api/uploads/${e.split("/").pop()}`}async function ga(e,t){let n=e.uploadUrl;if(!n)return{error:"Uploads are not available here"};let s=new FormData;s.append("image",t);try{let r=await fetch(n(),{method:"POST",body:s}),o=await r.json();if(!r.ok){let a=Br.safeParse(o);return{error:a.success?a.data.error:`Upload failed (HTTP ${r.status})`}}return{path:e.isShared?Hr.parse(o).url:zr.parse(o).path}}catch{return{error:"Upload failed"}}}function on({note:e,onNoteChange:t,images:n,onAddImage:s,onRemoveImage:r,sessionId:o,placeholder:a="Add your note...",autoFocus:l=!1,autoResize:i=!1,readOnly:c=!1,onKeyDown:d,onTextareaClick:f,textareaRef:g,textareaClassName:x,textareaStyle:u,minHeight:h,attachButton:y="always",openFilePickerRef:T}){let O=ha(),M=!c&&It(O),[I,_]=sn(!1),[j,U]=sn(!1),[ne,le]=sn(null),[G,J]=sn(!1),X=er(0),K=er(null),de=er(null),Le=Ie(()=>de.current?.click(),[]);if(T)T.current=Le;let He=Ie((C)=>{if(K.current=C,g)g.current=C;if(C&&i)Ne(C,h)},[g,i,h]);ma(()=>{if(l&&K.current){let C=K.current;if(C.focus(),C.value)C.setSelectionRange(C.value.length,C.value.length)}},[l]);let re=Ie(async(C)=>{if(!Qn.includes(C.type)){le(Fr);return}le(null),U(!0);try{let k=await ga(O,C);if("path"in k)s(k.path);else le(k.error)}finally{U(!1)}},[O,s]),ue=Ie((C)=>{for(let k of C.clipboardData?.items??[])if(k.type.startsWith("image/")){C.preventDefault();let H=k.getAsFile();if(H)re(H);return}},[re]),me=Ie((C)=>{if(C.preventDefault(),X.current++,X.current===1)_(!0)},[]),ge=Ie((C)=>{C.preventDefault()},[]),Be=Ie((C)=>{if(C.preventDefault(),X.current--,X.current===0)_(!1)},[]),Fe=Ie((C)=>{C.preventDefault(),X.current=0,_(!1);for(let k of C.dataTransfer?.files??[])if(k.type.startsWith("image/"))re(k)},[re]),xn=Ie((C)=>{if(t(C.currentTarget.value),i)C.currentTarget.style.height="auto",C.currentTarget.style.height=(h?Math.max(h,C.currentTarget.scrollHeight):C.currentTarget.scrollHeight)+"px"},[t,i,h]),yn="w-full bg-transparent text-[13px] font-body text-text-primary resize-none focus:outline-none leading-relaxed p-0 border-none",ut={width:"100%",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",outline:"none",...i?{resize:"none",overflow:"hidden"}:{resize:"vertical"}},jt=M&&(y==="always"||y==="on-focus"&&G);return te("div",{style:{position:"relative"},onDragEnter:M?me:void 0,onDragOver:M?ge:void 0,onDragLeave:M?Be:void 0,onDrop:M?Fe:void 0,children:[te("textarea",{ref:He,value:e,onChange:c?void 0:xn,onPaste:M?ue:void 0,onKeyDown:d,onClick:f,onFocus:()=>J(!0),onBlur:()=>{setTimeout(()=>J(!1),150)},readOnly:c,placeholder:a,className:x??yn,style:u??ut,rows:i?1:void 0},void 0,!1,void 0,this),M&&te("input",{ref:de,type:"file",accept:Qn.join(","),multiple:!0,style:{display:"none"},onChange:(C)=>{let k=C.currentTarget.files;if(k)for(let H of k)re(H);C.currentTarget.value=""}},void 0,!1,void 0,this),(n.length>0||jt)&&te("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",marginTop:"6px",alignItems:"center"},children:[n.map((C)=>te("div",{style:{position:"relative",width:"56px",height:"56px",borderRadius:"6px",overflow:"hidden",border:"1px solid var(--color-border-subtle)",flexShrink:0},children:[te("img",{src:Ur(C),alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}},void 0,!1,void 0,this),!c&&te("button",{onClick:(k)=>{k.stopPropagation(),r(C)},style:{position:"absolute",top:"2px",right:"2px",width:"16px",height:"16px",borderRadius:"50%",background:"rgba(0,0,0,0.6)",color:"white",border:"none",cursor:"pointer",fontSize:"11px",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:0},title:"Remove image",children:"×"},void 0,!1,void 0,this)]},C,!0,void 0,this)),jt&&te(an,{onClick:Le},void 0,!1,void 0,this)]},void 0,!0,void 0,this),j&&te("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:"Uploading..."},void 0,!1,void 0,this),ne&&te("div",{role:"alert",style:{fontSize:"11px",color:"var(--color-accent-red)",fontFamily:"'Inter', sans-serif",marginTop:"4px"},children:ne},void 0,!1,void 0,this),I&&te("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-highlight-bg)",opacity:0.9,border:"2px dashed var(--color-highlight-border)",borderRadius:"6px",zIndex:10,pointerEvents:"none",fontSize:"12px",fontFamily:"'Inter', sans-serif",color:"var(--color-text-secondary)"},children:"Drop image"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function an({onClick:e,size:t=16}){return te("button",{onClick:(n)=>{n.stopPropagation(),e()},style:{width:`${t*2}px`,height:`${t*2}px`,borderRadius:"6px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--color-text-tertiary)",flexShrink:0,transition:"color 0.15s"},title:"Attach image",onMouseEnter:(n)=>{n.currentTarget.style.color="var(--color-text-secondary)"},onMouseLeave:(n)=>{n.currentTarget.style.color="var(--color-text-tertiary)"},children:te("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[te("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},void 0,!1,void 0,this),te("circle",{cx:"8.5",cy:"8.5",r:"1.5"},void 0,!1,void 0,this),te("polyline",{points:"21 15 16 10 5 21"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}import{SessionContext as ld}from"@fabrika/annotations/runtime";import{useContext as dd,useEffect as ud,useRef as pd}from"react";import{SessionContext as va,useAnnotationHost as ka}from"@fabrika/annotations/runtime";import{useCallback as ln,useContext as wa,useEffect as _a,useMemo as Gr,useRef as cn,useState as at}from"react";import{createPortal as Sa}from"react-dom";function Vr(e){let t=/^(\d+(?:\.\d+)?)px$/.exec(e.trim());return t?Number(t[1]):void 0}function Wr(e,t,n=280){let r=t||document.body,o=e.getBoundingClientRect(),a=r.getBoundingClientRect(),l=r===document.body?0:r.scrollTop,i=o.bottom-a.top+l+8,c=Math.max(0,Math.min(o.left-a.left,a.width-n-12));return r.style.position="relative",{style:{position:"absolute",top:`${i}px`,left:`${c}px`},parent:r}}import{jsxDEV as Z,Fragment as Ta}from"react/jsx-dev-runtime";function Yr({anchorEl:e,scrollContainer:t,onClose:n,ignoreSelector:s,zIndex:r="50",padding:o="12px",width:a="280px",children:l}){let i=cn(null),c=cn(n);c.current=n;let{style:d,parent:f}=Wr(e,t,Vr(a));return _a(()=>{let g=setTimeout(()=>{let x=(u)=>{if(i.current&&!i.current.contains(u.target)){if(s&&u.target.closest?.(s))return;c.current(),document.removeEventListener("mousedown",x)}};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},0);return()=>clearTimeout(g)},[s]),Sa(Z("div",{ref:i,style:{...d,zIndex:r,width:a,background:"var(--color-bg-elevated)",border:"1px solid var(--color-border-hover)",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",padding:o,fontFamily:"'Inter', sans-serif"},children:l},void 0,!1,void 0,this),f)}var Jr=[{label:"Clarity",items:["Unclear","Why?","Needs example","Missing context"]},{label:"Scope",items:["Overkill","Out of scope","Important","Risky"]},{label:"Action",items:["Simplify","Rethink","Expand on this","Skip this"]}],Kr=Jr.flatMap((e)=>e.items);function Xr({anchorEl:e,scrollContainer:t,snippet:n,truncateAt:s=100,header:r,initialNote:o="",initialImages:a,onConfirm:l,onCancel:i,onDelete:c}){let d=wa(va),f=ka(),g=It(f),x=o!==""||!!c,[u,h]=at(o),[y,T]=at(a||[]),[O,M]=at(null),[I,_]=at(x),[j,U]=at(!1),ne=cn(null),le=cn(null),G=ln(()=>{if(u.trim()||y.length>0)l(u.trim(),y);else if(x&&c)c();else i()},[u,y,l,i,x,c]),J=ln(()=>{if(x){if(!u.trim()&&y.length===0&&c){c(),i();return}l(u,y);return}i()},[u,y,x,l,i,c]),X=!x,K=u.trim().length>0?Kr.filter((k)=>k.toLowerCase().startsWith(u.trim().toLowerCase())):Kr,de=!X||I?[]:K.length===1&&K[0]?.toLowerCase()===u.trim().toLowerCase()?[]:K,Le=new Set(de),He=Jr.map((k)=>({label:k.label,items:k.items.filter((H)=>Le.has(H))})).filter((k)=>k.items.length>0),re=He.map((k)=>k.items),ue=(k)=>re[k]?.length??0,me=re.flat(),ge=Gr(()=>{if(O===null)return 0;let k=0;for(let H=0;H<re.length;H++){if(O<k+ue(H))return H;k+=ue(H)}return 0},[O,re]),Be=Gr(()=>{if(O===null)return 0;let k=0;for(let H=0;H<ge;H++)k+=ue(H);return O-k},[O,ge,re]),Fe=(k,H)=>{let Y=0;for(let xe=0;xe<k;xe++)Y+=ue(xe);return Y+H},[xn,yn]=at(u);if(u!==xn)yn(u),M(null),_(x);let ut=ln((k)=>{h(k)},[]),jt=n.length>s?n.slice(0,s)+"...":n,C=ln((k)=>{if(me.length>0&&(k.key==="ArrowDown"||k.key==="ArrowUp"||k.key==="ArrowLeft"||k.key==="ArrowRight")){if(k.preventDefault(),O===null){M(0);return}if(k.key==="ArrowDown"){let Y=Math.min(Be+1,ue(ge)-1);M(Fe(ge,Y))}else if(k.key==="ArrowUp"){let Y=Math.max(Be-1,0);M(Fe(ge,Y))}else if(k.key==="ArrowRight"){let Y=Math.min(ge+1,re.length-1),xe=Math.min(Be,ue(Y)-1);M(Fe(Y,xe))}else if(k.key==="ArrowLeft"){let Y=Math.max(ge-1,0),xe=Math.min(Be,ue(Y)-1);M(Fe(Y,xe))}return}let H=O===null?void 0:me[O];if(H!==void 0){if(k.key==="Tab"){k.preventDefault(),ut(H);return}if(k.key==="Enter"&&!k.shiftKey){k.preventDefault(),l(H,y);return}}if(k.key==="Enter"&&!k.shiftKey){k.preventDefault(),G();return}if(k.key==="Escape")if(me.length>0&&!I)_(!0);else if(x)J();else i()},[me,O,Be,ge,re,Fe,ut,l,y,G,I,x,J,i]);return Z(Yr,{anchorEl:e,scrollContainer:t,onClose:x?J:i,ignoreSelector:x?"[data-annotation-id]":void 0,zIndex:x?"60":"50",padding:x?"10px 12px":"12px",width:"420px",children:[!x&&(r??Z("div",{style:{fontSize:"11px",color:"var(--color-text-tertiary)",fontStyle:"italic",marginBottom:"8px",lineHeight:"1.4",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:["“",jt,"”"]},void 0,!0,void 0,this)),Z(on,{note:u,onNoteChange:h,images:y,onAddImage:(k)=>T((H)=>[...H,k]),onRemoveImage:(k)=>T((H)=>H.filter((Y)=>Y!==k)),sessionId:d,autoFocus:!0,autoResize:x,textareaRef:ne,onKeyDown:C,attachButton:"none",openFilePickerRef:le,textareaStyle:x?{width:"100%",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",resize:"none",outline:"none",overflow:"hidden"}:{width:"100%",minHeight:"60px",background:"transparent",border:"none",color:"var(--color-text-primary)",fontFamily:"'Inter', sans-serif",fontSize:"13px",lineHeight:"1.5",resize:"vertical",outline:"none"},placeholder:"Add your note..."},void 0,!1,void 0,this),Z("div",{style:{display:"flex",alignItems:"center",gap:"8px",marginTop:x?"6px":"8px"},children:[g&&Z(an,{onClick:()=>le.current?.(),size:14},void 0,!1,void 0,this),Z("div",{style:{flex:1}},void 0,!1,void 0,this),x?Z("button",{onClick:()=>{if(c)c();i()},onMouseEnter:()=>U(!0),onMouseLeave:()=>U(!1),style:{fontSize:"11px",color:j?"var(--color-accent-red)":"var(--color-text-tertiary)",background:"none",border:"none",cursor:"pointer",padding:"2px 0",fontFamily:"'Inter', sans-serif"},children:"Delete"},void 0,!1,void 0,this):Z(Ta,{children:[Z("button",{onClick:i,style:{fontSize:"11px",color:"var(--color-text-tertiary)",background:"none",border:"none",cursor:"pointer",padding:"4px 12px",fontFamily:"'Inter', sans-serif"},children:"Cancel"},void 0,!1,void 0,this),Z("button",{onClick:G,style:{fontSize:"11px",fontWeight:500,padding:"4px 12px",borderRadius:"6px",background:"var(--color-highlight-bg)",color:"var(--color-text-primary)",border:"1px solid var(--color-highlight-border)",cursor:"pointer",fontFamily:"'Inter', sans-serif"},children:"Add"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),me.length>0&&Z("div",{style:{marginTop:"6px",borderTop:"1px solid var(--color-border-subtle)",paddingTop:"8px",display:"flex",gap:"4px"},children:He.map((k)=>Z("div",{style:{flex:1},children:[Z("div",{style:{fontSize:"10px",fontWeight:600,color:"var(--color-text-disabled)",textTransform:"uppercase",letterSpacing:"0.05em",padding:"2px 6px",marginBottom:"2px",fontFamily:"'Inter', sans-serif"},children:k.label},void 0,!1,void 0,this),k.items.map((H)=>{let Y=me.indexOf(H);return Z("div",{onMouseDown:(xe)=>{xe.preventDefault(),xe.stopPropagation(),ut(H)},onMouseEnter:()=>M(Y),style:{padding:"3px 6px",fontSize:"12px",borderRadius:"4px",fontFamily:"'Inter', sans-serif",color:Y===O?"var(--color-text-primary)":"var(--color-text-secondary)",background:Y===O?"var(--color-highlight-selected)":"transparent",cursor:"pointer"},children:[Z("span",{style:{fontWeight:500},children:H.slice(0,u.trim().length)},void 0,!1,void 0,this),H.slice(u.trim().length)]},H,!0,void 0,this)})]},k.label,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Lt({anchorEl:e,scrollContainer:t,snippet:n,truncateAt:s,header:r,onAdd:o,onCancel:a}){return Z(Xr,{anchorEl:e,scrollContainer:t,snippet:n,truncateAt:s,header:r,onConfirm:(l,i)=>o(l,i),onCancel:a},void 0,!1,void 0,this)}import{useEffect as Md,useRef as $d,useState as Pd}from"react";import{useCallback as qd,useEffect as Vd,useRef as Wd,useState as Gd}from"react";import{jsxDEV as Qr}from"react/jsx-dev-runtime";function it({note:e,onChange:t}){return Qr("div",{className:"mt-1.5",children:Qr("textarea",{value:e,onChange:(n)=>t(n.currentTarget.value),className:"w-full bg-transparent text-[12px] font-body text-text-primary resize-none focus:outline-none border-none placeholder:text-text-disabled transition-colors min-h-[20px] p-0 leading-relaxed",placeholder:"Add a note...",rows:1,onInput:(n)=>Ne(n.currentTarget),ref:(n)=>{if(n)Ne(n)}},void 0,!1,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as V}from"react/jsx-dev-runtime";function os(e){return e.map((t)=>typeof t==="string"?{value:t,label:t}:{value:t.value,label:t.label??t.value})}function Pa({id:e,label:t,options:n,required:s}){let{responses:r,setResponse:o}=Zr();es(e);let a=ns(()=>os(n),[n]),l=r.get(e),i=l?.value,c=l?.note||"",[d,f]=ss(!1),g=rs(null);if(!r.has(e))o(e,{id:e,type:"radio",label:t,value:null,options:a.map((h)=>h.value),required:s});let x=(h)=>{o(e,{...l,value:h})};ts(()=>{let h=g.current;if(!h)return;let y=(T)=>{let M=T.target.closest("[data-md-label]")?.getAttribute("data-md-label"),I=a.find((_)=>_.label===M);if(I)x(I.value)};return h.addEventListener("kb-select",y),()=>h.removeEventListener("kb-select",y)},[a,x]);let u=l?.required&&!i;return V("div",{ref:g,"data-md":"choice","data-md-label":t,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[V("div",{className:"flex items-baseline gap-2 mb-2",children:[V("span",{className:"text-[13px] font-body font-medium text-text-primary",children:t},void 0,!1,void 0,this),s&&V("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),V("div",{className:"space-y-1",children:a.map(({value:h,label:y})=>V("label",{"data-md":"choice-option","data-md-label":y,onClick:()=>x(h),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${i===h?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[V("span",{className:`w-4 h-4 rounded-full border-[1.5px] flex items-center justify-center flex-shrink-0 transition-all ${i===h?"border-accent-amber bg-accent-amber":"border-border-strong"}`,children:i===h&&V("span",{className:"w-1.5 h-1.5 rounded-full bg-text-inverse"},void 0,!1,void 0,this)},void 0,!1,void 0,this),V("span",{className:"text-[13px] font-body text-text-secondary",children:y},void 0,!1,void 0,this)]},h,!0,void 0,this))},void 0,!1,void 0,this),V(it,{show:d,note:c,onToggle:()=>f(!d),onChange:(h)=>o(e,{...l,note:h})},void 0,!1,void 0,this),u&&V("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"Please select an option."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function Oa({id:e,label:t,options:n,required:s}){let{responses:r,setResponse:o}=Zr();es(e);let a=ns(()=>os(n),[n]),l=r.get(e),i=l?.value||[],c=l?.note||"",[d,f]=ss(!1),g=rs(null);if(!r.has(e))o(e,{id:e,type:"checkbox",label:t,value:[],options:a.map((h)=>h.value),required:s});let x=(h)=>{let y=i.includes(h)?i.filter((T)=>T!==h):[...i,h];o(e,{...l,value:y})};ts(()=>{let h=g.current;if(!h)return;let y=(T)=>{let M=T.target.closest("[data-md-label]")?.getAttribute("data-md-label"),I=a.find((_)=>_.label===M);if(I)x(I.value)};return h.addEventListener("kb-select",y),()=>h.removeEventListener("kb-select",y)},[a,x]);let u=l?.required&&i.length===0;return V("div",{ref:g,"data-md":"multichoice","data-md-label":t,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[V("div",{className:"flex items-baseline gap-2 mb-2",children:[V("span",{className:"text-[13px] font-body font-medium text-text-primary",children:t},void 0,!1,void 0,this),s&&V("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),V("div",{className:"space-y-1",children:a.map(({value:h,label:y})=>{let T=i.includes(h);return V("label",{"data-md":"multichoice-option","data-md-label":y,onClick:()=>x(h),className:`flex items-center gap-2.5 px-3 py-2 rounded-lg cursor-pointer transition-all duration-150 ${T?"bg-highlight-selected":"hover:bg-bg-elevated"}`,children:[V("span",{className:`w-4 h-4 rounded flex items-center justify-center flex-shrink-0 transition-all ${T?"bg-accent-amber":"border-[1.5px] border-border-strong"}`,children:T&&V("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",children:V("path",{d:"M2.5 5L4.5 7L7.5 3",style:{stroke:"var(--color-text-inverse)"},strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),V("span",{className:"text-[13px] font-body text-text-secondary",children:y},void 0,!1,void 0,this)]},h,!0,void 0,this)})},void 0,!1,void 0,this),V(it,{show:d,note:c,onToggle:()=>f(!d),onChange:(h)=>o(e,{...l,note:h})},void 0,!1,void 0,this),u&&V("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"Please select at least one option."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useEffect as ja,useRef as Da}from"react";function dn(){return window.hljs}function as(){return window.mermaid}import{jsxDEV as un}from"react/jsx-dev-runtime";function za({language:e,children:t}){let n=typeof t==="string"?t:String(t??""),s=Da(null);return ja(()=>{let r=s.current,o=dn();if(!r||!o)return;r.removeAttribute("data-highlighted"),r.className=e?`language-${e}`:"",r.textContent=n,o.highlightElement(r)},[n,e]),un("div",{className:"relative mt-3 group/code","data-md":"codeblock","data-md-language":e||"",children:[e&&un("span",{className:"absolute top-2 right-3 text-tiny text-text-tertiary opacity-0 group-hover/code:opacity-60 transition-opacity duration-150 z-10 font-mono",children:e},void 0,!1,void 0,this),un("pre",{className:"bg-bg-code rounded-md p-4 overflow-x-auto text-code font-mono leading-relaxed",children:un("code",{ref:s,className:e?`language-${e}`:"",children:n},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function is(e,t){let n=e.split(`
60
+ `),s=t.split(`
61
+ `),r=Ha(n,s),o=[],a=0,l=0,i=0;while(a<n.length||l<s.length){let c=n[a],d=s[l];if(i<r.length&&c!==void 0&&d!==void 0&&c===r[i]&&d===r[i])o.push({type:"same",line:c}),a++,l++,i++;else if(c!==void 0&&(i>=r.length||c!==r[i]))o.push({type:"removed",line:c}),a++;else if(d!==void 0)o.push({type:"added",line:d}),l++}return o}function Ha(e,t){let n=e.length,s=t.length,r=Array.from({length:n+1},()=>Array(s+1).fill(0));for(let i=1;i<=n;i++){let c=r[i]??[],d=r[i-1]??[];for(let f=1;f<=s;f++)c[f]=e[i-1]===t[f-1]?(d[f-1]??0)+1:Math.max(d[f]??0,c[f-1]??0)}let o=[],a=n,l=s;while(a>0&&l>0){let i=e[a-1];if(i!==void 0&&i===t[l-1])o.unshift(i),a--,l--;else if((r[a-1]?.[l]??0)>(r[a]?.[l-1]??0))a--;else l--}return o}import{jsxDEV as Mt}from"react/jsx-dev-runtime";function Ba({before:e,after:t,language:n}){let s=is(e,t);return Mt("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden group/diff","data-md":"diff","data-md-language":n||"",children:[n&&Mt("div",{className:"px-4 py-2 text-meta font-mono text-text-tertiary opacity-0 group-hover/diff:opacity-60 transition-opacity",children:["diff (",n,")"]},void 0,!0,void 0,this),Mt("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono",children:s.map((r,o)=>Mt("div",{className:r.type==="removed"?"bg-accent-red-muted text-accent-red":r.type==="added"?"bg-accent-green-muted text-accent-green":"text-text-tertiary",children:[Mt("span",{className:"select-none w-6 inline-block text-center opacity-60",children:r.type==="removed"?"-":r.type==="added"?"+":" "},void 0,!1,void 0,this),r.line]},o,!0,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{ActiveViewCtx as qa,SessionContext as Va}from"#canvas/runtime";import{useContext as cs,useEffect as ds,useRef as Wa,useState as pn}from"react";var Fa=S({id:m(),type:ot(["select","radio","checkbox","text","range"]),label:m(),value:ca(),options:q(m()).optional(),required:we().optional(),note:m().optional()}).passthrough().transform((e)=>({...e,value:e.value})),Ua=S({id:m(),markdown:m(),label:m().optional(),required:we().optional()}).passthrough(),np=Xn.extend({responses:q(Dr([m(),Fa]).optional().catch(void 0)).transform((e)=>e.filter((t)=>t!==void 0)).catch([]),feedbackEntries:q(Dr([m(),Ua]).optional().catch(void 0)).transform((e)=>e.filter((t)=>t!==void 0)).optional().catch([])});var rp=S({feedback:m().nullish()}),ls=Kn([S({error:m().min(1)}),S({content:m(),language:m().nullish()})]);import{jsxDEV as je}from"react/jsx-dev-runtime";var Ga={ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",py:"python",rs:"rust",go:"go",rb:"ruby",java:"java",json:"json",yaml:"yaml",yml:"yaml",md:"markdown",css:"css",html:"html",sh:"bash",bash:"bash",toml:"toml",sql:"sql",xml:"xml",c:"c",cpp:"cpp",h:"c"};function Ka({path:e,lines:t,__content:n}){let s=cs(Va),{setActiveView:r}=cs(qa),[o,a]=pn(n??null),[l,i]=pn(()=>{let u=e.split(".").pop()||"";return Ga[u]||"text"}),[c,d]=pn(null),[f,g]=pn(!n),x=Wa(null);if(ds(()=>{if(n!==void 0)return;g(!0),d(null),fetch(`/api/file?session=${s}&path=${encodeURIComponent(e)}`).then((u)=>u.json()).then((u)=>{let h=ls.parse(u);if("error"in h)d(h.error);else{let y=h.content;if(t)y=y.split(`
62
+ `).slice(t[0]-1,t[1]).join(`
63
+ `);a(y),i(h.language||"text")}}).catch(()=>d("Failed to fetch file")).finally(()=>g(!1))},[s,e,t?.[0],t?.[1],n]),ds(()=>{let u=x.current,h=dn();if(!u||!h||!o)return;u.removeAttribute("data-highlighted"),u.className=l?`language-${l}`:"",u.textContent=o,h.highlightElement(u)},[o,l]),f)return je("div",{className:"text-text-tertiary text-body mt-3 bg-bg-code rounded-md p-4",children:["Loading ",e,"..."]},void 0,!0,void 0,this);if(c)return je("div",{className:"text-accent-red text-body mt-3 bg-accent-red-muted rounded-md p-4",children:[e,": ",c]},void 0,!0,void 0,this);return je("div",{className:"mt-3 bg-bg-code rounded-md overflow-hidden","data-md":"filepreview","data-md-path":e,...t?{"data-md-lines":`${t[0]}-${t[1]}`}:{},children:[je("div",{className:"px-4 py-2 flex items-center justify-between",children:[je("button",{className:"font-mono text-meta text-text-tertiary hover:text-text-secondary hover:underline cursor-pointer text-left",onClick:()=>r({type:"file",path:e}),title:`Open ${e}`,children:e},void 0,!1,void 0,this),t&&je("span",{className:"font-mono text-meta text-text-tertiary opacity-60",children:["L",t[0],"–",t[1]]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),je("pre",{className:"px-4 pb-3 overflow-x-auto text-code font-mono !bg-transparent",style:{background:"transparent"},children:je("code",{ref:x,className:l?`language-${l}`:"",children:o},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{SessionContext as Ya}from"#canvas/runtime";import{useContext as Ja,useState as Xa}from"react";import{jsxDEV as $t}from"react/jsx-dev-runtime";function Qa({src:e,alt:t,caption:n,width:s,height:r}){let o=Ja(Ya),[a,l]=Xa(!1),i=`/api/image?session=${encodeURIComponent(o)}&path=${encodeURIComponent(e)}`;if(a)return $t("div",{className:"mt-3 text-accent-red text-body bg-accent-red-muted rounded-md p-4",children:[e,": Failed to load image"]},void 0,!0,void 0,this);return $t("figure",{className:"mt-3 relative","data-md":"image","data-md-src":e,children:[$t("div",{"data-annotation-image":!0,className:"rounded-md overflow-hidden border border-border-subtle bg-bg-code inline-block",children:$t("img",{src:i,alt:t||e,onError:()=>l(!0),draggable:!1,className:"block max-w-full h-auto",...s?{width:s}:{},...r?{height:r}:{}},void 0,!1,void 0,this)},void 0,!1,void 0,this),n&&$t("figcaption",{className:"mt-1.5 text-meta text-text-tertiary font-body",children:n},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useMemo as Za}from"react";import{jsxDEV as us}from"react/jsx-dev-runtime";D.setOptions({gfm:!0,breaks:!1});function ei({children:e,file:t,__content:n}){let s=n??(typeof e==="string"?e:String(e??"")),r=Za(()=>{if(!s)return"";return D.parse(s,{async:!1})},[s]);if(!s)return us("div",{className:"text-text-tertiary text-tiny mt-3",children:t?`Could not load: ${t}`:"No markdown content"},void 0,!1,void 0,this);return us("div",{className:"mt-3 prose-canvas","data-md":"markdown",...t?{"data-md-file":t}:{},"data-md-source":s,dangerouslySetInnerHTML:{__html:r}},void 0,!1,void 0,this)}import{useAnnotations as ti,useCanvasFile as ni}from"#canvas/runtime";import{useCallback as _e,useEffect as tr,useRef as Pt,useState as lt}from"react";import ri from"react-dom";import{jsxDEV as N,Fragment as ms}from"react/jsx-dev-runtime";var ct=0.2,fn=0.25,hn=4;function fs({zoom:e,onZoomIn:t,onZoomOut:n,onZoomReset:s,onFullscreen:r}){return N("div",{className:"flex items-center gap-0.5 bg-bg-surface border border-border-subtle rounded-md px-1 py-0.5",style:{fontSize:"12px"},children:[N("button",{className:"flex items-center justify-center w-7 h-7 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:n,title:"Zoom out",disabled:e<=fn,children:N("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:N("line",{x1:"5",y1:"12",x2:"19",y2:"12"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),N("button",{className:"px-1.5 h-7 rounded hover:bg-bg-elevated text-text-tertiary hover:text-text-primary transition-colors tabular-nums",onClick:s,title:"Reset zoom",children:[Math.round(e*100),"%"]},void 0,!0,void 0,this),N("button",{className:"flex items-center justify-center w-7 h-7 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:t,title:"Zoom in",disabled:e>=hn,children:N("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[N("line",{x1:"12",y1:"5",x2:"12",y2:"19"},void 0,!1,void 0,this),N("line",{x1:"5",y1:"12",x2:"19",y2:"12"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this),r&&N(ms,{children:[N("div",{className:"w-px h-4 bg-border-subtle mx-0.5"},void 0,!1,void 0,this),N("button",{className:"flex items-center justify-center w-7 h-7 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:r,title:"Fullscreen",children:N("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[N("polyline",{points:"15 3 21 3 21 9"},void 0,!1,void 0,this),N("polyline",{points:"9 21 3 21 3 15"},void 0,!1,void 0,this),N("line",{x1:"21",y1:"3",x2:"14",y2:"10"},void 0,!1,void 0,this),N("line",{x1:"3",y1:"21",x2:"10",y2:"14"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)}function hs(e=1){let[t,n]=lt(e),s=_e(()=>n((a)=>Math.min(hn,+(a+ct).toFixed(2))),[]),r=_e(()=>n((a)=>Math.max(fn,+(a-ct).toFixed(2))),[]),o=_e(()=>n(1),[]);return{zoom:t,zoomIn:s,zoomOut:r,zoomReset:o,setZoom:n}}function si({svgHtml:e,source:t,onClose:n}){let s=Pt(null),{zoom:r,zoomIn:o,zoomOut:a,zoomReset:l,setZoom:i}=hs(1),[c,d]=lt({x:0,y:0}),f=Pt(null);tr(()=>{let T=(O)=>{if(O.key==="Escape")n()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[n]);let g=_e((T)=>{T.preventDefault();let O=T.deltaY>0?-ct:ct;i((M)=>Math.max(fn,Math.min(hn,+(M+O).toFixed(2))))},[i]),x=_e((T)=>{if(T.button!==0)return;f.current={startX:T.clientX,startY:T.clientY,panX:c.x,panY:c.y},T.preventDefault()},[c]),u=_e((T)=>{if(!f.current)return;d({x:f.current.panX+(T.clientX-f.current.startX),y:f.current.panY+(T.clientY-f.current.startY)})},[]),h=_e(()=>{f.current=null},[]),y=_e(()=>{l(),d({x:0,y:0})},[l]);return ri.createPortal(N("div",{style:{position:"fixed",inset:0,zIndex:9999,background:"var(--color-bg-base)",display:"flex",flexDirection:"column"},onMouseMove:u,onMouseUp:h,onMouseLeave:h,children:[N("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border-subtle",style:{flexShrink:0,background:"var(--color-bg-surface)"},children:[N("span",{className:"text-body text-text-secondary",style:{fontSize:"13px"},children:"Mermaid Diagram"},void 0,!1,void 0,this),N("div",{className:"flex items-center gap-2",children:[N(fs,{zoom:r,onZoomIn:o,onZoomOut:a,onZoomReset:y},void 0,!1,void 0,this),N("button",{className:"flex items-center justify-center w-8 h-8 rounded hover:bg-bg-elevated text-text-secondary hover:text-text-primary transition-colors",onClick:n,title:"Close (Esc)",children:N("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[N("line",{x1:"18",y1:"6",x2:"6",y2:"18"},void 0,!1,void 0,this),N("line",{x1:"6",y1:"6",x2:"18",y2:"18"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),N("div",{style:{flex:1,overflow:"hidden",cursor:f.current?"grabbing":"grab"},onWheel:g,onMouseDown:x,children:N("div",{ref:s,style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",transform:`translate(${c.x}px, ${c.y}px) scale(${r})`,transformOrigin:"center center",transition:f.current?"none":"transform 0.1s ease-out"},dangerouslySetInnerHTML:{__html:e}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),document.body)}function oi({children:e}){let t=Pt(null),[n,s]=lt(null),[r,o]=lt(!1),[a,l]=lt(""),i=typeof e==="string"?e:String(e??""),{annotations:c,addAnnotationWithId:d,activeAnnotationId:f,setActiveAnnotationId:g}=ti(),x=ni(),[u,h]=lt(null),{zoom:y,zoomIn:T,zoomOut:O,zoomReset:M,setZoom:I}=hs(1),_=Pt(c);_.current=c;let j=_e((G,J,X)=>{let K=`[Diagram ${X.toLowerCase()}] ${J}`,de=_.current.find((Le)=>Le.snippet===K);if(de)g(de.id);else h({anchorEl:G,snippet:J,prefix:X})},[g]),U=Pt(j);U.current=j,tr(()=>{let G=!1,J=async()=>{try{let K=as();if(!K){s("Mermaid library not loaded");return}let de=document.documentElement.dataset.theme==="light"?"default":"dark";K.initialize({startOnLoad:!1,theme:de});let Le=`mermaid-${Math.random().toString(36).slice(2)}`,{svg:He}=await K.render(Le,i.trim());if(!G&&t.current)t.current.innerHTML=He,l(He),ai(t.current,(re,ue,me)=>U.current(re,ue,me)),ps(t.current,_.current);s(null)}catch(K){if(!G)s(K instanceof Error&&K.message||"Invalid diagram")}};J();let X=new MutationObserver((K)=>{for(let de of K)if(de.attributeName==="data-theme")J()});return X.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]}),()=>{G=!0,X.disconnect()}},[i]),tr(()=>{if(t.current)ps(t.current,c,f)},[c,f]);let ne=_e((G)=>{if(!G.ctrlKey&&!G.metaKey)return;G.preventDefault();let J=G.deltaY>0?-ct:ct;I((X)=>Math.max(fn,Math.min(hn,+(X+J).toFixed(2))))},[I]);if(n)return N("div",{className:"bg-accent-red-muted rounded-md p-4 mt-3 text-body text-accent-red",children:["Mermaid error: ",n,N("pre",{className:"mt-2 text-tiny text-text-tertiary whitespace-pre-wrap",children:i},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let le=t.current?.closest("#plan-scroll-container");return N(ms,{children:[N("div",{className:"mt-3 mermaid-container","data-md":"mermaid","data-md-source":i.trim(),children:[N("div",{className:"flex justify-end mb-1",children:N(fs,{zoom:y,onZoomIn:T,onZoomOut:O,onZoomReset:M,onFullscreen:()=>o(!0)},void 0,!1,void 0,this)},void 0,!1,void 0,this),N("div",{style:{overflow:"auto",maxHeight:"70vh"},onWheel:ne,children:N("div",{ref:t,className:"flex justify-center",style:{transform:`scale(${y})`,transformOrigin:"top center",transition:"transform 0.1s ease-out",minHeight:y<1?void 0:void 0}},void 0,!1,void 0,this)},void 0,!1,void 0,this)]},void 0,!0,void 0,this),u&&N(Lt,{anchorEl:u.anchorEl,scrollContainer:le,snippet:u.snippet,header:N("div",{style:{fontSize:"12px",color:"var(--color-text-tertiary)",marginBottom:"8px",lineHeight:"1.4",display:"flex",alignItems:"center",gap:"6px"},children:[N("span",{style:{width:"8px",height:"8px",borderRadius:"50%",background:"var(--color-accent-amber)",flexShrink:0}},void 0,!1,void 0,this),u.snippet]},void 0,!0,void 0,this),onAdd:(G,J)=>{let X=`ann-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;d(X,`[Diagram ${u.prefix.toLowerCase()}] ${u.snippet}`,G,void 0,void 0,J,x||void 0),h(null)},onCancel:()=>h(null)},void 0,!1,void 0,this),r&&a&&N(si,{svgHtml:a,source:i,onClose:()=>o(!1)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function ai(e,t){let n=(s,r,o)=>{s.style.cursor="pointer",s.addEventListener("mouseenter",()=>{s.style.filter="brightness(1.2)"}),s.addEventListener("mouseleave",()=>{s.style.filter=""}),s.addEventListener("click",(a)=>{a.stopPropagation(),a.preventDefault(),t(s,r(),o)})};for(let s of e.querySelectorAll(".node"))n(s,()=>(s.querySelector(".nodeLabel")||s.querySelector("foreignObject span")||s.querySelector("text"))?.textContent?.trim()||"Node","Node");for(let s of e.querySelectorAll(".edgePath")){let r=s,o=r.querySelector("path");if(o){o.style.strokeWidth=Math.max(parseFloat(o.style.strokeWidth||"1"),8)+"px",o.style.strokeOpacity="0";let l=o.cloneNode(!0);l.style.strokeWidth="",l.style.strokeOpacity="",r.insertBefore(l,o)}let a=r.id||"";n(r,()=>{let l=e.querySelectorAll(".edgeLabel");for(let i of l)if(i.id&&a&&i.id.replace("label","").includes(a.replace("L-","").replace("edge",""))){let c=i.textContent?.trim();if(c)return c}return"Connection"},"Edge")}for(let s of e.querySelectorAll(".edgeLabel")){let r=s.textContent?.trim();if(!r)continue;n(s,()=>r,"Edge")}for(let s of e.querySelectorAll(".actor")){let r=s.closest("g")?.querySelector("text")||s.parentElement?.querySelector("text");if(!r)continue;let o=s.closest("g");if(!o||o.hasAttribute("data-clickable"))continue;o.setAttribute("data-clickable","true"),n(o,()=>r.textContent?.trim()||"Participant","Node")}for(let s of e.querySelectorAll(".messageText")){let r=s.textContent?.trim();if(!r)continue;n(s,()=>r,"Edge")}for(let s of e.querySelectorAll(".entityBox")){let r=s.closest("g");if(!r||r.hasAttribute("data-clickable"))continue;let o=r.querySelector(".entityLabel");if(!o)continue;r.setAttribute("data-clickable","true"),n(r,()=>o.textContent?.trim()||"Entity","Node")}for(let s of e.querySelectorAll(".relationshipLabel")){let r=s.textContent?.trim();if(!r)continue;let a=s.closest("g")||s;if(a.hasAttribute("data-clickable"))continue;a.setAttribute("data-clickable","true"),n(a,()=>r,"Edge")}for(let s of e.querySelectorAll(".classGroup")){let r=s;if(r.hasAttribute("data-clickable"))continue;let o=r.querySelector(".classTitle, .classTitleText, text");if(!o)continue;r.setAttribute("data-clickable","true"),n(r,()=>o.textContent?.trim()||"Class","Node")}for(let s of e.querySelectorAll(".statediagram-state")){let r=s;if(r.hasAttribute("data-clickable"))continue;let o=r.querySelector(".state-title, text");if(!o)continue;r.setAttribute("data-clickable","true"),n(r,()=>o.textContent?.trim()||"State","Node")}for(let s of e.querySelectorAll(".mindmap-node")){let r=s;if(r.hasAttribute("data-clickable"))continue;let o=r.querySelector(".mindmap-node-label, text");if(!o)continue;r.setAttribute("data-clickable","true"),n(r,()=>o.textContent?.trim()||"Node","Node")}}function ps(e,t,n){let s=new Map;for(let o of t){let a=o.snippet.match(/^\[Diagram (?:node|edge)\] (.+)$/)?.[1];if(a)s.set(a,o.id)}for(let o of e.querySelectorAll("[data-annotated]"))o.style.outline="",o.style.outlineOffset="",o.style.borderRadius="",o.removeAttribute("data-annotated");if(s.size===0)return;for(let o of e.querySelectorAll(".node")){let l=(o.querySelector(".nodeLabel")||o.querySelector("foreignObject span")||o.querySelector("text"))?.textContent?.trim();if(!l||!s.has(l))continue;let i=s.get(l),c=o;c.setAttribute("data-annotated",i);let d=i===n;c.style.outline=d?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",c.style.outlineOffset="2px",c.style.borderRadius="4px"}for(let o of e.querySelectorAll(".edgeLabel")){let a=o.textContent?.trim();if(!a||!s.has(a))continue;let l=s.get(a),i=o;i.setAttribute("data-annotated",l);let c=l===n;i.style.outline=c?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",i.style.outlineOffset="2px",i.style.borderRadius="4px"}for(let o of e.querySelectorAll(".actor")){let a=o.closest("g");if(!a)continue;let i=a.querySelector("text")?.textContent?.trim();if(!i||!s.has(i))continue;if(a.hasAttribute("data-annotated"))continue;let c=s.get(i);a.setAttribute("data-annotated",c);let d=c===n,f=a.querySelector("rect");if(f)f.style.outline=d?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",f.style.outlineOffset="2px",f.style.borderRadius="4px"}for(let o of e.querySelectorAll(".messageText")){let a=o.textContent?.trim();if(!a||!s.has(a))continue;let l=s.get(a),i=o;i.setAttribute("data-annotated",l);let c=l===n;i.style.outline=c?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",i.style.outlineOffset="2px",i.style.borderRadius="4px"}let r=(o,a,l)=>{for(let i of e.querySelectorAll(o)){let c=l(i);if(!c||c.hasAttribute("data-annotated"))continue;let f=c.querySelector(a)?.textContent?.trim();if(!f||!s.has(f))continue;let g=s.get(f);c.setAttribute("data-annotated",g);let x=g===n,u=c.querySelector("rect, circle, ellipse, polygon")||c;u.style.outline=x?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",u.style.outlineOffset="2px",u.style.borderRadius="4px"}};r(".entityBox",".entityLabel",(o)=>o.closest("g"));for(let o of e.querySelectorAll(".relationshipLabel")){let l=o.closest("g")||o;if(l.hasAttribute("data-annotated"))continue;let i=o.textContent?.trim();if(!i||!s.has(i))continue;let c=s.get(i);l.setAttribute("data-annotated",c);let d=c===n;l.style.outline=d?"2px solid var(--color-highlight-border)":"2px solid var(--color-highlight-annotation)",l.style.outlineOffset="2px",l.style.borderRadius="4px"}r(".classGroup",".classTitle, .classTitleText, text",(o)=>o),r(".statediagram-state",".state-title, text",(o)=>o),r(".mindmap-node",".mindmap-node-label, text",(o)=>o)}import{jsxDEV as li}from"react/jsx-dev-runtime";function ii({children:e}){return li("div",{className:"relative bg-bg-elevated rounded-lg px-5 py-4 mt-3 text-body text-text-secondary italic leading-relaxed","data-md":"note",children:Me(e)},void 0,!1,void 0,this)}import{jsxDEV as ui}from"react/jsx-dev-runtime";var ci={high:"text-accent-red bg-accent-red-muted",medium:"text-accent-amber bg-accent-amber-muted",low:"text-text-tertiary bg-border-subtle"};function di({level:e}){return ui("span",{className:`inline text-tiny font-medium font-body ml-2 px-1.5 py-0.5 rounded ${ci[e]}`,"data-md":"priority","data-md-level":e,children:e},void 0,!1,void 0,this)}import{useState as pi}from"react";import{jsxDEV as Ye}from"react/jsx-dev-runtime";function fi({title:e,children:t}){let[n,s]=pi(!1);return Ye("div",{className:"relative mb-8 p-4 group/section","data-md":"section","data-md-title":e,children:[Ye("div",{className:"relative mb-2",children:[Ye("button",{onClick:()=>s(!n),className:`absolute -left-8 top-1/2 -translate-y-1/2 text-text-tertiary opacity-0 group-hover/section:opacity-50 hover:!opacity-100 transition-all duration-150 p-0.5 ${n?"-rotate-90":""}`,children:Ye("svg",{width:"14",height:"14",viewBox:"0 0 12 12",fill:"none",children:Ye("path",{d:"M3 4.5L6 7.5L9 4.5",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},void 0,!1,void 0,this)},void 0,!1,void 0,this)},void 0,!1,void 0,this),Ye("h2",{className:"font-heading text-section text-text-primary",style:{fontWeight:400},children:e},void 0,!1,void 0,this)]},void 0,!0,void 0,this),Ye("div",{className:n?"mt-6 hidden":"mt-6",children:Me(t)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{jsxDEV as De}from"react/jsx-dev-runtime";function hi({headers:e,rows:t}){return De("div",{className:"overflow-x-auto mt-3","data-md":"table",children:De("table",{className:"w-full text-body",children:[De("thead",{children:De("tr",{className:"border-b border-border-subtle",children:e.map((n,s)=>De("th",{className:"text-left px-4 py-2.5 text-meta font-medium uppercase tracking-wider text-text-tertiary font-body",children:n},s,!1,void 0,this))},void 0,!1,void 0,this)},void 0,!1,void 0,this),De("tbody",{children:t.map((n,s)=>De("tr",{className:`relative border-b border-border-subtle last:border-b-0 transition-colors hover:bg-bg-surface/50 ${s%2===1?"bg-bg-surface/30":""}`,children:n.map((r,o)=>De("td",{className:"px-4 py-2.5 text-text-secondary font-body",children:r},o,!1,void 0,this))},s,!1,void 0,this))},void 0,!1,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}import{jsxDEV as Se}from"react/jsx-dev-runtime";var mi={todo:"bg-border-hover",done:"bg-accent-green",blocked:"bg-accent-red","in-progress":"bg-accent-blue"},gi={todo:"Todo",done:"Done",blocked:"Blocked","in-progress":"In progress"},xi={info:"bg-accent-blue-muted text-accent-blue",success:"bg-accent-green-muted text-accent-green",warning:"bg-accent-amber-muted text-accent-amber",danger:"bg-accent-red-muted text-accent-red",neutral:"bg-border-subtle text-text-tertiary"};function gs({id:e,label:t,status:n,badge:s,badgeVariant:r="neutral",children:o}){return Se("div",{className:"group/task relative -mx-4 px-4 py-3 rounded-md transition-colors duration-150 hover:bg-bg-input","data-task-id":e,"data-md":"item","data-md-label":t,...n?{"data-md-status":n}:{},...s?{"data-md-badge":s}:{},children:Se("div",{className:"flex items-start gap-3",children:[n&&Se("span",{className:`w-2 h-2 rounded-full mt-[7px] flex-shrink-0 ${mi[n]}`},void 0,!1,void 0,this),Se("div",{className:"flex-1 min-w-0",children:[Se("div",{className:"flex items-baseline gap-2",children:[Se("span",{className:"font-body text-task-label font-semibold text-text-primary",children:t},void 0,!1,void 0,this),n&&Se("span",{className:"font-body text-tiny uppercase tracking-wider text-text-tertiary opacity-0 group-hover/task:opacity-100 transition-opacity duration-150",children:gi[n]},void 0,!1,void 0,this),s&&Se("span",{className:`font-body text-tiny font-medium px-1.5 py-px rounded-full ${xi[r]}`,children:s},void 0,!1,void 0,this)]},void 0,!0,void 0,this),o&&Se("div",{className:"text-body text-text-secondary mt-1 leading-relaxed",children:Me(o)},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this)},void 0,!1,void 0,this)}function yi(e){return Se(gs,{...e},void 0,!1,void 0,this)}import{useAnnotations as xs,useResponseRegistration as ys}from"#canvas/runtime";import{useRef as bi,useState as bs}from"react";import{jsxDEV as F}from"react/jsx-dev-runtime";function vi({id:e,label:t,placeholder:n,multiline:s,required:r}){let{responses:o,setResponse:a}=xs();ys(e);let l=o.get(e),i=l?.value??"",c=l?.note||"",[d,f]=bs(!1),g=bi(null);if(!o.has(e))a(e,{id:e,type:"text",label:t,value:"",required:r});let x=(y)=>{a(e,{...l,value:y})},u=(y)=>Ne(y,s?60:32),h=l?.required&&!i.trim();return F("div",{"data-md":"userinput","data-md-label":t,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[F("div",{className:"flex items-baseline gap-2 mb-2",children:[F("span",{className:"text-[13px] font-body font-medium text-text-primary",children:t},void 0,!1,void 0,this),r&&F("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F("textarea",{ref:g,value:i,onChange:(y)=>{x(y.currentTarget.value),u(y.currentTarget)},placeholder:n||"Type your response...",rows:s?3:1,className:"w-full bg-bg-input text-[13px] font-body text-text-primary rounded-lg px-3 py-2 resize-none focus:outline-none border border-border-subtle focus:border-border-hover placeholder:text-text-tertiary transition-colors",onInput:(y)=>u(y.currentTarget),onFocus:(y)=>u(y.currentTarget)},void 0,!1,void 0,this),F(it,{show:d,note:c,onToggle:()=>f(!d),onChange:(y)=>a(e,{...l,note:y})},void 0,!1,void 0,this),h&&F("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"This field is required."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}function ki({id:e,label:t,min:n=1,max:s=10,step:r=1,required:o,minLabel:a,maxLabel:l}){let{responses:i,setResponse:c}=xs();ys(e);let d=i.get(e),f=d?.value,g=d?.note||"",[x,u]=bs(!1);if(!i.has(e))c(e,{id:e,type:"range",label:t,value:null,required:o});let h=(j)=>{c(e,{...d,value:j})},y=f!==null&&f!==void 0,T=y?f:Math.round((n+s)/2),O=(T-n)/(s-n)*100,M=Math.round((s-n)/r),I=M<=20,_=d?.required&&!y;return F("div",{"data-md":"rangeinput","data-md-label":t,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[F("div",{className:"flex items-baseline justify-between mb-1",children:[F("div",{className:"flex items-baseline gap-2",children:[F("span",{className:"text-[13px] font-body font-medium text-text-primary",children:t},void 0,!1,void 0,this),o&&F("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F("span",{className:"flex items-center gap-1.5",children:[F("span",{className:`text-[13px] font-mono ${y?"text-accent-amber":"text-text-disabled"}`,children:y?f:"—"},void 0,!1,void 0,this),y&&F("button",{onClick:()=>c(e,{...d,value:null}),className:"text-text-disabled hover:text-text-tertiary transition-colors text-[10px] leading-none",title:"Clear",children:"✕"},void 0,!1,void 0,this)]},void 0,!0,void 0,this)]},void 0,!0,void 0,this),F("div",{className:"relative h-6 flex items-center",children:[F("div",{className:"absolute left-0 right-0 h-1.5 rounded-full bg-border-medium",children:y&&F("div",{className:"h-full rounded-full bg-accent-amber transition-all duration-150",style:{width:`${O}%`}},void 0,!1,void 0,this)},void 0,!1,void 0,this),I&&Array.from({length:M+1},(j,U)=>{let ne=n+U*r,le=(ne-n)/(s-n)*100,G=y&&ne<=f;return F("div",{className:`absolute rounded-full pointer-events-none transition-all duration-150 ${y&&ne===f?"w-2.5 h-2.5 bg-accent-amber":G?"w-1.5 h-1.5 bg-accent-amber":"w-1.5 h-1.5 bg-border-hover"}`,style:{left:`${le}%`,transform:"translate(-50%, -50%)",top:"50%"}},U,!1,void 0,this)}),y?F("div",{className:"absolute h-5 w-5 rounded-full bg-accent-amber shadow-md pointer-events-none transition-all duration-150",style:{left:`calc(${O}% - 10px)`,borderWidth:"2px",borderStyle:"solid",borderColor:"var(--color-bg-base)"}},void 0,!1,void 0,this):F("div",{className:"absolute h-4 w-4 rounded-full bg-border-hover pointer-events-none opacity-50",style:{left:"calc(50% - 8px)",borderWidth:"2px",borderStyle:"solid",borderColor:"var(--color-bg-base)"}},void 0,!1,void 0,this),F("input",{type:"range",min:n,max:s,step:r,value:T,onChange:(j)=>h(Number(j.currentTarget.value)),className:"absolute inset-0 w-full opacity-0 cursor-pointer"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),I&&M<=10?F("div",{className:"flex justify-between -mt-0.5 px-0",children:Array.from({length:M+1},(j,U)=>{let ne=n+U*r;return F("span",{className:`text-[10px] font-mono transition-colors ${y&&ne===f?"text-accent-amber font-medium":"text-text-disabled"}`,style:{minWidth:"1ch",textAlign:"center"},children:ne},U,!1,void 0,this)})},void 0,!1,void 0,this):F("div",{className:"flex justify-between -mt-0.5",children:[F("span",{className:"text-[11px] text-text-tertiary font-body",children:a||n},void 0,!1,void 0,this),F("span",{className:"text-[11px] text-text-tertiary font-body",children:l||s},void 0,!1,void 0,this)]},void 0,!0,void 0,this),F(it,{show:x,note:g,onToggle:()=>u(!x),onChange:(j)=>c(e,{...d,note:j})},void 0,!1,void 0,this),_&&F("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"Please select a value."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}var nr=26214400,vs=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/,rr=S({id:m(),name:m(),path:m(),size:Q().int()});var ks=S({shareId:m(),url:m(),revision:Q(),createdAt:m(),ownerToken:m().optional(),expiresAt:m().optional(),lastFeedbackAt:m().optional(),encryptionKey:m().optional()}),wi=S({revision:Q(),label:m().optional(),canvasFiles:q(S({filename:m(),diffStats:S({added:Q(),removed:Q()}).optional()})),createdAt:m(),hasFeedback:we(),feedbackConsumed:we(),response:m().optional()}).passthrough(),_i=S({encryption:S({alg:st("AES-GCM"),v:st(1)}).optional(),origin:S({sessionId:m().optional(),label:m().optional(),revision:Q().optional(),createdAt:m().optional()}).optional(),currentRevision:Q().optional(),revisions:q(wi).optional(),canvasFiles:q(m()).optional(),projectRoot:m().optional(),shares:q(ks).optional(),shareEnabled:we().optional()}).passthrough(),yf=S({entries:q(S({name:m(),type:ot(["file","dir"])}))}),Si=S({id:m(),shareId:m(),revision:Q(),submittedAt:m(),author:Yn,annotations:q(Jn.omit({source:!0,author:!0})),generalNote:m().optional()}),bf=S({entries:q(Si)}),vf=Kn([S({ok:st(!0),share:ks}),S({ok:st(!1).optional(),error:m().optional()})]),kf=Kn([S({ok:st(!0)}),S({ok:st(!1).optional(),error:m().optional()})]);async function ws(e){let t=Ti(e);return crypto.subtle.importKey("raw",t,{name:"AES-GCM",length:256},!1,["encrypt","decrypt"])}async function _s(e,t){let n=Ss(t);if(n.byteLength<28)throw Error("Ciphertext too short");let s=n.subarray(0,12),r=n.subarray(12),o=await crypto.subtle.decrypt({name:"AES-GCM",iv:s},e,r);return new TextDecoder().decode(o)}function Ss(e){let t=atob(e),n=new Uint8Array(t.length);for(let s=0;s<t.length;s++)n[s]=t.charCodeAt(s);return n}function Ti(e){let t=e.replace(/-/g,"+").replace(/_/g,"/")+"===".slice((e.length+3)%4);return Ss(t)}function Ai(e){let t;try{t=new URL(e)}catch{return!1}if(t.protocol!=="http:"&&t.protocol!=="https:")return!1;return t.hostname==="localhost"||t.hostname==="127.0.0.1"||t.hostname==="[::1]"||t.hostname.endsWith(".localhost")}var ze=m().max(500),Ri=4000,Ei=1000,Ci=1000,Ni=S({label:ze,file:m().max(Ei),line:Q().int().positive(),column:Q().int().nonnegative()}),As=S({url:m().min(1).max(2000),selector:m().max(2000),role:ze.optional(),name:ze.optional(),text:ze.optional(),components:q(m().max(200)).max(20).optional(),sources:q(Ni).max(10).optional(),context:ze.optional(),browser:S({name:ze,viewport:S({width:Q().int().nonnegative(),height:Q().int().nonnegative(),scale:Q().positive()}),colorScheme:ot(["light","dark"])}).optional(),style:m().max(Ci).optional(),html:m().max(Ri).optional(),quote:S({exact:m().min(1).max(2000),before:ze,after:ze}).optional()}),Ii=ot(["user","agent"]),sr=S({id:m(),author:Ii,body:m().min(1).max(20000),createdAt:m()}),or=ot(["open","queued","working","resolved"]),Li=S({id:m(),anchor:As,state:or,comments:q(sr).min(1),screenshot:m().optional(),createdAt:m(),updatedAt:m()}),Tf=S({threads:q(Li)}),ar=m().trim().min(1).max(20000),Ts="data:image/png;base64,",Mi=m().startsWith(Ts).max(8000000).transform((e)=>Uint8Array.from(atob(e.slice(Ts.length)),(t)=>t.charCodeAt(0))),Af=S({anchor:As,body:ar,send:we(),screenshot:Mi.optional()}),Rf=S({body:ar,send:we()}),Ef=S({body:ar,resolve:we()}),Rs=m().url().refine((e)=>Ai(e),"must be an http(s) URL on localhost"),Cf=S({target:Rs}),Nf=S({target:Rs,port:Q().int().min(1).max(65535)});var Ot=S({id:m(),state:or,revision:Q().int(),snippet:m(),canvasFile:m().optional(),filePath:m().optional(),comments:q(sr),createdAt:m(),updatedAt:m()}),Bf=S({threads:q(Ot)}),Es=m().trim().min(1).max(20000),Ff=S({body:Es,resolve:we()}),Uf=S({body:Es}),qf=S({resolved:we()});var $i=S({threads:q(Ot)}),Pi=S({thread:Ot});async function Cs(e){let t=await e.json().catch(()=>null),n=S({error:m()}).safeParse(t);return Error(n.success?n.data.error:`Thread request failed with status ${e.status}`)}function Oi(e,t){let n=new Map(t.map((o)=>[o.id,o])),s=e.map((o)=>{let a=n.get(o.id);return a!==void 0&&a.updatedAt>=o.updatedAt?a:o}),r=new Set(e.map((o)=>o.id));return[...s,...t.filter((o)=>!r.has(o.id))]}function Ns(e){let t=[],n=new Set,s=`/api/session/${encodeURIComponent(e)}/threads`,r=(a)=>{t=Oi(t,a);for(let l of n)l()},o=async(a,l)=>{let i=await fetch(`${s}/${a}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(l)});if(!i.ok)throw await Cs(i);r([Pi.parse(await i.json()).thread])};return{subscribe(a){return n.add(a),()=>n.delete(a)},current:()=>t,async load(){let a=await fetch(s,{cache:"no-store"});if(!a.ok)throw await Cs(a);r($i.parse(await a.json()).threads)},receive(a){let l=q(Ot).safeParse(a);if(l.success)r(l.data)},reply:(a,l)=>o(`${encodeURIComponent(a)}/comments`,{body:l}),setResolved:(a,l)=>o(`${encodeURIComponent(a)}/resolved`,{resolved:l})}}function ji(){if(typeof window>"u")return null;let e=window.location.hash.replace(/^#/,"");if(!e)return null;for(let t of e.split("&")){let[n,s]=t.split("=");if(n==="k"&&s)return decodeURIComponent(s)}return null}function Di(){if(typeof window<"u"&&window.__CANVAS_SHARE__?.shareId){let t=ji();return{isShared:!0,shareId:window.__CANVAS_SHARE__.shareId,encryptionKey:t?ws(t):null}}return{isShared:!1,sessionId:typeof window<"u"?window.location.pathname.replace("/s/",""):""}}var B=Di();function zi(){return B.isShared&&B.encryptionKey!==null}function Hi(){return B.isShared?B.shareId:B.sessionId}function Bi(e,t){let n=e.replace(/\.jsx$/,".js");if(B.isShared)return`/s/${B.shareId}/canvas/${encodeURIComponent(n)}`;let s=t?`?rev=${t}&t=${Date.now()}`:`?t=${Date.now()}`;return`/api/session/${B.sessionId}/canvas/${encodeURIComponent(n)}${s}`}function Fi(){if(B.isShared)return`/s/${B.shareId}/upload`;return`/api/session/${B.sessionId}/upload`}function ir(e,t){if(B.isShared)throw Error("Secret inputs are available only on the local canvas daemon");return`/api/session/${encodeURIComponent(B.sessionId)}/secrets/${encodeURIComponent(e)}/${t}`}async function dt(e){let t=await e.json().catch(()=>null);if(typeof t==="object"&&t!==null&&"error"in t&&typeof t.error==="string")return Error(t.error);return Error(`Request failed with status ${e.status}`)}function lr(e,t){if(B.isShared)throw Error("File drops are available only on the local canvas daemon");let n=`/api/session/${encodeURIComponent(B.sessionId)}/assets/${encodeURIComponent(e)}`;return t===void 0?n:`${n}/${encodeURIComponent(t)}`}async function Is(e){let t=await fetch(lr(e),{cache:"no-store"});if(!t.ok)throw await dt(t);return S({files:q(rr)}).parse(await t.json()).files}async function Ls(e,t){let n=new FormData;n.append("file",t);let s=await fetch(lr(e),{method:"POST",body:n});if(!s.ok)throw await dt(s);return S({file:rr}).parse(await s.json()).file}async function Ms(e,t){let n=await fetch(lr(e,t),{method:"DELETE"});if(!n.ok)throw await dt(n)}async function $s(e){let t=await fetch(ir(e,"status"),{cache:"no-store"});if(!t.ok)throw await dt(t);let n=await t.json();return typeof n==="object"&&n!==null&&"ready"in n&&n.ready===!0}async function Ps(e,t){let n=await fetch(ir(e,"value"),{method:"POST",headers:{"Content-Type":"application/json"},cache:"no-store",body:JSON.stringify({value:t})});if(!n.ok)throw await dt(n)}async function Os(e){let t=await fetch(ir(e,"value"),{method:"DELETE",cache:"no-store"});if(!t.ok)throw await dt(t)}var Ui=async(e,t)=>{let n=Bi(e,t);if(!zi())return import(n);let s=await fetch(n);if(!s.ok)throw Error(`canvas ${s.status}`);let r=await s.text(),o=await B.encryptionKey,a=await _s(o,r),l=new Blob([a],{type:"application/javascript"}),i=URL.createObjectURL(l);try{return await import(i)}finally{setTimeout(()=>URL.revokeObjectURL(i),0)}};var qi=!B.isShared,nh=!B.isShared,Vi=B.isShared?null:Ns(B.sessionId),rh={get sessionId(){return Hi()},isShared:B.isShared,fsAvailable:qi,uploadUrl:Fi,loadCanvasModule:Ui,threads:Vi};import{jsxDEV as cr}from"react/jsx-dev-runtime";function Wi({path:e,label:t}){let n=e.split("/").pop()||"download";if(B.isShared)return cr("p",{className:"text-[13px] font-body text-text-tertiary my-2",children:[t||n," (download available only on the canvas author's machine)"]},void 0,!0,void 0,this);let s=`/api/download?session=${encodeURIComponent(B.sessionId)}&path=${encodeURIComponent(e)}`;return cr("a",{href:s,download:n,className:"inline-flex items-center gap-2 my-2 px-3 py-1.5 rounded-lg border border-border-subtle bg-bg-input text-[13px] font-body text-text-primary hover:border-border-hover",children:[cr("span",{"aria-hidden":"true",children:"↓"},void 0,!1,void 0,this),t||n]},void 0,!0,void 0,this)}import{useFeedback as Gi}from"#canvas/runtime";import{useEffect as Ki,useState as mn}from"react";import{jsxDEV as ae}from"react/jsx-dev-runtime";function dr(e){if(e<1024)return`${e} B`;if(e<1048576)return`${(e/1024).toFixed(1)} KB`;return`${(e/1024/1024).toFixed(1)} MB`}function Yi({id:e,label:t,accept:n,maxBytes:s,required:r}){let[o,a]=mn([]),[l,i]=mn(!B.isShared),[c,d]=mn(null),[f,g]=mn(!1),x=vs.test(e),u=!B.isShared,h=r===!0&&u&&x,y=Math.min(s??nr,nr);Ki(()=>{if(!u||!x){i(!1);return}let _=!0;return Is(e).then((j)=>{if(_)a(j)}).catch((j)=>{if(_)d(j instanceof Error?j.message:"Could not read the files")}).finally(()=>{if(_)i(!1)}),()=>{_=!1}},[e,u,x]);let T=o.length===0?"":`**${t}**
64
+ ${o.map((_)=>`- \`${_.path}\` (${_.name}, ${dr(_.size)})`).join(`
65
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};
66
+ `;Gi(`files:${e}`,T,{label:t,required:h});let O=async(_)=>{if(_.length===0)return;if(l){d("Wait until the current upload finishes");return}let j=_.filter((U)=>U.size>y);if(j.length>0){d(`${j.map((U)=>U.name).join(", ")}: larger than ${dr(y)}`);return}i(!0),d(null);try{for(let U of _){let ne=await Ls(e,U);a((le)=>[...le,ne])}}catch(U){d(U instanceof Error?U.message:"Could not upload the file")}finally{i(!1)}},M=async(_)=>{i(!0),d(null);try{await Ms(e,_.id),a((j)=>j.filter((U)=>U.id!==_.id))}catch(j){d(j instanceof Error?j.message:"Could not remove the file")}finally{i(!1)}},I=`file-drop-${e}`;return ae("div",{"data-md":"filedrop","data-md-label":t,className:"-mx-4 px-4 py-3 my-1 rounded-lg",children:[ae("div",{className:"flex items-baseline gap-2 mb-2",children:[ae("label",{htmlFor:I,className:"text-[13px] font-body font-medium text-text-primary",children:t},void 0,!1,void 0,this),h&&ae("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),!x&&ae("p",{className:"text-[12px] text-accent-red font-body",children:"Invalid field ID."},void 0,!1,void 0,this),!u&&ae("p",{className:"text-[12px] text-text-tertiary font-body",children:"Files can be added only on the canvas author's machine."},void 0,!1,void 0,this),u&&x&&ae("div",{onDragOver:(_)=>{_.preventDefault(),g(!0)},onDragLeave:(_)=>{if(_.relatedTarget instanceof Node&&_.currentTarget.contains(_.relatedTarget))return;g(!1)},onDrop:(_)=>{_.preventDefault(),g(!1),O([..._.dataTransfer?.files??[]])},className:`rounded-lg border border-dashed px-3 py-4 text-center text-[13px] font-body ${f?"border-accent-blue bg-accent-blue-muted":"border-border-medium bg-bg-input"}`,children:[ae("span",{className:"text-text-secondary",children:"Drop files here or"},void 0,!1,void 0,this)," ",ae("input",{id:I,type:"file",multiple:!0,accept:n,disabled:l,onChange:(_)=>{let j=[..._.currentTarget.files??[]];_.currentTarget.value="",O(j)},className:"text-[12px] text-text-secondary"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),o.length>0&&ae("ul",{className:"mt-2 space-y-1",children:o.map((_)=>ae("li",{className:"flex items-center justify-between gap-2 text-[13px] font-body text-text-primary",children:[ae("span",{className:"truncate",title:_.path,children:[_.name," · ",dr(_.size)]},void 0,!0,void 0,this),ae("button",{type:"button",disabled:l,onClick:()=>void M(_),className:"text-[12px] text-text-tertiary hover:text-text-secondary",children:"Remove"},void 0,!1,void 0,this)]},_.id,!0,void 0,this))},void 0,!1,void 0,this),c&&ae("p",{role:"alert",className:"text-[12px] text-accent-red font-body mt-1",children:c},void 0,!1,void 0,this),h&&o.length===0&&ae("p",{className:"text-[11px] text-accent-red font-body mt-1",children:"This field is required."},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}import{useFeedback as Ji}from"#canvas/runtime";import{useEffect as Xi,useState as gn}from"react";import{jsxDEV as ie}from"react/jsx-dev-runtime";var Qi=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/,Zi=/^[A-Za-z_][A-Za-z0-9_]*$/;function el({id:e,label:t,env:n,placeholder:s,required:r}){let[o,a]=gn(""),[l,i]=gn(!1),[c,d]=gn(!B.isShared),[f,g]=gn(null),x=Qi.test(e),u=Zi.test(n),h=!B.isShared;Xi(()=>{if(!h||!x){d(!1);return}let I=!0;return $s(e).then((_)=>{if(I)i(_)}).catch((_)=>{if(I)g(_ instanceof Error?_.message:"Could not read secret status")}).finally(()=>{if(I)d(!1)}),()=>{I=!1}},[e,h,x]);let y=l?`**${t}**
67
+ Secret is ready. Field: \`${e}\`. Environment variable: \`${n}\`.
68
+ `:"";Ji(`secret:${e}`,y,{label:t,required:r&&h});let T=async()=>{if(!o||!x||!u)return;d(!0),g(null);try{await Ps(e,o),a(""),i(!0)}catch(I){g(I instanceof Error?I.message:"Could not store secret")}finally{d(!1)}},O=async()=>{d(!0),g(null);try{await Os(e),i(!1)}catch(I){g(I instanceof Error?I.message:"Could not clear secret")}finally{d(!1)}};if(!h)return ie("div",{"data-md":"secretinput","data-md-label":t,className:"-mx-4 px-4 py-3 my-1 rounded-lg bg-accent-amber-muted",children:[ie("div",{className:"text-[13px] font-body font-medium text-text-primary",children:t},void 0,!1,void 0,this),ie("p",{className:"text-[12px] font-body text-text-secondary mt-1",children:"Secret input is unavailable in shared canvases. Open this runbook on the author's local canvas daemon."},void 0,!1,void 0,this)]},void 0,!0,void 0,this);let M=!x?"Secret field IDs may contain letters, numbers, dots, underscores, and hyphens.":!u?"Environment variable names must use letters, numbers, and underscores and may not start with a number.":null;return ie("div",{"data-md":"secretinput","data-md-label":t,className:"-mx-4 px-4 py-3 my-1 rounded-lg transition-colors duration-150 hover:bg-bg-input",children:[ie("div",{className:"flex items-baseline justify-between gap-3 mb-2",children:[ie("div",{className:"flex items-baseline gap-2",children:[ie("span",{className:"text-[13px] font-body font-medium text-text-primary",children:t},void 0,!1,void 0,this),r&&ie("span",{className:"text-[10px] text-accent-red font-body",children:"*"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ie("span",{className:`text-[11px] font-body ${l?"text-accent-green":"text-text-tertiary"}`,children:c?"Working…":l?"Ready in memory":"Not stored"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ie("div",{className:"flex gap-2",children:[ie("input",{type:"password",value:o,onChange:(I)=>a(I.target.value),onKeyDown:(I)=>{if(I.key==="Enter")I.preventDefault(),T()},placeholder:s||"Paste secret value",autoComplete:"off",spellCheck:!1,disabled:c||!!M,className:"min-w-0 flex-1 bg-bg-input text-[13px] font-mono text-text-primary rounded-lg px-3 py-2 focus:outline-none border border-border-subtle focus:border-border-hover placeholder:text-text-tertiary disabled:opacity-50 transition-colors"},void 0,!1,void 0,this),ie("button",{type:"button",onClick:()=>void T(),disabled:c||!o||!!M,className:"px-3 py-2 rounded-lg bg-btn-primary text-btn-primary-text text-[12px] font-body font-medium disabled:opacity-40 disabled:cursor-default",children:l?"Replace":"Store"},void 0,!1,void 0,this),l&&ie("button",{type:"button",onClick:()=>void O(),disabled:c,className:"px-3 py-2 rounded-lg border border-border-subtle text-text-secondary text-[12px] font-body font-medium hover:border-border-hover disabled:opacity-40",children:"Clear"},void 0,!1,void 0,this)]},void 0,!0,void 0,this),ie("p",{className:"text-[11px] font-body text-text-tertiary mt-1.5",children:["Stored only in daemon memory. The agent receives field ",e," for ",n,", not the value."]},void 0,!0,void 0,this),(M||f)&&ie("p",{className:"text-[11px] text-accent-red font-body mt-1",children:M||f},void 0,!1,void 0,this)]},void 0,!0,void 0,this)}export{Io as Callout,Lo as Checklist,Pa as Choice,za as CodeBlock,Ba as Diff,Wi as Download,Yi as FileDrop,Ka as FilePreview,Qa as ImageView,gs as Item,ei as Markdown,oi as Mermaid,Oa as MultiChoice,ii as Note,di as Priority,ki as RangeInput,el as SecretInput,fi as Section,hi as Table,yi as Task,vi as UserInput,Xp as useFeedback};